diff --git a/docs/index.md b/docs/index.md index 0bd378a3..a4c4bb0b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -546,16 +546,14 @@ memos | [memos](#transaction-memos) | *Optional* Array of memos to attach to the "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "maxAmount": { "value": "0.01", - "currency": "USD", - "counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" + "currency": "XRP" } }, "destination": { "address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", "amount": { "value": "0.01", - "currency": "USD", - "counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" + "currency": "XRP" } }, "allowCancelAfter": "2014-09-24T21:21:50.000Z" @@ -3171,16 +3169,14 @@ const escrowCreation = { "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "maxAmount": { "value": "0.01", - "currency": "USD", - "counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" + "currency": "XRP" } }, "destination": { "address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", "amount": { "value": "0.01", - "currency": "USD", - "counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" + "currency": "XRP" } }, "allowCancelAfter": "2014-09-24T21:21:50.000Z" @@ -3192,7 +3188,7 @@ return api.prepareEscrowCreation(address, escrowCreation).then(prepared => ```json { - "txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"CancelAfter\":464908910,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"CancelAfter\":464908910,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", "instructions": { "fee": "0.000012", "sequence": 23, diff --git a/src/transaction/escrow-creation.js b/src/transaction/escrow-creation.js index 911b524c..89a7b2fd 100644 --- a/src/transaction/escrow-creation.js +++ b/src/transaction/escrow-creation.js @@ -26,6 +26,9 @@ function createEscrowCreationTransaction(account: string, Amount: toRippledAmount(payment.destination.amount) } + if (txJSON.Amount.currency !== undefined) { + throw new ValidationError('"Amount" currency must be XRP') + } if (payment.condition !== undefined) { txJSON.Condition = payment.condition } diff --git a/test/api-test.js b/test/api-test.js index 97342c70..9b8df950 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -649,15 +649,6 @@ describe('RippleAPI', function() { 'getTransaction')); }); - it('getTransaction - EscrowCreation iou', function() { - const hash = - '144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE2'; - return this.api.getTransaction(hash).then( - _.partial(checkResult, - responses.getTransaction.EscrowCreationIOU, - 'getTransaction')); - }); - it('getTransaction - EscrowCancellation', function() { const hash = 'F346E542FFB7A8398C30A87B952668DAB48B7D421094F8B71776DA19775A3B22'; diff --git a/test/fixtures/requests/prepare-escrow-creation-full.json b/test/fixtures/requests/prepare-escrow-creation-full.json index 38553905..5039c6e1 100644 --- a/test/fixtures/requests/prepare-escrow-creation-full.json +++ b/test/fixtures/requests/prepare-escrow-creation-full.json @@ -3,8 +3,7 @@ "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "maxAmount": { "value": "0.01", - "currency": "USD", - "counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" + "currency": "XRP" }, "tag": 1 }, @@ -12,8 +11,7 @@ "address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", "amount": { "value": "0.01", - "currency": "USD", - "counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" + "currency": "XRP" }, "tag": 2 }, diff --git a/test/fixtures/requests/prepare-escrow-creation.json b/test/fixtures/requests/prepare-escrow-creation.json index 2d1ef8a3..7a6a611d 100644 --- a/test/fixtures/requests/prepare-escrow-creation.json +++ b/test/fixtures/requests/prepare-escrow-creation.json @@ -3,16 +3,14 @@ "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "maxAmount": { "value": "0.01", - "currency": "USD", - "counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" + "currency": "XRP" } }, "destination": { "address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", "amount": { "value": "0.01", - "currency": "USD", - "counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" + "currency": "XRP" } }, "allowCancelAfter": "2014-09-24T21:21:50.000Z" diff --git a/test/fixtures/responses/get-transaction-escrow-create-iou.json b/test/fixtures/responses/get-transaction-escrow-create-iou.json deleted file mode 100644 index cb6a4d63..00000000 --- a/test/fixtures/responses/get-transaction-escrow-create-iou.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "type": "escrowCreation", - "address": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "sequence": 10, - "id": "144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE2", - "specification": { - "source": { - "address": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "maxAmount": { - "currency": "USD", - "value": "2" - }, - "tag": 1 - }, - "destination": { - "address": "rp8rJYTpodf8qbSCHVTNacf8nSW8mRakFw", - "amount": { - "currency": "USD", - "value": "2", - "counterparty": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" - }, - "tag": 2 - }, - "memos": [ - { - "type": "x2", - "format": "text/plain", - "data": "mema data" - } - ], - "condition": "8F434346648F6B96DF89DDA901C5176B10A6D83961DD3C1AC88B59B2DC327AA4", - "allowCancelAfter": "2015-11-16T06:53:42.000Z", - "allowExecuteAfter": "2015-11-16T06:47:42.000Z" - }, - "outcome": { - "result": "tesSUCCESS", - "timestamp": "2015-11-16T06:43:00.000Z", - "fee": "0.000012", - "balanceChanges": { - "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh": [ - { - "currency": "XRP", - "value": "-0.000014" - } - ] - }, - "orderbookChanges": {}, - "ledgerVersion": 15, - "indexInLedger": 0 - } -} diff --git a/test/fixtures/responses/index.js b/test/fixtures/responses/index.js index a69dd998..d239d074 100644 --- a/test/fixtures/responses/index.js +++ b/test/fixtures/responses/index.js @@ -36,8 +36,6 @@ module.exports = { notValidated: require('./get-transaction-not-validated.json'), escrowCreation: require('./get-transaction-escrow-create.json'), - EscrowCreationIOU: - require('./get-transaction-escrow-create-iou.json'), escrowCancellation: require('./get-transaction-escrow-cancellation.json'), escrowExecution: diff --git a/test/fixtures/responses/prepare-escrow-creation-full.json b/test/fixtures/responses/prepare-escrow-creation-full.json index 034c7125..34e5f487 100644 --- a/test/fixtures/responses/prepare-escrow-creation-full.json +++ b/test/fixtures/responses/prepare-escrow-creation-full.json @@ -1,5 +1,5 @@ { - "txJSON": "{\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\",\"value\":\"0.01\"},\"Condition\":\"8F434346648F6B96DF89DDA901C5176B10A6D83961DD3C1AC88B59B2DC327AA4\",\"FinishAfter\":464908910,\"SourceTag\":1,\"DestinationTag\":2,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}", + "txJSON": "{\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"Condition\":\"8F434346648F6B96DF89DDA901C5176B10A6D83961DD3C1AC88B59B2DC327AA4\",\"FinishAfter\":464908910,\"SourceTag\":1,\"DestinationTag\":2,\"Memos\":[{\"Memo\":{\"MemoData\":\"7465787465642064617461\",\"MemoType\":\"74657374\"}}],\"Flags\":2147483648,\"LastLedgerSequence\":8819954,\"Fee\":\"12\",\"Sequence\":23}", "instructions": { "fee": "0.000012", "sequence": 23, diff --git a/test/fixtures/responses/prepare-escrow-creation.json b/test/fixtures/responses/prepare-escrow-creation.json index 24afa21d..debc9c9f 100644 --- a/test/fixtures/responses/prepare-escrow-creation.json +++ b/test/fixtures/responses/prepare-escrow-creation.json @@ -1,5 +1,5 @@ { - "txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"CancelAfter\":464908910,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "txJSON": "{\"Flags\":2147483648,\"TransactionType\":\"EscrowCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"CancelAfter\":464908910,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", "instructions": { "fee": "0.000012", "sequence": 23, diff --git a/test/fixtures/rippled/index.js b/test/fixtures/rippled/index.js index 77c086f0..a8f78b13 100644 --- a/test/fixtures/rippled/index.js +++ b/test/fixtures/rippled/index.js @@ -65,8 +65,6 @@ module.exports = { NotValidated: require('./tx/not-validated.json'), OfferWithExpiration: require('./tx/order-with-expiration.json'), EscrowCreation: require('./tx/escrow-creation.json'), - EscrowCreationIOU: - require('./tx/escrow-creation-iou.json'), EscrowCancellation: require('./tx/escrow-cancellation.json'), EscrowExecution: require('./tx/escrow-execution.json'), diff --git a/test/mock-rippled.js b/test/mock-rippled.js index 8d8de3ca..570fe67d 100644 --- a/test/mock-rippled.js +++ b/test/mock-rippled.js @@ -274,9 +274,6 @@ module.exports = function createMockRippled(port) { } else if (request.transaction === '144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE1') { conn.send(createResponse(request, fixtures.tx.EscrowCreation)); - } else if (request.transaction === - '144F272380BDB4F1BD92329A2178BABB70C20F59042C495E10BF72EBFB408EE2') { - conn.send(createResponse(request, fixtures.tx.EscrowCreationIOU)); } else if (request.transaction === 'F346E542FFB7A8398C30A87B952668DAB48B7D421094F8B71776DA19775A3B22') { conn.send(createResponse(request, fixtures.tx.EscrowCancellation));