good morning!!!!

Skip to content
Snippets Groups Projects
Commit 1105aa55 authored by Garet Halliday's avatar Garet Halliday
Browse files

get events as well

parent 8b19d10a
Branches
Tags
No related merge requests found
Pipeline #22290 passed
...@@ -38,14 +38,20 @@ func FromSolidity(src string) []*Entry { ...@@ -38,14 +38,20 @@ func FromSolidity(src string) []*Entry {
var entries []*Entry var entries []*Entry
for { for {
idx := strings.Index(src, "function") eventIdx := strings.Index(src, "event")
functionIdx := strings.Index(src, "function")
idx := eventIdx
if idx == -1 || (functionIdx != -1 && functionIdx < idx) {
idx = functionIdx
}
if idx == -1 { if idx == -1 {
break break
} }
// try to read signature // try to read signature
sig, ok := Normalize(src[idx:]) sig, ok := Normalize(src[idx:])
src = src[idx+len("function"):] src = src[idx+5:]
if !ok { if !ok {
continue continue
} }
......
...@@ -294,8 +294,16 @@ var Arguments = p.Func( ...@@ -294,8 +294,16 @@ var Arguments = p.Func(
if ok { if ok {
types = append(types, typ) types = append(types, typ)
// optional name // optional indexed or location
p.Try(ctx, Whitespaces)
p.String(ctx, "indexed")
p.String(ctx, "memory")
p.String(ctx, "storage")
p.String(ctx, "calldata")
p.Try(ctx, Whitespaces) p.Try(ctx, Whitespaces)
// optional name
p.Try(ctx, Identifier) p.Try(ctx, Identifier)
p.Try(ctx, Whitespaces) p.Try(ctx, Whitespaces)
...@@ -319,8 +327,9 @@ var Arguments = p.Func( ...@@ -319,8 +327,9 @@ var Arguments = p.Func(
var Signature = p.Func( var Signature = p.Func(
func(ctx *p.Context) (p.Signature, bool) { func(ctx *p.Context) (p.Signature, bool) {
// optional "function" at the beginning // optional "function" or "event" at the beginning
p.String(ctx, "function") p.String(ctx, "function")
p.String(ctx, "event")
p.Try(ctx, Whitespaces) p.Try(ctx, Whitespaces)
......
...@@ -41,6 +41,6 @@ func TestNormalizing(t *testing.T) { ...@@ -41,6 +41,6 @@ func TestNormalizing(t *testing.T) {
} }
func TestParser(t *testing.T) { func TestParser(t *testing.T) {
v, ok := parse("setDeposit(address,bytes32,((address,address,address,address,address,address,address[],address[]),(uint256,uint256,uint256,uint256,uint256,uint256),(bool)))") v, ok := parse("event Deposit(address indexed _from, uint256 _value)")
log.Println(v.String(), ok) log.Println(v.String(), ok)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment