From 79a4c1a919c6937f28cdf9109b9c6a76f2ac8f03 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Thu, 13 Feb 2025 11:45:56 +0000 Subject: [PATCH 1/2] Enable loading previous proxy deployments. --- apps/remix-ide/src/blockchain/blockchain.tsx | 3 +-- libs/remix-ui/run-tab/src/lib/actions/deploy.ts | 4 ++-- libs/remix-ui/run-tab/src/lib/actions/events.ts | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide/src/blockchain/blockchain.tsx b/apps/remix-ide/src/blockchain/blockchain.tsx index 31c692abe17..896d3eb6946 100644 --- a/apps/remix-ide/src/blockchain/blockchain.tsx +++ b/apps/remix-ide/src/blockchain/blockchain.tsx @@ -93,11 +93,10 @@ export class Blockchain extends Plugin { (_) => this.executionContext.currentblockGasLimit() ) this.txRunner = new TxRunner(web3Runner, {}) - this.networkcallid = 0 - this.networkStatus = { network: { name: ' - ', id: ' - ' } } this.registeredPluginEvents = [] this.defaultPinnedProviders = ['vm-cancun', 'vm-mainnet-fork', 'walletconnect', 'injected-MetaMask', 'basic-http-provider', 'hardhat-provider', 'foundry-provider'] + this.networkStatus = { network: { name: this.defaultPinnedProviders[0], id: ' - ' } } this.pinnedProviders = [] this.setupEvents() this.setupProviders() diff --git a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts index 37fbca3d273..8fae5640743 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts @@ -375,7 +375,7 @@ export const isValidContractAddress = async (plugin: RunTab, address: string) => export const getNetworkProxyAddresses = async (plugin: RunTab, dispatch: React.Dispatch) => { const network = plugin.blockchain.networkStatus.network - const identifier = network.name === 'custom' ? network.name + '-' + network.id : network.name + const identifier = network.name.startsWith('vm') ? 'VM' : network.name === 'custom' ? network.name + '-' + network.id : network.name const networkDeploymentsExists = await plugin.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${identifier}/UUPS.json`) if (networkDeploymentsExists) { @@ -383,7 +383,7 @@ export const getNetworkProxyAddresses = async (plugin: RunTab, dispatch: React.D const parsedNetworkFile: NetworkDeploymentFile = JSON.parse(networkFile) const deployments = [] - for (const proxyAddress in Object.keys(parsedNetworkFile.deployments)) { + for (const proxyAddress of Object.keys(parsedNetworkFile.deployments)) { if (parsedNetworkFile.deployments[proxyAddress] && parsedNetworkFile.deployments[proxyAddress].implementationAddress) { const solcBuildExists = await plugin.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${identifier}/solc-${parsedNetworkFile.deployments[proxyAddress].implementationAddress}.json`) diff --git a/libs/remix-ui/run-tab/src/lib/actions/events.ts b/libs/remix-ui/run-tab/src/lib/actions/events.ts index 2e06963e11a..89e949ccab6 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/events.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/events.ts @@ -39,7 +39,7 @@ export const setupEvents = (plugin: RunTab) => { plugin.blockchain.event.register('contextChanged', async (context) => { dispatch(resetProxyDeployments()) - if (!context.startsWith('vm')) getNetworkProxyAddresses(plugin, dispatch) + getNetworkProxyAddresses(plugin, dispatch) if (context !== 'walletconnect') { (await plugin.call('manager', 'isActive', 'walletconnect')) && plugin.call('manager', 'deactivatePlugin', 'walletconnect') } From 8a2ef0a06b2145af92bae3e542d036a6138b41b2 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 24 Feb 2025 00:09:05 +0000 Subject: [PATCH 2/2] Load vm states based on forks --- apps/remix-ide/src/blockchain/blockchain.tsx | 2 +- libs/remix-ui/run-tab/src/lib/actions/deploy.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/blockchain/blockchain.tsx b/apps/remix-ide/src/blockchain/blockchain.tsx index 896d3eb6946..74fbe5314e4 100644 --- a/apps/remix-ide/src/blockchain/blockchain.tsx +++ b/apps/remix-ide/src/blockchain/blockchain.tsx @@ -378,7 +378,7 @@ export class Blockchain extends Plugin { async saveDeployedContractStorageLayout(contractObject, proxyAddress, networkInfo) { const { contractName, implementationAddress } = contractObject - const networkName = networkInfo.name === 'custom' ? networkInfo.name + '-' + networkInfo.id : networkInfo.name + const networkName = networkInfo.name === 'custom' ? networkInfo.name + '-' + networkInfo.id : networkInfo.name === 'VM' ? networkInfo.name.toLowerCase() + '-' + this.getCurrentFork() : networkInfo.name const hasPreviousDeploys = await this.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${networkName}/UUPS.json`) // TODO: make deploys folder read only. if (hasPreviousDeploys) { diff --git a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts index 8fae5640743..37fbca3d273 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts @@ -375,7 +375,7 @@ export const isValidContractAddress = async (plugin: RunTab, address: string) => export const getNetworkProxyAddresses = async (plugin: RunTab, dispatch: React.Dispatch) => { const network = plugin.blockchain.networkStatus.network - const identifier = network.name.startsWith('vm') ? 'VM' : network.name === 'custom' ? network.name + '-' + network.id : network.name + const identifier = network.name === 'custom' ? network.name + '-' + network.id : network.name const networkDeploymentsExists = await plugin.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${identifier}/UUPS.json`) if (networkDeploymentsExists) { @@ -383,7 +383,7 @@ export const getNetworkProxyAddresses = async (plugin: RunTab, dispatch: React.D const parsedNetworkFile: NetworkDeploymentFile = JSON.parse(networkFile) const deployments = [] - for (const proxyAddress of Object.keys(parsedNetworkFile.deployments)) { + for (const proxyAddress in Object.keys(parsedNetworkFile.deployments)) { if (parsedNetworkFile.deployments[proxyAddress] && parsedNetworkFile.deployments[proxyAddress].implementationAddress) { const solcBuildExists = await plugin.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${identifier}/solc-${parsedNetworkFile.deployments[proxyAddress].implementationAddress}.json`)