@aeternity/aepp-sdk 12.1.3 → 13.0.0-alpha.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/bin/aesophia_cli +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 +12031 -11231
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +7 -3
- package/es/AeSdk.mjs +17 -22
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +6 -5
- package/es/AeSdkAepp.mjs +7 -30
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +18 -140
- package/es/AeSdkBase.mjs +30 -184
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +123 -0
- package/es/AeSdkMethods.mjs +122 -0
- package/es/AeSdkMethods.mjs.map +1 -0
- package/es/AeSdkWallet.d.ts +7 -21
- package/es/AeSdkWallet.mjs +38 -86
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +11 -15
- package/es/Node.mjs +35 -48
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +24 -40
- package/es/account/Base.mjs +1 -101
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.d.ts +16 -0
- package/es/account/Generalized.mjs +113 -0
- package/es/account/Generalized.mjs.map +1 -0
- package/es/account/Ledger.d.ts +28 -0
- package/es/account/Ledger.mjs +102 -0
- package/es/account/Ledger.mjs.map +1 -0
- package/es/account/LedgerFactory.d.ts +39 -0
- package/es/account/LedgerFactory.mjs +81 -0
- package/es/account/LedgerFactory.mjs.map +1 -0
- package/es/account/Memory.d.ts +13 -17
- package/es/account/Memory.mjs +43 -64
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +6 -8
- package/es/account/Rpc.mjs +14 -32
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +4 -4
- package/es/aens.mjs +46 -41
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +22 -11
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -42
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.mjs +14 -68
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.d.ts +23 -29
- package/es/apis/compiler/compiler.mjs +128 -189
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/index.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +82 -135
- package/es/apis/compiler/models/index.mjs +1 -47
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.d.ts +8 -8
- package/es/apis/compiler/models/mappers.mjs +165 -183
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/compiler/models/parameters.d.ts +0 -1
- package/es/apis/compiler/models/parameters.mjs +5 -9
- package/es/apis/compiler/models/parameters.mjs.map +1 -1
- package/es/apis/node/index.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +48 -48
- package/es/apis/node/models/mappers.mjs +12 -6
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/parameters.mjs.map +1 -1
- package/es/apis/node/node.mjs +43 -84
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +10 -2
- package/es/chain.mjs +37 -59
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +200 -0
- package/es/channel/Base.mjs +293 -0
- package/es/channel/Base.mjs.map +1 -0
- package/es/channel/Contract.d.ts +248 -0
- package/es/channel/Contract.mjs +420 -0
- package/es/channel/Contract.mjs.map +1 -0
- package/es/channel/Spend.d.ts +219 -0
- package/es/channel/Spend.mjs +385 -0
- package/es/channel/Spend.mjs.map +1 -0
- package/es/channel/handlers.d.ts +8 -21
- package/es/channel/handlers.mjs +151 -899
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +27 -21
- package/es/channel/internal.mjs +101 -191
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +210 -0
- package/es/contract/Contract.mjs +551 -0
- package/es/contract/Contract.mjs.map +1 -0
- package/es/contract/compiler/Base.d.ts +81 -0
- package/es/contract/compiler/Base.mjs +5 -0
- package/es/contract/compiler/Base.mjs.map +1 -0
- package/es/contract/compiler/Cli.d.ts +23 -0
- package/es/contract/compiler/Cli.mjs +155 -0
- package/es/contract/compiler/Cli.mjs.map +1 -0
- package/es/contract/compiler/Http.d.ts +32 -0
- package/es/contract/compiler/Http.mjs +118 -0
- package/es/contract/compiler/Http.mjs.map +1 -0
- package/es/contract/compiler/HttpNode.d.ts +17 -0
- package/es/contract/compiler/HttpNode.mjs +26 -0
- package/es/contract/compiler/HttpNode.mjs.map +1 -0
- package/es/contract/compiler/getFileSystem.d.ts +6 -0
- package/es/contract/compiler/getFileSystem.mjs +40 -0
- package/es/contract/compiler/getFileSystem.mjs.map +1 -0
- package/es/contract/ga.d.ts +9 -34
- package/es/contract/ga.mjs +29 -112
- package/es/contract/ga.mjs.map +1 -1
- package/es/index-browser.d.ts +39 -0
- package/es/index-browser.mjs +55 -0
- package/es/index-browser.mjs.map +1 -0
- package/es/index.d.ts +4 -35
- package/es/index.mjs +4 -51
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +5 -5
- package/es/oracle.mjs +34 -40
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +3 -3
- package/es/spend.mjs +18 -23
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/constants.d.ts +30 -2
- package/es/tx/builder/constants.mjs +43 -14
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.d.ts +10 -0
- package/es/tx/builder/field-types/abi-version.mjs +20 -0
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
- package/es/tx/builder/field-types/address.d.ts +14 -0
- package/es/tx/builder/field-types/address.mjs +51 -0
- package/es/tx/builder/field-types/address.mjs.map +1 -0
- package/es/tx/builder/field-types/array.d.ts +7 -0
- package/es/tx/builder/field-types/array.mjs +11 -0
- package/es/tx/builder/field-types/array.mjs.map +1 -0
- package/es/tx/builder/field-types/boolean.d.ts +6 -0
- package/es/tx/builder/field-types/boolean.mjs +13 -0
- package/es/tx/builder/field-types/boolean.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +2 -3
- package/es/tx/builder/field-types/coin-amount.mjs +4 -12
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.d.ts +30 -0
- package/es/tx/builder/field-types/ct-version.mjs +48 -0
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +1 -2
- package/es/tx/builder/field-types/deposit.mjs +2 -4
- package/es/tx/builder/field-types/deposit.mjs.map +1 -1
- package/es/tx/builder/field-types/encoded.d.ts +6 -0
- package/es/tx/builder/field-types/encoded.mjs +21 -0
- package/es/tx/builder/field-types/encoded.mjs.map +1 -0
- package/es/tx/builder/field-types/entry.d.ts +11 -0
- package/es/tx/builder/field-types/entry.mjs +31 -0
- package/es/tx/builder/field-types/entry.mjs.map +1 -0
- package/es/tx/builder/field-types/enumeration.d.ts +7 -0
- package/es/tx/builder/field-types/enumeration.mjs +30 -0
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +10 -15
- package/es/tx/builder/field-types/fee.mjs +31 -43
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/field.mjs +0 -2
- package/es/tx/builder/field-types/field.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.d.ts +5 -2
- package/es/tx/builder/field-types/gas-limit.mjs +12 -14
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +1 -2
- package/es/tx/builder/field-types/gas-price.mjs +3 -7
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +80 -30
- package/es/tx/builder/field-types/index.mjs +34 -9
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/mptree.d.ts +37 -0
- package/es/tx/builder/field-types/mptree.mjs +268 -0
- package/es/tx/builder/field-types/mptree.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +1 -3
- package/es/tx/builder/field-types/name-fee.mjs +3 -5
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/name-id.d.ts +1 -4
- package/es/tx/builder/field-types/name-id.mjs +5 -10
- package/es/tx/builder/field-types/name-id.mjs.map +1 -1
- package/es/tx/builder/field-types/name.mjs +0 -2
- package/es/tx/builder/field-types/name.mjs.map +1 -1
- package/es/tx/builder/field-types/pointers.d.ts +23 -0
- package/es/tx/builder/field-types/pointers.mjs +36 -0
- package/es/tx/builder/field-types/pointers.mjs.map +1 -0
- package/es/tx/builder/field-types/raw.d.ts +6 -0
- package/es/tx/builder/field-types/raw.mjs +13 -0
- package/es/tx/builder/field-types/raw.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int-const.d.ts +5 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs +16 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.mjs +0 -2
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/string.d.ts +6 -0
- package/es/tx/builder/field-types/string.mjs +10 -0
- package/es/tx/builder/field-types/string.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.d.ts +1 -2
- package/es/tx/builder/field-types/u-int.mjs +3 -4
- package/es/tx/builder/field-types/u-int.mjs.map +1 -1
- package/es/tx/builder/helpers.d.ts +2 -32
- package/es/tx/builder/helpers.mjs +19 -71
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +11 -49
- package/es/tx/builder/index.mjs +57 -337
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2367 -667
- package/es/tx/builder/schema.mjs +70 -145
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +4 -49
- package/es/tx/index.mjs +38 -112
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +4 -6
- package/es/tx/validator.mjs +104 -90
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
- package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
- package/es/utils/amount-formatter.mjs +4 -10
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +1 -0
- package/es/utils/autorest.mjs +17 -19
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bignumber.mjs +4 -7
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/utils/bytes.d.ts +0 -17
- package/es/utils/bytes.mjs +6 -35
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +15 -8
- package/es/utils/crypto.mjs +40 -40
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.d.ts +28 -28
- package/es/utils/encoder-types.mjs +0 -1
- package/es/utils/encoder-types.mjs.map +1 -1
- package/es/utils/encoder.d.ts +0 -1
- package/es/utils/encoder.mjs +7 -15
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +15 -14
- package/es/utils/errors.mjs +86 -172
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +27 -19
- package/es/utils/hd-wallet.mjs +42 -26
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs +0 -8
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.d.ts +2 -0
- package/es/utils/keystore.mjs +37 -36
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/other.d.ts +4 -2
- package/es/utils/other.mjs +11 -7
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.mjs +0 -3
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.d.ts +0 -12
- package/es/utils/string.mjs +1 -21
- package/es/utils/string.mjs.map +1 -1
- package/package.json +98 -51
- package/src/AeSdk.ts +15 -11
- package/src/AeSdkAepp.ts +9 -7
- package/src/AeSdkBase.ts +31 -202
- package/src/AeSdkMethods.ts +169 -0
- package/src/AeSdkWallet.ts +16 -47
- package/src/Node.ts +17 -18
- package/src/account/Base.ts +29 -75
- package/src/account/Generalized.ts +98 -0
- package/src/account/Ledger.ts +131 -0
- package/src/account/LedgerFactory.ts +86 -0
- package/src/account/Memory.ts +46 -60
- package/src/account/Rpc.ts +17 -26
- package/src/aens.ts +13 -11
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +21 -9
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -4
- package/src/aepp-wallet-communication/rpc/types.ts +11 -1
- package/src/aepp-wallet-communication/schema.ts +18 -18
- package/src/apis/compiler/code-model-v4.yaml +681 -888
- package/src/apis/compiler/compiler.ts +113 -154
- package/src/apis/compiler/models/index.ts +80 -140
- package/src/apis/compiler/models/mappers.ts +165 -183
- package/src/apis/compiler/models/parameters.ts +6 -12
- package/src/chain.ts +11 -6
- package/src/channel/Base.ts +335 -0
- package/src/channel/Contract.ts +488 -0
- package/src/channel/Spend.ts +408 -0
- package/src/channel/handlers.ts +164 -582
- package/src/channel/internal.ts +114 -143
- package/src/contract/Contract.ts +610 -0
- package/src/contract/compiler/Base.ts +94 -0
- package/src/contract/compiler/Cli.ts +134 -0
- package/src/contract/compiler/Http.ts +124 -0
- package/src/contract/compiler/HttpNode.ts +26 -0
- package/src/contract/compiler/getFileSystem.ts +42 -0
- package/src/contract/ga.ts +23 -106
- package/src/index-browser.ts +58 -0
- package/src/index.ts +4 -55
- package/src/oracle.ts +8 -8
- package/src/spend.ts +6 -14
- package/src/tx/builder/constants.ts +33 -3
- package/src/tx/builder/field-types/abi-version.ts +21 -0
- package/src/tx/builder/field-types/address.ts +62 -0
- package/src/tx/builder/field-types/array.ts +19 -0
- package/src/tx/builder/field-types/boolean.ts +9 -0
- package/src/tx/builder/field-types/coin-amount.ts +4 -9
- package/src/tx/builder/field-types/ct-version.ts +50 -0
- package/src/tx/builder/field-types/deposit.ts +1 -1
- package/src/tx/builder/field-types/encoded.ts +27 -0
- package/src/tx/builder/field-types/entry.ts +31 -0
- package/src/tx/builder/field-types/enumeration.ts +32 -0
- package/src/tx/builder/field-types/fee.ts +39 -21
- package/src/tx/builder/field-types/gas-limit.ts +13 -8
- package/src/tx/builder/field-types/gas-price.ts +0 -2
- package/src/tx/builder/field-types/index.ts +54 -15
- package/src/tx/builder/field-types/mptree.ts +242 -0
- package/src/tx/builder/field-types/name-fee.ts +2 -3
- package/src/tx/builder/field-types/name-id.ts +7 -10
- package/src/tx/builder/field-types/pointers.ts +41 -0
- package/src/tx/builder/field-types/raw.ts +9 -0
- package/src/tx/builder/field-types/short-u-int-const.ts +20 -0
- package/src/tx/builder/field-types/string.ts +11 -0
- package/src/tx/builder/field-types/u-int.ts +4 -5
- package/src/tx/builder/helpers.ts +10 -60
- package/src/tx/builder/index.ts +65 -308
- package/src/tx/builder/schema.ts +280 -341
- package/src/tx/index.ts +40 -103
- package/src/tx/validator.ts +91 -96
- package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
- package/src/utils/autorest.ts +16 -1
- package/src/utils/bytes.ts +6 -34
- package/src/utils/crypto.ts +23 -16
- package/src/utils/encoder.ts +0 -1
- package/src/utils/errors.ts +22 -25
- package/src/utils/hd-wallet.ts +30 -9
- package/src/utils/keystore.ts +24 -21
- package/src/utils/other.ts +16 -1
- package/src/utils/string.ts +0 -20
- package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
- package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
- package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +140 -0
- package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
- package/types-legacy/ts4.2/Node.d.ts +78 -0
- package/types-legacy/ts4.2/account/Base.d.ts +52 -0
- package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
- package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
- package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
- package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
- package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
- package/types-legacy/ts4.2/aens.d.ts +222 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
- package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
- package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
- package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
- package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
- package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
- package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
- package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
- package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
- package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
- package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
- package/types-legacy/ts4.2/chain.d.ts +256 -0
- package/types-legacy/ts4.2/channel/Base.d.ts +199 -0
- package/types-legacy/ts4.2/channel/Contract.d.ts +248 -0
- package/types-legacy/ts4.2/channel/Spend.d.ts +219 -0
- package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
- package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
- package/types-legacy/ts4.2/contract/Contract.d.ts +212 -0
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +81 -0
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +44 -0
- package/types-legacy/ts4.2/globals.d.ts +16 -0
- package/types-legacy/ts4.2/index-browser.d.ts +39 -0
- package/types-legacy/ts4.2/index.d.ts +5 -0
- package/types-legacy/ts4.2/oracle.d.ts +161 -0
- package/types-legacy/ts4.2/spend.d.ts +62 -0
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +98 -0
- package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +10 -0
- package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +21 -0
- package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
- package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +42 -0
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +20 -0
- package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +15 -0
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +129 -0
- package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +43 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +18 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
- package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
- package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +5 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +50 -0
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +4675 -0
- package/types-legacy/ts4.2/tx/index.d.ts +19 -0
- package/types-legacy/ts4.2/tx/validator.d.ts +18 -0
- package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
- package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
- package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
- package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
- package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
- package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
- package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
- package/types-legacy/ts4.2/utils/errors.d.ts +475 -0
- package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
- package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
- package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
- package/types-legacy/ts4.2/utils/other.d.ts +31 -0
- package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
- package/types-legacy/ts4.2/utils/string.d.ts +12 -0
- package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
- package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
- package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +140 -0
- package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
- package/types-legacy/ts4.5/Node.d.ts +78 -0
- package/types-legacy/ts4.5/account/Base.d.ts +52 -0
- package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
- package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
- package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
- package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
- package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
- package/types-legacy/ts4.5/aens.d.ts +222 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
- package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
- package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
- package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
- package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
- package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
- package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
- package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
- package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
- package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
- package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
- package/types-legacy/ts4.5/chain.d.ts +256 -0
- package/types-legacy/ts4.5/channel/Base.d.ts +199 -0
- package/types-legacy/ts4.5/channel/Contract.d.ts +248 -0
- package/types-legacy/ts4.5/channel/Spend.d.ts +219 -0
- package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
- package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
- package/types-legacy/ts4.5/contract/Contract.d.ts +212 -0
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +81 -0
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +44 -0
- package/types-legacy/ts4.5/index-browser.d.ts +39 -0
- package/types-legacy/ts4.5/index.d.ts +4 -0
- package/types-legacy/ts4.5/oracle.d.ts +161 -0
- package/types-legacy/ts4.5/spend.d.ts +62 -0
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +98 -0
- package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +10 -0
- package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +21 -0
- package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
- package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +42 -0
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +20 -0
- package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +15 -0
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +129 -0
- package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +43 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +18 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
- package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
- package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +5 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +50 -0
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +4675 -0
- package/types-legacy/ts4.5/tx/index.d.ts +19 -0
- package/types-legacy/ts4.5/tx/validator.d.ts +18 -0
- package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
- package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
- package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
- package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
- package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
- package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
- package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
- package/types-legacy/ts4.5/utils/errors.d.ts +475 -0
- package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
- package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
- package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
- package/types-legacy/ts4.5/utils/other.d.ts +31 -0
- package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
- package/types-legacy/ts4.5/utils/string.d.ts +12 -0
- package/es/channel/index.d.ts +0 -625
- package/es/channel/index.mjs +0 -975
- package/es/channel/index.mjs.map +0 -1
- package/es/contract/Compiler.d.ts +0 -18
- package/es/contract/Compiler.mjs +0 -68
- package/es/contract/Compiler.mjs.map +0 -1
- package/es/contract/aci.d.ts +0 -127
- package/es/contract/aci.mjs +0 -508
- package/es/contract/aci.mjs.map +0 -1
- package/es/contract/methods.d.ts +0 -71
- package/es/contract/methods.mjs +0 -104
- package/es/contract/methods.mjs.map +0 -1
- package/es/deprecated/index.d.ts +0 -143
- package/es/deprecated/index.mjs +0 -162
- package/es/deprecated/index.mjs.map +0 -1
- package/es/deprecated/methods.d.ts +0 -18
- package/es/deprecated/methods.mjs +0 -26
- package/es/deprecated/methods.mjs.map +0 -1
- package/es/tx/builder/address.d.ts +0 -25
- package/es/tx/builder/address.mjs +0 -45
- package/es/tx/builder/address.mjs.map +0 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
- package/es/utils/mptree.d.ts +0 -26
- package/es/utils/mptree.mjs +0 -165
- package/es/utils/mptree.mjs.map +0 -1
- package/src/channel/index.ts +0 -1025
- package/src/contract/Compiler.ts +0 -67
- package/src/contract/aci.ts +0 -537
- package/src/contract/methods.ts +0 -123
- package/src/deprecated/index.ts +0 -172
- package/src/deprecated/methods.ts +0 -25
- package/src/tx/builder/address.ts +0 -50
- package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
- package/src/utils/mptree.ts +0 -145
package/es/Node.mjs
CHANGED
|
@@ -1,75 +1,47 @@
|
|
|
1
|
+
import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
|
|
2
|
+
import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
|
|
3
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
1
4
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
2
|
-
|
|
3
5
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
4
|
-
|
|
5
6
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
6
|
-
|
|
7
7
|
// eslint-disable-next-line max-classes-per-file
|
|
8
8
|
import BigNumber from 'bignumber.js';
|
|
9
9
|
import { genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy, genVersionCheckPolicy } from "./utils/autorest.mjs";
|
|
10
10
|
import { Node as NodeApi } from "./apis/node/index.mjs";
|
|
11
11
|
import { mapObject } from "./utils/other.mjs";
|
|
12
|
-
import { MissingParamError } from "./utils/errors.mjs";
|
|
13
|
-
/**
|
|
14
|
-
* Obtain networkId from account or node
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export async function getNetworkId() {
|
|
18
|
-
var _ref, _await$this$api$getSt, _this$api;
|
|
19
|
-
|
|
20
|
-
let {
|
|
21
|
-
networkId
|
|
22
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
23
|
-
const res = (_ref = networkId !== null && networkId !== void 0 ? networkId : this.networkId) !== null && _ref !== void 0 ? _ref : (_await$this$api$getSt = await ((_this$api = this.api) === null || _this$api === void 0 ? void 0 : _this$api.getStatus())) === null || _await$this$api$getSt === void 0 ? void 0 : _await$this$api$getSt.networkId;
|
|
24
|
-
if (res != null) return res;
|
|
25
|
-
throw new MissingParamError('networkId is not provided');
|
|
26
|
-
}
|
|
27
12
|
const bigIntPropertyNames = ['balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount', 'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal', 'responderAmountFinal', 'gasPrice', 'deposit'];
|
|
28
|
-
const numberPropertyNames = ['time', 'gas', 'gasUsed', 'nameSalt', 'nonce', 'nextNonce', 'height', 'blockHeight', '
|
|
29
|
-
|
|
13
|
+
const numberPropertyNames = ['time', 'gas', 'gasUsed', 'nameSalt', 'nonce', 'nextNonce', 'height', 'blockHeight', 'topBlockHeight', 'ttl', 'nameTtl', 'clientTtl', 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight', 'version', 'solutions', 'round'];
|
|
30
14
|
var _mapData = /*#__PURE__*/new WeakSet();
|
|
31
|
-
|
|
32
15
|
var _encodeArg = /*#__PURE__*/new WeakSet();
|
|
33
|
-
|
|
34
16
|
var _decodeRes = /*#__PURE__*/new WeakSet();
|
|
35
|
-
|
|
36
17
|
class NodeTransformed extends NodeApi {
|
|
37
18
|
constructor() {
|
|
38
19
|
super(...arguments);
|
|
39
|
-
|
|
40
20
|
_classPrivateMethodInitSpec(this, _decodeRes);
|
|
41
|
-
|
|
42
21
|
_classPrivateMethodInitSpec(this, _encodeArg);
|
|
43
|
-
|
|
44
22
|
_classPrivateMethodInitSpec(this, _mapData);
|
|
45
23
|
}
|
|
46
|
-
|
|
47
24
|
async sendOperationRequest(operationArguments, operationSpec) {
|
|
48
|
-
const args = mapObject(operationArguments,
|
|
49
|
-
let [key, value] =
|
|
25
|
+
const args = mapObject(operationArguments, _ref => {
|
|
26
|
+
let [key, value] = _ref;
|
|
50
27
|
return [key, _classPrivateMethodGet(this, _encodeArg, _encodeArg2).call(this, value)];
|
|
51
28
|
});
|
|
52
29
|
return _classPrivateMethodGet(this, _decodeRes, _decodeRes2).call(this, await super.sendOperationRequest(args, operationSpec));
|
|
53
30
|
}
|
|
54
|
-
|
|
55
31
|
}
|
|
56
|
-
|
|
57
32
|
function _mapData2(data, transform) {
|
|
58
33
|
if (Array.isArray(data)) return data.map(d => _classPrivateMethodGet(this, _mapData, _mapData2).call(this, d, transform));
|
|
59
|
-
|
|
60
34
|
if (data != null && typeof data === 'object') {
|
|
61
|
-
return mapObject(data,
|
|
62
|
-
let [key, value] =
|
|
35
|
+
return mapObject(data, _ref6 => {
|
|
36
|
+
let [key, value] = _ref6;
|
|
63
37
|
if (value == null) return [key, value];
|
|
64
38
|
if (bigIntPropertyNames.some(k => k === key)) return [key, transform.bigInt(value)];
|
|
65
39
|
if (numberPropertyNames.some(k => k === key)) return [key, transform.number(value)];
|
|
66
40
|
return [key, _classPrivateMethodGet(this, _mapData, _mapData2).call(this, value, transform)];
|
|
67
41
|
});
|
|
68
42
|
}
|
|
69
|
-
|
|
70
43
|
return data;
|
|
71
44
|
}
|
|
72
|
-
|
|
73
45
|
function _encodeArg2(data) {
|
|
74
46
|
return _classPrivateMethodGet(this, _mapData, _mapData2).call(this, data, {
|
|
75
47
|
bigInt: value => {
|
|
@@ -79,14 +51,13 @@ function _encodeArg2(data) {
|
|
|
79
51
|
number: value => value.toString()
|
|
80
52
|
});
|
|
81
53
|
}
|
|
82
|
-
|
|
83
54
|
function _decodeRes2(data) {
|
|
84
55
|
return _classPrivateMethodGet(this, _mapData, _mapData2).call(this, data, {
|
|
85
56
|
bigInt: value => BigInt(value),
|
|
86
57
|
number: value => +value
|
|
87
58
|
});
|
|
88
59
|
}
|
|
89
|
-
|
|
60
|
+
var _networkIdPromise = /*#__PURE__*/new WeakMap();
|
|
90
61
|
export default class Node extends NodeTransformed {
|
|
91
62
|
/**
|
|
92
63
|
* @param url - Url for node API
|
|
@@ -104,21 +75,38 @@ export default class Node extends NodeTransformed {
|
|
|
104
75
|
additionalPolicies: [genRequestQueuesPolicy(), genCombineGetRequestsPolicy(), genErrorFormatterPolicy(body => ` ${body.reason}`)],
|
|
105
76
|
...options
|
|
106
77
|
});
|
|
107
|
-
this
|
|
108
|
-
|
|
78
|
+
_classPrivateFieldInitSpec(this, _networkIdPromise, {
|
|
79
|
+
writable: true,
|
|
80
|
+
value: void 0
|
|
81
|
+
});
|
|
109
82
|
if (!ignoreVersion) {
|
|
110
|
-
const
|
|
83
|
+
const statusPromise = this.getStatus();
|
|
84
|
+
const versionPromise = statusPromise.then(_ref2 => {
|
|
111
85
|
let {
|
|
112
86
|
nodeVersion
|
|
113
|
-
} =
|
|
87
|
+
} = _ref2;
|
|
114
88
|
return nodeVersion;
|
|
115
89
|
});
|
|
90
|
+
_classPrivateFieldSet(this, _networkIdPromise, statusPromise.then(_ref3 => {
|
|
91
|
+
let {
|
|
92
|
+
networkId
|
|
93
|
+
} = _ref3;
|
|
94
|
+
return networkId;
|
|
95
|
+
}));
|
|
116
96
|
this.pipeline.addPolicy(genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'));
|
|
117
97
|
}
|
|
118
|
-
|
|
119
98
|
this.intAsString = true;
|
|
120
99
|
}
|
|
121
|
-
|
|
100
|
+
async getNetworkId() {
|
|
101
|
+
var _classPrivateFieldGet2;
|
|
102
|
+
(_classPrivateFieldGet2 = _classPrivateFieldGet(this, _networkIdPromise)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : _classPrivateFieldSet(this, _networkIdPromise, this.getStatus().then(_ref4 => {
|
|
103
|
+
let {
|
|
104
|
+
networkId
|
|
105
|
+
} = _ref4;
|
|
106
|
+
return networkId;
|
|
107
|
+
}));
|
|
108
|
+
return _classPrivateFieldGet(this, _networkIdPromise);
|
|
109
|
+
}
|
|
122
110
|
async getNodeInfo() {
|
|
123
111
|
const {
|
|
124
112
|
nodeVersion: version,
|
|
@@ -126,22 +114,21 @@ export default class Node extends NodeTransformed {
|
|
|
126
114
|
protocols,
|
|
127
115
|
topBlockHeight
|
|
128
116
|
} = await this.getStatus();
|
|
129
|
-
const consensusProtocolVersion = protocols.filter(
|
|
117
|
+
const consensusProtocolVersion = protocols.filter(_ref5 => {
|
|
130
118
|
let {
|
|
131
119
|
effectiveAtHeight
|
|
132
|
-
} =
|
|
120
|
+
} = _ref5;
|
|
133
121
|
return topBlockHeight >= effectiveAtHeight;
|
|
134
122
|
}).reduce((acc, p) => p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc, {
|
|
135
123
|
effectiveAtHeight: -1,
|
|
136
124
|
version: 0
|
|
137
125
|
}).version;
|
|
138
126
|
return {
|
|
139
|
-
url: this
|
|
127
|
+
url: this.$host,
|
|
140
128
|
nodeNetworkId,
|
|
141
129
|
version,
|
|
142
130
|
consensusProtocolVersion
|
|
143
131
|
};
|
|
144
132
|
}
|
|
145
|
-
|
|
146
133
|
}
|
|
147
134
|
//# sourceMappingURL=Node.mjs.map
|
package/es/Node.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.mjs","names":["BigNumber","genRequestQueuesPolicy","genCombineGetRequestsPolicy","genErrorFormatterPolicy","genVersionCheckPolicy","Node","NodeApi","mapObject","MissingParamError","getNetworkId","networkId","res","api","getStatus","bigIntPropertyNames","numberPropertyNames","NodeTransformed","sendOperationRequest","operationArguments","operationSpec","args","key","value","data","transform","Array","isArray","map","d","some","k","bigInt","number","toFixed","toString","BigInt","constructor","url","ignoreVersion","options","allowInsecureConnection","additionalPolicies","body","reason","versionPromise","then","nodeVersion","pipeline","addPolicy","intAsString","getNodeInfo","version","nodeNetworkId","protocols","topBlockHeight","consensusProtocolVersion","filter","effectiveAtHeight","reduce","acc","p"],"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,\n} from './utils/autorest';\nimport { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';\nimport { mapObject } from './utils/other';\nimport { Encoded } from './utils/encoder';\nimport { MissingParamError } from './utils/errors';\n\n/**\n * Obtain networkId from account or node\n */\nexport async function getNetworkId({ networkId }: { networkId?: string } = {}): Promise<string> {\n const res = networkId ?? this.networkId ?? (await this.api?.getStatus())?.networkId;\n if (res != null) return res;\n throw new MissingParamError('networkId is not provided');\n}\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', 'top', 'topBlockHeight',\n 'ttl', 'nameTtl', 'clientTtl',\n 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',\n 'version', 'solutions', 'round',\n] as const;\n\nclass NodeTransformed extends NodeApi {\n 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 : 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\nexport interface NodeInfo {\n url: string;\n nodeNetworkId: string;\n version: string;\n consensusProtocolVersion: number;\n}\n\nexport default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {\n url: string;\n\n /**\n * @param url - Url for node API\n * @param options - Options\n * @param options.ignoreVersion - Don't check node version\n */\n constructor(\n url: string,\n { ignoreVersion = false, ...options }: NodeOptionalParams & { ignoreVersion?: boolean } = {},\n ) {\n // eslint-disable-next-line constructor-super\n super(url, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genRequestQueuesPolicy(),\n genCombineGetRequestsPolicy(),\n genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`),\n ],\n ...options,\n });\n this.url = url;\n if (!ignoreVersion) {\n const versionPromise = this.getStatus().then(({ nodeVersion }) => nodeVersion);\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 getNodeInfo(): Promise<NodeInfo> {\n const {\n nodeVersion: version,\n networkId: nodeNetworkId,\n protocols,\n topBlockHeight,\n } = await this.getStatus();\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 return {\n url: this.url,\n nodeNetworkId,\n version,\n consensusProtocolVersion,\n };\n }\n}\n"],"mappings":";;;;;;AAAA;AACA,OAAOA,SAAP,MAAsB,cAAtB;SAGEC,sB,EAAwBC,2B,EAA6BC,uB,EACrDC,qB;SAEOC,IAAI,IAAIC,O;SACRC,S;SAEAC,iB;AAET;AACA;AACA;;AACA,OAAO,eAAeC,YAAf,GAAyF;EAAA;;EAAA,IAA7D;IAAEC;EAAF,CAA6D,uEAArB,EAAqB;EAC9F,MAAMC,GAAG,WAAGD,SAAH,aAAGA,SAAH,cAAGA,SAAH,GAAgB,KAAKA,SAArB,gEAAmC,oBAAM,KAAKE,GAAX,8CAAM,UAAUC,SAAV,EAAN,CAAnC,0DAAkC,sBAA+BH,SAA1E;EACA,IAAIC,GAAG,IAAI,IAAX,EAAiB,OAAOA,GAAP;EACjB,MAAM,IAAIH,iBAAJ,CAAsB,2BAAtB,CAAN;AACD;AAED,MAAMM,mBAAmB,GAAG,CAC1B,SAD0B,EACf,UADe,EACH,KADG,EACI,QADJ,EACc,SADd,EACyB,eADzB,EAE1B,iBAF0B,EAEP,iBAFO,EAEY,gBAFZ,EAE8B,sBAF9B,EAG1B,sBAH0B,EAGF,UAHE,EAGU,SAHV,CAA5B;AAMA,MAAMC,mBAAmB,GAAG,CAC1B,MAD0B,EAClB,KADkB,EACX,SADW,EACA,UADA,EAE1B,OAF0B,EAEjB,WAFiB,EAEJ,QAFI,EAEM,aAFN,EAEqB,KAFrB,EAE4B,gBAF5B,EAG1B,KAH0B,EAGnB,SAHmB,EAGR,WAHQ,EAI1B,SAJ0B,EAIf,UAJe,EAIH,WAJG,EAIU,0BAJV,EAIsC,mBAJtC,EAK1B,SAL0B,EAKf,WALe,EAKF,OALE,CAA5B;;;;;;;;AAQA,MAAMC,eAAN,SAA8BV,OAA9B,CAAsC;EAAA;IAAA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C,cAAvB,EAAuC,OAAvC,EAAgD,OAAhD,CADvB;IAGD;;IACD,KAAKK,WAAL,GAAmB,IAAnB;EACD;;EAEgB,MAAXC,WAAW,GAAsB;IACrC,MAAM;MACJJ,WAAW,EAAEK,OADT;MAEJzC,SAAS,EAAE0C,aAFP;MAGJC,SAHI;MAIJC;IAJI,IAKF,MAAM,KAAKzC,SAAL,EALV;IAMA,MAAM0C,wBAAwB,GAAGF,SAAS,CACvCG,MAD8B,CACvB;MAAA,IAAC;QAAEC;MAAF,CAAD;MAAA,OAA2BH,cAAc,IAAIG,iBAA7C;IAAA,CADuB,EAE9BC,MAF8B,CAG7B,CAACC,GAAD,EAAMC,CAAN,KAAaA,CAAC,CAACH,iBAAF,GAAsBE,GAAG,CAACF,iBAA1B,GAA8CG,CAA9C,GAAkDD,GAHlC,EAI7B;MAAEF,iBAAiB,EAAE,CAAC,CAAtB;MAAyBN,OAAO,EAAE;IAAlC,CAJ6B,EAM9BA,OANH;IAOA,OAAO;MACLd,GAAG,EAAE,KAAKA,GADL;MAELe,aAFK;MAGLD,OAHK;MAILI;IAJK,CAAP;EAMD;;AApDkF"}
|
|
1
|
+
{"version":3,"file":"Node.mjs","names":["BigNumber","genRequestQueuesPolicy","genCombineGetRequestsPolicy","genErrorFormatterPolicy","genVersionCheckPolicy","Node","NodeApi","mapObject","bigIntPropertyNames","numberPropertyNames","NodeTransformed","sendOperationRequest","operationArguments","operationSpec","args","key","value","data","transform","Array","isArray","map","d","some","k","bigInt","number","toFixed","toString","BigInt","constructor","url","ignoreVersion","options","allowInsecureConnection","additionalPolicies","body","reason","statusPromise","getStatus","versionPromise","then","nodeVersion","networkId","pipeline","addPolicy","intAsString","getNetworkId","getNodeInfo","version","nodeNetworkId","protocols","topBlockHeight","consensusProtocolVersion","filter","effectiveAtHeight","reduce","acc","p","$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,\n} from './utils/autorest';\nimport { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';\nimport { mapObject } from './utils/other';\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\nexport interface 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>;\n\n /**\n * @param url - Url for node API\n * @param options - Options\n * @param options.ignoreVersion - Don't check node version\n */\n constructor(\n url: string,\n { ignoreVersion = false, ...options }: NodeOptionalParams & { ignoreVersion?: boolean } = {},\n ) {\n // eslint-disable-next-line constructor-super\n super(url, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genRequestQueuesPolicy(),\n genCombineGetRequestsPolicy(),\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);\n this.#networkIdPromise = statusPromise.then(({ networkId }) => networkId);\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 return this.#networkIdPromise;\n }\n\n async getNodeInfo(): Promise<NodeInfo> {\n const {\n nodeVersion: version,\n networkId: nodeNetworkId,\n protocols,\n topBlockHeight,\n } = await this.getStatus();\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 return {\n url: this.$host,\n nodeNetworkId,\n version,\n consensusProtocolVersion,\n };\n }\n}\n"],"mappings":";;;;;;AAAA;AACA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAGnCC,sBAAsB,EAAEC,2BAA2B,EAAEC,uBAAuB,EAC5EC,qBAAqB;AAAA,SAEdC,IAAI,IAAIC,OAAO;AAAA,SACfC,SAAS;AAIlB,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,SAAS,CACrC;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,E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
CHANGED
|
@@ -1,58 +1,43 @@
|
|
|
1
1
|
import { Encoded } from '../utils/encoder';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
/**
|
|
5
|
-
* Check is provided object looks like an instance of AccountBase
|
|
6
|
-
* @param acc - Object to check
|
|
7
|
-
*/
|
|
8
|
-
export declare const isAccountBase: (acc: AccountBase | any) => boolean;
|
|
2
|
+
import Node from '../Node';
|
|
3
|
+
import CompilerBase from '../contract/compiler/Base';
|
|
9
4
|
/**
|
|
10
5
|
* Account is one of the three basic building blocks of an
|
|
11
6
|
* {@link AeSdk} and provides access to a signing key pair.
|
|
12
7
|
*/
|
|
13
8
|
export default abstract class AccountBase {
|
|
14
|
-
networkId?: string;
|
|
15
|
-
/**
|
|
16
|
-
* @param options - Options
|
|
17
|
-
* @param options.networkId - Using for signing transactions
|
|
18
|
-
*/
|
|
19
|
-
constructor({ networkId }?: {
|
|
20
|
-
networkId?: string;
|
|
21
|
-
});
|
|
22
9
|
/**
|
|
23
10
|
* Sign encoded transaction
|
|
24
11
|
* @param tx - Transaction to sign
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
12
|
+
* @param options - Options
|
|
13
|
+
* @param options.innerTx - Sign as inner transaction for PayingFor
|
|
14
|
+
* @param options.authData - Object with gaMeta params
|
|
27
15
|
* @returns Signed transaction
|
|
28
16
|
*/
|
|
29
|
-
signTransaction(tx: Encoded.Transaction,
|
|
17
|
+
abstract signTransaction(tx: Encoded.Transaction, options: {
|
|
30
18
|
innerTx?: boolean;
|
|
31
19
|
networkId?: string;
|
|
32
|
-
authData?:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
authData?: {
|
|
21
|
+
gasLimit?: number;
|
|
22
|
+
callData?: Encoded.ContractBytearray;
|
|
23
|
+
sourceCode?: string;
|
|
24
|
+
args?: any[];
|
|
25
|
+
};
|
|
26
|
+
onNode?: Node;
|
|
27
|
+
onCompiler?: CompilerBase;
|
|
28
|
+
aeppOrigin?: string;
|
|
29
|
+
aeppRpcClientId?: string;
|
|
30
|
+
}): Promise<Encoded.Transaction>;
|
|
40
31
|
/**
|
|
41
32
|
* Sign message
|
|
42
33
|
* @param message - Message to sign
|
|
43
|
-
* @param opt - Options
|
|
44
|
-
* @returns Signature as hex string of Uint8Array
|
|
45
|
-
*/
|
|
46
|
-
signMessage(message: string, { returnHex, ...options }?: {
|
|
47
|
-
returnHex?: boolean;
|
|
48
|
-
}): Promise<string | Uint8Array>;
|
|
49
|
-
/**
|
|
50
|
-
* Verify message
|
|
51
|
-
* @param message - Message to verify
|
|
52
|
-
* @param signature - Signature
|
|
53
34
|
* @param options - Options
|
|
35
|
+
* @returns Signature as hex string of Uint8Array
|
|
54
36
|
*/
|
|
55
|
-
|
|
37
|
+
abstract signMessage(message: string, options?: {
|
|
38
|
+
aeppOrigin?: string;
|
|
39
|
+
aeppRpcClientId?: string;
|
|
40
|
+
}): Promise<Uint8Array>;
|
|
56
41
|
/**
|
|
57
42
|
* Sign data blob
|
|
58
43
|
* @param data - Data blob to sign
|
|
@@ -61,8 +46,7 @@ export default abstract class AccountBase {
|
|
|
61
46
|
*/
|
|
62
47
|
abstract sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;
|
|
63
48
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @returns Public account address
|
|
49
|
+
* Account address
|
|
66
50
|
*/
|
|
67
|
-
|
|
51
|
+
readonly address: Encoded.AccountAddress;
|
|
68
52
|
}
|
package/es/account/Base.mjs
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import _buffer from "buffer";
|
|
2
|
-
const {
|
|
3
|
-
Buffer: _Buffer
|
|
4
|
-
} = _buffer;
|
|
5
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
6
|
-
|
|
7
1
|
/*
|
|
8
2
|
* ISC License (ISC)
|
|
9
3
|
* Copyright (c) 2022 aeternity developers
|
|
@@ -20,104 +14,10 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
|
20
14
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
21
15
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
22
16
|
*/
|
|
23
|
-
import { messageToHash, verifyMessage as verifyMessageCrypto, hash } from "../utils/crypto.mjs";
|
|
24
|
-
import { buildTx } from "../tx/builder/index.mjs";
|
|
25
|
-
import { decode } from "../utils/encoder.mjs";
|
|
26
|
-
import { Tag } from "../tx/builder/constants.mjs";
|
|
27
|
-
import { getNetworkId } from "../Node.mjs";
|
|
28
|
-
import { concatBuffers } from "../utils/other.mjs";
|
|
29
17
|
|
|
30
|
-
/**
|
|
31
|
-
* Check is provided object looks like an instance of AccountBase
|
|
32
|
-
* @param acc - Object to check
|
|
33
|
-
*/
|
|
34
|
-
export const isAccountBase = acc => !['sign', 'address', 'signTransaction', 'signMessage'].some(f => typeof acc[f] !== 'function');
|
|
35
18
|
/**
|
|
36
19
|
* Account is one of the three basic building blocks of an
|
|
37
20
|
* {@link AeSdk} and provides access to a signing key pair.
|
|
38
21
|
*/
|
|
39
|
-
|
|
40
|
-
export default class AccountBase {
|
|
41
|
-
/**
|
|
42
|
-
* @param options - Options
|
|
43
|
-
* @param options.networkId - Using for signing transactions
|
|
44
|
-
*/
|
|
45
|
-
constructor() {
|
|
46
|
-
var _this$networkId;
|
|
47
|
-
|
|
48
|
-
let {
|
|
49
|
-
networkId
|
|
50
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
51
|
-
|
|
52
|
-
_defineProperty(this, "getNetworkId", getNetworkId);
|
|
53
|
-
|
|
54
|
-
(_this$networkId = this.networkId) !== null && _this$networkId !== void 0 ? _this$networkId : this.networkId = networkId;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Sign encoded transaction
|
|
58
|
-
* @param tx - Transaction to sign
|
|
59
|
-
* @param opt - Options
|
|
60
|
-
* @param opt.innerTx - Sign as inner transaction for PayingFor
|
|
61
|
-
* @returns Signed transaction
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
async signTransaction(tx) {
|
|
66
|
-
let {
|
|
67
|
-
innerTx,
|
|
68
|
-
networkId,
|
|
69
|
-
...options
|
|
70
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
71
|
-
const prefixes = [await this.getNetworkId({
|
|
72
|
-
networkId
|
|
73
|
-
})];
|
|
74
|
-
if (innerTx === true) prefixes.push('inner_tx');
|
|
75
|
-
const rlpBinaryTx = decode(tx);
|
|
76
|
-
const txWithNetworkId = concatBuffers([_Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);
|
|
77
|
-
const signatures = [await this.sign(txWithNetworkId, options)];
|
|
78
|
-
return buildTx({
|
|
79
|
-
encodedTx: rlpBinaryTx,
|
|
80
|
-
signatures
|
|
81
|
-
}, Tag.SignedTx).tx;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Get network Id
|
|
85
|
-
* @returns Network Id
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Sign message
|
|
91
|
-
* @param message - Message to sign
|
|
92
|
-
* @param opt - Options
|
|
93
|
-
* @returns Signature as hex string of Uint8Array
|
|
94
|
-
*/
|
|
95
|
-
async signMessage(message) {
|
|
96
|
-
let {
|
|
97
|
-
returnHex = false,
|
|
98
|
-
...options
|
|
99
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
100
|
-
const sig = await this.sign(messageToHash(message), options);
|
|
101
|
-
return returnHex ? _Buffer.from(sig).toString('hex') : sig;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Verify message
|
|
105
|
-
* @param message - Message to verify
|
|
106
|
-
* @param signature - Signature
|
|
107
|
-
* @param options - Options
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
async verifyMessage(message, signature, options) {
|
|
112
|
-
return verifyMessageCrypto(message, typeof signature === 'string' ? _Buffer.from(signature, 'hex') : signature, decode(await this.address(options)));
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Sign data blob
|
|
116
|
-
* @param data - Data blob to sign
|
|
117
|
-
* @param options - Options
|
|
118
|
-
* @returns Signed data blob
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
22
|
+
export default class AccountBase {}
|
|
123
23
|
//# sourceMappingURL=Base.mjs.map
|
package/es/account/Base.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base.mjs","names":["
|
|
1
|
+
{"version":3,"file":"Base.mjs","names":["AccountBase"],"sources":["../../src/account/Base.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport { Encoded } from '../utils/encoder';\nimport Node from '../Node';\nimport CompilerBase from '../contract/compiler/Base';\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?: {\n gasLimit?: number;\n callData?: Encoded.ContractBytearray;\n sourceCode?: string;\n args?: any[];\n };\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 as hex string of Uint8Array\n */\n abstract signMessage(\n message: string,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signed data blob\n */\n abstract sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;\n\n /**\n * Account address\n */\n readonly address: Encoded.AccountAddress;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA,eAAe,MAAeA,WAAW,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import AccountBase from './Base';
|
|
2
|
+
import { Encoded } from '../utils/encoder';
|
|
3
|
+
/**
|
|
4
|
+
* Generalized account class
|
|
5
|
+
*/
|
|
6
|
+
export default class AccountGeneralized extends AccountBase {
|
|
7
|
+
#private;
|
|
8
|
+
readonly address: Encoded.AccountAddress;
|
|
9
|
+
/**
|
|
10
|
+
* @param address - Address of generalized account
|
|
11
|
+
*/
|
|
12
|
+
constructor(address: Encoded.AccountAddress);
|
|
13
|
+
sign(): Promise<Uint8Array>;
|
|
14
|
+
signMessage(): Promise<Uint8Array>;
|
|
15
|
+
signTransaction(tx: Encoded.Transaction, { authData, onCompiler, onNode }: Parameters<AccountBase['signTransaction']>[1]): Promise<Encoded.Transaction>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
|
|
2
|
+
import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
|
|
3
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
4
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
5
|
+
/*
|
|
6
|
+
* ISC License (ISC)
|
|
7
|
+
* Copyright (c) 2022 aeternity developers
|
|
8
|
+
*
|
|
9
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
11
|
+
* copyright notice and this permission notice appear in all copies.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
* PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
import AccountBase from "./Base.mjs";
|
|
22
|
+
import { ArgumentError, InternalError, InvalidAuthDataError, NotImplementedError } from "../utils/errors.mjs";
|
|
23
|
+
import { decode } from "../utils/encoder.mjs";
|
|
24
|
+
import { getAccount } from "../chain.mjs";
|
|
25
|
+
import Contract from "../contract/Contract.mjs";
|
|
26
|
+
import { _buildTx } from "../tx/index.mjs";
|
|
27
|
+
import { Tag } from "../tx/builder/constants.mjs";
|
|
28
|
+
import { buildTx } from "../tx/builder/index.mjs";
|
|
29
|
+
/**
|
|
30
|
+
* Generalized account class
|
|
31
|
+
*/
|
|
32
|
+
var _authFun = /*#__PURE__*/new WeakMap();
|
|
33
|
+
export default class AccountGeneralized extends AccountBase {
|
|
34
|
+
/**
|
|
35
|
+
* @param address - Address of generalized account
|
|
36
|
+
*/
|
|
37
|
+
constructor(address) {
|
|
38
|
+
super();
|
|
39
|
+
_classPrivateFieldInitSpec(this, _authFun, {
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
decode(address);
|
|
44
|
+
this.address = address;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line class-methods-use-this
|
|
48
|
+
async sign() {
|
|
49
|
+
throw new NotImplementedError('Can\'t sign using generalized account');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line class-methods-use-this
|
|
53
|
+
async signMessage() {
|
|
54
|
+
throw new NotImplementedError('Can\'t sign using generalized account');
|
|
55
|
+
}
|
|
56
|
+
async signTransaction(tx, _ref) {
|
|
57
|
+
let {
|
|
58
|
+
authData,
|
|
59
|
+
onCompiler,
|
|
60
|
+
onNode
|
|
61
|
+
} = _ref;
|
|
62
|
+
if (authData == null || onCompiler == null || onNode == null) {
|
|
63
|
+
throw new ArgumentError('authData, onCompiler, onNode', 'provided', null);
|
|
64
|
+
}
|
|
65
|
+
const {
|
|
66
|
+
callData,
|
|
67
|
+
sourceCode,
|
|
68
|
+
args,
|
|
69
|
+
gasLimit
|
|
70
|
+
} = authData;
|
|
71
|
+
const authCallData = callData !== null && callData !== void 0 ? callData : await (async () => {
|
|
72
|
+
if (_classPrivateFieldGet(this, _authFun) == null) {
|
|
73
|
+
const account = await getAccount(this.address, {
|
|
74
|
+
onNode
|
|
75
|
+
});
|
|
76
|
+
if (account.kind !== 'generalized') {
|
|
77
|
+
throw new ArgumentError('account kind', 'generalized', account.kind);
|
|
78
|
+
}
|
|
79
|
+
_classPrivateFieldSet(this, _authFun, account.authFun);
|
|
80
|
+
}
|
|
81
|
+
if (_classPrivateFieldGet(this, _authFun) == null) {
|
|
82
|
+
throw new InternalError('Account in generalised, but authFun not provided');
|
|
83
|
+
}
|
|
84
|
+
if (sourceCode == null || args == null) {
|
|
85
|
+
throw new InvalidAuthDataError('Auth data must contain source code and arguments.');
|
|
86
|
+
}
|
|
87
|
+
const contract = await Contract.initialize({
|
|
88
|
+
onCompiler,
|
|
89
|
+
onNode,
|
|
90
|
+
sourceCode
|
|
91
|
+
});
|
|
92
|
+
return contract._calldata.encode(contract._name, _classPrivateFieldGet(this, _authFun), args);
|
|
93
|
+
})();
|
|
94
|
+
const gaMetaTx = await _buildTx(Tag.GaMetaTx, {
|
|
95
|
+
tx: decode(buildTx({
|
|
96
|
+
tag: Tag.SignedTx,
|
|
97
|
+
encodedTx: decode(tx),
|
|
98
|
+
signatures: []
|
|
99
|
+
})),
|
|
100
|
+
gaId: this.address,
|
|
101
|
+
authData: authCallData,
|
|
102
|
+
gasLimit,
|
|
103
|
+
nonce: 0,
|
|
104
|
+
onNode
|
|
105
|
+
});
|
|
106
|
+
return buildTx({
|
|
107
|
+
tag: Tag.SignedTx,
|
|
108
|
+
encodedTx: decode(gaMetaTx),
|
|
109
|
+
signatures: []
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=Generalized.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Generalized.mjs","names":["AccountBase","ArgumentError","InternalError","InvalidAuthDataError","NotImplementedError","decode","getAccount","Contract","_buildTx","Tag","buildTx","AccountGeneralized","constructor","address","sign","signMessage","signTransaction","tx","authData","onCompiler","onNode","callData","sourceCode","args","gasLimit","authCallData","account","kind","authFun","contract","initialize","_calldata","encode","_name","gaMetaTx","GaMetaTx","tag","SignedTx","encodedTx","signatures","gaId","nonce"],"sources":["../../src/account/Generalized.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport 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 { _buildTx } from '../tx';\nimport { Tag } from '../tx/builder/constants';\nimport { buildTx } from '../tx/builder';\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 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, gasLimit,\n } = 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 source code and arguments.');\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 _buildTx(Tag.GaMetaTx, {\n tx: decode(buildTx({ tag: Tag.SignedTx, encodedTx: decode(tx), signatures: [] })),\n gaId: this.address,\n authData: authCallData,\n gasLimit,\n nonce: 0,\n onNode,\n });\n return buildTx({ tag: Tag.SignedTx, encodedTx: decode(gaMetaTx), signatures: [] });\n }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAfA,OAgBOA,WAAW;AAAA,SAEhBC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB;AAAA,SAEZC,MAAM;AAAA,SACNC,UAAU;AAAA,OACZC,QAAQ;AAAA,SACNC,QAAQ;AAAA,SACRC,GAAG;AAAA,SACHC,OAAO;AAEhB;AACA;AACA;AAFA;AAGA,eAAe,MAAMC,kBAAkB,SAASX,WAAW,CAAC;EAK1D;AACF;AACA;EACEY,WAA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AAM,IAAIpB,oBAAoB,CAAC,mDAAmD,CAAC;MACrF;MACA,MAAM0B,QAAQ,GAAG,MAAMtB,QAAQ,CAACuB,UAAU,CAAC;QAAEX,UAAU;QAAEC,MAAM;QAAEE;MAAW,CAAC,CAAC;MAC9E,OAAOO,QAAQ,CAACE,SAAS,CAACC,MAAM,CAACH,QAAQ,CAACI,KAAK,wBAAE,IAAI,aAAWV,IAAI,CAAC;IACvE,CAAC,GAAG;IAEJ,MAAMW,QAAQ,GAAG,MAAM1B,QAAQ,CAACC,GAAG,CAAC0B,QAAQ,EAAE;MAC5ClB,EAAE,EAAEZ,MAAM,CAACK,OAAO,CAAC;QAAE0B,GAAG,EAAE3B,GAAG,CAAC4B,QAAQ;QAAEC,SAAS,EAAEjC,MAAM,CAACY,EAAE,CAAC;QAAEsB,UAAU,EAAE;MAAG,CAAC,CAAC,CAAC;MACjFC,IAAI,EAAE,IAAI,CAAC3B,OAAO;MAClBK,QAAQ,EAAEO,YAAY;MACtBD,QAAQ;MACRiB,KAAK,EAAE,CAAC;MACRrB;IACF,CAAC,CAAC;IACF,OAAOV,OAAO,CAAC;MAAE0B,GAAG,EAAE3B,GAAG,CAAC4B,QAAQ;MAAEC,SAAS,EAAEjC,MAAM,CAAC6B,QAAQ,CAAC;MAAEK,UAAU,EAAE;IAAG,CAAC,CAAC;EACpF;AACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
+
import AccountBase from './Base';
|
|
3
|
+
import { Encoded } from '../utils/encoder';
|
|
4
|
+
export declare const CLA = 224;
|
|
5
|
+
export declare const GET_ADDRESS = 2;
|
|
6
|
+
export declare const SIGN_TRANSACTION = 4;
|
|
7
|
+
export declare const GET_APP_CONFIGURATION = 6;
|
|
8
|
+
export declare const SIGN_PERSONAL_MESSAGE = 8;
|
|
9
|
+
/**
|
|
10
|
+
* Ledger wallet account class
|
|
11
|
+
*/
|
|
12
|
+
export default class AccountLedger extends AccountBase {
|
|
13
|
+
readonly transport: Transport;
|
|
14
|
+
readonly address: Encoded.AccountAddress;
|
|
15
|
+
readonly index: number;
|
|
16
|
+
/**
|
|
17
|
+
* @param transport - Connection to Ledger to use
|
|
18
|
+
* @param index - Index of account
|
|
19
|
+
* @param address - Address of account
|
|
20
|
+
*/
|
|
21
|
+
constructor(transport: Transport, index: number, address: Encoded.AccountAddress);
|
|
22
|
+
sign(): Promise<Uint8Array>;
|
|
23
|
+
signTransaction(tx: Encoded.Transaction, { innerTx, networkId }?: {
|
|
24
|
+
innerTx?: boolean;
|
|
25
|
+
networkId?: string;
|
|
26
|
+
}): Promise<Encoded.Transaction>;
|
|
27
|
+
signMessage(messageStr: string): Promise<Uint8Array>;
|
|
28
|
+
}
|