more segregation

pull/1222/head
aniket-engg 4 years ago committed by Aniket
parent c7799a1854
commit 294e130c16
  1. 32
      apps/remix-ide/src/app/tabs/hardhat-provider.js
  2. 4
      apps/remix-ide/src/app/tabs/runTab/settings.js

@ -20,6 +20,10 @@ export default class HardhatProvider extends Plugin {
this.blockchain = blockchain this.blockchain = blockchain
} }
onDeactivation () {
this.provider = null
}
hardhatProviderDialogBody () { hardhatProviderDialogBody () {
return yo` return yo`
<div class=""> <div class="">
@ -29,22 +33,32 @@ export default class HardhatProvider extends Plugin {
} }
sendAsync (data) { sendAsync (data) {
return new Promise((resolve, reject) => {
if (!this.provider) {
modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => {
this.blockchain.setProviderFromEndpoint(target, 'Hardhat Provider', (alertMsg) => {
console.log('target-->', target)
this.provider = new Web3.providers.HttpProvider(target) this.provider = new Web3.providers.HttpProvider(target)
return new Promise((resolve, reject) => { sendAsyncInternal(this.provider, data, resolve, reject)
if (this.provider) { }, () => {
this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](data, (error, message) => { console.log('cancel clicked', this.provider)
if (error) return reject(error) console.log('inside if--->', this.blockchain.getProvider())
resolve(message) console.log('inside if-2-->', this.blockchain.getCurrentProvider())
this.call('udapp', 'setEnvironmentMode', this.blockchain.getProvider())
}) })
} else { } else {
resolve({ jsonrpc: '2.0', result: [], id: data.id }) sendAsyncInternal(this.provider, data, resolve, reject)
} }
}) })
}
}
const sendAsyncInternal = (provider, data, resolve, reject) => {
if (provider) {
provider[provider.sendAsync ? 'sendAsync' : 'send'](data, (error, message) => {
if (error) return reject(error)
resolve(message)
}) })
}) } else {
resolve({ jsonrpc: '2.0', result: [], id: data.id })
} }
} }

@ -244,9 +244,6 @@ class SettingsUI {
} }
setExecutionContext (context) { setExecutionContext (context) {
if (context === 'Hardhat Provider') {
this.blockchain.changeExecutionContext(context)
} else {
this.blockchain.changeExecutionContext(context, () => { this.blockchain.changeExecutionContext(context, () => {
modalDialogCustom.prompt('External node request', this.web3ProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { modalDialogCustom.prompt('External node request', this.web3ProviderDialogBody(), 'http://127.0.0.1:8545', (target) => {
this.blockchain.setProviderFromEndpoint(target, context, (alertMsg) => { this.blockchain.setProviderFromEndpoint(target, context, (alertMsg) => {
@ -258,7 +255,6 @@ class SettingsUI {
addTooltip(alertMsg) addTooltip(alertMsg)
}, this.setFinalContext.bind(this)) }, this.setFinalContext.bind(this))
} }
}
web3ProviderDialogBody () { web3ProviderDialogBody () {
const thePath = '<path/to/local/folder/for/test/chain>' const thePath = '<path/to/local/folder/for/test/chain>'

Loading…
Cancel
Save