more segregation

pull/1222/head
aniket-engg 4 years ago committed by Aniket
parent c7799a1854
commit 294e130c16
  1. 44
      apps/remix-ide/src/app/tabs/hardhat-provider.js
  2. 22
      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) {
modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { return new Promise((resolve, reject) => {
this.blockchain.setProviderFromEndpoint(target, 'Hardhat Provider', (alertMsg) => { if (!this.provider) {
console.log('target-->', target) modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (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 { })
resolve({ jsonrpc: '2.0', result: [], id: data.id }) } else {
} 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,20 +244,16 @@ class SettingsUI {
} }
setExecutionContext (context) { setExecutionContext (context) {
if (context === 'Hardhat Provider') { this.blockchain.changeExecutionContext(context, () => {
this.blockchain.changeExecutionContext(context) modalDialogCustom.prompt('External node request', this.web3ProviderDialogBody(), 'http://127.0.0.1:8545', (target) => {
} else { this.blockchain.setProviderFromEndpoint(target, context, (alertMsg) => {
this.blockchain.changeExecutionContext(context, () => { if (alertMsg) addTooltip(alertMsg)
modalDialogCustom.prompt('External node request', this.web3ProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { this.setFinalContext()
this.blockchain.setProviderFromEndpoint(target, context, (alertMsg) => { })
if (alertMsg) addTooltip(alertMsg)
this.setFinalContext()
})
}, this.setFinalContext.bind(this))
}, (alertMsg) => {
addTooltip(alertMsg)
}, this.setFinalContext.bind(this)) }, this.setFinalContext.bind(this))
} }, (alertMsg) => {
addTooltip(alertMsg)
}, this.setFinalContext.bind(this))
} }
web3ProviderDialogBody () { web3ProviderDialogBody () {

Loading…
Cancel
Save