@aeternity/aepp-sdk 13.0.0-alpha.0 → 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 +5595 -2249
- 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.d.ts +3 -3
- package/es/AeSdkBase.mjs +4 -0
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkMethods.d.ts +12 -14
- 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 +9 -4
- package/es/Node.mjs +12 -6
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +13 -8
- package/es/account/Base.mjs +0 -17
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.mjs +14 -25
- package/es/account/Generalized.mjs.map +1 -1
- package/es/account/Ledger.mjs +2 -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 +11 -22
- 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 +22 -32
- 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.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -20
- 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 +5 -6
- 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 +17 -9
- package/es/chain.mjs +23 -23
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +27 -9
- package/es/channel/Base.mjs +27 -27
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.d.ts +8 -7
- package/es/channel/Contract.mjs +8 -21
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +5 -1
- package/es/channel/Spend.mjs +4 -18
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +16 -26
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.d.ts +19 -2
- package/es/channel/internal.mjs +22 -20
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +43 -123
- package/es/contract/Contract.mjs +230 -250
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +74 -0
- package/es/contract/compiler/Base.mjs +5 -0
- package/es/contract/compiler/Base.mjs.map +1 -0
- package/es/contract/compiler/Cli.d.ts +23 -0
- package/es/contract/compiler/Cli.mjs +149 -0
- package/es/contract/compiler/Cli.mjs.map +1 -0
- package/es/contract/compiler/Http.d.ts +32 -0
- package/es/contract/compiler/Http.mjs +94 -0
- package/es/contract/compiler/Http.mjs.map +1 -0
- package/es/contract/compiler/HttpNode.d.ts +17 -0
- package/es/contract/compiler/HttpNode.mjs +26 -0
- package/es/contract/compiler/HttpNode.mjs.map +1 -0
- package/es/contract/compiler/getFileSystem.d.ts +6 -0
- package/es/contract/compiler/getFileSystem.mjs +40 -0
- package/es/contract/compiler/getFileSystem.mjs.map +1 -0
- 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 +27 -10
- package/es/contract/ga.mjs +63 -29
- package/es/contract/ga.mjs.map +1 -1
- package/es/index-browser.d.ts +40 -0
- package/es/index-browser.mjs +41 -0
- package/es/index-browser.mjs.map +1 -0
- package/es/index.d.ts +4 -38
- package/es/index.mjs +4 -53
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +12 -17
- package/es/oracle.mjs +29 -49
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +19 -27
- package/es/spend.mjs +21 -46
- 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 +31 -2
- package/es/tx/builder/constants.mjs +34 -3
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.d.ts +19 -0
- package/es/tx/builder/field-types/abi-version.mjs +40 -0
- package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
- package/es/tx/builder/field-types/address.d.ts +5 -6
- package/es/tx/builder/field-types/address.mjs +17 -8
- package/es/tx/builder/field-types/address.mjs.map +1 -1
- package/es/tx/builder/field-types/array.d.ts +7 -0
- package/es/tx/builder/field-types/array.mjs +11 -0
- package/es/tx/builder/field-types/array.mjs.map +1 -0
- package/es/tx/builder/field-types/boolean.d.ts +6 -0
- package/es/tx/builder/field-types/boolean.mjs +13 -0
- package/es/tx/builder/field-types/boolean.mjs.map +1 -0
- package/es/tx/builder/field-types/coin-amount.d.ts +4 -5
- 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 +49 -0
- package/es/tx/builder/field-types/ct-version.mjs +76 -0
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +3 -2
- 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 +6 -0
- package/es/tx/builder/field-types/encoded.mjs +21 -0
- package/es/tx/builder/field-types/encoded.mjs.map +1 -0
- package/es/tx/builder/field-types/entry.d.ts +11 -0
- package/es/tx/builder/field-types/entry.mjs +34 -0
- package/es/tx/builder/field-types/entry.mjs.map +1 -0
- package/es/tx/builder/field-types/enumeration.d.ts +5 -3
- package/es/tx/builder/field-types/enumeration.mjs +11 -2
- package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +12 -7
- package/es/tx/builder/field-types/fee.mjs +28 -20
- 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 +7 -3
- package/es/tx/builder/field-types/gas-limit.mjs +13 -8
- 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 +107 -30
- package/es/tx/builder/field-types/index.mjs +38 -12
- 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 +42 -0
- package/es/tx/builder/field-types/mptree.mjs +266 -0
- package/es/tx/builder/field-types/mptree.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +2 -3
- 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 +2 -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 +2 -2
- package/es/tx/builder/field-types/pointers.mjs.map +1 -1
- package/es/tx/builder/field-types/raw.d.ts +6 -0
- package/es/tx/builder/field-types/raw.mjs +13 -0
- package/es/tx/builder/field-types/raw.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int-const.d.ts +7 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs +20 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
- package/es/tx/builder/field-types/string.d.ts +6 -0
- package/es/tx/builder/field-types/string.mjs +10 -0
- package/es/tx/builder/field-types/string.mjs.map +1 -0
- 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.d.ts +1 -2
- 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 +18 -36
- package/es/tx/builder/index.mjs +65 -236
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2734 -1324
- 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 -223
- 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.d.ts +3 -5
- package/es/tx/validator.mjs +91 -153
- 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 +1 -17
- 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 +16 -38
- package/es/utils/errors.mjs +3 -43
- 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.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 +52 -40
- package/src/AeSdkBase.ts +6 -3
- package/src/AeSdkMethods.ts +12 -18
- package/src/AeSdkWallet.ts +1 -1
- package/src/Node.ts +23 -9
- package/src/account/Base.ts +13 -24
- package/src/account/Generalized.ts +9 -24
- package/src/account/Ledger.ts +1 -1
- package/src/account/Memory.ts +15 -22
- package/src/aens.ts +34 -49
- package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -24
- 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/RpcClient.ts +2 -2
- 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 +33 -30
- package/src/channel/Base.ts +39 -31
- package/src/channel/Contract.ts +18 -32
- package/src/channel/Spend.ts +8 -18
- package/src/channel/handlers.ts +14 -26
- package/src/channel/internal.ts +41 -23
- package/src/contract/Contract.ts +188 -228
- package/src/contract/compiler/Base.ts +87 -0
- package/src/contract/compiler/Cli.ts +128 -0
- package/src/contract/compiler/Http.ts +105 -0
- package/src/contract/compiler/HttpNode.ts +26 -0
- package/src/contract/compiler/getFileSystem.ts +42 -0
- package/src/contract/delegation-signature.ts +56 -0
- package/src/contract/ga.ts +61 -37
- package/src/index-browser.ts +50 -0
- package/src/index.ts +4 -56
- package/src/oracle.ts +47 -57
- package/src/spend.ts +34 -68
- package/src/tx/builder/SchemaTypes.ts +79 -0
- package/src/tx/builder/constants.ts +34 -3
- package/src/tx/builder/field-types/abi-version.ts +44 -0
- package/src/tx/builder/field-types/address.ts +23 -13
- package/src/tx/builder/field-types/array.ts +19 -0
- package/src/tx/builder/field-types/boolean.ts +9 -0
- package/src/tx/builder/field-types/coin-amount.ts +8 -5
- package/src/tx/builder/field-types/ct-version.ts +83 -0
- package/src/tx/builder/field-types/deposit.ts +4 -2
- package/src/tx/builder/field-types/encoded.ts +27 -0
- package/src/tx/builder/field-types/entry.ts +36 -0
- package/src/tx/builder/field-types/enumeration.ts +15 -4
- package/src/tx/builder/field-types/fee.ts +41 -19
- package/src/tx/builder/field-types/gas-limit.ts +13 -8
- package/src/tx/builder/field-types/index.ts +60 -17
- package/src/tx/builder/field-types/map.ts +45 -0
- package/src/tx/builder/field-types/mptree.ts +243 -0
- package/src/tx/builder/field-types/name-fee.ts +3 -3
- package/src/tx/builder/field-types/name-id.ts +1 -1
- package/src/tx/builder/field-types/nonce.ts +40 -0
- package/src/tx/builder/field-types/pointers.ts +2 -2
- package/src/tx/builder/field-types/raw.ts +9 -0
- package/src/tx/builder/field-types/short-u-int-const.ts +30 -0
- package/src/tx/builder/field-types/string.ts +11 -0
- package/src/tx/builder/field-types/ttl.ts +24 -0
- package/src/tx/builder/field-types/u-int.ts +1 -3
- package/src/tx/builder/field-types/wrapped.ts +32 -0
- package/src/tx/builder/index.ts +82 -280
- package/src/tx/builder/schema.generated.ts +2013 -0
- package/src/tx/builder/schema.ts +536 -666
- package/src/tx/execution-cost.ts +146 -0
- package/src/tx/transaction-signer.ts +27 -0
- package/src/tx/validator.ts +100 -154
- package/src/utils/amount-formatter.ts +0 -16
- package/src/utils/autorest.ts +52 -11
- package/src/utils/bytes.ts +1 -17
- package/src/utils/crypto.ts +0 -16
- package/src/utils/errors.ts +18 -56
- package/src/utils/string.ts +0 -17
- package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +12 -14
- package/types-legacy/ts4.2/Node.d.ts +8 -4
- package/types-legacy/ts4.2/account/Base.d.ts +13 -8
- 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/connection/BrowserRuntime.d.ts +1 -0
- 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 +17 -9
- package/types-legacy/ts4.2/channel/Base.d.ts +27 -9
- package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.2/channel/Spend.d.ts +5 -1
- package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.2/contract/Contract.d.ts +42 -122
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +74 -0
- package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.2/contract/ga.d.ts +27 -10
- package/types-legacy/ts4.2/index-browser.d.ts +40 -0
- package/types-legacy/ts4.2/index.d.ts +4 -38
- 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 +31 -2
- package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +19 -0
- package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +11 -12
- package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +4 -5
- package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +72 -0
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +3 -2
- package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -3
- package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +12 -7
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +7 -3
- 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 +113 -30
- 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 +48 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +2 -3
- package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +7 -0
- package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.2/tx/builder/index.d.ts +21 -36
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2971 -2926
- 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/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.2/utils/errors.d.ts +16 -38
- package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +12 -14
- package/types-legacy/ts4.5/Node.d.ts +8 -4
- package/types-legacy/ts4.5/account/Base.d.ts +13 -8
- 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/connection/BrowserRuntime.d.ts +1 -0
- 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 +17 -9
- package/types-legacy/ts4.5/channel/Base.d.ts +27 -9
- package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.5/channel/Spend.d.ts +5 -1
- package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
- package/types-legacy/ts4.5/contract/Contract.d.ts +42 -122
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +74 -0
- package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
- package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
- package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
- package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
- package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
- package/types-legacy/ts4.5/contract/ga.d.ts +27 -10
- package/types-legacy/ts4.5/index-browser.d.ts +40 -0
- package/types-legacy/ts4.5/index.d.ts +4 -38
- 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 +31 -2
- package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +19 -0
- package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +11 -12
- package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +4 -5
- package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +72 -0
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +3 -2
- package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -3
- package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +12 -7
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +7 -3
- 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 +113 -30
- 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 +48 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +2 -3
- package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +7 -0
- package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
- package/types-legacy/ts4.5/tx/builder/index.d.ts +21 -36
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2971 -2926
- 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/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
- package/types-legacy/ts4.5/utils/errors.d.ts +16 -38
- package/es/contract/CompilerHttp.d.ts +0 -18
- package/es/contract/CompilerHttp.mjs +0 -63
- package/es/contract/CompilerHttp.mjs.map +0 -1
- package/es/tx/builder/field-types/addresses.d.ts +0 -6
- package/es/tx/builder/field-types/addresses.mjs +0 -13
- package/es/tx/builder/field-types/addresses.mjs.map +0 -1
- package/es/tx/index.d.ts +0 -34
- package/es/tx/index.mjs +0 -172
- package/es/tx/index.mjs.map +0 -1
- package/es/utils/mptree.d.ts +0 -26
- package/es/utils/mptree.mjs +0 -143
- package/es/utils/mptree.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/contract/CompilerHttp.ts +0 -67
- package/src/tx/builder/field-types/addresses.ts +0 -18
- package/src/tx/index.ts +0 -196
- package/src/utils/mptree.ts +0 -145
- package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +0 -18
- package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +0 -6
- package/types-legacy/ts4.2/tx/index.d.ts +0 -34
- package/types-legacy/ts4.2/utils/mptree.d.ts +0 -32
- package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +0 -18
- package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +0 -6
- package/types-legacy/ts4.5/tx/index.d.ts +0 -34
- package/types-legacy/ts4.5/utils/mptree.d.ts +0 -32
package/es/spend.mjs
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ISC License (ISC)
|
|
3
|
-
* Copyright (c) 2022 aeternity developers
|
|
4
|
-
*
|
|
5
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
* copyright notice and this permission notice appear in all copies.
|
|
8
|
-
*
|
|
9
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
*/
|
|
17
1
|
import BigNumber from 'bignumber.js';
|
|
18
2
|
import { sendTransaction, getBalance, resolveName } from "./chain.mjs";
|
|
19
|
-
import {
|
|
20
|
-
import { buildTxHash, unpackTx } from "./tx/builder/index.mjs";
|
|
3
|
+
import { buildTxAsync, unpackTx } from "./tx/builder/index.mjs";
|
|
21
4
|
import { ArgumentError } from "./utils/errors.mjs";
|
|
22
5
|
import { Tag } from "./tx/builder/constants.mjs";
|
|
23
|
-
/**
|
|
24
|
-
* Sign and post a transaction to the chain
|
|
25
|
-
* @category chain
|
|
26
|
-
* @param tx - Transaction
|
|
27
|
-
* @param options - Options
|
|
28
|
-
* @param options.verify - Verify transaction before broadcast, throw error if not
|
|
29
|
-
* valid
|
|
30
|
-
* @returns Transaction
|
|
31
|
-
*/
|
|
32
|
-
export async function send(tx, options) {
|
|
33
|
-
const signed = await options.onAccount.signTransaction(tx, {
|
|
34
|
-
...options,
|
|
35
|
-
networkId: await options.onNode.getNetworkId()
|
|
36
|
-
});
|
|
37
|
-
return options.innerTx === true ? {
|
|
38
|
-
hash: buildTxHash(signed),
|
|
39
|
-
rawTx: signed
|
|
40
|
-
} : sendTransaction(signed, options);
|
|
41
|
-
}
|
|
42
6
|
/**
|
|
43
7
|
* Send coins to another account
|
|
44
8
|
* @category chain
|
|
@@ -48,8 +12,9 @@ export async function send(tx, options) {
|
|
|
48
12
|
* @returns Transaction
|
|
49
13
|
*/
|
|
50
14
|
export async function spend(amount, recipientIdOrName, options) {
|
|
51
|
-
return
|
|
15
|
+
return sendTransaction(await buildTxAsync({
|
|
52
16
|
...options,
|
|
17
|
+
tag: Tag.SpendTx,
|
|
53
18
|
senderId: options.onAccount.address,
|
|
54
19
|
recipientId: await resolveName(recipientIdOrName, 'account_pubkey', options),
|
|
55
20
|
amount
|
|
@@ -57,12 +22,21 @@ export async function spend(amount, recipientIdOrName, options) {
|
|
|
57
22
|
}
|
|
58
23
|
// TODO: Rename to spendFraction
|
|
59
24
|
/**
|
|
60
|
-
*
|
|
25
|
+
* Spend a fraction of coin balance to another account. Useful if needed to drain account balance
|
|
26
|
+
* completely, sending funds to another account (with fraction set to 1).
|
|
61
27
|
* @category chain
|
|
62
28
|
* @param fraction - Fraction of balance to spend (between 0 and 1)
|
|
63
29
|
* @param recipientIdOrName - Address or name of recipient account
|
|
64
30
|
* @param options - Options
|
|
65
|
-
* @
|
|
31
|
+
* @example
|
|
32
|
+
* ```js
|
|
33
|
+
* // `fraction` * 100 = % of AE to be transferred (e.g. `0.42` for 42% or `1` for 100%)
|
|
34
|
+
* const { blockHeight } = await aeSdk.transferFunds(
|
|
35
|
+
* 0.42,
|
|
36
|
+
* 'ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E',
|
|
37
|
+
* );
|
|
38
|
+
* console.log('Transaction mined at', blockHeight);
|
|
39
|
+
* ```
|
|
66
40
|
*/
|
|
67
41
|
export async function transferFunds(fraction, recipientIdOrName, options) {
|
|
68
42
|
if (fraction < 0 || fraction > 1) {
|
|
@@ -73,19 +47,19 @@ export async function transferFunds(fraction, recipientIdOrName, options) {
|
|
|
73
47
|
const balance = new BigNumber(await getBalance.bind(options.onAccount)(senderId, options));
|
|
74
48
|
const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);
|
|
75
49
|
const {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
} = unpackTx(await _buildTx(Tag.SpendTx, {
|
|
50
|
+
fee
|
|
51
|
+
} = unpackTx(await buildTxAsync({
|
|
80
52
|
...options,
|
|
53
|
+
tag: Tag.SpendTx,
|
|
81
54
|
senderId,
|
|
82
55
|
recipientId,
|
|
83
56
|
amount: desiredAmount
|
|
84
57
|
}), Tag.SpendTx);
|
|
85
58
|
// Reducing of the amount may reduce transaction fee, so this is not completely accurate
|
|
86
59
|
const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;
|
|
87
|
-
return
|
|
60
|
+
return sendTransaction(await buildTxAsync({
|
|
88
61
|
...options,
|
|
62
|
+
tag: Tag.SpendTx,
|
|
89
63
|
senderId,
|
|
90
64
|
recipientId,
|
|
91
65
|
amount
|
|
@@ -99,8 +73,9 @@ export async function transferFunds(fraction, recipientIdOrName, options) {
|
|
|
99
73
|
* @returns Object Transaction
|
|
100
74
|
*/
|
|
101
75
|
export async function payForTransaction(transaction, options) {
|
|
102
|
-
return
|
|
76
|
+
return sendTransaction(await buildTxAsync({
|
|
103
77
|
...options,
|
|
78
|
+
tag: Tag.PayingForTx,
|
|
104
79
|
payerId: options.onAccount.address,
|
|
105
80
|
tx: transaction
|
|
106
81
|
}), options);
|
package/es/spend.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spend.mjs","names":["BigNumber","sendTransaction","getBalance","resolveName","
|
|
1
|
+
{"version":3,"file":"spend.mjs","names":["BigNumber","sendTransaction","getBalance","resolveName","buildTxAsync","unpackTx","ArgumentError","Tag","spend","amount","recipientIdOrName","options","tag","SpendTx","senderId","onAccount","address","recipientId","transferFunds","fraction","balance","bind","desiredAmount","times","integerValue","ROUND_HALF_UP","fee","plus","gt","minus","payForTransaction","transaction","PayingForTx","payerId","tx"],"sources":["../src/spend.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport {\n sendTransaction, getBalance, resolveName, SendTransactionOptions,\n} from './chain';\nimport { buildTxAsync, BuildTxOptions, unpackTx } from './tx/builder';\nimport { ArgumentError } from './utils/errors';\nimport { Encoded, Encoding } from './utils/encoder';\nimport { Tag, AensName } from './tx/builder/constants';\nimport AccountBase from './account/Base';\n\n/**\n * Send coins to another account\n * @category chain\n * @param amount - Amount to spend\n * @param recipientIdOrName - Address or name of recipient account\n * @param options - Options\n * @returns Transaction\n */\nexport async function spend(\n amount: number | string,\n recipientIdOrName: Encoded.AccountAddress | AensName,\n options: SpendOptions,\n): ReturnType<typeof sendTransaction> {\n return sendTransaction(\n await buildTxAsync({\n ...options,\n tag: Tag.SpendTx,\n senderId: options.onAccount.address,\n recipientId: await resolveName<Encoding.AccountAddress>(\n recipientIdOrName,\n 'account_pubkey',\n options,\n ),\n amount,\n }),\n options,\n );\n}\n\ntype SpendOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>\n& Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendTransactionOptions;\ninterface SpendOptions extends SpendOptionsType {}\n\n// TODO: Rename to spendFraction\n/**\n * Spend a fraction of coin balance to another account. Useful if needed to drain account balance\n * completely, sending funds to another account (with fraction set to 1).\n * @category chain\n * @param fraction - Fraction of balance to spend (between 0 and 1)\n * @param recipientIdOrName - Address or name of recipient account\n * @param options - Options\n * @example\n * ```js\n * // `fraction` * 100 = % of AE to be transferred (e.g. `0.42` for 42% or `1` for 100%)\n * const { blockHeight } = await aeSdk.transferFunds(\n * 0.42,\n * 'ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E',\n * );\n * console.log('Transaction mined at', blockHeight);\n * ```\n */\nexport async function transferFunds(\n fraction: number | string,\n recipientIdOrName: AensName | Encoded.AccountAddress,\n options: TransferFundsOptions,\n): ReturnType<typeof sendTransaction> {\n if (fraction < 0 || fraction > 1) {\n throw new ArgumentError('fraction', 'a number between 0 and 1', fraction);\n }\n const recipientId = await resolveName<Encoding.AccountAddress>(\n recipientIdOrName,\n 'account_pubkey',\n options,\n );\n const senderId = options.onAccount.address;\n const balance = new BigNumber(\n await getBalance.bind(options.onAccount)(senderId, options),\n );\n const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);\n const { fee } = unpackTx(\n await buildTxAsync({\n ...options, tag: Tag.SpendTx, senderId, recipientId, amount: desiredAmount,\n }),\n Tag.SpendTx,\n );\n // Reducing of the amount may reduce transaction fee, so this is not completely accurate\n const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;\n return sendTransaction(\n await buildTxAsync({\n ...options, tag: Tag.SpendTx, senderId, recipientId, amount,\n }),\n options,\n );\n}\n\ntype TransferFundsOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>\n& Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendTransactionOptions;\ninterface TransferFundsOptions extends TransferFundsOptionsType {}\n\n/**\n * Submit transaction of another account paying for it (fee and gas)\n * @category chain\n * @param transaction - tx_<base64>-encoded transaction\n * @param options - Options\n * @returns Object Transaction\n */\nexport async function payForTransaction(\n transaction: Encoded.Transaction,\n options: PayForTransactionOptions,\n): ReturnType<typeof sendTransaction> {\n return sendTransaction(\n await buildTxAsync({\n ...options, tag: Tag.PayingForTx, payerId: options.onAccount.address, tx: transaction,\n }),\n options,\n );\n}\n\ninterface PayForTransactionOptions extends\n BuildTxOptions<Tag.PayingForTx, 'payerId' | 'tx' | 'onNode'>, SendTransactionOptions {\n onAccount: AccountBase;\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAEnCC,eAAe,EAAEC,UAAU,EAAEC,WAAW;AAAA,SAEjCC,YAAY,EAAkBC,QAAQ;AAAA,SACtCC,aAAa;AAAA,SAEbC,GAAG;AAGZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,KAAKA,CACzBC,MAAuB,EACvBC,iBAAoD,EACpDC,OAAqB,EACe;EACpC,OAAOV,eAAe,CACpB,MAAMG,YAAY,CAAC;IACjB,GAAGO,OAAO;IACVC,GAAG,EAAEL,GAAG,CAACM,OAAO;IAChBC,QAAQ,EAAEH,OAAO,CAACI,SAAS,CAACC,OAAO;IACnCC,WAAW,EAAE,MAAMd,WAAW,CAC5BO,iBAAiB,EACjB,gBAAgB,EAChBC,OAAO,CACR;IACDF;EACF,CAAC,CAAC,EACFE,OAAO,CACR;AACH;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeO,aAAaA,CACjCC,QAAyB,EACzBT,iBAAoD,EACpDC,OAA6B,EACO;EACpC,IAAIQ,QAAQ,GAAG,CAAC,IAAIA,QAAQ,GAAG,CAAC,EAAE;IAChC,MAAM,IAAIb,aAAa,CAAC,UAAU,EAAE,0BAA0B,EAAEa,QAAQ,CAAC;EAC3E;EACA,MAAMF,WAAW,GAAG,MAAMd,WAAW,CACnCO,iBAAiB,EACjB,gBAAgB,EAChBC,OAAO,CACR;EACD,MAAMG,QAAQ,GAAGH,OAAO,CAACI,SAAS,CAACC,OAAO;EAC1C,MAAMI,OAAO,GAAG,IAAIpB,SAAS,CAC3B,MAAME,UAAU,CAACmB,IAAI,CAACV,OAAO,CAACI,SAAS,CAAC,CAACD,QAAQ,EAAEH,OAAO,CAAC,CAC5D;EACD,MAAMW,aAAa,GAAGF,OAAO,CAACG,KAAK,CAACJ,QAAQ,CAAC,CAACK,YAAY,CAACxB,SAAS,CAACyB,aAAa,CAAC;EACnF,MAAM;IAAEC;EAAI,CAAC,GAAGrB,QAAQ,CACtB,MAAMD,YAAY,CAAC;IACjB,GAAGO,OAAO;IAAEC,GAAG,EAAEL,GAAG,CAACM,OAAO;IAAEC,QAAQ;IAAEG,WAAW;IAAER,MAAM,EAAEa;EAC/D,CAAC,CAAC,EACFf,GAAG,CAACM,OAAO,CACZ;EACD;EACA,MAAMJ,MAAM,GAAGa,aAAa,CAACK,IAAI,CAACD,GAAG,CAAC,CAACE,EAAE,CAACR,OAAO,CAAC,GAAGA,OAAO,CAACS,KAAK,CAACH,GAAG,CAAC,GAAGJ,aAAa;EACvF,OAAOrB,eAAe,CACpB,MAAMG,YAAY,CAAC;IACjB,GAAGO,OAAO;IAAEC,GAAG,EAAEL,GAAG,CAACM,OAAO;IAAEC,QAAQ;IAAEG,WAAW;IAAER;EACvD,CAAC,CAAC,EACFE,OAAO,CACR;AACH;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAemB,iBAAiBA,CACrCC,WAAgC,EAChCpB,OAAiC,EACG;EACpC,OAAOV,eAAe,CACpB,MAAMG,YAAY,CAAC;IACjB,GAAGO,OAAO;IAAEC,GAAG,EAAEL,GAAG,CAACyB,WAAW;IAAEC,OAAO,EAAEtB,OAAO,CAACI,SAAS,CAACC,OAAO;IAAEkB,EAAE,EAAEH;EAC5E,CAAC,CAAC,EACFpB,OAAO,CACR;AACH"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Field as OriginalField } from './field-types';
|
|
2
|
+
import { UnionToIntersection } from '../../utils/other';
|
|
3
|
+
export interface Field extends OriginalField {
|
|
4
|
+
serialize: (...args: any[]) => any;
|
|
5
|
+
}
|
|
6
|
+
type NullablePartial<T, NK extends keyof T = {
|
|
7
|
+
[K in keyof T]: undefined extends T[K] ? K : never;
|
|
8
|
+
}[keyof T]> = Partial<Pick<T, NK>> & Omit<T, NK>;
|
|
9
|
+
type Or<A, B> = A extends undefined ? B : A;
|
|
10
|
+
type TxParamsBySchemaInternal<SchemaItem> = {
|
|
11
|
+
-readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field ? Parameters<SchemaItem[key]['serialize']>[0] : never;
|
|
12
|
+
};
|
|
13
|
+
type TxParamsBySchemaInternalParams<SchemaItem, SchemaItemValues = SchemaItem[keyof SchemaItem]> = UnionToIntersection<SchemaItemValues extends Field ? Or<Parameters<SchemaItemValues['serialize']>[2], {}> : never>;
|
|
14
|
+
type PickIsRec<SchemaItem, Recursive extends boolean> = {
|
|
15
|
+
[Key in keyof SchemaItem as SchemaItem[Key] extends Field & {
|
|
16
|
+
recursiveType: true;
|
|
17
|
+
} ? (Recursive extends true ? Key : never) : (Recursive extends true ? never : Key)]: SchemaItem[Key];
|
|
18
|
+
};
|
|
19
|
+
type TxParamsBySchema<SchemaItem> = SchemaItem extends Object ? TxParamsBySchemaInternal<PickIsRec<SchemaItem, true>> & NullablePartial<TxParamsBySchemaInternal<PickIsRec<SchemaItem, false>>> & TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>> : never;
|
|
20
|
+
type TxParamsAsyncBySchemaInternal<SchemaItem> = {
|
|
21
|
+
-readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field & {
|
|
22
|
+
prepare: Function;
|
|
23
|
+
} ? Parameters<SchemaItem[key]['prepare']>[0] : SchemaItem[key] extends Field ? Parameters<SchemaItem[key]['serialize']>[0] : never;
|
|
24
|
+
};
|
|
25
|
+
type TxParamsAsyncBySchemaInternalParams<SchemaItem, SchemaItemValues = SchemaItem[keyof SchemaItem]> = UnionToIntersection<SchemaItemValues extends Field & {
|
|
26
|
+
prepare: Function;
|
|
27
|
+
} ? Or<Parameters<SchemaItemValues['prepare']>[2], {}> : {}>;
|
|
28
|
+
type TxParamsAsyncBySchema<SchemaItem> = SchemaItem extends Object ? TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, true>> & NullablePartial<TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, false>>> & TxParamsAsyncBySchemaInternalParams<PickIsRec<SchemaItem, false>> & TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>> : never;
|
|
29
|
+
type TxUnpackedBySchema<SchemaItem> = {
|
|
30
|
+
-readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field ? ReturnType<SchemaItem[key]['deserialize']> : never;
|
|
31
|
+
};
|
|
32
|
+
export default interface SchemaTypes<Schema extends readonly any[], SchemaItems = Schema[number]> {
|
|
33
|
+
TxParams: TxParamsBySchema<SchemaItems>;
|
|
34
|
+
TxParamsAsync: TxParamsAsyncBySchema<SchemaItems>;
|
|
35
|
+
TxUnpacked: TxUnpackedBySchema<SchemaItems>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaTypes.mjs","names":[],"sources":["../../../src/tx/builder/SchemaTypes.ts"],"sourcesContent":["import { Field as OriginalField } from './field-types';\nimport { UnionToIntersection } from '../../utils/other';\n\n// TODO: figure out why this override is necessary\nexport interface Field extends OriginalField {\n serialize: (...args: any[]) => any;\n}\n\ntype NullablePartial<\n T,\n NK extends keyof T = { [K in keyof T]: undefined extends T[K] ? K : never }[keyof T],\n> = Partial<Pick<T, NK>> & Omit<T, NK>;\n\ntype Or<A, B> = A extends undefined ? B : A;\n\ntype TxParamsBySchemaInternal<SchemaItem> = {\n -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field\n ? Parameters<SchemaItem[key]['serialize']>[0]\n : never;\n};\n\ntype TxParamsBySchemaInternalParams<\n SchemaItem,\n SchemaItemValues = SchemaItem[keyof SchemaItem],\n> = UnionToIntersection<\nSchemaItemValues extends Field\n ? Or<Parameters<SchemaItemValues['serialize']>[2], {}> : never\n>;\n\ntype PickIsRec<SchemaItem, Recursive extends boolean> = {\n [Key in keyof SchemaItem\n as SchemaItem[Key] extends Field & { recursiveType: true }\n ? (Recursive extends true ? Key : never)\n : (Recursive extends true ? never : Key)]: SchemaItem[Key];\n};\n\ntype TxParamsBySchema<SchemaItem> = SchemaItem extends Object\n ? TxParamsBySchemaInternal<PickIsRec<SchemaItem, true>> &\n NullablePartial<TxParamsBySchemaInternal<PickIsRec<SchemaItem, false>>> &\n TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>>\n : never;\n\ntype TxParamsAsyncBySchemaInternal<SchemaItem> = {\n -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field & { prepare: Function }\n ? Parameters<SchemaItem[key]['prepare']>[0]\n : SchemaItem[key] extends Field\n ? Parameters<SchemaItem[key]['serialize']>[0]\n : never;\n};\n\ntype TxParamsAsyncBySchemaInternalParams<\n SchemaItem,\n SchemaItemValues = SchemaItem[keyof SchemaItem],\n> = UnionToIntersection<\nSchemaItemValues extends Field & { prepare: Function }\n ? Or<Parameters<SchemaItemValues['prepare']>[2], {}> : {}\n>;\n\ntype TxParamsAsyncBySchema<SchemaItem> = SchemaItem extends Object\n ? TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, true>>\n & NullablePartial<TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, false>>>\n & TxParamsAsyncBySchemaInternalParams<PickIsRec<SchemaItem, false>>\n & TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>>\n : never;\n\ntype TxUnpackedBySchema<SchemaItem> = {\n -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field\n ? ReturnType<SchemaItem[key]['deserialize']>\n : never;\n};\n\nexport default interface SchemaTypes<\n Schema extends readonly any[],\n SchemaItems = Schema[number],\n> {\n TxParams: TxParamsBySchema<SchemaItems>;\n TxParamsAsync: TxParamsAsyncBySchema<SchemaItems>;\n TxUnpacked: TxUnpackedBySchema<SchemaItems>;\n}\n"],"mappings":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
export declare const MAX_AUTH_FUN_GAS = 50000;
|
|
3
|
+
export type Int = number | string | BigNumber;
|
|
3
4
|
export type AensName = `${string}.chain`;
|
|
4
5
|
export declare const NAME_TTL = 180000;
|
|
5
6
|
export declare const NAME_MAX_TTL = 36000;
|
|
@@ -14,6 +15,32 @@ export declare const NAME_BID_MAX_LENGTH = 12;
|
|
|
14
15
|
export declare const NAME_BID_RANGES: {
|
|
15
16
|
[k: string]: BigNumber;
|
|
16
17
|
};
|
|
18
|
+
export declare enum ConsensusProtocolVersion {
|
|
19
|
+
Iris = 5,
|
|
20
|
+
Ceres = 6
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @category transaction builder
|
|
24
|
+
* @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
|
|
25
|
+
*/
|
|
26
|
+
export declare enum VmVersion {
|
|
27
|
+
NoVm = 0,
|
|
28
|
+
Sophia = 1,
|
|
29
|
+
SophiaImprovementsMinerva = 3,
|
|
30
|
+
SophiaImprovementsFortuna = 4,
|
|
31
|
+
Fate = 5,
|
|
32
|
+
SophiaImprovementsLima = 6,
|
|
33
|
+
Fate2 = 7
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @category transaction builder
|
|
37
|
+
* @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
|
|
38
|
+
*/
|
|
39
|
+
export declare enum AbiVersion {
|
|
40
|
+
NoAbi = 0,
|
|
41
|
+
Sophia = 1,
|
|
42
|
+
Fate = 3
|
|
43
|
+
}
|
|
17
44
|
/**
|
|
18
45
|
* Enum with tag types
|
|
19
46
|
* @category transaction builder
|
|
@@ -24,10 +51,12 @@ export declare enum Tag {
|
|
|
24
51
|
Account = 10,
|
|
25
52
|
SignedTx = 11,
|
|
26
53
|
SpendTx = 12,
|
|
54
|
+
Oracle = 20,
|
|
27
55
|
OracleRegisterTx = 22,
|
|
28
56
|
OracleQueryTx = 23,
|
|
29
57
|
OracleResponseTx = 24,
|
|
30
58
|
OracleExtendTx = 25,
|
|
59
|
+
Name = 30,
|
|
31
60
|
NameClaimTx = 32,
|
|
32
61
|
NamePreclaimTx = 33,
|
|
33
62
|
NameUpdateTx = 34,
|
|
@@ -64,8 +93,8 @@ export declare enum Tag {
|
|
|
64
93
|
NameserviceMtree = 624,
|
|
65
94
|
OraclesMtree = 625,
|
|
66
95
|
AccountsMtree = 626,
|
|
67
|
-
CompilerSophia = 70,
|
|
68
96
|
GaAttachTx = 80,
|
|
69
97
|
GaMetaTx = 81,
|
|
70
|
-
PayingForTx = 82
|
|
98
|
+
PayingForTx = 82,
|
|
99
|
+
GaMetaTxAuthData = 810
|
|
71
100
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { mapObject } from "../../utils/other.mjs";
|
|
3
3
|
export const MAX_AUTH_FUN_GAS = 50000;
|
|
4
|
-
// # AENS
|
|
5
|
-
|
|
6
4
|
export const NAME_TTL = 180000;
|
|
7
5
|
// # max number of block into the future that the name is going to be available
|
|
8
6
|
// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update
|
|
@@ -58,6 +56,32 @@ export const NAME_BID_RANGES = mapObject({
|
|
|
58
56
|
let [key, value] = _ref;
|
|
59
57
|
return [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)];
|
|
60
58
|
});
|
|
59
|
+
export let ConsensusProtocolVersion;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @category transaction builder
|
|
63
|
+
* @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
|
|
64
|
+
*/
|
|
65
|
+
(function (ConsensusProtocolVersion) {
|
|
66
|
+
ConsensusProtocolVersion[ConsensusProtocolVersion["Iris"] = 5] = "Iris";
|
|
67
|
+
ConsensusProtocolVersion[ConsensusProtocolVersion["Ceres"] = 6] = "Ceres";
|
|
68
|
+
})(ConsensusProtocolVersion || (ConsensusProtocolVersion = {}));
|
|
69
|
+
export let VmVersion;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @category transaction builder
|
|
73
|
+
* @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
|
|
74
|
+
*/
|
|
75
|
+
(function (VmVersion) {
|
|
76
|
+
VmVersion[VmVersion["NoVm"] = 0] = "NoVm";
|
|
77
|
+
VmVersion[VmVersion["Sophia"] = 1] = "Sophia";
|
|
78
|
+
VmVersion[VmVersion["SophiaImprovementsMinerva"] = 3] = "SophiaImprovementsMinerva";
|
|
79
|
+
VmVersion[VmVersion["SophiaImprovementsFortuna"] = 4] = "SophiaImprovementsFortuna";
|
|
80
|
+
VmVersion[VmVersion["Fate"] = 5] = "Fate";
|
|
81
|
+
VmVersion[VmVersion["SophiaImprovementsLima"] = 6] = "SophiaImprovementsLima";
|
|
82
|
+
VmVersion[VmVersion["Fate2"] = 7] = "Fate2";
|
|
83
|
+
})(VmVersion || (VmVersion = {}));
|
|
84
|
+
export let AbiVersion;
|
|
61
85
|
|
|
62
86
|
/**
|
|
63
87
|
* Enum with tag types
|
|
@@ -66,6 +90,11 @@ export const NAME_BID_RANGES = mapObject({
|
|
|
66
90
|
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}
|
|
67
91
|
*/
|
|
68
92
|
// TODO: implement serialisation for commented-out tags
|
|
93
|
+
(function (AbiVersion) {
|
|
94
|
+
AbiVersion[AbiVersion["NoAbi"] = 0] = "NoAbi";
|
|
95
|
+
AbiVersion[AbiVersion["Sophia"] = 1] = "Sophia";
|
|
96
|
+
AbiVersion[AbiVersion["Fate"] = 3] = "Fate";
|
|
97
|
+
})(AbiVersion || (AbiVersion = {}));
|
|
69
98
|
export let Tag; // KeyBlock = 100,
|
|
70
99
|
// MicroBlock = 101,
|
|
71
100
|
// LightMicroBlock = 102,
|
|
@@ -74,10 +103,12 @@ export let Tag; // KeyBlock = 100,
|
|
|
74
103
|
Tag[Tag["Account"] = 10] = "Account";
|
|
75
104
|
Tag[Tag["SignedTx"] = 11] = "SignedTx";
|
|
76
105
|
Tag[Tag["SpendTx"] = 12] = "SpendTx";
|
|
106
|
+
Tag[Tag["Oracle"] = 20] = "Oracle";
|
|
77
107
|
Tag[Tag["OracleRegisterTx"] = 22] = "OracleRegisterTx";
|
|
78
108
|
Tag[Tag["OracleQueryTx"] = 23] = "OracleQueryTx";
|
|
79
109
|
Tag[Tag["OracleResponseTx"] = 24] = "OracleResponseTx";
|
|
80
110
|
Tag[Tag["OracleExtendTx"] = 25] = "OracleExtendTx";
|
|
111
|
+
Tag[Tag["Name"] = 30] = "Name";
|
|
81
112
|
Tag[Tag["NameClaimTx"] = 32] = "NameClaimTx";
|
|
82
113
|
Tag[Tag["NamePreclaimTx"] = 33] = "NamePreclaimTx";
|
|
83
114
|
Tag[Tag["NameUpdateTx"] = 34] = "NameUpdateTx";
|
|
@@ -114,9 +145,9 @@ export let Tag; // KeyBlock = 100,
|
|
|
114
145
|
Tag[Tag["NameserviceMtree"] = 624] = "NameserviceMtree";
|
|
115
146
|
Tag[Tag["OraclesMtree"] = 625] = "OraclesMtree";
|
|
116
147
|
Tag[Tag["AccountsMtree"] = 626] = "AccountsMtree";
|
|
117
|
-
Tag[Tag["CompilerSophia"] = 70] = "CompilerSophia";
|
|
118
148
|
Tag[Tag["GaAttachTx"] = 80] = "GaAttachTx";
|
|
119
149
|
Tag[Tag["GaMetaTx"] = 81] = "GaMetaTx";
|
|
120
150
|
Tag[Tag["PayingForTx"] = 82] = "PayingForTx";
|
|
151
|
+
Tag[Tag["GaMetaTxAuthData"] = 810] = "GaMetaTxAuthData";
|
|
121
152
|
})(Tag || (Tag = {}));
|
|
122
153
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":["BigNumber","mapObject","MAX_AUTH_FUN_GAS","NAME_TTL","NAME_MAX_TTL","NAME_MAX_CLIENT_TTL","CLIENT_TTL","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_MAX_LENGTH","NAME_BID_RANGES","key","value","times","Tag"],"sources":["../../../src/tx/builder/constants.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { mapObject } from '../../utils/other';\n\nexport const MAX_AUTH_FUN_GAS = 50000;\n// # AENS\nexport type AensName = `${string}.chain`;\nexport const NAME_TTL = 180000;\n// # max number of block into the future that the name is going to be available\n// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update\n// # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry\nexport const NAME_MAX_TTL = 36000;\nexport const NAME_MAX_CLIENT_TTL = 84600;\nexport const CLIENT_TTL = NAME_MAX_CLIENT_TTL;\nexport const MIN_GAS_PRICE = 1e9;\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67\nexport const NAME_FEE_MULTIPLIER = 1e14; // 100000000000000\nexport const NAME_FEE_BID_INCREMENT = 0.05; // # the increment is in percentage\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272\nexport const NAME_BID_TIMEOUT_BLOCKS = 480; // # ~1 day\n// # this is the max length for a domain that requires a base fee to be paid\nexport const NAME_MAX_LENGTH_FEE = 31;\nexport const NAME_BID_MAX_LENGTH = 12; // # this is the max length for a domain to be part of a bid\n// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290\n// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times\n// # bid ranges:\nexport const NAME_BID_RANGES = mapObject({\n 31: 3,\n 30: 5,\n 29: 8,\n 28: 13,\n 27: 21,\n 26: 34,\n 25: 55,\n 24: 89,\n 23: 144,\n 22: 233,\n 21: 377,\n 20: 610,\n 19: 987,\n 18: 1597,\n 17: 2584,\n 16: 4181,\n 15: 6765,\n 14: 10946,\n 13: 17711,\n 12: 28657,\n 11: 46368,\n 10: 75025,\n 9: 121393,\n 8: 196418,\n 7: 317811,\n 6: 514229,\n 5: 832040,\n 4: 1346269,\n 3: 2178309,\n 2: 3524578,\n 1: 5702887,\n}, ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)]);\n\n/**\n * Enum with tag types\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}\n */\n// TODO: implement serialisation for commented-out tags\nexport enum Tag {\n Account = 10,\n SignedTx = 11,\n SpendTx = 12,\n
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":["BigNumber","mapObject","MAX_AUTH_FUN_GAS","NAME_TTL","NAME_MAX_TTL","NAME_MAX_CLIENT_TTL","CLIENT_TTL","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_MAX_LENGTH","NAME_BID_RANGES","_ref","key","value","times","ConsensusProtocolVersion","VmVersion","AbiVersion","Tag"],"sources":["../../../src/tx/builder/constants.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { mapObject } from '../../utils/other';\n\nexport const MAX_AUTH_FUN_GAS = 50000;\nexport type Int = number | string | BigNumber;\n// # AENS\nexport type AensName = `${string}.chain`;\nexport const NAME_TTL = 180000;\n// # max number of block into the future that the name is going to be available\n// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update\n// # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry\nexport const NAME_MAX_TTL = 36000;\nexport const NAME_MAX_CLIENT_TTL = 84600;\nexport const CLIENT_TTL = NAME_MAX_CLIENT_TTL;\nexport const MIN_GAS_PRICE = 1e9;\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67\nexport const NAME_FEE_MULTIPLIER = 1e14; // 100000000000000\nexport const NAME_FEE_BID_INCREMENT = 0.05; // # the increment is in percentage\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272\nexport const NAME_BID_TIMEOUT_BLOCKS = 480; // # ~1 day\n// # this is the max length for a domain that requires a base fee to be paid\nexport const NAME_MAX_LENGTH_FEE = 31;\nexport const NAME_BID_MAX_LENGTH = 12; // # this is the max length for a domain to be part of a bid\n// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290\n// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times\n// # bid ranges:\nexport const NAME_BID_RANGES = mapObject({\n 31: 3,\n 30: 5,\n 29: 8,\n 28: 13,\n 27: 21,\n 26: 34,\n 25: 55,\n 24: 89,\n 23: 144,\n 22: 233,\n 21: 377,\n 20: 610,\n 19: 987,\n 18: 1597,\n 17: 2584,\n 16: 4181,\n 15: 6765,\n 14: 10946,\n 13: 17711,\n 12: 28657,\n 11: 46368,\n 10: 75025,\n 9: 121393,\n 8: 196418,\n 7: 317811,\n 6: 514229,\n 5: 832040,\n 4: 1346269,\n 3: 2178309,\n 2: 3524578,\n 1: 5702887,\n}, ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)]);\n\nexport enum ConsensusProtocolVersion {\n Iris = 5,\n Ceres = 6,\n}\n\n/**\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}\n */\nexport enum VmVersion {\n NoVm = 0,\n Sophia = 1,\n SophiaImprovementsMinerva = 3,\n SophiaImprovementsFortuna = 4,\n Fate = 5,\n SophiaImprovementsLima = 6,\n Fate2 = 7,\n}\n\n/**\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}\n */\nexport enum AbiVersion {\n NoAbi = 0,\n Sophia = 1,\n Fate = 3,\n}\n\n/**\n * Enum with tag types\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}\n */\n// TODO: implement serialisation for commented-out tags\nexport enum Tag {\n Account = 10,\n SignedTx = 11,\n SpendTx = 12,\n Oracle = 20,\n // OracleQuery = 21,\n OracleRegisterTx = 22,\n OracleQueryTx = 23,\n OracleResponseTx = 24,\n OracleExtendTx = 25,\n Name = 30,\n // NameCommitment = 31,\n NameClaimTx = 32,\n NamePreclaimTx = 33,\n NameUpdateTx = 34,\n NameRevokeTx = 35,\n NameTransferTx = 36,\n // NameAuction = 37,\n Contract = 40,\n ContractCall = 41,\n ContractCreateTx = 42,\n ContractCallTx = 43,\n ChannelCreateTx = 50,\n // ChannelSetDelegatesTx = 501,\n ChannelDepositTx = 51,\n ChannelWithdrawTx = 52,\n ChannelForceProgressTx = 521,\n ChannelCloseMutualTx = 53,\n ChannelCloseSoloTx = 54,\n ChannelSlashTx = 55,\n ChannelSettleTx = 56,\n ChannelOffChainTx = 57,\n ChannelOffChainUpdateTransfer = 570,\n ChannelOffChainUpdateDeposit = 571,\n ChannelOffChainUpdateWithdraw = 572,\n ChannelOffChainUpdateCreateContract = 573,\n ChannelOffChainUpdateCallContract = 574,\n // ChannelOffChainUpdateMeta = 576,\n ChannelClientReconnectTx = 575,\n Channel = 58,\n ChannelSnapshotSoloTx = 59,\n TreesPoi = 60,\n // TreesDb = 61,\n StateTrees = 62,\n Mtree = 63,\n MtreeValue = 64,\n ContractsMtree = 621,\n CallsMtree = 622,\n ChannelsMtree = 623,\n NameserviceMtree = 624,\n OraclesMtree = 625,\n AccountsMtree = 626,\n // CompilerSophia = 70,\n GaAttachTx = 80,\n GaMetaTx = 81,\n PayingForTx = 82,\n GaMetaTxAuthData = 810,\n // KeyBlock = 100,\n // MicroBlock = 101,\n // LightMicroBlock = 102,\n // Pof = 200,\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,SAAS;AAElB,OAAO,MAAMC,gBAAgB,GAAG,KAAK;AAIrC,OAAO,MAAMC,QAAQ,GAAG,MAAM;AAC9B;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAG,KAAK;AACjC,OAAO,MAAMC,mBAAmB,GAAG,KAAK;AACxC,OAAO,MAAMC,UAAU,GAAGD,mBAAmB;AAC7C,OAAO,MAAME,aAAa,GAAG,GAAG;AAChC;AACA,OAAO,MAAMC,mBAAmB,GAAG,IAAI,CAAC,CAAC;AACzC,OAAO,MAAMC,sBAAsB,GAAG,IAAI,CAAC,CAAC;AAC5C;AACA,OAAO,MAAMC,uBAAuB,GAAG,GAAG,CAAC,CAAC;AAC5C;AACA,OAAO,MAAMC,mBAAmB,GAAG,EAAE;AACrC,OAAO,MAAMC,mBAAmB,GAAG,EAAE,CAAC,CAAC;AACvC;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGZ,SAAS,CAAC;EACvC,EAAE,EAAE,CAAC;EACL,EAAE,EAAE,CAAC;EACL,EAAE,EAAE,CAAC;EACL,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,IAAI;EACR,EAAE,EAAE,IAAI;EACR,EAAE,EAAE,IAAI;EACR,EAAE,EAAE,IAAI;EACR,EAAE,EAAE,KAAK;EACT,EAAE,EAAE,KAAK;EACT,EAAE,EAAE,KAAK;EACT,EAAE,EAAE,KAAK;EACT,EAAE,EAAE,KAAK;EACT,CAAC,EAAE,MAAM;EACT,CAAC,EAAE,MAAM;EACT,CAAC,EAAE,MAAM;EACT,CAAC,EAAE,MAAM;EACT,CAAC,EAAE,MAAM;EACT,CAAC,EAAE,OAAO;EACV,CAAC,EAAE,OAAO;EACV,CAAC,EAAE,OAAO;EACV,CAAC,EAAE;AACL,CAAC,EAAEa,IAAA;EAAA,IAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;EAAA,OAAK,CAACC,GAAG,EAAE,IAAIf,SAAS,CAACgB,KAAK,CAAC,CAACC,KAAK,CAACT,mBAAmB,CAAC,CAAC;AAAA,EAAC;AAE5E,WAAYU,wBAAwB;;AAKpC;AACA;AACA;AACA;AAHA,WALYA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;AAAA,GAAxBA,wBAAwB,KAAxBA,wBAAwB;AASpC,WAAYC,SAAS;;AAUrB;AACA;AACA;AACA;AAHA,WAVYA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;AAAA,GAATA,SAAS,KAATA,SAAS;AAcrB,WAAYC,UAAU;;AAMtB;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,WAZYA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;AAAA,GAAVA,UAAU,KAAVA,UAAU;AAatB,WAAYC,GAAG,EAyDb;AACA;AACA;AACA;AACD,WA7DWA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;AAAA,GAAHA,GAAG,KAAHA,GAAG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants';
|
|
3
|
+
import Node from '../../../Node';
|
|
4
|
+
declare const _default: {
|
|
5
|
+
_getProtocolDetails(c: ConsensusProtocolVersion, tag: Tag): AbiVersion;
|
|
6
|
+
serialize(value: AbiVersion | undefined, { tag }: {
|
|
7
|
+
tag: Tag;
|
|
8
|
+
}, { consensusProtocolVersion }: {
|
|
9
|
+
consensusProtocolVersion?: ConsensusProtocolVersion | undefined;
|
|
10
|
+
}): Buffer;
|
|
11
|
+
prepare(value: AbiVersion | undefined, { tag }: {
|
|
12
|
+
tag: Tag;
|
|
13
|
+
}, options: {
|
|
14
|
+
consensusProtocolVersion?: ConsensusProtocolVersion;
|
|
15
|
+
onNode?: Node;
|
|
16
|
+
}): Promise<AbiVersion | undefined>;
|
|
17
|
+
deserialize(buffer: Buffer): AbiVersion;
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _buffer from "buffer";
|
|
2
|
+
const {
|
|
3
|
+
Buffer: _Buffer
|
|
4
|
+
} = _buffer;
|
|
5
|
+
import { Tag, ConsensusProtocolVersion } from "../constants.mjs";
|
|
6
|
+
import { getProtocolDetails } from "./ct-version.mjs";
|
|
7
|
+
export default {
|
|
8
|
+
_getProtocolDetails(c, tag) {
|
|
9
|
+
const kind = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag ? 'contract-call' : 'oracle-call';
|
|
10
|
+
return getProtocolDetails(c, kind).abiVersion;
|
|
11
|
+
},
|
|
12
|
+
serialize(value, _ref, _ref2) {
|
|
13
|
+
let {
|
|
14
|
+
tag
|
|
15
|
+
} = _ref;
|
|
16
|
+
let {
|
|
17
|
+
consensusProtocolVersion = ConsensusProtocolVersion.Iris
|
|
18
|
+
} = _ref2;
|
|
19
|
+
const result = value !== null && value !== void 0 ? value : this._getProtocolDetails(consensusProtocolVersion, tag);
|
|
20
|
+
return _Buffer.from([result]);
|
|
21
|
+
},
|
|
22
|
+
async prepare(value, _ref3,
|
|
23
|
+
// TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}
|
|
24
|
+
options) {
|
|
25
|
+
let {
|
|
26
|
+
tag
|
|
27
|
+
} = _ref3;
|
|
28
|
+
if (value != null) return value;
|
|
29
|
+
if (options.consensusProtocolVersion != null) return undefined;
|
|
30
|
+
if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
|
|
31
|
+
if (options.onNode != null) {
|
|
32
|
+
return this._getProtocolDetails((await options.onNode.getNodeInfo()).consensusProtocolVersion, tag);
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
},
|
|
36
|
+
deserialize(buffer) {
|
|
37
|
+
return buffer[0];
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=abi-version.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi-version.mjs","names":["Tag","ConsensusProtocolVersion","getProtocolDetails","_getProtocolDetails","c","tag","kind","ContractCallTx","GaMetaTx","abiVersion","serialize","value","_ref","_ref2","consensusProtocolVersion","Iris","result","_Buffer","from","prepare","_ref3","options","undefined","Object","keys","length","onNode","getNodeInfo","deserialize","buffer"],"sources":["../../../../src/tx/builder/field-types/abi-version.ts"],"sourcesContent":["import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants';\nimport { getProtocolDetails } from './ct-version';\nimport Node from '../../../Node';\n\nexport default {\n _getProtocolDetails(c: ConsensusProtocolVersion, tag: Tag): AbiVersion {\n const kind = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag\n ? 'contract-call' : 'oracle-call';\n return getProtocolDetails(c, kind).abiVersion;\n },\n\n serialize(\n value: AbiVersion | undefined,\n { tag }: { tag: Tag },\n { consensusProtocolVersion = ConsensusProtocolVersion.Iris }:\n { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n const result = value ?? this._getProtocolDetails(consensusProtocolVersion, tag);\n\n return Buffer.from([result]);\n },\n\n async prepare(\n value: AbiVersion | undefined,\n { tag }: { tag: Tag },\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<AbiVersion | undefined> {\n if (value != null) return value;\n if (options.consensusProtocolVersion != null) return undefined;\n if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;\n if (options.onNode != null) {\n return this._getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n tag,\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): AbiVersion {\n return buffer[0];\n },\n};\n"],"mappings":";;;;SAASA,GAAG,EAAEC,wBAAwB;AAAA,SAC7BC,kBAAkB;AAG3B,eAAe;EACbC,mBAAmBA,CAACC,CAA2B,EAAEC,GAAQ,EAAc;IACrE,MAAMC,IAAI,GAAGN,GAAG,CAACO,cAAc,KAAKF,GAAG,IAAIL,GAAG,CAACQ,QAAQ,KAAKH,GAAG,GAC3D,eAAe,GAAG,aAAa;IACnC,OAAOH,kBAAkB,CAACE,CAAC,EAAEE,IAAI,CAAC,CAACG,UAAU;EAC/C,CAAC;EAEDC,SAASA,CACPC,KAA6B,EAAAC,IAAA,EAAAC,KAAA,EAIrB;IAAA,IAHR;MAAER;IAAkB,CAAC,GAAAO,IAAA;IAAA,IACrB;MAAEE,wBAAwB,GAAGb,wBAAwB,CAACc;IACA,CAAC,GAAAF,KAAA;IAEvD,MAAMG,MAAM,GAAGL,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,IAAI,CAACR,mBAAmB,CAACW,wBAAwB,EAAET,GAAG,CAAC;IAE/E,OAAOY,OAAA,CAAOC,IAAI,CAAC,CAACF,MAAM,CAAC,CAAC;EAC9B,CAAC;EAED,MAAMG,OAAOA,CACXR,KAA6B,EAAAS,KAAA;EAE7B;EACAC,OAA+E,EAC9C;IAAA,IAHjC;MAAEhB;IAAkB,CAAC,GAAAe,KAAA;IAIrB,IAAIT,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;IAC/B,IAAIU,OAAO,CAACP,wBAAwB,IAAI,IAAI,EAAE,OAAOQ,SAAS;IAC9D,IAAIC,MAAM,CAACC,IAAI,CAACvB,wBAAwB,CAAC,CAACwB,MAAM,KAAK,CAAC,EAAE,OAAOH,SAAS;IACxE,IAAID,OAAO,CAACK,MAAM,IAAI,IAAI,EAAE;MAC1B,OAAO,IAAI,CAACvB,mBAAmB,CAC7B,CAAC,MAAMkB,OAAO,CAACK,MAAM,CAACC,WAAW,EAAE,EAAEb,wBAAwB,EAC7DT,GAAG,CACJ;IACH;IACA,OAAOiB,SAAS;EAClB,CAAC;EAEDM,WAAWA,CAACC,MAAc,EAAc;IACtC,OAAOA,MAAM,CAAC,CAAC,CAAC;EAClB;AACF,CAAC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { Encoded } from '../../../utils/encoder';
|
|
3
3
|
/**
|
|
4
4
|
* Map of prefix to ID tag constant
|
|
5
5
|
* @see {@link https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type}
|
|
6
6
|
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}
|
|
7
7
|
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}
|
|
8
8
|
*/
|
|
9
|
-
declare const idTagToEncoding: readonly [Encoding.AccountAddress, Encoding.Name, Encoding.Commitment, Encoding.OracleAddress, Encoding.ContractAddress, Encoding.Channel];
|
|
9
|
+
export declare const idTagToEncoding: readonly [Encoded.Encoding.AccountAddress, Encoded.Encoding.Name, Encoded.Encoding.Commitment, Encoded.Encoding.OracleAddress, Encoded.Encoding.ContractAddress, Encoded.Encoding.Channel];
|
|
10
10
|
export type AddressEncodings = typeof idTagToEncoding[number];
|
|
11
|
-
export default function genAddressField<Encoding extends AddressEncodings>(): {
|
|
12
|
-
serialize: (value:
|
|
13
|
-
deserialize: (value: Buffer) =>
|
|
11
|
+
export default function genAddressField<Encoding extends AddressEncodings>(...encodings: Encoding[]): {
|
|
12
|
+
serialize: (value: Encoded.Generic<Encoding>) => Buffer;
|
|
13
|
+
deserialize: (value: Buffer) => Encoded.Generic<Encoding>;
|
|
14
14
|
};
|
|
15
|
-
export {};
|
|
@@ -2,7 +2,7 @@ import _buffer from "buffer";
|
|
|
2
2
|
const {
|
|
3
3
|
Buffer: _Buffer
|
|
4
4
|
} = _buffer;
|
|
5
|
-
import { PrefixNotFoundError, TagNotFoundError } from "../../../utils/errors.mjs";
|
|
5
|
+
import { ArgumentError, PrefixNotFoundError, TagNotFoundError } from "../../../utils/errors.mjs";
|
|
6
6
|
import { toBytes } from "../../../utils/bytes.mjs";
|
|
7
7
|
import { decode, encode, Encoding } from "../../../utils/encoder.mjs";
|
|
8
8
|
import { isItemOfArray } from "../../../utils/other.mjs";
|
|
@@ -12,8 +12,11 @@ import { isItemOfArray } from "../../../utils/other.mjs";
|
|
|
12
12
|
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}
|
|
13
13
|
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}
|
|
14
14
|
*/
|
|
15
|
-
const idTagToEncoding = [Encoding.AccountAddress, Encoding.Name, Encoding.Commitment, Encoding.OracleAddress, Encoding.ContractAddress, Encoding.Channel];
|
|
15
|
+
export const idTagToEncoding = [Encoding.AccountAddress, Encoding.Name, Encoding.Commitment, Encoding.OracleAddress, Encoding.ContractAddress, Encoding.Channel];
|
|
16
16
|
export default function genAddressField() {
|
|
17
|
+
for (var _len = arguments.length, encodings = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
encodings[_key] = arguments[_key];
|
|
19
|
+
}
|
|
17
20
|
return {
|
|
18
21
|
/**
|
|
19
22
|
* Utility function to create and _id type
|
|
@@ -21,9 +24,12 @@ export default function genAddressField() {
|
|
|
21
24
|
* @returns Buffer Buffer with ID tag and decoded HASh
|
|
22
25
|
*/
|
|
23
26
|
serialize(hashId) {
|
|
24
|
-
const
|
|
25
|
-
if (!isItemOfArray(
|
|
26
|
-
|
|
27
|
+
const enc = hashId.slice(0, 2);
|
|
28
|
+
if (!isItemOfArray(enc, idTagToEncoding)) throw new TagNotFoundError(enc);
|
|
29
|
+
if (!isItemOfArray(enc, encodings)) {
|
|
30
|
+
throw new ArgumentError('Address encoding', encodings.join(', '), enc);
|
|
31
|
+
}
|
|
32
|
+
const idTag = idTagToEncoding.indexOf(enc) + 1;
|
|
27
33
|
return _Buffer.from([...toBytes(idTag), ...decode(hashId)]);
|
|
28
34
|
},
|
|
29
35
|
/**
|
|
@@ -33,9 +39,12 @@ export default function genAddressField() {
|
|
|
33
39
|
*/
|
|
34
40
|
deserialize(buf) {
|
|
35
41
|
const idTag = _Buffer.from(buf).readUIntBE(0, 1);
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
42
|
+
const enc = idTagToEncoding[idTag - 1];
|
|
43
|
+
if (enc == null) throw new PrefixNotFoundError(idTag);
|
|
44
|
+
if (!isItemOfArray(enc, encodings)) {
|
|
45
|
+
throw new ArgumentError('Address encoding', encodings.join(', '), enc);
|
|
46
|
+
}
|
|
47
|
+
return encode(buf.subarray(1), enc);
|
|
39
48
|
}
|
|
40
49
|
};
|
|
41
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.mjs","names":["PrefixNotFoundError","TagNotFoundError","toBytes","decode","encode","Encoding","isItemOfArray","idTagToEncoding","AccountAddress","Name","Commitment","OracleAddress","ContractAddress","Channel","genAddressField","serialize","hashId","
|
|
1
|
+
{"version":3,"file":"address.mjs","names":["ArgumentError","PrefixNotFoundError","TagNotFoundError","toBytes","decode","encode","Encoding","isItemOfArray","idTagToEncoding","AccountAddress","Name","Commitment","OracleAddress","ContractAddress","Channel","genAddressField","_len","arguments","length","encodings","Array","_key","serialize","hashId","enc","slice","join","idTag","indexOf","_Buffer","from","deserialize","buf","readUIntBE","subarray"],"sources":["../../../../src/tx/builder/field-types/address.ts"],"sourcesContent":["import { ArgumentError, PrefixNotFoundError, TagNotFoundError } from '../../../utils/errors';\nimport { toBytes } from '../../../utils/bytes';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport { isItemOfArray } from '../../../utils/other';\n\n/**\n * Map of prefix to ID tag constant\n * @see {@link https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}\n */\nexport const idTagToEncoding = [\n Encoding.AccountAddress,\n Encoding.Name,\n Encoding.Commitment,\n Encoding.OracleAddress,\n Encoding.ContractAddress,\n Encoding.Channel,\n] as const;\n\nexport type AddressEncodings = typeof idTagToEncoding[number];\n\nexport default function genAddressField<Encoding extends AddressEncodings>(\n ...encodings: Encoding[]\n): {\n serialize: (value: Encoded.Generic<Encoding>) => Buffer;\n deserialize: (value: Buffer) => Encoded.Generic<Encoding>;\n } {\n return {\n /**\n * Utility function to create and _id type\n * @param hashId - Encoded hash\n * @returns Buffer Buffer with ID tag and decoded HASh\n */\n serialize(hashId) {\n const enc = hashId.slice(0, 2);\n if (!isItemOfArray(enc, idTagToEncoding)) throw new TagNotFoundError(enc);\n if (!isItemOfArray(enc, encodings)) {\n throw new ArgumentError('Address encoding', encodings.join(', '), enc);\n }\n const idTag = idTagToEncoding.indexOf(enc) + 1;\n return Buffer.from([...toBytes(idTag), ...decode(hashId)]);\n },\n\n /**\n * Utility function to read and _id type\n * @param buf - Data\n * @returns Encoded hash string with prefix\n */\n deserialize(buf) {\n const idTag = Buffer.from(buf).readUIntBE(0, 1);\n const enc = idTagToEncoding[idTag - 1];\n if (enc == null) throw new PrefixNotFoundError(idTag);\n if (!isItemOfArray(enc, encodings)) {\n throw new ArgumentError('Address encoding', encodings.join(', '), enc);\n }\n return encode(buf.subarray(1), enc) as Encoded.Generic<Encoding>;\n },\n };\n}\n"],"mappings":";;;;SAASA,aAAa,EAAEC,mBAAmB,EAAEC,gBAAgB;AAAA,SACpDC,OAAO;AAAA,SAEdC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,aAAa;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG,CAC7BF,QAAQ,CAACG,cAAc,EACvBH,QAAQ,CAACI,IAAI,EACbJ,QAAQ,CAACK,UAAU,EACnBL,QAAQ,CAACM,aAAa,EACtBN,QAAQ,CAACO,eAAe,EACxBP,QAAQ,CAACQ,OAAO,CACR;AAIV,eAAe,SAASC,eAAeA,CAAA,EAKnC;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAJCC,SAAS,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAATF,SAAS,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EAKZ,OAAO;IACL;AACJ;AACA;AACA;AACA;IACIC,SAASA,CAACC,MAAM,EAAE;MAChB,MAAMC,GAAG,GAAGD,MAAM,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;MAC9B,IAAI,CAAClB,aAAa,CAACiB,GAAG,EAAEhB,eAAe,CAAC,EAAE,MAAM,IAAIN,gBAAgB,CAACsB,GAAG,CAAC;MACzE,IAAI,CAACjB,aAAa,CAACiB,GAAG,EAAEL,SAAS,CAAC,EAAE;QAClC,MAAM,IAAInB,aAAa,CAAC,kBAAkB,EAAEmB,SAAS,CAACO,IAAI,CAAC,IAAI,CAAC,EAAEF,GAAG,CAAC;MACxE;MACA,MAAMG,KAAK,GAAGnB,eAAe,CAACoB,OAAO,CAACJ,GAAG,CAAC,GAAG,CAAC;MAC9C,OAAOK,OAAA,CAAOC,IAAI,CAAC,CAAC,GAAG3B,OAAO,CAACwB,KAAK,CAAC,EAAE,GAAGvB,MAAM,CAACmB,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED;AACJ;AACA;AACA;AACA;IACIQ,WAAWA,CAACC,GAAG,EAAE;MACf,MAAML,KAAK,GAAGE,OAAA,CAAOC,IAAI,CAACE,GAAG,CAAC,CAACC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;MAC/C,MAAMT,GAAG,GAAGhB,eAAe,CAACmB,KAAK,GAAG,CAAC,CAAC;MACtC,IAAIH,GAAG,IAAI,IAAI,EAAE,MAAM,IAAIvB,mBAAmB,CAAC0B,KAAK,CAAC;MACrD,IAAI,CAACpB,aAAa,CAACiB,GAAG,EAAEL,SAAS,CAAC,EAAE;QAClC,MAAM,IAAInB,aAAa,CAAC,kBAAkB,EAAEmB,SAAS,CAACO,IAAI,CAAC,IAAI,CAAC,EAAEF,GAAG,CAAC;MACxE;MACA,OAAOnB,MAAM,CAAC2B,GAAG,CAACE,QAAQ,CAAC,CAAC,CAAC,EAAEV,GAAG,CAAC;IACrC;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export default function genArrayField<Input, Output, Binary>(itemHandler: {
|
|
2
|
+
serialize: (value: Input, params: unknown) => Binary;
|
|
3
|
+
deserialize: (value: Binary, params: unknown) => Output;
|
|
4
|
+
}): {
|
|
5
|
+
serialize: (value: readonly Input[], params: unknown) => Binary[];
|
|
6
|
+
deserialize: (value: Binary[], params: unknown) => Output[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default function genArrayField(itemHandler) {
|
|
2
|
+
return {
|
|
3
|
+
serialize(items, params) {
|
|
4
|
+
return items.map(item => itemHandler.serialize(item, params));
|
|
5
|
+
},
|
|
6
|
+
deserialize(buffers, params) {
|
|
7
|
+
return buffers.map(buffer => itemHandler.deserialize(buffer, params));
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=array.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.mjs","names":["genArrayField","itemHandler","serialize","items","params","map","item","deserialize","buffers","buffer"],"sources":["../../../../src/tx/builder/field-types/array.ts"],"sourcesContent":["export default function genArrayField<Input, Output, Binary>(\n itemHandler: {\n serialize: (value: Input, params: unknown) => Binary;\n deserialize: (value: Binary, params: unknown) => Output;\n },\n): {\n serialize: (value: readonly Input[], params: unknown) => Binary[];\n deserialize: (value: Binary[], params: unknown) => Output[];\n } {\n return {\n serialize(items, params) {\n return items.map((item) => itemHandler.serialize(item, params));\n },\n\n deserialize(buffers, params) {\n return buffers.map((buffer) => itemHandler.deserialize(buffer, params));\n },\n };\n}\n"],"mappings":"AAAA,eAAe,SAASA,aAAaA,CACnCC,WAGC,EAIC;EACF,OAAO;IACLC,SAASA,CAACC,KAAK,EAAEC,MAAM,EAAE;MACvB,OAAOD,KAAK,CAACE,GAAG,CAAEC,IAAI,IAAKL,WAAW,CAACC,SAAS,CAACI,IAAI,EAAEF,MAAM,CAAC,CAAC;IACjE,CAAC;IAEDG,WAAWA,CAACC,OAAO,EAAEJ,MAAM,EAAE;MAC3B,OAAOI,OAAO,CAACH,GAAG,CAAEI,MAAM,IAAKR,WAAW,CAACM,WAAW,CAACE,MAAM,EAAEL,MAAM,CAAC,CAAC;IACzE;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _buffer from "buffer";
|
|
2
|
+
const {
|
|
3
|
+
Buffer: _Buffer
|
|
4
|
+
} = _buffer;
|
|
5
|
+
export default {
|
|
6
|
+
serialize(value) {
|
|
7
|
+
return _Buffer.from([value ? 1 : 0]);
|
|
8
|
+
},
|
|
9
|
+
deserialize(buffer) {
|
|
10
|
+
return buffer[0] === 1;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=boolean.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.mjs","names":["serialize","value","_Buffer","from","deserialize","buffer"],"sources":["../../../../src/tx/builder/field-types/boolean.ts"],"sourcesContent":["export default {\n serialize(value: boolean): Buffer {\n return Buffer.from([value ? 1 : 0]);\n },\n\n deserialize(buffer: Buffer): boolean {\n return buffer[0] === 1;\n },\n};\n"],"mappings":";;;;AAAA,eAAe;EACbA,SAASA,CAACC,KAAc,EAAU;IAChC,OAAOC,OAAA,CAAOC,IAAI,CAAC,CAACF,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;EACrC,CAAC;EAEDG,WAAWA,CAACC,MAAc,EAAW;IACnC,OAAOA,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;EACxB;AACF,CAAC"}
|