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: remove legacy codes of wasm #640

Merged
merged 6 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (client) [\#565](https://github.com/line/lbm-sdk/pull/565) fix the data race problem in `TestQueryABCIHeight`
* (x/token) [\#589](https://github.com/line/lbm-sdk/pull/589) fix naming collision in x/token enums
* (x/token) [\#599](https://github.com/line/lbm-sdk/pull/599) fix the order of events
* (x/wasm) [\#640](https://github.com/line/lbm-sdk/pull/640) remove legacy codes of wasm

### Breaking Changes
* (proto) [\#564](https://github.com/line/lbm-sdk/pull/564) change gRPC path to original cosmos path
Expand Down
3 changes: 0 additions & 3 deletions x/wasm/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,4 @@ type (
CustomQuerier = keeper.CustomQuerier
QueryPlugins = keeper.QueryPlugins
Option = keeper.Option

EncodeHandler = types.EncodeHandler
EncodeQuerier = types.EncodeQuerier
)
57 changes: 2 additions & 55 deletions x/wasm/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package keeper

import (
"encoding/hex"
"strconv"
"strings"

sdk "github.com/line/lbm-sdk/types"
sdkerrors "github.com/line/lbm-sdk/types/errors"
Expand Down Expand Up @@ -182,17 +180,7 @@ func handleUpdateAdminProposal(ctx sdk.Context, k types.ContractOpsKeeper, p typ
return sdkerrors.Wrap(err, "run as address")
}

if err := k.UpdateContractAdmin(ctx, contractAddr, nil, newAdminAddr); err != nil {
return err
}

ourEvent := sdk.NewEvent(
types.EventTypeUpdateAdmin,
sdk.NewAttribute(types.AttributeKeyContractAddr, p.Contract),
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
)
ctx.EventManager().EmitEvent(ourEvent)
return nil
return k.UpdateContractAdmin(ctx, contractAddr, nil, newAdminAddr)
}

func handleClearAdminProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.ClearAdminProposal) error {
Expand All @@ -204,17 +192,7 @@ func handleClearAdminProposal(ctx sdk.Context, k types.ContractOpsKeeper, p type
if err != nil {
return sdkerrors.Wrap(err, "contract")
}
if err := k.ClearContractAdmin(ctx, contractAddr, nil); err != nil {
return err
}

ourEvent := sdk.NewEvent(
types.EventTypeClearAdmin,
sdk.NewAttribute(types.AttributeKeyContractAddr, p.Contract),
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
)
ctx.EventManager().EmitEvent(ourEvent)
return nil
return k.ClearContractAdmin(ctx, contractAddr, nil)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could I check handleClearAdminProposal

When checking
cosmos/wasmd@e9156be#diff-a5c1aab521b573562de4814c157ce3c9b7564672c24f0acafffdb003de9c16fb (L159(129)-L178(142))
https://github.com/CosmWasm/wasmd/blob/main/x/wasm/keeper/proposal_handler.go#L188-L201

It seems a little different, my understanding might be wrong, but please could you double check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it works as same as wasmd's code, but I think it is better to unify the code with wasmd's.

Copy link
Member Author

@zemyblue zemyblue Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the difference with wasmd. But I thought this code is better suited to the return pattern of handleUpdateAdminProposal.

BTW, EventTypeUpdateAdmin and EventTypeClearAdmin events are not defined in wasmd. I think these events seems to define only our code. And there is no event anywhere about ClearAdminProposal and UpdateAdminProposal. I think this events are necessary. What do you think, @shiki-tak and @loloicci ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, thank you.
But I also think it would be better to unify the code with wasmd's.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @da1suk8.

And the governance process i shandled by cosmos-sdk gov module, and it seems there is a rule about proposal handler do not emit any events of type message anymore in cosmwasm/wasmd. So we need to remove this message type event.

CosmWasm/wasmd@e9156be


func handlePinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.PinCodesProposal) error {
Expand All @@ -226,22 +204,6 @@ func handlePinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.
return sdkerrors.Wrapf(err, "code id: %d", v)
}
}
s := make([]string, len(p.CodeIDs))
for _, v := range p.CodeIDs {
ourEvent := sdk.NewEvent(
types.EventTypePinCode,
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
sdk.NewAttribute(types.AttributeKeyCodeID, strconv.FormatUint(v, 10)),
)
ctx.EventManager().EmitEvent(ourEvent)
}

ourEvent := sdk.NewEvent(
types.EventTypePinCode,
sdk.NewAttribute(types.AttributeKeyCodeIDs, strings.Join(s, ",")),
)
ctx.EventManager().EmitEvent(ourEvent)

return nil
}

Expand All @@ -254,21 +216,6 @@ func handleUnpinCodesProposal(ctx sdk.Context, k types.ContractOpsKeeper, p type
return sdkerrors.Wrapf(err, "code id: %d", v)
}
}
s := make([]string, len(p.CodeIDs))
for _, v := range p.CodeIDs {
ourEvent := sdk.NewEvent(
types.EventTypeUnpinCode,
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
sdk.NewAttribute(types.AttributeKeyCodeID, strconv.FormatUint(v, 10)),
)
ctx.EventManager().EmitEvent(ourEvent)
}

ourEvent := sdk.NewEvent(
types.EventTypeUnpinCode,
sdk.NewAttribute(types.AttributeKeyCodeIDs, strings.Join(s, ",")),
)
ctx.EventManager().EmitEvent(ourEvent)

return nil
}
Expand Down
65 changes: 0 additions & 65 deletions x/wasm/types/querier_router.go

This file was deleted.

29 changes: 0 additions & 29 deletions x/wasm/types/querier_router_test.go

This file was deleted.

67 changes: 0 additions & 67 deletions x/wasm/types/router.go

This file was deleted.

27 changes: 0 additions & 27 deletions x/wasm/types/router_test.go

This file was deleted.