Skip to content

Commit 99aa01a

Browse files
committed
feat: added optional token field in canton
transfer builder Ticket: COIN-7303
1 parent 8a2810a commit 99aa01a

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

modules/sdk-coin-canton/src/lib/iface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,5 @@ export interface CantonTransferRequest {
152152
expiryEpoch: number;
153153
sendViaOneStep: boolean;
154154
memoId?: string;
155+
token?: string;
155156
}

modules/sdk-coin-canton/src/lib/transferBuilder.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class TransferBuilder extends TransactionBuilder {
1313
private _sendOneStep = false;
1414
private _expiryEpoch: number;
1515
private _memoId: string;
16+
private _token: string;
1617
constructor(_coinConfig: Readonly<CoinConfig>) {
1718
super(_coinConfig);
1819
}
@@ -145,6 +146,20 @@ export class TransferBuilder extends TransactionBuilder {
145146
return this;
146147
}
147148

149+
/**
150+
* Sets the optional token field if present, used for canton token transaction
151+
* @param name - the bitgo name of the token
152+
* @returns The current builder for chaining
153+
* @throws Error if name is invalid
154+
*/
155+
token(name: string): this {
156+
if (!name || !name.trim()) {
157+
throw new Error('token name must be a non-empty string');
158+
}
159+
this._token = name.trim();
160+
return this;
161+
}
162+
148163
/**
149164
* Get the canton transfer request object
150165
* @returns CantonTransferRequest
@@ -163,6 +178,9 @@ export class TransferBuilder extends TransactionBuilder {
163178
if (this._memoId) {
164179
data.memoId = this._memoId;
165180
}
181+
if (this._token) {
182+
data.token = this._token;
183+
}
166184
return data;
167185
}
168186

0 commit comments

Comments
 (0)