From b88e9370c6d2fcd9e94c9fc97ddc9b9cd63caf6c Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Fri, 28 Aug 2015 13:21:49 -0700 Subject: [PATCH] Return instructions in prepare responses --- npm-shrinkwrap.json | 16 ++--- package.json | 2 +- src/api/common/schemas/prepare.json | 21 +++++++ src/api/transaction/order.js | 4 +- src/api/transaction/ordercancellation.js | 8 ++- src/api/transaction/payment.js | 4 +- src/api/transaction/settings.js | 4 +- src/api/transaction/sign.js | 16 ++--- src/api/transaction/trustline.js | 5 +- src/api/transaction/utils.js | 33 ++++++++--- test/api-test.js | 40 +++++++------ test/fixtures/api/requests/sign.json | 13 ++--- .../responses/prepare-order-cancellation.json | 13 ++--- .../api/responses/prepare-order-sell.json | 20 +++---- .../fixtures/api/responses/prepare-order.json | 18 ++---- .../prepare-payment-all-options.json | 26 ++------- .../prepare-payment-no-counterparty.json | 58 +++---------------- .../api/responses/prepare-payment.json | 23 ++------ .../prepare-settings-field-clear.json | 15 +++-- .../prepare-settings-flag-clear.json | 13 ++--- .../responses/prepare-settings-flag-set.json | 13 ++--- .../prepare-settings-regular-key.json | 13 ++--- .../prepare-settings-set-transfer-rate.json | 15 +++-- .../api/responses/prepare-settings.json | 14 ++--- .../responses/prepare-trustline-simple.json | 17 ++---- .../api/responses/prepare-trustline.json | 19 ++---- 26 files changed, 191 insertions(+), 252 deletions(-) create mode 100644 src/api/common/schemas/prepare.json diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 5b2c5323..9e804ccd 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -13,8 +13,8 @@ "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.20.tgz", "dependencies": { "core-js": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.0.1.tgz" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.1.2.tgz" } } }, @@ -23,8 +23,8 @@ "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.0.7.tgz" }, "bn.js": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.1.1.tgz" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.1.2.tgz" }, "es6-promisify": { "version": "2.0.0", @@ -81,8 +81,8 @@ } }, "is-my-json-valid": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.1.tgz", + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.2.tgz", "dependencies": { "generate-function": { "version": "2.0.0", @@ -99,8 +99,8 @@ } }, "jsonpointer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-1.1.0.tgz" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz" }, "xtend": { "version": "4.0.0", diff --git a/package.json b/package.json index d1b0caf4..d8d256a0 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "babel-eslint": "^4.0.5", "babel-loader": "^5.3.2", "coveralls": "~2.10.0", - "eslint": "^1.2.0", + "eslint": "^1.3.0", "eslint-plugin-flowtype": "^1.0.0", "eventemitter2": "^0.4.14", "flow-bin": "^0.14", diff --git a/src/api/common/schemas/prepare.json b/src/api/common/schemas/prepare.json new file mode 100644 index 00000000..7f681fc4 --- /dev/null +++ b/src/api/common/schemas/prepare.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "prepare", + "description": "Result of prepare function", + "type": "object", + "properties": { + "txJSON": {"type": "string"}, + "instructions": { + "type": "object", + "properties": { + "fee": {"$ref": "value"}, + "sequence": {"$ref": "sequence"}, + "maxLedgerVersion": {"$ref": "ledgerVersion"} + }, + "additionalProperties": false, + "required": ["fee", "sequence"] + } + }, + "additionalProperties": false, + "required": ["txJSON", "instructions"] +} diff --git a/src/api/transaction/order.js b/src/api/transaction/order.js index aac4ca72..fbe22055 100644 --- a/src/api/transaction/order.js +++ b/src/api/transaction/order.js @@ -32,10 +32,10 @@ function createOrderTransaction(account, order) { function prepareOrderAsync(account, order, instructions, callback) { const transaction = createOrderTransaction(account, order); - utils.createTxJSON(transaction, this.remote, instructions, callback); + utils.prepareTransaction(transaction, this.remote, instructions, callback); } -function prepareOrder(account: string, order: Object, instructions={}) { +function prepareOrder(account: string, order: Object, instructions = {}) { return utils.promisify(prepareOrderAsync.bind(this))( account, order, instructions); } diff --git a/src/api/transaction/ordercancellation.js b/src/api/transaction/ordercancellation.js index 77a81592..63ddd42e 100644 --- a/src/api/transaction/ordercancellation.js +++ b/src/api/transaction/ordercancellation.js @@ -14,13 +14,15 @@ function createOrderCancellationTransaction(account, sequence) { } function prepareOrderCancellationAsync(account, sequence, instructions, - callback) { + callback +) { const transaction = createOrderCancellationTransaction(account, sequence); - utils.createTxJSON(transaction, this.remote, instructions, callback); + utils.prepareTransaction(transaction, this.remote, instructions, callback); } function prepareOrderCancellation(account: string, sequence: number, - instructions={}) { + instructions = {} +) { return utils.promisify(prepareOrderCancellationAsync.bind(this))( account, sequence, instructions); } diff --git a/src/api/transaction/payment.js b/src/api/transaction/payment.js index 4b8594a2..123f09ed 100644 --- a/src/api/transaction/payment.js +++ b/src/api/transaction/payment.js @@ -83,10 +83,10 @@ function createPaymentTransaction(account, payment) { function preparePaymentAsync(account, payment, instructions, callback) { const transaction = createPaymentTransaction(account, payment); - utils.createTxJSON(transaction, this.remote, instructions, callback); + utils.prepareTransaction(transaction, this.remote, instructions, callback); } -function preparePayment(account: string, payment: Object, instructions={}) { +function preparePayment(account: string, payment: Object, instructions = {}) { return utils.promisify(preparePaymentAsync.bind(this))( account, payment, instructions); } diff --git a/src/api/transaction/settings.js b/src/api/transaction/settings.js index f5fee470..d5e765d4 100644 --- a/src/api/transaction/settings.js +++ b/src/api/transaction/settings.js @@ -92,10 +92,10 @@ function createSettingsTransaction(account, settings) { function prepareSettingsAsync(account, settings, instructions, callback) { const transaction = createSettingsTransaction(account, settings); - utils.createTxJSON(transaction, this.remote, instructions, callback); + utils.prepareTransaction(transaction, this.remote, instructions, callback); } -function prepareSettings(account: string, settings: Object, instructions={}) { +function prepareSettings(account: string, settings: Object, instructions = {}) { return utils.promisify(prepareSettingsAsync.bind(this))( account, settings, instructions); } diff --git a/src/api/transaction/sign.js b/src/api/transaction/sign.js index a0202662..23df9efb 100644 --- a/src/api/transaction/sign.js +++ b/src/api/transaction/sign.js @@ -40,18 +40,18 @@ function computeSignature(txJSON, keypair) { return keypair.signHex(signingData(txJSON)); } -function sign(txJSON: {Account: string; SigningPubKey: string, - TxnSignature: string}, secret: string): - {signedTransaction: string; id: string} { - validate.txJSON(txJSON); +function sign(txJSON: string, secret: string +): {signedTransaction: string; id: string} { + const tx = JSON.parse(txJSON); + validate.txJSON(tx); validate.secret(secret); const keypair = getKeyPair(secret); - if (txJSON.SigningPubKey === undefined) { - txJSON.SigningPubKey = getPublicKeyHex(keypair); + if (tx.SigningPubKey === undefined) { + tx.SigningPubKey = getPublicKeyHex(keypair); } - txJSON.TxnSignature = computeSignature(txJSON, keypair); - const serialized = serialize(txJSON); + tx.TxnSignature = computeSignature(tx, keypair); + const serialized = serialize(tx); return { signedTransaction: serialized.to_hex(), id: hashSerialization(serialized, HASH_TX_ID) diff --git a/src/api/transaction/trustline.js b/src/api/transaction/trustline.js index 2e6e2ca7..4d1bf01e 100644 --- a/src/api/transaction/trustline.js +++ b/src/api/transaction/trustline.js @@ -35,10 +35,11 @@ function createTrustlineTransaction(account, trustline) { function prepareTrustlineAsync(account, trustline, instructions, callback) { const transaction = createTrustlineTransaction(account, trustline); - utils.createTxJSON(transaction, this.remote, instructions, callback); + utils.prepareTransaction(transaction, this.remote, instructions, callback); } -function prepareTrustline(account: string, trustline: Object, instructions={}) { +function prepareTrustline(account: string, trustline: Object, instructions = {} +) { return utils.promisify(prepareTrustlineAsync.bind(this))( account, trustline, instructions); } diff --git a/src/api/transaction/utils.js b/src/api/transaction/utils.js index 20e844e9..a72b72fb 100644 --- a/src/api/transaction/utils.js +++ b/src/api/transaction/utils.js @@ -1,10 +1,11 @@ /* @flow */ 'use strict'; +const _ = require('lodash'); const BigNumber = require('bignumber.js'); const common = require('../common'); -function setTransactionBitFlags(transaction: any, values: any, flags: any): - void { +function setTransactionBitFlags(transaction: any, values: any, flags: any +): void { for (const flagName in flags) { const flagValue = values[flagName]; const flagConversions = flags[flagName]; @@ -23,8 +24,22 @@ function getFeeDrops(remote) { return remote.feeTx(feeUnits).to_text(); } -function createTxJSON(transaction: any, remote: any, instructions: any, - callback: (err: ?(typeof Error), data: {tx_json: any}) => void): void { +function formatPrepareResponse(txJSON) { + const instructions = { + fee: txJSON.Fee, + sequence: txJSON.Sequence, + maxLedgerVersion: txJSON.LastLedgerSequence + }; + return { + txJSON: JSON.stringify(txJSON), + instructions: _.omit(instructions, _.isUndefined) + }; +} + +type Callback = (err: ?(typeof Error), + data: {txJSON: string, instructions: any}) => void; +function prepareTransaction(transaction: any, remote: any, instructions: any, + callback: Callback): void { common.validate.instructions(instructions); transaction.complete(); @@ -53,18 +68,18 @@ function createTxJSON(transaction: any, remote: any, instructions: any, if (instructions.sequence !== undefined) { txJSON.Sequence = parseInt(instructions.sequence, 10); - callback(null, txJSON); + callback(null, formatPrepareResponse(txJSON)); } else { remote.findAccount(account).getNextSequence(function(error, sequence) { txJSON.Sequence = sequence; - callback(null, txJSON); + callback(error, formatPrepareResponse(txJSON)); }); } } module.exports = { - setTransactionBitFlags: setTransactionBitFlags, - createTxJSON: createTxJSON, - common: common, + setTransactionBitFlags, + prepareTransaction, + common, promisify: common.promisify }; diff --git a/test/api-test.js b/test/api-test.js index 2635ab9f..c7548acd 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -48,7 +48,7 @@ describe('RippleAPI', function() { }, instructions); return this.api.preparePayment( address, requests.preparePayment, localInstructions).then( - _.partial(checkResult, responses.preparePayment, 'tx')); + _.partial(checkResult, responses.preparePayment, 'prepare')); }); it('preparePayment with all options specified', function() { @@ -58,72 +58,73 @@ describe('RippleAPI', function() { }; return this.api.preparePayment( address, requests.preparePaymentAllOptions, localInstructions).then( - _.partial(checkResult, responses.preparePaymentAllOptions, 'tx')); + _.partial(checkResult, responses.preparePaymentAllOptions, 'prepare')); }); it('preparePayment without counterparty set', function() { const localInstructions = _.defaults({sequence: 23}, instructions); return this.api.preparePayment( address, requests.preparePaymentNoCounterparty, localInstructions).then( - _.partial(checkResult, responses.preparePaymentNoCounterparty, 'tx')); + _.partial(checkResult, responses.preparePaymentNoCounterparty, + 'prepare')); }); it('prepareOrder - buy order', function() { return this.api.prepareOrder(address, requests.prepareOrder, instructions) - .then(_.partial(checkResult, responses.prepareOrder, 'tx')); + .then(_.partial(checkResult, responses.prepareOrder, 'prepare')); }); it('prepareOrder - sell order', function() { return this.api.prepareOrder( address, requests.prepareOrderSell, instructions).then( - _.partial(checkResult, responses.prepareOrderSell, 'tx')); + _.partial(checkResult, responses.prepareOrderSell, 'prepare')); }); it('prepareOrderCancellation', function() { return this.api.prepareOrderCancellation(address, 23, instructions).then( - _.partial(checkResult, responses.prepareOrderCancellation, 'tx')); + _.partial(checkResult, responses.prepareOrderCancellation, 'prepare')); }); it('prepareTrustline - simple', function() { return this.api.prepareTrustline( address, requests.prepareTrustline.simple, instructions).then( - _.partial(checkResult, responses.prepareTrustline.simple, 'tx')); + _.partial(checkResult, responses.prepareTrustline.simple, 'prepare')); }); it('prepareTrustline - complex', function() { return this.api.prepareTrustline( address, requests.prepareTrustline.complex, instructions).then( - _.partial(checkResult, responses.prepareTrustline.complex, 'tx')); + _.partial(checkResult, responses.prepareTrustline.complex, 'prepare')); }); it('prepareSettings', function() { return this.api.prepareSettings( address, requests.prepareSettings, instructions).then( - _.partial(checkResult, responses.prepareSettings.flags, 'tx')); + _.partial(checkResult, responses.prepareSettings.flags, 'prepare')); }); it('prepareSettings - regularKey', function() { const regularKey = {regularKey: 'rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD'}; return this.api.prepareSettings(address, regularKey, instructions).then( - _.partial(checkResult, responses.prepareSettings.regularKey, 'tx')); + _.partial(checkResult, responses.prepareSettings.regularKey, 'prepare')); }); it('prepareSettings - flag set', function() { const settings = {requireDestinationTag: true}; return this.api.prepareSettings(address, settings, instructions).then( - _.partial(checkResult, responses.prepareSettings.flagSet, 'tx')); + _.partial(checkResult, responses.prepareSettings.flagSet, 'prepare')); }); it('prepareSettings - flag clear', function() { const settings = {requireDestinationTag: false}; return this.api.prepareSettings(address, settings, instructions).then( - _.partial(checkResult, responses.prepareSettings.flagClear, 'tx')); + _.partial(checkResult, responses.prepareSettings.flagClear, 'prepare')); }); it('prepareSettings - string field clear', function() { const settings = {walletLocator: null}; return this.api.prepareSettings(address, settings, instructions).then( - _.partial(checkResult, responses.prepareSettings.fieldClear, 'tx')); + _.partial(checkResult, responses.prepareSettings.fieldClear, 'prepare')); }); it('prepareSettings - integer field clear', function() { @@ -131,19 +132,20 @@ describe('RippleAPI', function() { return this.api.prepareSettings(address, settings, instructions) .then(data => { assert(data); - assert.strictEqual(data.WalletSize, 0); + assert.strictEqual(JSON.parse(data.txJSON).WalletSize, 0); }); }); it('prepareSettings - set transferRate', function() { const settings = {transferRate: 1}; return this.api.prepareSettings(address, settings, instructions).then( - _.partial(checkResult, responses.prepareSettings.setTransferRate, 'tx')); + _.partial(checkResult, responses.prepareSettings.setTransferRate, + 'prepare')); }); it('sign', function() { const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'; - const result = this.api.sign(requests.sign, secret); + const result = this.api.sign(requests.sign.txJSON, secret); assert.deepEqual(result, responses.sign); schemaValidator.schemaValidate('sign', result); }); @@ -775,9 +777,9 @@ describe('RippleAPI - offline', function() { maxLedgerVersion: 8820051, fee: '0.000012' }; - return api.prepareSettings(address, settings, instructions).then(txJSON => { - assert.deepEqual(txJSON, responses.prepareSettings.flags); - assert.deepEqual(api.sign(txJSON, secret), responses.sign); + return api.prepareSettings(address, settings, instructions).then(data => { + assert.deepEqual(data, responses.prepareSettings.flags); + assert.deepEqual(api.sign(data.txJSON, secret), responses.sign); }); }); diff --git a/test/fixtures/api/requests/sign.json b/test/fixtures/api/requests/sign.json index 7226e3c9..f2d27b6d 100644 --- a/test/fixtures/api/requests/sign.json +++ b/test/fixtures/api/requests/sign.json @@ -1,9 +1,8 @@ { - "Flags": 0, - "TransactionType": "AccountSet", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "Domain": "726970706C652E636F6D", - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Domain\":\"726970706C652E636F6D\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-order-cancellation.json b/test/fixtures/api/responses/prepare-order-cancellation.json index 49940b9f..6b0d6fbe 100644 --- a/test/fixtures/api/responses/prepare-order-cancellation.json +++ b/test/fixtures/api/responses/prepare-order-cancellation.json @@ -1,9 +1,8 @@ { - "Flags": 0, - "TransactionType": "OfferCancel", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "OfferSequence": 23, - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":0,\"TransactionType\":\"OfferCancel\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":23,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-order-sell.json b/test/fixtures/api/responses/prepare-order-sell.json index adac6d4a..f1ce1da0 100644 --- a/test/fixtures/api/responses/prepare-order-sell.json +++ b/test/fixtures/api/responses/prepare-order-sell.json @@ -1,14 +1,8 @@ { - "Flags": 655360, - "TransactionType": "OfferCreate", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "TakerGets": { - "value": "10.1", - "currency": "USD", - "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" - }, - "TakerPays": "2000000", - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 -} \ No newline at end of file + "txJSON": "{\"Flags\":655360,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"TakerPays\":\"2000000\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } +} diff --git a/test/fixtures/api/responses/prepare-order.json b/test/fixtures/api/responses/prepare-order.json index ffe3f6a4..862ca51e 100644 --- a/test/fixtures/api/responses/prepare-order.json +++ b/test/fixtures/api/responses/prepare-order.json @@ -1,14 +1,8 @@ { - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "Fee": "12", - "Flags": 131072, - "LastLedgerSequence": 8820051, - "Sequence": 23, - "TakerGets": "2000000", - "TakerPays": { - "currency": "USD", - "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM", - "value": "10.1" - }, - "TransactionType": "OfferCreate" + "txJSON": "{\"Flags\":131072,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-payment-all-options.json b/test/fixtures/api/responses/prepare-payment-all-options.json index 89df281b..8fa93a15 100644 --- a/test/fixtures/api/responses/prepare-payment-all-options.json +++ b/test/fixtures/api/responses/prepare-payment-all-options.json @@ -1,22 +1,8 @@ { - "Flags": 458752, - "TransactionType": "Payment", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", - "Amount": "10000", - "InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A", - "SourceTag": 14, - "DestinationTag": 58, - "Memos": [ - { - "Memo": { - "MemoType": "74657374", - "MemoFormat": "706C61696E2F74657874", - "MemoData": "7465787465642064617461" - } - } - ], - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":458752,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\",\"MemoData\":\"7465787465642064617461\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-payment-no-counterparty.json b/test/fixtures/api/responses/prepare-payment-no-counterparty.json index 4f43f731..67f893d0 100644 --- a/test/fixtures/api/responses/prepare-payment-no-counterparty.json +++ b/test/fixtures/api/responses/prepare-payment-no-counterparty.json @@ -1,52 +1,8 @@ { - "Flags": 458752, - "TransactionType": "Payment", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", - "Amount": { - "value": "0.01", - "currency": "LTC", - "issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo" - }, - "InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A", - "SourceTag": 14, - "DestinationTag": 58, - "Paths": [ - [ - { - "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", - "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", - "currency": "USD", - "type_hex": "0000000000000031" - }, - { - "issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX", - "currency": "LTC", - "type_hex": "0000000000000030" - }, - { - "account": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX", - "issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX", - "currency": "LTC", - "type_hex": "0000000000000031" - } - ] - ], - "Memos": [ - { - "Memo": { - "MemoType": "74657374", - "MemoFormat": "706C61696E2F74657874", - "MemoData": "7465787465642064617461" - } - } - ], - "SendMax": { - "value": "0.01", - "currency": "USD", - "issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59" - }, - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 -} \ No newline at end of file + "txJSON": "{\"Flags\":458752,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"LTC\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\",\"MemoData\":\"7465787465642064617461\"}}],\"SendMax\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"},\"Paths\":[[{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\",\"type_hex\":\"0000000000000031\"},{\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\",\"type_hex\":\"0000000000000030\"},{\"account\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\",\"type_hex\":\"0000000000000031\"}]],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } +} diff --git a/test/fixtures/api/responses/prepare-payment.json b/test/fixtures/api/responses/prepare-payment.json index dbb748f9..59eeb2ac 100644 --- a/test/fixtures/api/responses/prepare-payment.json +++ b/test/fixtures/api/responses/prepare-payment.json @@ -1,19 +1,8 @@ { - "Flags": 0, - "TransactionType": "Payment", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", - "Amount": { - "value": "0.01", - "currency": "USD", - "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" - }, - "LastLedgerSequence": 8820051, - "SendMax": { - "currency": "USD", - "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM", - "value": "0.01" - }, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":0,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"SendMax\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-settings-field-clear.json b/test/fixtures/api/responses/prepare-settings-field-clear.json index f5c18c9f..11f3a545 100644 --- a/test/fixtures/api/responses/prepare-settings-field-clear.json +++ b/test/fixtures/api/responses/prepare-settings-field-clear.json @@ -1,9 +1,8 @@ { - "Flags": 0, - "TransactionType": "AccountSet", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "WalletLocator": "0", - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 -} \ No newline at end of file + "txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"WalletLocator\":\"0\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } +} diff --git a/test/fixtures/api/responses/prepare-settings-flag-clear.json b/test/fixtures/api/responses/prepare-settings-flag-clear.json index e605a1b7..617b5f42 100644 --- a/test/fixtures/api/responses/prepare-settings-flag-clear.json +++ b/test/fixtures/api/responses/prepare-settings-flag-clear.json @@ -1,9 +1,8 @@ { - "Flags": 0, - "TransactionType": "AccountSet", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "ClearFlag": 1, - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"ClearFlag\":1,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-settings-flag-set.json b/test/fixtures/api/responses/prepare-settings-flag-set.json index 3fc10774..61f2451a 100644 --- a/test/fixtures/api/responses/prepare-settings-flag-set.json +++ b/test/fixtures/api/responses/prepare-settings-flag-set.json @@ -1,9 +1,8 @@ { - "Flags": 0, - "TransactionType": "AccountSet", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "SetFlag": 1, - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"SetFlag\":1,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-settings-regular-key.json b/test/fixtures/api/responses/prepare-settings-regular-key.json index 6a1b4ce6..c83c92f1 100644 --- a/test/fixtures/api/responses/prepare-settings-regular-key.json +++ b/test/fixtures/api/responses/prepare-settings-regular-key.json @@ -1,9 +1,8 @@ { - "Flags": 0, - "TransactionType": "SetRegularKey", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "RegularKey": "rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD", - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":0,\"TransactionType\":\"SetRegularKey\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"RegularKey\":\"rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-settings-set-transfer-rate.json b/test/fixtures/api/responses/prepare-settings-set-transfer-rate.json index 1c6cb831..d9d6393f 100644 --- a/test/fixtures/api/responses/prepare-settings-set-transfer-rate.json +++ b/test/fixtures/api/responses/prepare-settings-set-transfer-rate.json @@ -1,9 +1,8 @@ { - "Flags": 0, - "TransactionType": "AccountSet", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "TransferRate": 1000000000, - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 -} \ No newline at end of file + "txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TransferRate\":1000000000,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } +} diff --git a/test/fixtures/api/responses/prepare-settings.json b/test/fixtures/api/responses/prepare-settings.json index 97949b71..f2d27b6d 100644 --- a/test/fixtures/api/responses/prepare-settings.json +++ b/test/fixtures/api/responses/prepare-settings.json @@ -1,10 +1,8 @@ { - "Flags": 1048576, - "TransactionType": "AccountSet", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "Domain": "726970706C652E636F6D", - "Flags": 0, - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Domain\":\"726970706C652E636F6D\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-trustline-simple.json b/test/fixtures/api/responses/prepare-trustline-simple.json index 1d8bf0e6..c3f52eda 100644 --- a/test/fixtures/api/responses/prepare-trustline-simple.json +++ b/test/fixtures/api/responses/prepare-trustline-simple.json @@ -1,13 +1,8 @@ { - "Flags": 0, - "TransactionType": "TrustSet", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "LimitAmount": { - "value": "0.1", - "currency": "BTC", - "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" - }, - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":0,\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"value\":\"0.1\",\"currency\":\"BTC\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } } diff --git a/test/fixtures/api/responses/prepare-trustline.json b/test/fixtures/api/responses/prepare-trustline.json index 0b138662..82de14a6 100644 --- a/test/fixtures/api/responses/prepare-trustline.json +++ b/test/fixtures/api/responses/prepare-trustline.json @@ -1,15 +1,8 @@ { - "Flags": 2228224, - "TransactionType": "TrustSet", - "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "LimitAmount": { - "value": "10000", - "currency": "USD", - "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" - }, - "QualityIn": 910000000, - "QualityOut": 870000000, - "LastLedgerSequence": 8820051, - "Fee": "12", - "Sequence": 23 + "txJSON": "{\"Flags\":2228224,\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"value\":\"10000\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"QualityIn\":910000000,\"QualityOut\":870000000,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}", + "instructions": { + "fee": "12", + "sequence": 23, + "maxLedgerVersion": 8820051 + } }