@aeternity/aepp-sdk 13.0.0-alpha.1 → 13.0.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/README.md +1 -1
- 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 +1833 -1543
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +5 -4
- package/es/AeSdkAepp.mjs +13 -17
- 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 +12 -25
- 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 +20 -23
- 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 +197 -215
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +10 -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 +5 -4
- package/es/index-browser.mjs +7 -21
- 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 +3 -33
- 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/AeSdkAepp.ts +16 -14
- 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 +9 -24
- 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 +7 -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 +29 -28
- 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 +161 -170
- package/src/contract/compiler/Base.ts +10 -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 +15 -21
- 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 +16 -45
- package/src/utils/string.ts +0 -17
- package/types-legacy/ts4.2/AeSdkAepp.d.ts +5 -4
- 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 +10 -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 +5 -4
- 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/AeSdkAepp.d.ts +5 -4
- 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 +10 -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 +5 -4
- 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
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Int } from '../constants';
|
|
3
3
|
import { AE_AMOUNT_FORMATS } from '../../../utils/amount-formatter';
|
|
4
|
-
export interface Options {
|
|
5
|
-
denomination?: AE_AMOUNT_FORMATS;
|
|
6
|
-
}
|
|
7
4
|
declare const _default: {
|
|
8
5
|
serializeAettos(value: string | undefined): string;
|
|
9
|
-
serialize(value: Int | undefined, { denomination
|
|
6
|
+
serialize(value: Int | undefined, params: {}, { denomination }: {
|
|
7
|
+
denomination?: AE_AMOUNT_FORMATS | undefined;
|
|
8
|
+
}): Buffer;
|
|
10
9
|
deserialize(value: Buffer): string;
|
|
11
10
|
};
|
|
12
11
|
export default _default;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import uInt from "./u-int.mjs";
|
|
2
|
-
import { formatAmount } from "../../../utils/amount-formatter.mjs";
|
|
2
|
+
import { AE_AMOUNT_FORMATS, formatAmount } from "../../../utils/amount-formatter.mjs";
|
|
3
3
|
export default {
|
|
4
4
|
...uInt,
|
|
5
5
|
serializeAettos(value) {
|
|
6
6
|
return value !== null && value !== void 0 ? value : '0';
|
|
7
7
|
},
|
|
8
|
-
serialize(value, _ref) {
|
|
8
|
+
serialize(value, params, _ref) {
|
|
9
9
|
let {
|
|
10
|
-
denomination
|
|
11
|
-
...options
|
|
10
|
+
denomination = AE_AMOUNT_FORMATS.AETTOS
|
|
12
11
|
} = _ref;
|
|
13
12
|
return uInt.serialize(this.serializeAettos(value != null ? formatAmount(value, {
|
|
14
13
|
denomination
|
|
15
|
-
}) : value,
|
|
14
|
+
}) : value, params));
|
|
16
15
|
}
|
|
17
16
|
};
|
|
18
17
|
//# sourceMappingURL=coin-amount.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coin-amount.mjs","names":["uInt","formatAmount","serializeAettos","value","serialize","denomination","
|
|
1
|
+
{"version":3,"file":"coin-amount.mjs","names":["uInt","AE_AMOUNT_FORMATS","formatAmount","serializeAettos","value","serialize","params","_ref","denomination","AETTOS"],"sources":["../../../../src/tx/builder/field-types/coin-amount.ts"],"sourcesContent":["import uInt from './u-int';\nimport { Int } from '../constants';\nimport { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter';\n\nexport default {\n ...uInt,\n\n serializeAettos(value: string | undefined): string {\n return value ?? '0';\n },\n\n serialize(\n value: Int | undefined,\n params: {},\n { denomination = AE_AMOUNT_FORMATS.AETTOS }: { denomination?: AE_AMOUNT_FORMATS },\n ): Buffer {\n return uInt.serialize(\n this.serializeAettos(\n value != null ? formatAmount(value, { denomination }) : value,\n params,\n ),\n );\n },\n};\n"],"mappings":"OAAOA,IAAI;AAAA,SAEFC,iBAAiB,EAAEC,YAAY;AAExC,eAAe;EACb,GAAGF,IAAI;EAEPG,eAAeA,CAACC,KAAyB,EAAU;IACjD,OAAOA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,GAAG;EACrB,CAAC;EAEDC,SAASA,CACPD,KAAsB,EACtBE,MAAU,EAAAC,IAAA,EAEF;IAAA,IADR;MAAEC,YAAY,GAAGP,iBAAiB,CAACQ;IAA6C,CAAC,GAAAF,IAAA;IAEjF,OAAOP,IAAI,CAACK,SAAS,CACnB,IAAI,CAACF,eAAe,CAClBC,KAAK,IAAI,IAAI,GAAGF,YAAY,CAACE,KAAK,EAAE;MAAEI;IAAa,CAAC,CAAC,GAAGJ,KAAK,EAC7DE,MAAM,CACP,CACF;EACH;AACF,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants';
|
|
3
|
+
import Node from '../../../Node';
|
|
3
4
|
export declare const ProtocolToVmAbi: {
|
|
4
5
|
readonly 5: {
|
|
5
6
|
readonly 'contract-create': {
|
|
@@ -12,7 +13,21 @@ export declare const ProtocolToVmAbi: {
|
|
|
12
13
|
};
|
|
13
14
|
readonly 'oracle-call': {
|
|
14
15
|
readonly vmVersion: readonly [];
|
|
15
|
-
readonly abiVersion: readonly [AbiVersion.NoAbi, AbiVersion.
|
|
16
|
+
readonly abiVersion: readonly [AbiVersion.NoAbi, AbiVersion.Fate];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
readonly 6: {
|
|
20
|
+
readonly 'contract-create': {
|
|
21
|
+
readonly vmVersion: readonly [VmVersion.Fate2];
|
|
22
|
+
readonly abiVersion: readonly [AbiVersion.Fate];
|
|
23
|
+
};
|
|
24
|
+
readonly 'contract-call': {
|
|
25
|
+
readonly vmVersion: readonly [];
|
|
26
|
+
readonly abiVersion: readonly [AbiVersion.Fate];
|
|
27
|
+
};
|
|
28
|
+
readonly 'oracle-call': {
|
|
29
|
+
readonly vmVersion: readonly [];
|
|
30
|
+
readonly abiVersion: readonly [AbiVersion.NoAbi, AbiVersion.Fate];
|
|
16
31
|
};
|
|
17
32
|
};
|
|
18
33
|
};
|
|
@@ -22,9 +37,13 @@ export interface CtVersion {
|
|
|
22
37
|
}
|
|
23
38
|
export declare function getProtocolDetails(protocolVersion: ConsensusProtocolVersion, type: 'contract-create' | 'contract-call' | 'oracle-call'): CtVersion;
|
|
24
39
|
declare const _default: {
|
|
25
|
-
serialize(value: CtVersion | undefined, { consensusProtocolVersion }: {
|
|
26
|
-
consensusProtocolVersion
|
|
40
|
+
serialize(value: CtVersion | undefined, params: {}, { consensusProtocolVersion }: {
|
|
41
|
+
consensusProtocolVersion?: ConsensusProtocolVersion | undefined;
|
|
27
42
|
}): Buffer;
|
|
43
|
+
prepare(value: CtVersion | undefined, params: {}, options: {
|
|
44
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
45
|
+
onNode?: Node;
|
|
46
|
+
}): Promise<CtVersion | undefined>;
|
|
28
47
|
deserialize(buffer: Buffer): CtVersion;
|
|
29
48
|
};
|
|
30
49
|
export default _default;
|
|
@@ -2,21 +2,38 @@ import _buffer from "buffer";
|
|
|
2
2
|
const {
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
|
-
import { ConsensusProtocolVersion, VmVersion, AbiVersion } from "../constants.mjs";
|
|
5
|
+
import { ConsensusProtocolVersion, VmVersion, AbiVersion } from "../constants.mjs";
|
|
6
|
+
/*
|
|
7
|
+
* First abi/vm by default
|
|
8
|
+
* @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}
|
|
9
|
+
*/
|
|
6
10
|
export const ProtocolToVmAbi = {
|
|
7
11
|
[ConsensusProtocolVersion.Iris]: {
|
|
8
12
|
'contract-create': {
|
|
9
13
|
vmVersion: [VmVersion.Fate2],
|
|
10
14
|
abiVersion: [AbiVersion.Fate]
|
|
11
15
|
},
|
|
12
|
-
// TODO: Ensure that AEVM (Sophia?) is still available here
|
|
13
16
|
'contract-call': {
|
|
14
17
|
vmVersion: [],
|
|
15
18
|
abiVersion: [AbiVersion.Fate, AbiVersion.Sophia]
|
|
16
19
|
},
|
|
17
20
|
'oracle-call': {
|
|
18
21
|
vmVersion: [],
|
|
19
|
-
abiVersion: [AbiVersion.NoAbi, AbiVersion.
|
|
22
|
+
abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
[ConsensusProtocolVersion.Ceres]: {
|
|
26
|
+
'contract-create': {
|
|
27
|
+
vmVersion: [VmVersion.Fate2],
|
|
28
|
+
abiVersion: [AbiVersion.Fate]
|
|
29
|
+
},
|
|
30
|
+
'contract-call': {
|
|
31
|
+
vmVersion: [],
|
|
32
|
+
abiVersion: [AbiVersion.Fate]
|
|
33
|
+
},
|
|
34
|
+
'oracle-call': {
|
|
35
|
+
vmVersion: [],
|
|
36
|
+
abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate]
|
|
20
37
|
}
|
|
21
38
|
}
|
|
22
39
|
};
|
|
@@ -29,7 +46,7 @@ export function getProtocolDetails(protocolVersion, type) {
|
|
|
29
46
|
};
|
|
30
47
|
}
|
|
31
48
|
export default {
|
|
32
|
-
serialize(value, _ref) {
|
|
49
|
+
serialize(value, params, _ref) {
|
|
33
50
|
var _value;
|
|
34
51
|
let {
|
|
35
52
|
consensusProtocolVersion = ConsensusProtocolVersion.Iris
|
|
@@ -37,6 +54,17 @@ export default {
|
|
|
37
54
|
(_value = value) !== null && _value !== void 0 ? _value : value = getProtocolDetails(consensusProtocolVersion, 'contract-create');
|
|
38
55
|
return _Buffer.from([value.vmVersion, 0, value.abiVersion]);
|
|
39
56
|
},
|
|
57
|
+
async prepare(value, params,
|
|
58
|
+
// TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}
|
|
59
|
+
options) {
|
|
60
|
+
if (value != null) return value;
|
|
61
|
+
if (options.consensusProtocolVersion != null) return undefined;
|
|
62
|
+
if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
|
|
63
|
+
if (options.onNode != null) {
|
|
64
|
+
return getProtocolDetails((await options.onNode.getNodeInfo()).consensusProtocolVersion, 'contract-create');
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
},
|
|
40
68
|
deserialize(buffer) {
|
|
41
69
|
const [vm,, abi] = buffer;
|
|
42
70
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-version.mjs","names":["ConsensusProtocolVersion","VmVersion","AbiVersion","ProtocolToVmAbi","Iris","vmVersion","Fate2","abiVersion","Fate","Sophia","NoAbi","getProtocolDetails","protocolVersion","type","protocol","serialize","value","consensusProtocolVersion","from","deserialize","buffer","vm","abi"],"sources":["../../../../src/tx/builder/field-types/ct-version.ts"],"sourcesContent":["import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants';\n\n
|
|
1
|
+
{"version":3,"file":"ct-version.mjs","names":["ConsensusProtocolVersion","VmVersion","AbiVersion","ProtocolToVmAbi","Iris","vmVersion","Fate2","abiVersion","Fate","Sophia","NoAbi","Ceres","getProtocolDetails","protocolVersion","type","_protocol$vmVersion$","protocol","serialize","value","params","_ref","_value","consensusProtocolVersion","_Buffer","from","prepare","options","undefined","Object","keys","length","onNode","getNodeInfo","deserialize","buffer","vm","abi"],"sources":["../../../../src/tx/builder/field-types/ct-version.ts"],"sourcesContent":["import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants';\nimport Node from '../../../Node';\n\n/*\n * First abi/vm by default\n * @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}\n */\nexport const ProtocolToVmAbi = {\n [ConsensusProtocolVersion.Iris]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [], abiVersion: [AbiVersion.Fate, AbiVersion.Sophia],\n },\n 'oracle-call': {\n vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n [ConsensusProtocolVersion.Ceres]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [], abiVersion: [AbiVersion.Fate],\n },\n 'oracle-call': {\n vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n} as const;\n\nexport interface CtVersion {\n vmVersion: VmVersion;\n abiVersion: AbiVersion;\n}\n\nexport function getProtocolDetails(\n protocolVersion: ConsensusProtocolVersion,\n type: 'contract-create' | 'contract-call' | 'oracle-call',\n): CtVersion {\n const protocol = ProtocolToVmAbi[protocolVersion][type];\n return {\n vmVersion: protocol.vmVersion[0] ?? VmVersion.Fate2,\n abiVersion: protocol.abiVersion[0],\n };\n}\n\nexport default {\n serialize(\n value: CtVersion | undefined,\n params: {},\n { consensusProtocolVersion = ConsensusProtocolVersion.Iris }:\n { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n value ??= getProtocolDetails(consensusProtocolVersion, 'contract-create');\n\n return Buffer.from([value.vmVersion, 0, value.abiVersion]);\n },\n\n async prepare(\n value: CtVersion | undefined,\n params: {},\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<CtVersion | undefined> {\n if (value != null) return value;\n if (options.consensusProtocolVersion != null) return undefined;\n if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;\n if (options.onNode != null) {\n return getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n 'contract-create',\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): CtVersion {\n const [vm, , abi] = buffer;\n return { vmVersion: +vm, abiVersion: +abi };\n },\n};\n"],"mappings":";;;;SAASA,wBAAwB,EAAEC,SAAS,EAAEC,UAAU;AAGxD;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG;EAC7B,CAACH,wBAAwB,CAACI,IAAI,GAAG;IAC/B,iBAAiB,EAAE;MACjBC,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAAEC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC5D,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;MAAEE,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI,EAAEN,UAAU,CAACO,MAAM;IAChE,CAAC;IACD,aAAa,EAAE;MACbJ,SAAS,EAAE,EAAE;MAAEE,UAAU,EAAE,CAACL,UAAU,CAACQ,KAAK,EAAER,UAAU,CAACM,IAAI;IAC/D;EACF,CAAC;EACD,CAACR,wBAAwB,CAACW,KAAK,GAAG;IAChC,iBAAiB,EAAE;MACjBN,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAAEC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC5D,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;MAAEE,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC7C,CAAC;IACD,aAAa,EAAE;MACbH,SAAS,EAAE,EAAE;MAAEE,UAAU,EAAE,CAACL,UAAU,CAACQ,KAAK,EAAER,UAAU,CAACM,IAAI;IAC/D;EACF;AACF,CAAU;AAOV,OAAO,SAASI,kBAAkBA,CAChCC,eAAyC,EACzCC,IAAyD,EAC9C;EAAA,IAAAC,oBAAA;EACX,MAAMC,QAAQ,GAAGb,eAAe,CAACU,eAAe,CAAC,CAACC,IAAI,CAAC;EAC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CAAC8B,EAAE;MAAE5B,UAAU,EAAE,CAAC6B;IAAI,CAAC;EAC7C;AACF,CAAC"}
|
|
@@ -5,9 +5,10 @@ declare const _default: {
|
|
|
5
5
|
/**
|
|
6
6
|
* @param value - Deposit value in string format. Should be equal to '0'.
|
|
7
7
|
* @param options - Options
|
|
8
|
+
* @param parameters - Parameters
|
|
8
9
|
* @returns Deposit value Buffer.
|
|
9
10
|
*/
|
|
10
|
-
serialize(value: Int | undefined, options: Parameters<(typeof coinAmount)['serialize']>[1]): Buffer;
|
|
11
|
+
serialize(value: Int | undefined, options: Parameters<(typeof coinAmount)['serialize']>[1], parameters: Parameters<(typeof coinAmount)['serialize']>[2]): Buffer;
|
|
11
12
|
serializeAettos(value: string | undefined): string;
|
|
12
13
|
deserialize(value: Buffer): string;
|
|
13
14
|
};
|
|
@@ -5,13 +5,14 @@ export default {
|
|
|
5
5
|
/**
|
|
6
6
|
* @param value - Deposit value in string format. Should be equal to '0'.
|
|
7
7
|
* @param options - Options
|
|
8
|
+
* @param parameters - Parameters
|
|
8
9
|
* @returns Deposit value Buffer.
|
|
9
10
|
*/
|
|
10
|
-
serialize(value, options) {
|
|
11
|
+
serialize(value, options, parameters) {
|
|
11
12
|
var _value;
|
|
12
13
|
(_value = value) !== null && _value !== void 0 ? _value : value = 0;
|
|
13
14
|
if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);
|
|
14
|
-
return coinAmount.serialize(value, options);
|
|
15
|
+
return coinAmount.serialize(value, options, parameters);
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
//# sourceMappingURL=deposit.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deposit.mjs","names":["coinAmount","IllegalArgumentError","serialize","value","options","toString"],"sources":["../../../../src/tx/builder/field-types/deposit.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { Int } from '../constants';\nimport { IllegalArgumentError } from '../../../utils/errors';\n\nexport default {\n ...coinAmount,\n\n /**\n * @param value - Deposit value in string format. Should be equal to '0'.\n * @param options - Options\n * @returns Deposit value Buffer.\n */\n serialize(\n value: Int | undefined,\n options: Parameters<typeof coinAmount['serialize']>[1],\n ): Buffer {\n value ??= 0;\n if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);\n return coinAmount.serialize(value, options);\n },\n};\n"],"mappings":"OAAOA,UAAU;AAAA,SAERC,oBAAoB;AAE7B,eAAe;EACb,GAAGD,UAAU;EAEb;AACF;AACA;AACA;AACA;EACEE,
|
|
1
|
+
{"version":3,"file":"deposit.mjs","names":["coinAmount","IllegalArgumentError","serialize","value","options","parameters","_value","toString"],"sources":["../../../../src/tx/builder/field-types/deposit.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { Int } from '../constants';\nimport { IllegalArgumentError } from '../../../utils/errors';\n\nexport default {\n ...coinAmount,\n\n /**\n * @param value - Deposit value in string format. Should be equal to '0'.\n * @param options - Options\n * @param parameters - Parameters\n * @returns Deposit value Buffer.\n */\n serialize(\n value: Int | undefined,\n options: Parameters<typeof coinAmount['serialize']>[1],\n parameters: Parameters<typeof coinAmount['serialize']>[2],\n ): Buffer {\n value ??= 0;\n if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);\n return coinAmount.serialize(value, options, parameters);\n },\n};\n"],"mappings":"OAAOA,UAAU;AAAA,SAERC,oBAAoB;AAE7B,eAAe;EACb,GAAGD,UAAU;EAEb;AACF;AACA;AACA;AACA;AACA;EACEE,SAASA,CACPC,KAAsB,EACtBC,OAAsD,EACtDC,UAAyD,EACjD;IAAA,IAAAC,MAAA;IACR,CAAAA,MAAA,GAAAH,KAAK,cAAAG,MAAA,cAAAA,MAAA,GAALH,KAAK,GAAK,CAAC;IACX,IAAI,CAACA,KAAK,KAAK,CAAC,EAAE,MAAM,IAAIF,oBAAoB,CAAE,oEAAmEE,KAAK,CAACI,QAAQ,EAAG,UAAS,CAAC;IAChJ,OAAOP,UAAU,CAACE,SAAS,CAACC,KAAK,EAAEC,OAAO,EAAEC,UAAU,CAAC;EACzD;AACF,CAAC"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { Encoded, Encoding } from '../../../utils/encoder';
|
|
3
3
|
export default function genEncodedField<E extends Encoding, Optional extends boolean = false>(encoding: E, optional?: Optional): {
|
|
4
4
|
serialize: Optional extends true ? (value?: Encoded.Generic<E>) => Buffer : (value: Encoded.Generic<E>) => Buffer;
|
|
5
|
-
deserialize: (value: Buffer) => Encoded.Generic<
|
|
5
|
+
deserialize: (value: Buffer) => Encoded.Generic<E>;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoded.mjs","names":["decode","encode","ArgumentError","genEncodedField","encoding","optional","serialize","encodedData","from","deserialize","buffer"],"sources":["../../../../src/tx/builder/field-types/encoded.ts"],"sourcesContent":["import {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport { ArgumentError } from '../../../utils/errors';\n\nexport default function genEncodedField<E extends Encoding, Optional extends boolean = false>(\n encoding: E,\n optional?: Optional,\n): {\n serialize: Optional extends true\n ? (value?: Encoded.Generic<E>) => Buffer : (value: Encoded.Generic<E>) => Buffer;\n deserialize: (value: Buffer) => Encoded.Generic<
|
|
1
|
+
{"version":3,"file":"encoded.mjs","names":["decode","encode","ArgumentError","genEncodedField","encoding","optional","serialize","encodedData","_Buffer","from","deserialize","buffer"],"sources":["../../../../src/tx/builder/field-types/encoded.ts"],"sourcesContent":["import {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport { ArgumentError } from '../../../utils/errors';\n\nexport default function genEncodedField<E extends Encoding, Optional extends boolean = false>(\n encoding: E,\n optional?: Optional,\n): {\n serialize: Optional extends true\n ? (value?: Encoded.Generic<E>) => Buffer : (value: Encoded.Generic<E>) => Buffer;\n deserialize: (value: Buffer) => Encoded.Generic<E>;\n } {\n return {\n serialize(encodedData?: Encoded.Generic<E>) {\n if (encodedData == null) {\n if (optional === true) return Buffer.from([]);\n throw new ArgumentError('Encoded data', 'provided', encodedData);\n }\n return decode(encodedData);\n },\n\n deserialize(buffer) {\n return encode(buffer, encoding);\n },\n };\n}\n"],"mappings":";;;;SACEA,MAAM,EAAEC,MAAM;AAAA,SAEPC,aAAa;AAEtB,eAAe,SAASC,eAAeA,CACrCC,QAAW,EACXC,QAAmB,EAKjB;EACF,OAAO;IACLC,SAASA,CAACC,WAAgC,EAAE;MAC1C,IAAIA,WAAW,IAAI,IAAI,EAAE;QACvB,IAAIF,QAAQ,KAAK,IAAI,EAAE,OAAOG,OAAA,CAAOC,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAIP,aAAa,CAAC,cAAc,EAAE,UAAU,EAAEK,WAAW,CAAC;MAClE;MACA,OAAOP,MAAM,CAACO,WAAW,CAAC;IAC5B,CAAC;IAEDG,WAAWA,CAACC,MAAM,EAAE;MAClB,OAAOV,MAAM,CAACU,MAAM,EAAEP,QAAQ,CAAC;IACjC;EACF,CAAC;AACH"}
|
|
@@ -11,6 +11,9 @@ export default function genEntryField(tag) {
|
|
|
11
11
|
buildTx
|
|
12
12
|
} = _ref;
|
|
13
13
|
if (ArrayBuffer.isView(txParams)) return _Buffer.from(txParams);
|
|
14
|
+
if (typeof txParams === 'string' && txParams.startsWith('tx_')) {
|
|
15
|
+
return decode(txParams);
|
|
16
|
+
}
|
|
14
17
|
return decode(buildTx({
|
|
15
18
|
...txParams,
|
|
16
19
|
...(tag != null && {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.mjs","names":["decode","encode","Encoding","ArgumentError","genEntryField","tag","serialize","txParams","buildTx","ArrayBuffer","isView","from","deserialize","buf","unpackTx","tx","Transaction"],"sources":["../../../../src/tx/builder/field-types/entry.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"entry.mjs","names":["decode","encode","Encoding","ArgumentError","genEntryField","tag","serialize","txParams","_ref","buildTx","ArrayBuffer","isView","_Buffer","from","startsWith","deserialize","buf","_ref2","unpackTx","tx","Transaction"],"sources":["../../../../src/tx/builder/field-types/entry.ts"],"sourcesContent":["import {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport { Tag } from '../constants';\nimport { ArgumentError } from '../../../utils/errors';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nexport default function genEntryField<T extends Tag = Tag>(tag?: T): {\n serialize: (\n // TODO: replace with `TxParams & { tag: T }`,\n // but fix TS2502 value is referenced directly or indirectly in its own type annotation\n value: any,\n options: { buildTx: typeof buildTxType },\n ) => Buffer;\n deserialize: (\n value: Buffer, options: { unpackTx: typeof unpackTxType },\n // TODO: replace with `TxUnpacked & { tag: T }`,\n // TS2577 Return type annotation circularly references itself\n ) => any;\n} {\n return {\n serialize(txParams, { buildTx }) {\n if (ArrayBuffer.isView(txParams)) return Buffer.from(txParams as any);\n if (typeof txParams === 'string' && txParams.startsWith('tx_')) {\n return decode(txParams as Encoded.Transaction);\n }\n return decode(buildTx({ ...txParams, ...tag != null && { tag } }));\n },\n\n deserialize(buf, { unpackTx }) {\n const tx = unpackTx(encode(buf, Encoding.Transaction));\n if (tag != null && tx.tag !== tag) throw new ArgumentError('Tag', tag, tx.tag);\n return tx;\n },\n };\n}\n"],"mappings":";;;;SACEA,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAG1BC,aAAa;AAGtB,eAAe,SAASC,aAAaA,CAAsBC,GAAO,EAYhE;EACA,OAAO;IACLC,SAASA,CAACC,QAAQ,EAAAC,IAAA,EAAe;MAAA,IAAb;QAAEC;MAAQ,CAAC,GAAAD,IAAA;MAC7B,IAAIE,WAAW,CAACC,MAAM,CAACJ,QAAQ,CAAC,EAAE,OAAOK,OAAA,CAAOC,IAAI,CAACN,QAAQ,CAAQ;MACrE,IAAI,OAAOA,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,CAACO,UAAU,CAAC,KAAK,CAAC,EAAE;QAC9D,OAAOd,MAAM,CAACO,QAAQ,CAAwB;MAChD;MACA,OAAOP,MAAM,CAACS,OAAO,CAAC;QAAE,GAAGF,QAAQ;QAAE,IAAGF,GAAG,IAAI,IAAI,IAAI;UAAEA;QAAI,CAAC;MAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IAEDU,WAAWA,CAACC,GAAG,EAAAC,KAAA,EAAgB;MAAA,IAAd;QAAEC;MAAS,CAAC,GAAAD,KAAA;MAC3B,MAAME,EAAE,GAAGD,QAAQ,CAACjB,MAAM,CAACe,GAAG,EAAEd,QAAQ,CAACkB,WAAW,CAAC,CAAC;MACtD,IAAIf,GAAG,IAAI,IAAI,IAAIc,EAAE,CAACd,GAAG,KAAKA,GAAG,EAAE,MAAM,IAAIF,aAAa,CAAC,KAAK,EAAEE,GAAG,EAAEc,EAAE,CAACd,GAAG,CAAC;MAC9E,OAAOc,EAAE;IACX;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumeration.mjs","names":["ArgumentError","isItemOfArray","genEnumerationField","enm","values","Object","filter","v","serialize","value","from","deserialize","buffer","length"],"sources":["../../../../src/tx/builder/field-types/enumeration.ts"],"sourcesContent":["import { ArgumentError } from '../../../utils/errors';\nimport { isItemOfArray } from '../../../utils/other';\n\nexport default function genEnumerationField<\n Enum extends { [key: string]: number | string },\n>(enm: Enum): {\n serialize: (value: Enum[keyof Enum]) => Buffer;\n deserialize: (value: Buffer) => Enum[keyof Enum];\n} {\n const values = Object.values(enm).filter((v) => typeof v === 'number');\n return {\n serialize(value) {\n if (typeof value !== 'number') throw new ArgumentError('value', 'to be a number', value);\n if (value > 0xff) throw new ArgumentError('value', 'to be less than 256', value);\n if (!isItemOfArray(value, values)) {\n throw new ArgumentError('value', 'to be a value of Enum', value);\n }\n return Buffer.from([value]);\n },\n\n deserialize(buffer) {\n if (buffer.length !== 1) {\n throw new ArgumentError('buffer', 'to have single element', buffer.length);\n }\n const value = buffer[0];\n if (!isItemOfArray(value, values)) {\n throw new ArgumentError('value', 'to be a value of Enum', value);\n }\n return value as Enum[keyof Enum];\n },\n };\n}\n"],"mappings":";;;;SAASA,aAAa;AAAA,SACbC,aAAa;AAEtB,eAAe,SAASC,
|
|
1
|
+
{"version":3,"file":"enumeration.mjs","names":["ArgumentError","isItemOfArray","genEnumerationField","enm","values","Object","filter","v","serialize","value","_Buffer","from","deserialize","buffer","length"],"sources":["../../../../src/tx/builder/field-types/enumeration.ts"],"sourcesContent":["import { ArgumentError } from '../../../utils/errors';\nimport { isItemOfArray } from '../../../utils/other';\n\nexport default function genEnumerationField<\n Enum extends { [key: string]: number | string },\n>(enm: Enum): {\n serialize: (value: Enum[keyof Enum]) => Buffer;\n deserialize: (value: Buffer) => Enum[keyof Enum];\n} {\n const values = Object.values(enm).filter((v) => typeof v === 'number');\n return {\n serialize(value) {\n if (typeof value !== 'number') throw new ArgumentError('value', 'to be a number', value);\n if (value > 0xff) throw new ArgumentError('value', 'to be less than 256', value);\n if (!isItemOfArray(value, values)) {\n throw new ArgumentError('value', 'to be a value of Enum', value);\n }\n return Buffer.from([value]);\n },\n\n deserialize(buffer) {\n if (buffer.length !== 1) {\n throw new ArgumentError('buffer', 'to have single element', buffer.length);\n }\n const value = buffer[0];\n if (!isItemOfArray(value, values)) {\n throw new ArgumentError('value', 'to be a value of Enum', value);\n }\n return value as Enum[keyof Enum];\n },\n };\n}\n"],"mappings":";;;;SAASA,aAAa;AAAA,SACbC,aAAa;AAEtB,eAAe,SAASC,mBAAmBA,CAEzCC,GAAS,EAGT;EACA,MAAMC,MAAM,GAAGC,MAAM,CAACD,MAAM,CAACD,GAAG,CAAC,CAACG,MAAM,CAAEC,CAAC,IAAK,OAAOA,CAAC,KAAK,QAAQ,CAAC;EACtE,OAAO;IACLC,SAASA,CAACC,KAAK,EAAE;MACf,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,MAAM,IAAIT,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAES,KAAK,CAAC;MACxF,IAAIA,KAAK,GAAG,IAAI,EAAE,MAAM,IAAIT,aAAa,CAAC,OAAO,EAAE,qBAAqB,EAAES,KAAK,CAAC;MAChF,IAAI,CAACR,aAAa,CAACQ,KAAK,EAAEL,MAAM,CAAC,EAAE;QACjC,MAAM,IAAIJ,aAAa,CAAC,OAAO,EAAE,uBAAuB,EAAES,KAAK,CAAC;MAClE;MACA,OAAOC,OAAA,CAAOC,IAAI,CAAC,CAACF,KAAK,CAAC,CAAC;IAC7B,CAAC;IAEDG,WAAWA,CAACC,MAAM,EAAE;MAClB,IAAIA,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAId,aAAa,CAAC,QAAQ,EAAE,wBAAwB,EAAEa,MAAM,CAACC,MAAM,CAAC;MAC5E;MACA,MAAML,KAAK,GAAGI,MAAM,CAAC,CAAC,CAAC;MACvB,IAAI,CAACZ,aAAa,CAACQ,KAAK,EAAEL,MAAM,CAAC,EAAE;QACjC,MAAM,IAAIJ,aAAa,CAAC,OAAO,EAAE,uBAAuB,EAAES,KAAK,CAAC;MAClE;MACA,OAAOA,KAAK;IACd;EACF,CAAC;AACH"}
|
|
@@ -14,7 +14,9 @@ declare const _default: {
|
|
|
14
14
|
_computingMinFee?: BigNumber | undefined;
|
|
15
15
|
_pickBiggerFee?: boolean | undefined;
|
|
16
16
|
}): string;
|
|
17
|
-
serialize(value: import("../constants").Int | undefined, { denomination
|
|
17
|
+
serialize(value: import("../constants").Int | undefined, params: {}, { denomination }: {
|
|
18
|
+
denomination?: import("../../..").AE_AMOUNT_FORMATS | undefined;
|
|
19
|
+
}): Buffer;
|
|
18
20
|
deserialize(value: Buffer): string;
|
|
19
21
|
};
|
|
20
22
|
export default _default;
|
|
@@ -93,9 +93,13 @@ export function buildFee(builtTx, unpackTx, buildTx) {
|
|
|
93
93
|
length
|
|
94
94
|
} = decode(builtTx);
|
|
95
95
|
const txObject = unpackTx(builtTx);
|
|
96
|
+
let innerTxSize = 0;
|
|
97
|
+
if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {
|
|
98
|
+
innerTxSize = decode(buildTx(txObject.tx.encodedTx)).length;
|
|
99
|
+
}
|
|
96
100
|
return TX_FEE_BASE_GAS(txObject.tag).plus(TX_FEE_OTHER_GAS(txObject.tag, length, {
|
|
97
101
|
relativeTtl: getOracleRelativeTtl(txObject),
|
|
98
|
-
innerTxSize
|
|
102
|
+
innerTxSize
|
|
99
103
|
})).times(MIN_GAS_PRICE);
|
|
100
104
|
}
|
|
101
105
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee.mjs","names":["BigNumber","IllegalArgumentError","MIN_GAS_PRICE","Tag","coinAmount","isKeyOfObject","decode","BASE_GAS","GAS_PER_BYTE","KEY_BLOCK_INTERVAL","TX_FEE_BASE_GAS","txType","feeFactors","ChannelForceProgressTx","ChannelOffChainTx","ChannelOffChainUpdateCallContract","ChannelOffChainUpdateCreateContract","ChannelOffChainUpdateDeposit","ChannelOffChainUpdateWithdraw","ChannelOffChainUpdateTransfer","ContractCreateTx","ContractCallTx","GaAttachTx","GaMetaTx","PayingForTx","factor","TX_FEE_OTHER_GAS","txSize","relativeTtl","innerTxSize","OracleRegisterTx","OracleExtendTx","OracleQueryTx","OracleResponseTx","times","plus","Math","ceil","floor","minus","getOracleRelativeTtl","params","ttlKeys","tag","buildFee","builtTx","unpackTx","buildTx","length","txObject","tx","encodedTx","calculateMinFee","rebuildTx","fee","previousFee","eq","serializeAettos","_value","_computingMinFee","_pickBiggerFee","toFixed","minFee","value","gt","toString"],"sources":["../../../../src/tx/builder/field-types/fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag } from '../constants';\nimport coinAmount from './coin-amount';\nimport { isKeyOfObject } from '../../../utils/other';\nimport { decode, Encoded } from '../../../utils/encoder';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nconst BASE_GAS = 15000;\nconst GAS_PER_BYTE = 20;\nconst KEY_BLOCK_INTERVAL = 3;\n\n/**\n * Calculate the Base fee gas\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @returns The base fee\n * @example\n * ```js\n * TX_FEE_BASE('channelForceProgress') => new BigNumber(30 * 15000)\n * ```\n */\nconst TX_FEE_BASE_GAS = (txType: Tag): BigNumber => {\n const feeFactors = {\n [Tag.ChannelForceProgressTx]: 30,\n [Tag.ChannelOffChainTx]: 0,\n [Tag.ChannelOffChainUpdateCallContract]: 0,\n [Tag.ChannelOffChainUpdateCreateContract]: 0,\n [Tag.ChannelOffChainUpdateDeposit]: 0,\n [Tag.ChannelOffChainUpdateWithdraw]: 0,\n [Tag.ChannelOffChainUpdateTransfer]: 0,\n [Tag.ContractCreateTx]: 5,\n [Tag.ContractCallTx]: 12,\n [Tag.GaAttachTx]: 5,\n [Tag.GaMetaTx]: 5,\n [Tag.PayingForTx]: 1 / 5,\n } as const;\n const factor = feeFactors[txType as keyof typeof feeFactors] ?? 1;\n return new BigNumber(factor * BASE_GAS);\n};\n\n/**\n * Calculate fee for Other types of transactions\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @param txSize - The transaction size\n * @returns parameters - The transaction parameters\n * @returns parameters.relativeTtl - The relative ttl\n * @returns parameters.innerTxSize - The size of the inner transaction\n * @returns The Other fee\n * @example\n * ```js\n * TX_FEE_OTHER_GAS('oracleResponse',10, { relativeTtl: 10, innerTxSize: 10 })\n * => new BigNumber(10).times(20).plus(Math.ceil(32000 * 10 / Math.floor(60 * 24 * 365 / 2)))\n * ```\n */\nconst TX_FEE_OTHER_GAS = (\n txType: Tag,\n txSize: number,\n { relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },\n): BigNumber => {\n switch (txType) {\n case Tag.OracleRegisterTx:\n case Tag.OracleExtendTx:\n case Tag.OracleQueryTx:\n case Tag.OracleResponseTx:\n return new BigNumber(txSize)\n .times(GAS_PER_BYTE)\n .plus(\n Math.ceil((32000 * relativeTtl) / Math.floor((60 * 24 * 365) / KEY_BLOCK_INTERVAL)),\n );\n case Tag.GaMetaTx:\n case Tag.PayingForTx:\n return new BigNumber(txSize).minus(innerTxSize).times(GAS_PER_BYTE);\n default:\n return new BigNumber(txSize).times(GAS_PER_BYTE);\n }\n};\n\nfunction getOracleRelativeTtl(params: any): number {\n const ttlKeys = {\n [Tag.OracleRegisterTx]: 'oracleTtlValue',\n [Tag.OracleExtendTx]: 'oracleTtlValue',\n [Tag.OracleQueryTx]: 'queryTtlValue',\n [Tag.OracleResponseTx]: 'responseTtlValue',\n } as const;\n\n const { tag } = params;\n if (!isKeyOfObject(tag, ttlKeys)) return 1;\n return params[ttlKeys[tag]];\n}\n\n/**\n * Calculate fee based on tx type and params\n */\nexport function buildFee(\n builtTx: Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): BigNumber {\n const { length } = decode(builtTx);\n const txObject = unpackTx(builtTx);\n\n return TX_FEE_BASE_GAS(txObject.tag)\n .plus(TX_FEE_OTHER_GAS(txObject.tag, length, {\n relativeTtl: getOracleRelativeTtl(txObject),\n innerTxSize: txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx\n ? decode(buildTx(txObject.tx.encodedTx)).length\n : 0,\n }))\n .times(MIN_GAS_PRICE);\n}\n\n/**\n * Calculate min fee\n * @category transaction builder\n * @param rebuildTx - Callback to get built transaction with specific fee\n */\nfunction calculateMinFee(\n rebuildTx: (value: BigNumber) => Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): BigNumber {\n let fee = new BigNumber(0);\n let previousFee;\n do {\n previousFee = fee;\n fee = buildFee(rebuildTx(fee), unpackTx, buildTx);\n } while (!fee.eq(previousFee));\n return fee;\n}\n\nexport default {\n ...coinAmount,\n\n serializeAettos(\n _value: string | undefined,\n {\n rebuildTx, unpackTx, buildTx, _computingMinFee, _pickBiggerFee,\n }: {\n rebuildTx: (params: any) => Encoded.Transaction;\n unpackTx: typeof unpackTxType;\n buildTx: typeof buildTxType;\n _computingMinFee?: BigNumber;\n _pickBiggerFee?: boolean;\n },\n ): string {\n if (_computingMinFee != null) return _computingMinFee.toFixed();\n const minFee = calculateMinFee(\n (fee) => rebuildTx({ _computingMinFee: fee }),\n unpackTx,\n buildTx,\n );\n const value = new BigNumber(_value ?? minFee);\n if (minFee.gt(value)) {\n if (_pickBiggerFee === true) return minFee.toFixed();\n throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);\n }\n return value.toFixed();\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,oBAAoB;AAAA,SACpBC,aAAa,EAAEC,GAAG;AAAA,OACpBC,UAAU;AAAA,SACRC,aAAa;AAAA,SACbC,MAAM;AAGf,MAAMC,QAAQ,GAAG,KAAK;AACtB,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,kBAAkB,GAAG,CAAC;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAIC,MAAW,IAAgB;EAAA;EAClD,MAAMC,UAAU,GAAG;IACjB,CAACT,GAAG,CAACU,sBAAsB,GAAG,EAAE;IAChC,CAACV,GAAG,CAACW,iBAAiB,GAAG,CAAC;IAC1B,CAACX,GAAG,CAACY,iCAAiC,GAAG,CAAC;IAC1C,CAACZ,GAAG,CAACa,mCAAmC,GAAG,CAAC;IAC5C,CAACb,GAAG,CAACc,4BAA4B,GAAG,CAAC;IACrC,CAACd,GAAG,CAACe,6BAA6B,GAAG,CAAC;IACtC,CAACf,GAAG,CAACgB,6BAA6B,GAAG,CAAC;IACtC,CAAChB,GAAG,CAACiB,gBAAgB,GAAG,CAAC;IACzB,CAACjB,GA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uD,WAAW;EACf,GAAG;IACDA,WAAW,GAAGD,GAAG;IACjBA,GAAG,GAAGV,QAAQ,CAACS,SAAS,CAACC,GAAG,CAAC,EAAER,QAAQ,EAAEC,OAAO,CAAC;EACnD,CAAC,QAAQ,CAACO,GAAG,CAACE,EAAE,CAACD,WAAW,CAAC;EAC7B,OAAOD,GAAG;AACZ;AAEA,eAAe;EACb,GAAGlD,UAAU;EAEbqD,eAAe,CACbC,MAA0B,SAUlB;IAAA,IATR;MACEL,SAAS;MAAEP,QAAQ;MAAEC,OAAO;MAAEY,gBAAgB;MAAEC;IAOlD,CAAC;IAED,IAAID,gBAAgB,IAAI,IAAI,EAAE,OAAOA,gBAAgB,CAACE,OAAO,EAAE;IAC/D,MAAMC,MAAM,GAAGV,eAAe,CAC3BE,GAAG,IAAKD,SAAS,CAAC;MAAEM,gBAAgB,EAAEL;IAAI,CAAC,CAAC,EAC7CR,QAAQ,EACRC,OAAO,CACR;IACD,MAAMgB,KAAK,GAAG,IAAI/D,SAAS,CAAC0D,MAAM,aAANA,MAAM,cAANA,MAAM,GAAII,MAAM,CAAC;IAC7C,IAAIA,MAAM,CAACE,EAAE,CAACD,KAAK,CAAC,EAAE;MACpB,IAAIH,cAAc,KAAK,IAAI,EAAE,OAAOE,MAAM,CAACD,OAAO,EAAE;MACpD,MAAM,IAAI5D,oBAAoB,CAAE,OAAM8D,KAAK,CAACE,QAAQ,EAAG,wBAAuBH,MAAO,EAAC,CAAC;IACzF;IACA,OAAOC,KAAK,CAACF,OAAO,EAAE;EACxB;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"fee.mjs","names":["BigNumber","IllegalArgumentError","MIN_GAS_PRICE","Tag","coinAmount","isKeyOfObject","decode","BASE_GAS","GAS_PER_BYTE","KEY_BLOCK_INTERVAL","TX_FEE_BASE_GAS","txType","_feeFactors","feeFactors","ChannelForceProgressTx","ChannelOffChainTx","ChannelOffChainUpdateCallContract","ChannelOffChainUpdateCreateContract","ChannelOffChainUpdateDeposit","ChannelOffChainUpdateWithdraw","ChannelOffChainUpdateTransfer","ContractCreateTx","ContractCallTx","GaAttachTx","GaMetaTx","PayingForTx","factor","TX_FEE_OTHER_GAS","txSize","_ref","relativeTtl","innerTxSize","OracleRegisterTx","OracleExtendTx","OracleQueryTx","OracleResponseTx","times","plus","Math","ceil","floor","minus","getOracleRelativeTtl","params","ttlKeys","tag","buildFee","builtTx","unpackTx","buildTx","length","txObject","tx","encodedTx","calculateMinFee","rebuildTx","fee","previousFee","eq","serializeAettos","_value","_ref2","_computingMinFee","_pickBiggerFee","toFixed","minFee","value","gt","toString"],"sources":["../../../../src/tx/builder/field-types/fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag } from '../constants';\nimport coinAmount from './coin-amount';\nimport { isKeyOfObject } from '../../../utils/other';\nimport { decode, Encoded } from '../../../utils/encoder';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nconst BASE_GAS = 15000;\nconst GAS_PER_BYTE = 20;\nconst KEY_BLOCK_INTERVAL = 3;\n\n/**\n * Calculate the Base fee gas\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @returns The base fee\n * @example\n * ```js\n * TX_FEE_BASE('channelForceProgress') => new BigNumber(30 * 15000)\n * ```\n */\nconst TX_FEE_BASE_GAS = (txType: Tag): BigNumber => {\n const feeFactors = {\n [Tag.ChannelForceProgressTx]: 30,\n [Tag.ChannelOffChainTx]: 0,\n [Tag.ChannelOffChainUpdateCallContract]: 0,\n [Tag.ChannelOffChainUpdateCreateContract]: 0,\n [Tag.ChannelOffChainUpdateDeposit]: 0,\n [Tag.ChannelOffChainUpdateWithdraw]: 0,\n [Tag.ChannelOffChainUpdateTransfer]: 0,\n [Tag.ContractCreateTx]: 5,\n [Tag.ContractCallTx]: 12,\n [Tag.GaAttachTx]: 5,\n [Tag.GaMetaTx]: 5,\n [Tag.PayingForTx]: 1 / 5,\n } as const;\n const factor = feeFactors[txType as keyof typeof feeFactors] ?? 1;\n return new BigNumber(factor * BASE_GAS);\n};\n\n/**\n * Calculate fee for Other types of transactions\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @param txSize - The transaction size\n * @returns parameters - The transaction parameters\n * @returns parameters.relativeTtl - The relative ttl\n * @returns parameters.innerTxSize - The size of the inner transaction\n * @returns The Other fee\n * @example\n * ```js\n * TX_FEE_OTHER_GAS('oracleResponse',10, { relativeTtl: 10, innerTxSize: 10 })\n * => new BigNumber(10).times(20).plus(Math.ceil(32000 * 10 / Math.floor(60 * 24 * 365 / 2)))\n * ```\n */\nconst TX_FEE_OTHER_GAS = (\n txType: Tag,\n txSize: number,\n { relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },\n): BigNumber => {\n switch (txType) {\n case Tag.OracleRegisterTx:\n case Tag.OracleExtendTx:\n case Tag.OracleQueryTx:\n case Tag.OracleResponseTx:\n return new BigNumber(txSize)\n .times(GAS_PER_BYTE)\n .plus(\n Math.ceil((32000 * relativeTtl) / Math.floor((60 * 24 * 365) / KEY_BLOCK_INTERVAL)),\n );\n case Tag.GaMetaTx:\n case Tag.PayingForTx:\n return new BigNumber(txSize).minus(innerTxSize).times(GAS_PER_BYTE);\n default:\n return new BigNumber(txSize).times(GAS_PER_BYTE);\n }\n};\n\nfunction getOracleRelativeTtl(params: any): number {\n const ttlKeys = {\n [Tag.OracleRegisterTx]: 'oracleTtlValue',\n [Tag.OracleExtendTx]: 'oracleTtlValue',\n [Tag.OracleQueryTx]: 'queryTtlValue',\n [Tag.OracleResponseTx]: 'responseTtlValue',\n } as const;\n\n const { tag } = params;\n if (!isKeyOfObject(tag, ttlKeys)) return 1;\n return params[ttlKeys[tag]];\n}\n\n/**\n * Calculate fee based on tx type and params\n */\nexport function buildFee(\n builtTx: Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): BigNumber {\n const { length } = decode(builtTx);\n const txObject = unpackTx(builtTx);\n\n let innerTxSize = 0;\n if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {\n innerTxSize = decode(buildTx(txObject.tx.encodedTx)).length;\n }\n\n return TX_FEE_BASE_GAS(txObject.tag)\n .plus(TX_FEE_OTHER_GAS(txObject.tag, length, {\n relativeTtl: getOracleRelativeTtl(txObject), innerTxSize,\n }))\n .times(MIN_GAS_PRICE);\n}\n\n/**\n * Calculate min fee\n * @category transaction builder\n * @param rebuildTx - Callback to get built transaction with specific fee\n */\nfunction calculateMinFee(\n rebuildTx: (value: BigNumber) => Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): BigNumber {\n let fee = new BigNumber(0);\n let previousFee;\n do {\n previousFee = fee;\n fee = buildFee(rebuildTx(fee), unpackTx, buildTx);\n } while (!fee.eq(previousFee));\n return fee;\n}\n\nexport default {\n ...coinAmount,\n\n serializeAettos(\n _value: string | undefined,\n {\n rebuildTx, unpackTx, buildTx, _computingMinFee, _pickBiggerFee,\n }: {\n rebuildTx: (params: any) => Encoded.Transaction;\n unpackTx: typeof unpackTxType;\n buildTx: typeof buildTxType;\n _computingMinFee?: BigNumber;\n _pickBiggerFee?: boolean;\n },\n ): string {\n if (_computingMinFee != null) return _computingMinFee.toFixed();\n const minFee = calculateMinFee(\n (fee) => rebuildTx({ _computingMinFee: fee }),\n unpackTx,\n buildTx,\n );\n const value = new BigNumber(_value ?? minFee);\n if (minFee.gt(value)) {\n if (_pickBiggerFee === true) return minFee.toFixed();\n throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);\n }\n return value.toFixed();\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,oBAAoB;AAAA,SACpBC,aAAa,EAAEC,GAAG;AAAA,OACpBC,UAAU;AAAA,SACRC,aAAa;AAAA,SACbC,MAAM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AAM,GAAGX,eAAe,CAC3BE,GAAG,IAAKD,SAAS,CAAC;MAAEO,gBAAgB,EAAEN;IAAI,CAAC,CAAC,EAC7CR,QAAQ,EACRC,OAAO,CACR;IACD,MAAMiB,KAAK,GAAG,IAAIlE,SAAS,CAAC4D,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIK,MAAM,CAAC;IAC7C,IAAIA,MAAM,CAACE,EAAE,CAACD,KAAK,CAAC,EAAE;MACpB,IAAIH,cAAc,KAAK,IAAI,EAAE,OAAOE,MAAM,CAACD,OAAO,EAAE;MACpD,MAAM,IAAI/D,oBAAoB,CAAE,OAAMiE,KAAK,CAACE,QAAQ,EAAG,wBAAuBH,MAAO,EAAC,CAAC;IACzF;IACA,OAAOC,KAAK,CAACF,OAAO,EAAE;EACxB;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.mjs","names":["serialize","value","from","deserialize","toString"],"sources":["../../../../src/tx/builder/field-types/field.ts"],"sourcesContent":["export default {\n serialize(value: string): Buffer {\n return Buffer.from(value);\n },\n\n deserialize(value: Buffer): string {\n return value.toString();\n },\n};\n"],"mappings":";;;;AAAA,eAAe;EACbA,
|
|
1
|
+
{"version":3,"file":"field.mjs","names":["serialize","value","_Buffer","from","deserialize","toString"],"sources":["../../../../src/tx/builder/field-types/field.ts"],"sourcesContent":["export default {\n serialize(value: string): Buffer {\n return Buffer.from(value);\n },\n\n deserialize(value: Buffer): string {\n return value.toString();\n },\n};\n"],"mappings":";;;;AAAA,eAAe;EACbA,SAASA,CAACC,KAAa,EAAU;IAC/B,OAAOC,OAAA,CAAOC,IAAI,CAACF,KAAK,CAAC;EAC3B,CAAC;EAEDG,WAAWA,CAACH,KAAa,EAAU;IACjC,OAAOA,KAAK,CAACI,QAAQ,EAAE;EACzB;AACF,CAAC"}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import { Tag } from '../constants';
|
|
3
3
|
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
4
4
|
declare const _default: {
|
|
5
|
-
serialize(_value: number | undefined, { tag, rebuildTx, unpackTx, buildTx,
|
|
5
|
+
serialize(_value: number | undefined, { tag, rebuildTx, unpackTx, buildTx, _computingGasLimit, }: {
|
|
6
6
|
tag: Tag;
|
|
7
7
|
rebuildTx: (params: any) => any;
|
|
8
8
|
unpackTx: typeof unpackTxType;
|
|
9
9
|
buildTx: typeof buildTxType;
|
|
10
|
-
gasMax: number;
|
|
11
10
|
_computingGasLimit?: number | undefined;
|
|
11
|
+
}, { gasMax }: {
|
|
12
|
+
gasMax?: number | undefined;
|
|
12
13
|
}): Buffer;
|
|
13
14
|
deserialize(value: Buffer): number;
|
|
14
15
|
};
|
|
@@ -7,15 +7,17 @@ function calculateGasLimitMax(gasMax, rebuildTx, unpackTx, buildTx) {
|
|
|
7
7
|
}
|
|
8
8
|
export default {
|
|
9
9
|
...shortUInt,
|
|
10
|
-
serialize(_value, _ref) {
|
|
10
|
+
serialize(_value, _ref, _ref2) {
|
|
11
11
|
let {
|
|
12
12
|
tag,
|
|
13
13
|
rebuildTx,
|
|
14
14
|
unpackTx,
|
|
15
15
|
buildTx,
|
|
16
|
-
gasMax = 6e6,
|
|
17
16
|
_computingGasLimit
|
|
18
17
|
} = _ref;
|
|
18
|
+
let {
|
|
19
|
+
gasMax = 6e6
|
|
20
|
+
} = _ref2;
|
|
19
21
|
if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);
|
|
20
22
|
const gasLimitMax = tag === Tag.GaMetaTx ? MAX_AUTH_FUN_GAS : calculateGasLimitMax(gasMax, gasLimit => rebuildTx({
|
|
21
23
|
_computingGasLimit: gasLimit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas-limit.mjs","names":["IllegalArgumentError","MIN_GAS_PRICE","Tag","MAX_AUTH_FUN_GAS","shortUInt","buildFee","calculateGasLimitMax","gasMax","rebuildTx","unpackTx","buildTx","dividedBy","serialize","_value","tag","_computingGasLimit","gasLimitMax","GaMetaTx","gasLimit","_pickBiggerFee","value"],"sources":["../../../../src/tx/builder/field-types/gas-limit.ts"],"sourcesContent":["import { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag, MAX_AUTH_FUN_GAS } from '../constants';\nimport shortUInt from './short-u-int';\nimport { buildFee } from './fee';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nfunction calculateGasLimitMax(\n gasMax: number,\n rebuildTx: (value: number) => any,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): number {\n return gasMax - +buildFee(rebuildTx(gasMax), unpackTx, buildTx).dividedBy(MIN_GAS_PRICE);\n}\n\nexport default {\n ...shortUInt,\n\n serialize(\n _value: number | undefined,\n {\n tag, rebuildTx, unpackTx, buildTx,
|
|
1
|
+
{"version":3,"file":"gas-limit.mjs","names":["IllegalArgumentError","MIN_GAS_PRICE","Tag","MAX_AUTH_FUN_GAS","shortUInt","buildFee","calculateGasLimitMax","gasMax","rebuildTx","unpackTx","buildTx","dividedBy","serialize","_value","_ref","_ref2","tag","_computingGasLimit","gasLimitMax","GaMetaTx","gasLimit","_pickBiggerFee","value"],"sources":["../../../../src/tx/builder/field-types/gas-limit.ts"],"sourcesContent":["import { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag, MAX_AUTH_FUN_GAS } from '../constants';\nimport shortUInt from './short-u-int';\nimport { buildFee } from './fee';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nfunction calculateGasLimitMax(\n gasMax: number,\n rebuildTx: (value: number) => any,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): number {\n return gasMax - +buildFee(rebuildTx(gasMax), unpackTx, buildTx).dividedBy(MIN_GAS_PRICE);\n}\n\nexport default {\n ...shortUInt,\n\n serialize(\n _value: number | undefined,\n {\n tag, rebuildTx, unpackTx, buildTx, _computingGasLimit,\n }: {\n tag: Tag;\n rebuildTx: (params: any) => any;\n unpackTx: typeof unpackTxType;\n buildTx: typeof buildTxType;\n _computingGasLimit?: number;\n },\n { gasMax = 6e6 }: { gasMax?: number },\n ): Buffer {\n if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);\n\n const gasLimitMax = tag === Tag.GaMetaTx ? MAX_AUTH_FUN_GAS : calculateGasLimitMax(\n gasMax,\n (gasLimit) => rebuildTx({ _computingGasLimit: gasLimit, _pickBiggerFee: true }),\n unpackTx,\n buildTx,\n );\n const value = _value ?? gasLimitMax;\n if (value > gasLimitMax) {\n throw new IllegalArgumentError(`Gas limit ${value} must be less or equal to ${gasLimitMax}`);\n }\n return shortUInt.serialize(value);\n },\n};\n"],"mappings":"SAASA,oBAAoB;AAAA,SACpBC,aAAa,EAAEC,GAAG,EAAEC,gBAAgB;AAAA,OACtCC,SAAS;AAAA,SACPC,QAAQ;AAGjB,SAASC,oBAAoBA,CAC3BC,MAAc,EACdC,SAAiC,EACjCC,QAA6B,EAC7BC,OAA2B,EACnB;EACR,OAAOH,MAAM,GAAG,CAACF,QAAQ,CAACG,SAAS,CAACD,MAAM,CAAC,EAAEE,QAAQ,EAAEC,OAAO,CAAC,CAACC,SAAS,CAACV,aAAa,CAAC;AAC1F;AAEA,eAAe;EACb,GAAGG,SAAS;EAEZQ,SAASA,CACPC,MAA0B,EAAAC,IAAA,EAAAC,KAAA,EAWlB;IAAA,IAVR;MACEC,GAAG;MAAER,SAAS;MAAEC,QAAQ;MAAEC,OAAO;MAAEO;IAOrC,CAAC,GAAAH,IAAA;IAAA,IACD;MAAEP,MAAM,GAAG;IAAyB,CAAC,GAAAQ,KAAA;IAErC,IAAIE,kBAAkB,IAAI,IAAI,EAAE,OAAOb,SAAS,CAACQ,SAAS,CAACK,kBAAkB,CAAC;IAE9E,MAAMC,WAAW,GAAGF,GAAG,KAAKd,GAAG,CAACiB,QAAQ,GAAGhB,gBAAgB,GAAGG,oBAAoB,CAChFC,MAAM,EACLa,QAAQ,IAAKZ,SAAS,CAAC;MAAES,kBAAkB,EAAEG,QAAQ;MAAEC,cAAc,EAAE;IAAK,CAAC,CAAC,EAC/EZ,QAAQ,EACRC,OAAO,CACR;IACD,MAAMY,KAAK,GAAGT,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIK,WAAW;IACnC,IAAII,KAAK,GAAGJ,WAAW,EAAE;MACvB,MAAM,IAAIlB,oBAAoB,CAAE,aAAYsB,KAAM,6BAA4BJ,WAAY,EAAC,CAAC;IAC9F;IACA,OAAOd,SAAS,CAACQ,SAAS,CAACU,KAAK,CAAC;EACnC;AACF,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
declare const _default: {
|
|
3
3
|
serializeAettos(value?: string | undefined): string;
|
|
4
|
-
serialize(value: import("../constants").Int | undefined, { denomination
|
|
4
|
+
serialize(value: import("../constants").Int | undefined, params: {}, { denomination }: {
|
|
5
|
+
denomination?: import("../../..").AE_AMOUNT_FORMATS | undefined;
|
|
6
|
+
}): Buffer;
|
|
5
7
|
deserialize(value: Buffer): string;
|
|
6
8
|
};
|
|
7
9
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas-price.mjs","names":["coinAmount","IllegalArgumentError","MIN_GAS_PRICE","serializeAettos","value","toString"],"sources":["../../../../src/tx/builder/field-types/gas-price.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE } from '../constants';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(value: string | undefined = MIN_GAS_PRICE.toString()): string {\n if (+value < MIN_GAS_PRICE) {\n throw new IllegalArgumentError(`Gas price ${value.toString()} must be bigger then ${MIN_GAS_PRICE}`);\n }\n return value;\n },\n};\n"],"mappings":"OAAOA,UAAU;AAAA,SACRC,oBAAoB;AAAA,SACpBC,aAAa;AAEtB,eAAe;EACb,GAAGF,UAAU;EAEbG,
|
|
1
|
+
{"version":3,"file":"gas-price.mjs","names":["coinAmount","IllegalArgumentError","MIN_GAS_PRICE","serializeAettos","value","arguments","length","undefined","toString"],"sources":["../../../../src/tx/builder/field-types/gas-price.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE } from '../constants';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(value: string | undefined = MIN_GAS_PRICE.toString()): string {\n if (+value < MIN_GAS_PRICE) {\n throw new IllegalArgumentError(`Gas price ${value.toString()} must be bigger then ${MIN_GAS_PRICE}`);\n }\n return value;\n },\n};\n"],"mappings":"OAAOA,UAAU;AAAA,SACRC,oBAAoB;AAAA,SACpBC,aAAa;AAEtB,eAAe;EACb,GAAGF,UAAU;EAEbG,eAAeA,CAAA,EAA+D;IAAA,IAA9DC,KAAyB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGH,aAAa,CAACM,QAAQ,EAAE;IAClE,IAAI,CAACJ,KAAK,GAAGF,aAAa,EAAE;MAC1B,MAAM,IAAID,oBAAoB,CAAE,aAAYG,KAAK,CAACI,QAAQ,EAAG,wBAAuBN,aAAc,EAAC,CAAC;IACtG;IACA,OAAOE,KAAK;EACd;AACF,CAAC"}
|
|
@@ -4,13 +4,24 @@ import _array from './array';
|
|
|
4
4
|
import _encoded from './encoded';
|
|
5
5
|
import _entry from './entry';
|
|
6
6
|
import _enumeration from './enumeration';
|
|
7
|
+
import _map from './map';
|
|
7
8
|
import _mptree from './mptree';
|
|
9
|
+
import _nonce from './nonce';
|
|
8
10
|
import _shortUIntConst from './short-u-int-const';
|
|
11
|
+
import _wrapped from './wrapped';
|
|
9
12
|
declare const abiVersion: {
|
|
10
|
-
|
|
13
|
+
_getProtocolDetails(c: import("../constants").ConsensusProtocolVersion, tag: import("../constants").Tag): import("../constants").AbiVersion;
|
|
14
|
+
serialize(value: import("../constants").AbiVersion | undefined, { tag }: {
|
|
11
15
|
tag: import("../constants").Tag;
|
|
12
|
-
|
|
16
|
+
}, { consensusProtocolVersion }: {
|
|
17
|
+
consensusProtocolVersion?: import("../constants").ConsensusProtocolVersion | undefined;
|
|
13
18
|
}): Buffer;
|
|
19
|
+
prepare(value: import("../constants").AbiVersion | undefined, { tag }: {
|
|
20
|
+
tag: import("../constants").Tag;
|
|
21
|
+
}, options: {
|
|
22
|
+
consensusProtocolVersion?: import("../constants").ConsensusProtocolVersion | undefined;
|
|
23
|
+
onNode?: import("../../..").Node | undefined;
|
|
24
|
+
}): Promise<import("../constants").AbiVersion | undefined>;
|
|
14
25
|
deserialize(buffer: Buffer): import("../constants").AbiVersion;
|
|
15
26
|
};
|
|
16
27
|
declare const address: typeof _address;
|
|
@@ -21,17 +32,25 @@ declare const boolean: {
|
|
|
21
32
|
};
|
|
22
33
|
declare const coinAmount: {
|
|
23
34
|
serializeAettos(value: string | undefined): string;
|
|
24
|
-
serialize(value: import("../constants").Int | undefined, { denomination
|
|
35
|
+
serialize(value: import("../constants").Int | undefined, params: {}, { denomination }: {
|
|
36
|
+
denomination?: import("../../..").AE_AMOUNT_FORMATS | undefined;
|
|
37
|
+
}): Buffer;
|
|
25
38
|
deserialize(value: Buffer): string;
|
|
26
39
|
};
|
|
27
40
|
declare const ctVersion: {
|
|
28
|
-
serialize(value: import("./ct-version").CtVersion | undefined, { consensusProtocolVersion }: {
|
|
29
|
-
consensusProtocolVersion
|
|
41
|
+
serialize(value: import("./ct-version").CtVersion | undefined, params: {}, { consensusProtocolVersion }: {
|
|
42
|
+
consensusProtocolVersion?: import("../constants").ConsensusProtocolVersion | undefined;
|
|
30
43
|
}): Buffer;
|
|
44
|
+
prepare(value: import("./ct-version").CtVersion | undefined, params: {}, options: {
|
|
45
|
+
consensusProtocolVersion?: import("../constants").ConsensusProtocolVersion | undefined;
|
|
46
|
+
onNode?: import("../../..").Node | undefined;
|
|
47
|
+
}): Promise<import("./ct-version").CtVersion | undefined>;
|
|
31
48
|
deserialize(buffer: Buffer): import("./ct-version").CtVersion;
|
|
32
49
|
};
|
|
33
50
|
declare const deposit: {
|
|
34
|
-
serialize(value: import("../constants").Int | undefined, options:
|
|
51
|
+
serialize(value: import("../constants").Int | undefined, options: {}, parameters: {
|
|
52
|
+
denomination?: import("../../..").AE_AMOUNT_FORMATS | undefined;
|
|
53
|
+
}): Buffer;
|
|
35
54
|
serializeAettos(value: string | undefined): string;
|
|
36
55
|
deserialize(value: Buffer): string;
|
|
37
56
|
};
|
|
@@ -46,7 +65,9 @@ declare const fee: {
|
|
|
46
65
|
_computingMinFee?: import("bignumber.js").BigNumber | undefined;
|
|
47
66
|
_pickBiggerFee?: boolean | undefined;
|
|
48
67
|
}): string;
|
|
49
|
-
serialize(value: import("../constants").Int | undefined, { denomination
|
|
68
|
+
serialize(value: import("../constants").Int | undefined, params: {}, { denomination }: {
|
|
69
|
+
denomination?: import("../../..").AE_AMOUNT_FORMATS | undefined;
|
|
70
|
+
}): Buffer;
|
|
50
71
|
deserialize(value: Buffer): string;
|
|
51
72
|
};
|
|
52
73
|
declare const field: {
|
|
@@ -54,21 +75,25 @@ declare const field: {
|
|
|
54
75
|
deserialize(value: Buffer): string;
|
|
55
76
|
};
|
|
56
77
|
declare const gasLimit: {
|
|
57
|
-
serialize(_value: number | undefined, { tag, rebuildTx, unpackTx, buildTx,
|
|
78
|
+
serialize(_value: number | undefined, { tag, rebuildTx, unpackTx, buildTx, _computingGasLimit, }: {
|
|
58
79
|
tag: import("../constants").Tag;
|
|
59
80
|
rebuildTx: (params: any) => any;
|
|
60
81
|
unpackTx: typeof import("..").unpackTx;
|
|
61
82
|
buildTx: typeof import("..").buildTx;
|
|
62
|
-
gasMax: number;
|
|
63
83
|
_computingGasLimit?: number | undefined;
|
|
84
|
+
}, { gasMax }: {
|
|
85
|
+
gasMax?: number | undefined;
|
|
64
86
|
}): Buffer;
|
|
65
87
|
deserialize(value: Buffer): number;
|
|
66
88
|
};
|
|
67
89
|
declare const gasPrice: {
|
|
68
90
|
serializeAettos(value?: string | undefined): string;
|
|
69
|
-
serialize(value: import("../constants").Int | undefined, { denomination
|
|
91
|
+
serialize(value: import("../constants").Int | undefined, params: {}, { denomination }: {
|
|
92
|
+
denomination?: import("../../..").AE_AMOUNT_FORMATS | undefined;
|
|
93
|
+
}): Buffer;
|
|
70
94
|
deserialize(value: Buffer): string;
|
|
71
95
|
};
|
|
96
|
+
declare const map: typeof _map;
|
|
72
97
|
declare const mptree: typeof _mptree;
|
|
73
98
|
declare const name: {
|
|
74
99
|
serialize(value: `${string}.chain`): Buffer;
|
|
@@ -80,13 +105,16 @@ declare const nameFee: {
|
|
|
80
105
|
}): string;
|
|
81
106
|
serialize(value: import("../constants").Int | undefined, txFields: {
|
|
82
107
|
name: `${string}.chain`;
|
|
83
|
-
}
|
|
108
|
+
}, parameters: {
|
|
109
|
+
denomination?: import("../../..").AE_AMOUNT_FORMATS | undefined;
|
|
110
|
+
}): Buffer;
|
|
84
111
|
deserialize(value: Buffer): string;
|
|
85
112
|
};
|
|
86
113
|
declare const nameId: {
|
|
87
114
|
serialize(value: `${string}.chain` | `nm_${string}`): Buffer;
|
|
88
115
|
deserialize: (value: Buffer) => `nm_${string}`;
|
|
89
116
|
};
|
|
117
|
+
declare const nonce: typeof _nonce;
|
|
90
118
|
declare const pointers: {
|
|
91
119
|
serialize(pointers: (import("../../../apis/node").NamePointer & {
|
|
92
120
|
id: `ch_${string}` | `ct_${string}` | `ok_${string}` | `ak_${string}` | `cm_${string}` | `nm_${string}`;
|
|
@@ -108,13 +136,24 @@ declare const string: {
|
|
|
108
136
|
serialize(string: string): Buffer;
|
|
109
137
|
deserialize(buffer: Buffer): string;
|
|
110
138
|
};
|
|
139
|
+
declare const ttl: {
|
|
140
|
+
serialize(value: number | undefined): Buffer;
|
|
141
|
+
prepare(value: number | undefined, params: {}, { onNode, absoluteTtl }: {
|
|
142
|
+
onNode?: import("../../..").Node | undefined;
|
|
143
|
+
absoluteTtl?: boolean | undefined;
|
|
144
|
+
}): Promise<number | undefined>;
|
|
145
|
+
deserialize(value: Buffer): number;
|
|
146
|
+
};
|
|
111
147
|
declare const uInt: {
|
|
112
148
|
serialize(value: import("../constants").Int): Buffer;
|
|
113
149
|
deserialize(value: Buffer): string;
|
|
114
150
|
};
|
|
151
|
+
declare const wrapped: typeof _wrapped;
|
|
115
152
|
export type BinaryData = Buffer | Buffer[] | Buffer[][] | Array<[Buffer, Array<[Buffer, Buffer[]]>]>;
|
|
116
153
|
export interface Field {
|
|
117
|
-
serialize: (value: any, options: any) => BinaryData;
|
|
154
|
+
serialize: (value: any, options: any, parameters: any) => BinaryData;
|
|
155
|
+
prepare?: (value: any, options: any, parameters: any) => Promise<any>;
|
|
118
156
|
deserialize: (value: BinaryData, options: any) => any;
|
|
157
|
+
recursiveType?: boolean;
|
|
119
158
|
}
|
|
120
|
-
export { abiVersion, address, array, boolean, coinAmount, ctVersion, deposit, encoded, entry, enumeration, fee, field, gasLimit, gasPrice, mptree, name, nameFee, nameId, pointers, raw, shortUInt, shortUIntConst, string, uInt, };
|
|
159
|
+
export { abiVersion, address, array, boolean, coinAmount, ctVersion, deposit, encoded, entry, enumeration, fee, field, gasLimit, gasPrice, map, mptree, name, nameFee, nameId, nonce, pointers, raw, shortUInt, shortUIntConst, string, ttl, uInt, wrapped, };
|