@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":["BigNumber","genSalt","hash","decode","encode","Encoding","toBytes","concatBuffers","NAME_BID_RANGES","NAME_BID_TIMEOUT_BLOCKS","NAME_FEE_BID_INCREMENT","NAME_MAX_LENGTH_FEE","ceil","ArgumentError","IllegalBidFeeError","buildContractId","ownerId","nonce","ownerIdAndNonce","from","b2bHash","ContractAddress","oracleQueryId","senderId","oracleId","_int32","val","nonceBE","alloc","length","OracleQueryId","produceNameId","name","toLowerCase","Name","commitmentHash","salt","toString","padStart","Commitment","readInt","buf","AENS_SUFFIX","isNameValid","endsWith","encodingToPointerKey","AccountAddress","OracleAddress","Channel","getDefaultPointerKey","identifier","encoding","substring","result","find","e","map","join","getMinimumNameFee","nameLength","Math","min","computeBidFee","startFee","increment","Number","times","plus","computeAuctionEndBlock","claimHeight","h","isAuctionName"],"sources":["../../../src/tx/builder/helpers.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { genSalt, hash } from '../../utils/crypto';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../utils/encoder';\nimport { toBytes } from '../../utils/bytes';\nimport { concatBuffers } from '../../utils/other';\nimport {\n AensName,\n NAME_BID_RANGES,\n NAME_BID_TIMEOUT_BLOCKS,\n NAME_FEE_BID_INCREMENT,\n NAME_MAX_LENGTH_FEE,\n} from './constants';\nimport { ceil } from '../../utils/bignumber';\nimport { ArgumentError, IllegalBidFeeError } from '../../utils/errors';\n\n/**\n * JavaScript-based Transaction builder helper function's\n */\n\n/**\n * Build a contract public key\n * @category contract\n * @param ownerId - The public key of the owner account\n * @param nonce - the nonce of the transaction\n * @returns Contract public key\n */\nexport function buildContractId(\n ownerId: Encoded.AccountAddress,\n nonce: number | BigNumber,\n): Encoded.ContractAddress {\n const ownerIdAndNonce = Buffer.from([...decode(ownerId), ...toBytes(nonce)]);\n const b2bHash = hash(ownerIdAndNonce);\n return encode(b2bHash, Encoding.ContractAddress);\n}\n\n/**\n * Build a oracle query id\n * @category oracle\n * @param senderId - The public key of the sender account\n * @param nonce - the nonce of the transaction\n * @param oracleId - The oracle public key\n * @returns Contract public key\n */\nexport function oracleQueryId(\n senderId: Encoded.AccountAddress,\n nonce: number | BigNumber | string,\n oracleId: Encoded.OracleAddress,\n): Encoded.OracleQueryId {\n function _int32(val: number | string | BigNumber): Buffer {\n const nonceBE = toBytes(val, true);\n return concatBuffers([Buffer.alloc(32 - nonceBE.length), nonceBE]);\n }\n\n const b2bHash = hash(\n Buffer.from([...decode(senderId), ..._int32(nonce), ...decode(oracleId)]),\n );\n return encode(b2bHash, Encoding.OracleQueryId);\n}\n\n/**\n * Encode an AENS name\n * @category AENS\n * @param name - Name to encode\n * @returns `nm_` prefixed encoded AENS name\n */\nexport function produceNameId(name: AensName): Encoded.Name {\n return encode(hash(name.toLowerCase()), Encoding.Name);\n}\n\n/**\n * Generate the commitment hash by hashing the salt and\n * name, base 58 encoding the result and prepending 'cm_'\n * @category transaction builder\n * @param name - Name to be registered\n * @param salt - Random number\n * @returns Commitment hash\n */\nexport function commitmentHash(\n name: AensName,\n salt: number = genSalt(),\n): Encoded.Commitment {\n return encode(\n hash(concatBuffers([\n Buffer.from(name.toLowerCase()),\n Buffer.from(salt.toString(16).padStart(64, '0'), 'hex'),\n ])),\n Encoding.Commitment,\n );\n}\n\n/**\n * Utility function to convert bytes to int\n * @category transaction builder\n * @param buf - Value\n * @returns Buffer Buffer from number(BigEndian)\n */\nexport function readInt(buf: Buffer = Buffer.from([])): string {\n return new BigNumber(Buffer.from(buf).toString('hex'), 16).toString(10);\n}\n\nconst AENS_SUFFIX = '.chain';\n\n/**\n * Is AENS name valid\n * @category AENS\n * @param name - AENS name\n */\nexport function isNameValid(name: string): name is AensName {\n // TODO: probably there are stronger requirements\n return name.endsWith(AENS_SUFFIX);\n}\n\nconst encodingToPointerKey = [\n [Encoding.AccountAddress, 'account_pubkey'],\n [Encoding.OracleAddress, 'oracle_pubkey'],\n [Encoding.ContractAddress, 'contract_pubkey'],\n [Encoding.Channel, 'channel'],\n] as const;\n\n/**\n * @category AENS\n * @param identifier - account/oracle/contract address, or channel\n * @returns default AENS pointer key\n */\nexport function getDefaultPointerKey(\n identifier: Encoded.Generic<typeof encodingToPointerKey[number][0]>,\n): typeof encodingToPointerKey[number][1] {\n decode(identifier);\n const encoding = identifier.substring(0, 2);\n const result = encodingToPointerKey.find(([e]) => e === encoding)?.[1];\n if (result != null) return result;\n throw new ArgumentError(\n 'identifier',\n `prefixed with one of ${encodingToPointerKey.map(([e]) => `${e}_`).join(', ')}`,\n identifier,\n );\n}\n\n/**\n * Get the minimum AENS name fee\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @returns the minimum fee for the AENS name auction\n */\nexport function getMinimumNameFee(name: AensName): BigNumber {\n const nameLength = name.length - AENS_SUFFIX.length;\n return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)];\n}\n\n/**\n * Compute bid fee for AENS auction\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @param options - Options\n * @param options.startFee - Auction start fee\n * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1)\n * @returns Bid fee\n */\nexport function computeBidFee(\n name: AensName,\n { startFee, increment = NAME_FEE_BID_INCREMENT }:\n { startFee?: number | string | BigNumber; increment?: number } = {},\n): BigNumber {\n if (!(Number(increment) === increment && increment % 1 !== 0)) throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`);\n if (increment < NAME_FEE_BID_INCREMENT) throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`);\n // FIXME: increment should be used somehow here\n return ceil(\n new BigNumber(startFee ?? getMinimumNameFee(name))\n .times(new BigNumber(NAME_FEE_BID_INCREMENT).plus(1)),\n );\n}\n\n/**\n * Compute auction end height\n * @category AENS\n * @param name - Name to compute auction end for\n * @param claimHeight - Auction starting height\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}\n * @returns Auction end height\n */\nexport function computeAuctionEndBlock(name: AensName, claimHeight: number): number {\n const length = name.length - AENS_SUFFIX.length;\n const h = (length <= 4 ? 62 * NAME_BID_TIMEOUT_BLOCKS : null)\n ?? (length <= 8 ? 31 * NAME_BID_TIMEOUT_BLOCKS : null)\n ?? (length <= 12 ? NAME_BID_TIMEOUT_BLOCKS : null)\n ?? 0;\n return h + claimHeight;\n}\n\n/**\n * Is name accept going to auction\n * @category AENS\n */\nexport function isAuctionName(name: AensName): boolean {\n return name.length < 13 + AENS_SUFFIX.length;\n}\n"],"mappings":";;;;AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,OAAO,EAAEC,IAAI;AAAA,SAEpBC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,OAAO;AAAA,SACPC,aAAa;AAAA,SAGpBC,eAAe,EACfC,uBAAuB,EACvBC,sBAAsB,EACtBC,mBAAmB;AAAA,SAEZC,IAAI;AAAA,SACJC,aAAa,EAAEC,kBAAkB;AAE1C;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAe,CAC7BC,OAA+B,EAC/BC,KAAyB,EACA;EACzB,MAAMC,eAAe,GAAG,QAAOC,IAAI,CAAC,CAAC,GAAGhB,MAAM,CAACa,OAAO,CAAC,EAAE,GAAGV,OAAO,CAACW,KAAK,CAAC,CAAC,CAAC;EAC5E,MAAMG,OAAO,GAAGlB,IAAI,CAACgB,eAAe,CAAC;EACrC,OAAOd,MAAM,CAACgB,OAAO,EAAEf,QAAQ,CAACgB,eAAe,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAa,CAC3BC,QAAgC,EAChCN,KAAkC,EAClCO,QAA+B,EACR;EACvB,SAASC,MAAM,CAACC,GAAgC,EAAU;IACxD,MAAMC,OAAO,GAAGrB,OAAO,CAACoB,GAAG,EAAE,IAAI,CAAC;IAClC,OAAOnB,aAAa,CAAC,CAAC,QAAOqB,KAAK,CAAC,EAAE,GAAGD,OAAO,CAACE,MAAM,CAAC,EAAEF,OAAO,CAAC,CAAC;EACpE;EAEA,MAAMP,OAAO,GAAGlB,IAAI,CAClB,QAAOiB,IAAI,CAAC,CAAC,GAAGhB,MAAM,CAACoB,QAAQ,CAAC,EAAE,GAAGE,MAAM,CAACR,KAAK,CAAC,EAAE,GAAGd,MAAM,CAACqB,QAAQ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AAC,KAAKA,SAAS,IAAIA,SAAS,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,IAAIlD,kBAAkB,CAAE,8CAA6CkD,SAAU,EAAC,CAAC;EACtJ,IAAIA,SAAS,GAAGtD,sBAAsB,EAAE,MAAM,IAAII,kBAAkB,CAAE,mCAAkCJ,sBAAuB,EAAC,CAAC;EACjI;EACA,OAAOE,IAAI,CACT,IAAIZ,SAAS,CAAC+D,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIL,iBAAiB,CAAC1B,IAAI,CAAC,CAAC,CAC/CkC,KAAK,CAAC,IAAIlE,SAAS,CAACU,sBAAsB,CAAC,CAACyD,IAAI,CAAC,CAAC,CAAC,CAAC,CACxD;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsB,CAACpC,IAAc,EAAEqC,WAAmB,EAAU;EAAA;EAClF,MAAMxC,MAAM,GAAGG,IAAI,CAACH,MAAM,GAAGa,WAAW,CAACb,MAAM;EAC/C,MAAMyC,CAAC,8BAAIzC,MAAM,IAAI,CAAC,GAAG,EAAE,GAAGpB,uBAAuB,GAAG,IAAI,yCACtDoB,MAAM,IAAI,CAAC,GAAG,EAAE,GAAGpB,uBAAuB,GAAG,IAAI,yCACjDoB,MAAM,IAAI,EAAE,GAAGpB,uBAAuB,GAAG,IAAI,yCAC9C,CAAC;EACN,OAAO6D,CAAC,GAAGD,WAAW;AACxB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,aAAa,CAACvC,IAAc,EAAW;EACrD,OAAOA,IAAI,CAACH,MAAM,GAAG,EAAE,GAAGa,WAAW,CAACb,MAAM;AAC9C"}
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":["BigNumber","genSalt","hash","decode","encode","Encoding","toBytes","concatBuffers","NAME_BID_RANGES","NAME_BID_TIMEOUT_BLOCKS","NAME_FEE_BID_INCREMENT","NAME_MAX_LENGTH_FEE","ceil","ArgumentError","IllegalBidFeeError","buildContractId","ownerId","nonce","ownerIdAndNonce","_Buffer","from","b2bHash","ContractAddress","oracleQueryId","senderId","oracleId","_int32","val","nonceBE","alloc","length","OracleQueryId","produceNameId","name","toLowerCase","Name","commitmentHash","salt","arguments","undefined","toString","padStart","Commitment","readInt","buf","AENS_SUFFIX","isNameValid","endsWith","encodingToPointerKey","AccountAddress","OracleAddress","Channel","getDefaultPointerKey","identifier","_encodingToPointerKey","encoding","substring","result","find","_ref","e","map","_ref2","join","getMinimumNameFee","nameLength","Math","min","computeBidFee","startFee","increment","Number","times","plus","computeAuctionEndBlock","claimHeight","_ref3","_ref4","_ref5","h","isAuctionName"],"sources":["../../../src/tx/builder/helpers.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { genSalt, hash } from '../../utils/crypto';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../utils/encoder';\nimport { toBytes } from '../../utils/bytes';\nimport { concatBuffers } from '../../utils/other';\nimport {\n AensName,\n NAME_BID_RANGES,\n NAME_BID_TIMEOUT_BLOCKS,\n NAME_FEE_BID_INCREMENT,\n NAME_MAX_LENGTH_FEE,\n} from './constants';\nimport { ceil } from '../../utils/bignumber';\nimport { ArgumentError, IllegalBidFeeError } from '../../utils/errors';\n\n/**\n * JavaScript-based Transaction builder helper function's\n */\n\n/**\n * Build a contract public key\n * @category contract\n * @param ownerId - The public key of the owner account\n * @param nonce - the nonce of the transaction\n * @returns Contract public key\n */\nexport function buildContractId(\n ownerId: Encoded.AccountAddress,\n nonce: number | BigNumber,\n): Encoded.ContractAddress {\n const ownerIdAndNonce = Buffer.from([...decode(ownerId), ...toBytes(nonce)]);\n const b2bHash = hash(ownerIdAndNonce);\n return encode(b2bHash, Encoding.ContractAddress);\n}\n\n/**\n * Build a oracle query id\n * @category oracle\n * @param senderId - The public key of the sender account\n * @param nonce - the nonce of the transaction\n * @param oracleId - The oracle public key\n * @returns Contract public key\n */\nexport function oracleQueryId(\n senderId: Encoded.AccountAddress,\n nonce: number | BigNumber | string,\n oracleId: Encoded.OracleAddress,\n): Encoded.OracleQueryId {\n function _int32(val: number | string | BigNumber): Buffer {\n const nonceBE = toBytes(val, true);\n return concatBuffers([Buffer.alloc(32 - nonceBE.length), nonceBE]);\n }\n\n const b2bHash = hash(\n Buffer.from([...decode(senderId), ..._int32(nonce), ...decode(oracleId)]),\n );\n return encode(b2bHash, Encoding.OracleQueryId);\n}\n\n/**\n * Encode an AENS name\n * @category AENS\n * @param name - Name to encode\n * @returns `nm_` prefixed encoded AENS name\n */\nexport function produceNameId(name: AensName): Encoded.Name {\n return encode(hash(name.toLowerCase()), Encoding.Name);\n}\n\n/**\n * Generate the commitment hash by hashing the salt and\n * name, base 58 encoding the result and prepending 'cm_'\n * @category transaction builder\n * @param name - Name to be registered\n * @param salt - Random number\n * @returns Commitment hash\n */\nexport function commitmentHash(\n name: AensName,\n salt: number = genSalt(),\n): Encoded.Commitment {\n return encode(\n hash(concatBuffers([\n Buffer.from(name.toLowerCase()),\n Buffer.from(salt.toString(16).padStart(64, '0'), 'hex'),\n ])),\n Encoding.Commitment,\n );\n}\n\n/**\n * Utility function to convert bytes to int\n * @category transaction builder\n * @param buf - Value\n * @returns Buffer Buffer from number(BigEndian)\n */\nexport function readInt(buf: Buffer = Buffer.from([])): string {\n return new BigNumber(Buffer.from(buf).toString('hex'), 16).toString(10);\n}\n\nconst AENS_SUFFIX = '.chain';\n\n/**\n * Is AENS name valid\n * @category AENS\n * @param name - AENS name\n */\nexport function isNameValid(name: string): name is AensName {\n // TODO: probably there are stronger requirements\n return name.endsWith(AENS_SUFFIX);\n}\n\nconst encodingToPointerKey = [\n [Encoding.AccountAddress, 'account_pubkey'],\n [Encoding.OracleAddress, 'oracle_pubkey'],\n [Encoding.ContractAddress, 'contract_pubkey'],\n [Encoding.Channel, 'channel'],\n] as const;\n\n/**\n * @category AENS\n * @param identifier - account/oracle/contract address, or channel\n * @returns default AENS pointer key\n */\nexport function getDefaultPointerKey(\n identifier: Encoded.Generic<typeof encodingToPointerKey[number][0]>,\n): typeof encodingToPointerKey[number][1] {\n decode(identifier);\n const encoding = identifier.substring(0, 2);\n const result = encodingToPointerKey.find(([e]) => e === encoding)?.[1];\n if (result != null) return result;\n throw new ArgumentError(\n 'identifier',\n `prefixed with one of ${encodingToPointerKey.map(([e]) => `${e}_`).join(', ')}`,\n identifier,\n );\n}\n\n/**\n * Get the minimum AENS name fee\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @returns the minimum fee for the AENS name auction\n */\nexport function getMinimumNameFee(name: AensName): BigNumber {\n const nameLength = name.length - AENS_SUFFIX.length;\n return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)];\n}\n\n/**\n * Compute bid fee for AENS auction\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @param options - Options\n * @param options.startFee - Auction start fee\n * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1)\n * @returns Bid fee\n */\nexport function computeBidFee(\n name: AensName,\n { startFee, increment = NAME_FEE_BID_INCREMENT }:\n { startFee?: number | string | BigNumber; increment?: number } = {},\n): BigNumber {\n if (!(Number(increment) === increment && increment % 1 !== 0)) throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`);\n if (increment < NAME_FEE_BID_INCREMENT) throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`);\n // FIXME: increment should be used somehow here\n return ceil(\n new BigNumber(startFee ?? getMinimumNameFee(name))\n .times(new BigNumber(NAME_FEE_BID_INCREMENT).plus(1)),\n );\n}\n\n/**\n * Compute auction end height\n * @category AENS\n * @param name - Name to compute auction end for\n * @param claimHeight - Auction starting height\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}\n * @returns Auction end height\n */\nexport function computeAuctionEndBlock(name: AensName, claimHeight: number): number {\n const length = name.length - AENS_SUFFIX.length;\n const h = (length <= 4 ? 62 * NAME_BID_TIMEOUT_BLOCKS : null)\n ?? (length <= 8 ? 31 * NAME_BID_TIMEOUT_BLOCKS : null)\n ?? (length <= 12 ? NAME_BID_TIMEOUT_BLOCKS : null)\n ?? 0;\n return h + claimHeight;\n}\n\n/**\n * Is name accept going to auction\n * @category AENS\n */\nexport function isAuctionName(name: AensName): boolean {\n return name.length < 13 + AENS_SUFFIX.length;\n}\n"],"mappings":";;;;AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,OAAO,EAAEC,IAAI;AAAA,SAEpBC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,OAAO;AAAA,SACPC,aAAa;AAAA,SAGpBC,eAAe,EACfC,uBAAuB,EACvBC,sBAAsB,EACtBC,mBAAmB;AAAA,SAEZC,IAAI;AAAA,SACJC,aAAa,EAAEC,kBAAkB;AAE1C;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,OAA+B,EAC/BC,KAAyB,EACA;EACzB,MAAMC,eAAe,GAAGC,OAAA,CAAOC,IAAI,CAAC,CAAC,GAAGjB,MAAM,CAACa,OAAO,CAAC,EAAE,GAAGV,OAAO,CAACW,KAAK,CAAC,CAAC,CAAC;EAC5E,MAAMI,OAAO,GAAGnB,IAAI,CAACgB,eAAe,CAAC;EACrC,OAAOd,MAAM,CAACiB,OAAO,EAAEhB,QAAQ,CAACiB,eAAe,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BC,QAAgC,EAChCP,KAAkC,EAClCQ,QAA+B,EACR;EACvB,SAASC,MAAMA,CAACC,GAAgC,EAAU;IACxD,MAAMC,OAAO,GAAGtB,OAAO,CAACqB,GAAG,EAAE,IAAI,CAAC;IAClC,OAAOpB,aAAa,CAAC,CAACY,OAAA,CAAOU,KAAK,CAAC,EAAE,GAAGD,OAAO,CAACE,MAAM,CAAC,EAAEF,OAAO,CAAC,CAAC;EACp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C,KAAA,IAAAC,KAAA,GAAIhD,MAAM,IAAI,CAAC,GAAG,EAAE,GAAGrB,uBAAuB,GAAG,IAAI,cAAAqE,KAAA,cAAAA,KAAA,GACtDhD,MAAM,IAAI,CAAC,GAAG,EAAE,GAAGrB,uBAAuB,GAAG,IAAI,cAAAoE,KAAA,cAAAA,KAAA,GACjD/C,MAAM,IAAI,EAAE,GAAGrB,uBAAuB,GAAG,IAAI,cAAAmE,KAAA,cAAAA,KAAA,GAC9C,CAAC;EACN,OAAOG,CAAC,GAAGJ,WAAW;AACxB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASK,aAAaA,CAAC/C,IAAc,EAAW;EACrD,OAAOA,IAAI,CAACH,MAAM,GAAG,EAAE,GAAGe,WAAW,CAACf,MAAM;AAC9C"}
|
package/es/tx/builder/index.d.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { Encoded, Encoding } from '../../utils/encoder';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Field } from './field-types';
|
|
3
|
+
import { TxUnpacked, TxParams, TxParamsAsync } from './schema.generated';
|
|
4
4
|
import { Tag } from './constants';
|
|
5
|
+
/**
|
|
6
|
+
* JavaScript-based Transaction builder
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSchema(tag: Tag, version?: number): Array<[string, Field]>;
|
|
5
9
|
/**
|
|
6
10
|
* Build transaction hash
|
|
7
11
|
* @category transaction builder
|
|
8
12
|
* @param params - Object with tx params
|
|
9
13
|
* @param options - options
|
|
10
|
-
* @param options.denomination - Denomination of amounts
|
|
11
14
|
* @param options.prefix - Prefix of transaction
|
|
12
|
-
* @
|
|
13
|
-
* @returns object
|
|
14
|
-
* @returns object.tx Base64Check transaction hash with 'tx_' prefix
|
|
15
|
-
* @returns object.rlpEncoded rlp encoded transaction
|
|
16
|
-
* @returns object.binary binary transaction
|
|
15
|
+
* @returns object Base64Check transaction hash with 'tx_' prefix
|
|
17
16
|
*/
|
|
18
|
-
export declare function buildTx<
|
|
19
|
-
tag: TxType;
|
|
20
|
-
version?: number;
|
|
21
|
-
} & Omit<TxTypeSchemas[TxType], 'tag' | 'version'> & (TxType extends Tag.ContractCreateTx | Tag.ContractCallTx | Tag.ChannelOffChainUpdateCallContract | Tag.GaAttachTx | Tag.GaMetaTx ? {
|
|
22
|
-
gasMax?: number;
|
|
23
|
-
} : {}), { prefix, denomination, }?: {
|
|
17
|
+
export declare function buildTx<E extends Encoding = Encoding.Transaction>(params: TxParams, { prefix, }?: {
|
|
24
18
|
prefix?: E;
|
|
25
|
-
denomination?: AE_AMOUNT_FORMATS;
|
|
26
19
|
}): Encoded.Generic<E>;
|
|
20
|
+
export type BuildTxOptions<TxType extends Tag, OmitFields extends string> = Omit<TxParamsAsync & {
|
|
21
|
+
tag: TxType;
|
|
22
|
+
}, 'tag' | OmitFields>;
|
|
27
23
|
/**
|
|
28
|
-
*
|
|
24
|
+
* @category transaction builder
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildTxAsync(params: TxParamsAsync): Promise<Encoded.Transaction>;
|
|
27
|
+
/**
|
|
28
|
+
* Unpack transaction encoded as string
|
|
29
29
|
* @category transaction builder
|
|
30
30
|
* @param encodedTx - Transaction to unpack
|
|
31
31
|
* @param txType - Expected transaction type
|
|
32
|
-
* @returns
|
|
33
|
-
* @returns object.tx Object with transaction param's
|
|
34
|
-
* @returns object.txType Transaction type
|
|
32
|
+
* @returns Object with transaction param's
|
|
35
33
|
*/
|
|
36
|
-
export declare function unpackTx<TxType extends Tag>(encodedTx: Encoded.Transaction | Encoded.Poi, txType?: TxType):
|
|
34
|
+
export declare function unpackTx<TxType extends Tag>(encodedTx: Encoded.Transaction | Encoded.Poi | Encoded.StateTrees | Encoded.CallStateTree, txType?: TxType): TxUnpacked & {
|
|
35
|
+
tag: TxType;
|
|
36
|
+
};
|
|
37
37
|
/**
|
|
38
38
|
* Build a transaction hash
|
|
39
39
|
* @category transaction builder
|
package/es/tx/builder/index.mjs
CHANGED
|
@@ -4,38 +4,22 @@ const {
|
|
|
4
4
|
encode: rlpEncode
|
|
5
5
|
} = _rlp;
|
|
6
6
|
import { decode, encode, Encoding } from "../../utils/encoder.mjs";
|
|
7
|
-
import { AE_AMOUNT_FORMATS } from "../../utils/amount-formatter.mjs";
|
|
8
7
|
import { hash } from "../../utils/crypto.mjs";
|
|
9
|
-
import {
|
|
8
|
+
import { txSchema } from "./schema.mjs";
|
|
10
9
|
import { Tag } from "./constants.mjs";
|
|
11
10
|
import { buildContractId, readInt } from "./helpers.mjs";
|
|
12
11
|
import { ArgumentError, DecodeError, SchemaNotFoundError } from "../../utils/errors.mjs";
|
|
13
|
-
import { isKeyOfObject } from "../../utils/other.mjs";
|
|
14
12
|
/**
|
|
15
13
|
* JavaScript-based Transaction builder
|
|
16
14
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (binary.length !== schema.length) {
|
|
26
|
-
throw new ArgumentError('Transaction RLP length', schema.length, binary.length);
|
|
27
|
-
}
|
|
28
|
-
return schema.reduce((acc, _ref, index) => {
|
|
29
|
-
let [name, field] = _ref;
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
31
|
-
const deserialized = field.deserialize(binary[index], {
|
|
32
|
-
unpackTx
|
|
33
|
-
});
|
|
34
|
-
return {
|
|
35
|
-
...acc,
|
|
36
|
-
[name]: deserialized
|
|
37
|
-
};
|
|
38
|
-
}, {});
|
|
15
|
+
export function getSchema(tag, version) {
|
|
16
|
+
var _version;
|
|
17
|
+
const schemas = txSchema.filter(s => s.tag.constValue === tag);
|
|
18
|
+
if (schemas.length === 0) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, 0);
|
|
19
|
+
(_version = version) !== null && _version !== void 0 ? _version : version = Math.max(...schemas.map(schema => schema.version.constValue));
|
|
20
|
+
const schema = schemas.find(s => s.version.constValue === version);
|
|
21
|
+
if (schema == null) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, version);
|
|
22
|
+
return Object.entries(schema);
|
|
39
23
|
}
|
|
40
24
|
|
|
41
25
|
/**
|
|
@@ -43,65 +27,75 @@ function unpackRawTx(binary, schema) {
|
|
|
43
27
|
* @category transaction builder
|
|
44
28
|
* @param params - Object with tx params
|
|
45
29
|
* @param options - options
|
|
46
|
-
* @param options.denomination - Denomination of amounts
|
|
47
30
|
* @param options.prefix - Prefix of transaction
|
|
48
|
-
* @
|
|
49
|
-
* @returns object
|
|
50
|
-
* @returns object.tx Base64Check transaction hash with 'tx_' prefix
|
|
51
|
-
* @returns object.rlpEncoded rlp encoded transaction
|
|
52
|
-
* @returns object.binary binary transaction
|
|
31
|
+
* @returns object Base64Check transaction hash with 'tx_' prefix
|
|
53
32
|
*/
|
|
54
33
|
export function buildTx(params) {
|
|
55
|
-
var _params$version;
|
|
56
34
|
let {
|
|
57
|
-
prefix
|
|
58
|
-
denomination = AE_AMOUNT_FORMATS.AETTOS
|
|
35
|
+
prefix
|
|
59
36
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const binary = schema.map(_ref2 => {
|
|
67
|
-
let [key, field] = _ref2;
|
|
68
|
-
return field.serialize(params[key], {
|
|
37
|
+
const schema = getSchema(params.tag, params.version);
|
|
38
|
+
const binary = schema.map(_ref => {
|
|
39
|
+
let [key, field] = _ref;
|
|
40
|
+
return field.serialize(
|
|
41
|
+
// @ts-expect-error the type of `params[key]` can't be determined accurately
|
|
42
|
+
params[key], {
|
|
69
43
|
...params,
|
|
70
44
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
71
45
|
unpackTx,
|
|
72
46
|
buildTx,
|
|
73
|
-
denomination,
|
|
74
47
|
rebuildTx: overrideParams => buildTx({
|
|
75
48
|
...params,
|
|
76
49
|
...overrideParams
|
|
77
|
-
}, {
|
|
78
|
-
denomination
|
|
79
50
|
})
|
|
80
|
-
});
|
|
51
|
+
}, params);
|
|
81
52
|
});
|
|
82
53
|
|
|
83
54
|
// @ts-expect-error looks like a TypeScript edge case
|
|
84
55
|
return encode(rlpEncode(binary), prefix !== null && prefix !== void 0 ? prefix : Encoding.Transaction);
|
|
85
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* @category transaction builder
|
|
59
|
+
*/
|
|
60
|
+
export async function buildTxAsync(params) {
|
|
61
|
+
await Promise.all(getSchema(params.tag, params.version).map(async _ref2 => {
|
|
62
|
+
let [key, field] = _ref2;
|
|
63
|
+
if (field.prepare == null) return;
|
|
64
|
+
// @ts-expect-error the type of `params[key]` can't be determined accurately
|
|
65
|
+
params[key] = await field.prepare(params[key], params, params);
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
// @ts-expect-error after preparation properties should be compatible with sync tx builder
|
|
69
|
+
return buildTx(params);
|
|
70
|
+
}
|
|
86
71
|
|
|
87
72
|
/**
|
|
88
|
-
* Unpack transaction
|
|
73
|
+
* Unpack transaction encoded as string
|
|
89
74
|
* @category transaction builder
|
|
90
75
|
* @param encodedTx - Transaction to unpack
|
|
91
76
|
* @param txType - Expected transaction type
|
|
92
|
-
* @returns
|
|
93
|
-
* @returns object.tx Object with transaction param's
|
|
94
|
-
* @returns object.txType Transaction type
|
|
77
|
+
* @returns Object with transaction param's
|
|
95
78
|
*/
|
|
96
79
|
export function unpackTx(encodedTx, txType) {
|
|
97
80
|
const binary = rlpDecode(decode(encodedTx));
|
|
98
81
|
const tag = +readInt(binary[0]);
|
|
99
|
-
if (!isKeyOfObject(tag, TX_SCHEMA)) throw new DecodeError(`Unknown transaction tag: ${tag}`);
|
|
100
|
-
if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);
|
|
101
82
|
const version = +readInt(binary[1]);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
83
|
+
const schema = getSchema(tag, version);
|
|
84
|
+
if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);
|
|
85
|
+
if (binary.length !== schema.length) {
|
|
86
|
+
throw new ArgumentError('Transaction RLP length', schema.length, binary.length);
|
|
87
|
+
}
|
|
88
|
+
return schema.reduce((acc, _ref3, index) => {
|
|
89
|
+
let [name, field] = _ref3;
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
91
|
+
const deserialized = field.deserialize(binary[index], {
|
|
92
|
+
unpackTx
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
...acc,
|
|
96
|
+
[name]: deserialized
|
|
97
|
+
};
|
|
98
|
+
}, {});
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
/**
|
|
@@ -122,14 +116,10 @@ export function buildTxHash(rawTx) {
|
|
|
122
116
|
* @returns Contract public key
|
|
123
117
|
*/
|
|
124
118
|
export function buildContractIdByContractTx(contractTx) {
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
nonce
|
|
129
|
-
} = unpackTx(contractTx);
|
|
130
|
-
if (![Tag.ContractCreateTx, Tag.GaAttachTx].includes(tag)) {
|
|
131
|
-
throw new ArgumentError('contractCreateTx', 'a contractCreateTx or gaAttach', tag);
|
|
119
|
+
const params = unpackTx(contractTx);
|
|
120
|
+
if (Tag.ContractCreateTx !== params.tag && Tag.GaAttachTx !== params.tag) {
|
|
121
|
+
throw new ArgumentError('contractTx', 'a contractCreateTx or gaAttach', params.tag);
|
|
132
122
|
}
|
|
133
|
-
return buildContractId(ownerId,
|
|
123
|
+
return buildContractId(params.ownerId, params.nonce);
|
|
134
124
|
}
|
|
135
125
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["decode","encode","
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["_rlp","decode","rlpDecode","encode","rlpEncode","Encoding","hash","txSchema","Tag","buildContractId","readInt","ArgumentError","DecodeError","SchemaNotFoundError","getSchema","tag","version","_version","schemas","filter","s","constValue","length","Math","max","map","schema","find","Object","entries","buildTx","params","prefix","arguments","undefined","binary","_ref","key","field","serialize","unpackTx","rebuildTx","overrideParams","Transaction","buildTxAsync","Promise","all","_ref2","prepare","encodedTx","txType","reduce","acc","_ref3","index","name","deserialized","deserialize","buildTxHash","rawTx","data","startsWith","TxHash","buildContractIdByContractTx","contractTx","ContractCreateTx","GaAttachTx","ownerId","nonce"],"sources":["../../../src/tx/builder/index.ts"],"sourcesContent":["import { decode as rlpDecode, encode as rlpEncode } from 'rlp';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../utils/encoder';\nimport { hash } from '../../utils/crypto';\nimport { BinaryData, Field } from './field-types';\nimport { txSchema } from './schema';\nimport { TxUnpacked, TxParams, TxParamsAsync } from './schema.generated';\nimport { Tag } from './constants';\nimport { buildContractId, readInt } from './helpers';\nimport { ArgumentError, DecodeError, SchemaNotFoundError } from '../../utils/errors';\n\n/**\n * JavaScript-based Transaction builder\n */\n\nexport function getSchema(tag: Tag, version?: number): Array<[string, Field]> {\n const schemas = txSchema.filter((s) => s.tag.constValue === tag);\n if (schemas.length === 0) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, 0);\n version ??= Math.max(...schemas.map((schema) => schema.version.constValue));\n const schema = schemas.find((s) => s.version.constValue === version);\n if (schema == null) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, version);\n return Object.entries(schema);\n}\n\n/**\n * Build transaction hash\n * @category transaction builder\n * @param params - Object with tx params\n * @param options - options\n * @param options.prefix - Prefix of transaction\n * @returns object Base64Check transaction hash with 'tx_' prefix\n */\nexport function buildTx<\n E extends Encoding = Encoding.Transaction,\n>(\n params: TxParams,\n {\n prefix,\n }: {\n prefix?: E;\n } = {},\n): Encoded.Generic<E> {\n const schema = getSchema(params.tag, params.version);\n\n const binary = schema.map(([key, field]) => (\n field.serialize(\n // @ts-expect-error the type of `params[key]` can't be determined accurately\n params[key],\n {\n ...params,\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n unpackTx,\n buildTx,\n rebuildTx: (overrideParams: any) => buildTx(\n { ...params, ...overrideParams },\n ),\n },\n params,\n )\n ));\n\n // @ts-expect-error looks like a TypeScript edge case\n return encode(rlpEncode(binary), prefix ?? Encoding.Transaction);\n}\n\nexport type BuildTxOptions <TxType extends Tag, OmitFields extends string> =\n Omit<TxParamsAsync & { tag: TxType }, 'tag' | OmitFields>;\n\n/**\n * @category transaction builder\n */\nexport async function buildTxAsync(params: TxParamsAsync): Promise<Encoded.Transaction> {\n await Promise.all(\n getSchema(params.tag, params.version)\n .map(async ([key, field]) => {\n if (field.prepare == null) return;\n // @ts-expect-error the type of `params[key]` can't be determined accurately\n params[key] = await field.prepare(params[key], params, params);\n }),\n );\n\n // @ts-expect-error after preparation properties should be compatible with sync tx builder\n return buildTx(params);\n}\n\n/**\n * Unpack transaction encoded as string\n * @category transaction builder\n * @param encodedTx - Transaction to unpack\n * @param txType - Expected transaction type\n * @returns Object with transaction param's\n */\nexport function unpackTx<TxType extends Tag>(\n encodedTx: Encoded.Transaction | Encoded.Poi | Encoded.StateTrees | Encoded.CallStateTree,\n txType?: TxType,\n): TxUnpacked & { tag: TxType } {\n const binary = rlpDecode(decode(encodedTx));\n const tag = +readInt(binary[0] as Buffer);\n const version = +readInt(binary[1] as Buffer);\n const schema = getSchema(tag, version);\n if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);\n if (binary.length !== schema.length) {\n throw new ArgumentError('Transaction RLP length', schema.length, binary.length);\n }\n return schema.reduce<any>(\n (acc, [name, field], index) => {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const deserialized = field.deserialize(binary[index] as BinaryData, { unpackTx });\n return { ...acc, [name]: deserialized };\n },\n {},\n ) as any;\n}\n\n/**\n * Build a transaction hash\n * @category transaction builder\n * @param rawTx - base64 or rlp encoded transaction\n * @returns Transaction hash\n */\nexport function buildTxHash(rawTx: Encoded.Transaction | Uint8Array): Encoded.TxHash {\n const data = typeof rawTx === 'string' && rawTx.startsWith('tx_')\n ? decode(rawTx)\n : rawTx;\n return encode(hash(data), Encoding.TxHash);\n}\n\n/**\n * Build a contract public key by contractCreateTx or gaAttach\n * @category contract\n * @param contractTx - Transaction\n * @returns Contract public key\n */\nexport function buildContractIdByContractTx(\n contractTx: Encoded.Transaction,\n): Encoded.ContractAddress {\n const params = unpackTx(contractTx);\n if (Tag.ContractCreateTx !== params.tag && Tag.GaAttachTx !== params.tag) {\n throw new ArgumentError('contractTx', 'a contractCreateTx or gaAttach', params.tag);\n }\n return buildContractId(params.ownerId, params.nonce);\n}\n"],"mappings":"AAAA,OAAAA,IAAA,MAAyD,KAAK;AAAC;EAAAC,MAAA,EAAAC,SAAA;EAAAC,MAAA,EAAAC;AAAA,IAAAJ,IAAA;AAAA,SAE7DC,MAAM,EAAEE,MAAM,EAAWE,QAAQ;AAAA,SAE1BC,IAAI;AAAA,SAEJC,QAAQ;AAAA,SAERC,GAAG;AAAA,SACHC,eAAe,EAAEC,OAAO;AAAA,SACxBC,aAAa,EAAEC,WAAW,EAAEC,mBAAmB;AAExD;AACA;AACA;AAEA,OAAO,SAASC,SAASA,CAACC,GAAQ,EAAEC,OAAgB,EAA0B;EAAA,IAAAC,QAAA;EAC5E,MAAMC,OAAO,GAAGX,QAAQ,CAACY,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACL,GAAG,CAACM,UAAU,KAAKN,GAAG,CAAC;EAChE,IAAIG,OAAO,CAACI,MAAM,KAAK,CAAC,EAAE,MAAM,IAAIT,mBAAmB,CAAE,GAAEL,GAAG,CAACO,GAAG,CAAE,KAAIA,GAAI,GAAE,EAAE,CAAC,CAAC;EAClF,CAAAE,QAAA,GAAAD,OAAO,cAAAC,QAAA,cAAAA,QAAA,GAAPD,OAAO,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