@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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Field as OriginalField } from './field-types';
|
|
2
|
+
import { UnionToIntersection } from '../../utils/other';
|
|
3
|
+
|
|
4
|
+
// TODO: figure out why this override is necessary
|
|
5
|
+
export interface Field extends OriginalField {
|
|
6
|
+
serialize: (...args: any[]) => any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type NullablePartial<
|
|
10
|
+
T,
|
|
11
|
+
NK extends keyof T = { [K in keyof T]: undefined extends T[K] ? K : never }[keyof T],
|
|
12
|
+
> = Partial<Pick<T, NK>> & Omit<T, NK>;
|
|
13
|
+
|
|
14
|
+
type Or<A, B> = A extends undefined ? B : A;
|
|
15
|
+
|
|
16
|
+
type TxParamsBySchemaInternal<SchemaItem> = {
|
|
17
|
+
-readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field
|
|
18
|
+
? Parameters<SchemaItem[key]['serialize']>[0]
|
|
19
|
+
: never;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type TxParamsBySchemaInternalParams<
|
|
23
|
+
SchemaItem,
|
|
24
|
+
SchemaItemValues = SchemaItem[keyof SchemaItem],
|
|
25
|
+
> = UnionToIntersection<
|
|
26
|
+
SchemaItemValues extends Field
|
|
27
|
+
? Or<Parameters<SchemaItemValues['serialize']>[2], {}> : never
|
|
28
|
+
>;
|
|
29
|
+
|
|
30
|
+
type PickIsRec<SchemaItem, Recursive extends boolean> = {
|
|
31
|
+
[Key in keyof SchemaItem
|
|
32
|
+
as SchemaItem[Key] extends Field & { recursiveType: true }
|
|
33
|
+
? (Recursive extends true ? Key : never)
|
|
34
|
+
: (Recursive extends true ? never : Key)]: SchemaItem[Key];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type TxParamsBySchema<SchemaItem> = SchemaItem extends Object
|
|
38
|
+
? TxParamsBySchemaInternal<PickIsRec<SchemaItem, true>> &
|
|
39
|
+
NullablePartial<TxParamsBySchemaInternal<PickIsRec<SchemaItem, false>>> &
|
|
40
|
+
TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>>
|
|
41
|
+
: never;
|
|
42
|
+
|
|
43
|
+
type TxParamsAsyncBySchemaInternal<SchemaItem> = {
|
|
44
|
+
-readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field & { prepare: Function }
|
|
45
|
+
? Parameters<SchemaItem[key]['prepare']>[0]
|
|
46
|
+
: SchemaItem[key] extends Field
|
|
47
|
+
? Parameters<SchemaItem[key]['serialize']>[0]
|
|
48
|
+
: never;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type TxParamsAsyncBySchemaInternalParams<
|
|
52
|
+
SchemaItem,
|
|
53
|
+
SchemaItemValues = SchemaItem[keyof SchemaItem],
|
|
54
|
+
> = UnionToIntersection<
|
|
55
|
+
SchemaItemValues extends Field & { prepare: Function }
|
|
56
|
+
? Or<Parameters<SchemaItemValues['prepare']>[2], {}> : {}
|
|
57
|
+
>;
|
|
58
|
+
|
|
59
|
+
type TxParamsAsyncBySchema<SchemaItem> = SchemaItem extends Object
|
|
60
|
+
? TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, true>>
|
|
61
|
+
& NullablePartial<TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, false>>>
|
|
62
|
+
& TxParamsAsyncBySchemaInternalParams<PickIsRec<SchemaItem, false>>
|
|
63
|
+
& TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>>
|
|
64
|
+
: never;
|
|
65
|
+
|
|
66
|
+
type TxUnpackedBySchema<SchemaItem> = {
|
|
67
|
+
-readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field
|
|
68
|
+
? ReturnType<SchemaItem[key]['deserialize']>
|
|
69
|
+
: never;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default interface SchemaTypes<
|
|
73
|
+
Schema extends readonly any[],
|
|
74
|
+
SchemaItems = Schema[number],
|
|
75
|
+
> {
|
|
76
|
+
TxParams: TxParamsBySchema<SchemaItems>;
|
|
77
|
+
TxParamsAsync: TxParamsAsyncBySchema<SchemaItems>;
|
|
78
|
+
TxUnpacked: TxUnpackedBySchema<SchemaItems>;
|
|
79
|
+
}
|
|
@@ -60,6 +60,7 @@ export const NAME_BID_RANGES = mapObject({
|
|
|
60
60
|
|
|
61
61
|
export enum ConsensusProtocolVersion {
|
|
62
62
|
Iris = 5,
|
|
63
|
+
Ceres = 6,
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
@@ -149,6 +150,7 @@ export enum Tag {
|
|
|
149
150
|
GaAttachTx = 80,
|
|
150
151
|
GaMetaTx = 81,
|
|
151
152
|
PayingForTx = 82,
|
|
153
|
+
GaMetaTxAuthData = 810,
|
|
152
154
|
// KeyBlock = 100,
|
|
153
155
|
// MicroBlock = 101,
|
|
154
156
|
// LightMicroBlock = 102,
|
|
@@ -1,20 +1,43 @@
|
|
|
1
1
|
import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants';
|
|
2
2
|
import { getProtocolDetails } from './ct-version';
|
|
3
|
+
import Node from '../../../Node';
|
|
3
4
|
|
|
4
5
|
export default {
|
|
6
|
+
_getProtocolDetails(c: ConsensusProtocolVersion, tag: Tag): AbiVersion {
|
|
7
|
+
const kind = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag
|
|
8
|
+
? 'contract-call' : 'oracle-call';
|
|
9
|
+
return getProtocolDetails(c, kind).abiVersion;
|
|
10
|
+
},
|
|
11
|
+
|
|
5
12
|
serialize(
|
|
6
13
|
value: AbiVersion | undefined,
|
|
7
|
-
{ tag
|
|
8
|
-
{
|
|
14
|
+
{ tag }: { tag: Tag },
|
|
15
|
+
{ consensusProtocolVersion = ConsensusProtocolVersion.Iris }:
|
|
16
|
+
{ consensusProtocolVersion?: ConsensusProtocolVersion },
|
|
9
17
|
): Buffer {
|
|
10
|
-
const result = value ??
|
|
11
|
-
consensusProtocolVersion,
|
|
12
|
-
Tag.ContractCallTx === tag || Tag.GaMetaTx === tag ? 'contract-call' : 'oracle-call',
|
|
13
|
-
).abiVersion;
|
|
18
|
+
const result = value ?? this._getProtocolDetails(consensusProtocolVersion, tag);
|
|
14
19
|
|
|
15
20
|
return Buffer.from([result]);
|
|
16
21
|
},
|
|
17
22
|
|
|
23
|
+
async prepare(
|
|
24
|
+
value: AbiVersion | undefined,
|
|
25
|
+
{ tag }: { tag: Tag },
|
|
26
|
+
// TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}
|
|
27
|
+
options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },
|
|
28
|
+
): Promise<AbiVersion | undefined> {
|
|
29
|
+
if (value != null) return value;
|
|
30
|
+
if (options.consensusProtocolVersion != null) return undefined;
|
|
31
|
+
if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
|
|
32
|
+
if (options.onNode != null) {
|
|
33
|
+
return this._getProtocolDetails(
|
|
34
|
+
(await options.onNode.getNodeInfo()).consensusProtocolVersion,
|
|
35
|
+
tag,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
},
|
|
40
|
+
|
|
18
41
|
deserialize(buffer: Buffer): AbiVersion {
|
|
19
42
|
return buffer[0];
|
|
20
43
|
},
|
|
@@ -4,7 +4,7 @@ export default function genArrayField<Input, Output, Binary>(
|
|
|
4
4
|
deserialize: (value: Binary, params: unknown) => Output;
|
|
5
5
|
},
|
|
6
6
|
): {
|
|
7
|
-
serialize: (value: Input[], params: unknown) => Binary[];
|
|
7
|
+
serialize: (value: readonly Input[], params: unknown) => Binary[];
|
|
8
8
|
deserialize: (value: Binary[], params: unknown) => Output[];
|
|
9
9
|
} {
|
|
10
10
|
return {
|
|
@@ -2,8 +2,6 @@ import uInt from './u-int';
|
|
|
2
2
|
import { Int } from '../constants';
|
|
3
3
|
import { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter';
|
|
4
4
|
|
|
5
|
-
export interface Options { denomination?: AE_AMOUNT_FORMATS }
|
|
6
|
-
|
|
7
5
|
export default {
|
|
8
6
|
...uInt,
|
|
9
7
|
|
|
@@ -11,11 +9,15 @@ export default {
|
|
|
11
9
|
return value ?? '0';
|
|
12
10
|
},
|
|
13
11
|
|
|
14
|
-
serialize(
|
|
12
|
+
serialize(
|
|
13
|
+
value: Int | undefined,
|
|
14
|
+
params: {},
|
|
15
|
+
{ denomination = AE_AMOUNT_FORMATS.AETTOS }: { denomination?: AE_AMOUNT_FORMATS },
|
|
16
|
+
): Buffer {
|
|
15
17
|
return uInt.serialize(
|
|
16
18
|
this.serializeAettos(
|
|
17
19
|
value != null ? formatAmount(value, { denomination }) : value,
|
|
18
|
-
|
|
20
|
+
params,
|
|
19
21
|
),
|
|
20
22
|
);
|
|
21
23
|
},
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants';
|
|
2
|
+
import Node from '../../../Node';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/*
|
|
5
|
+
* First abi/vm by default
|
|
6
|
+
* @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}
|
|
7
|
+
*/
|
|
4
8
|
export const ProtocolToVmAbi = {
|
|
5
9
|
[ConsensusProtocolVersion.Iris]: {
|
|
6
10
|
'contract-create': {
|
|
7
11
|
vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],
|
|
8
12
|
},
|
|
9
|
-
// TODO: Ensure that AEVM (Sophia?) is still available here
|
|
10
13
|
'contract-call': {
|
|
11
14
|
vmVersion: [], abiVersion: [AbiVersion.Fate, AbiVersion.Sophia],
|
|
12
15
|
},
|
|
13
16
|
'oracle-call': {
|
|
14
|
-
vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.
|
|
17
|
+
vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
[ConsensusProtocolVersion.Ceres]: {
|
|
21
|
+
'contract-create': {
|
|
22
|
+
vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],
|
|
23
|
+
},
|
|
24
|
+
'contract-call': {
|
|
25
|
+
vmVersion: [], abiVersion: [AbiVersion.Fate],
|
|
26
|
+
},
|
|
27
|
+
'oracle-call': {
|
|
28
|
+
vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],
|
|
15
29
|
},
|
|
16
30
|
},
|
|
17
31
|
} as const;
|
|
@@ -35,14 +49,33 @@ export function getProtocolDetails(
|
|
|
35
49
|
export default {
|
|
36
50
|
serialize(
|
|
37
51
|
value: CtVersion | undefined,
|
|
52
|
+
params: {},
|
|
38
53
|
{ consensusProtocolVersion = ConsensusProtocolVersion.Iris }:
|
|
39
|
-
{ consensusProtocolVersion
|
|
54
|
+
{ consensusProtocolVersion?: ConsensusProtocolVersion },
|
|
40
55
|
): Buffer {
|
|
41
56
|
value ??= getProtocolDetails(consensusProtocolVersion, 'contract-create');
|
|
42
57
|
|
|
43
58
|
return Buffer.from([value.vmVersion, 0, value.abiVersion]);
|
|
44
59
|
},
|
|
45
60
|
|
|
61
|
+
async prepare(
|
|
62
|
+
value: CtVersion | undefined,
|
|
63
|
+
params: {},
|
|
64
|
+
// TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}
|
|
65
|
+
options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },
|
|
66
|
+
): Promise<CtVersion | undefined> {
|
|
67
|
+
if (value != null) return value;
|
|
68
|
+
if (options.consensusProtocolVersion != null) return undefined;
|
|
69
|
+
if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
|
|
70
|
+
if (options.onNode != null) {
|
|
71
|
+
return getProtocolDetails(
|
|
72
|
+
(await options.onNode.getNodeInfo()).consensusProtocolVersion,
|
|
73
|
+
'contract-create',
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
},
|
|
78
|
+
|
|
46
79
|
deserialize(buffer: Buffer): CtVersion {
|
|
47
80
|
const [vm, , abi] = buffer;
|
|
48
81
|
return { vmVersion: +vm, abiVersion: +abi };
|
|
@@ -8,14 +8,16 @@ export default {
|
|
|
8
8
|
/**
|
|
9
9
|
* @param value - Deposit value in string format. Should be equal to '0'.
|
|
10
10
|
* @param options - Options
|
|
11
|
+
* @param parameters - Parameters
|
|
11
12
|
* @returns Deposit value Buffer.
|
|
12
13
|
*/
|
|
13
14
|
serialize(
|
|
14
15
|
value: Int | undefined,
|
|
15
16
|
options: Parameters<typeof coinAmount['serialize']>[1],
|
|
17
|
+
parameters: Parameters<typeof coinAmount['serialize']>[2],
|
|
16
18
|
): Buffer {
|
|
17
19
|
value ??= 0;
|
|
18
20
|
if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);
|
|
19
|
-
return coinAmount.serialize(value, options);
|
|
21
|
+
return coinAmount.serialize(value, options, parameters);
|
|
20
22
|
},
|
|
21
23
|
};
|
|
@@ -9,7 +9,7 @@ export default function genEncodedField<E extends Encoding, Optional extends boo
|
|
|
9
9
|
): {
|
|
10
10
|
serialize: Optional extends true
|
|
11
11
|
? (value?: Encoded.Generic<E>) => Buffer : (value: Encoded.Generic<E>) => Buffer;
|
|
12
|
-
deserialize: (value: Buffer) => Encoded.Generic<
|
|
12
|
+
deserialize: (value: Buffer) => Encoded.Generic<E>;
|
|
13
13
|
} {
|
|
14
14
|
return {
|
|
15
15
|
serialize(encodedData?: Encoded.Generic<E>) {
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
decode, encode, Encoded, Encoding,
|
|
3
|
+
} from '../../../utils/encoder';
|
|
2
4
|
import { Tag } from '../constants';
|
|
3
5
|
import { ArgumentError } from '../../../utils/errors';
|
|
4
6
|
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
5
7
|
|
|
6
8
|
export default function genEntryField<T extends Tag = Tag>(tag?: T): {
|
|
7
9
|
serialize: (
|
|
8
|
-
// TODO: replace with `
|
|
10
|
+
// TODO: replace with `TxParams & { tag: T }`,
|
|
9
11
|
// but fix TS2502 value is referenced directly or indirectly in its own type annotation
|
|
10
12
|
value: any,
|
|
11
13
|
options: { buildTx: typeof buildTxType },
|
|
12
14
|
) => Buffer;
|
|
13
15
|
deserialize: (
|
|
14
16
|
value: Buffer, options: { unpackTx: typeof unpackTxType },
|
|
15
|
-
// TODO: replace with `
|
|
17
|
+
// TODO: replace with `TxUnpacked & { tag: T }`,
|
|
16
18
|
// TS2577 Return type annotation circularly references itself
|
|
17
19
|
) => any;
|
|
18
20
|
} {
|
|
19
21
|
return {
|
|
20
22
|
serialize(txParams, { buildTx }) {
|
|
21
23
|
if (ArrayBuffer.isView(txParams)) return Buffer.from(txParams as any);
|
|
24
|
+
if (typeof txParams === 'string' && txParams.startsWith('tx_')) {
|
|
25
|
+
return decode(txParams as Encoded.Transaction);
|
|
26
|
+
}
|
|
22
27
|
return decode(buildTx({ ...txParams, ...tag != null && { tag } }));
|
|
23
28
|
},
|
|
24
29
|
|
|
@@ -101,12 +101,14 @@ export function buildFee(
|
|
|
101
101
|
const { length } = decode(builtTx);
|
|
102
102
|
const txObject = unpackTx(builtTx);
|
|
103
103
|
|
|
104
|
+
let innerTxSize = 0;
|
|
105
|
+
if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {
|
|
106
|
+
innerTxSize = decode(buildTx(txObject.tx.encodedTx)).length;
|
|
107
|
+
}
|
|
108
|
+
|
|
104
109
|
return TX_FEE_BASE_GAS(txObject.tag)
|
|
105
110
|
.plus(TX_FEE_OTHER_GAS(txObject.tag, length, {
|
|
106
|
-
relativeTtl: getOracleRelativeTtl(txObject),
|
|
107
|
-
innerTxSize: txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx
|
|
108
|
-
? decode(buildTx(txObject.tx.encodedTx)).length
|
|
109
|
-
: 0,
|
|
111
|
+
relativeTtl: getOracleRelativeTtl(txObject), innerTxSize,
|
|
110
112
|
}))
|
|
111
113
|
.times(MIN_GAS_PRICE);
|
|
112
114
|
}
|
|
@@ -19,15 +19,15 @@ export default {
|
|
|
19
19
|
serialize(
|
|
20
20
|
_value: number | undefined,
|
|
21
21
|
{
|
|
22
|
-
tag, rebuildTx, unpackTx, buildTx,
|
|
22
|
+
tag, rebuildTx, unpackTx, buildTx, _computingGasLimit,
|
|
23
23
|
}: {
|
|
24
24
|
tag: Tag;
|
|
25
25
|
rebuildTx: (params: any) => any;
|
|
26
26
|
unpackTx: typeof unpackTxType;
|
|
27
27
|
buildTx: typeof buildTxType;
|
|
28
|
-
gasMax: number;
|
|
29
28
|
_computingGasLimit?: number;
|
|
30
29
|
},
|
|
30
|
+
{ gasMax = 6e6 }: { gasMax?: number },
|
|
31
31
|
): Buffer {
|
|
32
32
|
if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);
|
|
33
33
|
|
|
@@ -12,16 +12,20 @@ import _fee from './fee';
|
|
|
12
12
|
import _field from './field';
|
|
13
13
|
import _gasLimit from './gas-limit';
|
|
14
14
|
import _gasPrice from './gas-price';
|
|
15
|
+
import _map from './map';
|
|
15
16
|
import _mptree from './mptree';
|
|
16
17
|
import _name from './name';
|
|
17
18
|
import _nameFee from './name-fee';
|
|
18
19
|
import _nameId from './name-id';
|
|
20
|
+
import _nonce from './nonce';
|
|
19
21
|
import _pointers from './pointers';
|
|
20
22
|
import _raw from './raw';
|
|
21
23
|
import _shortUInt from './short-u-int';
|
|
22
24
|
import _shortUIntConst from './short-u-int-const';
|
|
23
25
|
import _string from './string';
|
|
26
|
+
import _ttl from './ttl';
|
|
24
27
|
import _uInt from './u-int';
|
|
28
|
+
import _wrapped from './wrapped';
|
|
25
29
|
|
|
26
30
|
// TODO: remove after fixing https://github.com/Gerrit0/typedoc-plugin-missing-exports/issues/15
|
|
27
31
|
const abiVersion = _abiVersion;
|
|
@@ -38,22 +42,28 @@ const fee = _fee;
|
|
|
38
42
|
const field = _field;
|
|
39
43
|
const gasLimit = _gasLimit;
|
|
40
44
|
const gasPrice = _gasPrice;
|
|
45
|
+
const map = _map;
|
|
41
46
|
const mptree = _mptree;
|
|
42
47
|
const name = _name;
|
|
43
48
|
const nameFee = _nameFee;
|
|
44
49
|
const nameId = _nameId;
|
|
50
|
+
const nonce = _nonce;
|
|
45
51
|
const pointers = _pointers;
|
|
46
52
|
const raw = _raw;
|
|
47
53
|
const shortUInt = _shortUInt;
|
|
48
54
|
const shortUIntConst = _shortUIntConst;
|
|
49
55
|
const string = _string;
|
|
56
|
+
const ttl = _ttl;
|
|
50
57
|
const uInt = _uInt;
|
|
58
|
+
const wrapped = _wrapped;
|
|
51
59
|
|
|
52
60
|
export type BinaryData = Buffer | Buffer[] | Buffer[][]
|
|
53
61
|
| Array<[Buffer, Array<[Buffer, Buffer[]]>]>;
|
|
54
62
|
export interface Field {
|
|
55
|
-
serialize: (value: any, options: any) => BinaryData;
|
|
63
|
+
serialize: (value: any, options: any, parameters: any) => BinaryData;
|
|
64
|
+
prepare?: (value: any, options: any, parameters: any) => Promise<any>;
|
|
56
65
|
deserialize: (value: BinaryData, options: any) => any;
|
|
66
|
+
recursiveType?: boolean;
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
export {
|
|
@@ -71,14 +81,18 @@ export {
|
|
|
71
81
|
field,
|
|
72
82
|
gasLimit,
|
|
73
83
|
gasPrice,
|
|
84
|
+
map,
|
|
74
85
|
mptree,
|
|
75
86
|
name,
|
|
76
87
|
nameFee,
|
|
77
88
|
nameId,
|
|
89
|
+
nonce,
|
|
78
90
|
pointers,
|
|
79
91
|
raw,
|
|
80
92
|
shortUInt,
|
|
81
93
|
shortUIntConst,
|
|
82
94
|
string,
|
|
95
|
+
ttl,
|
|
83
96
|
uInt,
|
|
97
|
+
wrapped,
|
|
84
98
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Tag } from '../constants';
|
|
2
|
+
import {
|
|
3
|
+
encode, Encoding, Encoded, decode,
|
|
4
|
+
} from '../../../utils/encoder';
|
|
5
|
+
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
6
|
+
|
|
7
|
+
export default function genMapField<E extends Encoding, T extends Tag>(encoding: E, tag: T): {
|
|
8
|
+
serialize: (
|
|
9
|
+
// TODO: replace with `TxParams & { tag: T }`,
|
|
10
|
+
// but fix TS2502 value is referenced directly or indirectly in its own type annotation
|
|
11
|
+
value: Record<Encoded.Generic<E>, any>, options: { buildTx: typeof buildTxType }
|
|
12
|
+
) => Buffer;
|
|
13
|
+
deserialize: (
|
|
14
|
+
value: Buffer, options: { unpackTx: typeof unpackTxType },
|
|
15
|
+
// TODO: replace with `TxUnpacked & { tag: T }`,
|
|
16
|
+
// TS2577 Return type annotation circularly references itself
|
|
17
|
+
) => Record<Encoded.Generic<E>, any>;
|
|
18
|
+
recursiveType: true;
|
|
19
|
+
} {
|
|
20
|
+
return {
|
|
21
|
+
serialize(object, { buildTx }) {
|
|
22
|
+
return decode(buildTx({
|
|
23
|
+
tag: Tag.Mtree,
|
|
24
|
+
values: Object.entries(object).map(([key, value]) => ({
|
|
25
|
+
tag: Tag.MtreeValue,
|
|
26
|
+
key: decode(key as Encoded.Generic<E>),
|
|
27
|
+
value: decode(buildTx({ ...value as any, tag })),
|
|
28
|
+
})),
|
|
29
|
+
}));
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
deserialize(buffer, { unpackTx }) {
|
|
33
|
+
const { values } = unpackTx(encode(buffer, Encoding.Transaction), Tag.Mtree);
|
|
34
|
+
return Object.fromEntries(values
|
|
35
|
+
// TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066
|
|
36
|
+
.filter(({ key }) => encoding !== Encoding.ContractAddress || key.length === 32)
|
|
37
|
+
.map(({ key, value }) => [
|
|
38
|
+
encode(key, encoding),
|
|
39
|
+
unpackTx(encode(value, Encoding.Transaction), tag),
|
|
40
|
+
])) as Record<Encoded.Generic<E>, any>;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
recursiveType: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
decode, encode, Encoded, Encoding,
|
|
14
14
|
} from '../../../utils/encoder';
|
|
15
15
|
import type { unpackTx } from '..';
|
|
16
|
+
import type { TxUnpacked } from '../schema.generated';
|
|
16
17
|
|
|
17
18
|
enum NodeType {
|
|
18
19
|
Branch,
|
|
@@ -176,7 +177,7 @@ class MPTree<E extends Encoding, T extends Tag> {
|
|
|
176
177
|
* @param key - The key of the element to retrieve
|
|
177
178
|
* @returns Value associated to the specified key
|
|
178
179
|
*/
|
|
179
|
-
get(key: Encoded.Generic<E>):
|
|
180
|
+
get(key: Encoded.Generic<E>): TxUnpacked & { tag: T } | undefined {
|
|
180
181
|
const d = this.#getRaw(decode(key).toString('hex'));
|
|
181
182
|
if (d == null) return d;
|
|
182
183
|
return this.#unpackTx(encode(d, Encoding.Transaction), this.#tag);
|
|
@@ -215,14 +216,14 @@ class MPTree<E extends Encoding, T extends Tag> {
|
|
|
215
216
|
return entries;
|
|
216
217
|
}
|
|
217
218
|
|
|
218
|
-
toObject(): Record<Encoded.
|
|
219
|
+
toObject(): Record<Encoded.Generic<E>, TxUnpacked & { tag: T }> {
|
|
219
220
|
return Object.fromEntries(this.#entriesRaw()
|
|
220
221
|
// TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066
|
|
221
222
|
.filter(([k]) => this.#encoding !== Encoding.ContractAddress || k.length !== 66)
|
|
222
223
|
.map(([k, v]) => [
|
|
223
224
|
encode(Buffer.from(k, 'hex'), this.#encoding),
|
|
224
225
|
this.#unpackTx(encode(v, Encoding.Transaction), this.#tag),
|
|
225
|
-
]))
|
|
226
|
+
])) as Record<Encoded.Generic<E>, TxUnpacked & { tag: T }>;
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
|
|
@@ -25,7 +25,8 @@ export default {
|
|
|
25
25
|
serialize(
|
|
26
26
|
value: Int | undefined,
|
|
27
27
|
txFields: { name: AensName } & Parameters<typeof coinAmount['serialize']>[1],
|
|
28
|
+
parameters: Parameters<typeof coinAmount['serialize']>[2],
|
|
28
29
|
): Buffer {
|
|
29
|
-
return coinAmount.serialize.call(this, value, txFields);
|
|
30
|
+
return coinAmount.serialize.call(this, value, txFields, parameters);
|
|
30
31
|
},
|
|
31
32
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isAccountNotFoundError } from '../../../utils/other';
|
|
2
|
+
import shortUInt from './short-u-int';
|
|
3
|
+
import Node from '../../../Node';
|
|
4
|
+
import { ArgumentError } from '../../../utils/errors';
|
|
5
|
+
import { NextNonceStrategy } from '../../../apis/node';
|
|
6
|
+
|
|
7
|
+
export default function genNonceField<SenderKey extends string>(senderKey: SenderKey): {
|
|
8
|
+
serialize: (value: number) => Buffer;
|
|
9
|
+
// TODO: (value: number) => Promise<number> | (value: undefined, ...) => Promise<number>
|
|
10
|
+
prepare: (
|
|
11
|
+
value: number | undefined,
|
|
12
|
+
params: {},
|
|
13
|
+
// TODO: replace `string` with AddressEncodings
|
|
14
|
+
options: { [key in SenderKey]: string } & { strategy?: NextNonceStrategy; onNode?: Node },
|
|
15
|
+
) => Promise<number>;
|
|
16
|
+
deserialize: (value: Buffer) => number;
|
|
17
|
+
senderKey: string;
|
|
18
|
+
} {
|
|
19
|
+
return {
|
|
20
|
+
...shortUInt,
|
|
21
|
+
|
|
22
|
+
async prepare(value, params, options) {
|
|
23
|
+
if (value != null) return value;
|
|
24
|
+
const { onNode, strategy } = options;
|
|
25
|
+
const senderId = options[senderKey];
|
|
26
|
+
const requirement = 'provided (or provide `nonce` instead)';
|
|
27
|
+
if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);
|
|
28
|
+
if (senderId == null) throw new ArgumentError('senderId', requirement, senderId);
|
|
29
|
+
return (
|
|
30
|
+
await onNode.getAccountNextNonce(senderId.replace(/^ok_/, 'ak_'), { strategy })
|
|
31
|
+
.catch((error) => {
|
|
32
|
+
if (!isAccountNotFoundError(error)) throw error;
|
|
33
|
+
return { nextNonce: 1 };
|
|
34
|
+
})
|
|
35
|
+
).nextNonce;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
senderKey,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
import { ArgumentError } from '../../../utils/errors';
|
|
2
2
|
import shortUInt from './short-u-int';
|
|
3
3
|
|
|
4
|
-
export default function genShortUIntConstField<
|
|
5
|
-
|
|
4
|
+
export default function genShortUIntConstField<
|
|
5
|
+
Value extends number, Optional extends boolean = false,
|
|
6
|
+
>(constValue: Value, optional?: Optional): {
|
|
7
|
+
serialize: Optional extends true ? (value?: Value) => Buffer : (value: Value) => Buffer;
|
|
6
8
|
deserialize: (value: Buffer) => Value;
|
|
9
|
+
constValue: Value;
|
|
10
|
+
constValueOptional: boolean;
|
|
7
11
|
} {
|
|
8
12
|
return {
|
|
9
|
-
serialize(
|
|
10
|
-
if (
|
|
11
|
-
|
|
13
|
+
serialize(value?: Value) {
|
|
14
|
+
if ((optional !== true || value != null) && value !== constValue) {
|
|
15
|
+
throw new ArgumentError('ShortUIntConst', constValue, value);
|
|
16
|
+
}
|
|
17
|
+
return shortUInt.serialize(constValue);
|
|
12
18
|
},
|
|
13
19
|
|
|
14
20
|
deserialize(buf) {
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
21
|
+
const value = shortUInt.deserialize(buf);
|
|
22
|
+
if (value !== constValue) throw new ArgumentError('ShortUIntConst', constValue, value);
|
|
23
|
+
return constValue;
|
|
18
24
|
},
|
|
25
|
+
|
|
26
|
+
constValue,
|
|
27
|
+
|
|
28
|
+
constValueOptional: optional === true,
|
|
19
29
|
};
|
|
20
30
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import shortUInt from './short-u-int';
|
|
2
|
+
import Node from '../../../Node';
|
|
3
|
+
import { ArgumentError } from '../../../utils/errors';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
...shortUInt,
|
|
7
|
+
|
|
8
|
+
serialize(value: number | undefined): Buffer {
|
|
9
|
+
return shortUInt.serialize(value ?? 0);
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
async prepare(
|
|
13
|
+
value: number | undefined,
|
|
14
|
+
params: {},
|
|
15
|
+
// TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }
|
|
16
|
+
{ onNode, absoluteTtl }: { onNode?: Node; absoluteTtl?: boolean },
|
|
17
|
+
) {
|
|
18
|
+
if (absoluteTtl !== true && value !== 0 && value != null) {
|
|
19
|
+
if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);
|
|
20
|
+
value += (await onNode.getCurrentKeyBlock()).height;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Tag } from '../constants';
|
|
2
|
+
import { encode, Encoding, decode } from '../../../utils/encoder';
|
|
3
|
+
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
4
|
+
|
|
5
|
+
type TagWrapping = Tag.AccountsMtree | Tag.CallsMtree | Tag.ChannelsMtree | Tag.ContractsMtree
|
|
6
|
+
| Tag.NameserviceMtree | Tag.OraclesMtree;
|
|
7
|
+
|
|
8
|
+
export default function genWrappedField<T extends TagWrapping>(tag: T): {
|
|
9
|
+
serialize: (
|
|
10
|
+
// TODO: replace with `(TxParams & { tag: T })['payload']`,
|
|
11
|
+
// but fix TS2502 value is referenced directly or indirectly in its own type annotation
|
|
12
|
+
value: any, options: { buildTx: typeof buildTxType }
|
|
13
|
+
) => Buffer;
|
|
14
|
+
deserialize: (
|
|
15
|
+
value: Buffer, options: { unpackTx: typeof unpackTxType },
|
|
16
|
+
// TODO: replace with `(TxUnpacked & { tag: T })['payload']`,
|
|
17
|
+
// TS2577 Return type annotation circularly references itself
|
|
18
|
+
) => any;
|
|
19
|
+
recursiveType: true;
|
|
20
|
+
} {
|
|
21
|
+
return {
|
|
22
|
+
serialize(payload, { buildTx }) {
|
|
23
|
+
return decode(buildTx({ tag, payload }));
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
deserialize(buffer, { unpackTx }) {
|
|
27
|
+
return unpackTx<TagWrapping>(encode(buffer, Encoding.Transaction), tag).payload;
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
recursiveType: true,
|
|
31
|
+
};
|
|
32
|
+
}
|