Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add contract addr checks to wasmbindings code #277

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions x/amm/client/wasm/msg_create_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgCreatePool(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, nil, wasmvmtypes.InvalidRequest{Err: "create pool null msg"}
}

if msg.Sender != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "create pool wrong sender"}
}

msgServer := ammkeeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/amm/client/wasm/msg_exit_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgExitPool(ctx sdk.Context, contractAddr sdk.AccAddress, ms
return nil, nil, wasmvmtypes.InvalidRequest{Err: "exit pool null msg"}
}

if msg.Sender != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "exit pool wrong sender"}
}

msgServer := ammkeeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/amm/client/wasm/msg_feed_multiple_external_liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgFeedMultipleExternalLiquidity(ctx sdk.Context, contractAd
return nil, nil, wasmvmtypes.InvalidRequest{Err: "FeedMultipleExternalLiquidity null msg"}
}

if msg.Sender != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "FeedMultipleExternalLiquidity wrong sender"}
}

msgServer := ammkeeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/amm/client/wasm/msg_join_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgJoinPool(ctx sdk.Context, contractAddr sdk.AccAddress, ms
return nil, nil, wasmvmtypes.InvalidRequest{Err: "join pool null msg"}
}

if msg.Sender != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "join pool wrong sender"}
}

msgServer := ammkeeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/amm/client/wasm/msg_swap_by_denom.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgSwapByDenom(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, nil, wasmvmtypes.InvalidRequest{Err: "swap by denom null msg"}
}

if msg.Sender != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "swap by denom wrong sender"}
}

msgServer := ammkeeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/amm/client/wasm/msg_swap_exact_amount_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgSwapExactAmountIn(ctx sdk.Context, contractAddr sdk.AccAd
return nil, nil, wasmvmtypes.InvalidRequest{Err: "swap exact amount in null msg"}
}

if msg.Sender != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "swap exact amount in wrong sender"}
}

msgServer := ammkeeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/amm/client/wasm/msg_swap_exact_amount_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgSwapExactAmountOut(ctx sdk.Context, contractAddr sdk.AccA
return nil, nil, wasmvmtypes.InvalidRequest{Err: "swap exact amount out null msg"}
}

if msg.Sender != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "swap exact amount out wrong sender"}
}

msgServer := ammkeeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/assetprofile/client/wasm/msg_create_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgCreateEntry(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, nil, wasmvmtypes.InvalidRequest{Err: "CreateEntry null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "create entry wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/assetprofile/client/wasm/msg_delete_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgDeleteEntry(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, nil, wasmvmtypes.InvalidRequest{Err: "DeleteEntry null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "delete entry wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/assetprofile/client/wasm/msg_update_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgUpdateEntry(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateEntry null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "update entry wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/clock/client/wasm/msg_update_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgUpdateParams(ctx sdk.Context, contractAddr sdk.AccAddress
return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateParams null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "update params wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions x/commitment/client/wasm/msg_cancel_vest.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import (
)

func (m *Messenger) msgCancelVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelVest *commitmenttypes.MsgCancelVest) ([]sdk.Event, [][]byte, error) {
if msgCancelVest == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "cancel vest null msg"}
}

if msgCancelVest.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "cancel vest wrong sender"}
}

var res *wasmbindingstypes.RequestResponse
var err error
if msgCancelVest.Denom != paramtypes.Eden {
Expand Down
4 changes: 4 additions & 0 deletions x/commitment/client/wasm/msg_commit_liquid_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgCommitLiquidTokens(ctx sdk.Context, contractAddr sdk.AccA
return nil, nil, wasmvmtypes.InvalidRequest{Err: "CommitLiquidTokens null msg"}
}

if msg.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "commit liquid tokens wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/commitment/client/wasm/msg_commit_unclaimed_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgCommitClaimedRewards(ctx sdk.Context, contractAddr sdk.Ac
return nil, nil, wasmvmtypes.InvalidRequest{Err: "CommitUnclaimedRewards null msg"}
}

if msg.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "commit unclaimed rewards wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/commitment/client/wasm/msg_stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func (m *Messenger) msgStake(ctx sdk.Context, contractAddr sdk.AccAddress, msgSt
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Invalid staking parameter"}
}

if msgStake.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "stake wrong sender"}
}

entry, found := m.apKeeper.GetEntry(ctx, ptypes.BaseCurrency)
if !found {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Invalid usdc denom"}
Expand Down
4 changes: 4 additions & 0 deletions x/commitment/client/wasm/msg_uncommit_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgUncommitTokens(ctx sdk.Context, contractAddr sdk.AccAddre
return nil, nil, wasmvmtypes.InvalidRequest{Err: "UncommitTokens null msg"}
}

if msg.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "uncommit tokens wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/commitment/client/wasm/msg_unstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func (m *Messenger) msgUnstake(ctx sdk.Context, contractAddr sdk.AccAddress, msg
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Invalid unstaking parameter"}
}

if msgUnstake.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "unstake wrong sender"}
}

entry, found := m.apKeeper.GetEntry(ctx, ptypes.BaseCurrency)
if !found {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Invalid usdc denom"}
Expand Down
4 changes: 4 additions & 0 deletions x/commitment/client/wasm/msg_update_vesting_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgUpdateVestingInfo(ctx sdk.Context, contractAddr sdk.AccAd
return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateVestingInfo null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "update vesting info wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions x/commitment/client/wasm/msg_vest.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import (
)

func (m *Messenger) msgVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgVest *commitmenttypes.MsgVest) ([]sdk.Event, [][]byte, error) {
if msgVest == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Vest null msg"}
}

