Skip to content

Commit

Permalink
Merge pull request #113 from Lorenzo-Protocol/oris/amino-types
Browse files Browse the repository at this point in the history
amino: impl legacy msg to support eip-712
  • Loading branch information
sheldonleedev authored Aug 21, 2024
2 parents db2b809 + 0a05991 commit c9ea3e7
Show file tree
Hide file tree
Showing 35 changed files with 905 additions and 315 deletions.
6 changes: 5 additions & 1 deletion proto/lorenzo/agent/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package lorenzo.agent.v1;
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "gogoproto/gogo.proto";

import "amino/amino.proto";
import "lorenzo/agent/v1/params.proto";

option go_package = "github.com/Lorenzo-Protocol/lorenzo/v3/x/agent/types";
Expand All @@ -28,6 +28,7 @@ service Msg {

message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/agent/MsgUpdateParams";

// authority is the address of the governance account.
// just FYI: cosmos.AddressString marks that this field should use type alias
Expand All @@ -45,6 +46,7 @@ message MsgUpdateParamsResponse {}
// MsgUpdateParams defines a message for add a agent.
message MsgAddAgent {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/agent/MsgAddAgent";

// agent name,required
string name = 1;
Expand All @@ -69,6 +71,7 @@ message MsgAddAgentResponse {
// MsgEditAgent defines a message for editting the agent.
message MsgEditAgent {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/agent/MsgEditAgent";

// id is the unique identifier of the agent
uint64 id = 1;
Expand All @@ -88,6 +91,7 @@ message MsgEditAgentResponse {}
// MsgRemoveAgent defines a message for removing the agent.
message MsgRemoveAgent {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/agent/MsgRemoveAgent";

// id is the unique identifier of the agent
uint64 id = 1;
Expand Down
4 changes: 4 additions & 0 deletions proto/lorenzo/bnblightclient/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package lorenzo.bnblightclient.v1;
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "amino/amino.proto";
import "lorenzo/bnblightclient/v1/client.proto";
import "lorenzo/bnblightclient/v1/params.proto";

Expand All @@ -27,6 +28,7 @@ service Msg {
// MsgUploadHeaders defines the message for multiple incoming header bytes
message MsgUploadHeaders {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "lorenzo/bnblightclient/MsgUploadHeaders";

repeated lorenzo.bnblightclient.v1.Header headers = 1;
string signer = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
Expand All @@ -37,6 +39,7 @@ message MsgUploadHeadersResponse {}
// MsgUpdateHeader defines the message for updating bnb light client header.
message MsgUpdateHeader {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "lorenzo/bnblightclient/MsgUpdateHeader";

lorenzo.bnblightclient.v1.Header header = 1;
bool delete_subsequent_headers = 2;
Expand All @@ -49,6 +52,7 @@ message MsgUpdateHeaderResponse {}
// MsgUpdateParams defines a message for updating fee module parameters.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/bnblightclient/MsgUpdateParams";

// authority is the address of the governance account.
// just FYI: cosmos.AddressString marks that this field should use type alias
Expand Down
4 changes: 4 additions & 0 deletions proto/lorenzo/btclightclient/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package lorenzo.btclightclient.v1;
import "gogoproto/gogo.proto";
import "cosmos/msg/v1/msg.proto";
import "lorenzo/btclightclient/v1/params.proto";
import "amino/amino.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/Lorenzo-Protocol/lorenzo/v3/x/btclightclient/types";
Expand All @@ -25,6 +26,7 @@ service Msg {
// MsgInsertHeaders defines the message for multiple incoming header bytes
message MsgInsertHeaders {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "lorenzo/btclightclient/MsgInsertHeaders";

string signer = 1;
repeated bytes headers = 2
Expand All @@ -39,6 +41,7 @@ message MsgInsertHeadersResponse {}
// parameters.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/btclightclient/MsgUpdateParams";

// authority is the address of the governance account.
// just FYI: cosmos.AddressString marks that this field should use type alias
Expand All @@ -57,6 +60,7 @@ message MsgUpdateParamsResponse {}

message MsgUpdateFeeRate {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "lorenzo/btclightclient/MsgUpdateFeeRate";

string signer = 1;
// sat/vbyte * 1000
Expand Down
10 changes: 9 additions & 1 deletion proto/lorenzo/btcstaking/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package lorenzo.btcstaking.v1;
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "lorenzo/btcstaking/v1/params.proto";
// import "cosmos/staking/v1beta1/staking.proto";

option go_package = "github.com/Lorenzo-Protocol/lorenzo/v3/x/btcstaking/types";

Expand Down Expand Up @@ -55,6 +55,8 @@ message TransactionInfo {

message MsgCreateBTCStaking {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "lorenzo/btcstaking/MsgCreateBTCStaking";

string signer = 1;
TransactionInfo staking_tx = 2;
// deprecated
Expand All @@ -66,6 +68,7 @@ message MsgCreateBTCStakingResponse {}

message MsgCreateBTCBStaking {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "lorenzo/btcstaking/MsgCreateBTCBStaking";

string signer = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
uint64 number = 2;
Expand All @@ -77,6 +80,8 @@ message MsgCreateBTCBStakingResponse {}

message MsgBurnRequest {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "lorenzo/btcstaking/MsgBurnRequest";

string signer = 1;
string btc_target_address = 2;
string amount = 3 [
Expand All @@ -89,6 +94,7 @@ message MsgBurnResponse {}

message MsgAddReceiver {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/btcstaking/MsgAddReceiver";

string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

Expand All @@ -98,6 +104,7 @@ message MsgAddReceiver {
message MsgAddReceiverResponse {}
message MsgRemoveReceiver {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/btcstaking/MsgRemoveReceiver";

string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

Expand All @@ -106,6 +113,7 @@ message MsgRemoveReceiver {
message MsgRemoveReceiverResponse {}
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/btcstaking/MsgUpdateParams";

string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

Expand Down
2 changes: 2 additions & 0 deletions proto/lorenzo/fee/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package lorenzo.fee.v1;
import "gogoproto/gogo.proto";
import "cosmos/msg/v1/msg.proto";
import "lorenzo/fee/v1/params.proto";
import "amino/amino.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/Lorenzo-Protocol/lorenzo/v3/x/fee/types";
Expand All @@ -19,6 +20,7 @@ service Msg {
// MsgUpdateParams defines a message for updating fee module parameters.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/fee/MsgUpdateParams";

// authority is the address of the governance account.
// just FYI: cosmos.AddressString marks that this field should use type alias
Expand Down
13 changes: 10 additions & 3 deletions proto/lorenzo/plan/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package lorenzo.plan.v1;
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "gogoproto/gogo.proto";

import "amino/amino.proto";
import "lorenzo/plan/v1/params.proto";
import "lorenzo/plan/v1/plan.proto";

Expand Down Expand Up @@ -46,7 +46,7 @@ service Msg {
// MsgUpdateParams is the request type for the Msg/UpdateParams RPC method.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";

option (amino.name) = "lorenzo/plan/MsgUpdateParams";
// authority is the address of the governance account.
// just FYI: cosmos.AddressString marks that this field should use type alias
// for AddressString instead of string, but the functionality is not yet
Expand All @@ -64,7 +64,7 @@ message MsgUpdateParamsResponse {}
// MsgUpgradePlan is the request type for the Msg/UpgradePlan RPC method.
message MsgUpgradePlan {
option (cosmos.msg.v1.signer) = "authority";

option (amino.name) = "lorenzo/plan/MsgUpgradePlan";
// implementation is the new yat logic contract address
string implementation = 1;

Expand All @@ -81,6 +81,7 @@ message MsgUpgradePlanResponse {}
// MsgCreatePlan is the request type for the Msg/CreatePlan RPC method.
message MsgCreatePlan {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/plan/MsgCreatePlan";

// name is the name of the plan
string name = 1;
Expand Down Expand Up @@ -113,6 +114,7 @@ message MsgCreatePlanResponse {
// MsgSetMerkleRoot is the request type for the Msg/SetMerkleRoot RPC method.
message MsgSetMerkleRoot {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/plan/MsgSetMerkleRoot";

// plan_id is the unique identifier of the plan
uint64 plan_id = 1;
Expand All @@ -137,6 +139,7 @@ message MsgSetMerkleRootResponse {}
// MsgClaims is the request type for the Msg/Claims RPC method.
message MsgClaims {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/plan/MsgClaims";

// plan_id is the unique identifier of the plan
uint64 plan_id = 1;
Expand Down Expand Up @@ -170,6 +173,7 @@ message MsgClaimsResponse {}
// method.
message MsgUpdatePlanStatus {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/plan/MsgUpdatePlanStatus";

// plan_id is the unique identifier of the plan
uint64 plan_id = 1;
Expand All @@ -188,6 +192,7 @@ message MsgUpdatePlanStatusResponse {}
// MsgCreateYAT is the request type for the Msg/CreateYAT RPC method.
message MsgCreateYAT {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/plan/MsgCreateYAT";

// name is the name of the yat contract
string name = 1;
Expand All @@ -208,6 +213,7 @@ message MsgCreateYATResponse {
// MsgSetMinter is the request type for the Msg/SetMinter RPC method.
message MsgSetMinter {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/plan/MsgSetMinter";

// minter is the address of the minter
string minter = 1;
Expand All @@ -225,6 +231,7 @@ message MsgSetMinterResponse {}
// MsgRemoveMinter is the request type for the Msg/RemoveMinter RPC method.
message MsgRemoveMinter {
option (cosmos.msg.v1.signer) = "sender";
option (amino.name) = "lorenzo/plan/MsgRemoveMinter";

// minter is the address of the minter
string minter = 1;
Expand Down
13 changes: 13 additions & 0 deletions proto/lorenzo/token/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/bank/v1beta1/bank.proto";
import "amino/amino.proto";
import "lorenzo/token/v1/genesis.proto";

option go_package = "github.com/Lorenzo-Protocol/lorenzo/v3/x/token/types";
Expand All @@ -31,6 +32,8 @@ service Msg {
// NOTE: this is a governance message.
message MsgRegisterCoin {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/token/MsgRegisterCoin";

// authority is the address that can update the parameters
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// metadata slice of coins
Expand All @@ -44,6 +47,8 @@ message MsgRegisterCoinResponse {}
// NOTE: this is a governance message.
message MsgRegisterERC20 {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/token/MsgRegisterERC20";

// authority is the address that can update the parameters
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// metadata slice of erc20 token contract addresses
Expand All @@ -56,6 +61,8 @@ message MsgRegisterERC20Response {}
// NOTE: this is a governance message.
message MsgToggleConversion {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/token/MsgToggleConversion";

// authority is the address that can update the parameters
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// token is in format of either coin base denom or erc20 contract address
Expand All @@ -66,6 +73,8 @@ message MsgToggleConversionResponse {}

// MsgConvertCoin converts a coin to an ERC20 token
message MsgConvertCoin {
option (amino.name) = "lorenzo/token/MsgConvertCoin";

// coin to be converted
cosmos.base.v1beta1.Coin coin = 1 [ (gogoproto.nullable) = false ];
// receiver of the erc20 token, evm hex format address.
Expand All @@ -78,6 +87,8 @@ message MsgConvertCoinResponse {}

// MsgConvertERC20 converts an ERC20 token to a coin
message MsgConvertERC20 {
option (amino.name) = "lorenzo/token/MsgConvertERC20";

// contract address of the ERC20 token
string contract_address = 1;
// amount of tokens to be converted
Expand All @@ -96,6 +107,8 @@ message MsgConvertERC20Response {}
// MsgUpdateParams updates the convert module parameters
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "lorenzo/token/MsgUpdateParams";

// authority is the address that can update the parameters
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// params are the new parameters
Expand Down
4 changes: 3 additions & 1 deletion x/agent/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func (AppModuleBasic) Name() string {
}

// RegisterLegacyAminoCodec registers the module's types for the given codec.
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
func (a AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
Expand Down
18 changes: 18 additions & 0 deletions x/agent/types/codec.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
package types

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

var (
amino = codec.NewLegacyAmino()
AminoCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
}

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgUpdateParams{}, "lorenzo/agent/MsgUpdateParams", nil)
cdc.RegisterConcrete(&MsgAddAgent{}, "lorenzo/agent/MsgAddAgent", nil)
cdc.RegisterConcrete(&MsgEditAgent{}, "lorenzo/agent/MsgEditAgent", nil)
cdc.RegisterConcrete(&MsgRemoveAgent{}, "lorenzo/agent/MsgRemoveAgent", nil)
}

// RegisterInterfaces registers implementations for sdk.Msg and MsgUpdateParams in the given InterfaceRegistry.
//
// Parameter:
Expand All @@ -15,6 +32,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
&MsgAddAgent{},
&MsgEditAgent{},
&MsgRemoveAgent{},
&MsgUpdateParams{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
Loading

0 comments on commit c9ea3e7

Please sign in to comment.