@aeternity/aepp-sdk 13.2.1 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/bin/aesophia_cli +0 -0
- package/bin/aesophia_cli_8 +0 -0
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +7288 -9464
- 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.d.ts +1 -1
- package/es/Middleware.mjs +32 -28
- 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 +11 -3
- package/es/Node.mjs +65 -57
- 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.d.ts +2 -5
- package/es/aepp-wallet-communication/wallet-detector.mjs +13 -9
- 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 +10 -2
- package/es/contract/Contract.mjs +83 -79
- 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 +12 -11
- package/es/contract/compiler/Cli.mjs +52 -25
- 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 +48 -0
- package/es/deprecated.mjs +66 -1
- package/es/deprecated.mjs.map +1 -1
- package/es/index-browser.d.ts +11 -6
- package/es/index-browser.mjs +10 -6
- 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 +6 -5
- package/es/tx/builder/constants.mjs +7 -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.d.ts +1 -1
- package/es/tx/builder/field-types/ct-version.mjs +4 -5
- 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 +57 -39
- 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 +53 -4
- 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 +41 -25
- 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 +9 -5
- package/es/utils/crypto.mjs +18 -14
- 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.d.ts +0 -2
- package/es/utils/typed-data.mjs +8 -23
- 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 +17 -9
- package/src/MiddlewareSubscriber.ts +1 -1
- package/src/Node.ts +51 -21
- 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 +14 -1
- package/src/aepp-wallet-communication/schema.ts +2 -0
- package/src/aepp-wallet-communication/wallet-detector.ts +10 -10
- 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 +36 -12
- package/src/contract/compiler/Base.ts +15 -8
- package/src/contract/compiler/Cli.ts +44 -23
- 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 +55 -1
- package/src/index-browser.ts +18 -11
- 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 +7 -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/ct-version.ts +1 -1
- package/src/tx/builder/field-types/entry.ts +1 -4
- package/src/tx/builder/field-types/fee.ts +72 -44
- package/src/tx/builder/field-types/gas-limit.ts +4 -4
- package/src/tx/builder/field-types/gas-price.ts +59 -3
- 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 +37 -28
- package/src/utils/crypto.ts +24 -14
- 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/typed-data.ts +4 -30
- 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/Middleware.d.ts +1 -1
- package/types-legacy/ts4.2/Node.d.ts +15 -2
- 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/aepp-wallet-communication/wallet-detector.d.ts +2 -5
- 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 +10 -2
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +14 -8
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +12 -11
- 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 +48 -0
- package/types-legacy/ts4.2/index-browser.d.ts +11 -6
- 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 +6 -5
- 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/ct-version.d.ts +1 -1
- 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 +9 -5
- 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/typed-data.d.ts +0 -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/Middleware.d.ts +1 -1
- package/types-legacy/ts4.5/Node.d.ts +15 -2
- 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/aepp-wallet-communication/wallet-detector.d.ts +2 -5
- 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 +10 -2
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +14 -8
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +12 -11
- 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 +48 -0
- package/types-legacy/ts4.5/index-browser.d.ts +11 -6
- 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 +6 -5
- 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/ct-version.d.ts +1 -1
- 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 +9 -5
- 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/typed-data.d.ts +0 -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
|
@@ -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,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;AACzC,OAAO,MAAMC,qBAAqB,GAAG,IAAI;;AAEzC;AACA;AACA;AACA,eAAe,MAAMC,aAAa,SAASX,WAAW,CAAC;EAOrD;AACF;AACA;AACA;AACA;EACEY,WAAWA,CAACC,SAAoB,EAAEC,KAAa,EAAEC,OAA+B,EAAE;IAChF,KAAK,CAAC,CAAC;IACP,IAAI,CAACF,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,OAAO,GAAGA,OAAO;IACtB,MAAMC,WAAW,GAAG,KAAK;IACzBH,SAAS,CAACI,qBAAqB,CAAC,IAAI,EAAE,CAAC,iBAAiB,EAA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OAAO,CAACjB,IAAI,CAACL,MAAM,EAAE,CAAC,EAAER,MAAM,EAAEA,MAAM,GAAGO,SAAS,CAAC;MACrD;MACAF,MAAM,CAACS,IAAI,CAACN,MAAM,CAAC;MACnBR,MAAM,IAAIO,SAAS;IACrB;IACA,MAAMQ,QAAQ,GAAG,MAAMV,MAAM,CAACW,MAAM,CAClC,OAAOC,QAAQ,EAAEC,IAAI,EAAEC,CAAC,KAAK;MAC3B,MAAMF,QAAQ;MACd,OAAO,IAAI,CAACnC,SAAS,CAACsC,IAAI,CACxB7C,GAAG,EACHI,qBAAqB,EACrBwC,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,EACrB,IAAI,EACJD,IACF,CAAC;IACH,CAAC,EACDG,OAAO,CAACC,OAAO,CAACnB,OAAA,CAAOM,KAAK,CAAC,CAAC,CAAC,CACjC,CAAC;IACD,OAAOM,QAAQ,CAACS,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;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;AACzC,OAAO,MAAMC,qBAAqB,GAAG,IAAI;;AAEzC;AACA;AACA;AACA,eAAe,MAAMC,aAAa,SAASX,WAAW,CAAC;EAOrD;AACF;AACA;AACA;AACA;EACEY,WAAWA,CAACC,SAAoB,EAAEC,KAAa,EAAEC,OAA+B,EAAE;IAChF,KAAK,CAAC,CAAC;IACP,IAAI,CAACF,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,OAAO,GAAGA,OAAO;IACtB,MAAMC,WAAW,GAAG,KAAK;IACzBH,SAAS,CAACI,qBAAqB,CAAC,IAAI,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC,EAAED,WAAW,CAAC;EACxF;;EAEA;EACA,MAAeE,IAAIA,CAAA,EAAwB;IACzC,MAAM,IAAIhB,mBAAmB,CAAC,6BAA6B,CAAC;EAC9D;;EAEA;EACA,MAAeiB,aAAaA,CAAA,EAA+B;IACzD,MAAM,IAAIjB,mBAAmB,CAAC,oCAAoC,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MACAH,MAAM,CAACU,IAAI,CAACN,MAAM,CAAC;MACnBT,MAAM,IAAIQ,SAAS;IACrB;IACA,MAAMQ,QAAQ,GAAG,MAAMX,MAAM,CAACY,MAAM,CAClC,OAAOC,QAAQ,EAAEC,IAAI,EAAEC,CAAC,KAAK;MAC3B,MAAMF,QAAQ;MACd,OAAO,IAAI,CAACnC,SAAS,CAACsC,IAAI,CACxB7C,GAAG,EACHI,qBAAqB,EACrBwC,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,EACrB,IAAI,EACJD,IACF,CAAC;IACH,CAAC,EACDG,OAAO,CAACC,OAAO,CAACpB,OAAA,CAAOO,KAAK,CAAC,CAAC,CAAC,CACjC,CAAC;IACD,OAAOM,QAAQ,CAACS,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;EACjC;AACF"}
|
|
@@ -14,10 +14,9 @@ export default class AccountLedgerFactory {
|
|
|
14
14
|
*/
|
|
15
15
|
constructor(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,eA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AAUA,CAACT,YAAoB,EAA0B;IAC7D,MAAM,IAAI,CAACX,mBAAmB;IAC9B,OAAO,IAAIT,aAAa,CAAC,IAAI,CAACQ,SAAS,EAAEY,YAAY,EAAE,MAAM,IAAI,CAACD,UAAU,CAACC,YAAY,CAAC,CAAC;EAC7F;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAMU,QAAQA,CAACC,IAAU,EAA4B;IACnD,IAAIC,KAAK,GAAG,CAAC;IACb,MAAMC,MAAM,GAAG,EAAE;IACjB,IAAIC,OAAO;IACX,GAAG;MACD,IAAIA,OAAO,IAAI,IAAI,EAAED,MAAM,CAACE,IAAI,CAACD,OAAO,CAAC;MACzCA,OAAO,GAAG,MAAM,IAAI,CAACL,UAAU,CAACG,KAAK,CAAC;MACtCA,KAAK,IAAI,CAAC;IACZ,CAAC,QAAQ,MAAMD,IAAI,CAACK,kBAAkB,CAACF,OAAO,CAACG,OAAO,CAAC,CAAC1B,IAAI,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
|
}
|
package/es/account/Memory.mjs
CHANGED
|
@@ -3,14 +3,16 @@ const {
|
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
5
|
import AccountBase from "./Base.mjs";
|
|
6
|
-
import { generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash } from "../utils/crypto.mjs";
|
|
7
|
-
import { ArgumentError } from "../utils/errors.mjs";
|
|
6
|
+
import { generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash, messagePrefixLength } from "../utils/crypto.mjs";
|
|
7
|
+
import { ArgumentError, UnexpectedTsError } from "../utils/errors.mjs";
|
|
8
8
|
import { decode, encode, Encoding } from "../utils/encoder.mjs";
|
|
9
9
|
import { concatBuffers } from "../utils/other.mjs";
|
|
10
10
|
import { hashTypedData } from "../utils/typed-data.mjs";
|
|
11
11
|
import { buildTx } from "../tx/builder/index.mjs";
|
|
12
|
-
import { Tag } from "../tx/builder/constants.mjs";
|
|
12
|
+
import { Tag, ConsensusProtocolVersion } from "../tx/builder/constants.mjs";
|
|
13
13
|
import { produceNameId } from "../tx/builder/helpers.mjs";
|
|
14
|
+
import { DelegationTag } from "../tx/builder/delegation/schema.mjs";
|
|
15
|
+
import { packDelegation } from "../tx/builder/delegation/index.mjs";
|
|
14
16
|
const secretKeys = new WeakMap();
|
|
15
17
|
export function getBufferToSign(transaction, networkId, innerTx) {
|
|
16
18
|
const prefixes = [networkId];
|
|
@@ -33,7 +35,7 @@ export default class AccountMemory extends AccountBase {
|
|
|
33
35
|
throw new ArgumentError('secretKey', '64 bytes', secretKey.length);
|
|
34
36
|
}
|
|
35
37
|
secretKeys.set(this, secretKey);
|
|
36
|
-
this.address = encode(generateKeyPairFromSecret(
|
|
38
|
+
this.address = encode(generateKeyPairFromSecret(secretKey).publicKey, Encoding.AccountAddress);
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/**
|
|
@@ -45,14 +47,15 @@ export default class AccountMemory extends AccountBase {
|
|
|
45
47
|
|
|
46
48
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
47
49
|
async sign(data, options) {
|
|
48
|
-
|
|
50
|
+
const secretKey = secretKeys.get(this);
|
|
51
|
+
if (secretKey == null) throw new UnexpectedTsError();
|
|
52
|
+
return sign(data, secretKey);
|
|
49
53
|
}
|
|
50
|
-
async signTransaction(transaction
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
54
|
+
async signTransaction(transaction, {
|
|
55
|
+
innerTx,
|
|
56
|
+
networkId,
|
|
57
|
+
...options
|
|
58
|
+
} = {}) {
|
|
56
59
|
if (networkId == null) {
|
|
57
60
|
throw new ArgumentError('networkId', 'provided', networkId);
|
|
58
61
|
}
|
|
@@ -68,14 +71,13 @@ export default class AccountMemory extends AccountBase {
|
|
|
68
71
|
async signMessage(message, options) {
|
|
69
72
|
return this.sign(messageToHash(message), options);
|
|
70
73
|
}
|
|
71
|
-
async signTypedData(data, aci
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
74
|
+
async signTypedData(data, aci, {
|
|
75
|
+
name,
|
|
76
|
+
version,
|
|
77
|
+
networkId,
|
|
78
|
+
contractAddress,
|
|
79
|
+
...options
|
|
80
|
+
} = {}) {
|
|
79
81
|
const dHash = hashTypedData(data, aci, {
|
|
80
82
|
name,
|
|
81
83
|
version,
|
|
@@ -85,28 +87,83 @@ export default class AccountMemory extends AccountBase {
|
|
|
85
87
|
const signature = await this.sign(dHash, options);
|
|
86
88
|
return encode(signature, Encoding.Signature);
|
|
87
89
|
}
|
|
88
|
-
async signDelegationToContract(contractAddress
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
async signDelegationToContract(contractAddress, {
|
|
91
|
+
networkId,
|
|
92
|
+
consensusProtocolVersion,
|
|
93
|
+
isOracle
|
|
94
|
+
} = {}) {
|
|
95
|
+
if (isOracle == null) {
|
|
96
|
+
const protocol = consensusProtocolVersion != null ? ConsensusProtocolVersion[consensusProtocolVersion] : 'unknown';
|
|
97
|
+
console.warn(`AccountMemory:signDelegationToContract: isOracle is not set. By default, sdk would generate an AENS preclaim delegation signature, but it won't be the same as the oracle delegation signature in Ceres (current protocol is ${protocol}).`);
|
|
98
|
+
}
|
|
99
|
+
if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
|
|
100
|
+
const delegation = packDelegation({
|
|
101
|
+
tag: isOracle === true ? DelegationTag.Oracle : DelegationTag.AensPreclaim,
|
|
102
|
+
accountAddress: this.address,
|
|
103
|
+
contractAddress
|
|
104
|
+
});
|
|
105
|
+
return this.signDelegation(delegation, {
|
|
106
|
+
networkId
|
|
107
|
+
});
|
|
108
|
+
}
|
|
92
109
|
if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
|
|
93
110
|
const payload = concatBuffers([_Buffer.from(networkId), decode(this.address), decode(contractAddress)]);
|
|
94
111
|
const signature = await this.sign(payload);
|
|
95
112
|
return encode(signature, Encoding.Signature);
|
|
96
113
|
}
|
|
97
|
-
async signNameDelegationToContract(contractAddress, name
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
114
|
+
async signNameDelegationToContract(contractAddress, name, {
|
|
115
|
+
networkId,
|
|
116
|
+
consensusProtocolVersion
|
|
117
|
+
} = {}) {
|
|
118
|
+
if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
|
|
119
|
+
const delegation = packDelegation({
|
|
120
|
+
tag: DelegationTag.AensName,
|
|
121
|
+
accountAddress: this.address,
|
|
122
|
+
contractAddress,
|
|
123
|
+
nameId: name
|
|
124
|
+
});
|
|
125
|
+
return this.signDelegation(delegation, {
|
|
126
|
+
networkId
|
|
127
|
+
});
|
|
128
|
+
}
|
|
101
129
|
if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
|
|
102
130
|
const payload = concatBuffers([_Buffer.from(networkId), decode(this.address), decode(produceNameId(name)), decode(contractAddress)]);
|
|
103
131
|
const signature = await this.sign(payload);
|
|
104
132
|
return encode(signature, Encoding.Signature);
|
|
105
133
|
}
|
|
106
|
-
async
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
134
|
+
async signAllNamesDelegationToContract(contractAddress, {
|
|
135
|
+
networkId,
|
|
136
|
+
consensusProtocolVersion
|
|
137
|
+
} = {}) {
|
|
138
|
+
if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
|
|
139
|
+
const delegation = packDelegation({
|
|
140
|
+
tag: DelegationTag.AensWildcard,
|
|
141
|
+
accountAddress: this.address,
|
|
142
|
+
contractAddress
|
|
143
|
+
});
|
|
144
|
+
return this.signDelegation(delegation, {
|
|
145
|
+
networkId
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
|
|
149
|
+
const payload = concatBuffers([_Buffer.from(networkId), decode(this.address), _Buffer.from('AENS'), decode(contractAddress)]);
|
|
150
|
+
const signature = await this.sign(payload);
|
|
151
|
+
return encode(signature, Encoding.Signature);
|
|
152
|
+
}
|
|
153
|
+
async signOracleQueryDelegationToContract(contractAddress, oracleQueryId, {
|
|
154
|
+
networkId,
|
|
155
|
+
consensusProtocolVersion
|
|
156
|
+
} = {}) {
|
|
157
|
+
if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
|
|
158
|
+
const delegation = packDelegation({
|
|
159
|
+
tag: DelegationTag.OracleResponse,
|
|
160
|
+
queryId: oracleQueryId,
|
|
161
|
+
contractAddress
|
|
162
|
+
});
|
|
163
|
+
return this.signDelegation(delegation, {
|
|
164
|
+
networkId
|
|
165
|
+
});
|
|
166
|
+
}
|
|
110
167
|
const oracleQueryIdDecoded = decode(oracleQueryId);
|
|
111
168
|
const addressDecoded = decode(this.address);
|
|
112
169
|
// TODO: remove after fixing https://github.com/aeternity/aesophia/issues/475
|
|
@@ -118,5 +175,13 @@ export default class AccountMemory extends AccountBase {
|
|
|
118
175
|
const signature = await this.sign(payload);
|
|
119
176
|
return encode(signature, Encoding.Signature);
|
|
120
177
|
}
|
|
178
|
+
async signDelegation(delegation, {
|
|
179
|
+
networkId
|
|
180
|
+
} = {}) {
|
|
181
|
+
if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
|
|
182
|
+
const payload = concatBuffers([messagePrefixLength, new Uint8Array([1]), _Buffer.from(networkId), decode(delegation)]);
|
|
183
|
+
const signature = await this.sign(payload);
|
|
184
|
+
return encode(signature, Encoding.Signature);
|
|
185
|
+
}
|
|
121
186
|
}
|
|
122
187
|
//# sourceMappingURL=Memory.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Memory.mjs","names":["AccountBase","generateKeyPairFromSecret","sign","generateKeyPair","hash","messageToHash","ArgumentError","decode","encode","Encoding","concatBuffers","hashTypedData","buildTx","Tag","produceNameId","secretKeys","WeakMap","getBufferToSign","transaction","networkId","innerTx","prefixes","push","rlpBinaryTx","_Buffer","from","join","AccountMemory","constructor","secretKey","length","set","address","get","publicKey","AccountAddress","generate","data","options","signTransaction","arguments","undefined","txWithNetworkId","signatures","tag","SignedTx","encodedTx","signMessage","message","signTypedData","aci","name","version","contractAddress","dHash","signature","Signature","signDelegationToContract","payload","signNameDelegationToContract","signOracleQueryDelegationToContract","oracleQueryId","oracleQueryIdDecoded","addressDecoded","compare"],"sources":["../../src/account/Memory.ts"],"sourcesContent":["import AccountBase from './Base';\nimport {\n generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash,\n} from '../utils/crypto';\nimport { ArgumentError } from '../utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../utils/encoder';\nimport { concatBuffers } from '../utils/other';\nimport { hashTypedData, AciValue } from '../utils/typed-data';\nimport { buildTx } from '../tx/builder';\nimport { Tag, AensName } from '../tx/builder/constants';\nimport { produceNameId } from '../tx/builder/helpers';\n\nconst secretKeys = new WeakMap();\n\nexport function getBufferToSign(\n transaction: Encoded.Transaction,\n networkId: string,\n innerTx: boolean,\n): Uint8Array {\n const prefixes = [networkId];\n if (innerTx) prefixes.push('inner_tx');\n const rlpBinaryTx = decode(transaction);\n return concatBuffers([Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);\n}\n\n/**\n * In-memory account class\n */\nexport default class AccountMemory extends AccountBase {\n override readonly address: Encoded.AccountAddress;\n\n /**\n * @param secretKey - Secret key\n */\n constructor(secretKey: string | Uint8Array) {\n super();\n secretKey = typeof secretKey === 'string' ? Buffer.from(secretKey, 'hex') : secretKey;\n if (secretKey.length !== 64) {\n throw new ArgumentError('secretKey', '64 bytes', secretKey.length);\n }\n secretKeys.set(this, secretKey);\n this.address = encode(\n generateKeyPairFromSecret(secretKeys.get(this)).publicKey,\n Encoding.AccountAddress,\n );\n }\n\n /**\n * Generates a new AccountMemory using a random secret key\n */\n static generate(): AccountMemory {\n return new AccountMemory(generateKeyPair().secretKey);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override async sign(data: string | Uint8Array, options?: any): Promise<Uint8Array> {\n return sign(data, secretKeys.get(this));\n }\n\n override async signTransaction(\n transaction: Encoded.Transaction,\n { innerTx, networkId, ...options }: { innerTx?: boolean; networkId?: string } = {},\n ): Promise<Encoded.Transaction> {\n if (networkId == null) {\n throw new ArgumentError('networkId', 'provided', networkId);\n }\n const rlpBinaryTx = decode(transaction);\n const txWithNetworkId = getBufferToSign(transaction, networkId, innerTx === true);\n\n const signatures = [await this.sign(txWithNetworkId, options)];\n return buildTx({ tag: Tag.SignedTx, encodedTx: rlpBinaryTx, signatures });\n }\n\n override async signMessage(message: string, options?: any): Promise<Uint8Array> {\n return this.sign(messageToHash(message), options);\n }\n\n override async signTypedData(\n data: Encoded.ContractBytearray,\n aci: AciValue,\n {\n name, version, networkId, contractAddress, ...options\n }: Parameters<AccountBase['signTypedData']>[2] = {},\n ): Promise<Encoded.Signature> {\n const dHash = hashTypedData(data, aci, {\n name, version, networkId, contractAddress,\n });\n const signature = await this.sign(dHash, options);\n return encode(signature, Encoding.Signature);\n }\n\n override async signDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n { networkId }: { networkId?: string } = {},\n ): Promise<Encoded.Signature> {\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const payload = concatBuffers([\n Buffer.from(networkId),\n decode(this.address),\n decode(contractAddress),\n ]);\n const signature = await this.sign(payload);\n return encode(signature, Encoding.Signature);\n }\n\n override async signNameDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n name: AensName,\n { networkId }: { networkId?: string } = {},\n ): Promise<Encoded.Signature> {\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const payload = concatBuffers([\n Buffer.from(networkId),\n decode(this.address),\n decode(produceNameId(name)),\n decode(contractAddress),\n ]);\n const signature = await this.sign(payload);\n return encode(signature, Encoding.Signature);\n }\n\n override async signOracleQueryDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n oracleQueryId: Encoded.OracleQueryId,\n { networkId }: { networkId?: string } = {},\n ): Promise<Encoded.Signature> {\n const oracleQueryIdDecoded = decode(oracleQueryId);\n const addressDecoded = decode(this.address);\n // TODO: remove after fixing https://github.com/aeternity/aesophia/issues/475\n if (oracleQueryIdDecoded.compare(addressDecoded) === 0) {\n throw new ArgumentError('oracleQueryId', 'not equal to account address', oracleQueryId);\n }\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const payload = concatBuffers([\n Buffer.from(networkId),\n oracleQueryIdDecoded,\n decode(contractAddress),\n ]);\n const signature = await this.sign(payload);\n return encode(signature, Encoding.Signature);\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SAEhBC,yBAAyB,EAAEC,IAAI,EAAEC,eAAe,EAAEC,IAAI,EAAEC,aAAa;AAAA,SAE9DC,aAAa;AAAA,SAEpBC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,aAAa;AAAA,SACbC,aAAa;AAAA,SACbC,OAAO;AAAA,SACPC,GAAG;AAAA,SACHC,aAAa;AAEtB,MAAMC,UAAU,GAAG,IAAIC,OAAO,CAAC,CAAC;AAEhC,OAAO,SAASC,eAAeA,CAC7BC,WAAgC,EAChCC,SAAiB,EACjBC,OAAgB,EACJ;E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,CAACrD,IAAI,CAACwD,OAAO,CAAC;IAC1C,OAAOlD,MAAM,CAAC+C,SAAS,EAAE9C,QAAQ,CAAC+C,SAAS,CAAC;EAC9C;EAEA,MAAeI,mCAAmCA,CAChDP,eAAwC,EACxCQ,aAAoC,EAER;IAAA,IAD5B;MAAE1C;IAAkC,CAAC,GAAAqB,SAAA,CAAAV,MAAA,QAAAU,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,CAAC,CAAC;IAE1C,MAAMsB,oBAAoB,GAAGvD,MAAM,CAACsD,aAAa,CAAC;IAClD,MAAME,cAAc,GAAGxD,MAAM,CAAC,IAAI,CAACyB,OAAO,CAAC;IAC3C;IACA,IAAI8B,oBAAoB,CAACE,OAAO,CAACD,cAAc,CAAC,KAAK,CAAC,EAAE;MACtD,MAAM,IAAIzD,aAAa,CAAC,eAAe,EAAE,8BAA8B,EAAEuD,aAAa,CAAC;IACzF;IACA,IAAI1C,SAAS,IAAI,IAAI,EAAE,MAAM,IAAIb,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEa,SAAS,CAAC;IAClF,MAAMuC,OAAO,GAAGhD,aAAa,CAAC,CAC5Bc,OAAA,CAAOC,IAAI,CAACN,SAAS,CAAC,EACtB2C,oBAAoB,EACpBvD,MAAM,CAAC8C,eAAe,CAAC,CACxB,CAAC;IACF,MAAME,SAAS,GAAG,MAAM,IAAI,CAACrD,IAAI,CAACwD,OAAO,CAAC;IAC1C,OAAOlD,MAAM,CAAC+C,SAAS,EAAE9C,QAAQ,CAAC+C,SAAS,CAAC;EAC9C;AACF"}
|
|
1
|
+
{"version":3,"file":"Memory.mjs","names":["AccountBase","generateKeyPairFromSecret","sign","generateKeyPair","hash","messageToHash","messagePrefixLength","ArgumentError","UnexpectedTsError","decode","encode","Encoding","concatBuffers","hashTypedData","buildTx","Tag","ConsensusProtocolVersion","produceNameId","DelegationTag","packDelegation","secretKeys","WeakMap","getBufferToSign","transaction","networkId","innerTx","prefixes","push","rlpBinaryTx","_Buffer","from","join","AccountMemory","constructor","secretKey","length","set","address","publicKey","AccountAddress","generate","data","options","get","signTransaction","txWithNetworkId","signatures","tag","SignedTx","encodedTx","signMessage","message","signTypedData","aci","name","version","contractAddress","dHash","signature","Signature","signDelegationToContract","consensusProtocolVersion","isOracle","protocol","console","warn","Ceres","delegation","Oracle","AensPreclaim","accountAddress","signDelegation","payload","signNameDelegationToContract","AensName","nameId","signAllNamesDelegationToContract","AensWildcard","signOracleQueryDelegationToContract","oracleQueryId","OracleResponse","queryId","oracleQueryIdDecoded","addressDecoded","compare","Uint8Array"],"sources":["../../src/account/Memory.ts"],"sourcesContent":["import AccountBase from './Base';\nimport {\n generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash, messagePrefixLength,\n} from '../utils/crypto';\nimport { ArgumentError, UnexpectedTsError } from '../utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../utils/encoder';\nimport { concatBuffers } from '../utils/other';\nimport { hashTypedData, AciValue } from '../utils/typed-data';\nimport { buildTx } from '../tx/builder';\nimport { Tag, AensName, ConsensusProtocolVersion } from '../tx/builder/constants';\nimport { produceNameId } from '../tx/builder/helpers';\nimport { DelegationTag } from '../tx/builder/delegation/schema';\nimport { packDelegation } from '../tx/builder/delegation';\n\nconst secretKeys = new WeakMap<AccountMemory, Uint8Array>();\n\nexport function getBufferToSign(\n transaction: Encoded.Transaction,\n networkId: string,\n innerTx: boolean,\n): Uint8Array {\n const prefixes = [networkId];\n if (innerTx) prefixes.push('inner_tx');\n const rlpBinaryTx = decode(transaction);\n return concatBuffers([Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);\n}\n\n/**\n * In-memory account class\n */\nexport default class AccountMemory extends AccountBase {\n override readonly address: Encoded.AccountAddress;\n\n /**\n * @param secretKey - Secret key\n */\n constructor(secretKey: string | Uint8Array) {\n super();\n secretKey = typeof secretKey === 'string' ? Buffer.from(secretKey, 'hex') : secretKey;\n if (secretKey.length !== 64) {\n throw new ArgumentError('secretKey', '64 bytes', secretKey.length);\n }\n secretKeys.set(this, secretKey);\n this.address = encode(\n generateKeyPairFromSecret(secretKey).publicKey,\n Encoding.AccountAddress,\n );\n }\n\n /**\n * Generates a new AccountMemory using a random secret key\n */\n static generate(): AccountMemory {\n return new AccountMemory(generateKeyPair().secretKey);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override async sign(data: string | Uint8Array, options?: any): Promise<Uint8Array> {\n const secretKey = secretKeys.get(this);\n if (secretKey == null) throw new UnexpectedTsError();\n return sign(data, secretKey);\n }\n\n override async signTransaction(\n transaction: Encoded.Transaction,\n { innerTx, networkId, ...options }: { innerTx?: boolean; networkId?: string } = {},\n ): Promise<Encoded.Transaction> {\n if (networkId == null) {\n throw new ArgumentError('networkId', 'provided', networkId);\n }\n const rlpBinaryTx = decode(transaction);\n const txWithNetworkId = getBufferToSign(transaction, networkId, innerTx === true);\n\n const signatures = [await this.sign(txWithNetworkId, options)];\n return buildTx({ tag: Tag.SignedTx, encodedTx: rlpBinaryTx, signatures });\n }\n\n override async signMessage(message: string, options?: any): Promise<Uint8Array> {\n return this.sign(messageToHash(message), options);\n }\n\n override async signTypedData(\n data: Encoded.ContractBytearray,\n aci: AciValue,\n {\n name, version, networkId, contractAddress, ...options\n }: Parameters<AccountBase['signTypedData']>[2] = {},\n ): Promise<Encoded.Signature> {\n const dHash = hashTypedData(data, aci, {\n name, version, networkId, contractAddress,\n });\n const signature = await this.sign(dHash, options);\n return encode(signature, Encoding.Signature);\n }\n\n override async signDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n { networkId, consensusProtocolVersion, isOracle }: {\n networkId?: string;\n consensusProtocolVersion?: ConsensusProtocolVersion;\n isOracle?: boolean;\n } = {},\n ): Promise<Encoded.Signature> {\n if (isOracle == null) {\n const protocol = (consensusProtocolVersion != null) ? ConsensusProtocolVersion[consensusProtocolVersion] : 'unknown';\n console.warn(`AccountMemory:signDelegationToContract: isOracle is not set. By default, sdk would generate an AENS preclaim delegation signature, but it won't be the same as the oracle delegation signature in Ceres (current protocol is ${protocol}).`);\n }\n if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {\n const delegation = packDelegation({\n tag: isOracle === true ? DelegationTag.Oracle : DelegationTag.AensPreclaim,\n accountAddress: this.address,\n contractAddress,\n });\n return this.signDelegation(delegation, { networkId });\n }\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const payload = concatBuffers([\n Buffer.from(networkId),\n decode(this.address),\n decode(contractAddress),\n ]);\n const signature = await this.sign(payload);\n return encode(signature, Encoding.Signature);\n }\n\n override async signNameDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n name: AensName,\n { networkId, consensusProtocolVersion }: {\n networkId?: string;\n consensusProtocolVersion?: ConsensusProtocolVersion;\n } = {},\n ): Promise<Encoded.Signature> {\n if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {\n const delegation = packDelegation({\n tag: DelegationTag.AensName, accountAddress: this.address, contractAddress, nameId: name,\n });\n return this.signDelegation(delegation, { networkId });\n }\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const payload = concatBuffers([\n Buffer.from(networkId),\n decode(this.address),\n decode(produceNameId(name)),\n decode(contractAddress),\n ]);\n const signature = await this.sign(payload);\n return encode(signature, Encoding.Signature);\n }\n\n override async signAllNamesDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n { networkId, consensusProtocolVersion }: {\n networkId?: string;\n consensusProtocolVersion?: ConsensusProtocolVersion;\n } = {},\n ): Promise<Encoded.Signature> {\n if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {\n const delegation = packDelegation({\n tag: DelegationTag.AensWildcard, accountAddress: this.address, contractAddress,\n });\n return this.signDelegation(delegation, { networkId });\n }\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const payload = concatBuffers([\n Buffer.from(networkId),\n decode(this.address),\n Buffer.from('AENS'),\n decode(contractAddress),\n ]);\n const signature = await this.sign(payload);\n return encode(signature, Encoding.Signature);\n }\n\n override async signOracleQueryDelegationToContract(\n contractAddress: Encoded.ContractAddress,\n oracleQueryId: Encoded.OracleQueryId,\n { networkId, consensusProtocolVersion }: {\n networkId?: string;\n consensusProtocolVersion?: ConsensusProtocolVersion;\n } = {},\n ): Promise<Encoded.Signature> {\n if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {\n const delegation = packDelegation({\n tag: DelegationTag.OracleResponse, queryId: oracleQueryId, contractAddress,\n });\n return this.signDelegation(delegation, { networkId });\n }\n const oracleQueryIdDecoded = decode(oracleQueryId);\n const addressDecoded = decode(this.address);\n // TODO: remove after fixing https://github.com/aeternity/aesophia/issues/475\n if (oracleQueryIdDecoded.compare(addressDecoded) === 0) {\n throw new ArgumentError('oracleQueryId', 'not equal to account address', oracleQueryId);\n }\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const payload = concatBuffers([\n Buffer.from(networkId),\n oracleQueryIdDecoded,\n decode(contractAddress),\n ]);\n const signature = await this.sign(payload);\n return encode(signature, Encoding.Signature);\n }\n\n override async signDelegation(\n delegation: Encoded.Bytearray,\n { networkId }: { networkId?: string } = {},\n ): Promise<Encoded.Signature> {\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const payload = concatBuffers([\n messagePrefixLength, new Uint8Array([1]), Buffer.from(networkId), decode(delegation),\n ]);\n const signature = await this.sign(payload);\n return encode(signature, Encoding.Signature);\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SAEhBC,yBAAyB,EAAEC,IAAI,EAAEC,eAAe,EAAEC,IAAI,EAAEC,aAAa,EAAEC,mBAAmB;AAAA,SAEnFC,aAAa,EAAEC,iBAAiB;AAAA,SAEvCC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,aAAa;AAAA,SACbC,aAAa;AAAA,SACbC,OAAO;AAAA,SACPC,GAAG,EAAYC,wBAAwB;AAAA,SACvCC,aAAa;AAAA,SACbC,aAAa;AAAA,SACbC,cAAc;AAEvB,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AAS,IAAI,IAAI,EAAE,MAAM,IAAIjB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEiB,SAAS,CAAC;IAClF,MAAMgD,OAAO,GAAG5D,aAAa,CAAC,CAC5BiB,OAAA,CAAOC,IAAI,CAACN,SAAS,CAAC,EACtB0D,oBAAoB,EACpBzE,MAAM,CAAC+C,eAAe,CAAC,CACxB,CAAC;IACF,MAAME,SAAS,GAAG,MAAM,IAAI,CAACxD,IAAI,CAACsE,OAAO,CAAC;IAC1C,OAAO9D,MAAM,CAACgD,SAAS,EAAE/C,QAAQ,CAACgD,SAAS,CAAC;EAC9C;EAEA,MAAeY,cAAcA,CAC3BJ,UAA6B,EAC7B;IAAE3C;EAAkC,CAAC,GAAG,CAAC,CAAC,EACd;IAC5B,IAAIA,SAAS,IAAI,IAAI,EAAE,MAAM,IAAIjB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEiB,SAAS,CAAC;IAClF,MAAMgD,OAAO,GAAG5D,aAAa,CAAC,CAC5BN,mBAAmB,EAAE,IAAI+E,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAExD,OAAA,CAAOC,IAAI,CAACN,SAAS,CAAC,EAAEf,MAAM,CAAC0D,UAAU,CAAC,CACrF,CAAC;IACF,MAAMT,SAAS,GAAG,MAAM,IAAI,CAACxD,IAAI,CAACsE,OAAO,CAAC;IAC1C,OAAO9D,MAAM,CAACgD,SAAS,EAAE/C,QAAQ,CAACgD,SAAS,CAAC;EAC9C;AACF"}
|
package/es/account/Rpc.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import AccountBase from './Base';
|
|
|
2
2
|
import { Encoded } from '../utils/encoder';
|
|
3
3
|
import RpcClient from '../aepp-wallet-communication/rpc/RpcClient';
|
|
4
4
|
import { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types';
|
|
5
|
-
import { AensName } from '../tx/builder/constants';
|
|
5
|
+
import { AensName, ConsensusProtocolVersion } from '../tx/builder/constants';
|
|
6
6
|
/**
|
|
7
7
|
* Account provided by wallet
|
|
8
8
|
* @param params - Params
|
|
@@ -14,11 +14,22 @@ export default class AccountRpc extends AccountBase {
|
|
|
14
14
|
_rpcClient: RpcClient<WalletApi, AeppApi>;
|
|
15
15
|
readonly address: Encoded.AccountAddress;
|
|
16
16
|
constructor(rpcClient: RpcClient<WalletApi, AeppApi>, address: Encoded.AccountAddress);
|
|
17
|
-
sign(): Promise<Uint8Array>;
|
|
17
|
+
sign(dataRaw: string | Uint8Array): Promise<Uint8Array>;
|
|
18
18
|
signTransaction(tx: Encoded.Transaction, { innerTx, networkId }?: Parameters<AccountBase['signTransaction']>[1]): Promise<Encoded.Transaction>;
|
|
19
19
|
signMessage(message: string): Promise<Uint8Array>;
|
|
20
20
|
signTypedData(data: Encoded.ContractBytearray, aci: Parameters<AccountBase['signTypedData']>[1], { name, version, contractAddress, networkId, }?: Parameters<AccountBase['signTypedData']>[2]): Promise<Encoded.Signature>;
|
|
21
|
-
signDelegationToContract(contractAddress: Encoded.ContractAddress
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
signDelegationToContract(contractAddress: Encoded.ContractAddress, { consensusProtocolVersion, isOracle }?: {
|
|
22
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
23
|
+
isOracle?: boolean;
|
|
24
|
+
}): Promise<Encoded.Signature>;
|
|
25
|
+
signNameDelegationToContract(contractAddress: Encoded.ContractAddress, name: AensName, { consensusProtocolVersion }?: {
|
|
26
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
27
|
+
}): Promise<Encoded.Signature>;
|
|
28
|
+
signAllNamesDelegationToContract(contractAddress: Encoded.ContractAddress, { consensusProtocolVersion }?: {
|
|
29
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
30
|
+
}): Promise<Encoded.Signature>;
|
|
31
|
+
signOracleQueryDelegationToContract(contractAddress: Encoded.ContractAddress, oracleQueryId: Encoded.OracleQueryId, { consensusProtocolVersion }?: {
|
|
32
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
33
|
+
}): Promise<Encoded.Signature>;
|
|
34
|
+
signDelegation(delegation: Encoded.Bytearray): Promise<Encoded.Signature>;
|
|
24
35
|
}
|
package/es/account/Rpc.mjs
CHANGED
|
@@ -4,7 +4,11 @@ const {
|
|
|
4
4
|
} = _buffer;
|
|
5
5
|
import AccountBase from "./Base.mjs";
|
|
6
6
|
import { METHODS } from "../aepp-wallet-communication/schema.mjs";
|
|
7
|
-
import { ArgumentError,
|
|
7
|
+
import { ArgumentError, UnsupportedProtocolError } from "../utils/errors.mjs";
|
|
8
|
+
import { Encoding, decode, encode } from "../utils/encoder.mjs";
|
|
9
|
+
import { ConsensusProtocolVersion } from "../tx/builder/constants.mjs";
|
|
10
|
+
import { packDelegation } from "../tx/builder/delegation/index.mjs";
|
|
11
|
+
import { DelegationTag } from "../tx/builder/delegation/schema.mjs";
|
|
8
12
|
/**
|
|
9
13
|
* Account provided by wallet
|
|
10
14
|
* @param params - Params
|
|
@@ -18,16 +22,20 @@ export default class AccountRpc extends AccountBase {
|
|
|
18
22
|
this._rpcClient = rpcClient;
|
|
19
23
|
this.address = address;
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
async sign(dataRaw) {
|
|
26
|
+
const data = encode(_Buffer.from(dataRaw), Encoding.Bytearray);
|
|
27
|
+
const {
|
|
28
|
+
signature
|
|
29
|
+
} = await this._rpcClient.request(METHODS.unsafeSign, {
|
|
30
|
+
onAccount: this.address,
|
|
31
|
+
data
|
|
32
|
+
});
|
|
33
|
+
return decode(signature);
|
|
25
34
|
}
|
|
26
|
-
async signTransaction(tx
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
35
|
+
async signTransaction(tx, {
|
|
36
|
+
innerTx,
|
|
37
|
+
networkId
|
|
38
|
+
} = {}) {
|
|
31
39
|
if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
|
|
32
40
|
const res = await this._rpcClient.request(METHODS.sign, {
|
|
33
41
|
onAccount: this.address,
|
|
@@ -50,13 +58,12 @@ export default class AccountRpc extends AccountBase {
|
|
|
50
58
|
});
|
|
51
59
|
return _Buffer.from(signature, 'hex');
|
|
52
60
|
}
|
|
53
|
-
async signTypedData(data, aci
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
61
|
+
async signTypedData(data, aci, {
|
|
62
|
+
name,
|
|
63
|
+
version,
|
|
64
|
+
contractAddress,
|
|
65
|
+
networkId
|
|
66
|
+
} = {}) {
|
|
60
67
|
const {
|
|
61
68
|
signature
|
|
62
69
|
} = await this._rpcClient.request(METHODS.signTypedData, {
|
|
@@ -72,16 +79,43 @@ export default class AccountRpc extends AccountBase {
|
|
|
72
79
|
});
|
|
73
80
|
return signature;
|
|
74
81
|
}
|
|
75
|
-
async signDelegationToContract(contractAddress
|
|
82
|
+
async signDelegationToContract(contractAddress, {
|
|
83
|
+
consensusProtocolVersion,
|
|
84
|
+
isOracle
|
|
85
|
+
} = {}) {
|
|
86
|
+
if (isOracle == null) {
|
|
87
|
+
const protocol = consensusProtocolVersion != null ? ConsensusProtocolVersion[consensusProtocolVersion] : 'unknown';
|
|
88
|
+
console.warn(`AccountRpc:signDelegationToContract: isOracle is not set. By default, sdk would generate an AENS preclaim delegation signature, but it won't be the same as the oracle delegation signature in Ceres (current protocol is ${protocol}).`);
|
|
89
|
+
}
|
|
90
|
+
if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
|
|
91
|
+
const delegation = packDelegation({
|
|
92
|
+
tag: isOracle === true ? DelegationTag.Oracle : DelegationTag.AensPreclaim,
|
|
93
|
+
accountAddress: this.address,
|
|
94
|
+
contractAddress
|
|
95
|
+
});
|
|
96
|
+
return this.signDelegation(delegation);
|
|
97
|
+
}
|
|
76
98
|
const {
|
|
77
99
|
signature
|
|
78
100
|
} = await this._rpcClient.request(METHODS.signDelegationToContract, {
|
|
79
101
|
onAccount: this.address,
|
|
80
|
-
contractAddress
|
|
102
|
+
contractAddress,
|
|
103
|
+
isOracle
|
|
81
104
|
});
|
|
82
105
|
return signature;
|
|
83
106
|
}
|
|
84
|
-
async signNameDelegationToContract(contractAddress, name
|
|
107
|
+
async signNameDelegationToContract(contractAddress, name, {
|
|
108
|
+
consensusProtocolVersion
|
|
109
|
+
} = {}) {
|
|
110
|
+
if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
|
|
111
|
+
const delegation = packDelegation({
|
|
112
|
+
tag: DelegationTag.AensName,
|
|
113
|
+
accountAddress: this.address,
|
|
114
|
+
contractAddress,
|
|
115
|
+
nameId: name
|
|
116
|
+
});
|
|
117
|
+
return this.signDelegation(delegation);
|
|
118
|
+
}
|
|
85
119
|
const {
|
|
86
120
|
signature
|
|
87
121
|
} = await this._rpcClient.request(METHODS.signDelegationToContract, {
|
|
@@ -91,7 +125,37 @@ export default class AccountRpc extends AccountBase {
|
|
|
91
125
|
});
|
|
92
126
|
return signature;
|
|
93
127
|
}
|
|
94
|
-
async
|
|
128
|
+
async signAllNamesDelegationToContract(contractAddress, {
|
|
129
|
+
consensusProtocolVersion
|
|
130
|
+
} = {}) {
|
|
131
|
+
if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
|
|
132
|
+
const delegation = packDelegation({
|
|
133
|
+
tag: DelegationTag.AensWildcard,
|
|
134
|
+
accountAddress: this.address,
|
|
135
|
+
contractAddress
|
|
136
|
+
});
|
|
137
|
+
return this.signDelegation(delegation);
|
|
138
|
+
}
|
|
139
|
+
const {
|
|
140
|
+
signature
|
|
141
|
+
} = await this._rpcClient.request(METHODS.signDelegationToContract, {
|
|
142
|
+
onAccount: this.address,
|
|
143
|
+
contractAddress,
|
|
144
|
+
allNames: true
|
|
145
|
+
});
|
|
146
|
+
return signature;
|
|
147
|
+
}
|
|
148
|
+
async signOracleQueryDelegationToContract(contractAddress, oracleQueryId, {
|
|
149
|
+
consensusProtocolVersion
|
|
150
|
+
} = {}) {
|
|
151
|
+
if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
|
|
152
|
+
const delegation = packDelegation({
|
|
153
|
+
tag: DelegationTag.OracleResponse,
|
|
154
|
+
queryId: oracleQueryId,
|
|
155
|
+
contractAddress
|
|
156
|
+
});
|
|
157
|
+
return this.signDelegation(delegation);
|
|
158
|
+
}
|
|
95
159
|
const {
|
|
96
160
|
signature
|
|
97
161
|
} = await this._rpcClient.request(METHODS.signDelegationToContract, {
|
|
@@ -101,5 +165,14 @@ export default class AccountRpc extends AccountBase {
|
|
|
101
165
|
});
|
|
102
166
|
return signature;
|
|
103
167
|
}
|
|
168
|
+
async signDelegation(delegation) {
|
|
169
|
+
const {
|
|
170
|
+
signature
|
|
171
|
+
} = await this._rpcClient.request(METHODS.signDelegation, {
|
|
172
|
+
delegation,
|
|
173
|
+
onAccount: this.address
|
|
174
|
+
});
|
|
175
|
+
return signature;
|
|
176
|
+
}
|
|
104
177
|
}
|
|
105
178
|
//# sourceMappingURL=Rpc.mjs.map
|