if msgVest.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "vest wrong sender"}
}

var res *wasmbindingstypes.RequestResponse
var err error
if msgVest.Denom != paramtypes.Eden {
Expand Down
4 changes: 4 additions & 0 deletions x/commitment/client/wasm/msg_vest_now.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgVestNow(ctx sdk.Context, contractAddr sdk.AccAddress, msg
return nil, nil, wasmvmtypes.InvalidRequest{Err: "VestNow null msg"}
}

if msg.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "vest now wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions x/leveragelp/client/wasm/msg_close.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import (
)

func (m *Messenger) msgClose(ctx sdk.Context, contractAddr sdk.AccAddress, msgClose *leveragelptypes.MsgClose) ([]sdk.Event, [][]byte, error) {
if msgClose == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Close null msg"}
}

if msgClose.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "close wrong sender"}
}

res, err := PerformMsgClose(m.keeper, ctx, contractAddr, msgClose)
if err != nil {
return nil, nil, errorsmod.Wrap(err, "perform close")
Expand Down
4 changes: 4 additions & 0 deletions x/leveragelp/client/wasm/msg_dewhitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgDewhitelist(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Dewhitelist null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "dewhitelist wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions x/leveragelp/client/wasm/msg_open.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import (
)

func (m *Messenger) msgOpen(ctx sdk.Context, contractAddr sdk.AccAddress, msgOpen *leveragelptypes.MsgOpen) ([]sdk.Event, [][]byte, error) {
if msgOpen == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Open null msg"}
}

if msgOpen.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "open wrong sender"}
}

res, err := PerformMsgOpen(m.keeper, ctx, contractAddr, msgOpen)
if err != nil {
return nil, nil, errorsmod.Wrap(err, "perform open")
Expand Down
4 changes: 4 additions & 0 deletions x/leveragelp/client/wasm/msg_update_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgUpdateParams(ctx sdk.Context, contractAddr sdk.AccAddress
return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateParams null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "update params wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/leveragelp/client/wasm/msg_update_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgUpdatePools(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdatePools null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "update pools wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/leveragelp/client/wasm/msg_whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgWhitelist(ctx sdk.Context, contractAddr sdk.AccAddress, m
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Whitelist null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "whitelist wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions x/margin/client/wasm/msg_broker_close.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import (
)

func (m *Messenger) msgBrokerClose(ctx sdk.Context, contractAddr sdk.AccAddress, msgBrokerClose *margintypes.MsgBrokerClose) ([]sdk.Event, [][]byte, error) {
if msgBrokerClose == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Broker Close null msg"}
}

if msgBrokerClose.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "broker close wrong sender"}
}

res, err := PerformMsgBrokerClose(m.keeper, ctx, contractAddr, msgBrokerClose)
if err != nil {
return nil, nil, errorsmod.Wrap(err, "perform broker close")
Expand Down
8 changes: 8 additions & 0 deletions x/margin/client/wasm/msg_broker_open.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import (
)

func (m *Messenger) msgBrokerOpen(ctx sdk.Context, contractAddr sdk.AccAddress, msgBrokerOpen *margintypes.MsgBrokerOpen) ([]sdk.Event, [][]byte, error) {
if msgBrokerOpen == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Broker Open null msg"}
}

if msgBrokerOpen.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "broker open wrong sender"}
}

res, err := PerformMsgBrokerOpen(m.keeper, ctx, contractAddr, msgBrokerOpen)
if err != nil {
return nil, nil, errorsmod.Wrap(err, "perform broker open")
Expand Down
8 changes: 8 additions & 0 deletions x/margin/client/wasm/msg_close.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import (
)

func (m *Messenger) msgClose(ctx sdk.Context, contractAddr sdk.AccAddress, msgClose *margintypes.MsgClose) ([]sdk.Event, [][]byte, error) {
if msgClose == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Close null msg"}
}

if msgClose.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "close wrong sender"}
}

res, err := PerformMsgClose(m.keeper, ctx, contractAddr, msgClose)
if err != nil {
return nil, nil, errorsmod.Wrap(err, "perform close")
Expand Down
4 changes: 4 additions & 0 deletions x/margin/client/wasm/msg_dewhitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgDewhitelist(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Dewhitelist null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "dewhitelist wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions x/margin/client/wasm/msg_open.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import (
)

func (m *Messenger) msgOpen(ctx sdk.Context, contractAddr sdk.AccAddress, msgOpen *margintypes.MsgOpen) ([]sdk.Event, [][]byte, error) {
if msgOpen == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "Open null msg"}
}

if msgOpen.Creator != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "open wrong sender"}
}

res, err := PerformMsgOpen(m.keeper, ctx, contractAddr, msgOpen)
if err != nil {
return nil, nil, errorsmod.Wrap(err, "perform open")
Expand Down
4 changes: 4 additions & 0 deletions x/margin/client/wasm/msg_update_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgUpdateParams(ctx sdk.Context, contractAddr sdk.AccAddress
return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateParams null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "update params wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/margin/client/wasm/msg_update_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func (m *Messenger) msgUpdatePools(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdatePools null msg"}
}

if msg.Authority != contractAddr.String() {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "update pools wrong sender"}
}

msgServer := keeper.NewMsgServerImpl(*m.keeper)

if err := msg.ValidateBasic(); err != nil {
Expand Down
Loading
Loading