cancel click handled

pull/1222/head
aniket-engg 4 years ago committed by Aniket
parent 294e130c16
commit 8f773cb5a8
  1. 12
      apps/remix-ide/src/app/tabs/hardhat-provider.js
  2. 7
      apps/remix-ide/src/blockchain/execution-context.js

@ -35,14 +35,11 @@ export default class HardhatProvider extends Plugin {
sendAsync (data) {
return new Promise((resolve, reject) => {
if (!this.provider) {
modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => {
this.provider = new Web3.providers.HttpProvider(target)
modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => {
this.provider = new Web3.providers.HttpProvider(target)
sendAsyncInternal(this.provider, data, resolve, reject)
}, () => {
console.log('cancel clicked', this.provider)
console.log('inside if--->', this.blockchain.getProvider())
console.log('inside if-2-->', this.blockchain.getCurrentProvider())
this.call('udapp', 'setEnvironmentMode', this.blockchain.getProvider())
sendAsyncInternal(this.provider, data, resolve, reject)
})
} else {
sendAsyncInternal(this.provider, data, resolve, reject)
@ -58,7 +55,8 @@ const sendAsyncInternal = (provider, data, resolve, reject) => {
resolve(message)
})
} else {
resolve({ jsonrpc: '2.0', result: [], id: data.id })
const result = data.method === 'net_listening' ? 'canceled' : []
resolve({ jsonrpc: '2.0', result: result, id: data.id })
}
}

@ -145,7 +145,6 @@ export class ExecutionContext {
if (context === 'web3') {
confirmCb(cb)
}
if (this.customNetWorks[context]) {
var network = this.customNetWorks[context]
this.setProviderFromEndpoint(network.provider, network.name, (error) => {
@ -189,14 +188,16 @@ export class ExecutionContext {
const oldProvider = web3.currentProvider
web3.setProvider(endpoint)
web3.eth.net.isListening((err, isConnected) => {
if (!err && isConnected) {
if (!err && isConnected === true) {
this.executionContext = context
this._updateBlockGasLimit()
this.event.trigger('contextChanged', [context])
this.event.trigger('web3EndpointChanged')
cb()
} else if (isConnected === 'canceled') {
web3.setProvider(oldProvider)
cb()
} else {
web3.setProvider(oldProvider)
cb('Not possible to connect to the Web3 provider. Make sure the provider is running, a connection is open (via IPC or RPC) or that the provider plugin is properly configured.')

Loading…
Cancel
Save