diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index 4bce9e4d2f..e42812c7a7 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -1,5 +1,6 @@ import * as packageJson from '../../../../../package.json' import { Plugin } from '@remixproject/engine' +const yo = require('yo-yo') const modalDialogCustom = require('../ui/modal-dialog-custom') import Web3 from 'web3' @@ -15,26 +16,12 @@ const profile = { export default class HardhatProvider extends Plugin { constructor () { super(profile) - this.provider = new Web3.providers.HttpProvider('http://127.0.0.1:8545') + this.provider = null } - web3ProviderDialogBody () { - const thePath = '' - + hardhatProviderDialogBody () { return yo`
- 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 -
-
Hardhat Provider Endpoint
` @@ -42,17 +29,22 @@ export default class HardhatProvider extends Plugin { sendAsync (data) { console.log('Inside sendAsync - modalDialogCustom', modalDialogCustom) - modalDialogCustom.prompt('Hardhat node request', this.web3ProviderDialogBody(), 'http://127.0.0.1:8545') - // return new Promise((resolve, reject) => { - // if (this.provider) { - // this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](data, (error, message) => { - // if (error) return reject(error) - // resolve(message) - // }) - // } else { - // resolve({"jsonrpc": "2.0", "result": [], "id": data.id}) - // } - // }) + modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { + console.log('target--->', target) + this.provider = new Web3.providers.HttpProvider(target) + return new Promise((resolve, reject) => { + console.log('inside sendAsync promise') + if (this.provider) { + this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](data, (error, message) => { + if (error) return reject(error) + resolve(message) + }) + } else { + resolve({"jsonrpc": "2.0", "result": [], "id": data.id}) + } + }) + }) + } }