@aeternity/aepp-sdk 12.1.3 → 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 +12031 -11231
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +7 -3
- package/es/AeSdk.mjs +17 -22
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +6 -5
- package/es/AeSdkAepp.mjs +7 -30
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +18 -140
- package/es/AeSdkBase.mjs +30 -184
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +123 -0
- package/es/AeSdkMethods.mjs +122 -0
- package/es/AeSdkMethods.mjs.map +1 -0
- package/es/AeSdkWallet.d.ts +7 -21
- package/es/AeSdkWallet.mjs +38 -86
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +11 -15
- package/es/Node.mjs +35 -48
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +24 -40
- package/es/account/Base.mjs +1 -101
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.d.ts +16 -0
- package/es/account/Generalized.mjs +113 -0
- package/es/account/Generalized.mjs.map +1 -0
- package/es/account/Ledger.d.ts +28 -0
- package/es/account/Ledger.mjs +102 -0
- package/es/account/Ledger.mjs.map +1 -0
- package/es/account/LedgerFactory.d.ts +39 -0
- package/es/account/LedgerFactory.mjs +81 -0
- package/es/account/LedgerFactory.mjs.map +1 -0
- package/es/account/Memory.d.ts +13 -17
- package/es/account/Memory.mjs +43 -64
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +6 -8
- package/es/account/Rpc.mjs +14 -32
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +4 -4
- package/es/aens.mjs +46 -41
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
- 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 +22 -11
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -42
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.mjs +14 -68
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.d.ts +23 -29
- package/es/apis/compiler/compiler.mjs +128 -189
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/index.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +82 -135
- package/es/apis/compiler/models/index.mjs +1 -47
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.d.ts +8 -8
- package/es/apis/compiler/models/mappers.mjs +165 -183
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/compiler/models/parameters.d.ts +0 -1
- package/es/apis/compiler/models/parameters.mjs +5 -9
- package/es/apis/compiler/models/parameters.mjs.map +1 -1
- package/es/apis/node/index.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +48 -48
- package/es/apis/node/models/mappers.mjs +12 -6
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/parameters.mjs.map +1 -1
- package/es/apis/node/node.mjs +43 -84
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +10 -2
- package/es/chain.mjs +37 -59
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +200 -0
- package/es/channel/Base.mjs +293 -0
- package/es/channel/Base.mjs.map +1 -0
- package/es/channel/Contract.d.ts +248 -0
- package/es/channel/Contract.mjs +420 -0
- package/es/channel/Contract.mjs.map +1 -0
- package/es/channel/Spend.d.ts +219 -0
- package/es/channel/Spend.mjs +385 -0
- package/es/channel/Spend.mjs.map +1 -0
- package/es/channel/handlers.d.ts +8 -21
- package/es/channel/handlers.mjs +151 -899
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +27 -21
- package/es/channel/internal.mjs +101 -191
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +210 -0
- package/es/contract/Contract.mjs +551 -0
- package/es/contract/Contract.mjs.map +1 -0
- 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/compiler/Http.mjs +118 -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/ga.d.ts +9 -34
- package/es/contract/ga.mjs +29 -112
- 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 -35
- package/es/index.mjs +4 -51
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +5 -5
- package/es/oracle.mjs +34 -40
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +3 -3
- package/es/spend.mjs +18 -23
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/constants.d.ts +30 -2
- package/es/tx/builder/constants.mjs +43 -14
- 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 +14 -0
- package/es/tx/builder/field-types/address.mjs +51 -0
- package/es/tx/builder/field-types/address.mjs.map +1 -0
- 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 +2 -3
- package/es/tx/builder/field-types/coin-amount.mjs +4 -12
- 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 -2
- package/es/tx/builder/field-types/deposit.mjs +2 -4
- 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 +7 -0
- package/es/tx/builder/field-types/enumeration.mjs +30 -0
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +10 -15
- package/es/tx/builder/field-types/fee.mjs +31 -43
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/field.mjs +0 -2
- package/es/tx/builder/field-types/field.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 +12 -14
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +1 -2
- package/es/tx/builder/field-types/gas-price.mjs +3 -7
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +80 -30
- package/es/tx/builder/field-types/index.mjs +34 -9
- 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 -3
- package/es/tx/builder/field-types/name-fee.mjs +3 -5
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/name-id.d.ts +1 -4
- package/es/tx/builder/field-types/name-id.mjs +5 -10
- package/es/tx/builder/field-types/name-id.mjs.map +1 -1
- package/es/tx/builder/field-types/name.mjs +0 -2
- package/es/tx/builder/field-types/name.mjs.map +1 -1
- package/es/tx/builder/field-types/pointers.d.ts +23 -0
- package/es/tx/builder/field-types/pointers.mjs +36 -0
- package/es/tx/builder/field-types/pointers.mjs.map +1 -0
- 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/short-u-int.mjs +0 -2
- 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/u-int.d.ts +1 -2
- package/es/tx/builder/field-types/u-int.mjs +3 -4
- package/es/tx/builder/field-types/u-int.mjs.map +1 -1
- package/es/tx/builder/helpers.d.ts +2 -32
- package/es/tx/builder/helpers.mjs +19 -71
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +11 -49
- package/es/tx/builder/index.mjs +57 -337
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2367 -667
- package/es/tx/builder/schema.mjs +70 -145
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +4 -49
- package/es/tx/index.mjs +38 -112
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +4 -6
- package/es/tx/validator.mjs +104 -90
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
- package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
- package/es/utils/amount-formatter.mjs +4 -10
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +1 -0
- package/es/utils/autorest.mjs +17 -19
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bignumber.mjs +4 -7
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/utils/bytes.d.ts +0 -17
- package/es/utils/bytes.mjs +6 -35
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +15 -8
- package/es/utils/crypto.mjs +40 -40
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.d.ts +28 -28
- package/es/utils/encoder-types.mjs +0 -1
- package/es/utils/encoder-types.mjs.map +1 -1
- package/es/utils/encoder.d.ts +0 -1
- package/es/utils/encoder.mjs +7 -15
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +15 -14
- package/es/utils/errors.mjs +86 -172
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +27 -19
- package/es/utils/hd-wallet.mjs +42 -26
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs +0 -8
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.d.ts +2 -0
- package/es/utils/keystore.mjs +37 -36
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/other.d.ts +4 -2
- package/es/utils/other.mjs +11 -7
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.mjs +0 -3
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.d.ts +0 -12
- package/es/utils/string.mjs +1 -21
- package/es/utils/string.mjs.map +1 -1
- package/package.json +98 -51
- package/src/AeSdk.ts +15 -11
- package/src/AeSdkAepp.ts +9 -7
- package/src/AeSdkBase.ts +31 -202
- package/src/AeSdkMethods.ts +169 -0
- package/src/AeSdkWallet.ts +16 -47
- package/src/Node.ts +17 -18
- package/src/account/Base.ts +29 -75
- package/src/account/Generalized.ts +98 -0
- package/src/account/Ledger.ts +131 -0
- package/src/account/LedgerFactory.ts +86 -0
- package/src/account/Memory.ts +46 -60
- package/src/account/Rpc.ts +17 -26
- package/src/aens.ts +13 -11
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +21 -9
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -4
- package/src/aepp-wallet-communication/rpc/types.ts +11 -1
- package/src/aepp-wallet-communication/schema.ts +18 -18
- package/src/apis/compiler/code-model-v4.yaml +681 -888
- package/src/apis/compiler/compiler.ts +113 -154
- package/src/apis/compiler/models/index.ts +80 -140
- package/src/apis/compiler/models/mappers.ts +165 -183
- package/src/apis/compiler/models/parameters.ts +6 -12
- package/src/chain.ts +11 -6
- package/src/channel/Base.ts +335 -0
- package/src/channel/Contract.ts +488 -0
- package/src/channel/Spend.ts +408 -0
- package/src/channel/handlers.ts +164 -582
- package/src/channel/internal.ts +114 -143
- package/src/contract/Contract.ts +610 -0
- 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 +23 -106
- package/src/index-browser.ts +58 -0
- package/src/index.ts +4 -55
- package/src/oracle.ts +8 -8
- package/src/spend.ts +6 -14
- package/src/tx/builder/constants.ts +33 -3
- package/src/tx/builder/field-types/abi-version.ts +21 -0
- package/src/tx/builder/field-types/address.ts +62 -0
- 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 +4 -9
- 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 +32 -0
- package/src/tx/builder/field-types/fee.ts +39 -21
- package/src/tx/builder/field-types/gas-limit.ts +13 -8
- package/src/tx/builder/field-types/gas-price.ts +0 -2
- package/src/tx/builder/field-types/index.ts +54 -15
- package/src/tx/builder/field-types/mptree.ts +242 -0
- package/src/tx/builder/field-types/name-fee.ts +2 -3
- package/src/tx/builder/field-types/name-id.ts +7 -10
- package/src/tx/builder/field-types/pointers.ts +41 -0
- 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 +4 -5
- package/src/tx/builder/helpers.ts +10 -60
- package/src/tx/builder/index.ts +65 -308
- package/src/tx/builder/schema.ts +280 -341
- package/src/tx/index.ts +40 -103
- package/src/tx/validator.ts +91 -96
- package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
- package/src/utils/autorest.ts +16 -1
- package/src/utils/bytes.ts +6 -34
- package/src/utils/crypto.ts +23 -16
- package/src/utils/encoder.ts +0 -1
- package/src/utils/errors.ts +22 -25
- package/src/utils/hd-wallet.ts +30 -9
- package/src/utils/keystore.ts +24 -21
- package/src/utils/other.ts +16 -1
- package/src/utils/string.ts +0 -20
- package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
- package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
- package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +140 -0
- package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
- package/types-legacy/ts4.2/Node.d.ts +78 -0
- package/types-legacy/ts4.2/account/Base.d.ts +52 -0
- package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
- package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
- package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
- package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
- package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
- package/types-legacy/ts4.2/aens.d.ts +222 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
- package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
- package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
- package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
- package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
- package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
- package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
- package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
- package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
- package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
- package/types-legacy/ts4.2/chain.d.ts +256 -0
- package/types-legacy/ts4.2/channel/Base.d.ts +199 -0
- package/types-legacy/ts4.2/channel/Contract.d.ts +248 -0
- package/types-legacy/ts4.2/channel/Spend.d.ts +219 -0
- package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
- package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
- package/types-legacy/ts4.2/contract/Contract.d.ts +212 -0
- 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 +44 -0
- package/types-legacy/ts4.2/globals.d.ts +16 -0
- package/types-legacy/ts4.2/index-browser.d.ts +39 -0
- package/types-legacy/ts4.2/index.d.ts +5 -0
- package/types-legacy/ts4.2/oracle.d.ts +161 -0
- package/types-legacy/ts4.2/spend.d.ts +62 -0
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +98 -0
- 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 +21 -0
- 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 +12 -0
- 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 +14 -0
- 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 +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +20 -0
- package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +15 -0
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +129 -0
- 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 +18 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
- package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -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 +5 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -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 +7 -0
- package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +50 -0
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +4675 -0
- package/types-legacy/ts4.2/tx/index.d.ts +19 -0
- package/types-legacy/ts4.2/tx/validator.d.ts +18 -0
- package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
- package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
- package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
- package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
- package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
- package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
- package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
- package/types-legacy/ts4.2/utils/errors.d.ts +475 -0
- package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
- package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
- package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
- package/types-legacy/ts4.2/utils/other.d.ts +31 -0
- package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
- package/types-legacy/ts4.2/utils/string.d.ts +12 -0
- package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
- package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
- package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +140 -0
- package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
- package/types-legacy/ts4.5/Node.d.ts +78 -0
- package/types-legacy/ts4.5/account/Base.d.ts +52 -0
- package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
- package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
- package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
- package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
- package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
- package/types-legacy/ts4.5/aens.d.ts +222 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
- package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
- package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
- package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
- package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
- package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
- package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
- package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
- package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
- package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
- package/types-legacy/ts4.5/chain.d.ts +256 -0
- package/types-legacy/ts4.5/channel/Base.d.ts +199 -0
- package/types-legacy/ts4.5/channel/Contract.d.ts +248 -0
- package/types-legacy/ts4.5/channel/Spend.d.ts +219 -0
- package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
- package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
- package/types-legacy/ts4.5/contract/Contract.d.ts +212 -0
- 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 +44 -0
- package/types-legacy/ts4.5/index-browser.d.ts +39 -0
- package/types-legacy/ts4.5/index.d.ts +4 -0
- package/types-legacy/ts4.5/oracle.d.ts +161 -0
- package/types-legacy/ts4.5/spend.d.ts +62 -0
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +98 -0
- 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 +21 -0
- 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 +12 -0
- 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 +14 -0
- 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 +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +20 -0
- package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +15 -0
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +129 -0
- 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 +18 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
- package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -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 +5 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -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 +7 -0
- package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +50 -0
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +4675 -0
- package/types-legacy/ts4.5/tx/index.d.ts +19 -0
- package/types-legacy/ts4.5/tx/validator.d.ts +18 -0
- package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
- package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
- package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
- package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
- package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
- package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
- package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
- package/types-legacy/ts4.5/utils/errors.d.ts +475 -0
- package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
- package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
- package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
- package/types-legacy/ts4.5/utils/other.d.ts +31 -0
- package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
- package/types-legacy/ts4.5/utils/string.d.ts +12 -0
- package/es/channel/index.d.ts +0 -625
- package/es/channel/index.mjs +0 -975
- package/es/channel/index.mjs.map +0 -1
- package/es/contract/Compiler.d.ts +0 -18
- package/es/contract/Compiler.mjs +0 -68
- package/es/contract/Compiler.mjs.map +0 -1
- package/es/contract/aci.d.ts +0 -127
- package/es/contract/aci.mjs +0 -508
- package/es/contract/aci.mjs.map +0 -1
- package/es/contract/methods.d.ts +0 -71
- package/es/contract/methods.mjs +0 -104
- package/es/contract/methods.mjs.map +0 -1
- package/es/deprecated/index.d.ts +0 -143
- package/es/deprecated/index.mjs +0 -162
- package/es/deprecated/index.mjs.map +0 -1
- package/es/deprecated/methods.d.ts +0 -18
- package/es/deprecated/methods.mjs +0 -26
- package/es/deprecated/methods.mjs.map +0 -1
- package/es/tx/builder/address.d.ts +0 -25
- package/es/tx/builder/address.mjs +0 -45
- package/es/tx/builder/address.mjs.map +0 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
- package/es/utils/mptree.d.ts +0 -26
- package/es/utils/mptree.mjs +0 -165
- package/es/utils/mptree.mjs.map +0 -1
- package/src/channel/index.ts +0 -1025
- package/src/contract/Compiler.ts +0 -67
- package/src/contract/aci.ts +0 -537
- package/src/contract/methods.ts +0 -123
- package/src/deprecated/index.ts +0 -172
- package/src/deprecated/methods.ts +0 -25
- package/src/tx/builder/address.ts +0 -50
- package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
- package/src/utils/mptree.ts +0 -145
package/src/tx/builder/index.ts
CHANGED
|
@@ -4,225 +4,19 @@ import {
|
|
|
4
4
|
} from '../../utils/encoder';
|
|
5
5
|
import { AE_AMOUNT_FORMATS } from '../../utils/amount-formatter';
|
|
6
6
|
import { hash } from '../../utils/crypto';
|
|
7
|
-
import { Field } from './field-types';
|
|
7
|
+
import { BinaryData, Field } from './field-types';
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
RawTxObject,
|
|
11
|
-
TX_SCHEMA,
|
|
12
|
-
TxField,
|
|
13
|
-
TxParamsCommon,
|
|
14
|
-
TxSchema,
|
|
15
|
-
TxTypeSchemas,
|
|
9
|
+
RawTxObject, TX_SCHEMA, TxField, TxSchema, TxTypeSchemas,
|
|
16
10
|
} from './schema';
|
|
17
11
|
import { Tag } from './constants';
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
} from './helpers';
|
|
21
|
-
import { readId, writeId } from './address';
|
|
22
|
-
import { toBytes } from '../../utils/bytes';
|
|
23
|
-
import MPTree, { MPTreeBinary } from '../../utils/mptree';
|
|
24
|
-
import {
|
|
25
|
-
ArgumentError,
|
|
26
|
-
DecodeError,
|
|
27
|
-
InvalidTxParamsError,
|
|
28
|
-
SchemaNotFoundError,
|
|
29
|
-
} from '../../utils/errors';
|
|
12
|
+
import { buildContractId, readInt } from './helpers';
|
|
13
|
+
import { ArgumentError, DecodeError, SchemaNotFoundError } from '../../utils/errors';
|
|
30
14
|
import { isKeyOfObject } from '../../utils/other';
|
|
31
|
-
import { NamePointer } from '../../apis/node';
|
|
32
15
|
|
|
33
16
|
/**
|
|
34
17
|
* JavaScript-based Transaction builder
|
|
35
18
|
*/
|
|
36
19
|
|
|
37
|
-
// SERIALIZE AND DESERIALIZE PART
|
|
38
|
-
function deserializeField(
|
|
39
|
-
value: any,
|
|
40
|
-
type: FIELD_TYPES | Field,
|
|
41
|
-
prefix?: Encoding | Encoding[],
|
|
42
|
-
): any {
|
|
43
|
-
if (value == null) return '';
|
|
44
|
-
switch (type) {
|
|
45
|
-
case FIELD_TYPES.ctVersion: {
|
|
46
|
-
const [vm, , abi] = value;
|
|
47
|
-
return {
|
|
48
|
-
vmVersion: readInt(Buffer.from([vm])),
|
|
49
|
-
abiVersion: readInt(Buffer.from([abi])),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
case FIELD_TYPES.abiVersion:
|
|
53
|
-
case FIELD_TYPES.ttlType:
|
|
54
|
-
return readInt(value);
|
|
55
|
-
case FIELD_TYPES.id:
|
|
56
|
-
return readId(value);
|
|
57
|
-
case FIELD_TYPES.ids:
|
|
58
|
-
return value.map(readId);
|
|
59
|
-
case FIELD_TYPES.bool:
|
|
60
|
-
return value[0] === 1;
|
|
61
|
-
case FIELD_TYPES.binary:
|
|
62
|
-
return encode(value, prefix as Encoding);
|
|
63
|
-
case FIELD_TYPES.stateTree:
|
|
64
|
-
return encode(value, Encoding.StateTrees);
|
|
65
|
-
case FIELD_TYPES.string:
|
|
66
|
-
return value.toString();
|
|
67
|
-
case FIELD_TYPES.payload:
|
|
68
|
-
return encode(value, Encoding.Bytearray);
|
|
69
|
-
case FIELD_TYPES.pointers:
|
|
70
|
-
return readPointers(value);
|
|
71
|
-
case FIELD_TYPES.rlpBinary:
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
73
|
-
return unpackTx(encode(value, Encoding.Transaction));
|
|
74
|
-
case FIELD_TYPES.rlpBinaries:
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
76
|
-
return value.map((v: Buffer) => unpackTx(encode(v, Encoding.Transaction)));
|
|
77
|
-
case FIELD_TYPES.rawBinary:
|
|
78
|
-
return value;
|
|
79
|
-
case FIELD_TYPES.hex:
|
|
80
|
-
return value.toString('hex');
|
|
81
|
-
case FIELD_TYPES.offChainUpdates:
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
83
|
-
return value.map((v: Buffer) => unpackTx(encode(v, Encoding.Transaction)));
|
|
84
|
-
case FIELD_TYPES.callStack:
|
|
85
|
-
// TODO: fix this
|
|
86
|
-
return [readInt(value)];
|
|
87
|
-
case FIELD_TYPES.mptrees:
|
|
88
|
-
return value.map((t: MPTreeBinary) => new MPTree(t));
|
|
89
|
-
case FIELD_TYPES.callReturnType:
|
|
90
|
-
switch (readInt(value)) {
|
|
91
|
-
case '0':
|
|
92
|
-
return 'ok';
|
|
93
|
-
case '1':
|
|
94
|
-
return 'error';
|
|
95
|
-
case '2':
|
|
96
|
-
return 'revert';
|
|
97
|
-
default:
|
|
98
|
-
return value;
|
|
99
|
-
}
|
|
100
|
-
case FIELD_TYPES.sophiaCodeTypeInfo:
|
|
101
|
-
return value.reduce(
|
|
102
|
-
(acc: object, [funHash, fnName, argType, outType]: [
|
|
103
|
-
funHash: Buffer,
|
|
104
|
-
fnName: string,
|
|
105
|
-
argType: string,
|
|
106
|
-
outType: string,
|
|
107
|
-
]) => ({
|
|
108
|
-
...acc,
|
|
109
|
-
[fnName.toString()]: { funHash, argType, outType },
|
|
110
|
-
}),
|
|
111
|
-
{},
|
|
112
|
-
);
|
|
113
|
-
default:
|
|
114
|
-
if (typeof type === 'number') return value;
|
|
115
|
-
return type.deserialize(value);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function serializeField(value: any, type: FIELD_TYPES | Field, params: any): any {
|
|
120
|
-
switch (type) {
|
|
121
|
-
case FIELD_TYPES.abiVersion:
|
|
122
|
-
case FIELD_TYPES.ttlType:
|
|
123
|
-
return writeInt(value);
|
|
124
|
-
case FIELD_TYPES.id:
|
|
125
|
-
return writeId(value);
|
|
126
|
-
case FIELD_TYPES.ids:
|
|
127
|
-
return value.map(writeId);
|
|
128
|
-
case FIELD_TYPES.bool:
|
|
129
|
-
return Buffer.from([(value === true) ? 1 : 0]);
|
|
130
|
-
case FIELD_TYPES.binary:
|
|
131
|
-
return decode(value);
|
|
132
|
-
case FIELD_TYPES.stateTree:
|
|
133
|
-
return decode(value);
|
|
134
|
-
case FIELD_TYPES.hex:
|
|
135
|
-
return Buffer.from(value, 'hex');
|
|
136
|
-
case FIELD_TYPES.signatures:
|
|
137
|
-
return value.map(Buffer.from);
|
|
138
|
-
case FIELD_TYPES.payload:
|
|
139
|
-
return typeof value === 'string' && value.split('_')[0] === 'ba'
|
|
140
|
-
? decode(value as Encoded.Bytearray)
|
|
141
|
-
: toBytes(value);
|
|
142
|
-
case FIELD_TYPES.string:
|
|
143
|
-
return toBytes(value);
|
|
144
|
-
case FIELD_TYPES.pointers:
|
|
145
|
-
return buildPointers(value);
|
|
146
|
-
case FIELD_TYPES.rlpBinary:
|
|
147
|
-
return value.rlpEncoded ?? value;
|
|
148
|
-
case FIELD_TYPES.mptrees:
|
|
149
|
-
return value.map((t: MPTree) => t.serialize());
|
|
150
|
-
case FIELD_TYPES.ctVersion:
|
|
151
|
-
return Buffer.from([...toBytes(value.vmVersion), 0, ...toBytes(value.abiVersion)]);
|
|
152
|
-
case FIELD_TYPES.callReturnType:
|
|
153
|
-
switch (value) {
|
|
154
|
-
case 'ok': return writeInt(0);
|
|
155
|
-
case 'error': return writeInt(1);
|
|
156
|
-
case 'revert': return writeInt(2);
|
|
157
|
-
default: return value;
|
|
158
|
-
}
|
|
159
|
-
default:
|
|
160
|
-
if (typeof type === 'number') return value;
|
|
161
|
-
// @ts-expect-error will be solved after removing the whole serializeField function
|
|
162
|
-
return type.serialize(value, params);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function validateField(
|
|
167
|
-
value: any,
|
|
168
|
-
type: FIELD_TYPES | Field,
|
|
169
|
-
prefix?: Encoding | Encoding[],
|
|
170
|
-
): string | undefined {
|
|
171
|
-
// All fields are required
|
|
172
|
-
if (value == null) return 'Field is required';
|
|
173
|
-
|
|
174
|
-
// Validate type of value
|
|
175
|
-
switch (type) {
|
|
176
|
-
case FIELD_TYPES.id: {
|
|
177
|
-
const prefixes = Array.isArray(prefix) ? prefix : [prefix];
|
|
178
|
-
if (!prefixes.includes(value.split('_')[0])) {
|
|
179
|
-
if (prefix == null) { return `'${String(value)}' prefix doesn't exist'`; }
|
|
180
|
-
return `'${String(value)}' prefix doesn't match expected prefix '${prefix.toString()}'`;
|
|
181
|
-
}
|
|
182
|
-
return undefined;
|
|
183
|
-
}
|
|
184
|
-
case FIELD_TYPES.ctVersion:
|
|
185
|
-
if (!(Boolean(value.abiVersion) && Boolean(value.vmVersion))) {
|
|
186
|
-
return 'Value must be an object with "vmVersion" and "abiVersion" fields';
|
|
187
|
-
}
|
|
188
|
-
return undefined;
|
|
189
|
-
case FIELD_TYPES.pointers:
|
|
190
|
-
if (!Array.isArray(value)) return 'Value must be of type Array';
|
|
191
|
-
if (value.some((p: NamePointer) => !(Boolean(p.key) && Boolean(p.id)))) {
|
|
192
|
-
return 'Value must contains only object\'s like \'{key: "account_pubkey", id: "ak_lkamsflkalsdalksdlasdlasdlamd"}\'';
|
|
193
|
-
}
|
|
194
|
-
if (value.length > 32) {
|
|
195
|
-
return `Expected 32 pointers or less, got ${value.length} instead`;
|
|
196
|
-
}
|
|
197
|
-
return undefined;
|
|
198
|
-
default:
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Validate transaction params
|
|
205
|
-
* @category transaction builder
|
|
206
|
-
* @param params - Object with tx params
|
|
207
|
-
* @param schema - Transaction schema
|
|
208
|
-
* @param excludeKeys - Array of keys to exclude for validation
|
|
209
|
-
* @returns Object with validation errors
|
|
210
|
-
*/
|
|
211
|
-
export function validateParams(
|
|
212
|
-
params: any,
|
|
213
|
-
schema: TxField[],
|
|
214
|
-
{ excludeKeys = [] }: { excludeKeys: string[] },
|
|
215
|
-
): object {
|
|
216
|
-
return Object.fromEntries(
|
|
217
|
-
schema
|
|
218
|
-
// TODO: allow optional keys in schema
|
|
219
|
-
.filter(([key]) => !excludeKeys.includes(key)
|
|
220
|
-
&& !['payload', 'nameFee', 'deposit', 'gasPrice', 'fee', 'gasLimit'].includes(key))
|
|
221
|
-
.map(([key, type, prefix]) => [key, validateField(params[key], type, prefix)])
|
|
222
|
-
.filter(([, message]) => message),
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
20
|
/**
|
|
227
21
|
* Unpack binary transaction
|
|
228
22
|
* @category transaction builder
|
|
@@ -230,38 +24,33 @@ export function validateParams(
|
|
|
230
24
|
* @param schema - Transaction schema
|
|
231
25
|
* @returns Object with transaction field's
|
|
232
26
|
*/
|
|
233
|
-
|
|
27
|
+
function unpackRawTx<Tx extends TxSchema>(
|
|
234
28
|
binary: Uint8Array | NestedUint8Array,
|
|
235
29
|
schema: TxField[],
|
|
236
30
|
): RawTxObject<Tx> {
|
|
31
|
+
if (binary.length !== schema.length) {
|
|
32
|
+
throw new ArgumentError('Transaction RLP length', schema.length, binary.length);
|
|
33
|
+
}
|
|
237
34
|
return schema
|
|
238
35
|
.reduce<any>(
|
|
239
36
|
(
|
|
240
37
|
acc,
|
|
241
|
-
[
|
|
38
|
+
[name, field],
|
|
242
39
|
index,
|
|
243
|
-
) =>
|
|
40
|
+
) => {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
42
|
+
const deserialized = field.deserialize(binary[index] as BinaryData, { unpackTx });
|
|
43
|
+
return { ...acc, [name]: deserialized };
|
|
44
|
+
},
|
|
244
45
|
{},
|
|
245
46
|
);
|
|
246
47
|
}
|
|
247
48
|
|
|
248
|
-
/**
|
|
249
|
-
* @category transaction builder
|
|
250
|
-
*/
|
|
251
|
-
export interface BuiltTx<Tx extends TxSchema, Prefix extends Encoding> {
|
|
252
|
-
tx: Encoded.Generic<Prefix>;
|
|
253
|
-
rlpEncoded: Uint8Array;
|
|
254
|
-
binary: Uint8Array;
|
|
255
|
-
txObject: RawTxObject<Tx>;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
49
|
/**
|
|
259
50
|
* Build transaction hash
|
|
260
51
|
* @category transaction builder
|
|
261
|
-
* @param
|
|
262
|
-
* @param type - Transaction type
|
|
52
|
+
* @param params - Object with tx params
|
|
263
53
|
* @param options - options
|
|
264
|
-
* @param options.excludeKeys - Array of keys to exclude for validation and build
|
|
265
54
|
* @param options.denomination - Denomination of amounts
|
|
266
55
|
* @param options.prefix - Prefix of transaction
|
|
267
56
|
* @throws {@link InvalidTxParamsError}
|
|
@@ -270,78 +59,51 @@ export interface BuiltTx<Tx extends TxSchema, Prefix extends Encoding> {
|
|
|
270
59
|
* @returns object.rlpEncoded rlp encoded transaction
|
|
271
60
|
* @returns object.binary binary transaction
|
|
272
61
|
*/
|
|
273
|
-
export function buildTx<
|
|
274
|
-
|
|
275
|
-
|
|
62
|
+
export function buildTx<
|
|
63
|
+
TxType extends Tag,
|
|
64
|
+
E extends Encoding = Encoding.Transaction,
|
|
65
|
+
>(
|
|
66
|
+
params: { tag: TxType; version?: number } & Omit<TxTypeSchemas[TxType], 'tag' | 'version'>
|
|
67
|
+
// TODO: get it from gas-limit.ts somehow
|
|
68
|
+
& (TxType extends Tag.ContractCreateTx | Tag.ContractCallTx
|
|
69
|
+
| Tag.ChannelOffChainUpdateCallContract | Tag.GaAttachTx | Tag.GaMetaTx
|
|
70
|
+
? { gasMax?: number } : {}),
|
|
276
71
|
{
|
|
277
|
-
|
|
278
|
-
prefix = Encoding.Transaction,
|
|
279
|
-
vsn,
|
|
72
|
+
prefix,
|
|
280
73
|
denomination = AE_AMOUNT_FORMATS.AETTOS,
|
|
281
74
|
}: {
|
|
282
|
-
|
|
283
|
-
prefix?: Encoding;
|
|
284
|
-
vsn?: number;
|
|
75
|
+
prefix?: E;
|
|
285
76
|
denomination?: AE_AMOUNT_FORMATS;
|
|
286
77
|
} = {},
|
|
287
|
-
):
|
|
288
|
-
const schemas = TX_SCHEMA[
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
const schema = schemas[vsn] as unknown as TxField[];
|
|
294
|
-
|
|
295
|
-
const params = _params as TxParamsCommon & { onNode: Node; denomination?: AE_AMOUNT_FORMATS };
|
|
296
|
-
params.VSN = vsn;
|
|
297
|
-
params.tag = type;
|
|
298
|
-
params.denomination = denomination;
|
|
299
|
-
const filteredSchema = schema.filter(([key]) => !excludeKeys.includes(key));
|
|
300
|
-
|
|
301
|
-
// Validation
|
|
302
|
-
const valid = validateParams(params, schema, { excludeKeys });
|
|
303
|
-
if (Object.keys(valid).length > 0) {
|
|
304
|
-
throw new InvalidTxParamsError(`Transaction build error. ${JSON.stringify(valid)}`);
|
|
78
|
+
): Encoded.Generic<E> {
|
|
79
|
+
const schemas = TX_SCHEMA[params.tag];
|
|
80
|
+
params.version ??= Math.max(...Object.keys(schemas).map((a) => +a));
|
|
81
|
+
if (!isKeyOfObject(params.version, schemas)) {
|
|
82
|
+
throw new SchemaNotFoundError('serialization', Tag[params.tag], params.version);
|
|
305
83
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const rlpEncoded = rlpEncode(binary);
|
|
328
|
-
const tx = encode(rlpEncoded, prefix);
|
|
329
|
-
return {
|
|
330
|
-
tx,
|
|
331
|
-
rlpEncoded,
|
|
332
|
-
binary,
|
|
333
|
-
txObject: unpackRawTx<TxTypeSchemas[Tag]>(binary, schema),
|
|
334
|
-
} as any;
|
|
84
|
+
const schema = schemas[params.version] as unknown as TxField[];
|
|
85
|
+
|
|
86
|
+
const binary = schema.map(([key, field]: [keyof TxSchema, Field]) => (
|
|
87
|
+
field.serialize(
|
|
88
|
+
params[key],
|
|
89
|
+
{
|
|
90
|
+
...params,
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
92
|
+
unpackTx,
|
|
93
|
+
buildTx,
|
|
94
|
+
denomination,
|
|
95
|
+
rebuildTx: (overrideParams: any) => buildTx(
|
|
96
|
+
{ ...params, ...overrideParams },
|
|
97
|
+
{ denomination },
|
|
98
|
+
),
|
|
99
|
+
},
|
|
100
|
+
)
|
|
101
|
+
));
|
|
102
|
+
|
|
103
|
+
// @ts-expect-error looks like a TypeScript edge case
|
|
104
|
+
return encode(rlpEncode(binary), prefix ?? Encoding.Transaction);
|
|
335
105
|
}
|
|
336
106
|
|
|
337
|
-
/**
|
|
338
|
-
* @category transaction builder
|
|
339
|
-
*/
|
|
340
|
-
export interface TxUnpacked<Tx extends TxSchema> {
|
|
341
|
-
txType: Tag;
|
|
342
|
-
tx: RawTxObject<Tx>;
|
|
343
|
-
rlpEncoded: Uint8Array;
|
|
344
|
-
}
|
|
345
107
|
/**
|
|
346
108
|
* Unpack transaction hash
|
|
347
109
|
* @category transaction builder
|
|
@@ -354,20 +116,15 @@ export interface TxUnpacked<Tx extends TxSchema> {
|
|
|
354
116
|
export function unpackTx<TxType extends Tag>(
|
|
355
117
|
encodedTx: Encoded.Transaction | Encoded.Poi,
|
|
356
118
|
txType?: TxType,
|
|
357
|
-
):
|
|
358
|
-
const
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
if (
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
return {
|
|
367
|
-
txType: objId,
|
|
368
|
-
tx: unpackRawTx<TxTypeSchemas[TxType]>(binary, schema),
|
|
369
|
-
rlpEncoded,
|
|
370
|
-
};
|
|
119
|
+
): RawTxObject<TxTypeSchemas[TxType]> {
|
|
120
|
+
const binary = rlpDecode(decode(encodedTx));
|
|
121
|
+
const tag = +readInt(binary[0] as Buffer);
|
|
122
|
+
if (!isKeyOfObject(tag, TX_SCHEMA)) throw new DecodeError(`Unknown transaction tag: ${tag}`);
|
|
123
|
+
if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);
|
|
124
|
+
const version = +readInt(binary[1] as Buffer);
|
|
125
|
+
if (!isKeyOfObject(version, TX_SCHEMA[tag])) throw new SchemaNotFoundError('deserialization', `tag ${tag}`, version);
|
|
126
|
+
const schema = TX_SCHEMA[tag][version];
|
|
127
|
+
return unpackRawTx<TxTypeSchemas[TxType]>(binary, schema);
|
|
371
128
|
}
|
|
372
129
|
|
|
373
130
|
/**
|
|
@@ -392,9 +149,9 @@ export function buildTxHash(rawTx: Encoded.Transaction | Uint8Array): Encoded.Tx
|
|
|
392
149
|
export function buildContractIdByContractTx(
|
|
393
150
|
contractTx: Encoded.Transaction,
|
|
394
151
|
): Encoded.ContractAddress {
|
|
395
|
-
const {
|
|
396
|
-
if (![Tag.ContractCreateTx, Tag.GaAttachTx].includes(
|
|
397
|
-
throw new ArgumentError('contractCreateTx', 'a contractCreateTx or gaAttach',
|
|
152
|
+
const { tag, ownerId, nonce } = unpackTx<Tag.ContractCreateTx | Tag.GaAttachTx>(contractTx);
|
|
153
|
+
if (![Tag.ContractCreateTx, Tag.GaAttachTx].includes(tag)) {
|
|
154
|
+
throw new ArgumentError('contractCreateTx', 'a contractCreateTx or gaAttach', tag);
|
|
398
155
|
}
|
|
399
|
-
return buildContractId(
|
|
156
|
+
return buildContractId(ownerId, +nonce);
|
|
400
157
|
}
|