Merge pull request #4511 from ethereum/fix4185

fix errors while contract deployment using script
pull/5370/head
yann300 9 months ago committed by GitHub
commit 86ee496b3d
  1. 10
      apps/remix-ide/src/app/tabs/web3-provider.js
  2. 3
      apps/remix-ide/src/blockchain/providers/injected.ts
  3. 3
      apps/remix-ide/src/blockchain/providers/node.ts
  4. 3
      apps/remix-ide/src/blockchain/providers/vm.ts
  5. 7
      libs/remix-simulator/src/methods/accounts.ts

@ -1,6 +1,7 @@
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../../../package.json'
import {isBigInt} from 'web3-validator'
import { addressToString } from "@remix-ui/helper"
export const profile = {
name: 'web3Provider',
@ -54,8 +55,13 @@ export class Web3ProviderModule extends Plugin {
console.log('receipt available but contract address not present', receipt)
return
}
const contractData = await this.call('compilerArtefacts', 'getContractDataFromAddress', receipt.contractAddress)
if (contractData) this.call('udapp', 'addInstance', receipt.contractAddress, contractData.contract.abi, contractData.name)
const contractAddressStr = addressToString(receipt.contractAddress)
const contractData = await this.call('compilerArtefacts', 'getContractDataFromAddress', contractAddressStr)
if (contractData) {
this.call('udapp', 'addInstance', contractAddressStr, contractData.contract.abi, contractData.name)
const data = await this.call('compilerArtefacts', 'getCompilerAbstract', contractData.file)
await this.call('compilerArtefacts', 'addResolvedContract', contractAddressStr, data)
}
}, 50)
}
}

@ -29,7 +29,8 @@ export class InjectedProvider {
async getBalanceInEther (address) {
const balance = await this.executionContext.web3().eth.getBalance(address)
return Web3.utils.fromWei(balance.toString(10), 'ether')
const balInString = balance.toString(10)
return balInString === '0' ? balInString : Web3.utils.fromWei(balInString, 'ether')
}
getGasPrice (cb) {

@ -35,7 +35,8 @@ export class NodeProvider {
async getBalanceInEther (address) {
const balance = await this.executionContext.web3().eth.getBalance(address)
return Web3.utils.fromWei(balance.toString(10), 'ether')
const balInString = balance.toString(10)
return balInString === '0' ? balInString : Web3.utils.fromWei(balInString, 'ether')
}
getGasPrice (cb) {

@ -97,7 +97,8 @@ export class VMProvider {
async getBalanceInEther (address) {
const balance = await this.web3.eth.getBalance(address, undefined, { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX })
return fromWei(toBigInt(balance).toString(10), 'ether')
const balInString = toBigInt(balance).toString(10)
return balInString === '0' ? balInString : fromWei(balInString, 'ether')
}
getGasPrice (cb) {

@ -71,7 +71,8 @@ export class Web3Accounts {
return {
eth_accounts: this.eth_accounts.bind(this),
eth_getBalance: this.eth_getBalance.bind(this),
eth_sign: this.eth_sign.bind(this)
eth_sign: this.eth_sign.bind(this),
eth_chainId: this.eth_chainId.bind(this)
}
}
@ -103,4 +104,8 @@ export class Web3Accounts {
cb(null, data.signature)
}
eth_chainId (_payload, cb) {
return cb(null, '0x539') // 0x539 is hex of 1337
}
}

Loading…
Cancel
Save