diff --git a/modules/sdk-coin-xrp/src/xrp.ts b/modules/sdk-coin-xrp/src/xrp.ts index 15af5ed1fb..70dcfd9466 100644 --- a/modules/sdk-coin-xrp/src/xrp.ts +++ b/modules/sdk-coin-xrp/src/xrp.ts @@ -308,7 +308,11 @@ export class Xrp extends BaseCoin { return amount1.toFixed() === amount2.toFixed(); }; - if ((txParams.type === undefined || txParams.type === 'payment') && !comparator(output, expectedOutput)) { + if ( + (txParams.type === undefined || txParams.type === 'payment') && + typeof output.amount !== 'object' && + !comparator(output, expectedOutput) + ) { throw new Error('transaction prebuild does not match expected output'); } diff --git a/modules/sdk-coin-xrp/test/unit/xrp.ts b/modules/sdk-coin-xrp/test/unit/xrp.ts index c3136f7dac..42cc8c1c70 100644 --- a/modules/sdk-coin-xrp/test/unit/xrp.ts +++ b/modules/sdk-coin-xrp/test/unit/xrp.ts @@ -336,6 +336,42 @@ describe('XRP:', function () { validTransaction.should.equal(true); }); + it('should verify token transfers', async function () { + const txPrebuild = { + txHex: + '{"Account":"rsgg4mwHTGPRP7A4eGUmrpTxTeDZHQrHkQ","Fee":"45","Sequence":1760661,"Flags":2147483648,"TransactionType":"Payment","Destination":"raJ4NmhHr2j2SGkmVFeMqKR5MUSWXjNF9a","Amount":{"value":"0.01","currency":"524C555344000000000000000000000000000000","issuer":"rQhWct2fv4Vc4KRjRgMrxa8xPN9Zx9iLKV"},"DestinationTag":1}', + txInfo: { + Account: 'rsgg4mwHTGPRP7A4eGUmrpTxTeDZHQrHkQ', + TransactionType: 'Payment', + Destination: 'raJ4NmhHr2j2SGkmVFeMqKR5MUSWXjNF9a', + Amount: { + value: '0.01', + currency: '524C555344000000000000000000000000000000', + issuer: 'rQhWct2fv4Vc4KRjRgMrxa8xPN9Zx9iLKV', + }, + DestinationTag: 1, + }, + coin: 'txrp', + token: 'txrp:rlusd', + }; + + const txParams = { + coin: 'txrp:rlusd', + recipients: [ + { + address: 'raJ4NmhHr2j2SGkmVFeMqKR5MUSWXjNF9a?dt=1', + amount: '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + }, + ], + }; + + const validTransaction = await token.verifyTransaction({ + txParams, + txPrebuild, + }); + validTransaction.should.equal(true); + }); + it('should fail verify trustline transaction with mismatch recipients', async function () { const txPrebuild = newTxPrebuild(); const txParams = {