Skip to content

Commit

Permalink
feat: add amino signing support to tokenfactory messages (#7139)
Browse files Browse the repository at this point in the history
* feat: add amino signing support to tokenfactory messages

* docs: add changelog entry
  • Loading branch information
madrezaz authored Jan 2, 2024
1 parent 2f3191b commit 2a64b0b
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 79 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Epoch optimizations are in this release, see a subset of PR links in v21.1.3 sec
### Features

* [#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)
}
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.

0 comments on commit 2a64b0b

Please sign in to comment.