feat: add payment channel details to tx (2) (#920)

* Bump transactionparser to v0.7.1 and update output schema
* yarn docgen for required `threshold` and `weights`
This commit is contained in:
Elliot Lee
2018-07-17 22:22:07 -07:00
committed by GitHub
parent 14444bea3f
commit 7a928804ec
8 changed files with 50 additions and 17 deletions

View File

@@ -516,8 +516,8 @@ regularKey | [address](#address),null | *Optional* The public key of a new keypa
requireAuthorization | boolean | *Optional* If set, this account must individually approve other users in order for those users to hold this accounts issuances.
requireDestinationTag | boolean | *Optional* Requires incoming payments to specify a destination tag.
signers | object | *Optional* Settings that determine what sets of accounts can be used to sign a transaction on behalf of this account using multisigning.
*signers.* threshold | integer | *Optional* A target number for the signer weights. A multi-signature from this list is valid only if the sum weights of the signatures provided is equal or greater than this value. To delete the signers setting, use the value `0`.
*signers.* weights | array | *Optional* Weights of signatures for each signer.
*signers.* threshold | integer | A target number for the signer weights. A multi-signature from this list is valid only if the sum weights of the signatures provided is equal or greater than this value. To delete the signers setting, use the value `0`.
*signers.* weights | array | Weights of signatures for each signer.
*signers.* weights[] | object | An association of an address and a weight.
*signers.weights[].* address | [address](#address) | A Ripple account address
*signers.weights[].* weight | integer | The weight that the signature of this account counts as towards the threshold.
@@ -1153,8 +1153,8 @@ specification | object | A specification that would produce the same outcome as
outcome | object | The outcome of the transaction (what effects it had).
*outcome.* result | string | Result code returned by rippled. See [Transaction Results](https://ripple.com/build/transactions/#full-transaction-response-list) for a complete list.
*outcome.* fee | [value](#value) | The XRP fee that was charged for the transaction.
*outcome.balanceChanges.* \* | array\<[balance](#amount)\> | Key is the ripple address; value is an array of signed amounts representing changes of balances for that address.
*outcome.orderbookChanges.* \* | array | Key is the maker's ripple address; value is an array of changes
*outcome.balanceChanges.* \* | array\<[balance](#amount)\> | Key is the XRP Ledger address; value is an array of signed amounts representing changes of balances for that address.
*outcome.orderbookChanges.* \* | array | Key is the maker's XRP Ledger address; value is an array of changes
*outcome.orderbookChanges.* \*[] | object | A change to an order.
*outcome.orderbookChanges.\*[].* direction | string | Equal to "buy" for buy orders and "sell" for sell orders.
*outcome.orderbookChanges.\*[].* quantity | [amount](#amount) | The amount to be bought or sold by the maker.
@@ -1166,6 +1166,7 @@ outcome | object | The outcome of the transaction (what effects it had).
*outcome.* ledgerVersion | integer | The ledger version that the transaction was validated in.
*outcome.* ledgerVersion | string | The ledger version that the transaction was validated in.
*outcome.* indexInLedger | integer | The ordering index of the transaction in the ledger.
*outcome.* channelChanges | object | *Optional* Properties reflecting the details of the payment channel.
*outcome.* deliveredAmount | [amount](#amount) | *Optional* For payment transactions, it is impossible to reliably compute the actual delivered amount from the balanceChanges due to fixed precision. If the payment is not a partial payment and the transaction succeeded, the deliveredAmount should always be considered to be the amount specified in the transaction.
*outcome.* timestamp | date-time string | *Optional* The timestamp when the transaction was validated. (May be missing when requesting transactions in binary mode.)
@@ -3566,8 +3567,8 @@ regularKey | [address](#address),null | *Optional* The public key of a new keypa
requireAuthorization | boolean | *Optional* If set, this account must individually approve other users in order for those users to hold this accounts issuances.
requireDestinationTag | boolean | *Optional* Requires incoming payments to specify a destination tag.
signers | object | *Optional* Settings that determine what sets of accounts can be used to sign a transaction on behalf of this account using multisigning.
*signers.* threshold | integer | *Optional* A target number for the signer weights. A multi-signature from this list is valid only if the sum weights of the signatures provided is equal or greater than this value. To delete the signers setting, use the value `0`.
*signers.* weights | array | *Optional* Weights of signatures for each signer.
*signers.* threshold | integer | A target number for the signer weights. A multi-signature from this list is valid only if the sum weights of the signatures provided is equal or greater than this value. To delete the signers setting, use the value `0`.
*signers.* weights | array | Weights of signatures for each signer.
*signers.* weights[] | object | An association of an address and a weight.
*signers.weights[].* address | [address](#address) | A Ripple account address
*signers.weights[].* weight | integer | The weight that the signature of this account counts as towards the threshold.

View File

@@ -26,7 +26,7 @@
"ripple-binary-codec": "^0.1.13",
"ripple-hashes": "^0.3.1",
"ripple-keypairs": "^0.10.1",
"ripple-lib-transactionparser": "^0.6.2",
"ripple-lib-transactionparser": "0.7.1",
"ws": "^3.3.1"
},
"devDependencies": {

View File

@@ -25,7 +25,7 @@
"type": "object",
"additionalProperties": {
"type": "array",
"description": "Key is the ripple address; value is an array of signed amounts representing changes of balances for that address.",
"description": "Key is the XRP Ledger address; value is an array of signed amounts representing changes of balances for that address.",
"items": {"$ref": "balance"}
}
},
@@ -33,10 +33,14 @@
"type": "object",
"additionalProperties": {
"type": "array",
"description": "Key is the maker's ripple address; value is an array of changes",
"description": "Key is the maker's XRP Ledger address; value is an array of changes",
"items": {"$ref": "orderChange"}
}
},
"channelChanges": {
"type": "object",
"description": "Properties reflecting the details of the payment channel."
},
"ledgerVersion": {
"$ref": "ledgerVersion",
"description": "The ledger version that the transaction was validated in."

View File

@@ -103,7 +103,7 @@ function parseOutcome(tx: any): any|undefined {
}
const balanceChanges = transactionParser.parseBalanceChanges(metadata)
const orderbookChanges = transactionParser.parseOrderbookChanges(metadata)
const channel = transactionParser.parseChannelDetails(metadata)
const channelChanges = transactionParser.parseChannelChanges(metadata)
removeEmptyCounterpartyInBalanceChanges(balanceChanges)
removeEmptyCounterpartyInOrderbookChanges(orderbookChanges)
@@ -114,7 +114,7 @@ function parseOutcome(tx: any): any|undefined {
fee: common.dropsToXrp(tx.Fee),
balanceChanges: balanceChanges,
orderbookChanges: orderbookChanges,
channel: channel,
channelChanges: channelChanges,
ledgerVersion: tx.ledger_index,
indexInLedger: tx.meta.TransactionIndex,
deliveredAmount: parseDeliveredAmount(tx)

View File

@@ -23,6 +23,16 @@
},
"orderbookChanges": {},
"ledgerVersion": 786310,
"indexInLedger": 0
"indexInLedger": 0,
"channelChanges": {
"status": "modified",
"channelId": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1",
"source": "rfAuMkVuZQnQhvdMcUKg4ndBb9SPDhzNmK",
"destination": "rBmNDZ7vbTCwakKXsX3pDAwDdQuxM7yBRa",
"channelBalanceChangeDrops": "801000",
"channelAmountDrops": "1000000",
"channelBalanceDrops": "801000",
"previousTxnId": "0E9CA3AB1053FC0C1CBAA75F636FE1EC92F118C7056BBEF5D63E4C116458A16D"
}
}
}

View File

@@ -24,6 +24,14 @@
},
"orderbookChanges": {},
"ledgerVersion": 786309,
"indexInLedger": 0
"indexInLedger": 0,
"channelChanges": {
"status": "created",
"channelId": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1",
"source": "rfAuMkVuZQnQhvdMcUKg4ndBb9SPDhzNmK",
"destination": "rBmNDZ7vbTCwakKXsX3pDAwDdQuxM7yBRa",
"channelAmountDrops": "1000000",
"channelBalanceDrops": "0"
}
}
}

View File

@@ -21,6 +21,16 @@
},
"orderbookChanges": {},
"ledgerVersion": 786310,
"indexInLedger": 1
"indexInLedger": 1,
"channelChanges": {
"status": "modified",
"channelId": "43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1",
"source": "rfAuMkVuZQnQhvdMcUKg4ndBb9SPDhzNmK",
"destination": "rBmNDZ7vbTCwakKXsX3pDAwDdQuxM7yBRa",
"channelAmountChangeDrops": "1000000",
"channelAmountDrops": "2000000",
"channelBalanceDrops": "801000",
"previousTxnId": "81B9ECAE7195EB6E8034AEDF44D8415A7A803E14513FDBB34FA984AB37D59563"
}
}
}

View File

@@ -4164,9 +4164,9 @@ ripple-keypairs@^0.10.1:
hash.js "^1.0.3"
ripple-address-codec "^2.0.1"
ripple-lib-transactionparser@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.6.2.tgz#eb117834816cab3398445a74ec3cacec95b6b5fa"
ripple-lib-transactionparser@0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/ripple-lib-transactionparser/-/ripple-lib-transactionparser-0.7.1.tgz#5ececb1e03d65d05605343f4b9dbb76d1089145b"
dependencies:
bignumber.js "^4.1.0"
lodash "^4.17.4"