diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 2b8a0b7..bd7d8f4 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -4,10 +4,14 @@ export function logInfo(topic: string, text: string) { console.log(chalk.blue(`Info[${topic}]: ${text}`)); } +export function logWarning(topic: string, text: string) { + console.log(chalk.yellow(`Warning[${topic}]: ${text}`)); +} + export function logError(topic: string, text: string) { - console.log(chalk.red(`Info[${topic}]: ${text}`)); + console.log(chalk.red(`Error[${topic}]: ${text}`)); } export function logSuccess(topic: string, text: string) { - console.log(chalk.green(`Info[${topic}]: ${text}`)); + console.log(chalk.green(`Success[${topic}]: ${text}`)); } diff --git a/src/utils/tenderlyClient.ts b/src/utils/tenderlyClient.ts index cb9f195..8d45a8f 100644 --- a/src/utils/tenderlyClient.ts +++ b/src/utils/tenderlyClient.ts @@ -13,7 +13,7 @@ import { fromHex, } from 'viem'; import { EOA } from './constants'; -import { logInfo } from './logger'; +import { logInfo, logWarning } from './logger'; export type StateObject = { balance?: string; code?: string; @@ -357,10 +357,15 @@ class Tenderly { // 2. warp time if (request.block_header?.timestamp) { const currentBlock = await publicProvider.getBlock(); - await publicProvider.request({ - method: 'evm_increaseTime' as any, - params: [toHex(fromHex(request.block_header?.timestamp, 'bigint') - currentBlock.timestamp)], - }); + // warping back in time + if (fromHex(request.block_header?.timestamp, 'bigint') > currentBlock.timestamp) { + await publicProvider.request({ + method: 'evm_increaseTime' as any, + params: [toHex(fromHex(request.block_header?.timestamp, 'bigint') - currentBlock.timestamp)], + }); + } else { + logWarning('tenderly', 'skipping time warp as tenderly forks do not support traveling back in time'); + } } // 3. execute txn diff --git a/tsconfig.json b/tsconfig.json index cb134bc..d14327f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "strict": true, "target": "ESNext", - "moduleResolution": "Node" + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true } }