ripple-binary-codec 0.2.7 → 1.0.0-mpt-beta
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/README.md +104 -2
- package/dist/binary.d.ts +90 -0
- package/dist/binary.js +128 -0
- package/dist/binary.js.map +1 -0
- package/dist/coretypes.d.ts +9 -0
- package/dist/coretypes.js +48 -0
- package/dist/coretypes.js.map +1 -0
- package/dist/enums/bytes.d.ts +25 -0
- package/dist/enums/bytes.js +63 -0
- package/dist/enums/bytes.js.map +1 -0
- package/dist/enums/constants.d.ts +4 -0
- package/dist/enums/constants.js +8 -0
- package/dist/enums/constants.js.map +1 -0
- package/dist/enums/definitions.json +2956 -0
- package/dist/enums/field.d.ts +28 -0
- package/dist/enums/field.js +58 -0
- package/dist/enums/field.js.map +1 -0
- package/dist/enums/index.d.ts +12 -0
- package/dist/enums/index.js +31 -0
- package/dist/enums/index.js.map +1 -0
- package/{distrib/npm → dist/enums/src}/enums/definitions.json +1709 -438
- package/dist/enums/utils-renumber.d.ts +101 -0
- package/dist/enums/utils-renumber.js +127 -0
- package/dist/enums/utils-renumber.js.map +1 -0
- package/dist/enums/xrpl-definitions-base.d.ts +44 -0
- package/dist/enums/xrpl-definitions-base.js +59 -0
- package/dist/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/enums/xrpl-definitions.d.ts +21 -0
- package/dist/enums/xrpl-definitions.js +29 -0
- package/dist/enums/xrpl-definitions.js.map +1 -0
- package/dist/hash-prefixes.d.ts +5 -0
- package/dist/hash-prefixes.js +41 -0
- package/dist/hash-prefixes.js.map +1 -0
- package/dist/hashes.d.ts +50 -0
- package/dist/hashes.js +76 -0
- package/dist/hashes.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +123 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger-hashes.d.ts +48 -0
- package/dist/ledger-hashes.js +141 -0
- package/dist/ledger-hashes.js.map +1 -0
- package/dist/quality.d.ts +21 -0
- package/dist/quality.js +42 -0
- package/dist/quality.js.map +1 -0
- package/dist/serdes/binary-parser.d.ts +100 -0
- package/dist/serdes/binary-parser.js +194 -0
- package/dist/serdes/binary-parser.js.map +1 -0
- package/dist/serdes/binary-serializer.d.ts +81 -0
- package/dist/serdes/binary-serializer.js +149 -0
- package/dist/serdes/binary-serializer.js.map +1 -0
- package/dist/shamap.d.ts +102 -0
- package/dist/shamap.js +172 -0
- package/dist/shamap.js.map +1 -0
- package/dist/src/binary.d.ts +90 -0
- package/dist/src/binary.js +128 -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 +63 -0
- package/dist/src/enums/bytes.js.map +1 -0
- package/dist/src/enums/constants.d.ts +4 -0
- package/dist/src/enums/constants.js +8 -0
- package/dist/src/enums/constants.js.map +1 -0
- package/dist/src/enums/definitions.json +2956 -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 +44 -0
- package/dist/src/enums/xrpl-definitions-base.js +59 -0
- package/dist/src/enums/xrpl-definitions-base.js.map +1 -0
- package/dist/src/enums/xrpl-definitions.d.ts +21 -0
- package/dist/src/enums/xrpl-definitions.js +29 -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 +41 -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 +64 -0
- package/dist/src/index.js +123 -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 +35 -0
- package/dist/src/types/account-id.js +69 -0
- package/dist/src/types/account-id.js.map +1 -0
- package/dist/src/types/amount.d.ts +91 -0
- package/dist/src/types/amount.js +289 -0
- package/dist/src/types/amount.js.map +1 -0
- package/dist/src/types/blob.d.ts +24 -0
- package/dist/src/types/blob.js +40 -0
- package/dist/src/types/blob.js.map +1 -0
- package/dist/src/types/currency.d.ts +28 -0
- package/dist/src/types/currency.js +127 -0
- package/dist/src/types/currency.js.map +1 -0
- package/dist/src/types/hash-128.d.ts +16 -0
- package/dist/src/types/hash-128.js +32 -0
- package/dist/src/types/hash-128.js.map +1 -0
- package/dist/src/types/hash-160.d.ts +10 -0
- package/dist/src/types/hash-160.js +19 -0
- package/dist/src/types/hash-160.js.map +1 -0
- package/dist/src/types/hash-192.d.ts +10 -0
- package/dist/src/types/hash-192.js +19 -0
- package/dist/src/types/hash-192.js.map +1 -0
- package/dist/src/types/hash-256.d.ts +10 -0
- package/dist/src/types/hash-256.js +16 -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 +73 -0
- package/dist/src/types/hash.js.map +1 -0
- package/dist/src/types/index.d.ts +19 -0
- package/dist/src/types/index.js +64 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/issue.d.ts +38 -0
- package/dist/src/types/issue.js +81 -0
- package/dist/src/types/issue.js.map +1 -0
- package/dist/src/types/path-set.d.ts +36 -0
- package/dist/src/types/path-set.js +233 -0
- package/dist/src/types/path-set.js.map +1 -0
- package/dist/src/types/serialized-type.d.ts +70 -0
- package/dist/src/types/serialized-type.js +105 -0
- package/dist/src/types/serialized-type.js.map +1 -0
- package/dist/src/types/st-array.d.ts +31 -0
- package/dist/src/types/st-array.js +83 -0
- package/dist/src/types/st-array.js.map +1 -0
- package/dist/src/types/st-object.d.ts +32 -0
- package/dist/src/types/st-object.js +155 -0
- package/dist/src/types/st-object.js.map +1 -0
- package/dist/src/types/uint-16.d.ts +24 -0
- package/dist/src/types/uint-16.js +45 -0
- package/dist/src/types/uint-16.js.map +1 -0
- package/dist/src/types/uint-32.d.ts +24 -0
- package/dist/src/types/uint-32.js +50 -0
- package/dist/src/types/uint-32.js.map +1 -0
- package/dist/src/types/uint-64.d.ts +37 -0
- package/dist/src/types/uint-64.js +86 -0
- package/dist/src/types/uint-64.js.map +1 -0
- package/dist/src/types/uint-8.d.ts +24 -0
- package/dist/src/types/uint-8.js +46 -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 +30 -0
- package/dist/src/types/vector-256.js +73 -0
- package/dist/src/types/vector-256.js.map +1 -0
- package/dist/src/types/xchain-bridge.d.ts +44 -0
- package/dist/src/types/xchain-bridge.js +102 -0
- package/dist/src/types/xchain-bridge.js.map +1 -0
- package/dist/src/utils.d.ts +47 -0
- package/dist/src/utils.js +137 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/account-id.d.ts +35 -0
- package/dist/types/account-id.js +69 -0
- package/dist/types/account-id.js.map +1 -0
- package/dist/types/amount.d.ts +91 -0
- package/dist/types/amount.js +289 -0
- package/dist/types/amount.js.map +1 -0
- package/dist/types/blob.d.ts +24 -0
- package/dist/types/blob.js +40 -0
- package/dist/types/blob.js.map +1 -0
- package/dist/types/currency.d.ts +28 -0
- package/dist/types/currency.js +127 -0
- package/dist/types/currency.js.map +1 -0
- package/dist/types/hash-128.d.ts +16 -0
- package/dist/types/hash-128.js +32 -0
- package/dist/types/hash-128.js.map +1 -0
- package/dist/types/hash-160.d.ts +10 -0
- package/dist/types/hash-160.js +19 -0
- package/dist/types/hash-160.js.map +1 -0
- package/dist/types/hash-192.d.ts +10 -0
- package/dist/types/hash-192.js +19 -0
- package/dist/types/hash-192.js.map +1 -0
- package/dist/types/hash-256.d.ts +10 -0
- package/dist/types/hash-256.js +16 -0
- package/dist/types/hash-256.js.map +1 -0
- package/dist/types/hash.d.ts +40 -0
- package/dist/types/hash.js +73 -0
- package/dist/types/hash.js.map +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.js +64 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/issue.d.ts +38 -0
- package/dist/types/issue.js +81 -0
- package/dist/types/issue.js.map +1 -0
- package/dist/types/path-set.d.ts +36 -0
- package/dist/types/path-set.js +233 -0
- package/dist/types/path-set.js.map +1 -0
- package/dist/types/serialized-type.d.ts +70 -0
- package/dist/types/serialized-type.js +105 -0
- package/dist/types/serialized-type.js.map +1 -0
- package/dist/types/st-array.d.ts +31 -0
- package/dist/types/st-array.js +83 -0
- package/dist/types/st-array.js.map +1 -0
- package/dist/types/st-object.d.ts +32 -0
- package/dist/types/st-object.js +155 -0
- package/dist/types/st-object.js.map +1 -0
- package/dist/types/uint-16.d.ts +24 -0
- package/dist/types/uint-16.js +45 -0
- package/dist/types/uint-16.js.map +1 -0
- package/dist/types/uint-32.d.ts +24 -0
- package/dist/types/uint-32.js +50 -0
- package/dist/types/uint-32.js.map +1 -0
- package/dist/types/uint-64.d.ts +37 -0
- package/dist/types/uint-64.js +86 -0
- package/dist/types/uint-64.js.map +1 -0
- package/dist/types/uint-8.d.ts +24 -0
- package/dist/types/uint-8.js +46 -0
- package/dist/types/uint-8.js.map +1 -0
- package/dist/types/uint.d.ts +29 -0
- package/dist/types/uint.js +47 -0
- package/dist/types/uint.js.map +1 -0
- package/dist/types/vector-256.d.ts +30 -0
- package/dist/types/vector-256.js +73 -0
- package/dist/types/vector-256.js.map +1 -0
- package/dist/types/xchain-bridge.d.ts +44 -0
- package/dist/types/xchain-bridge.js +102 -0
- package/dist/types/xchain-bridge.js.map +1 -0
- package/dist/utils.d.ts +47 -0
- package/dist/utils.js +137 -0
- package/dist/utils.js.map +1 -0
- package/package.json +28 -33
- package/src/README.md +5 -0
- package/src/binary.ts +194 -0
- package/src/coretypes.ts +31 -0
- package/src/enums/README.md +144 -0
- package/src/enums/bytes.ts +74 -0
- package/src/enums/constants.ts +4 -0
- package/src/enums/definitions.json +2961 -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 +111 -0
- package/src/enums/xrpl-definitions.ts +32 -0
- package/src/hash-prefixes.ts +40 -0
- package/src/hashes.ts +75 -0
- package/src/index.ts +153 -0
- package/src/ledger-hashes.ts +191 -0
- package/src/quality.ts +38 -0
- package/src/serdes/binary-parser.ts +224 -0
- package/src/serdes/binary-serializer.ts +166 -0
- package/src/shamap.ts +186 -0
- package/src/types/account-id.ts +86 -0
- package/src/types/amount.ts +362 -0
- package/src/types/blob.ts +43 -0
- package/src/types/currency.ts +140 -0
- package/src/types/hash-128.ts +33 -0
- package/src/types/hash-160.ts +19 -0
- package/src/types/hash-192.ts +19 -0
- package/src/types/hash-256.ts +15 -0
- package/src/types/hash.ts +83 -0
- package/src/types/index.ts +66 -0
- package/src/types/issue.ts +96 -0
- package/src/types/path-set.ts +290 -0
- package/src/types/serialized-type.ts +122 -0
- package/src/types/st-array.ts +107 -0
- package/src/types/st-object.ts +192 -0
- package/src/types/uint-16.ts +53 -0
- package/src/types/uint-32.ts +59 -0
- package/src/types/uint-64.ts +104 -0
- package/src/types/uint-8.ts +52 -0
- package/src/types/uint.ts +60 -0
- package/src/types/vector-256.ts +79 -0
- package/src/types/xchain-bridge.ts +128 -0
- package/src/utils.ts +152 -0
- package/HISTORY.md +0 -66
- package/distrib/npm/binary.js +0 -68
- package/distrib/npm/coretypes.js +0 -22
- package/distrib/npm/enums/index.js +0 -125
- package/distrib/npm/enums/utils-renumber.js +0 -134
- package/distrib/npm/hash-prefixes.js +0 -30
- package/distrib/npm/hashes.js +0 -42
- package/distrib/npm/index.js +0 -72
- package/distrib/npm/ledger-hashes.js +0 -71
- package/distrib/npm/quality.js +0 -20
- package/distrib/npm/serdes/binary-parser.js +0 -98
- package/distrib/npm/serdes/binary-serializer.js +0 -106
- package/distrib/npm/shamap.js +0 -107
- package/distrib/npm/types/account-id.js +0 -41
- package/distrib/npm/types/amount.js +0 -215
- package/distrib/npm/types/blob.js +0 -28
- package/distrib/npm/types/currency.js +0 -91
- package/distrib/npm/types/hash-128.js +0 -10
- package/distrib/npm/types/hash-160.js +0 -10
- package/distrib/npm/types/hash-256.js +0 -15
- package/distrib/npm/types/hash.js +0 -45
- package/distrib/npm/types/index.js +0 -45
- package/distrib/npm/types/path-set.js +0 -112
- package/distrib/npm/types/serialized-type.js +0 -63
- package/distrib/npm/types/st-array.js +0 -37
- package/distrib/npm/types/st-object.js +0 -65
- package/distrib/npm/types/uint-16.js +0 -10
- package/distrib/npm/types/uint-32.js +0 -10
- package/distrib/npm/types/uint-64.js +0 -49
- package/distrib/npm/types/uint-8.js +0 -10
- package/distrib/npm/types/uint.js +0 -60
- package/distrib/npm/types/vector-256.js +0 -31
- package/distrib/npm/utils/bytes-utils.js +0 -112
- package/distrib/npm/utils/make-class.js +0 -83
- package/test/amount-test.js +0 -43
- package/test/binary-json-test.js +0 -43
- package/test/binary-parser-test.js +0 -341
- package/test/binary-serializer-test.js +0 -194
- package/test/bytes-utils-test.js +0 -72
- 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 -3721
- 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/payment-channel-claim-binary.json +0 -1
- package/test/fixtures/payment-channel-claim-tx.json +0 -8
- package/test/fixtures/payment-channel-create-binary.json +0 -1
- package/test/fixtures/payment-channel-create-tx.json +0 -11
- package/test/fixtures/payment-channel-fund-binary.json +0 -1
- package/test/fixtures/payment-channel-fund-tx.json +0 -7
- package/test/fixtures/signerlistset-tx-binary.json +0 -1
- package/test/fixtures/signerlistset-tx-meta-binary.json +0 -1
- package/test/fixtures/signerlistset-tx.json +0 -94
- package/test/hash-test.js +0 -58
- package/test/ledger-test.js +0 -26
- package/test/mocha.opts +0 -1
- package/test/quality-test.js +0 -16
- package/test/shamap-test.js +0 -88
- package/test/signing-data-encoding-test.js +0 -120
- package/test/tx-encode-decode-test.js +0 -124
- package/test/types-test.js +0 -38
- package/test/uint-test.js +0 -38
- package/test/utils.js +0 -93
package/README.md
CHANGED
|
@@ -1,5 +1,107 @@
|
|
|
1
|
-
# ripple-binary-codec
|
|
1
|
+
# ripple-binary-codec [](https://npmjs.org/package/ripple-binary-codec)
|
|
2
2
|
|
|
3
|
-
encode/decode to/from the ripple binary serialization format
|
|
3
|
+
Functions to encode/decode to/from the ripple [binary serialization format](https://xrpl.org/serialization.html)
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.org/package/ripple-binary-codec)
|
|
6
|
+
|
|
7
|
+
## API
|
|
8
|
+
```js
|
|
9
|
+
> const api = require('ripple-binary-codec')
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### decode(binary: string): object
|
|
14
|
+
Decode a hex-string into a transaction object.
|
|
15
|
+
```js
|
|
16
|
+
> api.decode('1100612200000000240000000125000000072D0000000055DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF6240000002540BE4008114D0F5430B66E06498D4CEEC816C7B3337F9982337')
|
|
17
|
+
{
|
|
18
|
+
LedgerEntryType: 'AccountRoot',
|
|
19
|
+
Flags: 0,
|
|
20
|
+
Sequence: 1,
|
|
21
|
+
PreviousTxnLgrSeq: 7,
|
|
22
|
+
OwnerCount: 0,
|
|
23
|
+
PreviousTxnID: 'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
24
|
+
Balance: '10000000000',
|
|
25
|
+
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv'
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### encode(json: object): string
|
|
30
|
+
Encode a transaction object into a hex-string. Note that encode filters out fields with undefined values.
|
|
31
|
+
```js
|
|
32
|
+
> api.encode({
|
|
33
|
+
LedgerEntryType: 'AccountRoot',
|
|
34
|
+
Flags: 0,
|
|
35
|
+
Sequence: 1,
|
|
36
|
+
PreviousTxnLgrSeq: 7,
|
|
37
|
+
OwnerCount: 0,
|
|
38
|
+
PreviousTxnID: 'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF',
|
|
39
|
+
Balance: '10000000000',
|
|
40
|
+
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv'
|
|
41
|
+
})
|
|
42
|
+
'1100612200000000240000000125000000072D0000000055DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF6240000002540BE4008114D0F5430B66E06498D4CEEC816C7B3337F9982337'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### X-Address Compatibility
|
|
46
|
+
* ripple-binary-codec handles X-addresses by looking for a few specific files (Account/SourceTag, Destination/DestinationTag).
|
|
47
|
+
* If other fields (in the future) must to support X-addresses with tags, this library will need to be updated.
|
|
48
|
+
* When decoding rippled binary, the output will always output classic address + tag, with no X-addresses. X-address support only applies when encoding to binary.
|
|
49
|
+
|
|
50
|
+
#### Encoding Currency Codes
|
|
51
|
+
* The standard format for currency codes is a three-letter string such as `USD`. This is intended for use with ISO 4217 Currency Codes.
|
|
52
|
+
* Currency codes must be exactly 3 ASCII characters in length and there are [a few other rules](https://xrpl.org/currency-formats.html#currency-codes).
|
|
53
|
+
* ripple-binary-codec allows any 3-character ASCII string to be encoded as a currency code, although rippled may enforce tighter restrictions.
|
|
54
|
+
* When _decoding_, if a currency code is three uppercase letters or numbers (`/^[A-Z0-9]{3}$/`), then it will be decoded into that string. For example,`0000000000000000000000004142430000000000` decodes as `ABC`.
|
|
55
|
+
* When decoding, if a currency code is does not match the regex, then it is not considered to be an ISO 4217 or pseudo-ISO currency. ripple-binary-codec will return a 160-bit hex-string (40 hex characters). For example, `0000000000000000000000006142430000000000` (`aBC`) decodes as `0000000000000000000000006142430000000000` because it contains a lowercase letter.
|
|
56
|
+
|
|
57
|
+
### encodeForSigning(json: object): string
|
|
58
|
+
|
|
59
|
+
Encode the transaction object for signing.
|
|
60
|
+
|
|
61
|
+
### encodeForSigningClaim(json: object): string
|
|
62
|
+
|
|
63
|
+
Encode the transaction object for payment channel claim.
|
|
64
|
+
|
|
65
|
+
### encodeForMultisigning(json: object, signer: string): string
|
|
66
|
+
|
|
67
|
+
Encode the transaction object for multi-signing.
|
|
68
|
+
|
|
69
|
+
### encodeQuality(value: string): string
|
|
70
|
+
```js
|
|
71
|
+
> api.encodeQuality('195796912.5171664')
|
|
72
|
+
'5D06F4C3362FE1D0'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### decodeQuality(value: string): string
|
|
76
|
+
```js
|
|
77
|
+
> api.decodeQuality('5D06F4C3362FE1D0')
|
|
78
|
+
'195796912.5171664'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### decodeLedgerData(binary: string): object
|
|
82
|
+
```js
|
|
83
|
+
> api.decodeLedgerData("01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00")
|
|
84
|
+
{
|
|
85
|
+
ledger_index: 32052277,
|
|
86
|
+
total_coins: '99994494362043555',
|
|
87
|
+
parent_hash: 'EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6',
|
|
88
|
+
transaction_hash: 'DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87',
|
|
89
|
+
account_hash: '3B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D5',
|
|
90
|
+
parent_close_time: 556231902,
|
|
91
|
+
close_time: 556231910,
|
|
92
|
+
close_time_resolution: 10,
|
|
93
|
+
close_flags: 0
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Tests
|
|
98
|
+
|
|
99
|
+
Run unit tests with:
|
|
100
|
+
|
|
101
|
+
npm test
|
|
102
|
+
|
|
103
|
+
Use `--coverage` to generate and display code coverage information:
|
|
104
|
+
|
|
105
|
+
npm test --coverage
|
|
106
|
+
|
|
107
|
+
This tells jest to output code coverage info in the `./coverage` directory, in addition to showing it on the command line.
|
package/dist/binary.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { BinaryParser } from './serdes/binary-parser';
|
|
2
|
+
import { AccountID } from './types/account-id';
|
|
3
|
+
import { BinarySerializer, BytesList } from './serdes/binary-serializer';
|
|
4
|
+
import { sha512Half, transactionID } from './hashes';
|
|
5
|
+
import { type XrplDefinitionsBase } from './enums';
|
|
6
|
+
import { JsonObject } from './types/serialized-type';
|
|
7
|
+
/**
|
|
8
|
+
* Construct a BinaryParser
|
|
9
|
+
*
|
|
10
|
+
* @param bytes hex-string or Uint8Array to construct BinaryParser from
|
|
11
|
+
* @param definitions rippled definitions used to parse the values of transaction types and such.
|
|
12
|
+
* Can be customized for sidechains and amendments.
|
|
13
|
+
* @returns BinaryParser
|
|
14
|
+
*/
|
|
15
|
+
declare const makeParser: (bytes: string | Uint8Array, definitions?: XrplDefinitionsBase) => BinaryParser;
|
|
16
|
+
/**
|
|
17
|
+
* Parse BinaryParser into JSON
|
|
18
|
+
*
|
|
19
|
+
* @param parser BinaryParser object
|
|
20
|
+
* @param definitions rippled definitions used to parse the values of transaction types and such.
|
|
21
|
+
* Can be customized for sidechains and amendments.
|
|
22
|
+
* @returns JSON for the bytes in the BinaryParser
|
|
23
|
+
*/
|
|
24
|
+
declare const readJSON: (parser: BinaryParser, definitions?: XrplDefinitionsBase) => JsonObject;
|
|
25
|
+
/**
|
|
26
|
+
* Parse a hex-string into its JSON interpretation
|
|
27
|
+
*
|
|
28
|
+
* @param bytes hex-string to parse into JSON
|
|
29
|
+
* @param definitions rippled definitions used to parse the values of transaction types and such.
|
|
30
|
+
* Can be customized for sidechains and amendments.
|
|
31
|
+
* @returns JSON
|
|
32
|
+
*/
|
|
33
|
+
declare const binaryToJSON: (bytes: string, definitions?: XrplDefinitionsBase) => JsonObject;
|
|
34
|
+
/**
|
|
35
|
+
* Interface for passing parameters to SerializeObject
|
|
36
|
+
*
|
|
37
|
+
* @field set signingFieldOnly to true if you want to serialize only signing fields
|
|
38
|
+
*/
|
|
39
|
+
interface OptionObject {
|
|
40
|
+
prefix?: Uint8Array;
|
|
41
|
+
suffix?: Uint8Array;
|
|
42
|
+
signingFieldsOnly?: boolean;
|
|
43
|
+
definitions?: XrplDefinitionsBase;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Function to serialize JSON object representing a transaction
|
|
47
|
+
*
|
|
48
|
+
* @param object JSON object to serialize
|
|
49
|
+
* @param opts options for serializing, including optional prefix, suffix, signingFieldOnly, and definitions
|
|
50
|
+
* @returns A Uint8Array containing the serialized object
|
|
51
|
+
*/
|
|
52
|
+
declare function serializeObject(object: JsonObject, opts?: OptionObject): Uint8Array;
|
|
53
|
+
/**
|
|
54
|
+
* Serialize an object for signing
|
|
55
|
+
*
|
|
56
|
+
* @param transaction Transaction to serialize
|
|
57
|
+
* @param prefix Prefix bytes to put before the serialized object
|
|
58
|
+
* @param opts.definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
59
|
+
* @returns A Uint8Array with the serialized object
|
|
60
|
+
*/
|
|
61
|
+
declare function signingData(transaction: JsonObject, prefix?: Uint8Array, opts?: {
|
|
62
|
+
definitions?: XrplDefinitionsBase;
|
|
63
|
+
}): Uint8Array;
|
|
64
|
+
/**
|
|
65
|
+
* Interface describing fields required for a Claim
|
|
66
|
+
*/
|
|
67
|
+
interface ClaimObject extends JsonObject {
|
|
68
|
+
channel: string;
|
|
69
|
+
amount: string | number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Serialize a signingClaim
|
|
73
|
+
*
|
|
74
|
+
* @param claim A claim object to serialize
|
|
75
|
+
* @param opts.definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
76
|
+
* @returns the serialized object with appropriate prefix
|
|
77
|
+
*/
|
|
78
|
+
declare function signingClaimData(claim: ClaimObject): Uint8Array;
|
|
79
|
+
/**
|
|
80
|
+
* Serialize a transaction object for multiSigning
|
|
81
|
+
*
|
|
82
|
+
* @param transaction transaction to serialize
|
|
83
|
+
* @param signingAccount Account to sign the transaction with
|
|
84
|
+
* @param opts.definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
85
|
+
* @returns serialized transaction with appropriate prefix and suffix
|
|
86
|
+
*/
|
|
87
|
+
declare function multiSigningData(transaction: JsonObject, signingAccount: string | AccountID, opts?: {
|
|
88
|
+
definitions: XrplDefinitionsBase;
|
|
89
|
+
}): Uint8Array;
|
|
90
|
+
export { BinaryParser, BinarySerializer, BytesList, ClaimObject, makeParser, serializeObject, readJSON, multiSigningData, signingData, signingClaimData, binaryToJSON, sha512Half, transactionID, };
|
package/dist/binary.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable func-style */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.transactionID = exports.sha512Half = exports.binaryToJSON = exports.signingClaimData = exports.signingData = exports.multiSigningData = exports.readJSON = exports.serializeObject = exports.makeParser = exports.BytesList = exports.BinarySerializer = exports.BinaryParser = void 0;
|
|
5
|
+
const utils_1 = require("@xrplf/isomorphic/utils");
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
const binary_parser_1 = require("./serdes/binary-parser");
|
|
8
|
+
Object.defineProperty(exports, "BinaryParser", { enumerable: true, get: function () { return binary_parser_1.BinaryParser; } });
|
|
9
|
+
const hash_prefixes_1 = require("./hash-prefixes");
|
|
10
|
+
const binary_serializer_1 = require("./serdes/binary-serializer");
|
|
11
|
+
Object.defineProperty(exports, "BinarySerializer", { enumerable: true, get: function () { return binary_serializer_1.BinarySerializer; } });
|
|
12
|
+
Object.defineProperty(exports, "BytesList", { enumerable: true, get: function () { return binary_serializer_1.BytesList; } });
|
|
13
|
+
const hashes_1 = require("./hashes");
|
|
14
|
+
Object.defineProperty(exports, "sha512Half", { enumerable: true, get: function () { return hashes_1.sha512Half; } });
|
|
15
|
+
Object.defineProperty(exports, "transactionID", { enumerable: true, get: function () { return hashes_1.transactionID; } });
|
|
16
|
+
const enums_1 = require("./enums");
|
|
17
|
+
/**
|
|
18
|
+
* Construct a BinaryParser
|
|
19
|
+
*
|
|
20
|
+
* @param bytes hex-string or Uint8Array to construct BinaryParser from
|
|
21
|
+
* @param definitions rippled definitions used to parse the values of transaction types and such.
|
|
22
|
+
* Can be customized for sidechains and amendments.
|
|
23
|
+
* @returns BinaryParser
|
|
24
|
+
*/
|
|
25
|
+
const makeParser = (bytes, definitions) => new binary_parser_1.BinaryParser(bytes instanceof Uint8Array ? (0, utils_1.bytesToHex)(bytes) : bytes, definitions);
|
|
26
|
+
exports.makeParser = makeParser;
|
|
27
|
+
/**
|
|
28
|
+
* Parse BinaryParser into JSON
|
|
29
|
+
*
|
|
30
|
+
* @param parser BinaryParser object
|
|
31
|
+
* @param definitions rippled definitions used to parse the values of transaction types and such.
|
|
32
|
+
* Can be customized for sidechains and amendments.
|
|
33
|
+
* @returns JSON for the bytes in the BinaryParser
|
|
34
|
+
*/
|
|
35
|
+
const readJSON = (parser, definitions = enums_1.DEFAULT_DEFINITIONS) => parser.readType(types_1.coreTypes.STObject).toJSON(definitions);
|
|
36
|
+
exports.readJSON = readJSON;
|
|
37
|
+
/**
|
|
38
|
+
* Parse a hex-string into its JSON interpretation
|
|
39
|
+
*
|
|
40
|
+
* @param bytes hex-string to parse into JSON
|
|
41
|
+
* @param definitions rippled definitions used to parse the values of transaction types and such.
|
|
42
|
+
* Can be customized for sidechains and amendments.
|
|
43
|
+
* @returns JSON
|
|
44
|
+
*/
|
|
45
|
+
const binaryToJSON = (bytes, definitions) => readJSON(makeParser(bytes, definitions), definitions);
|
|
46
|
+
exports.binaryToJSON = binaryToJSON;
|
|
47
|
+
/**
|
|
48
|
+
* Function to serialize JSON object representing a transaction
|
|
49
|
+
*
|
|
50
|
+
* @param object JSON object to serialize
|
|
51
|
+
* @param opts options for serializing, including optional prefix, suffix, signingFieldOnly, and definitions
|
|
52
|
+
* @returns A Uint8Array containing the serialized object
|
|
53
|
+
*/
|
|
54
|
+
function serializeObject(object, opts = {}) {
|
|
55
|
+
const { prefix, suffix, signingFieldsOnly = false, definitions } = opts;
|
|
56
|
+
const bytesList = new binary_serializer_1.BytesList();
|
|
57
|
+
if (prefix) {
|
|
58
|
+
bytesList.put(prefix);
|
|
59
|
+
}
|
|
60
|
+
const filter = signingFieldsOnly
|
|
61
|
+
? (f) => f.isSigningField
|
|
62
|
+
: undefined;
|
|
63
|
+
types_1.coreTypes.STObject
|
|
64
|
+
.from(object, filter, definitions)
|
|
65
|
+
.toBytesSink(bytesList);
|
|
66
|
+
if (suffix) {
|
|
67
|
+
bytesList.put(suffix);
|
|
68
|
+
}
|
|
69
|
+
return bytesList.toBytes();
|
|
70
|
+
}
|
|
71
|
+
exports.serializeObject = serializeObject;
|
|
72
|
+
/**
|
|
73
|
+
* Serialize an object for signing
|
|
74
|
+
*
|
|
75
|
+
* @param transaction Transaction to serialize
|
|
76
|
+
* @param prefix Prefix bytes to put before the serialized object
|
|
77
|
+
* @param opts.definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
78
|
+
* @returns A Uint8Array with the serialized object
|
|
79
|
+
*/
|
|
80
|
+
function signingData(transaction, prefix = hash_prefixes_1.HashPrefix.transactionSig, opts = {}) {
|
|
81
|
+
return serializeObject(transaction, {
|
|
82
|
+
prefix,
|
|
83
|
+
signingFieldsOnly: true,
|
|
84
|
+
definitions: opts.definitions,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
exports.signingData = signingData;
|
|
88
|
+
/**
|
|
89
|
+
* Serialize a signingClaim
|
|
90
|
+
*
|
|
91
|
+
* @param claim A claim object to serialize
|
|
92
|
+
* @param opts.definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
93
|
+
* @returns the serialized object with appropriate prefix
|
|
94
|
+
*/
|
|
95
|
+
function signingClaimData(claim) {
|
|
96
|
+
const num = BigInt(String(claim.amount));
|
|
97
|
+
const prefix = hash_prefixes_1.HashPrefix.paymentChannelClaim;
|
|
98
|
+
const channel = types_1.coreTypes.Hash256.from(claim.channel).toBytes();
|
|
99
|
+
const amount = types_1.coreTypes.UInt64.from(num).toBytes();
|
|
100
|
+
const bytesList = new binary_serializer_1.BytesList();
|
|
101
|
+
bytesList.put(prefix);
|
|
102
|
+
bytesList.put(channel);
|
|
103
|
+
bytesList.put(amount);
|
|
104
|
+
return bytesList.toBytes();
|
|
105
|
+
}
|
|
106
|
+
exports.signingClaimData = signingClaimData;
|
|
107
|
+
/**
|
|
108
|
+
* Serialize a transaction object for multiSigning
|
|
109
|
+
*
|
|
110
|
+
* @param transaction transaction to serialize
|
|
111
|
+
* @param signingAccount Account to sign the transaction with
|
|
112
|
+
* @param opts.definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
|
|
113
|
+
* @returns serialized transaction with appropriate prefix and suffix
|
|
114
|
+
*/
|
|
115
|
+
function multiSigningData(transaction, signingAccount, opts = {
|
|
116
|
+
definitions: enums_1.DEFAULT_DEFINITIONS,
|
|
117
|
+
}) {
|
|
118
|
+
const prefix = hash_prefixes_1.HashPrefix.transactionMultiSig;
|
|
119
|
+
const suffix = types_1.coreTypes.AccountID.from(signingAccount).toBytes();
|
|
120
|
+
return serializeObject(transaction, {
|
|
121
|
+
prefix,
|
|
122
|
+
suffix,
|
|
123
|
+
signingFieldsOnly: true,
|
|
124
|
+
definitions: opts.definitions,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
exports.multiSigningData = multiSigningData;
|
|
128
|
+
//# sourceMappingURL=binary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../src/binary.ts"],"names":[],"mappings":";AAAA,+BAA+B;;;AAE/B,mDAAoD;AACpD,mCAAmC;AACnC,0DAAqD;AAgLnD,6FAhLO,4BAA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B,CACvB,WAAuB,EACvB,cAAkC,EAClC,OAA6C;IAC3C,WAAW,EAAE,2BAAmB;CACjC;IAED,MAAM,MAAM,GAAG,0BAAU,CAAC,mBAAmB,CAAA;IAC7C,MAAM,MAAM,GAAG,iBAAS,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,CAAA;IACjE,OAAO,eAAe,CAAC,WAAW,EAAE;QAClC,MAAM;QACN,MAAM;QACN,iBAAiB,EAAE,IAAI;QACvB,WAAW,EAAE,IAAI,CAAC,WAAW;KAC9B,CAAC,CAAA;AACJ,CAAC;AAUC,4CAAgB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DEFAULT_DEFINITIONS, Field, TransactionType, LedgerEntryType, Type, TransactionResult } from './enums';
|
|
2
|
+
import * as types from './types';
|
|
3
|
+
import * as binary from './binary';
|
|
4
|
+
import { ShaMap } from './shamap';
|
|
5
|
+
import * as ledgerHashes from './ledger-hashes';
|
|
6
|
+
import * as hashes from './hashes';
|
|
7
|
+
import { quality } from './quality';
|
|
8
|
+
import { HashPrefix } from './hash-prefixes';
|
|
9
|
+
export { hashes, binary, ledgerHashes, DEFAULT_DEFINITIONS, Field, TransactionType, LedgerEntryType, Type, TransactionResult, quality, HashPrefix, ShaMap, types, };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.types = exports.ShaMap = exports.HashPrefix = exports.quality = exports.TransactionResult = exports.Type = exports.LedgerEntryType = exports.TransactionType = exports.Field = exports.DEFAULT_DEFINITIONS = exports.ledgerHashes = exports.binary = exports.hashes = void 0;
|
|
27
|
+
const enums_1 = require("./enums");
|
|
28
|
+
Object.defineProperty(exports, "DEFAULT_DEFINITIONS", { enumerable: true, get: function () { return enums_1.DEFAULT_DEFINITIONS; } });
|
|
29
|
+
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return enums_1.Field; } });
|
|
30
|
+
Object.defineProperty(exports, "TransactionType", { enumerable: true, get: function () { return enums_1.TransactionType; } });
|
|
31
|
+
Object.defineProperty(exports, "LedgerEntryType", { enumerable: true, get: function () { return enums_1.LedgerEntryType; } });
|
|
32
|
+
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return enums_1.Type; } });
|
|
33
|
+
Object.defineProperty(exports, "TransactionResult", { enumerable: true, get: function () { return enums_1.TransactionResult; } });
|
|
34
|
+
const types = __importStar(require("./types"));
|
|
35
|
+
exports.types = types;
|
|
36
|
+
const binary = __importStar(require("./binary"));
|
|
37
|
+
exports.binary = binary;
|
|
38
|
+
const shamap_1 = require("./shamap");
|
|
39
|
+
Object.defineProperty(exports, "ShaMap", { enumerable: true, get: function () { return shamap_1.ShaMap; } });
|
|
40
|
+
const ledgerHashes = __importStar(require("./ledger-hashes"));
|
|
41
|
+
exports.ledgerHashes = ledgerHashes;
|
|
42
|
+
const hashes = __importStar(require("./hashes"));
|
|
43
|
+
exports.hashes = hashes;
|
|
44
|
+
const quality_1 = require("./quality");
|
|
45
|
+
Object.defineProperty(exports, "quality", { enumerable: true, get: function () { return quality_1.quality; } });
|
|
46
|
+
const hash_prefixes_1 = require("./hash-prefixes");
|
|
47
|
+
Object.defineProperty(exports, "HashPrefix", { enumerable: true, get: function () { return hash_prefixes_1.HashPrefix; } });
|
|
48
|
+
//# sourceMappingURL=coretypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coretypes.js","sourceRoot":"","sources":["../src/coretypes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAOgB;AAad,oGAnBA,2BAAmB,OAmBA;AACnB,sFAnBA,aAAK,OAmBA;AACL,gGAnBA,uBAAe,OAmBA;AACf,gGAnBA,uBAAe,OAmBA;AACf,qFAnBA,YAAI,OAmBA;AACJ,kGAnBA,yBAAiB,OAmBA;AAjBnB,+CAAgC;AAqB9B,sBAAK;AApBP,iDAAkC;AAShC,wBAAM;AARR,qCAAiC;AAkB/B,uFAlBO,eAAM,OAkBP;AAjBR,8DAA+C;AAQ7C,oCAAY;AAPd,iDAAkC;AAKhC,wBAAM;AAJR,uCAAmC;AAajC,wFAbO,iBAAO,OAaP;AAZT,mDAA4C;AAa1C,2FAbO,0BAAU,OAaP"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BytesList, BinaryParser } from '../binary';
|
|
2
|
+
export declare class Bytes {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly ordinal: number;
|
|
5
|
+
readonly ordinalWidth: number;
|
|
6
|
+
readonly bytes: Uint8Array;
|
|
7
|
+
constructor(name: string, ordinal: number, ordinalWidth: number);
|
|
8
|
+
toJSON(): string;
|
|
9
|
+
toBytesSink(sink: BytesList): void;
|
|
10
|
+
toBytes(): Uint8Array;
|
|
11
|
+
}
|
|
12
|
+
export declare class BytesLookup {
|
|
13
|
+
readonly ordinalWidth: number;
|
|
14
|
+
constructor(types: Record<string, number>, ordinalWidth: number);
|
|
15
|
+
/**
|
|
16
|
+
* Add a new name value pair to the BytesLookup.
|
|
17
|
+
*
|
|
18
|
+
* @param name - A human readable name for the field.
|
|
19
|
+
* @param value - The numeric value for the field.
|
|
20
|
+
* @throws if the name or value already exist in the lookup because it's unclear how to decode.
|
|
21
|
+
*/
|
|
22
|
+
add(name: string, value: number): void;
|
|
23
|
+
from(value: Bytes | string): Bytes;
|
|
24
|
+
fromParser(parser: BinaryParser): Bytes;
|
|
25
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BytesLookup = exports.Bytes = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* @brief: Bytes, name, and ordinal representing one type, ledger_type, transaction type, or result
|
|
6
|
+
*/
|
|
7
|
+
class Bytes {
|
|
8
|
+
constructor(name, ordinal, ordinalWidth) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.ordinal = ordinal;
|
|
11
|
+
this.ordinalWidth = ordinalWidth;
|
|
12
|
+
this.bytes = new Uint8Array(ordinalWidth);
|
|
13
|
+
for (let i = 0; i < ordinalWidth; i++) {
|
|
14
|
+
this.bytes[ordinalWidth - i - 1] = (ordinal >>> (i * 8)) & 0xff;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
toJSON() {
|
|
18
|
+
return this.name;
|
|
19
|
+
}
|
|
20
|
+
toBytesSink(sink) {
|
|
21
|
+
sink.put(this.bytes);
|
|
22
|
+
}
|
|
23
|
+
toBytes() {
|
|
24
|
+
return this.bytes;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.Bytes = Bytes;
|
|
28
|
+
/*
|
|
29
|
+
* @brief: Collection of Bytes objects, mapping bidirectionally
|
|
30
|
+
*/
|
|
31
|
+
class BytesLookup {
|
|
32
|
+
constructor(types, ordinalWidth) {
|
|
33
|
+
this.ordinalWidth = ordinalWidth;
|
|
34
|
+
Object.entries(types).forEach(([k, v]) => {
|
|
35
|
+
this.add(k, v);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Add a new name value pair to the BytesLookup.
|
|
40
|
+
*
|
|
41
|
+
* @param name - A human readable name for the field.
|
|
42
|
+
* @param value - The numeric value for the field.
|
|
43
|
+
* @throws if the name or value already exist in the lookup because it's unclear how to decode.
|
|
44
|
+
*/
|
|
45
|
+
add(name, value) {
|
|
46
|
+
if (this[name]) {
|
|
47
|
+
throw new SyntaxError(`Attempted to add a value with a duplicate name "${name}". This is not allowed because it is unclear how to decode.`);
|
|
48
|
+
}
|
|
49
|
+
if (this[value.toString()]) {
|
|
50
|
+
throw new SyntaxError(`Attempted to add a duplicate value under a different name (Given name: "${name}" and previous name: "${this[value.toString()]}. This is not allowed because it is unclear how to decode.\nGiven value: ${value.toString()}`);
|
|
51
|
+
}
|
|
52
|
+
this[name] = new Bytes(name, value, this.ordinalWidth);
|
|
53
|
+
this[value.toString()] = this[name];
|
|
54
|
+
}
|
|
55
|
+
from(value) {
|
|
56
|
+
return value instanceof Bytes ? value : this[value];
|
|
57
|
+
}
|
|
58
|
+
fromParser(parser) {
|
|
59
|
+
return this.from(parser.readUIntN(this.ordinalWidth).toString());
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.BytesLookup = BytesLookup;
|
|
63
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/enums/bytes.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,KAAK;IAGhB,YACW,IAAY,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AI,yBAC7E,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CACvB,4EAA4E,KAAK,CAAC,QAAQ,EAAE,EAAE,CAC/F,CAAA;SACF;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QACtD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED,IAAI,CAAC,KAAqB;QACxB,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAW,CAAA;IAChE,CAAC;IAED,UAAU,CAAC,MAAoB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;IAClE,CAAC;CACF;AAtCD,kCAsCC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRANSACTION_RESULT_WIDTH = exports.TRANSACTION_TYPE_WIDTH = exports.LEDGER_ENTRY_WIDTH = exports.TYPE_WIDTH = void 0;
|
|
4
|
+
exports.TYPE_WIDTH = 2;
|
|
5
|
+
exports.LEDGER_ENTRY_WIDTH = 2;
|
|
6
|
+
exports.TRANSACTION_TYPE_WIDTH = 2;
|
|
7
|
+
exports.TRANSACTION_RESULT_WIDTH = 1;
|
|
8
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/enums/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,CAAC,CAAA;AACd,QAAA,kBAAkB,GAAG,CAAC,CAAA;AACtB,QAAA,sBAAsB,GAAG,CAAC,CAAA;AAC1B,QAAA,wBAAwB,GAAG,CAAC,CAAA"}
|