From 96bfa6c66bc3df4093795983cd99fb05afeaa02d Mon Sep 17 00:00:00 2001 From: KillariDev Date: Wed, 30 Oct 2024 08:31:34 +0200 Subject: [PATCH 1/2] make micah poor again --- app/ts/background/windows/confirmTransaction.ts | 4 ++-- .../services/SimulationModeEthereumClientService.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/ts/background/windows/confirmTransaction.ts b/app/ts/background/windows/confirmTransaction.ts index f81b0a4a..66da4841 100644 --- a/app/ts/background/windows/confirmTransaction.ts +++ b/app/ts/background/windows/confirmTransaction.ts @@ -197,7 +197,7 @@ export const formEthSendTransaction = async(ethereumClientService: EthereumClien const transactionDetails = sendTransactionParams.params[0] if (activeAddress === undefined) throw new Error('Access to active address is denied') const from = simulationMode && transactionDetails.from !== undefined ? transactionDetails.from : activeAddress - const transactionCount = getSimulatedTransactionCount(ethereumClientService, requestAbortController, simulationState, from) + const transactionCountPromise = getSimulatedTransactionCount(ethereumClientService, requestAbortController, simulationState, from) const parentBlock = await parentBlockPromise if (parentBlock === null) throw new Error('The latest block is null') if (parentBlock.baseFeePerGas === undefined) throw new Error(CANNOT_SIMULATE_OFF_LEGACY_BLOCK) @@ -206,7 +206,7 @@ export const formEthSendTransaction = async(ethereumClientService: EthereumClien type: '1559' as const, from, chainId: ethereumClientService.getChainId(), - nonce: await transactionCount, + nonce: await transactionCountPromise, maxFeePerGas: transactionDetails.maxFeePerGas !== undefined && transactionDetails.maxFeePerGas !== null ? transactionDetails.maxFeePerGas : parentBlock.baseFeePerGas * 2n + maxPriorityFeePerGas, maxPriorityFeePerGas, to: transactionDetails.to === undefined ? null : transactionDetails.to, diff --git a/app/ts/simulation/services/SimulationModeEthereumClientService.ts b/app/ts/simulation/services/SimulationModeEthereumClientService.ts index a321190f..66b20f0e 100644 --- a/app/ts/simulation/services/SimulationModeEthereumClientService.ts +++ b/app/ts/simulation/services/SimulationModeEthereumClientService.ts @@ -224,6 +224,11 @@ export const appendTransaction = async (ethereumClientService: EthereumClientSer const signed = mockSignTransaction(transaction.transaction) return simulationState === undefined ? [signed] : simulationState.simulatedTransactions.map((x) => x.preSimulationTransaction.signedTransaction).concat([signed]) } + const getMakeMeRichAddress = async () => { + if (typeof browser === 'undefined') return simulationState?.addressToMakeRich // if we are not running in browser (tests) + if (simulationState === undefined) return undefined // we are not simulation, don't make anyone rich + return await getAddressToMakeRich() + } const parentBlock = await ethereumClientService.getBlock(requestAbortController) if (parentBlock === null) throw new Error('The latest block is null') @@ -231,7 +236,7 @@ export const appendTransaction = async (ethereumClientService: EthereumClientSer if (parentBaseFeePerGas === undefined) throw new Error(CANNOT_SIMULATE_OFF_LEGACY_BLOCK) const signedMessages = getSignedMessagesWithFakeSigner(simulationState) const signedTxs = getSignedTransactions() - const addressToMakeRich = typeof browser === 'undefined' ? simulationState?.addressToMakeRich : await getAddressToMakeRich() + const addressToMakeRich = await getMakeMeRichAddress() const makeMeRich = getMakeMeRichStateOverride(addressToMakeRich) const ethSimulateV1CallResult = await ethereumClientService.simulateTransactionsAndSignatures(signedTxs, signedMessages, parentBlock.number, requestAbortController, makeMeRich) const transactionWebsiteData = { website: transaction.website, created: transaction.created, originalRequestParameters: transaction.originalRequestParameters, transactionIdentifier: transaction.transactionIdentifier } From 992df7e10af2af1a29f25bc0ee6e7156452df0c1 Mon Sep 17 00:00:00 2001 From: KillariDev Date: Fri, 8 Nov 2024 06:58:38 +0200 Subject: [PATCH 2/2] swap order --- .../simulation/services/SimulationModeEthereumClientService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ts/simulation/services/SimulationModeEthereumClientService.ts b/app/ts/simulation/services/SimulationModeEthereumClientService.ts index 66b20f0e..2b7fc4ce 100644 --- a/app/ts/simulation/services/SimulationModeEthereumClientService.ts +++ b/app/ts/simulation/services/SimulationModeEthereumClientService.ts @@ -225,8 +225,8 @@ export const appendTransaction = async (ethereumClientService: EthereumClientSer return simulationState === undefined ? [signed] : simulationState.simulatedTransactions.map((x) => x.preSimulationTransaction.signedTransaction).concat([signed]) } const getMakeMeRichAddress = async () => { - if (typeof browser === 'undefined') return simulationState?.addressToMakeRich // if we are not running in browser (tests) if (simulationState === undefined) return undefined // we are not simulation, don't make anyone rich + if (typeof browser === 'undefined') return simulationState.addressToMakeRich // if we are not running in browser (tests) return await getAddressToMakeRich() }