ripple-binary-codec 1.7.1 → 1.9.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/enums/definitions.json +250 -1
- package/dist/enums/src/enums/definitions.json +250 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.d.ts +39 -0
- package/dist/types/issue.js +81 -0
- package/dist/types/issue.js.map +1 -0
- package/dist/types/xchain-bridge.d.ts +45 -0
- package/dist/types/xchain-bridge.js +102 -0
- package/dist/types/xchain-bridge.js.map +1 -0
- package/package.json +3 -4
- package/src/README.md +3 -0
- package/src/binary.ts +188 -0
- package/src/coretypes.ts +31 -0
- package/src/enums/README.md +144 -0
- package/src/enums/bytes.ts +75 -0
- package/src/enums/constants.ts +4 -0
- package/src/enums/definitions.json +2599 -0
- package/src/enums/field.ts +85 -0
- package/src/enums/index.ts +34 -0
- package/src/enums/utils-renumber.ts +134 -0
- package/src/enums/xrpl-definitions-base.ts +111 -0
- package/src/enums/xrpl-definitions.ts +32 -0
- package/src/hash-prefixes.ts +40 -0
- package/src/hashes.ts +76 -0
- package/src/index.ts +141 -0
- package/src/ledger-hashes.ts +187 -0
- package/src/quality.ts +39 -0
- package/src/serdes/binary-parser.ts +217 -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 +256 -0
- package/src/types/blob.ts +43 -0
- package/src/types/currency.ts +140 -0
- package/src/types/hash-128.ts +33 -0
- package/src/types/hash-160.ts +20 -0
- package/src/types/hash-256.ts +16 -0
- package/src/types/hash.ts +81 -0
- package/src/types/index.ts +61 -0
- package/src/types/issue.ts +96 -0
- package/src/types/path-set.ts +290 -0
- package/src/types/serialized-type.ts +120 -0
- package/src/types/st-array.ts +107 -0
- package/src/types/st-object.ts +192 -0
- package/src/types/uint-16.ts +49 -0
- package/src/types/uint-32.ts +56 -0
- package/src/types/uint-64.ts +105 -0
- package/src/types/uint-8.ts +49 -0
- package/src/types/uint.ts +57 -0
- package/src/types/vector-256.ts +84 -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 -289
- package/test/definitions.test.js +0 -160
- 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/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/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 -242
- 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
package/test/x-address.test.js
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
const { encode, decode } = require('./../src/index')
|
|
2
|
-
const fixtures = require('./fixtures/x-codec-fixtures.json')
|
|
3
|
-
|
|
4
|
-
let json_x1 = {
|
|
5
|
-
OwnerCount: 0,
|
|
6
|
-
Account: 'XVXdn5wEVm5G4UhEHWDPqjvdeH361P7BsapL4m2D2XnPSwT',
|
|
7
|
-
PreviousTxnLgrSeq: 7,
|
|
8
|
-
LedgerEntryType: 'AccountRoot',
|
|
9
|
-
PreviousTxnID:
|
|
10
|
-
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
11
|
-
Flags: 0,
|
|
12
|
-
Sequence: 1,
|
|
13
|
-
Balance: '10000000000',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let json_r1 = {
|
|
17
|
-
OwnerCount: 0,
|
|
18
|
-
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
19
|
-
PreviousTxnLgrSeq: 7,
|
|
20
|
-
LedgerEntryType: 'AccountRoot',
|
|
21
|
-
PreviousTxnID:
|
|
22
|
-
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
23
|
-
Flags: 0,
|
|
24
|
-
Sequence: 1,
|
|
25
|
-
Balance: '10000000000',
|
|
26
|
-
SourceTag: 12345,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let json_null_x = {
|
|
30
|
-
OwnerCount: 0,
|
|
31
|
-
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
32
|
-
Destination: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
33
|
-
Issuer: 'XVXdn5wEVm5G4UhEHWDPqjvdeH361P4GETfNyyXGaoqBj71',
|
|
34
|
-
PreviousTxnLgrSeq: 7,
|
|
35
|
-
LedgerEntryType: 'AccountRoot',
|
|
36
|
-
PreviousTxnID:
|
|
37
|
-
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
38
|
-
Flags: 0,
|
|
39
|
-
Sequence: 1,
|
|
40
|
-
Balance: '10000000000',
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let json_invalid_x = {
|
|
44
|
-
OwnerCount: 0,
|
|
45
|
-
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
46
|
-
Destination: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
47
|
-
Issuer: 'XVXdn5wEVm5g4UhEHWDPqjvdeH361P4GETfNyyXGaoqBj71',
|
|
48
|
-
PreviousTxnLgrSeq: 7,
|
|
49
|
-
LedgerEntryType: 'AccountRoot',
|
|
50
|
-
PreviousTxnID:
|
|
51
|
-
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
52
|
-
Flags: 0,
|
|
53
|
-
Sequence: 1,
|
|
54
|
-
Balance: '10000000000',
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let json_null_r = {
|
|
58
|
-
OwnerCount: 0,
|
|
59
|
-
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
60
|
-
Destination: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
61
|
-
Issuer: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
62
|
-
PreviousTxnLgrSeq: 7,
|
|
63
|
-
LedgerEntryType: 'AccountRoot',
|
|
64
|
-
PreviousTxnID:
|
|
65
|
-
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
66
|
-
Flags: 0,
|
|
67
|
-
Sequence: 1,
|
|
68
|
-
Balance: '10000000000',
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let invalid_json_issuer_tagged = {
|
|
72
|
-
OwnerCount: 0,
|
|
73
|
-
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
74
|
-
Destination: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
75
|
-
Issuer: 'XVXdn5wEVm5G4UhEHWDPqjvdeH361P7BsapL4m2D2XnPSwT',
|
|
76
|
-
PreviousTxnLgrSeq: 7,
|
|
77
|
-
LedgerEntryType: 'AccountRoot',
|
|
78
|
-
PreviousTxnID:
|
|
79
|
-
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
80
|
-
Flags: 0,
|
|
81
|
-
Sequence: 1,
|
|
82
|
-
Balance: '10000000000',
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
let invalid_json_x_and_tagged = {
|
|
86
|
-
OwnerCount: 0,
|
|
87
|
-
Account: 'XVXdn5wEVm5G4UhEHWDPqjvdeH361P7BsapL4m2D2XnPSwT',
|
|
88
|
-
PreviousTxnLgrSeq: 7,
|
|
89
|
-
LedgerEntryType: 'AccountRoot',
|
|
90
|
-
PreviousTxnID:
|
|
91
|
-
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
92
|
-
Flags: 0,
|
|
93
|
-
Sequence: 1,
|
|
94
|
-
Balance: '10000000000',
|
|
95
|
-
SourceTag: 12345,
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
let json_issued_x = {
|
|
99
|
-
TakerPays: {
|
|
100
|
-
currency: 'USD',
|
|
101
|
-
issuer: 'X7WZKEeNVS2p9Tire9DtNFkzWBZbFtJHWxDjN9fCrBGqVA4',
|
|
102
|
-
value: '7072.8',
|
|
103
|
-
},
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
let json_issued_r = {
|
|
107
|
-
TakerPays: {
|
|
108
|
-
currency: 'USD',
|
|
109
|
-
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
|
110
|
-
value: '7072.8',
|
|
111
|
-
},
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
let json_issued_with_tag = {
|
|
115
|
-
TakerPays: {
|
|
116
|
-
currency: 'USD',
|
|
117
|
-
issuer: 'X7WZKEeNVS2p9Tire9DtNFkzWBZbFtSiS2eDBib7svZXuc2',
|
|
118
|
-
value: '7072.8',
|
|
119
|
-
},
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
describe('X-Address Account is equivalent to a classic address w/ SourceTag', () => {
|
|
123
|
-
let encoded_x = encode(json_x1)
|
|
124
|
-
let encoded_r = encode(json_r1)
|
|
125
|
-
test('Can encode with x-Address', () => {
|
|
126
|
-
expect(encoded_x).toEqual(encoded_r)
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
test('decoded X-address is object w/ source and tag', () => {
|
|
130
|
-
let decoded_x = decode(encoded_x)
|
|
131
|
-
expect(decoded_x).toEqual(json_r1)
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
test('Encoding issuer X-Address w/ undefined destination tag', () => {
|
|
135
|
-
expect(encode(json_null_x)).toEqual(encode(json_null_r))
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
test('Throws when X-Address is invalid', () => {
|
|
139
|
-
expect(() => encode(json_invalid_x)).toThrow('checksum_invalid')
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
test('Encodes issued currency w/ x-address', () => {
|
|
143
|
-
expect(encode(json_issued_x)).toEqual(encode(json_issued_r))
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
describe('Invalid X-Address behavior', () => {
|
|
148
|
-
test('X-Address with tag throws value for invalid field', () => {
|
|
149
|
-
expect(() => encode(invalid_json_issuer_tagged)).toThrow(
|
|
150
|
-
new Error('Issuer cannot have an associated tag'),
|
|
151
|
-
)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
test('Throws when Account has both X-Addr and Destination Tag', () => {
|
|
155
|
-
expect(() => encode(invalid_json_x_and_tagged)).toThrow(
|
|
156
|
-
new Error('Cannot have Account X-Address and SourceTag'),
|
|
157
|
-
)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
test('Throws when issued currency has tag', () => {
|
|
161
|
-
expect(() => encode(json_issued_with_tag)).toThrow(
|
|
162
|
-
'Only allowed to have tag on Account or Destination',
|
|
163
|
-
)
|
|
164
|
-
})
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
describe('ripple-binary-codec x-address test', function () {
|
|
168
|
-
function makeSuite(name, entries) {
|
|
169
|
-
describe(name, function () {
|
|
170
|
-
entries.forEach((t, testN) => {
|
|
171
|
-
test(`${name}[${testN}] encodes X-address json equivalent to classic address json`, () => {
|
|
172
|
-
expect(encode(t.rjson)).toEqual(encode(t.xjson))
|
|
173
|
-
})
|
|
174
|
-
test(`${name}[${testN}] decodes X-address json equivalent to classic address json`, () => {
|
|
175
|
-
expect(decode(encode(t.xjson))).toEqual(t.rjson)
|
|
176
|
-
})
|
|
177
|
-
})
|
|
178
|
-
})
|
|
179
|
-
}
|
|
180
|
-
makeSuite('transactions', fixtures.transactions)
|
|
181
|
-
})
|