Skip to content

Commit 24f4d1a

Browse files
committed
fix(xrp): verifyTransaction for token transfers
Ticket: WIN-3763
1 parent c5a1da8 commit 24f4d1a

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,11 @@ export class Xrp extends BaseCoin {
308308
return amount1.toFixed() === amount2.toFixed();
309309
};
310310

311-
if ((txParams.type === undefined || txParams.type === 'payment') && !comparator(output, expectedOutput)) {
311+
if (
312+
(txParams.type === undefined || txParams.type === 'payment') &&
313+
typeof output.amount !== 'object' &&
314+
!comparator(output, expectedOutput)
315+
) {
312316
throw new Error('transaction prebuild does not match expected output');
313317
}
314318

modules/sdk-coin-xrp/test/unit/xrp.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,42 @@ describe('XRP:', function () {
336336
validTransaction.should.equal(true);
337337
});
338338

339+
it('should verify token transfers', async function () {
340+
const txPrebuild = {
341+
txHex:
342+
'{"Account":"rsgg4mwHTGPRP7A4eGUmrpTxTeDZHQrHkQ","Fee":"45","Sequence":1760661,"Flags":2147483648,"TransactionType":"Payment","Destination":"raJ4NmhHr2j2SGkmVFeMqKR5MUSWXjNF9a","Amount":{"value":"0.01","currency":"524C555344000000000000000000000000000000","issuer":"rQhWct2fv4Vc4KRjRgMrxa8xPN9Zx9iLKV"},"DestinationTag":1}',
343+
txInfo: {
344+
Account: 'rsgg4mwHTGPRP7A4eGUmrpTxTeDZHQrHkQ',
345+
TransactionType: 'Payment',
346+
Destination: 'raJ4NmhHr2j2SGkmVFeMqKR5MUSWXjNF9a',
347+
Amount: {
348+
value: '0.01',
349+
currency: '524C555344000000000000000000000000000000',
350+
issuer: 'rQhWct2fv4Vc4KRjRgMrxa8xPN9Zx9iLKV',
351+
},
352+
DestinationTag: 1,
353+
},
354+
coin: 'txrp',
355+
token: 'txrp:rlusd',
356+
};
357+
358+
const txParams = {
359+
coin: 'txrp:rlusd',
360+
recipients: [
361+
{
362+
address: 'raJ4NmhHr2j2SGkmVFeMqKR5MUSWXjNF9a?dt=1',
363+
amount: '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
364+
},
365+
],
366+
};
367+
368+
const validTransaction = await token.verifyTransaction({
369+
txParams,
370+
txPrebuild,
371+
});
372+
validTransaction.should.equal(true);
373+
});
374+
339375
it('should fail verify trustline transaction with mismatch recipients', async function () {
340376
const txPrebuild = newTxPrebuild();
341377
const txParams = {

0 commit comments

Comments
 (0)