Skip to content

Commit

Permalink
register feegrant amino codec to support legacy service
Browse files Browse the repository at this point in the history
  • Loading branch information
yun-yeo committed Jul 9, 2021
1 parent ba32a5e commit 0943940
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import (
customcrisis "github.com/terra-money/core/custom/crisis"
customdistr "github.com/terra-money/core/custom/distribution"
customevidence "github.com/terra-money/core/custom/evidence"
customfeegrant "github.com/terra-money/core/custom/feegrant"
customgov "github.com/terra-money/core/custom/gov"
custommint "github.com/terra-money/core/custom/mint"
customparams "github.com/terra-money/core/custom/params"
Expand Down Expand Up @@ -169,7 +170,7 @@ var (
customparams.AppModuleBasic{},
customcrisis.AppModuleBasic{},
customslashing.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
customfeegrant.AppModuleBasic{},
ibc.AppModuleBasic{},
customupgrade.AppModuleBasic{},
customevidence.AppModuleBasic{},
Expand Down
23 changes: 23 additions & 0 deletions custom/feegrant/module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package feegrant

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module"
feegrant "github.com/cosmos/cosmos-sdk/x/feegrant/module"

customtypes "github.com/terra-money/core/custom/feegrant/types"
)

var (
_ module.AppModuleBasic = AppModuleBasic{}
)

// AppModuleBasic defines the basic application module used by the distribution module.
type AppModuleBasic struct {
feegrant.AppModuleBasic
}

// RegisterLegacyAminoCodec registers the bank module's types for the given codec.
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
customtypes.RegisterLegacyAminoCodec(cdc)
}
18 changes: 18 additions & 0 deletions custom/feegrant/types/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package types

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)

// RegisterLegacyAminoCodec registers the necessary x/authz interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterInterface((*feegrant.FeeAllowanceI)(nil), nil)

cdc.RegisterConcrete(&feegrant.MsgGrantAllowance{}, "feegrant/MsgGrantAllowance", nil)
cdc.RegisterConcrete(&feegrant.MsgRevokeAllowance{}, "feegrant/MsgRevokeAllowance", nil)
cdc.RegisterConcrete(&feegrant.BasicAllowance{}, "feegrant/BasicAllowance", nil)
cdc.RegisterConcrete(&feegrant.PeriodicAllowance{}, "feegrant/PeriodicAllowance", nil)
cdc.RegisterConcrete(&feegrant.AllowedMsgAllowance{}, "feegrant/AllowedMsgAllowance", nil)
}
1 change: 1 addition & 0 deletions signed_tx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"body":{"messages":[{"@type":"/cosmos.feegrant.v1beta1.MsgGrantAllowance","granter":"terra1t849fxw7e8ney35mxemh4h3ayea4zf77dslwna","grantee":"terra1ucp369yry6n70qq3zaxyt85cnug75r7ln8l6se","allowance":{"@type":"/cosmos.feegrant.v1beta1.BasicAllowance","spend_limit":[{"denom":"uluna","amount":"1000000"}],"expiration":"2022-01-01T00:00:00Z"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A4p3L23DzwwM6JnbLyY1xdgAl5ewiYPBQU+cD7Jzqwu7"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"12"}],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":["sXJnHYbymwd3G0ax2gYMVt6K2m60YppZ5UYuM4TOkwkeTwFqcX0SR57cC5THRxnt47xJUif6N+aqXFUkg+Eh7w=="]}
2 changes: 1 addition & 1 deletion unsigned_tx.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"terra1t849fxw7e8ney35mxemh4h3ayea4zf77dslwna","to_address":"terra18h5pmhrz45z2ne7lz4nfd7cdfwl3jfeu99e7a5","amount":[{"denom":"ukrw","amount":"1000000"}]}],"memo":"return gov deposits","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[{"denom":"ukrw","amount":"100"}],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
{"body":{"messages":[{"@type":"/cosmos.feegrant.v1beta1.MsgGrantAllowance","granter":"terra1t849fxw7e8ney35mxemh4h3ayea4zf77dslwna","grantee":"terra1ucp369yry6n70qq3zaxyt85cnug75r7ln8l6se","allowance":{"@type":"/cosmos.feegrant.v1beta1.BasicAllowance","spend_limit":[{"denom":"uluna","amount":"1000000"}],"expiration":"2022-01-01T00:00:00Z"}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}

0 comments on commit 0943940

Please sign in to comment.