add forked chain in env explorer

pull/5083/head^2
yann300 3 months ago committed by Aniket
parent d7494cf875
commit 64bec7b787
  1. 42
      apps/remix-ide/src/app/providers/environment-explorer.tsx
  2. 9
      apps/remix-ide/src/app/udapp/run-tab.js
  3. 1
      apps/remix-ide/src/blockchain/blockchain.tsx

@ -25,7 +25,7 @@ const profile = {
methods: [] methods: []
} }
type ProvidersSection = `Injected` | 'Remix VMs' | 'Externals' type ProvidersSection = `Injected` | 'Remix VMs' | 'Externals' | 'Remix forked VMs'
export class EnvironmentExplorer extends ViewPlugin { export class EnvironmentExplorer extends ViewPlugin {
providers: { [key in ProvidersSection]: Provider[] } providers: { [key in ProvidersSection]: Provider[] }
@ -39,6 +39,7 @@ export class EnvironmentExplorer extends ViewPlugin {
this.providers = { this.providers = {
'Injected': [], 'Injected': [],
'Remix VMs': [], 'Remix VMs': [],
'Remix forked VMs': [],
'Externals': [] 'Externals': []
} }
} }
@ -52,6 +53,8 @@ export class EnvironmentExplorer extends ViewPlugin {
addProvider (provider: Provider) { addProvider (provider: Provider) {
if (provider.isInjected) { if (provider.isInjected) {
this.providers['Injected'].push(provider) this.providers['Injected'].push(provider)
} else if (provider.isForkedVM) {
this.providers['Remix forked VMs'].push(provider)
} else if (provider.isVM) { } else if (provider.isVM) {
this.providers['Remix VMs'].push(provider) this.providers['Remix VMs'].push(provider)
} else { } else {
@ -81,7 +84,8 @@ export class EnvironmentExplorer extends ViewPlugin {
this.providers = { this.providers = {
'Injected': [], 'Injected': [],
'Remix VMs': [], 'Remix VMs': [],
'Externals': [] 'Externals': [],
'Remix forked VMs': []
} }
for (const [key, provider] of Object.entries(this.providersFlat)) { for (const [key, provider] of Object.entries(this.providersFlat)) {
this.addProvider(provider) this.addProvider(provider)
@ -167,6 +171,40 @@ export class EnvironmentExplorer extends ViewPlugin {
<div>{provider.description}</div> <div>{provider.description}</div>
</RemixUIGridCell> </RemixUIGridCell>
})}</RemixUIGridSection> })}</RemixUIGridSection>
<RemixUIGridSection
plugin={this}
title='Deploy to an In-browser forked Virtual Machine.'
hScrollable={false}
>{this.providers['Remix forked VMs'].map(provider => {
return <RemixUIGridCell
plugin={this}
title={provider.displayName}
logos={provider.logos}
classList='EECellStyle'
searchKeywords={['Remix VMs', provider.name, provider.displayName, provider.title, provider.description]}
pinned={this.pinnedProviders.includes(provider.name)}
key={provider.name}
id={provider.name}
pinStateCallback={async (pinned: boolean) => {
if (pinned) {
this.emit('providerPinned', provider.name, provider)
this.call('notification', 'toast', `"${provider.displayName}" has been added to the Environment list of the Deploy & Run Transactions plugin.`)
return true
}
const providerName = await this.call('blockchain', 'getProvider')
if (providerName !== provider.name) {
this.emit('providerUnpinned', provider.name, provider)
this.call('notification', 'toast', `"${provider.displayName}" has been removed from the Environment list of the Deploy & Run Transactions plugin.`)
return true
} else {
this.call('notification', 'toast', 'Cannot unpin the current selected provider')
return false
}
}}
>
<div>{provider.description}</div>
</RemixUIGridCell>
})}</RemixUIGridSection>
<RemixUIGridSection <RemixUIGridSection
plugin={this} plugin={this}
title='Deploy to an external Provider.' title='Deploy to an external Provider.'

@ -165,7 +165,7 @@ export class RunTab extends ViewPlugin {
'foundry-provider': ['assets/img/foundry.png'] 'foundry-provider': ['assets/img/foundry.png']
} }
const addProvider = async (position, name, displayName, isInjected, isVM, fork = '', dataId = '', title = '') => { const addProvider = async (position, name, displayName, isInjected, isVM, fork = '', dataId = '', title = '', forkedVM = false) => {
await this.call('blockchain', 'addProvider', { await this.call('blockchain', 'addProvider', {
position, position,
options: {}, options: {},
@ -176,6 +176,7 @@ export class RunTab extends ViewPlugin {
logos: logos[name], logos: logos[name],
fork, fork,
isInjected, isInjected,
isForkedVM: forkedVM,
isVM, isVM,
title, title,
init: async function () { init: async function () {
@ -237,9 +238,9 @@ export class RunTab extends ViewPlugin {
await addProvider(51, 'vm-paris', 'Remix VM (Paris)', false, true, 'paris', 'settingsVMParisMode', titleVM) await addProvider(51, 'vm-paris', 'Remix VM (Paris)', false, true, 'paris', 'settingsVMParisMode', titleVM)
await addProvider(52, 'vm-london', 'Remix VM (London)', false, true, 'london', 'settingsVMLondonMode', titleVM) await addProvider(52, 'vm-london', 'Remix VM (London)', false, true, 'london', 'settingsVMLondonMode', titleVM)
await addProvider(53, 'vm-berlin', 'Remix VM (Berlin)', false, true, 'berlin', 'settingsVMBerlinMode', titleVM) await addProvider(53, 'vm-berlin', 'Remix VM (Berlin)', false, true, 'berlin', 'settingsVMBerlinMode', titleVM)
await addProvider(2, 'vm-mainnet-fork', 'Remix VM - Mainnet fork', false, true, 'cancun', 'settingsVMMainnetMode', titleVM) await addProvider(2, 'vm-mainnet-fork', 'Remix VM - Mainnet fork', false, true, 'cancun', 'settingsVMMainnetMode', titleVM, true)
await addProvider(3, 'vm-sepolia-fork', 'Remix VM - Sepolia fork', false, true, 'cancun', 'settingsVMSepoliaMode', titleVM) await addProvider(3, 'vm-sepolia-fork', 'Remix VM - Sepolia fork', false, true, 'cancun', 'settingsVMSepoliaMode', titleVM, true)
await addProvider(4, 'vm-custom-fork', 'Remix VM - Custom fork', false, true, '', 'settingsVMCustomMode', titleVM) await addProvider(4, 'vm-custom-fork', 'Remix VM - Custom fork', false, true, '', 'settingsVMCustomMode', titleVM, true)
// wallet connect // wallet connect
await addProvider(6, 'walletconnect', 'WalletConnect', false, false) await addProvider(6, 'walletconnect', 'WalletConnect', false, false)

@ -55,6 +55,7 @@ export type Provider = {
description?: string description?: string
isInjected: boolean isInjected: boolean
isVM: boolean isVM: boolean
isForkedVM: boolean
title: string title: string
init: () => Promise<void> init: () => Promise<void>
provider:{ provider:{

Loading…
Cancel
Save