Fix yarn nx build

pull/5370/head
Wyatt Barnes 1 year ago
parent b5aa531db8
commit 4014d79f62
  1. 4
      apps/remix-ide/src/app/plugins/solidity-script.tsx
  2. 9
      apps/remix-ide/src/blockchain/blockchain.tsx
  3. 6
      apps/remix-ide/src/blockchain/providers/node.ts
  4. 27
      apps/remix-ide/src/blockchain/providers/vm.ts
  5. 4
      libs/remix-simulator/src/VmProxy.ts
  6. 4
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx
  7. 36
      libs/remix-ui/editor/src/lib/web-types.ts
  8. 7
      libs/remix-ui/run-tab/src/lib/components/mainnet.tsx

@ -2,7 +2,7 @@ import React from 'react' // eslint-disable-line
import { format } from 'util'
import { Plugin } from '@remixproject/engine'
import { compile } from '@remix-project/remix-solidity'
import { TransactionConfig } from 'web3-core'
import { Transaction } from 'web3-types'
const _paq = window._paq = window._paq || [] //eslint-disable-line
const profile = {
@ -68,7 +68,7 @@ export class SolidityScript extends Plugin {
}
// deploy the contract
let tx: TransactionConfig = {
let tx: Transaction = {
from: accounts[0],
data: bytecode
}

@ -1,6 +1,7 @@
import React from 'react' // eslint-disable-line
import Web3 from 'web3'
import { fromWei, toBN, toWei } from 'web3-utils-legacy'
import { Plugin } from '@remixproject/engine'
import { toBuffer, addHexPrefix } from '@ethereumjs/util'
import { EventEmitter } from 'events'
@ -422,17 +423,17 @@ export class Blockchain extends Plugin {
fromWei (value, doTypeConversion, unit) {
if (doTypeConversion) {
return Web3.utils.fromWei(typeConversion.toInt(value), unit || 'ether')
return fromWei(typeConversion.toInt(value), unit || 'ether')
}
return Web3.utils.fromWei(value.toString(10), unit || 'ether')
return fromWei(value.toString(10), unit || 'ether')
}
toWei (value, unit) {
return Web3.utils.toWei(value, unit || 'gwei')
return toWei(value, unit || 'gwei')
}
calculateFee (gas, gasPrice, unit?) {
return Web3.utils.toBN(gas).mul(Web3.utils.toBN(Web3.utils.toWei(gasPrice.toString(10) as string, unit || 'gwei')))
return toBN(gas).mul(toBN(toWei(gasPrice.toString(10) as string, unit || 'gwei')))
}
determineGasFees (tx) {

@ -46,9 +46,9 @@ export class NodeProvider {
const messageHash = hashPersonalMessage(Buffer.from(message))
try {
const personal = new Personal(this.executionContext.web3().currentProvider)
personal.sign(message, account, passphrase, (error, signedData) => {
cb(error, '0x' + messageHash.toString('hex'), signedData)
})
personal.sign(message, account, passphrase)
.then(signedData => cb(undefined, '0x' + messageHash.toString('hex'), signedData))
.catch(error => cb(error, '0x' + messageHash.toString('hex'), undefined))
} catch (e) {
cb(e.message)
}

@ -1,4 +1,5 @@
import Web3 from 'web3'
import Web3, { FMT_BYTES, FMT_NUMBER, LegacySendAsyncProvider } from 'web3'
import { fromWei } from 'web3-utils-legacy'
import { privateToAddress, hashPersonalMessage } from '@ethereumjs/util'
import BN from 'bn.js'
import { extend, JSONRPCRequestPayload, JSONRPCResponseCallback } from '@remix-project/remix-simulator'
@ -21,12 +22,9 @@ export class VMProvider {
}
getAccounts (cb) {
this.web3.eth.getAccounts((err, accounts) => {
if (err) {
return cb('No accounts?')
}
return cb(null, accounts)
})
this.web3.eth.getAccounts()
.then(accounts => cb(null, accounts))
.catch(err => cb('No accounts?'))
}
async resetEnvironment () {
@ -51,7 +49,7 @@ export class VMProvider {
this.worker.postMessage({ cmd: 'sendAsync', query, stamp })
}
}
this.web3 = new Web3(this.provider)
this.web3 = new Web3(this.provider as LegacySendAsyncProvider)
extend(this.web3)
this.executionContext.setWeb3(this.executionContext.getProvider(), this.web3)
resolve({})
@ -85,8 +83,8 @@ export class VMProvider {
}
async getBalanceInEther (address) {
const balance = await this.web3.eth.getBalance(address)
return Web3.utils.fromWei(new BN(balance).toString(10), 'ether')
const balance = await this.web3.eth.getBalance(address, undefined, { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX })
return fromWei(new BN(balance).toString(10), 'ether')
}
getGasPrice (cb) {
@ -95,12 +93,9 @@ export class VMProvider {
signMessage (message, account, _passphrase, cb) {
const messageHash = hashPersonalMessage(Buffer.from(message))
this.web3.eth.sign(message, account, (error, signedData) => {
if (error) {
return cb(error)
}
cb(null, '0x' + messageHash.toString('hex'), signedData)
})
this.web3.eth.sign(message, account)
.then(signedData => cb(null, '0x' + messageHash.toString('hex'), signedData))
.catch(error => cb(error))
}
getProvider () {

@ -6,6 +6,7 @@ import { ConsoleLogs, hash } from '@remix-project/remix-lib'
import BN from 'bn.js'
import { toChecksumAddress, bufferToHex, Address, toBuffer } from '@ethereumjs/util'
import utils from 'web3-utils'
import { toBN } from 'web3-utils-legacy'
import { ethers } from 'ethers'
import { VMContext } from './vm-context'
import type { StateManager } from '@ethereumjs/statemanager'
@ -83,8 +84,7 @@ export class VmProxy {
this.fromDecimal = (...args) => utils.fromDecimal.apply(this, args)
this.fromWei = (...args) => utils.fromWei.apply(this, args)
this.toWei = (...args) => utils.toWei.apply(this, args)
// TODO Is this still needed?
// this.toBigNumber = (...args) => utils.toBN.apply(this, args)
this.toBigNumber = (...args) => toBN.apply(this, args)
this.isAddress = (...args) => utils.isAddress.apply(this, args)
this.utils = utils
this.txsMapBlock = {}

@ -1,7 +1,7 @@
import React from 'react' // eslint-disable-line
import DropdownPanel from './dropdown-panel' // eslint-disable-line
import { BN } from 'bn.js'
import Web3 from 'web3'
import { toBN } from 'web3-utils-legacy'
export const GlobalVariables = ({ block, receipt, tx, className }) => {
// see https://docs.soliditylang.org/en/latest/units-and-global-variables.html#block-and-transaction-properties
@ -18,7 +18,7 @@ export const GlobalVariables = ({ block, receipt, tx, className }) => {
'tx.origin': tx && tx.from
}
if (block && block.baseFeePerGas) {
globals['block.basefee'] = Web3.utils.toBN(block.baseFeePerGas).toString(10) + ` Wei (${block.baseFeePerGas})`
globals['block.basefee'] = toBN(block.baseFeePerGas).toString(10) + ` Wei (${block.baseFeePerGas})`
}
return (

@ -184,40 +184,32 @@ export const loadTypes = async (monaco) => {
// Web3
// @ts-ignore
const indexWeb3 = await import('raw-loader!web3/types/index.d.ts')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3.default, `file:///node_modules/@types/web3/index.d.ts`)
const indexWeb3 = await import('raw-loader!web3')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3.default, `file:///node_modules/web3/lib/types/index.d.ts`)
// @ts-ignore
const indexWeb3Bzz = await import('raw-loader!web3-bzz/types/index.d.ts')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Bzz.default, `file:///node_modules/@types/web3-bzz/index.d.ts`)
const indexWeb3Core = await import('raw-loader!web3-core')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Core.default, `file:///node_modules/web3-core/lib/types/index.d.ts`)
// @ts-ignore
const indexWeb3Core = await import('raw-loader!web3-core/types/index.d.ts')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Core.default, `file:///node_modules/@types/web3-core/index.d.ts`)
const indexWeb3Eth = await import('raw-loader!web3-eth')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Eth.default, `file:///node_modules/web3-eth/lib/types/index.d.ts`)
// @ts-ignore
const indexWeb3Eth = await import('raw-loader!web3-eth/types/index.d.ts')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Eth.default, `file:///node_modules/@types/web3-eth/index.d.ts`)
const indexWeb3Personal = await import('raw-loader!web3-eth-personal')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Personal.default, `file:///node_modules/web3-eth-personal/lib/types/index.d.ts`)
// @ts-ignore
const indexWeb3Personal = await import('raw-loader!web3-eth-personal/types/index.d.ts')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Personal.default, `file:///node_modules/@types/web3-eth-personal/index.d.ts`)
const indexWeb3Contract = await import('raw-loader!web3-eth-contract')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Contract.default, `file:///node_modules/web3-eth-contract/lib/types/index.d.ts`)
// @ts-ignore
const indexWeb3Contract = await import('raw-loader!web3-eth-contract/types/index.d.ts')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Contract.default, `file:///node_modules/@types/web3-eth-contract/index.d.ts`)
const indexWeb3Net = await import('raw-loader!web3-net')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Net.default, `file:///node_modules/web3-net/lib/types/index.d.ts`)
// @ts-ignore
const indexWeb3Net = await import('raw-loader!web3-net/types/index.d.ts')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Net.default, `file:///node_modules/@types/web3-net/index.d.ts`)
// @ts-ignore
const indexWeb3Shh = await import('raw-loader!web3-shh/types/index.d.ts')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Shh.default, `file:///node_modules/@types/web3-shh/index.d.ts`)
// @ts-ignore
const indexWeb3Util = await import('raw-loader!web3-utils/types/index.d.ts')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Util.default, `file:///node_modules/@types/web3-utils/index.d.ts`)
const indexWeb3Util = await import('raw-loader!web3-utils')
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Util.default, `file:///node_modules/web3-utils/lib/types/index.d.ts`)
// remix
const indexRemixApi = remixTypes + `\n
declare global {

@ -2,6 +2,7 @@
import React, { useEffect, useState } from 'react'
import { CopyToClipboard } from '@remix-ui/clipboard'
import Web3 from 'web3'
import { fromWei, toBN, toWei } from 'web3-utils-legacy'
import { MainnetProps } from '../types'
export function MainnetPrompt (props: MainnetProps) {
@ -13,7 +14,7 @@ export function MainnetPrompt (props: MainnetProps) {
if (txFeeText) setTransactionFee(txFeeText)
if (gasPriceValue) onGasPriceChange(gasPriceValue)
if (props.network && props.network.lastBlock && props.network.lastBlock.baseFeePerGas) {
const baseFee = Web3.utils.fromWei(Web3.utils.toBN(props.network.lastBlock.baseFeePerGas), 'Gwei')
const baseFee = fromWei(toBN(props.network.lastBlock.baseFeePerGas), 'Gwei')
setBaseFee(baseFee)
onMaxFeeChange(baseFee)
@ -25,7 +26,7 @@ export function MainnetPrompt (props: MainnetProps) {
const onMaxFeeChange = (value: string) => {
const maxFee = value
// @ts-ignore
if (Web3.utils.toBN(props.network.lastBlock.baseFeePerGas).gt(Web3.utils.toBN(Web3.utils.toWei(maxFee, 'Gwei')))) {
if (toBN(props.network.lastBlock.baseFeePerGas).gt(toBN(toWei(maxFee, 'Gwei')))) {
setTransactionFee('Transaction is invalid. Max fee should not be less than Base fee')
props.updateGasPriceStatus(false)
props.updateConfirmSettings(true)
@ -106,7 +107,7 @@ export function MainnetPrompt (props: MainnetProps) {
</div>
<div className="align-items-center my-1" title="Represents the maximum amount of fee that you will pay for this transaction. The minimun needs to be set to base fee.">
<div className='d-flex'>
<span className="text-dark mr-2 text-nowrap">Max fee (Not less than base fee {Web3.utils.fromWei(Web3.utils.toBN(props.network.lastBlock.baseFeePerGas), 'Gwei')} Gwei):</span>
<span className="text-dark mr-2 text-nowrap">Max fee (Not less than base fee {fromWei(toBN(props.network.lastBlock.baseFeePerGas), 'Gwei')} Gwei):</span>
<input className="form-control mr-1 text-right" style={{ height: '1.2rem', width: '6rem' }} id='maxfee' onInput={(e: any) => onMaxFeeChange(e.target.value)} defaultValue={baseFee} />
<span>Gwei</span>
<span className="text-dark ml-2"></span>

Loading…
Cancel
Save