fix request

pull/5343/head
yann300 4 weeks ago committed by Aniket
parent 5c3c3950d5
commit fe6bc2fd27
  1. 2
      apps/remix-dapp/src/utils/txRunner.ts
  2. 22
      apps/remix-ide/src/app/udapp/run-tab.tsx
  3. 6
      libs/remix-lib/src/execution/txRunnerWeb3.ts
  4. 11
      libs/remix-ui/run-tab/src/lib/actions/deploy.ts

@ -267,7 +267,7 @@ export class TxRunner {
};
} catch (error: any) {
console.log(
`Send transaction failed: ${error.message} . if you use an injected provider, please check it is properly unlocked. `
`Send transaction failed: ${error.message || error.error} . if you use an injected provider, please check it is properly unlocked. `
);
return { error };
}

@ -198,16 +198,18 @@ export class RunTab extends ViewPlugin {
sendAsync (payload) {
return udapp.call(name, 'sendAsync', payload)
},
async request (payload) {
try {
const requestResult = await udapp.call(name, 'sendAsync', payload)
if (requestResult.error) {
throw new Error(requestResult.error.message)
}
return requestResult.result
} catch (err) {
throw new Error(err.message)
}
request (payload) {
return new Promise<any>((resolve, reject) => {
udapp.call(name, 'sendAsync', payload).then((response) => {
if (response.error) {
reject(response.error.message)
} else {
resolve(response)
}
}).catch((err) => {
reject(err)
})
})
}
}
})

@ -66,7 +66,7 @@ export class TxRunnerWeb3 {
const res = await (this.getWeb3() as any).eth.personal.sendTransaction({ ...tx, value }, { checkRevertBeforeSending: false, ignoreGasPricing: true })
cb(null, res.transactionHash)
} catch (e) {
console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
console.log(`Send transaction failed: ${e.message || e.error} . if you use an injected provider, please check it is properly unlocked. `)
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// So we don't consider this to be an error.
if (e.receipt) cb(null, e.receipt.transactionHash)
@ -82,6 +82,10 @@ export class TxRunnerWeb3 {
const res = await this.getWeb3().eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true })
cb(null, res.transactionHash)
} catch (e) {
if (!e.message) e.message = ''
if (e.error) {
e.message = e.message + ' ' + e.error
}
console.log(`Send transaction failed: ${e.message} . if you use an injected provider, please check it is properly unlocked. `)
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// So we don't consider this to be an error.

@ -119,10 +119,19 @@ const getConfirmationCb = (plugin: RunTab, dispatch: React.Dispatch<any>, confir
export const continueHandler = (dispatch: React.Dispatch<any>, gasEstimationPrompt: (msg: string) => JSX.Element, error, continueTxExecution, cancelCb) => {
if (error) {
let msg = typeof error !== 'string' ? error.message : error
let msg = ''
if (typeof error === 'string') {
msg = error
}
if (error && error.innerError) {
msg += '\n' + error.innerError
}
if (error && error.message) {
msg += '\n' + error.message
}
if (error && error.error) {
msg += '\n' + error.error
}
if (msg.includes('invalid opcode')) msg += '\nThe EVM version used by the selected environment is not compatible with the compiler EVM version.'

Loading…
Cancel
Save