From fe1eb8785ef91242c73300df648bb16b61704fb3 Mon Sep 17 00:00:00 2001 From: GabrielMartinezRodriguez Date: Thu, 27 Mar 2025 14:23:50 +0100 Subject: [PATCH 1/6] feat(txm): dynamic priority fee --- apps/randomness/src/index.ts | 4 +- packages/txm/lib/GasPriceOracle.ts | 50 +++++++++++-- packages/txm/lib/TransactionManager.ts | 85 +++++++++++++++++------ packages/txm/lib/utils/safeViemClients.ts | 23 ++++++ 4 files changed, 134 insertions(+), 28 deletions(-) diff --git a/apps/randomness/src/index.ts b/apps/randomness/src/index.ts index 1209079f55..66d43cfa51 100644 --- a/apps/randomness/src/index.ts +++ b/apps/randomness/src/index.ts @@ -30,7 +30,9 @@ class RandomnessService { allowDebug: true, pollingInterval: 250, }, - maxPriorityFeePerGas: 10n, + gas: { + minPriorityFeePerGas: 50n, + }, }) this.transactionFactory = new TransactionFactory(this.txm, env.RANDOM_CONTRACT_ADDRESS, env.PRECOMMIT_DELAY) this.drandService = new DrandService(this.drandRepository, this.transactionFactory) diff --git a/packages/txm/lib/GasPriceOracle.ts b/packages/txm/lib/GasPriceOracle.ts index f3a9625def..186d3cbe5d 100644 --- a/packages/txm/lib/GasPriceOracle.ts +++ b/packages/txm/lib/GasPriceOracle.ts @@ -1,4 +1,5 @@ -import { bigIntMax } from "@happy.tech/common" +import { bigIntMax, bigIntReplacer } from "@happy.tech/common" +import { type Result, err, ok } from "neverthrow" import type { LatestBlock } from "./BlockMonitor.js" import { Topics, eventBus } from "./EventBus.js" import type { TransactionManager } from "./TransactionManager.js" @@ -24,6 +25,7 @@ import type { TransactionManager } from "./TransactionManager.js" export class GasPriceOracle { private txmgr: TransactionManager private expectedNextBaseFeePerGas!: bigint + private targetPriorityFee!: bigint constructor(_transactionManager: TransactionManager) { this.txmgr = _transactionManager @@ -37,7 +39,7 @@ export class GasPriceOracle { this.onNewBlock(block) } - private onNewBlock(block: LatestBlock) { + private async onNewBlock(block: LatestBlock) { const baseFeePerGas = block.baseFeePerGas const gasUsed = block.gasUsed const gasLimit = block.gasLimit @@ -47,6 +49,46 @@ export class GasPriceOracle { gasUsed, gasLimit, ) + const targetPriorityFeeResult = await this.calculateTargetPriorityFee() + if (targetPriorityFeeResult.isErr()) { + if (!this.targetPriorityFee) { + this.targetPriorityFee = this.txmgr.maxPriorityFeePerGas ?? 0n + } + return + } + this.targetPriorityFee = targetPriorityFeeResult.value + } + + private async calculateTargetPriorityFee(): Promise> { + const feeHistory = await this.txmgr.viemClient.safeFeeHistory({ + blockCount: this.txmgr.priorityFeeAnalysisBlocks, + blockTag: "latest", + rewardPercentiles: [this.txmgr.priorityFeeTargetPercentile], + }) + + console.log(JSON.stringify(feeHistory, bigIntReplacer, 2)) + + if (feeHistory.isErr()) { + return err(feeHistory.error) + } + + if (!feeHistory.value.reward) { + return err(new Error("No fee history found")) + } + + const priorityFee = + feeHistory.value.reward.flat().reduce((acc, curr) => acc + BigInt(curr), 0n) / + BigInt(feeHistory.value.reward.flat().length) + + if (this.txmgr.minPriorityFeePerGas && priorityFee < this.txmgr.minPriorityFeePerGas) { + return ok(this.txmgr.minPriorityFeePerGas) + } + + if (this.txmgr.maxPriorityFeePerGas && priorityFee > this.txmgr.maxPriorityFeePerGas) { + return ok(this.txmgr.maxPriorityFeePerGas) + } + + return ok(priorityFee) } private calculateExpectedNextBaseFeePerGas(baseFeePerGas: bigint, gasUsed: bigint, gasLimit: bigint): bigint { @@ -67,7 +109,7 @@ export class GasPriceOracle { public suggestGasForNextBlock(): { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint } { const maxBaseFeePerGas = (this.expectedNextBaseFeePerGas * (100n + this.txmgr.baseFeeMargin)) / 100n - const maxFeePerGas = maxBaseFeePerGas + this.txmgr.maxPriorityFeePerGas - return { maxFeePerGas, maxPriorityFeePerGas: this.txmgr.maxPriorityFeePerGas } + const maxFeePerGas = maxBaseFeePerGas + this.targetPriorityFee + return { maxFeePerGas, maxPriorityFeePerGas: this.targetPriorityFee } } } diff --git a/packages/txm/lib/TransactionManager.ts b/packages/txm/lib/TransactionManager.ts index f01b003a50..04c446dad9 100644 --- a/packages/txm/lib/TransactionManager.ts +++ b/packages/txm/lib/TransactionManager.ts @@ -120,25 +120,58 @@ export type TransactionManagerConfig = { /** The private key of the account used for signing transactions. */ privateKey: Hex - /** Optional EIP-1559 parameters. If not provided, defaults to the OP stack's stock parameters. */ - eip1559?: EIP1559Parameters - /** - * Safety margin for transaction base fees, expressed as a percentage. - * For example, a 20% increase should be represented as 20n. - * - * This is used to calculate the maximum fee per gas and safeguard from unanticipated or - * unpredictable gas price increases, in particular when the transaction cannot be included in - * the very next block. - * - * If not provided, defaults to 20n (20% increase). - */ - baseFeePercentageMargin?: bigint - /** - * Optional maximum priority fee per gas. - * This is the maximum amount of wei per gas the transaction is willing to pay as a tip to miners. - * If not provided, defaults to 0n. - */ - maxPriorityFeePerGas?: bigint + gas: { + /** Optional EIP-1559 parameters. If not provided, defaults to the OP stack's stock parameters. */ + eip1559?: EIP1559Parameters + /** + * Safety margin for transaction base fees, expressed as a percentage. + * For example, a 20% increase should be represented as 20n. + * + * This is used to calculate the maximum fee per gas and safeguard from unanticipated or + * unpredictable gas price increases, in particular when the transaction cannot be included in + * the very next block. + *l + * @default 20n (20% increase) + */ + baseFeePercentageMargin?: bigint + /** + * Maximum allowed priority fee per gas unit (in wei). + * Acts as a safety cap to prevent overpaying for transaction priority. + * Even if the calculated priority fee based on percentile is higher, + * it will be capped at this value. + * @default undefined (no maximum cap) + * @example 2_000_000_000n // 2 Gwei max priority fee + */ + maxPriorityFeePerGas?: bigint + + /** + * Minimum required priority fee per gas unit (in wei). + * Ensures transactions don't get stuck in the mempool due to too low priority fees. + * If the calculated priority fee based on percentile is lower, + * it will be raised to this minimum value. + * @default undefined (no minimum) + * @example 500_000_000n // 0.5 Gwei minimum priority fee + */ + minPriorityFeePerGas?: bigint + + /** + * Target percentile for priority fee calculation (0-100). + * The system analyzes priority fees from transactions in the analyzed blocks + * and sets the fee at this percentile level. + * Higher percentiles mean higher priority but more expensive transactions. + * @default 50 (50th percentile - median priority fee) + */ + priorityFeeTargetPercentile?: number + + /** + * Number of blocks to analyze when calculating the priority fee percentile. + * The system will look at transactions from this many blocks back to determine + * the appropriate priority fee level. + * Higher values provide more stable fee estimates but may be less responsive to recent changes. + * @default 2 (analyze the last 2 blocks) + */ + priorityFeeAnalysisBlocks?: number + } /** The ABIs used by the TransactionManager. * This is a record of aliases to ABIs. The aliases are used to reference the ABIs in the @@ -233,7 +266,6 @@ export class TransactionManager { public readonly chainId: number public readonly eip1559: EIP1559Parameters public readonly baseFeeMargin: bigint - public readonly maxPriorityFeePerGas: bigint public readonly rpcAllowDebug: boolean public readonly blockTime: bigint public readonly finalizedTransactionPurgeTime: number @@ -245,6 +277,10 @@ export class TransactionManager { public readonly livenessSuccessCount: number public readonly livenessDownDelay: number public readonly livenessCheckInterval: number + public readonly priorityFeeTargetPercentile: number + public readonly priorityFeeAnalysisBlocks: number + public readonly minPriorityFeePerGas: bigint | undefined + public readonly maxPriorityFeePerGas: bigint | undefined constructor(_config: TransactionManagerConfig) { initializeTelemetry({ @@ -343,11 +379,14 @@ export class TransactionManager { this.rpcLivenessMonitor = new RpcLivenessMonitor(this) this.chainId = _config.chainId - this.eip1559 = _config.eip1559 ?? opStackDefaultEIP1559Parameters + this.eip1559 = _config.gas.eip1559 ?? opStackDefaultEIP1559Parameters this.abiManager = new ABIManager(_config.abis) - this.baseFeeMargin = _config.baseFeePercentageMargin ?? 20n - this.maxPriorityFeePerGas = _config.maxPriorityFeePerGas ?? 0n + this.baseFeeMargin = _config.gas.baseFeePercentageMargin ?? 20n + this.maxPriorityFeePerGas = _config.gas.maxPriorityFeePerGas + this.minPriorityFeePerGas = _config.gas.minPriorityFeePerGas + this.priorityFeeTargetPercentile = _config.gas.priorityFeeTargetPercentile ?? 50 + this.priorityFeeAnalysisBlocks = _config.gas.priorityFeeAnalysisBlocks ?? 2 this.rpcAllowDebug = _config.rpc.allowDebug ?? false this.blockTime = _config.blockTime ?? 2n diff --git a/packages/txm/lib/utils/safeViemClients.ts b/packages/txm/lib/utils/safeViemClients.ts index e75e6876aa..5953fc97f7 100644 --- a/packages/txm/lib/utils/safeViemClients.ts +++ b/packages/txm/lib/utils/safeViemClients.ts @@ -6,6 +6,7 @@ import type { Chain, EstimateGasErrorType, GetChainIdErrorType, + GetFeeHistoryErrorType, GetTransactionCountErrorType, GetTransactionReceiptErrorType, Hash, @@ -102,6 +103,9 @@ export interface SafeViemPublicClient extends ViemPublicClient { safeGetTransactionCount: ( ...args: Parameters ) => ResultAsync>, GetTransactionCountErrorType> + safeFeeHistory: ( + ...args: Parameters + ) => ResultAsync>, GetFeeHistoryErrorType> } export interface MetricsHandlers { @@ -221,6 +225,25 @@ export function convertToSafeViemPublicClient( }) } + safeClient.safeFeeHistory = (...args: Parameters) => { + if (safeClient.rpcCounter) safeClient.rpcCounter.add(1, { method: "getFeeHistory" }) + const startTime = Date.now() + + return ResultAsync.fromPromise(client.getFeeHistory(...args), unknownToError) + .map((result) => { + const duration = Date.now() - startTime + if (safeClient.rpcResponseTimeHistogram) + safeClient.rpcResponseTimeHistogram.record(duration, { method: "getFeeHistory" }) + return result + }) + .mapErr((error) => { + if (safeClient.rpcErrorCounter) { + safeClient.rpcErrorCounter.add(1, { method: "getFeeHistory" }) + } + return error as GetFeeHistoryErrorType + }) + } + return safeClient } From ce03e8dbdecbd4dd4e7024fc50d764d9431b9b59 Mon Sep 17 00:00:00 2001 From: GabrielMartinezRodriguez Date: Thu, 27 Mar 2025 14:34:58 +0100 Subject: [PATCH 2/6] chore(txm): code review --- apps/randomness/src/index.ts | 2 +- packages/txm/lib/GasPriceOracle.ts | 6 ++---- packages/txm/lib/TransactionManager.ts | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/randomness/src/index.ts b/apps/randomness/src/index.ts index 66d43cfa51..8976cdc1bd 100644 --- a/apps/randomness/src/index.ts +++ b/apps/randomness/src/index.ts @@ -31,7 +31,7 @@ class RandomnessService { pollingInterval: 250, }, gas: { - minPriorityFeePerGas: 50n, + minPriorityFeePerGas: 10n, }, }) this.transactionFactory = new TransactionFactory(this.txm, env.RANDOM_CONTRACT_ADDRESS, env.PRECOMMIT_DELAY) diff --git a/packages/txm/lib/GasPriceOracle.ts b/packages/txm/lib/GasPriceOracle.ts index 186d3cbe5d..eff908df64 100644 --- a/packages/txm/lib/GasPriceOracle.ts +++ b/packages/txm/lib/GasPriceOracle.ts @@ -1,4 +1,4 @@ -import { bigIntMax, bigIntReplacer } from "@happy.tech/common" +import { bigIntMax } from "@happy.tech/common" import { type Result, err, ok } from "neverthrow" import type { LatestBlock } from "./BlockMonitor.js" import { Topics, eventBus } from "./EventBus.js" @@ -51,7 +51,7 @@ export class GasPriceOracle { ) const targetPriorityFeeResult = await this.calculateTargetPriorityFee() if (targetPriorityFeeResult.isErr()) { - if (!this.targetPriorityFee) { + if (this.targetPriorityFee === undefined) { this.targetPriorityFee = this.txmgr.maxPriorityFeePerGas ?? 0n } return @@ -66,8 +66,6 @@ export class GasPriceOracle { rewardPercentiles: [this.txmgr.priorityFeeTargetPercentile], }) - console.log(JSON.stringify(feeHistory, bigIntReplacer, 2)) - if (feeHistory.isErr()) { return err(feeHistory.error) } diff --git a/packages/txm/lib/TransactionManager.ts b/packages/txm/lib/TransactionManager.ts index 04c446dad9..d32b73e11e 100644 --- a/packages/txm/lib/TransactionManager.ts +++ b/packages/txm/lib/TransactionManager.ts @@ -130,7 +130,7 @@ export type TransactionManagerConfig = { * This is used to calculate the maximum fee per gas and safeguard from unanticipated or * unpredictable gas price increases, in particular when the transaction cannot be included in * the very next block. - *l + * * @default 20n (20% increase) */ baseFeePercentageMargin?: bigint From a200a917d4a311fcc4ad9bec6560148b24ab3d13 Mon Sep 17 00:00:00 2001 From: GabrielMartinezRodriguez Date: Thu, 27 Mar 2025 14:40:19 +0100 Subject: [PATCH 3/6] fix(txm): fixed tests --- .../deployments/unknown/mocks/abiMap.json | 8 + contracts/deployments/unknown/mocks/abis.json | 425 ++++++++++++++++ contracts/deployments/unknown/mocks/abis.ts | 469 ++++++++++++++++++ .../deployments/unknown/mocks/deployment.json | 8 + packages/txm/test/txm.test.ts | 6 +- 5 files changed, 914 insertions(+), 2 deletions(-) create mode 100644 contracts/deployments/unknown/mocks/abiMap.json create mode 100644 contracts/deployments/unknown/mocks/abis.json create mode 100644 contracts/deployments/unknown/mocks/abis.ts create mode 100644 contracts/deployments/unknown/mocks/deployment.json diff --git a/contracts/deployments/unknown/mocks/abiMap.json b/contracts/deployments/unknown/mocks/abiMap.json new file mode 100644 index 0000000000..391a4a03dc --- /dev/null +++ b/contracts/deployments/unknown/mocks/abiMap.json @@ -0,0 +1,8 @@ +{ + "HappyCounter": "HappyCounter", + "MockGasBurner": "MockGasBurner", + "MockRevert": "MockRevert", + "MockTokenA": "MockERC20", + "MockTokenB": "MockERC20", + "MockTokenC": "MockERC20" +} \ No newline at end of file diff --git a/contracts/deployments/unknown/mocks/abis.json b/contracts/deployments/unknown/mocks/abis.json new file mode 100644 index 0000000000..d6b42e7c1e --- /dev/null +++ b/contracts/deployments/unknown/mocks/abis.json @@ -0,0 +1,425 @@ +{ + "HappyCounter": [ + { + "type": "function", + "name": "getCount", + "inputs": [], + "outputs": [ + { + "name": "count", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "increment", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "reset", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + } + ], + "MockERC20": [ + { + "type": "constructor", + "inputs": [ + { + "name": "name_", + "type": "string", + "internalType": "string" + }, + { + "name": "symbol_", + "type": "string", + "internalType": "string" + }, + { + "name": "decimals_", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "allowance", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "burn", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "domainSeparator", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "mint", + "inputs": [ + { + "name": "_account", + "type": "address", + "internalType": "address" + }, + { + "name": "_amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "nonces", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "permit", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "deadline", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "v", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "r", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "s", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transfer", + "inputs": [ + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Approval", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + } + ], + "MockGasBurner": [ + { + "type": "function", + "name": "burnGas", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + } + ], + "MockRevert": [ + { + "type": "function", + "name": "intentionalRevert", + "inputs": [], + "outputs": [], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "intentionalRevertDueToGasLimit", + "inputs": [], + "outputs": [], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "intentionalRevertEmpty", + "inputs": [], + "outputs": [], + "stateMutability": "pure" + }, + { + "type": "error", + "name": "CustomErrorMockRevert", + "inputs": [] + } + ] +} diff --git a/contracts/deployments/unknown/mocks/abis.ts b/contracts/deployments/unknown/mocks/abis.ts new file mode 100644 index 0000000000..2182d7fbda --- /dev/null +++ b/contracts/deployments/unknown/mocks/abis.ts @@ -0,0 +1,469 @@ +// This file is auto-generated by `make deploy` in `contracts/Makefile` +import type { MapTuple, ObjectFromTuples, UnionToTuple } from "@happy.tech/common" +import type { Address } from "viem" + + +const contractToAbi = ({ + "HappyCounter": [ + { + "type": "function", + "name": "getCount", + "inputs": [], + "outputs": [ + { + "name": "count", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "increment", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "reset", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + } + ], + "MockERC20": [ + { + "type": "constructor", + "inputs": [ + { + "name": "name_", + "type": "string", + "internalType": "string" + }, + { + "name": "symbol_", + "type": "string", + "internalType": "string" + }, + { + "name": "decimals_", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "allowance", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "burn", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "domainSeparator", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "mint", + "inputs": [ + { + "name": "_account", + "type": "address", + "internalType": "address" + }, + { + "name": "_amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "nonces", + "inputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "permit", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "deadline", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "v", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "r", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "s", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transfer", + "inputs": [ + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Approval", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + } + ], + "MockGasBurner": [ + { + "type": "function", + "name": "burnGas", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + } + ], + "MockRevert": [ + { + "type": "function", + "name": "intentionalRevert", + "inputs": [], + "outputs": [], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "intentionalRevertDueToGasLimit", + "inputs": [], + "outputs": [], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "intentionalRevertEmpty", + "inputs": [], + "outputs": [], + "stateMutability": "pure" + }, + { + "type": "error", + "name": "CustomErrorMockRevert", + "inputs": [] + } + ] +} +) as const + +const aliasToContract = ({ + "HappyCounter": "HappyCounter", + "MockGasBurner": "MockGasBurner", + "MockRevert": "MockRevert", + "MockTokenA": "MockERC20", + "MockTokenB": "MockERC20", + "MockTokenC": "MockERC20" +}) as const + +export const deployment = ({ + "HappyCounter": "0x8D45cAd49F37CC512DAFFE6700ddc98084867E68", + "MockGasBurner": "0xdA504Bb1b736b04A5Aec28fD5d693Ad7447Ad438", + "MockRevert": "0x4065fA94A420c30c9bBc32483e65CaC8edDDa855", + "MockTokenA": "0x6C2A2f0B573bb660F5548E4B549b595ff478F441", + "MockTokenB": "0x0C25f86894C1a24160Cf7e96460F58CF9Ad79e01", + "MockTokenC": "0x2A8eb32069E47cC908F403194B5aaBC71d87c858" +}) as const + +export type ContractToAbi = typeof contractToAbi +export type AliasToContract = typeof aliasToContract +export type ContractName = keyof ContractToAbi +export type ContractAlias = keyof AliasToContract +export type Deployment = Record + +type AliasTuple = UnionToTuple +type AbiValuesTuple = MapTuple, ContractToAbi> + +export type StaticAbis = ObjectFromTuples + +export const abis = {} as StaticAbis + +for (const [alias, contractName] of Object.entries(aliasToContract)) { + // biome-ignore lint/suspicious/noExplicitAny: safe generated code + abis[alias as ContractAlias] = contractToAbi[contractName as ContractName] as any +} + + diff --git a/contracts/deployments/unknown/mocks/deployment.json b/contracts/deployments/unknown/mocks/deployment.json new file mode 100644 index 0000000000..8bb601c105 --- /dev/null +++ b/contracts/deployments/unknown/mocks/deployment.json @@ -0,0 +1,8 @@ +{ + "HappyCounter": "0x8D45cAd49F37CC512DAFFE6700ddc98084867E68", + "MockGasBurner": "0xdA504Bb1b736b04A5Aec28fD5d693Ad7447Ad438", + "MockRevert": "0x4065fA94A420c30c9bBc32483e65CaC8edDDa855", + "MockTokenA": "0x6C2A2f0B573bb660F5548E4B549b595ff478F441", + "MockTokenB": "0x0C25f86894C1a24160Cf7e96460F58CF9Ad79e01", + "MockTokenC": "0x2A8eb32069E47cC908F403194B5aaBC71d87c858" +} \ No newline at end of file diff --git a/packages/txm/test/txm.test.ts b/packages/txm/test/txm.test.ts index d3913881b1..f7bff6c9fc 100644 --- a/packages/txm/test/txm.test.ts +++ b/packages/txm/test/txm.test.ts @@ -44,8 +44,10 @@ const txm = new TransactionManager({ abis: abis, gasEstimator: new TestGasEstimator(), retryPolicyManager: retryManager, - baseFeePercentageMargin: BASE_FEE_PERCENTAGE_MARGIN, - eip1559: ethereumDefaultEIP1559Parameters, + gas: { + baseFeePercentageMargin: BASE_FEE_PERCENTAGE_MARGIN, + eip1559: ethereumDefaultEIP1559Parameters, + }, metrics: { active: false, }, From c0dbd8bc97c8d9b8492262828237acab465b77b6 Mon Sep 17 00:00:00 2001 From: GabrielMartinezRodriguez Date: Mon, 7 Apr 2025 14:01:32 +0200 Subject: [PATCH 4/6] chore(txm): renamed safeGetFeeHistory --- packages/txm/lib/GasPriceOracle.ts | 2 +- packages/txm/lib/utils/safeViemClients.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/txm/lib/GasPriceOracle.ts b/packages/txm/lib/GasPriceOracle.ts index eff908df64..31d3580a88 100644 --- a/packages/txm/lib/GasPriceOracle.ts +++ b/packages/txm/lib/GasPriceOracle.ts @@ -60,7 +60,7 @@ export class GasPriceOracle { } private async calculateTargetPriorityFee(): Promise> { - const feeHistory = await this.txmgr.viemClient.safeFeeHistory({ + const feeHistory = await this.txmgr.viemClient.safeGetFeeHistory({ blockCount: this.txmgr.priorityFeeAnalysisBlocks, blockTag: "latest", rewardPercentiles: [this.txmgr.priorityFeeTargetPercentile], diff --git a/packages/txm/lib/utils/safeViemClients.ts b/packages/txm/lib/utils/safeViemClients.ts index 5953fc97f7..9c1ba6735a 100644 --- a/packages/txm/lib/utils/safeViemClients.ts +++ b/packages/txm/lib/utils/safeViemClients.ts @@ -103,7 +103,7 @@ export interface SafeViemPublicClient extends ViemPublicClient { safeGetTransactionCount: ( ...args: Parameters ) => ResultAsync>, GetTransactionCountErrorType> - safeFeeHistory: ( + safeGetFeeHistory: ( ...args: Parameters ) => ResultAsync>, GetFeeHistoryErrorType> } @@ -225,7 +225,7 @@ export function convertToSafeViemPublicClient( }) } - safeClient.safeFeeHistory = (...args: Parameters) => { + safeClient.safeGetFeeHistory = (...args: Parameters) => { if (safeClient.rpcCounter) safeClient.rpcCounter.add(1, { method: "getFeeHistory" }) const startTime = Date.now() From 4f5219b37f6a691ba67b95a32f5d5e41a4e2c7de Mon Sep 17 00:00:00 2001 From: GabrielMartinezRodriguez Date: Mon, 7 Apr 2025 14:06:04 +0200 Subject: [PATCH 5/6] chore(contracts): remove unknown folder --- .../deployments/unknown/mocks/abiMap.json | 8 - contracts/deployments/unknown/mocks/abis.json | 425 ---------------- contracts/deployments/unknown/mocks/abis.ts | 469 ------------------ .../deployments/unknown/mocks/deployment.json | 8 - 4 files changed, 910 deletions(-) delete mode 100644 contracts/deployments/unknown/mocks/abiMap.json delete mode 100644 contracts/deployments/unknown/mocks/abis.json delete mode 100644 contracts/deployments/unknown/mocks/abis.ts delete mode 100644 contracts/deployments/unknown/mocks/deployment.json diff --git a/contracts/deployments/unknown/mocks/abiMap.json b/contracts/deployments/unknown/mocks/abiMap.json deleted file mode 100644 index 391a4a03dc..0000000000 --- a/contracts/deployments/unknown/mocks/abiMap.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "HappyCounter": "HappyCounter", - "MockGasBurner": "MockGasBurner", - "MockRevert": "MockRevert", - "MockTokenA": "MockERC20", - "MockTokenB": "MockERC20", - "MockTokenC": "MockERC20" -} \ No newline at end of file diff --git a/contracts/deployments/unknown/mocks/abis.json b/contracts/deployments/unknown/mocks/abis.json deleted file mode 100644 index d6b42e7c1e..0000000000 --- a/contracts/deployments/unknown/mocks/abis.json +++ /dev/null @@ -1,425 +0,0 @@ -{ - "HappyCounter": [ - { - "type": "function", - "name": "getCount", - "inputs": [], - "outputs": [ - { - "name": "count", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "increment", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "reset", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - } - ], - "MockERC20": [ - { - "type": "constructor", - "inputs": [ - { - "name": "name_", - "type": "string", - "internalType": "string" - }, - { - "name": "symbol_", - "type": "string", - "internalType": "string" - }, - { - "name": "decimals_", - "type": "uint8", - "internalType": "uint8" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "allowance", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - }, - { - "name": "spender", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "approve", - "inputs": [ - { - "name": "spender", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "balanceOf", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "burn", - "inputs": [ - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "decimals", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint8", - "internalType": "uint8" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "domainSeparator", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "mint", - "inputs": [ - { - "name": "_account", - "type": "address", - "internalType": "address" - }, - { - "name": "_amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "nonces", - "inputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "permit", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - }, - { - "name": "spender", - "type": "address", - "internalType": "address" - }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "deadline", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "v", - "type": "uint8", - "internalType": "uint8" - }, - { - "name": "r", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "s", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "symbol", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "totalSupply", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "transfer", - "inputs": [ - { - "name": "to", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferFrom", - "inputs": [ - { - "name": "from", - "type": "address", - "internalType": "address" - }, - { - "name": "to", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "Approval", - "inputs": [ - { - "name": "owner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "spender", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "value", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Transfer", - "inputs": [ - { - "name": "from", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "to", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "value", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - } - ], - "MockGasBurner": [ - { - "type": "function", - "name": "burnGas", - "inputs": [ - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - } - ], - "MockRevert": [ - { - "type": "function", - "name": "intentionalRevert", - "inputs": [], - "outputs": [], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "intentionalRevertDueToGasLimit", - "inputs": [], - "outputs": [], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "intentionalRevertEmpty", - "inputs": [], - "outputs": [], - "stateMutability": "pure" - }, - { - "type": "error", - "name": "CustomErrorMockRevert", - "inputs": [] - } - ] -} diff --git a/contracts/deployments/unknown/mocks/abis.ts b/contracts/deployments/unknown/mocks/abis.ts deleted file mode 100644 index 2182d7fbda..0000000000 --- a/contracts/deployments/unknown/mocks/abis.ts +++ /dev/null @@ -1,469 +0,0 @@ -// This file is auto-generated by `make deploy` in `contracts/Makefile` -import type { MapTuple, ObjectFromTuples, UnionToTuple } from "@happy.tech/common" -import type { Address } from "viem" - - -const contractToAbi = ({ - "HappyCounter": [ - { - "type": "function", - "name": "getCount", - "inputs": [], - "outputs": [ - { - "name": "count", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "increment", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "reset", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - } - ], - "MockERC20": [ - { - "type": "constructor", - "inputs": [ - { - "name": "name_", - "type": "string", - "internalType": "string" - }, - { - "name": "symbol_", - "type": "string", - "internalType": "string" - }, - { - "name": "decimals_", - "type": "uint8", - "internalType": "uint8" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "allowance", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - }, - { - "name": "spender", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "approve", - "inputs": [ - { - "name": "spender", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "balanceOf", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "burn", - "inputs": [ - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "decimals", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint8", - "internalType": "uint8" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "domainSeparator", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "mint", - "inputs": [ - { - "name": "_account", - "type": "address", - "internalType": "address" - }, - { - "name": "_amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "nonces", - "inputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "permit", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - }, - { - "name": "spender", - "type": "address", - "internalType": "address" - }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "deadline", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "v", - "type": "uint8", - "internalType": "uint8" - }, - { - "name": "r", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "s", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "symbol", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "totalSupply", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "transfer", - "inputs": [ - { - "name": "to", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferFrom", - "inputs": [ - { - "name": "from", - "type": "address", - "internalType": "address" - }, - { - "name": "to", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "Approval", - "inputs": [ - { - "name": "owner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "spender", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "value", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Transfer", - "inputs": [ - { - "name": "from", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "to", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "value", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - } - ], - "MockGasBurner": [ - { - "type": "function", - "name": "burnGas", - "inputs": [ - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - } - ], - "MockRevert": [ - { - "type": "function", - "name": "intentionalRevert", - "inputs": [], - "outputs": [], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "intentionalRevertDueToGasLimit", - "inputs": [], - "outputs": [], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "intentionalRevertEmpty", - "inputs": [], - "outputs": [], - "stateMutability": "pure" - }, - { - "type": "error", - "name": "CustomErrorMockRevert", - "inputs": [] - } - ] -} -) as const - -const aliasToContract = ({ - "HappyCounter": "HappyCounter", - "MockGasBurner": "MockGasBurner", - "MockRevert": "MockRevert", - "MockTokenA": "MockERC20", - "MockTokenB": "MockERC20", - "MockTokenC": "MockERC20" -}) as const - -export const deployment = ({ - "HappyCounter": "0x8D45cAd49F37CC512DAFFE6700ddc98084867E68", - "MockGasBurner": "0xdA504Bb1b736b04A5Aec28fD5d693Ad7447Ad438", - "MockRevert": "0x4065fA94A420c30c9bBc32483e65CaC8edDDa855", - "MockTokenA": "0x6C2A2f0B573bb660F5548E4B549b595ff478F441", - "MockTokenB": "0x0C25f86894C1a24160Cf7e96460F58CF9Ad79e01", - "MockTokenC": "0x2A8eb32069E47cC908F403194B5aaBC71d87c858" -}) as const - -export type ContractToAbi = typeof contractToAbi -export type AliasToContract = typeof aliasToContract -export type ContractName = keyof ContractToAbi -export type ContractAlias = keyof AliasToContract -export type Deployment = Record - -type AliasTuple = UnionToTuple -type AbiValuesTuple = MapTuple, ContractToAbi> - -export type StaticAbis = ObjectFromTuples - -export const abis = {} as StaticAbis - -for (const [alias, contractName] of Object.entries(aliasToContract)) { - // biome-ignore lint/suspicious/noExplicitAny: safe generated code - abis[alias as ContractAlias] = contractToAbi[contractName as ContractName] as any -} - - diff --git a/contracts/deployments/unknown/mocks/deployment.json b/contracts/deployments/unknown/mocks/deployment.json deleted file mode 100644 index 8bb601c105..0000000000 --- a/contracts/deployments/unknown/mocks/deployment.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "HappyCounter": "0x8D45cAd49F37CC512DAFFE6700ddc98084867E68", - "MockGasBurner": "0xdA504Bb1b736b04A5Aec28fD5d693Ad7447Ad438", - "MockRevert": "0x4065fA94A420c30c9bBc32483e65CaC8edDDa855", - "MockTokenA": "0x6C2A2f0B573bb660F5548E4B549b595ff478F441", - "MockTokenB": "0x0C25f86894C1a24160Cf7e96460F58CF9Ad79e01", - "MockTokenC": "0x2A8eb32069E47cC908F403194B5aaBC71d87c858" -} \ No newline at end of file From 1356e03d971e807ded1fd0a281d4a599f927e0be Mon Sep 17 00:00:00 2001 From: GabrielMartinezRodriguez Date: Mon, 7 Apr 2025 14:08:32 +0200 Subject: [PATCH 6/6] chore(txm): await onNewBlock on start --- packages/txm/lib/GasPriceOracle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/txm/lib/GasPriceOracle.ts b/packages/txm/lib/GasPriceOracle.ts index 31d3580a88..0df8be7994 100644 --- a/packages/txm/lib/GasPriceOracle.ts +++ b/packages/txm/lib/GasPriceOracle.ts @@ -36,7 +36,7 @@ export class GasPriceOracle { const block = await this.txmgr.viemClient.getBlock({ blockTag: "latest", }) - this.onNewBlock(block) + await this.onNewBlock(block) } private async onNewBlock(block: LatestBlock) {