Skip to content

Commit a4db2f9

Browse files
authored
Merge pull request #217 from BitGo/refactor/recipient-type
refactor: extract Recipient type in intentBuilder
2 parents 0feb0c2 + adc2d4f commit a4db2f9

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

packages/wasm-solana/js/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export type {
4141
CustomTxKey,
4242
SolanaIntent,
4343
StakePoolConfig,
44+
Recipient,
4445
BuildFromIntentParams,
4546
BuildFromIntentResult,
4647
GeneratedKeypair,

packages/wasm-solana/js/intentBuilder.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,22 @@ export interface BaseIntent {
8585
memo?: string;
8686
}
8787

88+
/** A recipient in a transaction — native SOL or SPL token transfer */
89+
export interface Recipient {
90+
address?: { address: string };
91+
amount?: { value: bigint; symbol?: string };
92+
/** Mint address (base58) — if set, this is an SPL token transfer */
93+
tokenAddress?: string;
94+
/** Token program ID (defaults to SPL Token Program) */
95+
tokenProgramId?: string;
96+
/** Decimal places for the token (required for transfer_checked) */
97+
decimalPlaces?: number;
98+
}
99+
88100
/** Payment intent */
89101
export interface PaymentIntent extends BaseIntent {
90102
intentType: "payment";
91-
recipients?: Array<{
92-
address?: { address: string };
93-
amount?: { value: bigint; symbol?: string };
94-
/** Mint address (base58) — if set, this is an SPL token transfer */
95-
tokenAddress?: string;
96-
/** Token program ID (defaults to SPL Token Program) */
97-
tokenProgramId?: string;
98-
/** Decimal places for the token (required for transfer_checked) */
99-
decimalPlaces?: number;
100-
}>;
103+
recipients?: Recipient[];
101104
}
102105

103106
/** Stake intent */
@@ -176,16 +179,7 @@ export interface ConsolidateIntent extends BaseIntent {
176179
/** The child address to consolidate from (sender) */
177180
receiveAddress: string;
178181
/** Recipients (root address for native SOL, wallet ATAs for tokens) */
179-
recipients?: Array<{
180-
address?: { address: string };
181-
amount?: { value: bigint; symbol?: string };
182-
/** Mint address (base58) — if set, this is an SPL token transfer */
183-
tokenAddress?: string;
184-
/** Token program ID (defaults to SPL Token Program) */
185-
tokenProgramId?: string;
186-
/** Decimal places for the token (required for transfer_checked) */
187-
decimalPlaces?: number;
188-
}>;
182+
recipients?: Recipient[];
189183
}
190184

191185
/** Authorize intent - pre-built transaction message */

0 commit comments

Comments
 (0)