-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from rarimo/feature/listener
Rootupdater module
- Loading branch information
Showing
48 changed files
with
4,839 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"github.com/ethereum/go-ethereum/accounts/abi" | ||
ethtypes "github.com/ethereum/go-ethereum/core/types" | ||
) | ||
|
||
// unpackLog copy-pasted from logic in generated s-c bindings. | ||
func UnpackLog(contractAbi abi.ABI, out interface{}, event string, log *ethtypes.Log) error { | ||
if log.Topics[0] != contractAbi.Events[event].ID { | ||
return fmt.Errorf("event signature mismatch") | ||
} | ||
|
||
if len(log.Data) > 0 { | ||
if err := contractAbi.UnpackIntoInterface(out, event, log.Data); err != nil { | ||
return err | ||
} | ||
} | ||
var indexed abi.Arguments | ||
for _, arg := range contractAbi.Events[event].Inputs { | ||
if arg.Indexed { | ||
indexed = append(indexed, arg) | ||
} | ||
} | ||
return abi.ParseTopics(out, indexed, log.Topics[1:]) | ||
} |
Oops, something went wrong.