remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/libs/remix-debug/test/vmCall.ts

38 lines
881 B

7 years ago
'use strict'
import { extendWeb3 } from '../src/init'
import { Address } from '@ethereumjs/util'
const { Provider } = require('@remix-project/remix-simulator')
const Web3 = require('web3')
7 years ago
async function getWeb3 () {
const remixSimulatorProvider = new Provider({ fork: 'berlin' })
await remixSimulatorProvider.init()
await remixSimulatorProvider.Accounts.resetAccounts()
const web3 = new Web3(remixSimulatorProvider)
extendWeb3(web3)
return web3
7 years ago
}
async function sendTx (web3, from, to, value, data, cb) {
4 years ago
try {
cb = cb || (() => {})
const receipt = await web3.eth.sendTransaction({
from: Address.fromPrivateKey(from.privateKey).toString(),
to,
value,
data,
gas: 7000000
})
cb(null, receipt.transactionHash)
return receipt.transactionHash
} catch (e) {
cb(e)
}
7 years ago
}
module.exports = {
sendTx,
getWeb3
7 years ago
}