Skip to content

Commit adfb6d1

Browse files
Merge pull request #456 from 0xPolygon/cmd/wrapcontract
Fix wrap-contract when reading content from file
2 parents 6a988dd + 65c9506 commit adfb6d1

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

cmd/wrapcontract/wrapcontract.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,24 @@ func init() {
5252

5353
func getInputData(args []string) (string, error) {
5454
var deployedBytecode string
55+
var deployedBytecodeOrFile string
56+
5557
if len(args) == 0 {
56-
deployedBytecodeBytes, err := io.ReadAll(os.Stdin)
58+
deployedBytecodeOrFileBytes, err := io.ReadAll(os.Stdin)
5759
if err != nil {
5860
return "", err
5961
}
60-
deployedBytecode = string(deployedBytecodeBytes)
62+
deployedBytecodeOrFile = string(deployedBytecodeOrFileBytes)
6163
} else {
62-
deployedBytecodeOrFile := args[0]
63-
// Try to open the param as a file, otherwise treat it as bytecode
64-
deployedBytecodeBytes, err := os.ReadFile(deployedBytecodeOrFile)
65-
if err != nil {
66-
deployedBytecode = deployedBytecodeOrFile
67-
} else {
68-
deployedBytecode = string(deployedBytecodeBytes)
69-
}
64+
deployedBytecodeOrFile = args[0]
65+
}
66+
// Try to open the param as a file, otherwise treat it as bytecode
67+
deployedBytecodeOrFile = strings.TrimSpace(deployedBytecodeOrFile)
68+
deployedBytecodeBytes, err := os.ReadFile(deployedBytecodeOrFile)
69+
if err != nil {
70+
deployedBytecode = deployedBytecodeOrFile
71+
} else {
72+
deployedBytecode = string(deployedBytecodeBytes)
7073
}
7174

7275
return strings.TrimSpace(deployedBytecode), nil

0 commit comments

Comments
 (0)