@aeternity/aepp-sdk 12.0.0 → 12.1.2
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/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -15
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +2 -1
- package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +20765 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/AeSdk.d.ts +7 -7
- package/es/AeSdk.mjs.map +1 -1
- package/es/AeSdkAepp.d.ts +4 -3
- package/es/AeSdkAepp.mjs +2 -1
- package/es/AeSdkAepp.mjs.map +1 -1
- package/es/AeSdkBase.d.ts +22 -21
- package/es/AeSdkBase.mjs +25 -21
- package/es/AeSdkBase.mjs.map +1 -1
- package/es/AeSdkWallet.d.ts +4 -3
- package/es/AeSdkWallet.mjs +5 -1
- package/es/AeSdkWallet.mjs.map +1 -1
- package/es/Node.d.ts +7 -10
- package/es/Node.mjs +63 -57
- package/es/Node.mjs.map +1 -1
- package/es/account/Base.d.ts +7 -4
- package/es/account/Base.mjs +3 -3
- package/es/account/Base.mjs.map +1 -1
- package/es/account/Memory.d.ts +5 -4
- package/es/account/Memory.mjs +24 -2
- package/es/account/Memory.mjs.map +1 -1
- package/es/account/Rpc.d.ts +6 -6
- package/es/account/Rpc.mjs +3 -2
- package/es/account/Rpc.mjs.map +1 -1
- package/es/aens.d.ts +27 -14
- package/es/aens.mjs +27 -21
- package/es/aens.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/Browser.d.ts +2 -1
- package/es/aepp-wallet-communication/connection/Browser.mjs +5 -2
- 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 +1 -0
- package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -0
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +5 -1
- package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
- package/es/aepp-wallet-communication/connection-proxy.d.ts +1 -0
- package/es/aepp-wallet-communication/connection-proxy.mjs +1 -0
- package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +1 -0
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -5
- package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
- package/es/aepp-wallet-communication/rpc/types.d.ts +8 -8
- package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
- package/es/aepp-wallet-communication/schema.d.ts +17 -2
- package/es/aepp-wallet-communication/schema.mjs +54 -17
- package/es/aepp-wallet-communication/schema.mjs.map +1 -1
- package/es/aepp-wallet-communication/wallet-detector.d.ts +2 -1
- package/es/aepp-wallet-communication/wallet-detector.mjs +2 -3
- package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
- package/es/apis/node/models/index.d.ts +6 -2
- package/es/apis/node/models/index.mjs.map +1 -1
- package/es/apis/node/models/mappers.mjs +4 -2
- package/es/apis/node/models/mappers.mjs.map +1 -1
- package/es/chain.d.ts +92 -64
- package/es/chain.mjs +190 -154
- package/es/chain.mjs.map +1 -1
- package/es/channel/handlers.d.ts +3 -3
- package/es/channel/handlers.mjs +42 -44
- package/es/channel/handlers.mjs.map +1 -1
- package/es/channel/index.d.ts +43 -52
- package/es/channel/index.mjs +46 -49
- package/es/channel/index.mjs.map +1 -1
- package/es/channel/internal.d.ts +16 -15
- package/es/channel/internal.mjs +67 -62
- package/es/channel/internal.mjs.map +1 -1
- package/es/contract/Compiler.d.ts +1 -0
- package/es/contract/Compiler.mjs +5 -4
- package/es/contract/Compiler.mjs.map +1 -1
- package/es/contract/aci.d.ts +17 -15
- package/es/contract/aci.mjs +58 -45
- package/es/contract/aci.mjs.map +1 -1
- package/es/contract/ga.d.ts +16 -15
- package/es/contract/ga.mjs +12 -7
- package/es/contract/ga.mjs.map +1 -1
- package/es/contract/methods.d.ts +9 -6
- package/es/contract/methods.mjs +9 -6
- package/es/contract/methods.mjs.map +1 -1
- package/es/deprecated/index.d.ts +143 -0
- package/es/deprecated/index.mjs +162 -0
- package/es/deprecated/index.mjs.map +1 -0
- package/es/deprecated/methods.d.ts +18 -0
- package/es/deprecated/methods.mjs +26 -0
- package/es/deprecated/methods.mjs.map +1 -0
- package/es/index.d.ts +4 -1
- package/es/index.mjs +4 -1
- package/es/index.mjs.map +1 -1
- package/es/oracle.d.ts +69 -62
- package/es/oracle.mjs +121 -103
- package/es/oracle.mjs.map +1 -1
- package/es/spend.d.ts +16 -15
- package/es/spend.mjs +19 -30
- package/es/spend.mjs.map +1 -1
- package/es/tx/builder/address.d.ts +25 -0
- package/es/tx/builder/address.mjs +45 -0
- package/es/tx/builder/address.mjs.map +1 -0
- package/es/tx/builder/constants.d.ts +55 -26
- package/es/tx/builder/constants.mjs +60 -38
- package/es/tx/builder/constants.mjs.map +1 -1
- package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
- package/es/tx/builder/field-types/coin-amount.mjs +26 -0
- package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
- package/es/tx/builder/field-types/deposit.d.ts +15 -0
- package/es/tx/builder/field-types/deposit.mjs +19 -0
- package/es/tx/builder/field-types/deposit.mjs.map +1 -0
- package/es/tx/builder/field-types/fee.d.ts +25 -0
- package/es/tx/{min-fee.mjs → builder/field-types/fee.mjs} +62 -60
- package/es/tx/builder/field-types/fee.mjs.map +1 -0
- package/es/tx/builder/field-types/field.d.ts +6 -0
- package/es/tx/builder/field-types/field.mjs +15 -0
- package/es/tx/builder/field-types/field.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
- package/es/tx/builder/field-types/gas-limit.mjs +33 -0
- package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
- package/es/tx/builder/field-types/gas-price.d.ts +8 -0
- package/es/tx/builder/field-types/gas-price.mjs +18 -0
- package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
- package/es/tx/builder/field-types/index.d.ts +70 -0
- package/es/tx/builder/field-types/index.mjs +25 -0
- package/es/tx/builder/field-types/index.mjs.map +1 -0
- package/es/tx/builder/field-types/name-fee.d.ts +20 -0
- package/es/tx/builder/field-types/name-fee.mjs +24 -0
- package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
- package/es/tx/builder/field-types/name-id.d.ts +14 -0
- package/es/tx/builder/field-types/name-id.mjs +19 -0
- package/es/tx/builder/field-types/name-id.mjs.map +1 -0
- package/es/tx/builder/field-types/name.d.ts +13 -0
- package/es/tx/builder/field-types/name.mjs +18 -0
- package/es/tx/builder/field-types/name.mjs.map +1 -0
- package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
- package/es/tx/builder/field-types/short-u-int.mjs +12 -0
- package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
- package/es/tx/builder/field-types/u-int.d.ts +8 -0
- package/es/tx/builder/field-types/u-int.mjs +14 -0
- package/es/tx/builder/field-types/u-int.mjs.map +1 -0
- package/es/tx/builder/helpers.d.ts +27 -33
- package/es/tx/builder/helpers.mjs +41 -47
- package/es/tx/builder/helpers.mjs.map +1 -1
- package/es/tx/builder/index.d.ts +25 -12
- package/es/tx/builder/index.mjs +74 -83
- package/es/tx/builder/index.mjs.map +1 -1
- package/es/tx/builder/schema.d.ts +995 -144
- package/es/tx/builder/schema.mjs +121 -170
- package/es/tx/builder/schema.mjs.map +1 -1
- package/es/tx/index.d.ts +28 -27
- package/es/tx/index.mjs +97 -117
- package/es/tx/index.mjs.map +1 -1
- package/es/tx/validator.d.ts +4 -3
- package/es/tx/validator.mjs +79 -92
- package/es/tx/validator.mjs.map +1 -1
- package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -1
- package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -1
- package/es/typings/bip32-path/index.d.mjs.map +1 -1
- package/es/typings/blakejs/index.d.mjs.map +1 -1
- package/es/typings/sha-js/index.d.mjs +2 -0
- package/es/typings/sha-js/index.d.mjs.map +1 -0
- package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -1
- package/es/utils/amount-formatter.d.ts +9 -9
- package/es/utils/amount-formatter.mjs +17 -17
- package/es/utils/amount-formatter.mjs.map +1 -1
- package/es/utils/autorest.mjs +7 -7
- package/es/utils/autorest.mjs.map +1 -1
- package/es/utils/bignumber.mjs +2 -1
- package/es/utils/bignumber.mjs.map +1 -1
- package/es/utils/bytes.mjs +1 -1
- package/es/utils/bytes.mjs.map +1 -1
- package/es/utils/crypto.d.ts +8 -23
- package/es/utils/crypto.mjs +15 -41
- package/es/utils/crypto.mjs.map +1 -1
- package/es/utils/encoder-types.d.ts +61 -0
- package/es/utils/encoder-types.mjs +36 -0
- package/es/utils/encoder-types.mjs.map +1 -0
- package/es/utils/encoder.d.ts +6 -7
- package/es/utils/encoder.mjs +42 -26
- package/es/utils/encoder.mjs.map +1 -1
- package/es/utils/errors.d.ts +1 -11
- package/es/utils/errors.mjs +4 -20
- package/es/utils/errors.mjs.map +1 -1
- package/es/utils/hd-wallet.d.ts +18 -2
- package/es/utils/hd-wallet.mjs +64 -34
- package/es/utils/hd-wallet.mjs.map +1 -1
- package/es/utils/json-big.mjs +2 -2
- package/es/utils/json-big.mjs.map +1 -1
- package/es/utils/keystore.mjs +4 -2
- package/es/utils/keystore.mjs.map +1 -1
- package/es/utils/mptree.d.ts +2 -2
- package/es/utils/mptree.mjs +11 -6
- package/es/utils/mptree.mjs.map +1 -1
- package/es/utils/other.d.ts +8 -2
- package/es/utils/other.mjs +15 -3
- package/es/utils/other.mjs.map +1 -1
- package/es/utils/semver-satisfies.d.ts +1 -1
- package/es/utils/semver-satisfies.mjs +2 -2
- package/es/utils/semver-satisfies.mjs.map +1 -1
- package/es/utils/string.mjs.map +1 -1
- package/package.json +36 -34
- package/src/AeSdk.ts +30 -27
- package/src/AeSdkAepp.ts +93 -84
- package/src/AeSdkBase.ts +148 -130
- package/src/AeSdkWallet.ts +172 -156
- package/src/Node.ts +108 -102
- package/src/account/Base.ts +42 -32
- package/src/account/Memory.ts +45 -30
- package/src/account/Rpc.ts +32 -30
- package/src/aens.ts +124 -108
- package/src/aepp-wallet-communication/connection/Browser.ts +18 -15
- package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +22 -21
- package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +63 -52
- package/src/aepp-wallet-communication/connection-proxy.ts +8 -7
- package/src/aepp-wallet-communication/rpc/RpcClient.ts +67 -61
- package/src/aepp-wallet-communication/rpc/types.ts +32 -32
- package/src/aepp-wallet-communication/schema.ts +117 -74
- package/src/aepp-wallet-communication/wallet-detector.ts +29 -28
- package/src/apis/node/code-model-v4.yaml +54 -20
- package/src/apis/node/models/index.ts +6 -2
- package/src/apis/node/models/mappers.ts +4 -2
- package/src/chain.ts +286 -228
- package/src/channel/handlers.ts +424 -372
- package/src/channel/index.ts +285 -251
- package/src/channel/internal.ts +248 -232
- package/src/contract/Compiler.ts +22 -21
- package/src/contract/aci.ts +267 -258
- package/src/contract/ga.ts +93 -72
- package/src/contract/methods.ts +32 -27
- package/src/deprecated/index.ts +172 -0
- package/src/deprecated/methods.ts +25 -0
- package/src/index.ts +37 -32
- package/src/oracle.ts +211 -189
- package/src/spend.ts +82 -70
- package/src/tx/builder/address.ts +50 -0
- package/src/tx/builder/constants.ts +82 -52
- package/src/tx/builder/field-types/coin-amount.ts +27 -0
- package/src/tx/builder/field-types/deposit.ts +21 -0
- package/src/tx/builder/field-types/fee.ts +143 -0
- package/src/tx/builder/field-types/field.ts +9 -0
- package/src/tx/builder/field-types/gas-limit.ts +41 -0
- package/src/tx/builder/field-types/gas-price.ts +16 -0
- package/src/tx/builder/field-types/index.ts +45 -0
- package/src/tx/builder/field-types/name-fee.ts +32 -0
- package/src/tx/builder/field-types/name-id.ts +20 -0
- package/src/tx/builder/field-types/name.ts +18 -0
- package/src/tx/builder/field-types/short-u-int.ts +11 -0
- package/src/tx/builder/field-types/u-int.ts +16 -0
- package/src/tx/builder/helpers.ts +112 -117
- package/src/tx/builder/index.ts +203 -197
- package/src/tx/builder/schema.ts +421 -465
- package/src/tx/index.ts +128 -135
- package/src/tx/validator.ts +165 -161
- package/src/typings/@aeternity__argon2-browser/index.d.ts +1 -1
- package/src/typings/@aeternity__uuid/index.d.ts +3 -1
- package/src/typings/bip32-path/index.d.ts +6 -6
- package/src/typings/blakejs/index.d.ts +4 -32
- package/src/typings/sha-js/index.d.ts +5 -0
- package/src/typings/tweetnacl-auth/index.d.ts +2 -2
- package/src/utils/amount-formatter.ts +41 -41
- package/src/utils/autorest.ts +57 -54
- package/src/utils/bignumber.ts +7 -6
- package/src/utils/bytes.ts +19 -19
- package/src/utils/crypto.ts +82 -94
- package/src/utils/encoder-types.ts +63 -0
- package/src/utils/encoder.ts +104 -56
- package/src/utils/errors.ts +246 -264
- package/src/utils/hd-wallet.ts +114 -82
- package/src/utils/json-big.ts +16 -15
- package/src/utils/keystore.ts +65 -62
- package/src/utils/mptree.ts +59 -56
- package/src/utils/other.ts +26 -18
- package/src/utils/semver-satisfies.ts +15 -11
- package/src/utils/string.ts +10 -10
- package/es/tx/builder/field-types.d.ts +0 -62
- package/es/tx/builder/field-types.mjs +0 -126
- package/es/tx/builder/field-types.mjs.map +0 -1
- package/es/tx/min-fee.d.ts +0 -20
- package/es/tx/min-fee.mjs.map +0 -1
- package/src/tx/builder/field-types.ts +0 -111
- package/src/tx/min-fee.ts +0 -136
|
@@ -20,18 +20,10 @@ export const NAME_BID_TIMEOUT_BLOCKS = 480; // # ~1 day
|
|
|
20
20
|
|
|
21
21
|
export const NAME_MAX_LENGTH_FEE = 31;
|
|
22
22
|
export const NAME_BID_MAX_LENGTH = 12; // # this is the max length for a domain to be part of a bid
|
|
23
|
-
|
|
24
|
-
export let POINTER_KEY_BY_PREFIX; // # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290
|
|
23
|
+
// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290
|
|
25
24
|
// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times
|
|
26
25
|
// # bid ranges:
|
|
27
26
|
|
|
28
|
-
(function (POINTER_KEY_BY_PREFIX) {
|
|
29
|
-
POINTER_KEY_BY_PREFIX["ak"] = "account_pubkey";
|
|
30
|
-
POINTER_KEY_BY_PREFIX["ok"] = "oracle_pubkey";
|
|
31
|
-
POINTER_KEY_BY_PREFIX["ct"] = "contract_pubkey";
|
|
32
|
-
POINTER_KEY_BY_PREFIX["ch"] = "channel";
|
|
33
|
-
})(POINTER_KEY_BY_PREFIX || (POINTER_KEY_BY_PREFIX = {}));
|
|
34
|
-
|
|
35
27
|
export const NAME_BID_RANGES = mapObject({
|
|
36
28
|
31: 3,
|
|
37
29
|
30: 5,
|
|
@@ -67,34 +59,64 @@ export const NAME_BID_RANGES = mapObject({
|
|
|
67
59
|
}, _ref => {
|
|
68
60
|
let [key, value] = _ref;
|
|
69
61
|
return [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)];
|
|
70
|
-
}); // # Tag constant for ids (type uint8)
|
|
71
|
-
// # see https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type
|
|
72
|
-
// # <<Tag:1/unsigned-integer-unit:8, Hash:32/binary-unit:8>>
|
|
73
|
-
|
|
74
|
-
const ID_TAG_ACCOUNT = 1;
|
|
75
|
-
const ID_TAG_NAME = 2;
|
|
76
|
-
const ID_TAG_COMMITMENT = 3;
|
|
77
|
-
const ID_TAG_ORACLE = 4;
|
|
78
|
-
const ID_TAG_CONTRACT = 5;
|
|
79
|
-
const ID_TAG_CHANNEL = 6;
|
|
80
|
-
export const ID_TAG = {
|
|
81
|
-
account: ID_TAG_ACCOUNT,
|
|
82
|
-
name: ID_TAG_NAME,
|
|
83
|
-
commitment: ID_TAG_COMMITMENT,
|
|
84
|
-
oracle: ID_TAG_ORACLE,
|
|
85
|
-
contract: ID_TAG_CONTRACT,
|
|
86
|
-
channel: ID_TAG_CHANNEL
|
|
87
|
-
};
|
|
88
|
-
export const PREFIX_ID_TAG = {
|
|
89
|
-
ak: ID_TAG.account,
|
|
90
|
-
nm: ID_TAG.name,
|
|
91
|
-
cm: ID_TAG.commitment,
|
|
92
|
-
ok: ID_TAG.oracle,
|
|
93
|
-
ct: ID_TAG.contract,
|
|
94
|
-
ch: ID_TAG.channel
|
|
95
|
-
};
|
|
96
|
-
export const ID_TAG_PREFIX = mapObject(PREFIX_ID_TAG, _ref2 => {
|
|
97
|
-
let [key, value] = _ref2;
|
|
98
|
-
return [value, key];
|
|
99
62
|
});
|
|
63
|
+
/**
|
|
64
|
+
* Enum with tag types
|
|
65
|
+
* @category transaction builder
|
|
66
|
+
* @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}
|
|
67
|
+
* @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}
|
|
68
|
+
*/
|
|
69
|
+
// TODO: implement serialisation for commented-out tags
|
|
70
|
+
|
|
71
|
+
export let Tag;
|
|
72
|
+
|
|
73
|
+
(function (Tag) {
|
|
74
|
+
Tag[Tag["Account"] = 10] = "Account";
|
|
75
|
+
Tag[Tag["SignedTx"] = 11] = "SignedTx";
|
|
76
|
+
Tag[Tag["SpendTx"] = 12] = "SpendTx";
|
|
77
|
+
Tag[Tag["OracleRegisterTx"] = 22] = "OracleRegisterTx";
|
|
78
|
+
Tag[Tag["OracleQueryTx"] = 23] = "OracleQueryTx";
|
|
79
|
+
Tag[Tag["OracleResponseTx"] = 24] = "OracleResponseTx";
|
|
80
|
+
Tag[Tag["OracleExtendTx"] = 25] = "OracleExtendTx";
|
|
81
|
+
Tag[Tag["NameClaimTx"] = 32] = "NameClaimTx";
|
|
82
|
+
Tag[Tag["NamePreclaimTx"] = 33] = "NamePreclaimTx";
|
|
83
|
+
Tag[Tag["NameUpdateTx"] = 34] = "NameUpdateTx";
|
|
84
|
+
Tag[Tag["NameRevokeTx"] = 35] = "NameRevokeTx";
|
|
85
|
+
Tag[Tag["NameTransferTx"] = 36] = "NameTransferTx";
|
|
86
|
+
Tag[Tag["Contract"] = 40] = "Contract";
|
|
87
|
+
Tag[Tag["ContractCall"] = 41] = "ContractCall";
|
|
88
|
+
Tag[Tag["ContractCreateTx"] = 42] = "ContractCreateTx";
|
|
89
|
+
Tag[Tag["ContractCallTx"] = 43] = "ContractCallTx";
|
|
90
|
+
Tag[Tag["ChannelCreateTx"] = 50] = "ChannelCreateTx";
|
|
91
|
+
Tag[Tag["ChannelDepositTx"] = 51] = "ChannelDepositTx";
|
|
92
|
+
Tag[Tag["ChannelWithdrawTx"] = 52] = "ChannelWithdrawTx";
|
|
93
|
+
Tag[Tag["ChannelForceProgressTx"] = 521] = "ChannelForceProgressTx";
|
|
94
|
+
Tag[Tag["ChannelCloseMutualTx"] = 53] = "ChannelCloseMutualTx";
|
|
95
|
+
Tag[Tag["ChannelCloseSoloTx"] = 54] = "ChannelCloseSoloTx";
|
|
96
|
+
Tag[Tag["ChannelSlashTx"] = 55] = "ChannelSlashTx";
|
|
97
|
+
Tag[Tag["ChannelSettleTx"] = 56] = "ChannelSettleTx";
|
|
98
|
+
Tag[Tag["ChannelOffChainTx"] = 57] = "ChannelOffChainTx";
|
|
99
|
+
Tag[Tag["ChannelOffChainUpdateTransfer"] = 570] = "ChannelOffChainUpdateTransfer";
|
|
100
|
+
Tag[Tag["ChannelOffChainUpdateDeposit"] = 571] = "ChannelOffChainUpdateDeposit";
|
|
101
|
+
Tag[Tag["ChannelOffChainUpdateWithdraw"] = 572] = "ChannelOffChainUpdateWithdraw";
|
|
102
|
+
Tag[Tag["ChannelOffChainUpdateCreateContract"] = 573] = "ChannelOffChainUpdateCreateContract";
|
|
103
|
+
Tag[Tag["ChannelOffChainUpdateCallContract"] = 574] = "ChannelOffChainUpdateCallContract";
|
|
104
|
+
Tag[Tag["ChannelClientReconnectTx"] = 575] = "ChannelClientReconnectTx";
|
|
105
|
+
Tag[Tag["Channel"] = 58] = "Channel";
|
|
106
|
+
Tag[Tag["ChannelSnapshotSoloTx"] = 59] = "ChannelSnapshotSoloTx";
|
|
107
|
+
Tag[Tag["TreesPoi"] = 60] = "TreesPoi";
|
|
108
|
+
Tag[Tag["StateTrees"] = 62] = "StateTrees";
|
|
109
|
+
Tag[Tag["Mtree"] = 63] = "Mtree";
|
|
110
|
+
Tag[Tag["MtreeValue"] = 64] = "MtreeValue";
|
|
111
|
+
Tag[Tag["ContractsMtree"] = 621] = "ContractsMtree";
|
|
112
|
+
Tag[Tag["CallsMtree"] = 622] = "CallsMtree";
|
|
113
|
+
Tag[Tag["ChannelsMtree"] = 623] = "ChannelsMtree";
|
|
114
|
+
Tag[Tag["NameserviceMtree"] = 624] = "NameserviceMtree";
|
|
115
|
+
Tag[Tag["OraclesMtree"] = 625] = "OraclesMtree";
|
|
116
|
+
Tag[Tag["AccountsMtree"] = 626] = "AccountsMtree";
|
|
117
|
+
Tag[Tag["CompilerSophia"] = 70] = "CompilerSophia";
|
|
118
|
+
Tag[Tag["GaAttachTx"] = 80] = "GaAttachTx";
|
|
119
|
+
Tag[Tag["GaMetaTx"] = 81] = "GaMetaTx";
|
|
120
|
+
Tag[Tag["PayingForTx"] = 82] = "PayingForTx";
|
|
121
|
+
})(Tag || (Tag = {}));
|
|
100
122
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":["BigNumber","mapObject","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","
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":["BigNumber","mapObject","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\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 // 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 // KeyBlock = 100,\n // MicroBlock = 101,\n // LightMicroBlock = 102,\n // Pof = 200,\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Int } from './u-int';
|
|
3
|
+
import { AE_AMOUNT_FORMATS } from '../../../utils/amount-formatter';
|
|
4
|
+
export interface Options {
|
|
5
|
+
denomination?: AE_AMOUNT_FORMATS;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: {
|
|
8
|
+
serializeAettos(value: string | undefined): string;
|
|
9
|
+
serializeOptional(value: Int | undefined, { denomination, ...options }: Options): Buffer;
|
|
10
|
+
serialize(value: Int, options: Options): Buffer;
|
|
11
|
+
deserialize(value: Buffer): string;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import uInt from "./u-int.mjs";
|
|
2
|
+
import { formatAmount } from "../../../utils/amount-formatter.mjs";
|
|
3
|
+
import { ArgumentError } from "../../../utils/errors.mjs";
|
|
4
|
+
export default { ...uInt,
|
|
5
|
+
|
|
6
|
+
serializeAettos(value) {
|
|
7
|
+
if (value == null) throw new ArgumentError('value', 'provided', value);
|
|
8
|
+
return value;
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
serializeOptional(value, _ref) {
|
|
12
|
+
let {
|
|
13
|
+
denomination,
|
|
14
|
+
...options
|
|
15
|
+
} = _ref;
|
|
16
|
+
return uInt.serialize(this.serializeAettos(value != null ? formatAmount(value, {
|
|
17
|
+
denomination
|
|
18
|
+
}) : value, options));
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
serialize(value, options) {
|
|
22
|
+
return this.serializeOptional(value, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=coin-amount.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coin-amount.mjs","names":["uInt","formatAmount","ArgumentError","serializeAettos","value","serializeOptional","denomination","options","serialize"],"sources":["../../../../src/tx/builder/field-types/coin-amount.ts"],"sourcesContent":["import uInt, { Int } from './u-int';\nimport { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter';\nimport { ArgumentError } from '../../../utils/errors';\n\nexport interface Options { denomination?: AE_AMOUNT_FORMATS }\n\nexport default {\n ...uInt,\n\n serializeAettos(value: string | undefined): string {\n if (value == null) throw new ArgumentError('value', 'provided', value);\n return value;\n },\n\n serializeOptional(value: Int | undefined, { denomination, ...options }: Options): Buffer {\n return uInt.serialize(\n this.serializeAettos(\n value != null ? formatAmount(value, { denomination }) : value,\n options,\n ),\n );\n },\n\n serialize(value: Int, options: Options): Buffer {\n return this.serializeOptional(value, options);\n },\n};\n"],"mappings":"OAAOA,I;SACqBC,Y;SACnBC,a;AAIT,eAAe,EACb,GAAGF,IADU;;EAGbG,eAAe,CAACC,KAAD,EAAoC;IACjD,IAAIA,KAAK,IAAI,IAAb,EAAmB,MAAM,IAAIF,aAAJ,CAAkB,OAAlB,EAA2B,UAA3B,EAAuCE,KAAvC,CAAN;IACnB,OAAOA,KAAP;EACD,CANY;;EAQbC,iBAAiB,CAACD,KAAD,QAAwE;IAAA,IAA/C;MAAEE,YAAF;MAAgB,GAAGC;IAAnB,CAA+C;IACvF,OAAOP,IAAI,CAACQ,SAAL,CACL,KAAKL,eAAL,CACEC,KAAK,IAAI,IAAT,GAAgBH,YAAY,CAACG,KAAD,EAAQ;MAAEE;IAAF,CAAR,CAA5B,GAAwDF,KAD1D,EAEEG,OAFF,CADK,CAAP;EAMD,CAfY;;EAiBbC,SAAS,CAACJ,KAAD,EAAaG,OAAb,EAAuC;IAC9C,OAAO,KAAKF,iBAAL,CAAuBD,KAAvB,EAA8BG,OAA9B,CAAP;EACD;;AAnBY,CAAf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import coinAmount from './coin-amount';
|
|
3
|
+
import { Int } from './u-int';
|
|
4
|
+
declare const _default: {
|
|
5
|
+
/**
|
|
6
|
+
* @param value - Deposit value in string format. Should be equal to '0'.
|
|
7
|
+
* @param options - Options
|
|
8
|
+
* @returns Deposit value Buffer.
|
|
9
|
+
*/
|
|
10
|
+
serialize(value: Int | undefined, options: Parameters<(typeof coinAmount)['serialize']>[1]): Buffer;
|
|
11
|
+
serializeAettos(value: string | undefined): string;
|
|
12
|
+
serializeOptional(value: Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
|
|
13
|
+
deserialize(value: Buffer): string;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import coinAmount from "./coin-amount.mjs";
|
|
2
|
+
import { IllegalArgumentError } from "../../../utils/errors.mjs";
|
|
3
|
+
export default { ...coinAmount,
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param value - Deposit value in string format. Should be equal to '0'.
|
|
7
|
+
* @param options - Options
|
|
8
|
+
* @returns Deposit value Buffer.
|
|
9
|
+
*/
|
|
10
|
+
serialize(value, options) {
|
|
11
|
+
var _value;
|
|
12
|
+
|
|
13
|
+
(_value = value) !== null && _value !== void 0 ? _value : value = 0;
|
|
14
|
+
if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);
|
|
15
|
+
return coinAmount.serialize(value, options);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=deposit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deposit.mjs","names":["coinAmount","IllegalArgumentError","serialize","value","options","toString"],"sources":["../../../../src/tx/builder/field-types/deposit.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { Int } from './u-int';\nimport { IllegalArgumentError } from '../../../utils/errors';\n\nexport default {\n ...coinAmount,\n\n /**\n * @param value - Deposit value in string format. Should be equal to '0'.\n * @param options - Options\n * @returns Deposit value Buffer.\n */\n serialize(\n value: Int | undefined,\n options: Parameters<typeof coinAmount['serialize']>[1],\n ): Buffer {\n value ??= 0;\n if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);\n return coinAmount.serialize(value, options);\n },\n};\n"],"mappings":"OAAOA,U;SAEEC,oB;AAET,eAAe,EACb,GAAGD,UADU;;EAGb;AACF;AACA;AACA;AACA;EACEE,SAAS,CACPC,KADO,EAEPC,OAFO,EAGC;IAAA;;IACR,UAAAD,KAAK,UAAL,iCAAAA,KAAK,GAAK,CAAV;IACA,IAAI,CAACA,KAAD,KAAW,CAAf,EAAkB,MAAM,IAAIF,oBAAJ,CAA0B,oEAAmEE,KAAK,CAACE,QAAN,EAAiB,UAA9G,CAAN;IAClB,OAAOL,UAAU,CAACE,SAAX,CAAqBC,KAArB,EAA4BC,OAA5B,CAAP;EACD;;AAfY,CAAf"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { Tag } from '../constants';
|
|
4
|
+
/**
|
|
5
|
+
* Calculate fee based on tx type and params
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildFee(txType: Tag, buildTx: any): BigNumber;
|
|
8
|
+
/**
|
|
9
|
+
* Calculate min fee
|
|
10
|
+
* @category transaction builder
|
|
11
|
+
* @param txType - Transaction type
|
|
12
|
+
* @param rebuildTx - Callback to get built transaction with specific fee
|
|
13
|
+
*/
|
|
14
|
+
export declare function calculateMinFee(txType: Tag, rebuildTx: (value: BigNumber) => any): BigNumber;
|
|
15
|
+
declare const _default: {
|
|
16
|
+
serializeAettos(_value: string | undefined, { txType, rebuildTx, _computingMinFee }: {
|
|
17
|
+
txType: Tag;
|
|
18
|
+
rebuildTx: (params: any) => any;
|
|
19
|
+
_computingMinFee?: string | undefined;
|
|
20
|
+
}): string;
|
|
21
|
+
serialize: (value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options) => Buffer;
|
|
22
|
+
serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
|
|
23
|
+
deserialize(value: Buffer): string;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
3
|
+
import { IllegalArgumentError } from "../../../utils/errors.mjs";
|
|
4
|
+
import { MIN_GAS_PRICE, Tag } from "../constants.mjs";
|
|
5
|
+
import coinAmount from "./coin-amount.mjs";
|
|
6
|
+
import { isKeyOfObject } from "../../../utils/other.mjs";
|
|
6
7
|
const BASE_GAS = 15000;
|
|
7
8
|
const GAS_PER_BYTE = 20;
|
|
8
9
|
const KEY_BLOCK_INTERVAL = 3;
|
|
@@ -21,18 +22,18 @@ const TX_FEE_BASE_GAS = txType => {
|
|
|
21
22
|
var _feeFactors;
|
|
22
23
|
|
|
23
24
|
const feeFactors = {
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
25
|
+
[Tag.ChannelForceProgressTx]: 30,
|
|
26
|
+
[Tag.ChannelOffChainTx]: 0,
|
|
27
|
+
[Tag.ChannelOffChainUpdateCallContract]: 0,
|
|
28
|
+
[Tag.ChannelOffChainUpdateCreateContract]: 0,
|
|
29
|
+
[Tag.ChannelOffChainUpdateDeposit]: 0,
|
|
30
|
+
[Tag.ChannelOffChainUpdateWithdraw]: 0,
|
|
31
|
+
[Tag.ChannelOffChainUpdateTransfer]: 0,
|
|
32
|
+
[Tag.ContractCreateTx]: 5,
|
|
33
|
+
[Tag.ContractCallTx]: 12,
|
|
34
|
+
[Tag.GaAttachTx]: 5,
|
|
35
|
+
[Tag.GaMetaTx]: 5,
|
|
36
|
+
[Tag.PayingForTx]: 1 / 5
|
|
36
37
|
};
|
|
37
38
|
const factor = (_feeFactors = feeFactors[txType]) !== null && _feeFactors !== void 0 ? _feeFactors : 1;
|
|
38
39
|
return new BigNumber(factor * BASE_GAS);
|
|
@@ -61,14 +62,14 @@ const TX_FEE_OTHER_GAS = (txType, txSize, _ref) => {
|
|
|
61
62
|
} = _ref;
|
|
62
63
|
|
|
63
64
|
switch (txType) {
|
|
64
|
-
case
|
|
65
|
-
case
|
|
66
|
-
case
|
|
67
|
-
case
|
|
65
|
+
case Tag.OracleRegisterTx:
|
|
66
|
+
case Tag.OracleExtendTx:
|
|
67
|
+
case Tag.OracleQueryTx:
|
|
68
|
+
case Tag.OracleResponseTx:
|
|
68
69
|
return new BigNumber(txSize).times(GAS_PER_BYTE).plus(Math.ceil(32000 * relativeTtl / Math.floor(60 * 24 * 365 / KEY_BLOCK_INTERVAL)));
|
|
69
70
|
|
|
70
|
-
case
|
|
71
|
-
case
|
|
71
|
+
case Tag.GaMetaTx:
|
|
72
|
+
case Tag.PayingForTx:
|
|
72
73
|
return new BigNumber(txSize).minus(innerTxSize).times(GAS_PER_BYTE);
|
|
73
74
|
|
|
74
75
|
default:
|
|
@@ -78,71 +79,72 @@ const TX_FEE_OTHER_GAS = (txType, txSize, _ref) => {
|
|
|
78
79
|
|
|
79
80
|
function getOracleRelativeTtl(params, txType) {
|
|
80
81
|
const ttlKeys = {
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
82
|
+
[Tag.OracleRegisterTx]: 'oracleTtlValue',
|
|
83
|
+
[Tag.OracleExtendTx]: 'oracleTtlValue',
|
|
84
|
+
[Tag.OracleQueryTx]: 'queryTtlValue',
|
|
85
|
+
[Tag.OracleResponseTx]: 'responseTtlValue'
|
|
85
86
|
};
|
|
86
|
-
if (!isKeyOfObject(txType, ttlKeys)) return 1;
|
|
87
|
+
if (!isKeyOfObject(txType, ttlKeys)) return 1;
|
|
88
|
+
return params[ttlKeys[txType]];
|
|
87
89
|
}
|
|
88
90
|
/**
|
|
89
91
|
* Calculate fee based on tx type and params
|
|
90
92
|
*/
|
|
91
93
|
|
|
92
94
|
|
|
93
|
-
function buildFee(txType,
|
|
95
|
+
export function buildFee(txType, buildTx) {
|
|
94
96
|
var _context;
|
|
95
97
|
|
|
96
|
-
let {
|
|
97
|
-
params,
|
|
98
|
-
vsn,
|
|
99
|
-
denomination
|
|
100
|
-
} = _ref2;
|
|
101
98
|
const {
|
|
102
99
|
rlpEncoded: {
|
|
103
100
|
length
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
denomination
|
|
108
|
-
});
|
|
101
|
+
},
|
|
102
|
+
txObject
|
|
103
|
+
} = buildTx;
|
|
109
104
|
return TX_FEE_BASE_GAS(txType).plus(TX_FEE_OTHER_GAS(txType, length, {
|
|
110
|
-
relativeTtl: getOracleRelativeTtl(
|
|
111
|
-
innerTxSize: _includesInstanceProperty(_context = [
|
|
105
|
+
relativeTtl: getOracleRelativeTtl(txObject, txType),
|
|
106
|
+
innerTxSize: _includesInstanceProperty(_context = [Tag.GaMetaTx, Tag.PayingForTx]).call(_context, txType) ? txObject.tx.tx.encodedTx.rlpEncoded.length : 0
|
|
112
107
|
})).times(MIN_GAS_PRICE);
|
|
113
108
|
}
|
|
114
109
|
/**
|
|
115
110
|
* Calculate min fee
|
|
111
|
+
* @category transaction builder
|
|
116
112
|
* @param txType - Transaction type
|
|
117
|
-
* @param
|
|
118
|
-
* @param options.params - Tx params
|
|
119
|
-
* @example
|
|
120
|
-
* ```js
|
|
121
|
-
* calculateMinFee('spendTx', { gasLimit, params })
|
|
122
|
-
* ```
|
|
113
|
+
* @param rebuildTx - Callback to get built transaction with specific fee
|
|
123
114
|
*/
|
|
124
115
|
|
|
125
|
-
|
|
126
|
-
export default function calculateMinFee(txType, _ref3) {
|
|
127
|
-
let {
|
|
128
|
-
params,
|
|
129
|
-
vsn,
|
|
130
|
-
denomination
|
|
131
|
-
} = _ref3;
|
|
116
|
+
export function calculateMinFee(txType, rebuildTx) {
|
|
132
117
|
let fee = new BigNumber(0);
|
|
133
118
|
let previousFee;
|
|
134
119
|
|
|
135
120
|
do {
|
|
136
121
|
previousFee = fee;
|
|
137
|
-
fee = buildFee(txType,
|
|
138
|
-
params: { ...params,
|
|
139
|
-
fee
|
|
140
|
-
},
|
|
141
|
-
vsn,
|
|
142
|
-
denomination
|
|
143
|
-
});
|
|
122
|
+
fee = buildFee(txType, rebuildTx(fee));
|
|
144
123
|
} while (!fee.eq(previousFee));
|
|
145
124
|
|
|
146
125
|
return fee;
|
|
147
126
|
}
|
|
148
|
-
|
|
127
|
+
export default { ...coinAmount,
|
|
128
|
+
|
|
129
|
+
serializeAettos(_value, _ref2) {
|
|
130
|
+
let {
|
|
131
|
+
txType,
|
|
132
|
+
rebuildTx,
|
|
133
|
+
_computingMinFee
|
|
134
|
+
} = _ref2;
|
|
135
|
+
if (_computingMinFee != null) return _computingMinFee;
|
|
136
|
+
const minFee = calculateMinFee(txType, fee => rebuildTx({
|
|
137
|
+
_computingMinFee: fee
|
|
138
|
+
}));
|
|
139
|
+
const value = new BigNumber(_value !== null && _value !== void 0 ? _value : minFee);
|
|
140
|
+
|
|
141
|
+
if (minFee.gt(value)) {
|
|
142
|
+
throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return value.toFixed();
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
serialize: coinAmount.serializeOptional
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=fee.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fee.mjs","names":["BigNumber","IllegalArgumentError","MIN_GAS_PRICE","Tag","coinAmount","isKeyOfObject","BASE_GAS","GAS_PER_BYTE","KEY_BLOCK_INTERVAL","TX_FEE_BASE_GAS","txType","feeFactors","ChannelForceProgressTx","ChannelOffChainTx","ChannelOffChainUpdateCallContract","ChannelOffChainUpdateCreateContract","ChannelOffChainUpdateDeposit","ChannelOffChainUpdateWithdraw","ChannelOffChainUpdateTransfer","ContractCreateTx","ContractCallTx","GaAttachTx","GaMetaTx","PayingForTx","factor","TX_FEE_OTHER_GAS","txSize","relativeTtl","innerTxSize","OracleRegisterTx","OracleExtendTx","OracleQueryTx","OracleResponseTx","times","plus","Math","ceil","floor","minus","getOracleRelativeTtl","params","ttlKeys","buildFee","buildTx","rlpEncoded","length","txObject","tx","encodedTx","calculateMinFee","rebuildTx","fee","previousFee","eq","serializeAettos","_value","_computingMinFee","minFee","value","gt","toString","toFixed","serialize","serializeOptional"],"sources":["../../../../src/tx/builder/field-types/fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag } from '../constants';\nimport coinAmount from './coin-amount';\nimport { isKeyOfObject } from '../../../utils/other';\n\nconst BASE_GAS = 15000;\nconst GAS_PER_BYTE = 20;\nconst KEY_BLOCK_INTERVAL = 3;\n\n/**\n * Calculate the Base fee gas\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @returns The base fee\n * @example\n * ```js\n * TX_FEE_BASE('channelForceProgress') => new BigNumber(30 * 15000)\n * ```\n */\nconst TX_FEE_BASE_GAS = (txType: Tag): BigNumber => {\n const feeFactors = {\n [Tag.ChannelForceProgressTx]: 30,\n [Tag.ChannelOffChainTx]: 0,\n [Tag.ChannelOffChainUpdateCallContract]: 0,\n [Tag.ChannelOffChainUpdateCreateContract]: 0,\n [Tag.ChannelOffChainUpdateDeposit]: 0,\n [Tag.ChannelOffChainUpdateWithdraw]: 0,\n [Tag.ChannelOffChainUpdateTransfer]: 0,\n [Tag.ContractCreateTx]: 5,\n [Tag.ContractCallTx]: 12,\n [Tag.GaAttachTx]: 5,\n [Tag.GaMetaTx]: 5,\n [Tag.PayingForTx]: 1 / 5,\n } as const;\n const factor = feeFactors[txType as keyof typeof feeFactors] ?? 1;\n return new BigNumber(factor * BASE_GAS);\n};\n\n/**\n * Calculate fee for Other types of transactions\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @param txSize - The transaction size\n * @returns parameters - The transaction parameters\n * @returns parameters.relativeTtl - The relative ttl\n * @returns parameters.innerTxSize - The size of the inner transaction\n * @returns The Other fee\n * @example\n * ```js\n * TX_FEE_OTHER_GAS('oracleResponse',10, { relativeTtl: 10, innerTxSize: 10 })\n * => new BigNumber(10).times(20).plus(Math.ceil(32000 * 10 / Math.floor(60 * 24 * 365 / 2)))\n * ```\n */\nconst TX_FEE_OTHER_GAS = (\n txType: Tag,\n txSize: number,\n { relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },\n): BigNumber => {\n switch (txType) {\n case Tag.OracleRegisterTx:\n case Tag.OracleExtendTx:\n case Tag.OracleQueryTx:\n case Tag.OracleResponseTx:\n return new BigNumber(txSize)\n .times(GAS_PER_BYTE)\n .plus(\n Math.ceil((32000 * relativeTtl) / Math.floor((60 * 24 * 365) / KEY_BLOCK_INTERVAL)),\n );\n case Tag.GaMetaTx:\n case Tag.PayingForTx:\n return new BigNumber(txSize).minus(innerTxSize).times(GAS_PER_BYTE);\n default:\n return new BigNumber(txSize).times(GAS_PER_BYTE);\n }\n};\n\nfunction getOracleRelativeTtl(params: any, txType: Tag): number {\n const ttlKeys = {\n [Tag.OracleRegisterTx]: 'oracleTtlValue',\n [Tag.OracleExtendTx]: 'oracleTtlValue',\n [Tag.OracleQueryTx]: 'queryTtlValue',\n [Tag.OracleResponseTx]: 'responseTtlValue',\n } as const;\n\n if (!isKeyOfObject(txType, ttlKeys)) return 1;\n return params[ttlKeys[txType]];\n}\n\n/**\n * Calculate fee based on tx type and params\n */\nexport function buildFee(txType: Tag, buildTx: any): BigNumber {\n const { rlpEncoded: { length }, txObject } = buildTx;\n\n return TX_FEE_BASE_GAS(txType)\n .plus(TX_FEE_OTHER_GAS(txType, length, {\n relativeTtl: getOracleRelativeTtl(txObject, txType),\n innerTxSize: [Tag.GaMetaTx, Tag.PayingForTx].includes(txType)\n ? txObject.tx.tx.encodedTx.rlpEncoded.length\n : 0,\n }))\n .times(MIN_GAS_PRICE);\n}\n\n/**\n * Calculate min fee\n * @category transaction builder\n * @param txType - Transaction type\n * @param rebuildTx - Callback to get built transaction with specific fee\n */\nexport function calculateMinFee(\n txType: Tag,\n rebuildTx: (value: BigNumber) => any,\n): BigNumber {\n let fee = new BigNumber(0);\n let previousFee;\n do {\n previousFee = fee;\n fee = buildFee(txType, rebuildTx(fee));\n } while (!fee.eq(previousFee));\n return fee;\n}\n\nexport default {\n ...coinAmount,\n\n serializeAettos(\n _value: string | undefined,\n { txType, rebuildTx, _computingMinFee }:\n { txType: Tag; rebuildTx: (params: any) => any; _computingMinFee?: string },\n ): string {\n if (_computingMinFee != null) return _computingMinFee;\n const minFee = calculateMinFee(txType, (fee) => rebuildTx({ _computingMinFee: fee }));\n const value = new BigNumber(_value ?? minFee);\n if (minFee.gt(value)) {\n throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);\n }\n return value.toFixed();\n },\n\n serialize: coinAmount.serializeOptional,\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _buffer from "buffer";
|
|
2
|
+
const {
|
|
3
|
+
Buffer: _Buffer
|
|
4
|
+
} = _buffer;
|
|
5
|
+
export default {
|
|
6
|
+
serialize(value) {
|
|
7
|
+
return _Buffer.from(value);
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
deserialize(value) {
|
|
11
|
+
return value.toString();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=field.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.mjs","names":["serialize","value","from","deserialize","toString"],"sources":["../../../../src/tx/builder/field-types/field.ts"],"sourcesContent":["export default {\n serialize(value: string): Buffer {\n return Buffer.from(value);\n },\n\n deserialize(value: Buffer): string {\n return value.toString();\n },\n};\n"],"mappings":";;;;AAAA,eAAe;EACbA,SAAS,CAACC,KAAD,EAAwB;IAC/B,OAAO,QAAOC,IAAP,CAAYD,KAAZ,CAAP;EACD,CAHY;;EAKbE,WAAW,CAACF,KAAD,EAAwB;IACjC,OAAOA,KAAK,CAACG,QAAN,EAAP;EACD;;AAPY,CAAf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Tag } from '../constants';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
serialize(_value: number | undefined, { txType, rebuildTx, gasMax, _computingGasLimit, }: {
|
|
5
|
+
txType: Tag;
|
|
6
|
+
rebuildTx: (params: any) => any;
|
|
7
|
+
gasMax: number;
|
|
8
|
+
_computingGasLimit?: number | undefined;
|
|
9
|
+
}): Buffer;
|
|
10
|
+
deserialize(value: Buffer): number;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IllegalArgumentError } from "../../../utils/errors.mjs";
|
|
2
|
+
import { MIN_GAS_PRICE } from "../constants.mjs";
|
|
3
|
+
import shortUInt from "./short-u-int.mjs";
|
|
4
|
+
import { buildFee } from "./fee.mjs";
|
|
5
|
+
|
|
6
|
+
function calculateGasLimitMax(txType, gasMax, rebuildTx) {
|
|
7
|
+
return gasMax - +buildFee(txType, rebuildTx(gasMax)).dividedBy(MIN_GAS_PRICE);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default { ...shortUInt,
|
|
11
|
+
|
|
12
|
+
serialize(_value, _ref) {
|
|
13
|
+
let {
|
|
14
|
+
txType,
|
|
15
|
+
rebuildTx,
|
|
16
|
+
gasMax = 6e6,
|
|
17
|
+
_computingGasLimit
|
|
18
|
+
} = _ref;
|
|
19
|
+
if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);
|
|
20
|
+
const gasLimitMax = calculateGasLimitMax(txType, gasMax, gasLimit => rebuildTx({
|
|
21
|
+
_computingGasLimit: gasLimit
|
|
22
|
+
}));
|
|
23
|
+
const value = _value !== null && _value !== void 0 ? _value : gasLimitMax;
|
|
24
|
+
|
|
25
|
+
if (value > gasLimitMax) {
|
|
26
|
+
throw new IllegalArgumentError(`Gas limit ${value} must be less or equal to ${gasLimitMax}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return shortUInt.serialize(value);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=gas-limit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gas-limit.mjs","names":["IllegalArgumentError","MIN_GAS_PRICE","shortUInt","buildFee","calculateGasLimitMax","txType","gasMax","rebuildTx","dividedBy","serialize","_value","_computingGasLimit","gasLimitMax","gasLimit","value"],"sources":["../../../../src/tx/builder/field-types/gas-limit.ts"],"sourcesContent":["import { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag } from '../constants';\nimport shortUInt from './short-u-int';\nimport { buildFee } from './fee';\n\nfunction calculateGasLimitMax(\n txType: Tag,\n gasMax: number,\n rebuildTx: (value: number) => any,\n): number {\n return gasMax - +buildFee(txType, rebuildTx(gasMax)).dividedBy(MIN_GAS_PRICE);\n}\n\nexport default {\n ...shortUInt,\n\n serialize(\n _value: number | undefined,\n {\n txType, rebuildTx, gasMax = 6e6, _computingGasLimit,\n }: {\n txType: Tag;\n rebuildTx: (params: any) => any;\n gasMax: number;\n _computingGasLimit?: number;\n },\n ): Buffer {\n if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);\n\n const gasLimitMax = calculateGasLimitMax(\n txType,\n gasMax,\n (gasLimit) => rebuildTx({ _computingGasLimit: gasLimit }),\n );\n const value = _value ?? gasLimitMax;\n if (value > gasLimitMax) {\n throw new IllegalArgumentError(`Gas limit ${value} must be less or equal to ${gasLimitMax}`);\n }\n return shortUInt.serialize(value);\n },\n};\n"],"mappings":"SAASA,oB;SACAC,a;OACFC,S;SACEC,Q;;AAET,SAASC,oBAAT,CACEC,MADF,EAEEC,MAFF,EAGEC,SAHF,EAIU;EACR,OAAOD,MAAM,GAAG,CAACH,QAAQ,CAACE,MAAD,EAASE,SAAS,CAACD,MAAD,CAAlB,CAAR,CAAoCE,SAApC,CAA8CP,aAA9C,CAAjB;AACD;;AAED,eAAe,EACb,GAAGC,SADU;;EAGbO,SAAS,CACPC,MADO,QAUC;IAAA,IARR;MACEL,MADF;MACUE,SADV;MACqBD,MAAM,GAAG,GAD9B;MACmCK;IADnC,CAQQ;IACR,IAAIA,kBAAkB,IAAI,IAA1B,EAAgC,OAAOT,SAAS,CAACO,SAAV,CAAoBE,kBAApB,CAAP;IAEhC,MAAMC,WAAW,GAAGR,oBAAoB,CACtCC,MADsC,EAEtCC,MAFsC,EAGrCO,QAAD,IAAcN,SAAS,CAAC;MAAEI,kBAAkB,EAAEE;IAAtB,CAAD,CAHe,CAAxC;IAKA,MAAMC,KAAK,GAAGJ,MAAH,aAAGA,MAAH,cAAGA,MAAH,GAAaE,WAAxB;;IACA,IAAIE,KAAK,GAAGF,WAAZ,EAAyB;MACvB,MAAM,IAAIZ,oBAAJ,CAA0B,aAAYc,KAAM,6BAA4BF,WAAY,EAApF,CAAN;IACD;;IACD,OAAOV,SAAS,CAACO,SAAV,CAAoBK,KAApB,CAAP;EACD;;AA1BY,CAAf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
declare const _default: {
|
|
3
|
+
serializeAettos(value?: string | undefined): string;
|
|
4
|
+
serialize: (value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options) => Buffer;
|
|
5
|
+
serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
|
|
6
|
+
deserialize(value: Buffer): string;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import coinAmount from "./coin-amount.mjs";
|
|
2
|
+
import { IllegalArgumentError } from "../../../utils/errors.mjs";
|
|
3
|
+
import { MIN_GAS_PRICE } from "../constants.mjs";
|
|
4
|
+
export default { ...coinAmount,
|
|
5
|
+
|
|
6
|
+
serializeAettos() {
|
|
7
|
+
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MIN_GAS_PRICE.toString();
|
|
8
|
+
|
|
9
|
+
if (+value < MIN_GAS_PRICE) {
|
|
10
|
+
throw new IllegalArgumentError(`Gas price ${value.toString()} must be bigger then ${MIN_GAS_PRICE}`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return value;
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
serialize: coinAmount.serializeOptional
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=gas-price.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gas-price.mjs","names":["coinAmount","IllegalArgumentError","MIN_GAS_PRICE","serializeAettos","value","toString","serialize","serializeOptional"],"sources":["../../../../src/tx/builder/field-types/gas-price.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE } from '../constants';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(value: string | undefined = MIN_GAS_PRICE.toString()): string {\n if (+value < MIN_GAS_PRICE) {\n throw new IllegalArgumentError(`Gas price ${value.toString()} must be bigger then ${MIN_GAS_PRICE}`);\n }\n return value;\n },\n\n serialize: coinAmount.serializeOptional,\n};\n"],"mappings":"OAAOA,U;SACEC,oB;SACAC,a;AAET,eAAe,EACb,GAAGF,UADU;;EAGbG,eAAe,GAA+D;IAAA,IAA9DC,KAA8D,uEAAlCF,aAAa,CAACG,QAAd,EAAkC;;IAC5E,IAAI,CAACD,KAAD,GAASF,aAAb,EAA4B;MAC1B,MAAM,IAAID,oBAAJ,CAA0B,aAAYG,KAAK,CAACC,QAAN,EAAiB,wBAAuBH,aAAc,EAA5F,CAAN;IACD;;IACD,OAAOE,KAAP;EACD,CARY;;EAUbE,SAAS,EAAEN,UAAU,CAACO;AAVT,CAAf"}
|