@aeternity/aepp-sdk 13.2.2 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +58 -2
- 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
package/src/oracle.ts
CHANGED
|
@@ -9,20 +9,13 @@
|
|
|
9
9
|
import { mapObject, pause } from './utils/other';
|
|
10
10
|
import { oracleQueryId } from './tx/builder/helpers';
|
|
11
11
|
import { unpackTx, buildTxAsync, BuildTxOptions } from './tx/builder';
|
|
12
|
-
import {
|
|
13
|
-
ORACLE_TTL,
|
|
14
|
-
ORACLE_TTL_TYPES,
|
|
15
|
-
QUERY_TTL,
|
|
16
|
-
RESPONSE_TTL,
|
|
17
|
-
} from './tx/builder/schema';
|
|
18
12
|
import { Tag } from './tx/builder/constants';
|
|
19
13
|
import { RequestTimedOutError } from './utils/errors';
|
|
20
14
|
import {
|
|
21
15
|
decode, encode, Encoded, Encoding,
|
|
22
16
|
} from './utils/encoder';
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
} from './chain';
|
|
17
|
+
import { _getPollInterval, getHeight } from './chain';
|
|
18
|
+
import { sendTransaction, SendTransactionOptions } from './send-transaction';
|
|
26
19
|
import Node from './Node';
|
|
27
20
|
import AccountBase from './account/Base';
|
|
28
21
|
|
|
@@ -93,7 +86,7 @@ export async function pollForQueryResponse(
|
|
|
93
86
|
const responseBuffer = decode(response as Encoded.OracleResponse);
|
|
94
87
|
if (responseBuffer.length > 0) return responseBuffer.toString();
|
|
95
88
|
await pause(interval);
|
|
96
|
-
height = await getHeight({ onNode });
|
|
89
|
+
height = await getHeight({ ...options, onNode, cached: true });
|
|
97
90
|
} while (ttl >= height);
|
|
98
91
|
throw new RequestTimedOutError(height);
|
|
99
92
|
}
|
|
@@ -139,11 +132,6 @@ interface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQue
|
|
|
139
132
|
* @param oracleId - Oracle public key
|
|
140
133
|
* @param query - Oracle query object
|
|
141
134
|
* @param options - Options object
|
|
142
|
-
* @param options.queryTtl - queryTtl Oracle query time to leave
|
|
143
|
-
* @param options.responseTtl - queryFee Oracle query response time to leave
|
|
144
|
-
* @param options.queryFee - queryFee Oracle query fee
|
|
145
|
-
* @param options.fee - fee Transaction fee
|
|
146
|
-
* @param options.ttl - Transaction time to leave
|
|
147
135
|
* @returns Query object
|
|
148
136
|
*/
|
|
149
137
|
export async function postQueryToOracle(
|
|
@@ -153,14 +141,10 @@ export async function postQueryToOracle(
|
|
|
153
141
|
): Promise<
|
|
154
142
|
Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getQueryObject>>
|
|
155
143
|
> {
|
|
156
|
-
options.queryFee ??= (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();
|
|
157
144
|
const senderId = options.onAccount.address;
|
|
158
145
|
|
|
159
146
|
const oracleQueryTx = await buildTxAsync({
|
|
160
|
-
|
|
161
|
-
queryTtlValue: QUERY_TTL.value,
|
|
162
|
-
responseTtlType: RESPONSE_TTL.type,
|
|
163
|
-
responseTtlValue: RESPONSE_TTL.value,
|
|
147
|
+
_isInternalBuild: true,
|
|
164
148
|
...options,
|
|
165
149
|
tag: Tag.OracleQueryTx,
|
|
166
150
|
oracleId,
|
|
@@ -177,23 +161,13 @@ export async function postQueryToOracle(
|
|
|
177
161
|
|
|
178
162
|
type PostQueryToOracleOptionsType = Parameters<typeof sendTransaction>[1]
|
|
179
163
|
& Parameters<typeof getQueryObject>[2]
|
|
180
|
-
& BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query'
|
|
181
|
-
& {
|
|
182
|
-
queryTtlType?: ORACLE_TTL_TYPES;
|
|
183
|
-
queryTtlValue?: number;
|
|
184
|
-
responseTtlType?: ORACLE_TTL_TYPES;
|
|
185
|
-
responseTtlValue?: number;
|
|
186
|
-
};
|
|
164
|
+
& BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query'>;
|
|
187
165
|
interface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {}
|
|
188
166
|
|
|
189
167
|
/**
|
|
190
168
|
* Extend oracle ttl
|
|
191
169
|
* @category oracle
|
|
192
170
|
* @param options - Options object
|
|
193
|
-
* @param options.fee - fee Transaction fee
|
|
194
|
-
* @param options.ttl - Transaction time to leave
|
|
195
|
-
* @param options.oracleTtlType - Oracle time to leave for extend
|
|
196
|
-
* @param options.oracleTtlValue - Oracle time to leave for extend
|
|
197
171
|
* @returns Oracle object
|
|
198
172
|
*/
|
|
199
173
|
export async function extendOracleTtl(options: ExtendOracleTtlOptions): Promise<
|
|
@@ -201,8 +175,7 @@ Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracl
|
|
|
201
175
|
> {
|
|
202
176
|
const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);
|
|
203
177
|
const oracleExtendTx = await buildTxAsync({
|
|
204
|
-
|
|
205
|
-
oracleTtlValue: ORACLE_TTL.value,
|
|
178
|
+
_isInternalBuild: true,
|
|
206
179
|
...options,
|
|
207
180
|
tag: Tag.OracleExtendTx,
|
|
208
181
|
oracleId,
|
|
@@ -215,8 +188,7 @@ Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracl
|
|
|
215
188
|
}
|
|
216
189
|
|
|
217
190
|
type ExtendOracleTtlOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]
|
|
218
|
-
& BuildTxOptions<Tag.OracleExtendTx, '
|
|
219
|
-
& { oracleTtlType?: ORACLE_TTL_TYPES; oracleTtlValue?: number };
|
|
191
|
+
& BuildTxOptions<Tag.OracleExtendTx, 'callerId' | 'oracleId'>;
|
|
220
192
|
interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {}
|
|
221
193
|
|
|
222
194
|
/**
|
|
@@ -225,9 +197,6 @@ interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {}
|
|
|
225
197
|
* @param queryId - Oracle query id
|
|
226
198
|
* @param response - Oracle query response
|
|
227
199
|
* @param options - Options object
|
|
228
|
-
* @param options.responseTtl - responseTtl Query response time to leave
|
|
229
|
-
* @param options.fee - Transaction fee
|
|
230
|
-
* @param options.ttl - Transaction time to leave
|
|
231
200
|
* @returns Oracle object
|
|
232
201
|
*/
|
|
233
202
|
export async function respondToQuery(
|
|
@@ -239,8 +208,7 @@ export async function respondToQuery(
|
|
|
239
208
|
> {
|
|
240
209
|
const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);
|
|
241
210
|
const oracleRespondTx = await buildTxAsync({
|
|
242
|
-
|
|
243
|
-
responseTtlValue: RESPONSE_TTL.value,
|
|
211
|
+
_isInternalBuild: true,
|
|
244
212
|
...options,
|
|
245
213
|
tag: Tag.OracleResponseTx,
|
|
246
214
|
oracleId,
|
|
@@ -255,8 +223,7 @@ export async function respondToQuery(
|
|
|
255
223
|
}
|
|
256
224
|
|
|
257
225
|
type RespondToQueryOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]
|
|
258
|
-
& BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response'
|
|
259
|
-
& { responseTtlType?: ORACLE_TTL_TYPES; responseTtlValue?: number };
|
|
226
|
+
& BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response'>;
|
|
260
227
|
interface RespondToQueryOptions extends RespondToQueryOptionsType {}
|
|
261
228
|
|
|
262
229
|
/**
|
|
@@ -315,11 +282,6 @@ interface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleBy
|
|
|
315
282
|
* @param queryFormat - Format of query
|
|
316
283
|
* @param responseFormat - Format of query response
|
|
317
284
|
* @param options - Options
|
|
318
|
-
* @param options.queryFee - Oracle query Fee
|
|
319
|
-
* @param options - Options object
|
|
320
|
-
* @param options.abiVersion - Always 0 (do not use virtual machine)
|
|
321
|
-
* @param options.fee - Transaction fee
|
|
322
|
-
* @param options.ttl - Transaction time to leave
|
|
323
285
|
* @returns Oracle object
|
|
324
286
|
*/
|
|
325
287
|
export async function registerOracle(
|
|
@@ -331,8 +293,7 @@ export async function registerOracle(
|
|
|
331
293
|
> {
|
|
332
294
|
const accountId = options.onAccount.address;
|
|
333
295
|
const oracleRegisterTx = await buildTxAsync({
|
|
334
|
-
|
|
335
|
-
oracleTtlType: ORACLE_TTL.type,
|
|
296
|
+
_isInternalBuild: true,
|
|
336
297
|
...options,
|
|
337
298
|
tag: Tag.OracleRegisterTx,
|
|
338
299
|
accountId,
|
|
@@ -346,9 +307,5 @@ export async function registerOracle(
|
|
|
346
307
|
}
|
|
347
308
|
|
|
348
309
|
type RegisterOracleOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]
|
|
349
|
-
& BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat'
|
|
350
|
-
& {
|
|
351
|
-
oracleTtlType?: ORACLE_TTL_TYPES;
|
|
352
|
-
oracleTtlValue?: number;
|
|
353
|
-
};
|
|
310
|
+
& BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat'>;
|
|
354
311
|
interface RegisterOracleOptions extends RegisterOracleOptionsType {}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import verifyTransaction, { ValidatorResult } from './tx/validator';
|
|
2
|
+
import { ensureError } from './utils/other';
|
|
3
|
+
import { TransactionError } from './utils/errors';
|
|
4
|
+
import Node, { TransformNodeType } from './Node';
|
|
5
|
+
import { SignedTx } from './apis/node';
|
|
6
|
+
import { Encoded } from './utils/encoder';
|
|
7
|
+
import AccountBase from './account/Base';
|
|
8
|
+
import { buildTxHash } from './tx/builder';
|
|
9
|
+
import { poll, waitForTxConfirm } from './chain';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @category exception
|
|
13
|
+
*/
|
|
14
|
+
export class InvalidTxError extends TransactionError {
|
|
15
|
+
validation: ValidatorResult[];
|
|
16
|
+
|
|
17
|
+
transaction: Encoded.Transaction;
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
message: string,
|
|
21
|
+
validation: ValidatorResult[],
|
|
22
|
+
transaction: Encoded.Transaction,
|
|
23
|
+
) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'InvalidTxError';
|
|
26
|
+
this.validation = validation;
|
|
27
|
+
this.transaction = transaction;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Signs and submits transaction for mining
|
|
33
|
+
* @category chain
|
|
34
|
+
* @param txUnsigned - Transaction to sign and submit
|
|
35
|
+
* @param options - Options
|
|
36
|
+
* @returns Transaction details
|
|
37
|
+
*/
|
|
38
|
+
export async function sendTransaction(
|
|
39
|
+
txUnsigned: Encoded.Transaction,
|
|
40
|
+
{
|
|
41
|
+
onNode, onAccount, verify = true, waitMined = true, confirm, innerTx, ...options
|
|
42
|
+
}:
|
|
43
|
+
SendTransactionOptions,
|
|
44
|
+
): Promise<SendTransactionReturnType> {
|
|
45
|
+
const tx = await onAccount.signTransaction(txUnsigned, {
|
|
46
|
+
...options,
|
|
47
|
+
onNode,
|
|
48
|
+
innerTx,
|
|
49
|
+
networkId: await onNode.getNetworkId(),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (innerTx === true) return { hash: buildTxHash(tx), rawTx: tx };
|
|
53
|
+
|
|
54
|
+
if (verify) {
|
|
55
|
+
const validation = await verifyTransaction(tx, onNode);
|
|
56
|
+
if (validation.length > 0) {
|
|
57
|
+
const message = `Transaction verification errors: ${
|
|
58
|
+
validation.map((v: { message: string }) => v.message).join(', ')}`;
|
|
59
|
+
throw new InvalidTxError(message, validation, tx);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
let __queue;
|
|
65
|
+
try {
|
|
66
|
+
__queue = onAccount != null ? `tx-${onAccount.address}` : null;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
__queue = null;
|
|
69
|
+
}
|
|
70
|
+
const { txHash } = await onNode.postTransaction({ tx }, {
|
|
71
|
+
requestOptions: {
|
|
72
|
+
customHeaders: {
|
|
73
|
+
// TODO: remove __retry-code after fixing https://github.com/aeternity/aeternity/issues/3803
|
|
74
|
+
'__retry-code': '400',
|
|
75
|
+
...__queue != null ? { __queue } : {},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (waitMined) {
|
|
81
|
+
const pollResult = await poll(txHash, { onNode, ...options });
|
|
82
|
+
const txData = {
|
|
83
|
+
...pollResult,
|
|
84
|
+
hash: pollResult.hash as Encoded.TxHash,
|
|
85
|
+
rawTx: tx,
|
|
86
|
+
};
|
|
87
|
+
// wait for transaction confirmation
|
|
88
|
+
if (confirm != null && +confirm > 0) {
|
|
89
|
+
const c = typeof confirm === 'boolean' ? undefined : confirm;
|
|
90
|
+
return {
|
|
91
|
+
...txData,
|
|
92
|
+
confirmationHeight: await waitForTxConfirm(txHash, { onNode, confirm: c, ...options }),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return txData;
|
|
96
|
+
}
|
|
97
|
+
return { hash: txHash, rawTx: tx };
|
|
98
|
+
} catch (error) {
|
|
99
|
+
ensureError(error);
|
|
100
|
+
throw Object.assign(error, {
|
|
101
|
+
rawTx: tx,
|
|
102
|
+
verifyTx: async () => verifyTransaction(tx, onNode),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type SendTransactionOptionsType = {
|
|
108
|
+
/**
|
|
109
|
+
* Node to use
|
|
110
|
+
*/
|
|
111
|
+
onNode: Node;
|
|
112
|
+
/**
|
|
113
|
+
* Account to use
|
|
114
|
+
*/
|
|
115
|
+
onAccount: AccountBase;
|
|
116
|
+
/**
|
|
117
|
+
* Verify transaction before broadcast, throw error if not
|
|
118
|
+
*/
|
|
119
|
+
verify?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Ensure that transaction get into block
|
|
122
|
+
*/
|
|
123
|
+
waitMined?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Number of micro blocks that should be mined after tx get included
|
|
126
|
+
*/
|
|
127
|
+
confirm?: boolean | number;
|
|
128
|
+
} & Parameters<typeof poll>[1] & Omit<Parameters<typeof waitForTxConfirm>[1], 'confirm'>
|
|
129
|
+
& Parameters<AccountBase['signTransaction']>[1];
|
|
130
|
+
export interface SendTransactionOptions extends SendTransactionOptionsType {}
|
|
131
|
+
interface SendTransactionReturnType extends Partial<TransformNodeType<SignedTx>> {
|
|
132
|
+
hash: Encoded.TxHash;
|
|
133
|
+
// TODO: use `SignedTx.encodedTx` instead
|
|
134
|
+
rawTx: Encoded.Transaction;
|
|
135
|
+
confirmationHeight?: number;
|
|
136
|
+
}
|
package/src/spend.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
} from './chain';
|
|
2
|
+
import { getBalance, resolveName } from './chain';
|
|
3
|
+
import { sendTransaction, SendTransactionOptions } from './send-transaction';
|
|
5
4
|
import { buildTxAsync, BuildTxOptions, unpackTx } from './tx/builder';
|
|
6
5
|
import { ArgumentError } from './utils/errors';
|
|
7
|
-
import { Encoded
|
|
6
|
+
import { Encoded } from './utils/encoder';
|
|
8
7
|
import { Tag, AensName } from './tx/builder/constants';
|
|
9
8
|
import AccountBase from './account/Base';
|
|
10
9
|
|
|
@@ -18,15 +17,16 @@ import AccountBase from './account/Base';
|
|
|
18
17
|
*/
|
|
19
18
|
export async function spend(
|
|
20
19
|
amount: number | string,
|
|
21
|
-
recipientIdOrName: Encoded.AccountAddress | AensName,
|
|
20
|
+
recipientIdOrName: Encoded.AccountAddress | Encoded.ContractAddress | AensName,
|
|
22
21
|
options: SpendOptions,
|
|
23
22
|
): ReturnType<typeof sendTransaction> {
|
|
24
23
|
return sendTransaction(
|
|
25
24
|
await buildTxAsync({
|
|
25
|
+
_isInternalBuild: true,
|
|
26
26
|
...options,
|
|
27
27
|
tag: Tag.SpendTx,
|
|
28
28
|
senderId: options.onAccount.address,
|
|
29
|
-
recipientId: await resolveName
|
|
29
|
+
recipientId: await resolveName(
|
|
30
30
|
recipientIdOrName,
|
|
31
31
|
'account_pubkey',
|
|
32
32
|
options,
|
|
@@ -61,13 +61,13 @@ interface SpendOptions extends SpendOptionsType {}
|
|
|
61
61
|
*/
|
|
62
62
|
export async function transferFunds(
|
|
63
63
|
fraction: number | string, // TODO: accept only number
|
|
64
|
-
recipientIdOrName: AensName | Encoded.AccountAddress,
|
|
64
|
+
recipientIdOrName: AensName | Encoded.AccountAddress | Encoded.ContractAddress,
|
|
65
65
|
options: TransferFundsOptions,
|
|
66
66
|
): ReturnType<typeof sendTransaction> {
|
|
67
67
|
if (+fraction < 0 || +fraction > 1) {
|
|
68
68
|
throw new ArgumentError('fraction', 'a number between 0 and 1', fraction);
|
|
69
69
|
}
|
|
70
|
-
const recipientId = await resolveName
|
|
70
|
+
const recipientId = await resolveName(
|
|
71
71
|
recipientIdOrName,
|
|
72
72
|
'account_pubkey',
|
|
73
73
|
options,
|
|
@@ -79,7 +79,12 @@ export async function transferFunds(
|
|
|
79
79
|
const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);
|
|
80
80
|
const { fee } = unpackTx(
|
|
81
81
|
await buildTxAsync({
|
|
82
|
-
|
|
82
|
+
_isInternalBuild: true,
|
|
83
|
+
...options,
|
|
84
|
+
tag: Tag.SpendTx,
|
|
85
|
+
senderId,
|
|
86
|
+
recipientId,
|
|
87
|
+
amount: desiredAmount,
|
|
83
88
|
}),
|
|
84
89
|
Tag.SpendTx,
|
|
85
90
|
);
|
|
@@ -87,7 +92,12 @@ export async function transferFunds(
|
|
|
87
92
|
const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;
|
|
88
93
|
return sendTransaction(
|
|
89
94
|
await buildTxAsync({
|
|
90
|
-
|
|
95
|
+
_isInternalBuild: true,
|
|
96
|
+
...options,
|
|
97
|
+
tag: Tag.SpendTx,
|
|
98
|
+
senderId,
|
|
99
|
+
recipientId,
|
|
100
|
+
amount,
|
|
91
101
|
}),
|
|
92
102
|
options,
|
|
93
103
|
);
|
|
@@ -110,7 +120,11 @@ export async function payForTransaction(
|
|
|
110
120
|
): ReturnType<typeof sendTransaction> {
|
|
111
121
|
return sendTransaction(
|
|
112
122
|
await buildTxAsync({
|
|
113
|
-
|
|
123
|
+
_isInternalBuild: true,
|
|
124
|
+
...options,
|
|
125
|
+
tag: Tag.PayingForTx,
|
|
126
|
+
payerId: options.onAccount.address,
|
|
127
|
+
tx: transaction,
|
|
114
128
|
}),
|
|
115
129
|
options,
|
|
116
130
|
);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { decode as rlpDecode, encode as rlpEncode } from 'rlp';
|
|
2
|
+
import { Field, BinaryData } from './field-types';
|
|
3
|
+
import {
|
|
4
|
+
ArgumentError, DecodeError, SchemaNotFoundError, InternalError,
|
|
5
|
+
} from '../../utils/errors';
|
|
6
|
+
import {
|
|
7
|
+
Encoding, Encoded, encode, decode,
|
|
8
|
+
} from '../../utils/encoder';
|
|
9
|
+
import { readInt } from './helpers';
|
|
10
|
+
|
|
11
|
+
type Schemas = ReadonlyArray<{
|
|
12
|
+
tag: { constValue: number } & Field;
|
|
13
|
+
version: { constValue: number; constValueOptional: boolean } & Field;
|
|
14
|
+
}>;
|
|
15
|
+
|
|
16
|
+
export function getSchema(
|
|
17
|
+
schemas: Schemas,
|
|
18
|
+
Tag: { [key: number]: string },
|
|
19
|
+
tag: number,
|
|
20
|
+
version: number | undefined,
|
|
21
|
+
): Array<[string, Field]> {
|
|
22
|
+
const subSchemas = schemas.filter((s) => s.tag.constValue === tag);
|
|
23
|
+
if (subSchemas.length === 0) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, 0);
|
|
24
|
+
if (version == null) {
|
|
25
|
+
const defaultSchema = subSchemas.find((schema) => schema.version.constValueOptional);
|
|
26
|
+
if (defaultSchema == null) throw new InternalError(`Can't find default schema of ${Tag[tag]} (${tag})`);
|
|
27
|
+
version = defaultSchema.version.constValue;
|
|
28
|
+
}
|
|
29
|
+
const schema = subSchemas.find((s) => s.version.constValue === version);
|
|
30
|
+
if (schema == null) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, version);
|
|
31
|
+
return Object.entries(schema);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function packRecord<E extends Encoding>(
|
|
35
|
+
schemas: Schemas,
|
|
36
|
+
Tag: { [key: number]: string },
|
|
37
|
+
params: {
|
|
38
|
+
tag: number;
|
|
39
|
+
version?: number;
|
|
40
|
+
[k: string]: unknown;
|
|
41
|
+
},
|
|
42
|
+
extraParams: { [k: string]: unknown },
|
|
43
|
+
encoding: E,
|
|
44
|
+
): Encoded.Generic<E> {
|
|
45
|
+
const schema = getSchema(schemas, Tag, params.tag, params.version);
|
|
46
|
+
const binary = schema.map(([key, field]) => (
|
|
47
|
+
field.serialize(params[key], { ...params, ...extraParams }, params)
|
|
48
|
+
));
|
|
49
|
+
return encode(rlpEncode(binary), encoding);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function unpackRecord(
|
|
53
|
+
schemas: Schemas,
|
|
54
|
+
Tag: { [key: number]: string },
|
|
55
|
+
encodedRecord: Encoded.Any,
|
|
56
|
+
expectedTag: number | undefined,
|
|
57
|
+
extraParams: { [k: string]: unknown },
|
|
58
|
+
): unknown {
|
|
59
|
+
const binary = rlpDecode(decode(encodedRecord));
|
|
60
|
+
const tag = +readInt(binary[0] as Buffer);
|
|
61
|
+
const version = +readInt(binary[1] as Buffer);
|
|
62
|
+
const schema = getSchema(schemas, Tag, tag, version);
|
|
63
|
+
if (expectedTag != null && expectedTag !== tag) {
|
|
64
|
+
throw new DecodeError(`Expected ${Tag[expectedTag]} tag, got ${Tag[tag]} instead`);
|
|
65
|
+
}
|
|
66
|
+
if (binary.length !== schema.length) {
|
|
67
|
+
throw new ArgumentError('RLP length', schema.length, binary.length);
|
|
68
|
+
}
|
|
69
|
+
return Object.fromEntries(
|
|
70
|
+
schema.map(([name, field], index) => [
|
|
71
|
+
name, field.deserialize(binary[index] as BinaryData, extraParams),
|
|
72
|
+
]),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { mapObject } from '../../utils/other';
|
|
3
3
|
|
|
4
|
+
export const DRY_RUN_ACCOUNT = {
|
|
5
|
+
pub: 'ak_11111111111111111111111111111111273Yts',
|
|
6
|
+
amount: 100000000000000000000000000000000000n,
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
4
9
|
export const MAX_AUTH_FUN_GAS = 50000;
|
|
5
10
|
export type Int = number | string | BigNumber;
|
|
6
|
-
// # AENS
|
|
7
11
|
export type AensName = `${string}.chain`;
|
|
8
|
-
export const
|
|
9
|
-
// # max number of block into the future that the name is going to be available
|
|
10
|
-
// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update
|
|
11
|
-
// # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry
|
|
12
|
-
export const NAME_MAX_TTL = 36000;
|
|
13
|
-
export const NAME_MAX_CLIENT_TTL = 84600;
|
|
14
|
-
export const CLIENT_TTL = NAME_MAX_CLIENT_TTL;
|
|
15
|
-
export const MIN_GAS_PRICE = 1e9;
|
|
12
|
+
export const MIN_GAS_PRICE = 1e9; // TODO: don't use number for ae
|
|
16
13
|
// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67
|
|
17
14
|
export const NAME_FEE_MULTIPLIER = 1e14; // 100000000000000
|
|
18
15
|
export const NAME_FEE_BID_INCREMENT = 0.05; // # the increment is in percentage
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Encoded, Encoding } from '../../../utils/encoder';
|
|
2
|
+
import { packRecord, unpackRecord } from '../common';
|
|
3
|
+
import { DelegationTag, schemas } from './schema';
|
|
4
|
+
import { DlgParams, DlgUnpacked } from './schema.generated';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Pack delegation
|
|
8
|
+
* @category delegation signature
|
|
9
|
+
* @param params - Params of delegation
|
|
10
|
+
* @returns Encoded delegation
|
|
11
|
+
*/
|
|
12
|
+
export function packDelegation(params: DlgParams): Encoded.Bytearray {
|
|
13
|
+
return packRecord(schemas, DelegationTag, params, {}, Encoding.Bytearray);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Unpack delegation
|
|
18
|
+
* @category delegation signature
|
|
19
|
+
* @param encoded - Encoded delegation
|
|
20
|
+
* @param expectedTag - Expected delegation signature type
|
|
21
|
+
* @returns Params of delegation
|
|
22
|
+
*/
|
|
23
|
+
export function unpackDelegation<T extends DelegationTag>(
|
|
24
|
+
encoded: Encoded.Bytearray,
|
|
25
|
+
expectedTag?: T,
|
|
26
|
+
): DlgUnpacked & { tag: T } {
|
|
27
|
+
return unpackRecord(schemas, DelegationTag, encoded, expectedTag, {}) as any;
|
|
28
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// This file generated by `npm run build:generate`, don't edit manually.
|
|
3
|
+
|
|
4
|
+
import { DlgParams as DlgParamsComplex, DlgUnpacked as DlgUnpackedComplex } from "./schema";
|
|
5
|
+
import { DelegationTag as Tag } from "./schema";
|
|
6
|
+
/**
|
|
7
|
+
* @category delegation signature
|
|
8
|
+
*/
|
|
9
|
+
type DlgParamsAensWildcard1Type = Omit<DlgParamsComplex & {
|
|
10
|
+
tag: Tag.AensWildcard;
|
|
11
|
+
version: 1;
|
|
12
|
+
}, "version"> & {
|
|
13
|
+
version?: 1;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* @category delegation signature
|
|
17
|
+
*/
|
|
18
|
+
export interface DlgParamsAensWildcard1 extends DlgParamsAensWildcard1Type {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @category delegation signature
|
|
22
|
+
*/
|
|
23
|
+
type DlgUnpackedAensWildcard1Type = DlgUnpackedComplex & {
|
|
24
|
+
tag: Tag.AensWildcard;
|
|
25
|
+
version: 1;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @category delegation signature
|
|
29
|
+
*/
|
|
30
|
+
export interface DlgUnpackedAensWildcard1 extends DlgUnpackedAensWildcard1Type {
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @category delegation signature
|
|
34
|
+
*/
|
|
35
|
+
type DlgParamsAensName1Type = Omit<DlgParamsComplex & {
|
|
36
|
+
tag: Tag.AensName;
|
|
37
|
+
version: 1;
|
|
38
|
+
}, "version"> & {
|
|
39
|
+
version?: 1;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* @category delegation signature
|
|
43
|
+
*/
|
|
44
|
+
export interface DlgParamsAensName1 extends DlgParamsAensName1Type {
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @category delegation signature
|
|
48
|
+
*/
|
|
49
|
+
type DlgUnpackedAensName1Type = DlgUnpackedComplex & {
|
|
50
|
+
tag: Tag.AensName;
|
|
51
|
+
version: 1;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* @category delegation signature
|
|
55
|
+
*/
|
|
56
|
+
export interface DlgUnpackedAensName1 extends DlgUnpackedAensName1Type {
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @category delegation signature
|
|
60
|
+
*/
|
|
61
|
+
type DlgParamsAensPreclaim1Type = Omit<DlgParamsComplex & {
|
|
62
|
+
tag: Tag.AensPreclaim;
|
|
63
|
+
version: 1;
|
|
64
|
+
}, "version"> & {
|
|
65
|
+
version?: 1;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* @category delegation signature
|
|
69
|
+
*/
|
|
70
|
+
export interface DlgParamsAensPreclaim1 extends DlgParamsAensPreclaim1Type {
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @category delegation signature
|
|
74
|
+
*/
|
|
75
|
+
type DlgUnpackedAensPreclaim1Type = DlgUnpackedComplex & {
|
|
76
|
+
tag: Tag.AensPreclaim;
|
|
77
|
+
version: 1;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* @category delegation signature
|
|
81
|
+
*/
|
|
82
|
+
export interface DlgUnpackedAensPreclaim1 extends DlgUnpackedAensPreclaim1Type {
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @category delegation signature
|
|
86
|
+
*/
|
|
87
|
+
type DlgParamsOracle1Type = Omit<DlgParamsComplex & {
|
|
88
|
+
tag: Tag.Oracle;
|
|
89
|
+
version: 1;
|
|
90
|
+
}, "version"> & {
|
|
91
|
+
version?: 1;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* @category delegation signature
|
|
95
|
+
*/
|
|
96
|
+
export interface DlgParamsOracle1 extends DlgParamsOracle1Type {
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @category delegation signature
|
|
100
|
+
*/
|
|
101
|
+
type DlgUnpackedOracle1Type = DlgUnpackedComplex & {
|
|
102
|
+
tag: Tag.Oracle;
|
|
103
|
+
version: 1;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* @category delegation signature
|
|
107
|
+
*/
|
|
108
|
+
export interface DlgUnpackedOracle1 extends DlgUnpackedOracle1Type {
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @category delegation signature
|
|
112
|
+
*/
|
|
113
|
+
type DlgParamsOracleResponse1Type = Omit<DlgParamsComplex & {
|
|
114
|
+
tag: Tag.OracleResponse;
|
|
115
|
+
version: 1;
|
|
116
|
+
}, "version"> & {
|
|
117
|
+
version?: 1;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* @category delegation signature
|
|
121
|
+
*/
|
|
122
|
+
export interface DlgParamsOracleResponse1 extends DlgParamsOracleResponse1Type {
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @category delegation signature
|
|
126
|
+
*/
|
|
127
|
+
type DlgUnpackedOracleResponse1Type = DlgUnpackedComplex & {
|
|
128
|
+
tag: Tag.OracleResponse;
|
|
129
|
+
version: 1;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* @category delegation signature
|
|
133
|
+
*/
|
|
134
|
+
export interface DlgUnpackedOracleResponse1 extends DlgUnpackedOracleResponse1Type {
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @category delegation signature
|
|
138
|
+
*/
|
|
139
|
+
export type DlgParams = DlgParamsAensWildcard1 | DlgParamsAensName1 | DlgParamsAensPreclaim1 | DlgParamsOracle1 | DlgParamsOracleResponse1;
|
|
140
|
+
/**
|
|
141
|
+
* @category delegation signature
|
|
142
|
+
*/
|
|
143
|
+
export type DlgUnpacked = DlgUnpackedAensWildcard1 | DlgUnpackedAensName1 | DlgUnpackedAensPreclaim1 | DlgUnpackedOracle1 | DlgUnpackedOracleResponse1;
|