Skip to content

Commit

Permalink
add forked chain in env explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 authored and Aniket-Engg committed Sep 2, 2024
1 parent d7494cf commit 64bec7b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
42 changes: 40 additions & 2 deletions apps/remix-ide/src/app/providers/environment-explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const profile = {
methods: []
}

type ProvidersSection = `Injected` | 'Remix VMs' | 'Externals'
type ProvidersSection = `Injected` | 'Remix VMs' | 'Externals' | 'Remix forked VMs'

export class EnvironmentExplorer extends ViewPlugin {
providers: { [key in ProvidersSection]: Provider[] }
Expand All @@ -39,6 +39,7 @@ export class EnvironmentExplorer extends ViewPlugin {
this.providers = {
'Injected': [],
'Remix VMs': [],
'Remix forked VMs': [],
'Externals': []
}
}
Expand All @@ -52,6 +53,8 @@ export class EnvironmentExplorer extends ViewPlugin {
addProvider (provider: Provider) {
if (provider.isInjected) {
this.providers['Injected'].push(provider)
} else if (provider.isForkedVM) {
this.providers['Remix forked VMs'].push(provider)
} else if (provider.isVM) {
this.providers['Remix VMs'].push(provider)
} else {
Expand Down Expand Up @@ -81,7 +84,8 @@ export class EnvironmentExplorer extends ViewPlugin {
this.providers = {
'Injected': [],
'Remix VMs': [],
'Externals': []
'Externals': [],
'Remix forked VMs': []
}
for (const [key, provider] of Object.entries(this.providersFlat)) {
this.addProvider(provider)
Expand Down Expand Up @@ -167,6 +171,40 @@ export class EnvironmentExplorer extends ViewPlugin {
<div>{provider.description}</div>
</RemixUIGridCell>
})}</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
plugin={this}
title='Deploy to an external Provider.'
Expand Down
9 changes: 5 additions & 4 deletions apps/remix-ide/src/app/udapp/run-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class RunTab extends ViewPlugin {
'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', {
position,
options: {},
Expand All @@ -176,6 +176,7 @@ export class RunTab extends ViewPlugin {
logos: logos[name],
fork,
isInjected,
isForkedVM: forkedVM,
isVM,
title,
init: async function () {
Expand Down Expand Up @@ -237,9 +238,9 @@ export class RunTab extends ViewPlugin {
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(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(3, 'vm-sepolia-fork', 'Remix VM - Sepolia fork', false, true, 'cancun', 'settingsVMSepoliaMode', titleVM)
await addProvider(4, 'vm-custom-fork', 'Remix VM - Custom fork', false, true, '', 'settingsVMCustomMode', 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, true)
await addProvider(4, 'vm-custom-fork', 'Remix VM - Custom fork', false, true, '', 'settingsVMCustomMode', titleVM, true)

// wallet connect
await addProvider(6, 'walletconnect', 'WalletConnect', false, false)
Expand Down
1 change: 1 addition & 0 deletions apps/remix-ide/src/blockchain/blockchain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type Provider = {
description?: string
isInjected: boolean
isVM: boolean
isForkedVM: boolean
title: string
init: () => Promise<void>
provider:{
Expand Down

0 comments on commit 64bec7b

Please sign in to comment.