Skip to content

Commit 40c7597

Browse files
committed
fix(sdk-coin-stx): fix issue in verifyTx for sip10 tokens
COIN-3616 TICKET: COIN-3616
1 parent 533984e commit 40c7597

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

modules/sdk-coin-stx/src/sip10Token.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import _ from 'lodash';
22
import BigNumber from 'bignumber.js';
33

4-
import { BitGoBase, CoinConstructor, Memo, NamedCoinConstructor, VerifyTransactionOptions } from '@bitgo/sdk-core';
4+
import { BitGoBase, CoinConstructor, NamedCoinConstructor, VerifyTransactionOptions } from '@bitgo/sdk-core';
55
import { BaseCoin as StaticsBaseCoin, coins, NetworkType, Sip10TokenConfig, tokens } from '@bitgo/statics';
66

77
import { Stx } from './stx';
88
import { TransactionBuilderFactory } from './lib';
99
import { TransactionBuilder } from './lib/transactionBuilder';
1010
import { getMemoIdAndBaseAddressFromAddress } from './lib/utils';
1111

12-
export interface Sip10VerifyTransactionOptions extends VerifyTransactionOptions {
13-
memo?: Memo;
14-
}
15-
1612
export class Sip10Token extends Stx {
1713
public readonly tokenConfig: Sip10TokenConfig;
1814

@@ -77,8 +73,9 @@ export class Sip10Token extends Stx {
7773
return new TransactionBuilderFactory(coinConfig).getFungibleTokenTransferBuilder();
7874
}
7975

80-
async verifyTransaction(params: Sip10VerifyTransactionOptions): Promise<boolean> {
81-
const { txPrebuild: txPrebuild, txParams: txParams, memo: memo } = params;
76+
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
77+
const { txPrebuild: txPrebuild, txParams: txParams } = params;
78+
const { memo } = txParams;
8279
if (Array.isArray(txParams.recipients) && txParams.recipients.length > 1) {
8380
throw new Error(
8481
`${this.getChain()} doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`

modules/sdk-coin-stx/test/unit/sip10Token.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'lodash';
22
import { BitGoAPI } from '@bitgo/sdk-api';
33
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
4-
import { ITransactionRecipient, Wallet } from '@bitgo/sdk-core';
4+
import { ITransactionRecipient, Wallet, Memo } from '@bitgo/sdk-core';
55

66
import { Sip10Token } from '../../src';
77
import * as testData from '../fixtures';
@@ -11,7 +11,7 @@ describe('Sip10Token:', function () {
1111
let bitgo: TestBitGoAPI;
1212
let basecoin: Sip10Token;
1313
let newTxPrebuild: () => { txHex: string; txInfo: Record<string, unknown> };
14-
let newTxParams: () => { recipients: ITransactionRecipient[] };
14+
let newTxParams: () => { recipients: ITransactionRecipient[]; memo?: Memo };
1515
let wallet: Wallet;
1616

1717
const txPreBuild = {
@@ -50,13 +50,13 @@ describe('Sip10Token:', function () {
5050
it('should succeed to verify transaction', async function () {
5151
const txPrebuild = newTxPrebuild();
5252
const txParams = newTxParams();
53+
txParams.memo = memo;
5354
const verification = {};
5455
const isTransactionVerified = await basecoin.verifyTransaction({
5556
txParams,
5657
txPrebuild,
5758
verification,
5859
wallet,
59-
memo,
6060
});
6161
isTransactionVerified.should.equal(true);
6262
});
@@ -69,13 +69,14 @@ describe('Sip10Token:', function () {
6969
return { address, amount: Number(amount), memo, tokenName };
7070
}
7171
);
72+
txParamsWithNumberAmounts.memo = memo;
73+
7274
const verification = {};
7375
const isTransactionVerified = await basecoin.verifyTransaction({
7476
txParams: txParamsWithNumberAmounts,
7577
txPrebuild,
7678
verification,
7779
wallet,
78-
memo,
7980
});
8081
isTransactionVerified.should.equal(true);
8182
});
@@ -85,7 +86,7 @@ describe('Sip10Token:', function () {
8586
txPrebuild.txHex = testData.txForExplainFungibleTokenTransferWithMemoId10;
8687
const txParams = newTxParams();
8788
const verification = {};
88-
const memo = {
89+
txParams.memo = {
8990
type: '',
9091
value: '10',
9192
};
@@ -94,7 +95,6 @@ describe('Sip10Token:', function () {
9495
txPrebuild,
9596
verification,
9697
wallet,
97-
memo,
9898
});
9999
isTransactionVerified.should.equal(true);
100100
});
@@ -103,7 +103,7 @@ describe('Sip10Token:', function () {
103103
const txPrebuild = newTxPrebuild();
104104
const txParams = newTxParams();
105105
txPrebuild.txHex = testData.txForExplainFungibleTokenTransferWithMemoZero;
106-
const memo = {
106+
txParams.memo = {
107107
type: '',
108108
value: '0',
109109
};
@@ -113,7 +113,6 @@ describe('Sip10Token:', function () {
113113
txPrebuild,
114114
verification,
115115
wallet,
116-
memo,
117116
});
118117
isTransactionVerified.should.equal(true);
119118
});

modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IPendingApprovals } from '../pendingApproval';
88
import { InitiateRecoveryOptions } from '../recovery';
99
import { EcdsaMPCv2Utils, EcdsaUtils } from '../utils/tss/ecdsa';
1010
import EddsaUtils, { PrebuildTransactionWithIntentOptions, TxRequest } from '../utils/tss/eddsa';
11-
import { CreateAddressFormat, CustomSigningFunction, IWallet, IWallets, Wallet, WalletData } from '../wallet';
11+
import { CreateAddressFormat, CustomSigningFunction, IWallet, IWallets, Wallet, WalletData, Memo } from '../wallet';
1212

1313
import { IWebhooks } from '../webhook/iWebhooks';
1414
import { TransactionType } from '../../account-lib';
@@ -136,6 +136,7 @@ export interface TransactionParams {
136136
recipients?: ITransactionRecipient[];
137137
walletPassphrase?: string;
138138
type?: string;
139+
memo?: Memo;
139140
}
140141

141142
export interface AddressVerificationData {

0 commit comments

Comments
 (0)