Skip to content

Commit

Permalink
Merge pull request #456 from 0xPolygon/cmd/wrapcontract
Browse files Browse the repository at this point in the history
Fix wrap-contract when reading content from file
  • Loading branch information
xavier-romero authored Dec 12, 2024
2 parents 6a988dd + 65c9506 commit adfb6d1
Showing 1 changed file with 13 additions and 10 deletions.
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

0 comments on commit adfb6d1

Please sign in to comment.