@transia/ripple-binary-codec 1.4.6-alpha.9 → 2.5.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 +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 +3 -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 +1604 -969
- 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 +1606 -971
- 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 +7 -8
- package/dist/serdes/binary-serializer.js +14 -37
- 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 +65 -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 +3404 -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 +37 -0
- package/dist/src/types/account-id.js +73 -0
- package/dist/src/types/account-id.js.map +1 -0
- package/dist/src/types/amount.d.ts +92 -0
- package/dist/src/types/amount.js +292 -0
- package/dist/src/types/amount.js.map +1 -0
- package/dist/src/types/blob.d.ts +25 -0
- package/dist/src/types/blob.js +46 -0
- package/dist/src/types/blob.js.map +1 -0
- package/dist/src/types/currency.d.ts +30 -0
- package/dist/src/types/currency.js +131 -0
- package/dist/src/types/currency.js.map +1 -0
- package/dist/src/types/data.d.ts +104 -0
- package/dist/src/types/data.js +387 -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 +18 -0
- package/dist/src/types/hash-128.js +36 -0
- package/dist/src/types/hash-128.js.map +1 -0
- package/dist/src/types/hash-160.d.ts +12 -0
- package/dist/src/types/hash-160.js +23 -0
- package/dist/src/types/hash-160.js.map +1 -0
- package/dist/src/types/hash-192.d.ts +12 -0
- package/dist/src/types/hash-192.js +23 -0
- package/dist/src/types/hash-192.js.map +1 -0
- package/dist/src/types/hash-256.d.ts +12 -0
- package/dist/src/types/hash-256.js +20 -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 +21 -0
- package/dist/src/types/index.js +72 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/issue.d.ts +49 -0
- package/dist/src/types/issue.js +107 -0
- package/dist/src/types/issue.js.map +1 -0
- package/dist/src/types/json.d.ts +169 -0
- package/dist/src/types/json.js +529 -0
- package/dist/src/types/json.js.map +1 -0
- package/dist/src/types/path-set.d.ts +37 -0
- package/dist/src/types/path-set.js +236 -0
- package/dist/src/types/path-set.js.map +1 -0
- package/dist/src/types/serialized-type.d.ts +117 -0
- package/dist/src/types/serialized-type.js +242 -0
- package/dist/src/types/serialized-type.js.map +1 -0
- package/dist/src/types/st-array.d.ts +32 -0
- package/dist/src/types/st-array.js +89 -0
- package/dist/src/types/st-array.js.map +1 -0
- package/dist/src/types/st-number.d.ts +55 -0
- package/dist/src/types/st-number.js +212 -0
- package/dist/src/types/st-number.js.map +1 -0
- package/dist/src/types/st-object.d.ts +33 -0
- package/dist/src/types/st-object.js +176 -0
- package/dist/src/types/st-object.js.map +1 -0
- package/dist/src/types/uint-16.d.ts +26 -0
- package/dist/src/types/uint-16.js +49 -0
- package/dist/src/types/uint-16.js.map +1 -0
- package/dist/src/types/uint-32.d.ts +26 -0
- package/dist/src/types/uint-32.js +54 -0
- package/dist/src/types/uint-32.js.map +1 -0
- package/dist/src/types/uint-64.d.ts +40 -0
- package/dist/src/types/uint-64.js +112 -0
- package/dist/src/types/uint-64.js.map +1 -0
- package/dist/src/types/uint-8.d.ts +26 -0
- package/dist/src/types/uint-8.js +50 -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 +31 -0
- package/dist/src/types/vector-256.js +76 -0
- package/dist/src/types/vector-256.js.map +1 -0
- package/dist/src/types/xchain-bridge.d.ts +45 -0
- package/dist/src/types/xchain-bridge.js +105 -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 +3 -2
- package/dist/types/account-id.js +8 -6
- package/dist/types/account-id.js.map +1 -1
- package/dist/types/amount.d.ts +33 -9
- package/dist/types/amount.js +128 -43
- package/dist/types/amount.js.map +1 -1
- package/dist/types/blob.d.ts +3 -3
- package/dist/types/blob.js +8 -2
- package/dist/types/blob.js.map +1 -1
- package/dist/types/currency.d.ts +3 -2
- package/dist/types/currency.js +17 -13
- package/dist/types/currency.js.map +1 -1
- package/dist/types/data.d.ts +104 -0
- package/dist/types/data.js +387 -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 +3 -2
- package/dist/types/hash-128.js +7 -3
- package/dist/types/hash-128.js.map +1 -1
- package/dist/types/hash-160.d.ts +3 -2
- package/dist/types/hash-160.js +5 -2
- package/dist/types/hash-160.js.map +1 -1
- package/dist/types/hash-192.d.ts +12 -0
- package/dist/types/hash-192.js +23 -0
- package/dist/types/hash-192.js.map +1 -0
- package/dist/types/hash-256.d.ts +3 -2
- package/dist/types/hash-256.js +5 -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 +4 -1
- package/dist/types/index.js +17 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/issue.d.ts +49 -0
- package/dist/types/issue.js +107 -0
- package/dist/types/issue.js.map +1 -0
- package/dist/types/json.d.ts +169 -0
- package/dist/types/json.js +529 -0
- package/dist/types/json.js.map +1 -0
- package/dist/types/path-set.d.ts +2 -1
- package/dist/types/path-set.js +15 -12
- package/dist/types/path-set.js.map +1 -1
- package/dist/types/serialized-type.d.ts +70 -16
- package/dist/types/serialized-type.js +153 -8
- package/dist/types/serialized-type.js.map +1 -1
- package/dist/types/st-array.d.ts +7 -3
- package/dist/types/st-array.js +20 -11
- package/dist/types/st-array.js.map +1 -1
- package/dist/types/st-number.d.ts +55 -0
- package/dist/types/st-number.js +212 -0
- package/dist/types/st-number.js.map +1 -0
- package/dist/types/st-object.d.ts +2 -1
- package/dist/types/st-object.js +35 -8
- package/dist/types/st-object.js.map +1 -1
- package/dist/types/uint-16.d.ts +3 -2
- package/dist/types/uint-16.js +10 -5
- package/dist/types/uint-16.js.map +1 -1
- package/dist/types/uint-32.d.ts +3 -2
- package/dist/types/uint-32.js +11 -6
- package/dist/types/uint-32.js.map +1 -1
- package/dist/types/uint-64.d.ts +8 -7
- package/dist/types/uint-64.js +49 -24
- package/dist/types/uint-64.js.map +1 -1
- package/dist/types/uint-8.d.ts +3 -2
- package/dist/types/uint-8.js +11 -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 +3 -3
- package/dist/types/vector-256.js +5 -4
- package/dist/types/vector-256.js.map +1 -1
- package/dist/types/xchain-bridge.d.ts +45 -0
- package/dist/types/xchain-bridge.js +105 -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 +80 -0
- package/src/enums/constants.ts +5 -0
- package/src/enums/definitions.json +3409 -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 +189 -0
- package/src/types/account-id.ts +91 -0
- package/src/types/amount.ts +366 -0
- package/src/types/blob.ts +50 -0
- package/src/types/currency.ts +145 -0
- package/src/types/data.ts +496 -0
- package/src/types/dataType.ts +178 -0
- package/src/types/hash-128.ts +38 -0
- package/src/types/hash-160.ts +24 -0
- package/src/types/hash-192.ts +24 -0
- package/src/types/hash-256.ts +20 -0
- package/src/types/hash.ts +86 -0
- package/src/types/index.ts +74 -0
- package/src/types/issue.ts +140 -0
- package/src/types/json.ts +641 -0
- package/src/types/path-set.ts +294 -0
- package/src/types/serialized-type.ts +271 -0
- package/src/types/st-array.ts +117 -0
- package/src/types/st-number.ts +238 -0
- package/src/types/st-object.ts +219 -0
- package/src/types/uint-16.ts +58 -0
- package/src/types/uint-32.ts +64 -0
- package/src/types/uint-64.ts +141 -0
- package/src/types/uint-8.ts +57 -0
- package/src/types/uint.ts +60 -0
- package/src/types/vector-256.ts +83 -0
- package/src/types/xchain-bridge.ts +132 -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
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Bytes } from './bytes'
|
|
2
|
+
import { SerializedType } from '../types/serialized-type'
|
|
3
|
+
import { TYPE_WIDTH } from './constants'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Encoding information for a rippled field, often used in transactions.
|
|
7
|
+
* See the enums [README.md](https://github.com/XRPLF/xrpl.js/tree/main/packages/ripple-binary-codec/src/enums) for more details on what each means.
|
|
8
|
+
*/
|
|
9
|
+
export interface FieldInfo {
|
|
10
|
+
nth: number
|
|
11
|
+
isVLEncoded: boolean
|
|
12
|
+
isSerialized: boolean
|
|
13
|
+
isSigningField: boolean
|
|
14
|
+
type: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface FieldInstance {
|
|
18
|
+
readonly nth: number
|
|
19
|
+
readonly isVariableLengthEncoded: boolean
|
|
20
|
+
readonly isSerialized: boolean
|
|
21
|
+
readonly isSigningField: boolean
|
|
22
|
+
readonly type: Bytes
|
|
23
|
+
readonly ordinal: number
|
|
24
|
+
readonly name: string
|
|
25
|
+
readonly header: Uint8Array
|
|
26
|
+
readonly associatedType: typeof SerializedType
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* @brief: Serialize a field based on type_code and Field.nth
|
|
31
|
+
*/
|
|
32
|
+
function fieldHeader(type: number, nth: number): Uint8Array {
|
|
33
|
+
const header: Array<number> = []
|
|
34
|
+
if (type < 16) {
|
|
35
|
+
if (nth < 16) {
|
|
36
|
+
header.push((type << 4) | nth)
|
|
37
|
+
} else {
|
|
38
|
+
header.push(type << 4, nth)
|
|
39
|
+
}
|
|
40
|
+
} else if (nth < 16) {
|
|
41
|
+
header.push(nth, type)
|
|
42
|
+
} else {
|
|
43
|
+
header.push(0, type, nth)
|
|
44
|
+
}
|
|
45
|
+
return Uint8Array.from(header)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function buildField(
|
|
49
|
+
[name, info]: [string, FieldInfo],
|
|
50
|
+
typeOrdinal: number,
|
|
51
|
+
): FieldInstance {
|
|
52
|
+
const field = fieldHeader(typeOrdinal, info.nth)
|
|
53
|
+
return {
|
|
54
|
+
name: name,
|
|
55
|
+
nth: info.nth,
|
|
56
|
+
isVariableLengthEncoded: info.isVLEncoded,
|
|
57
|
+
isSerialized: info.isSerialized,
|
|
58
|
+
isSigningField: info.isSigningField,
|
|
59
|
+
ordinal: (typeOrdinal << 16) | info.nth,
|
|
60
|
+
type: new Bytes(info.type, typeOrdinal, TYPE_WIDTH),
|
|
61
|
+
header: field,
|
|
62
|
+
associatedType: SerializedType, // For later assignment in ./types/index.js or Definitions.updateAll(...)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* @brief: The collection of all fields as defined in definitions.json
|
|
68
|
+
*/
|
|
69
|
+
export class FieldLookup {
|
|
70
|
+
constructor(
|
|
71
|
+
fields: Array<[string, FieldInfo]>,
|
|
72
|
+
types: Record<string, number>,
|
|
73
|
+
) {
|
|
74
|
+
fields.forEach(([name, field_info]) => {
|
|
75
|
+
const typeOrdinal = types[field_info.type]
|
|
76
|
+
this[name] = buildField([name, field_info], typeOrdinal)
|
|
77
|
+
this[this[name].ordinal.toString()] = this[name]
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
fromString(value: string): FieldInstance {
|
|
82
|
+
return this[value] as FieldInstance
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import enums from './definitions.json'
|
|
2
|
+
import {
|
|
3
|
+
XrplDefinitionsBase,
|
|
4
|
+
FieldInstance,
|
|
5
|
+
Bytes,
|
|
6
|
+
} from './xrpl-definitions-base'
|
|
7
|
+
/**
|
|
8
|
+
* By default, coreTypes from the `types` folder is where known type definitions are initialized to avoid import cycles.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_DEFINITIONS = new XrplDefinitionsBase(enums, {})
|
|
11
|
+
|
|
12
|
+
const Type = DEFAULT_DEFINITIONS.type
|
|
13
|
+
const LedgerEntryType = DEFAULT_DEFINITIONS.ledgerEntryType
|
|
14
|
+
const TransactionType = DEFAULT_DEFINITIONS.transactionType
|
|
15
|
+
const TransactionResult = DEFAULT_DEFINITIONS.transactionResult
|
|
16
|
+
const Field = DEFAULT_DEFINITIONS.field
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* @brief: All valid transaction types
|
|
20
|
+
*/
|
|
21
|
+
const TRANSACTION_TYPES = DEFAULT_DEFINITIONS.transactionNames
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
Bytes,
|
|
25
|
+
XrplDefinitionsBase,
|
|
26
|
+
DEFAULT_DEFINITIONS,
|
|
27
|
+
Field,
|
|
28
|
+
FieldInstance,
|
|
29
|
+
Type,
|
|
30
|
+
LedgerEntryType,
|
|
31
|
+
TransactionResult,
|
|
32
|
+
TransactionType,
|
|
33
|
+
TRANSACTION_TYPES,
|
|
34
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quick script to re-number values
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const input = {
|
|
6
|
+
temBAD_SEND_XRP_PATHS: -283,
|
|
7
|
+
temBAD_SEQUENCE: -282,
|
|
8
|
+
temBAD_SIGNATURE: -281,
|
|
9
|
+
temBAD_SRC_ACCOUNT: -280,
|
|
10
|
+
temBAD_TRANSFER_RATE: -279,
|
|
11
|
+
temDST_IS_SRC: -278,
|
|
12
|
+
temDST_NEEDED: -277,
|
|
13
|
+
temINVALID: -276,
|
|
14
|
+
temINVALID_FLAG: -275,
|
|
15
|
+
temREDUNDANT: -274,
|
|
16
|
+
temRIPPLE_EMPTY: -273,
|
|
17
|
+
temDISABLED: -272,
|
|
18
|
+
temBAD_SIGNER: -271,
|
|
19
|
+
temBAD_QUORUM: -270,
|
|
20
|
+
temBAD_WEIGHT: -269,
|
|
21
|
+
temBAD_TICK_SIZE: -268,
|
|
22
|
+
temINVALID_ACCOUNT_ID: -267,
|
|
23
|
+
temCANNOT_PREAUTH_SELF: -266,
|
|
24
|
+
|
|
25
|
+
temUNCERTAIN: -265,
|
|
26
|
+
temUNKNOWN: -264,
|
|
27
|
+
|
|
28
|
+
tefFAILURE: -199,
|
|
29
|
+
tefALREADY: -198,
|
|
30
|
+
tefBAD_ADD_AUTH: -197,
|
|
31
|
+
tefBAD_AUTH: -196,
|
|
32
|
+
tefBAD_LEDGER: -195,
|
|
33
|
+
tefCREATED: -194,
|
|
34
|
+
tefEXCEPTION: -193,
|
|
35
|
+
tefINTERNAL: -192,
|
|
36
|
+
tefNO_AUTH_REQUIRED: -191,
|
|
37
|
+
tefPAST_SEQ: -190,
|
|
38
|
+
tefWRONG_PRIOR: -189,
|
|
39
|
+
tefMASTER_DISABLED: -188,
|
|
40
|
+
tefMAX_LEDGER: -187,
|
|
41
|
+
tefBAD_SIGNATURE: -186,
|
|
42
|
+
tefBAD_QUORUM: -185,
|
|
43
|
+
tefNOT_MULTI_SIGNING: -184,
|
|
44
|
+
tefBAD_AUTH_MASTER: -183,
|
|
45
|
+
tefINVARIANT_FAILED: -182,
|
|
46
|
+
tefTOO_BIG: -181,
|
|
47
|
+
|
|
48
|
+
terRETRY: -99,
|
|
49
|
+
terFUNDS_SPENT: -98,
|
|
50
|
+
terINSUF_FEE_B: -97,
|
|
51
|
+
terNO_ACCOUNT: -96,
|
|
52
|
+
terNO_AUTH: -95,
|
|
53
|
+
terNO_LINE: -94,
|
|
54
|
+
terOWNERS: -93,
|
|
55
|
+
terPRE_SEQ: -92,
|
|
56
|
+
terLAST: -91,
|
|
57
|
+
terNO_RIPPLE: -90,
|
|
58
|
+
terQUEUED: -89,
|
|
59
|
+
|
|
60
|
+
tesSUCCESS: 0,
|
|
61
|
+
|
|
62
|
+
tecCLAIM: 100,
|
|
63
|
+
tecPATH_PARTIAL: 101,
|
|
64
|
+
tecUNFUNDED_ADD: 102,
|
|
65
|
+
tecUNFUNDED_OFFER: 103,
|
|
66
|
+
tecUNFUNDED_PAYMENT: 104,
|
|
67
|
+
tecFAILED_PROCESSING: 105,
|
|
68
|
+
tecDIR_FULL: 121,
|
|
69
|
+
tecINSUF_RESERVE_LINE: 122,
|
|
70
|
+
tecINSUF_RESERVE_OFFER: 123,
|
|
71
|
+
tecNO_DST: 124,
|
|
72
|
+
tecNO_DST_INSUF_XRP: 125,
|
|
73
|
+
tecNO_LINE_INSUF_RESERVE: 126,
|
|
74
|
+
tecNO_LINE_REDUNDANT: 127,
|
|
75
|
+
tecPATH_DRY: 128,
|
|
76
|
+
tecUNFUNDED: 129,
|
|
77
|
+
tecNO_ALTERNATIVE_KEY: 130,
|
|
78
|
+
tecNO_REGULAR_KEY: 131,
|
|
79
|
+
tecOWNERS: 132,
|
|
80
|
+
tecNO_ISSUER: 133,
|
|
81
|
+
tecNO_AUTH: 134,
|
|
82
|
+
tecNO_LINE: 135,
|
|
83
|
+
tecINSUFF_FEE: 136,
|
|
84
|
+
tecFROZEN: 137,
|
|
85
|
+
tecNO_TARGET: 138,
|
|
86
|
+
tecNO_PERMISSION: 139,
|
|
87
|
+
tecNO_ENTRY: 140,
|
|
88
|
+
tecINSUFFICIENT_RESERVE: 141,
|
|
89
|
+
tecNEED_MASTER_KEY: 142,
|
|
90
|
+
tecDST_TAG_NEEDED: 143,
|
|
91
|
+
tecINTERNAL: 144,
|
|
92
|
+
tecOVERSIZE: 145,
|
|
93
|
+
tecCRYPTOCONDITION_ERROR: 146,
|
|
94
|
+
tecINVARIANT_FAILED: 147,
|
|
95
|
+
tecEXPIRED: 148,
|
|
96
|
+
tecDUPLICATE: 149,
|
|
97
|
+
tecKILLED: 150,
|
|
98
|
+
tecHAS_OBLIGATIONS: 151,
|
|
99
|
+
tecTOO_SOON: 152,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let startingFromTemBADSENDXRPPATHS = -284
|
|
103
|
+
|
|
104
|
+
let startingFromTefFAILURE = -199
|
|
105
|
+
|
|
106
|
+
let startingFromTerRETRY = -99
|
|
107
|
+
|
|
108
|
+
const tesSUCCESS = 0
|
|
109
|
+
|
|
110
|
+
let startingFromTecCLAIM = 100
|
|
111
|
+
|
|
112
|
+
const startingFromTecDIRFULL = 121
|
|
113
|
+
|
|
114
|
+
let previousKey = 'tem'
|
|
115
|
+
Object.keys(input).forEach((key) => {
|
|
116
|
+
if (key.substring(0, 3) !== previousKey.substring(0, 3)) {
|
|
117
|
+
console.log()
|
|
118
|
+
previousKey = key
|
|
119
|
+
}
|
|
120
|
+
if (key.substring(0, 3) === 'tem') {
|
|
121
|
+
console.log(` "${key}": ${startingFromTemBADSENDXRPPATHS++},`)
|
|
122
|
+
} else if (key.substring(0, 3) === 'tef') {
|
|
123
|
+
console.log(` "${key}": ${startingFromTefFAILURE++},`)
|
|
124
|
+
} else if (key.substring(0, 3) === 'ter') {
|
|
125
|
+
console.log(` "${key}": ${startingFromTerRETRY++},`)
|
|
126
|
+
} else if (key.substring(0, 3) === 'tes') {
|
|
127
|
+
console.log(` "${key}": ${tesSUCCESS},`)
|
|
128
|
+
} else if (key.substring(0, 3) === 'tec') {
|
|
129
|
+
if (key === 'tecDIR_FULL') {
|
|
130
|
+
startingFromTecCLAIM = startingFromTecDIRFULL
|
|
131
|
+
}
|
|
132
|
+
console.log(` "${key}": ${startingFromTecCLAIM++},`)
|
|
133
|
+
}
|
|
134
|
+
})
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { SerializedType } from '../types/serialized-type'
|
|
2
|
+
import { Bytes, BytesLookup } from './bytes'
|
|
3
|
+
import { FieldInfo, FieldLookup, FieldInstance } from './field'
|
|
4
|
+
import {
|
|
5
|
+
TYPE_WIDTH,
|
|
6
|
+
LEDGER_ENTRY_WIDTH,
|
|
7
|
+
TRANSACTION_TYPE_WIDTH,
|
|
8
|
+
TRANSACTION_RESULT_WIDTH,
|
|
9
|
+
DELEGATABLE_PERMISSIONS_WIDTH,
|
|
10
|
+
} from './constants'
|
|
11
|
+
|
|
12
|
+
interface DefinitionsData {
|
|
13
|
+
TYPES: Record<string, number>
|
|
14
|
+
LEDGER_ENTRY_TYPES: Record<string, number>
|
|
15
|
+
FIELDS: (string | FieldInfo)[][]
|
|
16
|
+
TRANSACTION_RESULTS: Record<string, number>
|
|
17
|
+
TRANSACTION_TYPES: Record<string, number>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Stores the various types and fields for rippled to be used to encode/decode information later on.
|
|
22
|
+
* XrplDefinitions should be instantiated instead of this class.
|
|
23
|
+
*/
|
|
24
|
+
class XrplDefinitionsBase {
|
|
25
|
+
// A collection of fields that can be included in transactions
|
|
26
|
+
field: FieldLookup
|
|
27
|
+
// A collection of ids corresponding to types of ledger objects
|
|
28
|
+
ledgerEntryType: BytesLookup
|
|
29
|
+
// A collection of type flags used to determine how to serialize a field's data
|
|
30
|
+
type: BytesLookup
|
|
31
|
+
// Errors and result codes for transactions
|
|
32
|
+
transactionResult: BytesLookup
|
|
33
|
+
// Defined transactions that can be submitted to the ledger
|
|
34
|
+
transactionType: BytesLookup
|
|
35
|
+
// Valid transaction names
|
|
36
|
+
transactionNames: string[]
|
|
37
|
+
// Maps serializable types to their TypeScript class implementation
|
|
38
|
+
dataTypes: Record<string, typeof SerializedType>
|
|
39
|
+
// Maps granular permissions names to their corresponding integer ids
|
|
40
|
+
granularPermissions: Record<string, number>
|
|
41
|
+
// Defined delegatable permissions
|
|
42
|
+
delegatablePermissions: BytesLookup
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Present rippled types in a typed and updatable format.
|
|
46
|
+
* For an example of the input format see `definitions.json`.
|
|
47
|
+
* To generate a new definitions file from rippled source code, use the tool at
|
|
48
|
+
* `packages/ripple-binary-codec/tools/generateDefinitions.js`.
|
|
49
|
+
*
|
|
50
|
+
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
|
|
51
|
+
*
|
|
52
|
+
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
|
|
53
|
+
* @param types - A list of type objects with the same name as the fields defined.
|
|
54
|
+
* You can use the coreTypes object if you are not adding new types.
|
|
55
|
+
*/
|
|
56
|
+
constructor(
|
|
57
|
+
enums: DefinitionsData,
|
|
58
|
+
types: Record<string, typeof SerializedType>,
|
|
59
|
+
) {
|
|
60
|
+
this.type = new BytesLookup(enums.TYPES, TYPE_WIDTH)
|
|
61
|
+
this.ledgerEntryType = new BytesLookup(
|
|
62
|
+
enums.LEDGER_ENTRY_TYPES,
|
|
63
|
+
LEDGER_ENTRY_WIDTH,
|
|
64
|
+
)
|
|
65
|
+
this.transactionType = new BytesLookup(
|
|
66
|
+
enums.TRANSACTION_TYPES,
|
|
67
|
+
TRANSACTION_TYPE_WIDTH,
|
|
68
|
+
)
|
|
69
|
+
this.transactionResult = new BytesLookup(
|
|
70
|
+
enums.TRANSACTION_RESULTS,
|
|
71
|
+
TRANSACTION_RESULT_WIDTH,
|
|
72
|
+
)
|
|
73
|
+
this.field = new FieldLookup(
|
|
74
|
+
enums.FIELDS as Array<[string, FieldInfo]>,
|
|
75
|
+
enums.TYPES,
|
|
76
|
+
)
|
|
77
|
+
this.transactionNames = Object.entries(enums.TRANSACTION_TYPES)
|
|
78
|
+
.filter(([_key, value]) => value >= 0)
|
|
79
|
+
.map(([key, _value]) => key)
|
|
80
|
+
|
|
81
|
+
this.dataTypes = {} // Filled in via associateTypes
|
|
82
|
+
this.associateTypes(types)
|
|
83
|
+
|
|
84
|
+
this.granularPermissions = {
|
|
85
|
+
TrustlineAuthorize: 65537,
|
|
86
|
+
TrustlineFreeze: 65538,
|
|
87
|
+
TrustlineUnfreeze: 65539,
|
|
88
|
+
AccountDomainSet: 65540,
|
|
89
|
+
AccountEmailHashSet: 65541,
|
|
90
|
+
AccountMessageKeySet: 65542,
|
|
91
|
+
AccountTransferRateSet: 65543,
|
|
92
|
+
AccountTickSizeSet: 65544,
|
|
93
|
+
PaymentMint: 65545,
|
|
94
|
+
PaymentBurn: 65546,
|
|
95
|
+
MPTokenIssuanceLock: 65547,
|
|
96
|
+
MPTokenIssuanceUnlock: 65548,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const incrementedTransactionTypes = Object.fromEntries(
|
|
100
|
+
Object.entries(enums.TRANSACTION_TYPES).map(([key, value]) => [
|
|
101
|
+
key,
|
|
102
|
+
value + 1,
|
|
103
|
+
]),
|
|
104
|
+
)
|
|
105
|
+
const combinedPermissions = {
|
|
106
|
+
...this.granularPermissions,
|
|
107
|
+
...incrementedTransactionTypes,
|
|
108
|
+
}
|
|
109
|
+
this.delegatablePermissions = new BytesLookup(
|
|
110
|
+
combinedPermissions,
|
|
111
|
+
DELEGATABLE_PERMISSIONS_WIDTH,
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Associates each Field to a corresponding class that TypeScript can recognize.
|
|
117
|
+
*
|
|
118
|
+
* @param types a list of type objects with the same name as the fields defined.
|
|
119
|
+
* Defaults to xrpl.js's core type definitions.
|
|
120
|
+
*/
|
|
121
|
+
public associateTypes(types: Record<string, typeof SerializedType>): void {
|
|
122
|
+
// Overwrite any existing type definitions with the given types
|
|
123
|
+
this.dataTypes = Object.assign({}, this.dataTypes, types)
|
|
124
|
+
|
|
125
|
+
Object.values(this.field).forEach((field) => {
|
|
126
|
+
field.associatedType = this.dataTypes[field.type.name]
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
this.field['TransactionType'].associatedType = this.transactionType
|
|
130
|
+
this.field['TransactionResult'].associatedType = this.transactionResult
|
|
131
|
+
this.field['LedgerEntryType'].associatedType = this.ledgerEntryType
|
|
132
|
+
if (this.field['PermissionValue']) {
|
|
133
|
+
this.field['PermissionValue'].associatedType = this.delegatablePermissions
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public getAssociatedTypes(): Record<string, typeof SerializedType> {
|
|
138
|
+
return this.dataTypes
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export {
|
|
143
|
+
DefinitionsData,
|
|
144
|
+
XrplDefinitionsBase,
|
|
145
|
+
FieldLookup,
|
|
146
|
+
FieldInfo,
|
|
147
|
+
FieldInstance,
|
|
148
|
+
Bytes,
|
|
149
|
+
BytesLookup,
|
|
150
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type DefinitionsData,
|
|
3
|
+
XrplDefinitionsBase,
|
|
4
|
+
} from './xrpl-definitions-base'
|
|
5
|
+
import { coreTypes } from '../types'
|
|
6
|
+
import { SerializedType } from '../types/serialized-type'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Stores the various types and fields for rippled to be used to encode/decode information later on.
|
|
10
|
+
* Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
|
|
11
|
+
* ledger data.
|
|
12
|
+
*/
|
|
13
|
+
export class XrplDefinitions extends XrplDefinitionsBase {
|
|
14
|
+
/**
|
|
15
|
+
* Present rippled types in a typed and updatable format.
|
|
16
|
+
* For an example of the input format see `definitions.json`
|
|
17
|
+
* To generate a new definitions file from rippled source code, use the tool at
|
|
18
|
+
* `packages/ripple-binary-codec/tools/generateDefinitions.js`.
|
|
19
|
+
*
|
|
20
|
+
* See the definitions.test.js file for examples of how to create your own updated definitions.json.
|
|
21
|
+
*
|
|
22
|
+
* @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
|
|
23
|
+
* @param additionalTypes - A list of SerializedType objects with the same name as the fields defined.
|
|
24
|
+
* These types will be included in addition to the coreTypes used on mainnet.
|
|
25
|
+
*/
|
|
26
|
+
constructor(
|
|
27
|
+
enums: DefinitionsData,
|
|
28
|
+
additionalTypes?: Record<string, typeof SerializedType>,
|
|
29
|
+
) {
|
|
30
|
+
const types = Object.assign({}, coreTypes, additionalTypes)
|
|
31
|
+
super(enums, types)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { writeUInt32BE } from './utils'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Write a 32 bit integer to a Uint8Array
|
|
5
|
+
*
|
|
6
|
+
* @param uint32 32 bit integer to write to Uint8Array
|
|
7
|
+
* @returns a Uint8Array with the bytes representation of uint32
|
|
8
|
+
*/
|
|
9
|
+
function bytes(uint32: number): Uint8Array {
|
|
10
|
+
const result = new Uint8Array(4)
|
|
11
|
+
writeUInt32BE(result, uint32, 0)
|
|
12
|
+
return result
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Maps HashPrefix names to their byte representation
|
|
17
|
+
*/
|
|
18
|
+
const HashPrefix: Record<string, Uint8Array> = {
|
|
19
|
+
transactionID: bytes(0x54584e00),
|
|
20
|
+
// transaction plus metadata
|
|
21
|
+
transaction: bytes(0x534e4400),
|
|
22
|
+
// account state
|
|
23
|
+
accountStateEntry: bytes(0x4d4c4e00),
|
|
24
|
+
// inner node in tree
|
|
25
|
+
innerNode: bytes(0x4d494e00),
|
|
26
|
+
// ledger master data for signing
|
|
27
|
+
ledgerHeader: bytes(0x4c575200),
|
|
28
|
+
// inner transaction to sign
|
|
29
|
+
transactionSig: bytes(0x53545800),
|
|
30
|
+
// inner transaction to sign
|
|
31
|
+
transactionMultiSig: bytes(0x534d5400),
|
|
32
|
+
// validation for signing
|
|
33
|
+
validation: bytes(0x56414c00),
|
|
34
|
+
// proposal for signing
|
|
35
|
+
proposal: bytes(0x50525000),
|
|
36
|
+
// payment channel claim
|
|
37
|
+
paymentChannelClaim: bytes(0x434c4d00),
|
|
38
|
+
// batch
|
|
39
|
+
batch: bytes(0x42434800),
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { HashPrefix }
|
package/src/hashes.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { HashPrefix } from './hash-prefixes'
|
|
2
|
+
import { Hash256 } from './types'
|
|
3
|
+
import { BytesList } from './serdes/binary-serializer'
|
|
4
|
+
import { sha512 } from '@transia/isomorphic/sha512'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Class for hashing with SHA512
|
|
8
|
+
* @extends BytesList So SerializedTypes can write bytes to a Sha512Half
|
|
9
|
+
*/
|
|
10
|
+
class Sha512Half extends BytesList {
|
|
11
|
+
private hash = sha512.create()
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Construct a new Sha512Hash and write bytes this.hash
|
|
15
|
+
*
|
|
16
|
+
* @param bytes bytes to write to this.hash
|
|
17
|
+
* @returns the new Sha512Hash object
|
|
18
|
+
*/
|
|
19
|
+
static put(bytes: Uint8Array): Sha512Half {
|
|
20
|
+
return new Sha512Half().put(bytes)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Write bytes to an existing Sha512Hash
|
|
25
|
+
*
|
|
26
|
+
* @param bytes bytes to write to object
|
|
27
|
+
* @returns the Sha512 object
|
|
28
|
+
*/
|
|
29
|
+
put(bytes: Uint8Array): Sha512Half {
|
|
30
|
+
this.hash.update(bytes)
|
|
31
|
+
return this
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Compute SHA512 hash and slice in half
|
|
36
|
+
*
|
|
37
|
+
* @returns half of a SHA512 hash
|
|
38
|
+
*/
|
|
39
|
+
finish256(): Uint8Array {
|
|
40
|
+
return Uint8Array.from(this.hash.digest().slice(0, 32))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Constructs a Hash256 from the Sha512Half object
|
|
45
|
+
*
|
|
46
|
+
* @returns a Hash256 object
|
|
47
|
+
*/
|
|
48
|
+
finish(): Hash256 {
|
|
49
|
+
return new Hash256(this.finish256())
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* compute SHA512 hash of a list of bytes
|
|
55
|
+
*
|
|
56
|
+
* @param args zero or more arguments to hash
|
|
57
|
+
* @returns the sha512half hash of the arguments.
|
|
58
|
+
*/
|
|
59
|
+
function sha512Half(...args: Uint8Array[]): Uint8Array {
|
|
60
|
+
const hash = new Sha512Half()
|
|
61
|
+
args.forEach((a) => hash.put(a))
|
|
62
|
+
return hash.finish256()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Construct a transactionID from a Serialized Transaction
|
|
67
|
+
*
|
|
68
|
+
* @param serialized bytes to hash
|
|
69
|
+
* @returns a Hash256 object
|
|
70
|
+
*/
|
|
71
|
+
function transactionID(serialized: Uint8Array): Hash256 {
|
|
72
|
+
return new Hash256(sha512Half(HashPrefix.transactionID, serialized))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { Sha512Half, sha512Half, transactionID }
|