@aeternity/aepp-sdk 12.1.2 → 13.0.0-alpha.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/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 +6580 -8860
- 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 +27 -185
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +124 -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 +7 -12
- package/es/Node.mjs +34 -47
- 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 +111 -0
- package/es/account/Generalized.mjs.map +1 -0
- package/es/account/Ledger.d.ts +28 -0
- package/es/account/Ledger.mjs +101 -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 -65
- 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 +3 -3
- package/es/aens.mjs +42 -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.mjs +3 -7
- 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 +4 -41
- 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 +1 -1
- package/es/chain.mjs +33 -58
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +195 -0
- package/es/channel/Base.mjs +290 -0
- package/es/channel/Base.mjs.map +1 -0
- package/es/channel/Contract.d.ts +247 -0
- package/es/channel/Contract.mjs +420 -0
- package/es/channel/Contract.mjs.map +1 -0
- package/es/channel/Spend.d.ts +217 -0
- package/es/channel/Spend.mjs +383 -0
- package/es/channel/Spend.mjs.map +1 -0
- package/es/channel/handlers.d.ts +8 -21
- package/es/channel/handlers.mjs +141 -891
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +27 -21
- package/es/channel/internal.mjs +98 -190
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/{Compiler.d.ts → CompilerHttp.d.ts} +3 -3
- package/es/contract/{Compiler.mjs → CompilerHttp.mjs} +8 -13
- package/es/contract/CompilerHttp.mjs.map +1 -0
- package/es/contract/Contract.d.ts +235 -0
- package/es/contract/Contract.mjs +534 -0
- package/es/contract/Contract.mjs.map +1 -0
- package/es/contract/ga.d.ts +7 -33
- package/es/contract/ga.mjs +20 -112
- package/es/contract/ga.mjs.map +1 -1
- package/es/index.d.ts +9 -6
- package/es/index.mjs +8 -6
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +5 -5
- package/es/oracle.mjs +33 -39
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +3 -3
- package/es/spend.mjs +17 -20
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/constants.d.ts +2 -1
- package/es/tx/builder/constants.mjs +12 -12
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/address.d.ts +15 -0
- package/es/tx/builder/field-types/address.mjs +42 -0
- package/es/tx/builder/field-types/address.mjs.map +1 -0
- package/es/tx/builder/field-types/addresses.d.ts +6 -0
- package/es/tx/builder/field-types/addresses.mjs +13 -0
- package/es/tx/builder/field-types/addresses.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +1 -2
- 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/deposit.d.ts +0 -1
- 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/enumeration.d.ts +5 -0
- package/es/tx/builder/field-types/enumeration.mjs +21 -0
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +1 -9
- package/es/tx/builder/field-types/fee.mjs +9 -25
- 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.mjs +4 -9
- 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 +23 -11
- package/es/tx/builder/field-types/index.mjs +10 -3
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/name-fee.d.ts +0 -1
- 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 +4 -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/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/u-int.d.ts +1 -1
- 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 +1 -21
- package/es/tx/builder/index.mjs +29 -148
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +336 -176
- package/es/tx/builder/schema.mjs +71 -78
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +3 -33
- package/es/tx/index.mjs +26 -43
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +2 -2
- package/es/tx/validator.mjs +86 -59
- 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 +12 -6
- package/es/utils/errors.mjs +87 -163
- 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/mptree.d.ts +1 -1
- package/es/utils/mptree.mjs +4 -26
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +3 -1
- 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 +87 -48
- package/src/AeSdk.ts +15 -11
- package/src/AeSdkAepp.ts +9 -7
- package/src/AeSdkBase.ts +28 -202
- package/src/AeSdkMethods.ts +170 -0
- package/src/AeSdkWallet.ts +16 -47
- package/src/Node.ts +11 -15
- 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 +10 -9
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +5 -4
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
- 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 +6 -3
- package/src/channel/Base.ts +327 -0
- package/src/channel/Contract.ts +487 -0
- package/src/channel/Spend.ts +403 -0
- package/src/channel/handlers.ts +154 -573
- package/src/channel/internal.ts +113 -142
- package/src/contract/{Compiler.ts → CompilerHttp.ts} +5 -5
- package/src/contract/Contract.ts +620 -0
- package/src/contract/ga.ts +18 -104
- package/src/index.ts +9 -8
- package/src/oracle.ts +7 -7
- package/src/spend.ts +5 -13
- package/src/tx/builder/constants.ts +1 -0
- package/src/tx/builder/field-types/address.ts +52 -0
- package/src/tx/builder/field-types/addresses.ts +18 -0
- package/src/tx/builder/field-types/coin-amount.ts +2 -8
- package/src/tx/builder/field-types/enumeration.ts +21 -0
- package/src/tx/builder/field-types/fee.ts +1 -3
- package/src/tx/builder/field-types/gas-limit.ts +2 -2
- package/src/tx/builder/field-types/gas-price.ts +0 -2
- package/src/tx/builder/field-types/index.ts +16 -6
- package/src/tx/builder/field-types/name-fee.ts +1 -1
- 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/u-int.ts +3 -2
- package/src/tx/builder/helpers.ts +10 -60
- package/src/tx/builder/index.ts +6 -65
- package/src/tx/builder/schema.ts +89 -100
- package/src/tx/index.ts +19 -15
- package/src/tx/validator.ts +36 -18
- package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
- package/src/utils/autorest.ts +16 -1
- package/src/utils/bytes.ts +5 -33
- package/src/utils/crypto.ts +23 -16
- package/src/utils/encoder.ts +0 -1
- package/src/utils/errors.ts +18 -12
- 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 +141 -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 +18 -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 +248 -0
- package/types-legacy/ts4.2/channel/Base.d.ts +194 -0
- package/types-legacy/ts4.2/channel/Contract.d.ts +247 -0
- package/types-legacy/ts4.2/channel/Spend.d.ts +217 -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/CompilerHttp.d.ts +18 -0
- package/types-legacy/ts4.2/contract/Contract.d.ts +237 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +43 -0
- package/types-legacy/ts4.2/globals.d.ts +16 -0
- package/types-legacy/ts4.2/index.d.ts +39 -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 +71 -0
- package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +22 -0
- package/types-legacy/ts4.2/tx/builder/field-types/addresses.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/deposit.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -0
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +17 -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 +12 -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 +85 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +19 -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/short-u-int.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +8 -0
- package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +68 -0
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2963 -0
- package/types-legacy/ts4.2/tx/index.d.ts +34 -0
- package/types-legacy/ts4.2/tx/validator.d.ts +20 -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 +480 -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/mptree.d.ts +32 -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 +141 -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 +18 -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 +248 -0
- package/types-legacy/ts4.5/channel/Base.d.ts +194 -0
- package/types-legacy/ts4.5/channel/Contract.d.ts +247 -0
- package/types-legacy/ts4.5/channel/Spend.d.ts +217 -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/CompilerHttp.d.ts +18 -0
- package/types-legacy/ts4.5/contract/Contract.d.ts +237 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +43 -0
- package/types-legacy/ts4.5/index.d.ts +38 -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 +71 -0
- package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +22 -0
- package/types-legacy/ts4.5/tx/builder/field-types/addresses.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/deposit.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -0
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +17 -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 +12 -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 +85 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +19 -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/short-u-int.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +8 -0
- package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +68 -0
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2963 -0
- package/types-legacy/ts4.5/tx/index.d.ts +34 -0
- package/types-legacy/ts4.5/tx/validator.d.ts +20 -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 +480 -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/mptree.d.ts +32 -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.mjs.map +0 -1
- package/es/contract/aci.d.ts +0 -127
- package/es/contract/aci.mjs +0 -509
- 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/src/channel/index.ts +0 -1025
- package/src/contract/aci.ts +0 -538
- 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/es/tx/index.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
2
|
-
|
|
3
1
|
/*
|
|
4
2
|
* ISC License (ISC)
|
|
5
3
|
* Copyright (c) 2022 aeternity developers
|
|
@@ -16,7 +14,6 @@ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/ins
|
|
|
16
14
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
15
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
18
16
|
*/
|
|
19
|
-
|
|
20
17
|
/**
|
|
21
18
|
* Transaction methods
|
|
22
19
|
*
|
|
@@ -28,10 +25,9 @@ import { ABI_VERSIONS, PROTOCOL_VM_ABI, TX_TTL } from "./builder/schema.mjs";
|
|
|
28
25
|
import { Tag } from "./builder/constants.mjs";
|
|
29
26
|
import { ArgumentError, UnsupportedProtocolError, UnknownTxError, InvalidTxParamsError } from "../utils/errors.mjs";
|
|
30
27
|
import { buildTx as syncBuildTx, unpackTx } from "./builder/index.mjs";
|
|
31
|
-
import { isKeyOfObject } from "../utils/other.mjs";
|
|
32
|
-
|
|
28
|
+
import { isAccountNotFoundError, isKeyOfObject } from "../utils/other.mjs";
|
|
29
|
+
async function getVmVersion(txType, _ref) {
|
|
33
30
|
var _abiVersion, _vmVersion;
|
|
34
|
-
|
|
35
31
|
let {
|
|
36
32
|
vmVersion,
|
|
37
33
|
abiVersion,
|
|
@@ -40,17 +36,13 @@ export async function getVmVersion(txType, _ref) {
|
|
|
40
36
|
const {
|
|
41
37
|
consensusProtocolVersion
|
|
42
38
|
} = await onNode.getNodeInfo();
|
|
43
|
-
|
|
44
39
|
if (!isKeyOfObject(consensusProtocolVersion, PROTOCOL_VM_ABI)) {
|
|
45
40
|
throw new UnsupportedProtocolError('Not supported consensus protocol version');
|
|
46
41
|
}
|
|
47
|
-
|
|
48
42
|
const supportedProtocol = PROTOCOL_VM_ABI[consensusProtocolVersion];
|
|
49
|
-
|
|
50
43
|
if (!isKeyOfObject(txType, supportedProtocol)) {
|
|
51
44
|
throw new UnknownTxError('Not supported tx type');
|
|
52
45
|
}
|
|
53
|
-
|
|
54
46
|
const protocolForTX = supportedProtocol[txType];
|
|
55
47
|
(_abiVersion = abiVersion) !== null && _abiVersion !== void 0 ? _abiVersion : abiVersion = protocolForTX.abiVersion[0];
|
|
56
48
|
(_vmVersion = vmVersion) !== null && _vmVersion !== void 0 ? _vmVersion : vmVersion = protocolForTX.vmVersion[0];
|
|
@@ -59,6 +51,7 @@ export async function getVmVersion(txType, _ref) {
|
|
|
59
51
|
abiVersion
|
|
60
52
|
};
|
|
61
53
|
}
|
|
54
|
+
|
|
62
55
|
/**
|
|
63
56
|
* Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
64
57
|
* @category transaction builder
|
|
@@ -66,10 +59,8 @@ export async function getVmVersion(txType, _ref) {
|
|
|
66
59
|
* @param params - Object which contains all tx data
|
|
67
60
|
* @returns Object with account nonce, absolute ttl and transaction fee
|
|
68
61
|
*/
|
|
69
|
-
|
|
70
|
-
export async function prepareTxParams(txType, _ref2) {
|
|
62
|
+
async function prepareTxParams(txType, _ref2) {
|
|
71
63
|
var _nonce;
|
|
72
|
-
|
|
73
64
|
let {
|
|
74
65
|
senderId,
|
|
75
66
|
nonce,
|
|
@@ -80,28 +71,27 @@ export async function prepareTxParams(txType, _ref2) {
|
|
|
80
71
|
} = _ref2;
|
|
81
72
|
(_nonce = nonce) !== null && _nonce !== void 0 ? _nonce : nonce = (await onNode.getAccountNextNonce(senderId, {
|
|
82
73
|
strategy
|
|
83
|
-
}).catch(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
74
|
+
}).catch(error => {
|
|
75
|
+
if (!isAccountNotFoundError(error)) throw error;
|
|
76
|
+
return {
|
|
77
|
+
nextNonce: 1
|
|
78
|
+
};
|
|
79
|
+
})).nextNonce;
|
|
87
80
|
if (ttl !== 0) {
|
|
88
81
|
if (ttl < 0) throw new ArgumentError('ttl', 'greater or equal to 0', ttl);
|
|
89
82
|
ttl += absoluteTtl === true ? 0 : (await onNode.getCurrentKeyBlock()).height;
|
|
90
83
|
}
|
|
91
|
-
|
|
92
84
|
return {
|
|
93
85
|
ttl,
|
|
94
86
|
nonce
|
|
95
87
|
};
|
|
96
88
|
}
|
|
97
|
-
// TODO: find a better name or rearrange methods
|
|
98
89
|
|
|
90
|
+
// TODO: find a better name or rearrange methods
|
|
99
91
|
/**
|
|
100
92
|
* @category transaction builder
|
|
101
93
|
*/
|
|
102
94
|
export async function _buildTx(txType, _ref3) {
|
|
103
|
-
var _context;
|
|
104
|
-
|
|
105
95
|
let {
|
|
106
96
|
denomination,
|
|
107
97
|
absoluteTtl,
|
|
@@ -110,13 +100,11 @@ export async function _buildTx(txType, _ref3) {
|
|
|
110
100
|
// TODO: avoid this assertion
|
|
111
101
|
const params = _params;
|
|
112
102
|
let senderKey;
|
|
113
|
-
|
|
114
103
|
switch (txType) {
|
|
115
104
|
case Tag.SpendTx:
|
|
116
105
|
case Tag.OracleQueryTx:
|
|
117
106
|
senderKey = 'senderId';
|
|
118
107
|
break;
|
|
119
|
-
|
|
120
108
|
case Tag.NameClaimTx:
|
|
121
109
|
case Tag.NameUpdateTx:
|
|
122
110
|
case Tag.NameRevokeTx:
|
|
@@ -125,62 +113,57 @@ export async function _buildTx(txType, _ref3) {
|
|
|
125
113
|
case Tag.OracleRegisterTx:
|
|
126
114
|
senderKey = 'accountId';
|
|
127
115
|
break;
|
|
128
|
-
|
|
129
116
|
case Tag.ContractCreateTx:
|
|
130
117
|
case Tag.GaAttachTx:
|
|
131
118
|
senderKey = 'ownerId';
|
|
132
119
|
break;
|
|
133
|
-
|
|
120
|
+
case Tag.GaMetaTx:
|
|
121
|
+
senderKey = 'gaId';
|
|
122
|
+
break;
|
|
134
123
|
case Tag.ContractCallTx:
|
|
135
124
|
case Tag.OracleExtendTx:
|
|
136
125
|
case Tag.OracleResponseTx:
|
|
137
126
|
senderKey = 'callerId';
|
|
138
127
|
break;
|
|
139
|
-
|
|
140
128
|
case Tag.ChannelCloseSoloTx:
|
|
141
129
|
case Tag.ChannelSlashTx:
|
|
142
130
|
case Tag.ChannelSettleTx:
|
|
143
131
|
case Tag.ChannelSnapshotSoloTx:
|
|
144
132
|
senderKey = 'fromId';
|
|
145
133
|
break;
|
|
146
|
-
|
|
147
134
|
case Tag.PayingForTx:
|
|
148
135
|
senderKey = 'payerId';
|
|
149
136
|
break;
|
|
150
|
-
|
|
151
137
|
default:
|
|
152
138
|
throw new ArgumentError('txType', 'valid transaction type', txType);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
139
|
+
}
|
|
140
|
+
// TODO: move specific cases to field-types
|
|
141
|
+
if ([Tag.ContractCreateTx, Tag.GaAttachTx].includes(txType)) {
|
|
142
|
+
params.ctVersion = await getVmVersion(Tag.ContractCreateTx, {
|
|
143
|
+
...params,
|
|
158
144
|
...params.ctVersion
|
|
159
145
|
});
|
|
160
146
|
}
|
|
161
|
-
|
|
162
|
-
if (txType === Tag.ContractCallTx) {
|
|
147
|
+
if ([Tag.ContractCallTx, Tag.GaMetaTx].includes(txType)) {
|
|
163
148
|
params.abiVersion = (await getVmVersion(Tag.ContractCallTx, params)).abiVersion;
|
|
164
149
|
}
|
|
165
|
-
|
|
166
150
|
if (txType === Tag.OracleRegisterTx) {
|
|
167
151
|
var _params$abiVersion;
|
|
168
|
-
|
|
169
152
|
(_params$abiVersion = params.abiVersion) !== null && _params$abiVersion !== void 0 ? _params$abiVersion : params.abiVersion = ABI_VERSIONS.NO_ABI;
|
|
170
153
|
}
|
|
171
|
-
|
|
172
154
|
if (txType === Tag.PayingForTx) {
|
|
173
155
|
params.tx = unpackTx(params.tx);
|
|
174
156
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
157
|
+
const senderId = params[senderKey];
|
|
158
|
+
// TODO: do this check on TypeScript level
|
|
178
159
|
if (senderId == null) throw new InvalidTxParamsError(`Transaction field ${senderKey} is missed`);
|
|
179
|
-
const extraParams = await prepareTxParams(txType, {
|
|
160
|
+
const extraParams = await prepareTxParams(txType, {
|
|
161
|
+
...params,
|
|
180
162
|
senderId,
|
|
181
163
|
absoluteTtl
|
|
182
164
|
});
|
|
183
|
-
return syncBuildTx({
|
|
165
|
+
return syncBuildTx({
|
|
166
|
+
...params,
|
|
184
167
|
...extraParams
|
|
185
168
|
}, txType, {
|
|
186
169
|
denomination
|
package/es/tx/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["ABI_VERSIONS","PROTOCOL_VM_ABI","TX_TTL","Tag","ArgumentError","UnsupportedProtocolError","UnknownTxError","InvalidTxParamsError","buildTx","syncBuildTx","unpackTx","isKeyOfObject","getVmVersion","txType","vmVersion","abiVersion","onNode","consensusProtocolVersion","getNodeInfo","supportedProtocol","protocolForTX","prepareTxParams","senderId","nonce","ttl","absoluteTtl","strategy","getAccountNextNonce","catch","nextNonce","getCurrentKeyBlock","height","_buildTx","denomination","_params","params","senderKey","SpendTx","OracleQueryTx","NameClaimTx","NameUpdateTx","NameRevokeTx","NameTransferTx","NamePreclaimTx","OracleRegisterTx","ContractCreateTx","GaAttachTx","ContractCallTx","OracleExtendTx","OracleResponseTx","ChannelCloseSoloTx","ChannelSlashTx","ChannelSettleTx","ChannelSnapshotSoloTx","PayingForTx","ctVersion","NO_ABI","tx","extraParams"],"sources":["../../src/tx/index.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Transaction methods\n *\n * This is implementation of [Tx](api/tx.md) relays\n * the creation of transactions to {@link Node}.\n * These methods provide ability to create native transactions.\n */\nimport BigNumber from 'bignumber.js';\nimport {\n ABI_VERSIONS, CtVersion, PROTOCOL_VM_ABI, TX_TTL, TxParamsCommon,\n} from './builder/schema';\nimport { Tag } from './builder/constants';\nimport {\n ArgumentError, UnsupportedProtocolError, UnknownTxError, InvalidTxParamsError,\n} from '../utils/errors';\nimport Node from '../Node';\nimport { Encoded } from '../utils/encoder';\nimport { buildTx as syncBuildTx, unpackTx } from './builder/index';\nimport { isKeyOfObject } from '../utils/other';\nimport { AE_AMOUNT_FORMATS } from '../utils/amount-formatter';\n\ntype Int = number | string | BigNumber;\n\nexport type BuildTxOptions <TxType extends Tag, OmitFields extends string> =\n Omit<Parameters<typeof _buildTx<TxType>>[1], OmitFields>;\n\n/**\n * Validated vm/abi version or get default based on transaction type and NODE version\n * @category transaction builder\n * @param txType - Type of transaction\n * @param ctVersion - Object with vm and abi version fields\n * @returns Object with vm/abi version\n */\nexport async function getVmVersion(\n txType: Tag.ContractCreateTx, ctVersion: Partial<CtVersion> & { onNode: Node }\n): Promise<CtVersion>;\nexport async function getVmVersion(\n txType: Tag, ctVersion: Partial<Pick<CtVersion, 'abiVersion'>> & { onNode: Node }\n): Promise<Pick<CtVersion, 'abiVersion'>>;\nexport async function getVmVersion(\n txType: Tag,\n { vmVersion, abiVersion, onNode }: Partial<CtVersion> & { onNode: Node },\n): Promise<Partial<CtVersion>> {\n const { consensusProtocolVersion } = await onNode.getNodeInfo();\n if (!isKeyOfObject(consensusProtocolVersion, PROTOCOL_VM_ABI)) {\n throw new UnsupportedProtocolError('Not supported consensus protocol version');\n }\n const supportedProtocol = PROTOCOL_VM_ABI[consensusProtocolVersion];\n if (!isKeyOfObject(txType, supportedProtocol)) {\n throw new UnknownTxError('Not supported tx type');\n }\n const protocolForTX = supportedProtocol[txType];\n abiVersion ??= protocolForTX.abiVersion[0];\n vmVersion ??= protocolForTX.vmVersion[0];\n return { vmVersion, abiVersion };\n}\n\n/**\n * Calculate fee, get absolute ttl (ttl + height), get account nonce\n * @category transaction builder\n * @param txType - Type of transaction\n * @param params - Object which contains all tx data\n * @returns Object with account nonce, absolute ttl and transaction fee\n */\nexport async function prepareTxParams(\n txType: Tag,\n {\n senderId,\n nonce,\n ttl = TX_TTL,\n absoluteTtl,\n strategy,\n onNode,\n }: PrepareTxParamsOptions,\n): Promise<{ ttl: number; nonce: number }> {\n nonce ??= (\n await onNode.getAccountNextNonce(senderId, { strategy }).catch(() => ({ nextNonce: 1 }))\n ).nextNonce;\n\n if (ttl !== 0) {\n if (ttl < 0) throw new ArgumentError('ttl', 'greater or equal to 0', ttl);\n ttl += absoluteTtl === true ? 0 : (await onNode.getCurrentKeyBlock()).height;\n }\n\n return { ttl, nonce };\n}\n\ninterface PrepareTxParamsOptions extends Pick<TxParamsCommon, 'nonce' | 'ttl'> {\n senderId: Encoded.AccountAddress;\n absoluteTtl?: boolean;\n strategy?: 'continuity' | 'max';\n onNode: Node;\n}\n\n// TODO: find a better name or rearrange methods\n/**\n * @category transaction builder\n */\nexport async function _buildTx<TxType extends Tag>(\n txType: TxType,\n { denomination, absoluteTtl, ..._params }:\n Omit<Parameters<typeof syncBuildTx<TxType, 'tx'>>[0], 'fee' | 'nonce' | 'ttl' | 'ctVersion' | 'abiVersion'>\n & {\n onNode: Node;\n fee?: Int;\n nonce?: number;\n ttl?: number;\n denomination?: AE_AMOUNT_FORMATS;\n absoluteTtl?: boolean;\n }\n & (TxType extends Tag.OracleExtendTx | Tag.OracleResponseTx\n ? { callerId: Encoded.AccountAddress } : {})\n & (TxType extends Tag.ContractCreateTx | Tag.GaAttachTx ? { ctVersion?: CtVersion } : {})\n & (TxType extends Tag.ContractCallTx | Tag.OracleRegisterTx\n ? { abiVersion?: ABI_VERSIONS } : {}),\n): Promise<Encoded.Transaction> {\n // TODO: avoid this assertion\n const params = _params as unknown as TxParamsCommon & { onNode: Node };\n let senderKey: keyof TxParamsCommon | '<absent>';\n switch (txType) {\n case Tag.SpendTx:\n case Tag.OracleQueryTx:\n senderKey = 'senderId';\n break;\n case Tag.NameClaimTx:\n case Tag.NameUpdateTx:\n case Tag.NameRevokeTx:\n case Tag.NameTransferTx:\n case Tag.NamePreclaimTx:\n case Tag.OracleRegisterTx:\n senderKey = 'accountId';\n break;\n case Tag.ContractCreateTx:\n case Tag.GaAttachTx:\n senderKey = 'ownerId';\n break;\n case Tag.ContractCallTx:\n case Tag.OracleExtendTx:\n case Tag.OracleResponseTx:\n senderKey = 'callerId';\n break;\n case Tag.ChannelCloseSoloTx:\n case Tag.ChannelSlashTx:\n case Tag.ChannelSettleTx:\n case Tag.ChannelSnapshotSoloTx:\n senderKey = 'fromId';\n break;\n case Tag.PayingForTx:\n senderKey = 'payerId';\n break;\n default:\n throw new ArgumentError('txType', 'valid transaction type', txType);\n }\n // TODO: move specific cases to field-types\n if ([Tag.ContractCreateTx, Tag.GaAttachTx].includes(txType)) {\n params.ctVersion = await getVmVersion(\n Tag.ContractCreateTx,\n { ...params, ...params.ctVersion },\n );\n }\n if (txType === Tag.ContractCallTx) {\n params.abiVersion = (await getVmVersion(Tag.ContractCallTx, params)).abiVersion;\n }\n if (txType === Tag.OracleRegisterTx) {\n params.abiVersion ??= ABI_VERSIONS.NO_ABI;\n }\n if (txType === Tag.PayingForTx) {\n params.tx = unpackTx(params.tx);\n }\n const senderId = params[senderKey];\n // TODO: do this check on TypeScript level\n if (senderId == null) throw new InvalidTxParamsError(`Transaction field ${senderKey} is missed`);\n const extraParams = await prepareTxParams(txType, { ...params, senderId, absoluteTtl });\n return syncBuildTx({ ...params, ...extraParams } as any, txType, { denomination }).tx;\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;SAGEA,Y,EAAyBC,e,EAAiBC,M;SAEnCC,G;SAEPC,a,EAAeC,wB,EAA0BC,c,EAAgBC,oB;SAIlDC,OAAO,IAAIC,W,EAAaC,Q;SACxBC,a;AAqBT,OAAO,eAAeC,YAAf,CACLC,MADK,QAGwB;EAAA;;EAAA,IAD7B;IAAEC,SAAF;IAAaC,UAAb;IAAyBC;EAAzB,CAC6B;EAC7B,MAAM;IAAEC;EAAF,IAA+B,MAAMD,MAAM,CAACE,WAAP,EAA3C;;EACA,IAAI,CAACP,aAAa,CAACM,wBAAD,EAA2BhB,eAA3B,CAAlB,EAA+D;IAC7D,MAAM,IAAII,wBAAJ,CAA6B,0CAA7B,CAAN;EACD;;EACD,MAAMc,iBAAiB,GAAGlB,eAAe,CAACgB,wBAAD,CAAzC;;EACA,IAAI,CAACN,aAAa,CAACE,MAAD,EAASM,iBAAT,CAAlB,EAA+C;IAC7C,MAAM,IAAIb,cAAJ,CAAmB,uBAAnB,CAAN;EACD;;EACD,MAAMc,aAAa,GAAGD,iBAAiB,CAACN,MAAD,CAAvC;EACA,eAAAE,UAAU,UAAV,2CAAAA,UAAU,GAAKK,aAAa,CAACL,UAAd,CAAyB,CAAzB,CAAf;EACA,cAAAD,SAAS,UAAT,yCAAAA,SAAS,GAAKM,aAAa,CAACN,SAAd,CAAwB,CAAxB,CAAd;EACA,OAAO;IAAEA,SAAF;IAAaC;EAAb,CAAP;AACD;AAED;A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mD,WAAnB,EAAgC;IAC9BnB,MAAM,CAACsB,EAAP,GAAY/C,QAAQ,CAACyB,MAAM,CAACsB,EAAR,CAApB;EACD;;EACD,MAAMnC,QAAQ,GAAGa,MAAM,CAACC,SAAD,CAAvB,CAtD8B,CAuD9B;;EACA,IAAId,QAAQ,IAAI,IAAhB,EAAsB,MAAM,IAAIf,oBAAJ,CAA0B,qBAAoB6B,SAAU,YAAxD,CAAN;EACtB,MAAMsB,WAAW,GAAG,MAAMrC,eAAe,CAACR,MAAD,EAAS,EAAE,GAAGsB,MAAL;IAAab,QAAb;IAAuBG;EAAvB,CAAT,CAAzC;EACA,OAAOhB,WAAW,CAAC,EAAE,GAAG0B,MAAL;IAAa,GAAGuB;EAAhB,CAAD,EAAuC7C,MAAvC,EAA+C;IAAEoB;EAAF,CAA/C,CAAX,CAA4EwB,EAAnF;AACD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["ABI_VERSIONS","PROTOCOL_VM_ABI","TX_TTL","Tag","ArgumentError","UnsupportedProtocolError","UnknownTxError","InvalidTxParamsError","buildTx","syncBuildTx","unpackTx","isAccountNotFoundError","isKeyOfObject","getVmVersion","txType","vmVersion","abiVersion","onNode","consensusProtocolVersion","getNodeInfo","supportedProtocol","protocolForTX","prepareTxParams","senderId","nonce","ttl","absoluteTtl","strategy","getAccountNextNonce","catch","error","nextNonce","getCurrentKeyBlock","height","_buildTx","denomination","_params","params","senderKey","SpendTx","OracleQueryTx","NameClaimTx","NameUpdateTx","NameRevokeTx","NameTransferTx","NamePreclaimTx","OracleRegisterTx","ContractCreateTx","GaAttachTx","GaMetaTx","ContractCallTx","OracleExtendTx","OracleResponseTx","ChannelCloseSoloTx","ChannelSlashTx","ChannelSettleTx","ChannelSnapshotSoloTx","PayingForTx","includes","ctVersion","NO_ABI","tx","extraParams"],"sources":["../../src/tx/index.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Transaction methods\n *\n * This is implementation of [Tx](api/tx.md) relays\n * the creation of transactions to {@link Node}.\n * These methods provide ability to create native transactions.\n */\nimport BigNumber from 'bignumber.js';\nimport {\n ABI_VERSIONS, CtVersion, PROTOCOL_VM_ABI, TX_TTL, TxParamsCommon,\n} from './builder/schema';\nimport { Tag } from './builder/constants';\nimport {\n ArgumentError, UnsupportedProtocolError, UnknownTxError, InvalidTxParamsError,\n} from '../utils/errors';\nimport Node from '../Node';\nimport { Encoded } from '../utils/encoder';\nimport { buildTx as syncBuildTx, unpackTx } from './builder/index';\nimport { isAccountNotFoundError, isKeyOfObject } from '../utils/other';\nimport { AE_AMOUNT_FORMATS } from '../utils/amount-formatter';\n\ntype Int = number | string | BigNumber;\n\nexport type BuildTxOptions <TxType extends Tag, OmitFields extends string> =\n Omit<Parameters<typeof _buildTx<TxType>>[1], OmitFields>;\n\n/**\n * Validated vm/abi version or get default based on transaction type and NODE version\n * @category transaction builder\n * @param txType - Type of transaction\n * @param ctVersion - Object with vm and abi version fields\n * @returns Object with vm/abi version\n */\nasync function getVmVersion(\n txType: Tag.ContractCreateTx, ctVersion: Partial<CtVersion> & { onNode: Node }\n): Promise<CtVersion>;\nasync function getVmVersion(\n txType: Tag, ctVersion: Partial<Pick<CtVersion, 'abiVersion'>> & { onNode: Node }\n): Promise<Pick<CtVersion, 'abiVersion'>>;\nasync function getVmVersion(\n txType: Tag,\n { vmVersion, abiVersion, onNode }: Partial<CtVersion> & { onNode: Node },\n): Promise<Partial<CtVersion>> {\n const { consensusProtocolVersion } = await onNode.getNodeInfo();\n if (!isKeyOfObject(consensusProtocolVersion, PROTOCOL_VM_ABI)) {\n throw new UnsupportedProtocolError('Not supported consensus protocol version');\n }\n const supportedProtocol = PROTOCOL_VM_ABI[consensusProtocolVersion];\n if (!isKeyOfObject(txType, supportedProtocol)) {\n throw new UnknownTxError('Not supported tx type');\n }\n const protocolForTX = supportedProtocol[txType];\n abiVersion ??= protocolForTX.abiVersion[0];\n vmVersion ??= protocolForTX.vmVersion[0];\n return { vmVersion, abiVersion };\n}\n\n/**\n * Calculate fee, get absolute ttl (ttl + height), get account nonce\n * @category transaction builder\n * @param txType - Type of transaction\n * @param params - Object which contains all tx data\n * @returns Object with account nonce, absolute ttl and transaction fee\n */\nasync function prepareTxParams(\n txType: Tag,\n {\n senderId,\n nonce,\n ttl = TX_TTL,\n absoluteTtl,\n strategy,\n onNode,\n }: {\n senderId: Encoded.AccountAddress;\n absoluteTtl?: boolean;\n strategy?: 'continuity' | 'max';\n onNode: Node;\n } & Pick<TxParamsCommon, 'nonce' | 'ttl'>,\n): Promise<{ ttl: number; nonce: number }> {\n nonce ??= (\n await onNode.getAccountNextNonce(senderId, { strategy }).catch((error) => {\n if (!isAccountNotFoundError(error)) throw error;\n return { nextNonce: 1 };\n })\n ).nextNonce;\n\n if (ttl !== 0) {\n if (ttl < 0) throw new ArgumentError('ttl', 'greater or equal to 0', ttl);\n ttl += absoluteTtl === true ? 0 : (await onNode.getCurrentKeyBlock()).height;\n }\n\n return { ttl, nonce };\n}\n\n// TODO: find a better name or rearrange methods\n/**\n * @category transaction builder\n */\nexport async function _buildTx<TxType extends Tag>(\n txType: TxType,\n { denomination, absoluteTtl, ..._params }:\n Omit<Parameters<typeof syncBuildTx<TxType, 'tx'>>[0], 'fee' | 'nonce' | 'ttl' | 'ctVersion' | 'abiVersion'>\n & {\n onNode: Node;\n fee?: Int;\n nonce?: number;\n ttl?: number;\n denomination?: AE_AMOUNT_FORMATS;\n absoluteTtl?: boolean;\n }\n & (TxType extends Tag.OracleExtendTx | Tag.OracleResponseTx\n ? { callerId: Encoded.AccountAddress } : {})\n & (TxType extends Tag.ContractCreateTx | Tag.GaAttachTx ? { ctVersion?: CtVersion } : {})\n & (TxType extends Tag.ContractCallTx | Tag.OracleRegisterTx\n ? { abiVersion?: ABI_VERSIONS } : {}),\n): Promise<Encoded.Transaction> {\n // TODO: avoid this assertion\n const params = _params as unknown as TxParamsCommon & { onNode: Node };\n let senderKey: keyof TxParamsCommon | '<absent>';\n switch (txType) {\n case Tag.SpendTx:\n case Tag.OracleQueryTx:\n senderKey = 'senderId';\n break;\n case Tag.NameClaimTx:\n case Tag.NameUpdateTx:\n case Tag.NameRevokeTx:\n case Tag.NameTransferTx:\n case Tag.NamePreclaimTx:\n case Tag.OracleRegisterTx:\n senderKey = 'accountId';\n break;\n case Tag.ContractCreateTx:\n case Tag.GaAttachTx:\n senderKey = 'ownerId';\n break;\n case Tag.GaMetaTx:\n senderKey = 'gaId';\n break;\n case Tag.ContractCallTx:\n case Tag.OracleExtendTx:\n case Tag.OracleResponseTx:\n senderKey = 'callerId';\n break;\n case Tag.ChannelCloseSoloTx:\n case Tag.ChannelSlashTx:\n case Tag.ChannelSettleTx:\n case Tag.ChannelSnapshotSoloTx:\n senderKey = 'fromId';\n break;\n case Tag.PayingForTx:\n senderKey = 'payerId';\n break;\n default:\n throw new ArgumentError('txType', 'valid transaction type', txType);\n }\n // TODO: move specific cases to field-types\n if ([Tag.ContractCreateTx, Tag.GaAttachTx].includes(txType)) {\n params.ctVersion = await getVmVersion(\n Tag.ContractCreateTx,\n { ...params, ...params.ctVersion },\n );\n }\n if ([Tag.ContractCallTx, Tag.GaMetaTx].includes(txType)) {\n params.abiVersion = (await getVmVersion(Tag.ContractCallTx, params)).abiVersion;\n }\n if (txType === Tag.OracleRegisterTx) {\n params.abiVersion ??= ABI_VERSIONS.NO_ABI;\n }\n if (txType === Tag.PayingForTx) {\n params.tx = unpackTx(params.tx);\n }\n const senderId = params[senderKey];\n // TODO: do this check on TypeScript level\n if (senderId == null) throw new InvalidTxParamsError(`Transaction field ${senderKey} is missed`);\n const extraParams = await prepareTxParams(txType, { ...params, senderId, absoluteTtl });\n return syncBuildTx({ ...params, ...extraParams } as any, txType, { denomination }).tx;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,SASEA,YAAY,EAAaC,eAAe,EAAEC,MAAM;AAAA,SAEzCC,GAAG;AAAA,SAEVC,aAAa,EAAEC,wBAAwB,EAAEC,cAAc,EAAEC,oBAAoB;AAAA,SAItEC,OAAO,IAAIC,WAAW,EAAEC,QAAQ;AAAA,SAChCC,sBAAsB,EAAEC,aAAa;AAqB9C,eAAeC,YAAY,CACzBC,MAAW,QAEkB;EAAA;EAAA,IAD7B;IAAEC,SAAS;IAAEC,UAAU;IAAEC;EAA8C,CAAC;EAExE,MAAM;IAAEC;EAAyB,CAAC,GAAG,MAAMD,MAAM,CAACE,WAAW,EAAE;EAC/D,IAAI,CAACP,aAAa,CAACM,wBAAwB,EAAEjB,eAAe,CAAC,EAAE;IAC7D,MAAM,IAAII,wBAAwB,CAAC,0CAA0C,CAAC;EAChF;EACA,MAAMe,iBAAiB,GAAGnB,eAAe,CAACiB,wBAAwB,CAAC;EACnE,IAAI,CAACN,aAAa,CAACE,MAAM,EAAEM,iBAAiB,CAAC,EAAE;IAC7C,MAAM,IAAId,cAAc,CAAC,uBAAuB,CAAC;EACnD;EACA,MAAMe,aAAa,GAAGD,iBAAiB,CAACN,MAAM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D,GAAG,CAAC+C,cAAc,EAAE/C,GAAG,CAAC8C,QAAQ,CAAC,CAACS,QAAQ,CAAC5C,MAAM,CAAC,EAAE;IACvDuB,MAAM,CAACrB,UAAU,GAAG,CAAC,MAAMH,YAAY,CAACV,GAAG,CAAC+C,cAAc,EAAEb,MAAM,CAAC,EAAErB,UAAU;EACjF;EACA,IAAIF,MAAM,KAAKX,GAAG,CAAC2C,gBAAgB,EAAE;IAAA;IACnC,sBAAAT,MAAM,CAACrB,UAAU,mEAAjBqB,MAAM,CAACrB,UAAU,GAAKhB,YAAY,CAAC4D,MAAM;EAC3C;EACA,IAAI9C,MAAM,KAAKX,GAAG,CAACsD,WAAW,EAAE;IAC9BpB,MAAM,CAACwB,EAAE,GAAGnD,QAAQ,CAAC2B,MAAM,CAACwB,EAAE,CAAC;EACjC;EACA,MAAMtC,QAAQ,GAAGc,MAAM,CAACC,SAAS,CAAC;EAClC;EACA,IAAIf,QAAQ,IAAI,IAAI,EAAE,MAAM,IAAIhB,oBAAoB,CAAE,qBAAoB+B,SAAU,YAAW,CAAC;EAChG,MAAMwB,WAAW,GAAG,MAAMxC,eAAe,CAACR,MAAM,EAAE;IAAE,GAAGuB,MAAM;IAAEd,QAAQ;IAAEG;EAAY,CAAC,CAAC;EACvF,OAAOjB,WAAW,CAAC;IAAE,GAAG4B,MAAM;IAAE,GAAGyB;EAAY,CAAC,EAAShD,MAAM,EAAE;IAAEqB;EAAa,CAAC,CAAC,CAAC0B,EAAE;AACvF"}
|
package/es/tx/validator.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ export interface ValidatorResult {
|
|
|
12
12
|
* to make sure it can be posted it to the chain
|
|
13
13
|
* @category transaction builder
|
|
14
14
|
* @param transaction - Base64Check-encoded transaction
|
|
15
|
-
* @param
|
|
15
|
+
* @param nodeNotCached - Node to validate transaction against
|
|
16
16
|
* @param parentTxTypes - Types of parent transactions
|
|
17
17
|
* @returns Array with verification errors
|
|
18
18
|
* @example const errors = await verifyTransaction(transaction, node)
|
|
19
19
|
*/
|
|
20
|
-
export default function verifyTransaction(transaction: Encoded.Transaction | Encoded.Poi,
|
|
20
|
+
export default function verifyTransaction(transaction: Encoded.Transaction | Encoded.Poi, nodeNotCached: Node, parentTxTypes?: Tag[]): Promise<ValidatorResult[]>;
|
package/es/tx/validator.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _buffer from "buffer";
|
|
2
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
3
2
|
const {
|
|
4
3
|
Buffer: _Buffer
|
|
5
4
|
} = _buffer;
|
|
@@ -9,28 +8,39 @@ import { PROTOCOL_VM_ABI } from "./builder/schema.mjs";
|
|
|
9
8
|
import { Tag } from "./builder/constants.mjs";
|
|
10
9
|
import { unpackTx } from "./builder/index.mjs";
|
|
11
10
|
import { UnsupportedProtocolError } from "../utils/errors.mjs";
|
|
12
|
-
import { concatBuffers, isKeyOfObject } from "../utils/other.mjs";
|
|
13
|
-
import {
|
|
11
|
+
import { concatBuffers, isAccountNotFoundError, isKeyOfObject } from "../utils/other.mjs";
|
|
12
|
+
import { encode, Encoding } from "../utils/encoder.mjs";
|
|
13
|
+
import Node from "../Node.mjs";
|
|
14
|
+
import { genAggressiveCacheGetResponsesPolicy } from "../utils/autorest.mjs";
|
|
14
15
|
const validators = [];
|
|
15
|
-
|
|
16
16
|
const getSenderAddress = tx => ['senderId', 'accountId', 'ownerId', 'callerId', 'oracleId', 'fromId', 'initiator', 'gaId', 'payerId'].map(key => tx[key]).filter(a => a).map(a => a === null || a === void 0 ? void 0 : a.toString().replace(/^ok_/, 'ak_'))[0];
|
|
17
|
+
|
|
17
18
|
/**
|
|
18
19
|
* Transaction Validator
|
|
19
20
|
* This function validates some of transaction properties,
|
|
20
21
|
* to make sure it can be posted it to the chain
|
|
21
22
|
* @category transaction builder
|
|
22
23
|
* @param transaction - Base64Check-encoded transaction
|
|
23
|
-
* @param
|
|
24
|
+
* @param nodeNotCached - Node to validate transaction against
|
|
24
25
|
* @param parentTxTypes - Types of parent transactions
|
|
25
26
|
* @returns Array with verification errors
|
|
26
27
|
* @example const errors = await verifyTransaction(transaction, node)
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export default async function verifyTransaction(transaction, node) {
|
|
29
|
+
export default async function verifyTransaction(transaction, nodeNotCached) {
|
|
31
30
|
var _getSenderAddress;
|
|
32
|
-
|
|
33
31
|
let parentTxTypes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
32
|
+
let node = nodeNotCached;
|
|
33
|
+
if (!node.pipeline.getOrderedPolicies().some(_ref => {
|
|
34
|
+
let {
|
|
35
|
+
name
|
|
36
|
+
} = _ref;
|
|
37
|
+
return name === 'aggressive-cache-get-responses';
|
|
38
|
+
})) {
|
|
39
|
+
node = new Node(nodeNotCached.$host, {
|
|
40
|
+
ignoreVersion: true
|
|
41
|
+
});
|
|
42
|
+
node.pipeline.addPolicy(genAggressiveCacheGetResponsesPolicy());
|
|
43
|
+
}
|
|
34
44
|
const {
|
|
35
45
|
tx,
|
|
36
46
|
txType
|
|
@@ -41,12 +51,17 @@ export default async function verifyTransaction(transaction, node) {
|
|
|
41
51
|
}, {
|
|
42
52
|
consensusProtocolVersion,
|
|
43
53
|
nodeNetworkId
|
|
44
|
-
}] = await Promise.all([address == null ? undefined : node.getAccountByPubkey(address).catch(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
}] = await Promise.all([address == null ? undefined : node.getAccountByPubkey(address).catch(error => {
|
|
55
|
+
if (!isAccountNotFoundError(error)) throw error;
|
|
56
|
+
return {
|
|
57
|
+
id: address,
|
|
58
|
+
balance: 0n,
|
|
59
|
+
nonce: 0
|
|
60
|
+
};
|
|
61
|
+
})
|
|
62
|
+
// TODO: remove after fixing https://github.com/aeternity/aepp-sdk-js/issues/1537
|
|
63
|
+
.then(acc => ({
|
|
64
|
+
...acc,
|
|
50
65
|
id: acc.id
|
|
51
66
|
})), node.getCurrentKeyBlockHeight(), node.getNodeInfo()]);
|
|
52
67
|
return (await Promise.all(validators.map(v => v(tx, {
|
|
@@ -59,50 +74,47 @@ export default async function verifyTransaction(transaction, node) {
|
|
|
59
74
|
parentTxTypes
|
|
60
75
|
})))).flat();
|
|
61
76
|
}
|
|
62
|
-
validators.push((
|
|
77
|
+
validators.push((_ref2, _ref3) => {
|
|
63
78
|
let {
|
|
64
79
|
encodedTx,
|
|
65
80
|
signatures
|
|
66
|
-
} =
|
|
81
|
+
} = _ref2;
|
|
67
82
|
let {
|
|
68
83
|
account,
|
|
69
84
|
nodeNetworkId,
|
|
70
85
|
parentTxTypes
|
|
71
|
-
} =
|
|
86
|
+
} = _ref3;
|
|
72
87
|
if ((encodedTx !== null && encodedTx !== void 0 ? encodedTx : signatures) === undefined) return [];
|
|
73
88
|
if (account == null) return [];
|
|
74
89
|
if (signatures.length !== 1) return []; // TODO: Support multisignature?
|
|
75
|
-
|
|
76
|
-
const prefix = _Buffer.from([nodeNetworkId, ...(_includesInstanceProperty(parentTxTypes).call(parentTxTypes, Tag.PayingForTx) ? ['inner_tx'] : [])].join('-'));
|
|
77
|
-
|
|
90
|
+
const prefix = _Buffer.from([nodeNetworkId, ...(parentTxTypes.includes(Tag.PayingForTx) ? ['inner_tx'] : [])].join('-'));
|
|
78
91
|
const txWithNetworkId = concatBuffers([prefix, encodedTx.rlpEncoded]);
|
|
79
92
|
const txHashWithNetworkId = concatBuffers([prefix, hash(encodedTx.rlpEncoded)]);
|
|
80
|
-
|
|
81
|
-
if (verify(txWithNetworkId, signatures[0], decodedPub) || verify(txHashWithNetworkId, signatures[0], decodedPub)) return [];
|
|
93
|
+
if (verify(txWithNetworkId, signatures[0], account.id) || verify(txHashWithNetworkId, signatures[0], account.id)) return [];
|
|
82
94
|
return [{
|
|
83
95
|
message: 'Signature cannot be verified, please ensure that you transaction have' + ' the correct prefix and the correct private key for the sender address',
|
|
84
96
|
key: 'InvalidSignature',
|
|
85
97
|
checkedKeys: ['encodedTx', 'signatures']
|
|
86
98
|
}];
|
|
87
|
-
}, async (
|
|
99
|
+
}, async (_ref4, _ref5) => {
|
|
88
100
|
let {
|
|
89
101
|
encodedTx,
|
|
90
102
|
tx
|
|
91
|
-
} =
|
|
103
|
+
} = _ref4;
|
|
92
104
|
let {
|
|
93
105
|
node,
|
|
94
106
|
parentTxTypes,
|
|
95
107
|
txType
|
|
96
|
-
} =
|
|
108
|
+
} = _ref5;
|
|
97
109
|
if ((encodedTx !== null && encodedTx !== void 0 ? encodedTx : tx) === undefined) return [];
|
|
98
110
|
return verifyTransaction(encode((encodedTx !== null && encodedTx !== void 0 ? encodedTx : tx).rlpEncoded, Encoding.Transaction), node, [...parentTxTypes, txType]);
|
|
99
|
-
}, (
|
|
111
|
+
}, (_ref6, _ref7) => {
|
|
100
112
|
let {
|
|
101
113
|
ttl
|
|
102
|
-
} =
|
|
114
|
+
} = _ref6;
|
|
103
115
|
let {
|
|
104
116
|
height
|
|
105
|
-
} =
|
|
117
|
+
} = _ref7;
|
|
106
118
|
if (ttl === undefined) return [];
|
|
107
119
|
ttl = +ttl;
|
|
108
120
|
if (ttl === 0 || ttl >= height) return [];
|
|
@@ -111,43 +123,65 @@ validators.push((_ref, _ref2) => {
|
|
|
111
123
|
key: 'ExpiredTTL',
|
|
112
124
|
checkedKeys: ['ttl']
|
|
113
125
|
}];
|
|
114
|
-
}, (
|
|
115
|
-
var
|
|
116
|
-
|
|
126
|
+
}, (_ref8, _ref9) => {
|
|
127
|
+
var _ref10, _fee;
|
|
117
128
|
let {
|
|
118
129
|
amount,
|
|
119
130
|
fee,
|
|
120
131
|
nameFee,
|
|
121
132
|
tx
|
|
122
|
-
} =
|
|
133
|
+
} = _ref8;
|
|
123
134
|
let {
|
|
124
135
|
account,
|
|
125
136
|
parentTxTypes,
|
|
126
137
|
txType
|
|
127
|
-
} =
|
|
138
|
+
} = _ref9;
|
|
128
139
|
if (account == null) return [];
|
|
129
|
-
if (((
|
|
140
|
+
if (((_ref10 = amount !== null && amount !== void 0 ? amount : fee) !== null && _ref10 !== void 0 ? _ref10 : nameFee) === undefined) return [];
|
|
130
141
|
(_fee = fee) !== null && _fee !== void 0 ? _fee : fee = 0;
|
|
131
|
-
const cost = new BigNumber(fee).plus(nameFee !== null && nameFee !== void 0 ? nameFee : 0).plus(amount !== null && amount !== void 0 ? amount : 0).plus(txType === Tag.PayingForTx ? tx.tx.encodedTx.tx.fee : 0).minus(
|
|
142
|
+
const cost = new BigNumber(fee).plus(nameFee !== null && nameFee !== void 0 ? nameFee : 0).plus(amount !== null && amount !== void 0 ? amount : 0).plus(txType === Tag.PayingForTx ? tx.tx.encodedTx.tx.fee : 0).minus(parentTxTypes.includes(Tag.PayingForTx) ? fee : 0);
|
|
132
143
|
if (cost.lte(account.balance.toString())) return [];
|
|
133
144
|
return [{
|
|
134
145
|
message: `Account balance ${account.balance.toString()} is not enough to execute the transaction that costs ${cost.toFixed()}`,
|
|
135
146
|
key: 'InsufficientBalance',
|
|
136
147
|
checkedKeys: ['amount', 'fee', 'nameFee']
|
|
137
148
|
}];
|
|
138
|
-
}, (
|
|
149
|
+
}, (_ref11, _ref12) => {
|
|
150
|
+
let {
|
|
151
|
+
signatures
|
|
152
|
+
} = _ref11;
|
|
153
|
+
let {
|
|
154
|
+
account,
|
|
155
|
+
txType
|
|
156
|
+
} = _ref12;
|
|
157
|
+
if (account == null) return [];
|
|
158
|
+
let message;
|
|
159
|
+
if (txType === Tag.SignedTx && account.kind === 'generalized' && signatures.length !== 0) {
|
|
160
|
+
message = 'Generalized account can\'t be used to generate SignedTx with signatures';
|
|
161
|
+
}
|
|
162
|
+
if (txType === Tag.GaMetaTx && account.kind === 'basic') {
|
|
163
|
+
message = 'Basic account can\'t be used to generate GaMetaTx';
|
|
164
|
+
}
|
|
165
|
+
if (message == null) return [];
|
|
166
|
+
return [{
|
|
167
|
+
message,
|
|
168
|
+
key: 'InvalidAccountType',
|
|
169
|
+
checkedKeys: ['tag']
|
|
170
|
+
}];
|
|
171
|
+
}, (_ref13, _ref14) => {
|
|
139
172
|
let {
|
|
140
173
|
nonce
|
|
141
|
-
} =
|
|
174
|
+
} = _ref13;
|
|
142
175
|
let {
|
|
143
176
|
account,
|
|
144
177
|
parentTxTypes
|
|
145
|
-
} =
|
|
146
|
-
if (nonce == null || account == null ||
|
|
178
|
+
} = _ref14;
|
|
179
|
+
if (nonce == null || account == null || parentTxTypes.includes(Tag.GaMetaTx)) return [];
|
|
147
180
|
nonce = +nonce;
|
|
148
181
|
const validNonce = account.nonce + 1;
|
|
149
182
|
if (nonce === validNonce) return [];
|
|
150
|
-
return [{
|
|
183
|
+
return [{
|
|
184
|
+
...(nonce < validNonce ? {
|
|
151
185
|
message: `Nonce ${nonce} is already used, valid nonce is ${validNonce}`,
|
|
152
186
|
key: 'NonceAlreadyUsed'
|
|
153
187
|
} : {
|
|
@@ -156,33 +190,29 @@ validators.push((_ref, _ref2) => {
|
|
|
156
190
|
}),
|
|
157
191
|
checkedKeys: ['nonce']
|
|
158
192
|
}];
|
|
159
|
-
}, (
|
|
193
|
+
}, (_ref15, _ref16) => {
|
|
160
194
|
let {
|
|
161
195
|
ctVersion,
|
|
162
196
|
abiVersion
|
|
163
|
-
} =
|
|
197
|
+
} = _ref15;
|
|
164
198
|
let {
|
|
165
199
|
txType,
|
|
166
200
|
consensusProtocolVersion
|
|
167
|
-
} =
|
|
168
|
-
|
|
201
|
+
} = _ref16;
|
|
169
202
|
if (!isKeyOfObject(consensusProtocolVersion, PROTOCOL_VM_ABI)) {
|
|
170
203
|
throw new UnsupportedProtocolError(`Unsupported protocol: ${consensusProtocolVersion}`);
|
|
171
204
|
}
|
|
205
|
+
const protocol = PROTOCOL_VM_ABI[consensusProtocolVersion];
|
|
172
206
|
|
|
173
|
-
|
|
174
|
-
|
|
207
|
+
// If not contract create tx
|
|
175
208
|
if (ctVersion == null) ctVersion = {
|
|
176
209
|
abiVersion
|
|
177
210
|
};
|
|
178
211
|
const txProtocol = protocol[txType];
|
|
179
212
|
if (txProtocol == null) return [];
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
let [key, value] = _ref14;
|
|
185
|
-
return !_includesInstanceProperty(_context = txProtocol[key]).call(_context, +value);
|
|
213
|
+
if (Object.entries(ctVersion).some(_ref17 => {
|
|
214
|
+
let [key, value] = _ref17;
|
|
215
|
+
return !txProtocol[key].includes(+value);
|
|
186
216
|
})) {
|
|
187
217
|
return [{
|
|
188
218
|
message: `ABI/VM version ${JSON.stringify(ctVersion)} is wrong, supported is: ${JSON.stringify(txProtocol)}`,
|
|
@@ -190,19 +220,17 @@ validators.push((_ref, _ref2) => {
|
|
|
190
220
|
checkedKeys: ['ctVersion', 'abiVersion']
|
|
191
221
|
}];
|
|
192
222
|
}
|
|
193
|
-
|
|
194
223
|
return [];
|
|
195
|
-
}, async (
|
|
224
|
+
}, async (_ref18, _ref19) => {
|
|
196
225
|
let {
|
|
197
226
|
contractId
|
|
198
|
-
} =
|
|
227
|
+
} = _ref18;
|
|
199
228
|
let {
|
|
200
229
|
txType,
|
|
201
230
|
node
|
|
202
|
-
} =
|
|
231
|
+
} = _ref19;
|
|
203
232
|
if (Tag.ContractCallTx !== txType) return [];
|
|
204
233
|
contractId = contractId;
|
|
205
|
-
|
|
206
234
|
try {
|
|
207
235
|
const {
|
|
208
236
|
active
|
|
@@ -215,7 +243,6 @@ validators.push((_ref, _ref2) => {
|
|
|
215
243
|
}];
|
|
216
244
|
} catch (error) {
|
|
217
245
|
var _error$response, _error$response$parse;
|
|
218
|
-
|
|
219
246
|
if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$parse = _error$response.parsedBody) === null || _error$response$parse === void 0 ? void 0 : _error$response$parse.reason) == null) throw error;
|
|
220
247
|
return [{
|
|
221
248
|
message: error.response.parsedBody.reason,
|
package/es/tx/validator.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.mjs","names":["BigNumber","hash","verify","PROTOCOL_VM_ABI","Tag","unpackTx","UnsupportedProtocolError","concatBuffers","isKeyOfObject","decode","encode","Encoding","validators","getSenderAddress","tx","map","key","filter","a","toString","replace","verifyTransaction","transaction","node","parentTxTypes","txType","address","SignedTx","encodedTx","undefined","account","height","consensusProtocolVersion","nodeNetworkId","Promise","all","getAccountByPubkey","catch","id","balance","nonce","then","acc","getCurrentKeyBlockHeight","getNodeInfo","v","flat","push","signatures","length","prefix","from","PayingForTx","join","txWithNetworkId","rlpEncoded","txHashWithNetworkId","decodedPub","message","checkedKeys","Transaction","ttl","amount","fee","nameFee","cost","plus","minus","lte","toFixed","GaMetaTx","validNonce","ctVersion","abiVersion","protocol","txProtocol","Object","entries","some","value","JSON","stringify","contractId","ContractCallTx","active","getContract","error","response","parsedBody","reason"],"sources":["../../src/tx/validator.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { hash, verify } from '../utils/crypto';\nimport {\n CtVersion,\n PROTOCOL_VM_ABI,\n RawTxObject,\n TxParamsCommon,\n TxSchema,\n TxTypeSchemas,\n} from './builder/schema';\nimport { Tag } from './builder/constants';\nimport { TxUnpacked, unpackTx } from './builder';\nimport { UnsupportedProtocolError } from '../utils/errors';\nimport { concatBuffers, isKeyOfObject } from '../utils/other';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../utils/encoder';\nimport Node from '../Node';\n\ninterface Account {\n balance: bigint;\n id: Encoded.AccountAddress;\n nonce: number;\n}\n\nexport interface ValidatorResult {\n message: string;\n key: string;\n checkedKeys: string[];\n}\n\ntype Validator = (\n tx: {\n encodedTx: TxUnpacked<TxSchema>;\n signatures: Buffer[];\n tx: TxUnpacked<TxSchema> & {\n tx: TxTypeSchemas[Tag.SignedTx];\n };\n nonce?: number;\n ttl?: number;\n amount?: number;\n fee?: number;\n nameFee?: number;\n ctVersion?: Partial<CtVersion>;\n abiVersion?: number;\n contractId?: Encoded.ContractAddress;\n },\n options: {\n account?: Account;\n nodeNetworkId: string;\n parentTxTypes: Tag[];\n node: Node;\n txType: Tag;\n height: number;\n consensusProtocolVersion: number;\n }\n) => ValidatorResult[] | Promise<ValidatorResult[]>;\n\nconst validators: Validator[] = [];\n\nconst getSenderAddress = (\n tx: TxParamsCommon | RawTxObject<TxSchema>,\n): Encoded.AccountAddress | undefined => [\n 'senderId', 'accountId', 'ownerId', 'callerId',\n 'oracleId', 'fromId', 'initiator', 'gaId', 'payerId',\n]\n .map((key: keyof TxSchema) => tx[key])\n .filter((a) => a)\n .map((a) => a?.toString().replace(/^ok_/, 'ak_'))[0] as Encoded.AccountAddress | undefined;\n\n/**\n * Transaction Validator\n * This function validates some of transaction properties,\n * to make sure it can be posted it to the chain\n * @category transaction builder\n * @param transaction - Base64Check-encoded transaction\n * @param node - Node to validate transaction against\n * @param parentTxTypes - Types of parent transactions\n * @returns Array with verification errors\n * @example const errors = await verifyTransaction(transaction, node)\n */\nexport default async function verifyTransaction(\n transaction: Encoded.Transaction | Encoded.Poi,\n node: Node,\n parentTxTypes: Tag[] = [],\n): Promise<ValidatorResult[]> {\n const { tx, txType } = unpackTx<Tag.SignedTx>(transaction);\n const address = getSenderAddress(tx)\n ?? (txType === Tag.SignedTx ? getSenderAddress(tx.encodedTx.tx) : undefined);\n const [account, { height }, { consensusProtocolVersion, nodeNetworkId }] = await Promise.all([\n address == null\n ? undefined\n : node.getAccountByPubkey(address)\n .catch(() => ({ id: address, balance: 0n, nonce: 0 }))\n // TODO: remove after fixing https://github.com/aeternity/aepp-sdk-js/issues/1537\n .then((acc) => ({ ...acc, id: acc.id as Encoded.AccountAddress })),\n node.getCurrentKeyBlockHeight(),\n node.getNodeInfo(),\n ]);\n\n return (await Promise.all(\n validators.map((v) => v(\n tx as any,\n {\n txType, node, account, height, consensusProtocolVersion, nodeNetworkId, parentTxTypes,\n },\n )),\n )).flat();\n}\n\nvalidators.push(\n ({ encodedTx, signatures }, { account, nodeNetworkId, parentTxTypes }) => {\n if ((encodedTx ?? signatures) === undefined) return [];\n if (account == null) return [];\n if (signatures.length !== 1) return []; // TODO: Support multisignature?\n const prefix = Buffer.from([\n nodeNetworkId,\n ...parentTxTypes.includes(Tag.PayingForTx) ? ['inner_tx'] : [],\n ].join('-'));\n const txWithNetworkId = concatBuffers([prefix, encodedTx.rlpEncoded]);\n const txHashWithNetworkId = concatBuffers([prefix, hash(encodedTx.rlpEncoded)]);\n const decodedPub = decode(account.id);\n if (verify(txWithNetworkId, signatures[0], decodedPub)\n || verify(txHashWithNetworkId, signatures[0], decodedPub)) return [];\n return [{\n message: 'Signature cannot be verified, please ensure that you transaction have'\n + ' the correct prefix and the correct private key for the sender address',\n key: 'InvalidSignature',\n checkedKeys: ['encodedTx', 'signatures'],\n }];\n },\n async ({ encodedTx, tx }, { node, parentTxTypes, txType }) => {\n if ((encodedTx ?? tx) === undefined) return [];\n return verifyTransaction(\n encode((encodedTx ?? tx).rlpEncoded, Encoding.Transaction),\n node,\n [...parentTxTypes, txType],\n );\n },\n ({ ttl }, { height }) => {\n if (ttl === undefined) return [];\n ttl = +ttl;\n if (ttl === 0 || ttl >= height) return [];\n return [{\n message: `TTL ${ttl} is already expired, current height is ${height}`,\n key: 'ExpiredTTL',\n checkedKeys: ['ttl'],\n }];\n },\n ({\n amount, fee, nameFee, tx,\n }, { account, parentTxTypes, txType }) => {\n if (account == null) return [];\n if ((amount ?? fee ?? nameFee) === undefined) return [];\n fee ??= 0;\n const cost = new BigNumber(fee).plus(nameFee ?? 0).plus(amount ?? 0)\n .plus(txType === Tag.PayingForTx ? (tx.tx.encodedTx.tx).fee : 0)\n .minus(parentTxTypes.includes(Tag.PayingForTx) ? fee : 0);\n if (cost.lte(account.balance.toString())) return [];\n return [{\n message: `Account balance ${account.balance.toString()} is not enough to execute the transaction that costs ${cost.toFixed()}`,\n key: 'InsufficientBalance',\n checkedKeys: ['amount', 'fee', 'nameFee'],\n }];\n },\n ({ nonce }, { account, parentTxTypes }) => {\n if (nonce == null || account == null || parentTxTypes.includes(Tag.GaMetaTx)) return [];\n nonce = +nonce;\n const validNonce = account.nonce + 1;\n if (nonce === validNonce) return [];\n return [{\n ...nonce < validNonce\n ? {\n message: `Nonce ${nonce} is already used, valid nonce is ${validNonce}`,\n key: 'NonceAlreadyUsed',\n }\n : {\n message: `Nonce ${nonce} is too high, valid nonce is ${validNonce}`,\n key: 'NonceHigh',\n },\n checkedKeys: ['nonce'],\n }];\n },\n ({ ctVersion, abiVersion }, { txType, consensusProtocolVersion }) => {\n if (!isKeyOfObject(consensusProtocolVersion, PROTOCOL_VM_ABI)) {\n throw new UnsupportedProtocolError(`Unsupported protocol: ${consensusProtocolVersion}`);\n }\n const protocol = PROTOCOL_VM_ABI[consensusProtocolVersion];\n\n // If not contract create tx\n if (ctVersion == null) ctVersion = { abiVersion };\n const txProtocol = protocol[txType as keyof typeof protocol];\n if (txProtocol == null) return [];\n if (Object.entries(ctVersion).some(\n ([\n key,\n value,\n ]: [\n key:keyof typeof txProtocol,\n value:any]) => !(txProtocol[key].includes(+value as never)),\n )) {\n return [{\n message: `ABI/VM version ${JSON.stringify(ctVersion)} is wrong, supported is: ${JSON.stringify(txProtocol)}`,\n key: 'VmAndAbiVersionMismatch',\n checkedKeys: ['ctVersion', 'abiVersion'],\n }];\n }\n return [];\n },\n async ({ contractId }, { txType, node }) => {\n if (Tag.ContractCallTx !== txType) return [];\n contractId = contractId as Encoded.ContractAddress;\n try {\n const { active } = await node.getContract(contractId);\n if (active) return [];\n return [{\n message: `Contract ${contractId} is not active`,\n key: 'ContractNotActive',\n checkedKeys: ['contractId'],\n }];\n } catch (error) {\n if (error.response?.parsedBody?.reason == null) throw error;\n return [{\n message: error.response.parsedBody.reason,\n key: 'ContractNotFound',\n checkedKeys: ['contractId'],\n }];\n }\n },\n);\n"],"mappings":";;;;;AAAA,OAAOA,SAAP,MAAsB,cAAtB;SACSC,I,EAAMC,M;SAGbC,e;SAMOC,G;SACYC,Q;SACZC,wB;SACAC,a,EA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AD7B;MAENzE,GAAG,EAAE,kBAFC;MAGN2C,WAAW,EAAE,CAAC,YAAD;IAHP,CAAD,CAAP;EAKD;AACF,CAtHH"}
|
|
1
|
+
{"version":3,"file":"validator.mjs","names":["BigNumber","hash","verify","PROTOCOL_VM_ABI","Tag","unpackTx","UnsupportedProtocolError","concatBuffers","isAccountNotFoundError","isKeyOfObject","encode","Encoding","Node","genAggressiveCacheGetResponsesPolicy","validators","getSenderAddress","tx","map","key","filter","a","toString","replace","verifyTransaction","transaction","nodeNotCached","parentTxTypes","node","pipeline","getOrderedPolicies","some","name","$host","ignoreVersion","addPolicy","txType","address","SignedTx","encodedTx","undefined","account","height","consensusProtocolVersion","nodeNetworkId","Promise","all","getAccountByPubkey","catch","error","id","balance","nonce","then","acc","getCurrentKeyBlockHeight","getNodeInfo","v","flat","push","signatures","length","prefix","from","includes","PayingForTx","join","txWithNetworkId","rlpEncoded","txHashWithNetworkId","message","checkedKeys","Transaction","ttl","amount","fee","nameFee","cost","plus","minus","lte","toFixed","kind","GaMetaTx","validNonce","ctVersion","abiVersion","protocol","txProtocol","Object","entries","value","JSON","stringify","contractId","ContractCallTx","active","getContract","response","parsedBody","reason"],"sources":["../../src/tx/validator.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { hash, verify } from '../utils/crypto';\nimport {\n CtVersion,\n PROTOCOL_VM_ABI,\n RawTxObject,\n TxParamsCommon,\n TxSchema,\n TxTypeSchemas,\n} from './builder/schema';\nimport { Tag } from './builder/constants';\nimport { TxUnpacked, unpackTx } from './builder';\nimport { UnsupportedProtocolError } from '../utils/errors';\nimport { concatBuffers, isAccountNotFoundError, isKeyOfObject } from '../utils/other';\nimport { encode, Encoded, Encoding } from '../utils/encoder';\nimport Node, { TransformNodeType } from '../Node';\nimport { Account } from '../apis/node';\nimport { genAggressiveCacheGetResponsesPolicy } from '../utils/autorest';\n\nexport interface ValidatorResult {\n message: string;\n key: string;\n checkedKeys: string[];\n}\n\ntype Validator = (\n tx: {\n encodedTx: TxUnpacked<TxSchema>;\n signatures: Buffer[];\n tx: TxUnpacked<TxSchema> & {\n tx: TxTypeSchemas[Tag.SignedTx];\n };\n nonce?: number;\n ttl?: number;\n amount?: number;\n fee?: number;\n nameFee?: number;\n ctVersion?: Partial<CtVersion>;\n abiVersion?: number;\n contractId?: Encoded.ContractAddress;\n },\n options: {\n // TODO: remove after fixing node types\n account?: TransformNodeType<Account> & { id: Encoded.AccountAddress };\n nodeNetworkId: string;\n parentTxTypes: Tag[];\n node: Node;\n txType: Tag;\n height: number;\n consensusProtocolVersion: number;\n }\n) => ValidatorResult[] | Promise<ValidatorResult[]>;\n\nconst validators: Validator[] = [];\n\nconst getSenderAddress = (\n tx: TxParamsCommon | RawTxObject<TxSchema>,\n): Encoded.AccountAddress | undefined => [\n 'senderId', 'accountId', 'ownerId', 'callerId',\n 'oracleId', 'fromId', 'initiator', 'gaId', 'payerId',\n]\n .map((key: keyof TxSchema) => tx[key])\n .filter((a) => a)\n .map((a) => a?.toString().replace(/^ok_/, 'ak_'))[0] as Encoded.AccountAddress | undefined;\n\n/**\n * Transaction Validator\n * This function validates some of transaction properties,\n * to make sure it can be posted it to the chain\n * @category transaction builder\n * @param transaction - Base64Check-encoded transaction\n * @param nodeNotCached - Node to validate transaction against\n * @param parentTxTypes - Types of parent transactions\n * @returns Array with verification errors\n * @example const errors = await verifyTransaction(transaction, node)\n */\nexport default async function verifyTransaction(\n transaction: Encoded.Transaction | Encoded.Poi,\n nodeNotCached: Node,\n parentTxTypes: Tag[] = [],\n): Promise<ValidatorResult[]> {\n let node = nodeNotCached;\n if (\n !node.pipeline.getOrderedPolicies()\n .some(({ name }) => name === 'aggressive-cache-get-responses')\n ) {\n node = new Node(nodeNotCached.$host, { ignoreVersion: true });\n node.pipeline.addPolicy(genAggressiveCacheGetResponsesPolicy());\n }\n\n const { tx, txType } = unpackTx<Tag.SignedTx>(transaction);\n const address = getSenderAddress(tx)\n ?? (txType === Tag.SignedTx ? getSenderAddress(tx.encodedTx.tx) : undefined);\n const [account, { height }, { consensusProtocolVersion, nodeNetworkId }] = await Promise.all([\n address == null\n ? undefined\n : node.getAccountByPubkey(address)\n .catch((error) => {\n if (!isAccountNotFoundError(error)) throw error;\n return { id: address, balance: 0n, nonce: 0 };\n })\n // TODO: remove after fixing https://github.com/aeternity/aepp-sdk-js/issues/1537\n .then((acc) => ({ ...acc, id: acc.id as Encoded.AccountAddress })),\n node.getCurrentKeyBlockHeight(),\n node.getNodeInfo(),\n ]);\n\n return (await Promise.all(\n validators.map((v) => v(\n tx as any,\n {\n txType, node, account, height, consensusProtocolVersion, nodeNetworkId, parentTxTypes,\n },\n )),\n )).flat();\n}\n\nvalidators.push(\n ({ encodedTx, signatures }, { account, nodeNetworkId, parentTxTypes }) => {\n if ((encodedTx ?? signatures) === undefined) return [];\n if (account == null) return [];\n if (signatures.length !== 1) return []; // TODO: Support multisignature?\n const prefix = Buffer.from([\n nodeNetworkId,\n ...parentTxTypes.includes(Tag.PayingForTx) ? ['inner_tx'] : [],\n ].join('-'));\n const txWithNetworkId = concatBuffers([prefix, encodedTx.rlpEncoded]);\n const txHashWithNetworkId = concatBuffers([prefix, hash(encodedTx.rlpEncoded)]);\n if (verify(txWithNetworkId, signatures[0], account.id)\n || verify(txHashWithNetworkId, signatures[0], account.id)) return [];\n return [{\n message: 'Signature cannot be verified, please ensure that you transaction have'\n + ' the correct prefix and the correct private key for the sender address',\n key: 'InvalidSignature',\n checkedKeys: ['encodedTx', 'signatures'],\n }];\n },\n async ({ encodedTx, tx }, { node, parentTxTypes, txType }) => {\n if ((encodedTx ?? tx) === undefined) return [];\n return verifyTransaction(\n encode((encodedTx ?? tx).rlpEncoded, Encoding.Transaction),\n node,\n [...parentTxTypes, txType],\n );\n },\n ({ ttl }, { height }) => {\n if (ttl === undefined) return [];\n ttl = +ttl;\n if (ttl === 0 || ttl >= height) return [];\n return [{\n message: `TTL ${ttl} is already expired, current height is ${height}`,\n key: 'ExpiredTTL',\n checkedKeys: ['ttl'],\n }];\n },\n ({\n amount, fee, nameFee, tx,\n }, { account, parentTxTypes, txType }) => {\n if (account == null) return [];\n if ((amount ?? fee ?? nameFee) === undefined) return [];\n fee ??= 0;\n const cost = new BigNumber(fee).plus(nameFee ?? 0).plus(amount ?? 0)\n .plus(txType === Tag.PayingForTx ? (tx.tx.encodedTx.tx).fee : 0)\n .minus(parentTxTypes.includes(Tag.PayingForTx) ? fee : 0);\n if (cost.lte(account.balance.toString())) return [];\n return [{\n message: `Account balance ${account.balance.toString()} is not enough to execute the transaction that costs ${cost.toFixed()}`,\n key: 'InsufficientBalance',\n checkedKeys: ['amount', 'fee', 'nameFee'],\n }];\n },\n ({ signatures }, { account, txType }) => {\n if (account == null) return [];\n let message;\n if (txType === Tag.SignedTx && account.kind === 'generalized' && signatures.length !== 0) {\n message = 'Generalized account can\\'t be used to generate SignedTx with signatures';\n }\n if (txType === Tag.GaMetaTx && account.kind === 'basic') {\n message = 'Basic account can\\'t be used to generate GaMetaTx';\n }\n if (message == null) return [];\n return [{ message, key: 'InvalidAccountType', checkedKeys: ['tag'] }];\n },\n ({ nonce }, { account, parentTxTypes }) => {\n if (nonce == null || account == null || parentTxTypes.includes(Tag.GaMetaTx)) return [];\n nonce = +nonce;\n const validNonce = account.nonce + 1;\n if (nonce === validNonce) return [];\n return [{\n ...nonce < validNonce\n ? {\n message: `Nonce ${nonce} is already used, valid nonce is ${validNonce}`,\n key: 'NonceAlreadyUsed',\n }\n : {\n message: `Nonce ${nonce} is too high, valid nonce is ${validNonce}`,\n key: 'NonceHigh',\n },\n checkedKeys: ['nonce'],\n }];\n },\n ({ ctVersion, abiVersion }, { txType, consensusProtocolVersion }) => {\n if (!isKeyOfObject(consensusProtocolVersion, PROTOCOL_VM_ABI)) {\n throw new UnsupportedProtocolError(`Unsupported protocol: ${consensusProtocolVersion}`);\n }\n const protocol = PROTOCOL_VM_ABI[consensusProtocolVersion];\n\n // If not contract create tx\n if (ctVersion == null) ctVersion = { abiVersion };\n const txProtocol = protocol[txType as keyof typeof protocol];\n if (txProtocol == null) return [];\n if (Object.entries(ctVersion).some(\n ([\n key,\n value,\n ]: [\n key:keyof typeof txProtocol,\n value:any]) => !(txProtocol[key].includes(+value as never)),\n )) {\n return [{\n message: `ABI/VM version ${JSON.stringify(ctVersion)} is wrong, supported is: ${JSON.stringify(txProtocol)}`,\n key: 'VmAndAbiVersionMismatch',\n checkedKeys: ['ctVersion', 'abiVersion'],\n }];\n }\n return [];\n },\n async ({ contractId }, { txType, node }) => {\n if (Tag.ContractCallTx !== txType) return [];\n contractId = contractId as Encoded.ContractAddress;\n try {\n const { active } = await node.getContract(contractId);\n if (active) return [];\n return [{\n message: `Contract ${contractId} is not active`,\n key: 'ContractNotActive',\n checkedKeys: ['contractId'],\n }];\n } catch (error) {\n if (error.response?.parsedBody?.reason == null) throw error;\n return [{\n message: error.response.parsedBody.reason,\n key: 'ContractNotFound',\n checkedKeys: ['contractId'],\n }];\n }\n },\n);\n"],"mappings":";;;;AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,IAAI,EAAEC,MAAM;AAAA,SAGnBC,eAAe;AAAA,SAMRC,GAAG;AAAA,SACSC,QAAQ;AAAA,SACpBC,wBAAwB;AAAA,SACxBC,aAAa,EAAEC,sBAAsB,EAAEC,aAAa;AAAA,SACpDC,MAAM,EAAWC,QAAQ;AAAA,OAC3BC,IAAI;AAAA,SAEFC,oCAAoC;AAoC7C,MAAMC,UAAuB,GAAG,EAAE;AAElC,MAAMC,gBAAgB,GACpBC,EAA0C,IACH,CACvC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAC9C,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,CACrD,CACEC,GAAG,CAAEC,GAAmB,IAAKF,EAAE,CAACE,GAAG,CAAC,CAAC,CACrCC,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAAC,CAChBH,GAAG,CAAEG,CAAC,IAAKA,CAAC,a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;EAClD,IAAI;IACF,MAAM;MAAEE;IAAO,CAAC,GAAG,MAAMpE,IAAI,CAACqE,WAAW,CAACH,UAAU,CAAC;IACrD,IAAIE,MAAM,EAAE,OAAO,EAAE;IACrB,OAAO,CAAC;MACN1B,OAAO,EAAG,YAAWwB,UAAW,gBAAe;MAC/C3E,GAAG,EAAE,mBAAmB;MACxBoD,WAAW,EAAE,CAAC,YAAY;IAC5B,CAAC,CAAC;EACJ,CAAC,CAAC,OAAOtB,KAAK,EAAE;IAAA;IACd,IAAI,oBAAAA,KAAK,CAACiD,QAAQ,6EAAd,gBAAgBC,UAAU,0DAA1B,sBAA4BC,MAAM,KAAI,IAAI,EAAE,MAAMnD,KAAK;IAC3D,OAAO,CAAC;MACNqB,OAAO,EAAErB,KAAK,CAACiD,QAAQ,CAACC,UAAU,CAACC,MAAM;MACzCjF,GAAG,EAAE,kBAAkB;MACvBoD,WAAW,EAAE,CAAC,YAAY;IAC5B,CAAC,CAAC;EACJ;AACF,CAAC,CACF"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mjs","names":[],"sources":["../../../src/typings/@aeternity__aepp-calldata/index.d.ts"],"sourcesContent":["declare module '@aeternity/aepp-calldata' {\n // eslint-disable-next-line import/prefer-default-export\n export class Encoder {\n constructor(aci: object);\n\n encode(contract: string, funName: string, args: any[]): `cb_${string}`;\n\n decode(contract: string, funName: string, data: `cb_${string}`): any;\n\n decodeString(data: `cb_${string}`): Uint8Array;\n\n decodeFateString(data: `cb_${string}`): string;\n\n decodeEvent(\n contract: string,\n encodedData: `cb_${string}`,\n topics: BigInt[],\n ): { [key: string]: any[] };\n }\n}\n"],"mappings":""}
|