Skip to content

Commit

Permalink
Add --contract, only translate the specified contract
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp committed Jan 15, 2024
1 parent 3cc6dfc commit edc3abf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/abigen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ var (
Name: "alias",
Usage: "Comma separated aliases for function and event renaming, e.g. original1=alias1, original2=alias2",
}
contractFlag = &cli.StringFlag{
Name: "contract",
Usage: "Name of the contract to generate the bindings for",
}
)

var app = flags.NewApp("Ethereum ABI wrapper code generator")
Expand All @@ -88,6 +92,7 @@ func init() {
outFlag,
langFlag,
aliasFlag,
contractFlag,
}
app.Action = abigen
}
Expand Down Expand Up @@ -186,6 +191,10 @@ func abigen(c *cli.Context) error {
fmt.Fprintf(os.Stderr, "excluding: %v\n", name)
continue
}
// If a contract name is provided then ignore all other contracts
if c.IsSet(contractFlag.Name) && c.String(contractFlag.Name) != typeName {
continue
}
abi, err := json.Marshal(contract.Info.AbiDefinition) // Flatten the compiler parse
if err != nil {
utils.Fatalf("Failed to parse ABIs from compiler output: %v", err)
Expand Down

0 comments on commit edc3abf

Please sign in to comment.