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
3 changes: 2 additions & 1 deletion modules/sdk-coin-xdc/src/xdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export class Xdc extends AbstractEthLikeNewCoins {
!txParams?.recipients &&
!(
txParams.prebuildTx?.consolidateId ||
(txParams.type && ['acceleration', 'fillNonce', 'transferToken'].includes(txParams.type))
(txParams.type &&
['acceleration', 'fillNonce', 'transferToken', 'tokenApproval', 'consolidate'].includes(txParams.type))
)
) {
throw new Error(`missing txParams`);
Expand Down
3 changes: 2 additions & 1 deletion modules/sdk-coin-xdc/src/xdcToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export class XdcToken extends EthLikeToken {
!txParams?.recipients &&
!(
txParams.prebuildTx?.consolidateId ||
(txParams.type && ['acceleration', 'fillNonce', 'transferToken'].includes(txParams.type))
(txParams.type &&
['acceleration', 'fillNonce', 'transferToken', 'tokenApproval', 'consolidate'].includes(txParams.type))
)
) {
throw new Error(`missing txParams`);
Expand Down
34 changes: 34 additions & 0 deletions modules/sdk-coin-xdc/test/unit/xdcToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,40 @@ describe('XDC Token:', function () {
result.should.equal(true);
});

it('should return true for tokenApproval type without recipients', async function () {
const token = bitgo.coin('txdc:tmt') as XdcToken;
const mockWallet = {} as unknown as IWallet;

const result = await token.verifyTssTransaction({
txParams: {
type: 'tokenApproval',
},
txPrebuild: mockTokenTransferData.txPrebuild as unknown as Parameters<
typeof token.verifyTssTransaction
>[0]['txPrebuild'],
wallet: mockWallet,
});

result.should.equal(true);
});

it('should return true for consolidate type without recipients', async function () {
const token = bitgo.coin('txdc:tmt') as XdcToken;
const mockWallet = {} as unknown as IWallet;

const result = await token.verifyTssTransaction({
txParams: {
type: 'consolidate',
},
txPrebuild: mockTokenTransferData.txPrebuild as unknown as Parameters<
typeof token.verifyTssTransaction
>[0]['txPrebuild'],
wallet: mockWallet,
});

result.should.equal(true);
});

it('should throw error when txParams.recipients is missing and no valid type', async function () {
const token = bitgo.coin('txdc:tmt') as XdcToken;
const mockWallet = {} as unknown as IWallet;
Expand Down
Loading