@aeternity/aepp-sdk 13.0.0-alpha.0 → 13.0.0-alpha.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/bin/aesophia_cli +0 -0
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +4206 -1127
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdkBase.d.ts +3 -3
- package/es/AeSdkBase.mjs +4 -0
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +3 -4
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/Node.d.ts +4 -3
- package/es/Node.mjs +1 -1
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +2 -2
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.mjs +5 -3
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.mjs +2 -1
- package/es/account/Ledger.mjs.map +1 -1
- package/es/account/Memory.mjs +2 -1
- package/es/account/Memory.mjs.map +1 -1
- package/es/aens.d.ts +1 -1
- package/es/aens.mjs +5 -1
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -4
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/chain.d.ts +9 -1
- package/es/chain.mjs +4 -1
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +6 -1
- package/es/channel/Base.mjs +9 -6
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.d.ts +8 -7
- package/es/channel/Contract.mjs +1 -1
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +3 -1
- package/es/channel/Spend.mjs +4 -2
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +11 -9
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.mjs +3 -1
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +21 -46
- package/es/contract/Contract.mjs +69 -52
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +81 -0
- package/es/contract/compiler/Base.mjs +5 -0
- package/es/contract/compiler/Base.mjs.map +1 -0
- package/es/contract/compiler/Cli.d.ts +23 -0
- package/es/contract/compiler/Cli.mjs +155 -0
- package/es/contract/compiler/Cli.mjs.map +1 -0
- package/es/contract/compiler/Http.d.ts +32 -0
- package/es/contract/{CompilerHttp.mjs → compiler/Http.mjs} +64 -9
- package/es/contract/compiler/Http.mjs.map +1 -0
- package/es/contract/compiler/HttpNode.d.ts +17 -0
- package/es/contract/compiler/HttpNode.mjs +26 -0
- package/es/contract/compiler/HttpNode.mjs.map +1 -0
- package/es/contract/compiler/getFileSystem.d.ts +6 -0
- package/es/contract/compiler/getFileSystem.mjs +40 -0
- package/es/contract/compiler/getFileSystem.mjs.map +1 -0
- package/es/contract/ga.d.ts +5 -4
- package/es/contract/ga.mjs +11 -2
- package/es/contract/ga.mjs.map +1 -1
- package/es/index-browser.d.ts +39 -0
- package/es/index-browser.mjs +55 -0
- package/es/index-browser.mjs.map +1 -0
- package/es/index.d.ts +4 -38
- package/es/index.mjs +4 -53
- package/es/index.mjs.map +1 -1
- package/es/oracle.mjs +1 -1
- package/es/oracle.mjs.map +1 -1
- package/es/spend.mjs +1 -3
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/constants.d.ts +28 -1
- package/es/tx/builder/constants.mjs +32 -3
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.d.ts +10 -0
- package/es/tx/builder/field-types/abi-version.mjs +20 -0
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
- package/es/tx/builder/field-types/address.d.ts +5 -6
- package/es/tx/builder/field-types/address.mjs +17 -8
- package/es/tx/builder/field-types/address.mjs.map +1 -1
- package/es/tx/builder/field-types/array.d.ts +7 -0
- package/es/tx/builder/field-types/array.mjs +11 -0
- package/es/tx/builder/field-types/array.mjs.map +1 -0
- package/es/tx/builder/field-types/boolean.d.ts +6 -0
- package/es/tx/builder/field-types/boolean.mjs +13 -0
- package/es/tx/builder/field-types/boolean.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +1 -1
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.d.ts +30 -0
- package/es/tx/builder/field-types/ct-version.mjs +48 -0
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +1 -1
- package/es/tx/builder/field-types/deposit.mjs.map +1 -1
- package/es/tx/builder/field-types/encoded.d.ts +6 -0
- package/es/tx/builder/field-types/encoded.mjs +21 -0
- package/es/tx/builder/field-types/encoded.mjs.map +1 -0
- package/es/tx/builder/field-types/entry.d.ts +11 -0
- package/es/tx/builder/field-types/entry.mjs +31 -0
- package/es/tx/builder/field-types/entry.mjs.map +1 -0
- package/es/tx/builder/field-types/enumeration.d.ts +5 -3
- package/es/tx/builder/field-types/enumeration.mjs +11 -2
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +10 -7
- package/es/tx/builder/field-types/fee.mjs +24 -20
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.d.ts +5 -2
- package/es/tx/builder/field-types/gas-limit.mjs +9 -6
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +1 -1
- package/es/tx/builder/field-types/index.d.ts +66 -28
- package/es/tx/builder/field-types/index.mjs +30 -12
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/mptree.d.ts +37 -0
- package/es/tx/builder/field-types/mptree.mjs +268 -0
- package/es/tx/builder/field-types/mptree.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +1 -2
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/name-id.mjs +2 -1
- package/es/tx/builder/field-types/name-id.mjs.map +1 -1
- package/es/tx/builder/field-types/pointers.mjs +2 -2
- package/es/tx/builder/field-types/pointers.mjs.map +1 -1
- package/es/tx/builder/field-types/raw.d.ts +6 -0
- package/es/tx/builder/field-types/raw.mjs +13 -0
- package/es/tx/builder/field-types/raw.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int-const.d.ts +5 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs +16 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
- package/es/tx/builder/field-types/string.d.ts +6 -0
- package/es/tx/builder/field-types/string.mjs +10 -0
- package/es/tx/builder/field-types/string.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.d.ts +1 -2
- package/es/tx/builder/field-types/u-int.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +11 -29
- package/es/tx/builder/index.mjs +50 -211
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2111 -571
- package/es/tx/builder/schema.mjs +57 -125
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +5 -20
- package/es/tx/index.mjs +31 -88
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +3 -5
- package/es/tx/validator.mjs +82 -95
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/bytes.mjs +1 -1
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/errors.d.ts +3 -8
- package/es/utils/errors.mjs +1 -11
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/other.d.ts +1 -1
- package/package.json +35 -27
- package/src/AeSdkBase.ts +6 -3
- package/src/AeSdkMethods.ts +3 -4
- package/src/Node.ts +6 -3
- package/src/account/Base.ts +2 -2
- package/src/account/Generalized.ts +2 -2
- package/src/account/Ledger.ts +1 -1
- package/src/account/Memory.ts +1 -1
- package/src/aens.ts +3 -2
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -7
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
- package/src/chain.ts +5 -3
- package/src/channel/Base.ts +13 -5
- package/src/channel/Contract.ts +11 -10
- package/src/channel/Spend.ts +7 -2
- package/src/channel/handlers.ts +10 -9
- package/src/channel/internal.ts +1 -1
- package/src/contract/Contract.ts +69 -79
- package/src/contract/compiler/Base.ts +94 -0
- package/src/contract/compiler/Cli.ts +134 -0
- package/src/contract/compiler/Http.ts +124 -0
- package/src/contract/compiler/HttpNode.ts +26 -0
- package/src/contract/compiler/getFileSystem.ts +42 -0
- package/src/contract/ga.ts +9 -6
- package/src/index-browser.ts +58 -0
- package/src/index.ts +4 -56
- package/src/oracle.ts +1 -1
- package/src/spend.ts +1 -1
- package/src/tx/builder/constants.ts +32 -3
- package/src/tx/builder/field-types/abi-version.ts +21 -0
- package/src/tx/builder/field-types/address.ts +23 -13
- package/src/tx/builder/field-types/array.ts +19 -0
- package/src/tx/builder/field-types/boolean.ts +9 -0
- package/src/tx/builder/field-types/coin-amount.ts +2 -1
- package/src/tx/builder/field-types/ct-version.ts +50 -0
- package/src/tx/builder/field-types/deposit.ts +1 -1
- package/src/tx/builder/field-types/encoded.ts +27 -0
- package/src/tx/builder/field-types/entry.ts +31 -0
- package/src/tx/builder/field-types/enumeration.ts +15 -4
- package/src/tx/builder/field-types/fee.ts +38 -18
- package/src/tx/builder/field-types/gas-limit.ts +12 -7
- package/src/tx/builder/field-types/index.ts +46 -17
- package/src/tx/builder/field-types/mptree.ts +242 -0
- package/src/tx/builder/field-types/name-fee.ts +1 -2
- package/src/tx/builder/field-types/name-id.ts +1 -1
- package/src/tx/builder/field-types/pointers.ts +2 -2
- package/src/tx/builder/field-types/raw.ts +9 -0
- package/src/tx/builder/field-types/short-u-int-const.ts +20 -0
- package/src/tx/builder/field-types/string.ts +11 -0
- package/src/tx/builder/field-types/u-int.ts +1 -3
- package/src/tx/builder/index.ts +63 -247
- package/src/tx/builder/schema.ts +273 -323
- package/src/tx/index.ts +37 -104
- package/src/tx/validator.ts +72 -95
- package/src/utils/bytes.ts +1 -1
- package/src/utils/errors.ts +4 -13
- package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +3 -4
- package/types-legacy/ts4.2/Node.d.ts +3 -3
- package/types-legacy/ts4.2/account/Base.d.ts +2 -2
- package/types-legacy/ts4.2/aens.d.ts +1 -1
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/types-legacy/ts4.2/chain.d.ts +9 -1
- package/types-legacy/ts4.2/channel/Base.d.ts +6 -1
- package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.2/channel/Spend.d.ts +3 -1
- package/types-legacy/ts4.2/contract/Contract.d.ts +21 -46
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +81 -0
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +5 -4
- package/types-legacy/ts4.2/index-browser.d.ts +39 -0
- package/types-legacy/ts4.2/index.d.ts +4 -38
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +28 -1
- package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +10 -0
- package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +11 -12
- package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +42 -0
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -3
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +10 -7
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +5 -2
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +72 -28
- package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +43 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -2
- package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +5 -0
- package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.2/tx/builder/index.d.ts +11 -29
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2380 -668
- package/types-legacy/ts4.2/tx/index.d.ts +5 -20
- package/types-legacy/ts4.2/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.2/utils/errors.d.ts +3 -8
- package/types-legacy/ts4.2/utils/other.d.ts +1 -1
- package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +3 -4
- package/types-legacy/ts4.5/Node.d.ts +3 -3
- package/types-legacy/ts4.5/account/Base.d.ts +2 -2
- package/types-legacy/ts4.5/aens.d.ts +1 -1
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/types-legacy/ts4.5/chain.d.ts +9 -1
- package/types-legacy/ts4.5/channel/Base.d.ts +6 -1
- package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.5/channel/Spend.d.ts +3 -1
- package/types-legacy/ts4.5/contract/Contract.d.ts +21 -46
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +81 -0
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +5 -4
- package/types-legacy/ts4.5/index-browser.d.ts +39 -0
- package/types-legacy/ts4.5/index.d.ts +4 -38
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +28 -1
- package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +10 -0
- package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +11 -12
- package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +42 -0
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -3
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +10 -7
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +5 -2
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +72 -28
- package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +43 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -2
- package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +5 -0
- package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.5/tx/builder/index.d.ts +11 -29
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2380 -668
- package/types-legacy/ts4.5/tx/index.d.ts +5 -20
- package/types-legacy/ts4.5/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.5/utils/errors.d.ts +3 -8
- package/types-legacy/ts4.5/utils/other.d.ts +1 -1
- package/es/contract/CompilerHttp.d.ts +0 -18
- package/es/contract/CompilerHttp.mjs.map +0 -1
- package/es/tx/builder/field-types/addresses.d.ts +0 -6
- package/es/tx/builder/field-types/addresses.mjs +0 -13
- package/es/tx/builder/field-types/addresses.mjs.map +0 -1
- package/es/utils/mptree.d.ts +0 -26
- package/es/utils/mptree.mjs +0 -143
- package/es/utils/mptree.mjs.map +0 -1
- package/src/contract/CompilerHttp.ts +0 -67
- package/src/tx/builder/field-types/addresses.ts +0 -18
- package/src/utils/mptree.ts +0 -145
- package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +0 -18
- package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +0 -6
- package/types-legacy/ts4.2/utils/mptree.d.ts +0 -32
- package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +0 -18
- package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +0 -6
- package/types-legacy/ts4.5/utils/mptree.d.ts +0 -32
|
@@ -1,32 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _uInt from "./u-int.mjs";
|
|
3
|
-
import _shortUInt from "./short-u-int.mjs";
|
|
4
|
-
import _coinAmount from "./coin-amount.mjs";
|
|
1
|
+
import _abiVersion from "./abi-version.mjs";
|
|
5
2
|
import _address from "./address.mjs";
|
|
6
|
-
import
|
|
3
|
+
import _array from "./array.mjs";
|
|
4
|
+
import _boolean from "./boolean.mjs";
|
|
5
|
+
import _coinAmount from "./coin-amount.mjs";
|
|
6
|
+
import _ctVersion from "./ct-version.mjs";
|
|
7
7
|
import _deposit from "./deposit.mjs";
|
|
8
|
+
import _encoded from "./encoded.mjs";
|
|
9
|
+
import _entry from "./entry.mjs";
|
|
8
10
|
import _enumeration from "./enumeration.mjs";
|
|
9
11
|
import _fee from "./fee.mjs";
|
|
12
|
+
import _field from "./field.mjs";
|
|
10
13
|
import _gasLimit from "./gas-limit.mjs";
|
|
11
14
|
import _gasPrice from "./gas-price.mjs";
|
|
15
|
+
import _mptree from "./mptree.mjs";
|
|
12
16
|
import _name from "./name.mjs";
|
|
13
17
|
import _nameFee from "./name-fee.mjs";
|
|
14
18
|
import _nameId from "./name-id.mjs";
|
|
15
|
-
import _pointers from "./pointers.mjs";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
import _pointers from "./pointers.mjs";
|
|
20
|
+
import _raw from "./raw.mjs";
|
|
21
|
+
import _shortUInt from "./short-u-int.mjs";
|
|
22
|
+
import _shortUIntConst from "./short-u-int-const.mjs";
|
|
23
|
+
import _string from "./string.mjs";
|
|
24
|
+
import _uInt from "./u-int.mjs"; // TODO: remove after fixing https://github.com/Gerrit0/typedoc-plugin-missing-exports/issues/15
|
|
25
|
+
const abiVersion = _abiVersion;
|
|
20
26
|
const address = _address;
|
|
21
|
-
const
|
|
27
|
+
const array = _array;
|
|
28
|
+
const boolean = _boolean;
|
|
29
|
+
const coinAmount = _coinAmount;
|
|
30
|
+
const ctVersion = _ctVersion;
|
|
22
31
|
const deposit = _deposit;
|
|
32
|
+
const encoded = _encoded;
|
|
33
|
+
const entry = _entry;
|
|
23
34
|
const enumeration = _enumeration;
|
|
24
35
|
const fee = _fee;
|
|
36
|
+
const field = _field;
|
|
25
37
|
const gasLimit = _gasLimit;
|
|
26
38
|
const gasPrice = _gasPrice;
|
|
39
|
+
const mptree = _mptree;
|
|
27
40
|
const name = _name;
|
|
28
41
|
const nameFee = _nameFee;
|
|
29
42
|
const nameId = _nameId;
|
|
30
43
|
const pointers = _pointers;
|
|
31
|
-
|
|
44
|
+
const raw = _raw;
|
|
45
|
+
const shortUInt = _shortUInt;
|
|
46
|
+
const shortUIntConst = _shortUIntConst;
|
|
47
|
+
const string = _string;
|
|
48
|
+
const uInt = _uInt;
|
|
49
|
+
export { abiVersion, address, array, boolean, coinAmount, ctVersion, deposit, encoded, entry, enumeration, fee, field, gasLimit, gasPrice, mptree, name, nameFee, nameId, pointers, raw, shortUInt, shortUIntConst, string, uInt };
|
|
32
50
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["_abiVersion","_address","_array","_boolean","_coinAmount","_ctVersion","_deposit","_encoded","_entry","_enumeration","_fee","_field","_gasLimit","_gasPrice","_mptree","_name","_nameFee","_nameId","_pointers","_raw","_shortUInt","_shortUIntConst","_string","_uInt","abiVersion","address","array","boolean","coinAmount","ctVersion","deposit","encoded","entry","enumeration","fee","field","gasLimit","gasPrice","mptree","name","nameFee","nameId","pointers","raw","shortUInt","shortUIntConst","string","uInt"],"sources":["../../../../src/tx/builder/field-types/index.ts"],"sourcesContent":["import _abiVersion from './abi-version';\nimport _address from './address';\nimport _array from './array';\nimport _boolean from './boolean';\nimport _coinAmount from './coin-amount';\nimport _ctVersion from './ct-version';\nimport _deposit from './deposit';\nimport _encoded from './encoded';\nimport _entry from './entry';\nimport _enumeration from './enumeration';\nimport _fee from './fee';\nimport _field from './field';\nimport _gasLimit from './gas-limit';\nimport _gasPrice from './gas-price';\nimport _mptree from './mptree';\nimport _name from './name';\nimport _nameFee from './name-fee';\nimport _nameId from './name-id';\nimport _pointers from './pointers';\nimport _raw from './raw';\nimport _shortUInt from './short-u-int';\nimport _shortUIntConst from './short-u-int-const';\nimport _string from './string';\nimport _uInt from './u-int';\n\n// TODO: remove after fixing https://github.com/Gerrit0/typedoc-plugin-missing-exports/issues/15\nconst abiVersion = _abiVersion;\nconst address = _address;\nconst array = _array;\nconst boolean = _boolean;\nconst coinAmount = _coinAmount;\nconst ctVersion = _ctVersion;\nconst deposit = _deposit;\nconst encoded = _encoded;\nconst entry = _entry;\nconst enumeration = _enumeration;\nconst fee = _fee;\nconst field = _field;\nconst gasLimit = _gasLimit;\nconst gasPrice = _gasPrice;\nconst mptree = _mptree;\nconst name = _name;\nconst nameFee = _nameFee;\nconst nameId = _nameId;\nconst pointers = _pointers;\nconst raw = _raw;\nconst shortUInt = _shortUInt;\nconst shortUIntConst = _shortUIntConst;\nconst string = _string;\nconst uInt = _uInt;\n\nexport type BinaryData = Buffer | Buffer[] | Buffer[][]\n| Array<[Buffer, Array<[Buffer, Buffer[]]>]>;\nexport interface Field {\n serialize: (value: any, options: any) => BinaryData;\n deserialize: (value: BinaryData, options: any) => any;\n}\n\nexport {\n abiVersion,\n address,\n array,\n boolean,\n coinAmount,\n ctVersion,\n deposit,\n encoded,\n entry,\n enumeration,\n fee,\n field,\n gasLimit,\n gasPrice,\n mptree,\n name,\n nameFee,\n nameId,\n pointers,\n raw,\n shortUInt,\n shortUIntConst,\n string,\n uInt,\n};\n"],"mappings":"OAAOA,WAAW;AAAA,OACXC,QAAQ;AAAA,OACRC,MAAM;AAAA,OACNC,QAAQ;AAAA,OACRC,WAAW;AAAA,OACXC,UAAU;AAAA,OACVC,QAAQ;AAAA,OACRC,QAAQ;AAAA,OACRC,MAAM;AAAA,OACNC,YAAY;AAAA,OACZC,IAAI;AAAA,OACJC,MAAM;AAAA,OACNC,SAAS;AAAA,OACTC,SAAS;AAAA,OACTC,OAAO;AAAA,OACPC,KAAK;AAAA,OACLC,QAAQ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,GAAG,EACHC,SAAS,EACTC,cAAc,EACdC,MAAM,EACNC,IAAI"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Tag } from '../constants';
|
|
3
|
+
import { Encoded, Encoding } from '../../../utils/encoder';
|
|
4
|
+
import type { unpackTx } from '..';
|
|
5
|
+
type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];
|
|
6
|
+
declare class MPTree<E extends Encoding, T extends Tag> {
|
|
7
|
+
#private;
|
|
8
|
+
get isComplete(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Deserialize Merkle Patricia Tree
|
|
11
|
+
* @param binary - Binary
|
|
12
|
+
* @param tag - Tag to use to decode value
|
|
13
|
+
* @param unpTx - Implementation of unpackTx use to decode values
|
|
14
|
+
* @returns Merkle Patricia Tree
|
|
15
|
+
*/
|
|
16
|
+
constructor(binary: MPTreeBinary, encoding: E, tag: T, unpTx: typeof unpackTx);
|
|
17
|
+
isEqual(tree: MPTree<E, T>): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Serialize Merkle Patricia Tree
|
|
20
|
+
* @returns Binary
|
|
21
|
+
*/
|
|
22
|
+
serialize(): MPTreeBinary;
|
|
23
|
+
/**
|
|
24
|
+
* Retrieve value from Merkle Patricia Tree
|
|
25
|
+
* @param key - The key of the element to retrieve
|
|
26
|
+
* @returns Value associated to the specified key
|
|
27
|
+
*/
|
|
28
|
+
get(key: Encoded.Generic<E>): ReturnType<typeof unpackTx<T>> | undefined;
|
|
29
|
+
toObject(): Record<Encoded.Any, ReturnType<typeof unpackTx<T>>>;
|
|
30
|
+
}
|
|
31
|
+
export default function genMPTreeField<E extends Encoding, T extends Tag>(encoding: E, tag: T): {
|
|
32
|
+
serialize: (value: MPTree<E, T>) => MPTreeBinary;
|
|
33
|
+
deserialize: (value: MPTreeBinary, o: {
|
|
34
|
+
unpackTx: typeof unpackTx;
|
|
35
|
+
}) => MPTree<E, T>;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import _buffer from "buffer";
|
|
2
|
+
const {
|
|
3
|
+
Buffer: _Buffer
|
|
4
|
+
} = _buffer;
|
|
5
|
+
import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
|
|
6
|
+
import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
|
|
7
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
8
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
9
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
10
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
11
|
+
function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; }
|
|
12
|
+
function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
|
|
13
|
+
import _rlp from 'rlp';
|
|
14
|
+
const {
|
|
15
|
+
encode: rlpEncode
|
|
16
|
+
} = _rlp;
|
|
17
|
+
import { hash } from "../../../utils/crypto.mjs";
|
|
18
|
+
import { MerkleTreeHashMismatchError, MissingNodeInTreeError, UnknownPathNibbleError, UnexpectedTsError, UnknownNodeLengthError, InternalError } from "../../../utils/errors.mjs";
|
|
19
|
+
import { decode, encode, Encoding } from "../../../utils/encoder.mjs";
|
|
20
|
+
var NodeType;
|
|
21
|
+
(function (NodeType) {
|
|
22
|
+
NodeType[NodeType["Branch"] = 0] = "Branch";
|
|
23
|
+
NodeType[NodeType["Extension"] = 1] = "Extension";
|
|
24
|
+
NodeType[NodeType["Leaf"] = 2] = "Leaf";
|
|
25
|
+
})(NodeType || (NodeType = {}));
|
|
26
|
+
var _rootHash = /*#__PURE__*/new WeakMap();
|
|
27
|
+
var _isComplete = /*#__PURE__*/new WeakMap();
|
|
28
|
+
var _nodes = /*#__PURE__*/new WeakMap();
|
|
29
|
+
var _encoding = /*#__PURE__*/new WeakMap();
|
|
30
|
+
var _tag = /*#__PURE__*/new WeakMap();
|
|
31
|
+
var _unpackTx = /*#__PURE__*/new WeakMap();
|
|
32
|
+
var _getRaw = /*#__PURE__*/new WeakSet();
|
|
33
|
+
var _entriesRaw = /*#__PURE__*/new WeakSet();
|
|
34
|
+
class MPTree {
|
|
35
|
+
get isComplete() {
|
|
36
|
+
return _classPrivateFieldGet(this, _isComplete);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Deserialize Merkle Patricia Tree
|
|
40
|
+
* @param binary - Binary
|
|
41
|
+
* @param tag - Tag to use to decode value
|
|
42
|
+
* @param unpTx - Implementation of unpackTx use to decode values
|
|
43
|
+
* @returns Merkle Patricia Tree
|
|
44
|
+
*/
|
|
45
|
+
constructor(binary, encoding, tag, unpTx) {
|
|
46
|
+
_classPrivateMethodInitSpec(this, _entriesRaw);
|
|
47
|
+
_classPrivateMethodInitSpec(this, _getRaw);
|
|
48
|
+
_classPrivateFieldInitSpec(this, _rootHash, {
|
|
49
|
+
writable: true,
|
|
50
|
+
value: void 0
|
|
51
|
+
});
|
|
52
|
+
_classPrivateFieldInitSpec(this, _isComplete, {
|
|
53
|
+
writable: true,
|
|
54
|
+
value: true
|
|
55
|
+
});
|
|
56
|
+
_classPrivateFieldInitSpec(this, _nodes, {
|
|
57
|
+
writable: true,
|
|
58
|
+
value: void 0
|
|
59
|
+
});
|
|
60
|
+
_classPrivateFieldInitSpec(this, _encoding, {
|
|
61
|
+
writable: true,
|
|
62
|
+
value: void 0
|
|
63
|
+
});
|
|
64
|
+
_classPrivateFieldInitSpec(this, _tag, {
|
|
65
|
+
writable: true,
|
|
66
|
+
value: void 0
|
|
67
|
+
});
|
|
68
|
+
_classPrivateFieldInitSpec(this, _unpackTx, {
|
|
69
|
+
writable: true,
|
|
70
|
+
value: void 0
|
|
71
|
+
});
|
|
72
|
+
_classPrivateFieldSet(this, _encoding, encoding);
|
|
73
|
+
_classPrivateFieldSet(this, _tag, tag);
|
|
74
|
+
_classPrivateFieldSet(this, _unpackTx, unpTx);
|
|
75
|
+
_classPrivateFieldSet(this, _rootHash, binary[0].toString('hex'));
|
|
76
|
+
_classPrivateFieldSet(this, _nodes, Object.fromEntries(binary[1].map(node => [node[0].toString('hex'), node[1]])));
|
|
77
|
+
if (_classPrivateFieldGet(this, _nodes)[_classPrivateFieldGet(this, _rootHash)] == null) {
|
|
78
|
+
if (Object.keys(_classPrivateFieldGet(this, _nodes)).length !== 0) {
|
|
79
|
+
throw new MissingNodeInTreeError('Can\'t find a node by root hash');
|
|
80
|
+
}
|
|
81
|
+
_classPrivateFieldSet(this, _isComplete, false);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
Object.entries(_classPrivateFieldGet(this, _nodes)).forEach(_ref => {
|
|
85
|
+
let [key, node] = _ref;
|
|
86
|
+
if (_classStaticPrivateMethodGet(MPTree, MPTree, _nodeHash).call(MPTree, node) !== key) throw new MerkleTreeHashMismatchError();
|
|
87
|
+
const {
|
|
88
|
+
type
|
|
89
|
+
} = _classStaticPrivateMethodGet(MPTree, MPTree, _parseNode).call(MPTree, node);
|
|
90
|
+
switch (type) {
|
|
91
|
+
case NodeType.Branch:
|
|
92
|
+
node.slice(0, 16).filter(n => n.length).forEach(n => {
|
|
93
|
+
// TODO: enable after resolving https://github.com/aeternity/aeternity/issues/4066
|
|
94
|
+
// if (n.length !== 32) {
|
|
95
|
+
// throw new ArgumentError('MPTree branch item length', 32, n.length);
|
|
96
|
+
// }
|
|
97
|
+
if (_classPrivateFieldGet(this, _nodes)[n.toString('hex')] == null) _classPrivateFieldSet(this, _isComplete, false);
|
|
98
|
+
});
|
|
99
|
+
break;
|
|
100
|
+
case NodeType.Extension:
|
|
101
|
+
if (_classPrivateFieldGet(this, _nodes)[node[1].toString('hex')] == null) {
|
|
102
|
+
throw new MissingNodeInTreeError('Can\'t find a node by hash in extension node');
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
case NodeType.Leaf:
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
throw new InternalError(`Unknown MPTree node type: ${type}`);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
isEqual(tree) {
|
|
113
|
+
return _classPrivateFieldGet(this, _rootHash) === _classPrivateFieldGet(tree, _rootHash);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Serialize Merkle Patricia Tree
|
|
117
|
+
* @returns Binary
|
|
118
|
+
*/
|
|
119
|
+
serialize() {
|
|
120
|
+
return [_Buffer.from(_classPrivateFieldGet(this, _rootHash), 'hex'), Object.entries(_classPrivateFieldGet(this, _nodes)).map(_ref2 => {
|
|
121
|
+
let [mptHash, value] = _ref2;
|
|
122
|
+
return [_Buffer.from(mptHash, 'hex'), value];
|
|
123
|
+
})];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Retrieve value from Merkle Patricia Tree
|
|
128
|
+
* @param _key - The key of the element to retrieve
|
|
129
|
+
* @returns Value associated to the specified key
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Retrieve value from Merkle Patricia Tree
|
|
134
|
+
* @param key - The key of the element to retrieve
|
|
135
|
+
* @returns Value associated to the specified key
|
|
136
|
+
*/
|
|
137
|
+
get(key) {
|
|
138
|
+
const d = _classPrivateMethodGet(this, _getRaw, _getRaw2).call(this, decode(key).toString('hex'));
|
|
139
|
+
if (d == null) return d;
|
|
140
|
+
return _classPrivateFieldGet(this, _unpackTx).call(this, encode(d, Encoding.Transaction), _classPrivateFieldGet(this, _tag));
|
|
141
|
+
}
|
|
142
|
+
toObject() {
|
|
143
|
+
return Object.fromEntries(_classPrivateMethodGet(this, _entriesRaw, _entriesRaw2).call(this) // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066
|
|
144
|
+
.filter(_ref3 => {
|
|
145
|
+
let [k] = _ref3;
|
|
146
|
+
return _classPrivateFieldGet(this, _encoding) !== Encoding.ContractAddress || k.length !== 66;
|
|
147
|
+
}).map(_ref4 => {
|
|
148
|
+
let [k, v] = _ref4;
|
|
149
|
+
return [encode(_Buffer.from(k, 'hex'), _classPrivateFieldGet(this, _encoding)), _classPrivateFieldGet(this, _unpackTx).call(this, encode(v, Encoding.Transaction), _classPrivateFieldGet(this, _tag))];
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function _nodeHash(node) {
|
|
154
|
+
return _Buffer.from(hash(rlpEncode(node))).toString('hex');
|
|
155
|
+
}
|
|
156
|
+
function _parseNode(node) {
|
|
157
|
+
switch (node.length) {
|
|
158
|
+
case 17:
|
|
159
|
+
return {
|
|
160
|
+
type: NodeType.Branch,
|
|
161
|
+
...(node[16].length !== 0 && {
|
|
162
|
+
value: node[16]
|
|
163
|
+
})
|
|
164
|
+
};
|
|
165
|
+
case 2:
|
|
166
|
+
{
|
|
167
|
+
const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise
|
|
168
|
+
if (nibble > 3) throw new UnknownPathNibbleError(nibble);
|
|
169
|
+
const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;
|
|
170
|
+
const slice = [0, 2].includes(nibble) ? 2 : 1;
|
|
171
|
+
return {
|
|
172
|
+
type,
|
|
173
|
+
...(type === NodeType.Leaf && {
|
|
174
|
+
value: node[1]
|
|
175
|
+
}),
|
|
176
|
+
path: node[0].toString('hex').slice(slice)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
default:
|
|
180
|
+
throw new UnknownNodeLengthError(node.length);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function _getRaw2(_key) {
|
|
184
|
+
let searchFrom = _classPrivateFieldGet(this, _rootHash);
|
|
185
|
+
let key = _key;
|
|
186
|
+
while (true) {
|
|
187
|
+
// eslint-disable-line no-constant-condition
|
|
188
|
+
const node = _classPrivateFieldGet(this, _nodes)[searchFrom];
|
|
189
|
+
if (node == null) {
|
|
190
|
+
if (!this.isComplete) return undefined;
|
|
191
|
+
throw new InternalError('Can\'t find node in complete tree');
|
|
192
|
+
}
|
|
193
|
+
const {
|
|
194
|
+
type,
|
|
195
|
+
value,
|
|
196
|
+
path
|
|
197
|
+
} = _classStaticPrivateMethodGet(MPTree, MPTree, _parseNode).call(MPTree, node);
|
|
198
|
+
switch (type) {
|
|
199
|
+
case NodeType.Branch:
|
|
200
|
+
if (key.length === 0) return value;
|
|
201
|
+
searchFrom = node[+`0x${key[0]}`].toString('hex');
|
|
202
|
+
key = key.substring(1);
|
|
203
|
+
break;
|
|
204
|
+
case NodeType.Extension:
|
|
205
|
+
if (key.substring(0, path === null || path === void 0 ? void 0 : path.length) !== path) return undefined;
|
|
206
|
+
searchFrom = node[1].toString('hex');
|
|
207
|
+
key = key.substring(path.length);
|
|
208
|
+
break;
|
|
209
|
+
case NodeType.Leaf:
|
|
210
|
+
if (path !== key) return undefined;
|
|
211
|
+
return value;
|
|
212
|
+
default:
|
|
213
|
+
throw new InternalError(`Unknown MPTree node type: ${type}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function _entriesRaw2() {
|
|
218
|
+
const entries = [];
|
|
219
|
+
const rec = (searchFrom, key) => {
|
|
220
|
+
const node = _classPrivateFieldGet(this, _nodes)[searchFrom];
|
|
221
|
+
if (node == null) {
|
|
222
|
+
if (!this.isComplete) return;
|
|
223
|
+
throw new InternalError('Can\'t find node in complete tree');
|
|
224
|
+
}
|
|
225
|
+
const {
|
|
226
|
+
type,
|
|
227
|
+
value,
|
|
228
|
+
path
|
|
229
|
+
} = _classStaticPrivateMethodGet(MPTree, MPTree, _parseNode).call(MPTree, node);
|
|
230
|
+
switch (type) {
|
|
231
|
+
case NodeType.Branch:
|
|
232
|
+
node.slice(0, 16).map((t, idx) => [t, idx]).filter(_ref6 => {
|
|
233
|
+
let [t] = _ref6;
|
|
234
|
+
return t.length;
|
|
235
|
+
}).forEach(_ref7 => {
|
|
236
|
+
let [t, idx] = _ref7;
|
|
237
|
+
return rec(t.toString('hex'), key + idx.toString(16));
|
|
238
|
+
});
|
|
239
|
+
if (value != null) entries.push([key, value]);
|
|
240
|
+
break;
|
|
241
|
+
case NodeType.Extension:
|
|
242
|
+
rec(node[1].toString('hex'), key + path);
|
|
243
|
+
break;
|
|
244
|
+
case NodeType.Leaf:
|
|
245
|
+
if (value == null) throw new UnexpectedTsError();
|
|
246
|
+
entries.push([key + path, value]);
|
|
247
|
+
break;
|
|
248
|
+
default:
|
|
249
|
+
throw new InternalError(`Unknown MPTree node type: ${type}`);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
rec(_classPrivateFieldGet(this, _rootHash), '');
|
|
253
|
+
return entries;
|
|
254
|
+
}
|
|
255
|
+
export default function genMPTreeField(encoding, tag) {
|
|
256
|
+
return {
|
|
257
|
+
serialize(value) {
|
|
258
|
+
return value.serialize();
|
|
259
|
+
},
|
|
260
|
+
deserialize(value, _ref5) {
|
|
261
|
+
let {
|
|
262
|
+
unpackTx
|
|
263
|
+
} = _ref5;
|
|
264
|
+
return new MPTree(value, encoding, tag, unpackTx);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=mptree.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mptree.mjs","names":["hash","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownPathNibbleError","UnexpectedTsError","UnknownNodeLengthError","InternalError","decode","encode","Encoding","NodeType","MPTree","isComplete","constructor","binary","encoding","tag","unpTx","toString","Object","fromEntries","map","node","keys","length","entries","forEach","key","type","Branch","slice","filter","n","Extension","Leaf","isEqual","tree","serialize","from","mptHash","value","get","d","Transaction","toObject","k","ContractAddress","v","rlpEncode","nibble","includes","path","_key","searchFrom","undefined","substring","rec","t","idx","push","genMPTreeField","deserialize","unpackTx"],"sources":["../../../../src/tx/builder/field-types/mptree.ts"],"sourcesContent":["import { encode as rlpEncode, Input } from 'rlp';\nimport { Tag } from '../constants';\nimport { hash } from '../../../utils/crypto';\nimport {\n MerkleTreeHashMismatchError,\n MissingNodeInTreeError,\n UnknownPathNibbleError,\n UnexpectedTsError,\n UnknownNodeLengthError,\n InternalError,\n} from '../../../utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport type { unpackTx } from '..';\n\nenum NodeType {\n Branch,\n Extension,\n Leaf,\n}\n\ntype MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];\n\nclass MPTree<E extends Encoding, T extends Tag> {\n readonly #rootHash: string;\n\n #isComplete = true;\n\n get isComplete(): boolean {\n return this.#isComplete;\n }\n\n readonly #nodes: { [key: string]: Buffer[] };\n\n readonly #encoding: E;\n\n readonly #tag: T;\n\n readonly #unpackTx: typeof unpackTx;\n\n static #nodeHash(node: Input): string {\n return Buffer.from(hash(rlpEncode(node))).toString('hex');\n }\n\n /**\n * Deserialize Merkle Patricia Tree\n * @param binary - Binary\n * @param tag - Tag to use to decode value\n * @param unpTx - Implementation of unpackTx use to decode values\n * @returns Merkle Patricia Tree\n */\n constructor(binary: MPTreeBinary, encoding: E, tag: T, unpTx: typeof unpackTx) {\n this.#encoding = encoding;\n this.#tag = tag;\n this.#unpackTx = unpTx;\n this.#rootHash = binary[0].toString('hex');\n this.#nodes = Object.fromEntries(\n binary[1].map((node) => [node[0].toString('hex'), node[1]]),\n );\n\n if (this.#nodes[this.#rootHash] == null) {\n if (Object.keys(this.#nodes).length !== 0) {\n throw new MissingNodeInTreeError('Can\\'t find a node by root hash');\n }\n this.#isComplete = false;\n return;\n }\n Object.entries(this.#nodes).forEach(([key, node]) => {\n if (MPTree.#nodeHash(node) !== key) throw new MerkleTreeHashMismatchError();\n const { type } = MPTree.#parseNode(node);\n switch (type) {\n case NodeType.Branch:\n node\n .slice(0, 16)\n .filter((n) => n.length)\n .forEach((n) => {\n // TODO: enable after resolving https://github.com/aeternity/aeternity/issues/4066\n // if (n.length !== 32) {\n // throw new ArgumentError('MPTree branch item length', 32, n.length);\n // }\n if (this.#nodes[n.toString('hex')] == null) this.#isComplete = false;\n });\n break;\n case NodeType.Extension:\n if (this.#nodes[node[1].toString('hex')] == null) {\n throw new MissingNodeInTreeError('Can\\'t find a node by hash in extension node');\n }\n break;\n case NodeType.Leaf:\n break;\n default:\n throw new InternalError(`Unknown MPTree node type: ${type}`);\n }\n });\n }\n\n isEqual(tree: MPTree<E, T>): boolean {\n return this.#rootHash === tree.#rootHash;\n }\n\n static #parseNode(node: Buffer[]): { type: NodeType; value?: Buffer; path?: string } {\n switch (node.length) {\n case 17:\n return {\n type: NodeType.Branch,\n ...node[16].length !== 0 && { value: node[16] },\n };\n case 2: {\n const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise\n if (nibble > 3) throw new UnknownPathNibbleError(nibble);\n const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;\n const slice = [0, 2].includes(nibble) ? 2 : 1;\n return {\n type,\n ...type === NodeType.Leaf && { value: node[1] },\n path: node[0].toString('hex').slice(slice),\n };\n }\n default:\n throw new UnknownNodeLengthError(node.length);\n }\n }\n\n /**\n * Serialize Merkle Patricia Tree\n * @returns Binary\n */\n serialize(): MPTreeBinary {\n return [\n Buffer.from(this.#rootHash, 'hex'),\n Object.entries(this.#nodes).map(([mptHash, value]) => ([\n Buffer.from(mptHash, 'hex'),\n value,\n ])),\n ];\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @param _key - The key of the element to retrieve\n * @returns Value associated to the specified key\n */\n #getRaw(_key: string): Buffer | undefined {\n let searchFrom = this.#rootHash;\n let key = _key;\n while (true) { // eslint-disable-line no-constant-condition\n const node = this.#nodes[searchFrom];\n if (node == null) {\n if (!this.isComplete) return undefined;\n throw new InternalError('Can\\'t find node in complete tree');\n }\n const { type, value, path } = MPTree.#parseNode(node);\n switch (type) {\n case NodeType.Branch:\n if (key.length === 0) return value;\n searchFrom = node[+`0x${key[0]}`].toString('hex');\n key = key.substring(1);\n break;\n case NodeType.Extension:\n if (key.substring(0, path?.length) !== path) return undefined;\n searchFrom = node[1].toString('hex');\n key = key.substring(path.length);\n break;\n case NodeType.Leaf:\n if (path !== key) return undefined;\n return value;\n default:\n throw new InternalError(`Unknown MPTree node type: ${type}`);\n }\n }\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @param key - The key of the element to retrieve\n * @returns Value associated to the specified key\n */\n get(key: Encoded.Generic<E>): ReturnType<typeof unpackTx<T>> | undefined {\n const d = this.#getRaw(decode(key).toString('hex'));\n if (d == null) return d;\n return this.#unpackTx(encode(d, Encoding.Transaction), this.#tag);\n }\n\n #entriesRaw(): Array<[string, Buffer]> {\n const entries: Array<[string, Buffer]> = [];\n const rec = (searchFrom: string, key: string): void => {\n const node = this.#nodes[searchFrom];\n if (node == null) {\n if (!this.isComplete) return;\n throw new InternalError('Can\\'t find node in complete tree');\n }\n const { type, value, path } = MPTree.#parseNode(node);\n switch (type) {\n case NodeType.Branch:\n node\n .slice(0, 16)\n .map((t, idx): [typeof t, number] => [t, idx])\n .filter(([t]) => t.length)\n .forEach(([t, idx]) => rec(t.toString('hex'), key + idx.toString(16)));\n if (value != null) entries.push([key, value]);\n break;\n case NodeType.Extension:\n rec(node[1].toString('hex'), key + path);\n break;\n case NodeType.Leaf:\n if (value == null) throw new UnexpectedTsError();\n entries.push([key + path, value]);\n break;\n default:\n throw new InternalError(`Unknown MPTree node type: ${type}`);\n }\n };\n rec(this.#rootHash, '');\n return entries;\n }\n\n toObject(): Record<Encoded.Any, ReturnType<typeof unpackTx<T>>> {\n return Object.fromEntries(this.#entriesRaw()\n // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066\n .filter(([k]) => this.#encoding !== Encoding.ContractAddress || k.length !== 66)\n .map(([k, v]) => [\n encode(Buffer.from(k, 'hex'), this.#encoding),\n this.#unpackTx(encode(v, Encoding.Transaction), this.#tag),\n ]));\n }\n}\n\nexport default function genMPTreeField<E extends Encoding, T extends Tag>(encoding: E, tag: T): {\n serialize: (value: MPTree<E, T>) => MPTreeBinary;\n deserialize: (value: MPTreeBinary, o: { unpackTx: typeof unpackTx }) => MPTree<E, T>;\n} {\n return {\n serialize(value) {\n return value.serialize();\n },\n\n deserialize(value, { unpackTx }) {\n return new MPTree(value, encoding, tag, unpackTx);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;AAAA,iBAA2C,KAAK;AAAC;EAAA;AAAA;AAAA,SAExCA,IAAI;AAAA,SAEXC,2BAA2B,EAC3BC,sBAAsB,EACtBC,sBAAsB,EACtBC,iBAAiB,EACjBC,sBAAsB,EACtBC,aAAa;AAAA,SAGbC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,IAI9BC,QAAQ;AAAA,WAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;AAAA,GAARA,QAAQ,KAARA,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQb,MAAMC,MAAM,CAAoC;EAK9C,IAAIC,UAAU,GAAY;IACxB,6BAAO,IAAI;EACb;EAcA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,WAAW,CAACC,MAAoB,EAAEC,QAAW,EAAEC,GAAM,EAAEC,KAAsB,EAAE;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;MAAA;MAAA,OAzBjE;IAAI;IAAA;MAAA;MAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IA0BhB,0BAAI,aAAaF,QAA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C,CAAC,CAACvC,QAAQ,CAAC,KAAK,CAAC,EAAES,GAAG,GAAG+B,GAAG,CAACxC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAAA,EAAC;QACxE,IAAIsB,KAAK,IAAI,IAAI,EAAEf,OAAO,CAACkC,IAAI,CAAC,CAAChC,GAAG,EAAEa,KAAK,CAAC,CAAC;QAC7C;MACF,KAAK9B,QAAQ,CAACuB,SAAS;QACrBuB,GAAG,CAAClC,IAAI,CAAC,CAAC,CAAC,CAACJ,QAAQ,CAAC,KAAK,CAAC,EAAES,GAAG,GAAGwB,IAAI,CAAC;QACxC;MACF,KAAKzC,QAAQ,CAACwB,IAAI;QAChB,IAAIM,KAAK,IAAI,IAAI,EAAE,MAAM,IAAIpC,iBAAiB,EAAE;QAChDqB,OAAO,CAACkC,IAAI,CAAC,CAAChC,GAAG,GAAGwB,IAAI,EAAEX,KAAK,CAAC,CAAC;QACjC;MACF;QACE,MAAM,IAAIlC,aAAa,CAAE,6BAA4BsB,IAAK,EAAC,CAAC;IAAC;EAEnE,CAAC;EACD4B,GAAG,uBAAC,IAAI,cAAY,EAAE,CAAC;EACvB,OAAO/B,OAAO;AAChB;AAaF,eAAe,SAASmC,cAAc,CAAoC7C,QAAW,EAAEC,GAAM,EAG3F;EACA,OAAO;IACLqB,SAAS,CAACG,KAAK,EAAE;MACf,OAAOA,KAAK,CAACH,SAAS,EAAE;IAC1B,CAAC;IAEDwB,WAAW,CAACrB,KAAK,SAAgB;MAAA,IAAd;QAAEsB;MAAS,CAAC;MAC7B,OAAO,IAAInD,MAAM,CAAC6B,KAAK,EAAEzB,QAAQ,EAAEC,GAAG,EAAE8C,QAAQ,CAAC;IACnD;EACF,CAAC;AACH"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Int } from './u-int';
|
|
3
2
|
import coinAmount from './coin-amount';
|
|
4
|
-
import { AensName } from '../constants';
|
|
3
|
+
import { AensName, Int } from '../constants';
|
|
5
4
|
declare const _default: {
|
|
6
5
|
serializeAettos(_value: string | undefined, txFields: {
|
|
7
6
|
name: AensName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-fee.mjs","names":["BigNumber","getMinimumNameFee","InsufficientNameFeeError","coinAmount","serializeAettos","_value","txFields","minNameFee","name","value","gt","toFixed","serialize","call"],"sources":["../../../../src/tx/builder/field-types/name-fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { getMinimumNameFee } from '../helpers';\nimport { InsufficientNameFeeError } from '../../../utils/errors';\nimport
|
|
1
|
+
{"version":3,"file":"name-fee.mjs","names":["BigNumber","getMinimumNameFee","InsufficientNameFeeError","coinAmount","serializeAettos","_value","txFields","minNameFee","name","value","gt","toFixed","serialize","call"],"sources":["../../../../src/tx/builder/field-types/name-fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { getMinimumNameFee } from '../helpers';\nimport { InsufficientNameFeeError } from '../../../utils/errors';\nimport coinAmount from './coin-amount';\nimport { AensName, Int } from '../constants';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(\n _value: string | undefined,\n txFields: { name: AensName },\n ): string {\n const minNameFee = getMinimumNameFee(txFields.name);\n const value = new BigNumber(_value ?? minNameFee);\n if (minNameFee.gt(value)) throw new InsufficientNameFeeError(value, minNameFee);\n return value.toFixed();\n },\n\n /**\n * @param value - AENS name fee Buffer\n * @param txFields - Transaction fields\n * @param txFields.name - AENS Name in transaction\n */\n serialize(\n value: Int | undefined,\n txFields: { name: AensName } & Parameters<typeof coinAmount['serialize']>[1],\n ): Buffer {\n return coinAmount.serialize.call(this, value, txFields);\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,iBAAiB;AAAA,SACjBC,wBAAwB;AAAA,OAC1BC,UAAU;AAGjB,eAAe;EACb,GAAGA,UAAU;EAEbC,eAAe,CACbC,MAA0B,EAC1BC,QAA4B,EACpB;IACR,MAAMC,UAAU,GAAGN,iBAAiB,CAACK,QAAQ,CAACE,IAAI,CAAC;IACnD,MAAMC,KAAK,GAAG,IAAIT,SAAS,CAACK,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIE,UAAU,CAAC;IACjD,IAAIA,UAAU,CAACG,EAAE,CAACD,KAAK,CAAC,EAAE,MAAM,IAAIP,wBAAwB,CAACO,KAAK,EAAEF,UAAU,CAAC;IAC/E,OAAOE,KAAK,CAACE,OAAO,EAAE;EACxB,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,SAAS,CACPH,KAAsB,EACtBH,QAA4E,EACpE;IACR,OAAOH,UAAU,CAACS,SAAS,CAACC,IAAI,CAAC,IAAI,EAAEJ,KAAK,EAAEH,QAAQ,CAAC;EACzD;AACF,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { produceNameId, isNameValid } from "../helpers.mjs";
|
|
2
2
|
import address from "./address.mjs";
|
|
3
|
-
|
|
3
|
+
import { Encoding } from "../../../utils/encoder.mjs";
|
|
4
|
+
const addressName = address(Encoding.Name);
|
|
4
5
|
export default {
|
|
5
6
|
...addressName,
|
|
6
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-id.mjs","names":["produceNameId","isNameValid","address","addressName","serialize","value"],"sources":["../../../../src/tx/builder/field-types/name-id.ts"],"sourcesContent":["import { AensName } from '../constants';\nimport { produceNameId, isNameValid } from '../helpers';\nimport address from './address';\nimport { Encoded, Encoding } from '../../../utils/encoder';\n\nconst addressName = address
|
|
1
|
+
{"version":3,"file":"name-id.mjs","names":["produceNameId","isNameValid","address","Encoding","addressName","Name","serialize","value"],"sources":["../../../../src/tx/builder/field-types/name-id.ts"],"sourcesContent":["import { AensName } from '../constants';\nimport { produceNameId, isNameValid } from '../helpers';\nimport address from './address';\nimport { Encoded, Encoding } from '../../../utils/encoder';\n\nconst addressName = address(Encoding.Name);\n\nexport default {\n ...addressName,\n\n /**\n * @param value - AENS name ID\n */\n serialize(value: AensName | Encoded.Name): Buffer {\n return addressName.serialize(isNameValid(value) ? produceNameId(value) : value);\n },\n};\n"],"mappings":"SACSA,aAAa,EAAEC,WAAW;AAAA,OAC5BC,OAAO;AAAA,SACIC,QAAQ;AAE1B,MAAMC,WAAW,GAAGF,OAAO,CAACC,QAAQ,CAACE,IAAI,CAAC;AAE1C,eAAe;EACb,GAAGD,WAAW;EAEd;AACF;AACA;EACEE,SAAS,CAACC,KAA8B,EAAU;IAChD,OAAOH,WAAW,CAACE,SAAS,CAACL,WAAW,CAACM,KAAK,CAAC,GAAGP,aAAa,CAACO,KAAK,CAAC,GAAGA,KAAK,CAAC;EACjF;AACF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toBytes } from "../../../utils/bytes.mjs";
|
|
2
2
|
import { IllegalArgumentError } from "../../../utils/errors.mjs";
|
|
3
|
-
import address from "./address.mjs";
|
|
4
|
-
const addressAny = address();
|
|
3
|
+
import address, { idTagToEncoding } from "./address.mjs";
|
|
4
|
+
const addressAny = address(...idTagToEncoding);
|
|
5
5
|
|
|
6
6
|
// TODO: remove after fixing node types
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointers.mjs","names":["toBytes","IllegalArgumentError","address","addressAny","serialize","pointers","length","map","pointer","key","id","deserialize","toString"],"sources":["../../../../src/tx/builder/field-types/pointers.ts"],"sourcesContent":["import { NamePointer as NamePointerString } from '../../../apis/node';\nimport { toBytes } from '../../../utils/bytes';\nimport { Encoded } from '../../../utils/encoder';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport address, { AddressEncodings } from './address';\n\nconst addressAny = address
|
|
1
|
+
{"version":3,"file":"pointers.mjs","names":["toBytes","IllegalArgumentError","address","idTagToEncoding","addressAny","serialize","pointers","length","map","pointer","key","id","deserialize","toString"],"sources":["../../../../src/tx/builder/field-types/pointers.ts"],"sourcesContent":["import { NamePointer as NamePointerString } from '../../../apis/node';\nimport { toBytes } from '../../../utils/bytes';\nimport { Encoded } from '../../../utils/encoder';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport address, { AddressEncodings, idTagToEncoding } from './address';\n\nconst addressAny = address(...idTagToEncoding);\n\n// TODO: remove after fixing node types\ntype NamePointer = NamePointerString & {\n id: Encoded.Generic<AddressEncodings>;\n};\n\nexport default {\n /**\n * Helper function to build pointers for name update TX\n * @param pointers - Array of pointers\n * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`\n * @returns Serialized pointers array\n */\n serialize(pointers: NamePointer[]): Buffer[][] {\n if (pointers.length > 32) {\n throw new IllegalArgumentError(`Expected 32 pointers or less, got ${pointers.length} instead`);\n }\n\n return pointers.map(\n (pointer) => [toBytes(pointer.key), addressAny.serialize(pointer.id)],\n );\n },\n\n /**\n * Helper function to read pointers from name update TX\n * @param pointers - Array of pointers\n * @returns Deserialize pointer array\n */\n deserialize(pointers: Array<[key: Buffer, id: Buffer]>): NamePointer[] {\n return pointers.map(\n ([key, id]) => ({ key: key.toString(), id: addressAny.deserialize(id) }),\n );\n },\n};\n"],"mappings":"SACSA,OAAO;AAAA,SAEPC,oBAAoB;AAAA,OACtBC,OAAO,IAAsBC,eAAe;AAEnD,MAAMC,UAAU,GAAGF,OAAO,CAAC,GAAGC,eAAe,CAAC;;AAE9C;;AAKA,eAAe;EACb;AACF;AACA;AACA;AACA;AACA;EACEE,SAAS,CAACC,QAAuB,EAAc;IAC7C,IAAIA,QAAQ,CAACC,MAAM,GAAG,EAAE,EAAE;MACxB,MAAM,IAAIN,oBAAoB,CAAE,qCAAoCK,QAAQ,CAACC,MAAO,UAAS,CAAC;IAChG;IAEA,OAAOD,QAAQ,CAACE,GAAG,CAChBC,OAAO,IAAK,CAACT,OAAO,CAACS,OAAO,CAACC,GAAG,CAAC,EAAEN,UAAU,CAACC,SAAS,CAACI,OAAO,CAACE,EAAE,CAAC,CAAC,CACtE;EACH,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,WAAW,CAACN,QAA0C,EAAiB;IACrE,OAAOA,QAAQ,CAACE,GAAG,CACjB;MAAA,IAAC,CAACE,GAAG,EAAEC,EAAE,CAAC;MAAA,OAAM;QAAED,GAAG,EAAEA,GAAG,CAACG,QAAQ,EAAE;QAAEF,EAAE,EAAEP,UAAU,CAACQ,WAAW,CAACD,EAAE;MAAE,CAAC;IAAA,CAAC,CACzE;EACH;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw.mjs","names":["serialize","buffer","from","deserialize"],"sources":["../../../../src/tx/builder/field-types/raw.ts"],"sourcesContent":["export default {\n serialize(buffer: Uint8Array): Buffer {\n return Buffer.from(buffer);\n },\n\n deserialize(buffer: Buffer): Buffer {\n return buffer;\n },\n};\n"],"mappings":";;;;AAAA,eAAe;EACbA,SAAS,CAACC,MAAkB,EAAU;IACpC,OAAO,QAAOC,IAAI,CAACD,MAAM,CAAC;EAC5B,CAAC;EAEDE,WAAW,CAACF,MAAc,EAAU;IAClC,OAAOA,MAAM;EACf;AACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ArgumentError } from "../../../utils/errors.mjs";
|
|
2
|
+
import shortUInt from "./short-u-int.mjs";
|
|
3
|
+
export default function genShortUIntConstField(value) {
|
|
4
|
+
return {
|
|
5
|
+
serialize(val) {
|
|
6
|
+
if (val != null && val !== value) throw new ArgumentError('ShortUIntConst', value, val);
|
|
7
|
+
return shortUInt.serialize(value);
|
|
8
|
+
},
|
|
9
|
+
deserialize(buf) {
|
|
10
|
+
const val = shortUInt.deserialize(buf);
|
|
11
|
+
if (val !== value) throw new ArgumentError('ShortUIntConst', value, val);
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=short-u-int-const.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"short-u-int-const.mjs","names":["ArgumentError","shortUInt","genShortUIntConstField","value","serialize","val","deserialize","buf"],"sources":["../../../../src/tx/builder/field-types/short-u-int-const.ts"],"sourcesContent":["import { ArgumentError } from '../../../utils/errors';\nimport shortUInt from './short-u-int';\n\nexport default function genShortUIntConstField<Value extends number>(value: Value): {\n serialize: (value?: Value) => Buffer;\n deserialize: (value: Buffer) => Value;\n} {\n return {\n serialize(val) {\n if (val != null && val !== value) throw new ArgumentError('ShortUIntConst', value, val);\n return shortUInt.serialize(value);\n },\n\n deserialize(buf) {\n const val = shortUInt.deserialize(buf);\n if (val !== value) throw new ArgumentError('ShortUIntConst', value, val);\n return value;\n },\n };\n}\n"],"mappings":"SAASA,aAAa;AAAA,OACfC,SAAS;AAEhB,eAAe,SAASC,sBAAsB,CAAuBC,KAAY,EAG/E;EACA,OAAO;IACLC,SAAS,CAACC,GAAG,EAAE;MACb,IAAIA,GAAG,IAAI,IAAI,IAAIA,GAAG,KAAKF,KAAK,EAAE,MAAM,IAAIH,aAAa,CAAC,gBAAgB,EAAEG,KAAK,EAAEE,GAAG,CAAC;MACvF,OAAOJ,SAAS,CAACG,SAAS,CAACD,KAAK,CAAC;IACnC,CAAC;IAEDG,WAAW,CAACC,GAAG,EAAE;MACf,MAAMF,GAAG,GAAGJ,SAAS,CAACK,WAAW,CAACC,GAAG,CAAC;MACtC,IAAIF,GAAG,KAAKF,KAAK,EAAE,MAAM,IAAIH,aAAa,CAAC,gBAAgB,EAAEG,KAAK,EAAEE,GAAG,CAAC;MACxE,OAAOF,KAAK;IACd;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.mjs","names":["toBytes","serialize","string","deserialize","buffer","toString"],"sources":["../../../../src/tx/builder/field-types/string.ts"],"sourcesContent":["import { toBytes } from '../../../utils/bytes';\n\nexport default {\n serialize(string: string): Buffer {\n return toBytes(string);\n },\n\n deserialize(buffer: Buffer): string {\n return buffer.toString();\n },\n};\n"],"mappings":"SAASA,OAAO;AAEhB,eAAe;EACbC,SAAS,CAACC,MAAc,EAAU;IAChC,OAAOF,OAAO,CAACE,MAAM,CAAC;EACxB,CAAC;EAEDC,WAAW,CAACC,MAAc,EAAU;IAClC,OAAOA,MAAM,CAACC,QAAQ,EAAE;EAC1B;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"u-int.mjs","names":["readInt","ArgumentError","toBytes","serialize","value","deserialize"],"sources":["../../../../src/tx/builder/field-types/u-int.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"u-int.mjs","names":["readInt","ArgumentError","toBytes","serialize","value","deserialize"],"sources":["../../../../src/tx/builder/field-types/u-int.ts"],"sourcesContent":["import { readInt } from '../helpers';\nimport { Int } from '../constants';\nimport { ArgumentError } from '../../../utils/errors';\nimport { toBytes } from '../../../utils/bytes';\n\nexport default {\n serialize(value: Int): Buffer {\n if (value < 0) throw new ArgumentError('value', 'greater or equal to 0', value);\n return toBytes(value, true);\n },\n\n deserialize(value: Buffer): string {\n return readInt(value);\n },\n};\n"],"mappings":"SAASA,OAAO;AAAA,SAEPC,aAAa;AAAA,SACbC,OAAO;AAEhB,eAAe;EACbC,SAAS,CAACC,KAAU,EAAU;IAC5B,IAAIA,KAAK,GAAG,CAAC,EAAE,MAAM,IAAIH,aAAa,CAAC,OAAO,EAAE,uBAAuB,EAAEG,KAAK,CAAC;IAC/E,OAAOF,OAAO,CAACE,KAAK,EAAE,IAAI,CAAC;EAC7B,CAAC;EAEDC,WAAW,CAACD,KAAa,EAAU;IACjC,OAAOJ,OAAO,CAACI,KAAK,CAAC;EACvB;AACF,CAAC"}
|