genlayer 0.40.0-clarke.1 → 0.40.0-clarke.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/.github/workflows/e2e-wallet.yml +63 -0
  2. package/CHANGELOG.md +23 -0
  3. package/CLAUDE.md +3 -1
  4. package/README.md +104 -2
  5. package/dist/index.js +4449 -643
  6. package/docs/api-references/_meta.json +3 -1
  7. package/docs/api-references/accounts/account/show.mdx +1 -0
  8. package/docs/api-references/balances.mdx +19 -0
  9. package/docs/api-references/contracts/deploy.mdx +1 -0
  10. package/docs/api-references/contracts/write.mdx +1 -0
  11. package/docs/api-references/finalize-batch.mdx +1 -0
  12. package/docs/api-references/finalize.mdx +1 -0
  13. package/docs/api-references/index.mdx +3 -1
  14. package/docs/api-references/staking/staking/delegator-claim.mdx +1 -0
  15. package/docs/api-references/staking/staking/delegator-exit.mdx +1 -0
  16. package/docs/api-references/staking/staking/delegator-join.mdx +1 -0
  17. package/docs/api-references/staking/staking/prime-all.mdx +1 -0
  18. package/docs/api-references/staking/staking/set-identity.mdx +1 -0
  19. package/docs/api-references/staking/staking/set-operator.mdx +1 -0
  20. package/docs/api-references/staking/staking/validator-claim.mdx +1 -0
  21. package/docs/api-references/staking/staking/validator-deposit.mdx +1 -0
  22. package/docs/api-references/staking/staking/validator-exit.mdx +1 -0
  23. package/docs/api-references/staking/staking/validator-join.mdx +1 -0
  24. package/docs/api-references/staking/staking/validator-prime.mdx +1 -0
  25. package/docs/api-references/staking/staking/wizard.mdx +4 -1
  26. package/docs/api-references/staking/staking.mdx +1 -1
  27. package/docs/api-references/transactions/appeal.mdx +1 -0
  28. package/docs/api-references/vesting/claim.mdx +1 -0
  29. package/docs/api-references/vesting/delegate.mdx +1 -0
  30. package/docs/api-references/vesting/undelegate.mdx +1 -0
  31. package/docs/api-references/vesting/validator/claim.mdx +2 -1
  32. package/docs/api-references/vesting/validator/create.mdx +1 -0
  33. package/docs/api-references/vesting/validator/deposit.mdx +2 -1
  34. package/docs/api-references/vesting/validator/exit.mdx +2 -1
  35. package/docs/api-references/vesting/validator/join.mdx +1 -0
  36. package/docs/api-references/vesting/validator/operator-transfer/cancel.mdx +2 -1
  37. package/docs/api-references/vesting/validator/operator-transfer/complete.mdx +2 -1
  38. package/docs/api-references/vesting/validator/operator-transfer/initiate.mdx +2 -1
  39. package/docs/api-references/vesting/validator/set-identity.mdx +2 -1
  40. package/docs/api-references/vesting/withdraw.mdx +1 -0
  41. package/docs/api-references/wallet/connect.mdx +17 -0
  42. package/docs/api-references/wallet/disconnect.mdx +15 -0
  43. package/docs/api-references/wallet/status.mdx +15 -0
  44. package/docs/api-references/wallet.mdx +25 -0
  45. package/e2e/config-default.e2e.ts +69 -0
  46. package/e2e/errors.e2e.ts +128 -0
  47. package/e2e/fixtures/StakingStub.json +114 -0
  48. package/e2e/fixtures/StakingStub.sol +33 -0
  49. package/e2e/fixtures/chain.ts +141 -0
  50. package/e2e/fixtures/cli.ts +257 -0
  51. package/e2e/fixtures/mockProvider.ts +64 -0
  52. package/e2e/helpers/bridgePage.ts +116 -0
  53. package/e2e/lane-a-staking.e2e.ts +89 -0
  54. package/e2e/lane-b-deploy.e2e.ts +25 -0
  55. package/e2e/wallet-session.e2e.ts +105 -0
  56. package/package.json +5 -1
  57. package/playwright.config.ts +18 -0
  58. package/src/commands/account/export.ts +10 -2
  59. package/src/commands/account/import.ts +6 -1
  60. package/src/commands/account/index.ts +1 -0
  61. package/src/commands/account/show.ts +16 -4
  62. package/src/commands/balances/BalancesAction.ts +307 -0
  63. package/src/commands/balances/index.ts +18 -0
  64. package/src/commands/contracts/deploy.ts +24 -10
  65. package/src/commands/contracts/index.ts +28 -25
  66. package/src/commands/contracts/write.ts +6 -0
  67. package/src/commands/staking/StakingAction.ts +96 -59
  68. package/src/commands/staking/delegatorClaim.ts +39 -0
  69. package/src/commands/staking/delegatorExit.ts +54 -0
  70. package/src/commands/staking/delegatorJoin.ts +41 -0
  71. package/src/commands/staking/index.ts +190 -145
  72. package/src/commands/staking/setIdentity.ts +96 -26
  73. package/src/commands/staking/setOperator.ts +67 -13
  74. package/src/commands/staking/stakingInfo.ts +6 -5
  75. package/src/commands/staking/validatorClaim.ts +56 -12
  76. package/src/commands/staking/validatorDeposit.ts +54 -12
  77. package/src/commands/staking/validatorExit.ts +71 -14
  78. package/src/commands/staking/validatorHistory.ts +1 -1
  79. package/src/commands/staking/validatorJoin.ts +48 -0
  80. package/src/commands/staking/validatorPrime.ts +91 -1
  81. package/src/commands/staking/validators.ts +4 -2
  82. package/src/commands/staking/wizard.ts +886 -34
  83. package/src/commands/transactions/appeal.ts +7 -0
  84. package/src/commands/transactions/finalize.ts +27 -2
  85. package/src/commands/transactions/index.ts +29 -25
  86. package/src/commands/transactions/trace.ts +1 -6
  87. package/src/commands/vesting/VestingAction.ts +39 -1
  88. package/src/commands/vesting/claim.ts +39 -0
  89. package/src/commands/vesting/delegate.ts +43 -0
  90. package/src/commands/vesting/index.ts +32 -26
  91. package/src/commands/vesting/list.ts +1 -2
  92. package/src/commands/vesting/undelegate.ts +51 -0
  93. package/src/commands/vesting/validatorClaim.ts +43 -4
  94. package/src/commands/vesting/validatorCreate.ts +54 -0
  95. package/src/commands/vesting/validatorDeposit.ts +46 -4
  96. package/src/commands/vesting/validatorExit.ts +55 -4
  97. package/src/commands/vesting/validatorList.ts +1 -1
  98. package/src/commands/vesting/validatorOperatorTransfer.ts +134 -10
  99. package/src/commands/vesting/validatorSetIdentity.ts +65 -4
  100. package/src/commands/vesting/vestingTypes.ts +8 -0
  101. package/src/commands/vesting/withdraw.ts +41 -0
  102. package/src/commands/wallet/WalletAction.ts +193 -0
  103. package/src/commands/wallet/index.ts +36 -0
  104. package/src/index.ts +4 -0
  105. package/src/lib/actions/BaseAction.ts +260 -16
  106. package/src/lib/config/ConfigFileManager.ts +4 -2
  107. package/src/lib/vesting/availableToStake.ts +29 -0
  108. package/src/lib/wallet/bridgePage.ts +289 -0
  109. package/src/lib/wallet/browserBridge.ts +791 -0
  110. package/src/lib/wallet/browserSend.ts +340 -0
  111. package/src/lib/wallet/sessionClient.ts +158 -0
  112. package/src/lib/wallet/sessionConstants.ts +65 -0
  113. package/src/lib/wallet/sessionDaemon.ts +238 -0
  114. package/src/lib/wallet/sessionDescriptor.ts +95 -0
  115. package/src/lib/wallet/sessionResolver.ts +131 -0
  116. package/src/lib/wallet/spawnDaemon.ts +104 -0
  117. package/src/lib/wallet/walletOption.ts +23 -0
  118. package/tests/actions/balances.test.ts +354 -0
  119. package/tests/actions/customNetworkProfiles.test.ts +3 -0
  120. package/tests/actions/deploy.test.ts +42 -0
  121. package/tests/actions/hasLiveWalletSession.test.ts +55 -0
  122. package/tests/actions/resolveActiveIdentity.test.ts +95 -0
  123. package/tests/actions/show.test.ts +94 -0
  124. package/tests/actions/staking.test.ts +575 -8
  125. package/tests/actions/stakingWizard.test.ts +917 -0
  126. package/tests/actions/trace.test.ts +71 -0
  127. package/tests/actions/vesting.test.ts +184 -0
  128. package/tests/actions/walletConnect.test.ts +161 -0
  129. package/tests/actions/walletSession.test.ts +86 -0
  130. package/tests/actions/walletStatusDisconnect.test.ts +273 -0
  131. package/tests/actions/write.test.ts +43 -0
  132. package/tests/commands/balances.test.ts +79 -0
  133. package/tests/commands/staking.test.ts +66 -10
  134. package/tests/commands/vesting.test.ts +78 -0
  135. package/tests/commands/wallet.test.ts +64 -0
  136. package/tests/index.test.ts +8 -0
  137. package/tests/libs/availableToStake.test.ts +47 -0
  138. package/tests/libs/baseAction.test.ts +32 -0
  139. package/tests/libs/browserBridge.test.ts +467 -0
  140. package/tests/libs/browserSend.test.ts +183 -0
  141. package/tests/libs/configFileManager.test.ts +5 -2
  142. package/tests/libs/sessionClient.test.ts +157 -0
  143. package/tests/libs/sessionDaemon.test.ts +141 -0
  144. package/tests/libs/sessionDescriptor.test.ts +95 -0
  145. package/tests/libs/sessionResolver.test.ts +283 -0
  146. package/tests/libs/spawnDaemon.test.ts +117 -0
  147. package/tests/setup.ts +33 -0
  148. package/vitest.config.ts +3 -2
  149. package/.github/workflows/npm-dist-tag.yml +0 -81
