@metamask-previews/transaction-controller 52.2.0-preview-b881bfc9 → 52.2.0-preview-bf2d2c4c
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 +0 -6
- package/dist/TransactionController.cjs +2 -13
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +2 -13
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.cjs +3 -1
- package/dist/gas-flows/DefaultGasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.d.cts +2 -2
- package/dist/gas-flows/DefaultGasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.d.mts +2 -2
- package/dist/gas-flows/DefaultGasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.mjs +3 -1
- package/dist/gas-flows/DefaultGasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.cjs +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.d.cts +1 -5
- package/dist/gas-flows/LineaGasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.d.mts +1 -5
- package/dist/gas-flows/LineaGasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.mjs +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts +1 -5
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts +1 -5
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts +1 -5
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts +1 -5
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts +1 -5
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts +1 -5
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/TestGasFeeFlow.cjs +1 -1
- package/dist/gas-flows/TestGasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/TestGasFeeFlow.d.cts +2 -2
- package/dist/gas-flows/TestGasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/TestGasFeeFlow.d.mts +2 -2
- package/dist/gas-flows/TestGasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/TestGasFeeFlow.mjs +1 -1
- package/dist/gas-flows/TestGasFeeFlow.mjs.map +1 -1
- package/dist/helpers/GasFeePoller.cjs +4 -9
- package/dist/helpers/GasFeePoller.cjs.map +1 -1
- package/dist/helpers/GasFeePoller.d.cts +1 -4
- package/dist/helpers/GasFeePoller.d.cts.map +1 -1
- package/dist/helpers/GasFeePoller.d.mts +1 -4
- package/dist/helpers/GasFeePoller.d.mts.map +1 -1
- package/dist/helpers/GasFeePoller.mjs +4 -9
- package/dist/helpers/GasFeePoller.mjs.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.cjs +1 -2
- package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.mjs +1 -2
- package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +5 -18
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +5 -18
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/feature-flags.cjs +2 -18
- package/dist/utils/feature-flags.cjs.map +1 -1
- package/dist/utils/feature-flags.d.cts +0 -16
- package/dist/utils/feature-flags.d.cts.map +1 -1
- package/dist/utils/feature-flags.d.mts +0 -16
- package/dist/utils/feature-flags.d.mts.map +1 -1
- package/dist/utils/feature-flags.mjs +1 -16
- package/dist/utils/feature-flags.mjs.map +1 -1
- package/dist/utils/gas-fees.cjs +3 -21
- package/dist/utils/gas-fees.cjs.map +1 -1
- package/dist/utils/gas-fees.d.cts +0 -14
- package/dist/utils/gas-fees.d.cts.map +1 -1
- package/dist/utils/gas-fees.d.mts +0 -14
- package/dist/utils/gas-fees.d.mts.map +1 -1
- package/dist/utils/gas-fees.mjs +2 -19
- package/dist/utils/gas-fees.mjs.map +1 -1
- package/dist/utils/gas-flow.cjs +2 -3
- package/dist/utils/gas-flow.cjs.map +1 -1
- package/dist/utils/gas-flow.d.cts +1 -3
- package/dist/utils/gas-flow.d.cts.map +1 -1
- package/dist/utils/gas-flow.d.mts +1 -3
- package/dist/utils/gas-flow.d.mts.map +1 -1
- package/dist/utils/gas-flow.mjs +2 -3
- package/dist/utils/gas-flow.mjs.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.cjs +4 -9
- package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.d.cts +1 -4
- package/dist/utils/layer1-gas-fee-flow.d.cts.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.d.mts +1 -4
- package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.mjs +4 -9
- package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs +0 -123
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs.map +0 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.cts +0 -28
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.cts.map +0 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.mts +0 -28
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.mts.map +0 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.mjs +0 -118
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.mjs.map +0 -1
|
@@ -20,7 +20,7 @@ class DefaultGasFeeFlow {
|
|
|
20
20
|
constructor() {
|
|
21
21
|
_DefaultGasFeeFlow_instances.add(this);
|
|
22
22
|
}
|
|
23
|
-
matchesTransaction() {
|
|
23
|
+
matchesTransaction(_transactionMeta) {
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
async getGasFees(request) {
|
|
@@ -41,6 +41,8 @@ class DefaultGasFeeFlow {
|
|
|
41
41
|
response = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getGasPriceEstimates).call(this, gasFeeEstimates);
|
|
42
42
|
break;
|
|
43
43
|
default:
|
|
44
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
44
46
|
throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);
|
|
45
47
|
}
|
|
46
48
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultGasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;AAKA,qEAAkE;AAElE,2CAAqD;AAErD,0CAA0C;
|
|
1
|
+
{"version":3,"file":"DefaultGasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;AAKA,qEAAkE;AAElE,2CAAqD;AAErD,0CAA0C;AAY1C,wCAAmE;AACnE,oDAAwD;AAExD,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,sBAAsB,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAa,iBAAiB;IAA9B;;IA0GA,CAAC;IAzGC,kBAAkB,CAAC,gBAAiC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAA0B;QACzC,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC;QACzC,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG,oBAAoB,CAAC;QAElE,IAAI,QAAyB,CAAC;QAE9B,QAAQ,eAAe,EAAE;YACvB,KAAK,uCAAkB,CAAC,UAAU;gBAChC,GAAG,CAAC,4BAA4B,EAAE,eAAe,CAAC,CAAC;gBACnD,QAAQ,GAAG,uBAAA,IAAI,4EAAqB,MAAzB,IAAI,EAAsB,eAAe,CAAC,CAAC;gBACtD,MAAM;YACR,KAAK,uCAAkB,CAAC,MAAM;gBAC5B,GAAG,CAAC,wBAAwB,EAAE,eAAe,CAAC,CAAC;gBAC/C,QAAQ,GAAG,uBAAA,IAAI,2EAAoB,MAAxB,IAAI,EACb,eAAy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,QAAQ,EAAE,IAAA,8BAAmB,EAAC,eAAe,CAAC,QAAQ,CAAC;KACxD,CAAC;AACJ,CAAC,uFAGC,eAA0C,EAC1C,KAA0B;IAE1B,MAAM,YAAY,GAAG,IAAA,8BAAmB,EACtC,eAAe,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAC7C,CAAC;IAEF,MAAM,oBAAoB,GAAG,IAAA,8BAAmB,EAC9C,eAAe,CAAC,KAAK,CAAC,CAAC,6BAA6B,CACrD,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,oBAAoB;KACrB,CAAC;AACJ,CAAC,iFAGC,eAAuC,EACvC,KAA0B;IAE1B,OAAO,IAAA,8BAAmB,EAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import type {\n LegacyGasPriceEstimate,\n GasFeeEstimates as FeeMarketGasPriceEstimate,\n EthGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n FeeMarketGasFeeEstimateForLevel,\n FeeMarketGasFeeEstimates,\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n GasPriceGasFeeEstimates,\n LegacyGasFeeEstimates,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types';\nimport { gweiDecimalToWeiHex } from '../utils/gas-fees';\n\nconst log = createModuleLogger(projectLogger, 'default-gas-fee-flow');\n\n/**\n * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.\n */\nexport class DefaultGasFeeFlow implements GasFeeFlow {\n matchesTransaction(_transactionMeta: TransactionMeta): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n const { gasFeeControllerData } = request;\n const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;\n\n let response: GasFeeEstimates;\n\n switch (gasEstimateType) {\n case GAS_ESTIMATE_TYPES.FEE_MARKET:\n log('Using fee market estimates', gasFeeEstimates);\n response = this.#getFeeMarkEstimates(gasFeeEstimates);\n break;\n case GAS_ESTIMATE_TYPES.LEGACY:\n log('Using legacy estimates', gasFeeEstimates);\n response = this.#getLegacyEstimates(\n gasFeeEstimates as LegacyGasPriceEstimate,\n );\n break;\n case GAS_ESTIMATE_TYPES.ETH_GASPRICE:\n log('Using eth_gasPrice estimates', gasFeeEstimates);\n response = this.#getGasPriceEstimates(\n gasFeeEstimates as EthGasPriceEstimate,\n );\n break;\n default:\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);\n }\n\n return {\n estimates: response,\n };\n }\n\n #getFeeMarkEstimates(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n ): FeeMarketGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getFeeMarketLevel(gasFeeEstimates, level),\n }),\n {} as Omit<FeeMarketGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.FeeMarket,\n ...levels,\n };\n }\n\n #getLegacyEstimates(\n gasFeeEstimates: LegacyGasPriceEstimate,\n ): LegacyGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getLegacyLevel(gasFeeEstimates, level),\n }),\n {} as Omit<LegacyGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.Legacy,\n ...levels,\n };\n }\n\n #getGasPriceEstimates(\n gasFeeEstimates: EthGasPriceEstimate,\n ): GasPriceGasFeeEstimates {\n return {\n type: GasFeeEstimateType.GasPrice,\n gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.gasPrice),\n };\n }\n\n #getFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): FeeMarketGasFeeEstimateForLevel {\n const maxFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxFeePerGas,\n );\n\n const maxPriorityFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxPriorityFeePerGas,\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n }\n\n #getLegacyLevel(\n gasFeeEstimates: LegacyGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): Hex {\n return gweiDecimalToWeiHex(gasFeeEstimates[level]);\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse } from "../types.cjs";
|
|
1
|
+
import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from "../types.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.
|
|
4
4
|
*/
|
|
5
5
|
export declare class DefaultGasFeeFlow implements GasFeeFlow {
|
|
6
6
|
#private;
|
|
7
|
-
matchesTransaction(): boolean;
|
|
7
|
+
matchesTransaction(_transactionMeta: TransactionMeta): boolean;
|
|
8
8
|
getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=DefaultGasFeeFlow.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultGasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAIV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"DefaultGasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAIV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAGlB,eAAe,EAChB,qBAAiB;AAMlB;;GAEG;AACH,qBAAa,iBAAkB,YAAW,UAAU;;IAClD,kBAAkB,CAAC,gBAAgB,EAAE,eAAe,GAAG,OAAO;IAIxD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAqG1E"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse } from "../types.mjs";
|
|
1
|
+
import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from "../types.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.
|
|
4
4
|
*/
|
|
5
5
|
export declare class DefaultGasFeeFlow implements GasFeeFlow {
|
|
6
6
|
#private;
|
|
7
|
-
matchesTransaction(): boolean;
|
|
7
|
+
matchesTransaction(_transactionMeta: TransactionMeta): boolean;
|
|
8
8
|
getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=DefaultGasFeeFlow.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultGasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAIV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"DefaultGasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAIV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAGlB,eAAe,EAChB,qBAAiB;AAMlB;;GAEG;AACH,qBAAa,iBAAkB,YAAW,UAAU;;IAClD,kBAAkB,CAAC,gBAAgB,EAAE,eAAe,GAAG,OAAO;IAIxD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAqG1E"}
|
|
@@ -17,7 +17,7 @@ export class DefaultGasFeeFlow {
|
|
|
17
17
|
constructor() {
|
|
18
18
|
_DefaultGasFeeFlow_instances.add(this);
|
|
19
19
|
}
|
|
20
|
-
matchesTransaction() {
|
|
20
|
+
matchesTransaction(_transactionMeta) {
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
async getGasFees(request) {
|
|
@@ -38,6 +38,8 @@ export class DefaultGasFeeFlow {
|
|
|
38
38
|
response = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getGasPriceEstimates).call(this, gasFeeEstimates);
|
|
39
39
|
break;
|
|
40
40
|
default:
|
|
41
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
41
43
|
throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);
|
|
42
44
|
}
|
|
43
45
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultGasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":";;;;;;AAKA,OAAO,EAAE,kBAAkB,EAAE,qCAAqC;AAElE,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAErD,OAAO,EAAE,aAAa,EAAE,sBAAkB;
|
|
1
|
+
{"version":3,"file":"DefaultGasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":";;;;;;AAKA,OAAO,EAAE,kBAAkB,EAAE,qCAAqC;AAElE,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAErD,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAY1C,OAAO,EAAE,mBAAmB,EAAE,kB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esContent":["import type {\n LegacyGasPriceEstimate,\n GasFeeEstimates as FeeMarketGasPriceEstimate,\n EthGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n FeeMarketGasFeeEstimateForLevel,\n FeeMarketGasFeeEstimates,\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n GasPriceGasFeeEstimates,\n LegacyGasFeeEstimates,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types';\nimport { gweiDecimalToWeiHex } from '../utils/gas-fees';\n\nconst log = createModuleLogger(projectLogger, 'default-gas-fee-flow');\n\n/**\n * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.\n */\nexport class DefaultGasFeeFlow implements GasFeeFlow {\n matchesTransaction(_transactionMeta: TransactionMeta): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n const { gasFeeControllerData } = request;\n const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;\n\n let response: GasFeeEstimates;\n\n switch (gasEstimateType) {\n case GAS_ESTIMATE_TYPES.FEE_MARKET:\n log('Using fee market estimates', gasFeeEstimates);\n response = this.#getFeeMarkEstimates(gasFeeEstimates);\n break;\n case GAS_ESTIMATE_TYPES.LEGACY:\n log('Using legacy estimates', gasFeeEstimates);\n response = this.#getLegacyEstimates(\n gasFeeEstimates as LegacyGasPriceEstimate,\n );\n break;\n case GAS_ESTIMATE_TYPES.ETH_GASPRICE:\n log('Using eth_gasPrice estimates', gasFeeEstimates);\n response = this.#getGasPriceEstimates(\n gasFeeEstimates as EthGasPriceEstimate,\n );\n break;\n default:\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);\n }\n\n return {\n estimates: response,\n };\n }\n\n #getFeeMarkEstimates(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n ): FeeMarketGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getFeeMarketLevel(gasFeeEstimates, level),\n }),\n {} as Omit<FeeMarketGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.FeeMarket,\n ...levels,\n };\n }\n\n #getLegacyEstimates(\n gasFeeEstimates: LegacyGasPriceEstimate,\n ): LegacyGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getLegacyLevel(gasFeeEstimates, level),\n }),\n {} as Omit<LegacyGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.Legacy,\n ...levels,\n };\n }\n\n #getGasPriceEstimates(\n gasFeeEstimates: EthGasPriceEstimate,\n ): GasPriceGasFeeEstimates {\n return {\n type: GasFeeEstimateType.GasPrice,\n gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.gasPrice),\n };\n }\n\n #getFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): FeeMarketGasFeeEstimateForLevel {\n const maxFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxFeePerGas,\n );\n\n const maxPriorityFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxPriorityFeePerGas,\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n }\n\n #getLegacyLevel(\n gasFeeEstimates: LegacyGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): Hex {\n return gweiDecimalToWeiHex(gasFeeEstimates[level]);\n }\n}\n"]}
|
|
@@ -37,7 +37,7 @@ class LineaGasFeeFlow {
|
|
|
37
37
|
constructor() {
|
|
38
38
|
_LineaGasFeeFlow_instances.add(this);
|
|
39
39
|
}
|
|
40
|
-
matchesTransaction(
|
|
40
|
+
matchesTransaction(transactionMeta) {
|
|
41
41
|
return LINEA_CHAIN_IDS.includes(transactionMeta.chainId);
|
|
42
42
|
}
|
|
43
43
|
async getGasFees(request) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineaGasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iEAA4E;AAE5E,2CAA+D;AAG/D,+DAAwD;AACxD,0CAA0C;
|
|
1
|
+
{"version":3,"file":"LineaGasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iEAA4E;AAE5E,2CAA+D;AAG/D,+DAAwD;AACxD,0CAA0C;AAQ1C,wCAAmE;AAWnE,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,oBAAoB,CAAC,CAAC;AAEpE,MAAM,eAAe,GAAU;IAC7B,0BAAO,CAAC,eAAe,CAAC;IACxB,0BAAO,CAAC,cAAc,CAAC;IACvB,0BAAO,CAAC,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,oBAAoB,GAAG;IAC3B,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,GAAG;CACV,CAAC;AAEF,MAAM,wBAAwB,GAAG;IAC/B,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,GAAG;CACV,CAAC;AAEF;;;;GAIG;AACH,MAAa,eAAe;IAA5B;;IAwGA,CAAC;IAvGC,kBAAkB,CAAC,eAAgC;QACjD,OAAO,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAA0B;QACzC,IAAI;YACF,OAAO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M,CAAC;QAChD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;KAC3C,CAAC;AACJ,CAAC,yEAEa,IAAiB;IAC7B,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACtD,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { ChainId, hexToBN, query, toHex } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\nimport type BN from 'bn.js';\n\nimport { DefaultGasFeeFlow } from './DefaultGasFeeFlow';\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types';\n\ntype LineaEstimateGasResponse = {\n baseFeePerGas: Hex;\n priorityFeePerGas: Hex;\n};\n\ntype FeesByLevel = {\n [key in GasFeeEstimateLevel]: BN;\n};\n\nconst log = createModuleLogger(projectLogger, 'linea-gas-fee-flow');\n\nconst LINEA_CHAIN_IDS: Hex[] = [\n ChainId['linea-mainnet'],\n ChainId['linea-goerli'],\n ChainId['linea-sepolia'],\n];\n\nconst BASE_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.35,\n high: 1.7,\n};\n\nconst PRIORITY_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.05,\n high: 1.1,\n};\n\n/**\n * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:\n * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.\n * - Static multipliers to increase the base and priority fees.\n */\nexport class LineaGasFeeFlow implements GasFeeFlow {\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return LINEA_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n try {\n return await this.#getLineaGasFees(request);\n } catch (error) {\n log('Using default flow as fallback due to error', error);\n return new DefaultGasFeeFlow().getGasFees(request);\n }\n }\n\n async #getLineaGasFees(\n request: GasFeeFlowRequest,\n ): Promise<GasFeeFlowResponse> {\n const { ethQuery, transactionMeta } = request;\n\n const lineaResponse = await this.#getLineaResponse(\n transactionMeta,\n ethQuery,\n );\n\n log('Received Linea response', lineaResponse);\n\n const baseFees = this.#getValuesFromMultipliers(\n lineaResponse.baseFeePerGas,\n BASE_FEE_MULTIPLIERS,\n );\n\n log('Generated base fees', this.#feesToString(baseFees));\n\n const priorityFees = this.#getValuesFromMultipliers(\n lineaResponse.priorityFeePerGas,\n PRIORITY_FEE_MULTIPLIERS,\n );\n\n log('Generated priority fees', this.#feesToString(priorityFees));\n\n const maxFees = this.#getMaxFees(baseFees, priorityFees);\n\n log('Generated max fees', this.#feesToString(maxFees));\n\n const estimates = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: {\n maxFeePerGas: toHex(maxFees[level]),\n maxPriorityFeePerGas: toHex(priorityFees[level]),\n },\n }),\n { type: GasFeeEstimateType.FeeMarket } as GasFeeEstimates,\n );\n\n return { estimates };\n }\n\n #getLineaResponse(\n transactionMeta: TransactionMeta,\n ethQuery: EthQuery,\n ): Promise<LineaEstimateGasResponse> {\n return query(ethQuery, 'linea_estimateGas', [\n {\n from: transactionMeta.txParams.from,\n to: transactionMeta.txParams.to,\n value: transactionMeta.txParams.value,\n input: transactionMeta.txParams.data,\n },\n ]);\n }\n\n #getValuesFromMultipliers(\n value: Hex,\n multipliers: { low: number; medium: number; high: number },\n ): FeesByLevel {\n const base = hexToBN(value);\n const low = base.muln(multipliers.low);\n const medium = base.muln(multipliers.medium);\n const high = base.muln(multipliers.high);\n\n return {\n low,\n medium,\n high,\n };\n }\n\n #getMaxFees(\n baseFees: Record<GasFeeEstimateLevel, BN>,\n priorityFees: Record<GasFeeEstimateLevel, BN>,\n ): FeesByLevel {\n return {\n low: baseFees.low.add(priorityFees.low),\n medium: baseFees.medium.add(priorityFees.medium),\n high: baseFees.high.add(priorityFees.high),\n };\n }\n\n #feesToString(fees: FeesByLevel) {\n return Object.values(GasFeeEstimateLevel).map((level) =>\n fees[level].toString(10),\n );\n }\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TransactionControllerMessenger } from "../TransactionController.cjs";
|
|
2
1
|
import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from "../types.cjs";
|
|
3
2
|
/**
|
|
4
3
|
* Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:
|
|
@@ -7,10 +6,7 @@ import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta
|
|
|
7
6
|
*/
|
|
8
7
|
export declare class LineaGasFeeFlow implements GasFeeFlow {
|
|
9
8
|
#private;
|
|
10
|
-
matchesTransaction(
|
|
11
|
-
transactionMeta: TransactionMeta;
|
|
12
|
-
messenger: TransactionControllerMessenger;
|
|
13
|
-
}): boolean;
|
|
9
|
+
matchesTransaction(transactionMeta: TransactionMeta): boolean;
|
|
14
10
|
getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse>;
|
|
15
11
|
}
|
|
16
12
|
//# sourceMappingURL=LineaGasFeeFlow.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineaGasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"LineaGasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,qBAAiB;AAgClB;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,UAAU;;IAChD,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAIvD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAmG1E"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TransactionControllerMessenger } from "../TransactionController.mjs";
|
|
2
1
|
import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from "../types.mjs";
|
|
3
2
|
/**
|
|
4
3
|
* Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:
|
|
@@ -7,10 +6,7 @@ import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta
|
|
|
7
6
|
*/
|
|
8
7
|
export declare class LineaGasFeeFlow implements GasFeeFlow {
|
|
9
8
|
#private;
|
|
10
|
-
matchesTransaction(
|
|
11
|
-
transactionMeta: TransactionMeta;
|
|
12
|
-
messenger: TransactionControllerMessenger;
|
|
13
|
-
}): boolean;
|
|
9
|
+
matchesTransaction(transactionMeta: TransactionMeta): boolean;
|
|
14
10
|
getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse>;
|
|
15
11
|
}
|
|
16
12
|
//# sourceMappingURL=LineaGasFeeFlow.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineaGasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"LineaGasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,qBAAiB;AAgClB;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,UAAU;;IAChD,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAIvD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAmG1E"}
|
|
@@ -34,7 +34,7 @@ export class LineaGasFeeFlow {
|
|
|
34
34
|
constructor() {
|
|
35
35
|
_LineaGasFeeFlow_instances.add(this);
|
|
36
36
|
}
|
|
37
|
-
matchesTransaction(
|
|
37
|
+
matchesTransaction(transactionMeta) {
|
|
38
38
|
return LINEA_CHAIN_IDS.includes(transactionMeta.chainId);
|
|
39
39
|
}
|
|
40
40
|
async getGasFees(request) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineaGasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,mCAAmC;AAE5E,OAAO,EAAE,kBAAkB,EAAY,wBAAwB;AAG/D,OAAO,EAAE,iBAAiB,EAAE,gCAA4B;AACxD,OAAO,EAAE,aAAa,EAAE,sBAAkB;
|
|
1
|
+
{"version":3,"file":"LineaGasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,mCAAmC;AAE5E,OAAO,EAAE,kBAAkB,EAAY,wBAAwB;AAG/D,OAAO,EAAE,iBAAiB,EAAE,gCAA4B;AACxD,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAQ1C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,qBAAiB;AAWnE,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;AAEpE,MAAM,eAAe,GAAU;IAC7B,OAAO,CAAC,eAAe,CAAC;IACxB,OAAO,CAAC,cAAc,CAAC;IAC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,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEzC,OAAO;QACL,GAAG;QACH,MAAM;QACN,IAAI;KACL,CAAC;AACJ,CAAC,qEAGC,QAAyC,EACzC,YAA6C;IAE7C,OAAO;QACL,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC;QACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC;QAChD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;KAC3C,CAAC;AACJ,CAAC,yEAEa,IAAiB;IAC7B,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACtD,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { ChainId, hexToBN, query, toHex } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\nimport type BN from 'bn.js';\n\nimport { DefaultGasFeeFlow } from './DefaultGasFeeFlow';\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types';\n\ntype LineaEstimateGasResponse = {\n baseFeePerGas: Hex;\n priorityFeePerGas: Hex;\n};\n\ntype FeesByLevel = {\n [key in GasFeeEstimateLevel]: BN;\n};\n\nconst log = createModuleLogger(projectLogger, 'linea-gas-fee-flow');\n\nconst LINEA_CHAIN_IDS: Hex[] = [\n ChainId['linea-mainnet'],\n ChainId['linea-goerli'],\n ChainId['linea-sepolia'],\n];\n\nconst BASE_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.35,\n high: 1.7,\n};\n\nconst PRIORITY_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.05,\n high: 1.1,\n};\n\n/**\n * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:\n * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.\n * - Static multipliers to increase the base and priority fees.\n */\nexport class LineaGasFeeFlow implements GasFeeFlow {\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return LINEA_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n try {\n return await this.#getLineaGasFees(request);\n } catch (error) {\n log('Using default flow as fallback due to error', error);\n return new DefaultGasFeeFlow().getGasFees(request);\n }\n }\n\n async #getLineaGasFees(\n request: GasFeeFlowRequest,\n ): Promise<GasFeeFlowResponse> {\n const { ethQuery, transactionMeta } = request;\n\n const lineaResponse = await this.#getLineaResponse(\n transactionMeta,\n ethQuery,\n );\n\n log('Received Linea response', lineaResponse);\n\n const baseFees = this.#getValuesFromMultipliers(\n lineaResponse.baseFeePerGas,\n BASE_FEE_MULTIPLIERS,\n );\n\n log('Generated base fees', this.#feesToString(baseFees));\n\n const priorityFees = this.#getValuesFromMultipliers(\n lineaResponse.priorityFeePerGas,\n PRIORITY_FEE_MULTIPLIERS,\n );\n\n log('Generated priority fees', this.#feesToString(priorityFees));\n\n const maxFees = this.#getMaxFees(baseFees, priorityFees);\n\n log('Generated max fees', this.#feesToString(maxFees));\n\n const estimates = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: {\n maxFeePerGas: toHex(maxFees[level]),\n maxPriorityFeePerGas: toHex(priorityFees[level]),\n },\n }),\n { type: GasFeeEstimateType.FeeMarket } as GasFeeEstimates,\n );\n\n return { estimates };\n }\n\n #getLineaResponse(\n transactionMeta: TransactionMeta,\n ethQuery: EthQuery,\n ): Promise<LineaEstimateGasResponse> {\n return query(ethQuery, 'linea_estimateGas', [\n {\n from: transactionMeta.txParams.from,\n to: transactionMeta.txParams.to,\n value: transactionMeta.txParams.value,\n input: transactionMeta.txParams.data,\n },\n ]);\n }\n\n #getValuesFromMultipliers(\n value: Hex,\n multipliers: { low: number; medium: number; high: number },\n ): FeesByLevel {\n const base = hexToBN(value);\n const low = base.muln(multipliers.low);\n const medium = base.muln(multipliers.medium);\n const high = base.muln(multipliers.high);\n\n return {\n low,\n medium,\n high,\n };\n }\n\n #getMaxFees(\n baseFees: Record<GasFeeEstimateLevel, BN>,\n priorityFees: Record<GasFeeEstimateLevel, BN>,\n ): FeesByLevel {\n return {\n low: baseFees.low.add(priorityFees.low),\n medium: baseFees.medium.add(priorityFees.medium),\n high: baseFees.high.add(priorityFees.high),\n };\n }\n\n #feesToString(fees: FeesByLevel) {\n return Object.values(GasFeeEstimateLevel).map((level) =>\n fees[level].toString(10),\n );\n }\n}\n"]}
|
|
@@ -21,7 +21,7 @@ class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow_1.OracleLayer1GasF
|
|
|
21
21
|
constructor() {
|
|
22
22
|
super(OPTIMISM_GAS_PRICE_ORACLE_ADDRESS);
|
|
23
23
|
}
|
|
24
|
-
matchesTransaction(
|
|
24
|
+
matchesTransaction(transactionMeta) {
|
|
25
25
|
return OPTIMISM_STACK_CHAIN_IDS.includes(transactionMeta.chainId);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimismLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;AAEA,yEAAkE;AAClE,gDAAyC;
|
|
1
|
+
{"version":3,"file":"OptimismLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;AAEA,yEAAkE;AAClE,gDAAyC;AAGzC,MAAM,wBAAwB,GAAU;IACtC,qBAAS,CAAC,QAAQ;IAClB,qBAAS,CAAC,gBAAgB;IAC1B,qBAAS,CAAC,IAAI;IACd,qBAAS,CAAC,YAAY;IACtB,qBAAS,CAAC,KAAK;IACf,qBAAS,CAAC,aAAa;IACvB,qBAAS,CAAC,IAAI;CACf,CAAC;AAEF,8GAA8G;AAC9G,MAAM,iCAAiC,GACrC,4CAA4C,CAAC;AAE/C;;GAEG;AACH,MAAa,wBAAyB,SAAQ,+CAAsB;IAClE;QACE,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC3C,CAAC;IAED,kBAAkB,CAAC,eAAgC;QACjD,OAAO,wBAAwB,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;CACF;AARD,4DAQC","sourcesContent":["import { type Hex } from '@metamask/utils';\n\nimport { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow';\nimport { CHAIN_IDS } from '../constants';\nimport type { TransactionMeta } from '../types';\n\nconst OPTIMISM_STACK_CHAIN_IDS: Hex[] = [\n CHAIN_IDS.OPTIMISM,\n CHAIN_IDS.OPTIMISM_TESTNET,\n CHAIN_IDS.BASE,\n CHAIN_IDS.BASE_TESTNET,\n CHAIN_IDS.OPBNB,\n CHAIN_IDS.OPBNB_TESTNET,\n CHAIN_IDS.ZORA,\n];\n\n// BlockExplorer link: https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f#code\nconst OPTIMISM_GAS_PRICE_ORACLE_ADDRESS =\n '0x420000000000000000000000000000000000000F';\n\n/**\n * Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.\n */\nexport class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {\n constructor() {\n super(OPTIMISM_GAS_PRICE_ORACLE_ADDRESS);\n }\n\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return OPTIMISM_STACK_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n}\n"]}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.cjs";
|
|
2
|
-
import type { TransactionControllerMessenger } from "../TransactionController.cjs";
|
|
3
2
|
import type { TransactionMeta } from "../types.cjs";
|
|
4
3
|
/**
|
|
5
4
|
* Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
|
|
6
5
|
*/
|
|
7
6
|
export declare class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
|
|
8
7
|
constructor();
|
|
9
|
-
matchesTransaction(
|
|
10
|
-
transactionMeta: TransactionMeta;
|
|
11
|
-
messenger: TransactionControllerMessenger;
|
|
12
|
-
}): boolean;
|
|
8
|
+
matchesTransaction(transactionMeta: TransactionMeta): boolean;
|
|
13
9
|
}
|
|
14
10
|
//# sourceMappingURL=OptimismLayer1GasFeeFlow.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimismLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"OptimismLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAiB;AAgBhD;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,sBAAsB;;IAKlE,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;CAG9D"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.mjs";
|
|
2
|
-
import type { TransactionControllerMessenger } from "../TransactionController.mjs";
|
|
3
2
|
import type { TransactionMeta } from "../types.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
|
|
6
5
|
*/
|
|
7
6
|
export declare class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
|
|
8
7
|
constructor();
|
|
9
|
-
matchesTransaction(
|
|
10
|
-
transactionMeta: TransactionMeta;
|
|
11
|
-
messenger: TransactionControllerMessenger;
|
|
12
|
-
}): boolean;
|
|
8
|
+
matchesTransaction(transactionMeta: TransactionMeta): boolean;
|
|
13
9
|
}
|
|
14
10
|
//# sourceMappingURL=OptimismLayer1GasFeeFlow.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimismLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"OptimismLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAiB;AAgBhD;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,sBAAsB;;IAKlE,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;CAG9D"}
|
|
@@ -18,7 +18,7 @@ export class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
|
|
|
18
18
|
constructor() {
|
|
19
19
|
super(OPTIMISM_GAS_PRICE_ORACLE_ADDRESS);
|
|
20
20
|
}
|
|
21
|
-
matchesTransaction(
|
|
21
|
+
matchesTransaction(transactionMeta) {
|
|
22
22
|
return OPTIMISM_STACK_CHAIN_IDS.includes(transactionMeta.chainId);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimismLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,SAAS,EAAE,yBAAqB;
|
|
1
|
+
{"version":3,"file":"OptimismLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,SAAS,EAAE,yBAAqB;AAGzC,MAAM,wBAAwB,GAAU;IACtC,SAAS,CAAC,QAAQ;IAClB,SAAS,CAAC,gBAAgB;IAC1B,SAAS,CAAC,IAAI;IACd,SAAS,CAAC,YAAY;IACtB,SAAS,CAAC,KAAK;IACf,SAAS,CAAC,aAAa;IACvB,SAAS,CAAC,IAAI;CACf,CAAC;AAEF,8GAA8G;AAC9G,MAAM,iCAAiC,GACrC,4CAA4C,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,sBAAsB;IAClE;QACE,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC3C,CAAC;IAED,kBAAkB,CAAC,eAAgC;QACjD,OAAO,wBAAwB,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;CACF","sourcesContent":["import { type Hex } from '@metamask/utils';\n\nimport { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow';\nimport { CHAIN_IDS } from '../constants';\nimport type { TransactionMeta } from '../types';\n\nconst OPTIMISM_STACK_CHAIN_IDS: Hex[] = [\n CHAIN_IDS.OPTIMISM,\n CHAIN_IDS.OPTIMISM_TESTNET,\n CHAIN_IDS.BASE,\n CHAIN_IDS.BASE_TESTNET,\n CHAIN_IDS.OPBNB,\n CHAIN_IDS.OPBNB_TESTNET,\n CHAIN_IDS.ZORA,\n];\n\n// BlockExplorer link: https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f#code\nconst OPTIMISM_GAS_PRICE_ORACLE_ADDRESS =\n '0x420000000000000000000000000000000000000F';\n\n/**\n * Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.\n */\nexport class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {\n constructor() {\n super(OPTIMISM_GAS_PRICE_ORACLE_ADDRESS);\n }\n\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return OPTIMISM_STACK_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OracleLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAoD;AACpD,wDAA+E;AAE/E,2CAAqD;AAErD,0CAA0C;
|
|
1
|
+
{"version":3,"file":"OracleLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAoD;AACpD,wDAA+E;AAE/E,2CAAqD;AAErD,0CAA0C;AAO1C,kDAAsD;AAEtD,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,4BAA4B,CAAC,CAAC;AAE5E,MAAM,SAAS,GACb,kEAAkE,CAAC;AAErE,MAAM,oBAAoB,GAAG;IAC3B;QACE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACjE,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,E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C,uHAGC,eAAgC,EAChC,IAAa;IAEb,MAAM,QAAQ,GAAG,uBAAA,IAAI,yFAAwB,MAA5B,IAAI,EAAyB,eAAe,CAAC,CAAC;IAC/D,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;IAEpC,IAAI,uBAAuB,GAAG,IAAA,4BAAkB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEpE,IAAI,IAAI,EAAE;QACR,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAChD,uBAAuB,GAAG,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACnE;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC,2GAGC,eAAgC;IAEhC,OAAO;QACL,GAAG,eAAe,CAAC,QAAQ;QAC3B,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG;KACvC,CAAC;AACJ,CAAC","sourcesContent":["import { Contract } from '@ethersproject/contracts';\nimport { Web3Provider, type ExternalProvider } from '@ethersproject/providers';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n Layer1GasFeeFlow,\n Layer1GasFeeFlowRequest,\n Layer1GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { prepareTransaction } from '../utils/prepare';\n\nconst log = createModuleLogger(projectLogger, 'oracle-layer1-gas-fee-flow');\n\nconst DUMMY_KEY =\n 'abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789';\n\nconst GAS_PRICE_ORACLE_ABI = [\n {\n inputs: [{ internalType: 'bytes', name: '_data', type: 'bytes' }],\n name: 'getL1Fee',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n];\n\n/**\n * Layer 1 gas fee flow that obtains gas fee estimate using an oracle smart contract.\n */\nexport abstract class OracleLayer1GasFeeFlow implements Layer1GasFeeFlow {\n readonly #oracleAddress: Hex;\n\n readonly #signTransaction: boolean;\n\n constructor(oracleAddress: Hex, signTransaction?: boolean) {\n this.#oracleAddress = oracleAddress;\n this.#signTransaction = signTransaction ?? false;\n }\n\n abstract matchesTransaction(transactionMeta: TransactionMeta): boolean;\n\n async getLayer1Fee(\n request: Layer1GasFeeFlowRequest,\n ): Promise<Layer1GasFeeFlowResponse> {\n try {\n return await this.#getOracleLayer1GasFee(request);\n } catch (error) {\n log('Failed to get oracle layer 1 gas fee', error);\n throw new Error(`Failed to get oracle layer 1 gas fee`);\n }\n }\n\n async #getOracleLayer1GasFee(\n request: Layer1GasFeeFlowRequest,\n ): Promise<Layer1GasFeeFlowResponse> {\n const { provider, transactionMeta } = request;\n\n const contract = new Contract(\n this.#oracleAddress,\n GAS_PRICE_ORACLE_ABI,\n // Network controller provider type is incompatible with ethers provider\n new Web3Provider(provider as unknown as ExternalProvider),\n );\n\n const serializedTransaction = this.#buildUnserializedTransaction(\n transactionMeta,\n this.#signTransaction,\n ).serialize();\n\n const result = await contract.getL1Fee(serializedTransaction);\n\n if (result === undefined) {\n throw new Error('No value returned from oracle contract');\n }\n\n return {\n layer1Fee: result.toHexString(),\n };\n }\n\n #buildUnserializedTransaction(\n transactionMeta: TransactionMeta,\n sign: boolean,\n ) {\n const txParams = this.#buildTransactionParams(transactionMeta);\n const { chainId } = transactionMeta;\n\n let unserializedTransaction = prepareTransaction(chainId, txParams);\n\n if (sign) {\n const keyBuffer = Buffer.from(DUMMY_KEY, 'hex');\n unserializedTransaction = unserializedTransaction.sign(keyBuffer);\n }\n\n return unserializedTransaction;\n }\n\n #buildTransactionParams(\n transactionMeta: TransactionMeta,\n ): TransactionMeta['txParams'] {\n return {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n };\n }\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Hex } from "@metamask/utils";
|
|
2
|
-
import type { TransactionControllerMessenger } from "../TransactionController.cjs";
|
|
3
2
|
import type { Layer1GasFeeFlow, Layer1GasFeeFlowRequest, Layer1GasFeeFlowResponse, TransactionMeta } from "../types.cjs";
|
|
4
3
|
/**
|
|
5
4
|
* Layer 1 gas fee flow that obtains gas fee estimate using an oracle smart contract.
|
|
@@ -7,10 +6,7 @@ import type { Layer1GasFeeFlow, Layer1GasFeeFlowRequest, Layer1GasFeeFlowRespons
|
|
|
7
6
|
export declare abstract class OracleLayer1GasFeeFlow implements Layer1GasFeeFlow {
|
|
8
7
|
#private;
|
|
9
8
|
constructor(oracleAddress: Hex, signTransaction?: boolean);
|
|
10
|
-
abstract matchesTransaction(
|
|
11
|
-
transactionMeta: TransactionMeta;
|
|
12
|
-
messenger: TransactionControllerMessenger;
|
|
13
|
-
}): boolean;
|
|
9
|
+
abstract matchesTransaction(transactionMeta: TransactionMeta): boolean;
|
|
14
10
|
getLayer1Fee(request: Layer1GasFeeFlowRequest): Promise<Layer1GasFeeFlowResponse>;
|
|
15
11
|
}
|
|
16
12
|
//# sourceMappingURL=OracleLayer1GasFeeFlow.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OracleLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAI3C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"OracleLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAI3C,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EAChB,qBAAiB;AAkBlB;;GAEG;AACH,8BAAsB,sBAAuB,YAAW,gBAAgB;;gBAK1D,aAAa,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,OAAO;IAKzD,QAAQ,CAAC,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAEhE,YAAY,CAChB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC;CA8DrC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Hex } from "@metamask/utils";
|
|
2
|
-
import type { TransactionControllerMessenger } from "../TransactionController.mjs";
|
|
3
2
|
import type { Layer1GasFeeFlow, Layer1GasFeeFlowRequest, Layer1GasFeeFlowResponse, TransactionMeta } from "../types.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* Layer 1 gas fee flow that obtains gas fee estimate using an oracle smart contract.
|
|
@@ -7,10 +6,7 @@ import type { Layer1GasFeeFlow, Layer1GasFeeFlowRequest, Layer1GasFeeFlowRespons
|
|
|
7
6
|
export declare abstract class OracleLayer1GasFeeFlow implements Layer1GasFeeFlow {
|
|
8
7
|
#private;
|
|
9
8
|
constructor(oracleAddress: Hex, signTransaction?: boolean);
|
|
10
|
-
abstract matchesTransaction(
|
|
11
|
-
transactionMeta: TransactionMeta;
|
|
12
|
-
messenger: TransactionControllerMessenger;
|
|
13
|
-
}): boolean;
|
|
9
|
+
abstract matchesTransaction(transactionMeta: TransactionMeta): boolean;
|
|
14
10
|
getLayer1Fee(request: Layer1GasFeeFlowRequest): Promise<Layer1GasFeeFlowResponse>;
|
|
15
11
|
}
|
|
16
12
|
//# sourceMappingURL=OracleLayer1GasFeeFlow.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OracleLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAI3C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"OracleLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAI3C,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EAChB,qBAAiB;AAkBlB;;GAEG;AACH,8BAAsB,sBAAuB,YAAW,gBAAgB;;gBAK1D,aAAa,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,OAAO;IAKzD,QAAQ,CAAC,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAEhE,YAAY,CAChB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC;CA8DrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OracleLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,iCAAiC;AACpD,OAAO,EAAE,YAAY,EAAyB,iCAAiC;AAE/E,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAErD,OAAO,EAAE,aAAa,EAAE,sBAAkB;
|
|
1
|
+
{"version":3,"file":"OracleLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,iCAAiC;AACpD,OAAO,EAAE,YAAY,EAAyB,iCAAiC;AAE/E,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAErD,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAO1C,OAAO,EAAE,kBAAkB,EAAE,6BAAyB;AAEtD,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,4BAA4B,CAAC,CAAC;AAE5E,MAAM,SAAS,GACb,kEAAkE,CAAC;AAErE,MAAM,oBAAoB,GAAG;IAC3B;QACE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EA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KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC3D;IAED,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE;KAChC,CAAC;AACJ,CAAC,uHAGC,eAAgC,EAChC,IAAa;IAEb,MAAM,QAAQ,GAAG,uBAAA,IAAI,yFAAwB,MAA5B,IAAI,EAAyB,eAAe,CAAC,CAAC;IAC/D,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;IAEpC,IAAI,uBAAuB,GAAG,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEpE,IAAI,IAAI,EAAE;QACR,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAChD,uBAAuB,GAAG,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACnE;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC,2GAGC,eAAgC;IAEhC,OAAO;QACL,GAAG,eAAe,CAAC,QAAQ;QAC3B,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG;KACvC,CAAC;AACJ,CAAC","sourcesContent":["import { Contract } from '@ethersproject/contracts';\nimport { Web3Provider, type ExternalProvider } from '@ethersproject/providers';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n Layer1GasFeeFlow,\n Layer1GasFeeFlowRequest,\n Layer1GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { prepareTransaction } from '../utils/prepare';\n\nconst log = createModuleLogger(projectLogger, 'oracle-layer1-gas-fee-flow');\n\nconst DUMMY_KEY =\n 'abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789';\n\nconst GAS_PRICE_ORACLE_ABI = [\n {\n inputs: [{ internalType: 'bytes', name: '_data', type: 'bytes' }],\n name: 'getL1Fee',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n];\n\n/**\n * Layer 1 gas fee flow that obtains gas fee estimate using an oracle smart contract.\n */\nexport abstract class OracleLayer1GasFeeFlow implements Layer1GasFeeFlow {\n readonly #oracleAddress: Hex;\n\n readonly #signTransaction: boolean;\n\n constructor(oracleAddress: Hex, signTransaction?: boolean) {\n this.#oracleAddress = oracleAddress;\n this.#signTransaction = signTransaction ?? false;\n }\n\n abstract matchesTransaction(transactionMeta: TransactionMeta): boolean;\n\n async getLayer1Fee(\n request: Layer1GasFeeFlowRequest,\n ): Promise<Layer1GasFeeFlowResponse> {\n try {\n return await this.#getOracleLayer1GasFee(request);\n } catch (error) {\n log('Failed to get oracle layer 1 gas fee', error);\n throw new Error(`Failed to get oracle layer 1 gas fee`);\n }\n }\n\n async #getOracleLayer1GasFee(\n request: Layer1GasFeeFlowRequest,\n ): Promise<Layer1GasFeeFlowResponse> {\n const { provider, transactionMeta } = request;\n\n const contract = new Contract(\n this.#oracleAddress,\n GAS_PRICE_ORACLE_ABI,\n // Network controller provider type is incompatible with ethers provider\n new Web3Provider(provider as unknown as ExternalProvider),\n );\n\n const serializedTransaction = this.#buildUnserializedTransaction(\n transactionMeta,\n this.#signTransaction,\n ).serialize();\n\n const result = await contract.getL1Fee(serializedTransaction);\n\n if (result === undefined) {\n throw new Error('No value returned from oracle contract');\n }\n\n return {\n layer1Fee: result.toHexString(),\n };\n }\n\n #buildUnserializedTransaction(\n transactionMeta: TransactionMeta,\n sign: boolean,\n ) {\n const txParams = this.#buildTransactionParams(transactionMeta);\n const { chainId } = transactionMeta;\n\n let unserializedTransaction = prepareTransaction(chainId, txParams);\n\n if (sign) {\n const keyBuffer = Buffer.from(DUMMY_KEY, 'hex');\n unserializedTransaction = unserializedTransaction.sign(keyBuffer);\n }\n\n return unserializedTransaction;\n }\n\n #buildTransactionParams(\n transactionMeta: TransactionMeta,\n ): TransactionMeta['txParams'] {\n return {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n };\n }\n}\n"]}
|
|
@@ -13,7 +13,7 @@ class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow_1.OracleLayer1GasFee
|
|
|
13
13
|
constructor() {
|
|
14
14
|
super(SCROLL_GAS_PRICE_ORACLE_ADDRESS, true);
|
|
15
15
|
}
|
|
16
|
-
matchesTransaction(
|
|
16
|
+
matchesTransaction(transactionMeta) {
|
|
17
17
|
return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;AAEA,yEAAkE;AAClE,gDAAyC;
|
|
1
|
+
{"version":3,"file":"ScrollLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;AAEA,yEAAkE;AAClE,gDAAyC;AAGzC,MAAM,gBAAgB,GAAU,CAAC,qBAAS,CAAC,MAAM,EAAE,qBAAS,CAAC,cAAc,CAAC,CAAC;AAE7E,qGAAqG;AACrG,MAAM,+BAA+B,GACnC,4CAA4C,CAAC;AAE/C;;GAEG;AACH,MAAa,sBAAuB,SAAQ,+CAAsB;IAChE;QACE,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,kBAAkB,CAAC,eAAgC;QACjD,OAAO,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF;AARD,wDAQC","sourcesContent":["import { type Hex } from '@metamask/utils';\n\nimport { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow';\nimport { CHAIN_IDS } from '../constants';\nimport type { TransactionMeta } from '../types';\n\nconst SCROLL_CHAIN_IDS: Hex[] = [CHAIN_IDS.SCROLL, CHAIN_IDS.SCROLL_SEPOLIA];\n\n// BlockExplorer link: https://scrollscan.com/address/0x5300000000000000000000000000000000000002#code\nconst SCROLL_GAS_PRICE_ORACLE_ADDRESS =\n '0x5300000000000000000000000000000000000002';\n\n/**\n * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.\n */\nexport class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {\n constructor() {\n super(SCROLL_GAS_PRICE_ORACLE_ADDRESS, true);\n }\n\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n}\n"]}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.cjs";
|
|
2
|
-
import type { TransactionControllerMessenger } from "../TransactionController.cjs";
|
|
3
2
|
import type { TransactionMeta } from "../types.cjs";
|
|
4
3
|
/**
|
|
5
4
|
* Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
|
|
6
5
|
*/
|
|
7
6
|
export declare class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
|
|
8
7
|
constructor();
|
|
9
|
-
matchesTransaction(
|
|
10
|
-
transactionMeta: TransactionMeta;
|
|
11
|
-
messenger: TransactionControllerMessenger;
|
|
12
|
-
}): boolean;
|
|
8
|
+
matchesTransaction(transactionMeta: TransactionMeta): boolean;
|
|
13
9
|
}
|
|
14
10
|
//# sourceMappingURL=ScrollLayer1GasFeeFlow.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ScrollLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAiB;AAQhD;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,sBAAsB;;IAKhE,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;CAG9D"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.mjs";
|
|
2
|
-
import type { TransactionControllerMessenger } from "../TransactionController.mjs";
|
|
3
2
|
import type { TransactionMeta } from "../types.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
|
|
6
5
|
*/
|
|
7
6
|
export declare class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
|
|
8
7
|
constructor();
|
|
9
|
-
matchesTransaction(
|
|
10
|
-
transactionMeta: TransactionMeta;
|
|
11
|
-
messenger: TransactionControllerMessenger;
|
|
12
|
-
}): boolean;
|
|
8
|
+
matchesTransaction(transactionMeta: TransactionMeta): boolean;
|
|
13
9
|
}
|
|
14
10
|
//# sourceMappingURL=ScrollLayer1GasFeeFlow.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ScrollLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAiB;AAQhD;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,sBAAsB;;IAKhE,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;CAG9D"}
|
|
@@ -10,7 +10,7 @@ export class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super(SCROLL_GAS_PRICE_ORACLE_ADDRESS, true);
|
|
12
12
|
}
|
|
13
|
-
matchesTransaction(
|
|
13
|
+
matchesTransaction(transactionMeta) {
|
|
14
14
|
return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,SAAS,EAAE,yBAAqB;
|
|
1
|
+
{"version":3,"file":"ScrollLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,SAAS,EAAE,yBAAqB;AAGzC,MAAM,gBAAgB,GAAU,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;AAE7E,qGAAqG;AACrG,MAAM,+BAA+B,GACnC,4CAA4C,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,sBAAsB;IAChE;QACE,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,kBAAkB,CAAC,eAAgC;QACjD,OAAO,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["import { type Hex } from '@metamask/utils';\n\nimport { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow';\nimport { CHAIN_IDS } from '../constants';\nimport type { TransactionMeta } from '../types';\n\nconst SCROLL_CHAIN_IDS: Hex[] = [CHAIN_IDS.SCROLL, CHAIN_IDS.SCROLL_SEPOLIA];\n\n// BlockExplorer link: https://scrollscan.com/address/0x5300000000000000000000000000000000000002#code\nconst SCROLL_GAS_PRICE_ORACLE_ADDRESS =\n '0x5300000000000000000000000000000000000002';\n\n/**\n * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.\n */\nexport class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {\n constructor() {\n super(SCROLL_GAS_PRICE_ORACLE_ADDRESS, true);\n }\n\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n}\n"]}
|