Skip to content

Commit

Permalink
Merge pull request #18 from moonstream-to/hardhat
Browse files Browse the repository at this point in the history
Added "--hardhat" argument to "seer evm generate"
  • Loading branch information
zomglings authored Mar 11, 2024
2 parents 4411d20 + dccc2ba commit 2207c57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func CreateEVMCommand() *cobra.Command {

func CreateEVMGenerateCommand() *cobra.Command {
var cli, noformat, includemain bool
var infile, packageName, structName, bytecodefile, outfile, foundryBuildFile string
var infile, packageName, structName, bytecodefile, outfile, foundryBuildFile, hardhatBuildFile string
var rawABI, bytecode []byte
var readErr error
var aliases map[string]string
Expand Down Expand Up @@ -263,6 +263,22 @@ func CreateEVMGenerateCommand() *cobra.Command {
readErr = json.Unmarshal(contents, &artifact)
rawABI = []byte(artifact.ABI)
bytecode = []byte(artifact.Bytecode.Object)
} else if hardhatBuildFile != "" {
var contents []byte
contents, readErr = os.ReadFile(hardhatBuildFile)
if readErr != nil {
return readErr
}

type hardhatBuildArtifact struct {
ABI json.RawMessage `json:"abi"`
Bytecode string `json:"bytecode"`
}

var artifact hardhatBuildArtifact
readErr = json.Unmarshal(contents, &artifact)
rawABI = []byte(artifact.ABI)
bytecode = []byte(artifact.Bytecode)
} else if infile != "" {
rawABI, readErr = os.ReadFile(infile)
} else {
Expand Down Expand Up @@ -316,8 +332,9 @@ func CreateEVMGenerateCommand() *cobra.Command {
evmGenerateCmd.Flags().BoolVar(&noformat, "noformat", false, "Set this flag if you do not want the generated code to be formatted (useful to debug errors)")
evmGenerateCmd.Flags().BoolVar(&includemain, "includemain", false, "Set this flag if you want to generate a \"main\" function to execute the CLI and make the generated code self-contained - this option is ignored if --cli is not set")
evmGenerateCmd.Flags().StringVarP(&outfile, "output", "o", "", "Path to output file (default stdout)")
evmGenerateCmd.Flags().StringVar(&foundryBuildFile, "foundry", "", "If your contract is compiled using Foundry, you can specify a path to the build file here (typically \"<foundry project root>/out/<solidit filename>/<contract name>.json\") instead of specifying --abi and --bytecode separately")
evmGenerateCmd.Flags().StringToStringVar(&aliases, "alias", nil, "A map of identifier aliaes (e.g. --alias name=somename)")
evmGenerateCmd.Flags().StringVar(&foundryBuildFile, "foundry", "", "If your contract is compiled using Foundry, you can specify a path to the build file here (typically \"<foundry project root>/out/<solidity filename>/<contract name>.json\") instead of specifying --abi and --bytecode separately")
evmGenerateCmd.Flags().StringVar(&hardhatBuildFile, "hardhat", "", "If your contract is compiled using Hardhat, you can specify a path to the build file here (typically \"<path to solidity file in hardhat artifact directory>/<contract name>.json\") instead of specifying --abi and --bytecode separately")
evmGenerateCmd.Flags().StringToStringVar(&aliases, "alias", nil, "A map of identifier aliases (e.g. --alias name=somename)")

return evmGenerateCmd
}
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package version

var SeerVersion string = "0.1.2"
var SeerVersion string = "0.1.3"

0 comments on commit 2207c57

Please sign in to comment.