Skip to content

Commit

Permalink
Merge pull request #1076 from scrtlabs/lior-fix-contract-hash
Browse files Browse the repository at this point in the history
Fix contract-hash command in cli
  • Loading branch information
assafmo authored Aug 23, 2022
2 parents f56577d + bec9318 commit eccf551
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions x/compute/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ func GetCmdCodeHashByContract() *cobra.Command {
return fmt.Errorf("error querying contract hash: %s", err)
}

addr := hex.EncodeToString(res)
fmt.Printf("0x%s", addr)
if len(res) == 0 {
return fmt.Errorf("contract with address %s not found", args[0])
}

codeHash := hex.EncodeToString(res)
fmt.Printf("0x%s\n", codeHash)
return nil
},
}
Expand Down
4 changes: 4 additions & 0 deletions x/compute/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,5 +406,9 @@ func GetCodeHashByContractAddr(cliCtx client.Context, contractAddr sdk.AccAddres
return nil, err
}

if len(res) == 0 {
return nil, fmt.Errorf("contract with address %s not found", contractAddr.String())
}

return []byte(hex.EncodeToString(res)), nil
}

0 comments on commit eccf551

Please sign in to comment.