@aeternity/aepp-sdk 12.1.2 → 13.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +6580 -8860
- 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 +27 -185
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +124 -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 +7 -12
- package/es/Node.mjs +34 -47
- 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 +111 -0
- package/es/account/Generalized.mjs.map +1 -0
- package/es/account/Ledger.d.ts +28 -0
- package/es/account/Ledger.mjs +101 -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 -65
- 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 +3 -3
- package/es/aens.mjs +42 -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.mjs +3 -7
- 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 +4 -41
- 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 +1 -1
- package/es/chain.mjs +33 -58
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +195 -0
- package/es/channel/Base.mjs +290 -0
- package/es/channel/Base.mjs.map +1 -0
- package/es/channel/Contract.d.ts +247 -0
- package/es/channel/Contract.mjs +420 -0
- package/es/channel/Contract.mjs.map +1 -0
- package/es/channel/Spend.d.ts +217 -0
- package/es/channel/Spend.mjs +383 -0
- package/es/channel/Spend.mjs.map +1 -0
- package/es/channel/handlers.d.ts +8 -21
- package/es/channel/handlers.mjs +141 -891
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +27 -21
- package/es/channel/internal.mjs +98 -190
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/{Compiler.d.ts → CompilerHttp.d.ts} +3 -3
- package/es/contract/{Compiler.mjs → CompilerHttp.mjs} +8 -13
- package/es/contract/CompilerHttp.mjs.map +1 -0
- package/es/contract/Contract.d.ts +235 -0
- package/es/contract/Contract.mjs +534 -0
- package/es/contract/Contract.mjs.map +1 -0
- package/es/contract/ga.d.ts +7 -33
- package/es/contract/ga.mjs +20 -112
- package/es/contract/ga.mjs.map +1 -1
- package/es/index.d.ts +9 -6
- package/es/index.mjs +8 -6
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +5 -5
- package/es/oracle.mjs +33 -39
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +3 -3
- package/es/spend.mjs +17 -20
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/constants.d.ts +2 -1
- package/es/tx/builder/constants.mjs +12 -12
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/address.d.ts +15 -0
- package/es/tx/builder/field-types/address.mjs +42 -0
- package/es/tx/builder/field-types/address.mjs.map +1 -0
- package/es/tx/builder/field-types/addresses.d.ts +6 -0
- package/es/tx/builder/field-types/addresses.mjs +13 -0
- package/es/tx/builder/field-types/addresses.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +1 -2
- 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/deposit.d.ts +0 -1
- 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/enumeration.d.ts +5 -0
- package/es/tx/builder/field-types/enumeration.mjs +21 -0
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +1 -9
- package/es/tx/builder/field-types/fee.mjs +9 -25
- 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.mjs +4 -9
- 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 +23 -11
- package/es/tx/builder/field-types/index.mjs +10 -3
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/name-fee.d.ts +0 -1
- 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 +4 -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/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/u-int.d.ts +1 -1
- 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 +1 -21
- package/es/tx/builder/index.mjs +29 -148
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +336 -176
- package/es/tx/builder/schema.mjs +71 -78
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +3 -33
- package/es/tx/index.mjs +26 -43
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +2 -2
- package/es/tx/validator.mjs +86 -59
- 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 +12 -6
- package/es/utils/errors.mjs +87 -163
- 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/mptree.d.ts +1 -1
- package/es/utils/mptree.mjs +4 -26
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +3 -1
- 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 +87 -48
- package/src/AeSdk.ts +15 -11
- package/src/AeSdkAepp.ts +9 -7
- package/src/AeSdkBase.ts +28 -202
- package/src/AeSdkMethods.ts +170 -0
- package/src/AeSdkWallet.ts +16 -47
- package/src/Node.ts +11 -15
- 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 +10 -9
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +5 -4
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
- 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 +6 -3
- package/src/channel/Base.ts +327 -0
- package/src/channel/Contract.ts +487 -0
- package/src/channel/Spend.ts +403 -0
- package/src/channel/handlers.ts +154 -573
- package/src/channel/internal.ts +113 -142
- package/src/contract/{Compiler.ts → CompilerHttp.ts} +5 -5
- package/src/contract/Contract.ts +620 -0
- package/src/contract/ga.ts +18 -104
- package/src/index.ts +9 -8
- package/src/oracle.ts +7 -7
- package/src/spend.ts +5 -13
- package/src/tx/builder/constants.ts +1 -0
- package/src/tx/builder/field-types/address.ts +52 -0
- package/src/tx/builder/field-types/addresses.ts +18 -0
- package/src/tx/builder/field-types/coin-amount.ts +2 -8
- package/src/tx/builder/field-types/enumeration.ts +21 -0
- package/src/tx/builder/field-types/fee.ts +1 -3
- package/src/tx/builder/field-types/gas-limit.ts +2 -2
- package/src/tx/builder/field-types/gas-price.ts +0 -2
- package/src/tx/builder/field-types/index.ts +16 -6
- package/src/tx/builder/field-types/name-fee.ts +1 -1
- 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/u-int.ts +3 -2
- package/src/tx/builder/helpers.ts +10 -60
- package/src/tx/builder/index.ts +6 -65
- package/src/tx/builder/schema.ts +89 -100
- package/src/tx/index.ts +19 -15
- package/src/tx/validator.ts +36 -18
- package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
- package/src/utils/autorest.ts +16 -1
- package/src/utils/bytes.ts +5 -33
- package/src/utils/crypto.ts +23 -16
- package/src/utils/encoder.ts +0 -1
- package/src/utils/errors.ts +18 -12
- 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 +141 -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 +18 -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 +248 -0
- package/types-legacy/ts4.2/channel/Base.d.ts +194 -0
- package/types-legacy/ts4.2/channel/Contract.d.ts +247 -0
- package/types-legacy/ts4.2/channel/Spend.d.ts +217 -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/CompilerHttp.d.ts +18 -0
- package/types-legacy/ts4.2/contract/Contract.d.ts +237 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +43 -0
- package/types-legacy/ts4.2/globals.d.ts +16 -0
- package/types-legacy/ts4.2/index.d.ts +39 -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 +71 -0
- package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +22 -0
- package/types-legacy/ts4.2/tx/builder/field-types/addresses.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/deposit.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -0
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +17 -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 +12 -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 +85 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +19 -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/short-u-int.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +8 -0
- package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +68 -0
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2963 -0
- package/types-legacy/ts4.2/tx/index.d.ts +34 -0
- package/types-legacy/ts4.2/tx/validator.d.ts +20 -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 +480 -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/mptree.d.ts +32 -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 +141 -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 +18 -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 +248 -0
- package/types-legacy/ts4.5/channel/Base.d.ts +194 -0
- package/types-legacy/ts4.5/channel/Contract.d.ts +247 -0
- package/types-legacy/ts4.5/channel/Spend.d.ts +217 -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/CompilerHttp.d.ts +18 -0
- package/types-legacy/ts4.5/contract/Contract.d.ts +237 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +43 -0
- package/types-legacy/ts4.5/index.d.ts +38 -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 +71 -0
- package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +22 -0
- package/types-legacy/ts4.5/tx/builder/field-types/addresses.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/deposit.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -0
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +17 -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 +12 -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 +85 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +19 -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/short-u-int.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +8 -0
- package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +68 -0
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2963 -0
- package/types-legacy/ts4.5/tx/index.d.ts +34 -0
- package/types-legacy/ts4.5/tx/validator.d.ts +20 -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 +480 -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/mptree.d.ts +32 -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.mjs.map +0 -1
- package/es/contract/aci.d.ts +0 -127
- package/es/contract/aci.mjs +0 -509
- 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/src/channel/index.ts +0 -1025
- package/src/contract/aci.ts +0 -538
- 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
|
@@ -18,10 +18,10 @@ import BigNumber from 'bignumber.js';
|
|
|
18
18
|
import { isBigNumber } from "./bignumber.mjs";
|
|
19
19
|
import { ArgumentError } from "./errors.mjs";
|
|
20
20
|
export let AE_AMOUNT_FORMATS;
|
|
21
|
+
|
|
21
22
|
/**
|
|
22
23
|
* DENOMINATION_MAGNITUDE
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
25
|
(function (AE_AMOUNT_FORMATS) {
|
|
26
26
|
AE_AMOUNT_FORMATS["AE"] = "ae";
|
|
27
27
|
AE_AMOUNT_FORMATS["MILI_AE"] = "miliAE";
|
|
@@ -31,7 +31,6 @@ export let AE_AMOUNT_FORMATS;
|
|
|
31
31
|
AE_AMOUNT_FORMATS["FEMTO_AE"] = "femtoAE";
|
|
32
32
|
AE_AMOUNT_FORMATS["AETTOS"] = "aettos";
|
|
33
33
|
})(AE_AMOUNT_FORMATS || (AE_AMOUNT_FORMATS = {}));
|
|
34
|
-
|
|
35
34
|
const DENOMINATION_MAGNITUDE = {
|
|
36
35
|
[AE_AMOUNT_FORMATS.AE]: 0,
|
|
37
36
|
[AE_AMOUNT_FORMATS.MILI_AE]: -3,
|
|
@@ -41,6 +40,7 @@ const DENOMINATION_MAGNITUDE = {
|
|
|
41
40
|
[AE_AMOUNT_FORMATS.FEMTO_AE]: -15,
|
|
42
41
|
[AE_AMOUNT_FORMATS.AETTOS]: -18
|
|
43
42
|
};
|
|
43
|
+
|
|
44
44
|
/**
|
|
45
45
|
* Convert amount from one to other denomination
|
|
46
46
|
* @param value - amount to convert
|
|
@@ -49,7 +49,6 @@ const DENOMINATION_MAGNITUDE = {
|
|
|
49
49
|
* @param options.targetDenomination - target denomination,
|
|
50
50
|
* can be ['ae', 'aettos']
|
|
51
51
|
*/
|
|
52
|
-
|
|
53
52
|
export const formatAmount = (value, _ref) => {
|
|
54
53
|
let {
|
|
55
54
|
denomination = AE_AMOUNT_FORMATS.AETTOS,
|
|
@@ -58,13 +57,13 @@ export const formatAmount = (value, _ref) => {
|
|
|
58
57
|
if (!isBigNumber(value)) throw new ArgumentError('value', 'a number', value);
|
|
59
58
|
return new BigNumber(typeof value === 'bigint' ? value.toString() : value).shiftedBy(DENOMINATION_MAGNITUDE[denomination] - DENOMINATION_MAGNITUDE[targetDenomination]).toFixed();
|
|
60
59
|
};
|
|
60
|
+
|
|
61
61
|
/**
|
|
62
62
|
* Convert amount to AE
|
|
63
63
|
* @param value - amount to convert
|
|
64
64
|
* @param options - options
|
|
65
65
|
* @param options.denomination - denomination of amount, can be ['ae', 'aettos']
|
|
66
66
|
*/
|
|
67
|
-
|
|
68
67
|
export const toAe = function (value) {
|
|
69
68
|
let {
|
|
70
69
|
denomination = AE_AMOUNT_FORMATS.AETTOS
|
|
@@ -74,13 +73,13 @@ export const toAe = function (value) {
|
|
|
74
73
|
targetDenomination: AE_AMOUNT_FORMATS.AE
|
|
75
74
|
});
|
|
76
75
|
};
|
|
76
|
+
|
|
77
77
|
/**
|
|
78
78
|
* Convert amount to aettos
|
|
79
79
|
* @param value - amount to convert
|
|
80
80
|
* @param options - options
|
|
81
81
|
* @param options.denomination - denomination of amount, can be ['ae', 'aettos']
|
|
82
82
|
*/
|
|
83
|
-
|
|
84
83
|
export const toAettos = function (value) {
|
|
85
84
|
let {
|
|
86
85
|
denomination = AE_AMOUNT_FORMATS.AE
|
|
@@ -102,18 +101,13 @@ const prefixes = [{
|
|
|
102
101
|
name: 'pico',
|
|
103
102
|
magnitude: -12
|
|
104
103
|
}];
|
|
105
|
-
|
|
106
104
|
const getNearestPrefix = exponent => prefixes.reduce((p, n) => Math.abs(n.magnitude - exponent) < Math.abs(p.magnitude - exponent) ? n : p);
|
|
107
|
-
|
|
108
105
|
const getLowerBoundPrefix = exponent => {
|
|
109
106
|
var _prefixes$find;
|
|
110
|
-
|
|
111
107
|
return (_prefixes$find = prefixes.find(p => p.magnitude <= exponent)) !== null && _prefixes$find !== void 0 ? _prefixes$find : prefixes[prefixes.length - 1];
|
|
112
108
|
};
|
|
113
|
-
|
|
114
109
|
export default (rawValue => {
|
|
115
110
|
var _value$e;
|
|
116
|
-
|
|
117
111
|
const value = new BigNumber(rawValue);
|
|
118
112
|
const exp = (_value$e = value.e) !== null && _value$e !== void 0 ? _value$e : 0;
|
|
119
113
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount-formatter.mjs","names":["BigNumber","isBigNumber","ArgumentError","AE_AMOUNT_FORMATS","DENOMINATION_MAGNITUDE","AE","MILI_AE","MICRO_AE","NANO_AE","PICO_AE","FEMTO_AE","AETTOS","formatAmount","value","denomination","targetDenomination","toString","shiftedBy","toFixed","toAe","toAettos","prefixes","name","magnitude","getNearestPrefix","exponent","reduce","p","n","Math","abs","getLowerBoundPrefix","find","length","rawValue","exp","e","v","precision","min"],"sources":["../../src/utils/amount-formatter.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 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 { isBigNumber } from './bignumber';\nimport { ArgumentError } from './errors';\n\nexport enum AE_AMOUNT_FORMATS {\n AE = 'ae',\n MILI_AE = 'miliAE',\n MICRO_AE = 'microAE',\n NANO_AE = 'nanoAE',\n PICO_AE = 'picoAE',\n FEMTO_AE = 'femtoAE',\n AETTOS = 'aettos',\n}\n\n/**\n * DENOMINATION_MAGNITUDE\n */\nconst DENOMINATION_MAGNITUDE = {\n [AE_AMOUNT_FORMATS.AE]: 0,\n [AE_AMOUNT_FORMATS.MILI_AE]: -3,\n [AE_AMOUNT_FORMATS.MICRO_AE]: -6,\n [AE_AMOUNT_FORMATS.NANO_AE]: -9,\n [AE_AMOUNT_FORMATS.PICO_AE]: -12,\n [AE_AMOUNT_FORMATS.FEMTO_AE]: -15,\n [AE_AMOUNT_FORMATS.AETTOS]: -18,\n} as const;\n\n/**\n * Convert amount from one to other denomination\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n * @param options.targetDenomination - target denomination,\n * can be ['ae', 'aettos']\n */\nexport const formatAmount = (\n value: string | number | bigint | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AETTOS, targetDenomination = AE_AMOUNT_FORMATS.AETTOS }:\n { denomination?: AE_AMOUNT_FORMATS; targetDenomination?: AE_AMOUNT_FORMATS },\n): string => {\n if (!isBigNumber(value)) throw new ArgumentError('value', 'a number', value);\n\n return new BigNumber(typeof value === 'bigint' ? value.toString() : value)\n .shiftedBy(DENOMINATION_MAGNITUDE[denomination] - DENOMINATION_MAGNITUDE[targetDenomination])\n .toFixed();\n};\n\n/**\n * Convert amount to AE\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n */\nexport const toAe = (\n value: string | number | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AETTOS }: { denomination?: AE_AMOUNT_FORMATS } = {},\n): string => formatAmount(value, { denomination, targetDenomination: AE_AMOUNT_FORMATS.AE });\n\n/**\n * Convert amount to aettos\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n */\nexport const toAettos = (\n value: string | number | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AE }: { denomination?: AE_AMOUNT_FORMATS } = {},\n): string => formatAmount(value, { denomination });\n\ninterface Prefix {\n name: string;\n magnitude: number;\n}\n\nconst prefixes: Prefix[] = [\n { name: 'exa', magnitude: 18 },\n { name: 'giga', magnitude: 9 },\n { name: '', magnitude: 0 },\n { name: 'pico', magnitude: -12 },\n];\n\nconst getNearestPrefix = (exponent: number): Prefix => prefixes.reduce((p, n) => (\n Math.abs(n.magnitude - exponent) < Math.abs(p.magnitude - exponent) ? n : p));\n\nconst getLowerBoundPrefix = (exponent: number): Prefix => prefixes\n .find((p) => p.magnitude <= exponent) ?? prefixes[prefixes.length - 1];\n\nexport default (rawValue: string | number | BigNumber): string => {\n const value: BigNumber = new BigNumber(rawValue);\n\n const exp = value.e ?? 0;\n const { name, magnitude } = (exp < 0 ? getNearestPrefix : getLowerBoundPrefix)(exp);\n const v = value\n .shiftedBy(-magnitude)\n .precision(9 + Math.min(exp - magnitude, 0))\n .toFixed();\n return `${v}${name !== '' ? ' ' : ''}${name}`;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,
|
|
1
|
+
{"version":3,"file":"amount-formatter.mjs","names":["BigNumber","isBigNumber","ArgumentError","AE_AMOUNT_FORMATS","DENOMINATION_MAGNITUDE","AE","MILI_AE","MICRO_AE","NANO_AE","PICO_AE","FEMTO_AE","AETTOS","formatAmount","value","denomination","targetDenomination","toString","shiftedBy","toFixed","toAe","toAettos","prefixes","name","magnitude","getNearestPrefix","exponent","reduce","p","n","Math","abs","getLowerBoundPrefix","find","length","rawValue","exp","e","v","precision","min"],"sources":["../../src/utils/amount-formatter.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 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 { isBigNumber } from './bignumber';\nimport { ArgumentError } from './errors';\n\nexport enum AE_AMOUNT_FORMATS {\n AE = 'ae',\n MILI_AE = 'miliAE',\n MICRO_AE = 'microAE',\n NANO_AE = 'nanoAE',\n PICO_AE = 'picoAE',\n FEMTO_AE = 'femtoAE',\n AETTOS = 'aettos',\n}\n\n/**\n * DENOMINATION_MAGNITUDE\n */\nconst DENOMINATION_MAGNITUDE = {\n [AE_AMOUNT_FORMATS.AE]: 0,\n [AE_AMOUNT_FORMATS.MILI_AE]: -3,\n [AE_AMOUNT_FORMATS.MICRO_AE]: -6,\n [AE_AMOUNT_FORMATS.NANO_AE]: -9,\n [AE_AMOUNT_FORMATS.PICO_AE]: -12,\n [AE_AMOUNT_FORMATS.FEMTO_AE]: -15,\n [AE_AMOUNT_FORMATS.AETTOS]: -18,\n} as const;\n\n/**\n * Convert amount from one to other denomination\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n * @param options.targetDenomination - target denomination,\n * can be ['ae', 'aettos']\n */\nexport const formatAmount = (\n value: string | number | bigint | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AETTOS, targetDenomination = AE_AMOUNT_FORMATS.AETTOS }:\n { denomination?: AE_AMOUNT_FORMATS; targetDenomination?: AE_AMOUNT_FORMATS },\n): string => {\n if (!isBigNumber(value)) throw new ArgumentError('value', 'a number', value);\n\n return new BigNumber(typeof value === 'bigint' ? value.toString() : value)\n .shiftedBy(DENOMINATION_MAGNITUDE[denomination] - DENOMINATION_MAGNITUDE[targetDenomination])\n .toFixed();\n};\n\n/**\n * Convert amount to AE\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n */\nexport const toAe = (\n value: string | number | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AETTOS }: { denomination?: AE_AMOUNT_FORMATS } = {},\n): string => formatAmount(value, { denomination, targetDenomination: AE_AMOUNT_FORMATS.AE });\n\n/**\n * Convert amount to aettos\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n */\nexport const toAettos = (\n value: string | number | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AE }: { denomination?: AE_AMOUNT_FORMATS } = {},\n): string => formatAmount(value, { denomination });\n\ninterface Prefix {\n name: string;\n magnitude: number;\n}\n\nconst prefixes: Prefix[] = [\n { name: 'exa', magnitude: 18 },\n { name: 'giga', magnitude: 9 },\n { name: '', magnitude: 0 },\n { name: 'pico', magnitude: -12 },\n];\n\nconst getNearestPrefix = (exponent: number): Prefix => prefixes.reduce((p, n) => (\n Math.abs(n.magnitude - exponent) < Math.abs(p.magnitude - exponent) ? n : p));\n\nconst getLowerBoundPrefix = (exponent: number): Prefix => prefixes\n .find((p) => p.magnitude <= exponent) ?? prefixes[prefixes.length - 1];\n\nexport default (rawValue: string | number | BigNumber): string => {\n const value: BigNumber = new BigNumber(rawValue);\n\n const exp = value.e ?? 0;\n const { name, magnitude } = (exp < 0 ? getNearestPrefix : getLowerBoundPrefix)(exp);\n const v = value\n .shiftedBy(-magnitude)\n .precision(9 + Math.min(exp - magnit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AA,yBAAaJ,QAAQ,CAC/DW,IAAI,CAAEL,CAAC,IAAKA,CAAC,CAACJ,SAAS,IAAIE,QAAQ,CAAC,2DAAIJ,QAAQ,CAACA,QAAQ,CAACY,MAAM,GAAG,CAAC,CAAC;AAAA;AAExE,gBAAgBC,QAAqC,IAAa;EAAA;EAChE,MAAMrB,KAAgB,GAAG,IAAIb,SAAS,CAACkC,QAAQ,CAAC;EAEhD,MAAMC,GAAG,eAAGtB,KAAK,CAACuB,CAAC,+CAAI,CAAC;EACxB,MAAM;IAAEd,IAAI;IAAEC;EAAU,CAAC,GAAG,CAACY,GAAG,GAAG,CAAC,GAAGX,gBAAgB,GAAGO,mBAAmB,EAAEI,GAAG,CAAC;EACnF,MAAME,CAAC,GAAGxB,KAAK,CACZI,SAAS,CAAC,CAACM,SAAS,CAAC,CACrBe,SAAS,CAAC,CAAC,GAAGT,IAAI,CAACU,GAAG,CAACJ,GAAG,GAAGZ,SAAS,EAAE,CAAC,CAAC,CAAC,CAC3CL,OAAO,EAAE;EACZ,OAAQ,GAAEmB,CAAE,GAAEf,IAAI,KAAK,EAAE,GAAG,GAAG,GAAG,EAAG,GAAEA,IAAK,EAAC;AAC/C,CAAC"}
|
package/es/utils/autorest.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import { PipelinePolicy } from '@azure/core-rest-pipeline';
|
|
|
2
2
|
import { AdditionalPolicyConfig } from '@azure/core-client';
|
|
3
3
|
export declare const genRequestQueuesPolicy: () => AdditionalPolicyConfig;
|
|
4
4
|
export declare const genCombineGetRequestsPolicy: () => AdditionalPolicyConfig;
|
|
5
|
+
export declare const genAggressiveCacheGetResponsesPolicy: () => PipelinePolicy;
|
|
5
6
|
export declare const genErrorFormatterPolicy: (getMessage: (b: any) => string) => AdditionalPolicyConfig;
|
|
6
7
|
export declare const genVersionCheckPolicy: (name: string, ignorePath: string, versionPromise: Promise<string>, geVersion: string, ltVersion: string) => PipelinePolicy;
|
package/es/utils/autorest.mjs
CHANGED
|
@@ -7,23 +7,18 @@ export const genRequestQueuesPolicy = () => {
|
|
|
7
7
|
return {
|
|
8
8
|
policy: {
|
|
9
9
|
name: 'request-queues',
|
|
10
|
-
|
|
11
10
|
async sendRequest(request, next) {
|
|
12
11
|
var _requestQueues$get;
|
|
13
|
-
|
|
14
12
|
const key = request.headers.get('__queue');
|
|
15
13
|
request.headers.delete('__queue');
|
|
16
|
-
|
|
17
14
|
const getResponse = async () => next(request);
|
|
18
|
-
|
|
19
15
|
if (key == null) return getResponse();
|
|
20
|
-
const req = ((_requestQueues$get = requestQueues.get(key)) !== null && _requestQueues$get !== void 0 ? _requestQueues$get : Promise.resolve()).then(getResponse, getResponse);
|
|
16
|
+
const req = ((_requestQueues$get = requestQueues.get(key)) !== null && _requestQueues$get !== void 0 ? _requestQueues$get : Promise.resolve()).then(getResponse, getResponse);
|
|
17
|
+
// TODO: remove after fixing https://github.com/aeternity/aeternity/issues/3803
|
|
21
18
|
// gap to ensure that node won't reject the nonce
|
|
22
|
-
|
|
23
19
|
requestQueues.set(key, req.then(async () => pause(750)));
|
|
24
20
|
return req;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
},
|
|
28
23
|
position: 'perCall'
|
|
29
24
|
};
|
|
@@ -32,66 +27,69 @@ export const genCombineGetRequestsPolicy = () => {
|
|
|
32
27
|
const pendingGetRequests = new Map();
|
|
33
28
|
return {
|
|
34
29
|
policy: {
|
|
35
|
-
name: 'combine-requests',
|
|
36
|
-
|
|
30
|
+
name: 'combine-get-requests',
|
|
37
31
|
async sendRequest(request, next) {
|
|
38
32
|
var _pendingGetRequests$g;
|
|
39
|
-
|
|
40
33
|
if (request.method !== 'GET') return next(request);
|
|
41
34
|
const key = JSON.stringify([request.url, request.body]);
|
|
42
35
|
const response = (_pendingGetRequests$g = pendingGetRequests.get(key)) !== null && _pendingGetRequests$g !== void 0 ? _pendingGetRequests$g : next(request);
|
|
43
36
|
pendingGetRequests.set(key, response);
|
|
44
|
-
|
|
45
37
|
try {
|
|
46
38
|
return await response;
|
|
47
39
|
} finally {
|
|
48
40
|
pendingGetRequests.delete(key);
|
|
49
41
|
}
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
},
|
|
53
44
|
position: 'perCall'
|
|
54
45
|
};
|
|
55
46
|
};
|
|
47
|
+
export const genAggressiveCacheGetResponsesPolicy = () => {
|
|
48
|
+
const getRequests = new Map();
|
|
49
|
+
return {
|
|
50
|
+
name: 'aggressive-cache-get-responses',
|
|
51
|
+
async sendRequest(request, next) {
|
|
52
|
+
var _getRequests$get;
|
|
53
|
+
if (request.method !== 'GET') return next(request);
|
|
54
|
+
const key = JSON.stringify([request.url, request.body]);
|
|
55
|
+
const response = (_getRequests$get = getRequests.get(key)) !== null && _getRequests$get !== void 0 ? _getRequests$get : next(request);
|
|
56
|
+
getRequests.set(key, response);
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
56
61
|
export const genErrorFormatterPolicy = getMessage => ({
|
|
57
62
|
policy: {
|
|
58
63
|
name: 'error-formatter',
|
|
59
|
-
|
|
60
64
|
async sendRequest(request, next) {
|
|
61
65
|
try {
|
|
62
66
|
return await next(request);
|
|
63
67
|
} catch (error) {
|
|
64
68
|
var _error$response;
|
|
65
|
-
|
|
66
69
|
if (!(error instanceof RestError) || error.request == null) throw error;
|
|
67
70
|
if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.bodyAsText) == null) throw error;
|
|
68
71
|
let body;
|
|
69
|
-
|
|
70
72
|
try {
|
|
71
73
|
body = JSON.parse(error.response.bodyAsText);
|
|
72
74
|
} catch (e) {
|
|
73
75
|
throw error;
|
|
74
76
|
}
|
|
75
|
-
|
|
76
77
|
error.message = `${new URL(error.request.url).pathname.slice(1)} error`;
|
|
77
78
|
const message = getMessage(body);
|
|
78
79
|
if (message !== '') error.message += `:${message}`;
|
|
79
80
|
throw error;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
|
|
83
83
|
},
|
|
84
84
|
position: 'perCall'
|
|
85
85
|
});
|
|
86
86
|
export const genVersionCheckPolicy = (name, ignorePath, versionPromise, geVersion, ltVersion) => ({
|
|
87
87
|
name: 'version-check',
|
|
88
|
-
|
|
89
88
|
async sendRequest(request, next) {
|
|
90
89
|
if (new URL(request.url).pathname === ignorePath) return next(request);
|
|
91
90
|
const args = [await versionPromise, geVersion, ltVersion];
|
|
92
91
|
if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);
|
|
93
92
|
return next(request);
|
|
94
93
|
}
|
|
95
|
-
|
|
96
94
|
});
|
|
97
95
|
//# sourceMappingURL=autorest.mjs.map
|
|
@@ -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,gBAAgB;MACtB,MAAMC,WAAW,CAACC,OAAO,EAAEC,IAAI,EAAE;QAAA;QAC/B,MAAMC,GAAG,GAAGF,OAAO,CAACG,OAAO,CAACC,GAAG,CAAC,SAAS,CAAC;QAC1CJ,OAAO,CAACG,OAAO,CAACE,MAAM,CAAC,SAAS,CAAC;QACjC,MAAMC,WAAW,GAAG,YAAuCL,IAAI,CAACD,OAAO,CAAC;QACxE,IAAIE,GAAG,IAAI,IAAI,EAAE,OAAOI,WAAW,EAAE;QACrC,MAAMC,GAAG,GAAG,uBAACZ,aAAa,CAACS,GAAG,CAACF,GAAG,CAAC,mEAAIM,OAAO,CAACC,OAAO,EAAE,EAAEC,IAAI,CAACJ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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 === undefined || 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","undefined","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 === undefined || 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,KAAKE,SAAS,IAAIF,GAAG,KAAK,IAAI,EAAE,OAAO,QAAOG,IAAI,CAAC,EAAE,CAAC;EAC7D,IAAIC,MAAM,CAACC,SAAS,CAACL,GAAG,CAAC,IAAIJ,SAAS,CAACU,WAAW,CAACN,GAAG,CAAC,IAAIC,GAAG,EAAE;IAC9D,IAAI,CAACL,SAAS,CAACU,WAAW,CAACN,GAAG,CAAC,EAAEA,GAAG,GAAG,IAAIJ,SAAS,CAACI,GAAG,CAAC;IACzD,IAAI,CAACA,GAAG,CAACK,SAAS,EAAE,EAAE,MAAM,IAAIP,SAAS,CAAE,iCAAgCE,GAAG,CAACO,OAAO,EAAG,EAAC,CAAC;IAC3F,IAAIC,SAAS,GAAGR,GAAG,CAACS,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,OAAOR,GAAG,KAAK,QAAQ,EAAE;IAC3B,OAAO,QAAOG,IAAI,CAACH,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;
|