ripple-binary-codec 2.7.0-smartescrow.0 → 2.8.0-smartcontract.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 +173 -270
- package/dist/enums/src/enums/definitions.json +173 -270
- package/dist/quality.js +15 -3
- package/dist/quality.js.map +1 -1
- package/dist/serdes/binary-parser.js +8 -2
- package/dist/serdes/binary-parser.js.map +1 -1
- 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/enums/definitions.json +173 -270
- package/dist/src/quality.js +15 -3
- package/dist/src/quality.js.map +1 -1
- package/dist/src/serdes/binary-parser.js +8 -2
- package/dist/src/serdes/binary-parser.js.map +1 -1
- 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 +2 -0
- package/dist/src/types/account-id.js +4 -0
- package/dist/src/types/account-id.js.map +1 -1
- package/dist/src/types/amount.d.ts +2 -1
- package/dist/src/types/amount.js +25 -4
- package/dist/src/types/amount.js.map +1 -1
- package/dist/src/types/blob.d.ts +2 -1
- package/dist/src/types/blob.js +3 -0
- package/dist/src/types/blob.js.map +1 -1
- package/dist/src/types/currency.d.ts +2 -0
- package/dist/src/types/currency.js +4 -0
- package/dist/src/types/currency.js.map +1 -1
- package/dist/src/types/data.d.ts +86 -0
- package/dist/src/types/data.js +252 -0
- package/dist/src/types/data.js.map +1 -0
- package/dist/src/types/dataType.d.ts +94 -0
- package/dist/src/types/dataType.js +145 -0
- package/dist/src/types/dataType.js.map +1 -0
- package/dist/src/types/hash-128.d.ts +2 -0
- package/dist/src/types/hash-128.js +4 -0
- package/dist/src/types/hash-128.js.map +1 -1
- package/dist/src/types/hash-160.d.ts +2 -0
- package/dist/src/types/hash-160.js +4 -0
- package/dist/src/types/hash-160.js.map +1 -1
- package/dist/src/types/hash-192.d.ts +2 -0
- package/dist/src/types/hash-192.js +4 -0
- package/dist/src/types/hash-192.js.map +1 -1
- package/dist/src/types/hash-256.d.ts +2 -0
- package/dist/src/types/hash-256.js +4 -0
- package/dist/src/types/hash-256.js.map +1 -1
- package/dist/src/types/index.d.ts +3 -1
- package/dist/src/types/index.js +7 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/int-32.d.ts +17 -8
- package/dist/src/types/int-32.js +25 -11
- package/dist/src/types/int-32.js.map +1 -1
- package/dist/src/types/int.d.ts +38 -0
- package/dist/src/types/int.js +57 -0
- package/dist/src/types/int.js.map +1 -0
- package/dist/src/types/issue.d.ts +2 -1
- package/dist/src/types/issue.js +3 -0
- package/dist/src/types/issue.js.map +1 -1
- package/dist/src/types/json.d.ts +173 -0
- package/dist/src/types/json.js +531 -0
- package/dist/src/types/json.js.map +1 -0
- package/dist/src/types/path-set.d.ts +2 -1
- package/dist/src/types/path-set.js +3 -0
- package/dist/src/types/path-set.js.map +1 -1
- package/dist/src/types/serialized-type.d.ts +43 -0
- package/dist/src/types/serialized-type.js +63 -1
- package/dist/src/types/serialized-type.js.map +1 -1
- package/dist/src/types/st-array.d.ts +2 -1
- package/dist/src/types/st-array.js +3 -0
- package/dist/src/types/st-array.js.map +1 -1
- package/dist/src/types/st-number.d.ts +2 -1
- package/dist/src/types/st-number.js +3 -0
- package/dist/src/types/st-number.js.map +1 -1
- package/dist/src/types/st-object.d.ts +2 -1
- package/dist/src/types/st-object.js +9 -1
- package/dist/src/types/st-object.js.map +1 -1
- package/dist/src/types/uint-16.d.ts +2 -0
- package/dist/src/types/uint-16.js +4 -0
- package/dist/src/types/uint-16.js.map +1 -1
- package/dist/src/types/uint-32.d.ts +2 -0
- package/dist/src/types/uint-32.js +4 -0
- package/dist/src/types/uint-32.js.map +1 -1
- package/dist/src/types/uint-64.d.ts +2 -0
- package/dist/src/types/uint-64.js +4 -0
- package/dist/src/types/uint-64.js.map +1 -1
- package/dist/src/types/uint-8.d.ts +2 -0
- package/dist/src/types/uint-8.js +4 -0
- package/dist/src/types/uint-8.js.map +1 -1
- package/dist/src/types/vector-256.d.ts +2 -1
- package/dist/src/types/vector-256.js +3 -0
- package/dist/src/types/vector-256.js.map +1 -1
- package/dist/src/types/xchain-bridge.d.ts +2 -1
- package/dist/src/types/xchain-bridge.js +3 -0
- package/dist/src/types/xchain-bridge.js.map +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/account-id.d.ts +2 -0
- package/dist/types/account-id.js +4 -0
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +2 -1
- package/dist/types/amount.js +25 -4
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +2 -1
- package/dist/types/blob.js +3 -0
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +2 -0
- package/dist/types/currency.js +4 -0
- package/dist/types/currency.js.map +1 -1
- package/dist/types/data.d.ts +86 -0
- package/dist/types/data.js +252 -0
- package/dist/types/data.js.map +1 -0
- package/dist/types/dataType.d.ts +94 -0
- package/dist/types/dataType.js +145 -0
- package/dist/types/dataType.js.map +1 -0
- package/dist/types/hash-128.d.ts +2 -0
- package/dist/types/hash-128.js +4 -0
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +2 -0
- package/dist/types/hash-160.js +4 -0
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.d.ts +2 -0
- package/dist/types/hash-192.js +4 -0
- package/dist/types/hash-192.js.map +1 -1
- package/dist/types/hash-256.d.ts +2 -0
- package/dist/types/hash-256.js +4 -0
- package/dist/types/hash-256.js.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +7 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/int-32.d.ts +17 -8
- package/dist/types/int-32.js +25 -11
- package/dist/types/int-32.js.map +1 -1
- package/dist/types/int.d.ts +38 -0
- package/dist/types/int.js +57 -0
- package/dist/types/int.js.map +1 -0
- package/dist/types/issue.d.ts +2 -1
- package/dist/types/issue.js +3 -0
- package/dist/types/issue.js.map +1 -1
- package/dist/types/json.d.ts +173 -0
- package/dist/types/json.js +531 -0
- package/dist/types/json.js.map +1 -0
- package/dist/types/path-set.d.ts +2 -1
- package/dist/types/path-set.js +3 -0
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +43 -0
- package/dist/types/serialized-type.js +63 -1
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +2 -1
- package/dist/types/st-array.js +3 -0
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-number.d.ts +2 -1
- package/dist/types/st-number.js +3 -0
- package/dist/types/st-number.js.map +1 -1
- package/dist/types/st-object.d.ts +2 -1
- package/dist/types/st-object.js +9 -1
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +2 -0
- package/dist/types/uint-16.js +4 -0
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +2 -0
- package/dist/types/uint-32.js +4 -0
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +2 -0
- package/dist/types/uint-64.js +4 -0
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +2 -0
- package/dist/types/uint-8.js +4 -0
- package/dist/types/uint-8.js.map +1 -1
- package/dist/types/vector-256.d.ts +2 -1
- package/dist/types/vector-256.js +3 -0
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.d.ts +2 -1
- package/dist/types/xchain-bridge.js +3 -0
- package/dist/types/xchain-bridge.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/enums/definitions.json +173 -270
- package/src/quality.ts +13 -3
- package/src/serdes/binary-parser.ts +12 -2
- package/src/serdes/binary-serializer.ts +2 -2
- package/src/types/account-id.ts +5 -0
- package/src/types/amount.ts +25 -6
- package/src/types/blob.ts +5 -1
- package/src/types/currency.ts +5 -0
- package/src/types/data.ts +294 -0
- package/src/types/dataType.ts +178 -0
- package/src/types/hash-128.ts +5 -0
- package/src/types/hash-160.ts +5 -0
- package/src/types/hash-192.ts +5 -0
- package/src/types/hash-256.ts +5 -0
- package/src/types/index.ts +6 -0
- package/src/types/int-32.ts +27 -12
- package/src/types/int.ts +75 -0
- package/src/types/issue.ts +5 -1
- package/src/types/json.ts +650 -0
- package/src/types/path-set.ts +5 -1
- package/src/types/serialized-type.ts +67 -0
- package/src/types/st-array.ts +5 -1
- package/src/types/st-number.ts +5 -1
- package/src/types/st-object.ts +12 -2
- package/src/types/uint-16.ts +5 -0
- package/src/types/uint-32.ts +5 -0
- package/src/types/uint-64.ts +6 -1
- package/src/types/uint-8.ts +5 -0
- package/src/types/vector-256.ts +5 -1
- package/src/types/xchain-bridge.ts +5 -1
- package/src/utils.ts +1 -1
package/src/types/hash-160.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hash } from './hash'
|
|
2
|
+
import { SerializedTypeID } from './serialized-type'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Hash with a width of 160 bits
|
|
@@ -14,6 +15,10 @@ class Hash160 extends Hash {
|
|
|
14
15
|
|
|
15
16
|
super(bytes ?? Hash160.ZERO_160.bytes)
|
|
16
17
|
}
|
|
18
|
+
|
|
19
|
+
getSType(): SerializedTypeID {
|
|
20
|
+
return SerializedTypeID.STI_UINT160
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
export { Hash160 }
|
package/src/types/hash-192.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hash } from './hash'
|
|
2
|
+
import { SerializedTypeID } from './serialized-type'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Hash with a width of 192 bits
|
|
@@ -14,6 +15,10 @@ class Hash192 extends Hash {
|
|
|
14
15
|
|
|
15
16
|
super(bytes ?? Hash192.ZERO_192.bytes)
|
|
16
17
|
}
|
|
18
|
+
|
|
19
|
+
getSType(): SerializedTypeID {
|
|
20
|
+
return SerializedTypeID.STI_UINT192
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
export { Hash192 }
|
package/src/types/hash-256.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hash } from './hash'
|
|
2
|
+
import { SerializedTypeID } from './serialized-type'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Hash with a width of 256 bits
|
|
@@ -10,6 +11,10 @@ class Hash256 extends Hash {
|
|
|
10
11
|
constructor(bytes: Uint8Array) {
|
|
11
12
|
super(bytes ?? Hash256.ZERO_256.bytes)
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
getSType(): SerializedTypeID {
|
|
16
|
+
return SerializedTypeID.STI_UINT256
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
export { Hash256 }
|
package/src/types/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ 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'
|
|
5
7
|
import { Hash128 } from './hash-128'
|
|
6
8
|
import { Hash160 } from './hash-160'
|
|
7
9
|
import { Hash192 } from './hash-192'
|
|
@@ -26,6 +28,8 @@ const coreTypes: Record<string, typeof SerializedType> = {
|
|
|
26
28
|
Amount,
|
|
27
29
|
Blob,
|
|
28
30
|
Currency,
|
|
31
|
+
Data,
|
|
32
|
+
DataType,
|
|
29
33
|
Hash128,
|
|
30
34
|
Hash160,
|
|
31
35
|
Hash192,
|
|
@@ -55,6 +59,8 @@ export {
|
|
|
55
59
|
Amount,
|
|
56
60
|
Blob,
|
|
57
61
|
Currency,
|
|
62
|
+
Data,
|
|
63
|
+
DataType,
|
|
58
64
|
Hash128,
|
|
59
65
|
Hash160,
|
|
60
66
|
Hash192,
|
package/src/types/int-32.ts
CHANGED
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Int } from './int'
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser'
|
|
3
3
|
import { readInt32BE, writeInt32BE } from '../utils'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Derived Int class for serializing/deserializing 32
|
|
6
|
+
* Derived Int class for serializing/deserializing signed 32-bit integers.
|
|
7
7
|
*/
|
|
8
|
-
class Int32 extends
|
|
9
|
-
protected static readonly width: number = 32 / 8 // 4
|
|
8
|
+
class Int32 extends Int {
|
|
9
|
+
protected static readonly width: number = 32 / 8 // 4 bytes
|
|
10
10
|
static readonly defaultInt32: Int32 = new Int32(new Uint8Array(Int32.width))
|
|
11
11
|
|
|
12
|
+
// Signed 32-bit integer range
|
|
13
|
+
static readonly MIN_VALUE: number = -2147483648 // -2^31
|
|
14
|
+
static readonly MAX_VALUE: number = 2147483647 // 2^31 - 1
|
|
15
|
+
|
|
12
16
|
constructor(bytes: Uint8Array) {
|
|
13
17
|
super(bytes ?? Int32.defaultInt32.bytes)
|
|
14
18
|
}
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Construct an Int32 from a BinaryParser
|
|
22
|
+
*
|
|
23
|
+
* @param parser BinaryParser to read Int32 from
|
|
24
|
+
* @returns An Int32 object
|
|
25
|
+
*/
|
|
26
|
+
static fromParser(parser: BinaryParser): Int {
|
|
17
27
|
return new Int32(parser.read(Int32.width))
|
|
18
28
|
}
|
|
19
29
|
|
|
20
30
|
/**
|
|
21
|
-
* Construct
|
|
31
|
+
* Construct an Int32 object from a number or string
|
|
22
32
|
*
|
|
23
|
-
* @param val Int32 object or
|
|
33
|
+
* @param val Int32 object, number, or string
|
|
34
|
+
* @returns An Int32 object
|
|
24
35
|
*/
|
|
25
36
|
static from<T extends Int32 | number | string>(val: T): Int32 {
|
|
26
37
|
if (val instanceof Int32) {
|
|
@@ -30,13 +41,17 @@ class Int32 extends UInt {
|
|
|
30
41
|
const buf = new Uint8Array(Int32.width)
|
|
31
42
|
|
|
32
43
|
if (typeof val === 'string') {
|
|
33
|
-
const num = Number
|
|
44
|
+
const num = Number(val)
|
|
45
|
+
if (!Number.isFinite(num) || !Number.isInteger(num)) {
|
|
46
|
+
throw new Error(`Cannot construct Int32 from string: ${val}`)
|
|
47
|
+
}
|
|
48
|
+
Int32.checkIntRange('Int32', num, Int32.MIN_VALUE, Int32.MAX_VALUE)
|
|
34
49
|
writeInt32BE(buf, num, 0)
|
|
35
50
|
return new Int32(buf)
|
|
36
51
|
}
|
|
37
52
|
|
|
38
|
-
if (typeof val === 'number') {
|
|
39
|
-
Int32.
|
|
53
|
+
if (typeof val === 'number' && Number.isInteger(val)) {
|
|
54
|
+
Int32.checkIntRange('Int32', val, Int32.MIN_VALUE, Int32.MAX_VALUE)
|
|
40
55
|
writeInt32BE(buf, val, 0)
|
|
41
56
|
return new Int32(buf)
|
|
42
57
|
}
|
|
@@ -45,9 +60,9 @@ class Int32 extends UInt {
|
|
|
45
60
|
}
|
|
46
61
|
|
|
47
62
|
/**
|
|
48
|
-
*
|
|
63
|
+
* Get the value of the Int32 object
|
|
49
64
|
*
|
|
50
|
-
* @returns the
|
|
65
|
+
* @returns the signed 32-bit integer represented by this.bytes
|
|
51
66
|
*/
|
|
52
67
|
valueOf(): number {
|
|
53
68
|
return readInt32BE(this.bytes, 0)
|
package/src/types/int.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Comparable } from './serialized-type'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compare numbers and bigInts n1 and n2
|
|
5
|
+
*
|
|
6
|
+
* @param n1 First object to compare
|
|
7
|
+
* @param n2 Second object to compare
|
|
8
|
+
* @returns -1, 0, or 1, depending on how the two objects compare
|
|
9
|
+
*/
|
|
10
|
+
function compare(n1: number | bigint, n2: number | bigint): number {
|
|
11
|
+
return n1 < n2 ? -1 : n1 == n2 ? 0 : 1
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Base class for serializing and deserializing signed integers.
|
|
16
|
+
*/
|
|
17
|
+
abstract class Int extends Comparable<Int | number> {
|
|
18
|
+
protected static width: number
|
|
19
|
+
|
|
20
|
+
constructor(bytes: Uint8Array) {
|
|
21
|
+
super(bytes)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Overload of compareTo for Comparable
|
|
26
|
+
*
|
|
27
|
+
* @param other other Int to compare this to
|
|
28
|
+
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
29
|
+
*/
|
|
30
|
+
compareTo(other: Int | number): number {
|
|
31
|
+
return compare(this.valueOf(), other.valueOf())
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Convert an Int object to JSON
|
|
36
|
+
*
|
|
37
|
+
* @returns number or string represented by this.bytes
|
|
38
|
+
*/
|
|
39
|
+
toJSON(): number | string {
|
|
40
|
+
const val = this.valueOf()
|
|
41
|
+
return typeof val === 'number' ? val : val.toString()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get the value of the Int represented by this.bytes
|
|
46
|
+
*
|
|
47
|
+
* @returns the value
|
|
48
|
+
*/
|
|
49
|
+
abstract valueOf(): number | bigint
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Validate that a number is within the specified signed integer range
|
|
53
|
+
*
|
|
54
|
+
* @param typeName The name of the type (for error messages)
|
|
55
|
+
* @param val The number to validate
|
|
56
|
+
* @param min The minimum allowed value
|
|
57
|
+
* @param max The maximum allowed value
|
|
58
|
+
* @throws Error if the value is out of range
|
|
59
|
+
*/
|
|
60
|
+
// eslint-disable-next-line max-params -- for error clarity in browsers
|
|
61
|
+
static checkIntRange(
|
|
62
|
+
typeName: string,
|
|
63
|
+
val: number | bigint,
|
|
64
|
+
min: number | bigint,
|
|
65
|
+
max: number | bigint,
|
|
66
|
+
): void {
|
|
67
|
+
if (val < min || val > max) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
`Invalid ${typeName}: ${val} must be >= ${min} and <= ${max}`,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { Int }
|
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 } from './serialized-type'
|
|
6
|
+
import { JsonObject, SerializedType, SerializedTypeID } from './serialized-type'
|
|
7
7
|
import { Hash192 } from './hash-192'
|
|
8
8
|
import { readUInt32BE, writeUInt32BE } from '../utils'
|
|
9
9
|
|
|
@@ -158,6 +158,10 @@ class Issue extends SerializedType {
|
|
|
158
158
|
issuer: issuer.toJSON(),
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
+
|
|
162
|
+
getSType(): SerializedTypeID {
|
|
163
|
+
return SerializedTypeID.STI_ISSUE
|
|
164
|
+
}
|
|
161
165
|
}
|
|
162
166
|
|
|
163
167
|
export { Issue, IssueObject }
|