From e1d9de7b1fb372fae335472fde5c0d6b0c0f6844 Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Fri, 4 Dec 2015 15:18:03 -0800 Subject: [PATCH] Fix DeliverMin value when specifying minAmount --- src/ledger/transactions.js | 4 ++-- src/transaction/payment.js | 2 +- test/fixtures/responses/index.js | 4 ++-- ...t-xrp-xrp.json => prepare-payment-min-amount-xrp-xrp.json} | 0 ...min-amont-xrp.json => prepare-payment-min-amount-xrp.json} | 2 +- test/fixtures/responses/prepare-payment-min-amount.json | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename test/fixtures/responses/{prepare-payment-min-amont-xrp-xrp.json => prepare-payment-min-amount-xrp-xrp.json} (100%) rename test/fixtures/responses/{prepare-payment-min-amont-xrp.json => prepare-payment-min-amount-xrp.json} (81%) diff --git a/src/ledger/transactions.js b/src/ledger/transactions.js index 5ddc43a6..d9611005 100644 --- a/src/ledger/transactions.js +++ b/src/ledger/transactions.js @@ -170,11 +170,11 @@ function getTransactions(address: string, options: TransactionsOptions = {} const ledgerVersion = tx.outcome.ledgerVersion; const bound = options.earliestFirst ? {minLedgerVersion: ledgerVersion} : {maxLedgerVersion: ledgerVersion}; - const newOptions = _.assign(defaults, options, {startTx: tx}, bound); + const newOptions = _.assign({}, defaults, options, {startTx: tx}, bound); return getTransactionsInternal(this.connection, address, newOptions); }); } - const newOptions = _.assign(defaults, options); + const newOptions = _.assign({}, defaults, options); return getTransactionsInternal(this.connection, address, newOptions); } diff --git a/src/transaction/payment.js b/src/transaction/payment.js index 8b04b05c..f905c5a5 100644 --- a/src/transaction/payment.js +++ b/src/transaction/payment.js @@ -64,7 +64,7 @@ function createMaximalAmount(amount: Amount): Amount { const maxXRPValue = '100000000000'; const maxIOUValue = '9999999999999999e80'; const maxValue = amount.currency === 'XRP' ? maxXRPValue : maxIOUValue; - return _.assign(amount, {value: maxValue}); + return _.assign({}, amount, {value: maxValue}); } function createPaymentTransaction(address: string, paymentArgument: Payment diff --git a/test/fixtures/responses/index.js b/test/fixtures/responses/index.js index d9004049..c17e8751 100644 --- a/test/fixtures/responses/index.js +++ b/test/fixtures/responses/index.js @@ -71,8 +71,8 @@ module.exports = { }, preparePayment: { normal: require('./prepare-payment.json'), - minAmountXRP: require('./prepare-payment-min-amont-xrp.json'), - minAmountXRPXRP: require('./prepare-payment-min-amont-xrp-xrp.json'), + minAmountXRP: require('./prepare-payment-min-amount-xrp.json'), + minAmountXRPXRP: require('./prepare-payment-min-amount-xrp-xrp.json'), allOptions: require('./prepare-payment-all-options.json'), noCounterparty: require('./prepare-payment-no-counterparty.json'), minAmount: require('./prepare-payment-min-amount.json') diff --git a/test/fixtures/responses/prepare-payment-min-amont-xrp-xrp.json b/test/fixtures/responses/prepare-payment-min-amount-xrp-xrp.json similarity index 100% rename from test/fixtures/responses/prepare-payment-min-amont-xrp-xrp.json rename to test/fixtures/responses/prepare-payment-min-amount-xrp-xrp.json diff --git a/test/fixtures/responses/prepare-payment-min-amont-xrp.json b/test/fixtures/responses/prepare-payment-min-amount-xrp.json similarity index 81% rename from test/fixtures/responses/prepare-payment-min-amont-xrp.json rename to test/fixtures/responses/prepare-payment-min-amount-xrp.json index 84a0b068..8003192a 100644 --- a/test/fixtures/responses/prepare-payment-min-amont-xrp.json +++ b/test/fixtures/responses/prepare-payment-min-amount-xrp.json @@ -1,5 +1,5 @@ { - "txJSON": "{\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"100000000000000000\",\"Flags\":2147614720,\"SendMax\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"0.01\"},\"DeliverMin\":\"100000000000000000\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "txJSON": "{\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"100000000000000000\",\"Flags\":2147614720,\"SendMax\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"0.01\"},\"DeliverMin\":\"10000\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", "instructions": { "fee": "0.000012", "sequence": 23, diff --git a/test/fixtures/responses/prepare-payment-min-amount.json b/test/fixtures/responses/prepare-payment-min-amount.json index 1dd701af..75906ad1 100644 --- a/test/fixtures/responses/prepare-payment-min-amount.json +++ b/test/fixtures/responses/prepare-payment-min-amount.json @@ -1,5 +1,5 @@ { - "txJSON": "{\"Flags\":2147614720,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"ra5nK24KXen9AHvsdFTKHSANinZseWnPcX\",\"Amount\":{\"value\":\"9999999999999999e80\",\"currency\":\"USD\",\"issuer\":\"ra5nK24KXen9AHvsdFTKHSANinZseWnPcX\"},\"SendMax\":{\"value\":\"5\",\"currency\":\"USD\",\"issuer\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"},\"DeliverMin\":{\"value\":\"9999999999999999e80\",\"currency\":\"USD\",\"issuer\":\"ra5nK24KXen9AHvsdFTKHSANinZseWnPcX\"},\"Paths\":[[{\"account\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\"},{\"currency\":\"XRP\"},{\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\"},{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\"},{\"account\":\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\"}],[{\"account\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\"},{\"currency\":\"XRP\"},{\"issuer\":\"rfsEoNBUBbvkf4jPcFe2u9CyaQagLVHGfP\",\"currency\":\"USD\"},{\"account\":\"rfsEoNBUBbvkf4jPcFe2u9CyaQagLVHGfP\"},{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\"}]],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "txJSON": "{\"Flags\":2147614720,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"ra5nK24KXen9AHvsdFTKHSANinZseWnPcX\",\"Amount\":{\"value\":\"9999999999999999e80\",\"currency\":\"USD\",\"issuer\":\"ra5nK24KXen9AHvsdFTKHSANinZseWnPcX\"},\"SendMax\":{\"value\":\"5\",\"currency\":\"USD\",\"issuer\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"},\"DeliverMin\":{\"value\":\"4.93463759481038\",\"currency\":\"USD\",\"issuer\":\"ra5nK24KXen9AHvsdFTKHSANinZseWnPcX\"},\"Paths\":[[{\"account\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\"},{\"currency\":\"XRP\"},{\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\"},{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\"},{\"account\":\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\"}],[{\"account\":\"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B\"},{\"currency\":\"XRP\"},{\"issuer\":\"rfsEoNBUBbvkf4jPcFe2u9CyaQagLVHGfP\",\"currency\":\"USD\"},{\"account\":\"rfsEoNBUBbvkf4jPcFe2u9CyaQagLVHGfP\"},{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\"}]],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", "instructions": { "fee": "0.000012", "sequence": 23,