Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hard-nett committed Apr 8, 2024
1 parent dcd2464 commit 54daf58
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var (
tokenfactorytypes.EnableSetMetadata,
}

EmptyWasmOpts []wasm.Option
EmptyWasmOpts []wasmkeeper.Option
)

// module account permissions
Expand Down
5 changes: 3 additions & 2 deletions internal/wasm/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"encoding/json"
"fmt"

sdkerrors "cosmossdk.io/errors"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/errors"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
)

Expand Down Expand Up @@ -38,7 +39,7 @@ func CustomDistributionEncoder(contract sdk.AccAddress, data json.RawMessage, _
msg := &DistributionMsg{}
err := json.Unmarshal(data, msg)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
return nil, sdkerrors.Wrap(errors.ErrJSONUnmarshal, err.Error())
}
if msg.FundCommunityPool != nil {
return msg.FundCommunityPool.Encode(contract)
Expand Down
19 changes: 10 additions & 9 deletions internal/wasm/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ package wasm
import (
"encoding/json"

"github.com/CosmWasm/wasmd/x/wasm"
sdkerrors "cosmossdk.io/errors"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/errors"
)

// Encoder describes behavior for Stargaze smart contract message encoding.
// The contract address must ALWAYS be set as the Msg signer.
type Encoder func(contract sdk.AccAddress, data json.RawMessage, version string) ([]sdk.Msg, error)

// MessageEncoders provides stargaze custom encoder for contracts
func MessageEncoders(registry *EncoderRegistry) *wasm.MessageEncoders {
return &wasm.MessageEncoders{
func MessageEncoders(registry *EncoderRegistry) *wasmkeeper.MessageEncoders {
return &wasmkeeper.MessageEncoders{
Custom: customEncoders(registry),
}
}
Expand All @@ -25,25 +26,25 @@ type MessageEncodeRequest struct {
Version string `json:"version"`
}

func customEncoders(registry *EncoderRegistry) wasm.CustomEncoder {
func customEncoders(registry *EncoderRegistry) wasmkeeper.CustomEncoder {
return func(sender sdk.AccAddress, m json.RawMessage) ([]sdk.Msg, error) {
encodeRequest := &MessageEncodeRequest{}
err := json.Unmarshal(m, encodeRequest)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
return nil, sdkerrors.Wrap(errors.ErrJSONUnmarshal, err.Error())
}
encode, exists := registry.encoders[encodeRequest.Route]
if !exists {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "encoder not found for route: %s", encodeRequest.Route)
return nil, sdkerrors.Wrapf(errors.ErrInvalidRequest, "encoder not found for route: %s", encodeRequest.Route)
}

msgs, err := encode(sender, encodeRequest.MsgData, encodeRequest.Version)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
return nil, sdkerrors.Wrap(errors.ErrInvalidRequest, err.Error())
}
for _, msg := range msgs {
if err := msg.ValidateBasic(); err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
return nil, sdkerrors.Wrap(errors.ErrInvalidRequest, err.Error())
}
}
return msgs, nil
Expand Down

0 comments on commit 54daf58

Please sign in to comment.