11/**
22 * TypeScript type definitions for wasm-dot
33 *
4- * Follows wallet-platform pattern: buildTransaction(intent, context)
5- * - intent: what to do (transfer , stake, etc.) - single operation
4+ * buildTransaction(intent, context)
5+ * - intent: business-level intent (payment , stake, unstake, etc.)
66 * - context: how to build it (sender, nonce, material, validity)
7+ *
8+ * The crate handles intent composition internally. For example, a stake
9+ * intent with a proxy address produces a batchAll(bond, addProxy) extrinsic.
710 */
811
912// =============================================================================
@@ -54,9 +57,9 @@ export interface ParseContext {
5457 material : Material ;
5558 /** Sender address (optional, helps with decoding) */
5659 sender ?: string ;
57- /** Reference block hash (not in extrinsic bytes — pass-through for consumers) */
60+ /** Reference block hash (not in extrinsic bytes, pass-through for consumers) */
5861 referenceBlock ?: string ;
59- /** Block number when transaction becomes valid (not in extrinsic bytes — pass-through for consumers) */
62+ /** Block number when transaction becomes valid (not in extrinsic bytes, pass-through for consumers) */
6063 blockNumber ?: number ;
6164}
6265
@@ -65,9 +68,7 @@ export interface ParseContext {
6568// =============================================================================
6669
6770/**
68- * Build context - contains all non-intent data needed to build a transaction
69- *
70- * Matches wallet-platform's material + nonce + validity pattern.
71+ * Build context: contains all non-intent data needed to build a transaction.
7172 */
7273export interface BuildContext {
7374 /** Sender address (SS58 encoded) */
@@ -89,46 +90,54 @@ export interface BuildContext {
8990// =============================================================================
9091
9192/**
92- * Transaction intent - a single operation to perform
93+ * Business-level transaction intent.
9394 *
94- * Discriminated union using the `type` field.
95- * For multiple operations, use the `batch` intent type.
95+ * Discriminated union using the `type` field. The crate handles composing
96+ * these into the correct Polkadot extrinsic calls, including automatic
97+ * batching when multiple calls are needed (e.g., stake with proxy).
9698 */
9799export type TransactionIntent =
98- | TransferIntent
99- | TransferAllIntent
100+ | PaymentIntent
101+ | ConsolidateIntent
100102 | StakeIntent
101103 | UnstakeIntent
102- | WithdrawUnbondedIntent
103- | ChillIntent
104- | AddProxyIntent
105- | RemoveProxyIntent
106- | BatchIntent ;
107-
108- export interface TransferIntent {
109- type : "transfer" ;
104+ | ClaimIntent
105+ | FillNonceIntent ;
106+
107+ /** Transfer DOT to a recipient */
108+ export interface PaymentIntent {
109+ type : "payment" ;
110110 /** Recipient address (SS58) */
111111 to : string ;
112112 /** Amount in planck */
113113 amount : bigint ;
114- /** Use transferKeepAlive (default: true) */
114+ /** Use transferKeepAlive to prevent reaping (default: true) */
115115 keepAlive ?: boolean ;
116116}
117117
118- export interface TransferAllIntent {
119- type : "transferAll" ;
118+ /** Sweep all DOT to a recipient (transferAll) */
119+ export interface ConsolidateIntent {
120+ type : "consolidate" ;
120121 /** Recipient address (SS58) */
121122 to : string ;
122- /** Keep account alive after transfer */
123+ /** Keep sender account alive after transfer (default: true) */
123124 keepAlive ?: boolean ;
124125}
125126
127+ /**
128+ * Stake DOT.
129+ *
130+ * - With `proxyAddress`: new stake, produces batchAll(bond, addProxy)
131+ * - Without `proxyAddress`: top-up, produces bondExtra
132+ */
126133export interface StakeIntent {
127134 type : "stake" ;
128135 /** Amount to stake in planck */
129136 amount : bigint ;
130- /** Where to send staking rewards */
137+ /** Reward destination (default: Staked / compound) */
131138 payee ?: StakePayee ;
139+ /** Proxy address for new stake. Absent means top-up (bondExtra). */
140+ proxyAddress ?: string ;
132141}
133142
134143export type StakePayee =
@@ -137,48 +146,33 @@ export type StakePayee =
137146 | { type : "controller" }
138147 | { type : "account" ; address : string } ;
139148
149+ /**
150+ * Unstake DOT.
151+ *
152+ * - `stopStaking=true` + `proxyAddress`: full unstake, produces
153+ * batchAll(removeProxy, chill, unbond)
154+ * - `stopStaking=false`: partial unstake, produces unbond
155+ */
140156export interface UnstakeIntent {
141157 type : "unstake" ;
142158 /** Amount to unstake in planck */
143159 amount : bigint ;
160+ /** Full unstake (remove proxy + chill) or partial (just unbond). Default: false */
161+ stopStaking ?: boolean ;
162+ /** Proxy address to remove (required when stopStaking=true) */
163+ proxyAddress ?: string ;
144164}
145165
146- export interface WithdrawUnbondedIntent {
147- type : "withdrawUnbonded" ;
148- /** Number of slashing spans (usually 0) */
166+ /** Claim (withdraw unbonded) DOT after the unbonding period */
167+ export interface ClaimIntent {
168+ type : "claim" ;
169+ /** Number of slashing spans (default: 0) */
149170 slashingSpans ?: number ;
150171}
151172
152- export interface ChillIntent {
153- type : "chill" ;
154- }
155-
156- export interface AddProxyIntent {
157- type : "addProxy" ;
158- /** Delegate address (SS58) */
159- delegate : string ;
160- /** Proxy type (Any, NonTransfer, Staking, etc.) */
161- proxyType : string ;
162- /** Delay in blocks */
163- delay ?: number ;
164- }
165-
166- export interface RemoveProxyIntent {
167- type : "removeProxy" ;
168- /** Delegate address (SS58) */
169- delegate : string ;
170- /** Proxy type */
171- proxyType : string ;
172- /** Delay in blocks */
173- delay ?: number ;
174- }
175-
176- export interface BatchIntent {
177- type : "batch" ;
178- /** List of intents to execute */
179- calls : TransactionIntent [ ] ;
180- /** Use batchAll (atomic) instead of batch (default: true) */
181- atomic ?: boolean ;
173+ /** Zero-value self-transfer to advance the account nonce */
174+ export interface FillNonceIntent {
175+ type : "fillNonce" ;
182176}
183177
184178// =============================================================================
0 commit comments