From 0d829219363424249d43eef813b34696ea8529d3 Mon Sep 17 00:00:00 2001 From: 170210 <85928898+170210@users.noreply.github.com> Date: Tue, 22 Aug 2023 17:47:25 +0900 Subject: [PATCH] fix: cherry-pick fill ContractInfo result's Updated field (#89) (#93) * 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 * chore: fix 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 5ecf2e7bd3..559a6fb0b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Bug Fixes * [\#85](https://github.com/Finschia/wasmd/pull/85) cherry-pick fill ContractHistory querier result's Updated field (#62) * [\#52](https://github.com/Finschia/wasmd/pull/52) fix cli_test error of wasmplus and add cli_test ci +* [\#93](https://github.com/Finschia/wasmd/pull/93) cherry-pick fill ContractInfo querier result's Updated field (#89) ### 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 e2b4bb9f88..4f92b4fe65 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -619,20 +619,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": {