writing internals correctly

This commit is contained in:
Dustin Brickwood 2018-07-13 12:53:42 -04:00
parent 185c35523d
commit b9dda84e30
2 changed files with 21 additions and 2 deletions

View file

@ -32,6 +32,7 @@ import (
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"gopkg.in/olebedev/go-duktape.v3" "gopkg.in/olebedev/go-duktape.v3"
"database/sql" "database/sql"
"reflect"
) )
// bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js. // bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js.
@ -595,6 +596,12 @@ func (i *Internals) SWriteInteralTxs(hash common.Hash) {
if err != nil { if err != nil {
return return
} }
fmt.Println("[VALUE]", reflect.TypeOf(i.Value))
test := "0x3782dace9d900000"
if test == i.Value {
fmt.Println("[EQUAL]: ", test, i.Value)
}
gas, _ := hexutil.DecodeUint64(i.Gas) gas, _ := hexutil.DecodeUint64(i.Gas)
gasUsed, _ := hexutil.DecodeUint64(i.GasUsed) gasUsed, _ := hexutil.DecodeUint64(i.GasUsed)
@ -609,6 +616,11 @@ func (i *Internals) SWriteInteralTxs(hash common.Hash) {
} }
func (i *Internals) InternalRecursive(hash common.Hash) { func (i *Internals) InternalRecursive(hash common.Hash) {
amount, _ := hexutil.DecodeUint64(i.Value)
if i.Type != "CREATE" {
fmt.Println("[INSIDE RECURSIVE VALUE]", amount)
fmt.Printf("%+v", i)
}
i.SWriteInteralTxs(hash) i.SWriteInteralTxs(hash)
lengthOfCalls := len(i.Calls) lengthOfCalls := len(i.Calls)
if lengthOfCalls == 0 { if lengthOfCalls == 0 {
@ -713,7 +725,8 @@ func (jst *Tracer) SGetResult(hash common.Hash) (json.RawMessage, error) {
if err := json.Unmarshal(result, &dat); err != nil { if err := json.Unmarshal(result, &dat); err != nil {
panic(err) panic(err)
} }
fmt.Println("[THIS IS HASH]", hash.Hex()) //fmt.Println("[THIS IS HASH]", hash.Hex())
//fmt.Println("DAT DATA STRUCTURE" , dat)
dat.InternalRecursive(hash) dat.InternalRecursive(hash)
return result, jst.err return result, jst.err

View file

@ -4,12 +4,18 @@ var Transfers2 = artifacts.require("Transfers2");
contract('Transfers', function(accounts) { contract('Transfers', function(accounts) {
var addressA = web3.eth.accounts[0]; var addressA = web3.eth.accounts[0];
var addressB = web3.eth.accounts[1]; var addressB = web3.eth.accounts[1];
console.log("Addr A:", addressA)
console.log("Addr B:", addressB)
var transfers; var transfers;
web3.eth.defaultAccount = web3.eth.accounts[0]; web3.eth.defaultAccount = web3.eth.accounts[0];
it("should initialize", async() => { it("should initialize", async() => {
transfers = await Transfers.new(); transfers = await Transfers.new();
transfers2 = await Transfers2.new(); transfers2 = await Transfers2.new();
console.log("Transfer addr1", transfers.address)
console.log("Transfer addr2", transfers2.address)
assert(transfers !== undefined, ""); assert(transfers !== undefined, "");
assert(transfers2 !== undefined, ""); assert(transfers2 !== undefined, "");
}) })