@metamask/transaction-pay-controller 17.1.0 → 18.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/CHANGELOG.md +11 -1
- package/dist/strategy/across/across-quotes.cjs +64 -93
- package/dist/strategy/across/across-quotes.cjs.map +1 -1
- package/dist/strategy/across/across-quotes.d.cts.map +1 -1
- package/dist/strategy/across/across-quotes.d.mts.map +1 -1
- package/dist/strategy/across/across-quotes.mjs +65 -94
- package/dist/strategy/across/across-quotes.mjs.map +1 -1
- package/dist/strategy/across/across-submit.cjs +38 -37
- package/dist/strategy/across/across-submit.cjs.map +1 -1
- package/dist/strategy/across/across-submit.d.cts.map +1 -1
- package/dist/strategy/across/across-submit.d.mts.map +1 -1
- package/dist/strategy/across/across-submit.mjs +38 -37
- package/dist/strategy/across/across-submit.mjs.map +1 -1
- package/dist/strategy/across/transactions.cjs +23 -0
- package/dist/strategy/across/transactions.cjs.map +1 -0
- package/dist/strategy/across/transactions.d.cts +18 -0
- package/dist/strategy/across/transactions.d.cts.map +1 -0
- package/dist/strategy/across/transactions.d.mts +18 -0
- package/dist/strategy/across/transactions.d.mts.map +1 -0
- package/dist/strategy/across/transactions.mjs +19 -0
- package/dist/strategy/across/transactions.mjs.map +1 -0
- package/dist/strategy/across/types.cjs.map +1 -1
- package/dist/strategy/across/types.d.cts +6 -10
- package/dist/strategy/across/types.d.cts.map +1 -1
- package/dist/strategy/across/types.d.mts +6 -10
- package/dist/strategy/across/types.d.mts.map +1 -1
- package/dist/strategy/across/types.mjs.map +1 -1
- package/dist/strategy/relay/relay-quotes.cjs +49 -135
- package/dist/strategy/relay/relay-quotes.cjs.map +1 -1
- package/dist/strategy/relay/relay-quotes.d.cts.map +1 -1
- package/dist/strategy/relay/relay-quotes.d.mts.map +1 -1
- package/dist/strategy/relay/relay-quotes.mjs +51 -137
- package/dist/strategy/relay/relay-quotes.mjs.map +1 -1
- package/dist/strategy/relay/relay-submit.cjs +4 -3
- package/dist/strategy/relay/relay-submit.cjs.map +1 -1
- package/dist/strategy/relay/relay-submit.mjs +4 -3
- package/dist/strategy/relay/relay-submit.mjs.map +1 -1
- package/dist/strategy/relay/types.cjs.map +1 -1
- package/dist/strategy/relay/types.d.cts +10 -5
- package/dist/strategy/relay/types.d.cts.map +1 -1
- package/dist/strategy/relay/types.d.mts +10 -5
- package/dist/strategy/relay/types.d.mts.map +1 -1
- package/dist/strategy/relay/types.mjs.map +1 -1
- package/dist/utils/quote-gas.cjs +143 -0
- package/dist/utils/quote-gas.cjs.map +1 -0
- package/dist/utils/quote-gas.d.cts +31 -0
- package/dist/utils/quote-gas.d.cts.map +1 -0
- package/dist/utils/quote-gas.d.mts +31 -0
- package/dist/utils/quote-gas.d.mts.map +1 -0
- package/dist/utils/quote-gas.mjs +139 -0
- package/dist/utils/quote-gas.mjs.map +1 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/strategy/relay/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport type RelayQuoteRequest = {\n amount: string;\n authorizationList?: {\n address: Hex;\n chainId: number;\n nonce: number;\n r: Hex;\n s: Hex;\n yParity: number;\n }[];\n destinationChainId: number;\n destinationCurrency: Hex;\n originChainId: number;\n originCurrency: Hex;\n originGasOverhead?: string;\n recipient: Hex;\n refundTo?: Hex;\n slippageTolerance?: string;\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT';\n txs?: {\n to: Hex;\n data: Hex;\n value: Hex;\n }[];\n user: Hex;\n};\n\nexport type RelayQuote = {\n details: {\n currencyIn: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n chainId: number;\n decimals: number;\n };\n };\n currencyOut: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n chainId: number;\n decimals: number;\n };\n minimumAmount: string;\n };\n timeEstimate: number;\n totalImpact: {\n usd: string;\n };\n };\n fees: {\n app?: {\n amountUsd: string;\n };\n relayer: {\n amountUsd: string;\n };\n subsidized?: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n address: Hex;\n chainId: number;\n decimals: number;\n };\n minimumAmount: string;\n };\n };\n metamask:
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/strategy/relay/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport type RelayQuoteRequest = {\n amount: string;\n authorizationList?: {\n address: Hex;\n chainId: number;\n nonce: number;\n r: Hex;\n s: Hex;\n yParity: number;\n }[];\n destinationChainId: number;\n destinationCurrency: Hex;\n originChainId: number;\n originCurrency: Hex;\n originGasOverhead?: string;\n recipient: Hex;\n refundTo?: Hex;\n slippageTolerance?: string;\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT';\n txs?: {\n to: Hex;\n data: Hex;\n value: Hex;\n }[];\n user: Hex;\n};\n\nexport type RelayQuote = {\n details: {\n currencyIn: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n chainId: number;\n decimals: number;\n };\n };\n currencyOut: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n chainId: number;\n decimals: number;\n };\n minimumAmount: string;\n };\n timeEstimate: number;\n totalImpact: {\n usd: string;\n };\n };\n fees: {\n app?: {\n amountUsd: string;\n };\n relayer: {\n amountUsd: string;\n };\n subsidized?: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n address: Hex;\n chainId: number;\n decimals: number;\n };\n minimumAmount: string;\n };\n };\n metamask: RelayQuoteMetamask;\n request: RelayQuoteRequest;\n steps: {\n id: string;\n items: {\n check: {\n endpoint: string;\n method: 'GET' | 'POST';\n };\n data: {\n chainId: number;\n data: Hex;\n from: Hex;\n gas?: string;\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n to: Hex;\n value?: string;\n };\n status: 'complete' | 'incomplete';\n }[];\n kind: 'transaction';\n requestId: string;\n }[];\n};\n\ntype RelayQuoteMetamaskBase = {\n isExecute?: boolean;\n isMaxGasStation?: boolean;\n};\n\nexport type RelayQuoteMetamask = RelayQuoteMetamaskBase & {\n gasLimits: number[];\n is7702: boolean;\n};\n\nexport type RelayExecuteRequest = {\n executionKind: 'rawCalls';\n data: {\n chainId: number;\n to: Hex;\n data: Hex;\n value: string;\n authorizationList?: {\n chainId: number;\n address: Hex;\n nonce: number;\n yParity: number;\n r: Hex;\n s: Hex;\n }[];\n };\n executionOptions: {\n referrer?: string;\n subsidizeFees: boolean;\n };\n requestId?: string;\n};\n\nexport type RelayExecuteResponse = {\n message: string;\n requestId: string;\n};\n\nexport type RelayStatus =\n | 'delayed'\n | 'depositing'\n | 'failure'\n | 'pending'\n | 'refund'\n | 'refunded'\n | 'submitted'\n | 'success'\n | 'waiting';\n\nexport type RelayStatusResponse = {\n status: RelayStatus;\n inTxHashes: string[];\n txHashes: string[];\n updatedAt: number;\n originChainId: number;\n destinationChainId: number;\n};\n"]}
|
|
@@ -70,11 +70,7 @@ export type RelayQuote = {
|
|
|
70
70
|
minimumAmount: string;
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
-
metamask:
|
|
74
|
-
gasLimits: number[];
|
|
75
|
-
isExecute?: boolean;
|
|
76
|
-
isMaxGasStation?: boolean;
|
|
77
|
-
};
|
|
73
|
+
metamask: RelayQuoteMetamask;
|
|
78
74
|
request: RelayQuoteRequest;
|
|
79
75
|
steps: {
|
|
80
76
|
id: string;
|
|
@@ -99,6 +95,14 @@ export type RelayQuote = {
|
|
|
99
95
|
requestId: string;
|
|
100
96
|
}[];
|
|
101
97
|
};
|
|
98
|
+
type RelayQuoteMetamaskBase = {
|
|
99
|
+
isExecute?: boolean;
|
|
100
|
+
isMaxGasStation?: boolean;
|
|
101
|
+
};
|
|
102
|
+
export type RelayQuoteMetamask = RelayQuoteMetamaskBase & {
|
|
103
|
+
gasLimits: number[];
|
|
104
|
+
is7702: boolean;
|
|
105
|
+
};
|
|
102
106
|
export type RelayExecuteRequest = {
|
|
103
107
|
executionKind: 'rawCalls';
|
|
104
108
|
data: {
|
|
@@ -134,4 +138,5 @@ export type RelayStatusResponse = {
|
|
|
134
138
|
originChainId: number;
|
|
135
139
|
destinationChainId: number;
|
|
136
140
|
};
|
|
141
|
+
export {};
|
|
137
142
|
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/strategy/relay/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE;QAClB,OAAO,EAAE,GAAG,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,CAAC,EAAE,GAAG,CAAC;QACP,CAAC,EAAE,GAAG,CAAC;QACP,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,GAAG,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,GAAG,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,GAAG,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,aAAa,GAAG,cAAc,GAAG,iBAAiB,CAAC;IAC9D,GAAG,CAAC,EAAE;QACJ,EAAE,EAAE,GAAG,CAAC;QACR,IAAI,EAAE,GAAG,CAAC;QACV,KAAK,EAAE,GAAG,CAAC;KACZ,EAAE,CAAC;IACJ,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF,MAA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|
|
@@ -70,11 +70,7 @@ export type RelayQuote = {
|
|
|
70
70
|
minimumAmount: string;
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
-
metamask:
|
|
74
|
-
gasLimits: number[];
|
|
75
|
-
isExecute?: boolean;
|
|
76
|
-
isMaxGasStation?: boolean;
|
|
77
|
-
};
|
|
73
|
+
metamask: RelayQuoteMetamask;
|
|
78
74
|
request: RelayQuoteRequest;
|
|
79
75
|
steps: {
|
|
80
76
|
id: string;
|
|
@@ -99,6 +95,14 @@ export type RelayQuote = {
|
|
|
99
95
|
requestId: string;
|
|
100
96
|
}[];
|
|
101
97
|
};
|
|
98
|
+
type RelayQuoteMetamaskBase = {
|
|
99
|
+
isExecute?: boolean;
|
|
100
|
+
isMaxGasStation?: boolean;
|
|
101
|
+
};
|
|
102
|
+
export type RelayQuoteMetamask = RelayQuoteMetamaskBase & {
|
|
103
|
+
gasLimits: number[];
|
|
104
|
+
is7702: boolean;
|
|
105
|
+
};
|
|
102
106
|
export type RelayExecuteRequest = {
|
|
103
107
|
executionKind: 'rawCalls';
|
|
104
108
|
data: {
|
|
@@ -134,4 +138,5 @@ export type RelayStatusResponse = {
|
|
|
134
138
|
originChainId: number;
|
|
135
139
|
destinationChainId: number;
|
|
136
140
|
};
|
|
141
|
+
export {};
|
|
137
142
|
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/strategy/relay/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE;QAClB,OAAO,EAAE,GAAG,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,CAAC,EAAE,GAAG,CAAC;QACP,CAAC,EAAE,GAAG,CAAC;QACP,O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AAO,CAAC;KACxB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,YAAY,GACZ,SAAS,GACT,SAAS,GACT,QAAQ,GACR,UAAU,GACV,WAAW,GACX,SAAS,GACT,SAAS,CAAC;AAEd,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/strategy/relay/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport type RelayQuoteRequest = {\n amount: string;\n authorizationList?: {\n address: Hex;\n chainId: number;\n nonce: number;\n r: Hex;\n s: Hex;\n yParity: number;\n }[];\n destinationChainId: number;\n destinationCurrency: Hex;\n originChainId: number;\n originCurrency: Hex;\n originGasOverhead?: string;\n recipient: Hex;\n refundTo?: Hex;\n slippageTolerance?: string;\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT';\n txs?: {\n to: Hex;\n data: Hex;\n value: Hex;\n }[];\n user: Hex;\n};\n\nexport type RelayQuote = {\n details: {\n currencyIn: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n chainId: number;\n decimals: number;\n };\n };\n currencyOut: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n chainId: number;\n decimals: number;\n };\n minimumAmount: string;\n };\n timeEstimate: number;\n totalImpact: {\n usd: string;\n };\n };\n fees: {\n app?: {\n amountUsd: string;\n };\n relayer: {\n amountUsd: string;\n };\n subsidized?: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n address: Hex;\n chainId: number;\n decimals: number;\n };\n minimumAmount: string;\n };\n };\n metamask:
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/strategy/relay/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport type RelayQuoteRequest = {\n amount: string;\n authorizationList?: {\n address: Hex;\n chainId: number;\n nonce: number;\n r: Hex;\n s: Hex;\n yParity: number;\n }[];\n destinationChainId: number;\n destinationCurrency: Hex;\n originChainId: number;\n originCurrency: Hex;\n originGasOverhead?: string;\n recipient: Hex;\n refundTo?: Hex;\n slippageTolerance?: string;\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT';\n txs?: {\n to: Hex;\n data: Hex;\n value: Hex;\n }[];\n user: Hex;\n};\n\nexport type RelayQuote = {\n details: {\n currencyIn: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n chainId: number;\n decimals: number;\n };\n };\n currencyOut: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n chainId: number;\n decimals: number;\n };\n minimumAmount: string;\n };\n timeEstimate: number;\n totalImpact: {\n usd: string;\n };\n };\n fees: {\n app?: {\n amountUsd: string;\n };\n relayer: {\n amountUsd: string;\n };\n subsidized?: {\n amount: string;\n amountFormatted: string;\n amountUsd: string;\n currency: {\n address: Hex;\n chainId: number;\n decimals: number;\n };\n minimumAmount: string;\n };\n };\n metamask: RelayQuoteMetamask;\n request: RelayQuoteRequest;\n steps: {\n id: string;\n items: {\n check: {\n endpoint: string;\n method: 'GET' | 'POST';\n };\n data: {\n chainId: number;\n data: Hex;\n from: Hex;\n gas?: string;\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n to: Hex;\n value?: string;\n };\n status: 'complete' | 'incomplete';\n }[];\n kind: 'transaction';\n requestId: string;\n }[];\n};\n\ntype RelayQuoteMetamaskBase = {\n isExecute?: boolean;\n isMaxGasStation?: boolean;\n};\n\nexport type RelayQuoteMetamask = RelayQuoteMetamaskBase & {\n gasLimits: number[];\n is7702: boolean;\n};\n\nexport type RelayExecuteRequest = {\n executionKind: 'rawCalls';\n data: {\n chainId: number;\n to: Hex;\n data: Hex;\n value: string;\n authorizationList?: {\n chainId: number;\n address: Hex;\n nonce: number;\n yParity: number;\n r: Hex;\n s: Hex;\n }[];\n };\n executionOptions: {\n referrer?: string;\n subsidizeFees: boolean;\n };\n requestId?: string;\n};\n\nexport type RelayExecuteResponse = {\n message: string;\n requestId: string;\n};\n\nexport type RelayStatus =\n | 'delayed'\n | 'depositing'\n | 'failure'\n | 'pending'\n | 'refund'\n | 'refunded'\n | 'submitted'\n | 'success'\n | 'waiting';\n\nexport type RelayStatusResponse = {\n status: RelayStatus;\n inTxHashes: string[];\n txHashes: string[];\n updatedAt: number;\n originChainId: number;\n destinationChainId: number;\n};\n"]}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.estimateQuoteGasLimits = void 0;
|
|
4
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
7
|
+
const feature_flags_1 = require("./feature-flags.cjs");
|
|
8
|
+
const gas_1 = require("./gas.cjs");
|
|
9
|
+
const logger_1 = require("../logger.cjs");
|
|
10
|
+
const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'quote-gas');
|
|
11
|
+
async function estimateQuoteGasLimits({ fallbackGas, fallbackOnSimulationFailure = false, messenger, transactions, }) {
|
|
12
|
+
if (transactions.length === 0) {
|
|
13
|
+
throw new Error('Quote gas estimation requires at least one transaction');
|
|
14
|
+
}
|
|
15
|
+
const useBatch = transactions.length > 1;
|
|
16
|
+
if (useBatch) {
|
|
17
|
+
return {
|
|
18
|
+
...(await estimateQuoteGasLimitsBatch(transactions, messenger)),
|
|
19
|
+
usedBatch: true,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
...(await estimateQuoteGasLimitSingle({
|
|
24
|
+
fallbackGas,
|
|
25
|
+
fallbackOnSimulationFailure,
|
|
26
|
+
messenger,
|
|
27
|
+
transaction: transactions[0],
|
|
28
|
+
})),
|
|
29
|
+
is7702: false,
|
|
30
|
+
usedBatch: false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.estimateQuoteGasLimits = estimateQuoteGasLimits;
|
|
34
|
+
async function estimateQuoteGasLimitsBatch(transactions, messenger) {
|
|
35
|
+
const [firstTransaction] = transactions;
|
|
36
|
+
const gasBuffer = (0, feature_flags_1.getGasBuffer)(messenger, firstTransaction.chainId);
|
|
37
|
+
const paramGasLimits = transactions.map((transaction) => parseGasLimit(transaction.gas));
|
|
38
|
+
const { gasLimits } = await messenger.call('TransactionController:estimateGasBatch', {
|
|
39
|
+
chainId: firstTransaction.chainId,
|
|
40
|
+
from: firstTransaction.from,
|
|
41
|
+
transactions: transactions.map(toBatchTransactionParams),
|
|
42
|
+
});
|
|
43
|
+
if (gasLimits.length !== 1 && gasLimits.length !== transactions.length) {
|
|
44
|
+
throw new Error('Unexpected batch gas limit count');
|
|
45
|
+
}
|
|
46
|
+
const bufferedGasLimits = gasLimits.map((gasLimit, index) => {
|
|
47
|
+
const providedGasLimit = paramGasLimits[index];
|
|
48
|
+
const providedGasWasPreserved = providedGasLimit !== undefined && providedGasLimit === gasLimit;
|
|
49
|
+
// Per-entry batch results currently preserve validated input gas values
|
|
50
|
+
// for transactions that already provided gas. If that contract changes
|
|
51
|
+
// and batch estimation returns a different value, treat it as a fresh
|
|
52
|
+
// estimate and apply the buffer. A single combined 7702 result is always
|
|
53
|
+
// buffered because it is a fresh batch estimate.
|
|
54
|
+
const useBuffer = gasLimits.length === 1 || !providedGasWasPreserved;
|
|
55
|
+
const bufferedGas = Math.ceil(gasLimit * (useBuffer ? gasBuffer : 1));
|
|
56
|
+
return {
|
|
57
|
+
estimate: bufferedGas,
|
|
58
|
+
max: bufferedGas,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const totalGasLimit = bufferedGasLimits.reduce((acc, gasLimit) => acc + gasLimit.max, 0);
|
|
62
|
+
const is7702 = bufferedGasLimits.length === 1;
|
|
63
|
+
const batchGasLimit = is7702 ? bufferedGasLimits[0] : undefined;
|
|
64
|
+
return {
|
|
65
|
+
...(batchGasLimit ? { batchGasLimit } : {}),
|
|
66
|
+
gasLimits: bufferedGasLimits,
|
|
67
|
+
is7702,
|
|
68
|
+
totalGasEstimate: totalGasLimit,
|
|
69
|
+
totalGasLimit,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async function estimateQuoteGasLimitSingle({ fallbackGas, fallbackOnSimulationFailure, messenger, transaction, }) {
|
|
73
|
+
const providedGasLimit = parseGasLimit(transaction.gas);
|
|
74
|
+
if (providedGasLimit !== undefined) {
|
|
75
|
+
log('Using provided gas limit', {
|
|
76
|
+
chainId: transaction.chainId,
|
|
77
|
+
gas: providedGasLimit,
|
|
78
|
+
index: 0,
|
|
79
|
+
to: transaction.to,
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
gasLimits: [
|
|
83
|
+
{
|
|
84
|
+
estimate: providedGasLimit,
|
|
85
|
+
max: providedGasLimit,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
totalGasEstimate: providedGasLimit,
|
|
89
|
+
totalGasLimit: providedGasLimit,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const gasLimitResult = await (0, gas_1.estimateGasLimit)({
|
|
93
|
+
chainId: transaction.chainId,
|
|
94
|
+
data: transaction.data,
|
|
95
|
+
fallbackGas,
|
|
96
|
+
fallbackOnSimulationFailure,
|
|
97
|
+
from: transaction.from,
|
|
98
|
+
messenger,
|
|
99
|
+
to: transaction.to,
|
|
100
|
+
value: (0, controller_utils_1.toHex)(transaction.value ?? '0'),
|
|
101
|
+
});
|
|
102
|
+
if (gasLimitResult.usedFallback) {
|
|
103
|
+
log('Gas estimate failed, using fallback', {
|
|
104
|
+
chainId: transaction.chainId,
|
|
105
|
+
error: gasLimitResult.error,
|
|
106
|
+
index: 0,
|
|
107
|
+
to: transaction.to,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const gasLimit = {
|
|
111
|
+
estimate: gasLimitResult.estimate,
|
|
112
|
+
max: gasLimitResult.max,
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
gasLimits: [gasLimit],
|
|
116
|
+
totalGasEstimate: gasLimit.estimate,
|
|
117
|
+
totalGasLimit: gasLimit.max,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function toBatchTransactionParams(transaction) {
|
|
121
|
+
return {
|
|
122
|
+
data: transaction.data,
|
|
123
|
+
gas: transaction.gas === undefined ? undefined : (0, controller_utils_1.toHex)(transaction.gas),
|
|
124
|
+
maxFeePerGas: undefined,
|
|
125
|
+
maxPriorityFeePerGas: undefined,
|
|
126
|
+
to: transaction.to,
|
|
127
|
+
value: (0, controller_utils_1.toHex)(transaction.value ?? '0'),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function parseGasLimit(gas) {
|
|
131
|
+
if (gas === undefined) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
const parsedGas = new bignumber_js_1.BigNumber(gas);
|
|
135
|
+
if (!parsedGas.isFinite() ||
|
|
136
|
+
parsedGas.isNaN() ||
|
|
137
|
+
!parsedGas.isInteger() ||
|
|
138
|
+
parsedGas.lte(0)) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
return parsedGas.toNumber();
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=quote-gas.cj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,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport type { BatchTransactionParams } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport { getGasBuffer } from './feature-flags';\nimport { estimateGasLimit } from './gas';\nimport type { TransactionPayControllerMessenger } from '..';\nimport { projectLogger } from '../logger';\n\nconst log = createModuleLogger(projectLogger, 'quote-gas');\n\nexport type QuoteGasTransaction = {\n chainId: Hex;\n data: Hex;\n from: Hex;\n gas?: number | string;\n to: Hex;\n value?: number | string | Hex;\n};\n\nexport type QuoteGasLimit = {\n estimate: number;\n max: number;\n};\n\nexport async function estimateQuoteGasLimits({\n fallbackGas,\n fallbackOnSimulationFailure = false,\n messenger,\n transactions,\n}: {\n fallbackGas?: {\n estimate: number;\n max: number;\n };\n fallbackOnSimulationFailure?: boolean;\n messenger: TransactionPayControllerMessenger;\n transactions: QuoteGasTransaction[];\n}): Promise<{\n batchGasLimit?: QuoteGasLimit;\n gasLimits: QuoteGasLimit[];\n is7702: boolean;\n totalGasEstimate: number;\n totalGasLimit: number;\n usedBatch: boolean;\n}> {\n if (transactions.length === 0) {\n throw new Error('Quote gas estimation requires at least one transaction');\n }\n\n const useBatch = transactions.length > 1;\n\n if (useBatch) {\n return {\n ...(await estimateQuoteGasLimitsBatch(transactions, messenger)),\n usedBatch: true,\n };\n }\n\n return {\n ...(await estimateQuoteGasLimitSingle({\n fallbackGas,\n fallbackOnSimulationFailure,\n messenger,\n transaction: transactions[0],\n })),\n is7702: false,\n usedBatch: false,\n };\n}\n\nasync function estimateQuoteGasLimitsBatch(\n transactions: QuoteGasTransaction[],\n messenger: TransactionPayControllerMessenger,\n): Promise<{\n batchGasLimit?: QuoteGasLimit;\n gasLimits: QuoteGasLimit[];\n is7702: boolean;\n totalGasEstimate: number;\n totalGasLimit: number;\n}> {\n const [firstTransaction] = transactions;\n const gasBuffer = getGasBuffer(messenger, firstTransaction.chainId);\n\n const paramGasLimits = transactions.map((transaction) =>\n parseGasLimit(transaction.gas),\n );\n\n const { gasLimits } = await messenger.call(\n 'TransactionController:estimateGasBatch',\n {\n chainId: firstTransaction.chainId,\n from: firstTransaction.from,\n transactions: transactions.map(toBatchTransactionParams),\n },\n );\n\n if (gasLimits.length !== 1 && gasLimits.length !== transactions.length) {\n throw new Error('Unexpected batch gas limit count');\n }\n\n const bufferedGasLimits = gasLimits.map((gasLimit, index) => {\n const providedGasLimit = paramGasLimits[index];\n const providedGasWasPreserved =\n providedGasLimit !== undefined && providedGasLimit === gasLimit;\n\n // Per-entry batch results currently preserve validated input gas values\n // for transactions that already provided gas. If that contract changes\n // and batch estimation returns a different value, treat it as a fresh\n // estimate and apply the buffer. A single combined 7702 result is always\n // buffered because it is a fresh batch estimate.\n const useBuffer = gasLimits.length === 1 || !providedGasWasPreserved;\n const bufferedGas = Math.ceil(gasLimit * (useBuffer ? gasBuffer : 1));\n\n return {\n estimate: bufferedGas,\n max: bufferedGas,\n };\n });\n\n const totalGasLimit = bufferedGasLimits.reduce(\n (acc, gasLimit) => acc + gasLimit.max,\n 0,\n );\n const is7702 = bufferedGasLimits.length === 1;\n const batchGasLimit = is7702 ? bufferedGasLimits[0] : undefined;\n\n return {\n ...(batchGasLimit ? { batchGasLimit } : {}),\n gasLimits: bufferedGasLimits,\n is7702,\n totalGasEstimate: totalGasLimit,\n totalGasLimit,\n };\n}\n\nasync function estimateQuoteGasLimitSingle({\n fallbackGas,\n fallbackOnSimulationFailure,\n messenger,\n transaction,\n}: {\n fallbackGas?: {\n estimate: number;\n max: number;\n };\n fallbackOnSimulationFailure: boolean;\n messenger: TransactionPayControllerMessenger;\n transaction: QuoteGasTransaction;\n}): Promise<{\n gasLimits: QuoteGasLimit[];\n totalGasEstimate: number;\n totalGasLimit: number;\n}> {\n const providedGasLimit = parseGasLimit(transaction.gas);\n\n if (providedGasLimit !== undefined) {\n log('Using provided gas limit', {\n chainId: transaction.chainId,\n gas: providedGasLimit,\n index: 0,\n to: transaction.to,\n });\n\n return {\n gasLimits: [\n {\n estimate: providedGasLimit,\n max: providedGasLimit,\n },\n ],\n totalGasEstimate: providedGasLimit,\n totalGasLimit: providedGasLimit,\n };\n }\n\n const gasLimitResult = await estimateGasLimit({\n chainId: transaction.chainId,\n data: transaction.data,\n fallbackGas,\n fallbackOnSimulationFailure,\n from: transaction.from,\n messenger,\n to: transaction.to,\n value: toHex(transaction.value ?? '0'),\n });\n\n if (gasLimitResult.usedFallback) {\n log('Gas estimate failed, using fallback', {\n chainId: transaction.chainId,\n error: gasLimitResult.error,\n index: 0,\n to: transaction.to,\n });\n }\n\n const gasLimit = {\n estimate: gasLimitResult.estimate,\n max: gasLimitResult.max,\n };\n\n return {\n gasLimits: [gasLimit],\n totalGasEstimate: gasLimit.estimate,\n totalGasLimit: gasLimit.max,\n };\n}\n\nfunction toBatchTransactionParams(\n transaction: QuoteGasTransaction,\n): BatchTransactionParams {\n return {\n data: transaction.data,\n gas: transaction.gas === undefined ? undefined : toHex(transaction.gas),\n maxFeePerGas: undefined,\n maxPriorityFeePerGas: undefined,\n to: transaction.to,\n value: toHex(transaction.value ?? '0'),\n };\n}\n\nfunction parseGasLimit(gas?: number | string): number | undefined {\n if (gas === undefined) {\n return undefined;\n }\n\n const parsedGas = new BigNumber(gas);\n\n if (\n !parsedGas.isFinite() ||\n parsedGas.isNaN() ||\n !parsedGas.isInteger() ||\n parsedGas.lte(0)\n ) {\n return undefined;\n }\n\n return parsedGas.toNumber();\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { TransactionPayControllerMessenger } from "../index.cjs";
|
|
3
|
+
export type QuoteGasTransaction = {
|
|
4
|
+
chainId: Hex;
|
|
5
|
+
data: Hex;
|
|
6
|
+
from: Hex;
|
|
7
|
+
gas?: number | string;
|
|
8
|
+
to: Hex;
|
|
9
|
+
value?: number | string | Hex;
|
|
10
|
+
};
|
|
11
|
+
export type QuoteGasLimit = {
|
|
12
|
+
estimate: number;
|
|
13
|
+
max: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function estimateQuoteGasLimits({ fallbackGas, fallbackOnSimulationFailure, messenger, transactions, }: {
|
|
16
|
+
fallbackGas?: {
|
|
17
|
+
estimate: number;
|
|
18
|
+
max: number;
|
|
19
|
+
};
|
|
20
|
+
fallbackOnSimulationFailure?: boolean;
|
|
21
|
+
messenger: TransactionPayControllerMessenger;
|
|
22
|
+
transactions: QuoteGasTransaction[];
|
|
23
|
+
}): Promise<{
|
|
24
|
+
batchGasLimit?: QuoteGasLimit;
|
|
25
|
+
gasLimits: QuoteGasLimit[];
|
|
26
|
+
is7702: boolean;
|
|
27
|
+
totalGasEstimate: number;
|
|
28
|
+
totalGasLimit: number;
|
|
29
|
+
usedBatch: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=quote-gas.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-gas.d.cts","sourceRoot":"","sources":["../../src/utils/quote-gas.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAM3C,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAK5D,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,GAAG,CAAC;IACV,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,GAAG,CAAC;IACR,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wBAAsB,sBAAsB,CAAC,EAC3C,WAAW,EACX,2BAAmC,EACnC,SAAS,EACT,YAAY,GACb,EAAE;IACD,WAAW,CAAC,EAAE;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,YAAY,EAAE,mBAAmB,EAAE,CAAC;CACrC,GAAG,OAAO,CAAC;IACV,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC,CAwBD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { TransactionPayControllerMessenger } from "../index.mjs";
|
|
3
|
+
export type QuoteGasTransaction = {
|
|
4
|
+
chainId: Hex;
|
|
5
|
+
data: Hex;
|
|
6
|
+
from: Hex;
|
|
7
|
+
gas?: number | string;
|
|
8
|
+
to: Hex;
|
|
9
|
+
value?: number | string | Hex;
|
|
10
|
+
};
|
|
11
|
+
export type QuoteGasLimit = {
|
|
12
|
+
estimate: number;
|
|
13
|
+
max: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function estimateQuoteGasLimits({ fallbackGas, fallbackOnSimulationFailure, messenger, transactions, }: {
|
|
16
|
+
fallbackGas?: {
|
|
17
|
+
estimate: number;
|
|
18
|
+
max: number;
|
|
19
|
+
};
|
|
20
|
+
fallbackOnSimulationFailure?: boolean;
|
|
21
|
+
messenger: TransactionPayControllerMessenger;
|
|
22
|
+
transactions: QuoteGasTransaction[];
|
|
23
|
+
}): Promise<{
|
|
24
|
+
batchGasLimit?: QuoteGasLimit;
|
|
25
|
+
gasLimits: QuoteGasLimit[];
|
|
26
|
+
is7702: boolean;
|
|
27
|
+
totalGasEstimate: number;
|
|
28
|
+
totalGasLimit: number;
|
|
29
|
+
usedBatch: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=quote-gas.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-gas.d.mts","sourceRoot":"","sources":["../../src/utils/quote-gas.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAM3C,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAK5D,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,GAAG,CAAC;IACV,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,GAAG,CAAC;IACR,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wBAAsB,sBAAsB,CAAC,EAC3C,WAAW,EACX,2BAAmC,EACnC,SAAS,EACT,YAAY,GACb,EAAE;IACD,WAAW,CAAC,EAAE;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,YAAY,EAAE,mBAAmB,EAAE,CAAC;CACrC,GAAG,OAAO,CAAC;IACV,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC,CAwBD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { toHex } from "@metamask/controller-utils";
|
|
2
|
+
import { createModuleLogger } from "@metamask/utils";
|
|
3
|
+
import { BigNumber } from "bignumber.js";
|
|
4
|
+
import { getGasBuffer } from "./feature-flags.mjs";
|
|
5
|
+
import { estimateGasLimit } from "./gas.mjs";
|
|
6
|
+
import { projectLogger } from "../logger.mjs";
|
|
7
|
+
const log = createModuleLogger(projectLogger, 'quote-gas');
|
|
8
|
+
export async function estimateQuoteGasLimits({ fallbackGas, fallbackOnSimulationFailure = false, messenger, transactions, }) {
|
|
9
|
+
if (transactions.length === 0) {
|
|
10
|
+
throw new Error('Quote gas estimation requires at least one transaction');
|
|
11
|
+
}
|
|
12
|
+
const useBatch = transactions.length > 1;
|
|
13
|
+
if (useBatch) {
|
|
14
|
+
return {
|
|
15
|
+
...(await estimateQuoteGasLimitsBatch(transactions, messenger)),
|
|
16
|
+
usedBatch: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
...(await estimateQuoteGasLimitSingle({
|
|
21
|
+
fallbackGas,
|
|
22
|
+
fallbackOnSimulationFailure,
|
|
23
|
+
messenger,
|
|
24
|
+
transaction: transactions[0],
|
|
25
|
+
})),
|
|
26
|
+
is7702: false,
|
|
27
|
+
usedBatch: false,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function estimateQuoteGasLimitsBatch(transactions, messenger) {
|
|
31
|
+
const [firstTransaction] = transactions;
|
|
32
|
+
const gasBuffer = getGasBuffer(messenger, firstTransaction.chainId);
|
|
33
|
+
const paramGasLimits = transactions.map((transaction) => parseGasLimit(transaction.gas));
|
|
34
|
+
const { gasLimits } = await messenger.call('TransactionController:estimateGasBatch', {
|
|
35
|
+
chainId: firstTransaction.chainId,
|
|
36
|
+
from: firstTransaction.from,
|
|
37
|
+
transactions: transactions.map(toBatchTransactionParams),
|
|
38
|
+
});
|
|
39
|
+
if (gasLimits.length !== 1 && gasLimits.length !== transactions.length) {
|
|
40
|
+
throw new Error('Unexpected batch gas limit count');
|
|
41
|
+
}
|
|
42
|
+
const bufferedGasLimits = gasLimits.map((gasLimit, index) => {
|
|
43
|
+
const providedGasLimit = paramGasLimits[index];
|
|
44
|
+
const providedGasWasPreserved = providedGasLimit !== undefined && providedGasLimit === gasLimit;
|
|
45
|
+
// Per-entry batch results currently preserve validated input gas values
|
|
46
|
+
// for transactions that already provided gas. If that contract changes
|
|
47
|
+
// and batch estimation returns a different value, treat it as a fresh
|
|
48
|
+
// estimate and apply the buffer. A single combined 7702 result is always
|
|
49
|
+
// buffered because it is a fresh batch estimate.
|
|
50
|
+
const useBuffer = gasLimits.length === 1 || !providedGasWasPreserved;
|
|
51
|
+
const bufferedGas = Math.ceil(gasLimit * (useBuffer ? gasBuffer : 1));
|
|
52
|
+
return {
|
|
53
|
+
estimate: bufferedGas,
|
|
54
|
+
max: bufferedGas,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const totalGasLimit = bufferedGasLimits.reduce((acc, gasLimit) => acc + gasLimit.max, 0);
|
|
58
|
+
const is7702 = bufferedGasLimits.length === 1;
|
|
59
|
+
const batchGasLimit = is7702 ? bufferedGasLimits[0] : undefined;
|
|
60
|
+
return {
|
|
61
|
+
...(batchGasLimit ? { batchGasLimit } : {}),
|
|
62
|
+
gasLimits: bufferedGasLimits,
|
|
63
|
+
is7702,
|
|
64
|
+
totalGasEstimate: totalGasLimit,
|
|
65
|
+
totalGasLimit,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async function estimateQuoteGasLimitSingle({ fallbackGas, fallbackOnSimulationFailure, messenger, transaction, }) {
|
|
69
|
+
const providedGasLimit = parseGasLimit(transaction.gas);
|
|
70
|
+
if (providedGasLimit !== undefined) {
|
|
71
|
+
log('Using provided gas limit', {
|
|
72
|
+
chainId: transaction.chainId,
|
|
73
|
+
gas: providedGasLimit,
|
|
74
|
+
index: 0,
|
|
75
|
+
to: transaction.to,
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
gasLimits: [
|
|
79
|
+
{
|
|
80
|
+
estimate: providedGasLimit,
|
|
81
|
+
max: providedGasLimit,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
totalGasEstimate: providedGasLimit,
|
|
85
|
+
totalGasLimit: providedGasLimit,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const gasLimitResult = await estimateGasLimit({
|
|
89
|
+
chainId: transaction.chainId,
|
|
90
|
+
data: transaction.data,
|
|
91
|
+
fallbackGas,
|
|
92
|
+
fallbackOnSimulationFailure,
|
|
93
|
+
from: transaction.from,
|
|
94
|
+
messenger,
|
|
95
|
+
to: transaction.to,
|
|
96
|
+
value: toHex(transaction.value ?? '0'),
|
|
97
|
+
});
|
|
98
|
+
if (gasLimitResult.usedFallback) {
|
|
99
|
+
log('Gas estimate failed, using fallback', {
|
|
100
|
+
chainId: transaction.chainId,
|
|
101
|
+
error: gasLimitResult.error,
|
|
102
|
+
index: 0,
|
|
103
|
+
to: transaction.to,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const gasLimit = {
|
|
107
|
+
estimate: gasLimitResult.estimate,
|
|
108
|
+
max: gasLimitResult.max,
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
gasLimits: [gasLimit],
|
|
112
|
+
totalGasEstimate: gasLimit.estimate,
|
|
113
|
+
totalGasLimit: gasLimit.max,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function toBatchTransactionParams(transaction) {
|
|
117
|
+
return {
|
|
118
|
+
data: transaction.data,
|
|
119
|
+
gas: transaction.gas === undefined ? undefined : toHex(transaction.gas),
|
|
120
|
+
maxFeePerGas: undefined,
|
|
121
|
+
maxPriorityFeePerGas: undefined,
|
|
122
|
+
to: transaction.to,
|
|
123
|
+
value: toHex(transaction.value ?? '0'),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function parseGasLimit(gas) {
|
|
127
|
+
if (gas === undefined) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
const parsedGas = new BigNumber(gas);
|
|
131
|
+
if (!parsedGas.isFinite() ||
|
|
132
|
+
parsedGas.isNaN() ||
|
|
133
|
+
!parsedGas.isInteger() ||
|
|
134
|
+
parsedGas.lte(0)) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
return parsedGas.toNumber();
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=quote-gas.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-gas.mjs","sourceRoot":"","sources":["../../src/utils/quote-gas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,mCAAmC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AACrD,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,EAAE,YAAY,EAAE,4BAAwB;AAC/C,OAAO,EAAE,gBAAgB,EAAE,kBAAc;AAEzC,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAE1C,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAgB3D,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAC3C,WAAW,EACX,2BAA2B,GAAG,KAAK,EACnC,SAAS,EACT,YAAY,GASb;IAQC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAEzC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,GAAG,CAAC,MAAM,2BAA2B,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;YAC/D,SAAS,EAAE,IAAI;SAChB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EAAE,SAAS;QAC/B,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,IAAI,GAAG,CAAC;KACvC,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,GAAqB;IAC1C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;IAErC,IACE,CAAC,SAAS,CAAC,QAAQ,EAAE;QACrB,SAAS,CAAC,KAAK,EAAE;QACjB,CAAC,SAAS,CAAC,SAAS,EAAE;QACtB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAChB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport type { BatchTransactionParams } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport { getGasBuffer } from './feature-flags';\nimport { estimateGasLimit } from './gas';\nimport type { TransactionPayControllerMessenger } from '..';\nimport { projectLogger } from '../logger';\n\nconst log = createModuleLogger(projectLogger, 'quote-gas');\n\nexport type QuoteGasTransaction = {\n chainId: Hex;\n data: Hex;\n from: Hex;\n gas?: number | string;\n to: Hex;\n value?: number | string | Hex;\n};\n\nexport type QuoteGasLimit = {\n estimate: number;\n max: number;\n};\n\nexport async function estimateQuoteGasLimits({\n fallbackGas,\n fallbackOnSimulationFailure = false,\n messenger,\n transactions,\n}: {\n fallbackGas?: {\n estimate: number;\n max: number;\n };\n fallbackOnSimulationFailure?: boolean;\n messenger: TransactionPayControllerMessenger;\n transactions: QuoteGasTransaction[];\n}): Promise<{\n batchGasLimit?: QuoteGasLimit;\n gasLimits: QuoteGasLimit[];\n is7702: boolean;\n totalGasEstimate: number;\n totalGasLimit: number;\n usedBatch: boolean;\n}> {\n if (transactions.length === 0) {\n throw new Error('Quote gas estimation requires at least one transaction');\n }\n\n const useBatch = transactions.length > 1;\n\n if (useBatch) {\n return {\n ...(await estimateQuoteGasLimitsBatch(transactions, messenger)),\n usedBatch: true,\n };\n }\n\n return {\n ...(await estimateQuoteGasLimitSingle({\n fallbackGas,\n fallbackOnSimulationFailure,\n messenger,\n transaction: transactions[0],\n })),\n is7702: false,\n usedBatch: false,\n };\n}\n\nasync function estimateQuoteGasLimitsBatch(\n transactions: QuoteGasTransaction[],\n messenger: TransactionPayControllerMessenger,\n): Promise<{\n batchGasLimit?: QuoteGasLimit;\n gasLimits: QuoteGasLimit[];\n is7702: boolean;\n totalGasEstimate: number;\n totalGasLimit: number;\n}> {\n const [firstTransaction] = transactions;\n const gasBuffer = getGasBuffer(messenger, firstTransaction.chainId);\n\n const paramGasLimits = transactions.map((transaction) =>\n parseGasLimit(transaction.gas),\n );\n\n const { gasLimits } = await messenger.call(\n 'TransactionController:estimateGasBatch',\n {\n chainId: firstTransaction.chainId,\n from: firstTransaction.from,\n transactions: transactions.map(toBatchTransactionParams),\n },\n );\n\n if (gasLimits.length !== 1 && gasLimits.length !== transactions.length) {\n throw new Error('Unexpected batch gas limit count');\n }\n\n const bufferedGasLimits = gasLimits.map((gasLimit, index) => {\n const providedGasLimit = paramGasLimits[index];\n const providedGasWasPreserved =\n providedGasLimit !== undefined && providedGasLimit === gasLimit;\n\n // Per-entry batch results currently preserve validated input gas values\n // for transactions that already provided gas. If that contract changes\n // and batch estimation returns a different value, treat it as a fresh\n // estimate and apply the buffer. A single combined 7702 result is always\n // buffered because it is a fresh batch estimate.\n const useBuffer = gasLimits.length === 1 || !providedGasWasPreserved;\n const bufferedGas = Math.ceil(gasLimit * (useBuffer ? gasBuffer : 1));\n\n return {\n estimate: bufferedGas,\n max: bufferedGas,\n };\n });\n\n const totalGasLimit = bufferedGasLimits.reduce(\n (acc, gasLimit) => acc + gasLimit.max,\n 0,\n );\n const is7702 = bufferedGasLimits.length === 1;\n const batchGasLimit = is7702 ? bufferedGasLimits[0] : undefined;\n\n return {\n ...(batchGasLimit ? { batchGasLimit } : {}),\n gasLimits: bufferedGasLimits,\n is7702,\n totalGasEstimate: totalGasLimit,\n totalGasLimit,\n };\n}\n\nasync function estimateQuoteGasLimitSingle({\n fallbackGas,\n fallbackOnSimulationFailure,\n messenger,\n transaction,\n}: {\n fallbackGas?: {\n estimate: number;\n max: number;\n };\n fallbackOnSimulationFailure: boolean;\n messenger: TransactionPayControllerMessenger;\n transaction: QuoteGasTransaction;\n}): Promise<{\n gasLimits: QuoteGasLimit[];\n totalGasEstimate: number;\n totalGasLimit: number;\n}> {\n const providedGasLimit = parseGasLimit(transaction.gas);\n\n if (providedGasLimit !== undefined) {\n log('Using provided gas limit', {\n chainId: transaction.chainId,\n gas: providedGasLimit,\n index: 0,\n to: transaction.to,\n });\n\n return {\n gasLimits: [\n {\n estimate: providedGasLimit,\n max: providedGasLimit,\n },\n ],\n totalGasEstimate: providedGasLimit,\n totalGasLimit: providedGasLimit,\n };\n }\n\n const gasLimitResult = await estimateGasLimit({\n chainId: transaction.chainId,\n data: transaction.data,\n fallbackGas,\n fallbackOnSimulationFailure,\n from: transaction.from,\n messenger,\n to: transaction.to,\n value: toHex(transaction.value ?? '0'),\n });\n\n if (gasLimitResult.usedFallback) {\n log('Gas estimate failed, using fallback', {\n chainId: transaction.chainId,\n error: gasLimitResult.error,\n index: 0,\n to: transaction.to,\n });\n }\n\n const gasLimit = {\n estimate: gasLimitResult.estimate,\n max: gasLimitResult.max,\n };\n\n return {\n gasLimits: [gasLimit],\n totalGasEstimate: gasLimit.estimate,\n totalGasLimit: gasLimit.max,\n };\n}\n\nfunction toBatchTransactionParams(\n transaction: QuoteGasTransaction,\n): BatchTransactionParams {\n return {\n data: transaction.data,\n gas: transaction.gas === undefined ? undefined : toHex(transaction.gas),\n maxFeePerGas: undefined,\n maxPriorityFeePerGas: undefined,\n to: transaction.to,\n value: toHex(transaction.value ?? '0'),\n };\n}\n\nfunction parseGasLimit(gas?: number | string): number | undefined {\n if (gas === undefined) {\n return undefined;\n }\n\n const parsedGas = new BigNumber(gas);\n\n if (\n !parsedGas.isFinite() ||\n parsedGas.isNaN() ||\n !parsedGas.isInteger() ||\n parsedGas.lte(0)\n ) {\n return undefined;\n }\n\n return parsedGas.toNumber();\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/transaction-pay-controller",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0",
|
|
4
4
|
"description": "Manages alternate payment strategies to provide required funds for transactions in MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"@ethersproject/abi": "^5.7.0",
|
|
53
53
|
"@ethersproject/contracts": "^5.7.0",
|
|
54
54
|
"@ethersproject/providers": "^5.7.0",
|
|
55
|
-
"@metamask/assets-controller": "^
|
|
56
|
-
"@metamask/assets-controllers": "^101.0.
|
|
55
|
+
"@metamask/assets-controller": "^3.0.0",
|
|
56
|
+
"@metamask/assets-controllers": "^101.0.1",
|
|
57
57
|
"@metamask/base-controller": "^9.0.0",
|
|
58
58
|
"@metamask/bridge-controller": "^69.1.1",
|
|
59
|
-
"@metamask/bridge-status-controller": "^
|
|
59
|
+
"@metamask/bridge-status-controller": "^70.0.0",
|
|
60
60
|
"@metamask/controller-utils": "^11.19.0",
|
|
61
61
|
"@metamask/gas-fee-controller": "^26.1.0",
|
|
62
62
|
"@metamask/messenger": "^0.3.0",
|