From 0943940005851b44a99020ca4f6c034c7e20761b Mon Sep 17 00:00:00 2001 From: Yun Yeo Date: Fri, 9 Jul 2021 15:21:51 +0900 Subject: [PATCH] register feegrant amino codec to support legacy service --- app/app.go | 3 ++- custom/feegrant/module.go | 23 +++++++++++++++++++++++ custom/feegrant/types/codec.go | 18 ++++++++++++++++++ signed_tx.json | 1 + unsigned_tx.json | 2 +- 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 custom/feegrant/module.go create mode 100644 custom/feegrant/types/codec.go create mode 100644 signed_tx.json diff --git a/app/app.go b/app/app.go index c497ac5bc..1619b3b9c 100644 --- a/app/app.go +++ b/app/app.go @@ -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" @@ -169,7 +170,7 @@ var ( customparams.AppModuleBasic{}, customcrisis.AppModuleBasic{}, customslashing.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, + customfeegrant.AppModuleBasic{}, ibc.AppModuleBasic{}, customupgrade.AppModuleBasic{}, customevidence.AppModuleBasic{}, diff --git a/custom/feegrant/module.go b/custom/feegrant/module.go new file mode 100644 index 000000000..18e952867 --- /dev/null +++ b/custom/feegrant/module.go @@ -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) +} diff --git a/custom/feegrant/types/codec.go b/custom/feegrant/types/codec.go new file mode 100644 index 000000000..c00ef7c70 --- /dev/null +++ b/custom/feegrant/types/codec.go @@ -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) +} diff --git a/signed_tx.json b/signed_tx.json new file mode 100644 index 000000000..400b45293 --- /dev/null +++ b/signed_tx.json @@ -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=="]} diff --git a/unsigned_tx.json b/unsigned_tx.json index 48c08e9c6..f5255f883 100644 --- a/unsigned_tx.json +++ b/unsigned_tx.json @@ -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":[]}