diff --git a/bin/ci.sh b/bin/ci.sh index 94754352..511dd870 100755 --- a/bin/ci.sh +++ b/bin/ci.sh @@ -12,7 +12,7 @@ lint() { REPO_URL="https://raw.githubusercontent.com/ripple/javascript-style-guide" curl "$REPO_URL/es6/eslintrc" > ./eslintrc echo "plugins: [flowtype]" >> ./eslintrc - node_modules/.bin/eslint --reset -c ./eslintrc $(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$") + node_modules/.bin/eslint -c ./eslintrc $(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$") } unittest() { diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index d4ddc86c..d9a387bf 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -103,8 +103,8 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.2.tgz" }, "ripple-lib-transactionparser": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.4.0.tgz", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.5.0.tgz", "dependencies": { "bignumber.js": { "version": "1.4.1", diff --git a/package.json b/package.json index 39f9736b..79529d13 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "is-my-json-valid": "^2.12.0", "lodash": "^3.1.0", "lru-cache": "~2.5.0", - "ripple-lib-transactionparser": "^0.4", + "ripple-lib-transactionparser": "^0.5.0", "ripple-wallet-generator": "^1.0.3", "sjcl-extended": "ripple/sjcl-extended#1.0.3", "ws": "~0.7.1" @@ -36,7 +36,7 @@ "babel-eslint": "^3.1.23", "babel-loader": "^5.0.0", "coveralls": "~2.10.0", - "eslint": "^0.24.0", + "eslint": "^1.0.0", "eslint-plugin-flowtype": "^1.0.0", "eventemitter2": "^0.4.14", "flow-bin": "^0.14", diff --git a/src/api/common/schemas/order-change.json b/src/api/common/schemas/order-change.json new file mode 100644 index 00000000..65844c76 --- /dev/null +++ b/src/api/common/schemas/order-change.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "order-change", + "type": "object", + "properties": { + "direction": { + "type": "string", + "enum": ["buy", "sell"] + }, + "quantity": {"$ref": "balance"}, + "totalPrice": {"$ref": "balance"}, + "sequence": {"$ref": "sequence"}, + "status": {"enum": ["created", "open", "closed", "canceled"]} + }, + "required": ["direction", "quantity", "totalPrice", "sequence", "status"], + "additionalProperties": false +} diff --git a/src/api/common/schemas/outcome.json b/src/api/common/schemas/outcome.json index e6439b0b..498e36ab 100644 --- a/src/api/common/schemas/outcome.json +++ b/src/api/common/schemas/outcome.json @@ -6,8 +6,22 @@ "result": {"type": "string"}, "timestamp": {"type": "string"}, "fee": {"$ref": "value"}, - "balanceChanges": {"type": "object"}, - "orderbookChanges": {"type": "object"}, + "balanceChanges": { + "type": "object", + "description": "Key is the ripple address; value is an array of changes", + "additionalProperties": { + "type": "array", + "items": {"$ref": "balance"} + } + }, + "orderbookChanges": { + "type": "object", + "description": "Key is the maker's ripple address; value is an array of changes", + "additionalProperties": { + "type": "array", + "items": {"$ref": "order-change"} + } + }, "ledgerVersion": {"$ref": "ledgerVersion"}, "indexInLedger": {"type": "integer", "minimum": 0} }, diff --git a/src/api/ledger/parse/utils.js b/src/api/ledger/parse/utils.js index da8e483a..29a761cb 100644 --- a/src/api/ledger/parse/utils.js +++ b/src/api/ledger/parse/utils.js @@ -6,8 +6,9 @@ const toTimestamp = require('../../../core/utils').toTimestamp; const utils = require('../utils'); const BigNumber = require('bignumber.js'); -function adjustQualityForXRP(quality: string, takerGetsCurrency: string, - takerPaysCurrency: string) { +function adjustQualityForXRP( + quality: string, takerGetsCurrency: string, takerPaysCurrency: string +) { // quality = takerPays.value/takerGets.value // using drops (1e-6 XRP) for XRP values const numeratorShift = (takerPaysCurrency === 'XRP' ? -6 : 0); @@ -51,7 +52,7 @@ function parseOutcome(tx: Object): ?Object { } const balanceChanges = transactionParser.parseBalanceChanges(tx.meta); - const orderbookChanges = transactionParser.parseOrderBookChanges(tx.meta); + const orderbookChanges = transactionParser.parseOrderbookChanges(tx.meta); removeEmptyCounterpartyInBalanceChanges(balanceChanges); removeEmptyCounterpartyInOrderbookChanges(orderbookChanges); diff --git a/test/fixtures/api/responses/get-transaction-order-cancellation.json b/test/fixtures/api/responses/get-transaction-order-cancellation.json index a41bd7a8..458433e1 100644 --- a/test/fixtures/api/responses/get-transaction-order-cancellation.json +++ b/test/fixtures/api/responses/get-transaction-order-cancellation.json @@ -21,12 +21,13 @@ "orderbookChanges": { "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b": [ { - "taker_pays": { + "direction": "buy", + "quantity": { "currency": "USD", "counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", "value": "0" }, - "taker_gets": { + "totalPrice": { "currency": "XRP", "value": "0" }, diff --git a/test/fixtures/api/responses/get-transaction-order.json b/test/fixtures/api/responses/get-transaction-order.json index 65c22c0d..ea4b15dd 100644 --- a/test/fixtures/api/responses/get-transaction-order.json +++ b/test/fixtures/api/responses/get-transaction-order.json @@ -30,12 +30,13 @@ "orderbookChanges": { "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b": [ { - "taker_pays": { + "direction": "buy", + "quantity": { "currency": "USD", "counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", "value": "237" }, - "taker_gets": { + "totalPrice": { "currency": "XRP", "value": "0.0002" }, diff --git a/test/fixtures/api/responses/get-transaction-payment.json b/test/fixtures/api/responses/get-transaction-payment.json index e5d7e32a..56682f45 100644 --- a/test/fixtures/api/responses/get-transaction-payment.json +++ b/test/fixtures/api/responses/get-transaction-payment.json @@ -65,11 +65,12 @@ "orderbookChanges": { "r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [ { - "taker_pays": { + "direction": "buy", + "quantity": { "currency": "XRP", "value": "-1.101198" }, - "taker_gets": { + "totalPrice": { "currency": "USD", "counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", "value": "-0.001002" diff --git a/test/fixtures/api/responses/get-transactions.json b/test/fixtures/api/responses/get-transactions.json index 6947fbde..71545a54 100644 --- a/test/fixtures/api/responses/get-transactions.json +++ b/test/fixtures/api/responses/get-transactions.json @@ -71,11 +71,12 @@ "orderbookChanges": { "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [ { - "taker_pays": { + "direction": "buy", + "quantity": { "currency": "XRP", "value": "-1.101198" }, - "taker_gets": { + "totalPrice": { "currency": "USD", "counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", "value": "-0.001002" @@ -161,11 +162,12 @@ "orderbookChanges": { "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [ { - "taker_pays": { + "direction": "buy", + "quantity": { "currency": "XRP", "value": "-1.101198" }, - "taker_gets": { + "totalPrice": { "currency": "USD", "counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", "value": "-0.001002"