Commit febab2ef authored by aniket-engg's avatar aniket-engg Committed by Aniket

some types and import export update

parent 3834ac09
...@@ -43,7 +43,7 @@ module.exports = { ...@@ -43,7 +43,7 @@ module.exports = {
* @param {Function} finalCallback - last callback. * @param {Function} finalCallback - last callback.
*/ */
callFunction: function (from, to, data, value, gasLimit, funAbi, txRunner, callbacks, finalCallback) { callFunction: function (from, to, data, value, gasLimit, funAbi, txRunner, callbacks, finalCallback) {
const useCall = funAbi.stateMutability === 'view' || funAbi.stateMutability === 'pure' const useCall = funAbi.stateMutability === 'view' || funAbi.stateMutability === 'pure' || funAbi.constant
const tx = { from, to, data, useCall, value, gasLimit } const tx = { from, to, data, useCall, value, gasLimit }
txRunner.rawRun(tx, callbacks.confirmationCb, callbacks.gasEstimationForceSend, callbacks.promptCb, (error, txResult) => { txRunner.rawRun(tx, callbacks.confirmationCb, callbacks.gasEstimationForceSend, callbacks.promptCb, (error, txResult) => {
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case) // see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"email": "yann@ethdev.com" "email": "yann@ethdev.com"
} }
], ],
"main": "index.js", "main": "src/index.js",
"dependencies": { "dependencies": {
"@remix-project/remix-lib": "^0.4.31", "@remix-project/remix-lib": "^0.4.31",
"ansi-gray": "^0.1.1", "ansi-gray": "^0.1.1",
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
"type": "git", "type": "git",
"url": "git+https://github.com/ethereum/remix-project.git" "url": "git+https://github.com/ethereum/remix-project.git"
}, },
"author": "remix team", "author": "Remix Team",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/ethereum/remix-project/issues" "url": "https://github.com/ethereum/remix-project/issues"
......
import { Provider } from './provider' export { Provider } from './provider'
export { Provider } // export { Provider }
...@@ -5,8 +5,8 @@ import * as crypto from 'crypto' ...@@ -5,8 +5,8 @@ import * as crypto from 'crypto'
export class Accounts { export class Accounts {
web3 web3
accounts accounts: Record<string, unknown>
accountsKeys accountsKeys: Record<string, unknown>
executionContext executionContext
constructor (executionContext) { constructor (executionContext) {
...@@ -19,7 +19,7 @@ export class Accounts { ...@@ -19,7 +19,7 @@ export class Accounts {
this.executionContext.init({ get: () => { return true } }) this.executionContext.init({ get: () => { return true } })
} }
async resetAccounts () { async resetAccounts (): Promise<void> {
// TODO: setting this to {} breaks the app currently, unclear why still // TODO: setting this to {} breaks the app currently, unclear why still
// this.accounts = {} // this.accounts = {}
// this.accountsKeys = {} // this.accountsKeys = {}
...@@ -43,7 +43,7 @@ export class Accounts { ...@@ -43,7 +43,7 @@ export class Accounts {
_addAccount (privateKey, balance) { _addAccount (privateKey, balance) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
privateKey = Buffer.from(privateKey, 'hex') privateKey = Buffer.from(privateKey, 'hex')
const address = privateToAddress(privateKey) const address: Buffer = privateToAddress(privateKey)
this.accounts[toChecksumAddress('0x' + address.toString('hex'))] = { privateKey, nonce: 0 } this.accounts[toChecksumAddress('0x' + address.toString('hex'))] = { privateKey, nonce: 0 }
this.accountsKeys[toChecksumAddress('0x' + address.toString('hex'))] = '0x' + privateKey.toString('hex') this.accountsKeys[toChecksumAddress('0x' + address.toString('hex'))] = '0x' + privateKey.toString('hex')
...@@ -62,7 +62,7 @@ export class Accounts { ...@@ -62,7 +62,7 @@ export class Accounts {
} }
newAccount (cb) { newAccount (cb) {
let privateKey let privateKey:Buffer
do { do {
privateKey = crypto.randomBytes(32) privateKey = crypto.randomBytes(32)
} while (!isValidPrivate(privateKey)) } while (!isValidPrivate(privateKey))
...@@ -70,7 +70,7 @@ export class Accounts { ...@@ -70,7 +70,7 @@ export class Accounts {
return cb(null, '0x' + privateToAddress(privateKey).toString('hex')) return cb(null, '0x' + privateToAddress(privateKey).toString('hex'))
} }
methods () { methods (): Record<string, unknown> {
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),
......
export class Blocks { export class Blocks {
executionContext executionContext
coinbase coinbase: string
blockNumber blockNumber: number
constructor (executionContext, _options) { constructor (executionContext, _options) {
this.executionContext = executionContext this.executionContext = executionContext
...@@ -10,7 +10,7 @@ export class Blocks { ...@@ -10,7 +10,7 @@ export class Blocks {
this.blockNumber = 0 this.blockNumber = 0
} }
methods () { methods (): Record<string, unknown> {
return { return {
eth_getBlockByNumber: this.eth_getBlockByNumber.bind(this), eth_getBlockByNumber: this.eth_getBlockByNumber.bind(this),
eth_gasPrice: this.eth_gasPrice.bind(this), eth_gasPrice: this.eth_gasPrice.bind(this),
...@@ -68,7 +68,7 @@ export class Blocks { ...@@ -68,7 +68,7 @@ export class Blocks {
} }
eth_getBlockByHash (payload, cb) { eth_getBlockByHash (payload, cb) {
var block = this.executionContext.blocks[payload.params[0]] const block = this.executionContext.blocks[payload.params[0]]
const b = { const b = {
number: this.toHex(block.header.number), number: this.toHex(block.header.number),
...@@ -107,13 +107,13 @@ export class Blocks { ...@@ -107,13 +107,13 @@ export class Blocks {
} }
eth_getBlockTransactionCountByHash (payload, cb) { eth_getBlockTransactionCountByHash (payload, cb) {
var block = this.executionContext.blocks[payload.params[0]] const block = this.executionContext.blocks[payload.params[0]]
cb(null, block.transactions.length) cb(null, block.transactions.length)
} }
eth_getBlockTransactionCountByNumber (payload, cb) { eth_getBlockTransactionCountByNumber (payload, cb) {
var block = this.executionContext.blocks[payload.params[0]] const block = this.executionContext.blocks[payload.params[0]]
cb(null, block.transactions.length) cb(null, block.transactions.length)
} }
......
...@@ -44,7 +44,7 @@ export class Transactions { ...@@ -44,7 +44,7 @@ export class Transactions {
const txBlock = this.executionContext.txs[receipt.hash] const txBlock = this.executionContext.txs[receipt.hash]
const r = { const r: Record <string, unknown> = {
transactionHash: receipt.hash, transactionHash: receipt.hash,
transactionIndex: '0x00', transactionIndex: '0x00',
blockHash: '0x' + txBlock.hash().toString('hex'), blockHash: '0x' + txBlock.hash().toString('hex'),
...@@ -118,7 +118,7 @@ export class Transactions { ...@@ -118,7 +118,7 @@ export class Transactions {
const txBlock = this.executionContext.txs[receipt.transactionHash] const txBlock = this.executionContext.txs[receipt.transactionHash]
// TODO: params to add later // TODO: params to add later
const r = { const r: Record<string, unknown> = {
blockHash: '0x' + txBlock.hash().toString('hex'), blockHash: '0x' + txBlock.hash().toString('hex'),
blockNumber: '0x' + txBlock.header.number.toString('hex'), blockNumber: '0x' + txBlock.header.number.toString('hex'),
from: receipt.from, from: receipt.from,
...@@ -164,7 +164,7 @@ export class Transactions { ...@@ -164,7 +164,7 @@ export class Transactions {
} }
// TODO: params to add later // TODO: params to add later
const r = { const r: Record<string, unknown> = {
blockHash: '0x' + txBlock.hash().toString('hex'), blockHash: '0x' + txBlock.hash().toString('hex'),
blockNumber: '0x' + txBlock.header.number.toString('hex'), blockNumber: '0x' + txBlock.header.number.toString('hex'),
from: receipt.from, from: receipt.from,
...@@ -206,7 +206,7 @@ export class Transactions { ...@@ -206,7 +206,7 @@ export class Transactions {
} }
// TODO: params to add later // TODO: params to add later
const r = { const r: Record<string, unknown> = {
blockHash: '0x' + txBlock.hash().toString('hex'), blockHash: '0x' + txBlock.hash().toString('hex'),
blockNumber: '0x' + txBlock.header.number.toString('hex'), blockNumber: '0x' + txBlock.header.number.toString('hex'),
from: receipt.from, from: receipt.from,
......
const RemixLib = require('@remix-project/remix-lib') import { execution } from '@remix-project/remix-lib'
const TxExecution = RemixLib.execution.txExecution const TxExecution = execution.txExecution
const TxRunner = RemixLib.execution.txRunner const TxRunner = execution.txRunner
function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) { function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) {
const finalCallback = function (err, result) { const finalCallback = function (err, result) {
...@@ -12,7 +12,7 @@ function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, ...@@ -12,7 +12,7 @@ function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks,
return callback(null, toReturn) return callback(null, toReturn)
} }
TxExecution.callFunction(from, to, data, value, gasLimit, { constant: true }, txRunner, callbacks, finalCallback, true) TxExecution.callFunction(from, to, data, value, gasLimit, { constant: true }, txRunner, callbacks, finalCallback)
} }
function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) { function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) {
...@@ -23,7 +23,7 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, c ...@@ -23,7 +23,7 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, c
callback(null, result.transactionHash) callback(null, result.transactionHash)
} }
TxExecution.callFunction(from, to, data, value, gasLimit, { constant: false }, txRunner, callbacks, finalCallback, false) TxExecution.callFunction(from, to, data, value, gasLimit, { constant: false }, txRunner, callbacks, finalCallback)
} }
function createContract (payload, from, data, value, gasLimit, txRunner, callbacks, callback) { function createContract (payload, from, data, value, gasLimit, txRunner, callbacks, callback) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment