ripple-binary-codec 1.2.0-beta.1 → 1.2.2
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 +6 -6
- package/dist/binary.js.map +1 -1
- package/dist/coretypes.d.ts +8 -8
- package/dist/coretypes.js.map +1 -1
- package/dist/enums/index.d.ts +6 -5
- package/dist/enums/index.js +3 -2
- package/dist/enums/index.js.map +1 -1
- package/dist/enums/utils-renumber.js +12 -12
- package/dist/enums/utils-renumber.js.map +1 -1
- package/dist/hash-prefixes.d.ts +1 -1
- package/dist/hash-prefixes.js.map +1 -1
- package/dist/hashes.d.ts +3 -3
- package/dist/hashes.js +5 -4
- package/dist/hashes.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/ledger-hashes.d.ts +3 -3
- package/dist/ledger-hashes.js +5 -5
- package/dist/ledger-hashes.js.map +1 -1
- package/dist/quality.d.ts +2 -2
- package/dist/quality.js +4 -4
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.d.ts +3 -3
- package/dist/serdes/binary-parser.js +10 -10
- package/dist/serdes/binary-parser.js.map +1 -1
- package/dist/serdes/binary-serializer.d.ts +5 -5
- package/dist/serdes/binary-serializer.js +13 -8
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/shamap.d.ts +3 -3
- package/dist/shamap.js +5 -3
- package/dist/shamap.js.map +1 -1
- package/dist/types/account-id.d.ts +2 -2
- package/dist/types/account-id.js +12 -10
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +3 -3
- package/dist/types/amount.js +23 -21
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +3 -3
- package/dist/types/blob.js +6 -4
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +2 -2
- package/dist/types/currency.js +14 -12
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +2 -2
- package/dist/types/hash-128.js +3 -1
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +2 -2
- package/dist/types/hash-160.js +3 -1
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-256.d.ts +2 -2
- package/dist/types/hash-256.js +3 -1
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/hash.d.ts +3 -3
- package/dist/types/hash.js +7 -5
- package/dist/types/hash.js.map +1 -1
- package/dist/types/index.d.ts +15 -15
- package/dist/types/index.js +3 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/path-set.d.ts +2 -2
- package/dist/types/path-set.js +5 -3
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +4 -4
- package/dist/types/serialized-type.js +7 -5
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +2 -2
- package/dist/types/st-array.js +6 -4
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-object.d.ts +2 -2
- package/dist/types/st-object.js +25 -14
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +3 -3
- package/dist/types/uint-16.js +5 -3
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +3 -3
- package/dist/types/uint-32.js +6 -4
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +4 -4
- package/dist/types/uint-64.js +12 -10
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +3 -3
- package/dist/types/uint-8.js +5 -3
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/uint.d.ts +3 -3
- package/dist/types/uint.js +4 -2
- package/dist/types/uint.js.map +1 -1
- package/dist/types/vector-256.d.ts +3 -3
- package/dist/types/vector-256.js +7 -5
- package/dist/types/vector-256.js.map +1 -1
- package/package.json +14 -29
- package/test/amount.test.js +29 -29
- package/test/binary-json.test.js +24 -26
- package/test/binary-parser.test.js +225 -227
- package/test/binary-serializer.test.js +194 -169
- package/test/fixtures/negative-unl.json +4 -4
- package/test/fixtures/nf-token.json +547 -0
- package/test/hash.test.js +85 -78
- package/test/ledger.test.js +19 -19
- package/test/lower-case-hex.test.js +28 -28
- package/test/pseudo-transaction.test.js +26 -26
- package/test/quality.test.js +13 -13
- package/test/shamap.test.js +54 -54
- package/test/signing-data-encoding.test.js +79 -79
- package/test/tx-encode-decode.test.js +63 -63
- package/test/types.test.js +23 -23
- package/test/uint.test.js +107 -107
- package/test/x-address.test.js +106 -106
- package/dist/ShaMap/ShaMap.d.ts +0 -3
- package/dist/ShaMap/ShaMap.js +0 -25
- package/dist/ShaMap/ShaMap.js.map +0 -1
- package/dist/ShaMap/ShaMapInner.d.ts +0 -66
- package/dist/ShaMap/ShaMapInner.js +0 -145
- package/dist/ShaMap/ShaMapInner.js.map +0 -1
- package/dist/ShaMap/ShaMapLeaf.d.ts +0 -42
- package/dist/ShaMap/ShaMapLeaf.js +0 -84
- package/dist/ShaMap/ShaMapLeaf.js.map +0 -1
- package/dist/ShaMap/ShaMapNode.d.ts +0 -13
- package/dist/ShaMap/ShaMapNode.js +0 -12
- package/dist/ShaMap/ShaMapNode.js.map +0 -1
- package/dist/ShaMap/index.d.ts +0 -3
- package/dist/ShaMap/index.js +0 -9
- package/dist/ShaMap/index.js.map +0 -1
- package/dist/enums/Bytes.d.ts +0 -10
- package/dist/enums/Bytes.js +0 -30
- package/dist/enums/Bytes.js.map +0 -1
- package/dist/enums/BytesLookup.d.ts +0 -8
- package/dist/enums/BytesLookup.js +0 -29
- package/dist/enums/BytesLookup.js.map +0 -1
- package/dist/enums/Field.d.ts +0 -3
- package/dist/enums/Field.js +0 -9
- package/dist/enums/Field.js.map +0 -1
- package/dist/enums/FieldInfo.d.ts +0 -7
- package/dist/enums/FieldInfo.js +0 -3
- package/dist/enums/FieldInfo.js.map +0 -1
- package/dist/enums/FieldInstance.d.ts +0 -14
- package/dist/enums/FieldInstance.js +0 -3
- package/dist/enums/FieldInstance.js.map +0 -1
- package/dist/enums/FieldLookup.d.ts +0 -11
- package/dist/enums/FieldLookup.js +0 -102
- package/dist/enums/FieldLookup.js.map +0 -1
- package/dist/serdes/BinaryParser.d.ts +0 -100
- package/dist/serdes/BinaryParser.js +0 -200
- package/dist/serdes/BinaryParser.js.map +0 -1
- package/dist/serdes/BinarySerializer.d.ts +0 -50
- package/dist/serdes/BinarySerializer.js +0 -105
- package/dist/serdes/BinarySerializer.js.map +0 -1
- package/dist/serdes/BytesList.d.ts +0 -28
- package/dist/serdes/BytesList.js +0 -48
- package/dist/serdes/BytesList.js.map +0 -1
- package/dist/types/Comparable.d.ts +0 -18
- package/dist/types/Comparable.js +0 -43
- package/dist/types/Comparable.js.map +0 -1
- package/dist/types/PathSet/Hop.d.ts +0 -41
- package/dist/types/PathSet/Hop.js +0 -116
- package/dist/types/PathSet/Hop.js.map +0 -1
- package/dist/types/PathSet/Path.d.ts +0 -33
- package/dist/types/PathSet/Path.js +0 -83
- package/dist/types/PathSet/Path.js.map +0 -1
- package/dist/types/PathSet/index.d.ts +0 -29
- package/dist/types/PathSet/index.js +0 -98
- package/dist/types/PathSet/index.js.map +0 -1
- package/dist/types/SerializedType.d.ts +0 -47
- package/dist/types/SerializedType.js +0 -69
- package/dist/types/SerializedType.js.map +0 -1
package/test/uint.test.js
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
const { coreTypes } = require(
|
|
2
|
-
const { UInt8, UInt64 } = coreTypes
|
|
1
|
+
const { coreTypes } = require('../dist/types')
|
|
2
|
+
const { UInt8, UInt64 } = coreTypes
|
|
3
3
|
|
|
4
|
-
const { encode } = require(
|
|
4
|
+
const { encode } = require('../dist')
|
|
5
5
|
|
|
6
6
|
const binary =
|
|
7
|
-
|
|
7
|
+
'11007222000300003700000000000000003800000000000000006280000000000000000000000000000000000000005553440000000000000000000000000000000000000000000000000166D5438D7EA4C680000000000000000000000000005553440000000000AE123A8556F3CF91154711376AFB0F894F832B3D67D5438D7EA4C680000000000000000000000000005553440000000000F51DFC2A09D62CBBA1DFBDD4691DAC96AD98B90F'
|
|
8
8
|
const json = {
|
|
9
9
|
Balance: {
|
|
10
|
-
currency:
|
|
11
|
-
issuer:
|
|
12
|
-
value:
|
|
10
|
+
currency: 'USD',
|
|
11
|
+
issuer: 'rrrrrrrrrrrrrrrrrrrrBZbvji',
|
|
12
|
+
value: '0',
|
|
13
13
|
},
|
|
14
14
|
Flags: 196608,
|
|
15
15
|
HighLimit: {
|
|
16
|
-
currency:
|
|
17
|
-
issuer:
|
|
18
|
-
value:
|
|
16
|
+
currency: 'USD',
|
|
17
|
+
issuer: 'rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK',
|
|
18
|
+
value: '1000',
|
|
19
19
|
},
|
|
20
|
-
HighNode:
|
|
21
|
-
LedgerEntryType:
|
|
20
|
+
HighNode: '0',
|
|
21
|
+
LedgerEntryType: 'RippleState',
|
|
22
22
|
LowLimit: {
|
|
23
|
-
currency:
|
|
24
|
-
issuer:
|
|
25
|
-
value:
|
|
23
|
+
currency: 'USD',
|
|
24
|
+
issuer: 'rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn',
|
|
25
|
+
value: '1000',
|
|
26
26
|
},
|
|
27
|
-
LowNode:
|
|
28
|
-
}
|
|
27
|
+
LowNode: '0',
|
|
28
|
+
}
|
|
29
29
|
|
|
30
30
|
const binaryEntry0 =
|
|
31
|
-
|
|
31
|
+
'11007222001100002501EC24873700000000000000003800000000000000A35506FC7DE374089D50F81AAE13E7BBF3D0E694769331E14F55351B38D0148018EA62D44BF89AC2A40B800000000000000000000000004A50590000000000000000000000000000000000000000000000000166D6C38D7EA4C680000000000000000000000000004A5059000000000047C1258B4B79774B28176324068F759EDE226F686780000000000000000000000000000000000000004A505900000000005BBC0F22F61D9224A110650CFE21CC0C4BE13098'
|
|
32
32
|
const jsonEntry0 = {
|
|
33
33
|
Balance: {
|
|
34
|
-
currency:
|
|
35
|
-
issuer:
|
|
36
|
-
value:
|
|
34
|
+
currency: 'JPY',
|
|
35
|
+
issuer: 'rrrrrrrrrrrrrrrrrrrrBZbvji',
|
|
36
|
+
value: '0.3369568318',
|
|
37
37
|
},
|
|
38
38
|
Flags: 1114112,
|
|
39
39
|
HighLimit: {
|
|
40
|
-
currency:
|
|
41
|
-
issuer:
|
|
42
|
-
value:
|
|
40
|
+
currency: 'JPY',
|
|
41
|
+
issuer: 'r94s8px6kSw1uZ1MV98dhSRTvc6VMPoPcN',
|
|
42
|
+
value: '0',
|
|
43
43
|
},
|
|
44
|
-
HighNode:
|
|
45
|
-
LedgerEntryType:
|
|
44
|
+
HighNode: 'a3',
|
|
45
|
+
LedgerEntryType: 'RippleState',
|
|
46
46
|
LowLimit: {
|
|
47
|
-
currency:
|
|
48
|
-
issuer:
|
|
49
|
-
value:
|
|
47
|
+
currency: 'JPY',
|
|
48
|
+
issuer: 'rfYQMgj3g3Qp8VLoZNvvU35mEuuJC8nCmY',
|
|
49
|
+
value: '1000000000',
|
|
50
50
|
},
|
|
51
|
-
LowNode:
|
|
51
|
+
LowNode: '0',
|
|
52
52
|
PreviousTxnID:
|
|
53
|
-
|
|
53
|
+
'06FC7DE374089D50F81AAE13E7BBF3D0E694769331E14F55351B38D0148018EA',
|
|
54
54
|
PreviousTxnLgrSeq: 32253063,
|
|
55
|
-
index:
|
|
56
|
-
}
|
|
55
|
+
index: '000319BAE0A618A7D3BB492F17E98E5D92EA0C6458AFEBED44206B5B4798A840',
|
|
56
|
+
}
|
|
57
57
|
|
|
58
58
|
const binaryEntry1 =
|
|
59
|
-
|
|
59
|
+
'1100642200000000320000000000000002580CB3C1AD2C371136AEA434246D971C5FCCD32CBF520667E131AB7B10D706E7528214BA53D10260FFCC968ACD16BA30F7CEABAD6E5D92011340A3454ACED87177146EABD5E4A256021D836D1E3617618B1EB362D10B0D1BAC6AE1ED9E8D280BBE0B6656748FD647231851C6C650794D5E6852DFA1E35E68630F'
|
|
60
60
|
const jsonEntry1 = {
|
|
61
61
|
Flags: 0,
|
|
62
|
-
IndexPrevious:
|
|
62
|
+
IndexPrevious: '2',
|
|
63
63
|
Indexes: [
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
'A3454ACED87177146EABD5E4A256021D836D1E3617618B1EB362D10B0D1BAC6A',
|
|
65
|
+
'E1ED9E8D280BBE0B6656748FD647231851C6C650794D5E6852DFA1E35E68630F',
|
|
66
66
|
],
|
|
67
|
-
LedgerEntryType:
|
|
68
|
-
Owner:
|
|
69
|
-
RootIndex:
|
|
70
|
-
index:
|
|
71
|
-
}
|
|
67
|
+
LedgerEntryType: 'DirectoryNode',
|
|
68
|
+
Owner: 'rHzDaMNybxQppiE3uWyt2N265KvAKdiRdP',
|
|
69
|
+
RootIndex: '0CB3C1AD2C371136AEA434246D971C5FCCD32CBF520667E131AB7B10D706E752',
|
|
70
|
+
index: '0B4A2E68C111F7E42FAEEE405F7344560C8240840B151D9D04131EB79D080167',
|
|
71
|
+
}
|
|
72
72
|
|
|
73
73
|
const binaryEntry2 =
|
|
74
|
-
|
|
74
|
+
'1100722200210000250178D1CA37000000000000000038000000000000028355C0C37CE200B509E0A529880634F7841A9EF4CB65F03C12E6004CFAD9718D66946280000000000000000000000000000000000000004743420000000000000000000000000000000000000000000000000166D6071AFD498D000000000000000000000000000047434200000000002599D1D255BCA61189CA64C84528F2FCBE4BFC3867800000000000000000000000000000000000000047434200000000006EEBB1D1852CE667876A0B3630861FB6C6AB358E'
|
|
75
75
|
const jsonEntry2 = {
|
|
76
76
|
Balance: {
|
|
77
|
-
currency:
|
|
78
|
-
issuer:
|
|
79
|
-
value:
|
|
77
|
+
currency: 'GCB',
|
|
78
|
+
issuer: 'rrrrrrrrrrrrrrrrrrrrBZbvji',
|
|
79
|
+
value: '0',
|
|
80
80
|
},
|
|
81
81
|
Flags: 2162688,
|
|
82
82
|
HighLimit: {
|
|
83
|
-
currency:
|
|
84
|
-
issuer:
|
|
85
|
-
value:
|
|
83
|
+
currency: 'GCB',
|
|
84
|
+
issuer: 'rBfVgTnsdh8ckC19RM8aVGNuMZnpwrMP6n',
|
|
85
|
+
value: '0',
|
|
86
86
|
},
|
|
87
|
-
HighNode:
|
|
88
|
-
LedgerEntryType:
|
|
87
|
+
HighNode: '283',
|
|
88
|
+
LedgerEntryType: 'RippleState',
|
|
89
89
|
LowLimit: {
|
|
90
|
-
currency:
|
|
91
|
-
issuer:
|
|
92
|
-
value:
|
|
90
|
+
currency: 'GCB',
|
|
91
|
+
issuer: 'rhRFGCy2RJTA8oxkjjtYTvofPVGqcgvXWj',
|
|
92
|
+
value: '2000000',
|
|
93
93
|
},
|
|
94
|
-
LowNode:
|
|
94
|
+
LowNode: '0',
|
|
95
95
|
PreviousTxnID:
|
|
96
|
-
|
|
96
|
+
'C0C37CE200B509E0A529880634F7841A9EF4CB65F03C12E6004CFAD9718D6694',
|
|
97
97
|
PreviousTxnLgrSeq: 24695242,
|
|
98
|
-
index:
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
test(
|
|
102
|
-
expect(UInt8.from(124).compareTo(UInt64.from(124))).toBe(0)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
test(
|
|
106
|
-
expect(UInt64.from(124).compareTo(UInt8.from(124))).toBe(0)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test(
|
|
110
|
-
expect(UInt64.from(124).compareTo(UInt8.from(123))).toBe(1)
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
test(
|
|
114
|
-
expect(UInt8.from(124).compareTo(UInt8.from(13))).toBe(1)
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
test(
|
|
118
|
-
expect(UInt8.from(124).compareTo(124)).toBe(0)
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
test(
|
|
122
|
-
expect(UInt64.from(124).compareTo(124)).toBe(0)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
test(
|
|
126
|
-
expect(UInt64.from(124).compareTo(123)).toBe(1)
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
test(
|
|
130
|
-
expect(UInt8.from(124).compareTo(13)).toBe(1)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test(
|
|
134
|
-
expect(UInt64.from(
|
|
135
|
-
expect(encode(json)).toEqual(binary)
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
test(
|
|
139
|
-
expect(encode(jsonEntry0)).toEqual(binaryEntry0)
|
|
140
|
-
expect(encode(jsonEntry1)).toEqual(binaryEntry1)
|
|
141
|
-
expect(encode(jsonEntry2)).toEqual(binaryEntry2)
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
test(
|
|
145
|
-
let val = UInt8.from(1)
|
|
146
|
-
val |= 0x2
|
|
147
|
-
expect(val).toBe(3)
|
|
148
|
-
})
|
|
98
|
+
index: '0000041EFD027808D3F78C8352F97E324CB816318E00B977C74ECDDC7CD975B2',
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
test('compareToTests[0]', () => {
|
|
102
|
+
expect(UInt8.from(124).compareTo(UInt64.from(124))).toBe(0)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('compareToTest[1]', () => {
|
|
106
|
+
expect(UInt64.from(124).compareTo(UInt8.from(124))).toBe(0)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
test('compareToTest[2]', () => {
|
|
110
|
+
expect(UInt64.from(124).compareTo(UInt8.from(123))).toBe(1)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
test('compareToTest[3]', () => {
|
|
114
|
+
expect(UInt8.from(124).compareTo(UInt8.from(13))).toBe(1)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
test('compareToTest[4]', () => {
|
|
118
|
+
expect(UInt8.from(124).compareTo(124)).toBe(0)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test('compareToTest[5]', () => {
|
|
122
|
+
expect(UInt64.from(124).compareTo(124)).toBe(0)
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
test('compareToTest[6]', () => {
|
|
126
|
+
expect(UInt64.from(124).compareTo(123)).toBe(1)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
test('compareToTest[7]', () => {
|
|
130
|
+
expect(UInt8.from(124).compareTo(13)).toBe(1)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
test('UInt64 from string zero', () => {
|
|
134
|
+
expect(UInt64.from('0')).toEqual(UInt64.from(0))
|
|
135
|
+
expect(encode(json)).toEqual(binary)
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
test('UInt64 from non 16 length hex', () => {
|
|
139
|
+
expect(encode(jsonEntry0)).toEqual(binaryEntry0)
|
|
140
|
+
expect(encode(jsonEntry1)).toEqual(binaryEntry1)
|
|
141
|
+
expect(encode(jsonEntry2)).toEqual(binaryEntry2)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
test('valueOfTests', () => {
|
|
145
|
+
let val = UInt8.from(1)
|
|
146
|
+
val |= 0x2
|
|
147
|
+
expect(val).toBe(3)
|
|
148
|
+
})
|
package/test/x-address.test.js
CHANGED
|
@@ -1,181 +1,181 @@
|
|
|
1
|
-
const { encode, decode } = require(
|
|
2
|
-
const fixtures = require(
|
|
1
|
+
const { encode, decode } = require('./../dist/index')
|
|
2
|
+
const fixtures = require('./fixtures/x-codec-fixtures.json')
|
|
3
3
|
|
|
4
4
|
let json_x1 = {
|
|
5
5
|
OwnerCount: 0,
|
|
6
|
-
Account:
|
|
6
|
+
Account: 'XVXdn5wEVm5G4UhEHWDPqjvdeH361P7BsapL4m2D2XnPSwT',
|
|
7
7
|
PreviousTxnLgrSeq: 7,
|
|
8
|
-
LedgerEntryType:
|
|
8
|
+
LedgerEntryType: 'AccountRoot',
|
|
9
9
|
PreviousTxnID:
|
|
10
|
-
|
|
10
|
+
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
11
11
|
Flags: 0,
|
|
12
12
|
Sequence: 1,
|
|
13
|
-
Balance:
|
|
14
|
-
}
|
|
13
|
+
Balance: '10000000000',
|
|
14
|
+
}
|
|
15
15
|
|
|
16
16
|
let json_r1 = {
|
|
17
17
|
OwnerCount: 0,
|
|
18
|
-
Account:
|
|
18
|
+
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
19
19
|
PreviousTxnLgrSeq: 7,
|
|
20
|
-
LedgerEntryType:
|
|
20
|
+
LedgerEntryType: 'AccountRoot',
|
|
21
21
|
PreviousTxnID:
|
|
22
|
-
|
|
22
|
+
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
23
23
|
Flags: 0,
|
|
24
24
|
Sequence: 1,
|
|
25
|
-
Balance:
|
|
25
|
+
Balance: '10000000000',
|
|
26
26
|
SourceTag: 12345,
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
|
|
29
29
|
let json_null_x = {
|
|
30
30
|
OwnerCount: 0,
|
|
31
|
-
Account:
|
|
32
|
-
Destination:
|
|
33
|
-
Issuer:
|
|
31
|
+
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
32
|
+
Destination: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
33
|
+
Issuer: 'XVXdn5wEVm5G4UhEHWDPqjvdeH361P4GETfNyyXGaoqBj71',
|
|
34
34
|
PreviousTxnLgrSeq: 7,
|
|
35
|
-
LedgerEntryType:
|
|
35
|
+
LedgerEntryType: 'AccountRoot',
|
|
36
36
|
PreviousTxnID:
|
|
37
|
-
|
|
37
|
+
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
38
38
|
Flags: 0,
|
|
39
39
|
Sequence: 1,
|
|
40
|
-
Balance:
|
|
41
|
-
}
|
|
40
|
+
Balance: '10000000000',
|
|
41
|
+
}
|
|
42
42
|
|
|
43
43
|
let json_invalid_x = {
|
|
44
44
|
OwnerCount: 0,
|
|
45
|
-
Account:
|
|
46
|
-
Destination:
|
|
47
|
-
Issuer:
|
|
45
|
+
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
46
|
+
Destination: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
47
|
+
Issuer: 'XVXdn5wEVm5g4UhEHWDPqjvdeH361P4GETfNyyXGaoqBj71',
|
|
48
48
|
PreviousTxnLgrSeq: 7,
|
|
49
|
-
LedgerEntryType:
|
|
49
|
+
LedgerEntryType: 'AccountRoot',
|
|
50
50
|
PreviousTxnID:
|
|
51
|
-
|
|
51
|
+
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
52
52
|
Flags: 0,
|
|
53
53
|
Sequence: 1,
|
|
54
|
-
Balance:
|
|
55
|
-
}
|
|
54
|
+
Balance: '10000000000',
|
|
55
|
+
}
|
|
56
56
|
|
|
57
57
|
let json_null_r = {
|
|
58
58
|
OwnerCount: 0,
|
|
59
|
-
Account:
|
|
60
|
-
Destination:
|
|
61
|
-
Issuer:
|
|
59
|
+
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
60
|
+
Destination: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
61
|
+
Issuer: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
62
62
|
PreviousTxnLgrSeq: 7,
|
|
63
|
-
LedgerEntryType:
|
|
63
|
+
LedgerEntryType: 'AccountRoot',
|
|
64
64
|
PreviousTxnID:
|
|
65
|
-
|
|
65
|
+
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
66
66
|
Flags: 0,
|
|
67
67
|
Sequence: 1,
|
|
68
|
-
Balance:
|
|
69
|
-
}
|
|
68
|
+
Balance: '10000000000',
|
|
69
|
+
}
|
|
70
70
|
|
|
71
71
|
let invalid_json_issuer_tagged = {
|
|
72
72
|
OwnerCount: 0,
|
|
73
|
-
Account:
|
|
74
|
-
Destination:
|
|
75
|
-
Issuer:
|
|
73
|
+
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
74
|
+
Destination: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv',
|
|
75
|
+
Issuer: 'XVXdn5wEVm5G4UhEHWDPqjvdeH361P7BsapL4m2D2XnPSwT',
|
|
76
76
|
PreviousTxnLgrSeq: 7,
|
|
77
|
-
LedgerEntryType:
|
|
77
|
+
LedgerEntryType: 'AccountRoot',
|
|
78
78
|
PreviousTxnID:
|
|
79
|
-
|
|
79
|
+
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
80
80
|
Flags: 0,
|
|
81
81
|
Sequence: 1,
|
|
82
|
-
Balance:
|
|
83
|
-
}
|
|
82
|
+
Balance: '10000000000',
|
|
83
|
+
}
|
|
84
84
|
|
|
85
85
|
let invalid_json_x_and_tagged = {
|
|
86
86
|
OwnerCount: 0,
|
|
87
|
-
Account:
|
|
87
|
+
Account: 'XVXdn5wEVm5G4UhEHWDPqjvdeH361P7BsapL4m2D2XnPSwT',
|
|
88
88
|
PreviousTxnLgrSeq: 7,
|
|
89
|
-
LedgerEntryType:
|
|
89
|
+
LedgerEntryType: 'AccountRoot',
|
|
90
90
|
PreviousTxnID:
|
|
91
|
-
|
|
91
|
+
'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
92
92
|
Flags: 0,
|
|
93
93
|
Sequence: 1,
|
|
94
|
-
Balance:
|
|
94
|
+
Balance: '10000000000',
|
|
95
95
|
SourceTag: 12345,
|
|
96
|
-
}
|
|
96
|
+
}
|
|
97
97
|
|
|
98
98
|
let json_issued_x = {
|
|
99
99
|
TakerPays: {
|
|
100
|
-
currency:
|
|
101
|
-
issuer:
|
|
102
|
-
value:
|
|
100
|
+
currency: 'USD',
|
|
101
|
+
issuer: 'X7WZKEeNVS2p9Tire9DtNFkzWBZbFtJHWxDjN9fCrBGqVA4',
|
|
102
|
+
value: '7072.8',
|
|
103
103
|
},
|
|
104
|
-
}
|
|
104
|
+
}
|
|
105
105
|
|
|
106
106
|
let json_issued_r = {
|
|
107
107
|
TakerPays: {
|
|
108
|
-
currency:
|
|
109
|
-
issuer:
|
|
110
|
-
value:
|
|
108
|
+
currency: 'USD',
|
|
109
|
+
issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
|
110
|
+
value: '7072.8',
|
|
111
111
|
},
|
|
112
|
-
}
|
|
112
|
+
}
|
|
113
113
|
|
|
114
114
|
let json_issued_with_tag = {
|
|
115
115
|
TakerPays: {
|
|
116
|
-
currency:
|
|
117
|
-
issuer:
|
|
118
|
-
value:
|
|
116
|
+
currency: 'USD',
|
|
117
|
+
issuer: 'X7WZKEeNVS2p9Tire9DtNFkzWBZbFtSiS2eDBib7svZXuc2',
|
|
118
|
+
value: '7072.8',
|
|
119
119
|
},
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
describe(
|
|
123
|
-
let encoded_x = encode(json_x1)
|
|
124
|
-
let encoded_r = encode(json_r1)
|
|
125
|
-
test(
|
|
126
|
-
expect(encoded_x).toEqual(encoded_r)
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
test(
|
|
130
|
-
let decoded_x = decode(encoded_x)
|
|
131
|
-
expect(decoded_x).toEqual(json_r1)
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
test(
|
|
135
|
-
expect(encode(json_null_x)).toEqual(encode(json_null_r))
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
test(
|
|
139
|
-
expect(() => encode(json_invalid_x)).toThrow(
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
test(
|
|
143
|
-
expect(encode(json_issued_x)).toEqual(encode(json_issued_r))
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
describe(
|
|
148
|
-
test(
|
|
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
149
|
expect(() => encode(invalid_json_issuer_tagged)).toThrow(
|
|
150
|
-
new Error(
|
|
151
|
-
)
|
|
152
|
-
})
|
|
150
|
+
new Error('Issuer cannot have an associated tag'),
|
|
151
|
+
)
|
|
152
|
+
})
|
|
153
153
|
|
|
154
|
-
test(
|
|
154
|
+
test('Throws when Account has both X-Addr and Destination Tag', () => {
|
|
155
155
|
expect(() => encode(invalid_json_x_and_tagged)).toThrow(
|
|
156
|
-
new Error(
|
|
157
|
-
)
|
|
158
|
-
})
|
|
156
|
+
new Error('Cannot have Account X-Address and SourceTag'),
|
|
157
|
+
)
|
|
158
|
+
})
|
|
159
159
|
|
|
160
|
-
test(
|
|
160
|
+
test('Throws when issued currency has tag', () => {
|
|
161
161
|
expect(() => encode(json_issued_with_tag)).toThrow(
|
|
162
|
-
|
|
163
|
-
)
|
|
164
|
-
})
|
|
165
|
-
})
|
|
162
|
+
'Only allowed to have tag on Account or Destination',
|
|
163
|
+
)
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
166
|
|
|
167
|
-
describe(
|
|
167
|
+
describe('ripple-binary-codec x-address test', function () {
|
|
168
168
|
function makeSuite(name, entries) {
|
|
169
169
|
describe(name, function () {
|
|
170
170
|
entries.forEach((t, testN) => {
|
|
171
171
|
test(`${name}[${testN}] encodes X-address json equivalent to classic address json`, () => {
|
|
172
|
-
expect(encode(t.rjson)).toEqual(encode(t.xjson))
|
|
173
|
-
})
|
|
172
|
+
expect(encode(t.rjson)).toEqual(encode(t.xjson))
|
|
173
|
+
})
|
|
174
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
|
-
})
|
|
175
|
+
expect(decode(encode(t.xjson))).toEqual(t.rjson)
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
179
|
}
|
|
180
|
-
makeSuite(
|
|
181
|
-
})
|
|
180
|
+
makeSuite('transactions', fixtures.transactions)
|
|
181
|
+
})
|
package/dist/ShaMap/ShaMap.d.ts
DELETED
package/dist/ShaMap/ShaMap.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var ShaMapInner_1 = require("./ShaMapInner");
|
|
17
|
-
var ShaMap = /** @class */ (function (_super) {
|
|
18
|
-
__extends(ShaMap, _super);
|
|
19
|
-
function ShaMap() {
|
|
20
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
21
|
-
}
|
|
22
|
-
return ShaMap;
|
|
23
|
-
}(ShaMapInner_1.default));
|
|
24
|
-
exports.default = ShaMap;
|
|
25
|
-
//# sourceMappingURL=ShaMap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShaMap.js","sourceRoot":"","sources":["../../src/ShaMap/ShaMap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAuC;AAEvC;IAAoC,0BAAW;IAA/C;;IAAiD,CAAC;IAAD,aAAC;AAAD,CAAC,AAAlD,CAAoC,qBAAW,GAAG"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Buffer } from 'buffer/';
|
|
2
|
-
import BytesList from '../serdes/BytesList';
|
|
3
|
-
import { Hash256 } from '../types';
|
|
4
|
-
import ShaMapLeaf from './ShaMapLeaf';
|
|
5
|
-
import ShaMapNode from './ShaMapNode';
|
|
6
|
-
/**
|
|
7
|
-
* Class defining an Inner Node of a SHAMap.
|
|
8
|
-
*/
|
|
9
|
-
export default class ShaMapInner extends ShaMapNode {
|
|
10
|
-
private _slotBits;
|
|
11
|
-
private _branches;
|
|
12
|
-
private readonly _depth;
|
|
13
|
-
constructor(depth?: number);
|
|
14
|
-
/**
|
|
15
|
-
* Returns `true` because ShaMapInners are always inner nodes.
|
|
16
|
-
*
|
|
17
|
-
* @returns `true`.
|
|
18
|
-
*/
|
|
19
|
-
isInner(): true;
|
|
20
|
-
/**
|
|
21
|
-
* Returns `false` because ShaMapInners are never leaves.
|
|
22
|
-
*
|
|
23
|
-
* @returns `false`.
|
|
24
|
-
*/
|
|
25
|
-
isLeaf(): false;
|
|
26
|
-
/**
|
|
27
|
-
* Get the hash prefix for this node.
|
|
28
|
-
*
|
|
29
|
-
* @returns Hash prefix describing an inner node.
|
|
30
|
-
*/
|
|
31
|
-
hashPrefix(): Buffer;
|
|
32
|
-
/**
|
|
33
|
-
* Set a branch of this node to be another node.
|
|
34
|
-
*
|
|
35
|
-
* @param slot - Slot to add branch to this._branches.
|
|
36
|
-
* @param branch - Branch to add.
|
|
37
|
-
*/
|
|
38
|
-
setBranch(slot: number, branch: ShaMapNode): void;
|
|
39
|
-
/**
|
|
40
|
-
* Returns `true` if node is empty.
|
|
41
|
-
*
|
|
42
|
-
* @returns `true` if node is empty.
|
|
43
|
-
*/
|
|
44
|
-
empty(): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Compute the hash of this node.
|
|
47
|
-
*
|
|
48
|
-
* @returns The hash of this node.
|
|
49
|
-
*/
|
|
50
|
-
hash(): Hash256;
|
|
51
|
-
/**
|
|
52
|
-
* Writes the bytes representation of this node to a BytesList.
|
|
53
|
-
*
|
|
54
|
-
* @param list - BytesList to write bytes to.
|
|
55
|
-
*/
|
|
56
|
-
toBytesSink(list: BytesList): void;
|
|
57
|
-
/**
|
|
58
|
-
* Add item to the SHAMap.
|
|
59
|
-
*
|
|
60
|
-
* @param index - Hash of the index of the item being inserted.
|
|
61
|
-
* @param item - Item to insert in the map.
|
|
62
|
-
* @param leaf - Leaf node to insert when branch doesn't exist.
|
|
63
|
-
* @throws Error.
|
|
64
|
-
*/
|
|
65
|
-
addItem(index?: Hash256, item?: ShaMapNode, leaf?: ShaMapLeaf): void;
|
|
66
|
-
}
|