Skip to content

Commit 8048c56

Browse files
authored
refactor: replace interface{} with any for clarity and modernization (#2402)
Signed-off-by: black5box <[email protected]>
1 parent e4c9d66 commit 8048c56

File tree

17 files changed

+36
-36
lines changed

17 files changed

+36
-36
lines changed

app/sim_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func TestAppStateDeterminism(t *testing.T) {
311311

312312
appOptions := viper.New()
313313
if FlagEnableStreamingValue {
314-
m := make(map[string]interface{})
314+
m := make(map[string]any)
315315
m["streaming.abci.keys"] = []string{"*"}
316316
m["streaming.abci.plugin"] = "abci_v1"
317317
m["streaming.abci.stop-node-on-err"] = true

cmd/wasmd/commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func initCometBFTConfig() *cmtcfg.Config {
5454

5555
// initAppConfig helps to override default appConfig template and configs.
5656
// return "", nil if no custom configuration is required for the application.
57-
func initAppConfig() (string, interface{}) {
57+
func initAppConfig() (string, any) {
5858
// The following code snippet is just for reference.
5959

6060
type CustomAppConfig struct {

tests/integration/common_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ func must[t any](s t, err error) t {
5757
return s
5858
}
5959

60-
func mustUnmarshal(t *testing.T, data []byte, res interface{}) {
60+
func mustUnmarshal(t *testing.T, data []byte, res any) {
6161
t.Helper()
6262
err := json.Unmarshal(data, res)
6363
require.NoError(t, err)
6464
}
6565

66-
func mustMarshal(t *testing.T, r interface{}) []byte {
66+
func mustMarshal(t *testing.T, r any) []byte {
6767
t.Helper()
6868
bz, err := json.Marshal(r)
6969
require.NoError(t, err)

tests/integration/module_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ func TestHandleExecuteEscrow(t *testing.T) {
409409
require.NoError(t, err)
410410

411411
bob := keyPubAddr()
412-
initMsg := map[string]interface{}{
412+
initMsg := map[string]any{
413413
"verifier": fred.String(),
414414
"beneficiary": bob.String(),
415415
}
@@ -429,8 +429,8 @@ func TestHandleExecuteEscrow(t *testing.T) {
429429
contractBech32Addr := parseInitResponse(t, res.Data)
430430
require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", contractBech32Addr)
431431

432-
handleMsg := map[string]interface{}{
433-
"release": map[string]interface{}{},
432+
handleMsg := map[string]any{
433+
"release": map[string]any{},
434434
}
435435
handleMsgBz, err := json.Marshal(handleMsg)
436436
require.NoError(t, err)
@@ -533,9 +533,9 @@ func TestReadNodeConfig(t *testing.T) {
533533
}
534534
}
535535

536-
type AppOptionsMock map[string]interface{}
536+
type AppOptionsMock map[string]any
537537

538-
func (a AppOptionsMock) Get(s string) interface{} {
538+
func (a AppOptionsMock) Get(s string) any {
539539
return a[s]
540540
}
541541

tests/wasmibctesting/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func (chain *WasmTestChain) SendNonDefaultSenderMsgs(senderPrivKey cryptotypes.P
244244
// SmartQuery This will serialize the query message and submit it to the contract.
245245
// The response is parsed into the provided interface.
246246
// Usage: SmartQuery(addr, QueryMsg{Foo: 1}, &response)
247-
func (chain *WasmTestChain) SmartQuery(contractAddr string, queryMsg, response interface{}) error {
247+
func (chain *WasmTestChain) SmartQuery(contractAddr string, queryMsg, response any) error {
248248
msg, err := json.Marshal(queryMsg)
249249
if err != nil {
250250
return err

x/wasm/keeper/ante_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestLimitSimulationGasDecorator(t *testing.T) {
120120
consumeGas storetypes.Gas
121121
maxBlockGas int64
122122
simulation bool
123-
expErr interface{}
123+
expErr any
124124
}{
125125
"custom limit set": {
126126
customLimit: &hundred,

x/wasm/keeper/handler_plugin_encoders.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ func EncodeGovMsg(sender sdk.AccAddress, msg *wasmvmtypes.GovMsg) ([]sdk.Msg, er
397397
}
398398
}
399399

400-
func convertVoteOption(s interface{}) (v1.VoteOption, error) {
400+
func convertVoteOption(s any) (v1.VoteOption, error) {
401401
var option v1.VoteOption
402402
switch s {
403403
case wasmvmtypes.Yes:

x/wasm/keeper/keeper_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ func TestMigrateWithDispatchedMessage(t *testing.T) {
15261526
ctx = ctx.WithEventManager(sdk.NewEventManager()).WithBlockHeight(ctx.BlockHeight() + 1)
15271527
_, err = keeper.Migrate(ctx, contractAddr, fred, burnerContractID, migMsgBz)
15281528
require.NoError(t, err)
1529-
type dict map[string]interface{}
1529+
type dict map[string]any
15301530
expEvents := []dict{
15311531
{
15321532
"Type": "migrate",
@@ -1746,7 +1746,7 @@ func prettyEvents(t *testing.T, events sdk.Events) string {
17461746
return string(mustMarshal(t, r))
17471747
}
17481748

1749-
func mustMarshal(t *testing.T, r interface{}) []byte {
1749+
func mustMarshal(t *testing.T, r any) []byte {
17501750
t.Helper()
17511751
bz, err := json.Marshal(r)
17521752
require.NoError(t, err)

x/wasm/keeper/reflect_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
ReflectCapabilities = []string{"staking", "mask", "stargate", "cosmwasm_1_1", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "cosmwasm_2_0"}
3030
)
3131

32-
func mustUnmarshal(t *testing.T, data []byte, res interface{}) {
32+
func mustUnmarshal(t *testing.T, data []byte, res any) {
3333
t.Helper()
3434
err := json.Unmarshal(data, res)
3535
require.NoError(t, err)

x/wasm/keeper/test_fuzz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/CosmWasm/wasmd/x/wasm/types"
1212
)
1313

14-
var ModelFuzzers = []interface{}{FuzzAddr, FuzzAddrString, FuzzAbsoluteTxPosition, FuzzContractInfo, FuzzStateModel, FuzzAccessType, FuzzAccessConfig, FuzzContractCodeHistory}
14+
var ModelFuzzers = []any{FuzzAddr, FuzzAddrString, FuzzAbsoluteTxPosition, FuzzContractInfo, FuzzStateModel, FuzzAccessType, FuzzAccessConfig, FuzzContractCodeHistory}
1515

1616
func FuzzAddr(m *sdk.AccAddress, c fuzz.Continue) {
1717
*m = make([]byte, 20)

0 commit comments

Comments
 (0)