From 1b88f0d1ac94a340c4501e0fda5e15609613a791 Mon Sep 17 00:00:00 2001 From: 170210 <85928898+170210@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:57:48 +0900 Subject: [PATCH] fix: fill ContractInfo result's Updated field (#89) * fix: fill Updated in queryContractInfo result Signed-off-by: 170210 * chore: add this PR to CHANGELOG Signed-off-by: 170210 --------- Signed-off-by: 170210 --- CHANGELOG.md | 1 + x/wasm/client/testutil/query.go | 4 +++- x/wasm/keeper/querier.go | 2 -- x/wasm/keeper/querier_test.go | 12 ++++-------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d74ae50ec1..eb930cf811 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ ### Bug Fixes * [\#62](https://github.com/Finschia/wasmd/pull/62) fill ContractHistory querier result's Updated field * [\#52](https://github.com/Finschia/wasmd/pull/52) fix cli_test error of wasmplus and add cli_test ci +* [\#89](https://github.com/Finschia/wasmd/pull/89) fill ContractInfo querier result's Updated field ### Breaking Changes diff --git a/x/wasm/client/testutil/query.go b/x/wasm/client/testutil/query.go index 7953c88cf3..166244e22f 100644 --- a/x/wasm/client/testutil/query.go +++ b/x/wasm/client/testutil/query.go @@ -140,6 +140,8 @@ func (s *IntegrationTestSuite) TestGetCmdGetContractInfo() { codeID, err := strconv.ParseUint(s.codeID, 10, 64) s.Require().NoError(err) + s.Require().True(s.setupHeight > 0) + codeUpdateHeight := uint64(s.setupHeight) testCases := map[string]struct { args []string @@ -158,7 +160,7 @@ func (s *IntegrationTestSuite) TestGetCmdGetContractInfo() { Creator: val.Address.String(), Admin: val.Address.String(), Label: "TestContract", - Created: nil, + Created: &types.AbsoluteTxPosition{BlockHeight: codeUpdateHeight, TxIndex: 0}, IBCPortID: "", Extension: nil, }, diff --git a/x/wasm/keeper/querier.go b/x/wasm/keeper/querier.go index e02d91ca3f..5c84ae297d 100644 --- a/x/wasm/keeper/querier.go +++ b/x/wasm/keeper/querier.go @@ -256,8 +256,6 @@ func queryContractInfo(ctx sdk.Context, addr sdk.AccAddress, keeper types.ViewKe if info == nil { return nil, types.ErrNotFound } - // redact the Created field (just used for sorting, not part of public API) - info.Created = nil return &types.QueryContractInfoResponse{ Address: addr.String(), ContractInfo: *info, diff --git a/x/wasm/keeper/querier_test.go b/x/wasm/keeper/querier_test.go index f30303ff76..96fb6300a6 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -856,20 +856,16 @@ func TestQueryContractInfo(t *testing.T) { src: &types.QueryContractInfoRequest{Address: contractAddr.String()}, stored: types.ContractInfoFixture(), expRsp: &types.QueryContractInfoResponse{ - Address: contractAddr.String(), - ContractInfo: types.ContractInfoFixture(func(info *types.ContractInfo) { - info.Created = nil // not returned on queries - }), + Address: contractAddr.String(), + ContractInfo: types.ContractInfoFixture(), }, }, "with extension": { src: &types.QueryContractInfoRequest{Address: contractAddr.String()}, stored: types.ContractInfoFixture(myExtension), expRsp: &types.QueryContractInfoResponse{ - Address: contractAddr.String(), - ContractInfo: types.ContractInfoFixture(myExtension, func(info *types.ContractInfo) { - info.Created = nil // not returned on queries - }), + Address: contractAddr.String(), + ContractInfo: types.ContractInfoFixture(myExtension), }, }, "not found": {