Merge pull request #1910 from ethereum/fix_hardhat_provider

Fix hardhat provider
pull/1915/head
David Disu 3 years ago committed by GitHub
commit fb4623cb44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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(() => {
client.onload(async () => {
const customProfiles = ['menuicons', 'tabs', 'solidityUnitTesting']
const customProfiles = ['menuicons', 'tabs', 'solidityUnitTesting', 'hardhat-provider']
client.testCommand = async (data: any) => {
console.log(data)

@ -10,7 +10,7 @@ declare global {
const localPluginData: Profile & LocationProfile & ExternalProfile = {
name: 'localPlugin',
displayName: 'Local Plugin',
canActivate: ['dGitProvider', 'flattener', 'solidityUnitTesting', 'udapp'],
canActivate: ['dGitProvider', 'flattener', 'solidityUnitTesting', 'udapp', 'hardhat-provider'],
url: 'http://localhost:2020',
location: 'sidePanel'
}
@ -324,5 +324,33 @@ module.exports = {
'Should get compilationresults #group6': async function (browser: NightwatchBrowser) {
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"
TEST_EXITCODE=0
npm run ganache-cli &
npm run serve:production &
npx nx serve remix-ide-e2e-src-local-plugin &

@ -66,7 +66,7 @@ export class HardhatProvider extends Plugin {
value = await ((): Promise<string> => {
return new Promise((resolve, reject) => {
const modalContent: AppModal = {
id: 'harrhatprovider',
id: 'hardhatprovider',
title: 'Hardhat node request',
message: this.hardhatProviderDialogBody(),
modalType: ModalTypes.prompt,
@ -110,7 +110,7 @@ export class HardhatProvider extends Plugin {
} catch (error) {
this.blocked = true
const modalContent: AlertModal = {
id: 'harrhatprovider',
id: 'hardhatprovider',
title: 'Hardhat Provider',
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>) => {
dispatch(setEnvToasterContent(envToasterContent))
dispatch(setWeb3Dialog)
dispatch(setWeb3Dialog(web3Dialog))
}
const updateAccountBalances = () => {
@ -237,7 +237,7 @@ export const setExecutionContext = (executionContext: { context: string, fork: s
}, () => { setFinalContext() }))
}, (alertMsg) => {
dispatch(displayPopUp(alertMsg))
}, setFinalContext())
}, () => { setFinalContext() })
}
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 {
type: 'SET_WEB3_DIALOG'
type: 'SET_WEB3_DIALOG',
payload: web3Dialog
}
}

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

Loading…
Cancel
Save