Skip to content

Commit

Permalink
fix: fill Updated in legacy query ContractHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
loloicci committed Aug 7, 2023
1 parent 3464f84 commit 1c86503
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 0 additions & 4 deletions x/wasm/keeper/legacy_querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ func queryCodeList(ctx sdk.Context, keeper types.ViewKeeper) ([]types.CodeInfoRe
//nolint:unparam
func queryContractHistory(ctx sdk.Context, contractAddr sdk.AccAddress, keeper types.ViewKeeper) ([]types.ContractCodeHistoryEntry, error) {
history := keeper.GetContractHistory(ctx, contractAddr)
// redact response
for i := range history {
history[i].Updated = nil
}
return history, nil
}

Expand Down
14 changes: 9 additions & 5 deletions x/wasm/keeper/legacy_querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,43 +233,47 @@ func TestLegacyQueryContractHistory(t *testing.T) {
srcHistory: []types.ContractCodeHistoryEntry{{
Operation: types.ContractCodeHistoryOperationTypeGenesis,
CodeID: firstCodeID,
Updated: types.NewAbsoluteTxPosition(ctx),
Updated: &types.AbsoluteTxPosition{BlockHeight: 1, TxIndex: 2},
Msg: []byte(`"init message"`),
}},
expContent: []types.ContractCodeHistoryEntry{{
Operation: types.ContractCodeHistoryOperationTypeGenesis,
CodeID: firstCodeID,
Updated: &types.AbsoluteTxPosition{BlockHeight: 1, TxIndex: 2},
Msg: []byte(`"init message"`),
}},
},
"response with multiple entries": {
srcHistory: []types.ContractCodeHistoryEntry{{
Operation: types.ContractCodeHistoryOperationTypeInit,
CodeID: firstCodeID,
Updated: types.NewAbsoluteTxPosition(ctx),
Updated: &types.AbsoluteTxPosition{BlockHeight: 1, TxIndex: 2},
Msg: []byte(`"init message"`),
}, {
Operation: types.ContractCodeHistoryOperationTypeMigrate,
CodeID: 2,
Updated: types.NewAbsoluteTxPosition(ctx),
Updated: &types.AbsoluteTxPosition{BlockHeight: 3, TxIndex: 4},
Msg: []byte(`"migrate message 1"`),
}, {
Operation: types.ContractCodeHistoryOperationTypeMigrate,
CodeID: 3,
Updated: types.NewAbsoluteTxPosition(ctx),
Updated: &types.AbsoluteTxPosition{BlockHeight: 5, TxIndex: 6},
Msg: []byte(`"migrate message 2"`),
}},
expContent: []types.ContractCodeHistoryEntry{{
Operation: types.ContractCodeHistoryOperationTypeInit,
CodeID: firstCodeID,
Updated: &types.AbsoluteTxPosition{BlockHeight: 1, TxIndex: 2},
Msg: []byte(`"init message"`),
}, {
Operation: types.ContractCodeHistoryOperationTypeMigrate,
CodeID: 2,
Updated: &types.AbsoluteTxPosition{BlockHeight: 3, TxIndex: 4},
Msg: []byte(`"migrate message 1"`),
}, {
Operation: types.ContractCodeHistoryOperationTypeMigrate,
CodeID: 3,
Updated: &types.AbsoluteTxPosition{BlockHeight: 5, TxIndex: 6},
Msg: []byte(`"migrate message 2"`),
}},
},
Expand All @@ -278,7 +282,7 @@ func TestLegacyQueryContractHistory(t *testing.T) {
srcHistory: []types.ContractCodeHistoryEntry{{
Operation: types.ContractCodeHistoryOperationTypeGenesis,
CodeID: firstCodeID,
Updated: types.NewAbsoluteTxPosition(ctx),
Updated: &types.AbsoluteTxPosition{BlockHeight: 1, TxIndex: 2},
Msg: []byte(`"init message"`),
}},
expContent: []types.ContractCodeHistoryEntry{},
Expand Down

0 comments on commit 1c86503

Please sign in to comment.