@aeternity/aepp-sdk 13.0.0-alpha.0 → 13.0.0-alpha.1
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 +4206 -1127
- package/dist/aepp-sdk.js.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 +3 -4
- package/es/AeSdkMethods.mjs.map +1 -1
- package/es/Node.d.ts +4 -3
- package/es/Node.mjs +1 -1
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +2 -2
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Generalized.mjs +5 -3
- 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/Memory.mjs +2 -1
- package/es/account/Memory.mjs.map +1 -1
- package/es/aens.d.ts +1 -1
- package/es/aens.mjs +5 -1
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -4
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/chain.d.ts +9 -1
- package/es/chain.mjs +4 -1
- package/es/chain.mjs.map +1 -1
- package/es/channel/Base.d.ts +6 -1
- package/es/channel/Base.mjs +9 -6
- package/es/channel/Base.mjs.map +1 -1
- package/es/channel/Contract.d.ts +8 -7
- package/es/channel/Contract.mjs +1 -1
- package/es/channel/Contract.mjs.map +1 -1
- package/es/channel/Spend.d.ts +3 -1
- package/es/channel/Spend.mjs +4 -2
- package/es/channel/Spend.mjs.map +1 -1
- package/es/channel/handlers.mjs +11 -9
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/internal.mjs +3 -1
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Contract.d.ts +21 -46
- package/es/contract/Contract.mjs +69 -52
- package/es/contract/Contract.mjs.map +1 -1
- package/es/contract/compiler/Base.d.ts +81 -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 +155 -0
- package/es/contract/compiler/Cli.mjs.map +1 -0
- package/es/contract/compiler/Http.d.ts +32 -0
- package/es/contract/{CompilerHttp.mjs → compiler/Http.mjs} +64 -9
- 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/ga.d.ts +5 -4
- package/es/contract/ga.mjs +11 -2
- package/es/contract/ga.mjs.map +1 -1
- package/es/index-browser.d.ts +39 -0
- package/es/index-browser.mjs +55 -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.mjs +1 -1
- package/es/oracle.mjs.map +1 -1
- package/es/spend.mjs +1 -3
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/constants.d.ts +28 -1
- package/es/tx/builder/constants.mjs +32 -3
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/abi-version.d.ts +10 -0
- package/es/tx/builder/field-types/abi-version.mjs +20 -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 +1 -1
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
- package/es/tx/builder/field-types/ct-version.d.ts +30 -0
- package/es/tx/builder/field-types/ct-version.mjs +48 -0
- package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +1 -1
- 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 +31 -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 +10 -7
- package/es/tx/builder/field-types/fee.mjs +24 -20
- package/es/tx/builder/field-types/fee.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-limit.d.ts +5 -2
- package/es/tx/builder/field-types/gas-limit.mjs +9 -6
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +1 -1
- package/es/tx/builder/field-types/index.d.ts +66 -28
- package/es/tx/builder/field-types/index.mjs +30 -12
- package/es/tx/builder/field-types/index.mjs.map +1 -1
- package/es/tx/builder/field-types/mptree.d.ts +37 -0
- package/es/tx/builder/field-types/mptree.mjs +268 -0
- package/es/tx/builder/field-types/mptree.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +1 -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/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 +5 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs +16 -0
- package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
- 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/u-int.d.ts +1 -2
- package/es/tx/builder/field-types/u-int.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +11 -29
- package/es/tx/builder/index.mjs +50 -211
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +2111 -571
- package/es/tx/builder/schema.mjs +57 -125
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +5 -20
- package/es/tx/index.mjs +31 -88
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +3 -5
- package/es/tx/validator.mjs +82 -95
- package/es/tx/validator.mjs.map +1 -1
- package/es/utils/bytes.mjs +1 -1
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/errors.d.ts +3 -8
- package/es/utils/errors.mjs +1 -11
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/other.d.ts +1 -1
- package/package.json +35 -27
- package/src/AeSdkBase.ts +6 -3
- package/src/AeSdkMethods.ts +3 -4
- package/src/Node.ts +6 -3
- package/src/account/Base.ts +2 -2
- package/src/account/Generalized.ts +2 -2
- package/src/account/Ledger.ts +1 -1
- package/src/account/Memory.ts +1 -1
- package/src/aens.ts +3 -2
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -7
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
- package/src/chain.ts +5 -3
- package/src/channel/Base.ts +13 -5
- package/src/channel/Contract.ts +11 -10
- package/src/channel/Spend.ts +7 -2
- package/src/channel/handlers.ts +10 -9
- package/src/channel/internal.ts +1 -1
- package/src/contract/Contract.ts +69 -79
- package/src/contract/compiler/Base.ts +94 -0
- package/src/contract/compiler/Cli.ts +134 -0
- package/src/contract/compiler/Http.ts +124 -0
- package/src/contract/compiler/HttpNode.ts +26 -0
- package/src/contract/compiler/getFileSystem.ts +42 -0
- package/src/contract/ga.ts +9 -6
- package/src/index-browser.ts +58 -0
- package/src/index.ts +4 -56
- package/src/oracle.ts +1 -1
- package/src/spend.ts +1 -1
- package/src/tx/builder/constants.ts +32 -3
- package/src/tx/builder/field-types/abi-version.ts +21 -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 +2 -1
- package/src/tx/builder/field-types/ct-version.ts +50 -0
- package/src/tx/builder/field-types/deposit.ts +1 -1
- package/src/tx/builder/field-types/encoded.ts +27 -0
- package/src/tx/builder/field-types/entry.ts +31 -0
- package/src/tx/builder/field-types/enumeration.ts +15 -4
- package/src/tx/builder/field-types/fee.ts +38 -18
- package/src/tx/builder/field-types/gas-limit.ts +12 -7
- package/src/tx/builder/field-types/index.ts +46 -17
- package/src/tx/builder/field-types/mptree.ts +242 -0
- package/src/tx/builder/field-types/name-fee.ts +1 -2
- package/src/tx/builder/field-types/name-id.ts +1 -1
- 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 +20 -0
- package/src/tx/builder/field-types/string.ts +11 -0
- package/src/tx/builder/field-types/u-int.ts +1 -3
- package/src/tx/builder/index.ts +63 -247
- package/src/tx/builder/schema.ts +273 -323
- package/src/tx/index.ts +37 -104
- package/src/tx/validator.ts +72 -95
- package/src/utils/bytes.ts +1 -1
- package/src/utils/errors.ts +4 -13
- package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.2/AeSdkMethods.d.ts +3 -4
- package/types-legacy/ts4.2/Node.d.ts +3 -3
- package/types-legacy/ts4.2/account/Base.d.ts +2 -2
- package/types-legacy/ts4.2/aens.d.ts +1 -1
- package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/types-legacy/ts4.2/chain.d.ts +9 -1
- package/types-legacy/ts4.2/channel/Base.d.ts +6 -1
- package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.2/channel/Spend.d.ts +3 -1
- package/types-legacy/ts4.2/contract/Contract.d.ts +21 -46
- package/types-legacy/ts4.2/contract/compiler/Base.d.ts +81 -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/ga.d.ts +5 -4
- package/types-legacy/ts4.2/index-browser.d.ts +39 -0
- package/types-legacy/ts4.2/index.d.ts +4 -38
- package/types-legacy/ts4.2/tx/builder/constants.d.ts +28 -1
- package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +10 -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 +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +42 -0
- package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +1 -1
- 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 +10 -7
- package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +5 -2
- package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +1 -1
- package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +72 -28
- package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +43 -0
- package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -2
- 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 +5 -0
- package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.2/tx/builder/index.d.ts +11 -29
- package/types-legacy/ts4.2/tx/builder/schema.d.ts +2380 -668
- package/types-legacy/ts4.2/tx/index.d.ts +5 -20
- package/types-legacy/ts4.2/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.2/utils/errors.d.ts +3 -8
- package/types-legacy/ts4.2/utils/other.d.ts +1 -1
- package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
- package/types-legacy/ts4.5/AeSdkMethods.d.ts +3 -4
- package/types-legacy/ts4.5/Node.d.ts +3 -3
- package/types-legacy/ts4.5/account/Base.d.ts +2 -2
- package/types-legacy/ts4.5/aens.d.ts +1 -1
- package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
- package/types-legacy/ts4.5/chain.d.ts +9 -1
- package/types-legacy/ts4.5/channel/Base.d.ts +6 -1
- package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
- package/types-legacy/ts4.5/channel/Spend.d.ts +3 -1
- package/types-legacy/ts4.5/contract/Contract.d.ts +21 -46
- package/types-legacy/ts4.5/contract/compiler/Base.d.ts +81 -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/ga.d.ts +5 -4
- package/types-legacy/ts4.5/index-browser.d.ts +39 -0
- package/types-legacy/ts4.5/index.d.ts +4 -38
- package/types-legacy/ts4.5/tx/builder/constants.d.ts +28 -1
- package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +10 -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 +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +42 -0
- package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +1 -1
- 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 +10 -7
- package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +5 -2
- package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +1 -1
- package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +72 -28
- package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +43 -0
- package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -2
- 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 +5 -0
- package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
- package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
- package/types-legacy/ts4.5/tx/builder/index.d.ts +11 -29
- package/types-legacy/ts4.5/tx/builder/schema.d.ts +2380 -668
- package/types-legacy/ts4.5/tx/index.d.ts +5 -20
- package/types-legacy/ts4.5/tx/validator.d.ts +3 -5
- package/types-legacy/ts4.5/utils/errors.d.ts +3 -8
- package/types-legacy/ts4.5/utils/other.d.ts +1 -1
- package/es/contract/CompilerHttp.d.ts +0 -18
- 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/utils/mptree.d.ts +0 -26
- package/es/utils/mptree.mjs +0 -143
- package/es/utils/mptree.mjs.map +0 -1
- package/src/contract/CompilerHttp.ts +0 -67
- package/src/tx/builder/field-types/addresses.ts +0 -18
- 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/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/utils/mptree.d.ts +0 -32
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default function genArrayField<Input, Output, Binary>(
|
|
2
|
+
itemHandler: {
|
|
3
|
+
serialize: (value: Input, params: unknown) => Binary;
|
|
4
|
+
deserialize: (value: Binary, params: unknown) => Output;
|
|
5
|
+
},
|
|
6
|
+
): {
|
|
7
|
+
serialize: (value: Input[], params: unknown) => Binary[];
|
|
8
|
+
deserialize: (value: Binary[], params: unknown) => Output[];
|
|
9
|
+
} {
|
|
10
|
+
return {
|
|
11
|
+
serialize(items, params) {
|
|
12
|
+
return items.map((item) => itemHandler.serialize(item, params));
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
deserialize(buffers, params) {
|
|
16
|
+
return buffers.map((buffer) => itemHandler.deserialize(buffer, params));
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants';
|
|
2
|
+
|
|
3
|
+
// First abi/vm by default
|
|
4
|
+
export const ProtocolToVmAbi = {
|
|
5
|
+
[ConsensusProtocolVersion.Iris]: {
|
|
6
|
+
'contract-create': {
|
|
7
|
+
vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],
|
|
8
|
+
},
|
|
9
|
+
// TODO: Ensure that AEVM (Sophia?) is still available here
|
|
10
|
+
'contract-call': {
|
|
11
|
+
vmVersion: [], abiVersion: [AbiVersion.Fate, AbiVersion.Sophia],
|
|
12
|
+
},
|
|
13
|
+
'oracle-call': {
|
|
14
|
+
vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Sophia],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
export interface CtVersion {
|
|
20
|
+
vmVersion: VmVersion;
|
|
21
|
+
abiVersion: AbiVersion;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getProtocolDetails(
|
|
25
|
+
protocolVersion: ConsensusProtocolVersion,
|
|
26
|
+
type: 'contract-create' | 'contract-call' | 'oracle-call',
|
|
27
|
+
): CtVersion {
|
|
28
|
+
const protocol = ProtocolToVmAbi[protocolVersion][type];
|
|
29
|
+
return {
|
|
30
|
+
vmVersion: protocol.vmVersion[0] ?? VmVersion.Fate2,
|
|
31
|
+
abiVersion: protocol.abiVersion[0],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
serialize(
|
|
37
|
+
value: CtVersion | undefined,
|
|
38
|
+
{ consensusProtocolVersion = ConsensusProtocolVersion.Iris }:
|
|
39
|
+
{ consensusProtocolVersion: ConsensusProtocolVersion },
|
|
40
|
+
): Buffer {
|
|
41
|
+
value ??= getProtocolDetails(consensusProtocolVersion, 'contract-create');
|
|
42
|
+
|
|
43
|
+
return Buffer.from([value.vmVersion, 0, value.abiVersion]);
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
deserialize(buffer: Buffer): CtVersion {
|
|
47
|
+
const [vm, , abi] = buffer;
|
|
48
|
+
return { vmVersion: +vm, abiVersion: +abi };
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
decode, encode, Encoded, Encoding,
|
|
3
|
+
} from '../../../utils/encoder';
|
|
4
|
+
import { ArgumentError } from '../../../utils/errors';
|
|
5
|
+
|
|
6
|
+
export default function genEncodedField<E extends Encoding, Optional extends boolean = false>(
|
|
7
|
+
encoding: E,
|
|
8
|
+
optional?: Optional,
|
|
9
|
+
): {
|
|
10
|
+
serialize: Optional extends true
|
|
11
|
+
? (value?: Encoded.Generic<E>) => Buffer : (value: Encoded.Generic<E>) => Buffer;
|
|
12
|
+
deserialize: (value: Buffer) => Encoded.Generic<Encoding>;
|
|
13
|
+
} {
|
|
14
|
+
return {
|
|
15
|
+
serialize(encodedData?: Encoded.Generic<E>) {
|
|
16
|
+
if (encodedData == null) {
|
|
17
|
+
if (optional === true) return Buffer.from([]);
|
|
18
|
+
throw new ArgumentError('Encoded data', 'provided', encodedData);
|
|
19
|
+
}
|
|
20
|
+
return decode(encodedData);
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
deserialize(buffer) {
|
|
24
|
+
return encode(buffer, encoding);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { decode, encode, Encoding } from '../../../utils/encoder';
|
|
2
|
+
import { Tag } from '../constants';
|
|
3
|
+
import { ArgumentError } from '../../../utils/errors';
|
|
4
|
+
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
5
|
+
|
|
6
|
+
export default function genEntryField<T extends Tag = Tag>(tag?: T): {
|
|
7
|
+
serialize: (
|
|
8
|
+
// TODO: replace with `Parameters<typeof buildTxType<T>>[0]`,
|
|
9
|
+
// but fix TS2502 value is referenced directly or indirectly in its own type annotation
|
|
10
|
+
value: any,
|
|
11
|
+
options: { buildTx: typeof buildTxType },
|
|
12
|
+
) => Buffer;
|
|
13
|
+
deserialize: (
|
|
14
|
+
value: Buffer, options: { unpackTx: typeof unpackTxType },
|
|
15
|
+
// TODO: replace with `ReturnType<typeof unpackTxType<T>>`,
|
|
16
|
+
// TS2577 Return type annotation circularly references itself
|
|
17
|
+
) => any;
|
|
18
|
+
} {
|
|
19
|
+
return {
|
|
20
|
+
serialize(txParams, { buildTx }) {
|
|
21
|
+
if (ArrayBuffer.isView(txParams)) return Buffer.from(txParams as any);
|
|
22
|
+
return decode(buildTx({ ...txParams, ...tag != null && { tag } }));
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
deserialize(buf, { unpackTx }) {
|
|
26
|
+
const tx = unpackTx(encode(buf, Encoding.Transaction));
|
|
27
|
+
if (tag != null && tx.tag !== tag) throw new ArgumentError('Tag', tag, tx.tag);
|
|
28
|
+
return tx;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { ArgumentError } from '../../../utils/errors';
|
|
2
|
+
import { isItemOfArray } from '../../../utils/other';
|
|
2
3
|
|
|
3
|
-
export default function genEnumerationField<
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export default function genEnumerationField<
|
|
5
|
+
Enum extends { [key: string]: number | string },
|
|
6
|
+
>(enm: Enum): {
|
|
7
|
+
serialize: (value: Enum[keyof Enum]) => Buffer;
|
|
8
|
+
deserialize: (value: Buffer) => Enum[keyof Enum];
|
|
6
9
|
} {
|
|
10
|
+
const values = Object.values(enm).filter((v) => typeof v === 'number');
|
|
7
11
|
return {
|
|
8
12
|
serialize(value) {
|
|
9
13
|
if (typeof value !== 'number') throw new ArgumentError('value', 'to be a number', value);
|
|
10
14
|
if (value > 0xff) throw new ArgumentError('value', 'to be less than 256', value);
|
|
15
|
+
if (!isItemOfArray(value, values)) {
|
|
16
|
+
throw new ArgumentError('value', 'to be a value of Enum', value);
|
|
17
|
+
}
|
|
11
18
|
return Buffer.from([value]);
|
|
12
19
|
},
|
|
13
20
|
|
|
@@ -15,7 +22,11 @@ export default function genEnumerationField<Enum extends number>(): {
|
|
|
15
22
|
if (buffer.length !== 1) {
|
|
16
23
|
throw new ArgumentError('buffer', 'to have single element', buffer.length);
|
|
17
24
|
}
|
|
18
|
-
|
|
25
|
+
const value = buffer[0];
|
|
26
|
+
if (!isItemOfArray(value, values)) {
|
|
27
|
+
throw new ArgumentError('value', 'to be a value of Enum', value);
|
|
28
|
+
}
|
|
29
|
+
return value as Enum[keyof Enum];
|
|
19
30
|
},
|
|
20
31
|
};
|
|
21
32
|
}
|
|
@@ -3,6 +3,8 @@ import { IllegalArgumentError } from '../../../utils/errors';
|
|
|
3
3
|
import { MIN_GAS_PRICE, Tag } from '../constants';
|
|
4
4
|
import coinAmount from './coin-amount';
|
|
5
5
|
import { isKeyOfObject } from '../../../utils/other';
|
|
6
|
+
import { decode, Encoded } from '../../../utils/encoder';
|
|
7
|
+
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
6
8
|
|
|
7
9
|
const BASE_GAS = 15000;
|
|
8
10
|
const GAS_PER_BYTE = 20;
|
|
@@ -75,7 +77,7 @@ const TX_FEE_OTHER_GAS = (
|
|
|
75
77
|
}
|
|
76
78
|
};
|
|
77
79
|
|
|
78
|
-
function getOracleRelativeTtl(params: any
|
|
80
|
+
function getOracleRelativeTtl(params: any): number {
|
|
79
81
|
const ttlKeys = {
|
|
80
82
|
[Tag.OracleRegisterTx]: 'oracleTtlValue',
|
|
81
83
|
[Tag.OracleExtendTx]: 'oracleTtlValue',
|
|
@@ -83,21 +85,27 @@ function getOracleRelativeTtl(params: any, txType: Tag): number {
|
|
|
83
85
|
[Tag.OracleResponseTx]: 'responseTtlValue',
|
|
84
86
|
} as const;
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
+
const { tag } = params;
|
|
89
|
+
if (!isKeyOfObject(tag, ttlKeys)) return 1;
|
|
90
|
+
return params[ttlKeys[tag]];
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
/**
|
|
91
94
|
* Calculate fee based on tx type and params
|
|
92
95
|
*/
|
|
93
|
-
export function buildFee(
|
|
94
|
-
|
|
96
|
+
export function buildFee(
|
|
97
|
+
builtTx: Encoded.Transaction,
|
|
98
|
+
unpackTx: typeof unpackTxType,
|
|
99
|
+
buildTx: typeof buildTxType,
|
|
100
|
+
): BigNumber {
|
|
101
|
+
const { length } = decode(builtTx);
|
|
102
|
+
const txObject = unpackTx(builtTx);
|
|
95
103
|
|
|
96
|
-
return TX_FEE_BASE_GAS(
|
|
97
|
-
.plus(TX_FEE_OTHER_GAS(
|
|
98
|
-
relativeTtl: getOracleRelativeTtl(txObject
|
|
99
|
-
innerTxSize:
|
|
100
|
-
? txObject.tx.
|
|
104
|
+
return TX_FEE_BASE_GAS(txObject.tag)
|
|
105
|
+
.plus(TX_FEE_OTHER_GAS(txObject.tag, length, {
|
|
106
|
+
relativeTtl: getOracleRelativeTtl(txObject),
|
|
107
|
+
innerTxSize: txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx
|
|
108
|
+
? decode(buildTx(txObject.tx.encodedTx)).length
|
|
101
109
|
: 0,
|
|
102
110
|
}))
|
|
103
111
|
.times(MIN_GAS_PRICE);
|
|
@@ -106,18 +114,18 @@ export function buildFee(txType: Tag, buildTx: any): BigNumber {
|
|
|
106
114
|
/**
|
|
107
115
|
* Calculate min fee
|
|
108
116
|
* @category transaction builder
|
|
109
|
-
* @param txType - Transaction type
|
|
110
117
|
* @param rebuildTx - Callback to get built transaction with specific fee
|
|
111
118
|
*/
|
|
112
119
|
function calculateMinFee(
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
rebuildTx: (value: BigNumber) => Encoded.Transaction,
|
|
121
|
+
unpackTx: typeof unpackTxType,
|
|
122
|
+
buildTx: typeof buildTxType,
|
|
115
123
|
): BigNumber {
|
|
116
124
|
let fee = new BigNumber(0);
|
|
117
125
|
let previousFee;
|
|
118
126
|
do {
|
|
119
127
|
previousFee = fee;
|
|
120
|
-
fee = buildFee(
|
|
128
|
+
fee = buildFee(rebuildTx(fee), unpackTx, buildTx);
|
|
121
129
|
} while (!fee.eq(previousFee));
|
|
122
130
|
return fee;
|
|
123
131
|
}
|
|
@@ -127,13 +135,25 @@ export default {
|
|
|
127
135
|
|
|
128
136
|
serializeAettos(
|
|
129
137
|
_value: string | undefined,
|
|
130
|
-
{
|
|
131
|
-
|
|
138
|
+
{
|
|
139
|
+
rebuildTx, unpackTx, buildTx, _computingMinFee, _pickBiggerFee,
|
|
140
|
+
}: {
|
|
141
|
+
rebuildTx: (params: any) => Encoded.Transaction;
|
|
142
|
+
unpackTx: typeof unpackTxType;
|
|
143
|
+
buildTx: typeof buildTxType;
|
|
144
|
+
_computingMinFee?: BigNumber;
|
|
145
|
+
_pickBiggerFee?: boolean;
|
|
146
|
+
},
|
|
132
147
|
): string {
|
|
133
|
-
if (_computingMinFee != null) return _computingMinFee;
|
|
134
|
-
const minFee = calculateMinFee(
|
|
148
|
+
if (_computingMinFee != null) return _computingMinFee.toFixed();
|
|
149
|
+
const minFee = calculateMinFee(
|
|
150
|
+
(fee) => rebuildTx({ _computingMinFee: fee }),
|
|
151
|
+
unpackTx,
|
|
152
|
+
buildTx,
|
|
153
|
+
);
|
|
135
154
|
const value = new BigNumber(_value ?? minFee);
|
|
136
155
|
if (minFee.gt(value)) {
|
|
156
|
+
if (_pickBiggerFee === true) return minFee.toFixed();
|
|
137
157
|
throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);
|
|
138
158
|
}
|
|
139
159
|
return value.toFixed();
|
|
@@ -2,13 +2,15 @@ import { IllegalArgumentError } from '../../../utils/errors';
|
|
|
2
2
|
import { MIN_GAS_PRICE, Tag, MAX_AUTH_FUN_GAS } from '../constants';
|
|
3
3
|
import shortUInt from './short-u-int';
|
|
4
4
|
import { buildFee } from './fee';
|
|
5
|
+
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
|
|
5
6
|
|
|
6
7
|
function calculateGasLimitMax(
|
|
7
|
-
txType: Tag,
|
|
8
8
|
gasMax: number,
|
|
9
9
|
rebuildTx: (value: number) => any,
|
|
10
|
+
unpackTx: typeof unpackTxType,
|
|
11
|
+
buildTx: typeof buildTxType,
|
|
10
12
|
): number {
|
|
11
|
-
return gasMax - +buildFee(
|
|
13
|
+
return gasMax - +buildFee(rebuildTx(gasMax), unpackTx, buildTx).dividedBy(MIN_GAS_PRICE);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export default {
|
|
@@ -17,20 +19,23 @@ export default {
|
|
|
17
19
|
serialize(
|
|
18
20
|
_value: number | undefined,
|
|
19
21
|
{
|
|
20
|
-
|
|
22
|
+
tag, rebuildTx, unpackTx, buildTx, gasMax = 6e6, _computingGasLimit,
|
|
21
23
|
}: {
|
|
22
|
-
|
|
24
|
+
tag: Tag;
|
|
23
25
|
rebuildTx: (params: any) => any;
|
|
26
|
+
unpackTx: typeof unpackTxType;
|
|
27
|
+
buildTx: typeof buildTxType;
|
|
24
28
|
gasMax: number;
|
|
25
29
|
_computingGasLimit?: number;
|
|
26
30
|
},
|
|
27
31
|
): Buffer {
|
|
28
32
|
if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);
|
|
29
33
|
|
|
30
|
-
const gasLimitMax =
|
|
31
|
-
txType,
|
|
34
|
+
const gasLimitMax = tag === Tag.GaMetaTx ? MAX_AUTH_FUN_GAS : calculateGasLimitMax(
|
|
32
35
|
gasMax,
|
|
33
|
-
(gasLimit) => rebuildTx({ _computingGasLimit: gasLimit }),
|
|
36
|
+
(gasLimit) => rebuildTx({ _computingGasLimit: gasLimit, _pickBiggerFee: true }),
|
|
37
|
+
unpackTx,
|
|
38
|
+
buildTx,
|
|
34
39
|
);
|
|
35
40
|
const value = _value ?? gasLimitMax;
|
|
36
41
|
if (value > gasLimitMax) {
|
|
@@ -1,55 +1,84 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _uInt from './u-int';
|
|
3
|
-
import _shortUInt from './short-u-int';
|
|
4
|
-
import _coinAmount from './coin-amount';
|
|
1
|
+
import _abiVersion from './abi-version';
|
|
5
2
|
import _address from './address';
|
|
6
|
-
import
|
|
3
|
+
import _array from './array';
|
|
4
|
+
import _boolean from './boolean';
|
|
5
|
+
import _coinAmount from './coin-amount';
|
|
6
|
+
import _ctVersion from './ct-version';
|
|
7
7
|
import _deposit from './deposit';
|
|
8
|
+
import _encoded from './encoded';
|
|
9
|
+
import _entry from './entry';
|
|
8
10
|
import _enumeration from './enumeration';
|
|
9
11
|
import _fee from './fee';
|
|
12
|
+
import _field from './field';
|
|
10
13
|
import _gasLimit from './gas-limit';
|
|
11
14
|
import _gasPrice from './gas-price';
|
|
15
|
+
import _mptree from './mptree';
|
|
12
16
|
import _name from './name';
|
|
13
17
|
import _nameFee from './name-fee';
|
|
14
18
|
import _nameId from './name-id';
|
|
15
19
|
import _pointers from './pointers';
|
|
20
|
+
import _raw from './raw';
|
|
21
|
+
import _shortUInt from './short-u-int';
|
|
22
|
+
import _shortUIntConst from './short-u-int-const';
|
|
23
|
+
import _string from './string';
|
|
24
|
+
import _uInt from './u-int';
|
|
16
25
|
|
|
17
26
|
// TODO: remove after fixing https://github.com/Gerrit0/typedoc-plugin-missing-exports/issues/15
|
|
18
|
-
const
|
|
19
|
-
const uInt = _uInt;
|
|
20
|
-
const shortUInt = _shortUInt;
|
|
21
|
-
const coinAmount = _coinAmount;
|
|
27
|
+
const abiVersion = _abiVersion;
|
|
22
28
|
const address = _address;
|
|
23
|
-
const
|
|
29
|
+
const array = _array;
|
|
30
|
+
const boolean = _boolean;
|
|
31
|
+
const coinAmount = _coinAmount;
|
|
32
|
+
const ctVersion = _ctVersion;
|
|
24
33
|
const deposit = _deposit;
|
|
34
|
+
const encoded = _encoded;
|
|
35
|
+
const entry = _entry;
|
|
25
36
|
const enumeration = _enumeration;
|
|
26
37
|
const fee = _fee;
|
|
38
|
+
const field = _field;
|
|
27
39
|
const gasLimit = _gasLimit;
|
|
28
40
|
const gasPrice = _gasPrice;
|
|
41
|
+
const mptree = _mptree;
|
|
29
42
|
const name = _name;
|
|
30
43
|
const nameFee = _nameFee;
|
|
31
44
|
const nameId = _nameId;
|
|
32
45
|
const pointers = _pointers;
|
|
46
|
+
const raw = _raw;
|
|
47
|
+
const shortUInt = _shortUInt;
|
|
48
|
+
const shortUIntConst = _shortUIntConst;
|
|
49
|
+
const string = _string;
|
|
50
|
+
const uInt = _uInt;
|
|
33
51
|
|
|
52
|
+
export type BinaryData = Buffer | Buffer[] | Buffer[][]
|
|
53
|
+
| Array<[Buffer, Array<[Buffer, Buffer[]]>]>;
|
|
34
54
|
export interface Field {
|
|
35
|
-
serialize: (value: any, options: any) =>
|
|
36
|
-
deserialize: (value:
|
|
55
|
+
serialize: (value: any, options: any) => BinaryData;
|
|
56
|
+
deserialize: (value: BinaryData, options: any) => any;
|
|
37
57
|
}
|
|
38
58
|
|
|
39
59
|
export {
|
|
40
|
-
|
|
41
|
-
uInt,
|
|
42
|
-
shortUInt,
|
|
43
|
-
coinAmount,
|
|
60
|
+
abiVersion,
|
|
44
61
|
address,
|
|
45
|
-
|
|
62
|
+
array,
|
|
63
|
+
boolean,
|
|
64
|
+
coinAmount,
|
|
65
|
+
ctVersion,
|
|
46
66
|
deposit,
|
|
67
|
+
encoded,
|
|
68
|
+
entry,
|
|
47
69
|
enumeration,
|
|
48
70
|
fee,
|
|
71
|
+
field,
|
|
49
72
|
gasLimit,
|
|
50
73
|
gasPrice,
|
|
74
|
+
mptree,
|
|
51
75
|
name,
|
|
52
76
|
nameFee,
|
|
53
77
|
nameId,
|
|
54
78
|
pointers,
|
|
79
|
+
raw,
|
|
80
|
+
shortUInt,
|
|
81
|
+
shortUIntConst,
|
|
82
|
+
string,
|
|
83
|
+
uInt,
|
|
55
84
|
};
|