Skip to content

Latest commit

 

History

History
86 lines (67 loc) · 3.75 KB

File metadata and controls

86 lines (67 loc) · 3.75 KB

AGENTS.md

Polkadot/Substrate extrinsics debugging toolkit.

⚠️ ALWAYS UPDATE THIS FILE when adding or modifying CLI commands or project structure.

CLI Usage

  • bun cli.ts help - Show help
  • bun cli.ts decode <extrinsic-hex> [--chain <name>] [--name <string>] - Decode extrinsic
  • bun cli.ts decode-call <call-hex> [--chain <name>] [--name <string>] - Decode call (without extrinsic wrapper)
  • bun cli.ts build --address <hex> --call <hex> [--nonce <n>] [--tip <n>] [--era immortal|mortal] - Build extrinsic
  • bun cli.ts build-with-extensions --address <hex> --call <hex> --extensions <hex> [--signature <hex>] [--chain <name>] [--decode] - Build extrinsic with custom signed extensions
  • bun cli.ts compare <hex1> <hex2> [--name1 <s>] [--name2 <s>] - Compare two extrinsics
  • bun cli.ts query-fees --address <hex> --call <hex> [--chain <name>] - Query fees
  • bun cli.ts query-extrinsic-fees <extrinsic-hex> [--chain <name>] - Query fees for existing extrinsic
  • bun cli.ts compact-scale --encode <n> | --decode <hex> - Encode/decode SCALE compact
  • bun cli.ts get-storage <key> [block] [--chain <name>] - Query storage
  • bun cli.ts get-block [--hash <hash>] [--chain <name>] - Get block data
  • bun cli.ts list-pallets [--chain <name>] - List pallets
  • bun cli.ts list-calls [--chain <name>] [--pallets <names>] - List calls
  • bun cli.ts list-types [--chain <name>] - List types
  • bun cli.ts describe-type <type-name> [--chain <name>] - Show type structure
  • bun cli.ts list-signed-extensions [--chain <name>] [--live] [--verbose] - List signed extensions order/encoding
  • bun cli.ts list-constants [--chain <name>] [--pallet <name>] - List constants
  • bun cli.ts describe-constant <pallet> <constant> [--chain <name>] - Show constant info
  • bun cli.ts add-chain --name <name> --ws-url <url> [--display-name <name>] [--papi-key <key>] [--set-default] - Add chain

Dispute Investigation Commands

  • bun cli.ts get-validators [--chain <name>] [--indices <list>] - Get session validators with indices
  • bun cli.ts get-disputes [--chain <name>] [--block <hash>] - Get disputes from block/storage
  • bun cli.ts analyze-dispute-votes --file <json> [--validators <csv>] - Analyze dispute vote patterns
  • bun cli.ts get-session-info [--chain <name>] - Get session info and dispute parameters
  • bun cli.ts check-para-validation --para-id <n> [--chain <name>] - Check para validation status

See docs/dispute-investigation.md for detailed guide.

Setup

bun install

Project Structure

cli.ts                      # CLI entry point
lib/extrinsic-utils.ts      # Decoder and builder
lib/extensions-parser.ts    # Dynamic extensions parser
extensions.json             # Chain-specific extensions config
chains.json                 # Chain RPC endpoints
commands/                   # CLI command implementations
docs/                       # Documentation
.papi/                      # Auto-generated by polkadot-api CLI (do not edit manually)

Adding a Chain

  1. Add chain to chains.json:

    {
      "name": "enjin-relay",
      "displayName": "Enjin Relay",
      "wsUrl": "wss://archive.relay.blockchain.enjin.io",
      "papiKey": "enjinRelay"
    }
  2. Generate metadata and descriptors:

    bunx papi add <chain> -n <papiKey>
  3. (Optional) Add signed extensions to extensions.json for extrinsic building/decoding.

Storage Keys

  • EVENTS: 0x26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7
  • SYSTEM_ACCOUNT: 0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9

Code Style

  • TypeScript: strict: true, ESNext target
  • noUncheckedIndexedAccess: true (require undefined checks for array access)
  • allowImportingTsExtensions: true