diff --git a/src/api/common/schemas/balance.json b/src/api/common/schemas/balance.json index 516c84a7..71ee34cf 100644 --- a/src/api/common/schemas/balance.json +++ b/src/api/common/schemas/balance.json @@ -6,7 +6,7 @@ "properties": { "value": { "description": "The balance on the trustline", - "$ref": "signed-value" + "$ref": "signedValue" }, "currency": { "description": "The three-character code or hex string used to denote currencies", diff --git a/src/api/common/schemas/max-adjustment.json b/src/api/common/schemas/max-adjustment.json new file mode 100644 index 00000000..b4a9eb1e --- /dev/null +++ b/src/api/common/schemas/max-adjustment.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "maxAdjustment", + "type": "object", + "properties": { + "address": {"$ref": "address"}, + "maxAmount": { + "type": "object", + "properties": { + "currency": {"$ref": "currency"}, + "counterparty": {"$ref": "address"}, + "value": {"$ref": "value"} + }, + "required": ["currency", "value"], + "additionalProperties": false + }, + "tag": { + "description": "A string representing an unsigned 32-bit integer most commonly used to refer to a sender's hosted account at a Ripple gateway", + "$ref": "uint32" + } + }, + "required": ["address", "maxAmount"], + "additionalProperties": false +} diff --git a/src/api/common/schemas/order-change.json b/src/api/common/schemas/order-change.json index 65844c76..c298da51 100644 --- a/src/api/common/schemas/order-change.json +++ b/src/api/common/schemas/order-change.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "order-change", + "title": "orderChange", "type": "object", "properties": { "direction": { diff --git a/src/api/common/schemas/outcome.json b/src/api/common/schemas/outcome.json index 498e36ab..0dfbcaab 100644 --- a/src/api/common/schemas/outcome.json +++ b/src/api/common/schemas/outcome.json @@ -19,7 +19,7 @@ "description": "Key is the maker's ripple address; value is an array of changes", "additionalProperties": { "type": "array", - "items": {"$ref": "order-change"} + "items": {"$ref": "orderChange"} } }, "ledgerVersion": {"$ref": "ledgerVersion"}, diff --git a/src/api/common/schemas/payment.json b/src/api/common/schemas/payment.json index bab67180..fa7b3842 100644 --- a/src/api/common/schemas/payment.json +++ b/src/api/common/schemas/payment.json @@ -3,7 +3,7 @@ "title": "payment", "type": "object", "properties": { - "source": {"$ref": "adjustment"}, + "source": {"$ref": "maxAdjustment"}, "destination": {"$ref": "adjustment"}, "paths": {"type": "string"}, "memos": { diff --git a/src/api/common/schemas/signed-value.json b/src/api/common/schemas/signed-value.json index 3c91b1fb..bf55b975 100644 --- a/src/api/common/schemas/signed-value.json +++ b/src/api/common/schemas/signed-value.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "value", + "title": "signedValue", "description": "A string representation of a floating point number", "type": "string", - "pattern": "[-]?^[0-9]*[.]?[0-9]+([eE][-+]?[0-9]+)?$" + "pattern": "^[-]?[0-9]*[.]?[0-9]+([eE][-+]?[0-9]+)?$" } diff --git a/src/api/ledger/parse/payment.js b/src/api/ledger/parse/payment.js index 9db2c1c4..0dfe438b 100644 --- a/src/api/ledger/parse/payment.js +++ b/src/api/ledger/parse/payment.js @@ -41,7 +41,7 @@ function parsePayment(tx: Object): Object { const source = { address: tx.Account, - amount: removeGenericCounterparty( + maxAmount: removeGenericCounterparty( parseAmount(tx.SendMax || tx.Amount), tx.Account), tag: tx.SourceTag }; diff --git a/src/api/transaction/payment.js b/src/api/transaction/payment.js index 2a4b033a..4b8594a2 100644 --- a/src/api/transaction/payment.js +++ b/src/api/transaction/payment.js @@ -7,7 +7,7 @@ const toRippledAmount = utils.common.toRippledAmount; const Transaction = utils.common.core.Transaction; function isXRPToXRPPayment(payment) { - const sourceCurrency = _.get(payment, 'source.amount.currency'); + const sourceCurrency = _.get(payment, 'source.maxAmount.currency'); const destinationCurrency = _.get(payment, 'destination.amount.currency'); return sourceCurrency === 'XRP' && destinationCurrency === 'XRP'; } @@ -23,8 +23,8 @@ function applyAnyCounterpartyEncoding(payment) { // https://ripple.com/build/transactions/ // #special-issuer-values-for-sendmax-and-amount // https://ripple.com/build/ripple-rest/#counterparties-in-payments - if (isIOUWithoutCounterparty(payment.source.amount)) { - payment.source.amount.counterparty = payment.source.address; + if (isIOUWithoutCounterparty(payment.source.maxAmount)) { + payment.source.maxAmount.counterparty = payment.source.address; } if (isIOUWithoutCounterparty(payment.destination.amount)) { payment.destination.amount.counterparty = payment.destination.address; @@ -71,7 +71,7 @@ function createPaymentTransaction(account, payment) { // temREDUNDANT_SEND_MAX removed in: // https://github.com/ripple/rippled/commit/ // c522ffa6db2648f1d8a987843e7feabf1a0b7de8/ - transaction.sendMax(toRippledAmount(payment.source.amount)); + transaction.sendMax(toRippledAmount(payment.source.maxAmount)); if (payment.paths) { transaction.paths(JSON.parse(payment.paths)); diff --git a/test/fixtures/api/requests/prepare-payment-all-options.json b/test/fixtures/api/requests/prepare-payment-all-options.json index 10f3e809..4cc232fd 100644 --- a/test/fixtures/api/requests/prepare-payment-all-options.json +++ b/test/fixtures/api/requests/prepare-payment-all-options.json @@ -1,7 +1,7 @@ { "source": { "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "amount": { + "maxAmount": { "value": "0.01", "currency": "XRP" }, diff --git a/test/fixtures/api/requests/prepare-payment-no-counterparty.json b/test/fixtures/api/requests/prepare-payment-no-counterparty.json index 6f8009fc..6f5782e3 100644 --- a/test/fixtures/api/requests/prepare-payment-no-counterparty.json +++ b/test/fixtures/api/requests/prepare-payment-no-counterparty.json @@ -1,7 +1,7 @@ { "source": { "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "amount": { + "maxAmount": { "value": "0.01", "currency": "USD" }, diff --git a/test/fixtures/api/requests/prepare-payment.json b/test/fixtures/api/requests/prepare-payment.json index f41def08..3907aa61 100644 --- a/test/fixtures/api/requests/prepare-payment.json +++ b/test/fixtures/api/requests/prepare-payment.json @@ -1,7 +1,7 @@ { "source": { "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "amount": { + "maxAmount": { "value": "0.01", "currency": "USD", "counterparty": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM" diff --git a/test/fixtures/api/responses/get-transaction-payment.json b/test/fixtures/api/responses/get-transaction-payment.json index 56682f45..ed14494a 100644 --- a/test/fixtures/api/responses/get-transaction-payment.json +++ b/test/fixtures/api/responses/get-transaction-payment.json @@ -6,7 +6,7 @@ "specification": { "source": { "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "amount": { + "maxAmount": { "currency": "XRP", "value": "1.112209" } diff --git a/test/fixtures/api/responses/get-transactions.json b/test/fixtures/api/responses/get-transactions.json index 71545a54..22cd3197 100644 --- a/test/fixtures/api/responses/get-transactions.json +++ b/test/fixtures/api/responses/get-transactions.json @@ -13,7 +13,7 @@ ], "source": { "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "amount": { + "maxAmount": { "currency": "XRP", "value": "1.112209" } @@ -104,7 +104,7 @@ ], "source": { "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "amount": { + "maxAmount": { "currency": "XRP", "value": "1.112209" }