@@ -0,0 +1,63 @@
1
+ # Tier-2 browser-wallet signing e2e (Playwright + mock provider on anvil).
2
+ #
3
+ # INFORMATIONAL / NOT A REQUIRED GATE (initially). This job drives a headless
4
+ # chromium against the real bridge page with a viem-backed mock window.ethereum
5
+ # that signs+broadcasts to an ephemeral anvil, exercising the full
6
+ # connect -> sign -> receipt loop with zero MetaMask. Keep it OFF the required
7
+ # status checks in branch protection until it has proven stable across a few
8
+ # weeks of PRs, then promote it to required.
9
+ #
10
+ # Distinct filename from the synced cross-repo e2e.yml (the /run-e2e cucumber
11
+ # pipeline) so the two never collide.
12
+ name: E2E Wallet (Tier 2)
13
+
14
+ on:
15
+ pull_request:
16
+ types: [opened, synchronize, reopened]
17
+ push:
18
+ branches:
19
+ - v0.40
20
+ - v0.40-dev
21
+
22
+ jobs:
23
+ e2e-wallet:
24
+ name: Browser-wallet e2e (anvil lanes)
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - name: Checkout code
28
+ uses: actions/checkout@v4
29
+
30
+ - name: Install libsecret runtime
31
+ run: sudo apt-get update && sudo apt-get install -y libsecret-1-0
32
+
33
+ - name: Set up Node.js
34
+ uses: actions/setup-node@v4
35
+ with:
36
+ node-version: 20
37
+ cache: "npm"
38
+
39
+ - name: Install dependencies
40
+ run: npm ci
41
+
42
+ - name: Build the project
43
+ run: npm run build
44
+
45
+ - name: Install Foundry (anvil)
46
+ uses: foundry-rs/foundry-toolchain@v1
47
+
48
+ - name: Install Playwright chromium
49
+ run: npx playwright install --with-deps chromium
50
+
51
+ - name: Run Tier-2 e2e (anvil lanes)
52
+ run: npm run test:e2e
53
+
54
+ - name: Upload Playwright report
55
+ if: always()
56
+ uses: actions/upload-artifact@v4
57
+ with:
58
+ name: playwright-report
59
+ path: |
60
+ playwright-report/
61
+ test-results/
62
+ retention-days: 7
63
+ if-no-files-found: ignore
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.40.0-clarke.3](https://github.com/genlayerlabs/genlayer-cli/compare/v0.40.0-clarke.2...v0.40.0-clarke.3) (2026-07-10)
4
+
5
+ ### Features
6
+
7
+ * **staking:** non-interactive wizard mode ([#384](https://github.com/genlayerlabs/genlayer-cli/issues/384)) ([ef47935](https://github.com/genlayerlabs/genlayer-cli/commit/ef47935f81f17119caafb4d3121874a27308a40c))
8
+ * **staking:** wizard guides identity on the vesting funding path ([#386](https://github.com/genlayerlabs/genlayer-cli/issues/386)) ([6249e26](https://github.com/genlayerlabs/genlayer-cli/commit/6249e26d68ce12236e4fda6512480778d2990621))
9
+
10
+ ### Bug Fixes
11
+
12
+ * **account:** clear error for password prompts with no TTY ([#390](https://github.com/genlayerlabs/genlayer-cli/issues/390)) ([0ce6b1b](https://github.com/genlayerlabs/genlayer-cli/commit/0ce6b1b19d4d6fb17ce52569a74574212c8d0d53))
13
+ * **balances:** degrade gracefully when staking is unavailable ([#389](https://github.com/genlayerlabs/genlayer-cli/issues/389)) ([8cdcb8a](https://github.com/genlayerlabs/genlayer-cli/commit/8cdcb8aea4c17fcb4f671f5d03bf7decf784618b)), closes [#2](https://github.com/genlayerlabs/genlayer-cli/issues/2)
14
+ * **balances:** wallet-only view when consensus infra is not deployed ([#391](https://github.com/genlayerlabs/genlayer-cli/issues/391)) ([f2d9c98](https://github.com/genlayerlabs/genlayer-cli/commit/f2d9c9837f88be42e53e0a4dcc94322e1d15b5b6)), closes [#389](https://github.com/genlayerlabs/genlayer-cli/issues/389)
15
+ * **cli:** read commands honor a live wallet session (connect-once identity) ([#385](https://github.com/genlayerlabs/genlayer-cli/issues/385)) ([923475d](https://github.com/genlayerlabs/genlayer-cli/commit/923475d93e36dbb8146f2dcb9ff5d80799af99a4))
16
+ * **staking:** route set-operator/validator-claim/set-identity/trace through the SDK ([#387](https://github.com/genlayerlabs/genlayer-cli/issues/387)) ([e70b31b](https://github.com/genlayerlabs/genlayer-cli/commit/e70b31b039bbb67b568628adc7219909e9d0d1af))
17
+ * **staking:** validator-deposit/exit work through the CLI ([#382](https://github.com/genlayerlabs/genlayer-cli/issues/382)) ([3de9a6a](https://github.com/genlayerlabs/genlayer-cli/commit/3de9a6a2ee07bd596d3706228d9584f529ce1e16))
18
+ * **wallet:** harden bridge (verify signer, Host check, constant-time token, 0700, url scrub, body cap) ([#383](https://github.com/genlayerlabs/genlayer-cli/issues/383)) ([e55f917](https://github.com/genlayerlabs/genlayer-cli/commit/e55f917f269ece99c98dee6337695c7e5c459b95))
19
+
20
+ ## [0.40.0-clarke.2](https://github.com/genlayerlabs/genlayer-cli/compare/v0.40.0-clarke.1...v0.40.0-clarke.2) (2026-07-09)
21
+
22
+ ### Features
23
+
24
+ * **staking:** browser-wallet signing for validator-join and wizard ([#367](https://github.com/genlayerlabs/genlayer-cli/issues/367)) ([ab128c0](https://github.com/genlayerlabs/genlayer-cli/commit/ab128c0b76b4f9d97ed660d91a556a5f769cef6f))
25
+
3
26
  ## [0.40.0-clarke.1](https://github.com/genlayerlabs/genlayer-cli/compare/v0.40.0-rc2...v0.40.0-clarke.1) (2026-07-08)
4
27
 
5
28
  ## [0.40.0-rc2](https://github.com/genlayerlabs/genlayer-cli/compare/v0.40.0-rc1...v0.40.0-rc2) (2026-07-08)
package/CLAUDE.md CHANGED
@@ -26,7 +26,9 @@ npx vitest -t "test name pattern" # Run specific test by name
26
26
  ### Entry Point & Command Structure
27
27
  - `src/index.ts` - Main entry, initializes Commander program and registers all command groups
28
28
  - Commands organized in `src/commands/<domain>/index.ts` - each exports `initialize*Commands(program)` function
29
- - Command domains: general (init/up/stop), account, contracts, config, localnet, update, scaffold, network, transactions, staking
29
+ - Command domains: general (init/up/stop), account, contracts, config, localnet, update, scaffold, network, transactions, staking, vesting, wallet, balances
30
+ - Custom networks: `network add <alias> --base <built-in>` registers a custom network profile (RPC/contract-address overrides); resolved by alias everywhere via `--network`
31
+ - Browser-wallet signing: write commands (staking/vesting/deploy/write) accept `--wallet browser` to sign in MetaMask through a local bridge (`addWalletModeOption` in `src/lib/wallet/walletOption.ts`); `wallet connect` starts a persistent session so the key never leaves MetaMask
30
32
 
31
33
  ### Core Classes
32
34
  - `BaseAction` (`src/lib/actions/BaseAction.ts`) - Base class for all CLI actions. Provides:
package/README.md CHANGED
@@ -151,15 +151,34 @@ USAGE:
151
151
  genlayer network set [network] Set the network to use
152
152
  genlayer network info Show current network configuration and contract addresses
153
153
  genlayer network list List available networks
154
+ genlayer network add <alias> Add a custom network profile
155
+ genlayer network remove <alias> Remove a custom network profile
156
+
157
+ OPTIONS (add):
158
+ --base <built-in-alias> Built-in base network to derive from (required)
159
+ --rpc <url> Node RPC URL override
160
+ --chain-id <n> Chain ID override
161
+ --consensus-main <addr> ConsensusMain contract address override
162
+ --consensus-data <addr> ConsensusData contract address override
163
+ --staking <addr> Staking contract address override
164
+ --fee-manager <addr> FeeManager contract address override
165
+ --deployment <path.json> Consensus deployments JSON file to read addresses from
154
166
 
155
167
  EXAMPLES:
156
168
  genlayer network set
157
- genlayer network set testnet
158
- genlayer network set mainnet
169
+ genlayer network set testnet-bradbury
159
170
  genlayer network info
160
171
  genlayer network list
172
+
173
+ # Register a custom network on top of a built-in base, then use it by alias
174
+ genlayer network add my-devnet --base testnet-bradbury --rpc https://rpc.example.com --chain-id 4221
175
+ genlayer network set my-devnet
176
+ genlayer deploy --network my-devnet
161
177
  ```
162
178
 
179
+ Custom networks are stored by alias and can be selected anywhere a built-in
180
+ network can, via `--network <alias>` (or `genlayer network set <alias>`).
181
+
163
182
  #### Deploy and Call Intelligent Contracts
164
183
 
165
184
  Deploy and interact with intelligent contracts.
@@ -478,6 +497,7 @@ COMMON OPTIONS (all commands):
478
497
  OPTIONS (validator-join):
479
498
  --amount <amount> Amount to stake (in wei or with 'gen' suffix)
480
499
  --operator <address> Operator address (defaults to signer)
500
+ --wallet <mode> 'keystore' (default) or 'browser' (sign in MetaMask)
481
501
 
482
502
  OPTIONS (delegator-join):
483
503
  --validator <address> Validator address to delegate to
@@ -497,6 +517,14 @@ EXAMPLES:
497
517
  # Join as validator with 42000 GEN
498
518
  genlayer staking validator-join --amount 42000gen
499
519
 
520
+ # Sign the validator-join with a browser wallet (MetaMask) instead of a keystore.
521
+ # The CLI serves a page on 127.0.0.1 and opens it; connect + confirm in the wallet.
522
+ # Remote/SSH: forward the printed port first (ssh -L <port>:127.0.0.1:<port> ...).
523
+ genlayer staking validator-join --amount 42000gen --wallet browser --network testnet-bradbury
524
+
525
+ # The wizard can also use a browser wallet as the owner (operator keystore is still generated locally):
526
+ genlayer staking wizard --wallet browser
527
+
500
528
  # Join as delegator with 42 GEN
501
529
  genlayer staking delegator-join --validator 0x... --amount 42gen
502
530
 
@@ -576,6 +604,80 @@ EXAMPLES:
576
604
  genlayer staking prime-all
577
605
  ```
578
606
 
607
+ #### Browser Wallet Signing
608
+
609
+ By default, write commands sign with your encrypted keystore. Any write command
610
+ (`deploy`, `write`, and the `staking`/`vesting` commands) also accepts
611
+ `--wallet browser` to sign in MetaMask instead: the CLI serves a small page on
612
+ `127.0.0.1`, opens it, and you connect and confirm in the wallet. Your private
613
+ key never leaves MetaMask.
614
+
615
+ To avoid reconnecting for every command, open a persistent session once with
616
+ `wallet connect` and reuse it across subsequent `--wallet browser` commands.
617
+
618
+ ```bash
619
+ USAGE:
620
+ genlayer wallet connect [options] Start a persistent browser-wallet session (connect once)
621
+ genlayer wallet status Show the current session (address, network, heartbeat)
622
+ genlayer wallet disconnect End the active session
623
+
624
+ EXAMPLES:
625
+ # Connect once, then reuse across commands
626
+ genlayer wallet connect --network testnet-bradbury
627
+ genlayer deploy --wallet browser
628
+ genlayer write 0x123...abc updateValue --args 42 --wallet browser
629
+ genlayer wallet status
630
+ genlayer wallet disconnect
631
+ ```
632
+
633
+ For remote/SSH hosts, forward the printed port first
634
+ (`ssh -L <port>:127.0.0.1:<port> ...`). The default signing mode can be set via
635
+ the `walletMode` config value.
636
+
637
+ #### Balances
638
+
639
+ Show wallet and vesting balances plus committed stake for an address
640
+ (read-only, no keystore unlock).
641
+
642
+ ```bash
643
+ USAGE:
644
+ genlayer balances [options]
645
+
646
+ OPTIONS:
647
+ --beneficiary <address> Address to inspect (defaults to the active account)
648
+ --account <name> Account whose address to use (no unlock)
649
+ --network <network> Built-in or custom network alias
650
+ --rpc <rpcUrl> RPC URL for the network
651
+
652
+ EXAMPLES:
653
+ genlayer balances
654
+ genlayer balances --beneficiary 0x123...abc --network testnet-bradbury
655
+ ```
656
+
657
+ #### Vesting
658
+
659
+ Manage vesting contracts and vesting-backed validators. Beneficiaries can list
660
+ their vesting contracts, delegate/withdraw vested tokens, and run validators
661
+ whose stake is committed from a vesting contract rather than their wallet.
662
+
663
+ ```bash
664
+ USAGE:
665
+ genlayer vesting list List beneficiary vesting contracts and state
666
+ genlayer vesting delegate <validator> Delegate vesting-held tokens to a validator
667
+ genlayer vesting withdraw --amount <amt> Withdraw vested tokens to the beneficiary
668
+ genlayer vesting validator create [operator] --amount <amt> Create a vesting-backed validator
669
+ genlayer vesting validator list List validator wallets owned by a vesting contract
670
+ ```
671
+
672
+ The `staking wizard` can fund a validator from either your wallet or a vesting
673
+ contract, and sign with a keystore key or a browser wallet — the recommended
674
+ path for creating a vesting-backed validator interactively:
675
+
676
+ ```bash
677
+ genlayer staking wizard
678
+ genlayer staking wizard --wallet browser
679
+ ```
680
+
579
681
  ### Running the CLI from the repository
580
682
 
581
683
  First, install the dependencies and start the build process