error msg if no from defined

pull/2585/head
yann300 3 years ago
parent 9df06eb9d7
commit e977d5bf6b
  1. 16
      apps/remix-ide/src/blockchain/blockchain.js
  2. 2
      libs/remix-lib/src/execution/txRunnerWeb3.ts

@ -530,6 +530,7 @@ export class Blockchain extends Plugin {
if (this.transactionContextAPI.getAddress) { if (this.transactionContextAPI.getAddress) {
return this.transactionContextAPI.getAddress(function (err, address) { return this.transactionContextAPI.getAddress(function (err, address) {
if (err) return reject(err) if (err) return reject(err)
if (!address) return reject('"from" is not defined. Please make sure an account is selected. If you are using a public node, it is likely that no account will be provided. In that case, add the public node to your injected provider (type Metamask) and use injected provider in Remix.')
return resolve(address) return resolve(address)
}) })
} }
@ -548,9 +549,18 @@ export class Blockchain extends Plugin {
const runTransaction = async () => { const runTransaction = async () => {
// eslint-disable-next-line no-async-promise-executor // eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const fromAddress = await getAccount() let fromAddress
const value = await queryValue() let value
const gasLimit = await getGasLimit() let gasLimit
try {
fromAddress = await getAccount()
value = await queryValue()
gasLimit = await getGasLimit()
} catch (e) {
reject(e)
return
}
const tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall, from: fromAddress, value: value, gasLimit: gasLimit, timestamp: args.data.timestamp } const tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall, from: fromAddress, value: value, gasLimit: gasLimit, timestamp: args.data.timestamp }
const payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode, contractName: args.data.contractName, contractABI: args.data.contractABI, linkReferences: args.data.linkReferences } const payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode, contractName: args.data.contractName, contractABI: args.data.contractABI, linkReferences: args.data.linkReferences }

@ -85,7 +85,7 @@ export class TxRunnerWeb3 {
runInNode (from, to, data, value, gasLimit, useCall, timestamp, confirmCb, gasEstimationForceSend, promptCb, callback) { runInNode (from, to, data, value, gasLimit, useCall, timestamp, confirmCb, gasEstimationForceSend, promptCb, callback) {
const tx = { from: from, to: to, data: data, value: value } const tx = { from: from, to: to, data: data, value: value }
if (!from) return callback('the value of "from" is not defined. Please make sure an account is selected.')
if (useCall) { if (useCall) {
tx['gas'] = gasLimit tx['gas'] = gasLimit
if (this._api && this._api.isVM()) tx['timestamp'] = timestamp if (this._api && this._api.isVM()) tx['timestamp'] = timestamp

Loading…
Cancel
Save