@aeternity/aepp-sdk 13.2.2 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/bin/aesophia_cli +0 -0
- package/bin/aesophia_cli_8 +0 -0
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +9171 -7086
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +3 -0
- package/es/AeSdk.mjs +12 -12
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +0 -1
- package/es/AeSdkAepp.mjs +12 -16
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +61 -6
- package/es/AeSdkBase.mjs +150 -69
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +19 -7
- package/es/AeSdkMethods.mjs +39 -38
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/AeSdkWallet.mjs +86 -55
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Middleware.mjs +31 -27
- package/es/Middleware.mjs.map +1 -1
- package/es/MiddlewareSubscriber.mjs +5 -14
- package/es/MiddlewareSubscriber.mjs.map +1 -1
- package/es/Node.d.ts +10 -2
- package/es/Node.mjs +53 -54
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +39 -3
- package/es/account/Base.mjs +35 -1
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.d.ts +2 -0
- package/es/account/Generalized.mjs +15 -6
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.d.ts +2 -0
- package/es/account/Ledger.mjs +14 -5
- package/es/account/Ledger.mjs.map +1 -1
- package/es/account/LedgerFactory.mjs +4 -6
- package/es/account/LedgerFactory.mjs.map +1 -1
- package/es/account/Memory.d.ts +15 -4
- package/es/account/Memory.mjs +96 -31
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +16 -5
- package/es/account/Rpc.mjs +94 -21
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +17 -44
- package/es/aens.mjs +32 -71
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +3 -4
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +7 -5
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +8 -9
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +7 -7
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +14 -0
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.d.ts +2 -0
- package/es/aepp-wallet-communication/schema.mjs +2 -0
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +4 -5
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +1 -0
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.mjs +13 -0
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/compiler/models/parameters.mjs.map +1 -1
- package/es/apis/middleware/middleware.d.ts +23 -5
- package/es/apis/middleware/middleware.mjs +114 -18
- package/es/apis/middleware/middleware.mjs.map +1 -1
- package/es/apis/middleware/models/index.d.ts +164 -15
- package/es/apis/middleware/models/index.mjs +53 -3
- package/es/apis/middleware/models/index.mjs.map +1 -1
- package/es/apis/middleware/models/mappers.d.ts +8 -1
- package/es/apis/middleware/models/mappers.mjs +376 -3
- package/es/apis/middleware/models/mappers.mjs.map +1 -1
- package/es/apis/middleware/models/parameters.d.ts +6 -3
- package/es/apis/middleware/models/parameters.mjs +38 -11
- package/es/apis/middleware/models/parameters.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +66 -2
- package/es/apis/node/models/index.mjs.map +1 -1
- package/es/apis/node/models/mappers.d.ts +5 -1
- package/es/apis/node/models/mappers.mjs +229 -7
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/parameters.d.ts +2 -2
- package/es/apis/node/models/parameters.mjs +2 -2
- package/es/apis/node/models/parameters.mjs.map +1 -1
- package/es/apis/node/node.d.ts +24 -3
- package/es/apis/node/node.mjs +135 -3
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +14 -44
- package/es/chain.mjs +125 -219
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +3 -47
- package/es/channel/Base.mjs +21 -54
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.d.ts +16 -25
- package/es/channel/Contract.mjs +39 -63
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +0 -8
- package/es/channel/Spend.mjs +17 -29
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +1 -1
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +104 -5
- package/es/channel/internal.mjs +26 -34
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +9 -1
- package/es/contract/Contract.mjs +67 -73
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +14 -8
- package/es/contract/compiler/Base.mjs.map +1 -1
- package/es/contract/compiler/Cli.d.ts +5 -9
- package/es/contract/compiler/Cli.mjs +45 -23
- package/es/contract/compiler/Cli.mjs.map +1 -1
- package/es/contract/compiler/Cli8.d.ts +13 -0
- package/es/contract/compiler/Cli8.mjs +22 -0
- package/es/contract/compiler/Cli8.mjs.map +1 -0
- package/es/contract/compiler/Http.d.ts +3 -9
- package/es/contract/compiler/Http.mjs +28 -16
- package/es/contract/compiler/Http.mjs.map +1 -1
- package/es/contract/compiler/HttpNode.d.ts +2 -5
- package/es/contract/compiler/HttpNode.mjs.map +1 -1
- package/es/contract/delegation-signature.d.ts +2 -1
- package/es/contract/delegation-signature.mjs +18 -14
- package/es/contract/delegation-signature.mjs.map +1 -1
- package/es/contract/ga.d.ts +1 -2
- package/es/contract/ga.mjs +23 -25
- package/es/contract/ga.mjs.map +1 -1
- package/es/deprecated.d.ts +38 -0
- package/es/deprecated.mjs +45 -0
- package/es/deprecated.mjs.map +1 -1
- package/es/index-browser.d.ts +10 -5
- package/es/index-browser.mjs +9 -5
- package/es/index-browser.mjs.map +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.mjs +1 -0
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +6 -37
- package/es/oracle.mjs +32 -66
- package/es/oracle.mjs.map +1 -1
- package/es/send-transaction.d.ts +53 -0
- package/es/send-transaction.mjs +109 -0
- package/es/send-transaction.mjs.map +1 -0
- package/es/spend.d.ts +4 -3
- package/es/spend.mjs +6 -1
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/common.d.ts +29 -0
- package/es/tx/builder/common.mjs +42 -0
- package/es/tx/builder/common.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +4 -4
- package/es/tx/builder/constants.mjs +6 -15
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/delegation/index.d.ts +20 -0
- package/es/tx/builder/delegation/index.mjs +24 -0
- package/es/tx/builder/delegation/index.mjs.map +1 -0
- package/es/tx/builder/delegation/schema.d.ts +130 -0
- package/es/tx/builder/delegation/schema.generated.d.ts +141 -0
- package/es/tx/builder/delegation/schema.generated.mjs +2 -0
- package/es/tx/builder/delegation/schema.generated.mjs.map +1 -0
- package/es/tx/builder/delegation/schema.mjs +54 -0
- package/es/tx/builder/delegation/schema.mjs.map +1 -0
- package/es/tx/builder/field-types/abi-version.mjs +8 -11
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
- package/es/tx/builder/field-types/address.mjs +1 -4
- package/es/tx/builder/field-types/address.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +2 -2
- package/es/tx/builder/field-types/coin-amount.mjs +6 -6
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.mjs +3 -4
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
- package/es/tx/builder/field-types/entry.mjs +7 -13
- package/es/tx/builder/field-types/entry.mjs.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +19 -11
- package/es/tx/builder/field-types/fee.mjs +56 -38
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.mjs +13 -15
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +10 -2
- package/es/tx/builder/field-types/gas-price.mjs +52 -3
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +31 -29
- package/es/tx/builder/field-types/index.mjs +31 -29
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/map.mjs +20 -31
- package/es/tx/builder/field-types/map.mjs.map +1 -1
- package/es/tx/builder/field-types/mptree.mjs +14 -29
- package/es/tx/builder/field-types/mptree.mjs.map +1 -1
- package/es/tx/builder/field-types/name-fee.d.ts +1 -1
- package/es/tx/builder/field-types/name-fee.mjs +1 -1
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/nonce.d.ts +1 -0
- package/es/tx/builder/field-types/nonce.mjs +2 -0
- package/es/tx/builder/field-types/nonce.mjs.map +1 -1
- package/es/tx/builder/field-types/pointers.mjs +4 -7
- package/es/tx/builder/field-types/pointers.mjs.map +1 -1
- package/es/tx/builder/field-types/pointers2.d.ts +23 -0
- package/es/tx/builder/field-types/pointers2.mjs +65 -0
- package/es/tx/builder/field-types/pointers2.mjs.map +1 -0
- package/es/tx/builder/field-types/query-fee.d.ts +19 -0
- package/es/tx/builder/field-types/query-fee.mjs +20 -0
- package/es/tx/builder/field-types/query-fee.mjs.map +1 -0
- package/es/tx/builder/field-types/ttl.d.ts +9 -1
- package/es/tx/builder/field-types/ttl.mjs +19 -8
- package/es/tx/builder/field-types/ttl.mjs.map +1 -1
- package/es/tx/builder/field-types/with-default.d.ts +7 -0
- package/es/tx/builder/field-types/with-default.mjs +9 -0
- package/es/tx/builder/field-types/with-default.mjs.map +1 -0
- package/es/tx/builder/field-types/with-formatting.d.ts +7 -0
- package/es/tx/builder/field-types/with-formatting.mjs +9 -0
- package/es/tx/builder/field-types/with-formatting.mjs.map +1 -0
- package/es/tx/builder/field-types/wrapped.mjs +6 -8
- package/es/tx/builder/field-types/wrapped.mjs.map +1 -1
- package/es/tx/builder/helpers.d.ts +2 -2
- package/es/tx/builder/helpers.mjs +12 -21
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +17 -10
- package/es/tx/builder/index.mjs +39 -65
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +478 -257
- package/es/tx/builder/schema.generated.d.ts +39 -3
- package/es/tx/builder/schema.generated.mjs.map +1 -1
- package/es/tx/builder/schema.mjs +48 -36
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/execution-cost.d.ts +6 -5
- package/es/tx/execution-cost.mjs +16 -17
- package/es/tx/execution-cost.mjs.map +1 -1
- package/es/tx/transaction-signer.mjs +1 -4
- package/es/tx/transaction-signer.mjs.map +1 -1
- package/es/tx/validator.mjs +61 -42
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/amount-formatter.mjs +15 -22
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +2 -3
- package/es/utils/autorest.mjs +40 -24
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bytes.mjs +1 -2
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +8 -4
- package/es/utils/crypto.mjs +17 -13
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/errors.d.ts +6 -0
- package/es/utils/errors.mjs +12 -6
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +2 -0
- package/es/utils/hd-wallet.mjs +6 -5
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs +2 -10
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/jwt.d.ts +53 -0
- package/es/utils/jwt.mjs +120 -0
- package/es/utils/jwt.mjs.map +1 -0
- package/es/utils/keystore.d.ts +6 -2
- package/es/utils/keystore.mjs +8 -16
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/typed-data.mjs +1 -0
- package/es/utils/typed-data.mjs.map +1 -1
- package/es/utils/wrap-proxy.d.ts +2 -0
- package/es/utils/wrap-proxy.mjs +15 -0
- package/es/utils/wrap-proxy.mjs.map +1 -0
- package/package.json +57 -51
- package/src/AeSdk.ts +3 -0
- package/src/AeSdkAepp.ts +0 -1
- package/src/AeSdkBase.ts +97 -10
- package/src/AeSdkMethods.ts +37 -33
- package/src/AeSdkWallet.ts +22 -3
- package/src/Middleware.ts +16 -8
- package/src/MiddlewareSubscriber.ts +1 -1
- package/src/Node.ts +37 -18
- package/src/account/Base.ts +62 -3
- package/src/account/Generalized.ts +10 -0
- package/src/account/Ledger.ts +10 -0
- package/src/account/Memory.ts +83 -9
- package/src/account/Rpc.ts +69 -6
- package/src/aens.ts +35 -56
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +3 -0
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +2 -2
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -2
- package/src/aepp-wallet-communication/rpc/types.ts +13 -0
- package/src/aepp-wallet-communication/schema.ts +2 -0
- package/src/apis/compiler/compiler.ts +93 -93
- package/src/apis/compiler/models/index.ts +1 -0
- package/src/apis/compiler/models/mappers.ts +178 -165
- package/src/apis/compiler/models/parameters.ts +18 -18
- package/src/apis/middleware/middleware.ts +462 -341
- package/src/apis/middleware/models/index.ts +258 -56
- package/src/apis/middleware/models/mappers.ts +2357 -1919
- package/src/apis/middleware/models/parameters.ts +172 -142
- package/src/apis/node/models/index.ts +79 -2
- package/src/apis/node/models/mappers.ts +1529 -1302
- package/src/apis/node/models/parameters.ts +51 -51
- package/src/apis/node/node.ts +420 -275
- package/src/chain.ts +42 -128
- package/src/channel/Base.ts +14 -47
- package/src/channel/Contract.ts +18 -26
- package/src/channel/Spend.ts +0 -8
- package/src/channel/internal.ts +115 -13
- package/src/contract/Contract.ts +26 -8
- package/src/contract/compiler/Base.ts +15 -8
- package/src/contract/compiler/Cli.ts +37 -21
- package/src/contract/compiler/Cli8.ts +17 -0
- package/src/contract/compiler/Http.ts +24 -14
- package/src/contract/compiler/HttpNode.ts +2 -2
- package/src/contract/delegation-signature.ts +11 -5
- package/src/contract/ga.ts +4 -3
- package/src/deprecated.ts +36 -0
- package/src/index-browser.ts +14 -7
- package/src/index.ts +1 -0
- package/src/oracle.ts +11 -54
- package/src/send-transaction.ts +136 -0
- package/src/spend.ts +25 -11
- package/src/tx/builder/common.ts +74 -0
- package/src/tx/builder/constants.ts +6 -9
- package/src/tx/builder/delegation/index.ts +28 -0
- package/src/tx/builder/delegation/schema.generated.ts +143 -0
- package/src/tx/builder/delegation/schema.ts +61 -0
- package/src/tx/builder/field-types/coin-amount.ts +3 -2
- package/src/tx/builder/field-types/entry.ts +1 -4
- package/src/tx/builder/field-types/fee.ts +71 -43
- package/src/tx/builder/field-types/gas-limit.ts +4 -4
- package/src/tx/builder/field-types/gas-price.ts +58 -2
- package/src/tx/builder/field-types/index.ts +31 -59
- package/src/tx/builder/field-types/name-fee.ts +1 -1
- package/src/tx/builder/field-types/nonce.ts +7 -1
- package/src/tx/builder/field-types/pointers2.ts +62 -0
- package/src/tx/builder/field-types/query-fee.ts +25 -0
- package/src/tx/builder/field-types/ttl.ts +13 -3
- package/src/tx/builder/field-types/with-default.ts +18 -0
- package/src/tx/builder/field-types/with-formatting.ts +18 -0
- package/src/tx/builder/helpers.ts +2 -2
- package/src/tx/builder/index.ts +42 -59
- package/src/tx/builder/schema.generated.ts +39 -3
- package/src/tx/builder/schema.ts +55 -29
- package/src/tx/execution-cost.ts +6 -5
- package/src/tx/validator.ts +31 -5
- package/src/utils/autorest.ts +36 -27
- package/src/utils/crypto.ts +23 -13
- package/src/utils/errors.ts +10 -0
- package/src/utils/hd-wallet.ts +2 -0
- package/src/utils/jwt.ts +126 -0
- package/src/utils/keystore.ts +6 -2
- package/src/utils/wrap-proxy.ts +24 -0
- package/types-legacy/ts4.2/AeSdk.d.ts +3 -0
- package/types-legacy/ts4.2/AeSdkAepp.d.ts +0 -1
- package/types-legacy/ts4.2/AeSdkBase.d.ts +61 -6
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +19 -7
- package/types-legacy/ts4.2/Node.d.ts +14 -1
- package/types-legacy/ts4.2/account/Base.d.ts +39 -3
- package/types-legacy/ts4.2/account/Generalized.d.ts +2 -0
- package/types-legacy/ts4.2/account/Ledger.d.ts +2 -0
- package/types-legacy/ts4.2/account/Memory.d.ts +15 -4
- package/types-legacy/ts4.2/account/Rpc.d.ts +16 -5
- package/types-legacy/ts4.2/aens.d.ts +17 -44
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +14 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +2 -0
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +1 -0
- package/types-legacy/ts4.2/apis/middleware/middleware.d.ts +23 -5
- package/types-legacy/ts4.2/apis/middleware/models/index.d.ts +164 -15
- package/types-legacy/ts4.2/apis/middleware/models/mappers.d.ts +8 -1
- package/types-legacy/ts4.2/apis/middleware/models/parameters.d.ts +6 -3
- package/types-legacy/ts4.2/apis/node/models/index.d.ts +66 -2
- package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +5 -1
- package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.2/apis/node/node.d.ts +24 -3
- package/types-legacy/ts4.2/chain.d.ts +14 -44
- package/types-legacy/ts4.2/channel/Base.d.ts +3 -47
- package/types-legacy/ts4.2/channel/Contract.d.ts +16 -25
- package/types-legacy/ts4.2/channel/Spend.d.ts +0 -8
- package/types-legacy/ts4.2/channel/internal.d.ts +104 -5
- package/types-legacy/ts4.2/contract/Contract.d.ts +9 -1
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +14 -8
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +5 -9
- package/types-legacy/ts4.2/contract/compiler/Cli8.d.ts +13 -0
- package/types-legacy/ts4.2/contract/compiler/Http.d.ts +3 -9
- package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +2 -5
- package/types-legacy/ts4.2/contract/delegation-signature.d.ts +2 -1
- package/types-legacy/ts4.2/contract/ga.d.ts +1 -2
- package/types-legacy/ts4.2/deprecated.d.ts +38 -0
- package/types-legacy/ts4.2/index-browser.d.ts +10 -5
- package/types-legacy/ts4.2/index.d.ts +1 -0
- package/types-legacy/ts4.2/oracle.d.ts +6 -37
- package/types-legacy/ts4.2/send-transaction.d.ts +53 -0
- package/types-legacy/ts4.2/spend.d.ts +4 -3
- package/types-legacy/ts4.2/tx/builder/common.d.ts +32 -0
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -4
- package/types-legacy/ts4.2/tx/builder/delegation/index.d.ts +20 -0
- package/types-legacy/ts4.2/tx/builder/delegation/schema.d.ts +136 -0
- package/types-legacy/ts4.2/tx/builder/delegation/schema.generated.d.ts +141 -0
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +2 -2
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +19 -11
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +10 -2
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +31 -29
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +1 -0
- package/types-legacy/ts4.2/tx/builder/field-types/pointers2.d.ts +26 -0
- package/types-legacy/ts4.2/tx/builder/field-types/query-fee.d.ts +19 -0
- package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +9 -1
- package/types-legacy/ts4.2/tx/builder/field-types/with-default.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/with-formatting.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/helpers.d.ts +2 -2
- package/types-legacy/ts4.2/tx/builder/index.d.ts +17 -10
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +482 -257
- package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +39 -3
- package/types-legacy/ts4.2/tx/execution-cost.d.ts +6 -5
- package/types-legacy/ts4.2/utils/autorest.d.ts +2 -3
- package/types-legacy/ts4.2/utils/crypto.d.ts +8 -4
- package/types-legacy/ts4.2/utils/errors.d.ts +6 -0
- package/types-legacy/ts4.2/utils/hd-wallet.d.ts +2 -0
- package/types-legacy/ts4.2/utils/jwt.d.ts +53 -0
- package/types-legacy/ts4.2/utils/keystore.d.ts +6 -2
- package/types-legacy/ts4.2/utils/wrap-proxy.d.ts +2 -0
- package/types-legacy/ts4.5/AeSdk.d.ts +3 -0
- package/types-legacy/ts4.5/AeSdkAepp.d.ts +0 -1
- package/types-legacy/ts4.5/AeSdkBase.d.ts +61 -6
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +19 -7
- package/types-legacy/ts4.5/Node.d.ts +14 -1
- package/types-legacy/ts4.5/account/Base.d.ts +39 -3
- package/types-legacy/ts4.5/account/Generalized.d.ts +2 -0
- package/types-legacy/ts4.5/account/Ledger.d.ts +2 -0
- package/types-legacy/ts4.5/account/Memory.d.ts +15 -4
- package/types-legacy/ts4.5/account/Rpc.d.ts +16 -5
- package/types-legacy/ts4.5/aens.d.ts +17 -44
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +14 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +2 -0
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +1 -0
- package/types-legacy/ts4.5/apis/middleware/middleware.d.ts +23 -5
- package/types-legacy/ts4.5/apis/middleware/models/index.d.ts +164 -15
- package/types-legacy/ts4.5/apis/middleware/models/mappers.d.ts +8 -1
- package/types-legacy/ts4.5/apis/middleware/models/parameters.d.ts +6 -3
- package/types-legacy/ts4.5/apis/node/models/index.d.ts +66 -2
- package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +5 -1
- package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.5/apis/node/node.d.ts +24 -3
- package/types-legacy/ts4.5/chain.d.ts +14 -44
- package/types-legacy/ts4.5/channel/Base.d.ts +3 -47
- package/types-legacy/ts4.5/channel/Contract.d.ts +16 -25
- package/types-legacy/ts4.5/channel/Spend.d.ts +0 -8
- package/types-legacy/ts4.5/channel/internal.d.ts +104 -5
- package/types-legacy/ts4.5/contract/Contract.d.ts +9 -1
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +14 -8
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +5 -9
- package/types-legacy/ts4.5/contract/compiler/Cli8.d.ts +13 -0
- package/types-legacy/ts4.5/contract/compiler/Http.d.ts +3 -9
- package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +2 -5
- package/types-legacy/ts4.5/contract/delegation-signature.d.ts +2 -1
- package/types-legacy/ts4.5/contract/ga.d.ts +1 -2
- package/types-legacy/ts4.5/deprecated.d.ts +38 -0
- package/types-legacy/ts4.5/index-browser.d.ts +10 -5
- package/types-legacy/ts4.5/index.d.ts +1 -0
- package/types-legacy/ts4.5/oracle.d.ts +6 -37
- package/types-legacy/ts4.5/send-transaction.d.ts +53 -0
- package/types-legacy/ts4.5/spend.d.ts +4 -3
- package/types-legacy/ts4.5/tx/builder/common.d.ts +32 -0
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -4
- package/types-legacy/ts4.5/tx/builder/delegation/index.d.ts +20 -0
- package/types-legacy/ts4.5/tx/builder/delegation/schema.d.ts +136 -0
- package/types-legacy/ts4.5/tx/builder/delegation/schema.generated.d.ts +141 -0
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +2 -2
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +19 -11
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +10 -2
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +31 -29
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +1 -0
- package/types-legacy/ts4.5/tx/builder/field-types/pointers2.d.ts +26 -0
- package/types-legacy/ts4.5/tx/builder/field-types/query-fee.d.ts +19 -0
- package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +9 -1
- package/types-legacy/ts4.5/tx/builder/field-types/with-default.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/with-formatting.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/helpers.d.ts +2 -2
- package/types-legacy/ts4.5/tx/builder/index.d.ts +17 -10
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +482 -257
- package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +39 -3
- package/types-legacy/ts4.5/tx/execution-cost.d.ts +6 -5
- package/types-legacy/ts4.5/utils/autorest.d.ts +2 -3
- package/types-legacy/ts4.5/utils/crypto.d.ts +8 -4
- package/types-legacy/ts4.5/utils/errors.d.ts +6 -0
- package/types-legacy/ts4.5/utils/hd-wallet.d.ts +2 -0
- package/types-legacy/ts4.5/utils/jwt.d.ts +53 -0
- package/types-legacy/ts4.5/utils/keystore.d.ts +6 -2
- package/types-legacy/ts4.5/utils/wrap-proxy.d.ts +2 -0
- package/es/tx/builder/field-types/deposit.d.ts +0 -15
- package/es/tx/builder/field-types/deposit.mjs +0 -18
- package/es/tx/builder/field-types/deposit.mjs.map +0 -1
- package/src/tx/builder/field-types/deposit.ts +0 -23
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +0 -15
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +0 -15
package/es/AeSdkBase.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AeSdkBase.mjs","names":["CompilerError","DuplicateNodeError","NodeNotFoundError","NotImplementedError","TypeError","AeSdkMethods","getValueOrErrorProxy","AeSdkBase","constructor","nodes","options","arguments","length","undefined","_defineProperty","Map","forEach","_ref","i","name","instance","addNode","compilerApi","_options","onCompiler","api","ensureNodeConnected","pool","get","selectedNodeName","node","select","has","set","selectNode","isNodeConnected","getNodeInfo","getNodesInPool","Promise","all","Array","from","entries","map","_ref2","addresses","_resolveAccount","account","onAccount","String","address","sign","data","signTransaction","tx","networkId","getNetworkId","signMessage","message","signTypedData","aci","signDelegationToContract","contractAddress","_options$networkId","signNameDelegationToContract","_options$networkId2","signOracleQueryDelegationToContract","oracleQueryId","_options$networkId3","_getOptions","callOptions","onNode"],"sources":["../src/AeSdkBase.ts"],"sourcesContent":["import Node from './Node';\nimport AccountBase from './account/Base';\nimport {\n CompilerError, DuplicateNodeError, NodeNotFoundError, NotImplementedError, TypeError,\n} from './utils/errors';\nimport { Encoded } from './utils/encoder';\nimport CompilerBase from './contract/compiler/Base';\nimport AeSdkMethods, { OnAccount, getValueOrErrorProxy, AeSdkMethodsOptions } from './AeSdkMethods';\nimport { AensName } from './tx/builder/constants';\n\ntype NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & { name: string };\n\n/**\n * Basic AeSdk class implements:\n * - node selector,\n * - integrated compiler support,\n * - wrappers of account methods mapped to the current account.\n */\nexport default class AeSdkBase extends AeSdkMethods {\n pool: Map<string, Node> = new Map();\n\n selectedNodeName?: string;\n\n /**\n * @param options - Options\n * @param options.nodes - Array of nodes\n */\n constructor(\n { nodes = [], ...options }: AeSdkMethodsOptions & {\n nodes?: Array<{ name: string; instance: Node }>;\n } = {},\n ) {\n super(options);\n\n nodes.forEach(({ name, instance }, i) => this.addNode(name, instance, i === 0));\n }\n\n // TODO: consider dropping this getter, because:\n // compiler is not intended to be used separately any more (functionality limited to sdk needs)\n // and user creates its instance by himself\n get compilerApi(): CompilerBase {\n if (this._options.onCompiler == null) {\n throw new CompilerError('You can\\'t use Compiler API. Compiler is not ready!');\n }\n return this._options.onCompiler;\n }\n\n get api(): Node {\n this.ensureNodeConnected();\n return this.pool.get(this.selectedNodeName) as Node;\n }\n\n /**\n * Add Node\n * @param name - Node name\n * @param node - Node instance\n * @param select - Select this node as current\n * @example\n * ```js\n * // add and select new node with name 'testNode'\n * aeSdkBase.addNode('testNode', new Node({ url }), true)\n * ```\n */\n addNode(name: string, node: Node, select = false): void {\n if (this.pool.has(name)) throw new DuplicateNodeError(name);\n\n this.pool.set(name, node);\n if (select || this.selectedNodeName == null) {\n this.selectNode(name);\n }\n }\n\n /**\n * Select Node\n * @param name - Node name\n * @example\n * nodePool.selectNode('testNode')\n */\n selectNode(name: string): void {\n if (!this.pool.has(name)) throw new NodeNotFoundError(`Node with name ${name} not in pool`);\n this.selectedNodeName = name;\n }\n\n /**\n * Check if you have selected node\n * @example\n * nodePool.isNodeConnected()\n */\n isNodeConnected(): this is AeSdkBase & { selectedNodeName: string } {\n return this.selectedNodeName != null;\n }\n\n protected ensureNodeConnected(): asserts this is AeSdkBase & { selectedNodeName: string } {\n if (!this.isNodeConnected()) {\n throw new NodeNotFoundError('You can\\'t use Node API. Node is not connected or not defined!');\n }\n }\n\n /**\n * Get information about node\n * @example\n * ```js\n * nodePool.getNodeInfo() // { name, version, networkId, protocol, ... }\n * ```\n */\n async getNodeInfo(): Promise<NodeInfo> {\n this.ensureNodeConnected();\n return {\n name: this.selectedNodeName,\n ...await this.api.getNodeInfo(),\n };\n }\n\n /**\n * Get array of available nodes\n * @example\n * nodePool.getNodesInPool()\n */\n async getNodesInPool(): Promise<NodeInfo[]> {\n return Promise.all(\n Array.from(this.pool.entries()).map(async ([name, node]) => ({\n name,\n ...await node.getNodeInfo(),\n })),\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n addresses(): Encoded.AccountAddress[] {\n return [];\n }\n\n /**\n * Resolves an account\n * @param account - ak-address, instance of AccountBase, or keypair\n */\n _resolveAccount(account: OnAccount = this._options.onAccount): AccountBase {\n if (typeof account === 'string') throw new NotImplementedError('Address in AccountResolver');\n if (typeof account === 'object') return account;\n throw new TypeError(\n 'Account should be an address (ak-prefixed string), '\n + `or instance of AccountBase, got ${String(account)} instead`,\n );\n }\n\n get address(): Encoded.AccountAddress {\n return this._resolveAccount().address;\n }\n\n async sign(\n data: string | Uint8Array,\n { onAccount, ...options }: { onAccount?: OnAccount } = {},\n ): Promise<Uint8Array> {\n return this._resolveAccount(onAccount).sign(data, options);\n }\n\n async signTransaction(\n tx: Encoded.Transaction,\n { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signTransaction']>[1] = {},\n ): Promise<Encoded.Transaction> {\n const networkId = this.selectedNodeName !== null ? await this.api.getNetworkId() : undefined;\n return this._resolveAccount(onAccount).signTransaction(tx, { networkId, ...options });\n }\n\n async signMessage(\n message: string,\n { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signMessage']>[1] = {},\n ): Promise<Uint8Array> {\n return this._resolveAccount(onAccount).signMessage(message, options);\n }\n\n async signTypedData(\n data: Encoded.ContractBytearray,\n aci: Parameters<AccountBase['signTypedData']>[1],\n { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signTypedData']>[2] = {},\n ): Promise<Encoded.Signature> {\n return this._resolveAccount(onAccount).signTypedData(data, aci, options);\n }\n\n async signDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n { onAccount, ...options }: { onAccount?: OnAccount }\n & Parameters<AccountBase['signDelegationToContract']>[1] = {},\n ): Promise<Encoded.Signature> {\n options.networkId ??= this.selectedNodeName !== null\n ? await this.api.getNetworkId() : undefined;\n return this._resolveAccount(onAccount)\n .signDelegationToContract(contractAddress, options);\n }\n\n async signNameDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n name: AensName,\n { onAccount, ...options }: { onAccount?: OnAccount }\n & Parameters<AccountBase['signNameDelegationToContract']>[2] = {},\n ): Promise<Encoded.Signature> {\n options.networkId ??= this.selectedNodeName !== null\n ? await this.api.getNetworkId() : undefined;\n return this._resolveAccount(onAccount)\n .signNameDelegationToContract(contractAddress, name, options);\n }\n\n async signOracleQueryDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n oracleQueryId: Encoded.OracleQueryId,\n { onAccount, ...options }: { onAccount?: OnAccount }\n & Parameters<AccountBase['signOracleQueryDelegationToContract']>[2] = {},\n ): Promise<Encoded.Signature> {\n options.networkId ??= this.selectedNodeName !== null\n ? await this.api.getNetworkId() : undefined;\n return this._resolveAccount(onAccount)\n .signOracleQueryDelegationToContract(contractAddress, oracleQueryId, options);\n }\n\n override _getOptions(callOptions: AeSdkMethodsOptions = {}): {\n onNode: Node;\n onAccount: AccountBase;\n onCompiler: CompilerBase;\n } {\n return {\n ...this._options,\n onNode: getValueOrErrorProxy(() => this.api),\n onCompiler: getValueOrErrorProxy(() => this.compilerApi),\n ...callOptions,\n onAccount: getValueOrErrorProxy(() => this._resolveAccount(callOptions.onAccount)),\n };\n }\n}\n"],"mappings":";SAGEA,aAAa,EAAEC,kBAAkB,EAAEC,iBAAiB,EAAEC,mBAAmB,EAAEC,SAAS;AAAA,O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JmBC,WAAgC,GAAA3D,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAKxD,OAAO;MACL,GAAG,IAAI,CAACY,QAAQ;MAChBgD,MAAM,EAAEjE,oBAAoB,CAAC,MAAM,IAAI,CAACmB,GAAG,CAAC;MAC5CD,UAAU,EAAElB,oBAAoB,CAAC,MAAM,IAAI,CAACgB,WAAW,CAAC;MACxD,GAAGgD,WAAW;MACdtB,SAAS,EAAE1C,oBAAoB,CAAC,MAAM,IAAI,CAACwC,eAAe,CAACwB,WAAW,CAACtB,SAAS,CAAC;IACnF,CAAC;EACH;AACF"}
|
|
1
|
+
{"version":3,"file":"AeSdkBase.mjs","names":["CompilerError","DuplicateNodeError","NodeNotFoundError","NotImplementedError","TypeError","wrapWithProxy","AeSdkMethods","_wrappedOptions","WeakMap","AeSdkBase","constructor","nodes","options","_defineProperty","Map","_classPrivateFieldInitSpec","writable","value","forEach","name","instance","i","addNode","_classPrivateFieldSet","onNode","api","onCompiler","compilerApi","onAccount","_resolveAccount","_options","ensureNodeConnected","pool","get","selectedNodeName","node","select","has","set","selectNode","isNodeConnected","getNodeInfo","getNodesInPool","Promise","all","Array","from","entries","map","addresses","account","String","address","sign","data","signTransaction","tx","networkId","getNetworkId","undefined","signMessage","message","signTypedData","aci","signDelegationToContract","contractAddress","_options$networkId","_options$consensusPro","consensusProtocolVersion","signNameDelegationToContract","_options$networkId2","_options$consensusPro2","signAllNamesDelegationToContract","_options$networkId3","_options$consensusPro3","signOracleQueryDelegationToContract","oracleQueryId","_options$networkId4","_options$consensusPro4","signDelegation","delegation","_options$networkId5","getContext","mergeWith","_classPrivateFieldGet"],"sources":["../src/AeSdkBase.ts"],"sourcesContent":["import Node from './Node';\nimport AccountBase from './account/Base';\nimport {\n CompilerError, DuplicateNodeError, NodeNotFoundError, NotImplementedError, TypeError,\n} from './utils/errors';\nimport { Encoded } from './utils/encoder';\nimport { wrapWithProxy } from './utils/wrap-proxy';\nimport CompilerBase from './contract/compiler/Base';\nimport AeSdkMethods, { OnAccount, AeSdkMethodsOptions, WrappedOptions } from './AeSdkMethods';\nimport { AensName } from './tx/builder/constants';\n\ntype NodeInfo = Awaited<ReturnType<Node['getNodeInfo']>> & { name: string };\n\n/**\n * Basic AeSdk class implements:\n * - node selector,\n * - integrated compiler support,\n * - wrappers of account methods mapped to the current account.\n */\nexport default class AeSdkBase extends AeSdkMethods {\n pool: Map<string, Node> = new Map();\n\n selectedNodeName?: string;\n\n readonly #wrappedOptions: WrappedOptions;\n\n /**\n * @param options - Options\n * @param options.nodes - Array of nodes\n */\n constructor(\n { nodes = [], ...options }: AeSdkMethodsOptions & {\n nodes?: Array<{ name: string; instance: Node }>;\n } = {},\n ) {\n super(options);\n\n nodes.forEach(({ name, instance }, i) => this.addNode(name, instance, i === 0));\n\n this.#wrappedOptions = {\n onNode: wrapWithProxy(() => this.api),\n onCompiler: wrapWithProxy(() => this.compilerApi),\n onAccount: wrapWithProxy(() => this._resolveAccount()),\n };\n }\n\n // TODO: consider dropping this getter, because:\n // compiler is not intended to be used separately any more (functionality limited to sdk needs)\n // and user creates its instance by himself\n get compilerApi(): CompilerBase {\n if (this._options.onCompiler == null) {\n throw new CompilerError('You can\\'t use Compiler API. Compiler is not ready!');\n }\n return this._options.onCompiler;\n }\n\n get api(): Node {\n this.ensureNodeConnected();\n return this.pool.get(this.selectedNodeName) as Node;\n }\n\n /**\n * Add Node\n * @param name - Node name\n * @param node - Node instance\n * @param select - Select this node as current\n * @example\n * ```js\n * // add and select new node with name 'testNode'\n * aeSdkBase.addNode('testNode', new Node({ url }), true)\n * ```\n */\n addNode(name: string, node: Node, select = false): void {\n if (this.pool.has(name)) throw new DuplicateNodeError(name);\n\n this.pool.set(name, node);\n if (select || this.selectedNodeName == null) {\n this.selectNode(name);\n }\n }\n\n /**\n * Select Node\n * @param name - Node name\n * @example\n * nodePool.selectNode('testNode')\n */\n selectNode(name: string): void {\n if (!this.pool.has(name)) throw new NodeNotFoundError(`Node with name ${name} not in pool`);\n this.selectedNodeName = name;\n }\n\n /**\n * Check if you have selected node\n * @example\n * nodePool.isNodeConnected()\n */\n isNodeConnected(): this is AeSdkBase & { selectedNodeName: string } {\n return this.selectedNodeName != null;\n }\n\n protected ensureNodeConnected(): asserts this is AeSdkBase & { selectedNodeName: string } {\n if (!this.isNodeConnected()) {\n throw new NodeNotFoundError('You can\\'t use Node API. Node is not connected or not defined!');\n }\n }\n\n /**\n * Get information about node\n * @example\n * ```js\n * nodePool.getNodeInfo() // { name, version, networkId, protocol, ... }\n * ```\n */\n async getNodeInfo(): Promise<NodeInfo> {\n this.ensureNodeConnected();\n return {\n name: this.selectedNodeName,\n ...await this.api.getNodeInfo(),\n };\n }\n\n /**\n * Get array of available nodes\n * @example\n * nodePool.getNodesInPool()\n */\n async getNodesInPool(): Promise<NodeInfo[]> {\n return Promise.all(\n Array.from(this.pool.entries()).map(async ([name, node]) => ({\n name,\n ...await node.getNodeInfo(),\n })),\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n addresses(): Encoded.AccountAddress[] {\n return [];\n }\n\n /**\n * Resolves an account\n * @param account - ak-address, instance of AccountBase, or keypair\n */\n _resolveAccount(account: OnAccount = this._options.onAccount): AccountBase {\n if (typeof account === 'string') throw new NotImplementedError('Address in AccountResolver');\n if (typeof account === 'object') return account;\n throw new TypeError(\n 'Account should be an address (ak-prefixed string), '\n + `or instance of AccountBase, got ${String(account)} instead`,\n );\n }\n\n get address(): Encoded.AccountAddress {\n return this._resolveAccount().address;\n }\n\n /**\n * Sign data blob\n * @param data - Data to sign\n * @param options - Options\n */\n async sign(\n data: string | Uint8Array,\n { onAccount, ...options }: { onAccount?: OnAccount } = {},\n ): Promise<Uint8Array> {\n return this._resolveAccount(onAccount).sign(data, options);\n }\n\n /**\n * Sign encoded transaction\n * @param tx - Transaction to sign\n * @param options - Options\n */\n async signTransaction(\n tx: Encoded.Transaction,\n { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signTransaction']>[1] = {},\n ): Promise<Encoded.Transaction> {\n const networkId = this.selectedNodeName !== null ? await this.api.getNetworkId() : undefined;\n return this._resolveAccount(onAccount).signTransaction(tx, { networkId, ...options });\n }\n\n /**\n * Sign message\n * @param message - Message to sign\n * @param options - Options\n */\n async signMessage(\n message: string,\n { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signMessage']>[1] = {},\n ): Promise<Uint8Array> {\n return this._resolveAccount(onAccount).signMessage(message, options);\n }\n\n /**\n * Sign typed data\n * @param data - Encoded data to sign\n * @param aci - Type of data to sign\n * @param options - Options\n */\n async signTypedData(\n data: Encoded.ContractBytearray,\n aci: Parameters<AccountBase['signTypedData']>[1],\n { onAccount, ...options }: { onAccount?: OnAccount } & Parameters<AccountBase['signTypedData']>[2] = {},\n ): Promise<Encoded.Signature> {\n return this._resolveAccount(onAccount).signTypedData(data, aci, options);\n }\n\n /**\n * @deprecated use AeSdkBase:signDelegation in Ceres\n * @param contractAddress - Contract address\n * @param options - Options\n */\n async signDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n { onAccount, ...options }: { onAccount?: OnAccount }\n & Parameters<AccountBase['signDelegationToContract']>[1] = {},\n ): Promise<Encoded.Signature> {\n options.networkId ??= this.selectedNodeName !== null\n ? await this.api.getNetworkId() : undefined;\n options.consensusProtocolVersion ??= this.selectedNodeName !== null\n ? (await this.api.getNodeInfo()).consensusProtocolVersion : undefined;\n return this._resolveAccount(onAccount)\n .signDelegationToContract(contractAddress, options);\n }\n\n /**\n * @deprecated use AeSdkBase:signDelegation in Ceres\n * @param contractAddress - Contract address\n * @param name - AENS name\n * @param options - Options\n */\n async signNameDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n name: AensName,\n { onAccount, ...options }: { onAccount?: OnAccount }\n & Parameters<AccountBase['signNameDelegationToContract']>[2] = {},\n ): Promise<Encoded.Signature> {\n options.networkId ??= this.selectedNodeName !== null\n ? await this.api.getNetworkId() : undefined;\n options.consensusProtocolVersion ??= this.selectedNodeName !== null\n ? (await this.api.getNodeInfo()).consensusProtocolVersion : undefined;\n return this._resolveAccount(onAccount)\n .signNameDelegationToContract(contractAddress, name, options);\n }\n\n /**\n * @deprecated use AeSdkBase:signDelegation in Ceres\n * @param contractAddress - Contract address\n * @param options - Options\n */\n async signAllNamesDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n { onAccount, ...options }: { onAccount?: OnAccount }\n & Parameters<AccountBase['signAllNamesDelegationToContract']>[1] = {},\n ): Promise<Encoded.Signature> {\n options.networkId ??= this.selectedNodeName !== null\n ? await this.api.getNetworkId() : undefined;\n options.consensusProtocolVersion ??= this.selectedNodeName !== null\n ? (await this.api.getNodeInfo()).consensusProtocolVersion : undefined;\n return this._resolveAccount(onAccount)\n .signAllNamesDelegationToContract(contractAddress, options);\n }\n\n /**\n * @deprecated use AeSdkBase:signDelegation in Ceres\n * @param contractAddress - Contract address\n * @param oracleQueryId - Oracle query id\n * @param options - Options\n */\n async signOracleQueryDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n oracleQueryId: Encoded.OracleQueryId,\n { onAccount, ...options }: { onAccount?: OnAccount }\n & Parameters<AccountBase['signOracleQueryDelegationToContract']>[2] = {},\n ): Promise<Encoded.Signature> {\n options.networkId ??= this.selectedNodeName !== null\n ? await this.api.getNetworkId() : undefined;\n options.consensusProtocolVersion ??= this.selectedNodeName !== null\n ? (await this.api.getNodeInfo()).consensusProtocolVersion : undefined;\n return this._resolveAccount(onAccount)\n .signOracleQueryDelegationToContract(contractAddress, oracleQueryId, options);\n }\n\n /**\n * Sign delegation, works only in Ceres\n * @param delegation - Delegation to sign\n * @param options - Options\n */\n async signDelegation(\n delegation: Encoded.Bytearray,\n { onAccount, ...options }: { onAccount?: OnAccount }\n & Parameters<AccountBase['signDelegation']>[1] = {},\n ): Promise<Encoded.Signature> {\n options.networkId ??= this.selectedNodeName !== null\n ? await this.api.getNetworkId() : undefined;\n return this._resolveAccount(onAccount).signDelegation(delegation, options);\n }\n\n /**\n * The same as AeSdkMethods:getContext, but it would resolve ak_-prefixed address in\n * `mergeWith.onAccount` to AccountBase.\n */\n override getContext(mergeWith: AeSdkMethodsOptions = {}): AeSdkMethodsOptions & WrappedOptions {\n return {\n ...this._options,\n ...this.#wrappedOptions,\n ...mergeWith,\n ...mergeWith.onAccount != null && {\n onAccount: this._resolveAccount(mergeWith.onAccount),\n },\n };\n }\n}\n"],"mappings":";;;;;SAGEA,aAAa,EAAEC,kBAAkB,EAAEC,iBAAiB,EAAEC,mBAAmB,EAAEC,SAAS,IAATA,UAAS;AAAA,SAG7EC,aAAa;AAAA,OAEfC,YAAY;AAAA,IAAAC,eAAA,oBAAAC,OAAA;AAKnB;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,SAAS,SAASH,YAAY,CAAC;EAOlD;AACF;AACA;AACA;EACEI,WAAWA,CACT;IAAEC,KAAK,GAAG,EAAE;IAAE,GAAGC;EAEjB,CAAC,GAAG,CAAC,CAAC,EACN;IACA,KAAK,CAACA,OAAO,CAAC;IAACC,eAAA,eAfS,IAAIC,GAAG,CAAC,CAAC;IAAAC,0BAAA,OAAAR,eAAA;MAAAS,QAAA;MAAAC,KAAA;IAAA;IAiBjCN,KAAK,CAACO,OAAO,CAAC,CAAC;MAAEC,IAAI;MAAEC;IAAS,CAAC,EAAEC,CAAC,KAAK,IAAI,CAACC,OAAO,CAACH,IAAI,EAAEC,QAAQ,EAAEC,CAAC,KAAK,CAAC,CAAC,CAAC;IAE/EE,qBAAA,KAAI,EAAAhB,eAAA,EAAmB;MACrBiB,MAAM,EAAEnB,aAAa,CAAC,MAAM,IAAI,CAACoB,GAAG,CAAC;MACrCC,UAAU,EAAErB,aAAa,CAAC,MAAM,IAAI,CAACsB,WAAW,CAAC;MACjDC,SAAS,EAAEvB,aAAa,CAAC,MAAM,IAAI,CAACwB,eAAe,CAAC,CAAC;IACvD,CAAC;EACH;;EAEA;EACA;EACA;EACA,IAAIF,W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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;
|
|
@@ -64,6 +64,11 @@ type GetMethodsOptions<Methods extends {
|
|
|
64
64
|
type MethodsOptions = GetMethodsOptions<typeof methods>;
|
|
65
65
|
export interface AeSdkMethodsOptions extends Partial<UnionToIntersection<MethodsOptions[keyof MethodsOptions]>> {
|
|
66
66
|
}
|
|
67
|
+
export interface WrappedOptions {
|
|
68
|
+
onAccount: AccountBase;
|
|
69
|
+
onCompiler: CompilerBase;
|
|
70
|
+
onNode: Node;
|
|
71
|
+
}
|
|
67
72
|
/**
|
|
68
73
|
* AeSdkMethods is the composition of:
|
|
69
74
|
* - chain methods
|
|
@@ -78,16 +83,19 @@ export interface AeSdkMethodsOptions extends Partial<UnionToIntersection<Methods
|
|
|
78
83
|
* their context (current account, network, and compiler to use).
|
|
79
84
|
*/
|
|
80
85
|
declare class AeSdkMethods {
|
|
86
|
+
#private;
|
|
81
87
|
_options: AeSdkMethodsOptions;
|
|
82
88
|
/**
|
|
83
89
|
* @param options - Options
|
|
84
90
|
*/
|
|
85
91
|
constructor(options?: AeSdkMethodsOptions);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Returns sdk instance options with references to current account, node, compiler.
|
|
94
|
+
* Used to create an instance (Contract, Oracle) bound to AeSdk state.
|
|
95
|
+
* @param mergeWith - Merge context with these extra options
|
|
96
|
+
* @returns Context object
|
|
97
|
+
*/
|
|
98
|
+
getContext(mergeWith?: AeSdkMethodsOptions): AeSdkMethodsOptions & WrappedOptions;
|
|
91
99
|
buildTx(options: TxParamsAsync): Promise<Encoded.Transaction>;
|
|
92
100
|
initializeContract<Methods extends ContractMethodsBase>(options?: Omit<Parameters<typeof Contract.initialize>[0], 'onNode'> & {
|
|
93
101
|
onNode?: Node;
|
|
@@ -100,6 +108,10 @@ type OptionalIfNotRequired<T extends [any]> = RequiredKeys<T[0]> extends never ?
|
|
|
100
108
|
type ReplaceOnAccount<Options> = Options extends {
|
|
101
109
|
onAccount: any;
|
|
102
110
|
} ? Omit<Options, 'onAccount'> & {
|
|
111
|
+
/**
|
|
112
|
+
* Make operation on specific account by providing address (to use account from sdk) or instance
|
|
113
|
+
* of AccountBase (like MemoryAccount)
|
|
114
|
+
*/
|
|
103
115
|
onAccount: OnAccount;
|
|
104
116
|
} : Options;
|
|
105
117
|
type MakeOptional<Options> = OptionalIfNotRequired<[
|
package/es/AeSdkMethods.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
|
+
import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
|
|
3
|
+
import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
|
|
4
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
5
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
2
6
|
import * as chainMethods from "./chain.mjs";
|
|
7
|
+
import { sendTransaction } from "./send-transaction.mjs";
|
|
3
8
|
import * as aensMethods from "./aens.mjs";
|
|
4
9
|
import * as spendMethods from "./spend.mjs";
|
|
5
10
|
import * as oracleMethods from "./oracle.mjs";
|
|
@@ -8,29 +13,17 @@ import createDelegationSignature from "./contract/delegation-signature.mjs";
|
|
|
8
13
|
import * as contractGaMethods from "./contract/ga.mjs";
|
|
9
14
|
import { buildTxAsync } from "./tx/builder/index.mjs";
|
|
10
15
|
import { mapObject } from "./utils/other.mjs";
|
|
11
|
-
|
|
12
|
-
return new Proxy({}, Object.fromEntries(['apply', 'construct', 'defineProperty', 'deleteProperty', 'getOwnPropertyDescriptor', 'getPrototypeOf', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf', 'get', 'has'].map(name => [name, function (t) {
|
|
13
|
-
const target = valueCb(); // to get a native exception in case it missed
|
|
14
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
15
|
-
args[_key - 1] = arguments[_key];
|
|
16
|
-
}
|
|
17
|
-
const res = Reflect[name](target, ...args);
|
|
18
|
-
return typeof res === 'function' && name === 'get' ? res.bind(target) // otherwise it fails with attempted to get private field on non-instance
|
|
19
|
-
: res;
|
|
20
|
-
}])));
|
|
21
|
-
}
|
|
22
|
-
const {
|
|
23
|
-
InvalidTxError: _2,
|
|
24
|
-
...chainMethodsOther
|
|
25
|
-
} = chainMethods;
|
|
16
|
+
import { wrapWithProxy } from "./utils/wrap-proxy.mjs";
|
|
26
17
|
const methods = {
|
|
27
|
-
...
|
|
18
|
+
...chainMethods,
|
|
19
|
+
sendTransaction,
|
|
28
20
|
...aensMethods,
|
|
29
21
|
...spendMethods,
|
|
30
22
|
...oracleMethods,
|
|
31
23
|
createDelegationSignature,
|
|
32
24
|
...contractGaMethods
|
|
33
25
|
};
|
|
26
|
+
var _wrappedOptions = /*#__PURE__*/new WeakMap();
|
|
34
27
|
/**
|
|
35
28
|
* AeSdkMethods is the composition of:
|
|
36
29
|
* - chain methods
|
|
@@ -48,43 +41,51 @@ class AeSdkMethods {
|
|
|
48
41
|
/**
|
|
49
42
|
* @param options - Options
|
|
50
43
|
*/
|
|
51
|
-
constructor() {
|
|
52
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
44
|
+
constructor(options = {}) {
|
|
53
45
|
_defineProperty(this, "_options", {});
|
|
46
|
+
_classPrivateFieldInitSpec(this, _wrappedOptions, {
|
|
47
|
+
writable: true,
|
|
48
|
+
value: void 0
|
|
49
|
+
});
|
|
54
50
|
Object.assign(this._options, options);
|
|
51
|
+
_classPrivateFieldSet(this, _wrappedOptions, {
|
|
52
|
+
onAccount: wrapWithProxy(() => this._options.onAccount),
|
|
53
|
+
onNode: wrapWithProxy(() => this._options.onNode),
|
|
54
|
+
onCompiler: wrapWithProxy(() => this._options.onCompiler)
|
|
55
|
+
});
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns sdk instance options with references to current account, node, compiler.
|
|
60
|
+
* Used to create an instance (Contract, Oracle) bound to AeSdk state.
|
|
61
|
+
* @param mergeWith - Merge context with these extra options
|
|
62
|
+
* @returns Context object
|
|
63
|
+
*/
|
|
64
|
+
getContext(mergeWith = {}) {
|
|
58
65
|
return {
|
|
59
66
|
...this._options,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
onCompiler: getValueOrErrorProxy(() => this._options.onCompiler),
|
|
63
|
-
...callOptions
|
|
67
|
+
..._classPrivateFieldGet(this, _wrappedOptions),
|
|
68
|
+
...mergeWith
|
|
64
69
|
};
|
|
65
70
|
}
|
|
71
|
+
|
|
72
|
+
// TODO: omit onNode from options, because it is already in context
|
|
66
73
|
async buildTx(options) {
|
|
67
74
|
return buildTxAsync({
|
|
68
|
-
...this.
|
|
75
|
+
...this.getContext(),
|
|
69
76
|
...options
|
|
70
77
|
});
|
|
71
78
|
}
|
|
72
79
|
async initializeContract(options) {
|
|
73
|
-
return Contract.initialize(this.
|
|
80
|
+
return Contract.initialize(this.getContext(options));
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
|
-
Object.assign(AeSdkMethods.prototype, mapObject(methods,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
args.length = handler.length;
|
|
83
|
-
const options = args[args.length - 1];
|
|
84
|
-
args[args.length - 1] = this._getOptions(options);
|
|
85
|
-
return handler(...args);
|
|
86
|
-
}];
|
|
87
|
-
}));
|
|
83
|
+
Object.assign(AeSdkMethods.prototype, mapObject(methods, ([name, handler]) => [name, function methodWrapper(...args) {
|
|
84
|
+
args.length = handler.length;
|
|
85
|
+
const options = args[args.length - 1];
|
|
86
|
+
args[args.length - 1] = this.getContext(options);
|
|
87
|
+
return handler(...args);
|
|
88
|
+
}]));
|
|
88
89
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
89
90
|
const AeSdkMethodsTyped = AeSdkMethods;
|
|
90
91
|
export default AeSdkMethodsTyped;
|
package/es/AeSdkMethods.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AeSdkMethods.mjs","names":["chainMethods","aensMethods","spendMethods","oracleMethods","Contract","createDelegationSignature","contractGaMethods","buildTxAsync","mapObject","
|
|
1
|
+
{"version":3,"file":"AeSdkMethods.mjs","names":["chainMethods","sendTransaction","aensMethods","spendMethods","oracleMethods","Contract","createDelegationSignature","contractGaMethods","buildTxAsync","mapObject","wrapWithProxy","methods","_wrappedOptions","WeakMap","AeSdkMethods","constructor","options","_defineProperty","_classPrivateFieldInitSpec","writable","value","Object","assign","_options","_classPrivateFieldSet","onAccount","onNode","onCompiler","getContext","mergeWith","_classPrivateFieldGet","buildTx","initializeContract","initialize","prototype","name","handler","methodWrapper","args","length","AeSdkMethodsTyped"],"sources":["../src/AeSdkMethods.ts"],"sourcesContent":["import * as chainMethods from './chain';\nimport { sendTransaction } from './send-transaction';\nimport * as aensMethods from './aens';\nimport * as spendMethods from './spend';\nimport * as oracleMethods from './oracle';\nimport Contract, { ContractMethodsBase } from './contract/Contract';\nimport createDelegationSignature from './contract/delegation-signature';\nimport * as contractGaMethods from './contract/ga';\nimport { buildTxAsync } from './tx/builder';\nimport { mapObject, UnionToIntersection } from './utils/other';\nimport { wrapWithProxy } from './utils/wrap-proxy';\nimport Node from './Node';\nimport { TxParamsAsync } from './tx/builder/schema.generated';\nimport AccountBase from './account/Base';\nimport { Encoded } from './utils/encoder';\nimport CompilerBase from './contract/compiler/Base';\n\nexport type OnAccount = Encoded.AccountAddress | AccountBase | undefined;\n\nconst methods = {\n ...chainMethods,\n sendTransaction,\n ...aensMethods,\n ...spendMethods,\n ...oracleMethods,\n createDelegationSignature,\n ...contractGaMethods,\n} as const;\n\ntype Decrement<Number extends number> = [-1, 0, 1, 2, 3, 4, 5][Number];\ntype GetMethodsOptions <Methods extends { [key: string]: Function }> =\n {\n [Name in keyof Methods]:\n Methods[Name] extends (...args: infer Args) => any\n ? Args[Decrement<Args['length']>] : never\n };\ntype MethodsOptions = GetMethodsOptions<typeof methods>;\nexport interface AeSdkMethodsOptions\n extends Partial<UnionToIntersection<MethodsOptions[keyof MethodsOptions]>> {\n}\n\nexport interface WrappedOptions {\n onAccount: AccountBase;\n onCompiler: CompilerBase;\n onNode: Node;\n}\n\n/**\n * AeSdkMethods is the composition of:\n * - chain methods\n * - tx methods\n * - aens methods\n * - spend methods\n * - oracle methods\n * - contract methods\n * - contract ga methods\n *\n * While these methods can be used separately, this class provides a handy way to store\n * their context (current account, network, and compiler to use).\n */\nclass AeSdkMethods {\n _options: AeSdkMethodsOptions = {};\n\n readonly #wrappedOptions: WrappedOptions;\n\n /**\n * @param options - Options\n */\n constructor(options: AeSdkMethodsOptions = {}) {\n Object.assign(this._options, options);\n this.#wrappedOptions = {\n onAccount: wrapWithProxy(() => this._options.onAccount),\n onNode: wrapWithProxy(() => this._options.onNode),\n onCompiler: wrapWithProxy(() => this._options.onCompiler),\n };\n }\n\n /**\n * Returns sdk instance options with references to current account, node, compiler.\n * Used to create an instance (Contract, Oracle) bound to AeSdk state.\n * @param mergeWith - Merge context with these extra options\n * @returns Context object\n */\n getContext(mergeWith: AeSdkMethodsOptions = {}): AeSdkMethodsOptions & WrappedOptions {\n return {\n ...this._options,\n ...this.#wrappedOptions,\n ...mergeWith,\n };\n }\n\n // TODO: omit onNode from options, because it is already in context\n async buildTx(options: TxParamsAsync): Promise<Encoded.Transaction> {\n return buildTxAsync({ ...this.getContext(), ...options });\n }\n\n async initializeContract<Methods extends ContractMethodsBase>(\n options?: Omit<Parameters<typeof Contract.initialize>[0], 'onNode'> & { onNode?: Node },\n ): Promise<Contract<Methods>> {\n return Contract.initialize<Methods>(this.getContext(options as AeSdkMethodsOptions));\n }\n}\n\ntype RequiredKeys<T> = {\n [K in keyof T]-?: {} extends Pick<T, K> ? never : K\n}[keyof T];\n\ntype OptionalIfNotRequired<T extends [any]> = RequiredKeys<T[0]> extends never ? T | [] : T;\n\ntype ReplaceOnAccount<Options> = Options extends { onAccount: any }\n ? Omit<Options, 'onAccount'> & {\n /**\n * Make operation on specific account by providing address (to use account from sdk) or instance\n * of AccountBase (like MemoryAccount)\n */\n onAccount: OnAccount;\n } : Options;\n\ntype MakeOptional<Options> = OptionalIfNotRequired<[\n Omit<Options, 'onNode' | 'onCompiler' | 'onAccount'> & Partial<ReplaceOnAccount<Options>>,\n]>;\n\ntype TransformMethods <Methods extends { [key: string]: Function }> =\n {\n [Name in keyof Methods]:\n Methods[Name] extends (...args: [...infer Args, infer Options]) => infer Ret\n ? (...args: [...Args, ...MakeOptional<Options>]) => Ret\n : never\n };\n\ninterface AeSdkMethodsTransformed extends TransformMethods<typeof methods> {}\n\nObject.assign(AeSdkMethods.prototype, mapObject<Function, Function>(\n methods,\n ([name, handler]) => [\n name,\n function methodWrapper(this: AeSdkMethods, ...args: any[]) {\n args.length = handler.length;\n const options = args[args.length - 1];\n args[args.length - 1] = this.getContext(options);\n return handler(...args);\n },\n ],\n));\n\ntype AeSdkMethodsTyped = AeSdkMethods & AeSdkMethodsTransformed;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nconst AeSdkMethodsTyped = AeSdkMethods as new (options?: AeSdkMethodsOptions) => AeSdkMethodsTyped;\nexport default AeSdkMethodsTyped;\n"],"mappings":";;;;;OAAO,KAAKA,YAAY;AAAA,SACfC,eAAe;AAAA,OACjB,KAAKC,WAAW;AAAA,OAChB,KAAKC,YAAY;AAAA,OACjB,KAAKC,aAAa;AAAA,OAClBC,QAAQ;AAAA,OACRC,yBAAyB;AAAA,OACzB,KAAKC,iBAAiB;AAAA,SACpBC,YAAY;AAAA,SACZC,SAAS;AAAA,SACTC,aAAa;AAStB,MAAMC,OAAO,GAAG;EACd,GAAGX,YAAY;EACfC,eAAe;EACf,GAAGC,WAAW;EACd,GAAGC,YAAY;EACf,GAAGC,aAAa;EAChBE,yBAAyB;EACzB,GAAGC;AACL,CAAU;AAAC,IAAAK,eAAA,oBAAAC,OA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AO,CAAC,KAAK,CACnBD,IAAI,EACJ,SAASE,aAAaA,CAAqB,GAAGC,IAAW,EAAE;EACzDA,IAAI,CAACC,MAAM,GAAGH,OAAO,CAACG,MAAM;EAC5B,MAAMvB,OAAO,GAAGsB,IAAI,CAACA,IAAI,CAACC,MAAM,GAAG,CAAC,CAAC;EACrCD,IAAI,CAACA,IAAI,CAACC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAACX,UAAU,CAACZ,OAAO,CAAC;EAChD,OAAOoB,OAAO,CAAC,GAAGE,IAAI,CAAC;AACzB,CAAC,CAEL,CAAC,CAAC;AAGF;AACA,MAAME,iBAAiB,GAAG1B,YAAwE;AAClG,eAAe0B,iBAAiB"}
|
package/es/AeSdkWallet.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import RpcClient from "./aepp-wallet-communication/rpc/RpcClient.mjs";
|
|
|
10
10
|
import { METHODS, RPC_STATUS, SUBSCRIPTION_TYPES, RpcInvalidTransactionError, RpcNotAuthorizeError, RpcPermissionDenyError, RpcUnsupportedProtocolError } from "./aepp-wallet-communication/schema.mjs";
|
|
11
11
|
import { InternalError, UnknownRpcClientError } from "./utils/errors.mjs";
|
|
12
12
|
import { RPC_VERSION } from "./aepp-wallet-communication/rpc/types.mjs";
|
|
13
|
+
import { Encoding, encode, decode } from "./utils/encoder.mjs";
|
|
13
14
|
import jsonBig from "./utils/json-big.mjs";
|
|
14
15
|
/**
|
|
15
16
|
* Contain functionality for aepp interaction and managing multiple aepps
|
|
@@ -26,17 +27,16 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
26
27
|
* @param options.onAskAccounts - Call-back function for incoming AEPP get address request
|
|
27
28
|
* @param options.onDisconnect - Call-back function for disconnect event
|
|
28
29
|
*/
|
|
29
|
-
constructor(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} = _ref;
|
|
30
|
+
constructor({
|
|
31
|
+
name,
|
|
32
|
+
id,
|
|
33
|
+
type,
|
|
34
|
+
onConnection,
|
|
35
|
+
onSubscription,
|
|
36
|
+
onDisconnect,
|
|
37
|
+
onAskAccounts,
|
|
38
|
+
...options
|
|
39
|
+
}) {
|
|
40
40
|
super(options);
|
|
41
41
|
_defineProperty(this, "_clients", new Map());
|
|
42
42
|
this.onConnection = onConnection;
|
|
@@ -47,10 +47,9 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
47
47
|
this.id = id;
|
|
48
48
|
this._type = type;
|
|
49
49
|
}
|
|
50
|
-
_getAccountsForClient(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} = _ref2;
|
|
50
|
+
_getAccountsForClient({
|
|
51
|
+
addressSubscription
|
|
52
|
+
}) {
|
|
54
53
|
const {
|
|
55
54
|
current,
|
|
56
55
|
connected
|
|
@@ -140,13 +139,12 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
140
139
|
},
|
|
141
140
|
// Store client info and prepare two fn for each client `connect` and `denyConnection`
|
|
142
141
|
// which automatically prepare and send response for that client
|
|
143
|
-
[METHODS.connect]: async (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} = _ref3;
|
|
142
|
+
[METHODS.connect]: async ({
|
|
143
|
+
name,
|
|
144
|
+
version,
|
|
145
|
+
icons,
|
|
146
|
+
connectNode
|
|
147
|
+
}, origin) => {
|
|
150
148
|
if (version !== RPC_VERSION) throw new RpcUnsupportedProtocolError();
|
|
151
149
|
await this.onConnection(id, {
|
|
152
150
|
name,
|
|
@@ -160,11 +158,10 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
160
158
|
...(connectNode && this._getNode())
|
|
161
159
|
};
|
|
162
160
|
},
|
|
163
|
-
[METHODS.subscribeAddress]: async (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
} = _ref4;
|
|
161
|
+
[METHODS.subscribeAddress]: async ({
|
|
162
|
+
type,
|
|
163
|
+
value
|
|
164
|
+
}, origin) => {
|
|
168
165
|
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
169
166
|
switch (type) {
|
|
170
167
|
case SUBSCRIPTION_TYPES.subscribe:
|
|
@@ -191,13 +188,12 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
191
188
|
await this.onAskAccounts(id, params, origin);
|
|
192
189
|
return this.addresses();
|
|
193
190
|
},
|
|
194
|
-
[METHODS.sign]: async (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
} = _ref5;
|
|
191
|
+
[METHODS.sign]: async ({
|
|
192
|
+
tx,
|
|
193
|
+
onAccount = this.address,
|
|
194
|
+
returnSigned,
|
|
195
|
+
innerTx
|
|
196
|
+
}, origin) => {
|
|
201
197
|
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
202
198
|
if (!this.addresses().includes(onAccount)) {
|
|
203
199
|
throw new RpcPermissionDenyError(onAccount);
|
|
@@ -226,11 +222,10 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
226
222
|
throw error;
|
|
227
223
|
}
|
|
228
224
|
},
|
|
229
|
-
[METHODS.signMessage]: async (
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
} = _ref6;
|
|
225
|
+
[METHODS.signMessage]: async ({
|
|
226
|
+
message,
|
|
227
|
+
onAccount = this.address
|
|
228
|
+
}, origin) => {
|
|
234
229
|
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
235
230
|
if (!this.addresses().includes(onAccount)) {
|
|
236
231
|
throw new RpcPermissionDenyError(onAccount);
|
|
@@ -244,13 +239,12 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
244
239
|
signature: _Buffer.from(await this.signMessage(message, parameters)).toString('hex')
|
|
245
240
|
};
|
|
246
241
|
},
|
|
247
|
-
[METHODS.signTypedData]: async (
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
} = _ref7;
|
|
242
|
+
[METHODS.signTypedData]: async ({
|
|
243
|
+
domain,
|
|
244
|
+
aci,
|
|
245
|
+
data,
|
|
246
|
+
onAccount = this.address
|
|
247
|
+
}, origin) => {
|
|
254
248
|
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
255
249
|
if (!this.addresses().includes(onAccount)) {
|
|
256
250
|
throw new RpcPermissionDenyError(onAccount);
|
|
@@ -265,24 +259,61 @@ export default class AeSdkWallet extends AeSdk {
|
|
|
265
259
|
signature: await this.signTypedData(data, aci, parameters)
|
|
266
260
|
};
|
|
267
261
|
},
|
|
268
|
-
[METHODS.signDelegationToContract]: async (
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
262
|
+
[METHODS.signDelegationToContract]: async ({
|
|
263
|
+
contractAddress,
|
|
264
|
+
name,
|
|
265
|
+
oracleQueryId,
|
|
266
|
+
allNames,
|
|
267
|
+
onAccount = this.address,
|
|
268
|
+
isOracle
|
|
269
|
+
}, origin) => {
|
|
270
|
+
var _isOracle, _ref, _ref2, _ref3;
|
|
276
271
|
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
277
272
|
if (!this.addresses().includes(onAccount)) {
|
|
278
273
|
throw new RpcPermissionDenyError(onAccount);
|
|
279
274
|
}
|
|
275
|
+
(_isOracle = isOracle) !== null && _isOracle !== void 0 ? _isOracle : isOracle = false;
|
|
276
|
+
const parameters = {
|
|
277
|
+
onAccount,
|
|
278
|
+
aeppOrigin: origin,
|
|
279
|
+
aeppRpcClientId: id
|
|
280
|
+
};
|
|
281
|
+
const signature = await ((_ref = (_ref2 = (_ref3 = name == null ? null : this.signNameDelegationToContract(contractAddress, name, parameters)) !== null && _ref3 !== void 0 ? _ref3 : oracleQueryId == null ? null : this.signOracleQueryDelegationToContract(contractAddress, oracleQueryId, parameters)) !== null && _ref2 !== void 0 ? _ref2 : allNames !== true ? null : this.signAllNamesDelegationToContract(contractAddress, parameters)) !== null && _ref !== void 0 ? _ref : this.signDelegationToContract(contractAddress, {
|
|
282
|
+
...parameters,
|
|
283
|
+
isOracle
|
|
284
|
+
}));
|
|
285
|
+
return {
|
|
286
|
+
signature
|
|
287
|
+
};
|
|
288
|
+
},
|
|
289
|
+
[METHODS.unsafeSign]: async ({
|
|
290
|
+
data,
|
|
291
|
+
onAccount = this.address
|
|
292
|
+
}, origin) => {
|
|
293
|
+
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
294
|
+
if (!this.addresses().includes(onAccount)) throw new RpcPermissionDenyError(onAccount);
|
|
295
|
+
const parameters = {
|
|
296
|
+
onAccount,
|
|
297
|
+
aeppOrigin: origin,
|
|
298
|
+
aeppRpcClientId: id
|
|
299
|
+
};
|
|
300
|
+
const signature = encode(await this.sign(decode(data), parameters), Encoding.Signature);
|
|
301
|
+
return {
|
|
302
|
+
signature
|
|
303
|
+
};
|
|
304
|
+
},
|
|
305
|
+
[METHODS.signDelegation]: async ({
|
|
306
|
+
delegation,
|
|
307
|
+
onAccount = this.address
|
|
308
|
+
}, origin) => {
|
|
309
|
+
if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
|
|
310
|
+
if (!this.addresses().includes(onAccount)) throw new RpcPermissionDenyError(onAccount);
|
|
280
311
|
const parameters = {
|
|
281
312
|
onAccount,
|
|
282
313
|
aeppOrigin: origin,
|
|
283
314
|
aeppRpcClientId: id
|
|
284
315
|
};
|
|
285
|
-
const signature = await
|
|
316
|
+
const signature = await this.signDelegation(delegation, parameters);
|
|
286
317
|
return {
|
|
287
318
|
signature
|
|
288
319
|
};
|