pull/3577/head
yann300 2 years ago committed by Aniket
parent 82d95b7631
commit 59543394e6
  1. 2
      apps/remix-ide/src/app.js
  2. 47
      apps/remix-ide/src/blockchain/blockchain.tsx
  3. 7
      apps/remix-ide/src/blockchain/providers/injected.ts
  4. 11
      apps/remix-ide/src/blockchain/providers/node.ts
  5. 14
      apps/remix-ide/src/blockchain/providers/vm.ts
  6. 2
      libs/remix-lib/src/eventManager.ts
  7. 2
      libs/remix-lib/src/helpers/txResultHelper.ts

@ -27,7 +27,7 @@ import { ConfigPlugin } from './app/plugins/config'
import { StoragePlugin } from './app/plugins/storage'
import { Layout } from './app/panels/layout'
import { NotificationPlugin } from './app/plugins/notification'
import { Blockchain } from './blockchain/blockchain.js'
import { Blockchain } from './blockchain/blockchain'
import { MergeVMProvider, LondonVMProvider, BerlinVMProvider} from './app/providers/vm-provider'
import { MainnetForkVMProvider } from './app/providers/mainnet-vm-fork-provider'
import { SepoliaForkVMProvider } from './app/providers/sepolia-vm-fork-provider'

@ -6,9 +6,10 @@ import { toBuffer, addHexPrefix } from '@ethereumjs/util'
import { EventEmitter } from 'events'
import { format } from 'util'
import { ExecutionContext } from './execution-context'
import VMProvider from './providers/vm.js'
import InjectedProvider from './providers/injected.js'
import NodeProvider from './providers/node.js'
import Config from '../config'
import { VMProvider } from './providers/vm'
import { InjectedProvider } from './providers/injected'
import { NodeProvider } from './providers/node'
import { execution, EventManager, helpers } from '@remix-project/remix-lib'
import { etherScanLink } from './helper'
import { logBuilder, cancelUpgradeMsg, cancelProxyMsg, addressToString } from "@remix-ui/helper"
@ -27,9 +28,37 @@ const profile = {
version: packageJson.version
}
// see TxRunner.ts in remix-lib
export type Transaction = {
from: string,
to: string,
value: string,
data: string,
gasLimit: number,
useCall: boolean,
timestamp?: number
}
export class Blockchain extends Plugin {
active: boolean
event: EventManager
events: EventEmitter
executionContext: ExecutionContext
config: Config
txRunner: any
networkcallid: number
networkStatus: {
network: {
name: string,
id: string
}
error?: string
}
providers: any
transactionContextAPI: any
// NOTE: the config object will need to be refactored out in remix-lib
constructor (config) {
constructor (config: Config) {
super(profile)
this.active = false
this.event = new EventManager()
@ -387,8 +416,8 @@ export class Blockchain extends Plugin {
return Web3.utils.toWei(value, unit || 'gwei')
}
calculateFee (gas, gasPrice, unit) {
return Web3.utils.toBN(gas).mul(Web3.utils.toBN(Web3.utils.toWei(gasPrice.toString(10), 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')))
}
determineGasFees (tx) {
@ -604,7 +633,7 @@ export class Blockchain extends Plugin {
*
* @param {Object} tx - transaction.
*/
sendTransaction (tx) {
sendTransaction (tx: Transaction) {
return new Promise((resolve, reject) => {
this.executionContext.detectNetwork((error, network) => {
if (error) return reject(error)
@ -747,8 +776,8 @@ export class Blockchain extends Plugin {
}
try {
const transaction = await runTransaction()
const txResult = transaction.result
const tx = transaction.tx
const txResult = (transaction as any).result
const tx = (transaction as any).tx
/*
value of txResult is inconsistent:
- transact to contract:

@ -1,7 +1,10 @@
const Web3 = require('web3')
import { hashPersonalMessage } from '@ethereumjs/util'
import { ExecutionContext } from '../execution-context'
export class InjectedProvider {
executionContext: ExecutionContext
class InjectedProvider {
constructor (executionContext) {
this.executionContext = executionContext
}
@ -44,5 +47,3 @@ class InjectedProvider {
return 'injected'
}
}
module.exports = InjectedProvider

@ -1,9 +1,14 @@
const Web3 = require('web3')
import { hashPersonalMessage } from '@ethereumjs/util'
const Personal = require('web3-eth-personal')
import { ExecutionContext } from '../execution-context'
import Config from '../../config'
class NodeProvider {
constructor (executionContext, config) {
export class NodeProvider {
executionContext: ExecutionContext
config: Config
constructor (executionContext: ExecutionContext, config: Config) {
this.executionContext = executionContext
this.config = config
}
@ -53,5 +58,3 @@ class NodeProvider {
return this.executionContext.getProvider()
}
}
module.exports = NodeProvider

@ -1,8 +1,16 @@
const Web3 = require('web3')
import Web3 from 'web3'
import { privateToAddress, hashPersonalMessage } from '@ethereumjs/util'
import BN from 'bn.js'
const { extend } = require('@remix-project/remix-simulator')
class VMProvider {
import { ExecutionContext } from '../execution-context'
export class VMProvider {
executionContext: ExecutionContext
web3: Web3
worker: Worker
provider: any
newAccountCallback: any
accounts: any
constructor (executionContext) {
this.executionContext = executionContext
this.worker = null
@ -99,5 +107,3 @@ class VMProvider {
return this.executionContext.getProvider()
}
}
module.exports = VMProvider

@ -40,7 +40,7 @@ export class EventManager {
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listeners that will be executed
*/
register (eventName, obj, func) {
register (eventName, obj, func?) {
if (!this.registered[eventName]) {
this.registered[eventName] = []
}

@ -20,7 +20,7 @@ function convertToPrefixedHex (input) {
Also, VM results use BN and Buffers, Node results use hex strings/ints,
So we need to normalize the values to prefixed hex strings
*/
export function resultToRemixTx (txResult, execResult) {
export function resultToRemixTx (txResult, execResult?) {
const { receipt, transactionHash, result } = txResult
const { status, gasUsed, contractAddress } = receipt
let returnValue, errorMessage

Loading…
Cancel
Save