diff --git a/apps/remix-ide/src/app/providers/injected-provider.tsx b/apps/remix-ide/src/app/providers/injected-provider.tsx index 16c3d404e89..70634f9594c 100644 --- a/apps/remix-ide/src/app/providers/injected-provider.tsx +++ b/apps/remix-ide/src/app/providers/injected-provider.tsx @@ -76,7 +76,6 @@ export abstract class InjectedProvider extends Plugin implements IProvider { } sendAsync(data: JsonDataRequest): Promise { - //console.log('sendAsync', data) return new Promise((resolve, reject) => { this.sendAsyncInternal(data, resolve, reject) }) diff --git a/apps/remix-ide/src/app/tabs/web3-provider.js b/apps/remix-ide/src/app/tabs/web3-provider.js index c6ba9fd7685..39e5543c2e6 100644 --- a/apps/remix-ide/src/app/tabs/web3-provider.js +++ b/apps/remix-ide/src/app/tabs/web3-provider.js @@ -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) { @@ -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 = { @@ -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) { diff --git a/apps/remix-ide/src/blockchain/execution-context.js b/apps/remix-ide/src/blockchain/execution-context.js index 39216ed3728..cf82b96ad82 100644 --- a/apps/remix-ide/src/blockchain/execution-context.js +++ b/apps/remix-ide/src/blockchain/execution-context.js @@ -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() diff --git a/libs/remix-api/src/lib/plugins/web3-provider.ts b/libs/remix-api/src/lib/plugins/web3-provider.ts deleted file mode 100644 index ac92ddad944..00000000000 --- a/libs/remix-api/src/lib/plugins/web3-provider.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { StatusEvents } from '@remixproject/plugin-utils' -import { JsonDataRequest, JsonDataResult } from '../types/rpc' - -export interface IWeb3Provider { - events: { - } & StatusEvents - methods: { - init(): void - sendAsync(payload: JsonDataRequest): Promise - } - -} diff --git a/libs/remix-api/src/lib/remix-api.ts b/libs/remix-api/src/lib/remix-api.ts index ba786e23d51..4fd77629391 100644 --- a/libs/remix-api/src/lib/remix-api.ts +++ b/libs/remix-api/src/lib/remix-api.ts @@ -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 @@ -42,7 +41,6 @@ export interface ICustomRemixApi extends IRemixApi { remixAI: IRemixAI, remixAID: IRemixAID desktopClient: IDesktopClient - web3Provider: IWeb3Provider } diff --git a/libs/remix-ui/environment-explorer/src/lib/components/environment-explorer-ui.tsx b/libs/remix-ui/environment-explorer/src/lib/components/environment-explorer-ui.tsx index bdf9758b9bd..0bd67a5c188 100644 --- a/libs/remix-ui/environment-explorer/src/lib/components/environment-explorer-ui.tsx +++ b/libs/remix-ui/environment-explorer/src/lib/components/environment-explorer-ui.tsx @@ -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.', @@ -28,80 +26,87 @@ const defaultSections: environmentExplorerUIGridSections = { const { latestBlock, timestamp } = JSON.parse(provider.description) return ( <> -
- Latest Block: - {parseInt(latestBlock)} -
- -
- Forked at: - {new Date(timestamp).toDateString()} -
+
Latest Block: {parseInt(latestBlock)}
+ +
Forked at: {(new Date(timestamp)).toDateString()}
- - ) - }, + ) + } }, '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 ( <> - - {Object.values(sections).map( - (section, key) => - section.providers.length > 0 && !section.hide && ( - - {section.providers.map((provider) => ( - { - await pinStateCallback(provider, pinned) - }} - > -
{(section.descriptionFn && section.descriptionFn(provider)) || provider.description}
-
- ))} -
- ) - )} + + {Object.values(sections).map((section) => ( + section.providers.length > 0 && ( + + {section.providers.map(provider => ( + { + await pinStateCallback(provider, pinned) + }} + > +
{(section.descriptionFn && section.descriptionFn(provider)) || provider.description}
+
+ ))} +
+ ) + ))}
) diff --git a/libs/remix-ui/environment-explorer/src/lib/types/index.ts b/libs/remix-ui/environment-explorer/src/lib/types/index.ts index 51cab0ca632..706e577eddf 100644 --- a/libs/remix-ui/environment-explorer/src/lib/types/index.ts +++ b/libs/remix-ui/environment-explorer/src/lib/types/index.ts @@ -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 = {