diff --git a/app/ts/background/windows/confirmTransaction.ts b/app/ts/background/windows/confirmTransaction.ts index 3a26fdc7..10661789 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 dfc5e7eb..0a2ad1e5 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 (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() + } 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 }