@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
package/src/chain.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { AE_AMOUNT_FORMATS, formatAmount } from './utils/amount-formatter';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { isAccountNotFoundError, pause } from './utils/other';
|
|
3
|
+
import { unwrapProxy } from './utils/wrap-proxy';
|
|
4
4
|
import { isNameValid, produceNameId } from './tx/builder/helpers';
|
|
5
|
-
import { DRY_RUN_ACCOUNT } from './tx/builder/
|
|
6
|
-
import { AensName } from './tx/builder/constants';
|
|
5
|
+
import { AensName, DRY_RUN_ACCOUNT } from './tx/builder/constants';
|
|
7
6
|
import {
|
|
8
|
-
AensPointerContextError, DryRunError, InvalidAensNameError,
|
|
7
|
+
AensPointerContextError, DryRunError, InvalidAensNameError,
|
|
9
8
|
TxTimedOutError, TxNotInChainError, InternalError,
|
|
10
9
|
} from './utils/errors';
|
|
11
10
|
import Node, { TransformNodeType } from './Node';
|
|
@@ -16,60 +15,62 @@ import {
|
|
|
16
15
|
import {
|
|
17
16
|
decode, encode, Encoded, Encoding,
|
|
18
17
|
} from './utils/encoder';
|
|
19
|
-
import AccountBase from './account/Base';
|
|
20
|
-
import { buildTxHash } from './tx/builder';
|
|
21
18
|
|
|
22
19
|
/**
|
|
23
20
|
* @category chain
|
|
21
|
+
* @param type - Type
|
|
22
|
+
* @param options - Options
|
|
24
23
|
*/
|
|
25
24
|
export function _getPollInterval(
|
|
26
25
|
type: 'block' | 'microblock', // TODO: rename to 'key-block' | 'micro-block'
|
|
27
|
-
{ _expectedMineRate = 180000, _microBlockCycle = 3000
|
|
28
|
-
{ _expectedMineRate?: number; _microBlockCycle?: number
|
|
26
|
+
{ _expectedMineRate = 180000, _microBlockCycle = 3000 }:
|
|
27
|
+
{ _expectedMineRate?: number; _microBlockCycle?: number },
|
|
29
28
|
): number {
|
|
30
29
|
const base = {
|
|
31
30
|
block: _expectedMineRate,
|
|
32
31
|
microblock: _microBlockCycle,
|
|
33
32
|
}[type];
|
|
34
|
-
return Math.
|
|
33
|
+
return Math.floor(base / 3);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
* @category exception
|
|
39
|
-
*/
|
|
40
|
-
export class InvalidTxError extends TransactionError {
|
|
41
|
-
validation: ValidatorResult[];
|
|
42
|
-
|
|
43
|
-
transaction: Encoded.Transaction;
|
|
44
|
-
|
|
45
|
-
constructor(
|
|
46
|
-
message: string,
|
|
47
|
-
validation: ValidatorResult[],
|
|
48
|
-
transaction: Encoded.Transaction,
|
|
49
|
-
) {
|
|
50
|
-
super(message);
|
|
51
|
-
this.name = 'InvalidTxError';
|
|
52
|
-
this.validation = validation;
|
|
53
|
-
this.transaction = transaction;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
36
|
+
const heightCache: WeakMap<Node, { time: number; height: number }> = new WeakMap();
|
|
56
37
|
|
|
57
38
|
/**
|
|
58
39
|
* Obtain current height of the chain
|
|
59
40
|
* @category chain
|
|
41
|
+
* @param options - Options
|
|
42
|
+
* @param options.cached - Get height from the cache. The lag behind the actual height shouldn't
|
|
43
|
+
* be more than 1 block. Use if needed to reduce requests count, and approximate value can be used.
|
|
44
|
+
* For example, for timeout check in transaction status polling.
|
|
60
45
|
* @returns Current chain height
|
|
61
46
|
*/
|
|
62
|
-
export async function getHeight(
|
|
63
|
-
|
|
47
|
+
export async function getHeight(
|
|
48
|
+
{ cached = false, ...options }: {
|
|
49
|
+
onNode: Node;
|
|
50
|
+
cached?: boolean;
|
|
51
|
+
} & Parameters<typeof _getPollInterval>[1],
|
|
52
|
+
): Promise<number> {
|
|
53
|
+
const onNode = unwrapProxy(options.onNode);
|
|
54
|
+
if (cached) {
|
|
55
|
+
const cache = heightCache.get(onNode);
|
|
56
|
+
if (cache != null && cache.time > Date.now() - _getPollInterval('block', options)) {
|
|
57
|
+
return cache.height;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const { height } = await onNode.getCurrentKeyBlockHeight();
|
|
61
|
+
heightCache.set(onNode, { height, time: Date.now() });
|
|
62
|
+
return height;
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
/**
|
|
67
|
-
*
|
|
66
|
+
* Return transaction details if it is mined, fail otherwise.
|
|
67
|
+
* If the transaction has ttl specified then would wait till it leaves the mempool.
|
|
68
|
+
* Otherwise would fail if a specified amount of blocks were mined.
|
|
68
69
|
* @category chain
|
|
69
70
|
* @param th - The hash of transaction to poll
|
|
70
71
|
* @param options - Options
|
|
71
72
|
* @param options.interval - Interval (in ms) at which to poll the chain
|
|
72
|
-
* @param options.blocks - Number of blocks mined after which to fail
|
|
73
|
+
* @param options.blocks - Number of blocks mined after which to fail if transaction ttl is not set
|
|
73
74
|
* @param options.onNode - Node to use
|
|
74
75
|
* @returns The transaction as it was mined
|
|
75
76
|
*/
|
|
@@ -81,12 +82,16 @@ export async function poll(
|
|
|
81
82
|
{ blocks?: number; interval?: number; onNode: Node } & Parameters<typeof _getPollInterval>[1],
|
|
82
83
|
): Promise<TransformNodeType<SignedTx>> {
|
|
83
84
|
interval ??= _getPollInterval('microblock', options);
|
|
84
|
-
|
|
85
|
+
let max;
|
|
85
86
|
do {
|
|
86
87
|
const tx = await onNode.getTransactionByHash(th);
|
|
87
88
|
if (tx.blockHeight !== -1) return tx;
|
|
89
|
+
if (max == null) {
|
|
90
|
+
max = tx.tx.ttl !== 0 ? -1
|
|
91
|
+
: await getHeight({ ...options, onNode, cached: true }) + blocks;
|
|
92
|
+
}
|
|
88
93
|
await pause(interval);
|
|
89
|
-
} while (await getHeight({ onNode }) < max);
|
|
94
|
+
} while (max === -1 ? true : await getHeight({ ...options, onNode, cached: true }) < max);
|
|
90
95
|
throw new TxTimedOutError(blocks, th);
|
|
91
96
|
}
|
|
92
97
|
|
|
@@ -104,11 +109,11 @@ export async function awaitHeight(
|
|
|
104
109
|
{ interval, onNode, ...options }:
|
|
105
110
|
{ interval?: number; onNode: Node } & Parameters<typeof _getPollInterval>[1],
|
|
106
111
|
): Promise<number> {
|
|
107
|
-
interval ??= _getPollInterval('block', options);
|
|
112
|
+
interval ??= Math.min(_getPollInterval('block', options), 5000);
|
|
108
113
|
let currentHeight;
|
|
109
114
|
do {
|
|
110
115
|
if (currentHeight != null) await pause(interval);
|
|
111
|
-
currentHeight =
|
|
116
|
+
currentHeight = await getHeight({ onNode });
|
|
112
117
|
} while (currentHeight < height);
|
|
113
118
|
return currentHeight;
|
|
114
119
|
}
|
|
@@ -140,97 +145,6 @@ export async function waitForTxConfirm(
|
|
|
140
145
|
}
|
|
141
146
|
}
|
|
142
147
|
|
|
143
|
-
/**
|
|
144
|
-
* Signs and submits transaction for mining
|
|
145
|
-
* @category chain
|
|
146
|
-
* @param txUnsigned - Transaction to sign and submit
|
|
147
|
-
* @param options - Options
|
|
148
|
-
* @param options.onNode - Node to use
|
|
149
|
-
* @param options.onAccount - Account to use
|
|
150
|
-
* @param options.verify - Verify transaction before broadcast, throw error if not
|
|
151
|
-
* @param options.waitMined - Ensure that transaction get into block
|
|
152
|
-
* @param options.confirm - Number of micro blocks that should be mined after tx get included
|
|
153
|
-
* @returns Transaction details
|
|
154
|
-
*/
|
|
155
|
-
export async function sendTransaction(
|
|
156
|
-
txUnsigned: Encoded.Transaction,
|
|
157
|
-
{
|
|
158
|
-
onNode, onAccount, verify = true, waitMined = true, confirm, innerTx, ...options
|
|
159
|
-
}:
|
|
160
|
-
SendTransactionOptions,
|
|
161
|
-
): Promise<SendTransactionReturnType> {
|
|
162
|
-
const tx = await onAccount.signTransaction(txUnsigned, {
|
|
163
|
-
...options,
|
|
164
|
-
onNode,
|
|
165
|
-
innerTx,
|
|
166
|
-
networkId: await onNode.getNetworkId(),
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
if (innerTx === true) return { hash: buildTxHash(tx), rawTx: tx };
|
|
170
|
-
|
|
171
|
-
if (verify) {
|
|
172
|
-
const validation = await verifyTransaction(tx, onNode);
|
|
173
|
-
if (validation.length > 0) {
|
|
174
|
-
const message = `Transaction verification errors: ${
|
|
175
|
-
validation.map((v: { message: string }) => v.message).join(', ')}`;
|
|
176
|
-
throw new InvalidTxError(message, validation, tx);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
try {
|
|
181
|
-
let __queue;
|
|
182
|
-
try {
|
|
183
|
-
__queue = onAccount != null ? `tx-${onAccount.address}` : null;
|
|
184
|
-
} catch (error) {
|
|
185
|
-
__queue = null;
|
|
186
|
-
}
|
|
187
|
-
const { txHash } = await onNode.postTransaction(
|
|
188
|
-
{ tx },
|
|
189
|
-
__queue != null ? { requestOptions: { customHeaders: { __queue } } } : {},
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
if (waitMined) {
|
|
193
|
-
const pollResult = await poll(txHash, { onNode, ...options });
|
|
194
|
-
const txData = {
|
|
195
|
-
...pollResult,
|
|
196
|
-
hash: pollResult.hash as Encoded.TxHash,
|
|
197
|
-
rawTx: tx,
|
|
198
|
-
};
|
|
199
|
-
// wait for transaction confirmation
|
|
200
|
-
if (confirm != null && +confirm > 0) {
|
|
201
|
-
const c = typeof confirm === 'boolean' ? undefined : confirm;
|
|
202
|
-
return {
|
|
203
|
-
...txData,
|
|
204
|
-
confirmationHeight: await waitForTxConfirm(txHash, { onNode, confirm: c, ...options }),
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
return txData;
|
|
208
|
-
}
|
|
209
|
-
return { hash: txHash, rawTx: tx };
|
|
210
|
-
} catch (error) {
|
|
211
|
-
ensureError(error);
|
|
212
|
-
throw Object.assign(error, {
|
|
213
|
-
rawTx: tx,
|
|
214
|
-
verifyTx: async () => verifyTransaction(tx, onNode),
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
type SendTransactionOptionsType = {
|
|
220
|
-
onNode: Node;
|
|
221
|
-
onAccount: AccountBase;
|
|
222
|
-
verify?: boolean;
|
|
223
|
-
waitMined?: boolean;
|
|
224
|
-
confirm?: boolean | number;
|
|
225
|
-
} & Parameters<typeof poll>[1] & Omit<Parameters<typeof waitForTxConfirm>[1], 'confirm'>
|
|
226
|
-
& Parameters<AccountBase['signTransaction']>[1];
|
|
227
|
-
export interface SendTransactionOptions extends SendTransactionOptionsType {}
|
|
228
|
-
interface SendTransactionReturnType extends Partial<TransformNodeType<SignedTx>> {
|
|
229
|
-
hash: Encoded.TxHash;
|
|
230
|
-
rawTx: Encoded.Transaction;
|
|
231
|
-
confirmationHeight?: number;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
148
|
/**
|
|
235
149
|
* Get account by account public key
|
|
236
150
|
* @category chain
|
package/src/channel/Base.ts
CHANGED
|
@@ -31,6 +31,8 @@ function snakeToPascalObjKeys<Type>(obj: object): Type {
|
|
|
31
31
|
}), {}) as Type;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
let channelCounter = 0;
|
|
35
|
+
|
|
34
36
|
/**
|
|
35
37
|
* Channel
|
|
36
38
|
* @example
|
|
@@ -81,57 +83,22 @@ export default class Channel {
|
|
|
81
83
|
|
|
82
84
|
_options!: ChannelOptions;
|
|
83
85
|
|
|
86
|
+
readonly #debugId: number;
|
|
87
|
+
|
|
84
88
|
_channelId?: Encoded.Channel;
|
|
85
89
|
|
|
90
|
+
protected constructor() {
|
|
91
|
+
channelCounter += 1;
|
|
92
|
+
this.#debugId = channelCounter;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
_debug(...args: any[]): void {
|
|
96
|
+
if (this._options.debug !== true) return;
|
|
97
|
+
console.debug(`Channel #${this.#debugId}`, ...args);
|
|
98
|
+
}
|
|
99
|
+
|
|
86
100
|
/**
|
|
87
101
|
* @param options - Channel params
|
|
88
|
-
* @param options.url - Channel url (for example: "ws://localhost:3001")
|
|
89
|
-
* @param options.role - Participant role ("initiator" or "responder")
|
|
90
|
-
* @param options.initiatorId - Initiator's public key
|
|
91
|
-
* @param options.responderId - Responder's public key
|
|
92
|
-
* @param options.pushAmount - Initial deposit in favour of the responder by the initiator
|
|
93
|
-
* @param options.initiatorAmount - Amount of coins the initiator has committed to
|
|
94
|
-
* the channel
|
|
95
|
-
* @param options.responderAmount - Amount of coins the responder has committed to
|
|
96
|
-
* the channel
|
|
97
|
-
* @param options.channelReserve - The minimum amount both peers need to maintain
|
|
98
|
-
* @param options.ttl - Minimum block height to include the channel_create_tx
|
|
99
|
-
* @param options.host - Host of the responder's node
|
|
100
|
-
* @param options.port - The port of the responders node
|
|
101
|
-
* @param options.lockPeriod - Amount of blocks for disputing a solo close
|
|
102
|
-
* @param options.minimumDepthStrategy - How to calculate minimum depth (default: txfee)
|
|
103
|
-
* @param options.minimumDepth - The minimum amount of blocks to be mined
|
|
104
|
-
* @param options.fee - The fee to be used for the channel open transaction
|
|
105
|
-
* @param options.gasPrice - Used for the fee computation of the channel open transaction
|
|
106
|
-
* @param options.existingChannelId - Existing channel id (required if reestablishing a
|
|
107
|
-
* channel)
|
|
108
|
-
* @param options.offchainTx - Offchain transaction (required if reestablishing
|
|
109
|
-
* a channel)
|
|
110
|
-
* @param options.timeoutIdle - The time waiting for a new event to be initiated
|
|
111
|
-
* (default: 600000)
|
|
112
|
-
* @param options.timeoutFundingCreate - The time waiting for the initiator to produce
|
|
113
|
-
* the create channel transaction after the noise session had been established (default: 120000)
|
|
114
|
-
* @param options.timeoutFundingSign - The time frame the other client has to sign an
|
|
115
|
-
* off-chain update after our client had initiated and signed it. This applies only for double
|
|
116
|
-
* signed on-chain intended updates: channel create transaction, deposit, withdrawal and etc.
|
|
117
|
-
* (default: 120000)
|
|
118
|
-
* @param options.timeoutFundingLock - The time frame the other client has to confirm an
|
|
119
|
-
* on-chain transaction reaching maturity (passing minimum depth) after the local node has
|
|
120
|
-
* detected this. This applies only for double signed on-chain intended updates: channel create
|
|
121
|
-
* transaction, deposit, withdrawal and etc. (default: 360000)
|
|
122
|
-
* @param options.timeoutSign - The time frame the client has to return a signed
|
|
123
|
-
* off-chain update or to decline it. This applies for all off-chain updates (default: 500000)
|
|
124
|
-
* @param options.timeoutAccept - The time frame the other client has to react to an
|
|
125
|
-
* event. This applies for all off-chain updates that are not meant to land on-chain, as well as
|
|
126
|
-
* some special cases: opening a noise connection, mutual closing acknowledgement and
|
|
127
|
-
* reestablishing an existing channel (default: 120000)
|
|
128
|
-
* @param options.timeoutInitialized - the time frame the responder has to accept an
|
|
129
|
-
* incoming noise session. Applicable only for initiator (default: timeout_accept's value)
|
|
130
|
-
* @param options.timeoutAwaitingOpen - The time frame the initiator has to start an
|
|
131
|
-
* outgoing noise session to the responder's node. Applicable only for responder (default:
|
|
132
|
-
* timeout_idle's value)
|
|
133
|
-
* @param options.debug=false - Log websocket communication
|
|
134
|
-
* @param options.sign - Function which verifies and signs transactions
|
|
135
102
|
*/
|
|
136
103
|
static async initialize(options: ChannelOptions): Promise<Channel> {
|
|
137
104
|
return Channel._initialize(new Channel(), options);
|
package/src/channel/Contract.ts
CHANGED
|
@@ -30,10 +30,25 @@ function snakeToPascalObjKeys<Type>(obj: object): Type {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
interface CallContractOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Amount the caller of the contract commits to it
|
|
35
|
+
*/
|
|
33
36
|
amount?: number | BigNumber;
|
|
37
|
+
/**
|
|
38
|
+
* ABI encoded compiled AEVM call data for the code
|
|
39
|
+
*/
|
|
34
40
|
callData?: Encoded.ContractBytearray;
|
|
41
|
+
/**
|
|
42
|
+
* Version of the ABI
|
|
43
|
+
*/
|
|
35
44
|
abiVersion?: AbiVersion;
|
|
45
|
+
/**
|
|
46
|
+
* Address of the contract to call
|
|
47
|
+
*/
|
|
36
48
|
contract?: Encoded.ContractAddress;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface CallContractResult extends CallContractOptions {
|
|
37
52
|
returnValue?: any;
|
|
38
53
|
gasUsed?: number | BigNumber;
|
|
39
54
|
gasPrice?: number | BigNumber;
|
|
@@ -175,10 +190,6 @@ export default class ChannelContract extends ChannelSpend {
|
|
|
175
190
|
* if a call with a similar computation amount is to be forced on-chain.
|
|
176
191
|
*
|
|
177
192
|
* @param options - Options
|
|
178
|
-
* @param options.amount - Amount the caller of the contract commits to it
|
|
179
|
-
* @param options.callData - ABI encoded compiled AEVM call data for the code
|
|
180
|
-
* @param options.contract - Address of the contract to call
|
|
181
|
-
* @param options.abiVersion - Version of the ABI
|
|
182
193
|
* @param sign - Function which verifies and signs contract call transaction
|
|
183
194
|
* @example
|
|
184
195
|
* ```js
|
|
@@ -248,12 +259,6 @@ export default class ChannelContract extends ChannelSpend {
|
|
|
248
259
|
* Trigger a force progress contract call
|
|
249
260
|
* This call is going on-chain
|
|
250
261
|
* @param options - Options
|
|
251
|
-
* @param options.amount - Amount the caller of the contract commits to it
|
|
252
|
-
* @param options.callData - ABI encoded compiled AEVM call data for the code
|
|
253
|
-
* @param options.contract - Address of the contract to call
|
|
254
|
-
* @param options.abiVersion - Version of the ABI
|
|
255
|
-
* @param options.gasPrice=1000000000]
|
|
256
|
-
* @param options.gasLimit=1000000]
|
|
257
262
|
* @param sign - Function which verifies and signs contract force progress transaction
|
|
258
263
|
* @param callbacks - Callbacks
|
|
259
264
|
* @example
|
|
@@ -276,11 +281,7 @@ export default class ChannelContract extends ChannelSpend {
|
|
|
276
281
|
async forceProgress(
|
|
277
282
|
{
|
|
278
283
|
amount, callData, contract, abiVersion, gasLimit = 1000000, gasPrice = MIN_GAS_PRICE,
|
|
279
|
-
}: {
|
|
280
|
-
amount: number;
|
|
281
|
-
callData: Encoded.ContractBytearray;
|
|
282
|
-
contract: Encoded.ContractAddress;
|
|
283
|
-
abiVersion: AbiVersion;
|
|
284
|
+
}: CallContractOptions & {
|
|
284
285
|
gasLimit?: number;
|
|
285
286
|
gasPrice?: number;
|
|
286
287
|
},
|
|
@@ -352,10 +353,6 @@ export default class ChannelContract extends ChannelSpend {
|
|
|
352
353
|
* top of the blockchain as seen by the node.
|
|
353
354
|
*
|
|
354
355
|
* @param options - Options
|
|
355
|
-
* @param options.amount - Amount the caller of the contract commits to it
|
|
356
|
-
* @param options.callData - ABI encoded compiled AEVM call data for the code
|
|
357
|
-
* @param options.contract - Address of the contract to call
|
|
358
|
-
* @param options.abiVersion - Version of the ABI
|
|
359
356
|
* @example
|
|
360
357
|
* ```js
|
|
361
358
|
* channel.callContractStatic({
|
|
@@ -372,13 +369,8 @@ export default class ChannelContract extends ChannelSpend {
|
|
|
372
369
|
async callContractStatic(
|
|
373
370
|
{
|
|
374
371
|
amount, callData, contract, abiVersion,
|
|
375
|
-
}:
|
|
376
|
-
|
|
377
|
-
callData: Encoded.ContractBytearray;
|
|
378
|
-
contract: Encoded.ContractAddress;
|
|
379
|
-
abiVersion: AbiVersion;
|
|
380
|
-
},
|
|
381
|
-
): Promise<CallContractOptions> {
|
|
372
|
+
}: CallContractOptions,
|
|
373
|
+
): Promise<CallContractResult> {
|
|
382
374
|
return snakeToPascalObjKeys(await call(this, 'channels.dry_run.call_contract', {
|
|
383
375
|
amount,
|
|
384
376
|
call_data: callData,
|
package/src/channel/Spend.ts
CHANGED
|
@@ -230,10 +230,6 @@ export default class ChannelSpend extends Channel {
|
|
|
230
230
|
* @param amount - Amount of coins to withdraw
|
|
231
231
|
* @param sign - Function which verifies and signs withdraw transaction
|
|
232
232
|
* @param callbacks - Callbacks
|
|
233
|
-
* @param callbacks.onOnChainTx - Called when withdraw transaction has been posted
|
|
234
|
-
* on chain
|
|
235
|
-
* @param callbacks.onOwnWithdrawLocked
|
|
236
|
-
* @param callbacks.onWithdrawLocked
|
|
237
233
|
* @example
|
|
238
234
|
* ```js
|
|
239
235
|
* channel.withdraw(
|
|
@@ -305,10 +301,6 @@ export default class ChannelSpend extends Channel {
|
|
|
305
301
|
* @param amount - Amount of coins to deposit
|
|
306
302
|
* @param sign - Function which verifies and signs deposit transaction
|
|
307
303
|
* @param callbacks - Callbacks
|
|
308
|
-
* @param callbacks.onOnChainTx - Called when deposit transaction has been posted
|
|
309
|
-
* on chain
|
|
310
|
-
* @param callbacks.onOwnDepositLocked
|
|
311
|
-
* @param callbacks.onDepositLocked
|
|
312
304
|
* @example
|
|
313
305
|
* ```js
|
|
314
306
|
* channel.deposit(
|
package/src/channel/internal.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w3cwebsocket as W3CWebSocket } from 'websocket';
|
|
1
|
+
import { w3cwebsocket as W3CWebSocket, ICloseEvent } from 'websocket';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
3
|
import type Channel from './Base';
|
|
4
4
|
import JsonBig from '../utils/json-big';
|
|
@@ -49,43 +49,139 @@ export type SignTx = (tx: Encoded.Transaction, options?: SignOptions) => (
|
|
|
49
49
|
Promise<Encoded.Transaction | number | null>
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* @see {@link https://github.com/aeternity/protocol/blob/6734de2e4c7cce7e5e626caa8305fb535785131d/node/api/channels_api_usage.md#channel-establishing-parameters}
|
|
54
|
+
*/
|
|
52
55
|
export interface ChannelOptions {
|
|
53
56
|
existingFsmId?: Encoded.Bytearray;
|
|
57
|
+
/**
|
|
58
|
+
* Channel url (for example: "ws://localhost:3001")
|
|
59
|
+
*/
|
|
54
60
|
url: string;
|
|
55
61
|
|
|
56
62
|
/**
|
|
57
|
-
*
|
|
63
|
+
* Initiator's public key
|
|
58
64
|
*/
|
|
59
65
|
initiatorId: Encoded.AccountAddress;
|
|
66
|
+
/**
|
|
67
|
+
* Responder's public key
|
|
68
|
+
*/
|
|
60
69
|
responderId: Encoded.AccountAddress;
|
|
70
|
+
/**
|
|
71
|
+
* Amount of blocks for disputing a solo close
|
|
72
|
+
*/
|
|
61
73
|
lockPeriod: number;
|
|
74
|
+
/**
|
|
75
|
+
* Initial deposit in favour of the responder by the initiator
|
|
76
|
+
*/
|
|
62
77
|
pushAmount: number;
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Amount of coins the initiator has committed to the channel
|
|
80
|
+
*/
|
|
81
|
+
initiatorAmount: BigNumber | number;
|
|
82
|
+
/**
|
|
83
|
+
* Amount of coins the responder has committed to the channel
|
|
84
|
+
*/
|
|
85
|
+
responderAmount: BigNumber | number;
|
|
86
|
+
/**
|
|
87
|
+
* The minimum amount both peers need to maintain
|
|
88
|
+
*/
|
|
65
89
|
channelReserve?: BigNumber | number;
|
|
90
|
+
/**
|
|
91
|
+
* Minimum block height to include the channel_create_tx
|
|
92
|
+
*/
|
|
66
93
|
ttl?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Host of the responder's node
|
|
96
|
+
*/
|
|
67
97
|
host: string;
|
|
98
|
+
/**
|
|
99
|
+
* The port of the responders node
|
|
100
|
+
*/
|
|
68
101
|
port: number;
|
|
102
|
+
/**
|
|
103
|
+
* Participant role
|
|
104
|
+
*/
|
|
69
105
|
role: 'initiator' | 'responder';
|
|
106
|
+
/**
|
|
107
|
+
* How to calculate minimum depth (default: txfee)
|
|
108
|
+
*/
|
|
70
109
|
minimumDepthStrategy?: 'txfee' | 'plain';
|
|
110
|
+
/**
|
|
111
|
+
* The minimum amount of blocks to be mined
|
|
112
|
+
*/
|
|
71
113
|
minimumDepth?: number;
|
|
114
|
+
/**
|
|
115
|
+
* The fee to be used for the channel open transaction
|
|
116
|
+
*/
|
|
72
117
|
fee?: BigNumber | number;
|
|
118
|
+
/**
|
|
119
|
+
* Used for the fee computation of the channel open transaction
|
|
120
|
+
*/
|
|
73
121
|
gasPrice?: BigNumber | number;
|
|
74
122
|
|
|
75
123
|
signedTx?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Existing channel id (required if reestablishing a channel)
|
|
126
|
+
*/
|
|
76
127
|
existingChannelId?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Offchain transaction (required if reestablishing a channel)
|
|
130
|
+
*/
|
|
77
131
|
offChainTx?: string;
|
|
78
132
|
reconnectTx?: string;
|
|
133
|
+
/**
|
|
134
|
+
* The time waiting for a new event to be initiated (default: 600000)
|
|
135
|
+
*/
|
|
79
136
|
timeoutIdle?: number;
|
|
137
|
+
/**
|
|
138
|
+
* The time waiting for the initiator to produce the create channel transaction after the noise
|
|
139
|
+
* session had been established (default: 120000)
|
|
140
|
+
*/
|
|
80
141
|
timeoutFundingCreate?: number;
|
|
142
|
+
/**
|
|
143
|
+
* The time frame the other client has to sign an off-chain update after our client had initiated
|
|
144
|
+
* and signed it. This applies only for double signed on-chain intended updates: channel create
|
|
145
|
+
* transaction, deposit, withdrawal and etc. (default: 120000)
|
|
146
|
+
*/
|
|
81
147
|
timeoutFundingSign?: number;
|
|
148
|
+
/**
|
|
149
|
+
* The time frame the other client has to confirm an on-chain transaction reaching maturity
|
|
150
|
+
* (passing minimum depth) after the local node has detected this. This applies only for double
|
|
151
|
+
* signed on-chain intended updates: channel create transaction, deposit, withdrawal and etc.
|
|
152
|
+
* (default: 360000)
|
|
153
|
+
*/
|
|
82
154
|
timeoutFundingLock?: number;
|
|
155
|
+
/**
|
|
156
|
+
* The time frame the client has to return a signed off-chain update or to decline it.
|
|
157
|
+
* This applies for all off-chain updates (default: 500000)
|
|
158
|
+
*/
|
|
83
159
|
timeoutSign?: number;
|
|
160
|
+
/**
|
|
161
|
+
* The time frame the other client has to react to an event. This applies for all off-chain
|
|
162
|
+
* updates that are not meant to land on-chain, as well as some special cases: opening a noise
|
|
163
|
+
* connection, mutual closing acknowledgement and reestablishing an existing channel
|
|
164
|
+
* (default: 120000)
|
|
165
|
+
*/
|
|
84
166
|
timeoutAccept?: number;
|
|
167
|
+
/**
|
|
168
|
+
* the time frame the responder has to accept an incoming noise session.
|
|
169
|
+
* Applicable only for initiator (default: timeout_accept's value)
|
|
170
|
+
*/
|
|
85
171
|
timeoutInitialized?: number;
|
|
172
|
+
/**
|
|
173
|
+
* The time frame the initiator has to start an outgoing noise session to the responder's node.
|
|
174
|
+
* Applicable only for responder (default: timeout_idle's value)
|
|
175
|
+
*/
|
|
86
176
|
timeoutAwaitingOpen?: number;
|
|
87
177
|
statePassword?: string;
|
|
88
|
-
|
|
178
|
+
/**
|
|
179
|
+
* Log websocket communication and state changes
|
|
180
|
+
*/
|
|
181
|
+
debug?: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Function which verifies and signs transactions
|
|
184
|
+
*/
|
|
89
185
|
sign: SignTxWithTag;
|
|
90
186
|
offchainTx?: string;
|
|
91
187
|
}
|
|
@@ -100,6 +196,9 @@ export interface ChannelState {
|
|
|
100
196
|
reject: (e: BaseError) => void;
|
|
101
197
|
sign: SignTx;
|
|
102
198
|
handler?: ChannelHandler;
|
|
199
|
+
/**
|
|
200
|
+
* Called when transaction has been posted on chain
|
|
201
|
+
*/
|
|
103
202
|
onOnChainTx?: (tx: Encoded.Transaction) => void;
|
|
104
203
|
onOwnWithdrawLocked?: () => void;
|
|
105
204
|
onWithdrawLocked?: () => void;
|
|
@@ -152,6 +251,7 @@ function enterState(channel: Channel, nextState: ChannelFsm): void {
|
|
|
152
251
|
if (nextState == null) {
|
|
153
252
|
throw new UnknownChannelStateError();
|
|
154
253
|
}
|
|
254
|
+
channel._debug('enter state', nextState.handler.name);
|
|
155
255
|
channel._fsm = nextState;
|
|
156
256
|
if (nextState?.handler?.enter != null) {
|
|
157
257
|
nextState.handler.enter(channel);
|
|
@@ -164,7 +264,8 @@ function enterState(channel: Channel, nextState: ChannelFsm): void {
|
|
|
164
264
|
export type ChannelStatus = 'connecting' | 'connected' | 'accepted' | 'halfSigned' | 'signed'
|
|
165
265
|
| 'open' | 'closing' | 'closed' | 'died' | 'disconnected';
|
|
166
266
|
|
|
167
|
-
export function changeStatus(channel: Channel, newStatus: ChannelStatus): void {
|
|
267
|
+
export function changeStatus(channel: Channel, newStatus: ChannelStatus, debug?: unknown): void {
|
|
268
|
+
channel._debug(newStatus, `(prev. ${channel._status})`, debug ?? '');
|
|
168
269
|
if (newStatus === channel._status) return;
|
|
169
270
|
channel._status = newStatus;
|
|
170
271
|
emit(channel, 'statusChanged', newStatus);
|
|
@@ -176,7 +277,7 @@ export function changeState(channel: Channel, newState: Encoded.Transaction | ''
|
|
|
176
277
|
}
|
|
177
278
|
|
|
178
279
|
function send(channel: Channel, message: ChannelMessage): void {
|
|
179
|
-
|
|
280
|
+
channel._debug('send message', message.method, message.params);
|
|
180
281
|
channel._websocket.send(JsonBig.stringify({ jsonrpc: '2.0', ...message }));
|
|
181
282
|
}
|
|
182
283
|
|
|
@@ -266,7 +367,7 @@ function ping(channel: Channel): void {
|
|
|
266
367
|
|
|
267
368
|
function onMessage(channel: Channel, data: string): void {
|
|
268
369
|
const message = JsonBig.parse(data);
|
|
269
|
-
|
|
370
|
+
channel._debug('received message', message.method, message.params);
|
|
270
371
|
if (message.id != null) {
|
|
271
372
|
const callback = channel._rpcCallbacks.get(message.id);
|
|
272
373
|
if (callback == null) {
|
|
@@ -317,7 +418,6 @@ export async function initialize(
|
|
|
317
418
|
{ url, ...channelOptions }: ChannelOptions,
|
|
318
419
|
): Promise<void> {
|
|
319
420
|
channel._options = { url, ...channelOptions };
|
|
320
|
-
channel._fsm = { handler: connectionHandler };
|
|
321
421
|
|
|
322
422
|
const wsUrl = new URL(url);
|
|
323
423
|
Object.entries(channelOptions)
|
|
@@ -329,9 +429,9 @@ export async function initialize(
|
|
|
329
429
|
await new Promise<void>((resolve, reject) => {
|
|
330
430
|
Object.assign(channel._websocket, {
|
|
331
431
|
onerror: reject,
|
|
332
|
-
onopen: async () => {
|
|
432
|
+
onopen: async (event: Event) => {
|
|
333
433
|
resolve();
|
|
334
|
-
changeStatus(channel, 'connected');
|
|
434
|
+
changeStatus(channel, 'connected', event);
|
|
335
435
|
if (channelOptions.reconnectTx != null) {
|
|
336
436
|
enterState(channel, { handler: openHandler });
|
|
337
437
|
const { signedTx } = await channel.state();
|
|
@@ -339,11 +439,13 @@ export async function initialize(
|
|
|
339
439
|
throw new ChannelError('`signedTx` missed in state while reconnection');
|
|
340
440
|
}
|
|
341
441
|
changeState(channel, buildTx(signedTx));
|
|
442
|
+
} else {
|
|
443
|
+
enterState(channel, { handler: connectionHandler });
|
|
342
444
|
}
|
|
343
445
|
ping(channel);
|
|
344
446
|
},
|
|
345
|
-
onclose: () => {
|
|
346
|
-
changeStatus(channel, 'disconnected');
|
|
447
|
+
onclose: (event: ICloseEvent) => {
|
|
448
|
+
changeStatus(channel, 'disconnected', event);
|
|
347
449
|
clearTimeout(channel._pingTimeoutId);
|
|
348
450
|
},
|
|
349
451
|
onmessage: ({ data }: { data: string }) => onMessage(channel, data),
|