+ Note: To use Geth & https://remix.ethereum.org, configure it to allow requests from Remix:(see
Geth Docs on rpc server )
+
geth --http --http.corsdomain https://remix.ethereum.org
+
+ To run Remix & a local Geth test node, use this command: (see
Geth Docs on Dev mode )
+
geth --http --http.corsdomain="${window.origin}" --http.api web3,eth,debug,personal,net --vmdebug --datadir ${thePath} --dev console
+
+
+
WARNING: It is not safe to use the --http.corsdomain flag with a wildcard:
--http.corsdomain *
+
+
For more info:
Remix Docs on Web3 Provider
+
+
+ Web3 Provider Endpoint
+
+
-
+
diff --git a/libs/remix-ui/run-tab/src/lib/run-tab.tsx b/libs/remix-ui/run-tab/src/lib/run-tab.tsx
index d07cbbb62b..edf41f8a68 100644
--- a/libs/remix-ui/run-tab/src/lib/run-tab.tsx
+++ b/libs/remix-ui/run-tab/src/lib/run-tab.tsx
@@ -1,19 +1,19 @@
// eslint-disable-next-line no-use-before-define
-import React, { Fragment, useEffect, useState } from 'react'
+import React, { Fragment, useEffect, useReducer, useState } from 'react'
import { ModalDialog } from '@remix-ui/modal-dialog'
// eslint-disable-next-line no-unused-vars
import { Toaster } from '@remix-ui/toaster'
-import { useRunTabPlugin } from './actions/custom'
import { ContractDropdownUI } from './components/contractDropdownUI'
import { InstanceContainerUI } from './components/instanceContainerUI'
import { RecorderUI } from './components/recorderCardUI'
import { SettingsUI } from './components/settingsUI'
import { Modal, RunTabProps } from './types'
import { runTabInitialState, runTabReducer } from './reducers/runTab'
+import { initRunTab, setAccount, setUnit, setGasFee, setExecutionContext, setWeb3Endpoint } from './actions'
import './css/run-tab.css'
export function RunTabUI (props: RunTabProps) {
- const { runTab, setupEvents, setAccount, setUnit, setGasFee, setExecEnv, setExecutionContext, setProviderFromEndpoint, setFinalContext, setWeb3Endpoint } = useRunTabPlugin(props.plugin, executionContextModal)
+ const { plugin } = props
const [focusModal, setFocusModal] = useState
({
hide: true,
title: '',
@@ -24,11 +24,16 @@ export function RunTabUI (props: RunTabProps) {
cancelFn: () => {}
})
const [modals, setModals] = useState([])
+ const [runTab, dispatch] = useReducer(runTabReducer, runTabInitialState)
const REACT_API = { runTab }
useEffect(() => {
- setupEvents()
- }, [])
+ initRunTab(plugin)(dispatch)
+ }, [plugin])
+
+ useEffect(() => {
+ plugin.onReady(runTab)
+ }, [REACT_API])
useEffect(() => {
if (modals.length > 0) {
@@ -57,10 +62,6 @@ export function RunTabUI (props: RunTabProps) {
}
}, [runTab.notification])
- useEffect(() => {
- props.plugin.onReady(runTab)
- }, [REACT_API])
-
// eslint-disable-next-line no-undef
const modal = (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => {
setModals(modals => {
@@ -75,53 +76,25 @@ export function RunTabUI (props: RunTabProps) {
})
}
- const handleInputEndpoint = (e: any) => {
- setWeb3Endpoint(e.target.value)
- }
-
- function executionContextModal (executionContext: { context: string, fork: string }) {
- modal('External node request', web3ProviderDialogBody(), 'OK', () => { setProviderFromEndpoint(executionContext) }, 'Cancel', () => { setFinalContext() })
- }
-
- const web3ProviderDialogBody = () => {
- const thePath = ''
-
- return (
- <>
-
- Note: To use Geth & https://remix.ethereum.org, configure it to allow requests from Remix:(see
Geth Docs on rpc server )
-
geth --http --http.corsdomain https://remix.ethereum.org
-
- To run Remix & a local Geth test node, use this command: (see
Geth Docs on Dev mode )
-
geth --http --http.corsdomain="${window.origin}" --http.api web3,eth,debug,personal,net --vmdebug --datadir ${thePath} --dev console
-
-
-
WARNING: It is not safe to use the --http.corsdomain flag with a wildcard:
--http.corsdomain *
-
-
For more info:
Remix Docs on Web3 Provider
-
-
- Web3 Provider Endpoint
-
-
- >
- )
- }
-
return (
-
+
diff --git a/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts b/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts
index 39a9292a0f..bd19058d4a 100644
--- a/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts
+++ b/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts
@@ -19,7 +19,7 @@ export class Blockchain extends Plugin
{
providers: {};
getCurrentProvider(): any;
/** Return the list of accounts */
- getAccounts(cb: any): any;
+ getAccounts(cb?: any): any;
deployContractAndLibraries(selectedContract: any, args: any, contractMetadata: any, compilerContracts: any, callbacks: any, confirmationCb: any): void;
deployContractWithLibrary(selectedContract: any, args: any, contractMetadata: any, compilerContracts: any, callbacks: any, confirmationCb: any): void;
createContract(selectedContract: any, data: any, continueCb: any, promptCb: any, confirmationCb: any, finalCb: any): void;
diff --git a/libs/remix-ui/run-tab/src/lib/types/index.ts b/libs/remix-ui/run-tab/src/lib/types/index.ts
index d2b19b5577..4aa70d5304 100644
--- a/libs/remix-ui/run-tab/src/lib/types/index.ts
+++ b/libs/remix-ui/run-tab/src/lib/types/index.ts
@@ -1,13 +1,7 @@
-import { RunTabState } from '../reducers/runTab'
-import { Blockchain } from './blockchain'
-
-export interface Udapp {
- onReady: (api: RunTabState) => void,
- REACT_API: RunTabState,
- blockchain: Blockchain
-}
+/* eslint-disable no-undef */
+import { RunTab } from './run-tab'
export interface RunTabProps {
- plugin: Udapp
+ plugin: RunTab
}
export interface SettingsProps {
@@ -25,7 +19,7 @@ export interface SettingsProps {
sendUnit: string,
gasLimit: number,
setGasFee: (value: number) => void,
- setExecEnv: (env: string) => void,
+ setWeb3Endpoint: (endpoint: string) => void,
personalMode: boolean,
networkName: string,
providers: {
@@ -41,11 +35,12 @@ export interface SettingsProps {
isSuccessful: boolean,
error: string
},
- setExecutionContext: (executionContext: { context: string, fork: string }) => void
+ setExecutionContext: (executionContext: { context: string, fork: string }, displayContent: JSX.Element) => void,
+ externalEndpoint: string
}
export interface EnvironmentProps {
- setExecEnv: (env: string) => void,
+ setWeb3Endpoint: (endpoint: string) => void,
selectedEnv: string,
providers: {
providerList: {
@@ -60,7 +55,8 @@ export interface EnvironmentProps {
isSuccessful: boolean,
error: string
},
- setExecutionContext: (executionContext: { context: string, fork: string }) => void
+ setExecutionContext: (executionContext: { context: string, fork: string }, displayContent: JSX.Element) => void,
+ externalEndpoint: string
}
export interface NetworkProps {
diff --git a/libs/remix-ui/run-tab/src/lib/types/run-tab.d.ts b/libs/remix-ui/run-tab/src/lib/types/run-tab.d.ts
new file mode 100644
index 0000000000..a1c50e6495
--- /dev/null
+++ b/libs/remix-ui/run-tab/src/lib/types/run-tab.d.ts
@@ -0,0 +1,41 @@
+export class RunTab extends ViewPlugin {
+ constructor(blockchain: any, config: any, fileManager: any, editor: any, filePanel: any, compilersArtefacts: any, networkModule: any, mainView: any, fileProvider: any);
+ event: any;
+ config: any;
+ blockchain: Blockchain;
+ fileManager: any;
+ editor: any;
+ logCallback: (msg: any) => void;
+ filePanel: any;
+ compilersArtefacts: any;
+ networkModule: any;
+ fileProvider: any;
+ REACT_API: RunTabState;
+ el: HTMLDivElement;
+ setupEvents(): void;
+ getSettings(): any;
+ setEnvironmentMode(env: any): Promise;
+ createVMAccount(newAccount: any): any;
+ sendTransaction(tx: any): any;
+ getAccounts(cb: any): any;
+ pendingTransactionsCount(): any;
+ renderInstanceContainer(): void;
+ instanceContainer: any;
+ noInstancesText: any;
+ renderSettings(): void;
+ settingsUI: any;
+ renderDropdown(udappUI: any, fileManager: any, compilersArtefacts: any, config: any, editor: any, logCallback: any): void;
+ contractDropdownUI: any;
+ renderRecorder(udappUI: any, fileManager: any, config: any, logCallback: any): void;
+ recorderCount: any;
+ recorderInterface: any;
+ renderRecorderCard(): void;
+ recorderCard: any;
+ udappUI: any;
+ renderComponent(): void;
+ onReady(api: any): void;
+}
+import { ViewPlugin } from "@remixproject/engine-web/lib/view";
+import { Blockchain } from "./blockchain";
+import { RunTabState } from "../reducers/runTab";
+