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
6 changes: 5 additions & 1 deletion modules/sdk-coin-xrp/src/xrp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
36 changes: 36 additions & 0 deletions modules/sdk-coin-xrp/test/unit/xrp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Loading