-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a different lib for abi parsing + add more methods
- Loading branch information
Showing
7 changed files
with
126 additions
and
62 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
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
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,37 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/hex" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"regexp" | ||
|
||
"github.com/ethereum/go-ethereum/crypto" | ||
) | ||
|
||
func main() { | ||
// read the console.sol Solidity file from input args | ||
console, err := os.ReadFile(os.Args[1]) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
rxp := regexp.MustCompile("abi.encodeWithSignature\\(\"log(.*)\"") | ||
matches := rxp.FindAllStringSubmatch(string(console), -1) | ||
|
||
methodMap := map[string]string{} | ||
for _, match := range matches { | ||
signature := match[1] | ||
|
||
// signature of the call. Use the version without the bytes in 'uint'. | ||
sig := crypto.Keccak256([]byte("log" + match[1]))[:4] | ||
methodMap["log"+signature] = hex.EncodeToString(sig) | ||
} | ||
|
||
raw, err := json.MarshalIndent(methodMap, "", "\t") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(string(raw)) | ||
} |