Skip to content

Commit 6c9d3f1

Browse files
committed
refactor(sdk-coin-eos): use token symbol while verifying transaction
Ticket: WIN-5533
1 parent 7ba7258 commit 6c9d3f1

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

modules/sdk-coin-eos/src/eos.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import { BigNumber } from 'bignumber.js';
55
import { bip32, BIP32Interface } from '@bitgo/secp256k1';
6+
import { coins, EosCoin } from '@bitgo/statics';
67
import { createHash, randomBytes } from 'crypto';
78
import { Api, ApiInterfaces, JsonRpc, RpcInterfaces } from 'eosjs';
89
import * as ecc from 'eosjs-ecc';
@@ -1123,7 +1124,7 @@ export class Eos extends BaseCoin {
11231124
}
11241125

11251126
if (txPrebuild.coin === 'eos' || txPrebuild.coin === 'teos') {
1126-
const expectedSymbol = _.isNil(txPrebuild.token) ? 'EOS' : txPrebuild.token.split(':')[1];
1127+
const expectedSymbol = _.isNil(txPrebuild.token) ? 'EOS' : (coins.get(txPrebuild.token) as EosCoin).symbol;
11271128

11281129
if (actualAmountAndCoin[1] !== expectedSymbol) {
11291130
throw new Error('txHex receive symbol does not match expected recipient symbol');

modules/sdk-coin-eos/test/unit/eosToken.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,36 @@ describe('EOS Token:', function () {
166166
.verifyTransaction({ txParams, txPrebuild, wallet, verification })
167167
.should.be.rejectedWith('txHex receive symbol does not match expected recipient symbol');
168168
});
169+
170+
it('should be able to verify vaulta transaction', async function () {
171+
const vaultaCoin = bitgo.coin('teos:VAULTA');
172+
const txParams = {
173+
recipients: [
174+
{
175+
address: 'lionteste212',
176+
amount: '1000',
177+
},
178+
],
179+
};
180+
const txPrebuild = {
181+
txHex:
182+
'5fff1dae8dc8e2fc4d5b23b2c7665c97f9e9d8edf2b6485a86ba311c25639191ee694868c24f71ef56f10000000100408c7a02ea3055000000000085269d000302323801004c8eda6ca02e45000000572d3ccdcd0170e5e73f5643715600000000a8ed32322170e5e73f5643715620825019ab3ca98be803000000000000044100000000000000000000000000000000000000000000000000000000000000000000000000000000',
183+
transaction: {
184+
packed_trx:
185+
'ee694868c24f71ef56f10000000100408c7a02ea3055000000000085269d000302323801004c8eda6ca02e45000000572d3ccdcd0170e5e73f5643715600000000a8ed32322170e5e73f5643715620825019ab3ca98be80300000000000004410000000000000000',
186+
signatures: [],
187+
compression: 'none',
188+
},
189+
token: 'teos:VAULTA',
190+
coin: 'teos',
191+
};
192+
const validTransaction = await vaultaCoin.verifyTransaction({
193+
txParams,
194+
txPrebuild,
195+
wallet,
196+
verification,
197+
});
198+
validTransaction.should.equal(true);
199+
});
169200
});
170201
});

0 commit comments

Comments
 (0)