@aeternity/aepp-sdk 14.1.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aepp-sdk.browser-script.cjs +1 -1
- package/dist/aepp-sdk.browser-script.cjs.map +1 -1
- package/dist/aepp-sdk.browser.cjs +1 -1
- package/dist/aepp-sdk.browser.cjs.map +1 -1
- package/dist/aepp-sdk.cjs +10776 -6350
- package/dist/aepp-sdk.cjs.map +1 -1
- package/es/account/Base.d.ts +6 -1
- package/es/account/Base.js.map +1 -1
- package/es/account/Generalized.d.ts +1 -1
- package/es/account/Generalized.js +7 -1
- package/es/account/Generalized.js.map +1 -1
- package/es/aens.d.ts +10 -2
- package/es/aens.js +10 -2
- package/es/aens.js.map +1 -1
- package/es/apis/middleware/models/index.js.map +1 -1
- package/es/apis/node/models/index.d.ts +405 -79
- package/es/apis/node/models/index.js.map +1 -1
- package/es/apis/node/models/mappers.d.ts +54 -4
- package/es/apis/node/models/mappers.js +1910 -500
- package/es/apis/node/models/mappers.js.map +1 -1
- package/es/apis/node/node.d.ts +28 -6
- package/es/apis/node/node.js +276 -5
- package/es/apis/node/node.js.map +1 -1
- package/es/channel/Contract.d.ts +5 -0
- package/es/channel/Contract.js +8 -2
- package/es/channel/Contract.js.map +1 -1
- package/es/channel/handlers.js +3 -3
- package/es/channel/handlers.js.map +1 -1
- package/es/contract/compiler/Cli.js +6 -2
- package/es/contract/compiler/Cli.js.map +1 -1
- package/es/contract/ga.d.ts +5 -2
- package/es/contract/ga.js +53 -21
- package/es/contract/ga.js.map +1 -1
- package/es/index-browser.d.ts +3 -1
- package/es/index-browser.js +2 -1
- package/es/index-browser.js.map +1 -1
- package/es/tx/builder/constants.d.ts +12 -2
- package/es/tx/builder/constants.js +11 -1
- package/es/tx/builder/constants.js.map +1 -1
- package/es/tx/builder/entry/index.js +6 -0
- package/es/tx/builder/entry/index.js.map +1 -1
- package/es/tx/builder/entry/schema.d.ts +10 -10
- package/es/tx/builder/field-types/ct-version.d.ts +14 -0
- package/es/tx/builder/field-types/ct-version.js +14 -0
- package/es/tx/builder/field-types/ct-version.js.map +1 -1
- package/es/tx/builder/field-types/fee.d.ts +9 -7
- package/es/tx/builder/field-types/fee.js +75 -66
- package/es/tx/builder/field-types/fee.js.map +1 -1
- package/es/tx/builder/field-types/gas-limit.d.ts +5 -3
- package/es/tx/builder/field-types/gas-limit.js +25 -14
- package/es/tx/builder/field-types/gas-limit.js.map +1 -1
- package/es/tx/builder/field-types/gas-price.d.ts +6 -4
- package/es/tx/builder/field-types/gas-price.js +87 -21
- package/es/tx/builder/field-types/gas-price.js.map +1 -1
- package/es/tx/builder/field-types/interface.d.ts +20 -0
- package/es/tx/builder/field-types/interface.js +17 -1
- package/es/tx/builder/field-types/interface.js.map +1 -1
- package/es/tx/builder/field-types/name-fee.d.ts +3 -2
- package/es/tx/builder/field-types/name-fee.js +6 -0
- package/es/tx/builder/field-types/name-fee.js.map +1 -1
- package/es/tx/builder/field-types/pointers.d.ts +2 -1
- package/es/tx/builder/field-types/pointers.js +6 -2
- package/es/tx/builder/field-types/pointers.js.map +1 -1
- package/es/tx/builder/field-types/transaction.d.ts +4 -1
- package/es/tx/builder/field-types/transaction.js +18 -3
- package/es/tx/builder/field-types/transaction.js.map +1 -1
- package/es/tx/builder/field-types/ttl.d.ts +1 -2
- package/es/tx/builder/field-types/ttl.js +7 -4
- package/es/tx/builder/field-types/ttl.js.map +1 -1
- package/es/tx/builder/field-types/with-formatting.d.ts +1 -1
- package/es/tx/builder/field-types/with-formatting.js +1 -1
- package/es/tx/builder/field-types/with-formatting.js.map +1 -1
- package/es/tx/builder/index.d.ts +13 -0
- package/es/tx/builder/index.js +92 -5
- package/es/tx/builder/index.js.map +1 -1
- package/es/tx/builder/protocol-parameters.d.ts +123 -0
- package/es/tx/builder/protocol-parameters.js +519 -0
- package/es/tx/builder/protocol-parameters.js.map +1 -0
- package/es/tx/builder/schema.d.ts +179 -201
- package/es/tx/builder/schema.js +5 -1
- package/es/tx/builder/schema.js.map +1 -1
- package/es/tx/execution-cost.js +5 -5
- package/es/tx/execution-cost.js.map +1 -1
- package/es/tx/transaction-signer.js +2 -2
- package/es/tx/transaction-signer.js.map +1 -1
- package/es/tx/validator.js +4 -4
- package/es/tx/validator.js.map +1 -1
- package/es/utils/wrap-proxy.d.ts +10 -0
- package/es/utils/wrap-proxy.js +18 -0
- package/es/utils/wrap-proxy.js.map +1 -1
- package/package.json +3 -3
|
@@ -10,8 +10,13 @@ export const DRY_RUN_ACCOUNT = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
+
* The maximum gas of a generalized account authentication function as it was at the moment of the
|
|
14
|
+
* SDK release. It is a node policy setting rather than a consensus parameter.
|
|
13
15
|
* @category account generalized
|
|
14
|
-
* @deprecated transaction builder
|
|
16
|
+
* @deprecated the transaction builder ensures that gas doesn't exceed the maximum by itself, and a
|
|
17
|
+
* node may accept another maximum than this constant. Use
|
|
18
|
+
* `(await getCachedProtocolParameters(node)).maxAuthFunGas` for the value the connected node
|
|
19
|
+
* reports, or `defaultProtocolParameters.maxAuthFunGas` for this one.
|
|
15
20
|
*/
|
|
16
21
|
export const MAX_AUTH_FUN_GAS = 50000;
|
|
17
22
|
/**
|
|
@@ -23,7 +28,11 @@ export const MAX_AUTH_FUN_GAS = 50000;
|
|
|
23
28
|
*/
|
|
24
29
|
|
|
25
30
|
/**
|
|
31
|
+
* The consensus minimum gas price as it was at the moment of the SDK release.
|
|
26
32
|
* @category transaction builder
|
|
33
|
+
* @deprecated a node may run another minimum gas price, and this constant is wrong on it. Use
|
|
34
|
+
* `(await getCachedProtocolParameters(node)).minGasPrice` for the value the connected node
|
|
35
|
+
* reports, or `defaultProtocolParameters.minGasPrice` for this one.
|
|
27
36
|
*/
|
|
28
37
|
export const MIN_GAS_PRICE = 1e9; // TODO: don't use number for ae
|
|
29
38
|
/**
|
|
@@ -96,6 +105,7 @@ export const NAME_BID_RANGES = mapObject({
|
|
|
96
105
|
*/
|
|
97
106
|
export let ConsensusProtocolVersion = /*#__PURE__*/function (ConsensusProtocolVersion) {
|
|
98
107
|
ConsensusProtocolVersion[ConsensusProtocolVersion["Ceres"] = 6] = "Ceres";
|
|
108
|
+
ConsensusProtocolVersion[ConsensusProtocolVersion["Arcus"] = 7] = "Arcus";
|
|
99
109
|
return ConsensusProtocolVersion;
|
|
100
110
|
}({});
|
|
101
111
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["BigNumber","mapObject","DRY_RUN_ACCOUNT","pub","amount","MAX_AUTH_FUN_GAS","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_RANGES","key","value","times","ConsensusProtocolVersion","VmVersion","AbiVersion","Tag"],"sources":["../../../src/tx/builder/constants.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { mapObject } from '../../utils/other.js';\n\n/**\n * @category transaction builder\n */\nexport const DRY_RUN_ACCOUNT = {\n pub: 'ak_11111111111111111111111111111111273Yts',\n amount: 100000000000000000000000000000000000n,\n} as const;\n\n/**\n * @category account generalized\n * @deprecated transaction builder
|
|
1
|
+
{"version":3,"file":"constants.js","names":["BigNumber","mapObject","DRY_RUN_ACCOUNT","pub","amount","MAX_AUTH_FUN_GAS","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_RANGES","key","value","times","ConsensusProtocolVersion","VmVersion","AbiVersion","Tag"],"sources":["../../../src/tx/builder/constants.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { mapObject } from '../../utils/other.js';\n\n/**\n * @category transaction builder\n */\nexport const DRY_RUN_ACCOUNT = {\n pub: 'ak_11111111111111111111111111111111273Yts',\n amount: 100000000000000000000000000000000000n,\n} as const;\n\n/**\n * The maximum gas of a generalized account authentication function as it was at the moment of the\n * SDK release. It is a node policy setting rather than a consensus parameter.\n * @category account generalized\n * @deprecated the transaction builder ensures that gas doesn't exceed the maximum by itself, and a\n * node may accept another maximum than this constant. Use\n * `(await getCachedProtocolParameters(node)).maxAuthFunGas` for the value the connected node\n * reports, or `defaultProtocolParameters.maxAuthFunGas` for this one.\n */\nexport const MAX_AUTH_FUN_GAS = 50000;\n/**\n * @category utils\n */\nexport type Int = number | string | BigNumber;\n/**\n * @category AENS\n */\nexport type AensName = `${string}.chain`;\n/**\n * The consensus minimum gas price as it was at the moment of the SDK release.\n * @category transaction builder\n * @deprecated a node may run another minimum gas price, and this constant is wrong on it. Use\n * `(await getCachedProtocolParameters(node)).minGasPrice` for the value the connected node\n * reports, or `defaultProtocolParameters.minGasPrice` for this one.\n */\nexport const MIN_GAS_PRICE = 1e9; // TODO: don't use number for ae\n/**\n * @category AENS\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67}\n * @deprecated use {@link getMinimumNameFee} instead\n */\nexport const NAME_FEE_MULTIPLIER = 1e14;\n/**\n * The next bid should be at least 5% bigger than the previous one\n * @category AENS\n * @deprecated use {@link computeBidFee} instead\n */\nexport const NAME_FEE_BID_INCREMENT = 0.05;\n/**\n * Approximately 1 day\n * @category AENS\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272}\n * @deprecated use {@link computeAuctionEndBlock} instead\n */\nexport const NAME_BID_TIMEOUT_BLOCKS = 480;\n/**\n * This is the max length for a domain that requires a base fee to be paid\n * @category AENS\n * @deprecated use {@link getMinimumNameFee} instead\n */\nexport const NAME_MAX_LENGTH_FEE = 31;\n/**\n * @category AENS\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290}\n * @see {@link https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times}\n * @deprecated use {@link getMinimumNameFee} instead\n */\nexport const NAME_BID_RANGES = mapObject(\n {\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 },\n ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)],\n);\n\n/**\n * @category chain\n */\nexport enum ConsensusProtocolVersion {\n Ceres = 6,\n Arcus = 7,\n}\n\n/**\n * @category contract\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 Fate3 = 8,\n}\n\n/**\n * @category contract\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 SignedTx = 11,\n SpendTx = 12,\n OracleRegisterTx = 22,\n OracleQueryTx = 23,\n /**\n * @deprecated use `OracleRespondTx` instead\n */\n OracleResponseTx = 24,\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n OracleRespondTx = 24,\n OracleExtendTx = 25,\n NameClaimTx = 32,\n NamePreclaimTx = 33,\n NameUpdateTx = 34,\n NameRevokeTx = 35,\n NameTransferTx = 36,\n ContractCreateTx = 42,\n ContractCallTx = 43,\n ChannelCreateTx = 50,\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 ChannelSnapshotSoloTx = 59,\n GaAttachTx = 80,\n GaMetaTx = 81,\n PayingForTx = 82,\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,SAASC,SAAS,QAAQ,sBAAsB;;AAEhD;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG;EAC7BC,GAAG,EAAE,2CAA2C;EAChDC,MAAM,EAAE;AACV,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,KAAK;AACrC;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAG,GAAG,CAAC,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAG,IAAI;AACvC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAG,IAAI;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAAG,GAAG;AAC1C;AACA;AACA;AACA;AACA;AACA,OAAO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from '../common.js';
|
|
3
3
|
import { schemas } from './schema.js';
|
|
4
4
|
import { EntryTag } from './constants.js';
|
|
5
|
+
import { checkParametersUsable } from '../protocol-parameters.js';
|
|
5
6
|
const encodingTag = [[EntryTag.CallsMtree, Encoding.CallStateTree], [EntryTag.StateTrees, Encoding.StateTrees], [EntryTag.TreesPoi, Encoding.Poi]];
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -13,6 +14,11 @@ const encodingTag = [[EntryTag.CallsMtree, Encoding.CallStateTree], [EntryTag.St
|
|
|
13
14
|
|
|
14
15
|
export function packEntry(params) {
|
|
15
16
|
var _encodingTag$find$;
|
|
17
|
+
// `GaMetaTxAuthData` holds a `gasPrice` priced by them, see the note in `buildTx`
|
|
18
|
+
const {
|
|
19
|
+
protocolParameters
|
|
20
|
+
} = params;
|
|
21
|
+
if (protocolParameters != null) checkParametersUsable(protocolParameters);
|
|
16
22
|
const encoding = (_encodingTag$find$ = encodingTag.find(([tag]) => tag === params.tag)?.[1]) !== null && _encodingTag$find$ !== void 0 ? _encodingTag$find$ : Encoding.Bytearray;
|
|
17
23
|
return packRecord(schemas, EntryTag, params, {
|
|
18
24
|
packEntry
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Encoding","packRecord","unpackRecord","schemas","EntryTag","encodingTag","CallsMtree","CallStateTree","StateTrees","TreesPoi","Poi","packEntry","params","_encodingTag$find$","encoding","find","tag","Bytearray","unpackEntry","encoded","expectedTag","enc","startsWith"],"sources":["../../../../src/tx/builder/entry/index.ts"],"sourcesContent":["import { Encoded, Encoding } from '../../../utils/encoder.js';\nimport { packRecord, unpackRecord } from '../common.js';\nimport { schemas } from './schema.js';\nimport { EntryTag } from './constants.js';\nimport { EntParams, EntUnpacked } from './schema.generated.js';\n\nconst encodingTag = [\n [EntryTag.CallsMtree, Encoding.CallStateTree],\n [EntryTag.StateTrees, Encoding.StateTrees],\n [EntryTag.TreesPoi, Encoding.Poi],\n] as const;\n\nexport function packEntry(params: EntParams & { tag: EntryTag.CallsMtree }): Encoded.CallStateTree;\nexport function packEntry(params: EntParams & { tag: EntryTag.StateTrees }): Encoded.StateTrees;\nexport function packEntry(params: EntParams & { tag: EntryTag.TreesPoi }): Encoded.Poi;\n/**\n * Pack entry\n * @category entry builder\n * @param params - Params of entry\n * @returns Encoded entry\n */\nexport function packEntry(params: EntParams): Encoded.Any;\nexport function packEntry(params: EntParams): Encoded.Any {\n const encoding = encodingTag.find(([tag]) => tag === params.tag)?.[1] ?? Encoding.Bytearray;\n return packRecord(schemas, EntryTag, params, { packEntry }, encoding);\n}\n\nexport function unpackEntry(\n encoded: Encoded.CallStateTree,\n): EntUnpacked & { tag: EntryTag.CallsMtree };\nexport function unpackEntry(\n encoded: Encoded.StateTrees,\n): EntUnpacked & { tag: EntryTag.StateTrees };\nexport function unpackEntry(encoded: Encoded.Poi): EntUnpacked & { tag: EntryTag.TreesPoi };\n/**\n * Unpack entry\n * @category entry builder\n * @param encoded - Encoded entry\n * @param expectedTag - Expected entry type\n * @returns Params of entry\n */\nexport function unpackEntry<T extends EntryTag>(\n encoded: Encoded.Any,\n expectedTag?: T,\n): EntUnpacked & { tag: T };\nexport function unpackEntry(encoded: Encoded.Any, expectedTag?: EntryTag): EntUnpacked {\n expectedTag ??= encodingTag.find(([, enc]) => encoded.startsWith(enc))?.[0];\n return unpackRecord(schemas, EntryTag, encoded, expectedTag, { unpackEntry }) as any;\n}\n"],"mappings":"AAAA,SAAkBA,QAAQ,QAAQ,2BAA2B;AAC7D,SAASC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AACvD,SAASC,OAAO,QAAQ,aAAa;AACrC,SAASC,QAAQ,QAAQ,gBAAgB;
|
|
1
|
+
{"version":3,"file":"index.js","names":["Encoding","packRecord","unpackRecord","schemas","EntryTag","checkParametersUsable","encodingTag","CallsMtree","CallStateTree","StateTrees","TreesPoi","Poi","packEntry","params","_encodingTag$find$","protocolParameters","encoding","find","tag","Bytearray","unpackEntry","encoded","expectedTag","enc","startsWith"],"sources":["../../../../src/tx/builder/entry/index.ts"],"sourcesContent":["import { Encoded, Encoding } from '../../../utils/encoder.js';\nimport { packRecord, unpackRecord } from '../common.js';\nimport { schemas } from './schema.js';\nimport { EntryTag } from './constants.js';\nimport { EntParams, EntUnpacked } from './schema.generated.js';\nimport { checkParametersUsable, ProtocolParametersOption } from '../protocol-parameters.js';\n\nconst encodingTag = [\n [EntryTag.CallsMtree, Encoding.CallStateTree],\n [EntryTag.StateTrees, Encoding.StateTrees],\n [EntryTag.TreesPoi, Encoding.Poi],\n] as const;\n\nexport function packEntry(params: EntParams & { tag: EntryTag.CallsMtree }): Encoded.CallStateTree;\nexport function packEntry(params: EntParams & { tag: EntryTag.StateTrees }): Encoded.StateTrees;\nexport function packEntry(params: EntParams & { tag: EntryTag.TreesPoi }): Encoded.Poi;\n/**\n * Pack entry\n * @category entry builder\n * @param params - Params of entry\n * @returns Encoded entry\n */\nexport function packEntry(params: EntParams): Encoded.Any;\nexport function packEntry(params: EntParams): Encoded.Any {\n // `GaMetaTxAuthData` holds a `gasPrice` priced by them, see the note in `buildTx`\n const { protocolParameters } = params as ProtocolParametersOption;\n if (protocolParameters != null) checkParametersUsable(protocolParameters);\n const encoding = encodingTag.find(([tag]) => tag === params.tag)?.[1] ?? Encoding.Bytearray;\n return packRecord(schemas, EntryTag, params, { packEntry }, encoding);\n}\n\nexport function unpackEntry(\n encoded: Encoded.CallStateTree,\n): EntUnpacked & { tag: EntryTag.CallsMtree };\nexport function unpackEntry(\n encoded: Encoded.StateTrees,\n): EntUnpacked & { tag: EntryTag.StateTrees };\nexport function unpackEntry(encoded: Encoded.Poi): EntUnpacked & { tag: EntryTag.TreesPoi };\n/**\n * Unpack entry\n * @category entry builder\n * @param encoded - Encoded entry\n * @param expectedTag - Expected entry type\n * @returns Params of entry\n */\nexport function unpackEntry<T extends EntryTag>(\n encoded: Encoded.Any,\n expectedTag?: T,\n): EntUnpacked & { tag: T };\nexport function unpackEntry(encoded: Encoded.Any, expectedTag?: EntryTag): EntUnpacked {\n expectedTag ??= encodingTag.find(([, enc]) => encoded.startsWith(enc))?.[0];\n return unpackRecord(schemas, EntryTag, encoded, expectedTag, { unpackEntry }) as any;\n}\n"],"mappings":"AAAA,SAAkBA,QAAQ,QAAQ,2BAA2B;AAC7D,SAASC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AACvD,SAASC,OAAO,QAAQ,aAAa;AACrC,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,SAASC,qBAAqB,QAAkC,2BAA2B;AAE3F,MAAMC,WAAW,GAAG,CAClB,CAACF,QAAQ,CAACG,UAAU,EAAEP,QAAQ,CAACQ,aAAa,CAAC,EAC7C,CAACJ,QAAQ,CAACK,UAAU,EAAET,QAAQ,CAACS,UAAU,CAAC,EAC1C,CAACL,QAAQ,CAACM,QAAQ,EAAEV,QAAQ,CAACW,GAAG,CAAC,CACzB;;AAKV;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,SAASA,CAACC,MAAiB,EAAe;EAAA,IAAAC,kBAAA;EACxD;EACA,MAAM;IAAEC;EAAmB,CAAC,GAAGF,MAAkC;EACjE,IAAIE,kBAAkB,IAAI,IAAI,EAAEV,qBAAqB,CAACU,kBAAkB,CAAC;EACzE,MAAMC,QAAQ,IAAAF,kBAAA,GAAGR,WAAW,CAACW,IAAI,CAAC,CAAC,CAACC,GAAG,CAAC,KAAKA,GAAG,KAAKL,MAAM,CAACK,GAAG,CAAC,GAAG,CAAC,CAAC,cAAAJ,kBAAA,cAAAA,kBAAA,GAAId,QAAQ,CAACmB,SAAS;EAC3F,OAAOlB,UAAU,CAACE,OAAO,EAAEC,QAAQ,EAAES,MAAM,EAAE;IAAED;EAAU,CAAC,EAAEI,QAAQ,CAAC;AACvE;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,SAASI,WAAWA,CAACC,OAAoB,EAAEC,WAAsB,EAAe;EACrFA,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAXA,WAAW,GAAKhB,WAAW,CAACW,IAAI,CAAC,CAAC,GAAGM,GAAG,CAAC,KAAKF,OAAO,CAACG,UAAU,CAACD,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;EAC3E,OAAOrB,YAAY,CAACC,OAAO,EAAEC,QAAQ,EAAEiB,OAAO,EAAEC,WAAW,EAAE;IAAEF;EAAY,CAAC,CAAC;AAC/E","ignoreList":[]}
|
|
@@ -158,7 +158,7 @@ export declare const schemas: readonly [{
|
|
|
158
158
|
id: Encoded.Generic<import("../field-types/address.js").AddressEncodings | Encoding.Bytearray>;
|
|
159
159
|
} : import("../../../apis/node/index.js").NamePointer & {
|
|
160
160
|
id: Encoded.Generic<import("../field-types/address.js").AddressEncodings>;
|
|
161
|
-
}
|
|
161
|
+
}>, params: import("../field-types/interface.js").SerializeAsIsParams) => Buffer[][];
|
|
162
162
|
deserialize: (pointers: Array<[key: Buffer, id: Buffer]>) => Array<AllowRaw extends true ? import("../../../apis/node/index.js").NamePointer & {
|
|
163
163
|
id: Encoded.Generic<import("../field-types/address.js").AddressEncodings | Encoding.Bytearray>;
|
|
164
164
|
} : import("../../../apis/node/index.js").NamePointer & {
|
|
@@ -543,26 +543,26 @@ export declare const schemas: readonly [{
|
|
|
543
543
|
deserialize(buffer: Buffer): Buffer;
|
|
544
544
|
};
|
|
545
545
|
readonly gasPrice: {
|
|
546
|
-
prepare(value: import("../constants.js").Int | undefined, params: {}, { onNode, denomination, }: {
|
|
546
|
+
prepare(value: import("../constants.js").Int | undefined, params: {}, { onNode, denomination, protocolParameters, }: {
|
|
547
547
|
onNode?: import("../../../Node.js").default;
|
|
548
548
|
denomination?: import("../../../index-browser.js").AE_AMOUNT_FORMATS;
|
|
549
|
-
}): Promise<import("../constants.js").Int | undefined>;
|
|
550
|
-
serializeAettos(value
|
|
549
|
+
} & import("../protocol-parameters.js").ProtocolParametersOption): Promise<import("../constants.js").Int | undefined>;
|
|
550
|
+
serializeAettos(value: string | undefined, params: import("../field-types/interface.js").SerializeAsIsParams, { protocolParameters }: import("../protocol-parameters.js").ProtocolParametersOption): string;
|
|
551
551
|
serialize(value: import("../constants.js").Int | undefined, params: {}, { denomination, ...options }: {
|
|
552
552
|
denomination?: import("../../../index-browser.js").AE_AMOUNT_FORMATS;
|
|
553
553
|
}): Buffer;
|
|
554
554
|
deserialize(value: Buffer): string;
|
|
555
555
|
};
|
|
556
556
|
readonly gasLimit: {
|
|
557
|
-
serialize(_value: number | undefined,
|
|
557
|
+
serialize(_value: number | undefined, params: {
|
|
558
558
|
tag: import("../constants.js").Tag;
|
|
559
559
|
rebuildTx: (params: any) => any;
|
|
560
560
|
unpackTx: typeof import("../index.js").unpackTx;
|
|
561
561
|
buildTx: typeof import("../index.js").buildTx;
|
|
562
562
|
_computingGasLimit?: number;
|
|
563
|
-
}, { gasMax }: {
|
|
563
|
+
} & import("../field-types/interface.js").SerializeAsIsParams, { gasMax, protocolParameters, }: {
|
|
564
564
|
gasMax?: number;
|
|
565
|
-
}): Buffer;
|
|
565
|
+
} & import("../protocol-parameters.js").ProtocolParametersOption): Buffer;
|
|
566
566
|
deserialize(value: Buffer): number;
|
|
567
567
|
};
|
|
568
568
|
}, {
|
|
@@ -1009,11 +1009,11 @@ export declare const schemas: readonly [{
|
|
|
1009
1009
|
deserialize(value: Buffer): string;
|
|
1010
1010
|
};
|
|
1011
1011
|
readonly gasPrice: {
|
|
1012
|
-
prepare(value: import("../constants.js").Int | undefined, params: {}, { onNode, denomination, }: {
|
|
1012
|
+
prepare(value: import("../constants.js").Int | undefined, params: {}, { onNode, denomination, protocolParameters, }: {
|
|
1013
1013
|
onNode?: import("../../../Node.js").default;
|
|
1014
1014
|
denomination?: import("../../../index-browser.js").AE_AMOUNT_FORMATS;
|
|
1015
|
-
}): Promise<import("../constants.js").Int | undefined>;
|
|
1016
|
-
serializeAettos(value
|
|
1015
|
+
} & import("../protocol-parameters.js").ProtocolParametersOption): Promise<import("../constants.js").Int | undefined>;
|
|
1016
|
+
serializeAettos(value: string | undefined, params: import("../field-types/interface.js").SerializeAsIsParams, { protocolParameters }: import("../protocol-parameters.js").ProtocolParametersOption): string;
|
|
1017
1017
|
serialize(value: import("../constants.js").Int | undefined, params: {}, { denomination, ...options }: {
|
|
1018
1018
|
denomination?: import("../../../index-browser.js").AE_AMOUNT_FORMATS;
|
|
1019
1019
|
}): Buffer;
|
|
@@ -15,6 +15,20 @@ export declare const ProtocolToVmAbi: {
|
|
|
15
15
|
readonly abiVersion: readonly [AbiVersion.NoAbi, AbiVersion.Fate];
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
+
readonly 7: {
|
|
19
|
+
readonly 'contract-create': {
|
|
20
|
+
readonly vmVersion: readonly [VmVersion.Fate3];
|
|
21
|
+
readonly abiVersion: readonly [AbiVersion.Fate];
|
|
22
|
+
};
|
|
23
|
+
readonly 'contract-call': {
|
|
24
|
+
readonly vmVersion: readonly [];
|
|
25
|
+
readonly abiVersion: readonly [AbiVersion.Fate];
|
|
26
|
+
};
|
|
27
|
+
readonly 'oracle-call': {
|
|
28
|
+
readonly vmVersion: readonly [];
|
|
29
|
+
readonly abiVersion: readonly [AbiVersion.NoAbi, AbiVersion.Fate];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
18
32
|
};
|
|
19
33
|
export interface CtVersion {
|
|
20
34
|
vmVersion: VmVersion;
|
|
@@ -18,6 +18,20 @@ export const ProtocolToVmAbi = {
|
|
|
18
18
|
vmVersion: [],
|
|
19
19
|
abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate]
|
|
20
20
|
}
|
|
21
|
+
},
|
|
22
|
+
[ConsensusProtocolVersion.Arcus]: {
|
|
23
|
+
'contract-create': {
|
|
24
|
+
vmVersion: [VmVersion.Fate3],
|
|
25
|
+
abiVersion: [AbiVersion.Fate]
|
|
26
|
+
},
|
|
27
|
+
'contract-call': {
|
|
28
|
+
vmVersion: [],
|
|
29
|
+
abiVersion: [AbiVersion.Fate]
|
|
30
|
+
},
|
|
31
|
+
'oracle-call': {
|
|
32
|
+
vmVersion: [],
|
|
33
|
+
abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate]
|
|
34
|
+
}
|
|
21
35
|
}
|
|
22
36
|
};
|
|
23
37
|
export function getProtocolDetails(protocolVersion, type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-version.js","names":["ConsensusProtocolVersion","VmVersion","AbiVersion","ProtocolToVmAbi","Ceres","vmVersion","Fate3","abiVersion","Fate","NoAbi","getProtocolDetails","protocolVersion","type","_protocol$vmVersion$","protocol","Fate2","serialize","value","params","consensusProtocolVersion","_Buffer","from","prepare","options","undefined","Object","keys","length","onNode","getNodeInfo","deserialize","buffer","vm","abi"],"sources":["../../../../src/tx/builder/field-types/ct-version.ts"],"sourcesContent":["import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants.js';\nimport Node from '../../../Node.js';\n\n/*\n * First abi/vm by default\n * @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}\n */\nexport const ProtocolToVmAbi = {\n [ConsensusProtocolVersion.Ceres]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate3],\n abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.Fate],\n },\n 'oracle-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n} as const;\n\nexport interface CtVersion {\n vmVersion: VmVersion;\n abiVersion: AbiVersion;\n}\n\nexport function getProtocolDetails(\n protocolVersion: ConsensusProtocolVersion,\n type: 'contract-create' | 'contract-call' | 'oracle-call',\n): CtVersion {\n const protocol = ProtocolToVmAbi[protocolVersion][type];\n return {\n vmVersion: protocol.vmVersion[0] ?? VmVersion.Fate2,\n abiVersion: protocol.abiVersion[0],\n };\n}\n\nexport default {\n serialize(\n value: CtVersion | undefined,\n params: {},\n {\n consensusProtocolVersion = ConsensusProtocolVersion.Ceres,\n }: { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n value ??= getProtocolDetails(consensusProtocolVersion, 'contract-create');\n\n return Buffer.from([value.vmVersion, 0, value.abiVersion]);\n },\n\n async prepare(\n value: CtVersion | undefined,\n params: {},\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<CtVersion | 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 getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n 'contract-create',\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): CtVersion {\n const [vm, , abi] = buffer;\n return { vmVersion: +vm, abiVersion: +abi };\n },\n};\n"],"mappings":";AAAA,SAASA,wBAAwB,EAAEC,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AAGjF;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG;EAC7B,CAACH,wBAAwB,CAACI,KAAK,GAAG;IAChC,iBAAiB,EAAE;MACjBC,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAC5BC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;MACbE,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,aAAa,EAAE;MACbH,SAAS,EAAE,EAAE;MACbE,UAAU,EAAE,CAACL,UAAU,CAACO,KAAK,EAAEP,UAAU,CAACM,IAAI;IAChD;EACF;AACF,CAAU;AAOV,OAAO,
|
|
1
|
+
{"version":3,"file":"ct-version.js","names":["ConsensusProtocolVersion","VmVersion","AbiVersion","ProtocolToVmAbi","Ceres","vmVersion","Fate3","abiVersion","Fate","NoAbi","Arcus","getProtocolDetails","protocolVersion","type","_protocol$vmVersion$","protocol","Fate2","serialize","value","params","consensusProtocolVersion","_Buffer","from","prepare","options","undefined","Object","keys","length","onNode","getNodeInfo","deserialize","buffer","vm","abi"],"sources":["../../../../src/tx/builder/field-types/ct-version.ts"],"sourcesContent":["import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants.js';\nimport Node from '../../../Node.js';\n\n/*\n * First abi/vm by default\n * @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}\n */\nexport const ProtocolToVmAbi = {\n [ConsensusProtocolVersion.Ceres]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate3],\n abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.Fate],\n },\n 'oracle-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n [ConsensusProtocolVersion.Arcus]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate3],\n abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.Fate],\n },\n 'oracle-call': {\n vmVersion: [],\n abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n} as const;\n\nexport interface CtVersion {\n vmVersion: VmVersion;\n abiVersion: AbiVersion;\n}\n\nexport function getProtocolDetails(\n protocolVersion: ConsensusProtocolVersion,\n type: 'contract-create' | 'contract-call' | 'oracle-call',\n): CtVersion {\n const protocol = ProtocolToVmAbi[protocolVersion][type];\n return {\n vmVersion: protocol.vmVersion[0] ?? VmVersion.Fate2,\n abiVersion: protocol.abiVersion[0],\n };\n}\n\nexport default {\n serialize(\n value: CtVersion | undefined,\n params: {},\n {\n consensusProtocolVersion = ConsensusProtocolVersion.Ceres,\n }: { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n value ??= getProtocolDetails(consensusProtocolVersion, 'contract-create');\n\n return Buffer.from([value.vmVersion, 0, value.abiVersion]);\n },\n\n async prepare(\n value: CtVersion | undefined,\n params: {},\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<CtVersion | 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 getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n 'contract-create',\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): CtVersion {\n const [vm, , abi] = buffer;\n return { vmVersion: +vm, abiVersion: +abi };\n },\n};\n"],"mappings":";AAAA,SAASA,wBAAwB,EAAEC,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AAGjF;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG;EAC7B,CAACH,wBAAwB,CAACI,KAAK,GAAG;IAChC,iBAAiB,EAAE;MACjBC,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAC5BC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;MACbE,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,aAAa,EAAE;MACbH,SAAS,EAAE,EAAE;MACbE,UAAU,EAAE,CAACL,UAAU,CAACO,KAAK,EAAEP,UAAU,CAACM,IAAI;IAChD;EACF,CAAC;EACD,CAACR,wBAAwB,CAACU,KAAK,GAAG;IAChC,iBAAiB,EAAE;MACjBL,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAC5BC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;MACbE,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC9B,CAAC;IACD,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AAW,CAAC,CAAC,EAAEV,wBAAwB,EAC7D,iBACF,CAAC;IACH;IACA,OAAOK,SAAS;EAClB,CAAC;EAEDM,WAAWA,CAACC,MAAc,EAAa;IACrC,MAAM,CAACC,EAAE,GAAIC,GAAG,CAAC,GAAGF,MAAM;IAC1B,OAAO;MAAE3B,SAAS,EAAE,CAAC4B,EAAE;MAAE1B,UAAU,EAAE,CAAC2B;IAAI,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { Int } from '../constants.js';
|
|
3
|
+
import { ProtocolParameters, ProtocolParametersOption } from '../protocol-parameters.js';
|
|
3
4
|
import coinAmount from './coin-amount.js';
|
|
5
|
+
import { SerializeAsIsParams } from './interface.js';
|
|
4
6
|
import { Encoded } from '../../../utils/encoder.js';
|
|
5
7
|
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index.js';
|
|
6
8
|
import Node from '../../../Node.js';
|
|
7
9
|
/**
|
|
8
10
|
* Calculate gas based on tx type and params
|
|
9
11
|
*/
|
|
10
|
-
export declare function buildGas(builtTx: Encoded.Transaction, unpackTx: typeof unpackTxType, buildTx: typeof buildTxType): number;
|
|
11
|
-
export interface SerializeAettosParams {
|
|
12
|
+
export declare function buildGas(builtTx: Encoded.Transaction, unpackTx: typeof unpackTxType, buildTx: typeof buildTxType, protocolParameters: ProtocolParameters): number;
|
|
13
|
+
export interface SerializeAettosParams extends SerializeAsIsParams {
|
|
12
14
|
rebuildTx: (params: any) => Encoded.Transaction;
|
|
13
15
|
unpackTx: typeof unpackTxType;
|
|
14
16
|
buildTx: typeof buildTxType;
|
|
15
17
|
_computingMinFee?: BigNumber;
|
|
16
18
|
}
|
|
17
19
|
declare const _default: {
|
|
18
|
-
prepare(value: Int | undefined, params: {}, { onNode }: {
|
|
20
|
+
prepare(value: Int | undefined, params: {}, { onNode, protocolParameters }: {
|
|
19
21
|
onNode?: Node;
|
|
20
|
-
}): Promise<Int | undefined>;
|
|
21
|
-
serializeAettos(_value: string | undefined,
|
|
22
|
+
} & ProtocolParametersOption): Promise<Int | undefined>;
|
|
23
|
+
serializeAettos(_value: string | undefined, params: SerializeAettosParams, { _canIncreaseFee, protocolParameters, }: {
|
|
22
24
|
_canIncreaseFee?: boolean;
|
|
23
|
-
}): string;
|
|
25
|
+
} & ProtocolParametersOption): string;
|
|
24
26
|
serialize(value: Parameters<typeof coinAmount.serialize>[0], params: Parameters<typeof coinAmount.serialize>[1] & SerializeAettosParams, options: {
|
|
25
27
|
_canIncreaseFee?: boolean;
|
|
26
|
-
} & Parameters<typeof coinAmount.serialize>[2]): Buffer;
|
|
28
|
+
} & ProtocolParametersOption & Parameters<typeof coinAmount.serialize>[2]): Buffer;
|
|
27
29
|
deserialize(value: Buffer): string;
|
|
28
30
|
};
|
|
29
31
|
export default _default;
|
|
@@ -1,72 +1,70 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { ArgumentError, IllegalArgumentError } from '../../../utils/errors.js';
|
|
3
|
-
import {
|
|
2
|
+
import { ArgumentError, IllegalArgumentError, InternalError } from '../../../utils/errors.js';
|
|
3
|
+
import { Tag } from '../constants.js';
|
|
4
|
+
import { defaultProtocolParameters, maxOf } from '../protocol-parameters.js';
|
|
4
5
|
import uInt from './u-int.js';
|
|
5
6
|
import coinAmount from './coin-amount.js';
|
|
6
7
|
import { getCachedIncreasedGasPrice } from './gas-price.js';
|
|
7
8
|
import { isKeyOfObject } from '../../../utils/other.js';
|
|
9
|
+
import { serializeAsIsParam } from './interface.js';
|
|
8
10
|
import { decode } from '../../../utils/encoder.js';
|
|
9
|
-
const BASE_GAS = 15000;
|
|
10
|
-
const GAS_PER_BYTE = 20;
|
|
11
|
-
const KEY_BLOCK_INTERVAL = 3;
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
12
|
+
* Get the base gas
|
|
15
13
|
* @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}
|
|
16
|
-
* @param
|
|
14
|
+
* @param txObject - The unpacked transaction
|
|
15
|
+
* @param protocolParameters - The protocol parameters
|
|
17
16
|
* @returns The base gas
|
|
18
|
-
* @example
|
|
19
|
-
* ```js
|
|
20
|
-
* TX_BASE_GAS(Tag.ChannelForceProgressTx) => 30 * 15000
|
|
21
|
-
* ```
|
|
22
17
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
function getTxBaseGas(txObject, protocolParameters) {
|
|
19
|
+
const {
|
|
20
|
+
tag
|
|
21
|
+
} = txObject;
|
|
22
|
+
const byAbiVersion = protocolParameters.contractTxBaseGas[tag];
|
|
23
|
+
if (byAbiVersion != null) {
|
|
24
|
+
var _txObject$ctVersion$a;
|
|
25
|
+
const abiVersion = (_txObject$ctVersion$a = txObject.ctVersion?.abiVersion) !== null && _txObject$ctVersion$a !== void 0 ? _txObject$ctVersion$a : txObject.abiVersion;
|
|
26
|
+
// read only what the checks in `protocol-parameters.ts` iterate, so that the two can't
|
|
27
|
+
// disagree about what the parameters hold — anything inherited is not a base gas
|
|
28
|
+
const gas = Object.prototype.hasOwnProperty.call(byAbiVersion, abiVersion) ? byAbiVersion[abiVersion] : undefined;
|
|
29
|
+
if (gas != null) return gas;
|
|
30
|
+
// node charges the maximum base gas for an abi version it doesn't know
|
|
31
|
+
const knownAbiVersions = Object.values(byAbiVersion);
|
|
32
|
+
// the maximum of nothing is `-Infinity`, fall through to `txBaseGas` instead
|
|
33
|
+
if (knownAbiVersions.length !== 0) return maxOf(knownAbiVersions);
|
|
34
|
+
}
|
|
35
|
+
const gas = protocolParameters.txBaseGas[tag];
|
|
36
|
+
if (gas == null) throw new InternalError(`Base gas of ${Tag[tag]} is not known`);
|
|
37
|
+
return gas;
|
|
38
|
+
}
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* Calculate gas for other types of transactions
|
|
40
42
|
* @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}
|
|
41
43
|
* @param txType - The transaction type
|
|
42
44
|
* @param txSize - The transaction size
|
|
43
|
-
* @
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
45
|
+
* @param parameters - The transaction parameters
|
|
46
|
+
* @param parameters.relativeTtl - The relative ttl
|
|
47
|
+
* @param parameters.innerTxSize - The size of the inner transaction
|
|
48
|
+
* @param protocolParameters - The protocol parameters
|
|
46
49
|
* @returns The other gas
|
|
47
|
-
* @example
|
|
48
|
-
* ```js
|
|
49
|
-
* TX_OTHER_GAS(Tag.OracleRespondTx, 10, { relativeTtl: 12, innerTxSize: 0 })
|
|
50
|
-
* => 10 * 20 + Math.ceil(32000 * 12 / Math.floor(60 * 24 * 365 / 3))
|
|
51
|
-
* ```
|
|
52
50
|
*/
|
|
53
|
-
|
|
51
|
+
function getTxOtherGas(txType, txSize, {
|
|
54
52
|
relativeTtl,
|
|
55
53
|
innerTxSize
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
54
|
+
}, protocolParameters) {
|
|
55
|
+
const {
|
|
56
|
+
gasPerByte
|
|
57
|
+
} = protocolParameters;
|
|
58
|
+
// the inner transaction of a meta transaction pays for its own bytes in its own fee. The
|
|
59
|
+
// deduction is separate from the state gas below: node reporting a state gas fraction for
|
|
60
|
+
// `GaMetaTx`/`PayingForTx` must not cancel it — that would charge the inner transaction twice
|
|
61
|
+
const isMeta = txType === Tag.GaMetaTx || txType === Tag.PayingForTx;
|
|
62
|
+
const sizeGas = (isMeta ? txSize - innerTxSize : txSize) * gasPerByte;
|
|
63
|
+
// oracle transactions pay a state rent for the time their entry occupies the state tree
|
|
64
|
+
const stateGas = protocolParameters.stateGasPerBlock[txType];
|
|
65
|
+
if (stateGas == null) return sizeGas;
|
|
66
|
+
return sizeGas + Math.ceil(stateGas.part * relativeTtl / stateGas.whole);
|
|
67
|
+
}
|
|
70
68
|
function getOracleRelativeTtl(params) {
|
|
71
69
|
const ttlKeys = {
|
|
72
70
|
[Tag.OracleRegisterTx]: 'oracleTtlValue',
|
|
@@ -84,19 +82,25 @@ function getOracleRelativeTtl(params) {
|
|
|
84
82
|
/**
|
|
85
83
|
* Calculate gas based on tx type and params
|
|
86
84
|
*/
|
|
87
|
-
export function buildGas(builtTx, unpackTx, buildTx) {
|
|
85
|
+
export function buildGas(builtTx, unpackTx, buildTx, protocolParameters) {
|
|
88
86
|
const {
|
|
89
87
|
length
|
|
90
88
|
} = decode(builtTx);
|
|
91
89
|
const txObject = unpackTx(builtTx);
|
|
92
90
|
let innerTxSize = 0;
|
|
93
91
|
if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {
|
|
94
|
-
|
|
92
|
+
// this rebuild only measures the size of an already signed inner transaction, its values are
|
|
93
|
+
// serialized as they are — see `serializeAsIsParam`
|
|
94
|
+
const innerTx = {
|
|
95
|
+
...txObject.tx.encodedTx,
|
|
96
|
+
[serializeAsIsParam]: true
|
|
97
|
+
};
|
|
98
|
+
innerTxSize = decode(buildTx(innerTx)).length;
|
|
95
99
|
}
|
|
96
|
-
return
|
|
100
|
+
return getTxBaseGas(txObject, protocolParameters) + getTxOtherGas(txObject.tag, length, {
|
|
97
101
|
relativeTtl: getOracleRelativeTtl(txObject),
|
|
98
102
|
innerTxSize
|
|
99
|
-
});
|
|
103
|
+
}, protocolParameters);
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
/**
|
|
@@ -104,12 +108,13 @@ export function buildGas(builtTx, unpackTx, buildTx) {
|
|
|
104
108
|
* @category transaction builder
|
|
105
109
|
* @param rebuildTx - Callback to get built transaction with specific fee
|
|
106
110
|
*/
|
|
107
|
-
function calculateMinFee(rebuildTx, unpackTx, buildTx) {
|
|
111
|
+
function calculateMinFee(rebuildTx, unpackTx, buildTx, protocolParameters) {
|
|
112
|
+
const minGasPrice = new BigNumber(protocolParameters.minGasPrice.toString());
|
|
108
113
|
let fee = new BigNumber(0);
|
|
109
114
|
let previousFee;
|
|
110
115
|
do {
|
|
111
116
|
previousFee = fee;
|
|
112
|
-
fee =
|
|
117
|
+
fee = minGasPrice.times(buildGas(rebuildTx(fee), unpackTx, buildTx, protocolParameters));
|
|
113
118
|
} while (!fee.eq(previousFee));
|
|
114
119
|
return fee;
|
|
115
120
|
}
|
|
@@ -121,29 +126,33 @@ const gasPricePrefix = '_gas-price:';
|
|
|
121
126
|
export default {
|
|
122
127
|
...coinAmount,
|
|
123
128
|
async prepare(value, params, {
|
|
124
|
-
onNode
|
|
129
|
+
onNode,
|
|
130
|
+
protocolParameters
|
|
125
131
|
}) {
|
|
126
132
|
if (value != null) return value;
|
|
127
133
|
if (onNode == null) {
|
|
128
134
|
throw new ArgumentError('onNode', 'provided (or provide `fee` instead)', onNode);
|
|
129
135
|
}
|
|
130
|
-
const gasPrice = await getCachedIncreasedGasPrice(onNode);
|
|
136
|
+
const gasPrice = await getCachedIncreasedGasPrice(onNode, protocolParameters);
|
|
131
137
|
if (gasPrice === 0n) return undefined;
|
|
132
138
|
return gasPricePrefix + gasPrice;
|
|
133
139
|
},
|
|
134
|
-
serializeAettos(_value, {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
buildTx,
|
|
138
|
-
_computingMinFee
|
|
139
|
-
}, {
|
|
140
|
-
_canIncreaseFee
|
|
140
|
+
serializeAettos(_value, params, {
|
|
141
|
+
_canIncreaseFee,
|
|
142
|
+
protocolParameters = defaultProtocolParameters
|
|
141
143
|
}) {
|
|
144
|
+
const {
|
|
145
|
+
rebuildTx,
|
|
146
|
+
unpackTx,
|
|
147
|
+
buildTx,
|
|
148
|
+
_computingMinFee
|
|
149
|
+
} = params;
|
|
142
150
|
if (_computingMinFee != null) return _computingMinFee.toFixed();
|
|
151
|
+
if (params[serializeAsIsParam] === true && _value != null) return new BigNumber(_value).toFixed();
|
|
143
152
|
const minFee = calculateMinFee(fee => rebuildTx({
|
|
144
153
|
_computingMinFee: fee
|
|
145
|
-
}), unpackTx, buildTx);
|
|
146
|
-
const value = _value?.startsWith(gasPricePrefix) === true ? minFee.dividedBy(
|
|
154
|
+
}), unpackTx, buildTx, protocolParameters);
|
|
155
|
+
const value = _value?.startsWith(gasPricePrefix) === true ? minFee.dividedBy(protocolParameters.minGasPrice.toString()).times(_value.replace(gasPricePrefix, '')) : new BigNumber(_value !== null && _value !== void 0 ? _value : minFee);
|
|
147
156
|
if (minFee.gt(value)) {
|
|
148
157
|
if (_canIncreaseFee === true) return minFee.toFixed();
|
|
149
158
|
throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger than ${minFee}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee.js","names":["BigNumber","ArgumentError","IllegalArgumentError","MIN_GAS_PRICE","Tag","uInt","coinAmount","getCachedIncreasedGasPrice","isKeyOfObject","decode","BASE_GAS","GAS_PER_BYTE","KEY_BLOCK_INTERVAL","TX_BASE_GAS","txType","_feeFactors","feeFactors","ChannelForceProgressTx","ChannelOffChainTx","ContractCreateTx","ContractCallTx","GaAttachTx","GaMetaTx","PayingForTx","factor","TX_OTHER_GAS","txSize","relativeTtl","innerTxSize","OracleRegisterTx","OracleExtendTx","OracleQueryTx","OracleRespondTx","Math","ceil","floor","getOracleRelativeTtl","params","ttlKeys","tag","buildGas","builtTx","unpackTx","buildTx","length","txObject","tx","encodedTx","calculateMinFee","rebuildTx","fee","previousFee","times","eq","gasPricePrefix","prepare","value","onNode","gasPrice","undefined","serializeAettos","_value","_computingMinFee","_canIncreaseFee","toFixed","minFee","startsWith","dividedBy","replace","gt","toString","serialize","options","call"],"sources":["../../../../src/tx/builder/field-types/fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { ArgumentError, IllegalArgumentError } from '../../../utils/errors.js';\nimport { Int, MIN_GAS_PRICE, Tag } from '../constants.js';\nimport uInt from './u-int.js';\nimport coinAmount from './coin-amount.js';\nimport { getCachedIncreasedGasPrice } from './gas-price.js';\nimport { isKeyOfObject } from '../../../utils/other.js';\nimport { decode, Encoded } from '../../../utils/encoder.js';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index.js';\nimport Node from '../../../Node.js';\n\nconst BASE_GAS = 15000;\nconst GAS_PER_BYTE = 20;\nconst KEY_BLOCK_INTERVAL = 3;\n\n/**\n * Calculate the base 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 gas\n * @example\n * ```js\n * TX_BASE_GAS(Tag.ChannelForceProgressTx) => 30 * 15000\n * ```\n */\nconst TX_BASE_GAS = (txType: Tag): number => {\n const feeFactors = {\n [Tag.ChannelForceProgressTx]: 30,\n [Tag.ChannelOffChainTx]: 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 factor * BASE_GAS;\n};\n\n/**\n * Calculate gas 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 gas\n * @example\n * ```js\n * TX_OTHER_GAS(Tag.OracleRespondTx, 10, { relativeTtl: 12, innerTxSize: 0 })\n * => 10 * 20 + Math.ceil(32000 * 12 / Math.floor(60 * 24 * 365 / 3))\n * ```\n */\nconst TX_OTHER_GAS = (\n txType: Tag,\n txSize: number,\n { relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },\n): number => {\n switch (txType) {\n case Tag.OracleRegisterTx:\n case Tag.OracleExtendTx:\n case Tag.OracleQueryTx:\n case Tag.OracleRespondTx:\n return (\n txSize * GAS_PER_BYTE +\n Math.ceil((32000 * relativeTtl) / Math.floor((60 * 24 * 365) / KEY_BLOCK_INTERVAL))\n );\n case Tag.GaMetaTx:\n case Tag.PayingForTx:\n return (txSize - innerTxSize) * GAS_PER_BYTE;\n default:\n return txSize * GAS_PER_BYTE;\n }\n};\n\nfunction getOracleRelativeTtl(params: any): number {\n const ttlKeys = {\n [Tag.OracleRegisterTx]: 'oracleTtlValue',\n [Tag.OracleExtendTx]: 'oracleTtlValue',\n [Tag.OracleQueryTx]: 'queryTtlValue',\n [Tag.OracleRespondTx]: 'responseTtlValue',\n } as const;\n\n const { tag } = params;\n if (!isKeyOfObject(tag, ttlKeys)) return 1;\n return params[ttlKeys[tag]];\n}\n\n/**\n * Calculate gas based on tx type and params\n */\nexport function buildGas(\n builtTx: Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): number {\n const { length } = decode(builtTx);\n const txObject = unpackTx(builtTx);\n\n let innerTxSize = 0;\n if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {\n innerTxSize = decode(buildTx(txObject.tx.encodedTx)).length;\n }\n\n return (\n TX_BASE_GAS(txObject.tag) +\n TX_OTHER_GAS(txObject.tag, length, {\n relativeTtl: getOracleRelativeTtl(txObject),\n innerTxSize,\n })\n );\n}\n\n/**\n * Calculate min fee\n * @category transaction builder\n * @param rebuildTx - Callback to get built transaction with specific fee\n */\nfunction calculateMinFee(\n rebuildTx: (value: BigNumber) => Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): BigNumber {\n let fee = new BigNumber(0);\n let previousFee;\n do {\n previousFee = fee;\n fee = new BigNumber(MIN_GAS_PRICE).times(buildGas(rebuildTx(fee), unpackTx, buildTx));\n } while (!fee.eq(previousFee));\n return fee;\n}\n\n// TODO: Get rid of this workaround. Transaction builder can't accept/return gas price instead of\n// fee because it may get a decimal gas price. So, it should accept the optional `gasPrice` even\n// if it is not a contract-related transaction. And use this `gasPrice` to calculate `fee`.\nconst gasPricePrefix = '_gas-price:';\n\nexport interface SerializeAettosParams {\n rebuildTx: (params: any) => Encoded.Transaction;\n unpackTx: typeof unpackTxType;\n buildTx: typeof buildTxType;\n _computingMinFee?: BigNumber;\n}\n\nexport default {\n ...coinAmount,\n\n async prepare(\n value: Int | undefined,\n params: {},\n { onNode }: { onNode?: Node },\n ): Promise<Int | undefined> {\n if (value != null) return value;\n if (onNode == null) {\n throw new ArgumentError('onNode', 'provided (or provide `fee` instead)', onNode);\n }\n const gasPrice = await getCachedIncreasedGasPrice(onNode);\n if (gasPrice === 0n) return undefined;\n return gasPricePrefix + gasPrice;\n },\n\n serializeAettos(\n _value: string | undefined,\n { rebuildTx, unpackTx, buildTx, _computingMinFee }: SerializeAettosParams,\n { _canIncreaseFee }: { _canIncreaseFee?: boolean },\n ): string {\n if (_computingMinFee != null) return _computingMinFee.toFixed();\n const minFee = calculateMinFee(\n (fee) => rebuildTx({ _computingMinFee: fee }),\n unpackTx,\n buildTx,\n );\n const value =\n _value?.startsWith(gasPricePrefix) === true\n ? minFee.dividedBy(MIN_GAS_PRICE).times(_value.replace(gasPricePrefix, ''))\n : new BigNumber(_value ?? minFee);\n if (minFee.gt(value)) {\n if (_canIncreaseFee === true) return minFee.toFixed();\n throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger than ${minFee}`);\n }\n return value.toFixed();\n },\n\n serialize(\n value: Parameters<typeof coinAmount.serialize>[0],\n params: Parameters<typeof coinAmount.serialize>[1] & SerializeAettosParams,\n options: { _canIncreaseFee?: boolean } & Parameters<typeof coinAmount.serialize>[2],\n ): Buffer {\n if (typeof value === 'string' && value.startsWith(gasPricePrefix)) {\n return uInt.serialize(this.serializeAettos(value, params, options));\n }\n return coinAmount.serialize.call(this, value, params, options);\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,SAASC,aAAa,EAAEC,oBAAoB,QAAQ,0BAA0B;AAC9E,SAAcC,aAAa,EAAEC,GAAG,QAAQ,iBAAiB;AACzD,OAAOC,IAAI,MAAM,YAAY;AAC7B,OAAOC,UAAU,MAAM,kBAAkB;AACzC,SAASC,0BAA0B,QAAQ,gBAAgB;AAC3D,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,MAAM,QAAiB,2BAA2B;AAI3D,MAAMC,QAAQ,GAAG,KAAK;AACtB,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,kBAAkB,GAAG,CAAC;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAIC,MAAW,IAAa;EAAA,IAAAC,WAAA;EAC3C,MAAMC,UAAU,GAAG;IACjB,CAACZ,GAAG,CAACa,sBAAsB,GAAG,EAAE;IAChC,CAACb,GAAG,CAACc,iBAAiB,GAAG,CAAC;IAC1B,CAACd,GAAG,CAACe,gBAAgB,GAAG,CAAC;IACzB,CAACf,GAAG,CAACgB,cAAc,GAAG,EAAE;IACxB,CAAChB,GAAG,CAACiB,UAAU,GAAG,CAAC;IACnB,CAACjB,GAAG,CAACkB,QAAQ,GAAG,CAAC;IACjB,CAAClB,GAAG,CAACmB,WAAW,GAAG,CAAC,GAAG;EACzB,CAAU;EACV,MAAMC,MAAM,IAAAT,WAAA,GAAGC,UAAU,CAACF,MAAM,CAA4B,cAAAC,WAAA,cAAAA,WAAA,GAAI,CAAC;EACjE,OAAOS,MAAM,GAAGd,QAAQ;AAC1B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMe,YAAY,GAAGA,CACnBX,MAAW,EACXY,MAAc,EACd;EAAEC,WAAW;EAAEC;AAA0D,CAAC,KAC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AAEnB,MAAM,EAAEmC,OAAO,CAAC,CAAC;IACrE;IACA,OAAOlE,UAAU,CAACiE,SAAS,CAACE,IAAI,CAAC,IAAI,EAAEjB,KAAK,EAAEnB,MAAM,EAAEmC,OAAO,CAAC;EAChE;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"fee.js","names":["BigNumber","ArgumentError","IllegalArgumentError","InternalError","Tag","defaultProtocolParameters","maxOf","uInt","coinAmount","getCachedIncreasedGasPrice","isKeyOfObject","serializeAsIsParam","decode","getTxBaseGas","txObject","protocolParameters","tag","byAbiVersion","contractTxBaseGas","_txObject$ctVersion$a","abiVersion","ctVersion","gas","Object","prototype","hasOwnProperty","call","undefined","knownAbiVersions","values","length","txBaseGas","getTxOtherGas","txType","txSize","relativeTtl","innerTxSize","gasPerByte","isMeta","GaMetaTx","PayingForTx","sizeGas","stateGas","stateGasPerBlock","Math","ceil","part","whole","getOracleRelativeTtl","params","ttlKeys","OracleRegisterTx","OracleExtendTx","OracleQueryTx","OracleRespondTx","buildGas","builtTx","unpackTx","buildTx","innerTx","tx","encodedTx","calculateMinFee","rebuildTx","minGasPrice","toString","fee","previousFee","times","eq","gasPricePrefix","prepare","value","onNode","gasPrice","serializeAettos","_value","_canIncreaseFee","_computingMinFee","toFixed","minFee","startsWith","dividedBy","replace","gt","serialize","options"],"sources":["../../../../src/tx/builder/field-types/fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { ArgumentError, IllegalArgumentError, InternalError } from '../../../utils/errors.js';\nimport { Int, Tag } from '../constants.js';\nimport {\n defaultProtocolParameters,\n maxOf,\n ProtocolParameters,\n ProtocolParametersOption,\n} from '../protocol-parameters.js';\nimport uInt from './u-int.js';\nimport coinAmount from './coin-amount.js';\nimport { getCachedIncreasedGasPrice } from './gas-price.js';\nimport { isKeyOfObject } from '../../../utils/other.js';\nimport { serializeAsIsParam, SerializeAsIsParams } from './interface.js';\nimport { decode, Encoded } from '../../../utils/encoder.js';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index.js';\nimport Node from '../../../Node.js';\n\n/**\n * Get the base gas\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txObject - The unpacked transaction\n * @param protocolParameters - The protocol parameters\n * @returns The base gas\n */\nfunction getTxBaseGas(txObject: any, protocolParameters: ProtocolParameters): number {\n const { tag }: { tag: Tag } = txObject;\n const byAbiVersion = protocolParameters.contractTxBaseGas[tag];\n if (byAbiVersion != null) {\n const abiVersion = txObject.ctVersion?.abiVersion ?? txObject.abiVersion;\n // read only what the checks in `protocol-parameters.ts` iterate, so that the two can't\n // disagree about what the parameters hold — anything inherited is not a base gas\n const gas = Object.prototype.hasOwnProperty.call(byAbiVersion, abiVersion)\n ? byAbiVersion[abiVersion as keyof typeof byAbiVersion]\n : undefined;\n if (gas != null) return gas;\n // node charges the maximum base gas for an abi version it doesn't know\n const knownAbiVersions = Object.values(byAbiVersion);\n // the maximum of nothing is `-Infinity`, fall through to `txBaseGas` instead\n if (knownAbiVersions.length !== 0) return maxOf(knownAbiVersions);\n }\n const gas = protocolParameters.txBaseGas[tag];\n if (gas == null) throw new InternalError(`Base gas of ${Tag[tag]} is not known`);\n return gas;\n}\n\n/**\n * Calculate gas 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 * @param parameters - The transaction parameters\n * @param parameters.relativeTtl - The relative ttl\n * @param parameters.innerTxSize - The size of the inner transaction\n * @param protocolParameters - The protocol parameters\n * @returns The other gas\n */\nfunction getTxOtherGas(\n txType: Tag,\n txSize: number,\n { relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },\n protocolParameters: ProtocolParameters,\n): number {\n const { gasPerByte } = protocolParameters;\n // the inner transaction of a meta transaction pays for its own bytes in its own fee. The\n // deduction is separate from the state gas below: node reporting a state gas fraction for\n // `GaMetaTx`/`PayingForTx` must not cancel it — that would charge the inner transaction twice\n const isMeta = txType === Tag.GaMetaTx || txType === Tag.PayingForTx;\n const sizeGas = (isMeta ? txSize - innerTxSize : txSize) * gasPerByte;\n // oracle transactions pay a state rent for the time their entry occupies the state tree\n const stateGas = protocolParameters.stateGasPerBlock[txType];\n if (stateGas == null) return sizeGas;\n return sizeGas + Math.ceil((stateGas.part * relativeTtl) / stateGas.whole);\n}\n\nfunction getOracleRelativeTtl(params: any): number {\n const ttlKeys = {\n [Tag.OracleRegisterTx]: 'oracleTtlValue',\n [Tag.OracleExtendTx]: 'oracleTtlValue',\n [Tag.OracleQueryTx]: 'queryTtlValue',\n [Tag.OracleRespondTx]: 'responseTtlValue',\n } as const;\n\n const { tag } = params;\n if (!isKeyOfObject(tag, ttlKeys)) return 1;\n return params[ttlKeys[tag]];\n}\n\n/**\n * Calculate gas based on tx type and params\n */\nexport function buildGas(\n builtTx: Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n protocolParameters: ProtocolParameters,\n): number {\n const { length } = decode(builtTx);\n const txObject = unpackTx(builtTx);\n\n let innerTxSize = 0;\n if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {\n // this rebuild only measures the size of an already signed inner transaction, its values are\n // serialized as they are — see `serializeAsIsParam`\n const innerTx = { ...txObject.tx.encodedTx, [serializeAsIsParam]: true };\n innerTxSize = decode(buildTx(innerTx as Parameters<typeof buildTx>[0])).length;\n }\n\n return (\n getTxBaseGas(txObject, protocolParameters) +\n getTxOtherGas(\n txObject.tag,\n length,\n { relativeTtl: getOracleRelativeTtl(txObject), innerTxSize },\n protocolParameters,\n )\n );\n}\n\n/**\n * Calculate min fee\n * @category transaction builder\n * @param rebuildTx - Callback to get built transaction with specific fee\n */\nfunction calculateMinFee(\n rebuildTx: (value: BigNumber) => Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n protocolParameters: ProtocolParameters,\n): BigNumber {\n const minGasPrice = new BigNumber(protocolParameters.minGasPrice.toString());\n let fee = new BigNumber(0);\n let previousFee;\n do {\n previousFee = fee;\n fee = minGasPrice.times(buildGas(rebuildTx(fee), unpackTx, buildTx, protocolParameters));\n } while (!fee.eq(previousFee));\n return fee;\n}\n\n// TODO: Get rid of this workaround. Transaction builder can't accept/return gas price instead of\n// fee because it may get a decimal gas price. So, it should accept the optional `gasPrice` even\n// if it is not a contract-related transaction. And use this `gasPrice` to calculate `fee`.\nconst gasPricePrefix = '_gas-price:';\n\nexport interface SerializeAettosParams extends SerializeAsIsParams {\n rebuildTx: (params: any) => Encoded.Transaction;\n unpackTx: typeof unpackTxType;\n buildTx: typeof buildTxType;\n _computingMinFee?: BigNumber;\n}\n\nexport default {\n ...coinAmount,\n\n async prepare(\n value: Int | undefined,\n params: {},\n { onNode, protocolParameters }: { onNode?: Node } & ProtocolParametersOption,\n ): Promise<Int | undefined> {\n if (value != null) return value;\n if (onNode == null) {\n throw new ArgumentError('onNode', 'provided (or provide `fee` instead)', onNode);\n }\n const gasPrice = await getCachedIncreasedGasPrice(onNode, protocolParameters);\n if (gasPrice === 0n) return undefined;\n return gasPricePrefix + gasPrice;\n },\n\n serializeAettos(\n _value: string | undefined,\n params: SerializeAettosParams,\n {\n _canIncreaseFee,\n protocolParameters = defaultProtocolParameters,\n }: { _canIncreaseFee?: boolean } & ProtocolParametersOption,\n ): string {\n const { rebuildTx, unpackTx, buildTx, _computingMinFee } = params;\n if (_computingMinFee != null) return _computingMinFee.toFixed();\n if (params[serializeAsIsParam] === true && _value != null)\n return new BigNumber(_value).toFixed();\n const minFee = calculateMinFee(\n (fee) => rebuildTx({ _computingMinFee: fee }),\n unpackTx,\n buildTx,\n protocolParameters,\n );\n const value =\n _value?.startsWith(gasPricePrefix) === true\n ? minFee\n .dividedBy(protocolParameters.minGasPrice.toString())\n .times(_value.replace(gasPricePrefix, ''))\n : new BigNumber(_value ?? minFee);\n if (minFee.gt(value)) {\n if (_canIncreaseFee === true) return minFee.toFixed();\n throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger than ${minFee}`);\n }\n return value.toFixed();\n },\n\n serialize(\n value: Parameters<typeof coinAmount.serialize>[0],\n params: Parameters<typeof coinAmount.serialize>[1] & SerializeAettosParams,\n options: { _canIncreaseFee?: boolean } & ProtocolParametersOption &\n Parameters<typeof coinAmount.serialize>[2],\n ): Buffer {\n if (typeof value === 'string' && value.startsWith(gasPricePrefix)) {\n return uInt.serialize(this.serializeAettos(value, params, options));\n }\n return coinAmount.serialize.call(this, value, params, options);\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,SAASC,aAAa,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ,0BAA0B;AAC7F,SAAcC,GAAG,QAAQ,iBAAiB;AAC1C,SACEC,yBAAyB,EACzBC,KAAK,QAGA,2BAA2B;AAClC,OAAOC,IAAI,MAAM,YAAY;AAC7B,OAAOC,UAAU,MAAM,kBAAkB;AACzC,SAASC,0BAA0B,QAAQ,gBAAgB;AAC3D,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,kBAAkB,QAA6B,gBAAgB;AACxE,SAASC,MAAM,QAAiB,2BAA2B;AAI3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAACC,QAAa,EAAEC,kBAAsC,EAAU;EACnF,MAAM;IAAEC;EAAkB,CAAC,GAAGF,QAAQ;EACtC,MAAMG,YAAY,GAAGF,kBAAkB,CAACG,iBAAiB,CAACF,GAAG,CAAC;EAC9D,IAAIC,YAAY,IAAI,IAAI,EAAE;IAAA,IAAAE,qBAAA;IACxB,MAAMC,UAAU,IAAAD,qBAAA,GAAGL,QAAQ,CAACO,SAAS,EAAED,UAAU,cAAAD,qBAAA,cAAAA,qBAAA,GAAIL,QAAQ,CAACM,UAAU;IACxE;IACA;IACA,MAAME,GAAG,GAAGC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACT,YAAY,EAAEG,UAAU,CAAC,GACtEH,YAAY,CAACG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OAAO9E,UAAU,CAAC6E,SAAS,CAAC3D,IAAI,CAAC,IAAI,EAAE8C,KAAK,EAAEvB,MAAM,EAAEqC,OAAO,CAAC;EAChE;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Tag } from '../constants.js';
|
|
2
|
+
import { ProtocolParametersOption } from '../protocol-parameters.js';
|
|
3
|
+
import { SerializeAsIsParams } from './interface.js';
|
|
2
4
|
import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index.js';
|
|
3
5
|
declare const _default: {
|
|
4
|
-
serialize(_value: number | undefined,
|
|
6
|
+
serialize(_value: number | undefined, params: {
|
|
5
7
|
tag: Tag;
|
|
6
8
|
rebuildTx: (params: any) => any;
|
|
7
9
|
unpackTx: typeof unpackTxType;
|
|
8
10
|
buildTx: typeof buildTxType;
|
|
9
11
|
_computingGasLimit?: number;
|
|
10
|
-
}, { gasMax }: {
|
|
12
|
+
} & SerializeAsIsParams, { gasMax, protocolParameters, }: {
|
|
11
13
|
gasMax?: number;
|
|
12
|
-
}): Buffer;
|
|
14
|
+
} & ProtocolParametersOption): Buffer;
|
|
13
15
|
deserialize(value: Buffer): number;
|
|
14
16
|
};
|
|
15
17
|
export default _default;
|