From 06e29ce5b9ddc7251bacf99c7ae3dbaeed471392 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 12 Feb 2024 21:20:45 +0100 Subject: [PATCH] Load state based on evm state --- apps/remix-ide/src/blockchain/blockchain.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/remix-ide/src/blockchain/blockchain.tsx b/apps/remix-ide/src/blockchain/blockchain.tsx index c9e68b3857..0903f535c3 100644 --- a/apps/remix-ide/src/blockchain/blockchain.tsx +++ b/apps/remix-ide/src/blockchain/blockchain.tsx @@ -646,14 +646,18 @@ export class Blockchain extends Plugin { } async loadContext(context: string) { - const contextExists = await this.call('fileManager', 'exists', `.states/${context}/state.json`) - - if (contextExists) { - const stateDb = await this.call('fileManager', 'readFile', `.states/${context}/state.json`) - - await this.getCurrentProvider().resetEnvironment(stateDb) - } else { - await this.getCurrentProvider().resetEnvironment() + const saveEvmState = this.config.get('settings/save-env-state') + + if (saveEvmState) { + const contextExists = await this.call('fileManager', 'exists', `.states/${context}/state.json`) + + if (contextExists) { + const stateDb = await this.call('fileManager', 'readFile', `.states/${context}/state.json`) + + await this.getCurrentProvider().resetEnvironment(stateDb) + } else { + await this.getCurrentProvider().resetEnvironment() + } } // TODO: most params here can be refactored away in txRunner