@aeternity/aepp-sdk 13.0.0-alpha.0 → 13.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +5595 -2249
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.mjs.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 +12 -14
- package/es/AeSdkMethods.mjs +6 -8
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/AeSdkWallet.mjs +1 -1
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +9 -4
- package/es/Node.mjs +12 -6
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +13 -8
- package/es/account/Base.mjs +0 -17
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.mjs +14 -25
- 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/LedgerFactory.mjs.map +1 -1
- package/es/account/Memory.d.ts +2 -1
- package/es/account/Memory.mjs +11 -22
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +12 -14
- package/es/aens.mjs +22 -32
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -20
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -6
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.d.ts +1 -1
- package/es/apis/compiler/compiler.mjs +4 -20
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +3 -2
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.d.ts +1 -1
- package/es/apis/compiler/models/mappers.mjs +19 -2
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +15 -15
- package/es/apis/node/models/index.mjs.map +1 -1
- package/es/apis/node/models/mappers.d.ts +1 -1
- package/es/apis/node/models/mappers.mjs +2 -1
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/parameters.d.ts +2 -2
- package/es/apis/node/models/parameters.mjs +2 -2
- package/es/apis/node/models/parameters.mjs.map +1 -1
- package/es/apis/node/node.mjs +3 -19
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +17 -9
- package/es/chain.mjs +23 -23
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +27 -9
- package/es/channel/Base.mjs +27 -27
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.d.ts +8 -7
- package/es/channel/Contract.mjs +8 -21
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +5 -1
- package/es/channel/Spend.mjs +4 -18
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +16 -26
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +19 -2
- package/es/channel/internal.mjs +22 -20
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +43 -123
- package/es/contract/Contract.mjs +230 -250
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +74 -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 +149 -0
- package/es/contract/compiler/Cli.mjs.map +1 -0
- package/es/contract/compiler/Http.d.ts +32 -0
- package/es/contract/compiler/Http.mjs +94 -0
- 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/delegation-signature.d.ts +43 -0
- package/es/contract/delegation-signature.mjs +45 -0
- package/es/contract/delegation-signature.mjs.map +1 -0
- package/es/contract/ga.d.ts +27 -10
- package/es/contract/ga.mjs +63 -29
- package/es/contract/ga.mjs.map +1 -1
- package/es/index-browser.d.ts +40 -0
- package/es/index-browser.mjs +41 -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.d.ts +12 -17
- package/es/oracle.mjs +29 -49
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +19 -27
- package/es/spend.mjs +21 -46
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/SchemaTypes.d.ts +37 -0
- package/es/tx/builder/SchemaTypes.mjs +2 -0
- package/es/tx/builder/SchemaTypes.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +31 -2
- package/es/tx/builder/constants.mjs +34 -3
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.d.ts +19 -0
- package/es/tx/builder/field-types/abi-version.mjs +40 -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 +4 -5
- package/es/tx/builder/field-types/coin-amount.mjs +4 -5
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.d.ts +49 -0
- package/es/tx/builder/field-types/ct-version.mjs +76 -0
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +3 -2
- package/es/tx/builder/field-types/deposit.mjs +3 -2
- 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 +34 -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 +12 -7
- package/es/tx/builder/field-types/fee.mjs +28 -20
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/field.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.d.ts +7 -3
- package/es/tx/builder/field-types/gas-limit.mjs +13 -8
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +3 -1
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +107 -30
- package/es/tx/builder/field-types/index.mjs +38 -12
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/map.d.ts +13 -0
- package/es/tx/builder/field-types/map.mjs +49 -0
- package/es/tx/builder/field-types/map.mjs.map +1 -0
- package/es/tx/builder/field-types/mptree.d.ts +42 -0
- package/es/tx/builder/field-types/mptree.mjs +266 -0
- package/es/tx/builder/field-types/mptree.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +2 -3
- package/es/tx/builder/field-types/name-fee.mjs +2 -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/name.mjs.map +1 -1
- package/es/tx/builder/field-types/nonce.d.ts +14 -0
- package/es/tx/builder/field-types/nonce.mjs +29 -0
- package/es/tx/builder/field-types/nonce.mjs.map +1 -0
- 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 +7 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs +20 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
- 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/ttl.d.ts +11 -0
- package/es/tx/builder/field-types/ttl.mjs +21 -0
- package/es/tx/builder/field-types/ttl.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/field-types/wrapped.d.ts +14 -0
- package/es/tx/builder/field-types/wrapped.mjs +22 -0
- package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +18 -36
- package/es/tx/builder/index.mjs +65 -236
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2734 -1324
- package/es/tx/builder/schema.generated.d.ts +2011 -0
- package/es/tx/builder/schema.generated.mjs +2 -0
- package/es/tx/builder/schema.generated.mjs.map +1 -0
- package/es/tx/builder/schema.mjs +459 -223
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/execution-cost.d.ts +35 -0
- package/es/tx/execution-cost.mjs +123 -0
- package/es/tx/execution-cost.mjs.map +1 -0
- package/es/tx/transaction-signer.d.ts +6 -0
- package/es/tx/transaction-signer.mjs +27 -0
- package/es/tx/transaction-signer.mjs.map +1 -0
- package/es/tx/validator.d.ts +3 -5
- package/es/tx/validator.mjs +91 -153
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/amount-formatter.mjs +0 -16
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +3 -2
- package/es/utils/autorest.mjs +43 -11
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bytes.mjs +1 -17
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.mjs +0 -16
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +16 -38
- package/es/utils/errors.mjs +3 -43
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.mjs +0 -17
- package/es/utils/string.mjs.map +1 -1
- package/package.json +52 -40
- package/src/AeSdkBase.ts +6 -3
- package/src/AeSdkMethods.ts +12 -18
- package/src/AeSdkWallet.ts +1 -1
- package/src/Node.ts +23 -9
- package/src/account/Base.ts +13 -24
- package/src/account/Generalized.ts +9 -24
- package/src/account/Ledger.ts +1 -1
- package/src/account/Memory.ts +15 -22
- package/src/aens.ts +34 -49
- package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -24
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
- package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
- package/src/aepp-wallet-communication/rpc/types.ts +6 -2
- package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
- package/src/apis/compiler/compiler.ts +3 -27
- package/src/apis/compiler/models/index.ts +3 -2
- package/src/apis/compiler/models/mappers.ts +15 -2
- package/src/apis/node/models/index.ts +16 -15
- package/src/apis/node/models/mappers.ts +2 -1
- package/src/apis/node/models/parameters.ts +2 -2
- package/src/apis/node/node.ts +3 -27
- package/src/chain.ts +33 -30
- package/src/channel/Base.ts +39 -31
- package/src/channel/Contract.ts +18 -32
- package/src/channel/Spend.ts +8 -18
- package/src/channel/handlers.ts +14 -26
- package/src/channel/internal.ts +41 -23
- package/src/contract/Contract.ts +188 -228
- package/src/contract/compiler/Base.ts +87 -0
- package/src/contract/compiler/Cli.ts +128 -0
- package/src/contract/compiler/Http.ts +105 -0
- package/src/contract/compiler/HttpNode.ts +26 -0
- package/src/contract/compiler/getFileSystem.ts +42 -0
- package/src/contract/delegation-signature.ts +56 -0
- package/src/contract/ga.ts +61 -37
- package/src/index-browser.ts +50 -0
- package/src/index.ts +4 -56
- package/src/oracle.ts +47 -57
- package/src/spend.ts +34 -68
- package/src/tx/builder/SchemaTypes.ts +79 -0
- package/src/tx/builder/constants.ts +34 -3
- package/src/tx/builder/field-types/abi-version.ts +44 -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 +8 -5
- package/src/tx/builder/field-types/ct-version.ts +83 -0
- package/src/tx/builder/field-types/deposit.ts +4 -2
- package/src/tx/builder/field-types/encoded.ts +27 -0
- package/src/tx/builder/field-types/entry.ts +36 -0
- package/src/tx/builder/field-types/enumeration.ts +15 -4
- package/src/tx/builder/field-types/fee.ts +41 -19
- package/src/tx/builder/field-types/gas-limit.ts +13 -8
- package/src/tx/builder/field-types/index.ts +60 -17
- package/src/tx/builder/field-types/map.ts +45 -0
- package/src/tx/builder/field-types/mptree.ts +243 -0
- package/src/tx/builder/field-types/name-fee.ts +3 -3
- package/src/tx/builder/field-types/name-id.ts +1 -1
- package/src/tx/builder/field-types/nonce.ts +40 -0
- 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 +30 -0
- package/src/tx/builder/field-types/string.ts +11 -0
- package/src/tx/builder/field-types/ttl.ts +24 -0
- package/src/tx/builder/field-types/u-int.ts +1 -3
- package/src/tx/builder/field-types/wrapped.ts +32 -0
- package/src/tx/builder/index.ts +82 -280
- package/src/tx/builder/schema.generated.ts +2013 -0
- package/src/tx/builder/schema.ts +536 -666
- package/src/tx/execution-cost.ts +146 -0
- package/src/tx/transaction-signer.ts +27 -0
- package/src/tx/validator.ts +100 -154
- package/src/utils/amount-formatter.ts +0 -16
- package/src/utils/autorest.ts +52 -11
- package/src/utils/bytes.ts +1 -17
- package/src/utils/crypto.ts +0 -16
- package/src/utils/errors.ts +18 -56
- package/src/utils/string.ts +0 -17
- package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +12 -14
- package/types-legacy/ts4.2/Node.d.ts +8 -4
- package/types-legacy/ts4.2/account/Base.d.ts +13 -8
- package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
- package/types-legacy/ts4.2/aens.d.ts +12 -14
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
- package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
- package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.2/chain.d.ts +17 -9
- package/types-legacy/ts4.2/channel/Base.d.ts +27 -9
- package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.2/channel/Spend.d.ts +5 -1
- package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.2/contract/Contract.d.ts +42 -122
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +74 -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/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +27 -10
- package/types-legacy/ts4.2/index-browser.d.ts +40 -0
- package/types-legacy/ts4.2/index.d.ts +4 -38
- package/types-legacy/ts4.2/oracle.d.ts +12 -17
- package/types-legacy/ts4.2/spend.d.ts +19 -27
- package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +31 -2
- package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +19 -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 +4 -5
- package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +72 -0
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +3 -2
- 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 +12 -7
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +7 -3
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +113 -30
- package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
- package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +48 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +2 -3
- package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
- 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 +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +21 -36
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2971 -2926
- package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
- package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
- package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
- package/types-legacy/ts4.2/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.2/utils/errors.d.ts +16 -38
- package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +12 -14
- package/types-legacy/ts4.5/Node.d.ts +8 -4
- package/types-legacy/ts4.5/account/Base.d.ts +13 -8
- package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
- package/types-legacy/ts4.5/aens.d.ts +12 -14
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
- package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
- package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.5/chain.d.ts +17 -9
- package/types-legacy/ts4.5/channel/Base.d.ts +27 -9
- package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.5/channel/Spend.d.ts +5 -1
- package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.5/contract/Contract.d.ts +42 -122
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +74 -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/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +27 -10
- package/types-legacy/ts4.5/index-browser.d.ts +40 -0
- package/types-legacy/ts4.5/index.d.ts +4 -38
- package/types-legacy/ts4.5/oracle.d.ts +12 -17
- package/types-legacy/ts4.5/spend.d.ts +19 -27
- package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +31 -2
- package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +19 -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 +4 -5
- package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +72 -0
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +3 -2
- 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 +12 -7
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +7 -3
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +113 -30
- package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
- package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +48 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +2 -3
- package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
- 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 +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +21 -36
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2971 -2926
- package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
- package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
- package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
- package/types-legacy/ts4.5/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.5/utils/errors.d.ts +16 -38
- package/es/contract/CompilerHttp.d.ts +0 -18
- package/es/contract/CompilerHttp.mjs +0 -63
- 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/tx/index.d.ts +0 -34
- package/es/tx/index.mjs +0 -172
- package/es/tx/index.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/apis/compiler/code-model-v4.yaml +0 -2442
- package/src/apis/node/code-model-v4.yaml +0 -10080
- package/src/contract/CompilerHttp.ts +0 -67
- package/src/tx/builder/field-types/addresses.ts +0 -18
- package/src/tx/index.ts +0 -196
- 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/tx/index.d.ts +0 -34
- 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/tx/index.d.ts +0 -34
- package/types-legacy/ts4.5/utils/mptree.d.ts +0 -32
|
@@ -0,0 +1,266 @@
|
|
|
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
|
+
/**
|
|
48
|
+
* Retrieve value from Merkle Patricia Tree
|
|
49
|
+
* @param _key - The key of the element to retrieve
|
|
50
|
+
* @returns Value associated to the specified key
|
|
51
|
+
*/
|
|
52
|
+
_classPrivateMethodInitSpec(this, _getRaw);
|
|
53
|
+
_classPrivateFieldInitSpec(this, _rootHash, {
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
57
|
+
_classPrivateFieldInitSpec(this, _isComplete, {
|
|
58
|
+
writable: true,
|
|
59
|
+
value: true
|
|
60
|
+
});
|
|
61
|
+
_classPrivateFieldInitSpec(this, _nodes, {
|
|
62
|
+
writable: true,
|
|
63
|
+
value: void 0
|
|
64
|
+
});
|
|
65
|
+
_classPrivateFieldInitSpec(this, _encoding, {
|
|
66
|
+
writable: true,
|
|
67
|
+
value: void 0
|
|
68
|
+
});
|
|
69
|
+
_classPrivateFieldInitSpec(this, _tag, {
|
|
70
|
+
writable: true,
|
|
71
|
+
value: void 0
|
|
72
|
+
});
|
|
73
|
+
_classPrivateFieldInitSpec(this, _unpackTx, {
|
|
74
|
+
writable: true,
|
|
75
|
+
value: void 0
|
|
76
|
+
});
|
|
77
|
+
_classPrivateFieldSet(this, _encoding, encoding);
|
|
78
|
+
_classPrivateFieldSet(this, _tag, tag);
|
|
79
|
+
_classPrivateFieldSet(this, _unpackTx, unpTx);
|
|
80
|
+
_classPrivateFieldSet(this, _rootHash, binary[0].toString('hex'));
|
|
81
|
+
_classPrivateFieldSet(this, _nodes, Object.fromEntries(binary[1].map(node => [node[0].toString('hex'), node[1]])));
|
|
82
|
+
if (_classPrivateFieldGet(this, _nodes)[_classPrivateFieldGet(this, _rootHash)] == null) {
|
|
83
|
+
if (Object.keys(_classPrivateFieldGet(this, _nodes)).length !== 0) {
|
|
84
|
+
throw new MissingNodeInTreeError('Can\'t find a node by root hash');
|
|
85
|
+
}
|
|
86
|
+
_classPrivateFieldSet(this, _isComplete, false);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
Object.entries(_classPrivateFieldGet(this, _nodes)).forEach(_ref => {
|
|
90
|
+
let [key, node] = _ref;
|
|
91
|
+
if (_classStaticPrivateMethodGet(MPTree, MPTree, _nodeHash).call(MPTree, node) !== key) throw new MerkleTreeHashMismatchError();
|
|
92
|
+
const {
|
|
93
|
+
type
|
|
94
|
+
} = _classStaticPrivateMethodGet(MPTree, MPTree, _parseNode).call(MPTree, node);
|
|
95
|
+
switch (type) {
|
|
96
|
+
case NodeType.Branch:
|
|
97
|
+
node.slice(0, 16).filter(n => n.length).forEach(n => {
|
|
98
|
+
// TODO: enable after resolving https://github.com/aeternity/aeternity/issues/4066
|
|
99
|
+
// if (n.length !== 32) {
|
|
100
|
+
// throw new ArgumentError('MPTree branch item length', 32, n.length);
|
|
101
|
+
// }
|
|
102
|
+
if (_classPrivateFieldGet(this, _nodes)[n.toString('hex')] == null) _classPrivateFieldSet(this, _isComplete, false);
|
|
103
|
+
});
|
|
104
|
+
break;
|
|
105
|
+
case NodeType.Extension:
|
|
106
|
+
if (_classPrivateFieldGet(this, _nodes)[node[1].toString('hex')] == null) {
|
|
107
|
+
throw new MissingNodeInTreeError('Can\'t find a node by hash in extension node');
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
case NodeType.Leaf:
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
throw new InternalError(`Unknown MPTree node type: ${type}`);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
isEqual(tree) {
|
|
118
|
+
return _classPrivateFieldGet(this, _rootHash) === _classPrivateFieldGet(tree, _rootHash);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Serialize Merkle Patricia Tree
|
|
122
|
+
* @returns Binary
|
|
123
|
+
*/
|
|
124
|
+
serialize() {
|
|
125
|
+
return [_Buffer.from(_classPrivateFieldGet(this, _rootHash), 'hex'), Object.entries(_classPrivateFieldGet(this, _nodes)).map(_ref2 => {
|
|
126
|
+
let [mptHash, value] = _ref2;
|
|
127
|
+
return [_Buffer.from(mptHash, 'hex'), value];
|
|
128
|
+
})];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Retrieve value from Merkle Patricia Tree
|
|
132
|
+
* @param key - The key of the element to retrieve
|
|
133
|
+
* @returns Value associated to the specified key
|
|
134
|
+
*/
|
|
135
|
+
get(key) {
|
|
136
|
+
const d = _classPrivateMethodGet(this, _getRaw, _getRaw2).call(this, decode(key).toString('hex'));
|
|
137
|
+
if (d == null) return d;
|
|
138
|
+
return _classPrivateFieldGet(this, _unpackTx).call(this, encode(d, Encoding.Transaction), _classPrivateFieldGet(this, _tag));
|
|
139
|
+
}
|
|
140
|
+
toObject() {
|
|
141
|
+
return Object.fromEntries(_classPrivateMethodGet(this, _entriesRaw, _entriesRaw2).call(this) // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066
|
|
142
|
+
.filter(_ref3 => {
|
|
143
|
+
let [k] = _ref3;
|
|
144
|
+
return _classPrivateFieldGet(this, _encoding) !== Encoding.ContractAddress || k.length !== 66;
|
|
145
|
+
}).map(_ref4 => {
|
|
146
|
+
let [k, v] = _ref4;
|
|
147
|
+
return [encode(_Buffer.from(k, 'hex'), _classPrivateFieldGet(this, _encoding)), _classPrivateFieldGet(this, _unpackTx).call(this, encode(v, Encoding.Transaction), _classPrivateFieldGet(this, _tag))];
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function _nodeHash(node) {
|
|
152
|
+
return _Buffer.from(hash(rlpEncode(node))).toString('hex');
|
|
153
|
+
}
|
|
154
|
+
function _parseNode(node) {
|
|
155
|
+
switch (node.length) {
|
|
156
|
+
case 17:
|
|
157
|
+
return {
|
|
158
|
+
type: NodeType.Branch,
|
|
159
|
+
...(node[16].length !== 0 && {
|
|
160
|
+
value: node[16]
|
|
161
|
+
})
|
|
162
|
+
};
|
|
163
|
+
case 2:
|
|
164
|
+
{
|
|
165
|
+
const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise
|
|
166
|
+
if (nibble > 3) throw new UnknownPathNibbleError(nibble);
|
|
167
|
+
const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;
|
|
168
|
+
const slice = [0, 2].includes(nibble) ? 2 : 1;
|
|
169
|
+
return {
|
|
170
|
+
type,
|
|
171
|
+
...(type === NodeType.Leaf && {
|
|
172
|
+
value: node[1]
|
|
173
|
+
}),
|
|
174
|
+
path: node[0].toString('hex').slice(slice)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
default:
|
|
178
|
+
throw new UnknownNodeLengthError(node.length);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function _getRaw2(_key) {
|
|
182
|
+
let searchFrom = _classPrivateFieldGet(this, _rootHash);
|
|
183
|
+
let key = _key;
|
|
184
|
+
while (true) {
|
|
185
|
+
// eslint-disable-line no-constant-condition
|
|
186
|
+
const node = _classPrivateFieldGet(this, _nodes)[searchFrom];
|
|
187
|
+
if (node == null) {
|
|
188
|
+
if (!this.isComplete) return undefined;
|
|
189
|
+
throw new InternalError('Can\'t find node in complete tree');
|
|
190
|
+
}
|
|
191
|
+
const {
|
|
192
|
+
type,
|
|
193
|
+
value,
|
|
194
|
+
path
|
|
195
|
+
} = _classStaticPrivateMethodGet(MPTree, MPTree, _parseNode).call(MPTree, node);
|
|
196
|
+
switch (type) {
|
|
197
|
+
case NodeType.Branch:
|
|
198
|
+
if (key.length === 0) return value;
|
|
199
|
+
searchFrom = node[+`0x${key[0]}`].toString('hex');
|
|
200
|
+
key = key.substring(1);
|
|
201
|
+
break;
|
|
202
|
+
case NodeType.Extension:
|
|
203
|
+
if (key.substring(0, path === null || path === void 0 ? void 0 : path.length) !== path) return undefined;
|
|
204
|
+
searchFrom = node[1].toString('hex');
|
|
205
|
+
key = key.substring(path.length);
|
|
206
|
+
break;
|
|
207
|
+
case NodeType.Leaf:
|
|
208
|
+
if (path !== key) return undefined;
|
|
209
|
+
return value;
|
|
210
|
+
default:
|
|
211
|
+
throw new InternalError(`Unknown MPTree node type: ${type}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function _entriesRaw2() {
|
|
216
|
+
const entries = [];
|
|
217
|
+
const rec = (searchFrom, key) => {
|
|
218
|
+
const node = _classPrivateFieldGet(this, _nodes)[searchFrom];
|
|
219
|
+
if (node == null) {
|
|
220
|
+
if (!this.isComplete) return;
|
|
221
|
+
throw new InternalError('Can\'t find node in complete tree');
|
|
222
|
+
}
|
|
223
|
+
const {
|
|
224
|
+
type,
|
|
225
|
+
value,
|
|
226
|
+
path
|
|
227
|
+
} = _classStaticPrivateMethodGet(MPTree, MPTree, _parseNode).call(MPTree, node);
|
|
228
|
+
switch (type) {
|
|
229
|
+
case NodeType.Branch:
|
|
230
|
+
node.slice(0, 16).map((t, idx) => [t, idx]).filter(_ref6 => {
|
|
231
|
+
let [t] = _ref6;
|
|
232
|
+
return t.length;
|
|
233
|
+
}).forEach(_ref7 => {
|
|
234
|
+
let [t, idx] = _ref7;
|
|
235
|
+
return rec(t.toString('hex'), key + idx.toString(16));
|
|
236
|
+
});
|
|
237
|
+
if (value != null) entries.push([key, value]);
|
|
238
|
+
break;
|
|
239
|
+
case NodeType.Extension:
|
|
240
|
+
rec(node[1].toString('hex'), key + path);
|
|
241
|
+
break;
|
|
242
|
+
case NodeType.Leaf:
|
|
243
|
+
if (value == null) throw new UnexpectedTsError();
|
|
244
|
+
entries.push([key + path, value]);
|
|
245
|
+
break;
|
|
246
|
+
default:
|
|
247
|
+
throw new InternalError(`Unknown MPTree node type: ${type}`);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
rec(_classPrivateFieldGet(this, _rootHash), '');
|
|
251
|
+
return entries;
|
|
252
|
+
}
|
|
253
|
+
export default function genMPTreeField(encoding, tag) {
|
|
254
|
+
return {
|
|
255
|
+
serialize(value) {
|
|
256
|
+
return value.serialize();
|
|
257
|
+
},
|
|
258
|
+
deserialize(value, _ref5) {
|
|
259
|
+
let {
|
|
260
|
+
unpackTx
|
|
261
|
+
} = _ref5;
|
|
262
|
+
return new MPTree(value, encoding, tag, unpackTx);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=mptree.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mptree.mjs","names":["_rlp","encode","rlpEncode","hash","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownPathNibbleError","UnexpectedTsError","UnknownNodeLengthError","InternalError","decode","Encoding","NodeType","_rootHash","WeakMap","_isComplete","_nodes","_encoding","_tag","_unpackTx","_getRaw","WeakSet","_entriesRaw","MPTree","isComplete","_classPrivateFieldGet","constructor","binary","encoding","tag","unpTx","_classPrivateMethodInitSpec","_classPrivateFieldInitSpec","writable","value","_classPrivateFieldSet","toString","Object","fromEntries","map","node","keys","length","entries","forEach","_ref","key","_classStaticPrivateMethodGet","_nodeHash","call","type","_parseNode","Branch","slice","filter","n","Extension","Leaf","isEqual","tree","serialize","_Buffer","from","_ref2","mptHash","get","d","_classPrivateMethodGet","_getRaw2","Transaction","toObject","_entriesRaw2","_ref3","k","ContractAddress","_ref4","v","nibble","includes","path","_key","searchFrom","undefined","substring","rec","t","idx","_ref6","_ref7","push","genMPTreeField","deserialize","_ref5","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 '..';\nimport type { TxUnpacked } from '../schema.generated';\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>): TxUnpacked & { tag: 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.Generic<E>, TxUnpacked & { tag: 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 ])) as Record<Encoded.Generic<E>, TxUnpacked & { tag: T }>;\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,OAAAA,IAAA,MAA2C,KAAK;AAAC;EAAAC,MAAA,EAAAC;AAAA,IAAAF,IAAA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CAAC,EAAEU,GAAG,GAAGwC,GAAG,CAAClD,QAAQ,CAAC,EAAE,CAAC,CAAC;QAAA,EAAC;QACxE,IAAIF,KAAK,IAAI,IAAI,EAAES,OAAO,CAAC8C,IAAI,CAAC,CAAC3C,GAAG,EAAEZ,KAAK,CAAC,CAAC;QAC7C;MACF,KAAKtB,QAAQ,CAAC4C,SAAS;QACrB4B,GAAG,CAAC5C,IAAI,CAAC,CAAC,CAAC,CAACJ,QAAQ,CAAC,KAAK,CAAC,EAAEU,GAAG,GAAGiC,IAAI,CAAC;QACxC;MACF,KAAKnE,QAAQ,CAAC6C,IAAI;QAChB,IAAIvB,KAAK,IAAI,IAAI,EAAE,MAAM,IAAI3B,iBAAiB,EAAE;QAChDoC,OAAO,CAAC8C,IAAI,CAAC,CAAC3C,GAAG,GAAGiC,IAAI,EAAE7C,KAAK,CAAC,CAAC;QACjC;MACF;QACE,MAAM,IAAIzB,aAAa,CAAE,6BAA4ByC,IAAK,EAAC,CAAC;IAAC;EAEnE,CAAC;EACDkC,GAAG,CAAA3D,qBAAA,CAAC,IAAI,EAAAZ,SAAA,GAAY,EAAE,CAAC;EACvB,OAAO8B,OAAO;AAChB;AAaF,eAAe,SAAS+C,cAAcA,CAAoC9D,QAAW,EAAEC,GAAM,EAG3F;EACA,OAAO;IACL+B,SAASA,CAAC1B,KAAK,EAAE;MACf,OAAOA,KAAK,CAAC0B,SAAS,EAAE;IAC1B,CAAC;IAED+B,WAAWA,CAACzD,KAAK,EAAA0D,KAAA,EAAgB;MAAA,IAAd;QAAEC;MAAS,CAAC,GAAAD,KAAA;MAC7B,OAAO,IAAIrE,MAAM,CAACW,KAAK,EAAEN,QAAQ,EAAEC,GAAG,EAAEgE,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;
|
|
@@ -13,7 +12,7 @@ declare const _default: {
|
|
|
13
12
|
*/
|
|
14
13
|
serialize(value: Int | undefined, txFields: {
|
|
15
14
|
name: AensName;
|
|
16
|
-
} & Parameters<(typeof coinAmount)['serialize']>[1]): Buffer;
|
|
15
|
+
} & Parameters<(typeof coinAmount)['serialize']>[1], parameters: Parameters<(typeof coinAmount)['serialize']>[2]): Buffer;
|
|
17
16
|
deserialize(value: Buffer): string;
|
|
18
17
|
};
|
|
19
18
|
export default _default;
|
|
@@ -15,8 +15,8 @@ export default {
|
|
|
15
15
|
* @param txFields - Transaction fields
|
|
16
16
|
* @param txFields.name - AENS Name in transaction
|
|
17
17
|
*/
|
|
18
|
-
serialize(value, txFields) {
|
|
19
|
-
return coinAmount.serialize.call(this, value, txFields);
|
|
18
|
+
serialize(value, txFields, parameters) {
|
|
19
|
+
return coinAmount.serialize.call(this, value, txFields, parameters);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
//# sourceMappingURL=name-fee.mjs.map
|
|
@@ -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","parameters","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 parameters: Parameters<typeof coinAmount['serialize']>[2],\n ): Buffer {\n return coinAmount.serialize.call(this, value, txFields, parameters);\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,iBAAiB;AAAA,SACjBC,wBAAwB;AAAA,OAC1BC,UAAU;AAGjB,eAAe;EACb,GAAGA,UAAU;EAEbC,eAAeA,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,SAASA,CACPH,KAAsB,EACtBH,QAA4E,EAC5EO,UAAyD,EACjD;IACR,OAAOV,UAAU,CAACS,SAAS,CAACE,IAAI,CAAC,IAAI,EAAEL,KAAK,EAAEH,QAAQ,EAAEO,UAAU,CAAC;EACrE;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,SAASA,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.mjs","names":["field","serialize","value","deserialize"],"sources":["../../../../src/tx/builder/field-types/name.ts"],"sourcesContent":["import field from './field';\nimport { AensName } from '../constants';\n\nexport default {\n /**\n * @param value - AENS name\n */\n serialize(value: AensName): Buffer {\n return field.serialize(value);\n },\n\n /**\n * @param value - AENS name\n */\n deserialize(value: Buffer): AensName {\n return field.deserialize(value) as AensName;\n },\n};\n"],"mappings":"OAAOA,KAAK;AAGZ,eAAe;EACb;AACF;AACA;EACEC,
|
|
1
|
+
{"version":3,"file":"name.mjs","names":["field","serialize","value","deserialize"],"sources":["../../../../src/tx/builder/field-types/name.ts"],"sourcesContent":["import field from './field';\nimport { AensName } from '../constants';\n\nexport default {\n /**\n * @param value - AENS name\n */\n serialize(value: AensName): Buffer {\n return field.serialize(value);\n },\n\n /**\n * @param value - AENS name\n */\n deserialize(value: Buffer): AensName {\n return field.deserialize(value) as AensName;\n },\n};\n"],"mappings":"OAAOA,KAAK;AAGZ,eAAe;EACb;AACF;AACA;EACEC,SAASA,CAACC,KAAe,EAAU;IACjC,OAAOF,KAAK,CAACC,SAAS,CAACC,KAAK,CAAC;EAC/B,CAAC;EAED;AACF;AACA;EACEC,WAAWA,CAACD,KAAa,EAAY;IACnC,OAAOF,KAAK,CAACG,WAAW,CAACD,KAAK,CAAC;EACjC;AACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import Node from '../../../Node';
|
|
3
|
+
import { NextNonceStrategy } from '../../../apis/node';
|
|
4
|
+
export default function genNonceField<SenderKey extends string>(senderKey: SenderKey): {
|
|
5
|
+
serialize: (value: number) => Buffer;
|
|
6
|
+
prepare: (value: number | undefined, params: {}, options: {
|
|
7
|
+
[key in SenderKey]: string;
|
|
8
|
+
} & {
|
|
9
|
+
strategy?: NextNonceStrategy;
|
|
10
|
+
onNode?: Node;
|
|
11
|
+
}) => Promise<number>;
|
|
12
|
+
deserialize: (value: Buffer) => number;
|
|
13
|
+
senderKey: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isAccountNotFoundError } from "../../../utils/other.mjs";
|
|
2
|
+
import shortUInt from "./short-u-int.mjs";
|
|
3
|
+
import { ArgumentError } from "../../../utils/errors.mjs";
|
|
4
|
+
export default function genNonceField(senderKey) {
|
|
5
|
+
return {
|
|
6
|
+
...shortUInt,
|
|
7
|
+
async prepare(value, params, options) {
|
|
8
|
+
if (value != null) return value;
|
|
9
|
+
const {
|
|
10
|
+
onNode,
|
|
11
|
+
strategy
|
|
12
|
+
} = options;
|
|
13
|
+
const senderId = options[senderKey];
|
|
14
|
+
const requirement = 'provided (or provide `nonce` instead)';
|
|
15
|
+
if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);
|
|
16
|
+
if (senderId == null) throw new ArgumentError('senderId', requirement, senderId);
|
|
17
|
+
return (await onNode.getAccountNextNonce(senderId.replace(/^ok_/, 'ak_'), {
|
|
18
|
+
strategy
|
|
19
|
+
}).catch(error => {
|
|
20
|
+
if (!isAccountNotFoundError(error)) throw error;
|
|
21
|
+
return {
|
|
22
|
+
nextNonce: 1
|
|
23
|
+
};
|
|
24
|
+
})).nextNonce;
|
|
25
|
+
},
|
|
26
|
+
senderKey
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=nonce.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonce.mjs","names":["isAccountNotFoundError","shortUInt","ArgumentError","genNonceField","senderKey","prepare","value","params","options","onNode","strategy","senderId","requirement","getAccountNextNonce","replace","catch","error","nextNonce"],"sources":["../../../../src/tx/builder/field-types/nonce.ts"],"sourcesContent":["import { isAccountNotFoundError } from '../../../utils/other';\nimport shortUInt from './short-u-int';\nimport Node from '../../../Node';\nimport { ArgumentError } from '../../../utils/errors';\nimport { NextNonceStrategy } from '../../../apis/node';\n\nexport default function genNonceField<SenderKey extends string>(senderKey: SenderKey): {\n serialize: (value: number) => Buffer;\n // TODO: (value: number) => Promise<number> | (value: undefined, ...) => Promise<number>\n prepare: (\n value: number | undefined,\n params: {},\n // TODO: replace `string` with AddressEncodings\n options: { [key in SenderKey]: string } & { strategy?: NextNonceStrategy; onNode?: Node },\n ) => Promise<number>;\n deserialize: (value: Buffer) => number;\n senderKey: string;\n} {\n return {\n ...shortUInt,\n\n async prepare(value, params, options) {\n if (value != null) return value;\n const { onNode, strategy } = options;\n const senderId = options[senderKey];\n const requirement = 'provided (or provide `nonce` instead)';\n if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);\n if (senderId == null) throw new ArgumentError('senderId', requirement, senderId);\n return (\n await onNode.getAccountNextNonce(senderId.replace(/^ok_/, 'ak_'), { strategy })\n .catch((error) => {\n if (!isAccountNotFoundError(error)) throw error;\n return { nextNonce: 1 };\n })\n ).nextNonce;\n },\n\n senderKey,\n };\n}\n"],"mappings":"SAASA,sBAAsB;AAAA,OACxBC,SAAS;AAAA,SAEPC,aAAa;AAGtB,eAAe,SAASC,aAAaA,CAA2BC,SAAoB,EAWlF;EACA,OAAO;IACL,GAAGH,SAAS;IAEZ,MAAMI,OAAOA,CAACC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAE;MACpC,IAAIF,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;MAC/B,MAAM;QAAEG,MAAM;QAAEC;MAAS,CAAC,GAAGF,OAAO;MACpC,MAAMG,QAAQ,GAAGH,OAAO,CAACJ,SAAS,CAAC;MACnC,MAAMQ,WAAW,GAAG,uCAAuC;MAC3D,IAAIH,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIP,aAAa,CAAC,QAAQ,EAAEU,WAAW,EAAEH,MAAM,CAAC;MAC1E,IAAIE,QAAQ,IAAI,IAAI,EAAE,MAAM,IAAIT,aAAa,CAAC,UAAU,EAAEU,WAAW,EAAED,QAAQ,CAAC;MAChF,OAAO,CACL,MAAMF,MAAM,CAACI,mBAAmB,CAACF,QAAQ,CAACG,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;QAAEJ;MAAS,CAAC,CAAC,CAC5EK,KAAK,CAAEC,KAAK,IAAK;QAChB,IAAI,CAAChB,sBAAsB,CAACgB,KAAK,CAAC,EAAE,MAAMA,KAAK;QAC/C,OAAO;UAAEC,SAAS,EAAE;QAAE,CAAC;MACzB,CAAC,CAAC,EACJA,SAAS;IACb,CAAC;IAEDb;EACF,CAAC;AACH"}
|
|
@@ -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","_ref","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,SAASA,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,WAAWA,CAACN,QAA0C,EAAiB;IACrE,OAAOA,QAAQ,CAACE,GAAG,CACjBK,IAAA;MAAA,IAAC,CAACH,GAAG,EAAEC,EAAE,CAAC,GAAAE,IAAA;MAAA,OAAM;QAAEH,GAAG,EAAEA,GAAG,CAACI,QAAQ,EAAE;QAAEH,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","_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,SAASA,CAACC,MAAkB,EAAU;IACpC,OAAOC,OAAA,CAAOC,IAAI,CAACF,MAAM,CAAC;EAC5B,CAAC;EAEDG,WAAWA,CAACH,MAAc,EAAU;IAClC,OAAOA,MAAM;EACf;AACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export default function genShortUIntConstField<Value extends number, Optional extends boolean = false>(constValue: Value, optional?: Optional): {
|
|
3
|
+
serialize: Optional extends true ? (value?: Value) => Buffer : (value: Value) => Buffer;
|
|
4
|
+
deserialize: (value: Buffer) => Value;
|
|
5
|
+
constValue: Value;
|
|
6
|
+
constValueOptional: boolean;
|
|
7
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ArgumentError } from "../../../utils/errors.mjs";
|
|
2
|
+
import shortUInt from "./short-u-int.mjs";
|
|
3
|
+
export default function genShortUIntConstField(constValue, optional) {
|
|
4
|
+
return {
|
|
5
|
+
serialize(value) {
|
|
6
|
+
if ((optional !== true || value != null) && value !== constValue) {
|
|
7
|
+
throw new ArgumentError('ShortUIntConst', constValue, value);
|
|
8
|
+
}
|
|
9
|
+
return shortUInt.serialize(constValue);
|
|
10
|
+
},
|
|
11
|
+
deserialize(buf) {
|
|
12
|
+
const value = shortUInt.deserialize(buf);
|
|
13
|
+
if (value !== constValue) throw new ArgumentError('ShortUIntConst', constValue, value);
|
|
14
|
+
return constValue;
|
|
15
|
+
},
|
|
16
|
+
constValue,
|
|
17
|
+
constValueOptional: optional === true
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=short-u-int-const.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"short-u-int-const.mjs","names":["ArgumentError","shortUInt","genShortUIntConstField","constValue","optional","serialize","value","deserialize","buf","constValueOptional"],"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<\n Value extends number, Optional extends boolean = false,\n>(constValue: Value, optional?: Optional): {\n serialize: Optional extends true ? (value?: Value) => Buffer : (value: Value) => Buffer;\n deserialize: (value: Buffer) => Value;\n constValue: Value;\n constValueOptional: boolean;\n} {\n return {\n serialize(value?: Value) {\n if ((optional !== true || value != null) && value !== constValue) {\n throw new ArgumentError('ShortUIntConst', constValue, value);\n }\n return shortUInt.serialize(constValue);\n },\n\n deserialize(buf) {\n const value = shortUInt.deserialize(buf);\n if (value !== constValue) throw new ArgumentError('ShortUIntConst', constValue, value);\n return constValue;\n },\n\n constValue,\n\n constValueOptional: optional === true,\n };\n}\n"],"mappings":"SAASA,aAAa;AAAA,OACfC,SAAS;AAEhB,eAAe,SAASC,sBAAsBA,CAE5CC,UAAiB,EAAEC,QAAmB,EAKtC;EACA,OAAO;IACLC,SAASA,CAACC,KAAa,EAAE;MACvB,IAAI,CAACF,QAAQ,KAAK,IAAI,IAAIE,KAAK,IAAI,IAAI,KAAKA,KAAK,KAAKH,UAAU,EAAE;QAChE,MAAM,IAAIH,aAAa,CAAC,gBAAgB,EAAEG,UAAU,EAAEG,KAAK,CAAC;MAC9D;MACA,OAAOL,SAAS,CAACI,SAAS,CAACF,UAAU,CAAC;IACxC,CAAC;IAEDI,WAAWA,CAACC,GAAG,EAAE;MACf,MAAMF,KAAK,GAAGL,SAAS,CAACM,WAAW,CAACC,GAAG,CAAC;MACxC,IAAIF,KAAK,KAAKH,UAAU,EAAE,MAAM,IAAIH,aAAa,CAAC,gBAAgB,EAAEG,UAAU,EAAEG,KAAK,CAAC;MACtF,OAAOH,UAAU;IACnB,CAAC;IAEDA,UAAU;IAEVM,kBAAkB,EAAEL,QAAQ,KAAK;EACnC,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"short-u-int.mjs","names":["uInt","serialize","value","deserialize"],"sources":["../../../../src/tx/builder/field-types/short-u-int.ts"],"sourcesContent":["import uInt from './u-int';\n\nexport default {\n serialize(value: number): Buffer {\n return uInt.serialize(value);\n },\n\n deserialize(value: Buffer): number {\n return +uInt.deserialize(value);\n },\n};\n"],"mappings":"OAAOA,IAAI;AAEX,eAAe;EACbC,
|
|
1
|
+
{"version":3,"file":"short-u-int.mjs","names":["uInt","serialize","value","deserialize"],"sources":["../../../../src/tx/builder/field-types/short-u-int.ts"],"sourcesContent":["import uInt from './u-int';\n\nexport default {\n serialize(value: number): Buffer {\n return uInt.serialize(value);\n },\n\n deserialize(value: Buffer): number {\n return +uInt.deserialize(value);\n },\n};\n"],"mappings":"OAAOA,IAAI;AAEX,eAAe;EACbC,SAASA,CAACC,KAAa,EAAU;IAC/B,OAAOF,IAAI,CAACC,SAAS,CAACC,KAAK,CAAC;EAC9B,CAAC;EAEDC,WAAWA,CAACD,KAAa,EAAU;IACjC,OAAO,CAACF,IAAI,CAACG,WAAW,CAACD,KAAK,CAAC;EACjC;AACF,CAAC"}
|
|
@@ -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,SAASA,CAACC,MAAc,EAAU;IAChC,OAAOF,OAAO,CAACE,MAAM,CAAC;EACxB,CAAC;EAEDC,WAAWA,CAACC,MAAc,EAAU;IAClC,OAAOA,MAAM,CAACC,QAAQ,EAAE;EAC1B;AACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import Node from '../../../Node';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
serialize(value: number | undefined): Buffer;
|
|
5
|
+
prepare(value: number | undefined, params: {}, { onNode, absoluteTtl }: {
|
|
6
|
+
onNode?: Node | undefined;
|
|
7
|
+
absoluteTtl?: boolean | undefined;
|
|
8
|
+
}): Promise<number | undefined>;
|
|
9
|
+
deserialize(value: Buffer): number;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import shortUInt from "./short-u-int.mjs";
|
|
2
|
+
import { ArgumentError } from "../../../utils/errors.mjs";
|
|
3
|
+
export default {
|
|
4
|
+
...shortUInt,
|
|
5
|
+
serialize(value) {
|
|
6
|
+
return shortUInt.serialize(value !== null && value !== void 0 ? value : 0);
|
|
7
|
+
},
|
|
8
|
+
async prepare(value, params, // TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }
|
|
9
|
+
_ref) {
|
|
10
|
+
let {
|
|
11
|
+
onNode,
|
|
12
|
+
absoluteTtl
|
|
13
|
+
} = _ref;
|
|
14
|
+
if (absoluteTtl !== true && value !== 0 && value != null) {
|
|
15
|
+
if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);
|
|
16
|
+
value += (await onNode.getCurrentKeyBlock()).height;
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=ttl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ttl.mjs","names":["shortUInt","ArgumentError","serialize","value","prepare","params","_ref","onNode","absoluteTtl","getCurrentKeyBlock","height"],"sources":["../../../../src/tx/builder/field-types/ttl.ts"],"sourcesContent":["import shortUInt from './short-u-int';\nimport Node from '../../../Node';\nimport { ArgumentError } from '../../../utils/errors';\n\nexport default {\n ...shortUInt,\n\n serialize(value: number | undefined): Buffer {\n return shortUInt.serialize(value ?? 0);\n },\n\n async prepare(\n value: number | undefined,\n params: {},\n // TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }\n { onNode, absoluteTtl }: { onNode?: Node; absoluteTtl?: boolean },\n ) {\n if (absoluteTtl !== true && value !== 0 && value != null) {\n if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);\n value += (await onNode.getCurrentKeyBlock()).height;\n }\n return value;\n },\n};\n"],"mappings":"OAAOA,SAAS;AAAA,SAEPC,aAAa;AAEtB,eAAe;EACb,GAAGD,SAAS;EAEZE,SAASA,CAACC,KAAyB,EAAU;IAC3C,OAAOH,SAAS,CAACE,SAAS,CAACC,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,CAAC,CAAC;EACxC,CAAC;EAED,MAAMC,OAAOA,CACXD,KAAyB,EACzBE,MAAU,EACV;EAAAC,IAAA,EAEA;IAAA,IADA;MAAEC,MAAM;MAAEC;IAAsD,CAAC,GAAAF,IAAA;IAEjE,IAAIE,WAAW,KAAK,IAAI,IAAIL,KAAK,KAAK,CAAC,IAAIA,KAAK,IAAI,IAAI,EAAE;MACxD,IAAII,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIN,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAEM,MAAM,CAAC;MACzEJ,KAAK,IAAI,CAAC,MAAMI,MAAM,CAACE,kBAAkB,EAAE,EAAEC,MAAM;IACrD;IACA,OAAOP,KAAK;EACd;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,SAASA,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,WAAWA,CAACD,KAAa,EAAU;IACjC,OAAOJ,OAAO,CAACI,KAAK,CAAC;EACvB;AACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Tag } from '../constants';
|
|
3
|
+
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
4
|
+
type TagWrapping = Tag.AccountsMtree | Tag.CallsMtree | Tag.ChannelsMtree | Tag.ContractsMtree | Tag.NameserviceMtree | Tag.OraclesMtree;
|
|
5
|
+
export default function genWrappedField<T extends TagWrapping>(tag: T): {
|
|
6
|
+
serialize: (value: any, options: {
|
|
7
|
+
buildTx: typeof buildTxType;
|
|
8
|
+
}) => Buffer;
|
|
9
|
+
deserialize: (value: Buffer, options: {
|
|
10
|
+
unpackTx: typeof unpackTxType;
|
|
11
|
+
}) => any;
|
|
12
|
+
recursiveType: true;
|
|
13
|
+
};
|
|
14
|
+
export {};
|