@aeternity/aepp-sdk 13.0.0-alpha.1 → 13.0.0-beta.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/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 +1792 -1525
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +11 -12
- package/es/AeSdkMethods.mjs +6 -8
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/AeSdkWallet.mjs +1 -1
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +5 -1
- package/es/Node.mjs +11 -5
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +11 -6
- package/es/account/Base.mjs +0 -17
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.mjs +11 -24
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.mjs.map +1 -1
- package/es/account/LedgerFactory.mjs.map +1 -1
- package/es/account/Memory.d.ts +2 -1
- package/es/account/Memory.mjs +9 -21
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +12 -14
- package/es/aens.mjs +17 -31
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
- package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +0 -16
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -5
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/compiler/compiler.d.ts +1 -1
- package/es/apis/compiler/compiler.mjs +4 -20
- package/es/apis/compiler/compiler.mjs.map +1 -1
- package/es/apis/compiler/models/index.d.ts +3 -2
- package/es/apis/compiler/models/index.mjs.map +1 -1
- package/es/apis/compiler/models/mappers.d.ts +1 -1
- package/es/apis/compiler/models/mappers.mjs +19 -2
- package/es/apis/compiler/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +15 -15
- package/es/apis/node/models/index.mjs.map +1 -1
- package/es/apis/node/models/mappers.d.ts +1 -1
- package/es/apis/node/models/mappers.mjs +2 -1
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/apis/node/models/parameters.d.ts +2 -2
- package/es/apis/node/models/parameters.mjs +2 -2
- package/es/apis/node/models/parameters.mjs.map +1 -1
- package/es/apis/node/node.mjs +3 -19
- package/es/apis/node/node.mjs.map +1 -1
- package/es/chain.d.ts +8 -8
- package/es/chain.mjs +19 -22
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +25 -12
- package/es/channel/Base.mjs +23 -26
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.mjs +8 -21
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +4 -2
- package/es/channel/Spend.mjs +0 -16
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +6 -18
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +19 -2
- package/es/channel/internal.mjs +19 -19
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +30 -85
- package/es/contract/Contract.mjs +174 -211
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +7 -14
- package/es/contract/compiler/Base.mjs.map +1 -1
- package/es/contract/compiler/Cli.mjs +5 -11
- package/es/contract/compiler/Cli.mjs.map +1 -1
- package/es/contract/compiler/Http.mjs +6 -30
- package/es/contract/compiler/Http.mjs.map +1 -1
- package/es/contract/compiler/HttpNode.mjs.map +1 -1
- package/es/contract/compiler/getFileSystem.mjs.map +1 -1
- package/es/contract/delegation-signature.d.ts +43 -0
- package/es/contract/delegation-signature.mjs +45 -0
- package/es/contract/delegation-signature.mjs.map +1 -0
- package/es/contract/ga.d.ts +23 -7
- package/es/contract/ga.mjs +52 -27
- package/es/contract/ga.mjs.map +1 -1
- package/es/index-browser.d.ts +4 -3
- package/es/index-browser.mjs +6 -20
- package/es/index-browser.mjs.map +1 -1
- package/es/oracle.d.ts +12 -17
- package/es/oracle.mjs +28 -48
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +19 -27
- package/es/spend.mjs +20 -43
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/SchemaTypes.d.ts +37 -0
- package/es/tx/builder/SchemaTypes.mjs +2 -0
- package/es/tx/builder/SchemaTypes.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +4 -2
- package/es/tx/builder/constants.mjs +2 -0
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.d.ts +11 -2
- package/es/tx/builder/field-types/abi-version.mjs +24 -4
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
- package/es/tx/builder/field-types/address.mjs.map +1 -1
- package/es/tx/builder/field-types/array.d.ts +1 -1
- package/es/tx/builder/field-types/array.mjs.map +1 -1
- package/es/tx/builder/field-types/boolean.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +3 -4
- package/es/tx/builder/field-types/coin-amount.mjs +4 -5
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.d.ts +22 -3
- package/es/tx/builder/field-types/ct-version.mjs +32 -4
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
- package/es/tx/builder/field-types/deposit.d.ts +2 -1
- package/es/tx/builder/field-types/deposit.mjs +3 -2
- package/es/tx/builder/field-types/deposit.mjs.map +1 -1
- package/es/tx/builder/field-types/encoded.d.ts +1 -1
- package/es/tx/builder/field-types/encoded.mjs.map +1 -1
- package/es/tx/builder/field-types/entry.mjs +3 -0
- package/es/tx/builder/field-types/entry.mjs.map +1 -1
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +3 -1
- package/es/tx/builder/field-types/fee.mjs +5 -1
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/field.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.d.ts +3 -2
- package/es/tx/builder/field-types/gas-limit.mjs +4 -2
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +3 -1
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
- package/es/tx/builder/field-types/index.d.ts +52 -13
- package/es/tx/builder/field-types/index.mjs +10 -2
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/map.d.ts +13 -0
- package/es/tx/builder/field-types/map.mjs +49 -0
- package/es/tx/builder/field-types/map.mjs.map +1 -0
- package/es/tx/builder/field-types/mptree.d.ts +7 -2
- package/es/tx/builder/field-types/mptree.mjs +5 -7
- package/es/tx/builder/field-types/mptree.mjs.map +1 -1
- package/es/tx/builder/field-types/name-fee.d.ts +1 -1
- package/es/tx/builder/field-types/name-fee.mjs +2 -2
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
- package/es/tx/builder/field-types/name-id.mjs.map +1 -1
- package/es/tx/builder/field-types/name.mjs.map +1 -1
- package/es/tx/builder/field-types/nonce.d.ts +14 -0
- package/es/tx/builder/field-types/nonce.mjs +29 -0
- package/es/tx/builder/field-types/nonce.mjs.map +1 -0
- package/es/tx/builder/field-types/pointers.mjs.map +1 -1
- package/es/tx/builder/field-types/raw.mjs.map +1 -1
- package/es/tx/builder/field-types/short-u-int-const.d.ts +4 -2
- package/es/tx/builder/field-types/short-u-int-const.mjs +12 -8
- package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -1
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/string.mjs.map +1 -1
- package/es/tx/builder/field-types/ttl.d.ts +11 -0
- package/es/tx/builder/field-types/ttl.mjs +21 -0
- package/es/tx/builder/field-types/ttl.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/wrapped.d.ts +14 -0
- package/es/tx/builder/field-types/wrapped.mjs +22 -0
- package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +20 -20
- package/es/tx/builder/index.mjs +54 -64
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2735 -2865
- package/es/tx/builder/schema.generated.d.ts +2011 -0
- package/es/tx/builder/schema.generated.mjs +2 -0
- package/es/tx/builder/schema.generated.mjs.map +1 -0
- package/es/tx/builder/schema.mjs +459 -155
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/execution-cost.d.ts +35 -0
- package/es/tx/execution-cost.mjs +123 -0
- package/es/tx/execution-cost.mjs.map +1 -0
- package/es/tx/transaction-signer.d.ts +6 -0
- package/es/tx/transaction-signer.mjs +27 -0
- package/es/tx/transaction-signer.mjs.map +1 -0
- package/es/tx/validator.mjs +60 -109
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/amount-formatter.mjs +0 -16
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.d.ts +3 -2
- package/es/utils/autorest.mjs +43 -11
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bytes.mjs +0 -16
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.mjs +0 -16
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +14 -31
- package/es/utils/errors.mjs +2 -32
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/other.d.ts +1 -1
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.mjs +0 -17
- package/es/utils/string.mjs.map +1 -1
- package/package.json +34 -30
- package/src/AeSdkMethods.ts +11 -16
- package/src/AeSdkWallet.ts +1 -1
- package/src/Node.ts +17 -6
- package/src/account/Base.ts +11 -22
- package/src/account/Generalized.ts +8 -23
- package/src/account/Memory.ts +14 -21
- package/src/aens.ts +31 -47
- package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +0 -17
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
- package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
- package/src/aepp-wallet-communication/rpc/types.ts +6 -2
- package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
- package/src/apis/compiler/compiler.ts +3 -27
- package/src/apis/compiler/models/index.ts +3 -2
- package/src/apis/compiler/models/mappers.ts +15 -2
- package/src/apis/node/models/index.ts +16 -15
- package/src/apis/node/models/mappers.ts +2 -1
- package/src/apis/node/models/parameters.ts +2 -2
- package/src/apis/node/node.ts +3 -27
- package/src/chain.ts +28 -27
- package/src/channel/Base.ts +33 -33
- package/src/channel/Contract.ts +8 -23
- package/src/channel/Spend.ts +2 -17
- package/src/channel/handlers.ts +5 -18
- package/src/channel/internal.ts +40 -22
- package/src/contract/Contract.ts +133 -163
- package/src/contract/compiler/Base.ts +7 -14
- package/src/contract/compiler/Cli.ts +5 -11
- package/src/contract/compiler/Http.ts +6 -25
- package/src/contract/delegation-signature.ts +56 -0
- package/src/contract/ga.ts +53 -32
- package/src/index-browser.ts +12 -20
- package/src/oracle.ts +46 -56
- package/src/spend.ts +33 -67
- package/src/tx/builder/SchemaTypes.ts +79 -0
- package/src/tx/builder/constants.ts +2 -0
- package/src/tx/builder/field-types/abi-version.ts +29 -6
- package/src/tx/builder/field-types/array.ts +1 -1
- package/src/tx/builder/field-types/coin-amount.ts +6 -4
- package/src/tx/builder/field-types/ct-version.ts +37 -4
- package/src/tx/builder/field-types/deposit.ts +3 -1
- package/src/tx/builder/field-types/encoded.ts +1 -1
- package/src/tx/builder/field-types/entry.ts +8 -3
- package/src/tx/builder/field-types/fee.ts +6 -4
- package/src/tx/builder/field-types/gas-limit.ts +2 -2
- package/src/tx/builder/field-types/index.ts +15 -1
- package/src/tx/builder/field-types/map.ts +45 -0
- package/src/tx/builder/field-types/mptree.ts +4 -3
- package/src/tx/builder/field-types/name-fee.ts +2 -1
- package/src/tx/builder/field-types/nonce.ts +40 -0
- package/src/tx/builder/field-types/short-u-int-const.ts +18 -8
- package/src/tx/builder/field-types/ttl.ts +24 -0
- package/src/tx/builder/field-types/wrapped.ts +32 -0
- package/src/tx/builder/index.ts +57 -71
- package/src/tx/builder/schema.generated.ts +2013 -0
- package/src/tx/builder/schema.ts +544 -624
- package/src/tx/execution-cost.ts +146 -0
- package/src/tx/transaction-signer.ts +27 -0
- package/src/tx/validator.ts +60 -91
- package/src/utils/amount-formatter.ts +0 -16
- package/src/utils/autorest.ts +52 -11
- package/src/utils/bytes.ts +0 -16
- package/src/utils/crypto.ts +0 -16
- package/src/utils/errors.ts +15 -44
- package/src/utils/string.ts +0 -17
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +11 -12
- package/types-legacy/ts4.2/Node.d.ts +5 -1
- package/types-legacy/ts4.2/account/Base.d.ts +11 -6
- package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
- package/types-legacy/ts4.2/aens.d.ts +12 -14
- package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
- package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
- package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
- package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.2/chain.d.ts +8 -8
- package/types-legacy/ts4.2/channel/Base.d.ts +25 -12
- package/types-legacy/ts4.2/channel/Spend.d.ts +4 -2
- package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.2/contract/Contract.d.ts +29 -84
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +7 -14
- package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +23 -7
- package/types-legacy/ts4.2/index-browser.d.ts +4 -3
- package/types-legacy/ts4.2/oracle.d.ts +12 -17
- package/types-legacy/ts4.2/spend.d.ts +19 -27
- package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -2
- package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +11 -2
- package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +3 -4
- package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +33 -3
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +2 -1
- package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +3 -1
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +3 -2
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +52 -13
- package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
- package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +7 -2
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +4 -2
- package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +23 -20
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2962 -4629
- package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
- package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
- package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
- package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.2/utils/errors.d.ts +14 -31
- package/types-legacy/ts4.2/utils/other.d.ts +1 -1
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +11 -12
- package/types-legacy/ts4.5/Node.d.ts +5 -1
- package/types-legacy/ts4.5/account/Base.d.ts +11 -6
- package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
- package/types-legacy/ts4.5/aens.d.ts +12 -14
- package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
- package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
- package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
- package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
- package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
- package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
- package/types-legacy/ts4.5/chain.d.ts +8 -8
- package/types-legacy/ts4.5/channel/Base.d.ts +25 -12
- package/types-legacy/ts4.5/channel/Spend.d.ts +4 -2
- package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.5/contract/Contract.d.ts +29 -84
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +7 -14
- package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +23 -7
- package/types-legacy/ts4.5/index-browser.d.ts +4 -3
- package/types-legacy/ts4.5/oracle.d.ts +12 -17
- package/types-legacy/ts4.5/spend.d.ts +19 -27
- package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -2
- package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +11 -2
- package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +3 -4
- package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +33 -3
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +2 -1
- package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +3 -1
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +3 -2
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +52 -13
- package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
- package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +7 -2
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +4 -2
- package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +23 -20
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2962 -4629
- package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
- package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
- package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
- package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.5/utils/errors.d.ts +14 -31
- package/types-legacy/ts4.5/utils/other.d.ts +1 -1
- package/es/tx/index.d.ts +0 -19
- package/es/tx/index.mjs +0 -115
- package/es/tx/index.mjs.map +0 -1
- package/src/apis/compiler/code-model-v4.yaml +0 -2442
- package/src/apis/node/code-model-v4.yaml +0 -10080
- package/src/tx/index.ts +0 -129
- package/types-legacy/ts4.2/tx/index.d.ts +0 -19
- package/types-legacy/ts4.5/tx/index.d.ts +0 -19
package/es/tx/validator.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import _buffer from "buffer";
|
|
|
2
2
|
const {
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
|
-
import BigNumber from 'bignumber.js';
|
|
6
5
|
import { hash, verify } from "../utils/crypto.mjs";
|
|
7
6
|
import { ProtocolToVmAbi } from "./builder/field-types/ct-version.mjs";
|
|
8
7
|
import { Tag } from "./builder/constants.mjs";
|
|
@@ -11,17 +10,18 @@ import { concatBuffers, isAccountNotFoundError } from "../utils/other.mjs";
|
|
|
11
10
|
import { decode } from "../utils/encoder.mjs";
|
|
12
11
|
import Node from "../Node.mjs";
|
|
13
12
|
import { genAggressiveCacheGetResponsesPolicy } from "../utils/autorest.mjs";
|
|
13
|
+
import { UnexpectedTsError } from "../utils/errors.mjs";
|
|
14
|
+
import getTransactionSignerAddress from "./transaction-signer.mjs";
|
|
15
|
+
import { getExecutionCostUsingNode } from "./execution-cost.mjs";
|
|
14
16
|
const validators = [];
|
|
15
|
-
const getSenderAddress = tx => ['senderId', 'accountId', 'ownerId', 'callerId', 'oracleId', 'fromId', 'initiator', 'gaId', 'payerId'].map(key => tx[key]).filter(a => a).map(a => a === null || a === void 0 ? void 0 : a.toString().replace(/^ok_/, 'ak_'))[0];
|
|
16
17
|
async function verifyTransactionInternal(tx, node, parentTxTypes) {
|
|
17
|
-
|
|
18
|
-
const address = (_getSenderAddress = getSenderAddress(tx)) !== null && _getSenderAddress !== void 0 ? _getSenderAddress : tx.tag === Tag.SignedTx ? getSenderAddress(tx.encodedTx) : undefined;
|
|
18
|
+
const address = getTransactionSignerAddress(buildTx(tx));
|
|
19
19
|
const [account, {
|
|
20
20
|
height
|
|
21
21
|
}, {
|
|
22
22
|
consensusProtocolVersion,
|
|
23
23
|
nodeNetworkId
|
|
24
|
-
}] = await Promise.all([
|
|
24
|
+
}] = await Promise.all([node.getAccountByPubkey(address).catch(error => {
|
|
25
25
|
if (!isAccountNotFoundError(error)) throw error;
|
|
26
26
|
return {
|
|
27
27
|
id: address,
|
|
@@ -34,7 +34,7 @@ async function verifyTransactionInternal(tx, node, parentTxTypes) {
|
|
|
34
34
|
...acc,
|
|
35
35
|
id: acc.id
|
|
36
36
|
})), node.getCurrentKeyBlockHeight(), node.getNodeInfo()]);
|
|
37
|
-
return (await Promise.all(validators.map(v => v(tx, {
|
|
37
|
+
return (await Promise.all(validators.map(async v => v(tx, {
|
|
38
38
|
node,
|
|
39
39
|
account,
|
|
40
40
|
height,
|
|
@@ -56,23 +56,24 @@ async function verifyTransactionInternal(tx, node, parentTxTypes) {
|
|
|
56
56
|
*/
|
|
57
57
|
export default async function verifyTransaction(transaction, nodeNotCached) {
|
|
58
58
|
const node = new Node(nodeNotCached.$host, {
|
|
59
|
-
ignoreVersion: true
|
|
59
|
+
ignoreVersion: true,
|
|
60
|
+
pipeline: nodeNotCached.pipeline.clone(),
|
|
61
|
+
additionalPolicies: [genAggressiveCacheGetResponsesPolicy()]
|
|
60
62
|
});
|
|
61
|
-
node.pipeline.addPolicy(genAggressiveCacheGetResponsesPolicy());
|
|
62
63
|
return verifyTransactionInternal(unpackTx(transaction), node, []);
|
|
63
64
|
}
|
|
64
|
-
validators.push((
|
|
65
|
-
let {
|
|
66
|
-
encodedTx,
|
|
67
|
-
signatures
|
|
68
|
-
} = _ref;
|
|
65
|
+
validators.push((tx, _ref) => {
|
|
69
66
|
let {
|
|
70
67
|
account,
|
|
71
68
|
nodeNetworkId,
|
|
72
69
|
parentTxTypes
|
|
73
|
-
} =
|
|
70
|
+
} = _ref;
|
|
71
|
+
if (tx.tag !== Tag.SignedTx) return [];
|
|
72
|
+
const {
|
|
73
|
+
encodedTx,
|
|
74
|
+
signatures
|
|
75
|
+
} = tx;
|
|
74
76
|
if ((encodedTx !== null && encodedTx !== void 0 ? encodedTx : signatures) == null) return [];
|
|
75
|
-
if (account == null) return [];
|
|
76
77
|
if (signatures.length !== 1) return []; // TODO: Support multisignature like in state channels
|
|
77
78
|
const prefix = _Buffer.from([nodeNetworkId, ...(parentTxTypes.includes(Tag.PayingForTx) ? ['inner_tx'] : [])].join('-'));
|
|
78
79
|
const txBinary = decode(buildTx(encodedTx));
|
|
@@ -84,70 +85,50 @@ validators.push((_ref, _ref2) => {
|
|
|
84
85
|
key: 'InvalidSignature',
|
|
85
86
|
checkedKeys: ['encodedTx', 'signatures']
|
|
86
87
|
}];
|
|
87
|
-
}, async (
|
|
88
|
-
let {
|
|
89
|
-
encodedTx,
|
|
90
|
-
tx,
|
|
91
|
-
tag
|
|
92
|
-
} = _ref3;
|
|
88
|
+
}, async (tx, _ref2) => {
|
|
93
89
|
let {
|
|
94
90
|
node,
|
|
95
91
|
parentTxTypes
|
|
96
|
-
} =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
} = _ref2;
|
|
93
|
+
let nestedTx;
|
|
94
|
+
if ('encodedTx' in tx) nestedTx = tx.encodedTx;
|
|
95
|
+
if ('tx' in tx) nestedTx = tx.tx;
|
|
96
|
+
if (nestedTx == null) return [];
|
|
97
|
+
return verifyTransactionInternal(nestedTx, node, [...parentTxTypes, tx.tag]);
|
|
98
|
+
}, (tx, _ref3) => {
|
|
103
99
|
let {
|
|
104
100
|
height
|
|
105
|
-
} =
|
|
106
|
-
if (ttl
|
|
107
|
-
ttl
|
|
108
|
-
if (ttl === 0 || ttl >= height) return [];
|
|
101
|
+
} = _ref3;
|
|
102
|
+
if (!('ttl' in tx)) return [];
|
|
103
|
+
if (tx.ttl === 0 || tx.ttl >= height) return [];
|
|
109
104
|
return [{
|
|
110
|
-
message: `TTL ${ttl} is already expired, current height is ${height}`,
|
|
105
|
+
message: `TTL ${tx.ttl} is already expired, current height is ${height}`,
|
|
111
106
|
key: 'ExpiredTTL',
|
|
112
107
|
checkedKeys: ['ttl']
|
|
113
108
|
}];
|
|
114
|
-
}, (
|
|
115
|
-
var _ref9, _fee;
|
|
116
|
-
let {
|
|
117
|
-
amount,
|
|
118
|
-
fee,
|
|
119
|
-
nameFee,
|
|
120
|
-
tx,
|
|
121
|
-
tag
|
|
122
|
-
} = _ref7;
|
|
109
|
+
}, async (tx, _ref4) => {
|
|
123
110
|
let {
|
|
124
111
|
account,
|
|
125
|
-
parentTxTypes
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (cost.lte(account.balance.toString())) return [];
|
|
112
|
+
parentTxTypes,
|
|
113
|
+
node
|
|
114
|
+
} = _ref4;
|
|
115
|
+
if (parentTxTypes.length !== 0) return [];
|
|
116
|
+
const cost = await getExecutionCostUsingNode(buildTx(tx), node).catch(() => 0n);
|
|
117
|
+
if (cost <= account.balance) return [];
|
|
132
118
|
return [{
|
|
133
|
-
message: `Account balance ${account.balance
|
|
119
|
+
message: `Account balance ${account.balance} is not enough to execute the transaction that costs ${cost}`,
|
|
134
120
|
key: 'InsufficientBalance',
|
|
135
|
-
checkedKeys: ['amount', 'fee', 'nameFee']
|
|
121
|
+
checkedKeys: ['amount', 'fee', 'nameFee', 'gasLimit', 'gasPrice']
|
|
136
122
|
}];
|
|
137
|
-
}, (
|
|
138
|
-
let {
|
|
139
|
-
signatures,
|
|
140
|
-
tag
|
|
141
|
-
} = _ref10;
|
|
123
|
+
}, (tx, _ref5) => {
|
|
142
124
|
let {
|
|
143
125
|
account
|
|
144
|
-
} =
|
|
145
|
-
if (account == null) return [];
|
|
126
|
+
} = _ref5;
|
|
146
127
|
let message;
|
|
147
|
-
if (tag === Tag.SignedTx && account.kind === 'generalized' && signatures.length !== 0) {
|
|
128
|
+
if (tx.tag === Tag.SignedTx && account.kind === 'generalized' && tx.signatures.length !== 0) {
|
|
148
129
|
message = 'Generalized account can\'t be used to generate SignedTx with signatures';
|
|
149
130
|
}
|
|
150
|
-
if (tag === Tag.GaMetaTx && account.kind === 'basic') {
|
|
131
|
+
if (tx.tag === Tag.GaMetaTx && account.kind === 'basic') {
|
|
151
132
|
message = 'Basic account can\'t be used to generate GaMetaTx';
|
|
152
133
|
}
|
|
153
134
|
if (message == null) return [];
|
|
@@ -156,50 +137,25 @@ validators.push((_ref, _ref2) => {
|
|
|
156
137
|
key: 'InvalidAccountType',
|
|
157
138
|
checkedKeys: ['tag']
|
|
158
139
|
}];
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
let {
|
|
164
|
-
account,
|
|
165
|
-
parentTxTypes
|
|
166
|
-
} = _ref13;
|
|
167
|
-
if (nonce == null || account == null || parentTxTypes.includes(Tag.GaMetaTx)) return [];
|
|
168
|
-
nonce = +nonce;
|
|
169
|
-
const validNonce = account.nonce + 1;
|
|
170
|
-
if (nonce === validNonce) return [];
|
|
171
|
-
return [{
|
|
172
|
-
...(nonce < validNonce ? {
|
|
173
|
-
message: `Nonce ${nonce} is already used, valid nonce is ${validNonce}`,
|
|
174
|
-
key: 'NonceAlreadyUsed'
|
|
175
|
-
} : {
|
|
176
|
-
message: `Nonce ${nonce} is too high, valid nonce is ${validNonce}`,
|
|
177
|
-
key: 'NonceHigh'
|
|
178
|
-
}),
|
|
179
|
-
checkedKeys: ['nonce']
|
|
180
|
-
}];
|
|
181
|
-
}, (_ref14, _ref15) => {
|
|
182
|
-
var _ref16, _ref17;
|
|
183
|
-
let {
|
|
184
|
-
ctVersion,
|
|
185
|
-
abiVersion,
|
|
186
|
-
tag
|
|
187
|
-
} = _ref14;
|
|
140
|
+
},
|
|
141
|
+
// TODO: revert nonce check
|
|
142
|
+
(tx, _ref6) => {
|
|
143
|
+
var _ref7, _ref8;
|
|
188
144
|
let {
|
|
189
145
|
consensusProtocolVersion
|
|
190
|
-
} =
|
|
191
|
-
const oracleCall = Tag.Oracle === tag || Tag.OracleRegisterTx === tag;
|
|
192
|
-
const contractCreate = Tag.ContractCreateTx === tag || Tag.GaAttachTx === tag;
|
|
193
|
-
const contractCall = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag;
|
|
194
|
-
const type = (
|
|
146
|
+
} = _ref6;
|
|
147
|
+
const oracleCall = Tag.Oracle === tx.tag || Tag.OracleRegisterTx === tx.tag;
|
|
148
|
+
const contractCreate = Tag.ContractCreateTx === tx.tag || Tag.GaAttachTx === tx.tag;
|
|
149
|
+
const contractCall = Tag.ContractCallTx === tx.tag || Tag.GaMetaTx === tx.tag;
|
|
150
|
+
const type = (_ref7 = (_ref8 = oracleCall ? 'oracle-call' : null) !== null && _ref8 !== void 0 ? _ref8 : contractCreate ? 'contract-create' : null) !== null && _ref7 !== void 0 ? _ref7 : contractCall ? 'contract-call' : null;
|
|
195
151
|
if (type == null) return [];
|
|
196
|
-
// TODO: remove assertion after fixing buildTx types
|
|
197
152
|
const protocol = ProtocolToVmAbi[consensusProtocolVersion][type];
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
abiVersion
|
|
153
|
+
let ctVersion;
|
|
154
|
+
if ('abiVersion' in tx) ctVersion = {
|
|
155
|
+
abiVersion: tx.abiVersion
|
|
202
156
|
};
|
|
157
|
+
if ('ctVersion' in tx) ctVersion = tx.ctVersion;
|
|
158
|
+
if (ctVersion == null) throw new UnexpectedTsError();
|
|
203
159
|
if (!protocol.abiVersion.includes(ctVersion.abiVersion) || contractCreate && !protocol.vmVersion.includes(ctVersion.vmVersion)) {
|
|
204
160
|
return [{
|
|
205
161
|
message: `ABI/VM version ${JSON.stringify(ctVersion)} is wrong, supported is: ${JSON.stringify(protocol)}`,
|
|
@@ -208,23 +164,18 @@ validators.push((_ref, _ref2) => {
|
|
|
208
164
|
}];
|
|
209
165
|
}
|
|
210
166
|
return [];
|
|
211
|
-
}, async (
|
|
212
|
-
let {
|
|
213
|
-
contractId,
|
|
214
|
-
tag
|
|
215
|
-
} = _ref18;
|
|
167
|
+
}, async (tx, _ref9) => {
|
|
216
168
|
let {
|
|
217
169
|
node
|
|
218
|
-
} =
|
|
219
|
-
if (Tag.ContractCallTx !== tag) return [];
|
|
220
|
-
contractId = contractId;
|
|
170
|
+
} = _ref9;
|
|
171
|
+
if (Tag.ContractCallTx !== tx.tag) return [];
|
|
221
172
|
try {
|
|
222
173
|
const {
|
|
223
174
|
active
|
|
224
|
-
} = await node.getContract(contractId);
|
|
175
|
+
} = await node.getContract(tx.contractId);
|
|
225
176
|
if (active) return [];
|
|
226
177
|
return [{
|
|
227
|
-
message: `Contract ${contractId} is not active`,
|
|
178
|
+
message: `Contract ${tx.contractId} is not active`,
|
|
228
179
|
key: 'ContractNotActive',
|
|
229
180
|
checkedKeys: ['contractId']
|
|
230
181
|
}];
|
package/es/tx/validator.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.mjs","names":["BigNumber","hash","verify","ProtocolToVmAbi","Tag","buildTx","unpackTx","concatBuffers","isAccountNotFoundError","decode","Node","genAggressiveCacheGetResponsesPolicy","validators","getSenderAddress","tx","map","key","filter","a","toString","replace","verifyTransactionInternal","node","parentTxTypes","address","tag","SignedTx","encodedTx","undefined","account","height","consensusProtocolVersion","nodeNetworkId","Promise","all","getAccountByPubkey","catch","error","id","balance","nonce","then","acc","getCurrentKeyBlockHeight","getNodeInfo","v","flat","verifyTransaction","transaction","nodeNotCached","$host","ignoreVersion","pipeline","addPolicy","push","signatures","length","prefix","from","includes","PayingForTx","join","txBinary","txWithNetworkId","txHashWithNetworkId","message","checkedKeys","ttl","amount","fee","nameFee","cost","plus","minus","lte","toFixed","kind","GaMetaTx","validNonce","ctVersion","abiVersion","oracleCall","Oracle","OracleRegisterTx","contractCreate","ContractCreateTx","GaAttachTx","contractCall","ContractCallTx","type","protocol","vmVersion","JSON","stringify","contractId","active","getContract","response","parsedBody","reason"],"sources":["../../src/tx/validator.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { hash, verify } from '../utils/crypto';\nimport { RawTxObject, TxParamsCommon, TxSchema } from './builder/schema';\nimport { ProtocolToVmAbi } from './builder/field-types/ct-version';\nimport { Tag, ConsensusProtocolVersion } from './builder/constants';\nimport { buildTx, unpackTx } from './builder';\nimport { concatBuffers, isAccountNotFoundError } from '../utils/other';\nimport { Encoded, decode } from '../utils/encoder';\nimport Node, { TransformNodeType } from '../Node';\nimport { Account } from '../apis/node';\nimport { genAggressiveCacheGetResponsesPolicy } from '../utils/autorest';\n\nexport interface ValidatorResult {\n message: string;\n key: string;\n checkedKeys: string[];\n}\n\ntype UnpackedTx = ReturnType<typeof unpackTx>['tx'];\n\ntype Validator = (\n tx: UnpackedTx,\n options: {\n // TODO: remove after fixing node types\n account?: TransformNodeType<Account> & { id: Encoded.AccountAddress };\n nodeNetworkId: string;\n parentTxTypes: Tag[];\n node: Node;\n height: number;\n consensusProtocolVersion: ConsensusProtocolVersion;\n }\n) => ValidatorResult[] | Promise<ValidatorResult[]>;\n\nconst validators: Validator[] = [];\n\nconst getSenderAddress = (\n tx: TxParamsCommon | RawTxObject<TxSchema>,\n): Encoded.AccountAddress | undefined => [\n 'senderId', 'accountId', 'ownerId', 'callerId',\n 'oracleId', 'fromId', 'initiator', 'gaId', 'payerId',\n]\n .map((key: keyof TxSchema) => tx[key])\n .filter((a) => a)\n .map((a) => a?.toString().replace(/^ok_/, 'ak_'))[0] as Encoded.AccountAddress | undefined;\n\nasync function verifyTransactionInternal(\n tx: UnpackedTx,\n node: Node,\n parentTxTypes: Tag[],\n): Promise<ValidatorResult[]> {\n const address = getSenderAddress(tx)\n ?? (tx.tag === Tag.SignedTx ? getSenderAddress(tx.encodedTx) : undefined);\n const [account, { height }, { consensusProtocolVersion, nodeNetworkId }] = await Promise.all([\n address == null\n ? undefined\n : node.getAccountByPubkey(address)\n .catch((error) => {\n if (!isAccountNotFoundError(error)) throw error;\n return { id: address, balance: 0n, nonce: 0 };\n })\n // TODO: remove after fixing https://github.com/aeternity/aepp-sdk-js/issues/1537\n .then((acc) => ({ ...acc, id: acc.id as Encoded.AccountAddress })),\n node.getCurrentKeyBlockHeight(),\n node.getNodeInfo(),\n ]);\n\n return (await Promise.all(\n validators.map((v) => v(\n tx,\n {\n node, account, height, consensusProtocolVersion, nodeNetworkId, parentTxTypes,\n },\n )),\n )).flat();\n}\n\n/**\n * Transaction Validator\n * This function validates some transaction properties,\n * to make sure it can be posted it to the chain\n * @category transaction builder\n * @param transaction - Base64Check-encoded transaction\n * @param nodeNotCached - Node to validate transaction against\n * @returns Array with verification errors\n * @example const errors = await verifyTransaction(transaction, node)\n */\nexport default async function verifyTransaction(\n transaction: Parameters<typeof unpackTx>[0],\n nodeNotCached: Node,\n): Promise<ValidatorResult[]> {\n const node = new Node(nodeNotCached.$host, { ignoreVersion: true });\n node.pipeline.addPolicy(genAggressiveCacheGetResponsesPolicy());\n return verifyTransactionInternal(unpackTx(transaction), node, []);\n}\n\nvalidators.push(\n ({ encodedTx, signatures }, { account, nodeNetworkId, parentTxTypes }) => {\n if ((encodedTx ?? signatures) == null) return [];\n if (account == null) return [];\n if (signatures.length !== 1) return []; // TODO: Support multisignature like in state channels\n const prefix = Buffer.from([\n nodeNetworkId,\n ...parentTxTypes.includes(Tag.PayingForTx) ? ['inner_tx'] : [],\n ].join('-'));\n const txBinary = decode(buildTx(encodedTx));\n const txWithNetworkId = concatBuffers([prefix, txBinary]);\n const txHashWithNetworkId = concatBuffers([prefix, hash(txBinary)]);\n if (verify(txWithNetworkId, signatures[0], account.id)\n || verify(txHashWithNetworkId, signatures[0], account.id)) return [];\n return [{\n message: 'Signature cannot be verified, please ensure that you transaction have'\n + ' the correct prefix and the correct private key for the sender address',\n key: 'InvalidSignature',\n checkedKeys: ['encodedTx', 'signatures'],\n }];\n },\n async ({ encodedTx, tx, tag }, { node, parentTxTypes }) => {\n if ((encodedTx ?? tx) == null) return [];\n return verifyTransactionInternal(encodedTx ?? tx, node, [...parentTxTypes, tag]);\n },\n ({ ttl }, { height }) => {\n if (ttl == null) return [];\n ttl = +ttl;\n if (ttl === 0 || ttl >= height) return [];\n return [{\n message: `TTL ${ttl} is already expired, current height is ${height}`,\n key: 'ExpiredTTL',\n checkedKeys: ['ttl'],\n }];\n },\n ({\n amount, fee, nameFee, tx, tag,\n }, { account, parentTxTypes }) => {\n if (account == null) return [];\n if ((amount ?? fee ?? nameFee) == null) return [];\n fee ??= 0;\n const cost = new BigNumber(fee).plus(nameFee ?? 0).plus(amount ?? 0)\n .plus(tag === Tag.PayingForTx ? tx.encodedTx.fee : 0)\n .minus(parentTxTypes.includes(Tag.PayingForTx) ? fee : 0);\n if (cost.lte(account.balance.toString())) return [];\n return [{\n message: `Account balance ${account.balance.toString()} is not enough to execute the transaction that costs ${cost.toFixed()}`,\n key: 'InsufficientBalance',\n checkedKeys: ['amount', 'fee', 'nameFee'],\n }];\n },\n ({ signatures, tag }, { account }) => {\n if (account == null) return [];\n let message;\n if (tag === Tag.SignedTx && account.kind === 'generalized' && signatures.length !== 0) {\n message = 'Generalized account can\\'t be used to generate SignedTx with signatures';\n }\n if (tag === Tag.GaMetaTx && account.kind === 'basic') {\n message = 'Basic account can\\'t be used to generate GaMetaTx';\n }\n if (message == null) return [];\n return [{ message, key: 'InvalidAccountType', checkedKeys: ['tag'] }];\n },\n ({ nonce }, { account, parentTxTypes }) => {\n if (nonce == null || account == null || parentTxTypes.includes(Tag.GaMetaTx)) return [];\n nonce = +nonce;\n const validNonce = account.nonce + 1;\n if (nonce === validNonce) return [];\n return [{\n ...nonce < validNonce\n ? {\n message: `Nonce ${nonce} is already used, valid nonce is ${validNonce}`,\n key: 'NonceAlreadyUsed',\n }\n : {\n message: `Nonce ${nonce} is too high, valid nonce is ${validNonce}`,\n key: 'NonceHigh',\n },\n checkedKeys: ['nonce'],\n }];\n },\n ({ ctVersion, abiVersion, tag }, { consensusProtocolVersion }) => {\n const oracleCall = Tag.Oracle === tag || Tag.OracleRegisterTx === tag;\n const contractCreate = Tag.ContractCreateTx === tag || Tag.GaAttachTx === tag;\n const contractCall = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag;\n const type = (oracleCall ? 'oracle-call' : null)\n ?? (contractCreate ? 'contract-create' : null)\n ?? (contractCall ? 'contract-call' : null);\n if (type == null) return [];\n // TODO: remove assertion after fixing buildTx types\n const protocol = ProtocolToVmAbi[consensusProtocolVersion][type] as unknown as {\n abiVersion: any[];\n vmVersion: any[];\n };\n\n // If not contract create tx\n if (ctVersion == null) ctVersion = { abiVersion };\n if (\n !protocol.abiVersion.includes(ctVersion.abiVersion)\n || (contractCreate && !protocol.vmVersion.includes(ctVersion.vmVersion))\n ) {\n return [{\n message: `ABI/VM version ${JSON.stringify(ctVersion)} is wrong, supported is: ${JSON.stringify(protocol)}`,\n key: 'VmAndAbiVersionMismatch',\n checkedKeys: ['ctVersion', 'abiVersion'],\n }];\n }\n return [];\n },\n async ({ contractId, tag }, { node }) => {\n if (Tag.ContractCallTx !== tag) return [];\n contractId = contractId as Encoded.ContractAddress;\n try {\n const { active } = await node.getContract(contractId);\n if (active) return [];\n return [{\n message: `Contract ${contractId} is not active`,\n key: 'ContractNotActive',\n checkedKeys: ['contractId'],\n }];\n } catch (error) {\n if (error.response?.parsedBody?.reason == null) throw error;\n return [{\n message: error.response.parsedBody.reason,\n key: 'ContractNotFound',\n checkedKeys: ['contractId'],\n }];\n }\n },\n);\n"],"mappings":";;;;AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,IAAI,EAAEC,MAAM;AAAA,SAEZC,eAAe;AAAA,SACfC,GAAG;AAAA,SACHC,OAAO,EAAEC,QAAQ;AAAA,SACjBC,aAAa,EAAEC,sBAAsB;AAAA,SAC5BC,MAAM;AAAA,OACjBC,IAAI;AAAA,SAEFC,oCAAoC;AAuB7C,MAAMC,UAAuB,GAAG,EAAE;AAElC,MAAMC,gBAAgB,GACpBC,EAA0C,IACH,CACvC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAC9C,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,CACrD,CACEC,GAAG,CAAEC,GAAmB,IAAKF,EAAE,CAACE,GAAG,CAAC,CAAC,CACrCC,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAAC,CAChBH,GAAG,CAAEG,CAAC,IAAKA,CAAC,aAADA,CAAC,uBAADA,CAAC,CAAEC,QAAQ,EAAE,CAACC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAuC;AAE5F,eAAeC,yBAAyB,CACtCP,EAAc,EACdQ,IAAU,EACVC,aAAoB,EACQ;EAAA;EAC5B,MAAMC,OAAO,wBAAGX,gBAAgB,CAACC,EAAE,CAAC,iEAC9BA,EAAE,CAACW,GAAG,KAAKrB,GAAG,CAACsB,QAAQ,GAAGb,gBAAgB,CAACC,EAAE,CAACa,SAAS,CAAC,GAAGC,SAAU;EAC3E,MAAM,CAACC,OAAO,EAAE;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AAgBC,UAAU,0DAA1B,sBAA4BC,MAAM,KAAI,IAAI,EAAE,MAAM9D,KAAK;IAC3D,OAAO,CAAC;MACN4B,OAAO,EAAE5B,KAAK,CAAC4D,QAAQ,CAACC,UAAU,CAACC,MAAM;MACzCnF,GAAG,EAAE,kBAAkB;MACvBkD,WAAW,EAAE,CAAC,YAAY;IAC5B,CAAC,CAAC;EACJ;AACF,CAAC,CACF"}
|
|
1
|
+
{"version":3,"file":"validator.mjs","names":["hash","verify","ProtocolToVmAbi","Tag","buildTx","unpackTx","concatBuffers","isAccountNotFoundError","decode","Node","genAggressiveCacheGetResponsesPolicy","UnexpectedTsError","getTransactionSignerAddress","getExecutionCostUsingNode","validators","verifyTransactionInternal","tx","node","parentTxTypes","address","account","height","consensusProtocolVersion","nodeNetworkId","Promise","all","getAccountByPubkey","catch","error","id","balance","nonce","then","acc","getCurrentKeyBlockHeight","getNodeInfo","map","v","flat","verifyTransaction","transaction","nodeNotCached","$host","ignoreVersion","pipeline","clone","additionalPolicies","push","_ref","tag","SignedTx","encodedTx","signatures","length","prefix","_Buffer","from","includes","PayingForTx","join","txBinary","txWithNetworkId","txHashWithNetworkId","message","key","checkedKeys","_ref2","nestedTx","_ref3","ttl","_ref4","cost","_ref5","kind","GaMetaTx","_ref6","_ref7","_ref8","oracleCall","Oracle","OracleRegisterTx","contractCreate","ContractCreateTx","GaAttachTx","contractCall","ContractCallTx","type","protocol","ctVersion","abiVersion","vmVersion","JSON","stringify","_ref9","active","getContract","contractId","_error$response","_error$response$parse","response","parsedBody","reason"],"sources":["../../src/tx/validator.ts"],"sourcesContent":["import { hash, verify } from '../utils/crypto';\nimport { TxUnpacked } from './builder/schema.generated';\nimport { CtVersion, ProtocolToVmAbi } from './builder/field-types/ct-version';\nimport { Tag, ConsensusProtocolVersion } from './builder/constants';\nimport { buildTx, unpackTx } from './builder';\nimport { concatBuffers, isAccountNotFoundError } from '../utils/other';\nimport { Encoded, decode } from '../utils/encoder';\nimport Node, { TransformNodeType } from '../Node';\nimport { Account } from '../apis/node';\nimport { genAggressiveCacheGetResponsesPolicy } from '../utils/autorest';\nimport { UnexpectedTsError } from '../utils/errors';\nimport getTransactionSignerAddress from './transaction-signer';\nimport { getExecutionCostUsingNode } from './execution-cost';\n\nexport interface ValidatorResult {\n message: string;\n key: string;\n checkedKeys: string[];\n}\n\ntype Validator = (\n tx: TxUnpacked,\n options: {\n // TODO: remove after fixing node types\n account: TransformNodeType<Account> & { id: Encoded.AccountAddress };\n nodeNetworkId: string;\n parentTxTypes: Tag[];\n node: Node;\n height: number;\n consensusProtocolVersion: ConsensusProtocolVersion;\n }\n) => ValidatorResult[] | Promise<ValidatorResult[]>;\n\nconst validators: Validator[] = [];\n\nasync function verifyTransactionInternal(\n tx: TxUnpacked,\n node: Node,\n parentTxTypes: Tag[],\n): Promise<ValidatorResult[]> {\n const address = getTransactionSignerAddress(buildTx(tx));\n const [account, { height }, { consensusProtocolVersion, nodeNetworkId }] = await Promise.all([\n node.getAccountByPubkey(address)\n .catch((error) => {\n if (!isAccountNotFoundError(error)) throw error;\n return { id: address, balance: 0n, nonce: 0 };\n })\n // TODO: remove after fixing https://github.com/aeternity/aepp-sdk-js/issues/1537\n .then((acc) => ({ ...acc, id: acc.id as Encoded.AccountAddress })),\n node.getCurrentKeyBlockHeight(),\n node.getNodeInfo(),\n ]);\n\n return (await Promise.all(\n validators.map(async (v) => v(\n tx,\n {\n node, account, height, consensusProtocolVersion, nodeNetworkId, parentTxTypes,\n },\n )),\n )).flat();\n}\n\n/**\n * Transaction Validator\n * This function validates some transaction properties,\n * to make sure it can be posted it to the chain\n * @category transaction builder\n * @param transaction - Base64Check-encoded transaction\n * @param nodeNotCached - Node to validate transaction against\n * @returns Array with verification errors\n * @example const errors = await verifyTransaction(transaction, node)\n */\nexport default async function verifyTransaction(\n transaction: Parameters<typeof unpackTx>[0],\n nodeNotCached: Node,\n): Promise<ValidatorResult[]> {\n const node = new Node(nodeNotCached.$host, {\n ignoreVersion: true,\n pipeline: nodeNotCached.pipeline.clone(),\n additionalPolicies: [genAggressiveCacheGetResponsesPolicy()],\n });\n return verifyTransactionInternal(unpackTx(transaction), node, []);\n}\n\nvalidators.push(\n (tx, { account, nodeNetworkId, parentTxTypes }) => {\n if (tx.tag !== Tag.SignedTx) return [];\n const { encodedTx, signatures } = tx;\n if ((encodedTx ?? signatures) == null) return [];\n if (signatures.length !== 1) return []; // TODO: Support multisignature like in state channels\n const prefix = Buffer.from([\n nodeNetworkId,\n ...parentTxTypes.includes(Tag.PayingForTx) ? ['inner_tx'] : [],\n ].join('-'));\n const txBinary = decode(buildTx(encodedTx));\n const txWithNetworkId = concatBuffers([prefix, txBinary]);\n const txHashWithNetworkId = concatBuffers([prefix, hash(txBinary)]);\n if (verify(txWithNetworkId, signatures[0], account.id)\n || verify(txHashWithNetworkId, signatures[0], account.id)) return [];\n return [{\n message: 'Signature cannot be verified, please ensure that you transaction have'\n + ' the correct prefix and the correct private key for the sender address',\n key: 'InvalidSignature',\n checkedKeys: ['encodedTx', 'signatures'],\n }];\n },\n async (tx, { node, parentTxTypes }) => {\n let nestedTx;\n if ('encodedTx' in tx) nestedTx = tx.encodedTx;\n if ('tx' in tx) nestedTx = tx.tx;\n if (nestedTx == null) return [];\n return verifyTransactionInternal(nestedTx, node, [...parentTxTypes, tx.tag]);\n },\n (tx, { height }) => {\n if (!('ttl' in tx)) return [];\n if (tx.ttl === 0 || tx.ttl >= height) return [];\n return [{\n message: `TTL ${tx.ttl} is already expired, current height is ${height}`,\n key: 'ExpiredTTL',\n checkedKeys: ['ttl'],\n }];\n },\n async (tx, { account, parentTxTypes, node }) => {\n if (parentTxTypes.length !== 0) return [];\n const cost = await getExecutionCostUsingNode(buildTx(tx), node).catch(() => 0n);\n if (cost <= account.balance) return [];\n return [{\n message: `Account balance ${account.balance} is not enough to execute the transaction that costs ${cost}`,\n key: 'InsufficientBalance',\n checkedKeys: ['amount', 'fee', 'nameFee', 'gasLimit', 'gasPrice'],\n }];\n },\n (tx, { account }) => {\n let message;\n if (tx.tag === Tag.SignedTx && account.kind === 'generalized' && tx.signatures.length !== 0) {\n message = 'Generalized account can\\'t be used to generate SignedTx with signatures';\n }\n if (tx.tag === Tag.GaMetaTx && account.kind === 'basic') {\n message = 'Basic account can\\'t be used to generate GaMetaTx';\n }\n if (message == null) return [];\n return [{ message, key: 'InvalidAccountType', checkedKeys: ['tag'] }];\n },\n // TODO: revert nonce check\n (tx, { consensusProtocolVersion }) => {\n const oracleCall = Tag.Oracle === tx.tag || Tag.OracleRegisterTx === tx.tag;\n const contractCreate = Tag.ContractCreateTx === tx.tag || Tag.GaAttachTx === tx.tag;\n const contractCall = Tag.ContractCallTx === tx.tag || Tag.GaMetaTx === tx.tag;\n const type = (oracleCall ? 'oracle-call' : null)\n ?? (contractCreate ? 'contract-create' : null)\n ?? (contractCall ? 'contract-call' : null);\n if (type == null) return [];\n const protocol = ProtocolToVmAbi[consensusProtocolVersion][type] as {\n abiVersion: readonly any[];\n vmVersion: readonly any[];\n };\n\n let ctVersion: Partial<CtVersion> | undefined;\n if ('abiVersion' in tx) ctVersion = { abiVersion: tx.abiVersion };\n if ('ctVersion' in tx) ctVersion = tx.ctVersion;\n if (ctVersion == null) throw new UnexpectedTsError();\n if (\n !protocol.abiVersion.includes(ctVersion.abiVersion)\n || (contractCreate && !protocol.vmVersion.includes(ctVersion.vmVersion))\n ) {\n return [{\n message: `ABI/VM version ${JSON.stringify(ctVersion)} is wrong, supported is: ${JSON.stringify(protocol)}`,\n key: 'VmAndAbiVersionMismatch',\n checkedKeys: ['ctVersion', 'abiVersion'],\n }];\n }\n return [];\n },\n async (tx, { node }) => {\n if (Tag.ContractCallTx !== tx.tag) return [];\n try {\n const { active } = await node.getContract(tx.contractId);\n if (active) return [];\n return [{\n message: `Contract ${tx.contractId} is not active`,\n key: 'ContractNotActive',\n checkedKeys: ['contractId'],\n }];\n } catch (error) {\n if (error.response?.parsedBody?.reason == null) throw error;\n return [{\n message: error.response.parsedBody.re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,cAAAF,qBAAA,uBAA1BA,qBAAA,CAA4BG,MAAM,KAAI,IAAI,EAAE,MAAMzE,KAAK;IAC3D,OAAO,CAAC;MACNmC,OAAO,EAAEnC,KAAK,CAACuE,QAAQ,CAACC,UAAU,CAACC,MAAM;MACzCrC,GAAG,EAAE,kBAAkB;MACvBC,WAAW,EAAE,CAAC,YAAY;IAC5B,CAAC,CAAC;EACJ;AACF,CAAC,CACF"}
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ISC License (ISC)
|
|
3
|
-
* Copyright (c) 2018 aeternity developers
|
|
4
|
-
*
|
|
5
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
* copyright notice and this permission notice appear in all copies.
|
|
8
|
-
*
|
|
9
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
*/
|
|
17
1
|
import BigNumber from 'bignumber.js';
|
|
18
2
|
import { isBigNumber } from "./bignumber.mjs";
|
|
19
3
|
import { ArgumentError } from "./errors.mjs";
|
|
@@ -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","
|
|
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","_ref","denomination","targetDenomination","toString","shiftedBy","toFixed","toAe","arguments","length","undefined","toAettos","prefixes","name","magnitude","getNearestPrefix","exponent","reduce","p","n","Math","abs","getLowerBoundPrefix","_prefixes$find","find","rawValue","_value$e","exp","e","v","precision","min"],"sources":["../../src/utils/amount-formatter.ts"],"sourcesContent":["import 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,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,WAAW;AAAA,SACXC,aAAa;AAEtB,WAAYC,iBAAiB;;AAU7B;AACA;AACA;AAFA,WAVYA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,KAAjBA,iBAAiB;AAa7B,MAAMC,sBAAsB,GAAG;EAC7B,CAACD,iBAAiB,CAACE,EAAE,GAAG,CAAC;EACzB,CAACF,iBAAiB,CAACG,OAAO,GAAG,CAAC,CAAC;EAC/B,CAACH,iBAAiB,CAACI,QAAQ,GAAG,CAAC,CAAC;EAChC,CAACJ,iBAAiB,CAACK,OAAO,GAAG,CAAC,CAAC;EAC/B,CAACL,iBAAiB,CAACM,OAAO,GAAG,CAAC,EAAE;EAChC,CAACN,iBAAiB,CAACO,QAAQ,GAAG,CAAC,EAAE;EACjC,CAACP,iBAAiB,CAACQ,MAAM,GAAG,CAAC;AAC/B,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGA,CAC1BC,KAA2C,EAAAC,IAAA,KAGhC;EAAA,IAFX;IAAEC,YAAY,GAAGZ,iBAAiB,CAACQ,MAAM;IAAEK,kBAAkB,GAAGb,iBAAiB,CAACQ;EACP,CAAC,GAAAG,IAAA;EAE5E,IAAI,CAACb,WAAW,CAACY,KAAK,CAAC,EAAE,MAAM,IAAIX,aAAa,CAAC,OAAO,EAAE,UAAU,EAAEW,KAAK,CAAC;EAE5E,OAAO,IAAIb,SAAS,CAAC,OAAOa,KAAK,KAAK,QAAQ,GAAGA,KAAK,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AS,GAAGE,QAAQ,CAAC,GAAGI,IAAI,CAACC,GAAG,CAACH,CAAC,CAACJ,SAAS,GAAGE,QAAQ,CAAC,GAAGG,CAAC,GAAGD,CAAE,CAAC;AAE/E,MAAMI,mBAAmB,GAAIN,QAAgB;EAAA,IAAAO,cAAA;EAAA,QAAAA,cAAA,GAAaX,QAAQ,CAC/DY,IAAI,CAAEN,CAAC,IAAKA,CAAC,CAACJ,SAAS,IAAIE,QAAQ,CAAC,cAAAO,cAAA,cAAAA,cAAA,GAAIX,QAAQ,CAACA,QAAQ,CAACH,MAAM,GAAG,CAAC,CAAC;AAAA;AAExE,gBAAgBgB,QAAqC,IAAa;EAAA,IAAAC,QAAA;EAChE,MAAM1B,KAAgB,GAAG,IAAIb,SAAS,CAACsC,QAAQ,CAAC;EAEhD,MAAME,GAAG,IAAAD,QAAA,GAAG1B,KAAK,CAAC4B,CAAC,cAAAF,QAAA,cAAAA,QAAA,GAAI,CAAC;EACxB,MAAM;IAAEb,IAAI;IAAEC;EAAU,CAAC,GAAG,CAACa,GAAG,GAAG,CAAC,GAAGZ,gBAAgB,GAAGO,mBAAmB,EAAEK,GAAG,CAAC;EACnF,MAAME,CAAC,GAAG7B,KAAK,CACZK,SAAS,CAAC,CAACS,SAAS,CAAC,CACrBgB,SAAS,CAAC,CAAC,GAAGV,IAAI,CAACW,GAAG,CAACJ,GAAG,GAAGb,SAAS,EAAE,CAAC,CAAC,CAAC,CAC3CR,OAAO,EAAE;EACZ,OAAQ,GAAEuB,CAAE,GAAEhB,IAAI,KAAK,EAAE,GAAG,GAAG,GAAG,EAAG,GAAEA,IAAK,EAAC;AAC/C,CAAC"}
|
package/es/utils/autorest.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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: () =>
|
|
5
|
+
export declare const genAggressiveCacheGetResponsesPolicy: () => AdditionalPolicyConfig;
|
|
6
6
|
export declare const genErrorFormatterPolicy: (getMessage: (b: any) => string) => AdditionalPolicyConfig;
|
|
7
|
-
export declare const genVersionCheckPolicy: (name: string, ignorePath: string, versionPromise: Promise<string>, geVersion: string, ltVersion: string) => PipelinePolicy;
|
|
7
|
+
export declare const genVersionCheckPolicy: (name: string, ignorePath: string, versionPromise: Promise<string | Error>, geVersion: string, ltVersion: string) => PipelinePolicy;
|
|
8
|
+
export declare const genRetryOnFailurePolicy: (retryCount: number, retryOverallDelay: number) => AdditionalPolicyConfig;
|
package/es/utils/autorest.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RestError } from '@azure/core-rest-pipeline';
|
|
2
2
|
import { pause } from "./other.mjs";
|
|
3
3
|
import semverSatisfies from "./semver-satisfies.mjs";
|
|
4
|
-
import { UnsupportedVersionError } from "./errors.mjs";
|
|
4
|
+
import { UnexpectedTsError, UnsupportedVersionError } from "./errors.mjs";
|
|
5
5
|
export const genRequestQueuesPolicy = () => {
|
|
6
6
|
const requestQueues = new Map();
|
|
7
7
|
return {
|
|
@@ -47,15 +47,18 @@ export const genCombineGetRequestsPolicy = () => {
|
|
|
47
47
|
export const genAggressiveCacheGetResponsesPolicy = () => {
|
|
48
48
|
const getRequests = new Map();
|
|
49
49
|
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
policy: {
|
|
51
|
+
name: 'aggressive-cache-get-responses',
|
|
52
|
+
async sendRequest(request, next) {
|
|
53
|
+
var _getRequests$get;
|
|
54
|
+
if (request.method !== 'GET') return next(request);
|
|
55
|
+
const key = JSON.stringify([request.url, request.body]);
|
|
56
|
+
const response = (_getRequests$get = getRequests.get(key)) !== null && _getRequests$get !== void 0 ? _getRequests$get : next(request);
|
|
57
|
+
getRequests.set(key, response);
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
position: 'perCall'
|
|
59
62
|
};
|
|
60
63
|
};
|
|
61
64
|
export const genErrorFormatterPolicy = getMessage => ({
|
|
@@ -87,9 +90,38 @@ export const genVersionCheckPolicy = (name, ignorePath, versionPromise, geVersio
|
|
|
87
90
|
name: 'version-check',
|
|
88
91
|
async sendRequest(request, next) {
|
|
89
92
|
if (new URL(request.url).pathname === ignorePath) return next(request);
|
|
90
|
-
const
|
|
93
|
+
const version = await versionPromise;
|
|
94
|
+
if (version instanceof Error) throw version;
|
|
95
|
+
const args = [version, geVersion, ltVersion];
|
|
91
96
|
if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);
|
|
92
97
|
return next(request);
|
|
93
98
|
}
|
|
94
99
|
});
|
|
100
|
+
export const genRetryOnFailurePolicy = (retryCount, retryOverallDelay) => ({
|
|
101
|
+
policy: {
|
|
102
|
+
name: 'retry-on-failure',
|
|
103
|
+
async sendRequest(request, next) {
|
|
104
|
+
const statusesToNotRetry = [200, 400, 403];
|
|
105
|
+
const intervals = new Array(retryCount).fill(0).map((_, idx) => ((idx + 1) / retryCount) ** 2);
|
|
106
|
+
const intervalSum = intervals.reduce((a, b) => a + b);
|
|
107
|
+
const intervalsInMs = intervals.map(el => el / intervalSum * retryOverallDelay);
|
|
108
|
+
let error;
|
|
109
|
+
for (let attempt = 0; attempt <= retryCount; attempt += 1) {
|
|
110
|
+
if (error != null) {
|
|
111
|
+
var _error$response$statu, _error$response2;
|
|
112
|
+
if (!(error instanceof RestError) || statusesToNotRetry.includes((_error$response$statu = (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) !== null && _error$response$statu !== void 0 ? _error$response$statu : 0)) throw error;
|
|
113
|
+
await pause(intervalsInMs[attempt - 1]);
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
return await next(request);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
error = e;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (error == null) throw new UnexpectedTsError();
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
position: 'perCall'
|
|
126
|
+
});
|
|
95
127
|
//# 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","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,GAA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Error","UnsupportedVersionError","genRequestQueuesPolicy","requestQueues","Map","policy","name","sendRequest","request","next","_requestQueues$get","key","headers","get","delete","getResponse","req","Promise","resolve","then","set","position","genCombineGetRequestsPolicy","pendingGetRequests","_pendingGetRequests$g","method","JSON","stringify","url","body","response","genAggressiveCacheGetResponsesPolicy","getRequests","_getRequests$get","genErrorFormatterPolicy","getMessage","error","_error$response","bodyAsText","parse","e","message","URL","pathname","slice","genVersionCheckPolicy","ignorePath","versionPromise","geVersion","ltVersion","version","Error","args","genRetryOnFailurePolicy","retryCount","retryOverallDelay","statusesToNotRetry","intervals","Array","fill","map","_","idx","intervalSum","reduce","a","b","intervalsInMs","el","attempt","_error$response$statu","_error$response2","includes","status"],"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 { UnexpectedTsError, 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 = (): AdditionalPolicyConfig => {\n const getRequests = new Map<string, Promise<PipelineResponse>>();\n\n return {\n policy: {\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 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 | Error>,\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 version = await versionPromise;\n if (version instanceof Error) throw version;\n const args = [version, geVersion, ltVersion] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);\n return next(request);\n },\n});\n\nexport const genRetryOnFailurePolicy = (\n retryCount: number,\n retryOverallDelay: number,\n): AdditionalPolicyConfig => ({\n policy: {\n name: 'retry-on-failure',\n async sendRequest(request, next) {\n const statusesToNotRetry = [200, 400, 403];\n\n const intervals = new Array(retryCount).fill(0)\n .map((_, idx) => ((idx + 1) / retryCount) ** 2);\n const intervalSum = intervals.reduce((a, b) => a + b);\n const intervalsInMs = intervals.map((el) => (el / intervalSum) * retryOverallDelay);\n\n let error: Error | undefined;\n for (let attempt = 0; attempt <= retryCount; attempt += 1) {\n if (error != null) {\n if (\n !(error instanceof RestError)\n || statusesToNotRetry.includes(error.response?.status ?? 0)\n ) throw error;\n await pause(intervalsInMs[attempt - 1]);\n }\n try {\n return await next(request);\n } catch (e) {\n error = e;\n }\n }\n if (error == null) throw new UnexpectedTsError();\n throw error;\n },\n },\n position: 'perCall',\n});\n"],"mappings":"AAAA,SAASA,SAAS,QAA0C,2BAA2B;AAAC,SAE/EC,KAAK;AAAA,OACPC,eAAe;AAAA,SACbC,iBAAiB,EAAEC,uBAAuB;AAEnD,OAAO,MAAMC,sBAAsB,GAAGA,CAAA,KAA8B;EAClE,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAA4B;EAEzD,OAAO;IACLC,MAAM,EAAE;MACNC,IAAI,EAAE,gBAAgB;MACtB,MAAMC,WAAWA,CAACC,OAAO,EAAEC,IAAI,EAAE;QAAA,IAAAC,kBAAA;QAC/B,MAAMC,GAAG,GAAGH,OAAO,CAACI,OAAO,CAACC,GAAG,CAAC,SAAS,CAAC;QAC1CL,OAAO,CAACI,OAAO,CAACE,MAAM,CAAC,SAAS,CAAC;QACjC,MAAMC,WAAW,GAAG,MAAAA,CAAA,KAAuCN,IAAI,CAACD,OAAO,CAAC;QACxE,IAAIG,GAAG,IAAI,IAAI,EAAE,OAAOI,WAAW,EAAE;QACrC,MAAMC,GAAG,GAAG,EAAAN,kBAAA,GAACP,aAAa,CAACU,GAAG,CAACF,GAAG,CAAC,cAAAD,kBAAA,cAAAA,kBAAA,GAAIO,OAAO,CAACC,OAAO,EAAE,EAAEC,IAAI,CAACJ,WAAW,EAAEA,WAAW,CAAC;QACxF;QACA;QACAZ,aAAa,CAACiB,GAAG,CAACT,GAAG,EAAEK,GAAG,CAACG,IAAI,CAAC,YAAYrB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QACxD,OAAOkB,GAAG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AMS,WAAW,GAAGN,SAAS,CAACO,MAAM,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;MACrD,MAAMC,aAAa,GAAGV,SAAS,CAACG,GAAG,CAAEQ,EAAE,IAAMA,EAAE,GAAGL,WAAW,GAAIR,iBAAiB,CAAC;MAEnF,IAAInB,KAAwB;MAC5B,KAAK,IAAIiC,OAAO,GAAG,CAAC,EAAEA,OAAO,IAAIf,UAAU,EAAEe,OAAO,IAAI,CAAC,EAAE;QACzD,IAAIjC,KAAK,IAAI,IAAI,EAAE;UAAA,IAAAkC,qBAAA,EAAAC,gBAAA;UACjB,IACE,EAAEnC,KAAK,YAAYvC,SAAS,CAAC,IAC1B2D,kBAAkB,CAACgB,QAAQ,EAAAF,qBAAA,IAAAC,gBAAA,GAACnC,KAAK,CAACN,QAAQ,cAAAyC,gBAAA,uBAAdA,gBAAA,CAAgBE,MAAM,cAAAH,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC,EAC3D,MAAMlC,KAAK;UACb,MAAMtC,KAAK,CAACqE,aAAa,CAACE,OAAO,GAAG,CAAC,CAAC,CAAC;QACzC;QACA,IAAI;UACF,OAAO,MAAM5D,IAAI,CAACD,OAAO,CAAC;QAC5B,CAAC,CAAC,OAAOgC,CAAC,EAAE;UACVJ,KAAK,GAAGI,CAAC;QACX;MACF;MACA,IAAIJ,KAAK,IAAI,IAAI,EAAE,MAAM,IAAIpC,iBAAiB,EAAE;MAChD,MAAMoC,KAAK;IACb;EACF,CAAC;EACDf,QAAQ,EAAE;AACZ,CAAC,CAAC"}
|
package/es/utils/bytes.mjs
CHANGED
|
@@ -2,22 +2,6 @@ import _buffer from "buffer";
|
|
|
2
2
|
const {
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
|
-
/*
|
|
6
|
-
* ISC License (ISC)
|
|
7
|
-
* Copyright 2018 aeternity developers
|
|
8
|
-
*
|
|
9
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
11
|
-
* copyright notice and this permission notice appear in all copies.
|
|
12
|
-
*
|
|
13
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
*/
|
|
21
5
|
import BigNumber from 'bignumber.js';
|
|
22
6
|
import { NoSerializerFoundError, TypeError } from "./errors.mjs";
|
|
23
7
|
/**
|
package/es/utils/bytes.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.mjs","names":["BigNumber","NoSerializerFoundError","TypeError","toBytes","val","big","from","Number","isInteger","isBigNumber","toFixed","hexString","toString"
|
|
1
|
+
{"version":3,"file":"bytes.mjs","names":["BigNumber","NoSerializerFoundError","TypeError","toBytes","val","big","arguments","length","undefined","_Buffer","from","Number","isInteger","isBigNumber","toFixed","hexString","toString"],"sources":["../../src/utils/bytes.ts"],"sourcesContent":["import 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,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,sBAAsB,EAAEC,SAAS;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAACC,GAAwC,EAAuB;EAAA,IAArBC,GAAG,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAC3E;EACA;EACA;;EAEA,IAAIF,GAAG,IAAI,IAAI,EAAE,OAAOK,OAAA,CAAOC,IAAI,CAAC,EAAE,CAAC;EACvC,IAAIC,MAAM,CAACC,SAAS,CAACR,GAAG,CAAC,IAAIJ,SAAS,CAACa,WAAW,CAACT,GAAG,CAAC,IAAIC,GAAG,EAAE;IAC9D,IAAI,CAACL,SAAS,CAACa,WAAW,CAACT,GAAG,CAAC,EAAEA,GAAG,GAAG,IAAIJ,SAAS,CAACI,GAAG,CAAC;IACzD,IAAI,CAACA,GAAG,CAACQ,SAAS,EAAE,EAAE,MAAM,IAAIV,SAAS,CAAE,iCAAgCE,GAAG,CAACU,OAAO,EAAG,EAAC,CAAC;IAC3F,IAAIC,SAAS,GAAGX,GAAG,CAACY,QAAQ,CAAC,EAAE,CAAC;IAChC,IAAID,SAAS,CAACR,MAAM,GAAG,CAAC,KAAK,CAAC,EAAEQ,SAAS,GAAI,IAAGA,SAAU,EAAC;IAC3D,OAAON,OAAA,CAAOC,IAAI,CAACK,SAAS,EAAE,KAAK,CAAC;EACtC;EACA,IAAI,OAAOX,GAAG,KAAK,QAAQ,EAAE;IAC3B,OAAOK,OAAA,CAAOC,IAAI,CAACN,GAAG,CAAC;EACzB;EACA,MAAM,IAAIH,sBAAsB,EAAE;AACpC"}
|
package/es/utils/crypto.mjs
CHANGED
|
@@ -2,22 +2,6 @@ import _buffer from "buffer";
|
|
|
2
2
|
const {
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
|
-
/*
|
|
6
|
-
* ISC License (ISC)
|
|
7
|
-
* Copyright 2018 aeternity developers
|
|
8
|
-
*
|
|
9
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
11
|
-
* copyright notice and this permission notice appear in all copies.
|
|
12
|
-
*
|
|
13
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
*/
|
|
21
5
|
import nacl from 'tweetnacl';
|
|
22
6
|
// js extension is required for mjs build, not importing the whole package to reduce bundle size
|
|
23
7
|
// eslint-disable-next-line import/extensions
|