Skip to content

feat(sdk-coin-tao): build claimRootWithHotkey extrinsic from intent - #9448

Open
bitgo-ai-agent-dev[bot] wants to merge 3 commits into
masterfrom
ashutosh/SI-1171-claim-root-with-hotkey
Open

feat(sdk-coin-tao): build claimRootWithHotkey extrinsic from intent#9448
bitgo-ai-agent-dev[bot] wants to merge 3 commits into
masterfrom
ashutosh/SI-1171-claim-root-with-hotkey

Conversation

@bitgo-ai-agent-dev

Copy link
Copy Markdown
Contributor

What

  • abstract-substrate: add ClaimRootWithHotkey to MethodNames const, add ClaimRootWithHotkeyArgs interface ({ hotkey: string }) to iface.ts TxMethod.args union, add ClaimRootWithHotkeyTransactionSchema joi schema
  • sdk-coin-tao: new ClaimRootBuilder — builds SubtensorModule.claimRootWithHotkey(hotkey) extrinsic via defineMethod; implements hotkey() setter, buildTransaction(), fromImplementation(), validateTransaction(), validateDecodedTransaction()
  • sdk-coin-tao: new ClaimRootTransaction — overrides toJson() (adds hotkey field), loadInputsAndOutputs() (populates _outputs with hotkey address, resets arrays before repopulating), explainTransaction()
  • sdk-coin-tao: new ClaimRootTxData interface in iface.ts
  • sdk-coin-tao: TransactionBuilderFactory — register ClaimRootWithHotkey dispatch in getBuilder() and expose getClaimRootBuilder()
  • sdk-coin-tao: Tao.verifyTransaction override — short-circuits for StakingClaim type (case-insensitive) before the parent tries to access _to/_amount which don't exist on ClaimRootBuilder
  • sdk-coin-tao: new src/resources/testnetV2.ts — Bittensor testnet metadata (specVersion 443) that includes claim_root_with_hotkey; existing testnet.ts (specVersion 224) unchanged
  • sdk-coin-tao: wire TaoClaimRootIntent { hotkey, netuid: 0 } end-to-end in tao.ts
  • Unit tests: unsigned build, signed build, round-trip from(), factory dispatch, outputs content, loadInputsAndOutputs null-safety, explainTransaction, validation, error paths, verifyTransaction with both PascalCase and lowercase type

Why

  • SI-1171 requires sdk-coin-tao to accept TaoClaimRootIntent { hotkey, netuid: 0 } and produce a signed, broadcastable SubtensorModule.claimRootWithHotkey extrinsic. This is a P0 blocker for the TAO Root Reborn claim feature and directly blocks SI-1172 ([WP] Route CLAIM_REWARDS request type for tao/ttao)

Test plan

  • mocha — 93 passing, 2 pending, 1 pre-existing failure (requires BITGOJS_TEST_PASSWORD)
  • TypeScript build: sdk-coin-tao and abstract-substrate compile clean
  • loadInputsAndOutputs resets _outputs/_inputs before push — idempotent on repeated build() calls
  • verifyTransaction uses case-insensitive comparison — handles WalletPlatform lowercase 'stakingclaim' intentType
  • Integration test on testnet after feature is wired end-to-end (SI-1172)

Ticket: SI-1171

Add SubtensorModule.claimRootWithHotkey(hotkey) Substrate extrinsic
support across abstract-substrate and sdk-coin-tao.

**abstract-substrate:**
- Add ClaimRootWithHotkey to MethodNames const
- Add ClaimRootWithHotkeyArgs interface ({ hotkey: string }) and
  include it in TxMethod.args union
- Add ClaimRootWithHotkeyTransactionSchema (joi, valid hotkey address)

**sdk-coin-tao:**
- New ClaimRootBuilder: builds the extrinsic via defineMethod; hotkey()
  setter, buildTransaction(), fromImplementation(), validate logic
- New ClaimRootTransaction: toJson() with hotkey field,
  loadInputsAndOutputs() populating _outputs, explainTransaction()
- New ClaimRootTxData interface in iface.ts
- TransactionBuilderFactory: dispatch ClaimRootWithHotkey in
  getBuilder(), expose getClaimRootBuilder()
- Wire TaoClaimRootIntent in tao.ts end-to-end
- New testnetV2.ts metadata (specVersion 443) that includes
  claim_root_with_hotkey; existing testnet.ts unchanged
- Unit tests: unsigned/signed build, round-trip from(), factory
  dispatch, outputs, validation, error paths

Implements TaoClaimRootIntent { hotkey, netuid: 0 } → signed,
broadcastable extrinsic. P0 blocker for TAO Root Reborn claim
feature (blocks SI-1172).

Ticket: SI-1171
Session-Id: ab70e181-1628-4e73-9662-8ef3fe0426ba
Task-Id: 091af7ce-ed42-4177-9ee0-2231917f41fa
Two correctness bugs identified by post-commit review:

1. ClaimRootTransaction.loadInputsAndOutputs() used push() without
   resetting _outputs/_ inputs first. The base TransactionBuilder calls
   loadInputsAndOutputs() on every build(), so repeated build() calls
   accumulated duplicate entries in _outputs. Fixed by resetting both
   arrays at the top of the method before delegating to super and
   before any push — consistent with how the base Transaction class
   handles Send/Staking paths via assignment.

2. Tao.verifyTransaction() compared txParams.type with the string
   literal 'StakingClaim' using strict equality. WalletPlatform delivers
   intentType as lowercase ('stakingclaim'), causing the bypass to be
   skipped and execution to fall through to super.verifyTransaction()
   which accesses _to/_amount (absent on ClaimRootBuilder) and throws
   'missing recipients in txParams' for a valid claim transaction.
   Fixed with toLowerCase() comparison.

Also strengthen tests: add case-insensitive lowercase test for
verifyTransaction and assert explanation.fee.fee value (tip=0 fallback).

Ticket: SI-1171
Session-Id: ab70e181-1628-4e73-9662-8ef3fe0426ba
Task-Id: 091af7ce-ed42-4177-9ee0-2231917f41fa
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

SI-1171

Prettier requires the template literal arguments to InvalidTransactionError
to be on a single line when they fit within the print-width limit. The two
throw statements in validateFields() and validateDecodedTransaction() were
wrapped across three lines, causing the format and lint CI jobs to fail.

Ticket: SI-1171
Session-Id: 82fbe26f-d2ca-43d9-9639-9c8f2b2891c2
Task-Id: 1a8e194e-1dbd-4e6e-ab11-445d93b59dbe
@ralph-bitgo
ralph-bitgo Bot force-pushed the ashutosh/SI-1171-claim-root-with-hotkey branch from cf99084 to c4e893b Compare August 7, 2026 08:34
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the ashutosh/SI-1171-claim-root-with-hotkey branch from c4e893b to 8b843b8 Compare August 7, 2026 08:34
@ashutoshkumar-6
ashutoshkumar-6 marked this pull request as ready for review August 7, 2026 09:32
@ashutoshkumar-6
ashutoshkumar-6 requested a review from a team as a code owner August 7, 2026 09:32
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.

1 participant