Merge pull request #1910 from ethereum/fix_hardhat_provider

Fix hardhat provider
pull/5370/head
David Disu 3 years ago committed by GitHub
commit ac24ee6557
  1. 2
      apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx
  2. 30
      apps/remix-ide-e2e/src/tests/plugin_api.ts
  3. 1
      apps/remix-ide/ci/browser_tests_plugin_api.sh
  4. 4
      apps/remix-ide/src/app/tabs/hardhat-provider.tsx
  5. 4
      libs/remix-ui/run-tab/src/lib/actions/index.ts
  6. 5
      libs/remix-ui/run-tab/src/lib/actions/payload.ts
  7. 24
      libs/remix-ui/run-tab/src/lib/reducers/runTab.ts

@ -33,7 +33,7 @@ function App () {
useEffect(() => { useEffect(() => {
client.onload(async () => { client.onload(async () => {
const customProfiles = ['menuicons', 'tabs', 'solidityUnitTesting'] const customProfiles = ['menuicons', 'tabs', 'solidityUnitTesting', 'hardhat-provider']
client.testCommand = async (data: any) => { client.testCommand = async (data: any) => {
console.log(data) console.log(data)

@ -10,7 +10,7 @@ declare global {
const localPluginData: Profile & LocationProfile & ExternalProfile = { const localPluginData: Profile & LocationProfile & ExternalProfile = {
name: 'localPlugin', name: 'localPlugin',
displayName: 'Local Plugin', displayName: 'Local Plugin',
canActivate: ['dGitProvider', 'flattener', 'solidityUnitTesting', 'udapp'], canActivate: ['dGitProvider', 'flattener', 'solidityUnitTesting', 'udapp', 'hardhat-provider'],
url: 'http://localhost:2020', url: 'http://localhost:2020',
location: 'sidePanel' location: 'sidePanel'
} }
@ -324,5 +324,33 @@ module.exports = {
'Should get compilationresults #group6': async function (browser: NightwatchBrowser) { 'Should get compilationresults #group6': async function (browser: NightwatchBrowser) {
await clickAndCheckLog(browser, 'solidity:getCompilationResult', 'contracts/1_Storage.sol', null, null) await clickAndCheckLog(browser, 'solidity:getCompilationResult', 'contracts/1_Storage.sol', null, null)
},
// PROVIDER
'Should switch to hardhat provider (provider plugin) #group8': function (browser: NightwatchBrowser) {
browser
.frameParent()
.useCss()
.clickLaunchIcon('pluginManager')
.scrollAndClick('[data-id="pluginManagerComponentActivateButtonhardhat-provider"]')
.clickLaunchIcon('udapp')
.click('*[data-id="Hardhat Provider"]')
.modalFooterOKClick('hardhatprovider')
.waitForElementContainsText('*[data-id="settingsNetworkEnv"]', 'Custom') // e.g Custom (1337) network
.clickLaunchIcon('localPlugin')
.useXpath()
// @ts-ignore
.frame(0)
.perform(async () => {
const request = {
id: 9999,
jsonrpc: '2.0',
method: 'net_listening',
params: []
}
const result = '{"jsonrpc":"2.0","result":true,"id":9999}'
await clickAndCheckLog(browser, 'hardhat-provider:sendAsync', result, null, request)
})
} }
} }

@ -6,6 +6,7 @@ BUILD_ID=${CIRCLE_BUILD_NUM:-${TRAVIS_JOB_NUMBER}}
echo "$BUILD_ID" echo "$BUILD_ID"
TEST_EXITCODE=0 TEST_EXITCODE=0
npm run ganache-cli &
npm run serve:production & npm run serve:production &
npx nx serve remix-ide-e2e-src-local-plugin & npx nx serve remix-ide-e2e-src-local-plugin &

@ -66,7 +66,7 @@ export class HardhatProvider extends Plugin {
value = await ((): Promise<string> => { value = await ((): Promise<string> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const modalContent: AppModal = { const modalContent: AppModal = {
id: 'harrhatprovider', id: 'hardhatprovider',
title: 'Hardhat node request', title: 'Hardhat node request',
message: this.hardhatProviderDialogBody(), message: this.hardhatProviderDialogBody(),
modalType: ModalTypes.prompt, modalType: ModalTypes.prompt,
@ -110,7 +110,7 @@ export class HardhatProvider extends Plugin {
} catch (error) { } catch (error) {
this.blocked = true this.blocked = true
const modalContent: AlertModal = { const modalContent: AlertModal = {
id: 'harrhatprovider', id: 'hardhatprovider',
title: 'Hardhat Provider', title: 'Hardhat Provider',
message: `Error while connecting to the hardhat provider: ${error.message}`, message: `Error while connecting to the hardhat provider: ${error.message}`,
} }

@ -110,7 +110,7 @@ const setupEvents = () => {
export const initWebDialogs = (envToasterContent: (env: { context: string, fork: string }, from: string) => void, web3Dialog: () => void) => async (dispatch: React.Dispatch<any>) => { export const initWebDialogs = (envToasterContent: (env: { context: string, fork: string }, from: string) => void, web3Dialog: () => void) => async (dispatch: React.Dispatch<any>) => {
dispatch(setEnvToasterContent(envToasterContent)) dispatch(setEnvToasterContent(envToasterContent))
dispatch(setWeb3Dialog) dispatch(setWeb3Dialog(web3Dialog))
} }
const updateAccountBalances = () => { const updateAccountBalances = () => {
@ -237,7 +237,7 @@ export const setExecutionContext = (executionContext: { context: string, fork: s
}, () => { setFinalContext() })) }, () => { setFinalContext() }))
}, (alertMsg) => { }, (alertMsg) => {
dispatch(displayPopUp(alertMsg)) dispatch(displayPopUp(alertMsg))
}, setFinalContext()) }, () => { setFinalContext() })
} }
export const setWeb3Endpoint = (endpoint: string) => { export const setWeb3Endpoint = (endpoint: string) => {

@ -278,9 +278,10 @@ export const setEnvToasterContent = (content: (env: { context: string, fork: str
} }
} }
export const setWeb3Dialog = () => { export const setWeb3Dialog = (web3Dialog: () => void) => {
return { return {
type: 'SET_WEB3_DIALOG' type: 'SET_WEB3_DIALOG',
payload: web3Dialog
} }
} }

@ -171,6 +171,11 @@ export const runTabInitialState: RunTabState = {
web3Dialog: null web3Dialog: null
} }
type AddProvider = {
name: string,
provider: any
}
export const runTabReducer = (state: RunTabState = runTabInitialState, action: Action) => { export const runTabReducer = (state: RunTabState = runTabInitialState, action: Action) => {
switch (action.type) { switch (action.type) {
case 'FETCH_ACCOUNTS_LIST_REQUEST': { case 'FETCH_ACCOUNTS_LIST_REQUEST': {
@ -328,25 +333,32 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A
} }
case 'ADD_PROVIDER': { case 'ADD_PROVIDER': {
const payload: string = action.payload const payload: AddProvider = action.payload
const id = action.payload.name
state.providers.providerList.push({
content: payload.name,
dataId: id,
id,
title: payload.name,
value: id
})
return { return {
...state, ...state,
providers: { providers: {
...state.providers, ...state.providers,
providerList: { ...state.providers.providerList, payload } providerList: state.providers.providerList
} }
} }
} }
case 'REMOVE_PROVIDER': { case 'REMOVE_PROVIDER': {
const payload: string = action.payload const id: string = action.payload
const providers = state.providers.providerList.filter((el) => el.id !== id)
return { return {
...state, ...state,
providers: { providers: {
...state.providers, ...state.providers,
providerList: delete state.providers.providerList[payload] ? state.providers.providerList : state.providers.providerList providerList: providers
} }
} }
} }

Loading…
Cancel
Save