From 49ed6f097203d0bdefc0e025e0af5305f48c3935 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 20 Mar 2023 15:06:58 +0700 Subject: [PATCH] faddat/re merge main (#1274) undefined --- .golangci.yml | 9 +++--- benchmarks/bench_test.go | 2 +- x/wasm/alias.go | 2 +- x/wasm/client/cli/new_tx.go | 1 + x/wasm/genesis_test.go | 2 +- x/wasm/ibctesting/chain.go | 18 ++++++------ x/wasm/ibctesting/coordinator.go | 12 +++----- x/wasm/ibctesting/path.go | 14 ++++------ x/wasm/keeper/ante_test.go | 2 +- x/wasm/keeper/handler_plugin_encoders.go | 6 ++-- x/wasm/keeper/ibc.go | 4 +-- x/wasm/keeper/keeper.go | 2 +- x/wasm/keeper/keeper_test.go | 22 +++++++-------- x/wasm/keeper/proposal_handler.go | 6 ++-- x/wasm/keeper/proposal_integration_test.go | 3 +- x/wasm/keeper/querier.go | 30 ++++++++++---------- x/wasm/keeper/querier_test.go | 4 +-- x/wasm/keeper/recurse_test.go | 10 +++---- x/wasm/keeper/reflect_test.go | 17 ++++++------ x/wasm/keeper/snapshotter.go | 2 +- x/wasm/keeper/staking_test.go | 2 +- x/wasm/keeper/submsg_test.go | 12 ++++---- x/wasm/keeper/test_common.go | 18 ++++++------ x/wasm/keeper/wasmtesting/gas_register.go | 2 +- x/wasm/module.go | 12 ++++---- x/wasm/module_test.go | 23 ++++++++-------- x/wasm/relay_pingpong_test.go | 16 +++++------ x/wasm/relay_test.go | 32 +++++++++++----------- x/wasm/simulation/proposals.go | 6 ++-- x/wasm/types/authz.go | 8 +++--- x/wasm/types/types.go | 4 +-- x/wasm/types/types_test.go | 10 ++++--- 32 files changed, 151 insertions(+), 162 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 21c604ffcc..6e12132bc5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -54,11 +54,10 @@ issues: max-same-issues: 10000 linters-settings: - dogsled: - max-blank-identifiers: 3 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true + revive: + # When set to false, ignores files with "GENERATED" header, similar to golint + ignore-generated-header: true + nolintlint: allow-unused: false allow-leading-space: true diff --git a/benchmarks/bench_test.go b/benchmarks/bench_test.go index c953c92195..c917e91d20 100644 --- a/benchmarks/bench_test.go +++ b/benchmarks/bench_test.go @@ -158,7 +158,7 @@ func buildTxFromMsg(builder func(info *AppInfo) ([]sdk.Msg, error)) func(b *test } } -func buildMemDB(b *testing.B) dbm.DB { +func buildMemDB(_ *testing.B) dbm.DB { return dbm.NewMemDB() } diff --git a/x/wasm/alias.go b/x/wasm/alias.go index 214fa03506..83480ab4dd 100644 --- a/x/wasm/alias.go +++ b/x/wasm/alias.go @@ -114,7 +114,7 @@ type ( BankEncoder = keeper.BankEncoder CustomEncoder = keeper.CustomEncoder StakingEncoder = keeper.StakingEncoder - WasmEncoder = keeper.WasmEncoder //nolint:revive + WasmEncoder = keeper.WasmEncoder MessageEncoders = keeper.MessageEncoders Keeper = keeper.Keeper QueryHandler = keeper.QueryHandler diff --git a/x/wasm/client/cli/new_tx.go b/x/wasm/client/cli/new_tx.go index 1e10552d45..a3d61466ac 100644 --- a/x/wasm/client/cli/new_tx.go +++ b/x/wasm/client/cli/new_tx.go @@ -72,6 +72,7 @@ func UpdateContractAdminCmd() *cobra.Command { } msg := parseUpdateContractAdminArgs(args, clientCtx) + if err := msg.ValidateBasic(); err != nil { return err } diff --git a/x/wasm/genesis_test.go b/x/wasm/genesis_test.go index 45afedaad9..83d5db2004 100644 --- a/x/wasm/genesis_test.go +++ b/x/wasm/genesis_test.go @@ -30,7 +30,7 @@ func TestInitGenesis(t *testing.T) { require.NoError(t, err) assertStoreCodeResponse(t, res.Data, 1) - _, _, bob := keyPubAddr() + bob := keyPubAddr() initMsg := initMsg{ Verifier: fred, Beneficiary: bob, diff --git a/x/wasm/ibctesting/chain.go b/x/wasm/ibctesting/chain.go index 0394860a61..0862de17fd 100644 --- a/x/wasm/ibctesting/chain.go +++ b/x/wasm/ibctesting/chain.go @@ -488,7 +488,7 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, AppHash: chain.CurrentHeader.AppHash, LastResultsHash: tmhash.Sum([]byte("last_results_hash")), EvidenceHash: tmhash.Sum([]byte("evidence_hash")), - ProposerAddress: tmValSet.Proposer.Address, //nolint:staticcheck + ProposerAddress: tmValSet.Proposer.Address, //nolint:staticcheck // SA5011: possible nil pointer dereference } hhash := tmHeader.Hash() @@ -550,11 +550,11 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope _, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.PortPath(portID)) if !ok { // create capability using the IBC capability keeper - cap, err := chain.App.ScopedIBCKeeper.NewCapability(chain.GetContext(), host.PortPath(portID)) + portCap, err := chain.App.ScopedIBCKeeper.NewCapability(chain.GetContext(), host.PortPath(portID)) require.NoError(chain.t, err) // claim capability using the scopedKeeper - err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, host.PortPath(portID)) + err = scopedKeeper.ClaimCapability(chain.GetContext(), portCap, host.PortPath(portID)) require.NoError(chain.t, err) } @@ -564,10 +564,10 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope // GetPortCapability returns the port capability for the given portID. The capability must // exist, otherwise testing will fail. func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability { - cap, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.PortPath(portID)) + portCap, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.PortPath(portID)) require.True(chain.t, ok) - return cap + return portCap } // CreateChannelCapability binds and claims a capability for the given portID and channelID @@ -578,9 +578,9 @@ func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.Sc // check if the portId is already binded, if not bind it _, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), capName) if !ok { - cap, err := chain.App.ScopedIBCKeeper.NewCapability(chain.GetContext(), capName) + portCap, err := chain.App.ScopedIBCKeeper.NewCapability(chain.GetContext(), capName) require.NoError(chain.t, err) - err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, capName) + err = scopedKeeper.ClaimCapability(chain.GetContext(), portCap, capName) require.NoError(chain.t, err) } @@ -590,10 +590,10 @@ func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.Sc // GetChannelCapability returns the channel capability for the given portID and channelID. // The capability must exist, otherwise testing will fail. func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability { - cap, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) + chanCap, ok := chain.App.ScopedIBCKeeper.GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) require.True(chain.t, ok) - return cap + return chanCap } // GetTimeoutHeight is a convenience function which returns a IBC packet timeout height diff --git a/x/wasm/ibctesting/coordinator.go b/x/wasm/ibctesting/coordinator.go index afdb933bf0..557db8305a 100644 --- a/x/wasm/ibctesting/coordinator.go +++ b/x/wasm/ibctesting/coordinator.go @@ -217,11 +217,9 @@ func (coord *Coordinator) ConnOpenInitOnBothChains(path *Path) error { return err } - if err := path.EndpointB.UpdateClient(); err != nil { - return err - } + err := path.EndpointB.UpdateClient() - return nil + return err } // ChanOpenInitOnBothChains initializes a channel on the source chain and counterparty chain @@ -242,11 +240,9 @@ func (coord *Coordinator) ChanOpenInitOnBothChains(path *Path) error { return err } - if err := path.EndpointB.UpdateClient(); err != nil { - return err - } + err := path.EndpointB.UpdateClient() - return nil + return err } // RelayAndAckPendingPackets sends pending packages from path.EndpointA to the counterparty chain and acks diff --git a/x/wasm/ibctesting/path.go b/x/wasm/ibctesting/path.go index 30d46778b2..c7f1af8f42 100644 --- a/x/wasm/ibctesting/path.go +++ b/x/wasm/ibctesting/path.go @@ -40,7 +40,7 @@ func (path *Path) SetChannelOrdered() { // RelayPacket attempts to relay the packet first on EndpointA and then on EndpointB // if EndpointA does not contain a packet commitment for that packet. An error is returned // if a relay step fails or the packet commitment does not exist on either endpoint. -func (path *Path) RelayPacket(packet channeltypes.Packet, ack []byte) error { +func (path *Path) RelayPacket(packet channeltypes.Packet, _ []byte) error { pc := path.EndpointA.Chain.App.IBCKeeper.ChannelKeeper.GetPacketCommitment(path.EndpointA.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointA.Chain.App.AppCodec(), packet)) { @@ -59,11 +59,9 @@ func (path *Path) RelayPacket(packet channeltypes.Packet, ack []byte) error { return err } - if err := path.EndpointA.AcknowledgePacket(packet, ack); err != nil { - return err - } + err = path.EndpointA.AcknowledgePacket(packet, ack) - return nil + return err } pc = path.EndpointB.Chain.App.IBCKeeper.ChannelKeeper.GetPacketCommitment(path.EndpointB.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) @@ -84,10 +82,8 @@ func (path *Path) RelayPacket(packet channeltypes.Packet, ack []byte) error { return err } - if err := path.EndpointB.AcknowledgePacket(packet, ack); err != nil { - return err - } - return nil + err = path.EndpointB.AcknowledgePacket(packet, ack) + return err } return fmt.Errorf("packet commitment does not exist on either endpoint for provided packet") diff --git a/x/wasm/keeper/ante_test.go b/x/wasm/keeper/ante_test.go index 90e7ae42fe..1ac746427c 100644 --- a/x/wasm/keeper/ante_test.go +++ b/x/wasm/keeper/ante_test.go @@ -113,7 +113,7 @@ func TestCountTxDecorator(t *testing.T) { func TestLimitSimulationGasDecorator(t *testing.T) { var ( hundred sdk.Gas = 100 - zero sdk.Gas = 0 //nolint:revive // leave the zero for clarity + zero sdk.Gas = 0 ) specs := map[string]struct { customLimit *sdk.Gas diff --git a/x/wasm/keeper/handler_plugin_encoders.go b/x/wasm/keeper/handler_plugin_encoders.go index 6ad1cedb49..f4545fca3f 100644 --- a/x/wasm/keeper/handler_plugin_encoders.go +++ b/x/wasm/keeper/handler_plugin_encoders.go @@ -127,7 +127,7 @@ func EncodeBankMsg(sender sdk.AccAddress, msg *wasmvmtypes.BankMsg) ([]sdk.Msg, return []sdk.Msg{&sdkMsg}, nil } -func NoCustomMsg(sender sdk.AccAddress, msg json.RawMessage) ([]sdk.Msg, error) { +func NoCustomMsg(_ sdk.AccAddress, _ json.RawMessage) ([]sdk.Msg, error) { return nil, errorsmod.Wrap(types.ErrUnknownMsg, "custom variant not supported") } @@ -194,12 +194,12 @@ func EncodeStakingMsg(sender sdk.AccAddress, msg *wasmvmtypes.StakingMsg) ([]sdk func EncodeStargateMsg(unpacker codectypes.AnyUnpacker) StargateEncoder { return func(sender sdk.AccAddress, msg *wasmvmtypes.StargateMsg) ([]sdk.Msg, error) { - any := codectypes.Any{ + codecAny := codectypes.Any{ TypeUrl: msg.TypeURL, Value: msg.Value, } var sdkMsg sdk.Msg - if err := unpacker.UnpackAny(&any, &sdkMsg); err != nil { + if err := unpacker.UnpackAny(&codecAny, &sdkMsg); err != nil { return nil, errorsmod.Wrap(types.ErrInvalidMsg, fmt.Sprintf("Cannot unpack proto message with type URL: %s", msg.TypeURL)) } if err := codectypes.UnpackInterfaces(sdkMsg, unpacker); err != nil { diff --git a/x/wasm/keeper/ibc.go b/x/wasm/keeper/ibc.go index faf06d5aa2..30eb34875a 100644 --- a/x/wasm/keeper/ibc.go +++ b/x/wasm/keeper/ibc.go @@ -15,8 +15,8 @@ import ( // returns a string name of the port or error if we cannot bind it. // this will fail if call twice. func (k Keeper) bindIbcPort(ctx sdk.Context, portID string) error { - cap := k.portKeeper.BindPort(ctx, portID) - return k.ClaimCapability(ctx, cap, host.PortPath(portID)) + portCap := k.portKeeper.BindPort(ctx, portID) + return k.ClaimCapability(ctx, portCap, host.PortPath(portID)) } // ensureIbcPort is like registerIbcPort, but it checks if we already hold the port diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index 5257933a49..ff0eb7625f 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -1100,7 +1100,7 @@ func moduleLogger(ctx sdk.Context) log.Logger { } // Querier creates a new grpc querier instance -func Querier(k *Keeper) *grpcQuerier { //nolint:revive +func Querier(k *Keeper) *GrpcQuerier { return NewGrpcQuerier(k.cdc, k.storeKey, k, k.queryGasLimit) } diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index c3046fd420..91413b2e2a 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -563,7 +563,6 @@ func TestInstantiateWithAccounts(t *testing.T) { senderAddr := DeterministicAccountAddress(t, 1) keepers.Faucet.Fund(parentCtx, senderAddr, sdk.NewInt64Coin("denom", 100000000)) - const myLabel = "testing" mySalt := []byte(`my salt`) contractAddr := BuildContractAddressPredictable(example.Checksum, senderAddr, mySalt, []byte{}) @@ -674,7 +673,7 @@ func TestInstantiateWithAccounts(t *testing.T) { } }() // when - gotAddr, _, gotErr := keepers.ContractKeeper.Instantiate2(ctx, 1, senderAddr, nil, initMsg, myLabel, spec.deposit, mySalt, false) + gotAddr, _, gotErr := keepers.ContractKeeper.Instantiate2(ctx, 1, senderAddr, nil, initMsg, myTestLabel, spec.deposit, mySalt, false) if spec.expErr != nil { assert.ErrorIs(t, gotErr, spec.expErr) return @@ -1000,7 +999,7 @@ func TestExecuteWithPanic(t *testing.T) { contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) - _, _, bob := keyPubAddr() + _, bob := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: fred, Beneficiary: bob, @@ -1032,7 +1031,7 @@ func TestExecuteWithCpuLoop(t *testing.T) { contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) - _, _, bob := keyPubAddr() + _, bob := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: fred, Beneficiary: bob, @@ -1063,6 +1062,7 @@ func TestExecuteWithCpuLoop(t *testing.T) { func TestExecuteWithStorageLoop(t *testing.T) { ctx, keepers := CreateTestInput(t, false, AvailableCapabilities) + keeper := keepers.ContractKeeper deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) @@ -1074,7 +1074,7 @@ func TestExecuteWithStorageLoop(t *testing.T) { contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) - _, _, bob := keyPubAddr() + _, bob := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: fred, Beneficiary: bob, @@ -1354,7 +1354,7 @@ func TestMigrateWithDispatchedMessage(t *testing.T) { require.NoError(t, err) require.NotEqual(t, originalContractID, burnerContractID) - _, _, myPayoutAddr := keyPubAddr() + _, myPayoutAddr := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: fred, Beneficiary: fred, @@ -1518,8 +1518,8 @@ func TestSudo(t *testing.T) { contractID, _, err := keeper.Create(ctx, creator, hackatomWasm, nil) require.NoError(t, err) - _, _, bob := keyPubAddr() - _, _, fred := keyPubAddr() + _, bob := keyPubAddr() + _, fred := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: fred, Beneficiary: bob, @@ -1531,7 +1531,7 @@ func TestSudo(t *testing.T) { require.Equal(t, "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", addr.String()) // the community is broke - _, _, community := keyPubAddr() + _, community := keyPubAddr() comAcct := accKeeper.GetAccount(ctx, community) require.Nil(t, comAcct) @@ -1604,7 +1604,7 @@ func TestUpdateContractAdmin(t *testing.T) { originalContractID, _, err := keeper.Create(parentCtx, creator, hackatomWasm, nil) require.NoError(t, err) - _, _, anyAddr := keyPubAddr() + _, anyAddr := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: fred, Beneficiary: anyAddr, @@ -1674,7 +1674,7 @@ func TestClearContractAdmin(t *testing.T) { originalContractID, _, err := keeper.Create(parentCtx, creator, hackatomWasm, nil) require.NoError(t, err) - _, _, anyAddr := keyPubAddr() + _, anyAddr := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: fred, Beneficiary: anyAddr, diff --git a/x/wasm/keeper/proposal_handler.go b/x/wasm/keeper/proposal_handler.go index 46d6b718cd..e47e973983 100644 --- a/x/wasm/keeper/proposal_handler.go +++ b/x/wasm/keeper/proposal_handler.go @@ -283,10 +283,8 @@ func handleClearAdminProposal(ctx sdk.Context, k types.ContractOpsKeeper, p type if err != nil { return errorsmod.Wrap(err, "contract") } - if err := k.ClearContractAdmin(ctx, contractAddr, nil); err != nil { - return err - } - return nil + err = k.ClearContractAdmin(ctx, contractAddr, nil) + return err } func handlePinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.PinCodesProposal) error { diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index 3e77954c02..ee560bf67f 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -488,6 +488,7 @@ func TestExecuteProposal(t *testing.T) { msgServer := govkeeper.NewMsgServerImpl(keepers.GovKeeper) _, err = submitLegacyProposal(t, ctx, badSrc, exampleContract.BeneficiaryAddr.String(), govAuthority, msgServer) require.Error(t, err) + // balance should not change bal = bankKeeper.GetBalance(ctx, contractAddr, "denom") require.Equal(t, bal.Amount, sdk.NewInt(100)) @@ -517,7 +518,7 @@ func TestSudoProposal(t *testing.T) { exampleContract := InstantiateHackatomExampleContract(t, ctx, keepers) contractAddr := exampleContract.Contract - _, _, anyAddr := keyPubAddr() + _, anyAddr := keyPubAddr() // check balance bal := bankKeeper.GetBalance(ctx, contractAddr, "denom") diff --git a/x/wasm/keeper/querier.go b/x/wasm/keeper/querier.go index d0ee2727e6..6ceed97b64 100644 --- a/x/wasm/keeper/querier.go +++ b/x/wasm/keeper/querier.go @@ -18,9 +18,9 @@ import ( "github.com/CosmWasm/wasmd/x/wasm/types" ) -var _ types.QueryServer = &grpcQuerier{} +var _ types.QueryServer = &GrpcQuerier{} -type grpcQuerier struct { +type GrpcQuerier struct { cdc codec.Codec storeKey storetypes.StoreKey keeper types.ViewKeeper @@ -28,11 +28,11 @@ type grpcQuerier struct { } // NewGrpcQuerier constructor -func NewGrpcQuerier(cdc codec.Codec, storeKey storetypes.StoreKey, keeper types.ViewKeeper, queryGasLimit sdk.Gas) *grpcQuerier { //nolint:revive - return &grpcQuerier{cdc: cdc, storeKey: storeKey, keeper: keeper, queryGasLimit: queryGasLimit} +func NewGrpcQuerier(cdc codec.Codec, storeKey storetypes.StoreKey, keeper types.ViewKeeper, queryGasLimit sdk.Gas) *GrpcQuerier { + return &GrpcQuerier{cdc: cdc, storeKey: storeKey, keeper: keeper, queryGasLimit: queryGasLimit} } -func (q grpcQuerier) ContractInfo(c context.Context, req *types.QueryContractInfoRequest) (*types.QueryContractInfoResponse, error) { +func (q GrpcQuerier) ContractInfo(c context.Context, req *types.QueryContractInfoRequest) (*types.QueryContractInfoResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -50,7 +50,7 @@ func (q grpcQuerier) ContractInfo(c context.Context, req *types.QueryContractInf return rsp, nil } -func (q grpcQuerier) ContractHistory(c context.Context, req *types.QueryContractHistoryRequest) (*types.QueryContractHistoryResponse, error) { +func (q GrpcQuerier) ContractHistory(c context.Context, req *types.QueryContractHistoryRequest) (*types.QueryContractHistoryResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -83,7 +83,7 @@ func (q grpcQuerier) ContractHistory(c context.Context, req *types.QueryContract } // ContractsByCode lists all smart contracts for a code id -func (q grpcQuerier) ContractsByCode(c context.Context, req *types.QueryContractsByCodeRequest) (*types.QueryContractsByCodeResponse, error) { +func (q GrpcQuerier) ContractsByCode(c context.Context, req *types.QueryContractsByCodeRequest) (*types.QueryContractsByCodeResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -110,7 +110,7 @@ func (q grpcQuerier) ContractsByCode(c context.Context, req *types.QueryContract }, nil } -func (q grpcQuerier) AllContractState(c context.Context, req *types.QueryAllContractStateRequest) (*types.QueryAllContractStateResponse, error) { +func (q GrpcQuerier) AllContractState(c context.Context, req *types.QueryAllContractStateRequest) (*types.QueryAllContractStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -143,7 +143,7 @@ func (q grpcQuerier) AllContractState(c context.Context, req *types.QueryAllCont }, nil } -func (q grpcQuerier) RawContractState(c context.Context, req *types.QueryRawContractStateRequest) (*types.QueryRawContractStateResponse, error) { +func (q GrpcQuerier) RawContractState(c context.Context, req *types.QueryRawContractStateRequest) (*types.QueryRawContractStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -161,7 +161,7 @@ func (q grpcQuerier) RawContractState(c context.Context, req *types.QueryRawCont return &types.QueryRawContractStateResponse{Data: rsp}, nil } -func (q grpcQuerier) SmartContractState(c context.Context, req *types.QuerySmartContractStateRequest) (rsp *types.QuerySmartContractStateResponse, err error) { +func (q GrpcQuerier) SmartContractState(c context.Context, req *types.QuerySmartContractStateRequest) (rsp *types.QuerySmartContractStateResponse, err error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -204,7 +204,7 @@ func (q grpcQuerier) SmartContractState(c context.Context, req *types.QuerySmart return &types.QuerySmartContractStateResponse{Data: bz}, nil } -func (q grpcQuerier) Code(c context.Context, req *types.QueryCodeRequest) (*types.QueryCodeResponse, error) { +func (q GrpcQuerier) Code(c context.Context, req *types.QueryCodeRequest) (*types.QueryCodeResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -224,7 +224,7 @@ func (q grpcQuerier) Code(c context.Context, req *types.QueryCodeRequest) (*type }, nil } -func (q grpcQuerier) Codes(c context.Context, req *types.QueryCodesRequest) (*types.QueryCodesResponse, error) { +func (q GrpcQuerier) Codes(c context.Context, req *types.QueryCodesRequest) (*types.QueryCodesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -287,7 +287,7 @@ func queryCode(ctx sdk.Context, codeID uint64, keeper types.ViewKeeper) (*types. return &types.QueryCodeResponse{CodeInfoResponse: &info, Data: code}, nil } -func (q grpcQuerier) PinnedCodes(c context.Context, req *types.QueryPinnedCodesRequest) (*types.QueryPinnedCodesResponse, error) { +func (q GrpcQuerier) PinnedCodes(c context.Context, req *types.QueryPinnedCodesRequest) (*types.QueryPinnedCodesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -311,13 +311,13 @@ func (q grpcQuerier) PinnedCodes(c context.Context, req *types.QueryPinnedCodesR } // Params returns params of the module. -func (q grpcQuerier) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (q GrpcQuerier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(c) params := q.keeper.GetParams(ctx) return &types.QueryParamsResponse{Params: params}, nil } -func (q grpcQuerier) ContractsByCreator(c context.Context, req *types.QueryContractsByCreatorRequest) (*types.QueryContractsByCreatorResponse, error) { +func (q GrpcQuerier) ContractsByCreator(c context.Context, req *types.QueryContractsByCreatorRequest) (*types.QueryContractsByCreatorResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } diff --git a/x/wasm/keeper/querier_test.go b/x/wasm/keeper/querier_test.go index 82a28b06e8..788f4b402d 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -271,7 +271,7 @@ func TestQueryContractListByCodeOrdering(t *testing.T) { codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) require.NoError(t, err) - _, _, bob := keyPubAddr() + _, bob := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: anyAddr, Beneficiary: bob, @@ -820,7 +820,7 @@ func TestQueryContractsByCreatorList(t *testing.T) { codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) require.NoError(t, err) - _, _, bob := keyPubAddr() + _, bob := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: anyAddr, Beneficiary: bob, diff --git a/x/wasm/keeper/recurse_test.go b/x/wasm/keeper/recurse_test.go index 73647df5fe..d6f73cfa41 100644 --- a/x/wasm/keeper/recurse_test.go +++ b/x/wasm/keeper/recurse_test.go @@ -38,7 +38,7 @@ type recurseResponse struct { // number os wasm queries called from a contract var totalWasmQueryCounter int -func initRecurseContract(t *testing.T) (contract sdk.AccAddress, creator sdk.AccAddress, ctx sdk.Context, keeper *Keeper) { //nolint:unparam +func initRecurseContract(t *testing.T) (contract sdk.AccAddress, ctx sdk.Context, keeper *Keeper) { countingQuerierDec := func(realWasmQuerier WasmVMQueryHandler) WasmVMQueryHandler { return WasmVMQueryHandlerFn(func(ctx sdk.Context, caller sdk.AccAddress, request wasmvmtypes.QueryRequest) ([]byte, error) { totalWasmQueryCounter++ @@ -48,7 +48,7 @@ func initRecurseContract(t *testing.T) (contract sdk.AccAddress, creator sdk.Acc ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithQueryHandlerDecorator(countingQuerierDec)) keeper = keepers.WasmKeeper exampleContract := InstantiateHackatomExampleContract(t, ctx, keepers) - return exampleContract.Contract, exampleContract.CreatorAddr, ctx, keeper + return exampleContract.Contract, ctx, keeper } func TestGasCostOnQuery(t *testing.T) { @@ -103,7 +103,7 @@ func TestGasCostOnQuery(t *testing.T) { }, } - contractAddr, _, ctx, keeper := initRecurseContract(t) + contractAddr, ctx, keeper := initRecurseContract(t) for name, tc := range cases { t.Run(name, func(t *testing.T) { @@ -179,7 +179,7 @@ func TestGasOnExternalQuery(t *testing.T) { }, } - contractAddr, _, ctx, keeper := initRecurseContract(t) + contractAddr, ctx, keeper := initRecurseContract(t) for name, tc := range cases { t.Run(name, func(t *testing.T) { @@ -265,7 +265,7 @@ func TestLimitRecursiveQueryGas(t *testing.T) { }, } - contractAddr, _, ctx, keeper := initRecurseContract(t) + contractAddr, ctx, keeper := initRecurseContract(t) for name, tc := range cases { t.Run(name, func(t *testing.T) { diff --git a/x/wasm/keeper/reflect_test.go b/x/wasm/keeper/reflect_test.go index 4587a3458d..d2e2ded65f 100644 --- a/x/wasm/keeper/reflect_test.go +++ b/x/wasm/keeper/reflect_test.go @@ -45,7 +45,7 @@ func TestReflectContractSend(t *testing.T) { deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedRandomAccount(ctx, deposit...) - _, _, bob := keyPubAddr() + _, bob := keyPubAddr() // upload reflect code reflectID, _, err := keeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) @@ -125,7 +125,7 @@ func TestReflectCustomMsg(t *testing.T) { deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) creator := keepers.Faucet.NewFundedRandomAccount(ctx, deposit...) bob := keepers.Faucet.NewFundedRandomAccount(ctx, deposit...) - _, _, fred := keyPubAddr() + _, fred := keyPubAddr() // upload code codeID, _, err := keeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) @@ -593,11 +593,11 @@ type reflectCustomMsg struct { // toReflectRawMsg encodes an sdk msg using any type with json encoding. // Then wraps it as an opaque message func toReflectRawMsg(cdc codec.Codec, msg sdk.Msg) (wasmvmtypes.CosmosMsg, error) { - any, err := codectypes.NewAnyWithValue(msg) + codecAny, err := codectypes.NewAnyWithValue(msg) if err != nil { return wasmvmtypes.CosmosMsg{}, err } - rawBz, err := cdc.MarshalJSON(any) + rawBz, err := cdc.MarshalJSON(codecAny) if err != nil { return wasmvmtypes.CosmosMsg{}, errorsmod.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } @@ -607,7 +607,7 @@ func toReflectRawMsg(cdc codec.Codec, msg sdk.Msg) (wasmvmtypes.CosmosMsg, error res := wasmvmtypes.CosmosMsg{ Custom: customMsg, } - return res, nil + return res, err } // reflectEncoders needs to be registered in test setup to handle custom message callbacks @@ -627,12 +627,12 @@ func fromReflectRawMsg(cdc codec.Codec) CustomEncoder { return nil, errorsmod.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } if custom.Raw != nil { - var any codectypes.Any - if err := cdc.UnmarshalJSON(custom.Raw, &any); err != nil { + var codecAny codectypes.Any + if err := cdc.UnmarshalJSON(custom.Raw, &codecAny); err != nil { return nil, errorsmod.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } var msg sdk.Msg - if err := cdc.UnpackAny(&any, &msg); err != nil { + if err := cdc.UnpackAny(&codecAny, &msg); err != nil { return nil, err } return []sdk.Msg{msg}, nil @@ -654,6 +654,7 @@ type customQueryResponse struct { Msg string `json:"msg"` } +// this is from the contract to the go code (capitalized or ping) type capitalizedResponse struct { Text string `json:"text"` } diff --git a/x/wasm/keeper/snapshotter.go b/x/wasm/keeper/snapshotter.go index 96db8035c7..4ac85b46fe 100644 --- a/x/wasm/keeper/snapshotter.go +++ b/x/wasm/keeper/snapshotter.go @@ -95,7 +95,7 @@ func (ws *WasmSnapshotter) RestoreExtension(height uint64, format uint32, payloa return snapshot.ErrUnknownFormat } -func restoreV1(ctx sdk.Context, k *Keeper, compressedCode []byte) error { +func restoreV1(_ sdk.Context, k *Keeper, compressedCode []byte) error { if !ioutils.IsGzip(compressedCode) { return types.ErrInvalid.Wrap("not a gzip") } diff --git a/x/wasm/keeper/staking_test.go b/x/wasm/keeper/staking_test.go index 86f9cadc02..224cc90cd6 100644 --- a/x/wasm/keeper/staking_test.go +++ b/x/wasm/keeper/staking_test.go @@ -130,7 +130,7 @@ func TestInitializeStaking(t *testing.T) { checkAccount(t, ctx, accKeeper, bankKeeper, creator, deposit) // try to register with a validator not on the list and it fails - _, _, bob := keyPubAddr() + _, bob := keyPubAddr() badInitMsg := StakingInitMsg{ Name: "Missing Validator", Symbol: "MISS", diff --git a/x/wasm/keeper/submsg_test.go b/x/wasm/keeper/submsg_test.go index f2c9d7d9c2..5dcdf4a98b 100644 --- a/x/wasm/keeper/submsg_test.go +++ b/x/wasm/keeper/submsg_test.go @@ -28,7 +28,7 @@ func TestDispatchSubMsgSuccessCase(t *testing.T) { creator := keepers.Faucet.NewFundedRandomAccount(ctx, deposit...) creatorBalance := deposit.Sub(contractStart...) - _, _, fred := keyPubAddr() + _, fred := keyPubAddr() // upload code codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) @@ -121,8 +121,8 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { require.NoError(t, err) hackatomID, _, err := keepers.ContractKeeper.Create(ctx, uploader, hackatomCode, nil) require.NoError(t, err) - _, _, bob := keyPubAddr() - _, _, fred := keyPubAddr() + _, bob := keyPubAddr() + _, fred := keyPubAddr() initMsg := HackatomExampleInitMsg{ Verifier: fred, Beneficiary: bob, @@ -283,7 +283,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { for name, tc := range cases { t.Run(name, func(t *testing.T) { creator := keepers.Faucet.NewFundedRandomAccount(ctx, contractStart...) - _, _, empty := keyPubAddr() + _, empty := keyPubAddr() contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, reflectID, creator, nil, []byte("{}"), fmt.Sprintf("contract %s", name), contractStart) require.NoError(t, err) @@ -367,7 +367,7 @@ func TestDispatchSubMsgEncodeToNoSdkMsg(t *testing.T) { contractStart := sdk.NewCoins(sdk.NewInt64Coin("denom", 40000)) creator := keepers.Faucet.NewFundedRandomAccount(ctx, deposit...) - _, _, fred := keyPubAddr() + _, fred := keyPubAddr() // upload code codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) @@ -433,7 +433,7 @@ func TestDispatchSubMsgConditionalReplyOn(t *testing.T) { contractStart := sdk.NewCoins(sdk.NewInt64Coin("denom", 40000)) creator := keepers.Faucet.NewFundedRandomAccount(ctx, deposit...) - _, _, fred := keyPubAddr() + _, fred := keyPubAddr() // upload code codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, testdata.ReflectContractWasm(), nil) diff --git a/x/wasm/keeper/test_common.go b/x/wasm/keeper/test_common.go index 4586045a80..d67441ad67 100644 --- a/x/wasm/keeper/test_common.go +++ b/x/wasm/keeper/test_common.go @@ -147,7 +147,7 @@ type TestFaucet struct { func NewTestFaucet(t testing.TB, ctx sdk.Context, bankKeeper bankkeeper.Keeper, minterModuleName string, initialAmount ...sdk.Coin) *TestFaucet { require.NotEmpty(t, initialAmount) r := &TestFaucet{t: t, bankKeeper: bankKeeper, minterModuleName: minterModuleName} - _, _, addr := keyPubAddr() + _, addr := keyPubAddr() r.sender = addr r.Mint(ctx, addr, initialAmount...) r.balance = initialAmount @@ -177,7 +177,7 @@ func (f *TestFaucet) Fund(parentCtx sdk.Context, receiver sdk.AccAddress, amount } func (f *TestFaucet) NewFundedRandomAccount(ctx sdk.Context, amounts ...sdk.Coin) sdk.AccAddress { - _, _, addr := keyPubAddr() + _, addr := keyPubAddr() f.Fund(ctx, addr, amounts...) return addr } @@ -576,7 +576,7 @@ func handleExecute(ctx sdk.Context, k types.ContractOpsKeeper, msg *types.MsgExe } func RandomAccountAddress(_ testing.TB) sdk.AccAddress { - _, _, addr := keyPubAddr() + _, addr := keyPubAddr() return addr } @@ -621,7 +621,7 @@ func StoreExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers, wa func StoreExampleContractWasm(t testing.TB, ctx sdk.Context, keepers TestKeepers, wasmCode []byte) ExampleContract { anyAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000)) - creator, _, creatorAddr := keyPubAddr() + creator, creatorAddr := keyPubAddr() fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount) codeID, _, err := keepers.ContractKeeper.Create(ctx, creatorAddr, wasmCode, nil) @@ -662,7 +662,7 @@ func StoreRandomContractWithAccessConfig( ) ExampleContract { t.Helper() anyAmount := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000)) - creator, _, creatorAddr := keyPubAddr() + creator, creatorAddr := keyPubAddr() fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, creatorAddr, anyAmount) keepers.WasmKeeper.wasmVM = mock wasmCode := append(wasmIdent, rand.Bytes(10)...) //nolint:gocritic @@ -687,10 +687,10 @@ type HackatomExampleInstance struct { func InstantiateHackatomExampleContract(t testing.TB, ctx sdk.Context, keepers TestKeepers) HackatomExampleInstance { contract := StoreHackatomExampleContract(t, ctx, keepers) - verifier, _, verifierAddr := keyPubAddr() + verifier, verifierAddr := keyPubAddr() fundAccounts(t, ctx, keepers.AccountKeeper, keepers.BankKeeper, verifierAddr, contract.InitialAmount) - beneficiary, _, beneficiaryAddr := keyPubAddr() + beneficiary, beneficiaryAddr := keyPubAddr() initMsgBz := HackatomExampleInitMsg{ Verifier: verifierAddr, Beneficiary: beneficiaryAddr, @@ -804,7 +804,7 @@ var keyCounter uint64 // we need to make this deterministic (same every test run), as encoded address size and thus gas cost, // depends on the actual bytes (due to ugly CanonicalAddress encoding) -func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { //nolint:unparam +func keyPubAddr() (crypto.PrivKey, sdk.AccAddress) { keyCounter++ seed := make([]byte, 8) binary.BigEndian.PutUint64(seed, keyCounter) @@ -812,5 +812,5 @@ func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { //nolint:unp key := ed25519.GenPrivKeyFromSecret(seed) pub := key.PubKey() addr := sdk.AccAddress(pub.Address()) - return key, pub, addr + return key, addr } diff --git a/x/wasm/keeper/wasmtesting/gas_register.go b/x/wasm/keeper/wasmtesting/gas_register.go index d1975f7638..516cd5fb4a 100644 --- a/x/wasm/keeper/wasmtesting/gas_register.go +++ b/x/wasm/keeper/wasmtesting/gas_register.go @@ -52,7 +52,7 @@ func (m MockGasRegister) ReplyCosts(pinned bool, reply wasmvmtypes.Reply) sdk.Ga return m.ReplyCostFn(pinned, reply) } -func (m MockGasRegister) EventCosts(evts []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas { +func (m MockGasRegister) EventCosts(evts []wasmvmtypes.EventAttribute, _ wasmvmtypes.Events) sdk.Gas { if m.EventCostsFn == nil { panic("not expected to be called") } diff --git a/x/wasm/module.go b/x/wasm/module.go index b92fce647a..272b32d1a4 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -72,7 +72,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { } // ValidateGenesis performs genesis state validation for the wasm module. -func (b AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error { +func (b AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, _ client.TxEncodingConfig, message json.RawMessage) error { var data GenesisState err := marshaler.UnmarshalJSON(message, &data) if err != nil { @@ -164,7 +164,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { } // RegisterInvariants registers the wasm module invariants. -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // QuerierRoute returns the wasm module's querier route name. func (AppModule) QuerierRoute() string { @@ -209,14 +209,12 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } // ProposalContents doesn't return any content functions for governance proposals. -// - -func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { +func (am AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { return simulation.ProposalContents(am.bankKeeper, am.keeper) } // RegisterStoreDecoder registers a decoder for supply module's types -func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { } // WeightedOperations returns the all the gov module operations with their respective weights. @@ -285,7 +283,7 @@ func getExpectedLibwasmVersion() string { return "" } -func checkLibwasmVersion(cmd *cobra.Command, args []string) error { +func checkLibwasmVersion(_ *cobra.Command, _ []string) error { wasmVersion, err := wasmvm.LibwasmvmVersion() if err != nil { return fmt.Errorf("unable to retrieve libwasmversion %w", err) diff --git a/x/wasm/module_test.go b/x/wasm/module_test.go index 012588c808..bd788d0cc3 100644 --- a/x/wasm/module_test.go +++ b/x/wasm/module_test.go @@ -11,7 +11,6 @@ import ( "github.com/spf13/viper" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto" "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" @@ -79,11 +78,11 @@ func setupTest(t *testing.T) testData { return data } -func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { //nolint:unparam +func keyPubAddr() sdk.AccAddress { key := ed25519.GenPrivKey() pub := key.PubKey() addr := sdk.AccAddress(pub.Address()) - return key, pub, addr + return addr } func mustLoad(path string) []byte { @@ -95,11 +94,11 @@ func mustLoad(path string) []byte { } var ( - _, _, addrAcc1 = keyPubAddr() - addr1 = addrAcc1.String() - testContract = mustLoad("./keeper/testdata/hackatom.wasm") - maskContract = testdata.ReflectContractWasm() - oldContract = mustLoad("./testdata/escrow_0.7.wasm") + addrAcc1 = keyPubAddr() + addr1 = addrAcc1.String() + testContract = mustLoad("./keeper/testdata/hackatom.wasm") + maskContract = testdata.ReflectContractWasm() + oldContract = mustLoad("./testdata/escrow_0.7.wasm") ) func TestHandleCreate(t *testing.T) { @@ -190,8 +189,8 @@ func TestHandleInstantiate(t *testing.T) { require.NoError(t, err) assertStoreCodeResponse(t, res.Data, 1) - _, _, bob := keyPubAddr() - _, _, fred := keyPubAddr() + bob := keyPubAddr() + fred := keyPubAddr() initPayload := initMsg{ Verifier: fred, @@ -251,7 +250,7 @@ func TestHandleExecute(t *testing.T) { require.NoError(t, err) assertStoreCodeResponse(t, res.Data, 1) - _, _, bob := keyPubAddr() + bob := keyPubAddr() initMsg := initMsg{ Verifier: fred, Beneficiary: bob, @@ -384,7 +383,7 @@ func TestHandleExecuteEscrow(t *testing.T) { _, err := h(data.ctx, msg) require.NoError(t, err) - _, _, bob := keyPubAddr() + bob := keyPubAddr() initMsg := map[string]interface{}{ "verifier": fred.String(), "beneficiary": bob.String(), diff --git a/x/wasm/relay_pingpong_test.go b/x/wasm/relay_pingpong_test.go index 1968bb46dd..ff52de3dc0 100644 --- a/x/wasm/relay_pingpong_test.go +++ b/x/wasm/relay_pingpong_test.go @@ -136,7 +136,7 @@ type player struct { // Execute starts the ping pong game // Contracts finds all connected channels and broadcasts a ping message -func (p *player) Execute(code wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { +func (p *player) Execute(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { p.execCalls++ // start game var start startGame @@ -174,7 +174,7 @@ func (p *player) Execute(code wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmt } // OnIBCChannelOpen ensures to accept only configured version -func (p player) IBCChannelOpen(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelOpenMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBC3ChannelOpenResponse, uint64, error) { +func (p player) IBCChannelOpen(_ wasmvm.Checksum, _ wasmvmtypes.Env, msg wasmvmtypes.IBCChannelOpenMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBC3ChannelOpenResponse, uint64, error) { if msg.GetChannel().Version != p.actor { return &wasmvmtypes.IBC3ChannelOpenResponse{}, 0, nil } @@ -182,7 +182,7 @@ func (p player) IBCChannelOpen(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg } // OnIBCChannelConnect persists connection endpoints -func (p player) IBCChannelConnect(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelConnectMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (p player) IBCChannelConnect(_ wasmvm.Checksum, _ wasmvmtypes.Env, msg wasmvmtypes.IBCChannelConnectMsg, store wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { p.storeEndpoint(store, msg.GetChannel()) return &wasmvmtypes.IBCBasicResponse{}, 0, nil } @@ -209,7 +209,7 @@ func (p player) storeEndpoint(store wasmvm.KVStore, channel wasmvmtypes.IBCChann store.Set(ibcEndpointsKey, bz) } -func (p player) IBCChannelClose(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelCloseMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (p player) IBCChannelClose(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCChannelCloseMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { panic("implement me") } @@ -222,7 +222,7 @@ var ( // store keys ) // IBCPacketReceive receives the hit and serves a response hit via `wasmvmtypes.IBCPacket` -func (p player) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { +func (p player) IBCPacketReceive(_ wasmvm.Checksum, _ wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { // parse received data and store packet := msg.Packet var receivedBall hit @@ -268,7 +268,7 @@ func (p player) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, ms } // OnIBCPacketAcknowledgement handles the packet acknowledgment frame. Stops the game on an any error -func (p player) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (p player) IBCPacketAck(_ wasmvm.Checksum, _ wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { // parse received data and store var sentBall hit if err := json.Unmarshal(msg.OriginalPacket.Data, &sentBall); err != nil { @@ -290,7 +290,7 @@ func (p player) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wa return &wasmvmtypes.IBCBasicResponse{}, 0, nil } -func (p player) IBCPacketTimeout(codeID wasmvm.Checksum, env wasmvmtypes.Env, packet wasmvmtypes.IBCPacketTimeoutMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (p player) IBCPacketTimeout(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCPacketTimeoutMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { panic("implement me") } @@ -324,7 +324,7 @@ func counterParty(s string) string { // hit is ibc packet payload type hit map[string]uint64 -func NewHit(player string, count uint64) hit { //nolint:revive // no need to make this public +func NewHit(player string, count uint64) hit { return map[string]uint64{ player: count, } diff --git a/x/wasm/relay_test.go b/x/wasm/relay_test.go index f94f759964..5b903c6f33 100644 --- a/x/wasm/relay_test.go +++ b/x/wasm/relay_test.go @@ -533,7 +533,7 @@ type captureCloseContract struct { closeCalled bool } -func (c *captureCloseContract) IBCChannelClose(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelCloseMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (c *captureCloseContract) IBCChannelClose(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCChannelCloseMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { c.closeCalled = true return &wasmvmtypes.IBCBasicResponse{}, 1, nil } @@ -546,7 +546,7 @@ type sendViaIBCTransferContract struct { t *testing.T } -func (s *sendViaIBCTransferContract) Execute(code wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { +func (s *sendViaIBCTransferContract) Execute(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.MessageInfo, executeMsg []byte, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { var in startTransfer if err := json.Unmarshal(executeMsg, &in); err != nil { return nil, 0, err @@ -576,7 +576,7 @@ type sendEmulatedIBCTransferContract struct { contractAddr string } -func (s *sendEmulatedIBCTransferContract) Execute(code wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { +func (s *sendEmulatedIBCTransferContract) Execute(_ wasmvm.Checksum, _ wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { var in startTransfer if err := json.Unmarshal(executeMsg, &in); err != nil { return nil, 0, err @@ -601,7 +601,7 @@ func (s *sendEmulatedIBCTransferContract) Execute(code wasmvm.Checksum, env wasm return &wasmvmtypes.Response{Messages: []wasmvmtypes.SubMsg{{ReplyOn: wasmvmtypes.ReplyNever, Msg: wasmvmtypes.CosmosMsg{IBC: ibcMsg}}}}, 0, nil } -func (s *sendEmulatedIBCTransferContract) IBCPacketTimeout(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketTimeoutMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (s *sendEmulatedIBCTransferContract) IBCPacketTimeout(_ wasmvm.Checksum, _ wasmvmtypes.Env, msg wasmvmtypes.IBCPacketTimeoutMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { packet := msg.Packet var data ibctransfertypes.FungibleTokenPacketData @@ -629,11 +629,11 @@ type closeChannelContract struct { contractStub } -func (c *closeChannelContract) IBCChannelClose(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelCloseMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (c *closeChannelContract) IBCChannelClose(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCChannelCloseMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { return &wasmvmtypes.IBCBasicResponse{}, 1, nil } -func (c *closeChannelContract) Execute(code wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { +func (c *closeChannelContract) Execute(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.MessageInfo, executeMsg []byte, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { var in closeIBCChannel if err := json.Unmarshal(executeMsg, &in); err != nil { return nil, 0, err @@ -685,7 +685,7 @@ type ackReceiverContract struct { chain *wasmibctesting.TestChain } -func (c *ackReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { +func (c *ackReceiverContract) IBCPacketReceive(_ wasmvm.Checksum, _ wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { packet := msg.Packet var src ibctransfertypes.FungibleTokenPacketData @@ -707,7 +707,7 @@ func (c *ackReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmv return &wasmvmtypes.IBCReceiveResult{Ok: &wasmvmtypes.IBCReceiveResponse{Acknowledgement: ack, Attributes: log}}, 0, nil } -func (c *ackReceiverContract) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (c *ackReceiverContract) IBCPacketAck(_ wasmvm.Checksum, _ wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { var data ibctransfertypes.FungibleTokenPacketData if err := ibctransfertypes.ModuleCdc.UnmarshalJSON(msg.OriginalPacket.Data, &data); err != nil { return nil, 0, err @@ -736,7 +736,7 @@ type nackReceiverContract struct { t *testing.T } -func (c *nackReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { +func (c *nackReceiverContract) IBCPacketReceive(_ wasmvm.Checksum, _ wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { packet := msg.Packet var src ibctransfertypes.FungibleTokenPacketData @@ -753,7 +753,7 @@ type errorReceiverContract struct { t *testing.T } -func (c *errorReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { +func (c *errorReceiverContract) IBCPacketReceive(_ wasmvm.Checksum, _ wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { packet := msg.Packet var src ibctransfertypes.FungibleTokenPacketData @@ -767,27 +767,27 @@ func (c *errorReceiverContract) IBCPacketReceive(codeID wasmvm.Checksum, env was // simple helper struct that implements connection setup methods. type contractStub struct{} -func (s *contractStub) IBCChannelOpen(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelOpenMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBC3ChannelOpenResponse, uint64, error) { +func (s *contractStub) IBCChannelOpen(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCChannelOpenMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBC3ChannelOpenResponse, uint64, error) { return &wasmvmtypes.IBC3ChannelOpenResponse{}, 0, nil } -func (s *contractStub) IBCChannelConnect(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelConnectMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (s *contractStub) IBCChannelConnect(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCChannelConnectMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { return &wasmvmtypes.IBCBasicResponse{}, 0, nil } -func (s *contractStub) IBCChannelClose(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelCloseMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (s *contractStub) IBCChannelClose(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCChannelCloseMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { panic("implement me") } -func (s *contractStub) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { +func (s *contractStub) IBCPacketReceive(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCPacketReceiveMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { panic("implement me") } -func (s *contractStub) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (s *contractStub) IBCPacketAck(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCPacketAckMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { return &wasmvmtypes.IBCBasicResponse{}, 0, nil } -func (s *contractStub) IBCPacketTimeout(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketTimeoutMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (s *contractStub) IBCPacketTimeout(_ wasmvm.Checksum, _ wasmvmtypes.Env, _ wasmvmtypes.IBCPacketTimeoutMsg, _ wasmvm.KVStore, _ wasmvm.GoAPI, _ wasmvm.Querier, _ wasmvm.GasMeter, _ uint64, _ wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { panic("implement me") } diff --git a/x/wasm/simulation/proposals.go b/x/wasm/simulation/proposals.go index fe6017e593..880e6cf371 100644 --- a/x/wasm/simulation/proposals.go +++ b/x/wasm/simulation/proposals.go @@ -148,9 +148,7 @@ func SimulateStoreCodeProposal(wasmKeeper WasmKeeper) simtypes.ContentSimulatorF } // Simulate instantiate contract proposal -// - -func SimulateInstantiateContractProposal(bk BankKeeper, wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.ContentSimulatorFn { +func SimulateInstantiateContractProposal(_ BankKeeper, wasmKeeper WasmKeeper, codeSelector CodeIDSelector) simtypes.ContentSimulatorFn { return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { simAccount, _ := simtypes.RandomAcc(r, accs) // admin @@ -178,7 +176,7 @@ func SimulateInstantiateContractProposal(bk BankKeeper, wasmKeeper WasmKeeper, c // func SimulateExecuteContractProposal( - bk BankKeeper, + _ BankKeeper, wasmKeeper WasmKeeper, contractSelector MsgExecuteContractSelector, senderSelector MsgExecuteSenderSelector, diff --git a/x/wasm/types/authz.go b/x/wasm/types/authz.go index 6cce369baf..9692088710 100644 --- a/x/wasm/types/authz.go +++ b/x/wasm/types/authz.go @@ -311,7 +311,7 @@ func (g ContractGrant) ValidateBasic() error { type UndefinedFilter struct{} // Accept always returns error -func (f *UndefinedFilter) Accept(ctx sdk.Context, msg RawContractMessage) (bool, error) { +func (f *UndefinedFilter) Accept(_ sdk.Context, _ RawContractMessage) (bool, error) { return false, sdkerrors.ErrNotFound.Wrapf("undefined filter") } @@ -326,7 +326,7 @@ func NewAllowAllMessagesFilter() *AllowAllMessagesFilter { } // Accept accepts any valid json message content. -func (f *AllowAllMessagesFilter) Accept(ctx sdk.Context, msg RawContractMessage) (bool, error) { +func (f *AllowAllMessagesFilter) Accept(_ sdk.Context, msg RawContractMessage) (bool, error) { return true, msg.ValidateBasic() } @@ -379,7 +379,7 @@ func NewAcceptedMessagesFilter(msgs ...RawContractMessage) *AcceptedMessagesFilt } // Accept only payload messages which are equal to the granted one. -func (f *AcceptedMessagesFilter) Accept(ctx sdk.Context, msg RawContractMessage) (bool, error) { +func (f *AcceptedMessagesFilter) Accept(_ sdk.Context, msg RawContractMessage) (bool, error) { for _, v := range f.Messages { if v.Equal(msg) { return true, nil @@ -425,7 +425,7 @@ func (u UndefinedLimit) ValidateBasic() error { } // Accept always returns error -func (u UndefinedLimit) Accept(ctx sdk.Context, msg AuthzableWasmMsg) (*ContractAuthzLimitAcceptResult, error) { +func (u UndefinedLimit) Accept(_ sdk.Context, _ AuthzableWasmMsg) (*ContractAuthzLimitAcceptResult, error) { return nil, sdkerrors.ErrNotFound.Wrapf("undefined filter") } diff --git a/x/wasm/types/types.go b/x/wasm/types/types.go index 5ecdb19064..ffec3049da 100644 --- a/x/wasm/types/types.go +++ b/x/wasm/types/types.go @@ -118,12 +118,12 @@ func (c *ContractInfo) SetExtension(ext ContractInfoExtension) error { return err } } - any, err := codectypes.NewAnyWithValue(ext) + codecAny, err := codectypes.NewAnyWithValue(ext) if err != nil { return errorsmod.Wrap(sdkerrors.ErrPackAny, err.Error()) } - c.Extension = any + c.Extension = codecAny return nil } diff --git a/x/wasm/types/types_test.go b/x/wasm/types/types_test.go index d4a84999fe..3221c00f48 100644 --- a/x/wasm/types/types_test.go +++ b/x/wasm/types/types_test.go @@ -54,18 +54,20 @@ func TestContractInfoValidateBasic(t *testing.T) { "invalid extension": { srcMutator: func(c *ContractInfo) { // any protobuf type with ValidateBasic method - any, err := codectypes.NewAnyWithValue(&v1beta1.TextProposal{}) + codecAny, err := codectypes.NewAnyWithValue(&v1beta1.TextProposal{}) + require.NoError(t, err) - c.Extension = any + c.Extension = codecAny }, expError: true, }, "not validatable extension": { srcMutator: func(c *ContractInfo) { // any protobuf type with ValidateBasic method - any, err := codectypes.NewAnyWithValue(&v1beta1.Proposal{}) + codecAny, err := codectypes.NewAnyWithValue(&v1beta1.Proposal{}) + require.NoError(t, err) - c.Extension = any + c.Extension = codecAny }, }, }