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

feat: add amino signing support to tokenfactory messages #7139

Merged
merged 2 commits into from
Jan 2, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#6804](https://github.com/osmosis-labs/osmosis/pull/6993) feat(math): add mutative api for BigDec.BigInt()
* [#6804](https://github.com/osmosis-labs/osmosis/pull/6804) feat: track and query protocol rev across all modules
* [#7139](https://github.com/osmosis-labs/osmosis/pull/7139) feat: add amino signing support to tokenfactory messages

### Fix Localosmosis docker-compose with state.

Expand Down
22 changes: 15 additions & 7 deletions proto/osmosis/tokenfactory/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ message MsgMint {
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.nullable) = false
];
string mintToAddress = 3
[ (gogoproto.moretags) = "yaml:\"mint_to_address\"" ];
string mintToAddress = 3 [
(gogoproto.moretags) = "yaml:\"mint_to_address\"",
(amino.dont_omitempty) = true
];
}

message MsgMintResponse {}
Expand All @@ -75,8 +77,10 @@ message MsgBurn {
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.nullable) = false
];
string burnFromAddress = 3
[ (gogoproto.moretags) = "yaml:\"burn_from_address\"" ];
string burnFromAddress = 3 [
(gogoproto.moretags) = "yaml:\"burn_from_address\"",
(amino.dont_omitempty) = true
];
}

message MsgBurnResponse {}
Expand All @@ -98,12 +102,14 @@ message MsgChangeAdminResponse {}
// MsgSetBeforeSendHook is the sdk.Msg type for allowing an admin account to
// assign a CosmWasm contract to call with a BeforeSend hook
message MsgSetBeforeSendHook {
option (amino.name) = "osmosis/tokenfactory/set-beforesend-hook";
option (amino.name) = "osmosis/tokenfactory/set-bef-send-hook";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ];
string cosmwasm_address = 3
[ (gogoproto.moretags) = "yaml:\"cosmwasm_address\"" ];
string cosmwasm_address = 3 [
(gogoproto.moretags) = "yaml:\"cosmwasm_address\"",
(amino.dont_omitempty) = true
];
}

// MsgSetBeforeSendHookResponse defines the response structure for an executed
Expand All @@ -113,6 +119,8 @@ message MsgSetBeforeSendHookResponse {}
// MsgSetDenomMetadata is the sdk.Msg type for allowing an admin account to set
// the denom's bank metadata
message MsgSetDenomMetadata {
option (amino.name) = "osmosis/tokenfactory/set-denom-metadata";

string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
cosmos.bank.v1beta1.Metadata metadata = 2 [
(gogoproto.moretags) = "yaml:\"metadata\"",
Expand Down
2 changes: 1 addition & 1 deletion x/tokenfactory/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (AppModuleBasic) Name() string {
}

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
types.RegisterLegacyAminoCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
Expand Down
37 changes: 23 additions & 14 deletions x/tokenfactory/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@ package types

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec"
groupcodec "github.com/cosmos/cosmos-sdk/x/group/codec"

// this line is used by starport scaffolding # 1
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgCreateDenom{}, "osmosis/tokenfactory/create-denom", nil)
cdc.RegisterConcrete(&MsgMint{}, "osmosis/tokenfactory/mint", nil)
cdc.RegisterConcrete(&MsgBurn{}, "osmosis/tokenfactory/burn", nil)
cdc.RegisterConcrete(&MsgForceTransfer{}, "osmosis/tokenfactory/force-transfer", nil)
cdc.RegisterConcrete(&MsgChangeAdmin{}, "osmosis/tokenfactory/change-admin", nil)
cdc.RegisterConcrete(&MsgSetBeforeSendHook{}, "osmosis/tokenfactory/set-beforesend-hook", nil)
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgCreateDenom{}, "osmosis/tokenfactory/create-denom")
legacy.RegisterAminoMsg(cdc, &MsgMint{}, "osmosis/tokenfactory/mint")
legacy.RegisterAminoMsg(cdc, &MsgBurn{}, "osmosis/tokenfactory/burn")
legacy.RegisterAminoMsg(cdc, &MsgChangeAdmin{}, "osmosis/tokenfactory/change-admin")
legacy.RegisterAminoMsg(cdc, &MsgSetDenomMetadata{}, "osmosis/tokenfactory/set-denom-metadata")
legacy.RegisterAminoMsg(cdc, &MsgSetBeforeSendHook{}, "osmosis/tokenfactory/set-bef-send-hook")
legacy.RegisterAminoMsg(cdc, &MsgForceTransfer{}, "osmosis/tokenfactory/force-transfer")
}

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
Expand All @@ -25,24 +30,28 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
&MsgCreateDenom{},
&MsgMint{},
&MsgBurn{},
// &MsgForceTransfer{},
&MsgChangeAdmin{},
&MsgSetDenomMetadata{},
&MsgSetBeforeSendHook{},
&MsgForceTransfer{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
RegisterCodec(authzcodec.Amino)

amino.Seal()

// Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(groupcodec.Amino)
Comment on lines +54 to +56
Copy link
Member

Choose a reason for hiding this comment

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

annoying that we need to do this :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I hope we can remove these in newer versions with textual sign mode

}
116 changes: 59 additions & 57 deletions x/tokenfactory/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.