Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
bunsenstraat committed Jan 9, 2025
1 parent 3b0d487 commit d85c7c5
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 83 deletions.
1 change: 0 additions & 1 deletion apps/remix-ide/src/app/providers/injected-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export abstract class InjectedProvider extends Plugin implements IProvider {
}

sendAsync(data: JsonDataRequest): Promise<any> {
//console.log('sendAsync', data)
return new Promise((resolve, reject) => {
this.sendAsyncInternal(data, resolve, reject)
})
Expand Down
8 changes: 2 additions & 6 deletions apps/remix-ide/src/app/tabs/web3-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ export class Web3ProviderModule extends Plugin {
Should be taken carefully and probably not be release as it is now.
*/
sendAsync(payload) {
//console.log('global web3 provider', payload)

return new Promise((resolve, reject) => {
this.askUserPermission('sendAsync', `Calling ${payload.method} with parameters ${JSON.stringify(payload.params, replacer, '\t')}`).then(
async (result) => {
if (result) {
const provider = this.blockchain.web3().currentProvider
const resultFn = async (error, message) => {
//console.log('resultFn', error, message)
if (error) {
// Handle 'The method "debug_traceTransaction" does not exist / is not available.' error
if(error.message && error.code && error.code === -32601) {
Expand All @@ -50,16 +49,14 @@ export class Web3ProviderModule extends Plugin {
}
if (payload.method === 'eth_sendTransaction') {
if (payload.params.length && !payload.params[0].to && message.result) {
//console.log('waiting for receipt', message.result)
setTimeout(async () => {
const receipt = await this.tryTillReceiptAvailable(message.result)
if (!receipt.contractAddress) {
//console.log('receipt available but contract address not present', receipt)
console.log('receipt available but contract address not present', receipt)
return
}
const contractAddressStr = addressToString(receipt.contractAddress)
const contractData = await this.call('compilerArtefacts', 'getContractDataFromAddress', contractAddressStr)
//console.log('contractData', contractData)
if (contractData) {
const data = await this.call('compilerArtefacts', 'getCompilerAbstract', contractData.file)
const contractObject = {
Expand Down Expand Up @@ -102,7 +99,6 @@ export class Web3ProviderModule extends Plugin {

async tryTillReceiptAvailable(txhash) {
try {
//console.log('tryTillReceiptAvailable', txhash)
const receipt = await this.call('blockchain', 'getTransactionReceipt', txhash)
if (receipt) return receipt
} catch (e) {
Expand Down
2 changes: 0 additions & 2 deletions apps/remix-ide/src/blockchain/execution-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,11 @@ export class ExecutionContext {
if (!cb) cb = () => { /* Do nothing. */ }
if (!confirmCb) confirmCb = () => { /* Do nothing. */ }
if (!infoCb) infoCb = () => { /* Do nothing. */ }
console.log(this.customNetWorks)
if (this.customNetWorks[context]) {
var network = this.customNetWorks[context]
await network.init()
this.currentFork = network.fork
this.executionContext = context
console.log(`context set to ${context}`)
// injected
web3.setProvider(network.provider)
await this._updateChainContext()
Expand Down
12 changes: 0 additions & 12 deletions libs/remix-api/src/lib/plugins/web3-provider.ts

This file was deleted.

2 changes: 0 additions & 2 deletions libs/remix-api/src/lib/remix-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { IMenuIconsApi } from "./plugins/menuicons-api"
import { IDgitPlugin } from "./plugins/dgitplugin-api"
import { IPopupPanelAPI } from "./plugins/popuppanel-api"
import { IDesktopClient } from "./plugins/desktop-client"
import { IWeb3Provider } from "./plugins/web3-provider"

export interface ICustomRemixApi extends IRemixApi {
popupPanel: IPopupPanelAPI
Expand All @@ -42,7 +41,6 @@ export interface ICustomRemixApi extends IRemixApi {
remixAI: IRemixAI,
remixAID: IRemixAID
desktopClient: IDesktopClient
web3Provider: IWeb3Provider
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
// eslint-disable-next-line no-use-before-define
import React, { useContext, useEffect, useState } from 'react'
import React, { useEffect, useState } from 'react'
import { environmentExplorerUIGridSections, environmentExplorerUIProps } from '../types'
import { RemixUIGridCell, RemixUIGridSection, RemixUIGridView } from '@remix-ui/remix-ui-grid-view'
import { CustomTooltip } from '@remix-ui/helper'
import { AppContext } from '@remix-ui/app'
import { desktopConnextionType } from '@remix-api'

const defaultSections: environmentExplorerUIGridSections = {
Injected: {
title: 'Deploy using a Browser Extension.',
keywords: ['Injected'],
providers: [],
filterFn: (provider) => provider.isInjected,
filterFn: (provider) => provider.isInjected
},
'Remix VMs': {
title: 'Deploy to an In-browser Virtual Machine.',
keywords: ['Remix VMs'],
providers: [],
filterFn: (provider) => provider.isVM && !provider.isForkedVM,
filterFn: (provider) => provider.isVM && !provider.isForkedVM
},
'Forked States': {
title: 'Deploy to an In-browser Forked State.',
Expand All @@ -28,80 +26,87 @@ const defaultSections: environmentExplorerUIGridSections = {
const { latestBlock, timestamp } = JSON.parse(provider.description)
return (
<>
<div>
<b>Latest Block: </b>
{parseInt(latestBlock)}
</div>
<CustomTooltip placement="auto" tooltipId="overlay-tooltip-forkedAt" tooltipText={`Forked at: ${new Date(timestamp).toLocaleString()}`}>
<div>
<b>Forked at: </b>
{new Date(timestamp).toDateString()}
</div>
<div><b>Latest Block: </b>{parseInt(latestBlock)}</div>
<CustomTooltip
placement="auto"
tooltipId="overlay-tooltip-forkedAt"
tooltipText={`Forked at: ${(new Date(timestamp)).toLocaleString()}`}
>
<div><b>Forked at: </b>{(new Date(timestamp)).toDateString()}</div>
</CustomTooltip>
</>
)
},
</>)
}
},
'Remix forked VMs': {
title: 'Deploy to a Remix forked Virtual Machine.',
keywords: ['Remix forked VMs'],
providers: [],
filterFn: (provider) => provider.isForkedVM,
filterFn: (provider) => provider.isForkedVM
},
Externals: {
'Externals': {
title: 'Deploy to an external Provider.',
keywords: ['Externals'],
providers: [],
filterFn: (provider) => !provider.isInjected && !provider.isVM && !provider.isForkedState && !provider.isForkedVM,
filterFn: (provider) => (!provider.isInjected && !provider.isVM && !provider.isForkedState && !provider.isForkedVM)
},
}
export const EnvironmentExplorerUI = (props: environmentExplorerUIProps) => {

const [sections, setSections] = useState(defaultSections)
const { state, pinStateCallback, profile } = props
const context = useContext(AppContext)

useEffect(() => {
console.log('context.appState.connectedToDesktop', context.appState.connectedToDesktop)

setSections((prevSections) => {
const newSections = { ...prevSections }
Object.keys(newSections).forEach((section) => {
newSections[section].providers = Object.values(state.providersFlat).filter(newSections[section].filterFn)
newSections[section].id = section
newSections[section].hide = (context.appState.connectedToDesktop && context.appState.connectedToDesktop !== desktopConnextionType.disabled && section !== 'Injected')
})
return newSections

setSections((prevSections) => {
const newSections = { ...prevSections }
Object.keys(newSections).forEach((section) => {
newSections[section].providers = Object.values(state.providersFlat).filter(newSections[section].filterFn)
newSections[section].id = section
})

}, [state, context])
return newSections
})
}, [state])

return (
<>
<RemixUIGridView plugin={null} styleList={''} logo={profile.icon} enableFilter={true} showUntagged={true} showPin={true} title={profile.description} description="Select the providers and chains to include them in the ENVIRONMENT select box of the Deploy & Run Transactions plugin.">
{Object.values(sections).map(
(section, key) =>
section.providers.length > 0 && !section.hide && (
<RemixUIGridSection plugin={this} title={section.title} hScrollable={false} key={section.title}>
{section.providers.map((provider) => (
<RemixUIGridCell
plugin={this}
title={provider.displayName}
logos={provider.logos}
classList="EECellStyle"
searchKeywords={['Injected', provider.name, provider.displayName, provider.title, provider.description]}
pinned={state.pinnedProviders.includes(provider.name)}
key={provider.name}
id={provider.name}
pinStateCallback={async (pinned: boolean) => {
await pinStateCallback(provider, pinned)
}}
>
<div data-id={`${provider.name}desc`}>{(section.descriptionFn && section.descriptionFn(provider)) || provider.description}</div>
</RemixUIGridCell>
))}
</RemixUIGridSection>
)
)}
<RemixUIGridView
plugin={null}
styleList={""}
logo={profile.icon}
enableFilter={true}
showUntagged={true}
showPin={true}
title={profile.description}
description="Select the providers and chains to include them in the ENVIRONMENT select box of the Deploy & Run Transactions plugin."
>
{Object.values(sections).map((section) => (
section.providers.length > 0 && (
<RemixUIGridSection
plugin={this}
title={section.title}
hScrollable={false}
key={section.title}
>
{section.providers.map(provider => (
<RemixUIGridCell
plugin={this}
title={provider.displayName}
logos={provider.logos}
classList='EECellStyle'
searchKeywords={['Injected', provider.name, provider.displayName, provider.title, provider.description]}
pinned={state.pinnedProviders.includes(provider.name)}
key={provider.name}
id={provider.name}
pinStateCallback={async (pinned: boolean) => {
await pinStateCallback(provider, pinned)
}}
>
<div data-id={`${provider.name}desc`}>{(section.descriptionFn && section.descriptionFn(provider)) || provider.description}</div>
</RemixUIGridCell>
))}
</RemixUIGridSection>
)
))}
</RemixUIGridView>
</>
)
Expand Down
3 changes: 1 addition & 2 deletions libs/remix-ui/environment-explorer/src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export type environmentExplorerUIGridSection = {
providers: Provider[]
filterFn: (provider: Provider) => boolean
descriptionFn?: (provider: Provider) => string | JSX.Element | null
id?: string,
hide?: boolean
id?: string
}

export type environmentExplorerUIGridSections = {
Expand Down

0 comments on commit d85c7c5

Please sign in to comment.