From fe4099f10d803f3bdcd6d30dbdc9c964b5816f04 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sat, 19 Aug 2023 12:25:48 +0200 Subject: [PATCH] fix: improve payload unwrapping --- src/utils/logger.ts | 8 ++++++-- src/utils/tenderlyClient.ts | 15 ++++++++++----- tsconfig.json | 3 ++- 3 files changed, 18 insertions(+), 8 deletions(-) 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 } }