From 36c72f54f2075a7b17c50ad3aaf0950fd304b822 Mon Sep 17 00:00:00 2001 From: Oleksii Kosynskyi Date: Wed, 16 Aug 2023 17:44:05 -0400 Subject: [PATCH] test --- .../src/blockchain/providers/injected.ts | 12 ++++++------ apps/remix-ide/src/blockchain/providers/vm.ts | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/blockchain/providers/injected.ts b/apps/remix-ide/src/blockchain/providers/injected.ts index c116457da6..bdbf077db0 100644 --- a/apps/remix-ide/src/blockchain/providers/injected.ts +++ b/apps/remix-ide/src/blockchain/providers/injected.ts @@ -10,12 +10,12 @@ export class InjectedProvider { } getAccounts (cb) { - return this.executionContext.web3().eth.getAccounts().then(res => cb(null, res)).catch(err => cb(err)) + return this.executionContext.web3().eth.getAccounts(cb) } newAccount (passwordPromptCb, cb) { passwordPromptCb((passphrase) => { - this.executionContext.web3().eth.personal.newAccount(passphrase).then(res => cb(null, res)).catch(err => cb(err)) + this.executionContext.web3().eth.personal.newAccount(passphrase, cb) }) } @@ -29,15 +29,15 @@ export class InjectedProvider { } getGasPrice (cb) { - this.executionContext.web3().eth.getGasPrice().then(res => cb(null, res)).catch(err => cb(err)) + this.executionContext.web3().eth.getGasPrice(cb) } signMessage (message, account, _passphrase, cb) { const messageHash = hashPersonalMessage(Buffer.from(message)) try { - this.executionContext.web3().eth.personal.sign(message, account) - .then(signedData=>cb(null, '0x' + messageHash.toString('hex'), signedData)) - .catch(error=>cb(error, '0x' + messageHash.toString('hex'))) + this.executionContext.web3().eth.personal.sign(message, account, (error, signedData) => { + cb(error, '0x' + messageHash.toString('hex'), signedData) + }) } catch (e) { cb(e.message) } diff --git a/apps/remix-ide/src/blockchain/providers/vm.ts b/apps/remix-ide/src/blockchain/providers/vm.ts index 8fc07563eb..720055df9d 100644 --- a/apps/remix-ide/src/blockchain/providers/vm.ts +++ b/apps/remix-ide/src/blockchain/providers/vm.ts @@ -1,5 +1,5 @@ -import Web3, { LegacySendAsyncProvider } from 'web3' -import { fromWei } from 'web3-utils' +import Web3, { FMT_BYTES, FMT_NUMBER, LegacySendAsyncProvider } from 'web3' +import { fromWei, toBigInt } from 'web3-utils' import { privateToAddress, hashPersonalMessage } from '@ethereumjs/util' import { extend, JSONRPCRequestPayload, JSONRPCResponseCallback } from '@remix-project/remix-simulator' import { ExecutionContext } from '../execution-context' @@ -22,7 +22,12 @@ export class VMProvider { } getAccounts (cb) { - this.web3.eth.getAccounts().then(accounts => cb(null, accounts)).catch(err => cb('No accounts?')) + this.web3.eth.getAccounts() + .then(accounts => cb(null, accounts)) + .catch(err => { + console.log('err',err) + cb('No accounts?') + }) } async resetEnvironment () { @@ -41,6 +46,8 @@ export class VMProvider { if (!msg.data.error) { this.provider = { sendAsync: (query, callback) => { + console.log('query',query) + console.log('callback',callback) const stamp = Date.now() + incr incr++ stamps[stamp] = callback @@ -81,12 +88,12 @@ export class VMProvider { } async getBalanceInEther (address) { - const balance = await this.web3.eth.getBalance(address) - return fromWei(balance.toString(10), 'ether') + const balance = await this.web3.eth.getBalance(address, undefined, { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX }) + return fromWei(toBigInt(balance).toString(10), 'ether') } getGasPrice (cb) { - this.web3.eth.getGasPrice().then(res => cb(null, res)).catch(err => cb(err)) + this.web3.eth.getGasPrice(cb) } signMessage (message, account, _passphrase, cb) {