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

Add ContractInfoResponse.Checksum #376

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions types/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,11 @@ type ContractInfoQuery struct {
}

type ContractInfoResponse struct {
CodeID uint64 `json:"code_id"`
Creator string `json:"creator"`
CodeID uint64 `json:"code_id"`
// Checksum is the checksum of the Wasm blob behind this code ID.
// This field was newly added in CosmWasm XX.YY.
Checksum string `json:"checksum,omitempty"`
Creator string `json:"creator"`
// Set to the admin who can migrate contract, if any
Admin string `json:"admin,omitempty"`
Pinned bool `json:"pinned"`
Expand Down
36 changes: 36 additions & 0 deletions types/queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,39 @@ func TestQueryResponseWithEmptyData(t *testing.T) {
})
}
}

func TestContractInfoResponse(t *testing.T) {
// No checksum
info := ContractInfoResponse{
CodeID: 3456,
Creator: "tgrade1js7ezrm55fqgxu3p62d9xn6patjku2z7ne5dvg",
Admin: "tgrade1z363ulwcrxged4z5jswyt5dn5v3lzsemwz9ewj",
Pinned: false,
IBCPort: "wasm.abcdef",
}
bz, err := json.Marshal(&info)
t.Logf("Serialized: %s", string(bz))
require.NoError(t, err)

var deserialized ContractInfoResponse
err = json.Unmarshal(bz, &deserialized)
require.NoError(t, err)
assert.Equal(t, deserialized, info)

// Checksum set
info = ContractInfoResponse{
CodeID: 3456,
Checksum: "75b6183689b80a229ea27994a7c8cd9c17ddd29e947998f2734abda825eac3c0",
Creator: "tgrade1js7ezrm55fqgxu3p62d9xn6patjku2z7ne5dvg",
Admin: "tgrade1z363ulwcrxged4z5jswyt5dn5v3lzsemwz9ewj",
Pinned: false,
IBCPort: "wasm.abcdef",
}
bz, err = json.Marshal(&info)
t.Logf("Serialized: %s", string(bz))
require.NoError(t, err)

err = json.Unmarshal(bz, &deserialized)
require.NoError(t, err)
assert.Equal(t, deserialized, info)
}