@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/es/Node.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.mjs","names":["BigNumber","genRequestQueuesPolicy","genCombineGetRequestsPolicy","genErrorFormatterPolicy","genVersionCheckPolicy","genRetryOnFailurePolicy","Node","NodeApi","mapObject","UnsupportedVersionError","ConsensusProtocolVersion","bigIntPropertyNames","numberPropertyNames","_mapData","WeakSet","_encodeArg","_decodeRes","NodeTransformed","constructor","arguments","_classPrivateMethodInitSpec","sendOperationRequest","operationArguments","operationSpec","args","_ref","key","value","_classPrivateMethodGet","_encodeArg2","call","_decodeRes2","_mapData2","data","transform","Array","isArray","map","d","_ref6","some","k","bigInt","number","toFixed","toString","BigInt","_networkIdPromise","WeakMap","url","ignoreVersion","retryCount","retryOverallDelay","options","length","undefined","allowInsecureConnection","additionalPolicies","body","reason","_classPrivateFieldInitSpec","writable","statusPromise","getStatus","versionPromise","then","_ref2","nodeVersion","error","_classPrivateFieldSet","_ref3","networkId","pipeline","addPolicy","intAsString","getNetworkId","_classPrivateFieldGet2","_classPrivateFieldGet","_ref4","Error","getNodeInfo","nodeNetworkId","protocols","topBlockHeight","consensusProtocolVersion","filter","_ref5","effectiveAtHeight","reduce","acc","p","version","versions","Object","values","el","geVersion","Math","min","ltVersion","max","$host"],"sources":["../src/Node.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\nimport { OperationArguments, OperationSpec } from '@azure/core-client';\nimport {\n genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,\n genVersionCheckPolicy, genRetryOnFailurePolicy,\n} from './utils/autorest';\nimport { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';\nimport { mapObject } from './utils/other';\nimport { UnsupportedVersionError } from './utils/errors';\nimport { Encoded } from './utils/encoder';\nimport { ConsensusProtocolVersion } from './tx/builder/constants';\n\nconst bigIntPropertyNames = [\n 'balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount',\n 'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal',\n 'responderAmountFinal', 'gasPrice', 'deposit',\n] as const;\n\nconst numberPropertyNames = [\n 'time', 'gas', 'gasUsed', 'nameSalt',\n 'nonce', 'nextNonce', 'height', 'blockHeight', 'topBlockHeight',\n 'ttl', 'nameTtl', 'clientTtl',\n 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',\n 'version', 'solutions', 'round',\n] as const;\n\nclass NodeTransformed extends NodeApi {\n override async sendOperationRequest(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<any> {\n const args = mapObject(\n operationArguments,\n ([key, value]) => [key, this.#encodeArg(value)],\n ) as OperationArguments;\n return this.#decodeRes(await super.sendOperationRequest(args, operationSpec));\n }\n\n #mapData(data: any, transform: {\n bigInt: (v: any) => any;\n number: (v: any) => any;\n }): unknown {\n if (Array.isArray(data)) return data.map((d) => this.#mapData(d, transform));\n if (data != null && typeof data === 'object') {\n return mapObject(data, ([key, value]) => {\n if (value == null) return [key, value];\n if (bigIntPropertyNames.some((k) => k === key)) return [key, transform.bigInt(value)];\n if (numberPropertyNames.some((k) => k === key)) return [key, transform.number(value)];\n return [key, this.#mapData(value, transform)];\n });\n }\n return data;\n }\n\n #encodeArg(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => {\n if (value instanceof BigNumber) return value.toFixed();\n return value.toString();\n },\n number: (value) => value.toString(),\n });\n }\n\n #decodeRes(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => BigInt(value),\n number: (value) => +value,\n });\n }\n}\n\ntype BigIntPropertyNames = typeof bigIntPropertyNames[number];\ntype NumberPropertyNames = typeof numberPropertyNames[number];\ntype PreserveOptional<NewType, OrigType> =\n OrigType extends undefined ? NewType | undefined : NewType;\nexport type TransformNodeType<Type> =\n Type extends (...args: infer Args) => infer Ret\n ? (...args: TransformNodeType<Args>) => TransformNodeType<Ret>\n : Type extends [infer Item, ...infer Rest]\n ? [TransformNodeType<Item>, ...TransformNodeType<Rest>]\n : Type extends Array<infer Item>\n ? Array<TransformNodeType<Item>>\n : Type extends Promise<infer T>\n ? Promise<TransformNodeType<T>>\n : Type extends { [P in any]: any }\n ? {\n [Property in keyof Type]:\n Property extends BigIntPropertyNames\n ? PreserveOptional<bigint, Type[Property]>\n : Property extends NumberPropertyNames\n ? PreserveOptional<number, Type[Property]>\n : Property extends 'txHash'\n ? PreserveOptional<Encoded.TxHash, Type[Property]>\n : Property extends 'bytecode'\n ? PreserveOptional<Encoded.ContractBytearray, Type[Property]>\n : TransformNodeType<Type[Property]>\n }\n : Type;\ntype NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {\n [Name in keyof InstanceType<typeof NodeApi>]:\n Name extends 'pipeline' | 'sendRequest' | 'sendOperationRequest'\n ? NodeApi[Name] : TransformNodeType<NodeApi[Name]>\n};\n\ninterface NodeInfo {\n url: string;\n nodeNetworkId: string;\n version: string;\n consensusProtocolVersion: ConsensusProtocolVersion;\n}\n\nexport default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {\n #networkIdPromise?: Promise<string | Error>;\n\n /**\n * @param url - Url for node API\n * @param options - Options\n * @param options.ignoreVersion - Don't ensure that the node is supported\n * @param options.retryCount - Amount of extra requests to do in case of failure\n * @param options.retryOverallDelay - Time in ms to wait between all retries\n */\n constructor(\n url: string,\n {\n ignoreVersion = false, retryCount = 3, retryOverallDelay = 800, ...options\n }: NodeOptionalParams & {\n ignoreVersion?: boolean;\n retryCount?: number;\n retryOverallDelay?: number;\n } = {},\n ) {\n // eslint-disable-next-line constructor-super\n super(url, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genRequestQueuesPolicy(),\n genCombineGetRequestsPolicy(),\n genRetryOnFailurePolicy(retryCount, retryOverallDelay),\n genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`),\n ],\n ...options,\n });\n if (!ignoreVersion) {\n const statusPromise = this.getStatus();\n const versionPromise = statusPromise.then(({ nodeVersion }) => nodeVersion, (error) => error);\n this.#networkIdPromise = statusPromise.then(({ networkId }) => networkId, (error) => error);\n this.pipeline.addPolicy(\n genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'),\n );\n }\n this.intAsString = true;\n }\n\n async getNetworkId(): Promise<string> {\n this.#networkIdPromise ??= this.getStatus().then(({ networkId }) => networkId);\n const networkId = await this.#networkIdPromise;\n if (networkId instanceof Error) throw networkId;\n return networkId;\n }\n\n async getNodeInfo(): Promise<NodeInfo> {\n const {\n nodeVersion,\n networkId: nodeNetworkId,\n protocols,\n topBlockHeight,\n } = await this.getStatus();\n\n const consensusProtocolVersion = protocols\n .filter(({ effectiveAtHeight }) => topBlockHeight >= effectiveAtHeight)\n .reduce(\n (acc, p) => (p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc),\n { effectiveAtHeight: -1, version: 0 },\n )\n .version;\n if (ConsensusProtocolVersion[consensusProtocolVersion] == null) {\n const version = consensusProtocolVersion.toString();\n const versions = Object.values(ConsensusProtocolVersion)\n .filter((el) => typeof el === 'number').map((el) => +el);\n const geVersion = Math.min(...versions).toString();\n const ltVersion = (Math.max(...versions) + 1).toString();\n throw new UnsupportedVersionError('consensus protocol', version, geVersion, ltVersion);\n }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ACxF;IAEA,OAAO;MACLlD,GAAG,EAAE,IAAI,CAACoD,KAAK;MACfpB,aAAa;MACbU,OAAO,EAAExB,WAAW;MACpBiB;IACF,CAAC;EACH;AACF"}
|
|
1
|
+
{"version":3,"file":"Node.mjs","names":["BigNumber","userAgentPolicyName","setClientRequestIdPolicyName","genRequestQueuesPolicy","genCombineGetRequestsPolicy","genErrorFormatterPolicy","genVersionCheckPolicy","genRetryOnFailurePolicy","Node","NodeApi","mapObject","UnsupportedVersionError","ConsensusProtocolVersion","bigIntPropertyNames","numberPropertyNames","_mapData","WeakSet","_encodeArg","_decodeRes","NodeTransformed","constructor","args","_classPrivateMethodInitSpec","sendOperationRequest","operationArguments","operationSpec","key","value","_classPrivateMethodGet","_encodeArg2","call","_decodeRes2","_mapData2","data","transform","Array","isArray","map","d","some","k","bigInt","number","toFixed","toString","BigInt","_cachedStatusPromise","WeakMap","url","ignoreVersion","retryCount","retryOverallDelay","options","getVersion","opts","_getCachedStatus","nodeVersion","allowInsecureConnection","additionalPolicies","body","reason","errorCode","join","_classPrivateFieldInitSpec","writable","pipeline","removePolicy","name","intAsString","_classPrivateFieldGet","getStatus","promise","then","_classPrivateFieldSet","getNetworkId","networkId","getNodeInfo","nodeNetworkId","protocols","topBlockHeight","consensusProtocolVersion","filter","effectiveAtHeight","reduce","acc","p","version","versions","Object","values","el","geVersion","Math","min","ltVersion","max","$host"],"sources":["../src/Node.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\nimport { OperationArguments, OperationOptions, OperationSpec } from '@azure/core-client';\nimport { userAgentPolicyName, setClientRequestIdPolicyName } from '@azure/core-rest-pipeline';\nimport {\n genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,\n genVersionCheckPolicy, genRetryOnFailurePolicy,\n} from './utils/autorest';\nimport { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';\nimport { mapObject } from './utils/other';\nimport { UnsupportedVersionError } from './utils/errors';\nimport { Encoded } from './utils/encoder';\nimport { ConsensusProtocolVersion } from './tx/builder/constants';\n\nconst bigIntPropertyNames = [\n 'balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount',\n 'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal',\n 'responderAmountFinal', 'gasPrice', 'minGasPrice', 'deposit',\n] as const;\n\nconst numberPropertyNames = [\n 'time', 'gas', 'gasUsed', 'nameSalt',\n 'nonce', 'nextNonce', 'height', 'blockHeight', 'topBlockHeight',\n 'ttl', 'nameTtl', 'clientTtl',\n 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',\n 'version', 'solutions', 'round', 'minutes', 'utilization', 'difficulty', 'hashrate',\n] as const;\n\nclass NodeTransformed extends NodeApi {\n override async sendOperationRequest(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<any> {\n const args = mapObject(\n operationArguments,\n ([key, value]) => [key, this.#encodeArg(value)],\n ) as OperationArguments;\n return this.#decodeRes(await super.sendOperationRequest(args, operationSpec));\n }\n\n #mapData(data: any, transform: {\n bigInt: (v: any) => any;\n number: (v: any) => any;\n }): unknown {\n if (Array.isArray(data)) return data.map((d) => this.#mapData(d, transform));\n if (data != null && typeof data === 'object') {\n return mapObject(data, ([key, value]) => {\n if (value == null) return [key, value];\n if (bigIntPropertyNames.some((k) => k === key)) return [key, transform.bigInt(value)];\n if (numberPropertyNames.some((k) => k === key)) return [key, transform.number(value)];\n return [key, this.#mapData(value, transform)];\n });\n }\n return data;\n }\n\n #encodeArg(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => {\n if (value instanceof BigNumber) return value.toFixed();\n return value.toString();\n },\n number: (value) => value.toString(),\n });\n }\n\n #decodeRes(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => BigInt(value),\n number: (value) => +value,\n });\n }\n}\n\ntype BigIntPropertyNames = typeof bigIntPropertyNames[number];\ntype NumberPropertyNames = typeof numberPropertyNames[number];\ntype PreserveOptional<NewType, OrigType> =\n OrigType extends undefined ? NewType | undefined : NewType;\nexport type TransformNodeType<Type> =\n Type extends (...args: infer Args) => infer Ret\n ? (...args: TransformNodeType<Args>) => TransformNodeType<Ret>\n : Type extends [infer Item, ...infer Rest]\n ? [TransformNodeType<Item>, ...TransformNodeType<Rest>]\n : Type extends Array<infer Item>\n ? Array<TransformNodeType<Item>>\n : Type extends Promise<infer T>\n ? Promise<TransformNodeType<T>>\n : Type extends { [P in any]: any }\n ? {\n [Property in keyof Type]:\n Property extends BigIntPropertyNames\n ? PreserveOptional<bigint, Type[Property]>\n : Property extends NumberPropertyNames\n ? PreserveOptional<number, Type[Property]>\n : Property extends 'txHash'\n ? PreserveOptional<Encoded.TxHash, Type[Property]>\n : Property extends 'bytecode'\n ? PreserveOptional<Encoded.ContractBytearray, Type[Property]>\n : TransformNodeType<Type[Property]>\n }\n : Type;\ntype NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {\n [Name in keyof InstanceType<typeof NodeApi>]:\n Name extends 'pipeline' | 'sendRequest' | 'sendOperationRequest'\n ? NodeApi[Name] : TransformNodeType<NodeApi[Name]>\n};\n\ninterface NodeInfo {\n url: string;\n nodeNetworkId: string;\n version: string;\n consensusProtocolVersion: ConsensusProtocolVersion;\n}\n\nexport default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {\n /**\n * @param url - Url for node API\n * @param options - Options\n * @param options.ignoreVersion - Don't ensure that the node is supported\n * @param options.retryCount - Amount of extra requests to do in case of failure\n * @param options.retryOverallDelay - Time in ms to wait between all retries\n */\n constructor(\n url: string,\n {\n ignoreVersion = false, retryCount = 3, retryOverallDelay = 800, ...options\n }: NodeOptionalParams & {\n ignoreVersion?: boolean;\n retryCount?: number;\n retryOverallDelay?: number;\n } = {},\n ) {\n const getVersion = async (opts: OperationOptions): Promise<string> => (\n (await this._getCachedStatus(opts)).nodeVersion\n );\n // eslint-disable-next-line constructor-super\n super(url, {\n allowInsecureConnection: true,\n additionalPolicies: [\n ...ignoreVersion ? [] : [genVersionCheckPolicy('node', getVersion, '6.2.0', '8.0.0')],\n genRequestQueuesPolicy(),\n genCombineGetRequestsPolicy(),\n genRetryOnFailurePolicy(retryCount, retryOverallDelay),\n genErrorFormatterPolicy((body: ErrorModel) => [\n ' ', body.reason, body.errorCode == null ? '' : ` (${body.errorCode})`,\n ].join('')),\n ],\n ...options,\n });\n this.pipeline.removePolicy({ name: userAgentPolicyName });\n this.pipeline.removePolicy({ name: setClientRequestIdPolicyName });\n // TODO: use instead our retry policy\n this.pipeline.removePolicy({ name: 'defaultRetryPolicy' });\n this.intAsString = true;\n }\n\n #cachedStatusPromise?: ReturnType<Node['getStatus']>;\n\n async _getCachedStatus(options?: OperationOptions): ReturnType<Node['getStatus']> {\n if (this.#cachedStatusPromise != null) return this.#cachedStatusPromise;\n return this.getStatus(options);\n }\n\n // eslint-disable-next-line rulesdir/tsdoc-syntax\n /** @ts-expect-error use code generation to create node class? */\n override async getStatus(\n ...args: Parameters<InstanceType<NodeTransformedApi>['getStatus']>\n ): ReturnType<InstanceType<NodeTransformedApi>['getStatus']> {\n const promise = super.getStatus(...args);\n promise.then(() => { this.#cachedStatusPromise = promise; }, () => {});\n return promise;\n }\n\n /**\n * Returns network ID provided by node.\n * This method won't do extra requests on subsequent calls.\n */\n async getNetworkId(): Promise<string> {\n return (await this._getCachedStatus()).networkId;\n }\n\n async getNodeInfo(): Promise<NodeInfo> {\n const {\n nodeVersion,\n networkId: nodeNetworkId,\n protocols,\n topBlockHeight,\n } = await this.getStatus();\n\n const consensusProtocolVersion = protocols\n .filter(({ effectiveAtHeight }) => topBlockHeight >= effectiveAtHeight)\n .reduce(\n (acc, p) => (p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc),\n { effectiveAtHeight: -1, version: 0 },\n )\n .version;\n if (ConsensusProtocolVersion[consensusProtocolVersion] == null) {\n const version = consensusProtocolVersion.toString();\n const versions = Object.values(ConsensusProtocolVersion)\n .filter((el) => typeof el === 'number').map((el) => +el);\n const geVersion = Math.min(...versions).toString();\n const ltVersion = (Math.max(...versions) + 1).toString();\n throw new UnsupportedVersionError('consensus protocol', version, geVersion, ltVersion);\n }\n\n return {\n url: this.$host,\n nodeNetworkId,\n version: nodeVersion,\n consensusProtocolVersion,\n };\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA,OAAOA,SAAS,MAAM,cAAc;AAEpC,SAASC,mBAAmB,EAAEC,4BAA4B,QAAQ,2BAA2B;AAAC,SAE5FC,sBAAsB,EAAEC,2BAA2B,EAAEC,uBAAuB,EAC5EC,qBAAqB,EAAEC,uBAAuB;AAAA,SAEvCC,IAAI,IAAIC,OAAO;AAAA,SACfC,SAAS;AAAA,SACTC,uBAAuB;AAAA,SAEvBC,wBAAwB;AAEjC,MAAMC,mBAAmB,GAAG,CAC1B,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAClE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,sBAAsB,EAC9E,sBAAsB,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,CACpD;AAEV,MAAMC,mBAAmB,GAAG,CAC1B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EACpC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAC/D,KAAK,EAAE,SAAS,EAAE,WAAW,EAC7B,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,0BAA0B,EAAE,mBAAmB,EACnF,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,CAC3E;AAAC,IAAAC,QAAA,oBAAAC,OAAA;AAAA,IAAAC,UAAA,oBAAAD,OAAA;AAAA,IAAAE,UAAA,oBAAAF,OAAA;AAEX,MAAMG,eAAe,SAASV,OAAO,CAAC;EAAAW,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,2BA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QAAQ,CAAC,CAAC3C,QAAQ,CAAC,CAAC;MAClD,MAAMkD,SAAS,GAAG,CAACF,IAAI,CAACG,GAAG,CAAC,GAAGR,QAAQ,CAAC,GAAG,CAAC,EAAE3C,QAAQ,CAAC,CAAC;MACxD,MAAM,IAAIjC,uBAAuB,CAAC,oBAAoB,EAAE2E,OAAO,EAAEK,SAAS,EAAEG,SAAS,CAAC;IACxF;IAEA,OAAO;MACL9C,GAAG,EAAE,IAAI,CAACgD,KAAK;MACfnB,aAAa;MACbS,OAAO,EAAE9B,WAAW;MACpBwB;IACF,CAAC;EACH;AACF"}
|
package/es/account/Base.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Encoded } from '../utils/encoder';
|
|
2
2
|
import Node from '../Node';
|
|
3
3
|
import CompilerBase from '../contract/compiler/Base';
|
|
4
|
-
import { AensName, Int } from '../tx/builder/constants';
|
|
4
|
+
import { AensName, ConsensusProtocolVersion, Int } from '../tx/builder/constants';
|
|
5
5
|
import { AciValue, Domain } from '../utils/typed-data';
|
|
6
6
|
interface AuthData {
|
|
7
7
|
fee?: Int;
|
|
@@ -45,8 +45,8 @@ export default abstract class AccountBase {
|
|
|
45
45
|
}): Promise<Uint8Array>;
|
|
46
46
|
/**
|
|
47
47
|
* Sign typed data
|
|
48
|
-
* @param type - Type of data to sign
|
|
49
48
|
* @param data - Encoded data to sign
|
|
49
|
+
* @param aci - Type of data to sign
|
|
50
50
|
* @param options - Options
|
|
51
51
|
* @returns Signature
|
|
52
52
|
*/
|
|
@@ -58,10 +58,15 @@ export default abstract class AccountBase {
|
|
|
58
58
|
* Sign delegation of AENS, oracle operations to a contract
|
|
59
59
|
* @param contractAddress - Address of a contract to delegate permissions to
|
|
60
60
|
* @param options - Options
|
|
61
|
+
* @param options.isOracle - Use to generate an oracle delegation signature in Ceres, otherwise an
|
|
62
|
+
* AENS preclaim delegation signature would be generated
|
|
61
63
|
* @returns Signature
|
|
64
|
+
* @deprecated use AccountBase:signDelegation in Ceres
|
|
62
65
|
*/
|
|
63
66
|
signDelegationToContract(contractAddress: Encoded.ContractAddress, options?: {
|
|
64
67
|
networkId?: string;
|
|
68
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
69
|
+
isOracle?: boolean;
|
|
65
70
|
aeppOrigin?: string;
|
|
66
71
|
aeppRpcClientId?: string;
|
|
67
72
|
}): Promise<Encoded.Signature>;
|
|
@@ -71,9 +76,24 @@ export default abstract class AccountBase {
|
|
|
71
76
|
* @param name - AENS name to manage by a contract
|
|
72
77
|
* @param options - Options
|
|
73
78
|
* @returns Signature
|
|
79
|
+
* @deprecated use AccountBase:signDelegation in Ceres
|
|
74
80
|
*/
|
|
75
81
|
signNameDelegationToContract(contractAddress: Encoded.ContractAddress, name: AensName, options?: {
|
|
76
82
|
networkId?: string;
|
|
83
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
84
|
+
aeppOrigin?: string;
|
|
85
|
+
aeppRpcClientId?: string;
|
|
86
|
+
}): Promise<Encoded.Signature>;
|
|
87
|
+
/**
|
|
88
|
+
* Sign delegation of all AENS names to a contract (not available in Iris)
|
|
89
|
+
* @param contractAddress - Address of a contract to delegate permissions to
|
|
90
|
+
* @param options - Options
|
|
91
|
+
* @returns Signature
|
|
92
|
+
* @deprecated use AccountBase:signDelegation in Ceres
|
|
93
|
+
*/
|
|
94
|
+
signAllNamesDelegationToContract(contractAddress: Encoded.ContractAddress, options?: {
|
|
95
|
+
networkId?: string;
|
|
96
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
77
97
|
aeppOrigin?: string;
|
|
78
98
|
aeppRpcClientId?: string;
|
|
79
99
|
}): Promise<Encoded.Signature>;
|
|
@@ -90,9 +110,11 @@ export default abstract class AccountBase {
|
|
|
90
110
|
* @param oracleQueryId - Oracle query ID to reply by a contract
|
|
91
111
|
* @param options - Options
|
|
92
112
|
* @returns Signature
|
|
113
|
+
* @deprecated use AccountBase:signDelegation in Ceres
|
|
93
114
|
*/
|
|
94
115
|
signOracleQueryDelegationToContract(contractAddress: Encoded.ContractAddress, oracleQueryId: Encoded.OracleQueryId, options?: {
|
|
95
116
|
networkId?: string;
|
|
117
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
96
118
|
aeppOrigin?: string;
|
|
97
119
|
aeppRpcClientId?: string;
|
|
98
120
|
}): Promise<Encoded.Signature>;
|
|
@@ -102,10 +124,24 @@ export default abstract class AccountBase {
|
|
|
102
124
|
* @param options - Options
|
|
103
125
|
* @returns Signature
|
|
104
126
|
*/
|
|
105
|
-
abstract sign(data: string | Uint8Array, options?:
|
|
127
|
+
abstract sign(data: string | Uint8Array, options?: {
|
|
128
|
+
aeppOrigin?: string;
|
|
129
|
+
aeppRpcClientId?: string;
|
|
130
|
+
}): Promise<Uint8Array>;
|
|
106
131
|
/**
|
|
107
132
|
* Account address
|
|
108
133
|
*/
|
|
109
134
|
readonly address: Encoded.AccountAddress;
|
|
135
|
+
/**
|
|
136
|
+
* Sign delegation, works only in Ceres
|
|
137
|
+
* @param delegation - Delegation to sign
|
|
138
|
+
* @param options - Options
|
|
139
|
+
* @returns Signature
|
|
140
|
+
*/
|
|
141
|
+
signDelegation(delegation: Encoded.Bytearray, options?: {
|
|
142
|
+
networkId?: string;
|
|
143
|
+
aeppOrigin?: string;
|
|
144
|
+
aeppRpcClientId?: string;
|
|
145
|
+
}): Promise<Encoded.Signature>;
|
|
110
146
|
}
|
|
111
147
|
export {};
|
package/es/account/Base.mjs
CHANGED
|
@@ -22,8 +22,8 @@ export default class AccountBase {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Sign typed data
|
|
25
|
-
* @param type - Type of data to sign
|
|
26
25
|
* @param data - Encoded data to sign
|
|
26
|
+
* @param aci - Type of data to sign
|
|
27
27
|
* @param options - Options
|
|
28
28
|
* @returns Signature
|
|
29
29
|
*/
|
|
@@ -39,7 +39,10 @@ export default class AccountBase {
|
|
|
39
39
|
* Sign delegation of AENS, oracle operations to a contract
|
|
40
40
|
* @param contractAddress - Address of a contract to delegate permissions to
|
|
41
41
|
* @param options - Options
|
|
42
|
+
* @param options.isOracle - Use to generate an oracle delegation signature in Ceres, otherwise an
|
|
43
|
+
* AENS preclaim delegation signature would be generated
|
|
42
44
|
* @returns Signature
|
|
45
|
+
* @deprecated use AccountBase:signDelegation in Ceres
|
|
43
46
|
*/
|
|
44
47
|
// TODO: make abstract in the next major release
|
|
45
48
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -55,6 +58,7 @@ export default class AccountBase {
|
|
|
55
58
|
* @param name - AENS name to manage by a contract
|
|
56
59
|
* @param options - Options
|
|
57
60
|
* @returns Signature
|
|
61
|
+
* @deprecated use AccountBase:signDelegation in Ceres
|
|
58
62
|
*/
|
|
59
63
|
// TODO: make abstract in the next major release
|
|
60
64
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -64,6 +68,21 @@ export default class AccountBase {
|
|
|
64
68
|
throw new NotImplementedError('signNameDelegationToContract method');
|
|
65
69
|
}
|
|
66
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Sign delegation of all AENS names to a contract (not available in Iris)
|
|
73
|
+
* @param contractAddress - Address of a contract to delegate permissions to
|
|
74
|
+
* @param options - Options
|
|
75
|
+
* @returns Signature
|
|
76
|
+
* @deprecated use AccountBase:signDelegation in Ceres
|
|
77
|
+
*/
|
|
78
|
+
// TODO: make abstract in the next major release
|
|
79
|
+
// eslint-disable-next-line class-methods-use-this
|
|
80
|
+
async signAllNamesDelegationToContract( /* eslint-disable @typescript-eslint/no-unused-vars */
|
|
81
|
+
contractAddress, options
|
|
82
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */) {
|
|
83
|
+
throw new NotImplementedError('signAllNamesDelegationToContract method');
|
|
84
|
+
}
|
|
85
|
+
|
|
67
86
|
/**
|
|
68
87
|
* Sign delegation of oracle query to a contract
|
|
69
88
|
*
|
|
@@ -77,6 +96,7 @@ export default class AccountBase {
|
|
|
77
96
|
* @param oracleQueryId - Oracle query ID to reply by a contract
|
|
78
97
|
* @param options - Options
|
|
79
98
|
* @returns Signature
|
|
99
|
+
* @deprecated use AccountBase:signDelegation in Ceres
|
|
80
100
|
*/
|
|
81
101
|
// TODO: make abstract in the next major release
|
|
82
102
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -96,5 +116,19 @@ export default class AccountBase {
|
|
|
96
116
|
/**
|
|
97
117
|
* Account address
|
|
98
118
|
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Sign delegation, works only in Ceres
|
|
122
|
+
* @param delegation - Delegation to sign
|
|
123
|
+
* @param options - Options
|
|
124
|
+
* @returns Signature
|
|
125
|
+
*/
|
|
126
|
+
// TODO: make abstract in the next major release
|
|
127
|
+
// eslint-disable-next-line class-methods-use-this
|
|
128
|
+
async signDelegation( /* eslint-disable @typescript-eslint/no-unused-vars */
|
|
129
|
+
delegation, options
|
|
130
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */) {
|
|
131
|
+
throw new NotImplementedError('signDelegation method');
|
|
132
|
+
}
|
|
99
133
|
}
|
|
100
134
|
//# sourceMappingURL=Base.mjs.map
|
package/es/account/Base.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base.mjs","names":["NotImplementedError","AccountBase","signTypedData","data","aci","options","signDelegationToContract","contractAddress","signNameDelegationToContract","name","signOracleQueryDelegationToContract","oracleQueryId"],"sources":["../../src/account/Base.ts"],"sourcesContent":["import { Encoded } from '../utils/encoder';\nimport Node from '../Node';\nimport CompilerBase from '../contract/compiler/Base';\nimport { AensName, Int } from '../tx/builder/constants';\nimport { AciValue, Domain } from '../utils/typed-data';\nimport { NotImplementedError } from '../utils/errors';\n\ninterface AuthData {\n fee?: Int;\n gasLimit?: number;\n gasPrice?: Int;\n callData?: Encoded.ContractBytearray;\n sourceCode?: string;\n args?: any[];\n}\n\n/**\n * Account is one of the three basic building blocks of an\n * {@link AeSdk} and provides access to a signing key pair.\n */\nexport default abstract class AccountBase {\n /**\n * Sign encoded transaction\n * @param tx - Transaction to sign\n * @param options - Options\n * @param options.innerTx - Sign as inner transaction for PayingFor\n * @param options.authData - Object with gaMeta params\n * @returns Signed transaction\n */\n abstract signTransaction(\n tx: Encoded.Transaction,\n options: {\n innerTx?: boolean;\n networkId?: string;\n authData?: AuthData | ((tx: Encoded.Transaction) => Promise<AuthData>);\n onNode?: Node;\n onCompiler?: CompilerBase;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Encoded.Transaction>;\n\n /**\n * Sign message\n * @param message - Message to sign\n * @param options - Options\n * @returns Signature\n */\n abstract signMessage(\n message: string,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Sign typed data\n * @param
|
|
1
|
+
{"version":3,"file":"Base.mjs","names":["NotImplementedError","AccountBase","signTypedData","data","aci","options","signDelegationToContract","contractAddress","signNameDelegationToContract","name","signAllNamesDelegationToContract","signOracleQueryDelegationToContract","oracleQueryId","signDelegation","delegation"],"sources":["../../src/account/Base.ts"],"sourcesContent":["import { Encoded } from '../utils/encoder';\nimport Node from '../Node';\nimport CompilerBase from '../contract/compiler/Base';\nimport { AensName, ConsensusProtocolVersion, Int } from '../tx/builder/constants';\nimport { AciValue, Domain } from '../utils/typed-data';\nimport { NotImplementedError } from '../utils/errors';\n\ninterface AuthData {\n fee?: Int;\n gasLimit?: number;\n gasPrice?: Int;\n callData?: Encoded.ContractBytearray;\n sourceCode?: string;\n args?: any[];\n}\n\n/**\n * Account is one of the three basic building blocks of an\n * {@link AeSdk} and provides access to a signing key pair.\n */\nexport default abstract class AccountBase {\n /**\n * Sign encoded transaction\n * @param tx - Transaction to sign\n * @param options - Options\n * @param options.innerTx - Sign as inner transaction for PayingFor\n * @param options.authData - Object with gaMeta params\n * @returns Signed transaction\n */\n abstract signTransaction(\n tx: Encoded.Transaction,\n options: {\n innerTx?: boolean;\n networkId?: string;\n authData?: AuthData | ((tx: Encoded.Transaction) => Promise<AuthData>);\n onNode?: Node;\n onCompiler?: CompilerBase;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Encoded.Transaction>;\n\n /**\n * Sign message\n * @param message - Message to sign\n * @param options - Options\n * @returns Signature\n */\n abstract signMessage(\n message: string,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\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 * @returns Signature\n */\n // TODO: make abstract in the next major release\n // eslint-disable-next-line class-methods-use-this\n async signTypedData(\n /* eslint-disable @typescript-eslint/no-unused-vars */\n data: Encoded.ContractBytearray,\n aci: AciValue,\n options?: Domain & {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ): Promise<Encoded.Signature> {\n throw new NotImplementedError('signTypedData method');\n }\n\n /**\n * Sign delegation of AENS, oracle operations to a contract\n * @param contractAddress - Address of a contract to delegate permissions to\n * @param options - Options\n * @param options.isOracle - Use to generate an oracle delegation signature in Ceres, otherwise an\n * AENS preclaim delegation signature would be generated\n * @returns Signature\n * @deprecated use AccountBase:signDelegation in Ceres\n */\n // TODO: make abstract in the next major release\n // eslint-disable-next-line class-methods-use-this\n async signDelegationToContract(\n /* eslint-disable @typescript-eslint/no-unused-vars */\n contractAddress: Encoded.ContractAddress,\n options?: {\n networkId?: string;\n consensusProtocolVersion?: ConsensusProtocolVersion;\n isOracle?: boolean;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ): Promise<Encoded.Signature> {\n throw new NotImplementedError('signDelegationToContract method');\n }\n\n /**\n * Sign delegation of an AENS name to a contract\n * @param contractAddress - Address of a contract to delegate permissions to\n * @param name - AENS name to manage by a contract\n * @param options - Options\n * @returns Signature\n * @deprecated use AccountBase:signDelegation in Ceres\n */\n // TODO: make abstract in the next major release\n // eslint-disable-next-line class-methods-use-this\n async signNameDelegationToContract(\n /* eslint-disable @typescript-eslint/no-unused-vars */\n contractAddress: Encoded.ContractAddress,\n name: AensName,\n options?: {\n networkId?: string;\n consensusProtocolVersion?: ConsensusProtocolVersion;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ): Promise<Encoded.Signature> {\n throw new NotImplementedError('signNameDelegationToContract method');\n }\n\n /**\n * Sign delegation of all AENS names to a contract (not available in Iris)\n * @param contractAddress - Address of a contract to delegate permissions to\n * @param options - Options\n * @returns Signature\n * @deprecated use AccountBase:signDelegation in Ceres\n */\n // TODO: make abstract in the next major release\n // eslint-disable-next-line class-methods-use-this\n async signAllNamesDelegationToContract(\n /* eslint-disable @typescript-eslint/no-unused-vars */\n contractAddress: Encoded.ContractAddress,\n options?: {\n networkId?: string;\n consensusProtocolVersion?: ConsensusProtocolVersion;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ): Promise<Encoded.Signature> {\n throw new NotImplementedError('signAllNamesDelegationToContract method');\n }\n\n /**\n * Sign delegation of oracle query to a contract\n *\n * Warning! Implementations needs to ensure that decoded oracle query id is not equal to decoded\n * current account address unless https://github.com/aeternity/aesophia/issues/475 is fixed.\n *\n * Warning! Implementations needs to ensure that oracle query and contract exists unless\n * https://github.com/aeternity/aesophia/issues/474 is fixed.\n *\n * @param contractAddress - Address of a contract to delegate permissions to\n * @param oracleQueryId - Oracle query ID to reply by a contract\n * @param options - Options\n * @returns Signature\n * @deprecated use AccountBase:signDelegation in Ceres\n */\n // TODO: make abstract in the next major release\n // eslint-disable-next-line class-methods-use-this\n async signOracleQueryDelegationToContract(\n /* eslint-disable @typescript-eslint/no-unused-vars */\n contractAddress: Encoded.ContractAddress,\n oracleQueryId: Encoded.OracleQueryId,\n options?: {\n networkId?: string;\n consensusProtocolVersion?: ConsensusProtocolVersion;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ): Promise<Encoded.Signature> {\n throw new NotImplementedError('signOracleQueryDelegationToContract method');\n }\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signature\n */\n abstract sign(\n data: string | Uint8Array,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Account address\n */\n readonly address!: Encoded.AccountAddress;\n\n /**\n * Sign delegation, works only in Ceres\n * @param delegation - Delegation to sign\n * @param options - Options\n * @returns Signature\n */\n // TODO: make abstract in the next major release\n // eslint-disable-next-line class-methods-use-this\n async signDelegation(\n /* eslint-disable @typescript-eslint/no-unused-vars */\n delegation: Encoded.Bytearray,\n options?: {\n networkId?: string;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ): Promise<Encoded.Signature> {\n throw new NotImplementedError('signDelegation method');\n }\n}\n"],"mappings":"SAKSA,mBAAmB;AAW5B;AACA;AACA;AACA;AACA,eAAe,MAAeC,WAAW,CAAC;EACxC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;EAcE;AACF;AACA;AACA;AACA;AACA;;EASE;AACF;AACA;AACA;AACA;AACA;AACA;EACE;EACA;EACA,MAAMC,aAAaA,CAAA,CACjB;EACAC,IAA+B,EAC/BC,GAAa,EACbC;EAIA,uDAC4B;IAC5B,MAAM,IAAIL,mBAAmB,CAAC,sBAAsB,CAAC;EACvD;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE;EACA;EACA,MAAMM,wBAAwBA,CAAA,CAC5B;EACAC,eAAwC,EACxCF;EAOA,uDAC4B;IAC5B,MAAM,IAAIL,mBAAmB,CAAC,iCAAiC,CAAC;EAClE;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE;EACA;EACA,MAAMQ,4BAA4BA,CAAA,CAChC;EACAD,eAAwC,EACxCE,IAAc,EACdJ;EAMA,uDAC4B;IAC5B,MAAM,IAAIL,mBAAmB,CAAC,qCAAqC,CAAC;EACtE;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE;EACA;EACA,MAAMU,gCAAgCA,CAAA,CACpC;EACAH,eAAwC,EACxCF;EAMA,uDAC4B;IAC5B,MAAM,IAAIL,mBAAmB,CAAC,yCAAyC,CAAC;EAC1E;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE;EACA;EACA,MAAMW,mCAAmCA,CAAA,CACvC;EACAJ,eAAwC,EACxCK,aAAoC,EACpCP;EAMA,uDAC4B;IAC5B,MAAM,IAAIL,mBAAmB,CAAC,4CAA4C,CAAC;EAC7E;;EAEA;AACF;AACA;AACA;AACA;AACA;;EASE;AACF;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;EACE;EACA;EACA,MAAMa,cAAcA,CAAA,CAClB;EACAC,UAA6B,EAC7BT;EAKA,uDAC4B;IAC5B,MAAM,IAAIL,mBAAmB,CAAC,uBAAuB,CAAC;EACxD;AACF"}
|
|
@@ -15,6 +15,8 @@ export default class AccountGeneralized extends AccountBase {
|
|
|
15
15
|
signTypedData(): Promise<Encoded.Signature>;
|
|
16
16
|
signDelegationToContract(): Promise<Encoded.Signature>;
|
|
17
17
|
signNameDelegationToContract(): Promise<Encoded.Signature>;
|
|
18
|
+
signAllNamesDelegationToContract(): Promise<Encoded.Signature>;
|
|
18
19
|
signOracleQueryDelegationToContract(): Promise<Encoded.Signature>;
|
|
20
|
+
signDelegation(): Promise<Encoded.Signature>;
|
|
19
21
|
signTransaction(tx: Encoded.Transaction, { authData, onCompiler, onNode }: Parameters<AccountBase['signTransaction']>[1]): Promise<Encoded.Transaction>;
|
|
20
22
|
}
|
|
@@ -52,16 +52,25 @@ export default class AccountGeneralized extends AccountBase {
|
|
|
52
52
|
throw new NotImplementedError('signing delegation to contract using generalized account');
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// eslint-disable-next-line class-methods-use-this
|
|
56
|
+
async signAllNamesDelegationToContract() {
|
|
57
|
+
throw new NotImplementedError('signing delegation to contract using generalized account');
|
|
58
|
+
}
|
|
59
|
+
|
|
55
60
|
// eslint-disable-next-line class-methods-use-this
|
|
56
61
|
async signOracleQueryDelegationToContract() {
|
|
57
62
|
throw new NotImplementedError('signing delegation to contract using generalized account');
|
|
58
63
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
|
|
65
|
+
// eslint-disable-next-line class-methods-use-this
|
|
66
|
+
async signDelegation() {
|
|
67
|
+
throw new NotImplementedError('signing delegation using generalized account');
|
|
68
|
+
}
|
|
69
|
+
async signTransaction(tx, {
|
|
70
|
+
authData,
|
|
71
|
+
onCompiler,
|
|
72
|
+
onNode
|
|
73
|
+
}) {
|
|
65
74
|
if (authData == null || onCompiler == null || onNode == null) {
|
|
66
75
|
throw new ArgumentError('authData, onCompiler, onNode', 'provided', null);
|
|
67
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Generalized.mjs","names":["AccountBase","ArgumentError","InternalError","InvalidAuthDataError","NotImplementedError","decode","getAccount","Contract","buildTxAsync","buildTx","Tag","_authFun","WeakMap","AccountGeneralized","constructor","address","_classPrivateFieldInitSpec","writable","value","sign","signMessage","signTypedData","signDelegationToContract","signNameDelegationToContract","signOracleQueryDelegationToContract","
|
|
1
|
+
{"version":3,"file":"Generalized.mjs","names":["AccountBase","ArgumentError","InternalError","InvalidAuthDataError","NotImplementedError","decode","getAccount","Contract","buildTxAsync","buildTx","Tag","_authFun","WeakMap","AccountGeneralized","constructor","address","_classPrivateFieldInitSpec","writable","value","sign","signMessage","signTypedData","signDelegationToContract","signNameDelegationToContract","signAllNamesDelegationToContract","signOracleQueryDelegationToContract","signDelegation","signTransaction","tx","authData","onCompiler","onNode","callData","sourceCode","args","fee","gasLimit","gasPrice","authCallData","_classPrivateFieldGet","account","kind","_classPrivateFieldSet","authFun","contract","initialize","_calldata","encode","_name","gaMetaTx","tag","GaMetaTx","SignedTx","encodedTx","signatures","gaId"],"sources":["../../src/account/Generalized.ts"],"sourcesContent":["import AccountBase from './Base';\nimport {\n ArgumentError,\n InternalError,\n InvalidAuthDataError,\n NotImplementedError,\n} from '../utils/errors';\nimport { decode, Encoded } from '../utils/encoder';\nimport { getAccount } from '../chain';\nimport Contract from '../contract/Contract';\nimport { buildTxAsync, buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\n\n/**\n * Generalized account class\n */\nexport default class AccountGeneralized extends AccountBase {\n override readonly address: Encoded.AccountAddress;\n\n #authFun?: string;\n\n /**\n * @param address - Address of generalized account\n */\n constructor(address: Encoded.AccountAddress) {\n super();\n decode(address);\n this.address = address;\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('Can\\'t sign using generalized account');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signMessage(): Promise<Uint8Array> {\n throw new NotImplementedError('Can\\'t sign using generalized account');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signTypedData(): Promise<Encoded.Signature> {\n throw new NotImplementedError('Can\\'t sign using generalized account');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using generalized account');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signNameDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using generalized account');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signAllNamesDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using generalized account');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signOracleQueryDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using generalized account');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signDelegation(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation using generalized account');\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n { authData, onCompiler, onNode }: Parameters<AccountBase['signTransaction']>[1],\n ): Promise<Encoded.Transaction> {\n if (authData == null || onCompiler == null || onNode == null) {\n throw new ArgumentError('authData, onCompiler, onNode', 'provided', null);\n }\n const {\n callData, sourceCode, args, fee, gasLimit, gasPrice,\n } = typeof authData === 'function' ? await authData(tx) : authData;\n\n const authCallData = callData ?? await (async () => {\n if (this.#authFun == null) {\n const account = await getAccount(this.address, { onNode });\n if (account.kind !== 'generalized') {\n throw new ArgumentError('account kind', 'generalized', account.kind);\n }\n this.#authFun = account.authFun;\n }\n if (this.#authFun == null) {\n throw new InternalError('Account in generalised, but authFun not provided');\n }\n\n if (sourceCode == null || args == null) {\n throw new InvalidAuthDataError('Auth data must contain sourceCode and args or callData.');\n }\n const contract = await Contract.initialize({ onCompiler, onNode, sourceCode });\n return contract._calldata.encode(contract._name, this.#authFun, args);\n })();\n\n const gaMetaTx = await buildTxAsync({\n tag: Tag.GaMetaTx,\n tx: { tag: Tag.SignedTx, encodedTx: decode(tx), signatures: [] },\n gaId: this.address,\n authData: authCallData,\n fee,\n gasLimit,\n gasPrice,\n onNode,\n });\n return buildTx({ tag: Tag.SignedTx, encodedTx: decode(gaMetaTx), signatures: [] });\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SAEhBC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB;AAAA,SAEZC,MAAM;AAAA,SACNC,UAAU;AAAA,OACZC,QAAQ;AAAA,SACNC,YAAY,EAAEC,OAAO;AAAA,SACrBC,GAAG;AAEZ;AACA;AACA;AAFA,IAAAC,QAAA,oBAAAC,OAAA;AAGA,eAAe,MAAMC,kBAAkB,SAASb,WAAW,CAAC;EAK1D;AACF;AACA;EACEc,WAAWA,CAACC,OAA+B,E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AG,EAAExC,GAAG,CAAC0C,QAAQ;QAAEC,SAAS,EAAEhD,MAAM,CAACuB,EAAE,CAAC;QAAE0B,UAAU,EAAE;MAAG,CAAC;MAChEC,IAAI,EAAE,IAAI,CAACxC,OAAO;MAClBc,QAAQ,EAAES,YAAY;MACtBH,GAAG;MACHC,QAAQ;MACRC,QAAQ;MACRN;IACF,CAAC,CAAC;IACF,OAAOtB,OAAO,CAAC;MAAEyC,GAAG,EAAExC,GAAG,CAAC0C,QAAQ;MAAEC,SAAS,EAAEhD,MAAM,CAAC4C,QAAQ,CAAC;MAAEK,UAAU,EAAE;IAAG,CAAC,CAAC;EACpF;AACF"}
|
package/es/account/Ledger.d.ts
CHANGED
|
@@ -23,7 +23,9 @@ export default class AccountLedger extends AccountBase {
|
|
|
23
23
|
signTypedData(): Promise<Encoded.Signature>;
|
|
24
24
|
signDelegationToContract(): Promise<Encoded.Signature>;
|
|
25
25
|
signNameDelegationToContract(): Promise<Encoded.Signature>;
|
|
26
|
+
signAllNamesDelegationToContract(): Promise<Encoded.Signature>;
|
|
26
27
|
signOracleQueryDelegationToContract(): Promise<Encoded.Signature>;
|
|
28
|
+
signDelegation(): Promise<Encoded.Signature>;
|
|
27
29
|
signTransaction(tx: Encoded.Transaction, { innerTx, networkId }?: {
|
|
28
30
|
innerTx?: boolean;
|
|
29
31
|
networkId?: string;
|
package/es/account/Ledger.mjs
CHANGED
|
@@ -51,15 +51,24 @@ export default class AccountLedger extends AccountBase {
|
|
|
51
51
|
throw new NotImplementedError('signing delegation to contract using Ledger HW');
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
// eslint-disable-next-line class-methods-use-this
|
|
55
|
+
async signAllNamesDelegationToContract() {
|
|
56
|
+
throw new NotImplementedError('signing delegation to contract using Ledger HW');
|
|
57
|
+
}
|
|
58
|
+
|
|
54
59
|
// eslint-disable-next-line class-methods-use-this
|
|
55
60
|
async signOracleQueryDelegationToContract() {
|
|
56
61
|
throw new NotImplementedError('signing delegation to contract using Ledger HW');
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
|
|
64
|
+
// eslint-disable-next-line class-methods-use-this
|
|
65
|
+
async signDelegation() {
|
|
66
|
+
throw new NotImplementedError('signing delegation using Ledger HW');
|
|
67
|
+
}
|
|
68
|
+
async signTransaction(tx, {
|
|
69
|
+
innerTx,
|
|
70
|
+
networkId
|
|
71
|
+
} = {}) {
|
|
63
72
|
if (innerTx != null) throw new NotImplementedError('innerTx option in AccountLedger');
|
|
64
73
|
if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
|
|
65
74
|
const rawTx = decode(tx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ledger.mjs","names":["AccountBase","ArgumentError","NotImplementedError","decode","buildTx","Tag","CLA","GET_ADDRESS","SIGN_TRANSACTION","GET_APP_CONFIGURATION","SIGN_PERSONAL_MESSAGE","AccountLedger","constructor","transport","index","address","scrambleKey","decorateAppAPIMethods","sign","signTypedData","signDelegationToContract","signNameDelegationToContract","signOracleQueryDelegationToContract","signTransaction","tx","innerTx","networkId","arguments","length","undefined","rawTx","offset","headerLength","networkIdBuffer","_Buffer","from","toSend","maxChunkSize","chunkSize","buffer","alloc","bufferOffset","writeUInt32BE","writeUInt8","copy","push","response","reduce","previous","data","i","send","Promise","resolve","signatures","subarray","tag","SignedTx","encodedTx","signMessage","messageStr","message"],"sources":["../../src/account/Ledger.ts"],"sourcesContent":["import type Transport from '@ledgerhq/hw-transport';\nimport AccountBase from './Base';\nimport { ArgumentError, NotImplementedError } from '../utils/errors';\nimport { decode, Encoded } from '../utils/encoder';\nimport { buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\n\nexport const CLA = 0xe0;\nexport const GET_ADDRESS = 0x02;\nexport const SIGN_TRANSACTION = 0x04;\nexport const GET_APP_CONFIGURATION = 0x06;\nexport const SIGN_PERSONAL_MESSAGE = 0x08;\n\n/**\n * Ledger wallet account class\n */\nexport default class AccountLedger extends AccountBase {\n readonly transport: Transport;\n\n override readonly address: Encoded.AccountAddress;\n\n readonly index: number;\n\n /**\n * @param transport - Connection to Ledger to use\n * @param index - Index of account\n * @param address - Address of account\n */\n constructor(transport: Transport, index: number, address: Encoded.AccountAddress) {\n super();\n this.transport = transport;\n this.index = index;\n this.address = address;\n const scrambleKey = 'w0w';\n transport.decorateAppAPIMethods(this, ['signTransaction', 'signMessage'], scrambleKey);\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signTypedData(): Promise<Encoded.Signature> {\n throw new NotImplementedError('Typed data signing using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signNameDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signOracleQueryDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using Ledger HW');\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId }: { innerTx?: boolean; networkId?: string } = {},\n ): Promise<Encoded.Transaction> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountLedger');\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n\n const rawTx = decode(tx);\n let offset = 0;\n const headerLength = 4 + 1 + 4;\n const networkIdBuffer = Buffer.from(networkId);\n const toSend = [];\n while (offset !== rawTx.length) {\n const maxChunkSize = offset === 0 ? 150 - headerLength - networkIdBuffer.length : 150;\n const chunkSize = offset + maxChunkSize > rawTx.length\n ? rawTx.length - offset : maxChunkSize;\n const buffer = Buffer.alloc(\n offset === 0 ? headerLength + networkIdBuffer.length + chunkSize : chunkSize,\n );\n if (offset === 0) {\n let bufferOffset = buffer.writeUInt32BE(this.index, 0);\n bufferOffset = buffer.writeUInt32BE(rawTx.length, bufferOffset);\n bufferOffset = buffer.writeUInt8(networkIdBuffer.length, bufferOffset);\n bufferOffset += networkIdBuffer.copy(\n buffer,\n bufferOffset,\n 0,\n networkIdBuffer.length,\n );\n rawTx.copy(buffer, bufferOffset, 0, 150 - bufferOffset);\n } else {\n rawTx.copy(buffer, 0, offset, offset + chunkSize);\n }\n toSend.push(buffer);\n offset += chunkSize;\n }\n const response = await toSend.reduce(\n async (previous, data, i) => {\n await previous;\n return this.transport.send(\n CLA,\n SIGN_TRANSACTION,\n i === 0 ? 0x00 : 0x80,\n 0x00,\n data,\n );\n },\n Promise.resolve(Buffer.alloc(0)),\n );\n const signatures = [response.subarray(0, 64)];\n\n return buildTx({ tag: Tag.SignedTx, encodedTx: rawTx, signatures });\n }\n\n override async signMessage(messageStr: string): Promise<Uint8Array> {\n let offset = 0;\n const message = Buffer.from(messageStr);\n const toSend = [];\n while (offset !== message.length) {\n const maxChunkSize = offset === 0 ? 150 - 4 - 4 : 150;\n const chunkSize = offset + maxChunkSize > message.length\n ? message.length - offset : maxChunkSize;\n const buffer = Buffer.alloc(offset === 0 ? 4 + 4 + chunkSize : chunkSize);\n if (offset === 0) {\n buffer.writeUInt32BE(this.index, 0);\n buffer.writeUInt32BE(message.length, 4);\n message.copy(buffer, 4 + 4, offset, offset + chunkSize);\n } else {\n message.copy(buffer, 0, offset, offset + chunkSize);\n }\n toSend.push(buffer);\n offset += chunkSize;\n }\n const response = await toSend.reduce(\n async (previous, data, i) => {\n await previous;\n return this.transport.send(\n CLA,\n SIGN_PERSONAL_MESSAGE,\n i === 0 ? 0x00 : 0x80,\n 0x00,\n data,\n );\n },\n Promise.resolve(Buffer.alloc(0)),\n );\n return response.subarray(0, 64);\n }\n}\n"],"mappings":";;;;OACOA,WAAW;AAAA,SACTC,aAAa,EAAEC,m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AAC;EACjC;AACF"}
|
|
1
|
+
{"version":3,"file":"Ledger.mjs","names":["AccountBase","ArgumentError","NotImplementedError","decode","buildTx","Tag","CLA","GET_ADDRESS","SIGN_TRANSACTION","GET_APP_CONFIGURATION","SIGN_PERSONAL_MESSAGE","AccountLedger","constructor","transport","index","address","scrambleKey","decorateAppAPIMethods","sign","signTypedData","signDelegationToContract","signNameDelegationToContract","signAllNamesDelegationToContract","signOracleQueryDelegationToContract","signDelegation","signTransaction","tx","innerTx","networkId","rawTx","offset","headerLength","networkIdBuffer","_Buffer","from","toSend","length","maxChunkSize","chunkSize","buffer","alloc","bufferOffset","writeUInt32BE","writeUInt8","copy","push","response","reduce","previous","data","i","send","Promise","resolve","signatures","subarray","tag","SignedTx","encodedTx","signMessage","messageStr","message"],"sources":["../../src/account/Ledger.ts"],"sourcesContent":["import type Transport from '@ledgerhq/hw-transport';\nimport AccountBase from './Base';\nimport { ArgumentError, NotImplementedError } from '../utils/errors';\nimport { decode, Encoded } from '../utils/encoder';\nimport { buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\n\nexport const CLA = 0xe0;\nexport const GET_ADDRESS = 0x02;\nexport const SIGN_TRANSACTION = 0x04;\nexport const GET_APP_CONFIGURATION = 0x06;\nexport const SIGN_PERSONAL_MESSAGE = 0x08;\n\n/**\n * Ledger wallet account class\n */\nexport default class AccountLedger extends AccountBase {\n readonly transport: Transport;\n\n override readonly address: Encoded.AccountAddress;\n\n readonly index: number;\n\n /**\n * @param transport - Connection to Ledger to use\n * @param index - Index of account\n * @param address - Address of account\n */\n constructor(transport: Transport, index: number, address: Encoded.AccountAddress) {\n super();\n this.transport = transport;\n this.index = index;\n this.address = address;\n const scrambleKey = 'w0w';\n transport.decorateAppAPIMethods(this, ['signTransaction', 'signMessage'], scrambleKey);\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signTypedData(): Promise<Encoded.Signature> {\n throw new NotImplementedError('Typed data signing using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signNameDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signAllNamesDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signOracleQueryDelegationToContract(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation to contract using Ledger HW');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signDelegation(): Promise<Encoded.Signature> {\n throw new NotImplementedError('signing delegation using Ledger HW');\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId }: { innerTx?: boolean; networkId?: string } = {},\n ): Promise<Encoded.Transaction> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountLedger');\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n\n const rawTx = decode(tx);\n let offset = 0;\n const headerLength = 4 + 1 + 4;\n const networkIdBuffer = Buffer.from(networkId);\n const toSend = [];\n while (offset !== rawTx.length) {\n const maxChunkSize = offset === 0 ? 150 - headerLength - networkIdBuffer.length : 150;\n const chunkSize = offset + maxChunkSize > rawTx.length\n ? rawTx.length - offset : maxChunkSize;\n const buffer = Buffer.alloc(\n offset === 0 ? headerLength + networkIdBuffer.length + chunkSize : chunkSize,\n );\n if (offset === 0) {\n let bufferOffset = buffer.writeUInt32BE(this.index, 0);\n bufferOffset = buffer.writeUInt32BE(rawTx.length, bufferOffset);\n bufferOffset = buffer.writeUInt8(networkIdBuffer.length, bufferOffset);\n bufferOffset += networkIdBuffer.copy(\n buffer,\n bufferOffset,\n 0,\n networkIdBuffer.length,\n );\n rawTx.copy(buffer, bufferOffset, 0, 150 - bufferOffset);\n } else {\n rawTx.copy(buffer, 0, offset, offset + chunkSize);\n }\n toSend.push(buffer);\n offset += chunkSize;\n }\n const response = await toSend.reduce(\n async (previous, data, i) => {\n await previous;\n return this.transport.send(\n CLA,\n SIGN_TRANSACTION,\n i === 0 ? 0x00 : 0x80,\n 0x00,\n data,\n );\n },\n Promise.resolve(Buffer.alloc(0)),\n );\n const signatures = [response.subarray(0, 64)];\n\n return buildTx({ tag: Tag.SignedTx, encodedTx: rawTx, signatures });\n }\n\n override async signMessage(messageStr: string): Promise<Uint8Array> {\n let offset = 0;\n const message = Buffer.from(messageStr);\n const toSend = [];\n while (offset !== message.length) {\n const maxChunkSize = offset === 0 ? 150 - 4 - 4 : 150;\n const chunkSize = offset + maxChunkSize > message.length\n ? message.length - offset : maxChunkSize;\n const buffer = Buffer.alloc(offset === 0 ? 4 + 4 + chunkSize : chunkSize);\n if (offset === 0) {\n buffer.writeUInt32BE(this.index, 0);\n buffer.writeUInt32BE(message.length, 4);\n message.copy(buffer, 4 + 4, offset, offset + chunkSize);\n } else {\n message.copy(buffer, 0, offset, offset + chunkSize);\n }\n toSend.push(buffer);\n offset += chunkSize;\n }\n const response = await toSend.reduce(\n async (previous, data, i) => {\n await previous;\n return this.transport.send(\n CLA,\n SIGN_PERSONAL_MESSAGE,\n i === 0 ? 0x00 : 0x80,\n 0x00,\n data,\n );\n },\n Promise.resolve(Buffer.alloc(0)),\n );\n return response.subarray(0, 64);\n }\n}\n"],"mappings":";;;;OACOA,WAAW;AAAA,SACTC,aAAa,EAAEC,mBAAmB;AAAA,SAClCC,MAAM;AAAA,SACNC,OAAO;AAAA,SACPC,GAAG;AAEZ,OAAO,MAAMC,GAAG,GAAG,IAAI;AACvB,OAAO,MAAMC,WAAW,GAAG,IAAI;AAC/B,OAAO,MAAMC,gBAAgB,GAAG,IAAI;AACpC,OAAO,MAAMC,qBAAqB,GAAG,IAAI;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or(transport) {
|
|
16
16
|
this.transport = transport;
|
|
17
|
-
this.versionCheckPromise = this.getAppConfiguration().then(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} = _ref;
|
|
17
|
+
this.versionCheckPromise = this.getAppConfiguration().then(({
|
|
18
|
+
version
|
|
19
|
+
}) => {
|
|
21
20
|
const args = [version, '0.4.4', '0.5.0'];
|
|
22
21
|
if (!semverSatisfies(...args)) throw new UnsupportedVersionError('app on ledger', ...args);
|
|
23
22
|
});
|
|
@@ -41,8 +40,7 @@ export default class AccountLedgerFactory {
|
|
|
41
40
|
* @param accountIndex - Index of account
|
|
42
41
|
* @param verify - Ask user to confirm address by showing it on the device screen
|
|
43
42
|
*/
|
|
44
|
-
async getAddress(accountIndex) {
|
|
45
|
-
let verify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
43
|
+
async getAddress(accountIndex, verify = false) {
|
|
46
44
|
await this.versionCheckPromise;
|
|
47
45
|
const buffer = _Buffer.alloc(4);
|
|
48
46
|
buffer.writeUInt32BE(accountIndex, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LedgerFactory.mjs","names":["AccountLedger","CLA","GET_ADDRESS","GET_APP_CONFIGURATION","UnsupportedVersionError","semverSatisfies","AccountLedgerFactory","constructor","transport","versionCheckPromise","getAppConfiguration","then","
|
|
1
|
+
{"version":3,"file":"LedgerFactory.mjs","names":["AccountLedger","CLA","GET_ADDRESS","GET_APP_CONFIGURATION","UnsupportedVersionError","semverSatisfies","AccountLedgerFactory","constructor","transport","versionCheckPromise","getAppConfiguration","then","version","args","scrambleKey","decorateAppAPIMethods","response","send","join","getAddress","accountIndex","verify","buffer","_Buffer","alloc","writeUInt32BE","addressLength","subarray","toString","initialize","discover","node","index","result","account","push","getAccountByPubkey","address"],"sources":["../../src/account/LedgerFactory.ts"],"sourcesContent":["import type Transport from '@ledgerhq/hw-transport';\nimport AccountLedger, { CLA, GET_ADDRESS, GET_APP_CONFIGURATION } from './Ledger';\nimport { UnsupportedVersionError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\nimport semverSatisfies from '../utils/semver-satisfies';\nimport Node from '../Node';\n\n/**\n * A factory class that generates instances of AccountLedger based on provided transport.\n */\nexport default class AccountLedgerFactory {\n readonly transport: Transport;\n\n private readonly versionCheckPromise: Promise<void>;\n\n /**\n * @param transport - Connection to Ledger to use\n */\n constructor(transport: Transport) {\n this.transport = transport;\n this.versionCheckPromise = this.getAppConfiguration().then(({ version }) => {\n const args = [version, '0.4.4', '0.5.0'] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError('app on ledger', ...args);\n });\n const scrambleKey = 'w0w';\n transport.decorateAppAPIMethods(this, ['getAddress', 'getAppConfiguration'], scrambleKey);\n }\n\n /**\n * @returns the version of app installed on Ledger wallet\n */\n async getAppConfiguration(): Promise<{ version: string }> {\n await this.versionCheckPromise;\n const response = await this.transport.send(CLA, GET_APP_CONFIGURATION, 0x00, 0x00);\n return {\n version: [response[1], response[2], response[3]].join('.'),\n };\n }\n\n /**\n * Get `ak_`-prefixed address for a given account index.\n * @param accountIndex - Index of account\n * @param verify - Ask user to confirm address by showing it on the device screen\n */\n async getAddress(accountIndex: number, verify = false): Promise<Encoded.AccountAddress> {\n await this.versionCheckPromise;\n const buffer = Buffer.alloc(4);\n buffer.writeUInt32BE(accountIndex, 0);\n const response = await this.transport.send(\n CLA,\n GET_ADDRESS,\n verify ? 0x01 : 0x00,\n 0x00,\n buffer,\n );\n const addressLength = response[0];\n return response.subarray(1, 1 + addressLength).toString('ascii') as Encoded.AccountAddress;\n }\n\n /**\n * Get an instance of AccountLedger for a given account index.\n * @param accountIndex - Index of account\n */\n async initialize(accountIndex: number): Promise<AccountLedger> {\n await this.versionCheckPromise;\n return new AccountLedger(this.transport, accountIndex, await this.getAddress(accountIndex));\n }\n\n /**\n * Discovers accounts on Ledger that already have been used (has any on-chain transactions).\n * It returns an empty array if none of accounts been used.\n * If a used account is preceded by an unused account then it would be ignored.\n * @param node - Instance of Node to get account information from\n */\n async discover(node: Node): Promise<AccountLedger[]> {\n let index = 0;\n const result = [];\n let account;\n do {\n if (account != null) result.push(account);\n account = await this.initialize(index);\n index += 1;\n } while (await node.getAccountByPubkey(account.address).then(() => true, () => false));\n return result;\n }\n}\n"],"mappings":";;;;OACOA,aAAa,IAAIC,GAAG,EAAEC,WAAW,EAAEC,qBAAqB;AAAA,SACtDC,uBAAuB;AAAA,OAEzBC,eAAe;AAGtB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,CAAC;EAKxC;AACF;AACA;EACEC,WAAWA,CAACC,SAAoB,EAAE;IAChC,IAAI,CAACA,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,mBAAmB,GAAG,IAAI,CAACC,mBAAmB,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC;MAAEC;IAAQ,CAAC,KAAK;MAC1E,MAAMC,IAAI,GAAG,CAACD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAU;MACjD,IAAI,CAACP,eAAe,CAAC,GAAGQ,IAAI,CAAC,EAAE,MAAM,IAAIT,uBAAuB,CAAC,eAAe,EAAE,GAAGS,IAAI,CAAC;IAC5F,CAAC,CAAC;IACF,MAAMC,WAAW,GAAG,KAAK;IACzBN,SAAS,CAACO,qBAAqB,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,qBAAqB,CAAC,EAAED,WAAW,CAAC;EAC3F;;EAEA;AACF;AACA;EACE,MAAMJ,mBAAmBA,CAAA,EAAiC;IACxD,MAAM,IAAI,CAACD,mBAAmB;IAC9B,MAAMO,QAAQ,GAAG,MAAM,IAAI,CAACR,SAAS,CAACS,IAAI,CAAChB,GAAG,EAAEE,qBAAqB,EAAE,IAAI,EAAE,IAAI,CAAC;IAClF,OAAO;MACLS,OAAO,EAAE,CAACI,QAAQ,CAAC,CAAC,CAAC,EAAEA,QAAQ,CAAC,CAAC,CAAC,EAAEA,QAAQ,CAAC,CAAC,CAAC,CAAC,CAACE,I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I,CAAC,MAAM,IAAI,EAAE,MAAM,KAAK,CAAC;IACrF,OAAOsB,MAAM;EACf;AACF"}
|
package/es/account/Memory.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AccountBase from './Base';
|
|
2
2
|
import { Encoded } from '../utils/encoder';
|
|
3
3
|
import { AciValue } from '../utils/typed-data';
|
|
4
|
-
import { AensName } from '../tx/builder/constants';
|
|
4
|
+
import { AensName, ConsensusProtocolVersion } from '../tx/builder/constants';
|
|
5
5
|
export declare function getBufferToSign(transaction: Encoded.Transaction, networkId: string, innerTx: boolean): Uint8Array;
|
|
6
6
|
/**
|
|
7
7
|
* In-memory account class
|
|
@@ -23,13 +23,24 @@ export default class AccountMemory extends AccountBase {
|
|
|
23
23
|
}): Promise<Encoded.Transaction>;
|
|
24
24
|
signMessage(message: string, options?: any): Promise<Uint8Array>;
|
|
25
25
|
signTypedData(data: Encoded.ContractBytearray, aci: AciValue, { name, version, networkId, contractAddress, ...options }?: Parameters<AccountBase['signTypedData']>[2]): Promise<Encoded.Signature>;
|
|
26
|
-
signDelegationToContract(contractAddress: Encoded.ContractAddress, { networkId }?: {
|
|
26
|
+
signDelegationToContract(contractAddress: Encoded.ContractAddress, { networkId, consensusProtocolVersion, isOracle }?: {
|
|
27
27
|
networkId?: string;
|
|
28
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
29
|
+
isOracle?: boolean;
|
|
28
30
|
}): Promise<Encoded.Signature>;
|
|
29
|
-
signNameDelegationToContract(contractAddress: Encoded.ContractAddress, name: AensName, { networkId }?: {
|
|
31
|
+
signNameDelegationToContract(contractAddress: Encoded.ContractAddress, name: AensName, { networkId, consensusProtocolVersion }?: {
|
|
30
32
|
networkId?: string;
|
|
33
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
31
34
|
}): Promise<Encoded.Signature>;
|
|
32
|
-
|
|
35
|
+
signAllNamesDelegationToContract(contractAddress: Encoded.ContractAddress, { networkId, consensusProtocolVersion }?: {
|
|
36
|
+
networkId?: string;
|
|
37
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
38
|
+
}): Promise<Encoded.Signature>;
|
|
39
|
+
signOracleQueryDelegationToContract(contractAddress: Encoded.ContractAddress, oracleQueryId: Encoded.OracleQueryId, { networkId, consensusProtocolVersion }?: {
|
|
40
|
+
networkId?: string;
|
|
41
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
42
|
+
}): Promise<Encoded.Signature>;
|
|
43
|
+
signDelegation(delegation: Encoded.Bytearray, { networkId }?: {
|
|
33
44
|
networkId?: string;
|
|
34
45
|
}): Promise<Encoded.Signature>;
|
|
35
46
|
}
|