Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrap-contract when reading content from file #456

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions cmd/wrapcontract/wrapcontract.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,24 @@ func init() {

func getInputData(args []string) (string, error) {
var deployedBytecode string
var deployedBytecodeOrFile string

if len(args) == 0 {
deployedBytecodeBytes, err := io.ReadAll(os.Stdin)
deployedBytecodeOrFileBytes, err := io.ReadAll(os.Stdin)
if err != nil {
return "", err
}
deployedBytecode = string(deployedBytecodeBytes)
deployedBytecodeOrFile = string(deployedBytecodeOrFileBytes)
} else {
deployedBytecodeOrFile := args[0]
// Try to open the param as a file, otherwise treat it as bytecode
deployedBytecodeBytes, err := os.ReadFile(deployedBytecodeOrFile)
if err != nil {
deployedBytecode = deployedBytecodeOrFile
} else {
deployedBytecode = string(deployedBytecodeBytes)
}
deployedBytecodeOrFile = args[0]
}
// Try to open the param as a file, otherwise treat it as bytecode
deployedBytecodeOrFile = strings.TrimSpace(deployedBytecodeOrFile)
deployedBytecodeBytes, err := os.ReadFile(deployedBytecodeOrFile)
if err != nil {
deployedBytecode = deployedBytecodeOrFile
} else {
deployedBytecode = string(deployedBytecodeBytes)
}

return strings.TrimSpace(deployedBytecode), nil
Expand Down
Loading