Skip to content

Extending bindgen (wip dont merge) - #66

Open
elliots wants to merge 8 commits into
newalchemylimited:masterfrom
elliots:moregen
Open

Extending bindgen (wip dont merge)#66
elliots wants to merge 8 commits into
newalchemylimited:masterfrom
elliots:moregen

Conversation

@elliots

@elliots elliots commented Sep 10, 2018

Copy link
Copy Markdown

I've started work extending bindgen.

What I'm aiming for:

  • Use go types instead of seth ones (somewhat done)
  • Support structs
  • Use text/template instead of strings in go (done)
  • Events (somewhat done)

Not near complete, just adding a PR so other people can keep track/help/suggest things :)

Btw, project is excellent Cheers :)

wip use go types in calls, bunch of ugly temp logging


wip, very wip


handle bytes and bytes32
@elliots

elliots commented Sep 13, 2018

Copy link
Copy Markdown
Author

Events are in... needs a bit of a cleanup (and filtering by indexed props) but it is usable.

Generating from

event SomethingHappened(uint16 uint16Val, address addressVal, string stringVal, bytes bytesVal);
    
function sendTestEvent(uint16 uint16Val, string stringVal, bytes bytesVal) public {
    emit SomethingHappened(uint16Val, msg.sender, stringVal, bytesVal);
}

Gives

type SomethingHappenedEvent struct {
	Log        *seth.Log
	Uint16Val  uint16
	AddressVal seth.Address
	StringVal  string
	BytesVal   []byte
}

func (c *Test) FilterSomethingHappenedEvent(start, end int64) (outChan chan *SomethingHappenedEvent, close func(), errChan chan error) {
<SNIP>
}

You can use it like

msgCh, _, errCh := cc.FilterSomethingHappenedEvent(0, -1)

for {
	select {
	case err := <-errCh:
		panic(err)
	case msg := <-msgCh:
		if msg == nil {
			break
		}

		spew.Dump("message", msg)

	}
}

To get

(*main.SomethingHappenedEvent)(0xc0000b84b0)({
 Log: (*seth.Log)(0xc0000ca258)(<SNIP>),
 Uint16Val: (uint16) 321,
 AddressVal: (seth.Address) (len=20 cap=20) 0x84ede7c61cbff3056d6deb24ff774b79c1d2c4e4,
 StringVal: (string) (len=14) "something else",
 BytesVal: ([]uint8) (len=7 cap=7) {
  00000000  67 6f 6f 64 62 79 65                              |goodbye|
 }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants