ripple-binary-codec 2.8.0-smartcontract.0 → 2.9.0-batch.1
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 +17 -4
- package/dist/binary.js +26 -2
- package/dist/binary.js.map +1 -1
- package/dist/enums/definitions.json +3261 -302
- package/dist/enums/src/enums/definitions.json +3261 -307
- package/dist/serdes/binary-serializer.d.ts +1 -1
- package/dist/serdes/binary-serializer.js +2 -2
- package/dist/serdes/binary-serializer.js.map +1 -1
- package/dist/src/binary.d.ts +17 -4
- package/dist/src/binary.js +26 -2
- package/dist/src/binary.js.map +1 -1
- package/dist/src/enums/definitions.json +3261 -302
- package/dist/src/serdes/binary-serializer.d.ts +1 -1
- package/dist/src/serdes/binary-serializer.js +2 -2
- package/dist/src/serdes/binary-serializer.js.map +1 -1
- package/dist/src/types/account-id.d.ts +0 -2
- package/dist/src/types/account-id.js +0 -4
- package/dist/src/types/account-id.js.map +1 -1
- package/dist/src/types/amount.d.ts +1 -2
- package/dist/src/types/amount.js +0 -3
- package/dist/src/types/amount.js.map +1 -1
- package/dist/src/types/blob.d.ts +1 -2
- package/dist/src/types/blob.js +0 -3
- package/dist/src/types/blob.js.map +1 -1
- package/dist/src/types/currency.d.ts +0 -2
- package/dist/src/types/currency.js +0 -4
- package/dist/src/types/currency.js.map +1 -1
- package/dist/src/types/hash-128.d.ts +0 -2
- package/dist/src/types/hash-128.js +0 -4
- package/dist/src/types/hash-128.js.map +1 -1
- package/dist/src/types/hash-160.d.ts +0 -2
- package/dist/src/types/hash-160.js +0 -4
- package/dist/src/types/hash-160.js.map +1 -1
- package/dist/src/types/hash-192.d.ts +0 -2
- package/dist/src/types/hash-192.js +0 -4
- package/dist/src/types/hash-192.js.map +1 -1
- package/dist/src/types/hash-256.d.ts +0 -2
- package/dist/src/types/hash-256.js +0 -4
- package/dist/src/types/hash-256.js.map +1 -1
- package/dist/src/types/index.d.ts +1 -3
- package/dist/src/types/index.js +1 -7
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/issue.d.ts +1 -2
- package/dist/src/types/issue.js +0 -3
- package/dist/src/types/issue.js.map +1 -1
- package/dist/src/types/path-set.d.ts +1 -2
- package/dist/src/types/path-set.js +0 -3
- package/dist/src/types/path-set.js.map +1 -1
- package/dist/src/types/serialized-type.d.ts +0 -43
- package/dist/src/types/serialized-type.js +1 -63
- package/dist/src/types/serialized-type.js.map +1 -1
- package/dist/src/types/st-array.d.ts +1 -2
- package/dist/src/types/st-array.js +0 -3
- package/dist/src/types/st-array.js.map +1 -1
- package/dist/src/types/st-number.d.ts +1 -2
- package/dist/src/types/st-number.js +0 -3
- package/dist/src/types/st-number.js.map +1 -1
- package/dist/src/types/st-object.d.ts +1 -2
- package/dist/src/types/st-object.js +1 -9
- package/dist/src/types/st-object.js.map +1 -1
- package/dist/src/types/uint-16.d.ts +0 -2
- package/dist/src/types/uint-16.js +0 -4
- package/dist/src/types/uint-16.js.map +1 -1
- package/dist/src/types/uint-32.d.ts +0 -2
- package/dist/src/types/uint-32.js +0 -4
- package/dist/src/types/uint-32.js.map +1 -1
- package/dist/src/types/uint-64.d.ts +0 -2
- package/dist/src/types/uint-64.js +0 -4
- package/dist/src/types/uint-64.js.map +1 -1
- package/dist/src/types/uint-8.d.ts +0 -2
- package/dist/src/types/uint-8.js +0 -4
- package/dist/src/types/uint-8.js.map +1 -1
- package/dist/src/types/vector-256.d.ts +1 -2
- package/dist/src/types/vector-256.js +0 -3
- package/dist/src/types/vector-256.js.map +1 -1
- package/dist/src/types/xchain-bridge.d.ts +1 -2
- package/dist/src/types/xchain-bridge.js +0 -3
- package/dist/src/types/xchain-bridge.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/account-id.d.ts +0 -2
- package/dist/types/account-id.js +0 -4
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +1 -2
- package/dist/types/amount.js +0 -3
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +1 -2
- package/dist/types/blob.js +0 -3
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +0 -2
- package/dist/types/currency.js +0 -4
- package/dist/types/currency.js.map +1 -1
- package/dist/types/hash-128.d.ts +0 -2
- package/dist/types/hash-128.js +0 -4
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +0 -2
- package/dist/types/hash-160.js +0 -4
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.d.ts +0 -2
- package/dist/types/hash-192.js +0 -4
- package/dist/types/hash-192.js.map +1 -1
- package/dist/types/hash-256.d.ts +0 -2
- package/dist/types/hash-256.js +0 -4
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/index.d.ts +1 -3
- package/dist/types/index.js +1 -7
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.d.ts +1 -2
- package/dist/types/issue.js +0 -3
- package/dist/types/issue.js.map +1 -1
- package/dist/types/path-set.d.ts +1 -2
- package/dist/types/path-set.js +0 -3
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +0 -43
- package/dist/types/serialized-type.js +1 -63
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +1 -2
- package/dist/types/st-array.js +0 -3
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-number.d.ts +1 -2
- package/dist/types/st-number.js +0 -3
- package/dist/types/st-number.js.map +1 -1
- package/dist/types/st-object.d.ts +1 -2
- package/dist/types/st-object.js +1 -9
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +0 -2
- package/dist/types/uint-16.js +0 -4
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +0 -2
- package/dist/types/uint-32.js +0 -4
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +0 -2
- package/dist/types/uint-64.js +0 -4
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +0 -2
- package/dist/types/uint-8.js +0 -4
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/vector-256.d.ts +1 -2
- package/dist/types/vector-256.js +0 -3
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.d.ts +1 -2
- package/dist/types/xchain-bridge.js +0 -3
- package/dist/types/xchain-bridge.js.map +1 -1
- package/package.json +3 -3
- package/src/binary.ts +41 -5
- package/src/enums/definitions.json +3261 -307
- package/src/serdes/binary-serializer.ts +2 -2
- package/src/types/account-id.ts +0 -5
- package/src/types/amount.ts +1 -5
- package/src/types/blob.ts +1 -5
- package/src/types/currency.ts +0 -5
- package/src/types/hash-128.ts +0 -5
- package/src/types/hash-160.ts +0 -5
- package/src/types/hash-192.ts +0 -5
- package/src/types/hash-256.ts +0 -5
- package/src/types/index.ts +0 -6
- package/src/types/issue.ts +1 -5
- package/src/types/path-set.ts +1 -5
- package/src/types/serialized-type.ts +0 -67
- package/src/types/st-array.ts +1 -5
- package/src/types/st-number.ts +1 -5
- package/src/types/st-object.ts +2 -12
- package/src/types/uint-16.ts +0 -5
- package/src/types/uint-32.ts +0 -5
- package/src/types/uint-64.ts +0 -5
- package/src/types/uint-8.ts +0 -5
- package/src/types/vector-256.ts +1 -5
- package/src/types/xchain-bridge.ts +1 -5
- package/dist/src/types/data.d.ts +0 -86
- package/dist/src/types/data.js +0 -252
- package/dist/src/types/data.js.map +0 -1
- package/dist/src/types/dataType.d.ts +0 -94
- package/dist/src/types/dataType.js +0 -145
- package/dist/src/types/dataType.js.map +0 -1
- package/dist/src/types/json.d.ts +0 -173
- package/dist/src/types/json.js +0 -531
- package/dist/src/types/json.js.map +0 -1
- package/dist/types/data.d.ts +0 -86
- package/dist/types/data.js +0 -252
- package/dist/types/data.js.map +0 -1
- package/dist/types/dataType.d.ts +0 -94
- package/dist/types/dataType.js +0 -145
- package/dist/types/dataType.js.map +0 -1
- package/dist/types/json.d.ts +0 -173
- package/dist/types/json.js +0 -531
- package/dist/types/json.js.map +0 -1
- package/src/types/data.ts +0 -294
- package/src/types/dataType.ts +0 -178
- package/src/types/json.ts +0 -650
|
@@ -99,7 +99,7 @@ class BinarySerializer {
|
|
|
99
99
|
*
|
|
100
100
|
* @param length the length of the bytes
|
|
101
101
|
*/
|
|
102
|
-
|
|
102
|
+
private encodeVariableLength(length: number): Uint8Array {
|
|
103
103
|
const lenBytes = new Uint8Array(3)
|
|
104
104
|
if (length <= 192) {
|
|
105
105
|
lenBytes[0] = length
|
|
@@ -158,7 +158,7 @@ class BinarySerializer {
|
|
|
158
158
|
// this part doesn't happen for the Account field in a UNLModify transaction
|
|
159
159
|
value.toBytesSink(bytes)
|
|
160
160
|
}
|
|
161
|
-
this.put(
|
|
161
|
+
this.put(this.encodeVariableLength(bytes.getLength()))
|
|
162
162
|
this.writeBytesList(bytes)
|
|
163
163
|
}
|
|
164
164
|
}
|
package/src/types/account-id.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
} from 'ripple-address-codec'
|
|
7
7
|
import { Hash160 } from './hash-160'
|
|
8
8
|
import { hexToBytes } from '@xrplf/isomorphic/utils'
|
|
9
|
-
import { SerializedTypeID } from './serialized-type'
|
|
10
9
|
|
|
11
10
|
const HEX_REGEX = /^[A-F0-9]{40}$/
|
|
12
11
|
|
|
@@ -82,10 +81,6 @@ class AccountID extends Hash160 {
|
|
|
82
81
|
toBase58(): string {
|
|
83
82
|
return encodeAccountID(this.bytes)
|
|
84
83
|
}
|
|
85
|
-
|
|
86
|
-
getSType(): SerializedTypeID {
|
|
87
|
-
return SerializedTypeID.STI_ACCOUNT
|
|
88
|
-
}
|
|
89
84
|
}
|
|
90
85
|
|
|
91
86
|
export { AccountID }
|
package/src/types/amount.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BinaryParser } from '../serdes/binary-parser'
|
|
|
2
2
|
|
|
3
3
|
import { AccountID } from './account-id'
|
|
4
4
|
import { Currency } from './currency'
|
|
5
|
-
import { JsonObject, SerializedType
|
|
5
|
+
import { JsonObject, SerializedType } from './serialized-type'
|
|
6
6
|
import BigNumber from 'bignumber.js'
|
|
7
7
|
import { bytesToHex, concat, hexToBytes } from '@xrplf/isomorphic/utils'
|
|
8
8
|
import { readUInt32BE, writeUInt32BE } from '../utils'
|
|
@@ -372,10 +372,6 @@ class Amount extends SerializedType {
|
|
|
372
372
|
private isIOU(): boolean {
|
|
373
373
|
return (this.bytes[0] & 0x80) !== 0
|
|
374
374
|
}
|
|
375
|
-
|
|
376
|
-
getSType(): SerializedTypeID {
|
|
377
|
-
return SerializedTypeID.STI_AMOUNT
|
|
378
|
-
}
|
|
379
375
|
}
|
|
380
376
|
|
|
381
377
|
export { Amount, AmountObject }
|
package/src/types/blob.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SerializedType
|
|
1
|
+
import { SerializedType } from './serialized-type'
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
3
3
|
import { hexToBytes } from '@xrplf/isomorphic/utils'
|
|
4
4
|
|
|
@@ -41,10 +41,6 @@ class Blob extends SerializedType {
|
|
|
41
41
|
|
|
42
42
|
throw new Error('Cannot construct Blob from value given')
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
getSType(): SerializedTypeID {
|
|
46
|
-
return SerializedTypeID.STI_VL
|
|
47
|
-
}
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
export { Blob }
|
package/src/types/currency.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Hash160 } from './hash-160'
|
|
2
2
|
import { bytesToHex, hexToBytes, hexToString } from '@xrplf/isomorphic/utils'
|
|
3
|
-
import { SerializedTypeID } from './serialized-type'
|
|
4
3
|
|
|
5
4
|
const XRP_HEX_REGEX = /^0{40}$/
|
|
6
5
|
const ISO_REGEX = /^[A-Z0-9a-z?!@#$%^&*(){}[\]|]{3}$/
|
|
@@ -136,10 +135,6 @@ class Currency extends Hash160 {
|
|
|
136
135
|
}
|
|
137
136
|
return bytesToHex(this.bytes)
|
|
138
137
|
}
|
|
139
|
-
|
|
140
|
-
getSType(): SerializedTypeID {
|
|
141
|
-
return SerializedTypeID.STI_CURRENCY
|
|
142
|
-
}
|
|
143
138
|
}
|
|
144
139
|
|
|
145
140
|
export { Currency }
|
package/src/types/hash-128.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Hash } from './hash'
|
|
2
2
|
import { bytesToHex } from '@xrplf/isomorphic/utils'
|
|
3
|
-
import { SerializedTypeID } from './serialized-type'
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Hash with a width of 128 bits
|
|
@@ -29,10 +28,6 @@ class Hash128 extends Hash {
|
|
|
29
28
|
}
|
|
30
29
|
return hex
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
getSType(): SerializedTypeID {
|
|
34
|
-
return SerializedTypeID.STI_UINT128
|
|
35
|
-
}
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
export { Hash128 }
|
package/src/types/hash-160.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Hash } from './hash'
|
|
2
|
-
import { SerializedTypeID } from './serialized-type'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Hash with a width of 160 bits
|
|
@@ -15,10 +14,6 @@ class Hash160 extends Hash {
|
|
|
15
14
|
|
|
16
15
|
super(bytes ?? Hash160.ZERO_160.bytes)
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
getSType(): SerializedTypeID {
|
|
20
|
-
return SerializedTypeID.STI_UINT160
|
|
21
|
-
}
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
export { Hash160 }
|
package/src/types/hash-192.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Hash } from './hash'
|
|
2
|
-
import { SerializedTypeID } from './serialized-type'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Hash with a width of 192 bits
|
|
@@ -15,10 +14,6 @@ class Hash192 extends Hash {
|
|
|
15
14
|
|
|
16
15
|
super(bytes ?? Hash192.ZERO_192.bytes)
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
getSType(): SerializedTypeID {
|
|
20
|
-
return SerializedTypeID.STI_UINT192
|
|
21
|
-
}
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
export { Hash192 }
|
package/src/types/hash-256.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Hash } from './hash'
|
|
2
|
-
import { SerializedTypeID } from './serialized-type'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Hash with a width of 256 bits
|
|
@@ -11,10 +10,6 @@ class Hash256 extends Hash {
|
|
|
11
10
|
constructor(bytes: Uint8Array) {
|
|
12
11
|
super(bytes ?? Hash256.ZERO_256.bytes)
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
getSType(): SerializedTypeID {
|
|
16
|
-
return SerializedTypeID.STI_UINT256
|
|
17
|
-
}
|
|
18
13
|
}
|
|
19
14
|
|
|
20
15
|
export { Hash256 }
|
package/src/types/index.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { AccountID } from './account-id'
|
|
|
2
2
|
import { Amount } from './amount'
|
|
3
3
|
import { Blob } from './blob'
|
|
4
4
|
import { Currency } from './currency'
|
|
5
|
-
import { Data } from './data'
|
|
6
|
-
import { DataType } from './dataType'
|
|
7
5
|
import { Hash128 } from './hash-128'
|
|
8
6
|
import { Hash160 } from './hash-160'
|
|
9
7
|
import { Hash192 } from './hash-192'
|
|
@@ -28,8 +26,6 @@ const coreTypes: Record<string, typeof SerializedType> = {
|
|
|
28
26
|
Amount,
|
|
29
27
|
Blob,
|
|
30
28
|
Currency,
|
|
31
|
-
Data,
|
|
32
|
-
DataType,
|
|
33
29
|
Hash128,
|
|
34
30
|
Hash160,
|
|
35
31
|
Hash192,
|
|
@@ -59,8 +55,6 @@ export {
|
|
|
59
55
|
Amount,
|
|
60
56
|
Blob,
|
|
61
57
|
Currency,
|
|
62
|
-
Data,
|
|
63
|
-
DataType,
|
|
64
58
|
Hash128,
|
|
65
59
|
Hash160,
|
|
66
60
|
Hash192,
|
package/src/types/issue.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BinaryParser } from '../serdes/binary-parser'
|
|
|
3
3
|
|
|
4
4
|
import { AccountID } from './account-id'
|
|
5
5
|
import { Currency } from './currency'
|
|
6
|
-
import { JsonObject, SerializedType
|
|
6
|
+
import { JsonObject, SerializedType } from './serialized-type'
|
|
7
7
|
import { Hash192 } from './hash-192'
|
|
8
8
|
import { readUInt32BE, writeUInt32BE } from '../utils'
|
|
9
9
|
|
|
@@ -158,10 +158,6 @@ class Issue extends SerializedType {
|
|
|
158
158
|
issuer: issuer.toJSON(),
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
getSType(): SerializedTypeID {
|
|
163
|
-
return SerializedTypeID.STI_ISSUE
|
|
164
|
-
}
|
|
165
161
|
}
|
|
166
162
|
|
|
167
163
|
export { Issue, IssueObject }
|
package/src/types/path-set.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountID } from './account-id'
|
|
2
2
|
import { Currency } from './currency'
|
|
3
3
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
4
|
-
import { SerializedType, JsonObject
|
|
4
|
+
import { SerializedType, JsonObject } from './serialized-type'
|
|
5
5
|
import { bytesToHex, concat } from '@xrplf/isomorphic/utils'
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -285,10 +285,6 @@ class PathSet extends SerializedType {
|
|
|
285
285
|
|
|
286
286
|
return json
|
|
287
287
|
}
|
|
288
|
-
|
|
289
|
-
getSType(): SerializedTypeID {
|
|
290
|
-
return SerializedTypeID.STI_PATHSET
|
|
291
|
-
}
|
|
292
288
|
}
|
|
293
289
|
|
|
294
290
|
export { PathSet }
|
|
@@ -2,69 +2,6 @@ import { BytesList } from '../serdes/binary-serializer'
|
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
3
3
|
import { XrplDefinitionsBase } from '../enums'
|
|
4
4
|
import { bytesToHex } from '@xrplf/isomorphic/utils'
|
|
5
|
-
import definitions from '../enums/definitions.json'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Enum for SerializedTypeID values used in XRPL
|
|
9
|
-
* These match the C++ implementation's STI_ constants
|
|
10
|
-
*/
|
|
11
|
-
export enum SerializedTypeID {
|
|
12
|
-
STI_NOTPRESENT = 0,
|
|
13
|
-
STI_UINT16 = 1,
|
|
14
|
-
STI_UINT32 = 2,
|
|
15
|
-
STI_UINT64 = 3,
|
|
16
|
-
STI_UINT128 = 4,
|
|
17
|
-
STI_UINT256 = 5,
|
|
18
|
-
STI_AMOUNT = 6,
|
|
19
|
-
STI_VL = 7,
|
|
20
|
-
STI_ACCOUNT = 8,
|
|
21
|
-
STI_NUMBER = 9,
|
|
22
|
-
STI_INT32 = 10,
|
|
23
|
-
STI_INT64 = 11,
|
|
24
|
-
|
|
25
|
-
STI_OBJECT = 14,
|
|
26
|
-
STI_ARRAY = 15,
|
|
27
|
-
|
|
28
|
-
STI_UINT8 = 16,
|
|
29
|
-
STI_UINT160 = 17,
|
|
30
|
-
STI_PATHSET = 18,
|
|
31
|
-
STI_VECTOR256 = 19,
|
|
32
|
-
STI_UINT96 = 20,
|
|
33
|
-
STI_UINT192 = 21,
|
|
34
|
-
STI_UINT384 = 22,
|
|
35
|
-
STI_UINT512 = 23,
|
|
36
|
-
STI_ISSUE = 24,
|
|
37
|
-
STI_XCHAIN_BRIDGE = 25,
|
|
38
|
-
STI_CURRENCY = 26,
|
|
39
|
-
STI_DATA = 27,
|
|
40
|
-
STI_DATATYPE = 28,
|
|
41
|
-
STI_JSON = 29,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Maps built dynamically from definitions.json TYPES.
|
|
46
|
-
* This ensures type string names (e.g. "Hash256", "Hash128") stay in sync
|
|
47
|
-
* with the canonical definitions rather than using hardcoded uppercase variants.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
// Map of type name strings to SerializedTypeID values
|
|
51
|
-
export const TYPE_STRING_TO_ID: Record<string, SerializedTypeID> = {}
|
|
52
|
-
|
|
53
|
-
// Map of numeric type codes to SerializedTypeID values
|
|
54
|
-
export const TYPE_NUMBER_TO_ID: Record<number, SerializedTypeID> = {}
|
|
55
|
-
|
|
56
|
-
// Map of SerializedTypeID values to type name strings
|
|
57
|
-
export const TYPE_ID_TO_STRING: Record<number, string> = {}
|
|
58
|
-
|
|
59
|
-
// Populate all three maps from definitions.json TYPES
|
|
60
|
-
for (const [name, id] of Object.entries(definitions.TYPES)) {
|
|
61
|
-
if (id >= 0) {
|
|
62
|
-
const typeId = id as SerializedTypeID
|
|
63
|
-
TYPE_STRING_TO_ID[name] = typeId
|
|
64
|
-
TYPE_NUMBER_TO_ID[id] = typeId
|
|
65
|
-
TYPE_ID_TO_STRING[typeId] = name
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
5
|
|
|
69
6
|
type JSON = string | number | boolean | null | undefined | JSON[] | JsonObject
|
|
70
7
|
|
|
@@ -140,10 +77,6 @@ class SerializedType {
|
|
|
140
77
|
toString(): string {
|
|
141
78
|
return this.toHex()
|
|
142
79
|
}
|
|
143
|
-
|
|
144
|
-
getSType(): SerializedTypeID {
|
|
145
|
-
return this.getSType()
|
|
146
|
-
}
|
|
147
80
|
}
|
|
148
81
|
|
|
149
82
|
/**
|
package/src/types/st-array.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_DEFINITIONS, XrplDefinitionsBase } from '../enums'
|
|
2
|
-
import { SerializedType, JsonObject
|
|
2
|
+
import { SerializedType, JsonObject } from './serialized-type'
|
|
3
3
|
import { STObject } from './st-object'
|
|
4
4
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
5
5
|
import { concat } from '@xrplf/isomorphic/utils'
|
|
@@ -108,10 +108,6 @@ class STArray extends SerializedType {
|
|
|
108
108
|
|
|
109
109
|
return result
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
getSType(): SerializedTypeID {
|
|
113
|
-
return SerializedTypeID.STI_ARRAY
|
|
114
|
-
}
|
|
115
111
|
}
|
|
116
112
|
|
|
117
113
|
export { STArray }
|
package/src/types/st-number.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable complexity -- required for various checks */
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
3
|
-
import { SerializedType
|
|
3
|
+
import { SerializedType } from './serialized-type'
|
|
4
4
|
import { writeInt32BE, writeInt64BE, readInt32BE, readInt64BE } from '../utils'
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -307,8 +307,4 @@ export class STNumber extends SerializedType {
|
|
|
307
307
|
fractionPart ? '.' + fractionPart : ''
|
|
308
308
|
}`
|
|
309
309
|
}
|
|
310
|
-
|
|
311
|
-
getSType(): SerializedTypeID {
|
|
312
|
-
return SerializedTypeID.STI_NUMBER
|
|
313
|
-
}
|
|
314
310
|
}
|
package/src/types/st-object.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
Bytes,
|
|
5
5
|
XrplDefinitionsBase,
|
|
6
6
|
} from '../enums'
|
|
7
|
-
import { SerializedType, JsonObject
|
|
7
|
+
import { SerializedType, JsonObject } from './serialized-type'
|
|
8
8
|
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
|
|
9
9
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
10
10
|
import { BinarySerializer, BytesList } from '../serdes/binary-serializer'
|
|
@@ -151,13 +151,7 @@ class STObject extends SerializedType {
|
|
|
151
151
|
? STArray.from(xAddressDecoded[field.name], definitions)
|
|
152
152
|
: field.type.name === 'UInt64'
|
|
153
153
|
? UInt64.from(xAddressDecoded[field.name], field.name)
|
|
154
|
-
: field.associatedType
|
|
155
|
-
? field.associatedType.from(xAddressDecoded[field.name])
|
|
156
|
-
: (() => {
|
|
157
|
-
throw new Error(
|
|
158
|
-
`Type ${field.type.name} for field ${field.name} is missing associatedType.from`,
|
|
159
|
-
)
|
|
160
|
-
})()
|
|
154
|
+
: field.associatedType.from(xAddressDecoded[field.name])
|
|
161
155
|
|
|
162
156
|
if (associatedValue == undefined) {
|
|
163
157
|
throw new TypeError(
|
|
@@ -207,10 +201,6 @@ class STObject extends SerializedType {
|
|
|
207
201
|
|
|
208
202
|
return accumulator
|
|
209
203
|
}
|
|
210
|
-
|
|
211
|
-
getSType(): SerializedTypeID {
|
|
212
|
-
return SerializedTypeID.STI_OBJECT
|
|
213
|
-
}
|
|
214
204
|
}
|
|
215
205
|
|
|
216
206
|
export { STObject }
|
package/src/types/uint-16.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { UInt } from './uint'
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
3
3
|
import { readUInt16BE, writeUInt16BE } from '../utils'
|
|
4
|
-
import { SerializedTypeID } from './serialized-type'
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Derived UInt class for serializing/deserializing 16 bit UInt
|
|
@@ -49,10 +48,6 @@ class UInt16 extends UInt {
|
|
|
49
48
|
valueOf(): number {
|
|
50
49
|
return parseInt(readUInt16BE(this.bytes, 0))
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
getSType(): SerializedTypeID {
|
|
54
|
-
return SerializedTypeID.STI_UINT16
|
|
55
|
-
}
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
export { UInt16 }
|
package/src/types/uint-32.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { UInt } from './uint'
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
3
3
|
import { readUInt32BE, writeUInt32BE } from '../utils'
|
|
4
|
-
import { SerializedTypeID } from './serialized-type'
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Derived UInt class for serializing/deserializing 32 bit UInt
|
|
@@ -55,10 +54,6 @@ class UInt32 extends UInt {
|
|
|
55
54
|
valueOf(): number {
|
|
56
55
|
return parseInt(readUInt32BE(this.bytes, 0), 10)
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
getSType(): SerializedTypeID {
|
|
60
|
-
return SerializedTypeID.STI_UINT32
|
|
61
|
-
}
|
|
62
57
|
}
|
|
63
58
|
|
|
64
59
|
export { UInt32 }
|
package/src/types/uint-64.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { BinaryParser } from '../serdes/binary-parser'
|
|
|
3
3
|
import { bytesToHex, concat, hexToBytes } from '@xrplf/isomorphic/utils'
|
|
4
4
|
import { readUInt32BE, writeUInt32BE } from '../utils'
|
|
5
5
|
import { DEFAULT_DEFINITIONS, XrplDefinitionsBase } from '../enums'
|
|
6
|
-
import { SerializedTypeID } from './serialized-type'
|
|
7
6
|
|
|
8
7
|
const HEX_REGEX = /^[a-fA-F0-9]{1,16}$/
|
|
9
8
|
const BASE10_REGEX = /^[0-9]{1,20}$/
|
|
@@ -132,10 +131,6 @@ class UInt64 extends UInt {
|
|
|
132
131
|
toBytes(): Uint8Array {
|
|
133
132
|
return this.bytes
|
|
134
133
|
}
|
|
135
|
-
|
|
136
|
-
getSType(): SerializedTypeID {
|
|
137
|
-
return SerializedTypeID.STI_UINT64
|
|
138
|
-
}
|
|
139
134
|
}
|
|
140
135
|
|
|
141
136
|
export { UInt64 }
|
package/src/types/uint-8.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { UInt } from './uint'
|
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
3
3
|
import { bytesToHex } from '@xrplf/isomorphic/utils'
|
|
4
4
|
import { writeUInt8 } from '../utils'
|
|
5
|
-
import { SerializedTypeID } from './serialized-type'
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Derived UInt class for serializing/deserializing 8 bit UInt
|
|
@@ -48,10 +47,6 @@ class UInt8 extends UInt {
|
|
|
48
47
|
valueOf(): number {
|
|
49
48
|
return parseInt(bytesToHex(this.bytes), 16)
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
getSType(): SerializedTypeID {
|
|
53
|
-
return SerializedTypeID.STI_UINT8
|
|
54
|
-
}
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
export { UInt8 }
|
package/src/types/vector-256.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SerializedType
|
|
1
|
+
import { SerializedType } from './serialized-type'
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
3
3
|
import { Hash256 } from './hash-256'
|
|
4
4
|
import { BytesList } from '../serdes/binary-serializer'
|
|
@@ -74,10 +74,6 @@ class Vector256 extends SerializedType {
|
|
|
74
74
|
}
|
|
75
75
|
return result
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
getSType(): SerializedTypeID {
|
|
79
|
-
return SerializedTypeID.STI_VECTOR256
|
|
80
|
-
}
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
export { Vector256 }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
2
2
|
|
|
3
3
|
import { AccountID } from './account-id'
|
|
4
|
-
import { JsonObject, SerializedType
|
|
4
|
+
import { JsonObject, SerializedType } from './serialized-type'
|
|
5
5
|
import { Issue, IssueObject } from './issue'
|
|
6
6
|
import { concat } from '@xrplf/isomorphic/utils'
|
|
7
7
|
|
|
@@ -123,10 +123,6 @@ class XChainBridge extends SerializedType {
|
|
|
123
123
|
})
|
|
124
124
|
return json as XChainBridgeObject
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
getSType(): SerializedTypeID {
|
|
128
|
-
return SerializedTypeID.STI_XCHAIN_BRIDGE
|
|
129
|
-
}
|
|
130
126
|
}
|
|
131
127
|
|
|
132
128
|
export { XChainBridge, XChainBridgeObject }
|
package/dist/src/types/data.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { BinaryParser } from '../serdes/binary-parser';
|
|
2
|
-
import { JsonObject, SerializedType, SerializedTypeID } from './serialized-type';
|
|
3
|
-
/**
|
|
4
|
-
* Interface for Data JSON representation
|
|
5
|
-
*/
|
|
6
|
-
interface DataJSON extends JsonObject {
|
|
7
|
-
type: string;
|
|
8
|
-
value: string | number | JsonObject;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* STData: Encodes XRPL's "Data" type.
|
|
12
|
-
*
|
|
13
|
-
* This type wraps both a SerializedTypeID and the actual data value.
|
|
14
|
-
* It's encoded as a 2-byte type ID followed by the serialized data.
|
|
15
|
-
*
|
|
16
|
-
* Usage:
|
|
17
|
-
* Data.from({ type: "Amount", value: "1000000" })
|
|
18
|
-
* Data.from({ type: "UInt64", value: "123456789" })
|
|
19
|
-
* Data.fromParser(parser)
|
|
20
|
-
*/
|
|
21
|
-
declare class Data extends SerializedType {
|
|
22
|
-
static readonly ZERO_DATA: Data;
|
|
23
|
-
/**
|
|
24
|
-
* Construct Data from bytes
|
|
25
|
-
* @param bytes - Uint8Array containing type ID and data
|
|
26
|
-
*/
|
|
27
|
-
constructor(bytes: Uint8Array);
|
|
28
|
-
/**
|
|
29
|
-
* Create Data from various input types
|
|
30
|
-
*
|
|
31
|
-
* @param value - Can be:
|
|
32
|
-
* - Data instance (returns as-is)
|
|
33
|
-
* - DataJSON object with 'type' and 'value' fields
|
|
34
|
-
* @returns Data instance
|
|
35
|
-
* @throws Error if value type is not supported
|
|
36
|
-
*/
|
|
37
|
-
static from(value: unknown): Data;
|
|
38
|
-
/**
|
|
39
|
-
* Create Data from JSON representation
|
|
40
|
-
*
|
|
41
|
-
* @param json - Object with 'type' and 'value' fields
|
|
42
|
-
* @returns Data instance
|
|
43
|
-
* @throws Error if type is not supported
|
|
44
|
-
*/
|
|
45
|
-
static fromJSON(json: DataJSON): Data;
|
|
46
|
-
/**
|
|
47
|
-
* Read Data from a BinaryParser stream
|
|
48
|
-
*
|
|
49
|
-
* @param parser - BinaryParser positioned at the start of Data
|
|
50
|
-
* @returns Data instance
|
|
51
|
-
*/
|
|
52
|
-
static fromParser(parser: BinaryParser): Data;
|
|
53
|
-
/**
|
|
54
|
-
* Get the inner SerializedTypeID
|
|
55
|
-
*
|
|
56
|
-
* @returns The inner type ID
|
|
57
|
-
*/
|
|
58
|
-
getInnerType(): SerializedTypeID;
|
|
59
|
-
/**
|
|
60
|
-
* Get the string representation of the inner type
|
|
61
|
-
*
|
|
62
|
-
* @returns String name of the type
|
|
63
|
-
*/
|
|
64
|
-
getInnerTypeString(): string;
|
|
65
|
-
/**
|
|
66
|
-
* Get the data value
|
|
67
|
-
*
|
|
68
|
-
* @returns The stored data value
|
|
69
|
-
*/
|
|
70
|
-
getValue(): SerializedType;
|
|
71
|
-
/**
|
|
72
|
-
* Convert to JSON representation
|
|
73
|
-
*
|
|
74
|
-
* @returns JSON object with 'type' and 'value' fields
|
|
75
|
-
*/
|
|
76
|
-
toJSON(): DataJSON;
|
|
77
|
-
/**
|
|
78
|
-
* Compare with another Data for equality
|
|
79
|
-
*
|
|
80
|
-
* @param other - Another Data to compare with
|
|
81
|
-
* @returns true if both have the same inner type and data
|
|
82
|
-
*/
|
|
83
|
-
equals(other: Data): boolean;
|
|
84
|
-
getSType(): SerializedTypeID;
|
|
85
|
-
}
|
|
86
|
-
export { Data };
|