mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Include memos when parsing trustlines (#949)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import * as assert from 'assert'
|
import * as assert from 'assert'
|
||||||
import {parseQuality} from './utils'
|
import {parseQuality, parseMemos} from './utils'
|
||||||
import {txFlags, removeUndefined} from '../../common'
|
import {txFlags, removeUndefined} from '../../common'
|
||||||
const flags = txFlags.TrustSet
|
const flags = txFlags.TrustSet
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@ function parseTrustline(tx: any): Object {
|
|||||||
limit: tx.LimitAmount.value,
|
limit: tx.LimitAmount.value,
|
||||||
currency: tx.LimitAmount.currency,
|
currency: tx.LimitAmount.currency,
|
||||||
counterparty: tx.LimitAmount.issuer,
|
counterparty: tx.LimitAmount.issuer,
|
||||||
|
memos: parseMemos(tx),
|
||||||
qualityIn: parseQuality(tx.QualityIn),
|
qualityIn: parseQuality(tx.QualityIn),
|
||||||
qualityOut: parseQuality(tx.QualityOut),
|
qualityOut: parseQuality(tx.QualityOut),
|
||||||
ripplingDisabled: parseFlag(
|
ripplingDisabled: parseFlag(
|
||||||
|
|||||||
@@ -1587,6 +1587,14 @@ describe('RippleAPI', function () {
|
|||||||
'getTransaction'));
|
'getTransaction'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getTransaction - trustline add memo', function () {
|
||||||
|
const hash =
|
||||||
|
'9D6AC5FD6545B2584885B85E36759EB6440CDD41B6C55859F84AFDEE2B428220';
|
||||||
|
return this.api.getTransaction(hash).then(
|
||||||
|
_.partial(checkResult, responses.getTransaction.trustlineAddMemo,
|
||||||
|
'getTransaction'));
|
||||||
|
});
|
||||||
|
|
||||||
it('getTransaction - not validated', function () {
|
it('getTransaction - not validated', function () {
|
||||||
const hash =
|
const hash =
|
||||||
'4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA10';
|
'4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA10';
|
||||||
|
|||||||
34
test/fixtures/responses/get-transaction-trust-add-memo.json
vendored
Normal file
34
test/fixtures/responses/get-transaction-trust-add-memo.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"type": "trustline",
|
||||||
|
"address": "r9nNHpMW4TfPnmWcRHi3Qmev2jjCJ2koi4",
|
||||||
|
"sequence": 40,
|
||||||
|
"id": "9D6AC5FD6545B2584885B85E36759EB6440CDD41B6C55859F84AFDEE2B428220",
|
||||||
|
"specification": {
|
||||||
|
"limit": "2000",
|
||||||
|
"currency": "USD",
|
||||||
|
"counterparty": "rkrbFLphJzLvyLE1obALNARQAnoVypoNX",
|
||||||
|
"memos": [
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"format": "plain/text",
|
||||||
|
"data": "test trust"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"outcome": {
|
||||||
|
"result": "tesSUCCESS",
|
||||||
|
"timestamp": "2018-09-18T03:36:51.000Z",
|
||||||
|
"fee": "0.000012",
|
||||||
|
"balanceChanges": {
|
||||||
|
"r9nNHpMW4TfPnmWcRHi3Qmev2jjCJ2koi4": [
|
||||||
|
{
|
||||||
|
"currency": "XRP",
|
||||||
|
"value": "-0.000012"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"orderbookChanges": {},
|
||||||
|
"ledgerVersion": 41608182,
|
||||||
|
"indexInLedger": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
1
test/fixtures/responses/index.js
vendored
1
test/fixtures/responses/index.js
vendored
@@ -43,6 +43,7 @@ module.exports = {
|
|||||||
setRegularKey: require('./get-transaction-settings-set-regular-key.json'),
|
setRegularKey: require('./get-transaction-settings-set-regular-key.json'),
|
||||||
trustlineFrozenOff: require('./get-transaction-trust-set-frozen-off.json'),
|
trustlineFrozenOff: require('./get-transaction-trust-set-frozen-off.json'),
|
||||||
trustlineNoQuality: require('./get-transaction-trust-no-quality.json'),
|
trustlineNoQuality: require('./get-transaction-trust-no-quality.json'),
|
||||||
|
trustlineAddMemo: require('./get-transaction-trust-add-memo.json'),
|
||||||
notValidated: require('./get-transaction-not-validated.json'),
|
notValidated: require('./get-transaction-not-validated.json'),
|
||||||
checkCreate:
|
checkCreate:
|
||||||
require('./get-transaction-check-create.json'),
|
require('./get-transaction-check-create.json'),
|
||||||
|
|||||||
1
test/fixtures/rippled/index.js
vendored
1
test/fixtures/rippled/index.js
vendored
@@ -75,6 +75,7 @@ module.exports = {
|
|||||||
TrustSet: require('./tx/trust-set.json'),
|
TrustSet: require('./tx/trust-set.json'),
|
||||||
TrustSetFrozenOff: require('./tx/trust-set-frozen-off.json'),
|
TrustSetFrozenOff: require('./tx/trust-set-frozen-off.json'),
|
||||||
TrustSetNoQuality: require('./tx/trust-set-no-quality.json'),
|
TrustSetNoQuality: require('./tx/trust-set-no-quality.json'),
|
||||||
|
TrustSetAddMemo: require('./tx/trust-set-add-memo.json'),
|
||||||
NotFound: require('./tx/not-found.json'),
|
NotFound: require('./tx/not-found.json'),
|
||||||
NoLedgerIndex: require('./tx/no-ledger-index.json'),
|
NoLedgerIndex: require('./tx/no-ledger-index.json'),
|
||||||
NoLedgerFound: require('./tx/no-ledger-found.json'),
|
NoLedgerFound: require('./tx/no-ledger-found.json'),
|
||||||
|
|||||||
59
test/fixtures/rippled/tx/trust-set-add-memo.json
vendored
Normal file
59
test/fixtures/rippled/tx/trust-set-add-memo.json
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"status": "success",
|
||||||
|
"type": "response",
|
||||||
|
"result": {
|
||||||
|
"Account": "r9nNHpMW4TfPnmWcRHi3Qmev2jjCJ2koi4",
|
||||||
|
"Fee": "12",
|
||||||
|
"Flags": 2147483648,
|
||||||
|
"LastLedgerSequence": 41608183,
|
||||||
|
"LimitAmount": {
|
||||||
|
"currency": "USD",
|
||||||
|
"issuer": "rkrbFLphJzLvyLE1obALNARQAnoVypoNX",
|
||||||
|
"value": "2000"
|
||||||
|
},
|
||||||
|
"Memos": [
|
||||||
|
{
|
||||||
|
"Memo": {
|
||||||
|
"MemoData": "74657374207472757374",
|
||||||
|
"MemoFormat": "706C61696E2F74657874",
|
||||||
|
"MemoType": "74657374"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Sequence": 40,
|
||||||
|
"SigningPubKey": "033FD06C0EEE1D865B21B9E1CF35E672912241C5730C631E3965B205F014C9CF5A",
|
||||||
|
"TransactionType": "TrustSet",
|
||||||
|
"TxnSignature": "3045022100FA2BEFAB78C7EC214AEDAD18B423E03BBC48FD6728D93EC25A213B4C84A5D38102205B618CD7A52CD4351381D2676E0A6044E4181118716DE98E8DEFA845C097ECB9",
|
||||||
|
"date": 590557011,
|
||||||
|
"hash": "9D6AC5FD6545B2584885B85E36759EB6440CDD41B6C55859F84AFDEE2B428220",
|
||||||
|
"inLedger": 41608182,
|
||||||
|
"ledger_index": 41608182,
|
||||||
|
"meta": {
|
||||||
|
"AffectedNodes": [
|
||||||
|
{
|
||||||
|
"ModifiedNode": {
|
||||||
|
"FinalFields": {
|
||||||
|
"Account": "r9nNHpMW4TfPnmWcRHi3Qmev2jjCJ2koi4",
|
||||||
|
"Balance": "119672499",
|
||||||
|
"Flags": 0,
|
||||||
|
"OwnerCount": 4,
|
||||||
|
"Sequence": 41
|
||||||
|
},
|
||||||
|
"LedgerEntryType": "AccountRoot",
|
||||||
|
"LedgerIndex": "9FD944BCDE2F599A59FE8E8D7A764B69F4B0F818385C9E54C6CC46405F1E1925",
|
||||||
|
"PreviousFields": {
|
||||||
|
"Balance": "119672511",
|
||||||
|
"Sequence": 40
|
||||||
|
},
|
||||||
|
"PreviousTxnID": "8E16AD23970715E212DE6208E11397E4E394430D40EBF560F5A80FB8716429CF",
|
||||||
|
"PreviousTxnLgrSeq": 41607559
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"TransactionIndex": 5,
|
||||||
|
"TransactionResult": "tesSUCCESS"
|
||||||
|
},
|
||||||
|
"validated": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -345,6 +345,9 @@ module.exports = function createMockRippled(port) {
|
|||||||
'BAF1C678323C37CCB7735550C379287667D8288C30F83148AD3C1CB019FC9002') {
|
'BAF1C678323C37CCB7735550C379287667D8288C30F83148AD3C1CB019FC9002') {
|
||||||
conn.send(createResponse(request, fixtures.tx.TrustSetNoQuality));
|
conn.send(createResponse(request, fixtures.tx.TrustSetNoQuality));
|
||||||
} else if (request.transaction ===
|
} else if (request.transaction ===
|
||||||
|
'9D6AC5FD6545B2584885B85E36759EB6440CDD41B6C55859F84AFDEE2B428220') {
|
||||||
|
conn.send(createResponse(request, fixtures.tx.TrustSetAddMemo));
|
||||||
|
}else if (request.transaction ===
|
||||||
'4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA10') {
|
'4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA10') {
|
||||||
conn.send(createResponse(request, fixtures.tx.NotValidated));
|
conn.send(createResponse(request, fixtures.tx.NotValidated));
|
||||||
} else if (request.transaction === hashes.NOTFOUND_TRANSACTION_HASH) {
|
} else if (request.transaction === hashes.NOTFOUND_TRANSACTION_HASH) {
|
||||||
|
|||||||
Reference in New Issue
Block a user