@aeternity/aepp-sdk 13.2.2 → 13.3.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/LICENSE +1 -1
- package/README.md +1 -1
- package/bin/aesophia_cli +0 -0
- package/bin/aesophia_cli_8 +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 +9171 -7086
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +3 -0
- package/es/AeSdk.mjs +12 -12
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +0 -1
- package/es/AeSdkAepp.mjs +12 -16
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +61 -6
- package/es/AeSdkBase.mjs +150 -69
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +19 -7
- package/es/AeSdkMethods.mjs +39 -38
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/AeSdkWallet.mjs +86 -55
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Middleware.mjs +31 -27
- package/es/Middleware.mjs.map +1 -1
- package/es/MiddlewareSubscriber.mjs +5 -14
- package/es/MiddlewareSubscriber.mjs.map +1 -1
- package/es/Node.d.ts +10 -2
- package/es/Node.mjs +53 -54
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +39 -3
- package/es/account/Base.mjs +35 -1
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.d.ts +2 -0
- package/es/account/Generalized.mjs +15 -6
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.d.ts +2 -0
- package/es/account/Ledger.mjs +14 -5
- package/es/account/Ledger.mjs.map +1 -1
- package/es/account/LedgerFactory.mjs +4 -6
- package/es/account/LedgerFactory.mjs.map +1 -1
- package/es/account/Memory.d.ts +15 -4
- package/es/account/Memory.mjs +96 -31
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +16 -5
- package/es/account/Rpc.mjs +94 -21
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +17 -44
- package/es/aens.mjs +32 -71
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +3 -4
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +7 -5
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +8 -9
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +7 -7
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +14 -0
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.d.ts +2 -0
- package/es/aepp-wallet-communication/schema.mjs +2 -0
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +4 -5
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +1 -0
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.mjs +13 -0
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/compiler/models/parameters.mjs.map +1 -1
- package/es/apis/middleware/middleware.d.ts +23 -5
- package/es/apis/middleware/middleware.mjs +114 -18
- package/es/apis/middleware/middleware.mjs.map +1 -1
- package/es/apis/middleware/models/index.d.ts +164 -15
- package/es/apis/middleware/models/index.mjs +53 -3
- package/es/apis/middleware/models/index.mjs.map +1 -1
- package/es/apis/middleware/models/mappers.d.ts +8 -1
- package/es/apis/middleware/models/mappers.mjs +376 -3
- package/es/apis/middleware/models/mappers.mjs.map +1 -1
- package/es/apis/middleware/models/parameters.d.ts +6 -3
- package/es/apis/middleware/models/parameters.mjs +38 -11
- package/es/apis/middleware/models/parameters.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +66 -2
- package/es/apis/node/models/index.mjs.map +1 -1
- package/es/apis/node/models/mappers.d.ts +5 -1
- package/es/apis/node/models/mappers.mjs +229 -7
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/parameters.d.ts +2 -2
- package/es/apis/node/models/parameters.mjs +2 -2
- package/es/apis/node/models/parameters.mjs.map +1 -1
- package/es/apis/node/node.d.ts +24 -3
- package/es/apis/node/node.mjs +135 -3
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +14 -44
- package/es/chain.mjs +125 -219
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +3 -47
- package/es/channel/Base.mjs +21 -54
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.d.ts +16 -25
- package/es/channel/Contract.mjs +39 -63
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +0 -8
- package/es/channel/Spend.mjs +17 -29
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +1 -1
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +104 -5
- package/es/channel/internal.mjs +26 -34
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +9 -1
- package/es/contract/Contract.mjs +67 -73
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +14 -8
- package/es/contract/compiler/Base.mjs.map +1 -1
- package/es/contract/compiler/Cli.d.ts +5 -9
- package/es/contract/compiler/Cli.mjs +45 -23
- package/es/contract/compiler/Cli.mjs.map +1 -1
- package/es/contract/compiler/Cli8.d.ts +13 -0
- package/es/contract/compiler/Cli8.mjs +22 -0
- package/es/contract/compiler/Cli8.mjs.map +1 -0
- package/es/contract/compiler/Http.d.ts +3 -9
- package/es/contract/compiler/Http.mjs +28 -16
- package/es/contract/compiler/Http.mjs.map +1 -1
- package/es/contract/compiler/HttpNode.d.ts +2 -5
- package/es/contract/compiler/HttpNode.mjs.map +1 -1
- package/es/contract/delegation-signature.d.ts +2 -1
- package/es/contract/delegation-signature.mjs +18 -14
- package/es/contract/delegation-signature.mjs.map +1 -1
- package/es/contract/ga.d.ts +1 -2
- package/es/contract/ga.mjs +23 -25
- package/es/contract/ga.mjs.map +1 -1
- package/es/deprecated.d.ts +38 -0
- package/es/deprecated.mjs +45 -0
- package/es/deprecated.mjs.map +1 -1
- package/es/index-browser.d.ts +10 -5
- package/es/index-browser.mjs +9 -5
- package/es/index-browser.mjs.map +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.mjs +1 -0
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +6 -37
- package/es/oracle.mjs +32 -66
- package/es/oracle.mjs.map +1 -1
- package/es/send-transaction.d.ts +53 -0
- package/es/send-transaction.mjs +109 -0
- package/es/send-transaction.mjs.map +1 -0
- package/es/spend.d.ts +4 -3
- package/es/spend.mjs +6 -1
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/common.d.ts +29 -0
- package/es/tx/builder/common.mjs +42 -0
- package/es/tx/builder/common.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +4 -4
- package/es/tx/builder/constants.mjs +6 -15
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/delegation/index.d.ts +20 -0
- package/es/tx/builder/delegation/index.mjs +24 -0
- package/es/tx/builder/delegation/index.mjs.map +1 -0
- package/es/tx/builder/delegation/schema.d.ts +130 -0
- package/es/tx/builder/delegation/schema.generated.d.ts +141 -0
- package/es/tx/builder/delegation/schema.generated.mjs +2 -0
- package/es/tx/builder/delegation/schema.generated.mjs.map +1 -0
- package/es/tx/builder/delegation/schema.mjs +54 -0
- package/es/tx/builder/delegation/schema.mjs.map +1 -0
- package/es/tx/builder/field-types/abi-version.mjs +8 -11
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
- package/es/tx/builder/field-types/address.mjs +1 -4
- package/es/tx/builder/field-types/address.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +2 -2
- package/es/tx/builder/field-types/coin-amount.mjs +6 -6
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.mjs +3 -4
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
- package/es/tx/builder/field-types/entry.mjs +7 -13
- package/es/tx/builder/field-types/entry.mjs.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +19 -11
- package/es/tx/builder/field-types/fee.mjs +56 -38
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.mjs +13 -15
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +10 -2
- package/es/tx/builder/field-types/gas-price.mjs +52 -3
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +31 -29
- package/es/tx/builder/field-types/index.mjs +31 -29
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/map.mjs +20 -31
- package/es/tx/builder/field-types/map.mjs.map +1 -1
- package/es/tx/builder/field-types/mptree.mjs +14 -29
- package/es/tx/builder/field-types/mptree.mjs.map +1 -1
- package/es/tx/builder/field-types/name-fee.d.ts +1 -1
- package/es/tx/builder/field-types/name-fee.mjs +1 -1
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/nonce.d.ts +1 -0
- package/es/tx/builder/field-types/nonce.mjs +2 -0
- package/es/tx/builder/field-types/nonce.mjs.map +1 -1
- package/es/tx/builder/field-types/pointers.mjs +4 -7
- package/es/tx/builder/field-types/pointers.mjs.map +1 -1
- package/es/tx/builder/field-types/pointers2.d.ts +23 -0
- package/es/tx/builder/field-types/pointers2.mjs +65 -0
- package/es/tx/builder/field-types/pointers2.mjs.map +1 -0
- package/es/tx/builder/field-types/query-fee.d.ts +19 -0
- package/es/tx/builder/field-types/query-fee.mjs +20 -0
- package/es/tx/builder/field-types/query-fee.mjs.map +1 -0
- package/es/tx/builder/field-types/ttl.d.ts +9 -1
- package/es/tx/builder/field-types/ttl.mjs +19 -8
- package/es/tx/builder/field-types/ttl.mjs.map +1 -1
- package/es/tx/builder/field-types/with-default.d.ts +7 -0
- package/es/tx/builder/field-types/with-default.mjs +9 -0
- package/es/tx/builder/field-types/with-default.mjs.map +1 -0
- package/es/tx/builder/field-types/with-formatting.d.ts +7 -0
- package/es/tx/builder/field-types/with-formatting.mjs +9 -0
- package/es/tx/builder/field-types/with-formatting.mjs.map +1 -0
- package/es/tx/builder/field-types/wrapped.mjs +6 -8
- package/es/tx/builder/field-types/wrapped.mjs.map +1 -1
- package/es/tx/builder/helpers.d.ts +2 -2
- package/es/tx/builder/helpers.mjs +12 -21
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +17 -10
- package/es/tx/builder/index.mjs +39 -65
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +478 -257
- package/es/tx/builder/schema.generated.d.ts +39 -3
- package/es/tx/builder/schema.generated.mjs.map +1 -1
- package/es/tx/builder/schema.mjs +48 -36
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/execution-cost.d.ts +6 -5
- package/es/tx/execution-cost.mjs +16 -17
- package/es/tx/execution-cost.mjs.map +1 -1
- package/es/tx/transaction-signer.mjs +1 -4
- package/es/tx/transaction-signer.mjs.map +1 -1
- package/es/tx/validator.mjs +61 -42
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/amount-formatter.mjs +15 -22
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +2 -3
- package/es/utils/autorest.mjs +40 -24
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bytes.mjs +1 -2
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +8 -4
- package/es/utils/crypto.mjs +17 -13
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/errors.d.ts +6 -0
- package/es/utils/errors.mjs +12 -6
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +2 -0
- package/es/utils/hd-wallet.mjs +6 -5
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs +2 -10
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/jwt.d.ts +53 -0
- package/es/utils/jwt.mjs +120 -0
- package/es/utils/jwt.mjs.map +1 -0
- package/es/utils/keystore.d.ts +6 -2
- package/es/utils/keystore.mjs +8 -16
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/typed-data.mjs +1 -0
- package/es/utils/typed-data.mjs.map +1 -1
- package/es/utils/wrap-proxy.d.ts +2 -0
- package/es/utils/wrap-proxy.mjs +15 -0
- package/es/utils/wrap-proxy.mjs.map +1 -0
- package/package.json +57 -51
- package/src/AeSdk.ts +3 -0
- package/src/AeSdkAepp.ts +0 -1
- package/src/AeSdkBase.ts +97 -10
- package/src/AeSdkMethods.ts +37 -33
- package/src/AeSdkWallet.ts +22 -3
- package/src/Middleware.ts +16 -8
- package/src/MiddlewareSubscriber.ts +1 -1
- package/src/Node.ts +37 -18
- package/src/account/Base.ts +62 -3
- package/src/account/Generalized.ts +10 -0
- package/src/account/Ledger.ts +10 -0
- package/src/account/Memory.ts +83 -9
- package/src/account/Rpc.ts +69 -6
- package/src/aens.ts +35 -56
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +3 -0
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +2 -2
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -2
- package/src/aepp-wallet-communication/rpc/types.ts +13 -0
- package/src/aepp-wallet-communication/schema.ts +2 -0
- package/src/apis/compiler/compiler.ts +93 -93
- package/src/apis/compiler/models/index.ts +1 -0
- package/src/apis/compiler/models/mappers.ts +178 -165
- package/src/apis/compiler/models/parameters.ts +18 -18
- package/src/apis/middleware/middleware.ts +462 -341
- package/src/apis/middleware/models/index.ts +258 -56
- package/src/apis/middleware/models/mappers.ts +2357 -1919
- package/src/apis/middleware/models/parameters.ts +172 -142
- package/src/apis/node/models/index.ts +79 -2
- package/src/apis/node/models/mappers.ts +1529 -1302
- package/src/apis/node/models/parameters.ts +51 -51
- package/src/apis/node/node.ts +420 -275
- package/src/chain.ts +42 -128
- package/src/channel/Base.ts +14 -47
- package/src/channel/Contract.ts +18 -26
- package/src/channel/Spend.ts +0 -8
- package/src/channel/internal.ts +115 -13
- package/src/contract/Contract.ts +26 -8
- package/src/contract/compiler/Base.ts +15 -8
- package/src/contract/compiler/Cli.ts +37 -21
- package/src/contract/compiler/Cli8.ts +17 -0
- package/src/contract/compiler/Http.ts +24 -14
- package/src/contract/compiler/HttpNode.ts +2 -2
- package/src/contract/delegation-signature.ts +11 -5
- package/src/contract/ga.ts +4 -3
- package/src/deprecated.ts +36 -0
- package/src/index-browser.ts +14 -7
- package/src/index.ts +1 -0
- package/src/oracle.ts +11 -54
- package/src/send-transaction.ts +136 -0
- package/src/spend.ts +25 -11
- package/src/tx/builder/common.ts +74 -0
- package/src/tx/builder/constants.ts +6 -9
- package/src/tx/builder/delegation/index.ts +28 -0
- package/src/tx/builder/delegation/schema.generated.ts +143 -0
- package/src/tx/builder/delegation/schema.ts +61 -0
- package/src/tx/builder/field-types/coin-amount.ts +3 -2
- package/src/tx/builder/field-types/entry.ts +1 -4
- package/src/tx/builder/field-types/fee.ts +71 -43
- package/src/tx/builder/field-types/gas-limit.ts +4 -4
- package/src/tx/builder/field-types/gas-price.ts +70 -14
- package/src/tx/builder/field-types/index.ts +31 -59
- package/src/tx/builder/field-types/name-fee.ts +1 -1
- package/src/tx/builder/field-types/nonce.ts +7 -1
- package/src/tx/builder/field-types/pointers2.ts +62 -0
- package/src/tx/builder/field-types/query-fee.ts +25 -0
- package/src/tx/builder/field-types/ttl.ts +13 -3
- package/src/tx/builder/field-types/with-default.ts +18 -0
- package/src/tx/builder/field-types/with-formatting.ts +18 -0
- package/src/tx/builder/helpers.ts +2 -2
- package/src/tx/builder/index.ts +42 -59
- package/src/tx/builder/schema.generated.ts +39 -3
- package/src/tx/builder/schema.ts +55 -29
- package/src/tx/execution-cost.ts +6 -5
- package/src/tx/validator.ts +31 -5
- package/src/utils/autorest.ts +36 -27
- package/src/utils/crypto.ts +23 -13
- package/src/utils/errors.ts +10 -0
- package/src/utils/hd-wallet.ts +2 -0
- package/src/utils/jwt.ts +126 -0
- package/src/utils/keystore.ts +6 -2
- package/src/utils/wrap-proxy.ts +24 -0
- package/types-legacy/ts4.2/AeSdk.d.ts +3 -0
- package/types-legacy/ts4.2/AeSdkAepp.d.ts +0 -1
- package/types-legacy/ts4.2/AeSdkBase.d.ts +61 -6
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +19 -7
- package/types-legacy/ts4.2/Node.d.ts +14 -1
- package/types-legacy/ts4.2/account/Base.d.ts +39 -3
- package/types-legacy/ts4.2/account/Generalized.d.ts +2 -0
- package/types-legacy/ts4.2/account/Ledger.d.ts +2 -0
- package/types-legacy/ts4.2/account/Memory.d.ts +15 -4
- package/types-legacy/ts4.2/account/Rpc.d.ts +16 -5
- package/types-legacy/ts4.2/aens.d.ts +17 -44
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +14 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +2 -0
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +1 -0
- package/types-legacy/ts4.2/apis/middleware/middleware.d.ts +23 -5
- package/types-legacy/ts4.2/apis/middleware/models/index.d.ts +164 -15
- package/types-legacy/ts4.2/apis/middleware/models/mappers.d.ts +8 -1
- package/types-legacy/ts4.2/apis/middleware/models/parameters.d.ts +6 -3
- package/types-legacy/ts4.2/apis/node/models/index.d.ts +66 -2
- package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +5 -1
- package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.2/apis/node/node.d.ts +24 -3
- package/types-legacy/ts4.2/chain.d.ts +14 -44
- package/types-legacy/ts4.2/channel/Base.d.ts +3 -47
- package/types-legacy/ts4.2/channel/Contract.d.ts +16 -25
- package/types-legacy/ts4.2/channel/Spend.d.ts +0 -8
- package/types-legacy/ts4.2/channel/internal.d.ts +104 -5
- package/types-legacy/ts4.2/contract/Contract.d.ts +9 -1
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +14 -8
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +5 -9
- package/types-legacy/ts4.2/contract/compiler/Cli8.d.ts +13 -0
- package/types-legacy/ts4.2/contract/compiler/Http.d.ts +3 -9
- package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +2 -5
- package/types-legacy/ts4.2/contract/delegation-signature.d.ts +2 -1
- package/types-legacy/ts4.2/contract/ga.d.ts +1 -2
- package/types-legacy/ts4.2/deprecated.d.ts +38 -0
- package/types-legacy/ts4.2/index-browser.d.ts +10 -5
- package/types-legacy/ts4.2/index.d.ts +1 -0
- package/types-legacy/ts4.2/oracle.d.ts +6 -37
- package/types-legacy/ts4.2/send-transaction.d.ts +53 -0
- package/types-legacy/ts4.2/spend.d.ts +4 -3
- package/types-legacy/ts4.2/tx/builder/common.d.ts +32 -0
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -4
- package/types-legacy/ts4.2/tx/builder/delegation/index.d.ts +20 -0
- package/types-legacy/ts4.2/tx/builder/delegation/schema.d.ts +136 -0
- package/types-legacy/ts4.2/tx/builder/delegation/schema.generated.d.ts +141 -0
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +2 -2
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +19 -11
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +10 -2
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +31 -29
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +1 -0
- package/types-legacy/ts4.2/tx/builder/field-types/pointers2.d.ts +26 -0
- package/types-legacy/ts4.2/tx/builder/field-types/query-fee.d.ts +19 -0
- package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +9 -1
- package/types-legacy/ts4.2/tx/builder/field-types/with-default.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/with-formatting.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/helpers.d.ts +2 -2
- package/types-legacy/ts4.2/tx/builder/index.d.ts +17 -10
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +482 -257
- package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +39 -3
- package/types-legacy/ts4.2/tx/execution-cost.d.ts +6 -5
- package/types-legacy/ts4.2/utils/autorest.d.ts +2 -3
- package/types-legacy/ts4.2/utils/crypto.d.ts +8 -4
- package/types-legacy/ts4.2/utils/errors.d.ts +6 -0
- package/types-legacy/ts4.2/utils/hd-wallet.d.ts +2 -0
- package/types-legacy/ts4.2/utils/jwt.d.ts +53 -0
- package/types-legacy/ts4.2/utils/keystore.d.ts +6 -2
- package/types-legacy/ts4.2/utils/wrap-proxy.d.ts +2 -0
- package/types-legacy/ts4.5/AeSdk.d.ts +3 -0
- package/types-legacy/ts4.5/AeSdkAepp.d.ts +0 -1
- package/types-legacy/ts4.5/AeSdkBase.d.ts +61 -6
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +19 -7
- package/types-legacy/ts4.5/Node.d.ts +14 -1
- package/types-legacy/ts4.5/account/Base.d.ts +39 -3
- package/types-legacy/ts4.5/account/Generalized.d.ts +2 -0
- package/types-legacy/ts4.5/account/Ledger.d.ts +2 -0
- package/types-legacy/ts4.5/account/Memory.d.ts +15 -4
- package/types-legacy/ts4.5/account/Rpc.d.ts +16 -5
- package/types-legacy/ts4.5/aens.d.ts +17 -44
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +14 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +2 -0
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +1 -0
- package/types-legacy/ts4.5/apis/middleware/middleware.d.ts +23 -5
- package/types-legacy/ts4.5/apis/middleware/models/index.d.ts +164 -15
- package/types-legacy/ts4.5/apis/middleware/models/mappers.d.ts +8 -1
- package/types-legacy/ts4.5/apis/middleware/models/parameters.d.ts +6 -3
- package/types-legacy/ts4.5/apis/node/models/index.d.ts +66 -2
- package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +5 -1
- package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.5/apis/node/node.d.ts +24 -3
- package/types-legacy/ts4.5/chain.d.ts +14 -44
- package/types-legacy/ts4.5/channel/Base.d.ts +3 -47
- package/types-legacy/ts4.5/channel/Contract.d.ts +16 -25
- package/types-legacy/ts4.5/channel/Spend.d.ts +0 -8
- package/types-legacy/ts4.5/channel/internal.d.ts +104 -5
- package/types-legacy/ts4.5/contract/Contract.d.ts +9 -1
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +14 -8
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +5 -9
- package/types-legacy/ts4.5/contract/compiler/Cli8.d.ts +13 -0
- package/types-legacy/ts4.5/contract/compiler/Http.d.ts +3 -9
- package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +2 -5
- package/types-legacy/ts4.5/contract/delegation-signature.d.ts +2 -1
- package/types-legacy/ts4.5/contract/ga.d.ts +1 -2
- package/types-legacy/ts4.5/deprecated.d.ts +38 -0
- package/types-legacy/ts4.5/index-browser.d.ts +10 -5
- package/types-legacy/ts4.5/index.d.ts +1 -0
- package/types-legacy/ts4.5/oracle.d.ts +6 -37
- package/types-legacy/ts4.5/send-transaction.d.ts +53 -0
- package/types-legacy/ts4.5/spend.d.ts +4 -3
- package/types-legacy/ts4.5/tx/builder/common.d.ts +32 -0
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -4
- package/types-legacy/ts4.5/tx/builder/delegation/index.d.ts +20 -0
- package/types-legacy/ts4.5/tx/builder/delegation/schema.d.ts +136 -0
- package/types-legacy/ts4.5/tx/builder/delegation/schema.generated.d.ts +141 -0
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +2 -2
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +19 -11
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +10 -2
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +31 -29
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +1 -0
- package/types-legacy/ts4.5/tx/builder/field-types/pointers2.d.ts +26 -0
- package/types-legacy/ts4.5/tx/builder/field-types/query-fee.d.ts +19 -0
- package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +9 -1
- package/types-legacy/ts4.5/tx/builder/field-types/with-default.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/with-formatting.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/helpers.d.ts +2 -2
- package/types-legacy/ts4.5/tx/builder/index.d.ts +17 -10
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +482 -257
- package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +39 -3
- package/types-legacy/ts4.5/tx/execution-cost.d.ts +6 -5
- package/types-legacy/ts4.5/utils/autorest.d.ts +2 -3
- package/types-legacy/ts4.5/utils/crypto.d.ts +8 -4
- package/types-legacy/ts4.5/utils/errors.d.ts +6 -0
- package/types-legacy/ts4.5/utils/hd-wallet.d.ts +2 -0
- package/types-legacy/ts4.5/utils/jwt.d.ts +53 -0
- package/types-legacy/ts4.5/utils/keystore.d.ts +6 -2
- package/types-legacy/ts4.5/utils/wrap-proxy.d.ts +2 -0
- package/es/tx/builder/field-types/deposit.d.ts +0 -15
- package/es/tx/builder/field-types/deposit.mjs +0 -18
- package/es/tx/builder/field-types/deposit.mjs.map +0 -1
- package/src/tx/builder/field-types/deposit.ts +0 -23
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +0 -15
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +0 -15
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import shortUInt from './short-u-int';
|
|
2
2
|
import Node from '../../../Node';
|
|
3
3
|
import { ArgumentError } from '../../../utils/errors';
|
|
4
|
+
import { _getPollInterval, getHeight } from '../../../chain';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Time to leave
|
|
8
|
+
*/
|
|
5
9
|
export default {
|
|
6
10
|
...shortUInt,
|
|
7
11
|
|
|
@@ -13,11 +17,17 @@ export default {
|
|
|
13
17
|
value: number | undefined,
|
|
14
18
|
params: {},
|
|
15
19
|
// TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }
|
|
16
|
-
{
|
|
20
|
+
{
|
|
21
|
+
onNode, absoluteTtl, _isInternalBuild, ...options
|
|
22
|
+
}: {
|
|
23
|
+
onNode?: Node;
|
|
24
|
+
absoluteTtl?: boolean;
|
|
25
|
+
_isInternalBuild?: boolean;
|
|
26
|
+
} & Parameters<typeof _getPollInterval>[1],
|
|
17
27
|
) {
|
|
18
|
-
if (absoluteTtl !== true && value !== 0 && value != null) {
|
|
28
|
+
if (absoluteTtl !== true && value !== 0 && (value != null || _isInternalBuild === true)) {
|
|
19
29
|
if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);
|
|
20
|
-
value
|
|
30
|
+
value = (value ?? 3) + await getHeight({ ...options, onNode, cached: true });
|
|
21
31
|
}
|
|
22
32
|
return value;
|
|
23
33
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function withDefault<Input, Output, Binary>(
|
|
2
|
+
defaultValue: Input,
|
|
3
|
+
field: {
|
|
4
|
+
serialize: (value: Input, params: unknown) => Binary;
|
|
5
|
+
deserialize: (value: Binary, params: unknown) => Output;
|
|
6
|
+
},
|
|
7
|
+
): {
|
|
8
|
+
serialize: (value: Input | undefined, params: unknown) => Binary;
|
|
9
|
+
deserialize: (value: Binary, params: unknown) => Output;
|
|
10
|
+
} {
|
|
11
|
+
return {
|
|
12
|
+
...field,
|
|
13
|
+
|
|
14
|
+
serialize(value, params) {
|
|
15
|
+
return field.serialize(value ?? defaultValue, params);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function withFormatting<Input, Output, Binary, Params, Options>(
|
|
2
|
+
format: (v: Input | undefined) => Input,
|
|
3
|
+
field: {
|
|
4
|
+
serialize: (value: Input, params: Params, options: Options) => Binary;
|
|
5
|
+
deserialize: (value: Binary) => Output;
|
|
6
|
+
},
|
|
7
|
+
): {
|
|
8
|
+
serialize: (value: Input | undefined, params: Params, options: Options) => Binary;
|
|
9
|
+
deserialize: (value: Binary) => Output;
|
|
10
|
+
} {
|
|
11
|
+
return {
|
|
12
|
+
...field,
|
|
13
|
+
|
|
14
|
+
serialize(value, params, options) {
|
|
15
|
+
return field.serialize(format(value), params, options);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -136,7 +136,7 @@ export function readInt(buf: Buffer = Buffer.from([])): string {
|
|
|
136
136
|
/**
|
|
137
137
|
* Ensure that name is valid AENS name, would throw an exception otherwise
|
|
138
138
|
* @category AENS
|
|
139
|
-
* @param
|
|
139
|
+
* @param maybeName - AENS name
|
|
140
140
|
*/
|
|
141
141
|
export function ensureName(maybeName: string): asserts maybeName is AensName {
|
|
142
142
|
nameToPunycode(maybeName);
|
|
@@ -145,7 +145,7 @@ export function ensureName(maybeName: string): asserts maybeName is AensName {
|
|
|
145
145
|
/**
|
|
146
146
|
* Is AENS name valid
|
|
147
147
|
* @category AENS
|
|
148
|
-
* @param
|
|
148
|
+
* @param maybeName - AENS name
|
|
149
149
|
*/
|
|
150
150
|
// TODO: consider renaming to isName
|
|
151
151
|
export function isNameValid(maybeName: string): maybeName is AensName {
|
package/src/tx/builder/index.ts
CHANGED
|
@@ -1,71 +1,65 @@
|
|
|
1
|
-
import { decode as rlpDecode, encode as rlpEncode } from 'rlp';
|
|
2
1
|
import {
|
|
3
2
|
decode, encode, Encoded, Encoding,
|
|
4
3
|
} from '../../utils/encoder';
|
|
5
4
|
import { hash } from '../../utils/crypto';
|
|
6
|
-
import {
|
|
5
|
+
import { Field } from './field-types';
|
|
7
6
|
import { txSchema } from './schema';
|
|
8
7
|
import { TxUnpacked, TxParams, TxParamsAsync } from './schema.generated';
|
|
9
8
|
import { Tag } from './constants';
|
|
10
|
-
import { buildContractId
|
|
11
|
-
import {
|
|
9
|
+
import { buildContractId } from './helpers';
|
|
10
|
+
import { getSchema as getSchemaCommon, packRecord, unpackRecord } from './common';
|
|
11
|
+
import { ArgumentError } from '../../utils/errors';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* JavaScript-based Transaction builder
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
export function getSchema(tag: Tag, version?: number): Array<[string, Field]> {
|
|
18
|
-
|
|
19
|
-
if (schemas.length === 0) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, 0);
|
|
20
|
-
version ??= Math.max(...schemas.map((schema) => schema.version.constValue));
|
|
21
|
-
const schema = schemas.find((s) => s.version.constValue === version);
|
|
22
|
-
if (schema == null) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, version);
|
|
23
|
-
return Object.entries(schema);
|
|
18
|
+
return getSchemaCommon(txSchema, Tag, tag, version);
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
type TxEncoding = Encoding.Transaction | Encoding.Poi | Encoding.StateTrees
|
|
27
22
|
| Encoding.CallStateTree;
|
|
28
23
|
|
|
29
24
|
/**
|
|
30
|
-
* Build transaction
|
|
25
|
+
* Build transaction
|
|
31
26
|
* @category transaction builder
|
|
32
|
-
* @param params -
|
|
33
|
-
* @param options - options
|
|
34
|
-
* @param options.prefix - Prefix of transaction
|
|
35
|
-
* @returns object Base64Check transaction hash with 'tx_' prefix
|
|
27
|
+
* @param params - Transaction params
|
|
36
28
|
*/
|
|
37
|
-
export function buildTx
|
|
29
|
+
export function buildTx(params: TxParams): Encoded.Transaction;
|
|
30
|
+
/**
|
|
31
|
+
* Build node entry with a custom encoding
|
|
32
|
+
* @param params - Entry params
|
|
33
|
+
* @param options - Options
|
|
34
|
+
* @param options.prefix - Output encoding
|
|
35
|
+
*/
|
|
36
|
+
export function buildTx<E extends TxEncoding>(
|
|
38
37
|
params: TxParams,
|
|
39
|
-
{ prefix }: { prefix
|
|
40
|
-
): Encoded.Generic<E
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{ ...params, ...overrideParams },
|
|
54
|
-
),
|
|
55
|
-
},
|
|
56
|
-
params,
|
|
57
|
-
)
|
|
58
|
-
));
|
|
59
|
-
|
|
60
|
-
// @ts-expect-error looks like a TypeScript edge case
|
|
61
|
-
return encode(rlpEncode(binary), prefix ?? Encoding.Transaction);
|
|
38
|
+
{ prefix }: { prefix: E },
|
|
39
|
+
): Encoded.Generic<E>;
|
|
40
|
+
export function buildTx(
|
|
41
|
+
params: TxParams,
|
|
42
|
+
{ prefix }: { prefix?: TxEncoding } = {},
|
|
43
|
+
): Encoded.Generic<TxEncoding> {
|
|
44
|
+
return packRecord(txSchema, Tag, params, {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
46
|
+
unpackTx,
|
|
47
|
+
buildTx,
|
|
48
|
+
rebuildTx: (overrideParams: any) => buildTx(
|
|
49
|
+
{ ...params, ...overrideParams },
|
|
50
|
+
),
|
|
51
|
+
}, prefix ?? Encoding.Transaction);
|
|
62
52
|
}
|
|
63
53
|
|
|
64
54
|
export type BuildTxOptions <TxType extends Tag, OmitFields extends string> =
|
|
65
55
|
Omit<TxParamsAsync & { tag: TxType }, 'tag' | OmitFields>;
|
|
66
56
|
|
|
57
|
+
// TODO: require onNode because it is the only reason this builder is async [breaking change]
|
|
67
58
|
/**
|
|
59
|
+
* Build transaction async (may request node for additional data)
|
|
68
60
|
* @category transaction builder
|
|
61
|
+
* @param params - Transaction params
|
|
62
|
+
* @returns tx_-encoded transaction
|
|
69
63
|
*/
|
|
70
64
|
export async function buildTxAsync(params: TxParamsAsync): Promise<Encoded.Transaction> {
|
|
71
65
|
await Promise.all(
|
|
@@ -84,30 +78,18 @@ export async function buildTxAsync(params: TxParamsAsync): Promise<Encoded.Trans
|
|
|
84
78
|
/**
|
|
85
79
|
* Unpack transaction encoded as string
|
|
86
80
|
* @category transaction builder
|
|
87
|
-
* @param encodedTx -
|
|
81
|
+
* @param encodedTx - Encoded transaction
|
|
88
82
|
* @param txType - Expected transaction type
|
|
89
|
-
* @returns
|
|
83
|
+
* @returns Transaction params
|
|
90
84
|
*/
|
|
91
85
|
export function unpackTx<TxType extends Tag>(
|
|
92
86
|
encodedTx: Encoded.Generic<TxEncoding>,
|
|
93
87
|
txType?: TxType,
|
|
94
88
|
): TxUnpacked & { tag: TxType } {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);
|
|
100
|
-
if (binary.length !== schema.length) {
|
|
101
|
-
throw new ArgumentError('Transaction RLP length', schema.length, binary.length);
|
|
102
|
-
}
|
|
103
|
-
return schema.reduce<any>(
|
|
104
|
-
(acc, [name, field], index) => {
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
106
|
-
const deserialized = field.deserialize(binary[index] as BinaryData, { unpackTx });
|
|
107
|
-
return { ...acc, [name]: deserialized };
|
|
108
|
-
},
|
|
109
|
-
{},
|
|
110
|
-
) as any;
|
|
89
|
+
return unpackRecord(txSchema, Tag, encodedTx, txType, {
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
91
|
+
unpackTx,
|
|
92
|
+
}) as any;
|
|
111
93
|
}
|
|
112
94
|
|
|
113
95
|
/**
|
|
@@ -124,7 +106,7 @@ export function buildTxHash(rawTx: Encoded.Transaction | Uint8Array): Encoded.Tx
|
|
|
124
106
|
}
|
|
125
107
|
|
|
126
108
|
/**
|
|
127
|
-
* Build a contract public key by contractCreateTx or
|
|
109
|
+
* Build a contract public key by contractCreateTx, gaAttach or signedTx
|
|
128
110
|
* @category contract
|
|
129
111
|
* @param contractTx - Transaction
|
|
130
112
|
* @returns Contract public key
|
|
@@ -132,7 +114,8 @@ export function buildTxHash(rawTx: Encoded.Transaction | Uint8Array): Encoded.Tx
|
|
|
132
114
|
export function buildContractIdByContractTx(
|
|
133
115
|
contractTx: Encoded.Transaction,
|
|
134
116
|
): Encoded.ContractAddress {
|
|
135
|
-
|
|
117
|
+
let params = unpackTx(contractTx);
|
|
118
|
+
if (Tag.SignedTx === params.tag) params = params.encodedTx;
|
|
136
119
|
if (Tag.ContractCreateTx !== params.tag && Tag.GaAttachTx !== params.tag) {
|
|
137
120
|
throw new ArgumentError('contractTx', 'a contractCreateTx or gaAttach', params.tag);
|
|
138
121
|
}
|
|
@@ -319,6 +319,42 @@ type TxUnpackedNameUpdateTx1Type = TxUnpackedComplex & {
|
|
|
319
319
|
*/
|
|
320
320
|
export interface TxUnpackedNameUpdateTx1 extends TxUnpackedNameUpdateTx1Type {
|
|
321
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* @category transaction builder
|
|
324
|
+
*/
|
|
325
|
+
type TxParamsNameUpdateTx2Type = TxParamsComplex & {
|
|
326
|
+
tag: Tag.NameUpdateTx;
|
|
327
|
+
version: 2;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* @category transaction builder
|
|
331
|
+
*/
|
|
332
|
+
export interface TxParamsNameUpdateTx2 extends TxParamsNameUpdateTx2Type {
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @category transaction builder
|
|
336
|
+
*/
|
|
337
|
+
type TxParamsAsyncNameUpdateTx2Type = TxParamsAsyncComplex & {
|
|
338
|
+
tag: Tag.NameUpdateTx;
|
|
339
|
+
version: 2;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* @category transaction builder
|
|
343
|
+
*/
|
|
344
|
+
export interface TxParamsAsyncNameUpdateTx2 extends TxParamsAsyncNameUpdateTx2Type {
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* @category transaction builder
|
|
348
|
+
*/
|
|
349
|
+
type TxUnpackedNameUpdateTx2Type = TxUnpackedComplex & {
|
|
350
|
+
tag: Tag.NameUpdateTx;
|
|
351
|
+
version: 2;
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* @category transaction builder
|
|
355
|
+
*/
|
|
356
|
+
export interface TxUnpackedNameUpdateTx2 extends TxUnpackedNameUpdateTx2Type {
|
|
357
|
+
}
|
|
322
358
|
/**
|
|
323
359
|
* @category transaction builder
|
|
324
360
|
*/
|
|
@@ -2002,12 +2038,12 @@ export interface TxUnpackedGaMetaTxAuthData1 extends TxUnpackedGaMetaTxAuthData1
|
|
|
2002
2038
|
/**
|
|
2003
2039
|
* @category transaction builder
|
|
2004
2040
|
*/
|
|
2005
|
-
export type TxParams = TxParamsAccount1 | TxParamsAccount2 | TxParamsSignedTx1 | TxParamsSpendTx1 | TxParamsName1 | TxParamsNamePreclaimTx1 | TxParamsNameClaimTx2 | TxParamsNameUpdateTx1 | TxParamsNameTransferTx1 | TxParamsNameRevokeTx1 | TxParamsContract1 | TxParamsContractCreateTx1 | TxParamsContractCallTx1 | TxParamsContractCall2 | TxParamsOracle1 | TxParamsOracleRegisterTx1 | TxParamsOracleExtendTx1 | TxParamsOracleQueryTx1 | TxParamsOracleResponseTx1 | TxParamsChannelCreateTx2 | TxParamsChannelCloseMutualTx1 | TxParamsChannelCloseSoloTx1 | TxParamsChannelSlashTx1 | TxParamsChannelDepositTx1 | TxParamsChannelWithdrawTx1 | TxParamsChannelSettleTx1 | TxParamsChannelForceProgressTx1 | TxParamsChannelOffChainTx2 | TxParamsChannel3 | TxParamsChannelSnapshotSoloTx1 | TxParamsChannelOffChainUpdateTransfer1 | TxParamsChannelOffChainUpdateDeposit1 | TxParamsChannelOffChainUpdateWithdraw1 | TxParamsChannelOffChainUpdateCreateContract1 | TxParamsChannelOffChainUpdateCallContract1 | TxParamsChannelClientReconnectTx1 | TxParamsTreesPoi1 | TxParamsStateTrees0 | TxParamsMtree1 | TxParamsMtreeValue1 | TxParamsContractsMtree1 | TxParamsCallsMtree1 | TxParamsChannelsMtree1 | TxParamsNameserviceMtree1 | TxParamsOraclesMtree1 | TxParamsAccountsMtree1 | TxParamsGaAttachTx1 | TxParamsGaMetaTx2 | TxParamsPayingForTx1 | TxParamsGaMetaTxAuthData1;
|
|
2041
|
+
export type TxParams = TxParamsAccount1 | TxParamsAccount2 | TxParamsSignedTx1 | TxParamsSpendTx1 | TxParamsName1 | TxParamsNamePreclaimTx1 | TxParamsNameClaimTx2 | TxParamsNameUpdateTx1 | TxParamsNameUpdateTx2 | TxParamsNameTransferTx1 | TxParamsNameRevokeTx1 | TxParamsContract1 | TxParamsContractCreateTx1 | TxParamsContractCallTx1 | TxParamsContractCall2 | TxParamsOracle1 | TxParamsOracleRegisterTx1 | TxParamsOracleExtendTx1 | TxParamsOracleQueryTx1 | TxParamsOracleResponseTx1 | TxParamsChannelCreateTx2 | TxParamsChannelCloseMutualTx1 | TxParamsChannelCloseSoloTx1 | TxParamsChannelSlashTx1 | TxParamsChannelDepositTx1 | TxParamsChannelWithdrawTx1 | TxParamsChannelSettleTx1 | TxParamsChannelForceProgressTx1 | TxParamsChannelOffChainTx2 | TxParamsChannel3 | TxParamsChannelSnapshotSoloTx1 | TxParamsChannelOffChainUpdateTransfer1 | TxParamsChannelOffChainUpdateDeposit1 | TxParamsChannelOffChainUpdateWithdraw1 | TxParamsChannelOffChainUpdateCreateContract1 | TxParamsChannelOffChainUpdateCallContract1 | TxParamsChannelClientReconnectTx1 | TxParamsTreesPoi1 | TxParamsStateTrees0 | TxParamsMtree1 | TxParamsMtreeValue1 | TxParamsContractsMtree1 | TxParamsCallsMtree1 | TxParamsChannelsMtree1 | TxParamsNameserviceMtree1 | TxParamsOraclesMtree1 | TxParamsAccountsMtree1 | TxParamsGaAttachTx1 | TxParamsGaMetaTx2 | TxParamsPayingForTx1 | TxParamsGaMetaTxAuthData1;
|
|
2006
2042
|
/**
|
|
2007
2043
|
* @category transaction builder
|
|
2008
2044
|
*/
|
|
2009
|
-
export type TxParamsAsync = TxParamsAsyncAccount1 | TxParamsAsyncAccount2 | TxParamsAsyncSignedTx1 | TxParamsAsyncSpendTx1 | TxParamsAsyncName1 | TxParamsAsyncNamePreclaimTx1 | TxParamsAsyncNameClaimTx2 | TxParamsAsyncNameUpdateTx1 | TxParamsAsyncNameTransferTx1 | TxParamsAsyncNameRevokeTx1 | TxParamsAsyncContract1 | TxParamsAsyncContractCreateTx1 | TxParamsAsyncContractCallTx1 | TxParamsAsyncContractCall2 | TxParamsAsyncOracle1 | TxParamsAsyncOracleRegisterTx1 | TxParamsAsyncOracleExtendTx1 | TxParamsAsyncOracleQueryTx1 | TxParamsAsyncOracleResponseTx1 | TxParamsAsyncChannelCreateTx2 | TxParamsAsyncChannelCloseMutualTx1 | TxParamsAsyncChannelCloseSoloTx1 | TxParamsAsyncChannelSlashTx1 | TxParamsAsyncChannelDepositTx1 | TxParamsAsyncChannelWithdrawTx1 | TxParamsAsyncChannelSettleTx1 | TxParamsAsyncChannelForceProgressTx1 | TxParamsAsyncChannelOffChainTx2 | TxParamsAsyncChannel3 | TxParamsAsyncChannelSnapshotSoloTx1 | TxParamsAsyncChannelOffChainUpdateTransfer1 | TxParamsAsyncChannelOffChainUpdateDeposit1 | TxParamsAsyncChannelOffChainUpdateWithdraw1 | TxParamsAsyncChannelOffChainUpdateCreateContract1 | TxParamsAsyncChannelOffChainUpdateCallContract1 | TxParamsAsyncChannelClientReconnectTx1 | TxParamsAsyncTreesPoi1 | TxParamsAsyncStateTrees0 | TxParamsAsyncMtree1 | TxParamsAsyncMtreeValue1 | TxParamsAsyncContractsMtree1 | TxParamsAsyncCallsMtree1 | TxParamsAsyncChannelsMtree1 | TxParamsAsyncNameserviceMtree1 | TxParamsAsyncOraclesMtree1 | TxParamsAsyncAccountsMtree1 | TxParamsAsyncGaAttachTx1 | TxParamsAsyncGaMetaTx2 | TxParamsAsyncPayingForTx1 | TxParamsAsyncGaMetaTxAuthData1;
|
|
2045
|
+
export type TxParamsAsync = TxParamsAsyncAccount1 | TxParamsAsyncAccount2 | TxParamsAsyncSignedTx1 | TxParamsAsyncSpendTx1 | TxParamsAsyncName1 | TxParamsAsyncNamePreclaimTx1 | TxParamsAsyncNameClaimTx2 | TxParamsAsyncNameUpdateTx1 | TxParamsAsyncNameUpdateTx2 | TxParamsAsyncNameTransferTx1 | TxParamsAsyncNameRevokeTx1 | TxParamsAsyncContract1 | TxParamsAsyncContractCreateTx1 | TxParamsAsyncContractCallTx1 | TxParamsAsyncContractCall2 | TxParamsAsyncOracle1 | TxParamsAsyncOracleRegisterTx1 | TxParamsAsyncOracleExtendTx1 | TxParamsAsyncOracleQueryTx1 | TxParamsAsyncOracleResponseTx1 | TxParamsAsyncChannelCreateTx2 | TxParamsAsyncChannelCloseMutualTx1 | TxParamsAsyncChannelCloseSoloTx1 | TxParamsAsyncChannelSlashTx1 | TxParamsAsyncChannelDepositTx1 | TxParamsAsyncChannelWithdrawTx1 | TxParamsAsyncChannelSettleTx1 | TxParamsAsyncChannelForceProgressTx1 | TxParamsAsyncChannelOffChainTx2 | TxParamsAsyncChannel3 | TxParamsAsyncChannelSnapshotSoloTx1 | TxParamsAsyncChannelOffChainUpdateTransfer1 | TxParamsAsyncChannelOffChainUpdateDeposit1 | TxParamsAsyncChannelOffChainUpdateWithdraw1 | TxParamsAsyncChannelOffChainUpdateCreateContract1 | TxParamsAsyncChannelOffChainUpdateCallContract1 | TxParamsAsyncChannelClientReconnectTx1 | TxParamsAsyncTreesPoi1 | TxParamsAsyncStateTrees0 | TxParamsAsyncMtree1 | TxParamsAsyncMtreeValue1 | TxParamsAsyncContractsMtree1 | TxParamsAsyncCallsMtree1 | TxParamsAsyncChannelsMtree1 | TxParamsAsyncNameserviceMtree1 | TxParamsAsyncOraclesMtree1 | TxParamsAsyncAccountsMtree1 | TxParamsAsyncGaAttachTx1 | TxParamsAsyncGaMetaTx2 | TxParamsAsyncPayingForTx1 | TxParamsAsyncGaMetaTxAuthData1;
|
|
2010
2046
|
/**
|
|
2011
2047
|
* @category transaction builder
|
|
2012
2048
|
*/
|
|
2013
|
-
export type TxUnpacked = TxUnpackedAccount1 | TxUnpackedAccount2 | TxUnpackedSignedTx1 | TxUnpackedSpendTx1 | TxUnpackedName1 | TxUnpackedNamePreclaimTx1 | TxUnpackedNameClaimTx2 | TxUnpackedNameUpdateTx1 | TxUnpackedNameTransferTx1 | TxUnpackedNameRevokeTx1 | TxUnpackedContract1 | TxUnpackedContractCreateTx1 | TxUnpackedContractCallTx1 | TxUnpackedContractCall2 | TxUnpackedOracle1 | TxUnpackedOracleRegisterTx1 | TxUnpackedOracleExtendTx1 | TxUnpackedOracleQueryTx1 | TxUnpackedOracleResponseTx1 | TxUnpackedChannelCreateTx2 | TxUnpackedChannelCloseMutualTx1 | TxUnpackedChannelCloseSoloTx1 | TxUnpackedChannelSlashTx1 | TxUnpackedChannelDepositTx1 | TxUnpackedChannelWithdrawTx1 | TxUnpackedChannelSettleTx1 | TxUnpackedChannelForceProgressTx1 | TxUnpackedChannelOffChainTx2 | TxUnpackedChannel3 | TxUnpackedChannelSnapshotSoloTx1 | TxUnpackedChannelOffChainUpdateTransfer1 | TxUnpackedChannelOffChainUpdateDeposit1 | TxUnpackedChannelOffChainUpdateWithdraw1 | TxUnpackedChannelOffChainUpdateCreateContract1 | TxUnpackedChannelOffChainUpdateCallContract1 | TxUnpackedChannelClientReconnectTx1 | TxUnpackedTreesPoi1 | TxUnpackedStateTrees0 | TxUnpackedMtree1 | TxUnpackedMtreeValue1 | TxUnpackedContractsMtree1 | TxUnpackedCallsMtree1 | TxUnpackedChannelsMtree1 | TxUnpackedNameserviceMtree1 | TxUnpackedOraclesMtree1 | TxUnpackedAccountsMtree1 | TxUnpackedGaAttachTx1 | TxUnpackedGaMetaTx2 | TxUnpackedPayingForTx1 | TxUnpackedGaMetaTxAuthData1;
|
|
2049
|
+
export type TxUnpacked = TxUnpackedAccount1 | TxUnpackedAccount2 | TxUnpackedSignedTx1 | TxUnpackedSpendTx1 | TxUnpackedName1 | TxUnpackedNamePreclaimTx1 | TxUnpackedNameClaimTx2 | TxUnpackedNameUpdateTx1 | TxUnpackedNameUpdateTx2 | TxUnpackedNameTransferTx1 | TxUnpackedNameRevokeTx1 | TxUnpackedContract1 | TxUnpackedContractCreateTx1 | TxUnpackedContractCallTx1 | TxUnpackedContractCall2 | TxUnpackedOracle1 | TxUnpackedOracleRegisterTx1 | TxUnpackedOracleExtendTx1 | TxUnpackedOracleQueryTx1 | TxUnpackedOracleResponseTx1 | TxUnpackedChannelCreateTx2 | TxUnpackedChannelCloseMutualTx1 | TxUnpackedChannelCloseSoloTx1 | TxUnpackedChannelSlashTx1 | TxUnpackedChannelDepositTx1 | TxUnpackedChannelWithdrawTx1 | TxUnpackedChannelSettleTx1 | TxUnpackedChannelForceProgressTx1 | TxUnpackedChannelOffChainTx2 | TxUnpackedChannel3 | TxUnpackedChannelSnapshotSoloTx1 | TxUnpackedChannelOffChainUpdateTransfer1 | TxUnpackedChannelOffChainUpdateDeposit1 | TxUnpackedChannelOffChainUpdateWithdraw1 | TxUnpackedChannelOffChainUpdateCreateContract1 | TxUnpackedChannelOffChainUpdateCallContract1 | TxUnpackedChannelClientReconnectTx1 | TxUnpackedTreesPoi1 | TxUnpackedStateTrees0 | TxUnpackedMtree1 | TxUnpackedMtreeValue1 | TxUnpackedContractsMtree1 | TxUnpackedCallsMtree1 | TxUnpackedChannelsMtree1 | TxUnpackedNameserviceMtree1 | TxUnpackedOraclesMtree1 | TxUnpackedAccountsMtree1 | TxUnpackedGaAttachTx1 | TxUnpackedGaMetaTx2 | TxUnpackedPayingForTx1 | TxUnpackedGaMetaTxAuthData1;
|
package/src/tx/builder/schema.ts
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
import { Tag } from './constants';
|
|
8
8
|
import SchemaTypes from './SchemaTypes';
|
|
9
9
|
import {
|
|
10
|
-
uInt, shortUInt, coinAmount, name, nameId, nameFee,
|
|
11
|
-
|
|
12
|
-
array, boolean, ctVersion, abiVersion, ttl, nonce, map, wrapped,
|
|
10
|
+
uInt, shortUInt, coinAmount, name, nameId, nameFee, gasLimit, gasPrice, fee, address, pointers,
|
|
11
|
+
pointers2, queryFee, entry, enumeration, mptree, shortUIntConst, string, encoded, raw,
|
|
12
|
+
array, boolean, ctVersion, abiVersion, ttl, nonce, map, withDefault, withFormatting, wrapped,
|
|
13
13
|
} from './field-types';
|
|
14
14
|
import { Encoded, Encoding } from '../../utils/encoder';
|
|
15
|
+
import { ArgumentError } from '../../utils/errors';
|
|
15
16
|
import { idTagToEncoding } from './field-types/address';
|
|
16
17
|
|
|
17
18
|
export enum ORACLE_TTL_TYPES {
|
|
@@ -19,16 +20,6 @@ export enum ORACLE_TTL_TYPES {
|
|
|
19
20
|
block = 1,
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
// # ORACLE
|
|
23
|
-
export const ORACLE_TTL = { type: ORACLE_TTL_TYPES.delta, value: 500 };
|
|
24
|
-
export const QUERY_TTL = { type: ORACLE_TTL_TYPES.delta, value: 10 };
|
|
25
|
-
export const RESPONSE_TTL = { type: ORACLE_TTL_TYPES.delta, value: 10 };
|
|
26
|
-
// # CONTRACT
|
|
27
|
-
export const DRY_RUN_ACCOUNT = {
|
|
28
|
-
pub: 'ak_11111111111111111111111111111111273Yts',
|
|
29
|
-
amount: 100000000000000000000000000000000000n,
|
|
30
|
-
} as const;
|
|
31
|
-
|
|
32
23
|
export enum CallReturnType {
|
|
33
24
|
Ok = 0,
|
|
34
25
|
Error = 1,
|
|
@@ -132,6 +123,19 @@ interface MapOracles {
|
|
|
132
123
|
|
|
133
124
|
const mapOracles = map(Encoding.OracleAddress, Tag.Oracle) as unknown as MapOracles;
|
|
134
125
|
|
|
126
|
+
// TODO: inline after dropping Iris compatibility
|
|
127
|
+
const clientTtl = withDefault(60 * 60, shortUInt);
|
|
128
|
+
// https://github.com/aeternity/protocol/blob/fd17982/AENS.md#update
|
|
129
|
+
const nameTtl = withFormatting(
|
|
130
|
+
(value) => {
|
|
131
|
+
const NAME_TTL = 180000;
|
|
132
|
+
value ??= NAME_TTL;
|
|
133
|
+
if (value >= 1 && value <= NAME_TTL) return value;
|
|
134
|
+
throw new ArgumentError('nameTtl', `a number between 1 and ${NAME_TTL} blocks`, value);
|
|
135
|
+
},
|
|
136
|
+
shortUInt,
|
|
137
|
+
);
|
|
138
|
+
|
|
135
139
|
/**
|
|
136
140
|
* @see {@link https://github.com/aeternity/protocol/blob/c007deeac4a01e401238412801ac7084ac72d60e/serializations.md#accounts-version-1-basic-accounts}
|
|
137
141
|
*/
|
|
@@ -157,7 +161,8 @@ export const txSchema = [{
|
|
|
157
161
|
tag: shortUIntConst(Tag.SpendTx),
|
|
158
162
|
version: shortUIntConst(1, true),
|
|
159
163
|
senderId: address(Encoding.AccountAddress),
|
|
160
|
-
|
|
164
|
+
// TODO: accept also an AENS name
|
|
165
|
+
recipientId: address(Encoding.AccountAddress, Encoding.ContractAddress, Encoding.Name),
|
|
161
166
|
amount: coinAmount,
|
|
162
167
|
fee,
|
|
163
168
|
ttl,
|
|
@@ -195,9 +200,20 @@ export const txSchema = [{
|
|
|
195
200
|
accountId: address(Encoding.AccountAddress),
|
|
196
201
|
nonce: nonce('accountId'),
|
|
197
202
|
nameId,
|
|
198
|
-
nameTtl
|
|
203
|
+
nameTtl,
|
|
199
204
|
pointers,
|
|
200
|
-
clientTtl
|
|
205
|
+
clientTtl,
|
|
206
|
+
fee,
|
|
207
|
+
ttl,
|
|
208
|
+
}, {
|
|
209
|
+
tag: shortUIntConst(Tag.NameUpdateTx),
|
|
210
|
+
version: shortUIntConst(2),
|
|
211
|
+
accountId: address(Encoding.AccountAddress),
|
|
212
|
+
nonce: nonce('accountId'),
|
|
213
|
+
nameId,
|
|
214
|
+
nameTtl,
|
|
215
|
+
pointers: pointers2,
|
|
216
|
+
clientTtl,
|
|
201
217
|
fee,
|
|
202
218
|
ttl,
|
|
203
219
|
}, {
|
|
@@ -206,6 +222,7 @@ export const txSchema = [{
|
|
|
206
222
|
accountId: address(Encoding.AccountAddress),
|
|
207
223
|
nonce: nonce('accountId'),
|
|
208
224
|
nameId,
|
|
225
|
+
// TODO: accept also an AENS name
|
|
209
226
|
recipientId: address(Encoding.AccountAddress, Encoding.Name),
|
|
210
227
|
fee,
|
|
211
228
|
ttl,
|
|
@@ -226,7 +243,7 @@ export const txSchema = [{
|
|
|
226
243
|
log: encoded(Encoding.ContractBytearray),
|
|
227
244
|
active: boolean,
|
|
228
245
|
referers: array(address(Encoding.AccountAddress)),
|
|
229
|
-
deposit,
|
|
246
|
+
deposit: coinAmount,
|
|
230
247
|
}, {
|
|
231
248
|
tag: shortUIntConst(Tag.ContractCreateTx),
|
|
232
249
|
version: shortUIntConst(1, true),
|
|
@@ -236,7 +253,13 @@ export const txSchema = [{
|
|
|
236
253
|
ctVersion,
|
|
237
254
|
fee,
|
|
238
255
|
ttl,
|
|
239
|
-
deposit
|
|
256
|
+
deposit: withFormatting(
|
|
257
|
+
(value = 0) => {
|
|
258
|
+
if (+value === 0) return value;
|
|
259
|
+
throw new ArgumentError('deposit', 'equal 0 (because is not refundable)', value);
|
|
260
|
+
},
|
|
261
|
+
coinAmount,
|
|
262
|
+
),
|
|
240
263
|
amount: coinAmount,
|
|
241
264
|
gasLimit,
|
|
242
265
|
gasPrice,
|
|
@@ -246,6 +269,7 @@ export const txSchema = [{
|
|
|
246
269
|
version: shortUIntConst(1, true),
|
|
247
270
|
callerId: address(Encoding.AccountAddress),
|
|
248
271
|
nonce: nonce('callerId'),
|
|
272
|
+
// TODO: accept also an AENS name
|
|
249
273
|
contractId: address(Encoding.ContractAddress, Encoding.Name),
|
|
250
274
|
abiVersion,
|
|
251
275
|
fee,
|
|
@@ -286,18 +310,19 @@ export const txSchema = [{
|
|
|
286
310
|
queryFormat: string,
|
|
287
311
|
responseFormat: string,
|
|
288
312
|
queryFee: coinAmount,
|
|
289
|
-
oracleTtlType: enumeration(ORACLE_TTL_TYPES),
|
|
290
|
-
oracleTtlValue: shortUInt,
|
|
313
|
+
oracleTtlType: withDefault(ORACLE_TTL_TYPES.delta, enumeration(ORACLE_TTL_TYPES)),
|
|
314
|
+
oracleTtlValue: withDefault(500, shortUInt),
|
|
291
315
|
fee,
|
|
292
316
|
ttl,
|
|
293
317
|
abiVersion,
|
|
294
318
|
}, {
|
|
295
319
|
tag: shortUIntConst(Tag.OracleExtendTx),
|
|
296
320
|
version: shortUIntConst(1, true),
|
|
321
|
+
// TODO: accept also an AENS name
|
|
297
322
|
oracleId: address(Encoding.OracleAddress, Encoding.Name),
|
|
298
323
|
nonce: nonce('oracleId'),
|
|
299
|
-
oracleTtlType: enumeration(ORACLE_TTL_TYPES),
|
|
300
|
-
oracleTtlValue: shortUInt,
|
|
324
|
+
oracleTtlType: withDefault(ORACLE_TTL_TYPES.delta, enumeration(ORACLE_TTL_TYPES)),
|
|
325
|
+
oracleTtlValue: withDefault(500, shortUInt),
|
|
301
326
|
fee,
|
|
302
327
|
ttl,
|
|
303
328
|
}, {
|
|
@@ -305,13 +330,14 @@ export const txSchema = [{
|
|
|
305
330
|
version: shortUIntConst(1, true),
|
|
306
331
|
senderId: address(Encoding.AccountAddress),
|
|
307
332
|
nonce: nonce('senderId'),
|
|
333
|
+
// TODO: accept also an AENS name
|
|
308
334
|
oracleId: address(Encoding.OracleAddress, Encoding.Name),
|
|
309
335
|
query: string,
|
|
310
|
-
queryFee
|
|
311
|
-
queryTtlType: enumeration(ORACLE_TTL_TYPES),
|
|
312
|
-
queryTtlValue: shortUInt,
|
|
313
|
-
responseTtlType: enumeration(ORACLE_TTL_TYPES),
|
|
314
|
-
responseTtlValue: shortUInt,
|
|
336
|
+
queryFee,
|
|
337
|
+
queryTtlType: withDefault(ORACLE_TTL_TYPES.delta, enumeration(ORACLE_TTL_TYPES)),
|
|
338
|
+
queryTtlValue: withDefault(10, shortUInt),
|
|
339
|
+
responseTtlType: withDefault(ORACLE_TTL_TYPES.delta, enumeration(ORACLE_TTL_TYPES)),
|
|
340
|
+
responseTtlValue: withDefault(10, shortUInt),
|
|
315
341
|
fee,
|
|
316
342
|
ttl,
|
|
317
343
|
}, {
|
|
@@ -321,8 +347,8 @@ export const txSchema = [{
|
|
|
321
347
|
nonce: nonce('oracleId'),
|
|
322
348
|
queryId: encoded(Encoding.OracleQueryId),
|
|
323
349
|
response: string,
|
|
324
|
-
responseTtlType: enumeration(ORACLE_TTL_TYPES),
|
|
325
|
-
responseTtlValue: shortUInt,
|
|
350
|
+
responseTtlType: withDefault(ORACLE_TTL_TYPES.delta, enumeration(ORACLE_TTL_TYPES)),
|
|
351
|
+
responseTtlValue: withDefault(10, shortUInt),
|
|
326
352
|
fee,
|
|
327
353
|
ttl,
|
|
328
354
|
}, {
|
package/src/tx/execution-cost.ts
CHANGED
|
@@ -29,10 +29,11 @@ import getTransactionSignerAddress from './transaction-signer';
|
|
|
29
29
|
* the SDK calculates the overall price of any transaction on its side.
|
|
30
30
|
*
|
|
31
31
|
* @param transaction - Transaction to calculate the cost of
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
32
|
+
* @param options - Options
|
|
33
|
+
* @param options.innerTx - Should be provided if transaction wrapped with Tag.PayingForTx
|
|
34
|
+
* @param options.gasUsed - Amount of gas actually used to make calculation more accurate
|
|
35
|
+
* @param options.queryFee - Oracle query fee
|
|
36
|
+
* @param options.isInitiator - Is transaction signer an initiator of state channel
|
|
36
37
|
*/
|
|
37
38
|
export function getExecutionCost(
|
|
38
39
|
transaction: Encoded.Transaction,
|
|
@@ -122,8 +123,8 @@ export function getExecutionCostBySignedTx(
|
|
|
122
123
|
* Calculates the cost of signed and not signed transaction execution using node
|
|
123
124
|
* @param transaction - Transaction to calculate the cost of
|
|
124
125
|
* @param node - Node to use
|
|
125
|
-
* @param isMined - Is transaction already mined or not
|
|
126
126
|
* @param options - Options
|
|
127
|
+
* @param options.isMined - Is transaction already mined or not
|
|
127
128
|
*/
|
|
128
129
|
export async function getExecutionCostUsingNode(
|
|
129
130
|
transaction: Encoded.Transaction,
|
package/src/tx/validator.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RestError } from '@azure/core-rest-pipeline';
|
|
2
|
-
import { hash, verify } from '../utils/crypto';
|
|
2
|
+
import { hash, isAddressValid, verify } from '../utils/crypto';
|
|
3
3
|
import { TxUnpacked } from './builder/schema.generated';
|
|
4
4
|
import { CtVersion, ProtocolToVmAbi } from './builder/field-types/ct-version';
|
|
5
5
|
import { Tag, ConsensusProtocolVersion } from './builder/constants';
|
|
6
6
|
import { buildTx, unpackTx } from './builder';
|
|
7
7
|
import { concatBuffers, isAccountNotFoundError } from '../utils/other';
|
|
8
|
-
import { Encoded, decode } from '../utils/encoder';
|
|
8
|
+
import { Encoded, Encoding, decode } from '../utils/encoder';
|
|
9
9
|
import Node, { TransformNodeType } from '../Node';
|
|
10
10
|
import { Account } from '../apis/node';
|
|
11
11
|
import { genAggressiveCacheGetResponsesPolicy } from '../utils/autorest';
|
|
@@ -48,7 +48,7 @@ async function verifyTransactionInternal(
|
|
|
48
48
|
})
|
|
49
49
|
// TODO: remove after fixing https://github.com/aeternity/aepp-sdk-js/issues/1537
|
|
50
50
|
.then((acc) => ({ ...acc, id: acc.id as Encoded.AccountAddress })),
|
|
51
|
-
node.getCurrentKeyBlockHeight(),
|
|
51
|
+
node.getCurrentKeyBlockHeight(), // TODO: don't request height on each validation, use caching
|
|
52
52
|
node.getNodeInfo(),
|
|
53
53
|
]);
|
|
54
54
|
|
|
@@ -115,7 +115,7 @@ validators.push(
|
|
|
115
115
|
},
|
|
116
116
|
(tx, { height }) => {
|
|
117
117
|
if (!('ttl' in tx)) return [];
|
|
118
|
-
if (tx.ttl === 0 || tx.ttl
|
|
118
|
+
if (tx.ttl === 0 || tx.ttl > height) return [];
|
|
119
119
|
return [{
|
|
120
120
|
message: `TTL ${tx.ttl} is already expired, current height is ${height}`,
|
|
121
121
|
key: 'ExpiredTTL',
|
|
@@ -132,6 +132,19 @@ validators.push(
|
|
|
132
132
|
checkedKeys: ['amount', 'fee', 'nameFee', 'gasLimit', 'gasPrice'],
|
|
133
133
|
}];
|
|
134
134
|
},
|
|
135
|
+
async (tx, { node }) => {
|
|
136
|
+
if (tx.tag !== Tag.SpendTx || isAddressValid(tx.recipientId, Encoding.Name)) return [];
|
|
137
|
+
const recipient = await node.getAccountByPubkey(tx.recipientId).catch((error) => {
|
|
138
|
+
if (!isAccountNotFoundError(error)) throw error;
|
|
139
|
+
return null;
|
|
140
|
+
});
|
|
141
|
+
if (recipient == null || recipient.payable === true) return [];
|
|
142
|
+
return [{
|
|
143
|
+
message: 'Recipient account is not payable',
|
|
144
|
+
key: 'RecipientAccountNotPayable',
|
|
145
|
+
checkedKeys: ['recipientId'],
|
|
146
|
+
}];
|
|
147
|
+
},
|
|
135
148
|
(tx, { account }) => {
|
|
136
149
|
let message;
|
|
137
150
|
if (tx.tag === Tag.SignedTx && account.kind === 'generalized' && tx.signatures.length !== 0) {
|
|
@@ -146,7 +159,7 @@ validators.push(
|
|
|
146
159
|
// TODO: revert nonce check
|
|
147
160
|
// TODO: ensure nonce valid when paying for own tx
|
|
148
161
|
(tx, { consensusProtocolVersion }) => {
|
|
149
|
-
const oracleCall = Tag.
|
|
162
|
+
const oracleCall = Tag.OracleRegisterTx === tx.tag;
|
|
150
163
|
const contractCreate = Tag.ContractCreateTx === tx.tag || Tag.GaAttachTx === tx.tag;
|
|
151
164
|
const contractCall = Tag.ContractCallTx === tx.tag || Tag.GaMetaTx === tx.tag;
|
|
152
165
|
const type = (oracleCall ? 'oracle-call' : null)
|
|
@@ -176,6 +189,8 @@ validators.push(
|
|
|
176
189
|
},
|
|
177
190
|
async (tx, { node }) => {
|
|
178
191
|
if (Tag.ContractCallTx !== tx.tag) return [];
|
|
192
|
+
// TODO: remove after solving https://github.com/aeternity/aeternity/issues/3669
|
|
193
|
+
if (tx.contractId.startsWith('nm_')) return [];
|
|
179
194
|
try {
|
|
180
195
|
const { active } = await node.getContract(tx.contractId);
|
|
181
196
|
if (active) return [];
|
|
@@ -193,4 +208,15 @@ validators.push(
|
|
|
193
208
|
}];
|
|
194
209
|
}
|
|
195
210
|
},
|
|
211
|
+
// TODO: move to fee field of tx builder after dropping Iris
|
|
212
|
+
(tx, { consensusProtocolVersion }) => ((
|
|
213
|
+
Tag.GaAttachTx === tx.tag
|
|
214
|
+
&& ConsensusProtocolVersion.Ceres === consensusProtocolVersion
|
|
215
|
+
&& tx.nonce !== 1
|
|
216
|
+
) ? [{
|
|
217
|
+
message: `Account ${tx.ownerId} can't become generalized because it is already used`,
|
|
218
|
+
key: 'AccountUsed',
|
|
219
|
+
checkedKeys: ['nonce'],
|
|
220
|
+
}]
|
|
221
|
+
: []),
|
|
196
222
|
);
|