@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/utils/autorest.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RestError, PipelineResponse
|
|
2
|
-
import { AdditionalPolicyConfig } from '@azure/core-client';
|
|
1
|
+
import { RestError, PipelineResponse } from '@azure/core-rest-pipeline';
|
|
2
|
+
import { AdditionalPolicyConfig, FullOperationResponse, OperationOptions } from '@azure/core-client';
|
|
3
3
|
import { pause } from './other';
|
|
4
4
|
import semverSatisfies from './semver-satisfies';
|
|
5
5
|
import { UnsupportedVersionError } from './errors';
|
|
@@ -16,9 +16,7 @@ export const genRequestQueuesPolicy = (): AdditionalPolicyConfig => {
|
|
|
16
16
|
const getResponse = async (): Promise<PipelineResponse> => next(request);
|
|
17
17
|
if (key == null) return getResponse();
|
|
18
18
|
const req = (requestQueues.get(key) ?? Promise.resolve()).then(getResponse);
|
|
19
|
-
|
|
20
|
-
// gap to ensure that node won't reject the nonce
|
|
21
|
-
requestQueues.set(key, req.then(async () => pause(750), () => {}));
|
|
19
|
+
requestQueues.set(key, req.catch(() => {}));
|
|
22
20
|
return req;
|
|
23
21
|
},
|
|
24
22
|
},
|
|
@@ -76,16 +74,16 @@ export const genErrorFormatterPolicy = (
|
|
|
76
74
|
return await next(request);
|
|
77
75
|
} catch (error) {
|
|
78
76
|
if (!(error instanceof RestError) || error.request == null) throw error;
|
|
79
|
-
|
|
77
|
+
const prefix = `${new URL(error.request.url).pathname.slice(1)} error`;
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
body = JSON.parse(error.response.bodyAsText);
|
|
84
|
-
} catch (e) {
|
|
79
|
+
if (error.response?.bodyAsText == null) {
|
|
80
|
+
if (error.message === '') error.message = `${prefix}: ${error.code}`;
|
|
85
81
|
throw error;
|
|
86
82
|
}
|
|
87
|
-
|
|
88
|
-
const
|
|
83
|
+
|
|
84
|
+
const body = (error.response as FullOperationResponse).parsedBody;
|
|
85
|
+
error.message = prefix;
|
|
86
|
+
const message = body == null ? ` ${error.response.status} status code` : getMessage(body);
|
|
89
87
|
if (message !== '') error.message += `:${message}`;
|
|
90
88
|
throw error;
|
|
91
89
|
}
|
|
@@ -96,20 +94,24 @@ export const genErrorFormatterPolicy = (
|
|
|
96
94
|
|
|
97
95
|
export const genVersionCheckPolicy = (
|
|
98
96
|
name: string,
|
|
99
|
-
|
|
100
|
-
versionPromise: Promise<string | Error>,
|
|
97
|
+
versionCb: (options: OperationOptions) => Promise<string>,
|
|
101
98
|
geVersion: string,
|
|
102
99
|
ltVersion: string,
|
|
103
|
-
):
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
): AdditionalPolicyConfig => ({
|
|
101
|
+
policy: {
|
|
102
|
+
name: 'version-check',
|
|
103
|
+
async sendRequest(request, next) {
|
|
104
|
+
if (request.headers.has('__version-check')) {
|
|
105
|
+
request.headers.delete('__version-check');
|
|
106
|
+
return next(request);
|
|
107
|
+
}
|
|
108
|
+
const options = { requestOptions: { customHeaders: { '__version-check': 'true' } } };
|
|
109
|
+
const args = [await versionCb(options), geVersion, ltVersion] as const;
|
|
110
|
+
if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);
|
|
111
|
+
return next(request);
|
|
112
|
+
},
|
|
112
113
|
},
|
|
114
|
+
position: 'perCall',
|
|
113
115
|
});
|
|
114
116
|
|
|
115
117
|
export const genRetryOnFailurePolicy = (
|
|
@@ -119,16 +121,23 @@ export const genRetryOnFailurePolicy = (
|
|
|
119
121
|
policy: {
|
|
120
122
|
name: 'retry-on-failure',
|
|
121
123
|
async sendRequest(request, next) {
|
|
122
|
-
const
|
|
124
|
+
const retryCode = request.headers.get('__retry-code') ?? NaN;
|
|
125
|
+
request.headers.delete('__retry-code');
|
|
126
|
+
const statusesToNotRetry = [200, 400, 403, 410, 500].filter((c) => c !== +retryCode);
|
|
123
127
|
|
|
124
128
|
const intervals = new Array(retryCount).fill(0)
|
|
125
129
|
.map((_, idx) => ((idx + 1) / retryCount) ** 2);
|
|
126
|
-
const intervalSum = intervals.reduce((a, b) => a + b);
|
|
127
|
-
const intervalsInMs = intervals.map((
|
|
130
|
+
const intervalSum = intervals.reduce((a, b) => a + b, 0);
|
|
131
|
+
const intervalsInMs = intervals.map((e) => Math.floor((e / intervalSum) * retryOverallDelay));
|
|
128
132
|
|
|
129
133
|
let error = new RestError('Not expected to be thrown');
|
|
130
134
|
for (let attempt = 0; attempt <= retryCount; attempt += 1) {
|
|
131
|
-
if (attempt !== 0)
|
|
135
|
+
if (attempt !== 0) {
|
|
136
|
+
await pause(intervalsInMs[attempt - 1]);
|
|
137
|
+
const urlParsed = new URL(request.url);
|
|
138
|
+
urlParsed.searchParams.set('__sdk-retry', attempt.toString());
|
|
139
|
+
request.url = urlParsed.toString();
|
|
140
|
+
}
|
|
132
141
|
try {
|
|
133
142
|
return await next(request);
|
|
134
143
|
} catch (e) {
|
package/src/utils/crypto.ts
CHANGED
|
@@ -4,7 +4,7 @@ import nacl, { SignKeyPair } from 'tweetnacl';
|
|
|
4
4
|
import { blake2b } from 'blakejs/blake2b.js';
|
|
5
5
|
import { encode as varuintEncode } from 'varuint-bitcoin';
|
|
6
6
|
|
|
7
|
-
import { concatBuffers } from './other';
|
|
7
|
+
import { concatBuffers, isItemOfArray } from './other';
|
|
8
8
|
import {
|
|
9
9
|
decode, encode, Encoded, Encoding,
|
|
10
10
|
} from './encoder';
|
|
@@ -23,22 +23,32 @@ export function getAddressFromPriv(secret: string | Uint8Array): Encoded.Account
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Check if address is valid
|
|
26
|
-
* @param
|
|
27
|
-
* @param prefix - Transaction prefix. Default: 'ak'
|
|
28
|
-
* @returns is valid
|
|
26
|
+
* @param maybeAddress - Address to check
|
|
29
27
|
*/
|
|
30
|
-
export function isAddressValid(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
export function isAddressValid(maybeAddress: string): maybeAddress is Encoded.AccountAddress;
|
|
29
|
+
/**
|
|
30
|
+
* Check if data is encoded in one of provided encodings
|
|
31
|
+
* @param maybeEncoded - Data to check
|
|
32
|
+
* @param encodings - Rest parameters with encodings to check against
|
|
33
|
+
*/
|
|
34
|
+
export function isAddressValid<E extends Encoding>(
|
|
35
|
+
maybeEncoded: string,
|
|
36
|
+
...encodings: E[]
|
|
37
|
+
): maybeEncoded is Encoded.Generic<E>;
|
|
38
|
+
export function isAddressValid(maybeEncoded: string, ...encodings: Encoding[]): boolean {
|
|
39
|
+
if (encodings.length === 0) encodings = [Encoding.AccountAddress];
|
|
34
40
|
try {
|
|
35
|
-
decode(
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
throw new ArgumentError(
|
|
41
|
+
decode(maybeEncoded as Encoded.Any);
|
|
42
|
+
const encoding = maybeEncoded.split('_')[0];
|
|
43
|
+
if (!isItemOfArray(encoding, encodings)) {
|
|
44
|
+
throw new ArgumentError(
|
|
45
|
+
'Encoded string type',
|
|
46
|
+
encodings.length > 1 ? `one of ${encodings.join(', ')}` : encodings[0],
|
|
47
|
+
encoding,
|
|
48
|
+
);
|
|
39
49
|
}
|
|
40
50
|
return true;
|
|
41
|
-
} catch (
|
|
51
|
+
} catch (error) {
|
|
42
52
|
return false;
|
|
43
53
|
}
|
|
44
54
|
}
|
package/src/utils/errors.ts
CHANGED
|
@@ -247,6 +247,16 @@ export class UnsupportedVersionError extends BaseError {
|
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
/**
|
|
251
|
+
* @category exception
|
|
252
|
+
*/
|
|
253
|
+
export class LogicError extends BaseError {
|
|
254
|
+
constructor(message: string) {
|
|
255
|
+
super(message);
|
|
256
|
+
this.name = 'LogicError';
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
250
260
|
/**
|
|
251
261
|
* @category exception
|
|
252
262
|
*/
|
package/src/utils/hd-wallet.ts
CHANGED
|
@@ -71,6 +71,8 @@ type Bip32Path<MaxLen extends number> =
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* @category hd-wallet
|
|
74
|
+
* @param keyTreeNode - A node of key tree
|
|
75
|
+
* @param index - index of child node to derive
|
|
74
76
|
*/
|
|
75
77
|
export function deriveChild({ secretKey, chainCode }: KeyTreeNode, index: number): KeyTreeNode {
|
|
76
78
|
if (index < HARDENED_OFFSET) {
|
package/src/utils/jwt.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import canonicalize from 'canonicalize';
|
|
2
|
+
import AccountBase from '../account/Base';
|
|
3
|
+
import {
|
|
4
|
+
Encoded, Encoding, decode, encode,
|
|
5
|
+
} from './encoder';
|
|
6
|
+
import { verify } from './crypto';
|
|
7
|
+
import { ArgumentError, InvalidSignatureError } from './errors';
|
|
8
|
+
|
|
9
|
+
// TODO: use Buffer.from(data, 'base64url') after solving https://github.com/feross/buffer/issues/309
|
|
10
|
+
const toBase64Url = (data: Buffer | Uint8Array | string): string => Buffer
|
|
11
|
+
.from(data)
|
|
12
|
+
.toString('base64')
|
|
13
|
+
.replaceAll('/', '_')
|
|
14
|
+
.replaceAll('+', '-')
|
|
15
|
+
.replace(/=+$/, '');
|
|
16
|
+
|
|
17
|
+
const fromBase64Url = (data: string): Buffer => Buffer
|
|
18
|
+
.from(data.replaceAll('_', '/').replaceAll('-', '+'), 'base64');
|
|
19
|
+
|
|
20
|
+
const objectToBase64Url = (data: any): string => toBase64Url(canonicalize(data) ?? '');
|
|
21
|
+
|
|
22
|
+
const header = 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9'; // objectToBase64Url({ alg: 'EdDSA', typ: 'JWT' })
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* JWT including specific header
|
|
26
|
+
* @category JWT
|
|
27
|
+
*/
|
|
28
|
+
export type Jwt = `${typeof header}.${string}.${string}`;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Generate a signed JWT
|
|
32
|
+
* Provide `"sub_jwk": undefined` in payload to omit signer public key added by default.
|
|
33
|
+
* @param originalPayload - Payload to sign
|
|
34
|
+
* @param account - Account to sign by
|
|
35
|
+
* @category JWT
|
|
36
|
+
*/
|
|
37
|
+
export async function signJwt(originalPayload: any, account: AccountBase): Promise<Jwt> {
|
|
38
|
+
const payload = { ...originalPayload };
|
|
39
|
+
if (!('sub_jwk' in payload)) {
|
|
40
|
+
payload.sub_jwk = {
|
|
41
|
+
kty: 'OKP',
|
|
42
|
+
crv: 'Ed25519',
|
|
43
|
+
x: toBase64Url(decode(account.address)),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (payload.sub_jwk === undefined) delete payload.sub_jwk;
|
|
47
|
+
const body = `${header}.${objectToBase64Url(payload)}` as const;
|
|
48
|
+
const signature = await account.sign(body);
|
|
49
|
+
return `${body}.${toBase64Url(signature)}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Unpack JWT. It will check signature if address or "sub_jwk" provided.
|
|
54
|
+
* @param jwt - JWT to unpack
|
|
55
|
+
* @param address - Address to check signature
|
|
56
|
+
* @category JWT
|
|
57
|
+
*/
|
|
58
|
+
export function unpackJwt(jwt: Jwt, address?: Encoded.AccountAddress): {
|
|
59
|
+
/**
|
|
60
|
+
* JWT payload as object
|
|
61
|
+
*/
|
|
62
|
+
payload: any;
|
|
63
|
+
/**
|
|
64
|
+
* Undefined returned in case signature is not checked
|
|
65
|
+
*/
|
|
66
|
+
signer: Encoded.AccountAddress | undefined;
|
|
67
|
+
} {
|
|
68
|
+
const components = jwt.split('.');
|
|
69
|
+
if (components.length !== 3) throw new ArgumentError('JWT components count', 3, components.length);
|
|
70
|
+
const [h, payloadEncoded, signature] = components;
|
|
71
|
+
if (h !== header) throw new ArgumentError('JWT header', header, h);
|
|
72
|
+
const payload = JSON.parse(fromBase64Url(payloadEncoded).toString());
|
|
73
|
+
const jwk = payload.sub_jwk ?? {};
|
|
74
|
+
const signer = jwk.x == null || jwk.kty !== 'OKP' || jwk.crv !== 'Ed25519'
|
|
75
|
+
? address
|
|
76
|
+
: encode(fromBase64Url(jwk.x), Encoding.AccountAddress);
|
|
77
|
+
if (address != null && signer !== address) {
|
|
78
|
+
throw new ArgumentError('address', `${signer} ("sub_jwk")`, address);
|
|
79
|
+
}
|
|
80
|
+
if (
|
|
81
|
+
signer != null
|
|
82
|
+
&& !verify(Buffer.from(`${h}.${payloadEncoded}`), fromBase64Url(signature), signer)
|
|
83
|
+
) {
|
|
84
|
+
throw new InvalidSignatureError(`JWT is not signed by ${signer}`);
|
|
85
|
+
}
|
|
86
|
+
return { payload, signer };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Check is string a JWT or not. Use to validate the user input.
|
|
91
|
+
* @param maybeJwt - A string to check
|
|
92
|
+
* @returns True if argument is a JWT
|
|
93
|
+
* @category JWT
|
|
94
|
+
*/
|
|
95
|
+
export function isJwt(maybeJwt: string): maybeJwt is Jwt {
|
|
96
|
+
try {
|
|
97
|
+
unpackJwt(maybeJwt as Jwt);
|
|
98
|
+
return true;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Throws an error if argument is not JWT. Use to ensure that a value is JWT.
|
|
106
|
+
* @param maybeJwt - A string to check
|
|
107
|
+
* @category JWT
|
|
108
|
+
*/
|
|
109
|
+
export function ensureJwt(maybeJwt: string): asserts maybeJwt is Jwt {
|
|
110
|
+
unpackJwt(maybeJwt as Jwt);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Check is JWT signed by address from arguments or "sub_jwk"
|
|
115
|
+
* @param jwt - JWT to check
|
|
116
|
+
* @param address - Address to check signature
|
|
117
|
+
* @category JWT
|
|
118
|
+
*/
|
|
119
|
+
export function verifyJwt(jwt: Jwt, address?: Encoded.AccountAddress): boolean {
|
|
120
|
+
try {
|
|
121
|
+
const { signer } = unpackJwt(jwt, address);
|
|
122
|
+
return signer != null;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
package/src/utils/keystore.ts
CHANGED
|
@@ -45,7 +45,13 @@ export interface Keystore {
|
|
|
45
45
|
cipher_params: {
|
|
46
46
|
nonce: string;
|
|
47
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Key derivation function name.
|
|
50
|
+
*/
|
|
48
51
|
kdf: keyof typeof DERIVED_KEY_FUNCTIONS;
|
|
52
|
+
/**
|
|
53
|
+
* Key derivation function parameters.
|
|
54
|
+
*/
|
|
49
55
|
kdf_params: {
|
|
50
56
|
memlimit_kib: number;
|
|
51
57
|
opslimit: number;
|
|
@@ -149,8 +155,6 @@ export async function recover(
|
|
|
149
155
|
* @param nonce - Randomly generated 24byte nonce.
|
|
150
156
|
* @param salt - Randomly generated 16byte salt.
|
|
151
157
|
* @param options - Encryption parameters.
|
|
152
|
-
* @param options.kdf - Key derivation function.
|
|
153
|
-
* @param options.kdf_params - KDF parameters.
|
|
154
158
|
*/
|
|
155
159
|
export async function dump(
|
|
156
160
|
name: string,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ArgumentError } from './errors';
|
|
2
|
+
|
|
3
|
+
export function wrapWithProxy<Value extends object | undefined>(
|
|
4
|
+
valueCb: () => Value,
|
|
5
|
+
): NonNullable<Value> {
|
|
6
|
+
return new Proxy(
|
|
7
|
+
{},
|
|
8
|
+
Object.fromEntries(([
|
|
9
|
+
'apply', 'construct', 'defineProperty', 'deleteProperty', 'getOwnPropertyDescriptor',
|
|
10
|
+
'getPrototypeOf', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf',
|
|
11
|
+
'get', 'has',
|
|
12
|
+
] as const).map((name) => [name, (t: {}, ...args: unknown[]) => {
|
|
13
|
+
const target = valueCb();
|
|
14
|
+
if (target == null) throw new ArgumentError('wrapped value', 'defined', target);
|
|
15
|
+
if (name === 'get' && args[0] === '_wrappedValue') return target;
|
|
16
|
+
const res = (Reflect[name] as any)(target, ...args);
|
|
17
|
+
return typeof res === 'function' && name === 'get' ? res.bind(target) : res;
|
|
18
|
+
}])),
|
|
19
|
+
) as NonNullable<Value>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function unwrapProxy<Value extends object>(value: Value): Value {
|
|
23
|
+
return (value as { _wrappedValue?: Value })._wrappedValue ?? value;
|
|
24
|
+
}
|
|
@@ -7,6 +7,9 @@ export default class AeSdk extends AeSdkBase {
|
|
|
7
7
|
[key: string]: AccountBase;
|
|
8
8
|
};
|
|
9
9
|
selectedAddress?: Encoded.AccountAddress;
|
|
10
|
+
/**
|
|
11
|
+
* @param options - Options
|
|
12
|
+
*/
|
|
10
13
|
constructor({ accounts, ...options }?: {
|
|
11
14
|
accounts?: AccountBase[];
|
|
12
15
|
} & ConstructorParameters<typeof AeSdkBase>[0]);
|
|
@@ -39,7 +39,6 @@ export default class AeSdkAepp extends AeSdkBase {
|
|
|
39
39
|
* @param options - Options
|
|
40
40
|
* @param options.connectNode - Request wallet to bind node
|
|
41
41
|
* @param options.name - Node name
|
|
42
|
-
* @param options.select - Select this node as current
|
|
43
42
|
*/
|
|
44
43
|
connectToWallet(connection: BrowserConnection, { connectNode, name }?: {
|
|
45
44
|
connectNode?: boolean;
|
|
@@ -2,7 +2,7 @@ import Node from './Node';
|
|
|
2
2
|
import AccountBase from './account/Base';
|
|
3
3
|
import { Encoded } from './utils/encoder';
|
|
4
4
|
import CompilerBase from './contract/compiler/Base';
|
|
5
|
-
import AeSdkMethods, { OnAccount, AeSdkMethodsOptions } from './AeSdkMethods';
|
|
5
|
+
import AeSdkMethods, { OnAccount, AeSdkMethodsOptions, WrappedOptions } from './AeSdkMethods';
|
|
6
6
|
import { AensName } from './tx/builder/constants';
|
|
7
7
|
type NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & {
|
|
8
8
|
name: string;
|
|
@@ -14,6 +14,7 @@ type NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & {
|
|
|
14
14
|
* - wrappers of account methods mapped to the current account.
|
|
15
15
|
*/
|
|
16
16
|
export default class AeSdkBase extends AeSdkMethods {
|
|
17
|
+
#private;
|
|
17
18
|
pool: Map<string, Node>;
|
|
18
19
|
selectedNodeName?: string;
|
|
19
20
|
/**
|
|
@@ -79,31 +80,85 @@ export default class AeSdkBase extends AeSdkMethods {
|
|
|
79
80
|
*/
|
|
80
81
|
_resolveAccount(account?: OnAccount): AccountBase;
|
|
81
82
|
get address(): Encoded.AccountAddress;
|
|
83
|
+
/**
|
|
84
|
+
* Sign data blob
|
|
85
|
+
* @param data - Data to sign
|
|
86
|
+
* @param options - Options
|
|
87
|
+
*/
|
|
82
88
|
sign(data: string | Uint8Array, { onAccount, ...options }?: {
|
|
83
89
|
onAccount?: OnAccount;
|
|
84
90
|
}): Promise<Uint8Array>;
|
|
91
|
+
/**
|
|
92
|
+
* Sign encoded transaction
|
|
93
|
+
* @param tx - Transaction to sign
|
|
94
|
+
* @param options - Options
|
|
95
|
+
*/
|
|
85
96
|
signTransaction(tx: Encoded.Transaction, { onAccount, ...options }?: {
|
|
86
97
|
onAccount?: OnAccount;
|
|
87
98
|
} & Parameters<AccountBase['signTransaction']>[1]): Promise<Encoded.Transaction>;
|
|
99
|
+
/**
|
|
100
|
+
* Sign message
|
|
101
|
+
* @param message - Message to sign
|
|
102
|
+
* @param options - Options
|
|
103
|
+
*/
|
|
88
104
|
signMessage(message: string, { onAccount, ...options }?: {
|
|
89
105
|
onAccount?: OnAccount;
|
|
90
106
|
} & Parameters<AccountBase['signMessage']>[1]): Promise<Uint8Array>;
|
|
107
|
+
/**
|
|
108
|
+
* Sign typed data
|
|
109
|
+
* @param data - Encoded data to sign
|
|
110
|
+
* @param aci - Type of data to sign
|
|
111
|
+
* @param options - Options
|
|
112
|
+
*/
|
|
91
113
|
signTypedData(data: Encoded.ContractBytearray, aci: Parameters<AccountBase['signTypedData']>[1], { onAccount, ...options }?: {
|
|
92
114
|
onAccount?: OnAccount;
|
|
93
115
|
} & Parameters<AccountBase['signTypedData']>[2]): Promise<Encoded.Signature>;
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated use AeSdkBase:signDelegation in Ceres
|
|
118
|
+
* @param contractAddress - Contract address
|
|
119
|
+
* @param options - Options
|
|
120
|
+
*/
|
|
94
121
|
signDelegationToContract(contractAddress: Encoded.ContractAddress, { onAccount, ...options }?: {
|
|
95
122
|
onAccount?: OnAccount;
|
|
96
123
|
} & Parameters<AccountBase['signDelegationToContract']>[1]): Promise<Encoded.Signature>;
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated use AeSdkBase:signDelegation in Ceres
|
|
126
|
+
* @param contractAddress - Contract address
|
|
127
|
+
* @param name - AENS name
|
|
128
|
+
* @param options - Options
|
|
129
|
+
*/
|
|
97
130
|
signNameDelegationToContract(contractAddress: Encoded.ContractAddress, name: AensName, { onAccount, ...options }?: {
|
|
98
131
|
onAccount?: OnAccount;
|
|
99
132
|
} & Parameters<AccountBase['signNameDelegationToContract']>[2]): Promise<Encoded.Signature>;
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated use AeSdkBase:signDelegation in Ceres
|
|
135
|
+
* @param contractAddress - Contract address
|
|
136
|
+
* @param options - Options
|
|
137
|
+
*/
|
|
138
|
+
signAllNamesDelegationToContract(contractAddress: Encoded.ContractAddress, { onAccount, ...options }?: {
|
|
139
|
+
onAccount?: OnAccount;
|
|
140
|
+
} & Parameters<AccountBase['signAllNamesDelegationToContract']>[1]): Promise<Encoded.Signature>;
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated use AeSdkBase:signDelegation in Ceres
|
|
143
|
+
* @param contractAddress - Contract address
|
|
144
|
+
* @param oracleQueryId - Oracle query id
|
|
145
|
+
* @param options - Options
|
|
146
|
+
*/
|
|
100
147
|
signOracleQueryDelegationToContract(contractAddress: Encoded.ContractAddress, oracleQueryId: Encoded.OracleQueryId, { onAccount, ...options }?: {
|
|
101
148
|
onAccount?: OnAccount;
|
|
102
149
|
} & Parameters<AccountBase['signOracleQueryDelegationToContract']>[2]): Promise<Encoded.Signature>;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Sign delegation, works only in Ceres
|
|
152
|
+
* @param delegation - Delegation to sign
|
|
153
|
+
* @param options - Options
|
|
154
|
+
*/
|
|
155
|
+
signDelegation(delegation: Encoded.Bytearray, { onAccount, ...options }?: {
|
|
156
|
+
onAccount?: OnAccount;
|
|
157
|
+
} & Parameters<AccountBase['signDelegation']>[1]): Promise<Encoded.Signature>;
|
|
158
|
+
/**
|
|
159
|
+
* The same as AeSdkMethods:getContext, but it would resolve ak_-prefixed address in
|
|
160
|
+
* `mergeWith.onAccount` to AccountBase.
|
|
161
|
+
*/
|
|
162
|
+
getContext(mergeWith?: AeSdkMethodsOptions): AeSdkMethodsOptions & WrappedOptions;
|
|
108
163
|
}
|
|
109
164
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as chainMethods from './chain';
|
|
2
|
+
import { sendTransaction } from './send-transaction';
|
|
2
3
|
import * as aensMethods from './aens';
|
|
3
4
|
import * as spendMethods from './spend';
|
|
4
5
|
import * as oracleMethods from './oracle';
|
|
@@ -12,7 +13,6 @@ import AccountBase from './account/Base';
|
|
|
12
13
|
import { Encoded } from './utils/encoder';
|
|
13
14
|
import CompilerBase from './contract/compiler/Base';
|
|
14
15
|
export type OnAccount = Encoded.AccountAddress | AccountBase | undefined;
|
|
15
|
-
export declare function getValueOrErrorProxy<Value extends object | undefined>(valueCb: () => Value): NonNullable<Value>;
|
|
16
16
|
declare const methods: {
|
|
17
17
|
readonly createGeneralizedAccount: typeof contractGaMethods.createGeneralizedAccount;
|
|
18
18
|
readonly buildAuthTxHash: typeof contractGaMethods.buildAuthTxHash;
|
|
@@ -36,12 +36,12 @@ declare const methods: {
|
|
|
36
36
|
readonly aensClaim: typeof aensMethods.aensClaim;
|
|
37
37
|
readonly aensPreclaim: typeof aensMethods.aensPreclaim;
|
|
38
38
|
readonly aensBid: typeof aensMethods.aensBid;
|
|
39
|
+
readonly sendTransaction: typeof sendTransaction;
|
|
39
40
|
readonly _getPollInterval: typeof chainMethods._getPollInterval;
|
|
40
41
|
readonly getHeight: typeof chainMethods.getHeight;
|
|
41
42
|
readonly poll: typeof chainMethods.poll;
|
|
42
43
|
readonly awaitHeight: typeof chainMethods.awaitHeight;
|
|
43
44
|
readonly waitForTxConfirm: typeof chainMethods.waitForTxConfirm;
|
|
44
|
-
readonly sendTransaction: typeof chainMethods.sendTransaction;
|
|
45
45
|
readonly getAccount: typeof chainMethods.getAccount;
|
|
46
46
|
readonly getBalance: typeof chainMethods.getBalance;
|
|
47
47
|
readonly getCurrentGeneration: typeof chainMethods.getCurrentGeneration;
|
|
@@ -72,6 +72,11 @@ type GetMethodsOptions<Methods extends {
|
|
|
72
72
|
type MethodsOptions = GetMethodsOptions<typeof methods>;
|
|
73
73
|
export interface AeSdkMethodsOptions extends Partial<UnionToIntersection<MethodsOptions[keyof MethodsOptions]>> {
|
|
74
74
|
}
|
|
75
|
+
export interface WrappedOptions {
|
|
76
|
+
onAccount: AccountBase;
|
|
77
|
+
onCompiler: CompilerBase;
|
|
78
|
+
onNode: Node;
|
|
79
|
+
}
|
|
75
80
|
/**
|
|
76
81
|
* AeSdkMethods is the composition of:
|
|
77
82
|
* - chain methods
|
|
@@ -86,16 +91,19 @@ export interface AeSdkMethodsOptions extends Partial<UnionToIntersection<Methods
|
|
|
86
91
|
* their context (current account, network, and compiler to use).
|
|
87
92
|
*/
|
|
88
93
|
declare class AeSdkMethods {
|
|
94
|
+
#private;
|
|
89
95
|
_options: AeSdkMethodsOptions;
|
|
90
96
|
/**
|
|
91
97
|
* @param options - Options
|
|
92
98
|
*/
|
|
93
99
|
constructor(options?: AeSdkMethodsOptions);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Returns sdk instance options with references to current account, node, compiler.
|
|
102
|
+
* Used to create an instance (Contract, Oracle) bound to AeSdk state.
|
|
103
|
+
* @param mergeWith - Merge context with these extra options
|
|
104
|
+
* @returns Context object
|
|
105
|
+
*/
|
|
106
|
+
getContext(mergeWith?: AeSdkMethodsOptions): AeSdkMethodsOptions & WrappedOptions;
|
|
99
107
|
buildTx(options: TxParamsAsync): Promise<Encoded.Transaction>;
|
|
100
108
|
initializeContract<Methods extends ContractMethodsBase>(options?: Omit<Parameters<typeof Contract.initialize>[0], 'onNode'> & {
|
|
101
109
|
onNode?: Node;
|
|
@@ -111,6 +119,10 @@ type OptionalIfNotRequired<T extends [
|
|
|
111
119
|
type ReplaceOnAccount<Options> = Options extends {
|
|
112
120
|
onAccount: any;
|
|
113
121
|
} ? Omit<Options, 'onAccount'> & {
|
|
122
|
+
/**
|
|
123
|
+
* Make operation on specific account by providing address (to use account from sdk) or instance
|
|
124
|
+
* of AccountBase (like MemoryAccount)
|
|
125
|
+
*/
|
|
114
126
|
onAccount: OnAccount;
|
|
115
127
|
} : Options;
|
|
116
128
|
type MakeOptional<Options> = OptionalIfNotRequired<[
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OperationOptions } from '@azure/core-client';
|
|
1
2
|
import { Node as NodeApi, NodeOptionalParams } from './apis/node';
|
|
2
3
|
import { Encoded } from './utils/encoder';
|
|
3
4
|
import { ConsensusProtocolVersion } from './tx/builder/constants';
|
|
@@ -14,6 +15,7 @@ declare const bigIntPropertyNames: readonly [
|
|
|
14
15
|
"initiatorAmountFinal",
|
|
15
16
|
"responderAmountFinal",
|
|
16
17
|
"gasPrice",
|
|
18
|
+
"minGasPrice",
|
|
17
19
|
"deposit"
|
|
18
20
|
];
|
|
19
21
|
declare const numberPropertyNames: readonly [
|
|
@@ -36,7 +38,11 @@ declare const numberPropertyNames: readonly [
|
|
|
36
38
|
"effectiveAtHeight",
|
|
37
39
|
"version",
|
|
38
40
|
"solutions",
|
|
39
|
-
"round"
|
|
41
|
+
"round",
|
|
42
|
+
"minutes",
|
|
43
|
+
"utilization",
|
|
44
|
+
"difficulty",
|
|
45
|
+
"hashrate"
|
|
40
46
|
];
|
|
41
47
|
type BigIntPropertyNames = typeof bigIntPropertyNames[number];
|
|
42
48
|
type NumberPropertyNames = typeof numberPropertyNames[number];
|
|
@@ -76,6 +82,13 @@ export default class Node extends Node_base {
|
|
|
76
82
|
retryCount?: number;
|
|
77
83
|
retryOverallDelay?: number;
|
|
78
84
|
});
|
|
85
|
+
_getCachedStatus(options?: OperationOptions): ReturnType<Node['getStatus']>;
|
|
86
|
+
/** @ts-expect-error use code generation to create node class? */
|
|
87
|
+
getStatus(...args: Parameters<InstanceType<NodeTransformedApi>['getStatus']>): ReturnType<InstanceType<NodeTransformedApi>['getStatus']>;
|
|
88
|
+
/**
|
|
89
|
+
* Returns network ID provided by node.
|
|
90
|
+
* This method won't do extra requests on subsequent calls.
|
|
91
|
+
*/
|
|
79
92
|
getNetworkId(): Promise<string>;
|
|
80
93
|
getNodeInfo(): Promise<NodeInfo>;
|
|
81
94
|
}
|