Skip to content

Commit 2e4c831

Browse files
chore: support tokenApproval for MPC
Ticket: COIN-4071
1 parent 9662833 commit 2e4c831

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

modules/sdk-core/src/bitgo/utils/mpcUtils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export abstract class MpcUtils {
117117
populateIntent(baseCoin: IBaseCoin, params: PrebuildTransactionWithIntentOptions): PopulatedIntent {
118118
const chain = this.baseCoin.getChain();
119119

120-
if (!['acceleration', 'fillNonce', 'transferToken'].includes(params.intentType)) {
120+
if (!['acceleration', 'fillNonce', 'transferToken', 'tokenApproval'].includes(params.intentType)) {
121121
assert(params.recipients, `'recipients' is a required parameter for ${params.intentType} intent`);
122122
}
123123
const intentRecipients = params.recipients?.map((recipient) => {
@@ -177,6 +177,12 @@ export abstract class MpcUtils {
177177
receiveAddress: params.receiveAddress,
178178
feeOptions: params.feeOptions,
179179
};
180+
case 'tokenApproval':
181+
return {
182+
...baseIntent,
183+
tokenName: params.tokenName,
184+
feeOptions: params.feeOptions,
185+
};
180186
default:
181187
throw new Error(`Unsupported intent type ${params.intentType}`);
182188
}

modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export interface PopulatedIntent extends PopulatedIntentBase {
253253
receiveAddress?: string;
254254
custodianTransactionId?: string;
255255
custodianMessageId?: string;
256+
tokenName?: string;
256257
}
257258

258259
export type TxRequestState =

modules/sdk-core/src/bitgo/wallet/wallet.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,6 +3285,17 @@ export class Wallet implements IWallet {
32853285
params.preview
32863286
);
32873287
break;
3288+
case 'tokenApproval':
3289+
txRequest = await this.tssUtils!.prebuildTxWithIntent(
3290+
{
3291+
reqId,
3292+
intentType: 'tokenApproval',
3293+
tokenName: params.tokenName,
3294+
},
3295+
apiVersion,
3296+
params.preview
3297+
);
3298+
break;
32883299
default:
32893300
throw new Error(`transaction type not supported: ${params.type}`);
32903301
}

0 commit comments

Comments
 (0)