@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
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _buffer from "buffer";
|
|
2
|
+
const {
|
|
3
|
+
Buffer: _Buffer
|
|
4
|
+
} = _buffer;
|
|
5
|
+
import AccountBase from "./Base.mjs";
|
|
6
|
+
import { ArgumentError, NotImplementedError } from "../utils/errors.mjs";
|
|
7
|
+
import { decode } from "../utils/encoder.mjs";
|
|
8
|
+
import { buildTx } from "../tx/builder/index.mjs";
|
|
9
|
+
import { Tag } from "../tx/builder/constants.mjs";
|
|
10
|
+
export const CLA = 0xe0;
|
|
11
|
+
export const GET_ADDRESS = 0x02;
|
|
12
|
+
export const SIGN_TRANSACTION = 0x04;
|
|
13
|
+
export const GET_APP_CONFIGURATION = 0x06;
|
|
14
|
+
export const SIGN_PERSONAL_MESSAGE = 0x08;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Ledger wallet account class
|
|
18
|
+
*/
|
|
19
|
+
export default class AccountLedger extends AccountBase {
|
|
20
|
+
/**
|
|
21
|
+
* @param transport - Connection to Ledger to use
|
|
22
|
+
* @param index - Index of account
|
|
23
|
+
* @param address - Address of account
|
|
24
|
+
*/
|
|
25
|
+
constructor(transport, index, address) {
|
|
26
|
+
super();
|
|
27
|
+
this.transport = transport;
|
|
28
|
+
this.index = index;
|
|
29
|
+
this.address = address;
|
|
30
|
+
const scrambleKey = 'w0w';
|
|
31
|
+
transport.decorateAppAPIMethods(this, ['signTransaction', 'signMessage'], scrambleKey);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line class-methods-use-this
|
|
35
|
+
async sign() {
|
|
36
|
+
throw new NotImplementedError('RAW signing using Ledger HW');
|
|
37
|
+
}
|
|
38
|
+
async signTransaction(tx) {
|
|
39
|
+
let {
|
|
40
|
+
innerTx,
|
|
41
|
+
networkId
|
|
42
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
43
|
+
if (innerTx != null) throw new NotImplementedError('innerTx option in AccountLedger');
|
|
44
|
+
if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
|
|
45
|
+
const rawTx = decode(tx);
|
|
46
|
+
let offset = 0;
|
|
47
|
+
const headerLength = 4 + 1 + 4;
|
|
48
|
+
const networkIdBuffer = _Buffer.from(networkId);
|
|
49
|
+
const toSend = [];
|
|
50
|
+
while (offset !== rawTx.length) {
|
|
51
|
+
const maxChunkSize = offset === 0 ? 150 - headerLength - networkIdBuffer.length : 150;
|
|
52
|
+
const chunkSize = offset + maxChunkSize > rawTx.length ? rawTx.length - offset : maxChunkSize;
|
|
53
|
+
const buffer = _Buffer.alloc(offset === 0 ? headerLength + networkIdBuffer.length + chunkSize : chunkSize);
|
|
54
|
+
if (offset === 0) {
|
|
55
|
+
let bufferOffset = buffer.writeUInt32BE(this.index, 0);
|
|
56
|
+
bufferOffset = buffer.writeUInt32BE(rawTx.length, bufferOffset);
|
|
57
|
+
bufferOffset = buffer.writeUInt8(networkIdBuffer.length, bufferOffset);
|
|
58
|
+
bufferOffset += networkIdBuffer.copy(buffer, bufferOffset, 0, networkIdBuffer.length);
|
|
59
|
+
rawTx.copy(buffer, bufferOffset, 0, 150 - bufferOffset);
|
|
60
|
+
} else {
|
|
61
|
+
rawTx.copy(buffer, 0, offset, offset + chunkSize);
|
|
62
|
+
}
|
|
63
|
+
toSend.push(buffer);
|
|
64
|
+
offset += chunkSize;
|
|
65
|
+
}
|
|
66
|
+
const response = await toSend.reduce(async (previous, data, i) => {
|
|
67
|
+
await previous;
|
|
68
|
+
return this.transport.send(CLA, SIGN_TRANSACTION, i === 0 ? 0x00 : 0x80, 0x00, data);
|
|
69
|
+
}, Promise.resolve(_Buffer.alloc(0)));
|
|
70
|
+
const signatures = [response.subarray(0, 64)];
|
|
71
|
+
return buildTx({
|
|
72
|
+
tag: Tag.SignedTx,
|
|
73
|
+
encodedTx: rawTx,
|
|
74
|
+
signatures
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async signMessage(messageStr) {
|
|
78
|
+
let offset = 0;
|
|
79
|
+
const message = _Buffer.from(messageStr);
|
|
80
|
+
const toSend = [];
|
|
81
|
+
while (offset !== message.length) {
|
|
82
|
+
const maxChunkSize = offset === 0 ? 150 - 4 - 4 : 150;
|
|
83
|
+
const chunkSize = offset + maxChunkSize > message.length ? message.length - offset : maxChunkSize;
|
|
84
|
+
const buffer = _Buffer.alloc(offset === 0 ? 4 + 4 + chunkSize : chunkSize);
|
|
85
|
+
if (offset === 0) {
|
|
86
|
+
buffer.writeUInt32BE(this.index, 0);
|
|
87
|
+
buffer.writeUInt32BE(message.length, 4);
|
|
88
|
+
message.copy(buffer, 4 + 4, offset, offset + chunkSize);
|
|
89
|
+
} else {
|
|
90
|
+
message.copy(buffer, 0, offset, offset + chunkSize);
|
|
91
|
+
}
|
|
92
|
+
toSend.push(buffer);
|
|
93
|
+
offset += chunkSize;
|
|
94
|
+
}
|
|
95
|
+
const response = await toSend.reduce(async (previous, data, i) => {
|
|
96
|
+
await previous;
|
|
97
|
+
return this.transport.send(CLA, SIGN_PERSONAL_MESSAGE, i === 0 ? 0x00 : 0x80, 0x00, data);
|
|
98
|
+
}, Promise.resolve(_Buffer.alloc(0)));
|
|
99
|
+
return response.subarray(0, 64);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=Ledger.mjs.map
|
|
@@ -0,0 +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","signTransaction","tx","innerTx","networkId","rawTx","offset","headerLength","networkIdBuffer","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 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,WAAW,CAACC,SAAoB,EAAEC,KAAa,EAAEC,OAA+B,EAAE;IAChF,KAAK,EAAE;IACP,IAAI,CAACF,SAAS,GAAGA,SAAS;IAC1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,IAAI,CACxBtC,GAAG,EACHI,qBAAqB,EACrBiC,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,EACrB,IAAI,EACJD,IAAI,CACL;IACH,CAAC,EACDG,OAAO,CAACC,OAAO,CAAC,QAAOb,KAAK,CAAC,CAAC,CAAC,CAAC,CACjC;IACD,OAAOM,QAAQ,CAACS,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;EACjC;AACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
+
import AccountLedger from './Ledger';
|
|
3
|
+
import { Encoded } from '../utils/encoder';
|
|
4
|
+
import Node from '../Node';
|
|
5
|
+
/**
|
|
6
|
+
* A factory class that generates instances of AccountLedger based on provided transport.
|
|
7
|
+
*/
|
|
8
|
+
export default class AccountLedgerFactory {
|
|
9
|
+
readonly transport: Transport;
|
|
10
|
+
private readonly versionCheckPromise;
|
|
11
|
+
/**
|
|
12
|
+
* @param transport - Connection to Ledger to use
|
|
13
|
+
*/
|
|
14
|
+
constructor(transport: Transport);
|
|
15
|
+
/**
|
|
16
|
+
* @returns the version of app installed on Ledger wallet
|
|
17
|
+
*/
|
|
18
|
+
getAppConfiguration(): Promise<{
|
|
19
|
+
version: string;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Get `ak_`-prefixed address for a given account index.
|
|
23
|
+
* @param accountIndex - Index of account
|
|
24
|
+
* @param verify - Ask user to confirm address by showing it on the device screen
|
|
25
|
+
*/
|
|
26
|
+
getAddress(accountIndex: number, verify?: boolean): Promise<Encoded.AccountAddress>;
|
|
27
|
+
/**
|
|
28
|
+
* Get an instance of AccountLedger for a given account index.
|
|
29
|
+
* @param accountIndex - Index of account
|
|
30
|
+
*/
|
|
31
|
+
initialize(accountIndex: number): Promise<AccountLedger>;
|
|
32
|
+
/**
|
|
33
|
+
* Discovers accounts on Ledger that already have been used (has any on-chain transactions).
|
|
34
|
+
* It returns an empty array if none of accounts been used.
|
|
35
|
+
* If a used account is preceded by an unused account then it would be ignored.
|
|
36
|
+
* @param node - Instance of Node to get account information from
|
|
37
|
+
*/
|
|
38
|
+
discover(node: Node): Promise<AccountLedger[]>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import _buffer from "buffer";
|
|
2
|
+
const {
|
|
3
|
+
Buffer: _Buffer
|
|
4
|
+
} = _buffer;
|
|
5
|
+
import AccountLedger, { CLA, GET_ADDRESS, GET_APP_CONFIGURATION } from "./Ledger.mjs";
|
|
6
|
+
import { UnsupportedVersionError } from "../utils/errors.mjs";
|
|
7
|
+
import semverSatisfies from "../utils/semver-satisfies.mjs";
|
|
8
|
+
/**
|
|
9
|
+
* A factory class that generates instances of AccountLedger based on provided transport.
|
|
10
|
+
*/
|
|
11
|
+
export default class AccountLedgerFactory {
|
|
12
|
+
/**
|
|
13
|
+
* @param transport - Connection to Ledger to use
|
|
14
|
+
*/
|
|
15
|
+
constructor(transport) {
|
|
16
|
+
this.transport = transport;
|
|
17
|
+
this.versionCheckPromise = this.getAppConfiguration().then(_ref => {
|
|
18
|
+
let {
|
|
19
|
+
version
|
|
20
|
+
} = _ref;
|
|
21
|
+
const args = [version, '0.4.4', '0.5.0'];
|
|
22
|
+
if (!semverSatisfies(...args)) throw new UnsupportedVersionError('app on ledger', ...args);
|
|
23
|
+
});
|
|
24
|
+
const scrambleKey = 'w0w';
|
|
25
|
+
transport.decorateAppAPIMethods(this, ['getAddress', 'getAppConfiguration'], scrambleKey);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @returns the version of app installed on Ledger wallet
|
|
30
|
+
*/
|
|
31
|
+
async getAppConfiguration() {
|
|
32
|
+
await this.versionCheckPromise;
|
|
33
|
+
const response = await this.transport.send(CLA, GET_APP_CONFIGURATION, 0x00, 0x00);
|
|
34
|
+
return {
|
|
35
|
+
version: [response[1], response[2], response[3]].join('.')
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get `ak_`-prefixed address for a given account index.
|
|
41
|
+
* @param accountIndex - Index of account
|
|
42
|
+
* @param verify - Ask user to confirm address by showing it on the device screen
|
|
43
|
+
*/
|
|
44
|
+
async getAddress(accountIndex) {
|
|
45
|
+
let verify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
46
|
+
await this.versionCheckPromise;
|
|
47
|
+
const buffer = _Buffer.alloc(4);
|
|
48
|
+
buffer.writeUInt32BE(accountIndex, 0);
|
|
49
|
+
const response = await this.transport.send(CLA, GET_ADDRESS, verify ? 0x01 : 0x00, 0x00, buffer);
|
|
50
|
+
const addressLength = response[0];
|
|
51
|
+
return response.subarray(1, 1 + addressLength).toString('ascii');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get an instance of AccountLedger for a given account index.
|
|
56
|
+
* @param accountIndex - Index of account
|
|
57
|
+
*/
|
|
58
|
+
async initialize(accountIndex) {
|
|
59
|
+
await this.versionCheckPromise;
|
|
60
|
+
return new AccountLedger(this.transport, accountIndex, await this.getAddress(accountIndex));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Discovers accounts on Ledger that already have been used (has any on-chain transactions).
|
|
65
|
+
* It returns an empty array if none of accounts been used.
|
|
66
|
+
* If a used account is preceded by an unused account then it would be ignored.
|
|
67
|
+
* @param node - Instance of Node to get account information from
|
|
68
|
+
*/
|
|
69
|
+
async discover(node) {
|
|
70
|
+
let index = 0;
|
|
71
|
+
const result = [];
|
|
72
|
+
let account;
|
|
73
|
+
do {
|
|
74
|
+
if (account != null) result.push(account);
|
|
75
|
+
account = await this.initialize(index);
|
|
76
|
+
index += 1;
|
|
77
|
+
} while (await node.getAccountByPubkey(account.address).then(() => true, () => false));
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=LedgerFactory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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","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,WAAW,CAACC,SAAoB,EAAE;IAChC,IAAI,CAACA,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,mBAAmB,GAAG,IAAI,CAACC,mBAAmB,EAAE,CAACC,IAAI,CAAC,QAAiB;MAAA,IAAhB;QAAEC;MAAQ,CAAC;MACrE,MAAMC,IAAI,GAAG,CAACD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAU;MACjD,IAAI,CAACP,eAAe,CAAC,GAAGQ,IAAI,CAAC,EAAE,MAAM,IAAIT,uBAAuB,CAAC,eAAe,EAAE,GAAGS,IAAI,CAAC;IAC5F,CAAC,CAAC;IACF,MAAMC,WAAW,GAAG,KAAK;IACzBN,SAAS,CAACO,qBAAqB,CAAC,I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;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAMS,QAAQ,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,CAACzB,IAAI,CAAC,MAAM,IAAI,EAAE,MAAM,KAAK,CAAC;IACrF,OAAOqB,MAAM;EACf;AACF"}
|
package/es/account/Memory.d.ts
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import AccountBase from './Base';
|
|
2
2
|
import { Encoded } from '../utils/encoder';
|
|
3
|
-
export interface Keypair {
|
|
4
|
-
publicKey: Encoded.AccountAddress;
|
|
5
|
-
secretKey: string | Uint8Array;
|
|
6
|
-
}
|
|
7
3
|
/**
|
|
8
4
|
* In-memory account class
|
|
9
5
|
*/
|
|
10
6
|
export default class AccountMemory extends AccountBase {
|
|
11
|
-
|
|
7
|
+
readonly address: Encoded.AccountAddress;
|
|
8
|
+
/**
|
|
9
|
+
* @param secretKey - Secret key
|
|
10
|
+
*/
|
|
11
|
+
constructor(secretKey: string | Uint8Array);
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param options.keypair - Key pair to use
|
|
15
|
-
* @param options.keypair.publicKey - Public key
|
|
16
|
-
* @param options.keypair.secretKey - Private key
|
|
17
|
-
* @param options.gaId - Address of generalized account
|
|
13
|
+
* Generates a new AccountMemory using a random secret key
|
|
18
14
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
static generate(): AccountMemory;
|
|
16
|
+
sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;
|
|
17
|
+
signTransaction(tx: Encoded.Transaction, { innerTx, networkId, ...options }?: {
|
|
18
|
+
innerTx?: boolean;
|
|
19
|
+
networkId?: string;
|
|
20
|
+
}): Promise<Encoded.Transaction>;
|
|
21
|
+
signMessage(message: string, options?: any): Promise<Uint8Array>;
|
|
26
22
|
}
|
package/es/account/Memory.mjs
CHANGED
|
@@ -2,10 +2,9 @@ import _buffer from "buffer";
|
|
|
2
2
|
const {
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
|
-
|
|
6
5
|
/*
|
|
7
6
|
* ISC License (ISC)
|
|
8
|
-
* Copyright (c)
|
|
7
|
+
* Copyright (c) 2022 aeternity developers
|
|
9
8
|
*
|
|
10
9
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
11
10
|
* purpose with or without fee is hereby granted, provided that the above
|
|
@@ -20,84 +19,64 @@ const {
|
|
|
20
19
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
21
20
|
*/
|
|
22
21
|
import AccountBase from "./Base.mjs";
|
|
23
|
-
import { sign,
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
|
|
22
|
+
import { generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash } from "../utils/crypto.mjs";
|
|
23
|
+
import { ArgumentError } from "../utils/errors.mjs";
|
|
24
|
+
import { decode, encode, Encoding } from "../utils/encoder.mjs";
|
|
25
|
+
import { concatBuffers } from "../utils/other.mjs";
|
|
26
|
+
import { buildTx } from "../tx/builder/index.mjs";
|
|
27
|
+
import { Tag } from "../tx/builder/constants.mjs";
|
|
28
|
+
const secretKeys = new WeakMap();
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* In-memory account class
|
|
32
32
|
*/
|
|
33
33
|
export default class AccountMemory extends AccountBase {
|
|
34
34
|
/**
|
|
35
|
-
* @param
|
|
36
|
-
* @param options.keypair - Key pair to use
|
|
37
|
-
* @param options.keypair.publicKey - Public key
|
|
38
|
-
* @param options.keypair.secretKey - Private key
|
|
39
|
-
* @param options.gaId - Address of generalized account
|
|
35
|
+
* @param secretKey - Secret key
|
|
40
36
|
*/
|
|
41
|
-
constructor(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} = _ref;
|
|
47
|
-
super(options);
|
|
48
|
-
this.isGa = gaId != null;
|
|
49
|
-
|
|
50
|
-
if (this.isGa && gaId != null) {
|
|
51
|
-
decode(gaId);
|
|
52
|
-
secrets.set(this, {
|
|
53
|
-
publicKey: gaId
|
|
54
|
-
});
|
|
55
|
-
return;
|
|
37
|
+
constructor(secretKey) {
|
|
38
|
+
super();
|
|
39
|
+
secretKey = typeof secretKey === 'string' ? _Buffer.from(secretKey, 'hex') : secretKey;
|
|
40
|
+
if (secretKey.length !== 64) {
|
|
41
|
+
throw new ArgumentError('secretKey', '64 bytes', secretKey.length);
|
|
56
42
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (!_Buffer.isBuffer(keypair.secretKey) && typeof keypair.secretKey === 'string' && !isHex(keypair.secretKey)) throw new InvalidKeypairError('Secret key must be hex string or Buffer');
|
|
60
|
-
const secretKey = typeof keypair.secretKey === 'string' ? _Buffer.from(keypair.secretKey, 'hex') : keypair.secretKey;
|
|
61
|
-
|
|
62
|
-
if (!isValidKeypair(secretKey, decode(keypair.publicKey))) {
|
|
63
|
-
throw new InvalidKeypairError('Invalid Key Pair');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
secrets.set(this, {
|
|
67
|
-
secretKey,
|
|
68
|
-
publicKey: keypair.publicKey
|
|
69
|
-
});
|
|
43
|
+
secretKeys.set(this, secretKey);
|
|
44
|
+
this.address = encode(generateKeyPairFromSecret(secretKeys.get(this)).publicKey, Encoding.AccountAddress);
|
|
70
45
|
}
|
|
71
46
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Generates a new AccountMemory using a random secret key
|
|
49
|
+
*/
|
|
50
|
+
static generate() {
|
|
51
|
+
return new AccountMemory(generateKeyPair().secretKey);
|
|
75
52
|
}
|
|
76
53
|
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
55
|
+
async sign(data, options) {
|
|
56
|
+
return sign(data, secretKeys.get(this));
|
|
57
|
+
}
|
|
77
58
|
async signTransaction(tx) {
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
} = options;
|
|
86
|
-
|
|
87
|
-
if (authFun == null || authData == null || onCompiler == null || onNode == null) {
|
|
88
|
-
throw new ArgumentError('authData, authFun, onCompiler, onNode', 'provided', null);
|
|
59
|
+
let {
|
|
60
|
+
innerTx,
|
|
61
|
+
networkId,
|
|
62
|
+
...options
|
|
63
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
64
|
+
if (networkId == null) {
|
|
65
|
+
throw new ArgumentError('networkId', 'provided', networkId);
|
|
89
66
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
67
|
+
const prefixes = [networkId];
|
|
68
|
+
if (innerTx === true) prefixes.push('inner_tx');
|
|
69
|
+
const rlpBinaryTx = decode(tx);
|
|
70
|
+
const txWithNetworkId = concatBuffers([_Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);
|
|
71
|
+
const signatures = [await this.sign(txWithNetworkId, options)];
|
|
72
|
+
return buildTx({
|
|
73
|
+
tag: Tag.SignedTx,
|
|
74
|
+
encodedTx: rlpBinaryTx,
|
|
75
|
+
signatures
|
|
95
76
|
});
|
|
96
77
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return secrets.get(this).publicKey;
|
|
78
|
+
async signMessage(message, options) {
|
|
79
|
+
return this.sign(messageToHash(message), options);
|
|
100
80
|
}
|
|
101
|
-
|
|
102
81
|
}
|
|
103
82
|
//# sourceMappingURL=Memory.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Memory.mjs","names":["AccountBase","sign","
|
|
1
|
+
{"version":3,"file":"Memory.mjs","names":["AccountBase","generateKeyPairFromSecret","sign","generateKeyPair","hash","messageToHash","ArgumentError","decode","encode","Encoding","concatBuffers","buildTx","Tag","secretKeys","WeakMap","AccountMemory","constructor","secretKey","from","length","set","address","get","publicKey","AccountAddress","generate","data","options","signTransaction","tx","innerTx","networkId","prefixes","push","rlpBinaryTx","txWithNetworkId","join","signatures","tag","SignedTx","encodedTx","signMessage","message"],"sources":["../../src/account/Memory.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 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 { buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\n\nconst secretKeys = new WeakMap();\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 tx: 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 prefixes = [networkId];\n if (innerTx === true) prefixes.push('inner_tx');\n const rlpBinaryTx = decode(tx);\n const txWithNetworkId = concatBuffers([Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);\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"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAfA,OAgBOA,WAAW;AAAA,SAEhBC,yBAAyB,EAAEC,IAAI,EAAEC,eAAe,EAAEC,IAAI,EAAEC,aAAa;AAAA,SAE9DC,aAAa;AAAA,S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AAMC,QAAQ,GAAG,CAACD,SAAS,CAAC;IAC5B,IAAID,OAAO,KAAK,IAAI,EAAEE,QAAQ,CAACC,IAAI,CAAC,UAAU,CAAC;IAC/C,MAAMC,WAAW,GAAG3B,MAAM,CAACsB,EAAE,CAAC;IAC9B,MAAMM,eAAe,GAAGzB,aAAa,CAAC,CAAC,QAAOQ,IAAI,CAACc,QAAQ,CAACI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAEhC,IAAI,CAAC8B,WAAW,CAAC,CAAC,CAAC;IAE3F,MAAMG,UAAU,GAAG,CAAC,MAAM,IAAI,CAACnC,IAAI,CAACiC,eAAe,EAAER,OAAO,CAAC,CAAC;IAC9D,OAAOhB,OAAO,CAAC;MAAE2B,GAAG,EAAE1B,GAAG,CAAC2B,QAAQ;MAAEC,SAAS,EAAEN,WAAW;MAAEG;IAAW,CAAC,CAAC;EAC3E;EAEA,MAAeI,WAAW,CAACC,OAAe,EAAEf,OAAa,EAAuB;IAC9E,OAAO,IAAI,CAACzB,IAAI,CAACG,aAAa,CAACqC,OAAO,CAAC,EAAEf,OAAO,CAAC;EACnD;AACF"}
|
package/es/account/Rpc.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import AccountBase from './Base';
|
|
2
2
|
import { Encoded } from '../utils/encoder';
|
|
3
|
+
import RpcClient from '../aepp-wallet-communication/rpc/RpcClient';
|
|
4
|
+
import { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types';
|
|
3
5
|
/**
|
|
4
6
|
* Account provided by wallet
|
|
5
7
|
* @param params - Params
|
|
@@ -8,14 +10,10 @@ import { Encoded } from '../utils/encoder';
|
|
|
8
10
|
* @returns AccountRpc instance
|
|
9
11
|
*/
|
|
10
12
|
export default class AccountRpc extends AccountBase {
|
|
11
|
-
_rpcClient:
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
rpcClient: any;
|
|
15
|
-
address: Encoded.AccountAddress;
|
|
16
|
-
} & ConstructorParameters<typeof AccountBase>[0]);
|
|
13
|
+
_rpcClient: RpcClient<WalletApi, AeppApi>;
|
|
14
|
+
readonly address: Encoded.AccountAddress;
|
|
15
|
+
constructor(rpcClient: RpcClient<WalletApi, AeppApi>, address: Encoded.AccountAddress);
|
|
17
16
|
sign(): Promise<Uint8Array>;
|
|
18
|
-
address(): Promise<Encoded.AccountAddress>;
|
|
19
17
|
/**
|
|
20
18
|
* @returns Signed transaction
|
|
21
19
|
*/
|
|
@@ -23,5 +21,5 @@ export default class AccountRpc extends AccountBase {
|
|
|
23
21
|
/**
|
|
24
22
|
* @returns Signed message
|
|
25
23
|
*/
|
|
26
|
-
signMessage(message: string
|
|
24
|
+
signMessage(message: string): Promise<Uint8Array>;
|
|
27
25
|
}
|
package/es/account/Rpc.mjs
CHANGED
|
@@ -4,8 +4,7 @@ const {
|
|
|
4
4
|
} = _buffer;
|
|
5
5
|
import AccountBase from "./Base.mjs";
|
|
6
6
|
import { METHODS } from "../aepp-wallet-communication/schema.mjs";
|
|
7
|
-
import { NotImplementedError } from "../utils/errors.mjs";
|
|
8
|
-
|
|
7
|
+
import { ArgumentError, NotImplementedError, UnsupportedProtocolError } from "../utils/errors.mjs";
|
|
9
8
|
/**
|
|
10
9
|
* Account provided by wallet
|
|
11
10
|
* @param params - Params
|
|
@@ -14,67 +13,50 @@ import { NotImplementedError } from "../utils/errors.mjs";
|
|
|
14
13
|
* @returns AccountRpc instance
|
|
15
14
|
*/
|
|
16
15
|
export default class AccountRpc extends AccountBase {
|
|
17
|
-
constructor(
|
|
18
|
-
|
|
19
|
-
rpcClient,
|
|
20
|
-
address,
|
|
21
|
-
...options
|
|
22
|
-
} = _ref;
|
|
23
|
-
super(options);
|
|
16
|
+
constructor(rpcClient, address) {
|
|
17
|
+
super();
|
|
24
18
|
this._rpcClient = rpcClient;
|
|
25
|
-
this.
|
|
26
|
-
}
|
|
27
|
-
|
|
19
|
+
this.address = address;
|
|
20
|
+
}
|
|
28
21
|
|
|
22
|
+
// eslint-disable-next-line class-methods-use-this
|
|
29
23
|
async sign() {
|
|
30
24
|
throw new NotImplementedError('RAW signing using wallet');
|
|
31
25
|
}
|
|
32
26
|
|
|
33
|
-
async address() {
|
|
34
|
-
return this._address;
|
|
35
|
-
}
|
|
36
27
|
/**
|
|
37
28
|
* @returns Signed transaction
|
|
38
29
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
30
|
async signTransaction(tx) {
|
|
42
31
|
let {
|
|
43
32
|
innerTx,
|
|
44
33
|
networkId
|
|
45
34
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
46
35
|
if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');
|
|
36
|
+
if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
|
|
47
37
|
const res = await this._rpcClient.request(METHODS.sign, {
|
|
48
|
-
onAccount: this.
|
|
38
|
+
onAccount: this.address,
|
|
49
39
|
tx,
|
|
50
40
|
returnSigned: true,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated Wallet provided networkId will be used (current network)
|
|
54
|
-
* required to maintain backward compatibility with wallets using SDK v11.0.1 and below
|
|
55
|
-
* @see {@link https://github.com/aeternity/aepp-sdk-js/commit/153fd89a52c4eab39fcd659b356b36d32129c1ba}
|
|
56
|
-
*/
|
|
57
41
|
networkId
|
|
58
42
|
});
|
|
43
|
+
if (res.signedTransaction == null) {
|
|
44
|
+
throw new UnsupportedProtocolError('signedTransaction is missed in wallet response');
|
|
45
|
+
}
|
|
59
46
|
return res.signedTransaction;
|
|
60
47
|
}
|
|
48
|
+
|
|
61
49
|
/**
|
|
62
50
|
* @returns Signed message
|
|
63
51
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
52
|
async signMessage(message) {
|
|
67
|
-
let {
|
|
68
|
-
returnHex = false
|
|
69
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
70
53
|
const {
|
|
71
54
|
signature
|
|
72
55
|
} = await this._rpcClient.request(METHODS.signMessage, {
|
|
73
|
-
onAccount: this.
|
|
56
|
+
onAccount: this.address,
|
|
74
57
|
message
|
|
75
58
|
});
|
|
76
|
-
return
|
|
59
|
+
return _Buffer.from(signature, 'hex');
|
|
77
60
|
}
|
|
78
|
-
|
|
79
61
|
}
|
|
80
62
|
//# sourceMappingURL=Rpc.mjs.map
|
package/es/account/Rpc.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rpc.mjs","names":["AccountBase","METHODS","NotImplementedError","AccountRpc","constructor","rpcClient","address","
|
|
1
|
+
{"version":3,"file":"Rpc.mjs","names":["AccountBase","METHODS","ArgumentError","NotImplementedError","UnsupportedProtocolError","AccountRpc","constructor","rpcClient","address","_rpcClient","sign","signTransaction","tx","innerTx","networkId","res","request","onAccount","returnSigned","signedTransaction","signMessage","message","signature","from"],"sources":["../../src/account/Rpc.ts"],"sourcesContent":["import AccountBase from './Base';\nimport { METHODS } from '../aepp-wallet-communication/schema';\nimport { ArgumentError, NotImplementedError, UnsupportedProtocolError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\nimport RpcClient from '../aepp-wallet-communication/rpc/RpcClient';\nimport { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types';\n\n/**\n * Account provided by wallet\n * @param params - Params\n * @param params.rpcClient - RpcClient instance\n * @param params.address - RPC account address\n * @returns AccountRpc instance\n */\nexport default class AccountRpc extends AccountBase {\n _rpcClient: RpcClient<WalletApi, AeppApi>;\n\n override readonly address: Encoded.AccountAddress;\n\n constructor(rpcClient: RpcClient<WalletApi, AeppApi>, address: Encoded.AccountAddress) {\n super();\n this._rpcClient = rpcClient;\n this.address = address;\n }\n\n // eslint-disable-next-line class-methods-use-this\n async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using wallet');\n }\n\n /**\n * @returns Signed transaction\n */\n override async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId }: Parameters<AccountBase['signTransaction']>[1] = {},\n ): Promise<Encoded.Transaction> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const res = await this._rpcClient.request(METHODS.sign, {\n onAccount: this.address,\n tx,\n returnSigned: true,\n networkId,\n });\n if (res.signedTransaction == null) {\n throw new UnsupportedProtocolError('signedTransaction is missed in wallet response');\n }\n return res.signedTransaction;\n }\n\n /**\n * @returns Signed message\n */\n override async signMessage(message: string): Promise<Uint8Array> {\n const { signature } = await this._rpcClient\n .request(METHODS.signMessage, { onAccount: this.address, message });\n return Buffer.from(signature, 'hex');\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SACTC,OAAO;AAAA,SACPC,aAAa,EAAEC,mBAAmB,EAAEC,wBAAwB;AAKrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,UAAU,SAASL,WAAW,CAAC;EAKlDM,WAAW,CAACC,SAAwC,EAAEC,OAA+B,EAAE;IACrF,KAAK,EAAE;IACP,IAAI,CAACC,UAAU,GAAGF,SAAS;IAC3B,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;;EAEA;EACA,MAAME,IAAI,GAAwB;IAChC,MAAM,IAAIP,mBAAmB,CAAC,0BAA0B,CAAC;EAC3D;;EAEA;AACF;AACA;EACE,MAAeQ,eAAe,CAC5BC,EAAuB,EAEO;IAAA,IAD9B;MAAEC,OAAO;MAAEC;IAAyD,CAAC,uEAAG,CAAC,CAAC;IAE1E,IAAID,OAAO,IAAI,IAAI,EAAE,MAAM,IAAIV,mBAAmB,CAAC,8BAA8B,CAAC;IAClF,IAAIW,SAAS,IAAI,IAAI,EAAE,MAAM,IAAIZ,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEY,SAAS,CAAC;IAClF,MAAMC,GAAG,GAAG,MAAM,IAAI,CAACN,UAAU,CAACO,OAAO,CAACf,OAAO,CAACS,IAAI,EAAE;MACtDO,SAAS,EAAE,IAAI,CAACT,OAAO;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