Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stake and unstake commands to Shardeum CLI #1

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

chrypnotoad
Copy link
Contributor

@chrypnotoad chrypnotoad commented Nov 23, 2024

Add shm:stake and shm:unstake commands to the Shardeum CLI.

  • shm:stake command

    • Takes amount of SHM and node's public key as inputs.
    • Sends internal transaction to contract address 0x0000000000000000000000000000000000010000 with internalTXType: 6.
    • Sends tokens with the transaction (value = stake amount).
    • Uses gasLimit of 30000000.
    • Encodes transaction data as hex-encoded JSON string.
  • shm:unstake command

    • Takes node's public key as input.
    • Optional force flag for forced unstaking.
    • Sends internal transaction to contract address 0x0000000000000000000000000000000000010000 with internalTXType: 7.
    • No value sent with the transaction.
    • Uses gasLimit of 30000000.
    • Encodes transaction data as hex-encoded JSON string.
  • README.md

    • Adds usage examples for shm:stake and shm:unstake commands.

For more details, open the Copilot Workspace session.

Add `shm:stake` and `shm:unstake` commands to the Shardeum CLI.

* **`shm:stake` command**
  - Takes amount of SHM and node's public key as inputs.
  - Sends internal transaction to contract address `0x0000000000000000000000000000000000010000` with `internalTXType: 6`.
  - Sends tokens with the transaction (value = stake amount).
  - Uses gasLimit of 30000000.
  - Encodes transaction data as hex-encoded JSON string.

* **`shm:unstake` command**
  - Takes node's public key as input.
  - Optional force flag for forced unstaking.
  - Sends internal transaction to contract address `0x0000000000000000000000000000000000010000` with `internalTXType: 7`.
  - No value sent with the transaction.
  - Uses gasLimit of 30000000.
  - Encodes transaction data as hex-encoded JSON string.

* **README.md**
  - Adds usage examples for `shm:stake` and `shm:unstake` commands.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/shardeum/shardeum-cli?shareId=XXXX-XXXX-XXXX-XXXX).
@chrypnotoad chrypnotoad force-pushed the chrypnotoad/add-stake-unstake branch from fbc0ec2 to e4e8840 Compare November 25, 2024 20:30
@chrypnotoad
Copy link
Contributor Author

Note: this was rebased onto #PR 2 that should be merged first

@chrischabot
Copy link
Contributor

@chrypnotoad there's some TS errors in the transaction type, could you resolve those please:

Error: src/index.ts(689,55): error TS2345: Argument of type '{ to: string; value: bigint; data: string; gasLimit: number; }' is not assignable to parameter of type 'SendTransactionParameters<undefined, { address: `0x${string}`; nonceManager?: NonceManager | undefined; sign: (parameters: { hash: `0x${string}`; }) => Promise<`0x${string}`>; experimental_signAuthorization: (parameters: Authorization) => Promise<...>; ... 5 more ...; type: "local"; }, undefined, SendTransactionRequ...'.
  Type '{ to: string; value: bigint; data: string; gasLimit: number; }' is not assignable to type 'Omit<{ data?: `0x${string}` | undefined; from?: `0x${string}` | undefined; gas?: bigint | undefined; nonce?: number | undefined; to?: `0x${string}` | null | undefined; type?: "eip7702" | undefined; ... 10 more ...; sidecars?: undefined; }, "from"> & { ...; } & { ...; } & { ...; }'.
    Type '{ to: string; value: bigint; data: string; gasLimit: number; }' is not assignable to type 'Omit<{ data?: `0x${string}` | undefined; from?: `0x${string}` | undefined; gas?: bigint | undefined; nonce?: number | undefined; to?: `0x${string}` | null | undefined; type?: "eip7702" | undefined; value?: bigint | undefined; ... [9](https://github.com/shardeum/shardeum-cli/actions/runs/12018295849/job/33502472368?pr=1#step:5:10) more ...; sidecars?: undefined; }, "from">'.
      Types of property 'to' are incompatible.
        Type 'string' is not assignable to type '`0x${string}`'.
Error: src/index.ts(730,24): error TS2737: BigInt literals are not available when targeting lower than ES2020.
Error: src/index.ts(735,55): error TS2345: Argument of type '{ to: string; value: bigint; data: string; gasLimit: number; }' is not assignable to parameter of type 'SendTransactionParameters<undefined, { address: `0x${string}`; nonceManager?: NonceManager | undefined; sign: (parameters: { hash: `0x${string}`; }) => Promise<`0x${string}`>; experimental_signAuthorization: (parameters: Authorization) => Promise<...>; ... 5 more ...; type: "local"; }, undefined, SendTransactionRequ...'.
  Type '{ to: string; value: bigint; data: string; gasLimit: number; }' is not assignable to type 'Omit<{ data?: `0x${string}` | undefined; from?: `0x${string}` | undefined; gas?: bigint | undefined; nonce?: number | undefined; to?: `0x${string}` | null | undefined; type?: "eip7702" | undefined; ... [10](https://github.com/shardeum/shardeum-cli/actions/runs/12018295849/job/33502472368?pr=1#step:5:11) more ...; sidecars?: undefined; }, "from"> & { ...; } & { ...; } & { ...; }'.
    Type '{ to: string; value: bigint; data: string; gasLimit: number; }' is not assignable to type 'Omit<{ data?: `0x${string}` | undefined; from?: `0x${string}` | undefined; gas?: bigint | undefined; nonce?: number | undefined; to?: `0x${string}` | null | undefined; type?: "eip7702" | undefined; value?: bigint | undefined; ... 9 more ...; sidecars?: undefined; }, "from">'.
      Types of property 'to' are incompatible.
        Type 'string' is not assignable to type '`0x${string}`'.
Error: Process completed with exit code 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants