|
|
@ -2,8 +2,7 @@ import Web3 from 'web3' |
|
|
|
import { toChecksumAddress, BN } from 'ethereumjs-util' |
|
|
|
import { toChecksumAddress, BN } from 'ethereumjs-util' |
|
|
|
import { processTx } from './txProcess' |
|
|
|
import { processTx } from './txProcess' |
|
|
|
|
|
|
|
|
|
|
|
class Transactions{ |
|
|
|
export class Transactions { |
|
|
|
|
|
|
|
|
|
|
|
executionContext |
|
|
|
executionContext |
|
|
|
accounts |
|
|
|
accounts |
|
|
|
|
|
|
|
|
|
|
@ -46,16 +45,16 @@ class Transactions{ |
|
|
|
const txBlock = this.executionContext.txs[receipt.hash] |
|
|
|
const txBlock = this.executionContext.txs[receipt.hash] |
|
|
|
|
|
|
|
|
|
|
|
const r = { |
|
|
|
const r = { |
|
|
|
'transactionHash': receipt.hash, |
|
|
|
transactionHash: receipt.hash, |
|
|
|
'transactionIndex': '0x00', |
|
|
|
transactionIndex: '0x00', |
|
|
|
'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'), |
|
|
|
'gasUsed': Web3.utils.toHex(receipt.gas), |
|
|
|
gasUsed: Web3.utils.toHex(receipt.gas), |
|
|
|
'cumulativeGasUsed': Web3.utils.toHex(receipt.gas), |
|
|
|
cumulativeGasUsed: Web3.utils.toHex(receipt.gas), |
|
|
|
'contractAddress': receipt.contractAddress, |
|
|
|
contractAddress: receipt.contractAddress, |
|
|
|
'logs': receipt.logs, |
|
|
|
logs: receipt.logs, |
|
|
|
'status': receipt.status, |
|
|
|
status: receipt.status, |
|
|
|
'to': receipt.to |
|
|
|
to: receipt.to |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (r.blockNumber === '0x') { |
|
|
|
if (r.blockNumber === '0x') { |
|
|
@ -71,7 +70,7 @@ class Transactions{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
eth_getCode (payload, cb) { |
|
|
|
eth_getCode (payload, cb) { |
|
|
|
let address = payload.params[0] |
|
|
|
const address = payload.params[0] |
|
|
|
|
|
|
|
|
|
|
|
this.executionContext.web3().eth.getCode(address, (error, result) => { |
|
|
|
this.executionContext.web3().eth.getCode(address, (error, result) => { |
|
|
|
if (error) { |
|
|
|
if (error) { |
|
|
@ -97,13 +96,13 @@ class Transactions{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
eth_getTransactionCount (payload, cb) { |
|
|
|
eth_getTransactionCount (payload, cb) { |
|
|
|
let address = payload.params[0] |
|
|
|
const address = payload.params[0] |
|
|
|
|
|
|
|
|
|
|
|
this.executionContext.vm().stateManager.getAccount(address, (err, account) => { |
|
|
|
this.executionContext.vm().stateManager.getAccount(address, (err, account) => { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
return cb(err) |
|
|
|
return cb(err) |
|
|
|
} |
|
|
|
} |
|
|
|
let nonce = new BN(account.nonce).toString(10) |
|
|
|
const nonce = new BN(account.nonce).toString(10) |
|
|
|
cb(null, nonce) |
|
|
|
cb(null, nonce) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -120,17 +119,17 @@ class Transactions{ |
|
|
|
|
|
|
|
|
|
|
|
// TODO: params to add later
|
|
|
|
// TODO: params to add later
|
|
|
|
const r = { |
|
|
|
const r = { |
|
|
|
'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, |
|
|
|
'gas': Web3.utils.toHex(receipt.gas), |
|
|
|
gas: Web3.utils.toHex(receipt.gas), |
|
|
|
// 'gasPrice': '2000000000000', // 0x123
|
|
|
|
// 'gasPrice': '2000000000000', // 0x123
|
|
|
|
'gasPrice': '0x4a817c800', // 20000000000
|
|
|
|
gasPrice: '0x4a817c800', // 20000000000
|
|
|
|
'hash': receipt.transactionHash, |
|
|
|
hash: receipt.transactionHash, |
|
|
|
'input': receipt.input, |
|
|
|
input: receipt.input, |
|
|
|
// "nonce": 2, // 0x15
|
|
|
|
// "nonce": 2, // 0x15
|
|
|
|
// "transactionIndex": 0,
|
|
|
|
// "transactionIndex": 0,
|
|
|
|
'value': receipt.value |
|
|
|
value: receipt.value |
|
|
|
// "value":"0xf3dbb76162000" // 4290000000000000
|
|
|
|
// "value":"0xf3dbb76162000" // 4290000000000000
|
|
|
|
// "v": "0x25", // 37
|
|
|
|
// "v": "0x25", // 37
|
|
|
|
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
|
|
|
|
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
|
|
|
@ -165,18 +164,18 @@ class Transactions{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: params to add later
|
|
|
|
// TODO: params to add later
|
|
|
|
let r = { |
|
|
|
const r = { |
|
|
|
'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, |
|
|
|
'gas': Web3.utils.toHex(receipt.gas), |
|
|
|
gas: Web3.utils.toHex(receipt.gas), |
|
|
|
// 'gasPrice': '2000000000000', // 0x123
|
|
|
|
// 'gasPrice': '2000000000000', // 0x123
|
|
|
|
'gasPrice': '0x4a817c800', // 20000000000
|
|
|
|
gasPrice: '0x4a817c800', // 20000000000
|
|
|
|
'hash': receipt.transactionHash, |
|
|
|
hash: receipt.transactionHash, |
|
|
|
'input': receipt.input, |
|
|
|
input: receipt.input, |
|
|
|
// "nonce": 2, // 0x15
|
|
|
|
// "nonce": 2, // 0x15
|
|
|
|
// "transactionIndex": 0,
|
|
|
|
// "transactionIndex": 0,
|
|
|
|
'value': receipt.value |
|
|
|
value: receipt.value |
|
|
|
// "value":"0xf3dbb76162000" // 4290000000000000
|
|
|
|
// "value":"0xf3dbb76162000" // 4290000000000000
|
|
|
|
// "v": "0x25", // 37
|
|
|
|
// "v": "0x25", // 37
|
|
|
|
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
|
|
|
|
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
|
|
|
@ -208,17 +207,17 @@ class Transactions{ |
|
|
|
|
|
|
|
|
|
|
|
// TODO: params to add later
|
|
|
|
// TODO: params to add later
|
|
|
|
const r = { |
|
|
|
const r = { |
|
|
|
'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, |
|
|
|
'gas': Web3.utils.toHex(receipt.gas), |
|
|
|
gas: Web3.utils.toHex(receipt.gas), |
|
|
|
// 'gasPrice': '2000000000000', // 0x123
|
|
|
|
// 'gasPrice': '2000000000000', // 0x123
|
|
|
|
'gasPrice': '0x4a817c800', // 20000000000
|
|
|
|
gasPrice: '0x4a817c800', // 20000000000
|
|
|
|
'hash': receipt.transactionHash, |
|
|
|
hash: receipt.transactionHash, |
|
|
|
'input': receipt.input, |
|
|
|
input: receipt.input, |
|
|
|
// "nonce": 2, // 0x15
|
|
|
|
// "nonce": 2, // 0x15
|
|
|
|
// "transactionIndex": 0,
|
|
|
|
// "transactionIndex": 0,
|
|
|
|
'value': receipt.value |
|
|
|
value: receipt.value |
|
|
|
// "value":"0xf3dbb76162000" // 4290000000000000
|
|
|
|
// "value":"0xf3dbb76162000" // 4290000000000000
|
|
|
|
// "v": "0x25", // 37
|
|
|
|
// "v": "0x25", // 37
|
|
|
|
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
|
|
|
|
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
|
|
|
|