Commit 3010dc0b authored by Iuri Matias's avatar Iuri Matias

fix eth_getCode call

parent fa830de1
......@@ -17,12 +17,12 @@ Implemented:
* [X] eth_blockNumber
* [X] eth_getBalance
* [_] eth_getStorageAt
* [X] eth_getTransactionCount
* [~] eth_getTransactionCount
* [_] eth_getBlockTransactionCountByHash
* [_] eth_getBlockTransactionCountByNumber
* [_] eth_getUncleCountByBlockHash
* [_] eth_getUncleCountByBlockNumber
* [~] eth_getCode
* [X] eth_getCode
* [~] eth_sign
* [X] eth_sendTransaction
* [_] eth_sendRawTransaction
......
......@@ -2,10 +2,23 @@ var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext
var processTx = require('./txProcess.js')
function hexConvert(ints) {
var ret = '0x'
for (var i = 0; i < ints.length; i++) {
var h = ints[i]
if (h) {
ret += (h <= 0xf ? '0' : '') + h.toString(16)
} else {
ret += '00'
}
}
return ret
}
var Transactions = function (accounts) {
this.accounts = accounts
// TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now
this.deployedContracts = {}
//this.deployedContracts = {}
}
Transactions.prototype.methods = function () {
......@@ -29,7 +42,7 @@ Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) {
if (error) {
return cb(error)
}
self.deployedContracts[receipt.contractAddress] = receipt.data
//self.deployedContracts[receipt.contractAddress] = receipt.data
var r = {
'transactionHash': receipt.hash,
......@@ -54,7 +67,11 @@ Transactions.prototype.eth_estimateGas = function (payload, cb) {
Transactions.prototype.eth_getCode = function (payload, cb) {
let address = payload.params[0]
cb(null, this.deployedContracts[address] || '0x')
const account = ethJSUtil.toBuffer(address)
executionContext.vm().stateManager.getContractCode(account, (error, result) => {
cb(error, hexConvert(result))
})
//cb(null, this.deployedContracts[address] || '0x')
}
Transactions.prototype.eth_call = function (payload, cb) {
......
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