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 contract-hash command in cli #1076

Merged
merged 4 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions x/compute/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,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
}