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 = {
* @param {Function} finalCallback - last callback.
*/
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 }
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)
......
......@@ -12,7 +12,7 @@
"email": "yann@ethdev.com"
}
],
"main": "index.js",
"main": "src/index.js",
"dependencies": {
"@remix-project/remix-lib": "^0.4.31",
"ansi-gray": "^0.1.1",
......@@ -56,7 +56,7 @@
"type": "git",
"url": "git+https://github.com/ethereum/remix-project.git"
},
"author": "remix team",
"author": "Remix Team",
"license": "MIT",
"bugs": {
"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'
export class Accounts {
web3
accounts
accountsKeys
accounts: Record<string, unknown>
accountsKeys: Record<string, unknown>
executionContext
constructor (executionContext) {
......@@ -19,7 +19,7 @@ export class Accounts {
this.executionContext.init({ get: () => { return true } })
}
async resetAccounts () {
async resetAccounts (): Promise<void> {
// TODO: setting this to {} breaks the app currently, unclear why still
// this.accounts = {}
// this.accountsKeys = {}
......@@ -43,7 +43,7 @@ export class Accounts {
_addAccount (privateKey, balance) {
return new Promise((resolve, reject) => {
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.accountsKeys[toChecksumAddress('0x' + address.toString('hex'))] = '0x' + privateKey.toString('hex')
......@@ -62,7 +62,7 @@ export class Accounts {
}
newAccount (cb) {
let privateKey
let privateKey:Buffer
do {
privateKey = crypto.randomBytes(32)
} while (!isValidPrivate(privateKey))
......@@ -70,7 +70,7 @@ export class Accounts {
return cb(null, '0x' + privateToAddress(privateKey).toString('hex'))
}
methods () {
methods (): Record<string, unknown> {
return {
eth_accounts: this.eth_accounts.bind(this),
eth_getBalance: this.eth_getBalance.bind(this),
......
export class Blocks {
executionContext
coinbase
blockNumber
coinbase: string
blockNumber: number
constructor (executionContext, _options) {
this.executionContext = executionContext
......@@ -10,7 +10,7 @@ export class Blocks {
this.blockNumber = 0
}
methods () {
methods (): Record<string, unknown> {
return {
eth_getBlockByNumber: this.eth_getBlockByNumber.bind(this),
eth_gasPrice: this.eth_gasPrice.bind(this),
......@@ -68,7 +68,7 @@ export class Blocks {
}
eth_getBlockByHash (payload, cb) {
var block = this.executionContext.blocks[payload.params[0]]
const block = this.executionContext.blocks[payload.params[0]]
const b = {
number: this.toHex(block.header.number),
......@@ -107,13 +107,13 @@ export class Blocks {
}
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)
}
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)
}
......
......@@ -44,7 +44,7 @@ export class Transactions {
const txBlock = this.executionContext.txs[receipt.hash]
const r = {
const r: Record <string, unknown> = {
transactionHash: receipt.hash,
transactionIndex: '0x00',
blockHash: '0x' + txBlock.hash().toString('hex'),
......@@ -118,7 +118,7 @@ export class Transactions {
const txBlock = this.executionContext.txs[receipt.transactionHash]
// TODO: params to add later
const r = {
const r: Record<string, unknown> = {
blockHash: '0x' + txBlock.hash().toString('hex'),
blockNumber: '0x' + txBlock.header.number.toString('hex'),
from: receipt.from,
......@@ -164,7 +164,7 @@ export class Transactions {
}
// TODO: params to add later
const r = {
const r: Record<string, unknown> = {
blockHash: '0x' + txBlock.hash().toString('hex'),
blockNumber: '0x' + txBlock.header.number.toString('hex'),
from: receipt.from,
......@@ -206,7 +206,7 @@ export class Transactions {
}
// TODO: params to add later
const r = {
const r: Record<string, unknown> = {
blockHash: '0x' + txBlock.hash().toString('hex'),
blockNumber: '0x' + txBlock.header.number.toString('hex'),
from: receipt.from,
......
const RemixLib = require('@remix-project/remix-lib')
const TxExecution = RemixLib.execution.txExecution
const TxRunner = RemixLib.execution.txRunner
import { execution } from '@remix-project/remix-lib'
const TxExecution = execution.txExecution
const TxRunner = execution.txRunner
function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) {
const finalCallback = function (err, result) {
......@@ -12,7 +12,7 @@ function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks,
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) {
......@@ -23,7 +23,7 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, c
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) {
......
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