Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/sdk-core/src/bitgo/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4346,7 +4346,9 @@ export class Wallet implements IWallet {

if (
typeof params.prebuildTx === 'string' ||
(params.prebuildTx?.buildParams?.type !== 'enabletoken' && params.prebuildTx?.buildParams?.type !== 'enableMpt')
(params.prebuildTx?.buildParams?.type !== 'enabletoken' &&
params.prebuildTx?.buildParams?.type !== 'enableMpt' &&
params.prebuildTx?.buildParams?.type !== 'disabletoken')
) {
throw new Error('Invalid build of token enablement.');
}
Expand Down
14 changes: 13 additions & 1 deletion modules/sdk-core/test/unit/bitgo/wallet/tokenApproval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sinon from 'sinon';
import 'should';
import { BuildTokenApprovalResponse, Wallet } from '../../../../src';
import { BuildTokenApprovalResponse, PrebuildTransactionResult, Wallet } from '../../../../src';

describe('Wallet - Token Approval', function () {
let wallet: Wallet;
Expand Down Expand Up @@ -224,6 +224,18 @@ describe('Wallet - Token Approval', function () {
sinon.assert.calledOnce(initiateStub);
});

it('should pass validation and proceed when buildParams.type is "disabletoken"', async function () {
const initiateStub = sinon.stub(teWallet, 'initiateTransaction' as keyof Wallet).resolves({ txid: 'disable789' });

const result = await teWallet.sendTokenEnablement({
// Partial fixture: only the fields sendTokenEnablement's validation guard reads.
prebuildTx: { buildParams: { type: 'disabletoken' } } as unknown as PrebuildTransactionResult,
});

result.should.eql({ txid: 'disable789' });
sinon.assert.calledOnce(initiateStub);
});

it('should throw when the coin does not require token enablement', async function () {
teBaseCoin.getTokenEnablementConfig.returns({ requiresTokenEnablement: false });

Expand Down
Loading