mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-22 05:05:48 +00:00
Switch to direction/quantity/totalPrice for orderbookChanges
This commit is contained in:
@@ -12,7 +12,7 @@ lint() {
|
|||||||
REPO_URL="https://raw.githubusercontent.com/ripple/javascript-style-guide"
|
REPO_URL="https://raw.githubusercontent.com/ripple/javascript-style-guide"
|
||||||
curl "$REPO_URL/es6/eslintrc" > ./eslintrc
|
curl "$REPO_URL/es6/eslintrc" > ./eslintrc
|
||||||
echo "plugins: [flowtype]" >> ./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() {
|
unittest() {
|
||||||
|
|||||||
4
npm-shrinkwrap.json
generated
4
npm-shrinkwrap.json
generated
@@ -103,8 +103,8 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.2.tgz"
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.2.tgz"
|
||||||
},
|
},
|
||||||
"ripple-lib-transactionparser": {
|
"ripple-lib-transactionparser": {
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.5.0.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bignumber.js": {
|
"bignumber.js": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.1",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
"is-my-json-valid": "^2.12.0",
|
"is-my-json-valid": "^2.12.0",
|
||||||
"lodash": "^3.1.0",
|
"lodash": "^3.1.0",
|
||||||
"lru-cache": "~2.5.0",
|
"lru-cache": "~2.5.0",
|
||||||
"ripple-lib-transactionparser": "^0.4",
|
"ripple-lib-transactionparser": "^0.5.0",
|
||||||
"ripple-wallet-generator": "^1.0.3",
|
"ripple-wallet-generator": "^1.0.3",
|
||||||
"sjcl-extended": "ripple/sjcl-extended#1.0.3",
|
"sjcl-extended": "ripple/sjcl-extended#1.0.3",
|
||||||
"ws": "~0.7.1"
|
"ws": "~0.7.1"
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
"babel-eslint": "^3.1.23",
|
"babel-eslint": "^3.1.23",
|
||||||
"babel-loader": "^5.0.0",
|
"babel-loader": "^5.0.0",
|
||||||
"coveralls": "~2.10.0",
|
"coveralls": "~2.10.0",
|
||||||
"eslint": "^0.24.0",
|
"eslint": "^1.0.0",
|
||||||
"eslint-plugin-flowtype": "^1.0.0",
|
"eslint-plugin-flowtype": "^1.0.0",
|
||||||
"eventemitter2": "^0.4.14",
|
"eventemitter2": "^0.4.14",
|
||||||
"flow-bin": "^0.14",
|
"flow-bin": "^0.14",
|
||||||
|
|||||||
17
src/api/common/schemas/order-change.json
Normal file
17
src/api/common/schemas/order-change.json
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -6,8 +6,22 @@
|
|||||||
"result": {"type": "string"},
|
"result": {"type": "string"},
|
||||||
"timestamp": {"type": "string"},
|
"timestamp": {"type": "string"},
|
||||||
"fee": {"$ref": "value"},
|
"fee": {"$ref": "value"},
|
||||||
"balanceChanges": {"type": "object"},
|
"balanceChanges": {
|
||||||
"orderbookChanges": {"type": "object"},
|
"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"},
|
"ledgerVersion": {"$ref": "ledgerVersion"},
|
||||||
"indexInLedger": {"type": "integer", "minimum": 0}
|
"indexInLedger": {"type": "integer", "minimum": 0}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ const toTimestamp = require('../../../core/utils').toTimestamp;
|
|||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
const BigNumber = require('bignumber.js');
|
const BigNumber = require('bignumber.js');
|
||||||
|
|
||||||
function adjustQualityForXRP(quality: string, takerGetsCurrency: string,
|
function adjustQualityForXRP(
|
||||||
takerPaysCurrency: string) {
|
quality: string, takerGetsCurrency: string, takerPaysCurrency: string
|
||||||
|
) {
|
||||||
// quality = takerPays.value/takerGets.value
|
// quality = takerPays.value/takerGets.value
|
||||||
// using drops (1e-6 XRP) for XRP values
|
// using drops (1e-6 XRP) for XRP values
|
||||||
const numeratorShift = (takerPaysCurrency === 'XRP' ? -6 : 0);
|
const numeratorShift = (takerPaysCurrency === 'XRP' ? -6 : 0);
|
||||||
@@ -51,7 +52,7 @@ function parseOutcome(tx: Object): ?Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const balanceChanges = transactionParser.parseBalanceChanges(tx.meta);
|
const balanceChanges = transactionParser.parseBalanceChanges(tx.meta);
|
||||||
const orderbookChanges = transactionParser.parseOrderBookChanges(tx.meta);
|
const orderbookChanges = transactionParser.parseOrderbookChanges(tx.meta);
|
||||||
removeEmptyCounterpartyInBalanceChanges(balanceChanges);
|
removeEmptyCounterpartyInBalanceChanges(balanceChanges);
|
||||||
removeEmptyCounterpartyInOrderbookChanges(orderbookChanges);
|
removeEmptyCounterpartyInOrderbookChanges(orderbookChanges);
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,13 @@
|
|||||||
"orderbookChanges": {
|
"orderbookChanges": {
|
||||||
"r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b": [
|
"r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b": [
|
||||||
{
|
{
|
||||||
"taker_pays": {
|
"direction": "buy",
|
||||||
|
"quantity": {
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
"counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
"counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||||
"value": "0"
|
"value": "0"
|
||||||
},
|
},
|
||||||
"taker_gets": {
|
"totalPrice": {
|
||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
"value": "0"
|
"value": "0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,12 +30,13 @@
|
|||||||
"orderbookChanges": {
|
"orderbookChanges": {
|
||||||
"r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b": [
|
"r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b": [
|
||||||
{
|
{
|
||||||
"taker_pays": {
|
"direction": "buy",
|
||||||
|
"quantity": {
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
"counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
"counterparty": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||||
"value": "237"
|
"value": "237"
|
||||||
},
|
},
|
||||||
"taker_gets": {
|
"totalPrice": {
|
||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
"value": "0.0002"
|
"value": "0.0002"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -65,11 +65,12 @@
|
|||||||
"orderbookChanges": {
|
"orderbookChanges": {
|
||||||
"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [
|
"r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr": [
|
||||||
{
|
{
|
||||||
"taker_pays": {
|
"direction": "buy",
|
||||||
|
"quantity": {
|
||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
"value": "-1.101198"
|
"value": "-1.101198"
|
||||||
},
|
},
|
||||||
"taker_gets": {
|
"totalPrice": {
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||||
"value": "-0.001002"
|
"value": "-0.001002"
|
||||||
|
|||||||
@@ -71,11 +71,12 @@
|
|||||||
"orderbookChanges": {
|
"orderbookChanges": {
|
||||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
|
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
|
||||||
{
|
{
|
||||||
"taker_pays": {
|
"direction": "buy",
|
||||||
|
"quantity": {
|
||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
"value": "-1.101198"
|
"value": "-1.101198"
|
||||||
},
|
},
|
||||||
"taker_gets": {
|
"totalPrice": {
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||||
"value": "-0.001002"
|
"value": "-0.001002"
|
||||||
@@ -161,11 +162,12 @@
|
|||||||
"orderbookChanges": {
|
"orderbookChanges": {
|
||||||
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
|
"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59": [
|
||||||
{
|
{
|
||||||
"taker_pays": {
|
"direction": "buy",
|
||||||
|
"quantity": {
|
||||||
"currency": "XRP",
|
"currency": "XRP",
|
||||||
"value": "-1.101198"
|
"value": "-1.101198"
|
||||||
},
|
},
|
||||||
"taker_gets": {
|
"totalPrice": {
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
"counterparty": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||||
"value": "-0.001002"
|
"value": "-0.001002"
|
||||||
|
|||||||
Reference in New Issue
Block a user