Merge pull request #4511 from ethereum/fix4185

fix errors while contract deployment using script
pull/4530/head
yann300 1 year ago committed by GitHub
commit 04318fcda1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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 { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../../../package.json' import * as packageJson from '../../../../../package.json'
import {isBigInt} from 'web3-validator' import {isBigInt} from 'web3-validator'
import { addressToString } from "@remix-ui/helper"
export const profile = { export const profile = {
name: 'web3Provider', name: 'web3Provider',
@ -54,8 +55,13 @@ export class Web3ProviderModule extends Plugin {
console.log('receipt available but contract address not present', receipt) console.log('receipt available but contract address not present', receipt)
return return
} }
const contractData = await this.call('compilerArtefacts', 'getContractDataFromAddress', receipt.contractAddress) const contractAddressStr = addressToString(receipt.contractAddress)
if (contractData) this.call('udapp', 'addInstance', receipt.contractAddress, contractData.contract.abi, contractData.name) 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) }, 50)
} }
} }

@ -29,7 +29,8 @@ export class InjectedProvider {
async getBalanceInEther (address) { async getBalanceInEther (address) {
const balance = await this.executionContext.web3().eth.getBalance(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) { getGasPrice (cb) {

@ -35,7 +35,8 @@ export class NodeProvider {
async getBalanceInEther (address) { async getBalanceInEther (address) {
const balance = await this.executionContext.web3().eth.getBalance(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) { getGasPrice (cb) {

@ -97,7 +97,8 @@ export class VMProvider {
async getBalanceInEther (address) { async getBalanceInEther (address) {
const balance = await this.web3.eth.getBalance(address, undefined, { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX }) 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) { getGasPrice (cb) {

@ -71,7 +71,8 @@ export class Web3Accounts {
return { return {
eth_accounts: this.eth_accounts.bind(this), eth_accounts: this.eth_accounts.bind(this),
eth_getBalance: this.eth_getBalance.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) cb(null, data.signature)
} }
eth_chainId (_payload, cb) {
return cb(null, '0x539') // 0x539 is hex of 1337
}
} }

Loading…
Cancel
Save