@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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import SchemaTypes from '../SchemaTypes';
|
|
2
|
+
import { address, nameId, shortUIntConst } from '../field-types';
|
|
3
|
+
import {
|
|
4
|
+
Encoded, Encoding, decode, encode,
|
|
5
|
+
} from '../../../utils/encoder';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @category delegation signature
|
|
9
|
+
*/
|
|
10
|
+
export enum DelegationTag {
|
|
11
|
+
AensWildcard = 1,
|
|
12
|
+
AensName = 2,
|
|
13
|
+
AensPreclaim = 3,
|
|
14
|
+
Oracle = 4,
|
|
15
|
+
OracleResponse = 5,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const oracleAddressField = address(Encoding.OracleAddress);
|
|
19
|
+
const queryIdField = {
|
|
20
|
+
serialize(value: Encoded.OracleQueryId): Buffer {
|
|
21
|
+
return oracleAddressField.serialize(encode(decode(value), Encoding.OracleAddress));
|
|
22
|
+
},
|
|
23
|
+
deserialize(value: Buffer): Encoded.OracleQueryId {
|
|
24
|
+
return encode(decode(oracleAddressField.deserialize(value)), Encoding.OracleQueryId);
|
|
25
|
+
},
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @see {@link https://github.com/aeternity/protocol/blob/8a9d1d1206174627f6aaef86159dc9c643080653/contracts/fate.md#from-ceres-serialized-signature-data}
|
|
30
|
+
*/
|
|
31
|
+
export const schemas = [{
|
|
32
|
+
tag: shortUIntConst(DelegationTag.AensWildcard),
|
|
33
|
+
version: shortUIntConst(1, true),
|
|
34
|
+
accountAddress: address(Encoding.AccountAddress),
|
|
35
|
+
contractAddress: address(Encoding.ContractAddress),
|
|
36
|
+
}, {
|
|
37
|
+
tag: shortUIntConst(DelegationTag.AensName),
|
|
38
|
+
version: shortUIntConst(1, true),
|
|
39
|
+
accountAddress: address(Encoding.AccountAddress),
|
|
40
|
+
nameId,
|
|
41
|
+
contractAddress: address(Encoding.ContractAddress),
|
|
42
|
+
}, {
|
|
43
|
+
tag: shortUIntConst(DelegationTag.AensPreclaim),
|
|
44
|
+
version: shortUIntConst(1, true),
|
|
45
|
+
accountAddress: address(Encoding.AccountAddress),
|
|
46
|
+
contractAddress: address(Encoding.ContractAddress),
|
|
47
|
+
}, {
|
|
48
|
+
tag: shortUIntConst(DelegationTag.Oracle),
|
|
49
|
+
version: shortUIntConst(1, true),
|
|
50
|
+
accountAddress: address(Encoding.AccountAddress),
|
|
51
|
+
contractAddress: address(Encoding.ContractAddress),
|
|
52
|
+
}, {
|
|
53
|
+
tag: shortUIntConst(DelegationTag.OracleResponse),
|
|
54
|
+
version: shortUIntConst(1, true),
|
|
55
|
+
queryId: queryIdField,
|
|
56
|
+
contractAddress: address(Encoding.ContractAddress),
|
|
57
|
+
}] as const;
|
|
58
|
+
|
|
59
|
+
type Schemas = SchemaTypes<typeof schemas>;
|
|
60
|
+
export type DlgParams = Schemas['TxParams'];
|
|
61
|
+
export type DlgUnpacked = Schemas['TxUnpacked'];
|
|
@@ -6,19 +6,20 @@ export default {
|
|
|
6
6
|
...uInt,
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
-
serializeAettos(value: string | undefined, params: {}): string {
|
|
9
|
+
serializeAettos(value: string | undefined, params: {}, options: {}): string {
|
|
10
10
|
return value ?? '0';
|
|
11
11
|
},
|
|
12
12
|
|
|
13
13
|
serialize(
|
|
14
14
|
value: Int | undefined,
|
|
15
15
|
params: {},
|
|
16
|
-
{ denomination = AE_AMOUNT_FORMATS.AETTOS }: { denomination?: AE_AMOUNT_FORMATS },
|
|
16
|
+
{ denomination = AE_AMOUNT_FORMATS.AETTOS, ...options }: { denomination?: AE_AMOUNT_FORMATS },
|
|
17
17
|
): Buffer {
|
|
18
18
|
return uInt.serialize(
|
|
19
19
|
this.serializeAettos(
|
|
20
20
|
value != null ? formatAmount(value, { denomination }) : value,
|
|
21
21
|
params,
|
|
22
|
+
options,
|
|
22
23
|
),
|
|
23
24
|
);
|
|
24
25
|
},
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
decode, encode, Encoded, Encoding,
|
|
3
3
|
} from '../../../utils/encoder';
|
|
4
4
|
import { Tag } from '../constants';
|
|
5
|
-
import { ArgumentError } from '../../../utils/errors';
|
|
6
5
|
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
7
6
|
|
|
8
7
|
export default function genEntryField<T extends Tag = Tag>(tag?: T): {
|
|
@@ -28,9 +27,7 @@ export default function genEntryField<T extends Tag = Tag>(tag?: T): {
|
|
|
28
27
|
},
|
|
29
28
|
|
|
30
29
|
deserialize(buf, { unpackTx }) {
|
|
31
|
-
|
|
32
|
-
if (tag != null && tx.tag !== tag) throw new ArgumentError('Tag', Tag[tag], Tag[tx.tag]);
|
|
33
|
-
return tx;
|
|
30
|
+
return unpackTx(encode(buf, Encoding.Transaction), tag);
|
|
34
31
|
},
|
|
35
32
|
};
|
|
36
33
|
}
|
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { IllegalArgumentError } from '../../../utils/errors';
|
|
3
|
-
import { MIN_GAS_PRICE, Tag } from '../constants';
|
|
2
|
+
import { ArgumentError, IllegalArgumentError } from '../../../utils/errors';
|
|
3
|
+
import { Int, MIN_GAS_PRICE, Tag } from '../constants';
|
|
4
|
+
import uInt from './u-int';
|
|
4
5
|
import coinAmount from './coin-amount';
|
|
6
|
+
import { getCachedIncreasedGasPrice } from './gas-price';
|
|
5
7
|
import { isKeyOfObject } from '../../../utils/other';
|
|
6
8
|
import { decode, Encoded } from '../../../utils/encoder';
|
|
7
9
|
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
10
|
+
import Node from '../../../Node';
|
|
8
11
|
|
|
9
12
|
const BASE_GAS = 15000;
|
|
10
13
|
const GAS_PER_BYTE = 20;
|
|
11
14
|
const KEY_BLOCK_INTERVAL = 3;
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
|
-
* Calculate the
|
|
17
|
+
* Calculate the base gas
|
|
15
18
|
* @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}
|
|
16
19
|
* @param txType - The transaction type
|
|
17
|
-
* @returns The base
|
|
20
|
+
* @returns The base gas
|
|
18
21
|
* @example
|
|
19
22
|
* ```js
|
|
20
|
-
*
|
|
23
|
+
* TX_BASE_GAS(Tag.ChannelForceProgressTx) => 30 * 15000
|
|
21
24
|
* ```
|
|
22
25
|
*/
|
|
23
|
-
const
|
|
26
|
+
const TX_BASE_GAS = (txType: Tag): number => {
|
|
24
27
|
const feeFactors = {
|
|
25
28
|
[Tag.ChannelForceProgressTx]: 30,
|
|
26
29
|
[Tag.ChannelOffChainTx]: 0,
|
|
27
|
-
[Tag.ChannelOffChainUpdateCallContract]: 0,
|
|
28
|
-
[Tag.ChannelOffChainUpdateCreateContract]: 0,
|
|
29
|
-
[Tag.ChannelOffChainUpdateDeposit]: 0,
|
|
30
|
-
[Tag.ChannelOffChainUpdateWithdraw]: 0,
|
|
31
|
-
[Tag.ChannelOffChainUpdateTransfer]: 0,
|
|
32
30
|
[Tag.ContractCreateTx]: 5,
|
|
33
31
|
[Tag.ContractCallTx]: 12,
|
|
34
32
|
[Tag.GaAttachTx]: 5,
|
|
@@ -36,44 +34,41 @@ const TX_FEE_BASE_GAS = (txType: Tag): BigNumber => {
|
|
|
36
34
|
[Tag.PayingForTx]: 1 / 5,
|
|
37
35
|
} as const;
|
|
38
36
|
const factor = feeFactors[txType as keyof typeof feeFactors] ?? 1;
|
|
39
|
-
return
|
|
37
|
+
return factor * BASE_GAS;
|
|
40
38
|
};
|
|
41
39
|
|
|
42
40
|
/**
|
|
43
|
-
* Calculate
|
|
41
|
+
* Calculate gas for other types of transactions
|
|
44
42
|
* @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}
|
|
45
43
|
* @param txType - The transaction type
|
|
46
44
|
* @param txSize - The transaction size
|
|
47
45
|
* @returns parameters - The transaction parameters
|
|
48
46
|
* @returns parameters.relativeTtl - The relative ttl
|
|
49
47
|
* @returns parameters.innerTxSize - The size of the inner transaction
|
|
50
|
-
* @returns The
|
|
48
|
+
* @returns The other gas
|
|
51
49
|
* @example
|
|
52
50
|
* ```js
|
|
53
|
-
*
|
|
54
|
-
* =>
|
|
51
|
+
* TX_OTHER_GAS(Tag.OracleResponseTx, 10, { relativeTtl: 12, innerTxSize: 0 })
|
|
52
|
+
* => 10 * 20 + Math.ceil(32000 * 12 / Math.floor(60 * 24 * 365 / 3))
|
|
55
53
|
* ```
|
|
56
54
|
*/
|
|
57
|
-
const
|
|
55
|
+
const TX_OTHER_GAS = (
|
|
58
56
|
txType: Tag,
|
|
59
57
|
txSize: number,
|
|
60
58
|
{ relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },
|
|
61
|
-
):
|
|
59
|
+
): number => {
|
|
62
60
|
switch (txType) {
|
|
63
61
|
case Tag.OracleRegisterTx:
|
|
64
62
|
case Tag.OracleExtendTx:
|
|
65
63
|
case Tag.OracleQueryTx:
|
|
66
64
|
case Tag.OracleResponseTx:
|
|
67
|
-
return
|
|
68
|
-
.
|
|
69
|
-
.plus(
|
|
70
|
-
Math.ceil((32000 * relativeTtl) / Math.floor((60 * 24 * 365) / KEY_BLOCK_INTERVAL)),
|
|
71
|
-
);
|
|
65
|
+
return txSize * GAS_PER_BYTE
|
|
66
|
+
+ Math.ceil((32000 * relativeTtl) / Math.floor((60 * 24 * 365) / KEY_BLOCK_INTERVAL));
|
|
72
67
|
case Tag.GaMetaTx:
|
|
73
68
|
case Tag.PayingForTx:
|
|
74
|
-
return
|
|
69
|
+
return (txSize - innerTxSize) * GAS_PER_BYTE;
|
|
75
70
|
default:
|
|
76
|
-
return
|
|
71
|
+
return txSize * GAS_PER_BYTE;
|
|
77
72
|
}
|
|
78
73
|
};
|
|
79
74
|
|
|
@@ -91,13 +86,13 @@ function getOracleRelativeTtl(params: any): number {
|
|
|
91
86
|
}
|
|
92
87
|
|
|
93
88
|
/**
|
|
94
|
-
* Calculate
|
|
89
|
+
* Calculate gas based on tx type and params
|
|
95
90
|
*/
|
|
96
|
-
export function
|
|
91
|
+
export function buildGas(
|
|
97
92
|
builtTx: Encoded.Transaction,
|
|
98
93
|
unpackTx: typeof unpackTxType,
|
|
99
94
|
buildTx: typeof buildTxType,
|
|
100
|
-
):
|
|
95
|
+
): number {
|
|
101
96
|
const { length } = decode(builtTx);
|
|
102
97
|
const txObject = unpackTx(builtTx);
|
|
103
98
|
|
|
@@ -106,11 +101,10 @@ export function buildFee(
|
|
|
106
101
|
innerTxSize = decode(buildTx(txObject.tx.encodedTx)).length;
|
|
107
102
|
}
|
|
108
103
|
|
|
109
|
-
return
|
|
110
|
-
|
|
104
|
+
return TX_BASE_GAS(txObject.tag)
|
|
105
|
+
+ TX_OTHER_GAS(txObject.tag, length, {
|
|
111
106
|
relativeTtl: getOracleRelativeTtl(txObject), innerTxSize,
|
|
112
|
-
})
|
|
113
|
-
.times(MIN_GAS_PRICE);
|
|
107
|
+
});
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
/**
|
|
@@ -127,25 +121,46 @@ function calculateMinFee(
|
|
|
127
121
|
let previousFee;
|
|
128
122
|
do {
|
|
129
123
|
previousFee = fee;
|
|
130
|
-
fee =
|
|
124
|
+
fee = new BigNumber(MIN_GAS_PRICE).times(buildGas(rebuildTx(fee), unpackTx, buildTx));
|
|
131
125
|
} while (!fee.eq(previousFee));
|
|
132
126
|
return fee;
|
|
133
127
|
}
|
|
134
128
|
|
|
129
|
+
// TODO: Get rid of this workaround. Transaction builder can't accept/return gas price instead of
|
|
130
|
+
// fee because it may get a decimal gas price. So, it should accept the optional `gasPrice` even
|
|
131
|
+
// if it is not a contract-related transaction. And use this `gasPrice` to calculate `fee`.
|
|
132
|
+
const gasPricePrefix = '_gas-price:';
|
|
133
|
+
|
|
134
|
+
export interface SerializeAettosParams {
|
|
135
|
+
rebuildTx: (params: any) => Encoded.Transaction;
|
|
136
|
+
unpackTx: typeof unpackTxType;
|
|
137
|
+
buildTx: typeof buildTxType;
|
|
138
|
+
_computingMinFee?: BigNumber;
|
|
139
|
+
}
|
|
140
|
+
|
|
135
141
|
export default {
|
|
136
142
|
...coinAmount,
|
|
137
143
|
|
|
144
|
+
async prepare(
|
|
145
|
+
value: Int | undefined,
|
|
146
|
+
params: {},
|
|
147
|
+
{ onNode }: { onNode?: Node },
|
|
148
|
+
): Promise<Int | undefined> {
|
|
149
|
+
if (value != null) return value;
|
|
150
|
+
if (onNode == null) {
|
|
151
|
+
throw new ArgumentError('onNode', 'provided (or provide `fee` instead)', onNode);
|
|
152
|
+
}
|
|
153
|
+
const gasPrice = await getCachedIncreasedGasPrice(onNode);
|
|
154
|
+
if (gasPrice === 0n) return undefined;
|
|
155
|
+
return gasPricePrefix + gasPrice;
|
|
156
|
+
},
|
|
157
|
+
|
|
138
158
|
serializeAettos(
|
|
139
159
|
_value: string | undefined,
|
|
140
160
|
{
|
|
141
|
-
rebuildTx, unpackTx, buildTx, _computingMinFee,
|
|
142
|
-
}:
|
|
143
|
-
|
|
144
|
-
unpackTx: typeof unpackTxType;
|
|
145
|
-
buildTx: typeof buildTxType;
|
|
146
|
-
_computingMinFee?: BigNumber;
|
|
147
|
-
_pickBiggerFee?: boolean;
|
|
148
|
-
},
|
|
161
|
+
rebuildTx, unpackTx, buildTx, _computingMinFee,
|
|
162
|
+
}: SerializeAettosParams,
|
|
163
|
+
{ _canIncreaseFee }: { _canIncreaseFee?: boolean },
|
|
149
164
|
): string {
|
|
150
165
|
if (_computingMinFee != null) return _computingMinFee.toFixed();
|
|
151
166
|
const minFee = calculateMinFee(
|
|
@@ -153,11 +168,24 @@ export default {
|
|
|
153
168
|
unpackTx,
|
|
154
169
|
buildTx,
|
|
155
170
|
);
|
|
156
|
-
const value =
|
|
171
|
+
const value = _value?.startsWith(gasPricePrefix) === true
|
|
172
|
+
? minFee.dividedBy(MIN_GAS_PRICE).times(_value.replace(gasPricePrefix, ''))
|
|
173
|
+
: new BigNumber(_value ?? minFee);
|
|
157
174
|
if (minFee.gt(value)) {
|
|
158
|
-
if (
|
|
175
|
+
if (_canIncreaseFee === true) return minFee.toFixed();
|
|
159
176
|
throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger than ${minFee}`);
|
|
160
177
|
}
|
|
161
178
|
return value.toFixed();
|
|
162
179
|
},
|
|
180
|
+
|
|
181
|
+
serialize(
|
|
182
|
+
value: Parameters<typeof coinAmount.serialize>[0],
|
|
183
|
+
params: Parameters<typeof coinAmount.serialize>[1] & SerializeAettosParams,
|
|
184
|
+
options: { _canIncreaseFee?: boolean } & Parameters<typeof coinAmount.serialize>[2],
|
|
185
|
+
): Buffer {
|
|
186
|
+
if (typeof value === 'string' && value.startsWith(gasPricePrefix)) {
|
|
187
|
+
return uInt.serialize(this.serializeAettos(value, params, options));
|
|
188
|
+
}
|
|
189
|
+
return coinAmount.serialize.call(this, value, params, options);
|
|
190
|
+
},
|
|
163
191
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IllegalArgumentError } from '../../../utils/errors';
|
|
2
|
-
import {
|
|
2
|
+
import { Tag, MAX_AUTH_FUN_GAS } from '../constants';
|
|
3
3
|
import shortUInt from './short-u-int';
|
|
4
|
-
import {
|
|
4
|
+
import { buildGas } from './fee';
|
|
5
5
|
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
6
6
|
|
|
7
7
|
function calculateGasLimitMax(
|
|
@@ -10,7 +10,7 @@ function calculateGasLimitMax(
|
|
|
10
10
|
unpackTx: typeof unpackTxType,
|
|
11
11
|
buildTx: typeof buildTxType,
|
|
12
12
|
): number {
|
|
13
|
-
return gasMax - +
|
|
13
|
+
return gasMax - +buildGas(rebuildTx(gasMax), unpackTx, buildTx);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default {
|
|
@@ -33,7 +33,7 @@ export default {
|
|
|
33
33
|
|
|
34
34
|
const gasLimitMax = tag === Tag.GaMetaTx ? MAX_AUTH_FUN_GAS : calculateGasLimitMax(
|
|
35
35
|
gasMax,
|
|
36
|
-
(gasLimit) => rebuildTx({ _computingGasLimit: gasLimit,
|
|
36
|
+
(gasLimit) => rebuildTx({ _computingGasLimit: gasLimit, _canIncreaseFee: true }),
|
|
37
37
|
unpackTx,
|
|
38
38
|
buildTx,
|
|
39
39
|
);
|
|
@@ -1,14 +1,70 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import coinAmount from './coin-amount';
|
|
3
|
+
import { ArgumentError, IllegalArgumentError } from '../../../utils/errors';
|
|
4
|
+
import { Int, MIN_GAS_PRICE } from '../constants';
|
|
5
|
+
import Node from '../../../Node';
|
|
6
|
+
import { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter';
|
|
7
|
+
import semverSatisfies from '../../../utils/semver-satisfies';
|
|
8
|
+
|
|
9
|
+
const gasPriceCache: WeakMap<Node, { time: number; gasPrice: bigint }> = new WeakMap();
|
|
10
|
+
|
|
11
|
+
export async function getCachedIncreasedGasPrice(node: Node): Promise<bigint> {
|
|
12
|
+
const cache = gasPriceCache.get(node);
|
|
13
|
+
if (cache != null && cache.time > Date.now() - 20 * 1000) {
|
|
14
|
+
return cache.gasPrice;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// TODO: remove after requiring node@6.13.0
|
|
18
|
+
const { nodeVersion } = await node._getCachedStatus();
|
|
19
|
+
// TODO: remove remove '6.12.0+' check after releasing 6.13.0
|
|
20
|
+
if (!nodeVersion.startsWith('6.12.0+') && !semverSatisfies(nodeVersion, '6.13.0', '8.0.0')) {
|
|
21
|
+
return 0n;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { minGasPrice, utilization } = (await node.getRecentGasPrices())[0];
|
|
25
|
+
let gasPrice = utilization < 70 ? 0n : BigInt(
|
|
26
|
+
new BigNumber(minGasPrice.toString()).times(1.01).integerValue().toFixed(),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const maxSafeGasPrice = BigInt(MIN_GAS_PRICE) * 100000n; // max microblock fee is 600ae or 35usd
|
|
30
|
+
if (gasPrice > maxSafeGasPrice) {
|
|
31
|
+
console.warn([
|
|
32
|
+
`Estimated gas price ${gasPrice} exceeds the maximum safe value for unknown reason.`,
|
|
33
|
+
`It will be limited to ${maxSafeGasPrice}.`,
|
|
34
|
+
'To overcome this restriction provide `gasPrice`/`fee` in options.',
|
|
35
|
+
].join(' '));
|
|
36
|
+
gasPrice = maxSafeGasPrice;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
gasPriceCache.set(node, { gasPrice, time: Date.now() });
|
|
40
|
+
return gasPrice;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// TODO: use withFormatting after using a single type for coins representation
|
|
44
|
+
export default {
|
|
45
|
+
...coinAmount,
|
|
46
|
+
|
|
47
|
+
async prepare(
|
|
48
|
+
value: Int | undefined,
|
|
49
|
+
params: {},
|
|
50
|
+
{ onNode, denomination }: {
|
|
51
|
+
onNode?: Node;
|
|
52
|
+
denomination?: AE_AMOUNT_FORMATS;
|
|
53
|
+
},
|
|
54
|
+
): Promise<Int | undefined> {
|
|
55
|
+
if (value != null) return value;
|
|
56
|
+
if (onNode == null) {
|
|
57
|
+
throw new ArgumentError('onNode', 'provided (or provide `gasPrice` instead)', onNode);
|
|
58
|
+
}
|
|
59
|
+
const gasPrice = await getCachedIncreasedGasPrice(onNode);
|
|
60
|
+
if (gasPrice === 0n) return undefined;
|
|
61
|
+
return formatAmount(gasPrice, { targetDenomination: denomination });
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
serializeAettos(value: string | undefined = MIN_GAS_PRICE.toString()): string {
|
|
65
|
+
if (+value < MIN_GAS_PRICE) {
|
|
66
|
+
throw new IllegalArgumentError(`Gas price ${value.toString()} must be bigger than ${MIN_GAS_PRICE}`);
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
export { default as abiVersion } from './abi-version';
|
|
2
|
+
export { default as address } from './address';
|
|
3
|
+
export { default as array } from './array';
|
|
4
|
+
export { default as boolean } from './boolean';
|
|
5
|
+
export { default as coinAmount } from './coin-amount';
|
|
6
|
+
export { default as ctVersion } from './ct-version';
|
|
7
|
+
export { default as encoded } from './encoded';
|
|
8
|
+
export { default as entry } from './entry';
|
|
9
|
+
export { default as enumeration } from './enumeration';
|
|
10
|
+
export { default as fee } from './fee';
|
|
11
|
+
export { default as field } from './field';
|
|
12
|
+
export { default as gasLimit } from './gas-limit';
|
|
13
|
+
export { default as gasPrice } from './gas-price';
|
|
14
|
+
export { default as map } from './map';
|
|
15
|
+
export { default as mptree } from './mptree';
|
|
16
|
+
export { default as name } from './name';
|
|
17
|
+
export { default as nameFee } from './name-fee';
|
|
18
|
+
export { default as nameId } from './name-id';
|
|
19
|
+
export { default as nonce } from './nonce';
|
|
20
|
+
export { default as pointers } from './pointers';
|
|
21
|
+
export { default as pointers2 } from './pointers2';
|
|
22
|
+
export { default as queryFee } from './query-fee';
|
|
23
|
+
export { default as raw } from './raw';
|
|
24
|
+
export { default as shortUInt } from './short-u-int';
|
|
25
|
+
export { default as shortUIntConst } from './short-u-int-const';
|
|
26
|
+
export { default as string } from './string';
|
|
27
|
+
export { default as ttl } from './ttl';
|
|
28
|
+
export { default as uInt } from './u-int';
|
|
29
|
+
export { default as withDefault } from './with-default';
|
|
30
|
+
export { default as withFormatting } from './with-formatting';
|
|
31
|
+
export { default as wrapped } from './wrapped';
|
|
29
32
|
|
|
30
33
|
export type BinaryData = Buffer | Buffer[] | Buffer[][]
|
|
31
34
|
| Array<[Buffer, Array<[Buffer, Buffer[]]>]>;
|
|
@@ -35,34 +38,3 @@ export interface Field {
|
|
|
35
38
|
deserialize: (value: BinaryData, options: any) => any;
|
|
36
39
|
recursiveType?: boolean;
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
abiVersion,
|
|
41
|
-
address,
|
|
42
|
-
array,
|
|
43
|
-
boolean,
|
|
44
|
-
coinAmount,
|
|
45
|
-
ctVersion,
|
|
46
|
-
deposit,
|
|
47
|
-
encoded,
|
|
48
|
-
entry,
|
|
49
|
-
enumeration,
|
|
50
|
-
fee,
|
|
51
|
-
field,
|
|
52
|
-
gasLimit,
|
|
53
|
-
gasPrice,
|
|
54
|
-
map,
|
|
55
|
-
mptree,
|
|
56
|
-
name,
|
|
57
|
-
nameFee,
|
|
58
|
-
nameId,
|
|
59
|
-
nonce,
|
|
60
|
-
pointers,
|
|
61
|
-
raw,
|
|
62
|
-
shortUInt,
|
|
63
|
-
shortUIntConst,
|
|
64
|
-
string,
|
|
65
|
-
ttl,
|
|
66
|
-
uInt,
|
|
67
|
-
wrapped,
|
|
68
|
-
};
|
|
@@ -11,7 +11,11 @@ export default function genNonceField<SenderKey extends string>(senderKey: Sende
|
|
|
11
11
|
value: number | undefined,
|
|
12
12
|
params: {},
|
|
13
13
|
// TODO: replace `string` with AddressEncodings
|
|
14
|
-
options: { [key in SenderKey]: string } & {
|
|
14
|
+
options: { [key in SenderKey]: string } & {
|
|
15
|
+
strategy?: NextNonceStrategy;
|
|
16
|
+
onNode?: Node;
|
|
17
|
+
_isInternalBuild?: boolean;
|
|
18
|
+
},
|
|
15
19
|
) => Promise<number>;
|
|
16
20
|
deserialize: (value: Buffer) => number;
|
|
17
21
|
senderKey: string;
|
|
@@ -21,6 +25,8 @@ export default function genNonceField<SenderKey extends string>(senderKey: Sende
|
|
|
21
25
|
|
|
22
26
|
async prepare(value, params, options) {
|
|
23
27
|
if (value != null) return value;
|
|
28
|
+
// TODO: uncomment the below line
|
|
29
|
+
// if (options._isInternalBuild === true) return 0;
|
|
24
30
|
const { onNode, strategy } = options;
|
|
25
31
|
const senderId = options[senderKey];
|
|
26
32
|
const requirement = 'provided (or provide `nonce` instead)';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { NamePointer as NamePointerString } from '../../../apis/node';
|
|
2
|
+
import { toBytes } from '../../../utils/bytes';
|
|
3
|
+
import {
|
|
4
|
+
Encoded, Encoding, decode, encode,
|
|
5
|
+
} from '../../../utils/encoder';
|
|
6
|
+
import { isAddressValid } from '../../../utils/crypto';
|
|
7
|
+
import { IllegalArgumentError, DecodeError, ArgumentError } from '../../../utils/errors';
|
|
8
|
+
import address, { AddressEncodings, idTagToEncoding } from './address';
|
|
9
|
+
|
|
10
|
+
const ID_TAG = Buffer.from([1]);
|
|
11
|
+
const DATA_TAG = Buffer.from([2]);
|
|
12
|
+
const DATA_LENGTH_MAX = 1024;
|
|
13
|
+
const addressAny = address(...idTagToEncoding);
|
|
14
|
+
|
|
15
|
+
// TODO: remove after fixing node types
|
|
16
|
+
type NamePointer = NamePointerString & {
|
|
17
|
+
id: Encoded.Generic<AddressEncodings | Encoding.Bytearray>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
/**
|
|
22
|
+
* Helper function to build pointers for name update TX
|
|
23
|
+
* @param pointers - Array of pointers
|
|
24
|
+
* `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`
|
|
25
|
+
* @returns Serialized pointers array
|
|
26
|
+
*/
|
|
27
|
+
serialize(pointers: NamePointer[]): Buffer[][] {
|
|
28
|
+
if (pointers.length > 32) {
|
|
29
|
+
throw new IllegalArgumentError(`Expected 32 pointers or less, got ${pointers.length} instead`);
|
|
30
|
+
}
|
|
31
|
+
return pointers.map(({ key, id }) => {
|
|
32
|
+
let payload;
|
|
33
|
+
if (isAddressValid(id, ...idTagToEncoding)) payload = [ID_TAG, addressAny.serialize(id)];
|
|
34
|
+
if (isAddressValid(id, Encoding.Bytearray)) {
|
|
35
|
+
const data = decode(id);
|
|
36
|
+
if (data.length > DATA_LENGTH_MAX) {
|
|
37
|
+
throw new ArgumentError('Raw pointer', `shorter than ${DATA_LENGTH_MAX + 1} bytes`, `${data.length} bytes`);
|
|
38
|
+
}
|
|
39
|
+
payload = [DATA_TAG, data];
|
|
40
|
+
}
|
|
41
|
+
if (payload == null) throw new DecodeError(`Unknown AENS pointer value: ${id}`);
|
|
42
|
+
return [toBytes(key), Buffer.concat(payload)];
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Helper function to read pointers from name update TX
|
|
48
|
+
* @param pointers - Array of pointers
|
|
49
|
+
* @returns Deserialize pointer array
|
|
50
|
+
*/
|
|
51
|
+
deserialize(pointers: Array<[key: Buffer, id: Buffer]>): NamePointer[] {
|
|
52
|
+
return pointers.map(([bKey, bId]) => {
|
|
53
|
+
const tag = bId.subarray(0, 1);
|
|
54
|
+
const payload = bId.subarray(1);
|
|
55
|
+
let id;
|
|
56
|
+
if (tag.equals(ID_TAG)) id = addressAny.deserialize(payload);
|
|
57
|
+
if (tag.equals(DATA_TAG)) id = encode(payload, Encoding.Bytearray);
|
|
58
|
+
if (id == null) throw new DecodeError(`Unknown AENS pointer tag: ${tag}`);
|
|
59
|
+
return { key: bKey.toString(), id };
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import coinAmount from './coin-amount';
|
|
2
|
+
import { Int } from '../constants';
|
|
3
|
+
import Node from '../../../Node';
|
|
4
|
+
import { Encoded } from '../../../utils/encoder';
|
|
5
|
+
import { ArgumentError } from '../../../utils/errors';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Oracle query fee
|
|
9
|
+
*/
|
|
10
|
+
export default {
|
|
11
|
+
...coinAmount,
|
|
12
|
+
|
|
13
|
+
async prepare(
|
|
14
|
+
value: Int | undefined,
|
|
15
|
+
params: {},
|
|
16
|
+
options: { oracleId?: Encoded.OracleAddress; onNode?: Node },
|
|
17
|
+
) {
|
|
18
|
+
if (value != null) return value;
|
|
19
|
+
const { onNode, oracleId } = options;
|
|
20
|
+
const requirement = 'provided (or provide `queryFee` instead)';
|
|
21
|
+
if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);
|
|
22
|
+
if (oracleId == null) throw new ArgumentError('oracleId', requirement, oracleId);
|
|
23
|
+
return (await onNode.getOracleByPubkey(oracleId)).queryFee.toString();
|
|
24
|
+
},
|
|
25
|
+
};
|