@transia/ripple-binary-codec 1.4.6-alpha.9 → 2.5.1-quantum.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/binary.d.ts +30 -16
- package/dist/binary.js +36 -16
- package/dist/binary.js.map +1 -1
- package/dist/enums/bytes.d.ts +1 -2
- package/dist/enums/bytes.js +1 -2
- package/dist/enums/bytes.js.map +1 -1
- package/dist/enums/constants.d.ts +1 -0
- package/dist/enums/constants.js +6 -5
- package/dist/enums/constants.js.map +1 -1
- package/dist/enums/definitions.json +1535 -919
- package/dist/enums/field.d.ts +1 -2
- package/dist/enums/field.js +1 -2
- package/dist/enums/field.js.map +1 -1
- package/dist/enums/index.d.ts +1 -2
- package/dist/enums/index.js +5 -27
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/src/enums/definitions.json +1537 -921
- package/dist/enums/xrpl-definitions-base.d.ts +5 -3
- package/dist/enums/xrpl-definitions-base.js +26 -6
- package/dist/enums/xrpl-definitions-base.js.map +1 -1
- package/dist/enums/xrpl-definitions.d.ts +2 -1
- package/dist/enums/xrpl-definitions.js +2 -1
- package/dist/enums/xrpl-definitions.js.map +1 -1
- package/dist/hash-prefixes.d.ts +1 -2
- package/dist/hash-prefixes.js +8 -6
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.d.ts +6 -7
- package/dist/hashes.js +6 -7
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +16 -11
- package/dist/index.js +53 -58
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +1 -2
- package/dist/ledger-hashes.js +11 -30
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.d.ts +3 -4
- package/dist/quality.js +10 -8
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +2 -3
- package/dist/serdes/binary-parser.js +16 -32
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +6 -7
- package/dist/serdes/binary-serializer.js +12 -35
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/shamap.d.ts +4 -5
- package/dist/shamap.js +5 -5
- package/dist/shamap.js.map +1 -1
- package/dist/src/binary.d.ts +106 -0
- package/dist/src/binary.js +154 -0
- package/dist/src/binary.js.map +1 -0
- package/dist/src/coretypes.d.ts +9 -0
- package/dist/src/coretypes.js +48 -0
- package/dist/src/coretypes.js.map +1 -0
- package/dist/src/enums/bytes.d.ts +25 -0
- package/dist/src/enums/bytes.js +63 -0
- package/dist/src/enums/bytes.js.map +1 -0
- package/dist/src/enums/constants.d.ts +5 -0
- package/dist/src/enums/constants.js +9 -0
- package/dist/src/enums/constants.js.map +1 -0
- package/dist/src/enums/definitions.json +3385 -0
- package/dist/src/enums/field.d.ts +28 -0
- package/dist/src/enums/field.js +58 -0
- package/dist/src/enums/field.js.map +1 -0
- package/dist/src/enums/index.d.ts +12 -0
- package/dist/src/enums/index.js +31 -0
- package/dist/src/enums/index.js.map +1 -0
- package/dist/src/enums/utils-renumber.d.ts +101 -0
- package/dist/src/enums/utils-renumber.js +127 -0
- package/dist/src/enums/utils-renumber.js.map +1 -0
- package/dist/src/enums/xrpl-definitions-base.d.ts +47 -0
- package/dist/src/enums/xrpl-definitions-base.js +83 -0
- package/dist/src/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/src/enums/xrpl-definitions.d.ts +22 -0
- package/dist/src/enums/xrpl-definitions.js +30 -0
- package/dist/src/enums/xrpl-definitions.js.map +1 -0
- package/dist/src/hash-prefixes.d.ts +5 -0
- package/dist/src/hash-prefixes.js +43 -0
- package/dist/src/hash-prefixes.js.map +1 -0
- package/dist/src/hashes.d.ts +50 -0
- package/dist/src/hashes.js +76 -0
- package/dist/src/hashes.js.map +1 -0
- package/dist/src/index.d.ts +69 -0
- package/dist/src/index.js +134 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ledger-hashes.d.ts +48 -0
- package/dist/src/ledger-hashes.js +141 -0
- package/dist/src/ledger-hashes.js.map +1 -0
- package/dist/src/quality.d.ts +21 -0
- package/dist/src/quality.js +42 -0
- package/dist/src/quality.js.map +1 -0
- package/dist/src/serdes/binary-parser.d.ts +100 -0
- package/dist/src/serdes/binary-parser.js +194 -0
- package/dist/src/serdes/binary-parser.js.map +1 -0
- package/dist/src/serdes/binary-serializer.d.ts +81 -0
- package/dist/src/serdes/binary-serializer.js +149 -0
- package/dist/src/serdes/binary-serializer.js.map +1 -0
- package/dist/src/shamap.d.ts +102 -0
- package/dist/src/shamap.js +172 -0
- package/dist/src/shamap.js.map +1 -0
- package/dist/src/types/account-id.d.ts +35 -0
- package/dist/src/types/account-id.js +69 -0
- package/dist/src/types/account-id.js.map +1 -0
- package/dist/src/types/amount.d.ts +91 -0
- package/dist/src/types/amount.js +289 -0
- package/dist/src/types/amount.js.map +1 -0
- package/dist/src/types/blob.d.ts +24 -0
- package/dist/src/types/blob.js +43 -0
- package/dist/src/types/blob.js.map +1 -0
- package/dist/src/types/currency.d.ts +28 -0
- package/dist/src/types/currency.js +127 -0
- package/dist/src/types/currency.js.map +1 -0
- package/dist/src/types/hash-128.d.ts +16 -0
- package/dist/src/types/hash-128.js +32 -0
- package/dist/src/types/hash-128.js.map +1 -0
- package/dist/src/types/hash-160.d.ts +10 -0
- package/dist/src/types/hash-160.js +19 -0
- package/dist/src/types/hash-160.js.map +1 -0
- package/dist/src/types/hash-192.d.ts +10 -0
- package/dist/src/types/hash-192.js +19 -0
- package/dist/src/types/hash-192.js.map +1 -0
- package/dist/src/types/hash-256.d.ts +10 -0
- package/dist/src/types/hash-256.js +16 -0
- package/dist/src/types/hash-256.js.map +1 -0
- package/dist/src/types/hash.d.ts +40 -0
- package/dist/src/types/hash.js +76 -0
- package/dist/src/types/hash.js.map +1 -0
- package/dist/src/types/index.d.ts +19 -0
- package/dist/src/types/index.js +66 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/issue.d.ts +48 -0
- package/dist/src/types/issue.js +104 -0
- package/dist/src/types/issue.js.map +1 -0
- package/dist/src/types/path-set.d.ts +36 -0
- package/dist/src/types/path-set.js +233 -0
- package/dist/src/types/path-set.js.map +1 -0
- package/dist/src/types/serialized-type.d.ts +70 -0
- package/dist/src/types/serialized-type.js +105 -0
- package/dist/src/types/serialized-type.js.map +1 -0
- package/dist/src/types/st-array.d.ts +31 -0
- package/dist/src/types/st-array.js +86 -0
- package/dist/src/types/st-array.js.map +1 -0
- package/dist/src/types/st-number.d.ts +54 -0
- package/dist/src/types/st-number.js +208 -0
- package/dist/src/types/st-number.js.map +1 -0
- package/dist/src/types/st-object.d.ts +32 -0
- package/dist/src/types/st-object.js +173 -0
- package/dist/src/types/st-object.js.map +1 -0
- package/dist/src/types/uint-16.d.ts +24 -0
- package/dist/src/types/uint-16.js +45 -0
- package/dist/src/types/uint-16.js.map +1 -0
- package/dist/src/types/uint-32.d.ts +24 -0
- package/dist/src/types/uint-32.js +50 -0
- package/dist/src/types/uint-32.js.map +1 -0
- package/dist/src/types/uint-64.d.ts +38 -0
- package/dist/src/types/uint-64.js +107 -0
- package/dist/src/types/uint-64.js.map +1 -0
- package/dist/src/types/uint-8.d.ts +24 -0
- package/dist/src/types/uint-8.js +46 -0
- package/dist/src/types/uint-8.js.map +1 -0
- package/dist/src/types/uint.d.ts +29 -0
- package/dist/src/types/uint.js +47 -0
- package/dist/src/types/uint.js.map +1 -0
- package/dist/src/types/vector-256.d.ts +30 -0
- package/dist/src/types/vector-256.js +73 -0
- package/dist/src/types/vector-256.js.map +1 -0
- package/dist/src/types/xchain-bridge.d.ts +44 -0
- package/dist/src/types/xchain-bridge.js +102 -0
- package/dist/src/types/xchain-bridge.js.map +1 -0
- package/dist/src/utils.d.ts +79 -0
- package/dist/src/utils.js +181 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/account-id.d.ts +1 -2
- package/dist/types/account-id.js +4 -6
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +31 -8
- package/dist/types/amount.js +125 -43
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +1 -2
- package/dist/types/blob.js +5 -2
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +1 -2
- package/dist/types/currency.js +13 -13
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +1 -2
- package/dist/types/hash-128.js +3 -3
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +1 -2
- package/dist/types/hash-160.js +1 -2
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.d.ts +10 -0
- package/dist/types/hash-192.js +19 -0
- package/dist/types/hash-192.js.map +1 -0
- package/dist/types/hash-256.d.ts +1 -2
- package/dist/types/hash-256.js +1 -2
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.d.ts +2 -3
- package/dist/types/hash.js +8 -4
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +11 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.d.ts +48 -0
- package/dist/types/issue.js +104 -0
- package/dist/types/issue.js.map +1 -0
- package/dist/types/path-set.js +12 -12
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +23 -16
- package/dist/types/serialized-type.js +15 -7
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +5 -2
- package/dist/types/st-array.js +17 -11
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-number.d.ts +54 -0
- package/dist/types/st-number.js +208 -0
- package/dist/types/st-number.js.map +1 -0
- package/dist/types/st-object.js +32 -8
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +1 -2
- package/dist/types/uint-16.js +6 -5
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +1 -2
- package/dist/types/uint-32.js +7 -6
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +6 -7
- package/dist/types/uint-64.js +44 -24
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +1 -2
- package/dist/types/uint-8.js +7 -5
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +5 -6
- package/dist/types/uint.js +5 -0
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.d.ts +1 -2
- package/dist/types/vector-256.js +2 -4
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.d.ts +44 -0
- package/dist/types/xchain-bridge.js +102 -0
- package/dist/types/xchain-bridge.js.map +1 -0
- package/dist/utils.d.ts +79 -0
- package/dist/utils.js +181 -0
- package/dist/utils.js.map +1 -0
- package/package.json +21 -17
- package/src/README.md +5 -0
- package/src/binary.ts +235 -0
- package/src/coretypes.ts +31 -0
- package/src/enums/README.md +144 -0
- package/src/enums/bytes.ts +74 -0
- package/src/enums/constants.ts +5 -0
- package/src/enums/definitions.json +3390 -0
- package/src/enums/field.ts +84 -0
- package/src/enums/index.ts +34 -0
- package/src/enums/utils-renumber.ts +134 -0
- package/src/enums/xrpl-definitions-base.ts +150 -0
- package/src/enums/xrpl-definitions.ts +33 -0
- package/src/hash-prefixes.ts +42 -0
- package/src/hashes.ts +75 -0
- package/src/index.ts +166 -0
- package/src/ledger-hashes.ts +191 -0
- package/src/quality.ts +38 -0
- package/src/serdes/binary-parser.ts +228 -0
- package/src/serdes/binary-serializer.ts +166 -0
- package/src/shamap.ts +186 -0
- package/src/types/account-id.ts +86 -0
- package/src/types/amount.ts +362 -0
- package/src/types/blob.ts +46 -0
- package/src/types/currency.ts +140 -0
- package/src/types/hash-128.ts +33 -0
- package/src/types/hash-160.ts +19 -0
- package/src/types/hash-192.ts +19 -0
- package/src/types/hash-256.ts +15 -0
- package/src/types/hash.ts +86 -0
- package/src/types/index.ts +68 -0
- package/src/types/issue.ts +136 -0
- package/src/types/path-set.ts +290 -0
- package/src/types/serialized-type.ts +122 -0
- package/src/types/st-array.ts +113 -0
- package/src/types/st-number.ts +233 -0
- package/src/types/st-object.ts +215 -0
- package/src/types/uint-16.ts +53 -0
- package/src/types/uint-32.ts +59 -0
- package/src/types/uint-64.ts +135 -0
- package/src/types/uint-8.ts +52 -0
- package/src/types/uint.ts +60 -0
- package/src/types/vector-256.ts +79 -0
- package/src/types/xchain-bridge.ts +128 -0
- package/src/utils.ts +220 -0
- package/test/amount.test.js +0 -43
- package/test/binary-json.test.js +0 -45
- package/test/binary-parser.test.js +0 -396
- package/test/binary-serializer.test.js +0 -319
- package/test/definitions.test.js +0 -100
- package/test/fixtures/account-tx-transactions.db +0 -0
- package/test/fixtures/codec-fixtures.json +0 -4466
- package/test/fixtures/data-driven-tests.json +0 -2919
- package/test/fixtures/delivermin-tx-binary.json +0 -1
- package/test/fixtures/delivermin-tx.json +0 -98
- package/test/fixtures/deposit-preauth-tx-binary.json +0 -1
- package/test/fixtures/deposit-preauth-tx-meta-binary.json +0 -1
- package/test/fixtures/deposit-preauth-tx.json +0 -58
- package/test/fixtures/escrow-cancel-binary.json +0 -1
- package/test/fixtures/escrow-cancel-tx.json +0 -6
- package/test/fixtures/escrow-create-binary.json +0 -1
- package/test/fixtures/escrow-create-tx.json +0 -10
- package/test/fixtures/escrow-finish-binary.json +0 -1
- package/test/fixtures/escrow-finish-meta-binary.json +0 -1
- package/test/fixtures/escrow-finish-tx.json +0 -95
- package/test/fixtures/ledger-full-38129.json +0 -1
- package/test/fixtures/ledger-full-40000.json +0 -1
- package/test/fixtures/negative-unl.json +0 -12
- package/test/fixtures/nf-token.json +0 -547
- package/test/fixtures/payment-channel-claim-binary.json +0 -1
- package/test/fixtures/payment-channel-claim-tx.json +0 -8
- package/test/fixtures/payment-channel-create-binary.json +0 -1
- package/test/fixtures/payment-channel-create-tx.json +0 -11
- package/test/fixtures/payment-channel-fund-binary.json +0 -1
- package/test/fixtures/payment-channel-fund-tx.json +0 -7
- package/test/fixtures/remit-binary.json +0 -1
- package/test/fixtures/remit-tx.json +0 -39
- package/test/fixtures/signerlistset-tx-binary.json +0 -1
- package/test/fixtures/signerlistset-tx-meta-binary.json +0 -1
- package/test/fixtures/signerlistset-tx.json +0 -94
- package/test/fixtures/ticket-create-binary.json +0 -1
- package/test/fixtures/ticket-create-tx.json +0 -7
- package/test/fixtures/unl-report-binary.json +0 -1
- package/test/fixtures/unl-report-meta-binary.json +0 -1
- package/test/fixtures/unl-report.json +0 -89
- package/test/fixtures/x-codec-fixtures.json +0 -188
- package/test/hash.test.js +0 -135
- package/test/ledger.test.js +0 -29
- package/test/lower-case-hex.test.js +0 -46
- package/test/pseudo-transaction.test.js +0 -38
- package/test/quality.test.js +0 -15
- package/test/shamap.test.js +0 -89
- package/test/signing-data-encoding.test.js +0 -213
- package/test/tx-encode-decode.test.js +0 -119
- package/test/types.test.js +0 -34
- package/test/uint.test.js +0 -148
- package/test/utils.js +0 -30
- package/test/x-address.test.js +0 -181
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
const { binary } = require('../src/coretypes')
|
|
2
|
-
const { encode, decode } = require('../src')
|
|
3
|
-
const { makeParser, BytesList, BinarySerializer } = binary
|
|
4
|
-
const { coreTypes } = require('../src/types')
|
|
5
|
-
const { UInt8, UInt16, UInt32, UInt64, STObject } = coreTypes
|
|
6
|
-
const bigInt = require('big-integer')
|
|
7
|
-
const { Buffer } = require('buffer/')
|
|
8
|
-
|
|
9
|
-
const { loadFixture } = require('./utils')
|
|
10
|
-
const fixtures = loadFixture('data-driven-tests.json')
|
|
11
|
-
const deliverMinTx = require('./fixtures/delivermin-tx.json')
|
|
12
|
-
const deliverMinTxBinary = require('./fixtures/delivermin-tx-binary.json')
|
|
13
|
-
const SignerListSet = {
|
|
14
|
-
tx: require('./fixtures/signerlistset-tx.json'),
|
|
15
|
-
binary: require('./fixtures/signerlistset-tx-binary.json'),
|
|
16
|
-
meta: require('./fixtures/signerlistset-tx-meta-binary.json'),
|
|
17
|
-
}
|
|
18
|
-
const DepositPreauth = {
|
|
19
|
-
tx: require('./fixtures/deposit-preauth-tx.json'),
|
|
20
|
-
binary: require('./fixtures/deposit-preauth-tx-binary.json'),
|
|
21
|
-
meta: require('./fixtures/deposit-preauth-tx-meta-binary.json'),
|
|
22
|
-
}
|
|
23
|
-
const Escrow = {
|
|
24
|
-
create: {
|
|
25
|
-
tx: require('./fixtures/escrow-create-tx.json'),
|
|
26
|
-
binary: require('./fixtures/escrow-create-binary.json'),
|
|
27
|
-
},
|
|
28
|
-
finish: {
|
|
29
|
-
tx: require('./fixtures/escrow-finish-tx.json'),
|
|
30
|
-
binary: require('./fixtures/escrow-finish-binary.json'),
|
|
31
|
-
meta: require('./fixtures/escrow-finish-meta-binary.json'),
|
|
32
|
-
},
|
|
33
|
-
cancel: {
|
|
34
|
-
tx: require('./fixtures/escrow-cancel-tx.json'),
|
|
35
|
-
binary: require('./fixtures/escrow-cancel-binary.json'),
|
|
36
|
-
},
|
|
37
|
-
}
|
|
38
|
-
const PaymentChannel = {
|
|
39
|
-
create: {
|
|
40
|
-
tx: require('./fixtures/payment-channel-create-tx.json'),
|
|
41
|
-
binary: require('./fixtures/payment-channel-create-binary.json'),
|
|
42
|
-
},
|
|
43
|
-
fund: {
|
|
44
|
-
tx: require('./fixtures/payment-channel-fund-tx.json'),
|
|
45
|
-
binary: require('./fixtures/payment-channel-fund-binary.json'),
|
|
46
|
-
},
|
|
47
|
-
claim: {
|
|
48
|
-
tx: require('./fixtures/payment-channel-claim-tx.json'),
|
|
49
|
-
binary: require('./fixtures/payment-channel-claim-binary.json'),
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const Ticket = {
|
|
54
|
-
create: {
|
|
55
|
-
tx: require('./fixtures/ticket-create-tx.json'),
|
|
56
|
-
binary: require('./fixtures/ticket-create-binary.json'),
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let json_undefined = {
|
|
61
|
-
TakerPays: '223174650',
|
|
62
|
-
Account: 'rPk2dXr27rMw9G5Ej9ad2Tt7RJzGy8ycBp',
|
|
63
|
-
TransactionType: 'OfferCreate',
|
|
64
|
-
Memos: [
|
|
65
|
-
{
|
|
66
|
-
Memo: {
|
|
67
|
-
MemoType: '584D4D2076616C7565',
|
|
68
|
-
MemoData: '322E3230393635',
|
|
69
|
-
MemoFormat: undefined,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
Fee: '15',
|
|
74
|
-
OfferSequence: undefined,
|
|
75
|
-
TakerGets: {
|
|
76
|
-
currency: 'XMM',
|
|
77
|
-
value: '100',
|
|
78
|
-
issuer: 'rExAPEZvbkZqYPuNcZ7XEBLENEshsWDQc8',
|
|
79
|
-
},
|
|
80
|
-
Flags: 524288,
|
|
81
|
-
Sequence: undefined,
|
|
82
|
-
LastLedgerSequence: 6220135,
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
let json_omitted = {
|
|
86
|
-
TakerPays: '223174650',
|
|
87
|
-
Account: 'rPk2dXr27rMw9G5Ej9ad2Tt7RJzGy8ycBp',
|
|
88
|
-
TransactionType: 'OfferCreate',
|
|
89
|
-
Memos: [
|
|
90
|
-
{
|
|
91
|
-
Memo: {
|
|
92
|
-
MemoType: '584D4D2076616C7565',
|
|
93
|
-
MemoData: '322E3230393635',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
Fee: '15',
|
|
98
|
-
TakerGets: {
|
|
99
|
-
currency: 'XMM',
|
|
100
|
-
value: '100',
|
|
101
|
-
issuer: 'rExAPEZvbkZqYPuNcZ7XEBLENEshsWDQc8',
|
|
102
|
-
},
|
|
103
|
-
Flags: 524288,
|
|
104
|
-
LastLedgerSequence: 6220135,
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const NegativeUNL = require('./fixtures/negative-unl.json')
|
|
108
|
-
const UNLReport = {
|
|
109
|
-
tx: require('./fixtures/unl-report.json'),
|
|
110
|
-
binary: require('./fixtures/unl-report-binary.json'),
|
|
111
|
-
meta: require('./fixtures/unl-report-meta-binary.json'),
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const Remit = {
|
|
115
|
-
tx: require('./fixtures/remit-tx.json'),
|
|
116
|
-
binary: require('./fixtures/remit-binary.json'),
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function bytesListTest() {
|
|
120
|
-
const list = new BytesList()
|
|
121
|
-
.put(Buffer.from([0]))
|
|
122
|
-
.put(Buffer.from([2, 3]))
|
|
123
|
-
.put(Buffer.from([4, 5]))
|
|
124
|
-
test('is an Array<Buffer>', function () {
|
|
125
|
-
expect(Array.isArray(list.bytesArray)).toBe(true)
|
|
126
|
-
expect(list.bytesArray[0] instanceof Buffer).toBe(true)
|
|
127
|
-
})
|
|
128
|
-
test('keeps track of the length itself', function () {
|
|
129
|
-
expect(list.getLength()).toBe(5)
|
|
130
|
-
})
|
|
131
|
-
test('can join all arrays into one via toBytes', function () {
|
|
132
|
-
const joined = list.toBytes()
|
|
133
|
-
expect(joined).toHaveLength(5)
|
|
134
|
-
expect(joined).toEqual(Buffer.from([0, 2, 3, 4, 5]))
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function assertRecycles(blob) {
|
|
139
|
-
const parser = makeParser(blob)
|
|
140
|
-
const so = parser.readType(STObject)
|
|
141
|
-
const out = new BytesList()
|
|
142
|
-
so.toBytesSink(out)
|
|
143
|
-
const hex = out.toHex()
|
|
144
|
-
expect(hex).toEqual(blob)
|
|
145
|
-
expect(hex + ':').not.toEqual(blob)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function nestedObjectTests() {
|
|
149
|
-
fixtures.whole_objects.forEach((f, i) => {
|
|
150
|
-
test(`whole_objects[${i}]: can parse blob and dump out same blob`, () => {
|
|
151
|
-
assertRecycles(f.blob_with_no_signing)
|
|
152
|
-
})
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function check(type, n, expected) {
|
|
157
|
-
test(`Uint${type.width * 8} serializes ${n} as ${expected}`, function () {
|
|
158
|
-
const bl = new BytesList()
|
|
159
|
-
const serializer = new BinarySerializer(bl)
|
|
160
|
-
if (expected === 'throws') {
|
|
161
|
-
expect(() => serializer.writeType(type, n)).toThrow()
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
serializer.writeType(type, n)
|
|
165
|
-
expect(bl.toBytes()).toEqual(Buffer.from(expected))
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
check(UInt8, 5, [5])
|
|
170
|
-
check(UInt16, 5, [0, 5])
|
|
171
|
-
check(UInt32, 5, [0, 0, 0, 5])
|
|
172
|
-
check(UInt32, 0xffffffff, [255, 255, 255, 255])
|
|
173
|
-
check(UInt8, 0xfeffffff, 'throws')
|
|
174
|
-
check(UInt16, 0xfeffffff, 'throws')
|
|
175
|
-
check(UInt16, 0xfeffffff, 'throws')
|
|
176
|
-
check(UInt64, 0xfeffffff, [0, 0, 0, 0, 254, 255, 255, 255])
|
|
177
|
-
check(UInt64, -1, 'throws')
|
|
178
|
-
check(UInt64, 0, [0, 0, 0, 0, 0, 0, 0, 0])
|
|
179
|
-
check(UInt64, 1, [0, 0, 0, 0, 0, 0, 0, 1])
|
|
180
|
-
check(UInt64, bigInt(1), [0, 0, 0, 0, 0, 0, 0, 1])
|
|
181
|
-
|
|
182
|
-
function deliverMinTest() {
|
|
183
|
-
test('can serialize DeliverMin', () => {
|
|
184
|
-
expect(encode(deliverMinTx)).toEqual(deliverMinTxBinary)
|
|
185
|
-
})
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function SignerListSetTest() {
|
|
189
|
-
test('can serialize SignerListSet', () => {
|
|
190
|
-
expect(encode(SignerListSet.tx)).toEqual(SignerListSet.binary)
|
|
191
|
-
})
|
|
192
|
-
test('can serialize SignerListSet metadata', () => {
|
|
193
|
-
expect(encode(SignerListSet.tx.meta)).toEqual(SignerListSet.meta)
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function DepositPreauthTest() {
|
|
198
|
-
test('can serialize DepositPreauth', () => {
|
|
199
|
-
expect(encode(DepositPreauth.tx)).toEqual(DepositPreauth.binary)
|
|
200
|
-
})
|
|
201
|
-
test('can serialize DepositPreauth metadata', () => {
|
|
202
|
-
expect(encode(DepositPreauth.tx.meta)).toEqual(DepositPreauth.meta)
|
|
203
|
-
})
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function EscrowTest() {
|
|
207
|
-
test('can serialize EscrowCreate', () => {
|
|
208
|
-
expect(encode(Escrow.create.tx)).toEqual(Escrow.create.binary)
|
|
209
|
-
})
|
|
210
|
-
test('can serialize EscrowFinish', () => {
|
|
211
|
-
expect(encode(Escrow.finish.tx)).toEqual(Escrow.finish.binary)
|
|
212
|
-
expect(encode(Escrow.finish.tx.meta)).toEqual(Escrow.finish.meta)
|
|
213
|
-
})
|
|
214
|
-
test('can serialize EscrowCancel', () => {
|
|
215
|
-
expect(encode(Escrow.cancel.tx)).toEqual(Escrow.cancel.binary)
|
|
216
|
-
})
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function PaymentChannelTest() {
|
|
220
|
-
test('can serialize PaymentChannelCreate', () => {
|
|
221
|
-
expect(encode(PaymentChannel.create.tx)).toEqual(
|
|
222
|
-
PaymentChannel.create.binary,
|
|
223
|
-
)
|
|
224
|
-
})
|
|
225
|
-
test('can serialize PaymentChannelFund', () => {
|
|
226
|
-
expect(encode(PaymentChannel.fund.tx)).toEqual(PaymentChannel.fund.binary)
|
|
227
|
-
})
|
|
228
|
-
test('can serialize PaymentChannelClaim', () => {
|
|
229
|
-
expect(encode(PaymentChannel.claim.tx)).toEqual(PaymentChannel.claim.binary)
|
|
230
|
-
})
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function NegativeUNLTest() {
|
|
234
|
-
test('can serialize NegativeUNL', () => {
|
|
235
|
-
expect(encode(NegativeUNL.tx)).toEqual(NegativeUNL.binary)
|
|
236
|
-
})
|
|
237
|
-
test('can deserialize NegativeUNL', () => {
|
|
238
|
-
expect(decode(NegativeUNL.binary)).toEqual(NegativeUNL.tx)
|
|
239
|
-
})
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function UNLReportTest() {
|
|
243
|
-
test('can serialize UNLReport', () => {
|
|
244
|
-
expect(encode(UNLReport.tx)).toEqual(UNLReport.binary)
|
|
245
|
-
})
|
|
246
|
-
test('can serialize UNLReport metadata', () => {
|
|
247
|
-
expect(encode(UNLReport.tx.meta)).toEqual(UNLReport.meta)
|
|
248
|
-
})
|
|
249
|
-
test('can deserialize UNLReport metadata', () => {
|
|
250
|
-
expect(decode(UNLReport.meta)).toEqual(UNLReport.tx.meta)
|
|
251
|
-
})
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function omitUndefinedTest() {
|
|
255
|
-
test('omits fields with undefined value', () => {
|
|
256
|
-
let encodedOmitted = encode(json_omitted)
|
|
257
|
-
let encodedUndefined = encode(json_undefined)
|
|
258
|
-
expect(encodedOmitted).toEqual(encodedUndefined)
|
|
259
|
-
expect(decode(encodedOmitted)).toEqual(decode(encodedUndefined))
|
|
260
|
-
})
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function ticketTest() {
|
|
264
|
-
test('can serialize TicketCreate', () => {
|
|
265
|
-
expect(encode(Ticket.create.tx)).toEqual(Ticket.create.binary)
|
|
266
|
-
})
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function nfTokenTest() {
|
|
270
|
-
const fixtures = require('./fixtures/nf-token.json')
|
|
271
|
-
|
|
272
|
-
for (const txName of Object.keys(fixtures)) {
|
|
273
|
-
test(`can serialize transaction ${txName}`, () => {
|
|
274
|
-
expect(encode(fixtures[txName].tx.json)).toEqual(
|
|
275
|
-
fixtures[txName].tx.binary,
|
|
276
|
-
)
|
|
277
|
-
})
|
|
278
|
-
|
|
279
|
-
test(`can deserialize transaction ${txName}`, () => {
|
|
280
|
-
expect(decode(fixtures[txName].tx.binary)).toEqual(
|
|
281
|
-
fixtures[txName].tx.json,
|
|
282
|
-
)
|
|
283
|
-
})
|
|
284
|
-
|
|
285
|
-
test(`can serialize meta ${txName}`, () => {
|
|
286
|
-
expect(encode(fixtures[txName].meta.json)).toEqual(
|
|
287
|
-
fixtures[txName].meta.binary,
|
|
288
|
-
)
|
|
289
|
-
})
|
|
290
|
-
|
|
291
|
-
test(`can deserialize meta ${txName}`, () => {
|
|
292
|
-
expect(decode(fixtures[txName].meta.binary)).toEqual(
|
|
293
|
-
fixtures[txName].meta.json,
|
|
294
|
-
)
|
|
295
|
-
})
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function RemitTest() {
|
|
300
|
-
test('can serialize Remit', () => {
|
|
301
|
-
expect(encode(Remit.tx)).toEqual(Remit.binary)
|
|
302
|
-
})
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
describe('Binary Serialization', function () {
|
|
306
|
-
describe('nestedObjectTests', nestedObjectTests)
|
|
307
|
-
describe('BytesList', bytesListTest)
|
|
308
|
-
describe('DeliverMin', deliverMinTest)
|
|
309
|
-
describe('DepositPreauth', DepositPreauthTest)
|
|
310
|
-
describe('SignerListSet', SignerListSetTest)
|
|
311
|
-
describe('Escrow', EscrowTest)
|
|
312
|
-
describe('PaymentChannel', PaymentChannelTest)
|
|
313
|
-
describe('NegativeUNLTest', NegativeUNLTest)
|
|
314
|
-
describe('OmitUndefined', omitUndefinedTest)
|
|
315
|
-
describe('TicketTest', ticketTest)
|
|
316
|
-
describe('NFToken', nfTokenTest)
|
|
317
|
-
describe('UNLReport', UNLReportTest)
|
|
318
|
-
describe('Remit', RemitTest)
|
|
319
|
-
})
|
package/test/definitions.test.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
const { encode, decode, XrplDefinitions } = require('../src')
|
|
2
|
-
const normalDefinitionsJson = require('../src/enums/definitions.json')
|
|
3
|
-
const { UInt32 } = require('../dist/types/uint-32')
|
|
4
|
-
|
|
5
|
-
const txJson = {
|
|
6
|
-
Account: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
|
|
7
|
-
Amount: '1000',
|
|
8
|
-
Destination: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
|
|
9
|
-
Fee: '10',
|
|
10
|
-
Flags: 0,
|
|
11
|
-
Sequence: 1,
|
|
12
|
-
TransactionType: 'Payment',
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe('encode and decode using new types as a parameter', function () {
|
|
16
|
-
test('can encode and decode a new TransactionType', function () {
|
|
17
|
-
const tx = { ...txJson, TransactionType: 'NewTestTransaction' }
|
|
18
|
-
// Before updating the types, this should not be encodable
|
|
19
|
-
expect(() => encode(tx)).toThrow()
|
|
20
|
-
|
|
21
|
-
// Normally this would be generated directly from rippled with something like `server_definitions`.
|
|
22
|
-
// Added here to make it easier to see what is actually changing in the definitions.json file.
|
|
23
|
-
const definitions = JSON.parse(JSON.stringify(normalDefinitionsJson))
|
|
24
|
-
definitions.TRANSACTION_TYPES['NewTestTransaction'] = 30
|
|
25
|
-
|
|
26
|
-
const newDefs = new XrplDefinitions(definitions)
|
|
27
|
-
|
|
28
|
-
const encoded = encode(tx, newDefs)
|
|
29
|
-
expect(() => decode(encoded)).toThrow()
|
|
30
|
-
const decoded = decode(encoded, newDefs)
|
|
31
|
-
expect(decoded).toStrictEqual(tx)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test('can encode and decode a new Field', function () {
|
|
35
|
-
const tx = { ...txJson, NewFieldDefinition: 10 }
|
|
36
|
-
|
|
37
|
-
// Before updating the types, undefined fields will be ignored on encode
|
|
38
|
-
expect(decode(encode(tx))).not.toStrictEqual(tx)
|
|
39
|
-
|
|
40
|
-
// Normally this would be generated directly from rippled with something like `server_definitions`.
|
|
41
|
-
// Added here to make it easier to see what is actually changing in the definitions.json file.
|
|
42
|
-
const definitions = JSON.parse(JSON.stringify(normalDefinitionsJson))
|
|
43
|
-
|
|
44
|
-
definitions.FIELDS.push([
|
|
45
|
-
'NewFieldDefinition',
|
|
46
|
-
{
|
|
47
|
-
nth: 101,
|
|
48
|
-
isVLEncoded: false,
|
|
49
|
-
isSerialized: true,
|
|
50
|
-
isSigningField: true,
|
|
51
|
-
type: 'UInt32',
|
|
52
|
-
},
|
|
53
|
-
])
|
|
54
|
-
|
|
55
|
-
const newDefs = new XrplDefinitions(definitions)
|
|
56
|
-
|
|
57
|
-
const encoded = encode(tx, newDefs)
|
|
58
|
-
expect(() => decode(encoded)).toThrow()
|
|
59
|
-
const decoded = decode(encoded, newDefs)
|
|
60
|
-
expect(decoded).toStrictEqual(tx)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test('can encode and decode a new Type', function () {
|
|
64
|
-
const tx = {
|
|
65
|
-
...txJson,
|
|
66
|
-
TestField: 10, // Should work the same as a UInt32
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Normally this would be generated directly from rippled with something like `server_definitions`.
|
|
70
|
-
// Added here to make it easier to see what is actually changing in the definitions.json file.
|
|
71
|
-
const definitions = JSON.parse(JSON.stringify(normalDefinitionsJson))
|
|
72
|
-
definitions.TYPES.NewType = 24
|
|
73
|
-
definitions.FIELDS.push([
|
|
74
|
-
'TestField',
|
|
75
|
-
{
|
|
76
|
-
nth: 100,
|
|
77
|
-
isVLEncoded: true,
|
|
78
|
-
isSerialized: true,
|
|
79
|
-
isSigningField: true,
|
|
80
|
-
type: 'NewType',
|
|
81
|
-
},
|
|
82
|
-
])
|
|
83
|
-
|
|
84
|
-
// Test that before updating the types this tx fails to decode correctly. Note that undefined fields are ignored on encode.
|
|
85
|
-
expect(decode(encode(tx))).not.toStrictEqual(tx)
|
|
86
|
-
|
|
87
|
-
class NewType extends UInt32 {
|
|
88
|
-
// Should be the same as UInt32
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const extendedCoreTypes = { NewType }
|
|
92
|
-
|
|
93
|
-
const newDefs = new XrplDefinitions(definitions, extendedCoreTypes)
|
|
94
|
-
|
|
95
|
-
const encoded = encode(tx, newDefs)
|
|
96
|
-
expect(() => decode(encoded)).toThrow()
|
|
97
|
-
const decoded = decode(encoded, newDefs)
|
|
98
|
-
expect(decoded).toStrictEqual(tx)
|
|
99
|
-
})
|
|
100
|
-
})
|
|
Binary file
|