@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autorest.mjs","names":["RestError","pause","semverSatisfies","UnsupportedVersionError","genRequestQueuesPolicy","requestQueues","Map","policy","name","sendRequest","request","next","key","headers","get","delete","getResponse","req","Promise","resolve","then","set","position","genCombineGetRequestsPolicy","pendingGetRequests","method","JSON","stringify","url","body","response","genErrorFormatterPolicy","getMessage","error","bodyAsText","parse","e","message","URL","pathname","slice","genVersionCheckPolicy","ignorePath","versionPromise","geVersion","ltVersion","args"],"sources":["../../src/utils/autorest.ts"],"sourcesContent":["import { RestError, PipelineResponse, PipelinePolicy } from '@azure/core-rest-pipeline';\nimport { AdditionalPolicyConfig } from '@azure/core-client';\nimport { pause } from './other';\nimport semverSatisfies from './semver-satisfies';\nimport { UnsupportedVersionError } from './errors';\n\nexport const genRequestQueuesPolicy = (): AdditionalPolicyConfig => {\n const requestQueues = new Map<string, Promise<unknown>>();\n\n return {\n policy: {\n name: 'request-queues',\n async sendRequest(request, next) {\n const key = request.headers.get('__queue');\n request.headers.delete('__queue');\n const getResponse = async (): Promise<PipelineResponse> => next(request);\n if (key == null) return getResponse();\n const req = (requestQueues.get(key) ?? Promise.resolve()).then(getResponse, getResponse);\n // TODO: remove after fixing https://github.com/aeternity/aeternity/issues/3803\n // gap to ensure that node won't reject the nonce\n requestQueues.set(key, req.then(async () => pause(750)));\n return req;\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genCombineGetRequestsPolicy = (): AdditionalPolicyConfig => {\n const pendingGetRequests = new Map<string, Promise<PipelineResponse>>();\n\n return {\n policy: {\n name: 'combine-requests',\n async sendRequest(request, next) {\n if (request.method !== 'GET') return next(request);\n const key = JSON.stringify([request.url, request.body]);\n const response = pendingGetRequests.get(key) ?? next(request);\n pendingGetRequests.set(key, response);\n try {\n return await response;\n } finally {\n pendingGetRequests.delete(key);\n }\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genErrorFormatterPolicy = (\n getMessage: (b: any) => string,\n): AdditionalPolicyConfig => ({\n policy: {\n name: 'error-formatter',\n async sendRequest(request, next) {\n try {\n return await next(request);\n } catch (error) {\n if (!(error instanceof RestError) || error.request == null) throw error;\n if (error.response?.bodyAsText == null) throw error;\n\n let body;\n try {\n body = JSON.parse(error.response.bodyAsText);\n } catch (e) {\n throw error;\n }\n error.message = `${new URL(error.request.url).pathname.slice(1)} error`;\n const message = getMessage(body);\n if (message !== '') error.message += `:${message}`;\n throw error;\n }\n },\n },\n position: 'perCall',\n});\n\nexport const genVersionCheckPolicy = (\n name: string,\n ignorePath: string,\n versionPromise: Promise<string>,\n geVersion: string,\n ltVersion: string,\n): PipelinePolicy => ({\n name: 'version-check',\n async sendRequest(request, next) {\n if (new URL(request.url).pathname === ignorePath) return next(request);\n const args = [await versionPromise, geVersion, ltVersion] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);\n return next(request);\n },\n});\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"file":"autorest.mjs","names":["RestError","pause","semverSatisfies","UnsupportedVersionError","genRequestQueuesPolicy","requestQueues","Map","policy","name","sendRequest","request","next","key","headers","get","delete","getResponse","req","Promise","resolve","then","set","position","genCombineGetRequestsPolicy","pendingGetRequests","method","JSON","stringify","url","body","response","genAggressiveCacheGetResponsesPolicy","getRequests","genErrorFormatterPolicy","getMessage","error","bodyAsText","parse","e","message","URL","pathname","slice","genVersionCheckPolicy","ignorePath","versionPromise","geVersion","ltVersion","args"],"sources":["../../src/utils/autorest.ts"],"sourcesContent":["import { RestError, PipelineResponse, PipelinePolicy } from '@azure/core-rest-pipeline';\nimport { AdditionalPolicyConfig } from '@azure/core-client';\nimport { pause } from './other';\nimport semverSatisfies from './semver-satisfies';\nimport { UnsupportedVersionError } from './errors';\n\nexport const genRequestQueuesPolicy = (): AdditionalPolicyConfig => {\n const requestQueues = new Map<string, Promise<unknown>>();\n\n return {\n policy: {\n name: 'request-queues',\n async sendRequest(request, next) {\n const key = request.headers.get('__queue');\n request.headers.delete('__queue');\n const getResponse = async (): Promise<PipelineResponse> => next(request);\n if (key == null) return getResponse();\n const req = (requestQueues.get(key) ?? Promise.resolve()).then(getResponse, getResponse);\n // TODO: remove after fixing https://github.com/aeternity/aeternity/issues/3803\n // gap to ensure that node won't reject the nonce\n requestQueues.set(key, req.then(async () => pause(750)));\n return req;\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genCombineGetRequestsPolicy = (): AdditionalPolicyConfig => {\n const pendingGetRequests = new Map<string, Promise<PipelineResponse>>();\n\n return {\n policy: {\n name: 'combine-get-requests',\n async sendRequest(request, next) {\n if (request.method !== 'GET') return next(request);\n const key = JSON.stringify([request.url, request.body]);\n const response = pendingGetRequests.get(key) ?? next(request);\n pendingGetRequests.set(key, response);\n try {\n return await response;\n } finally {\n pendingGetRequests.delete(key);\n }\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genAggressiveCacheGetResponsesPolicy = (): PipelinePolicy => {\n const getRequests = new Map<string, Promise<PipelineResponse>>();\n\n return {\n name: 'aggressive-cache-get-responses',\n async sendRequest(request, next) {\n if (request.method !== 'GET') return next(request);\n const key = JSON.stringify([request.url, request.body]);\n const response = getRequests.get(key) ?? next(request);\n getRequests.set(key, response);\n return response;\n },\n };\n};\n\nexport const genErrorFormatterPolicy = (\n getMessage: (b: any) => string,\n): AdditionalPolicyConfig => ({\n policy: {\n name: 'error-formatter',\n async sendRequest(request, next) {\n try {\n return await next(request);\n } catch (error) {\n if (!(error instanceof RestError) || error.request == null) throw error;\n if (error.response?.bodyAsText == null) throw error;\n\n let body;\n try {\n body = JSON.parse(error.response.bodyAsText);\n } catch (e) {\n throw error;\n }\n error.message = `${new URL(error.request.url).pathname.slice(1)} error`;\n const message = getMessage(body);\n if (message !== '') error.message += `:${message}`;\n throw error;\n }\n },\n },\n position: 'perCall',\n});\n\nexport const genVersionCheckPolicy = (\n name: string,\n ignorePath: string,\n versionPromise: Promise<string>,\n geVersion: string,\n ltVersion: string,\n): PipelinePolicy => ({\n name: 'version-check',\n async sendRequest(request, next) {\n if (new URL(request.url).pathname === ignorePath) return next(request);\n const args = [await versionPromise, geVersion, ltVersion] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);\n return next(request);\n },\n});\n"],"mappings":"AAAA,SAASA,SAAS,QAA0C,2BAA2B;AAAC,SAE/EC,KAAK;AAAA,OACPC,eAAe;AAAA,SACbC,uBAAuB;AAEhC,OAAO,MAAMC,sBAAsB,GAAG,MAA8B;EAClE,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAA4B;EAEzD,OAAO;IACLC,MAAM,EAAE;MACNC,IAAI,EAAE,gBA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IAAI,CAACW,KAAK,CAACF,KAAK,CAACL,QAAQ,CAACM,UAAU,CAAC;QAC9C,CAAC,CAAC,OAAOE,CAAC,EAAE;UACV,MAAMH,KAAK;QACb;QACAA,KAAK,CAACI,OAAO,GAAI,GAAE,IAAIC,GAAG,CAACL,KAAK,CAACzB,OAAO,CAACkB,GAAG,CAAC,CAACa,QAAQ,CAACC,KAAK,CAAC,CAAC,CAAE,QAAO;QACvE,MAAMH,OAAO,GAAGL,UAAU,CAACL,IAAI,CAAC;QAChC,IAAIU,OAAO,KAAK,EAAE,EAAEJ,KAAK,CAACI,OAAO,IAAK,IAAGA,OAAQ,EAAC;QAClD,MAAMJ,KAAK;MACb;IACF;EACF,CAAC;EACDb,QAAQ,EAAE;AACZ,CAAC,CAAC;AAEF,OAAO,MAAMqB,qBAAqB,GAAG,CACnCnC,IAAY,EACZoC,UAAkB,EAClBC,cAA+B,EAC/BC,SAAiB,EACjBC,SAAiB,MACG;EACpBvC,IAAI,EAAE,eAAe;EACrB,MAAMC,WAAW,CAACC,OAAO,EAAEC,IAAI,EAAE;IAC/B,IAAI,IAAI6B,GAAG,CAAC9B,OAAO,CAACkB,GAAG,CAAC,CAACa,QAAQ,KAAKG,UAAU,EAAE,OAAOjC,IAAI,CAACD,OAAO,CAAC;IACtE,MAAMsC,IAAI,GAAG,CAAC,MAAMH,cAAc,EAAEC,SAAS,EAAEC,SAAS,CAAU;IAClE,IAAI,CAAC7C,eAAe,CAAC,GAAG8C,IAAI,CAAC,EAAE,MAAM,IAAI7C,uBAAuB,CAACK,IAAI,EAAE,GAAGwC,IAAI,CAAC;IAC/E,OAAOrC,IAAI,CAACD,OAAO,CAAC;EACtB;AACF,CAAC,CAAC"}
|
package/es/utils/bignumber.mjs
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Big Number Helpers
|
|
5
3
|
*/
|
|
6
4
|
import BigNumber from 'bignumber.js';
|
|
5
|
+
|
|
7
6
|
/**
|
|
8
7
|
* Check if value is BigNumber, Number, BigInt or number string representation
|
|
9
8
|
* @param number - number to check
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
10
|
export const isBigNumber = number => {
|
|
13
|
-
var _context;
|
|
14
|
-
|
|
15
11
|
if (typeof number === 'bigint') return true;
|
|
16
|
-
return
|
|
12
|
+
return ['number', 'object', 'string'].includes(typeof number)
|
|
13
|
+
// eslint-disable-next-line no-restricted-globals
|
|
17
14
|
&& (!isNaN(number) || Number.isInteger(number) || BigNumber.isBigNumber(number));
|
|
18
15
|
};
|
|
16
|
+
|
|
19
17
|
/**
|
|
20
18
|
* BigNumber ceil operation
|
|
21
19
|
*/
|
|
22
|
-
|
|
23
20
|
export const ceil = bigNumber => bigNumber.integerValue(BigNumber.ROUND_CEIL);
|
|
24
21
|
//# sourceMappingURL=bignumber.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bignumber.mjs","names":["BigNumber","isBigNumber","number","isNaN","Number","isInteger","ceil","bigNumber","integerValue","ROUND_CEIL"],"sources":["../../src/utils/bignumber.ts"],"sourcesContent":["/**\n * Big Number Helpers\n */\nimport BigNumber from 'bignumber.js';\n\n/**\n * Check if value is BigNumber, Number, BigInt or number string representation\n * @param number - number to check\n */\nexport const isBigNumber = (number: string | number | bigint | BigNumber): boolean => {\n if (typeof number === 'bigint') return true;\n return ['number', 'object', 'string'].includes(typeof number)\n // eslint-disable-next-line no-restricted-globals\n && (!isNaN(number as number) || Number.isInteger(number) || BigNumber.isBigNumber(number));\n};\n\n/**\n * BigNumber ceil operation\n */\nexport const ceil = (bigNumber: BigNumber): BigNumber => bigNumber\n .integerValue(BigNumber.ROUND_CEIL);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bignumber.mjs","names":["BigNumber","isBigNumber","number","includes","isNaN","Number","isInteger","ceil","bigNumber","integerValue","ROUND_CEIL"],"sources":["../../src/utils/bignumber.ts"],"sourcesContent":["/**\n * Big Number Helpers\n */\nimport BigNumber from 'bignumber.js';\n\n/**\n * Check if value is BigNumber, Number, BigInt or number string representation\n * @param number - number to check\n */\nexport const isBigNumber = (number: string | number | bigint | BigNumber): boolean => {\n if (typeof number === 'bigint') return true;\n return ['number', 'object', 'string'].includes(typeof number)\n // eslint-disable-next-line no-restricted-globals\n && (!isNaN(number as number) || Number.isInteger(number) || BigNumber.isBigNumber(number));\n};\n\n/**\n * BigNumber ceil operation\n */\nexport const ceil = (bigNumber: BigNumber): BigNumber => bigNumber\n .integerValue(BigNumber.ROUND_CEIL);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,cAAc;;AAEpC;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAIC,MAA4C,IAAc;EACpF,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE,OAAO,IAAI;EAC3C,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAACC,QAAQ,CAAC,OAAOD,MAAM;EAC1D;EAAA,IACI,CAACE,KAAK,CAACF,MAAM,CAAW,IAAIG,MAAM,CAACC,SAAS,CAACJ,MAAM,CAAC,IAAIF,SAAS,CAACC,WAAW,CAACC,MAAM,CAAC,CAAC;AAC9F,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMK,IAAI,GAAIC,SAAoB,IAAgBA,SAAS,CAC/DC,YAAY,CAACT,SAAS,CAACU,UAAU,CAAC"}
|
package/es/utils/bytes.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
-
/**
|
|
4
|
-
* Convert bignumber to byte array
|
|
5
|
-
* @param x - bignumber instance
|
|
6
|
-
* @returns Buffer
|
|
7
|
-
*/
|
|
8
|
-
export declare function bigNumberToByteArray(x: BigNumber): Buffer;
|
|
9
3
|
/**
|
|
10
4
|
* Convert string, number, or BigNumber to byte array
|
|
11
5
|
* @param val - value to convert
|
|
@@ -13,14 +7,3 @@ export declare function bigNumberToByteArray(x: BigNumber): Buffer;
|
|
|
13
7
|
* @returns Buffer
|
|
14
8
|
*/
|
|
15
9
|
export declare function toBytes(val?: null | string | number | BigNumber, big?: boolean): Buffer;
|
|
16
|
-
/**
|
|
17
|
-
* Convert a string to a Buffer. If encoding is not specified, hex-encoding
|
|
18
|
-
* will be used if the input is valid hex. If the input is valid base64 but
|
|
19
|
-
* not valid hex, base64 will be used. Otherwise, utf8 will be used.
|
|
20
|
-
* @param str - String to be converted.
|
|
21
|
-
* @param enc - Encoding of the input string.
|
|
22
|
-
* @returns Buffer containing the input data.
|
|
23
|
-
*/
|
|
24
|
-
export declare function str2buf(str: string, enc?: BufferEncoding): Buffer;
|
|
25
|
-
export declare const bytesToHex: (b: Uint8Array) => string;
|
|
26
|
-
export declare const hexToBytes: (s: string) => Uint8Array;
|
package/es/utils/bytes.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import _buffer from "buffer";
|
|
|
2
2
|
const {
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
|
-
|
|
6
5
|
/*
|
|
7
6
|
* ISC License (ISC)
|
|
8
7
|
* Copyright 2018 aeternity developers
|
|
@@ -21,58 +20,30 @@ const {
|
|
|
21
20
|
*/
|
|
22
21
|
import BigNumber from 'bignumber.js';
|
|
23
22
|
import { NoSerializerFoundError, TypeError } from "./errors.mjs";
|
|
24
|
-
import { isBase64, isHex } from "./string.mjs";
|
|
25
|
-
/**
|
|
26
|
-
* Convert bignumber to byte array
|
|
27
|
-
* @param x - bignumber instance
|
|
28
|
-
* @returns Buffer
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
export function bigNumberToByteArray(x) {
|
|
32
|
-
if (!x.isInteger()) throw new TypeError(`Unexpected not integer value: ${x.toFixed()}`);
|
|
33
|
-
let hexString = x.toString(16);
|
|
34
|
-
if (hexString.length % 2 === 1) hexString = `0${hexString}`;
|
|
35
|
-
return _Buffer.from(hexString, 'hex');
|
|
36
|
-
}
|
|
37
23
|
/**
|
|
38
24
|
* Convert string, number, or BigNumber to byte array
|
|
39
25
|
* @param val - value to convert
|
|
40
26
|
* @param big - enables force conversion to BigNumber
|
|
41
27
|
* @returns Buffer
|
|
42
28
|
*/
|
|
43
|
-
|
|
29
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
44
30
|
export function toBytes(val) {
|
|
45
31
|
let big = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
46
32
|
// Encode a value to bytes.
|
|
47
33
|
// If the value is an int it will be encoded as bytes big endian
|
|
48
34
|
// Raises ValueError if the input is not an int or string
|
|
49
|
-
if (val === undefined || val === null) return _Buffer.from([]);
|
|
50
35
|
|
|
36
|
+
if (val == null) return _Buffer.from([]);
|
|
51
37
|
if (Number.isInteger(val) || BigNumber.isBigNumber(val) || big) {
|
|
52
38
|
if (!BigNumber.isBigNumber(val)) val = new BigNumber(val);
|
|
53
|
-
|
|
39
|
+
if (!val.isInteger()) throw new TypeError(`Unexpected not integer value: ${val.toFixed()}`);
|
|
40
|
+
let hexString = val.toString(16);
|
|
41
|
+
if (hexString.length % 2 === 1) hexString = `0${hexString}`;
|
|
42
|
+
return _Buffer.from(hexString, 'hex');
|
|
54
43
|
}
|
|
55
|
-
|
|
56
44
|
if (typeof val === 'string') {
|
|
57
45
|
return _Buffer.from(val);
|
|
58
46
|
}
|
|
59
|
-
|
|
60
47
|
throw new NoSerializerFoundError();
|
|
61
48
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Convert a string to a Buffer. If encoding is not specified, hex-encoding
|
|
64
|
-
* will be used if the input is valid hex. If the input is valid base64 but
|
|
65
|
-
* not valid hex, base64 will be used. Otherwise, utf8 will be used.
|
|
66
|
-
* @param str - String to be converted.
|
|
67
|
-
* @param enc - Encoding of the input string.
|
|
68
|
-
* @returns Buffer containing the input data.
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
export function str2buf(str, enc) {
|
|
72
|
-
var _ref;
|
|
73
|
-
|
|
74
|
-
return _Buffer.from(str, (_ref = enc !== null && enc !== void 0 ? enc : isHex(str) ? 'hex' : undefined) !== null && _ref !== void 0 ? _ref : isBase64(str) ? 'base64' : undefined);
|
|
75
|
-
}
|
|
76
|
-
export const bytesToHex = b => _Buffer.from(b).toString('hex');
|
|
77
|
-
export const hexToBytes = s => _Buffer.from(s, 'hex');
|
|
78
49
|
//# sourceMappingURL=bytes.mjs.map
|
package/es/utils/bytes.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.mjs","names":["BigNumber","NoSerializerFoundError","TypeError","
|
|
1
|
+
{"version":3,"file":"bytes.mjs","names":["BigNumber","NoSerializerFoundError","TypeError","toBytes","val","big","from","Number","isInteger","isBigNumber","toFixed","hexString","toString","length"],"sources":["../../src/utils/bytes.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright 2018 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 BigNumber from 'bignumber.js';\nimport { NoSerializerFoundError, TypeError } from './errors';\n\n/**\n * Convert string, number, or BigNumber to byte array\n * @param val - value to convert\n * @param big - enables force conversion to BigNumber\n * @returns Buffer\n */\n// eslint-disable-next-line import/prefer-default-export\nexport function toBytes(val?: null | string | number | BigNumber, big = false): Buffer {\n // Encode a value to bytes.\n // If the value is an int it will be encoded as bytes big endian\n // Raises ValueError if the input is not an int or string\n\n if (val == null) return Buffer.from([]);\n if (Number.isInteger(val) || BigNumber.isBigNumber(val) || big) {\n if (!BigNumber.isBigNumber(val)) val = new BigNumber(val);\n if (!val.isInteger()) throw new TypeError(`Unexpected not integer value: ${val.toFixed()}`);\n let hexString = val.toString(16);\n if (hexString.length % 2 === 1) hexString = `0${hexString}`;\n return Buffer.from(hexString, 'hex');\n }\n if (typeof val === 'string') {\n return Buffer.from(val);\n }\n throw new NoSerializerFoundError();\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,sBAAsB,EAAEC,SAAS;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAO,CAACC,GAAwC,EAAuB;EAAA,IAArBC,GAAG,uEAAG,KAAK;EAC3E;EACA;EACA;;EAEA,IAAID,GAAG,IAAI,IAAI,EAAE,OAAO,QAAOE,IAAI,CAAC,EAAE,CAAC;EACvC,IAAIC,MAAM,CAACC,SAAS,CAACJ,GAAG,CAAC,IAAIJ,SAAS,CAACS,WAAW,CAACL,GAAG,CAAC,IAAIC,GAAG,EAAE;IAC9D,IAAI,CAACL,SAAS,CAACS,WAAW,CAACL,GAAG,CAAC,EAAEA,GAAG,GAAG,IAAIJ,SAAS,CAACI,GAAG,CAAC;IACzD,IAAI,CAACA,GAAG,CAACI,SAAS,EAAE,EAAE,MAAM,IAAIN,SAAS,CAAE,iCAAgCE,GAAG,CAACM,OAAO,EAAG,EAAC,CAAC;IAC3F,IAAIC,SAAS,GAAGP,GAAG,CAACQ,QAAQ,CAAC,EAAE,CAAC;IAChC,IAAID,SAAS,CAACE,MAAM,GAAG,CAAC,KAAK,CAAC,EAAEF,SAAS,GAAI,IAAGA,SAAU,EAAC;IAC3D,OAAO,QAAOL,IAAI,CAACK,SAAS,EAAE,KAAK,CAAC;EACtC;EACA,IAAI,OAAOP,GAAG,KAAK,QAAQ,EAAE;IAC3B,OAAO,QAAOE,IAAI,CAACF,GAAG,CAAC;EACzB;EACA,MAAM,IAAIH,sBAAsB,EAAE;AACpC"}
|
package/es/utils/crypto.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { SignKeyPair } from 'tweetnacl';
|
|
|
3
3
|
import { Encoded, Encoding } from './encoder';
|
|
4
4
|
/**
|
|
5
5
|
* Generate address from secret key
|
|
6
|
-
* @param secret - Private key
|
|
6
|
+
* @param secret - Private key as hex string
|
|
7
7
|
* @returns Public key encoded as address
|
|
8
8
|
*/
|
|
9
9
|
export declare function getAddressFromPriv(secret: string | Uint8Array): Encoded.AccountAddress;
|
|
@@ -68,21 +68,28 @@ export declare function generateKeyPair(raw?: false): {
|
|
|
68
68
|
export declare function sign(data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array;
|
|
69
69
|
/**
|
|
70
70
|
* Verify that signature was signed by public key
|
|
71
|
-
* @param data - Data
|
|
72
|
-
* @param signature - Signature
|
|
73
|
-
* @param
|
|
74
|
-
* @returns
|
|
71
|
+
* @param data - Data that was signed
|
|
72
|
+
* @param signature - Signature of data
|
|
73
|
+
* @param address - Address to verify against
|
|
74
|
+
* @returns is data was signed by address
|
|
75
75
|
*/
|
|
76
|
-
export declare function verify(data: Uint8Array, signature: Uint8Array,
|
|
76
|
+
export declare function verify(data: Uint8Array, signature: Uint8Array, address: Encoded.AccountAddress): boolean;
|
|
77
77
|
export declare function messageToHash(message: string): Buffer;
|
|
78
78
|
export declare function signMessage(message: string, privateKey: string | Buffer): Uint8Array;
|
|
79
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Verify that message was signed by address
|
|
81
|
+
* @param message - Message that was signed
|
|
82
|
+
* @param signature - Signature of message
|
|
83
|
+
* @param address - Address to verify against
|
|
84
|
+
* @returns is data was signed by address
|
|
85
|
+
*/
|
|
86
|
+
export declare function verifyMessage(message: string, signature: Uint8Array, address: Encoded.AccountAddress): boolean;
|
|
80
87
|
/**
|
|
81
88
|
* Check key pair for validity
|
|
82
89
|
*
|
|
83
90
|
* Sign a message, and then verifying that signature
|
|
84
91
|
* @param privateKey - Private key to verify
|
|
85
|
-
* @param publicKey - Public key to verify
|
|
92
|
+
* @param publicKey - Public key to verify as hex string
|
|
86
93
|
* @returns Valid?
|
|
87
94
|
*/
|
|
88
95
|
export declare function isValidKeypair(privateKey: string | Uint8Array, publicKey: string | Uint8Array): boolean;
|
package/es/utils/crypto.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import _buffer from "buffer";
|
|
|
2
2
|
const {
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
|
-
|
|
6
5
|
/*
|
|
7
6
|
* ISC License (ISC)
|
|
8
7
|
* Copyright 2018 aeternity developers
|
|
@@ -19,9 +18,9 @@ const {
|
|
|
19
18
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
19
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
21
20
|
*/
|
|
22
|
-
import nacl from 'tweetnacl';
|
|
21
|
+
import nacl from 'tweetnacl';
|
|
22
|
+
// js extension is required for mjs build, not importing the whole package to reduce bundle size
|
|
23
23
|
// eslint-disable-next-line import/extensions
|
|
24
|
-
|
|
25
24
|
import _blakejsBlake2bJs from 'blakejs/blake2b.js';
|
|
26
25
|
const {
|
|
27
26
|
blake2b
|
|
@@ -30,30 +29,27 @@ import _varuintBitcoin from 'varuint-bitcoin';
|
|
|
30
29
|
const {
|
|
31
30
|
encode: varuintEncode
|
|
32
31
|
} = _varuintBitcoin;
|
|
33
|
-
import { str2buf } from "./bytes.mjs";
|
|
34
32
|
import { concatBuffers } from "./other.mjs";
|
|
35
33
|
import { decode, encode, Encoding } from "./encoder.mjs";
|
|
36
34
|
/**
|
|
37
35
|
* Generate address from secret key
|
|
38
|
-
* @param secret - Private key
|
|
36
|
+
* @param secret - Private key as hex string
|
|
39
37
|
* @returns Public key encoded as address
|
|
40
38
|
*/
|
|
41
|
-
|
|
42
39
|
export function getAddressFromPriv(secret) {
|
|
43
|
-
const secretBuffer = typeof secret === 'string' ?
|
|
40
|
+
const secretBuffer = typeof secret === 'string' ? _Buffer.from(secret, 'hex') : secret;
|
|
44
41
|
const keys = nacl.sign.keyPair.fromSecretKey(secretBuffer);
|
|
45
42
|
return encode(keys.publicKey, Encoding.AccountAddress);
|
|
46
43
|
}
|
|
44
|
+
|
|
47
45
|
/**
|
|
48
46
|
* Check if address is valid
|
|
49
47
|
* @param address - Address
|
|
50
48
|
* @param prefix - Transaction prefix. Default: 'ak'
|
|
51
49
|
* @returns is valid
|
|
52
50
|
*/
|
|
53
|
-
|
|
54
51
|
export function isAddressValid(address) {
|
|
55
52
|
let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Encoding.AccountAddress;
|
|
56
|
-
|
|
57
53
|
try {
|
|
58
54
|
decode(address);
|
|
59
55
|
return true;
|
|
@@ -61,37 +57,38 @@ export function isAddressValid(address) {
|
|
|
61
57
|
return false;
|
|
62
58
|
}
|
|
63
59
|
}
|
|
60
|
+
|
|
64
61
|
/**
|
|
65
62
|
* Generate a random salt (positive integer)
|
|
66
63
|
* @returns random salt
|
|
67
64
|
*/
|
|
68
|
-
|
|
69
65
|
export function genSalt() {
|
|
70
|
-
|
|
66
|
+
const [random] = new BigUint64Array(nacl.randomBytes(8).buffer);
|
|
67
|
+
return Number(random % BigInt(Number.MAX_SAFE_INTEGER));
|
|
71
68
|
}
|
|
69
|
+
|
|
72
70
|
/**
|
|
73
71
|
* Converts a positive integer to the smallest possible
|
|
74
72
|
* representation in a binary digit representation
|
|
75
73
|
* @param value - Value to encode
|
|
76
74
|
* @returns Encoded number
|
|
77
75
|
*/
|
|
78
|
-
|
|
79
76
|
export function encodeUnsigned(value) {
|
|
80
77
|
const binary = _Buffer.allocUnsafe(4);
|
|
81
|
-
|
|
82
78
|
binary.writeUInt32BE(value);
|
|
83
79
|
return binary.slice(binary.findIndex(i => i !== 0));
|
|
84
80
|
}
|
|
81
|
+
|
|
85
82
|
/**
|
|
86
83
|
* Calculate 256bits Blake2b hash of `input`
|
|
87
84
|
* @param input - Data to hash
|
|
88
85
|
* @returns Hash
|
|
89
86
|
*/
|
|
90
|
-
|
|
91
87
|
export function hash(input) {
|
|
92
88
|
return _Buffer.from(blake2b(input, undefined, 32)); // 256 bits
|
|
93
|
-
}
|
|
89
|
+
}
|
|
94
90
|
|
|
91
|
+
// Todo Duplicated in tx builder. remove
|
|
95
92
|
/**
|
|
96
93
|
* Compute contract address
|
|
97
94
|
* @category contract
|
|
@@ -99,22 +96,23 @@ export function hash(input) {
|
|
|
99
96
|
* @param nonce - Round when contract was created
|
|
100
97
|
* @returns Contract address
|
|
101
98
|
*/
|
|
102
|
-
|
|
103
99
|
export function encodeContractAddress(owner, nonce) {
|
|
104
100
|
const publicKey = decode(owner);
|
|
105
101
|
const binary = concatBuffers([publicKey, encodeUnsigned(nonce)]);
|
|
106
102
|
return encode(hash(binary), Encoding.ContractAddress);
|
|
107
|
-
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// KEY-PAIR HELPERS
|
|
108
106
|
|
|
109
107
|
/**
|
|
110
108
|
* Generate keyPair from secret key
|
|
111
109
|
* @param secret - secret key
|
|
112
110
|
* @returns Object with Private(privateKey) and Public(publicKey) keys
|
|
113
111
|
*/
|
|
114
|
-
|
|
115
112
|
export function generateKeyPairFromSecret(secret) {
|
|
116
113
|
return nacl.sign.keyPair.fromSecretKey(secret);
|
|
117
114
|
}
|
|
115
|
+
|
|
118
116
|
/**
|
|
119
117
|
* Generate a random ED25519 keypair
|
|
120
118
|
* @param raw - Whether to return raw (binary) keys
|
|
@@ -124,23 +122,21 @@ export function generateKeyPairFromSecret(secret) {
|
|
|
124
122
|
export function generateKeyPair() {
|
|
125
123
|
let raw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
126
124
|
const keyPair = nacl.sign.keyPair();
|
|
127
|
-
|
|
128
125
|
const publicBuffer = _Buffer.from(keyPair.publicKey);
|
|
129
|
-
|
|
130
126
|
const secretBuffer = _Buffer.from(keyPair.secretKey);
|
|
131
|
-
|
|
132
127
|
if (raw) {
|
|
133
128
|
return {
|
|
134
129
|
publicKey: publicBuffer,
|
|
135
130
|
secretKey: secretBuffer
|
|
136
131
|
};
|
|
137
132
|
}
|
|
138
|
-
|
|
139
133
|
return {
|
|
140
134
|
publicKey: encode(publicBuffer, Encoding.AccountAddress),
|
|
141
135
|
secretKey: secretBuffer.toString('hex')
|
|
142
136
|
};
|
|
143
|
-
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// SIGNATURES
|
|
144
140
|
|
|
145
141
|
/**
|
|
146
142
|
* Generate signature
|
|
@@ -148,48 +144,52 @@ export function generateKeyPair() {
|
|
|
148
144
|
* @param privateKey - Key to sign with
|
|
149
145
|
* @returns Signature
|
|
150
146
|
*/
|
|
151
|
-
|
|
152
147
|
export function sign(data, privateKey) {
|
|
153
148
|
return nacl.sign.detached(_Buffer.from(data), _Buffer.from(privateKey));
|
|
154
149
|
}
|
|
150
|
+
|
|
155
151
|
/**
|
|
156
152
|
* Verify that signature was signed by public key
|
|
157
|
-
* @param data - Data
|
|
158
|
-
* @param signature - Signature
|
|
159
|
-
* @param
|
|
160
|
-
* @returns
|
|
153
|
+
* @param data - Data that was signed
|
|
154
|
+
* @param signature - Signature of data
|
|
155
|
+
* @param address - Address to verify against
|
|
156
|
+
* @returns is data was signed by address
|
|
161
157
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const publicKeyBuffer = typeof publicKey === 'string' ? str2buf(publicKey) : publicKey;
|
|
165
|
-
return nacl.sign.detached.verify(data, signature, publicKeyBuffer);
|
|
158
|
+
export function verify(data, signature, address) {
|
|
159
|
+
return nacl.sign.detached.verify(data, signature, decode(address));
|
|
166
160
|
}
|
|
167
161
|
export function messageToHash(message) {
|
|
168
162
|
const p = _Buffer.from('aeternity Signed Message:\n', 'utf8');
|
|
169
|
-
|
|
170
163
|
const msg = _Buffer.from(message, 'utf8');
|
|
171
|
-
|
|
172
164
|
return hash(concatBuffers([varuintEncode(p.length), p, varuintEncode(msg.length), msg]));
|
|
173
165
|
}
|
|
174
166
|
export function signMessage(message, privateKey) {
|
|
175
167
|
return sign(messageToHash(message), privateKey);
|
|
176
168
|
}
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Verify that message was signed by address
|
|
172
|
+
* @param message - Message that was signed
|
|
173
|
+
* @param signature - Signature of message
|
|
174
|
+
* @param address - Address to verify against
|
|
175
|
+
* @returns is data was signed by address
|
|
176
|
+
*/
|
|
177
|
+
export function verifyMessage(message, signature, address) {
|
|
178
|
+
return verify(messageToHash(message), signature, address);
|
|
179
179
|
}
|
|
180
|
+
|
|
180
181
|
/**
|
|
181
182
|
* Check key pair for validity
|
|
182
183
|
*
|
|
183
184
|
* Sign a message, and then verifying that signature
|
|
184
185
|
* @param privateKey - Private key to verify
|
|
185
|
-
* @param publicKey - Public key to verify
|
|
186
|
+
* @param publicKey - Public key to verify as hex string
|
|
186
187
|
* @returns Valid?
|
|
187
188
|
*/
|
|
188
|
-
|
|
189
189
|
export function isValidKeypair(privateKey, publicKey) {
|
|
190
190
|
const message = _Buffer.from('TheMessage');
|
|
191
|
-
|
|
192
191
|
const signature = sign(message, privateKey);
|
|
193
|
-
|
|
192
|
+
const publicKeyBuffer = typeof publicKey === 'string' ? _Buffer.from(publicKey, 'hex') : publicKey;
|
|
193
|
+
return verify(message, signature, encode(publicKeyBuffer, Encoding.AccountAddress));
|
|
194
194
|
}
|
|
195
195
|
//# sourceMappingURL=crypto.mjs.map
|
package/es/utils/crypto.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.mjs","names":["nacl","str2buf","concatBuffers","decode","encode","Encoding","getAddressFromPriv","secret","secretBuffer","keys","sign","keyPair","fromSecretKey","publicKey","AccountAddress","isAddressValid","address","prefix","e","genSalt","Math","floor","random","Number","MAX_SAFE_INTEGER","encodeUnsigned","value","binary","allocUnsafe","writeUInt32BE","slice","findIndex","i","hash","input","from","blake2b","undefined","encodeContractAddress","owner","nonce","ContractAddress","generateKeyPairFromSecret","generateKeyPair","raw","publicBuffer","secretKey","toString","data","privateKey","detached","verify","signature","publicKeyBuffer","messageToHash","message","p","msg","varuintEncode","length","signMessage","verifyMessage","str","isValidKeypair"],"sources":["../../src/utils/crypto.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright 2018 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 nacl, { SignKeyPair } from 'tweetnacl';\n// js extension is required for mjs build, not importing the whole package to reduce bundle size\n// eslint-disable-next-line import/extensions\nimport { blake2b } from 'blakejs/blake2b.js';\nimport { encode as varuintEncode } from 'varuint-bitcoin';\n\nimport { str2buf } from './bytes';\nimport { concatBuffers } from './other';\nimport {\n decode, encode, Encoded, Encoding,\n} from './encoder';\n\n/**\n * Generate address from secret key\n * @param secret - Private key\n * @returns Public key encoded as address\n */\nexport function getAddressFromPriv(secret: string | Uint8Array): Encoded.AccountAddress {\n const secretBuffer = typeof secret === 'string' ? str2buf(secret) : secret;\n const keys = nacl.sign.keyPair.fromSecretKey(secretBuffer);\n return encode(keys.publicKey, Encoding.AccountAddress);\n}\n\n/**\n * Check if address is valid\n * @param address - Address\n * @param prefix - Transaction prefix. Default: 'ak'\n * @returns is valid\n */\nexport function isAddressValid(\n address: string,\n prefix: Encoding = Encoding.AccountAddress,\n): boolean {\n try {\n decode(address as Encoded.Generic<typeof prefix>);\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * Generate a random salt (positive integer)\n * @returns random salt\n */\nexport function genSalt(): number {\n return Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER));\n}\n\n/**\n * Converts a positive integer to the smallest possible\n * representation in a binary digit representation\n * @param value - Value to encode\n * @returns Encoded number\n */\nexport function encodeUnsigned(value: number): Buffer {\n const binary = Buffer.allocUnsafe(4);\n binary.writeUInt32BE(value);\n return binary.slice(binary.findIndex((i) => i !== 0));\n}\n\n/**\n * Calculate 256bits Blake2b hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function hash(input: string | Uint8Array): Buffer {\n return Buffer.from(blake2b(input, undefined, 32)); // 256 bits\n}\n\n// Todo Duplicated in tx builder. remove\n/**\n * Compute contract address\n * @category contract\n * @param owner - Address of contract owner\n * @param nonce - Round when contract was created\n * @returns Contract address\n */\nexport function encodeContractAddress(\n owner: Encoded.AccountAddress,\n nonce: number,\n): Encoded.ContractAddress {\n const publicKey = decode(owner);\n const binary = concatBuffers([publicKey, encodeUnsigned(nonce)]);\n return encode(hash(binary), Encoding.ContractAddress);\n}\n\n// KEY-PAIR HELPERS\n\n/**\n * Generate keyPair from secret key\n * @param secret - secret key\n * @returns Object with Private(privateKey) and Public(publicKey) keys\n */\nexport function generateKeyPairFromSecret(secret: Uint8Array): SignKeyPair {\n return nacl.sign.keyPair.fromSecretKey(secret);\n}\n\n/**\n * Generate a random ED25519 keypair\n * @param raw - Whether to return raw (binary) keys\n * @returns Key pair\n */\nexport function generateKeyPair(raw: true): { publicKey: Buffer; secretKey: Buffer };\nexport function generateKeyPair(raw?: false): {\n publicKey: Encoded.AccountAddress; secretKey: string;\n};\nexport function generateKeyPair(raw = false): {\n publicKey: Encoded.AccountAddress | Buffer;\n secretKey: string | Buffer;\n} {\n const keyPair = nacl.sign.keyPair();\n const publicBuffer = Buffer.from(keyPair.publicKey);\n const secretBuffer = Buffer.from(keyPair.secretKey);\n\n if (raw) {\n return {\n publicKey: publicBuffer,\n secretKey: secretBuffer,\n };\n }\n return {\n publicKey: encode(publicBuffer, Encoding.AccountAddress),\n secretKey: secretBuffer.toString('hex'),\n };\n}\n\n// SIGNATURES\n\n/**\n * Generate signature\n * @param data - Data to sign\n * @param privateKey - Key to sign with\n * @returns Signature\n */\nexport function sign(data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array {\n return nacl.sign.detached(Buffer.from(data), Buffer.from(privateKey));\n}\n\n/**\n * Verify that signature was signed by public key\n * @param data - Data to verify\n * @param signature - Signature to verify\n * @param publicKey - Key to verify against\n * @returns Valid?\n */\nexport function verify(\n data: Uint8Array,\n signature: Uint8Array,\n publicKey: string | Uint8Array,\n): boolean {\n const publicKeyBuffer = typeof publicKey === 'string' ? str2buf(publicKey) : publicKey;\n return nacl.sign.detached.verify(data, signature, publicKeyBuffer);\n}\n\nexport function messageToHash(message: string): Buffer {\n const p = Buffer.from('aeternity Signed Message:\\n', 'utf8');\n const msg = Buffer.from(message, 'utf8');\n return hash(concatBuffers([varuintEncode(p.length), p, varuintEncode(msg.length), msg]));\n}\n\nexport function signMessage(message: string, privateKey: string | Buffer): Uint8Array {\n return sign(messageToHash(message), privateKey);\n}\n\nexport function verifyMessage(\n str: string,\n signature: Uint8Array,\n publicKey: string | Uint8Array,\n): boolean {\n return verify(messageToHash(str), signature, publicKey);\n}\n\n/**\n * Check key pair for validity\n *\n * Sign a message, and then verifying that signature\n * @param privateKey - Private key to verify\n * @param publicKey - Public key to verify\n * @returns Valid?\n */\nexport function isValidKeypair(\n privateKey: string | Uint8Array,\n publicKey: string | Uint8Array,\n): boolean {\n const message = Buffer.from('TheMessage');\n const signature = sign(message, privateKey);\n return verify(message, signature, publicKey);\n}\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,IAAP,MAAkC,WAAlC,C,CACA;AACA;;AACA,8BAAwB,oBAAxB;;;;AACA,4BAAwC,iBAAxC;;;;SAESC,O;SACAC,a;SAEPC,M,EAAQC,M,EAAiBC,Q;AAG3B;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA4BC,MAA5B,EAAiF;EACtF,MAAMC,YAAY,GAAG,OAAOD,MAAP,KAAkB,QAAlB,GAA6BN,OAAO,CAACM,MAAD,CAApC,GAA+CA,MAApE;EACA,MAAME,IAAI,GAAGT,IAAI,CAACU,IAAL,CAAUC,OAAV,CAAkBC,aAAlB,CAAgCJ,YAAhC,CAAb;EACA,OAAOJ,MAAM,CAACK,IAAI,CAACI,SAAN,EAAiBR,QAAQ,CAACS,cAA1B,CAAb;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,CACLC,OADK,EAGI;EAAA,IADTC,MACS,uEADUZ,QAAQ,CAACS,cACnB;;EACT,IAAI;IACFX,MAAM,CAACa,OAAD,CAAN;IACA,OAAO,IAAP;EACD,CAHD,CAGE,OAAOE,CAAP,EAAU;IACV,OAAO,KAAP;EACD;AACF;AAED;AACA;AACA;AACA;;AACA,OAAO,SAASC,OAAT,GAA2B;EAChC,OAAOC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgBF,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AA6BE,aAAa,CAACD,GAAG,CAACE,MAAL,CAA1C,EAAwDF,GAAxD,CAAD,CAAd,CAAX;AACD;AAED,OAAO,SAASG,WAAT,CAAqBL,OAArB,EAAsCN,UAAtC,EAA+E;EACpF,OAAOvC,IAAI,CAAC4C,aAAa,CAACC,OAAD,CAAd,EAAyBN,UAAzB,CAAX;AACD;AAED,OAAO,SAASY,aAAT,CACLC,GADK,EAELV,SAFK,EAGLvC,SAHK,EAII;EACT,OAAOsC,MAAM,CAACG,aAAa,CAACQ,GAAD,CAAd,EAAqBV,SAArB,EAAgCvC,SAAhC,CAAb;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASkD,cAAT,CACLd,UADK,EAELpC,SAFK,EAGI;EACT,MAAM0C,OAAO,GAAG,QAAOpB,IAAP,CAAY,YAAZ,CAAhB;;EACA,MAAMiB,SAAS,GAAG1C,IAAI,CAAC6C,OAAD,EAAUN,UAAV,CAAtB;EACA,OAAOE,MAAM,CAACI,OAAD,EAAUH,SAAV,EAAqBvC,SAArB,CAAb;AACD"}
|
|
1
|
+
{"version":3,"file":"crypto.mjs","names":["nacl","concatBuffers","decode","encode","Encoding","getAddressFromPriv","secret","secretBuffer","from","keys","sign","keyPair","fromSecretKey","publicKey","AccountAddress","isAddressValid","address","prefix","e","genSalt","random","BigUint64Array","randomBytes","buffer","Number","BigInt","MAX_SAFE_INTEGER","encodeUnsigned","value","binary","allocUnsafe","writeUInt32BE","slice","findIndex","i","hash","input","blake2b","undefined","encodeContractAddress","owner","nonce","ContractAddress","generateKeyPairFromSecret","generateKeyPair","raw","publicBuffer","secretKey","toString","data","privateKey","detached","verify","signature","messageToHash","message","p","msg","varuintEncode","length","signMessage","verifyMessage","isValidKeypair","publicKeyBuffer"],"sources":["../../src/utils/crypto.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright 2018 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 nacl, { SignKeyPair } from 'tweetnacl';\n// js extension is required for mjs build, not importing the whole package to reduce bundle size\n// eslint-disable-next-line import/extensions\nimport { blake2b } from 'blakejs/blake2b.js';\nimport { encode as varuintEncode } from 'varuint-bitcoin';\n\nimport { concatBuffers } from './other';\nimport {\n decode, encode, Encoded, Encoding,\n} from './encoder';\n\n/**\n * Generate address from secret key\n * @param secret - Private key as hex string\n * @returns Public key encoded as address\n */\nexport function getAddressFromPriv(secret: string | Uint8Array): Encoded.AccountAddress {\n const secretBuffer = typeof secret === 'string' ? Buffer.from(secret, 'hex') : secret;\n const keys = nacl.sign.keyPair.fromSecretKey(secretBuffer);\n return encode(keys.publicKey, Encoding.AccountAddress);\n}\n\n/**\n * Check if address is valid\n * @param address - Address\n * @param prefix - Transaction prefix. Default: 'ak'\n * @returns is valid\n */\nexport function isAddressValid(\n address: string,\n prefix: Encoding = Encoding.AccountAddress,\n): boolean {\n try {\n decode(address as Encoded.Generic<typeof prefix>);\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * Generate a random salt (positive integer)\n * @returns random salt\n */\nexport function genSalt(): number {\n const [random] = new BigUint64Array(nacl.randomBytes(8).buffer);\n return Number(random % BigInt(Number.MAX_SAFE_INTEGER));\n}\n\n/**\n * Converts a positive integer to the smallest possible\n * representation in a binary digit representation\n * @param value - Value to encode\n * @returns Encoded number\n */\nexport function encodeUnsigned(value: number): Buffer {\n const binary = Buffer.allocUnsafe(4);\n binary.writeUInt32BE(value);\n return binary.slice(binary.findIndex((i) => i !== 0));\n}\n\n/**\n * Calculate 256bits Blake2b hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function hash(input: string | Uint8Array): Buffer {\n return Buffer.from(blake2b(input, undefined, 32)); // 256 bits\n}\n\n// Todo Duplicated in tx builder. remove\n/**\n * Compute contract address\n * @category contract\n * @param owner - Address of contract owner\n * @param nonce - Round when contract was created\n * @returns Contract address\n */\nexport function encodeContractAddress(\n owner: Encoded.AccountAddress,\n nonce: number,\n): Encoded.ContractAddress {\n const publicKey = decode(owner);\n const binary = concatBuffers([publicKey, encodeUnsigned(nonce)]);\n return encode(hash(binary), Encoding.ContractAddress);\n}\n\n// KEY-PAIR HELPERS\n\n/**\n * Generate keyPair from secret key\n * @param secret - secret key\n * @returns Object with Private(privateKey) and Public(publicKey) keys\n */\nexport function generateKeyPairFromSecret(secret: Uint8Array): SignKeyPair {\n return nacl.sign.keyPair.fromSecretKey(secret);\n}\n\n/**\n * Generate a random ED25519 keypair\n * @param raw - Whether to return raw (binary) keys\n * @returns Key pair\n */\nexport function generateKeyPair(raw: true): { publicKey: Buffer; secretKey: Buffer };\nexport function generateKeyPair(raw?: false): {\n publicKey: Encoded.AccountAddress; secretKey: string;\n};\nexport function generateKeyPair(raw = false): {\n publicKey: Encoded.AccountAddress | Buffer;\n secretKey: string | Buffer;\n} {\n const keyPair = nacl.sign.keyPair();\n const publicBuffer = Buffer.from(keyPair.publicKey);\n const secretBuffer = Buffer.from(keyPair.secretKey);\n\n if (raw) {\n return {\n publicKey: publicBuffer,\n secretKey: secretBuffer,\n };\n }\n return {\n publicKey: encode(publicBuffer, Encoding.AccountAddress),\n secretKey: secretBuffer.toString('hex'),\n };\n}\n\n// SIGNATURES\n\n/**\n * Generate signature\n * @param data - Data to sign\n * @param privateKey - Key to sign with\n * @returns Signature\n */\nexport function sign(data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array {\n return nacl.sign.detached(Buffer.from(data), Buffer.from(privateKey));\n}\n\n/**\n * Verify that signature was signed by public key\n * @param data - Data that was signed\n * @param signature - Signature of data\n * @param address - Address to verify against\n * @returns is data was signed by address\n */\nexport function verify(\n data: Uint8Array,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return nacl.sign.detached.verify(data, signature, decode(address));\n}\n\nexport function messageToHash(message: string): Buffer {\n const p = Buffer.from('aeternity Signed Message:\\n', 'utf8');\n const msg = Buffer.from(message, 'utf8');\n return hash(concatBuffers([varuintEncode(p.length), p, varuintEncode(msg.length), msg]));\n}\n\nexport function signMessage(message: string, privateKey: string | Buffer): Uint8Array {\n return sign(messageToHash(message), privateKey);\n}\n\n/**\n * Verify that message was signed by address\n * @param message - Message that was signed\n * @param signature - Signature of message\n * @param address - Address to verify against\n * @returns is data was signed by address\n */\nexport function verifyMessage(\n message: string,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return verify(messageToHash(message), signature, address);\n}\n\n/**\n * Check key pair for validity\n *\n * Sign a message, and then verifying that signature\n * @param privateKey - Private key to verify\n * @param publicKey - Public key to verify as hex string\n * @returns Valid?\n */\nexport function isValidKeypair(\n privateKey: string | Uint8Array,\n publicKey: string | Uint8Array,\n): boolean {\n const message = Buffer.from('TheMessage');\n const signature = sign(message, privateKey);\n const publicKeyBuffer = typeof publicKey === 'string' ? Buffer.from(publicKey, 'hex') : publicKey;\n return verify(message, signature, encode(publicKeyBuffer, Encoding.AccountAddress));\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,IAAI,MAAuB,WAAW;AAC7C;AACA;AACA,8BAAwB,oBAAoB;AAAC;EAAA;AAAA;AA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ACA;AACA,OAAO,SAAS8C,cAAc,CAC5BZ,UAA+B,EAC/BrC,SAA8B,EACrB;EACT,MAAM0C,OAAO,GAAG,QAAO/C,IAAI,CAAC,YAAY,CAAC;EACzC,MAAM6C,SAAS,GAAG3C,IAAI,CAAC6C,OAAO,EAAEL,UAAU,CAAC;EAC3C,MAAMa,eAAe,GAAG,OAAOlD,SAAS,KAAK,QAAQ,GAAG,QAAOL,IAAI,CAACK,SAAS,EAAE,KAAK,CAAC,GAAGA,SAAS;EACjG,OAAOuC,MAAM,CAACG,OAAO,EAAEF,SAAS,EAAElD,MAAM,CAAC4D,eAAe,EAAE3D,QAAQ,CAACU,cAAc,CAAC,CAAC;AACrF"}
|
|
@@ -31,31 +31,31 @@ export declare enum Encoding {
|
|
|
31
31
|
CallStateTree = "cs",
|
|
32
32
|
Bytearray = "ba"
|
|
33
33
|
}
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
34
|
+
export type KeyBlockHash = `${Encoding.KeyBlockHash}_${string}`;
|
|
35
|
+
export type MicroBlockHash = `${Encoding.MicroBlockHash}_${string}`;
|
|
36
|
+
export type BlockPofHash = `${Encoding.BlockPofHash}_${string}`;
|
|
37
|
+
export type BlockTxHash = `${Encoding.BlockTxHash}_${string}`;
|
|
38
|
+
export type BlockStateHash = `${Encoding.BlockStateHash}_${string}`;
|
|
39
|
+
export type Channel = `${Encoding.Channel}_${string}`;
|
|
40
|
+
export type ContractAddress = `${Encoding.ContractAddress}_${string}`;
|
|
41
|
+
export type ContractBytearray = `${Encoding.ContractBytearray}_${string}`;
|
|
42
|
+
export type ContractStoreKey = `${Encoding.ContractStoreKey}_${string}`;
|
|
43
|
+
export type ContractStoreValue = `${Encoding.ContractStoreValue}_${string}`;
|
|
44
|
+
export type Transaction = `${Encoding.Transaction}_${string}`;
|
|
45
|
+
export type TxHash = `${Encoding.TxHash}_${string}`;
|
|
46
|
+
export type OracleAddress = `${Encoding.OracleAddress}_${string}`;
|
|
47
|
+
export type OracleQuery = `${Encoding.OracleQuery}_${string}`;
|
|
48
|
+
export type OracleQueryId = `${Encoding.OracleQueryId}_${string}`;
|
|
49
|
+
export type OracleResponse = `${Encoding.OracleResponse}_${string}`;
|
|
50
|
+
export type AccountAddress = `${Encoding.AccountAddress}_${string}`;
|
|
51
|
+
export type Signature = `${Encoding.Signature}_${string}`;
|
|
52
|
+
export type Commitment = `${Encoding.Commitment}_${string}`;
|
|
53
|
+
export type PeerPubkey = `${Encoding.PeerPubkey}_${string}`;
|
|
54
|
+
export type Name = `${Encoding.Name}_${string}`;
|
|
55
|
+
export type State = `${Encoding.State}_${string}`;
|
|
56
|
+
export type Poi = `${Encoding.Poi}_${string}`;
|
|
57
|
+
export type StateTrees = `${Encoding.StateTrees}_${string}`;
|
|
58
|
+
export type CallStateTree = `${Encoding.CallStateTree}_${string}`;
|
|
59
|
+
export type Bytearray = `${Encoding.Bytearray}_${string}`;
|
|
60
|
+
export type Generic<Type extends Encoding> = `${Type}_${string}`;
|
|
61
|
+
export type Any = `${Encoding}_${string}`;
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L205-L230}
|
|
5
5
|
*/
|
|
6
6
|
export let Encoding;
|
|
7
|
-
|
|
8
7
|
(function (Encoding) {
|
|
9
8
|
Encoding["KeyBlockHash"] = "kh";
|
|
10
9
|
Encoding["MicroBlockHash"] = "mh";
|