diff --git a/CHANGELOG.md b/CHANGELOG.md index aaf3396b4..58f34fb7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Unreleased ### Features - +- [755](https://github.com/persistenceOne/pstake-native/pull/755) Add channel-id, port to ratesync host-chains and liquidstake instantiate. - [737](https://github.com/persistenceOne/pstake-native/pull/737) Unhandled errors. - [736](https://github.com/persistenceOne/pstake-native/pull/736) Check for host denom duplicates. - [733](https://github.com/persistenceOne/pstake-native/pull/733) Add more validation for host-chain. diff --git a/proto/pstake/ratesync/v1beta1/contract.proto b/proto/pstake/ratesync/v1beta1/contract.proto index f150079a8..049961db7 100644 --- a/proto/pstake/ratesync/v1beta1/contract.proto +++ b/proto/pstake/ratesync/v1beta1/contract.proto @@ -9,12 +9,15 @@ option go_package = "github.com/persistenceOne/pstake-native/v2/x/ratesync/types // msg blob for instantiate contract. message InstantiateLiquidStakeRateContract { - string admin = 1[(cosmos_proto.scalar) = "cosmos.AddressString"]; + string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + string transfer_channel_i_d = 2; + string transfer_port_i_d = 3; } -// wrapper for liquidstakerate as wasm msg should be marshalled as encodedMsg = { wasmMsg: { wasm MsgDetails } } -message ExecuteLiquidStakeRate{ - LiquidStakeRate liquid_stake_rate = 1[(gogoproto.nullable) = false]; +// wrapper for liquidstakerate as wasm msg should be marshalled as encodedMsg = +// { wasmMsg: { wasm MsgDetails } } +message ExecuteLiquidStakeRate { + LiquidStakeRate liquid_stake_rate = 1 [ (gogoproto.nullable) = false ]; } // msg blob for execute contract. @@ -23,6 +26,10 @@ message LiquidStakeRate { string stk_denom = 2; // cvalue = default_bond_denom_price/stk_denom_price // cvalue = stk_denom_supply/default_bond_denom_supply - string c_value = 3[(gogoproto.nullable) = false, (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec"]; + string c_value = 3 [ + (gogoproto.nullable) = false, + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec" + ]; int64 controller_chain_time = 4; } \ No newline at end of file diff --git a/proto/pstake/ratesync/v1beta1/genesis.proto b/proto/pstake/ratesync/v1beta1/genesis.proto index 21f7d0ae0..b02b2319b 100644 --- a/proto/pstake/ratesync/v1beta1/genesis.proto +++ b/proto/pstake/ratesync/v1beta1/genesis.proto @@ -9,6 +9,6 @@ option go_package = "github.com/persistenceOne/pstake-native/v2/x/ratesync/types // GenesisState defines the ratesync module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; - repeated HostChain host_chains = 2 [(gogoproto.nullable) = false]; + Params params = 1 [ (gogoproto.nullable) = false ]; + repeated HostChain host_chains = 2 [ (gogoproto.nullable) = false ]; } diff --git a/proto/pstake/ratesync/v1beta1/params.proto b/proto/pstake/ratesync/v1beta1/params.proto index e003b3152..a1ae5452c 100644 --- a/proto/pstake/ratesync/v1beta1/params.proto +++ b/proto/pstake/ratesync/v1beta1/params.proto @@ -10,5 +10,5 @@ option go_package = "github.com/persistenceOne/pstake-native/v2/x/ratesync/types message Params { option (gogoproto.goproto_stringer) = false; - string admin = 1[(cosmos_proto.scalar) = "cosmos.AddressString"]; + string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } diff --git a/proto/pstake/ratesync/v1beta1/query.proto b/proto/pstake/ratesync/v1beta1/query.proto index f1bf40ab7..61933ce7b 100644 --- a/proto/pstake/ratesync/v1beta1/query.proto +++ b/proto/pstake/ratesync/v1beta1/query.proto @@ -16,15 +16,14 @@ service Query { option (google.api.http).get = "/pstake/ratesync/v1beta1/params"; } - // Queries a list of Chain items. - rpc HostChain (QueryGetHostChainRequest) returns (QueryGetHostChainResponse) { - option (google.api.http).get = "/pstake-native/v2/ratesync/host_chain/{i_d}"; - + rpc HostChain(QueryGetHostChainRequest) returns (QueryGetHostChainResponse) { + option (google.api.http).get = + "/pstake-native/v2/ratesync/host_chain/{i_d}"; } - rpc AllHostChains (QueryAllHostChainsRequest) returns (QueryAllHostChainsResponse) { + rpc AllHostChains(QueryAllHostChainsRequest) + returns (QueryAllHostChainsResponse) { option (google.api.http).get = "/pstake-native/v2/ratesync/host_chains"; - } } @@ -34,15 +33,13 @@ message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { // params holds all the parameters of this module. - Params params = 1 [(gogoproto.nullable) = false]; + Params params = 1 [ (gogoproto.nullable) = false ]; } -message QueryGetHostChainRequest { - uint64 i_d = 1; -} +message QueryGetHostChainRequest { uint64 i_d = 1; } message QueryGetHostChainResponse { - HostChain host_chain = 1 [(gogoproto.nullable) = false]; + HostChain host_chain = 1 [ (gogoproto.nullable) = false ]; } message QueryAllHostChainsRequest { @@ -50,6 +47,6 @@ message QueryAllHostChainsRequest { } message QueryAllHostChainsResponse { - repeated HostChain host_chains = 1 [(gogoproto.nullable) = false]; + repeated HostChain host_chains = 1 [ (gogoproto.nullable) = false ]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/proto/pstake/ratesync/v1beta1/ratesync.proto b/proto/pstake/ratesync/v1beta1/ratesync.proto index cc90b7032..2a59970db 100644 --- a/proto/pstake/ratesync/v1beta1/ratesync.proto +++ b/proto/pstake/ratesync/v1beta1/ratesync.proto @@ -8,25 +8,31 @@ import "amino/amino.proto"; option go_package = "github.com/persistenceOne/pstake-native/v2/x/ratesync/types"; // HostChain defines the ratesync module's HostChain state. -message HostChain{ +message HostChain { // unique id uint64 i_d = 1; - string chain_i_d = 2; //not really required, just easier readability + string chain_i_d = 2; // not really required, just easier readability string connection_i_d = 3; - pstake.liquidstakeibc.v1beta1.ICAAccount i_c_a_account = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; - Feature features = 5 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + pstake.liquidstakeibc.v1beta1.ICAAccount i_c_a_account = 4 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; + Feature features = 5 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; + string transfer_channel_i_d = 6; + string transfer_port_i_d = 7; } -message Feature{ +message Feature { // triggers on hooks - LiquidStake liquid_stake_i_b_c = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + LiquidStake liquid_stake_i_b_c = 1 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; // triggers on hour epoch - LiquidStake liquid_stake = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + LiquidStake liquid_stake = 2 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; - //add more features + // add more features } -enum InstantiationState{ +enum InstantiationState { // Not Initiated INSTANTIATION_NOT_INITIATED = 0; // Initiated @@ -40,16 +46,18 @@ enum FeatureType { LIQUID_STAKE = 1; } -message LiquidStake{ +message LiquidStake { FeatureType feature_type = 1; // needs to be uploaded before hand uint64 code_i_d = 2; - // state of instantiation, do not support gov based instantiation. (need ICA to be at least admin) + // state of instantiation, do not support gov based instantiation. (need ICA + // to be at least admin) InstantiationState instantiation = 3; // address of instantiated contract. string contract_address = 4; - // allow * as default for all denoms in case of lsibc, or default bond denom in case of ls. + // allow * as default for all denoms in case of lsibc, or default bond denom + // in case of ls. repeated string denoms = 5; bool enabled = 6; @@ -60,4 +68,3 @@ message ICAMemo { FeatureType feature_type = 1; uint64 host_chain_i_d = 2; } - diff --git a/proto/pstake/ratesync/v1beta1/tx.proto b/proto/pstake/ratesync/v1beta1/tx.proto index 87de83a71..883add883 100644 --- a/proto/pstake/ratesync/v1beta1/tx.proto +++ b/proto/pstake/ratesync/v1beta1/tx.proto @@ -13,30 +13,30 @@ option go_package = "github.com/persistenceOne/pstake-native/v2/x/ratesync/types // Msg defines the Msg service. service Msg { - rpc CreateHostChain (MsgCreateHostChain) returns (MsgCreateHostChainResponse); - rpc UpdateHostChain (MsgUpdateHostChain) returns (MsgUpdateHostChainResponse); - rpc DeleteHostChain (MsgDeleteHostChain) returns (MsgDeleteHostChainResponse); - rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc CreateHostChain(MsgCreateHostChain) returns (MsgCreateHostChainResponse); + rpc UpdateHostChain(MsgUpdateHostChain) returns (MsgUpdateHostChainResponse); + rpc DeleteHostChain(MsgDeleteHostChain) returns (MsgDeleteHostChainResponse); + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } message MsgCreateHostChain { option (cosmos.msg.v1.signer) = "authority"; option (amino.name) = "pstake/ratesync/MsgCreateHostChain"; - string authority = 1[(cosmos_proto.scalar) = "cosmos.AddressString"]; - HostChain host_chain = 2[(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + HostChain host_chain = 2 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } -message MsgCreateHostChainResponse { - uint64 i_d = 1; -} +message MsgCreateHostChainResponse { uint64 i_d = 1; } message MsgUpdateHostChain { option (cosmos.msg.v1.signer) = "authority"; option (amino.name) = "pstake/ratesync/MsgUpdateHostChain"; - string authority = 1[(cosmos_proto.scalar) = "cosmos.AddressString"]; - HostChain host_chain = 2[(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + HostChain host_chain = 2 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } message MsgUpdateHostChainResponse {} @@ -45,7 +45,7 @@ message MsgDeleteHostChain { option (cosmos.msg.v1.signer) = "authority"; option (amino.name) = "pstake/ratesync/MsgDeleteHostChain"; - string authority = 1[(cosmos_proto.scalar) = "cosmos.AddressString"]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; uint64 i_d = 2; } @@ -55,8 +55,9 @@ message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; option (amino.name) = "pstake/ratesync/MsgUpdateParams"; - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - Params params = 2[(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + Params params = 2 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } message MsgUpdateParamsResponse {} \ No newline at end of file diff --git a/x/liquidstakeibc/types/params.pb.go b/x/liquidstakeibc/types/params.pb.go index 479cc85fe..643a1778d 100644 --- a/x/liquidstakeibc/types/params.pb.go +++ b/x/liquidstakeibc/types/params.pb.go @@ -87,25 +87,26 @@ func init() { } var fileDescriptor_ed8bf02c8aabc0b0 = []byte{ - // 281 bytes of a gzipped FileDescriptorProto + // 293 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2a, 0x28, 0x2e, 0x49, 0xcc, 0x4e, 0xd5, 0xcf, 0xc9, 0x2c, 0x2c, 0xcd, 0x4c, 0x01, 0xb3, 0x33, 0x93, 0x92, 0xf5, 0xcb, 0x0c, 0x93, 0x52, 0x4b, 0x12, 0x0d, 0xf5, 0x0b, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x64, 0x21, 0x6a, 0xf5, 0x50, 0xd5, 0xea, 0x41, 0xd5, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, 0xea, 0x83, 0x58, 0x10, 0x4d, 0x52, 0x92, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0x10, 0x09, 0x08, 0x07, 0x2a, 0x25, 0x98, 0x98, 0x9b, 0x99, 0x97, 0xaf, 0x0f, - 0x26, 0x21, 0x42, 0x4a, 0xcb, 0x19, 0xb9, 0xd8, 0x02, 0xc0, 0x76, 0x0a, 0xd9, 0x72, 0xf1, 0x26, + 0x26, 0x21, 0x42, 0x4a, 0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, 0x60, 0x2a, 0xd0, 0x83, 0x06, 0xe2, 0x3c, 0x2f, 0x16, 0x0e, 0x66, 0x01, + 0x16, 0x2f, 0x16, 0x0e, 0x16, 0x01, 0x56, 0xa7, 0xe8, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, + 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, + 0x96, 0x63, 0x88, 0x72, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x2f, + 0x48, 0x2d, 0x2a, 0xce, 0x2c, 0x2e, 0x49, 0xcd, 0x4b, 0x4e, 0xf5, 0xcf, 0x4b, 0xd5, 0x87, 0x98, + 0xaf, 0x9b, 0x97, 0x58, 0x92, 0x59, 0x96, 0xaa, 0x5f, 0x66, 0x84, 0x69, 0x53, 0x49, 0x65, 0x41, + 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x64, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x47, 0x82, + 0xbe, 0xaa, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/ratesync/keeper/chain_test.go b/x/ratesync/keeper/chain_test.go index 81473354e..427131ba2 100644 --- a/x/ratesync/keeper/chain_test.go +++ b/x/ratesync/keeper/chain_test.go @@ -43,6 +43,8 @@ var ValidHostChainInMsg = func(id uint64) types.HostChain { Enabled: false, }, }, + TransferChannelID: "channel-0", + TransferPortID: "transfer", } } diff --git a/x/ratesync/keeper/ibc_test.go b/x/ratesync/keeper/ibc_test.go index 81e301695..3146eb444 100644 --- a/x/ratesync/keeper/ibc_test.go +++ b/x/ratesync/keeper/ibc_test.go @@ -27,7 +27,7 @@ func (suite *IntegrationTestSuite) TestOnAcknowledgementPacket() { hc, _ := k.GetHostChain(ctx, 1) // case 1, instantiate msg. { - msg, memo, err := keeper.GenerateInstantiateLiquidStakeContractMsg(hc.ICAAccount, hc.Features.LiquidStakeIBC, hc.ID) + msg, memo, err := keeper.GenerateInstantiateLiquidStakeContractMsg(hc.ICAAccount, hc.Features.LiquidStakeIBC, hc.ID, hc.TransferChannelID, hc.TransferPortID) suite.Require().NoError(err) msgData, err := icatypes.SerializeCosmosTx(suite.app.AppCodec(), []proto.Message{msg}) suite.Require().NoError(err) @@ -59,7 +59,7 @@ func (suite *IntegrationTestSuite) TestOnAcknowledgementPacket() { } // case 2 instantiate failure { - msg, memo, err := keeper.GenerateInstantiateLiquidStakeContractMsg(hc.ICAAccount, hc.Features.LiquidStakeIBC, hc.ID) + msg, memo, err := keeper.GenerateInstantiateLiquidStakeContractMsg(hc.ICAAccount, hc.Features.LiquidStakeIBC, hc.ID, hc.TransferChannelID, hc.TransferPortID) suite.Require().NoError(err) msgData, err := icatypes.SerializeCosmosTx(suite.app.AppCodec(), []proto.Message{msg}) suite.Require().NoError(err) @@ -142,7 +142,7 @@ func (suite *IntegrationTestSuite) TestOnTimeoutPacket() { hc, _ := k.GetHostChain(ctx, 1) // case 1, instantiate msg. { - msg, memo, err := keeper.GenerateInstantiateLiquidStakeContractMsg(hc.ICAAccount, hc.Features.LiquidStakeIBC, hc.ID) + msg, memo, err := keeper.GenerateInstantiateLiquidStakeContractMsg(hc.ICAAccount, hc.Features.LiquidStakeIBC, hc.ID, hc.TransferChannelID, hc.TransferPortID) suite.Require().NoError(err) msgData, err := icatypes.SerializeCosmosTx(suite.app.AppCodec(), []proto.Message{msg}) suite.Require().NoError(err) diff --git a/x/ratesync/keeper/ica_tx.go b/x/ratesync/keeper/ica_tx.go index 761118965..a2417640f 100644 --- a/x/ratesync/keeper/ica_tx.go +++ b/x/ratesync/keeper/ica_tx.go @@ -148,10 +148,10 @@ func GenerateExecuteLiquidStakeRateTxMsg(blockTime int64, feature types.LiquidSt } func (k *Keeper) InstantiateLiquidStakeContract(ctx sdk.Context, icaAccount liquidstakeibctypes.ICAAccount, - feature types.LiquidStake, id uint64, connectionID string, + feature types.LiquidStake, id uint64, connectionID, transferChannelID, transferPort string, ) error { // generate contract msg{msg} - msg, memoBz, err := GenerateInstantiateLiquidStakeContractMsg(icaAccount, feature, id) + msg, memoBz, err := GenerateInstantiateLiquidStakeContractMsg(icaAccount, feature, id, transferChannelID, transferPort) if err != nil { return err } @@ -163,10 +163,12 @@ func (k *Keeper) InstantiateLiquidStakeContract(ctx sdk.Context, icaAccount liqu } func GenerateInstantiateLiquidStakeContractMsg(icaAccount liquidstakeibctypes.ICAAccount, - feature types.LiquidStake, id uint64, + feature types.LiquidStake, id uint64, transferChannelID, transferPort string, ) (sdk.Msg, []byte, error) { contractMsg := types.InstantiateLiquidStakeRateContract{ - Admin: icaAccount.Address, + Admin: icaAccount.Address, + TransferChannelID: transferChannelID, + TransferPortID: transferPort, } contractMsgBz, err := json.Marshal(contractMsg) if err != nil { diff --git a/x/ratesync/keeper/ica_tx_test.go b/x/ratesync/keeper/ica_tx_test.go index 1d26acc2d..1801c6d58 100644 --- a/x/ratesync/keeper/ica_tx_test.go +++ b/x/ratesync/keeper/ica_tx_test.go @@ -11,5 +11,5 @@ func (suite *IntegrationTestSuite) TestExecuteLiquidStakeRateTx() { suite.Require().NoError(k.ExecuteLiquidStakeRateTx(ctx, hc.Features.LiquidStakeIBC, "stk/uatom", "uatom", sdk.OneDec(), hc.ID, suite.ratesyncPathAB.EndpointA.ConnectionID, hc.ICAAccount)) suite.Require().NoError(k.InstantiateLiquidStakeContract(ctx, hc.ICAAccount, - hc.Features.LiquidStake, hc.ID, suite.ratesyncPathAB.EndpointA.ConnectionID)) + hc.Features.LiquidStake, hc.ID, suite.ratesyncPathAB.EndpointA.ConnectionID, hc.TransferChannelID, hc.TransferPortID)) } diff --git a/x/ratesync/keeper/msg_server.go b/x/ratesync/keeper/msg_server.go index 8f7499574..fee744156 100644 --- a/x/ratesync/keeper/msg_server.go +++ b/x/ratesync/keeper/msg_server.go @@ -2,15 +2,12 @@ package keeper import ( "context" - "encoding/json" "fmt" "slices" errorsmod "cosmossdk.io/errors" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/gogoproto/proto" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" liquidstakeibctypes "github.com/persistenceOne/pstake-native/v2/x/liquidstakeibc/types" @@ -66,6 +63,18 @@ func (k msgServer) CreateHostChain(goCtx context.Context, msg *types.MsgCreateHo } } // else handled in validate basic (not allowed to create new host chain with previous ICA as portID is default and suffixed by ID + channel, found := k.ibcKeeper.ChannelKeeper.GetChannel(ctx, msg.HostChain.TransferPortID, msg.HostChain.TransferChannelID) + if !found || channel.State != channeltypes.OPEN { + if err != nil { + return nil, errorsmod.Wrapf( + sdkerrors.ErrNotFound, + "error creating %s ratesync with channel: %s, port: %s, err:%s", + chainID, msg.HostChain.TransferChannelID, msg.HostChain.TransferPortID, + err.Error(), + ) + } + } + k.SetHostChain( ctx, msg.HostChain, @@ -108,6 +117,15 @@ func (k msgServer) UpdateHostChain(goCtx context.Context, msg *types.MsgUpdateHo "connectionID mismatch got %s, found %s", msg.HostChain.ConnectionID, oldHC.ConnectionID) } + if msg.HostChain.TransferChannelID != oldHC.TransferChannelID { + return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid channelID, channelID cannot be updated, "+ + "channelID mismatch got %s, found %s", msg.HostChain.TransferChannelID, oldHC.TransferChannelID) + } + if msg.HostChain.TransferPortID != oldHC.TransferPortID { + return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid portID, portID cannot be updated, "+ + "portID mismatch got %s, found %s", msg.HostChain.TransferPortID, oldHC.TransferPortID) + } + if oldHC.ICAAccount.ChannelState != liquidstakeibctypes.ICAAccount_ICA_CHANNEL_CREATED { return nil, errorsmod.Wrapf(types.ErrInvalid, "invalid ICAAccount state, should already be active") } @@ -149,36 +167,10 @@ func (k msgServer) UpdateHostChain(goCtx context.Context, msg *types.MsgUpdateHo // update oldhc, generate and execute wasm instantiate oldHC.Features.LiquidStakeIBC = msg.HostChain.Features.LiquidStakeIBC - // generate contract msg{msg} - contractMsg := types.InstantiateLiquidStakeRateContract{ - Admin: oldHC.ICAAccount.Address, - } - contractMsgBz, err := json.Marshal(contractMsg) - if err != nil { - return nil, errorsmod.Wrapf(err, "unable to marshal InstantiateLiquidStakeRateContract") - } - - msg := &wasmtypes.MsgInstantiateContract{ - Sender: oldHC.ICAAccount.Address, - Admin: oldHC.ICAAccount.Address, - CodeID: oldHC.Features.LiquidStakeIBC.CodeID, - Label: fmt.Sprintf("PSTAKE ratesync, ID-%v", oldHC.ID), - Msg: contractMsgBz, - Funds: sdk.Coins{}, - } - memo := types.ICAMemo{ - FeatureType: types.FeatureType_LIQUID_STAKE_IBC, - HostChainID: oldHC.ID, - } - memobz, err := json.Marshal(memo) - if err != nil { - return nil, err - } - _, err = k.GenerateAndExecuteICATx(ctx, oldHC.ConnectionID, oldHC.ICAAccount.Owner, []proto.Message{msg}, string(memobz)) + err := k.InstantiateLiquidStakeContract(ctx, oldHC.ICAAccount, oldHC.Features.LiquidStakeIBC, oldHC.ID, oldHC.ConnectionID, oldHC.TransferChannelID, oldHC.TransferPortID) if err != nil { return nil, err } - case types.InstantiationState_INSTANTIATION_COMPLETED: // just update oldhc, validate basic will take care of mismatch states. oldHC.Features.LiquidStakeIBC = msg.HostChain.Features.LiquidStakeIBC @@ -200,36 +192,10 @@ func (k msgServer) UpdateHostChain(goCtx context.Context, msg *types.MsgUpdateHo // update oldhc, generate and execute wasm instantiate oldHC.Features.LiquidStake = msg.HostChain.Features.LiquidStake - // generate contract msg{msg} - contractMsg := types.InstantiateLiquidStakeRateContract{ - Admin: oldHC.ICAAccount.Address, - } - contractMsgBz, err := json.Marshal(contractMsg) - if err != nil { - return nil, errorsmod.Wrapf(err, "unable to marshal InstantiateLiquidStakeRateContract") - } - - msg := &wasmtypes.MsgInstantiateContract{ - Sender: oldHC.ICAAccount.Address, - Admin: oldHC.ICAAccount.Address, - CodeID: oldHC.Features.LiquidStake.CodeID, - Label: fmt.Sprintf("PSTAKE ratesync, ID-%v", oldHC.ID), - Msg: contractMsgBz, - Funds: sdk.Coins{}, - } - memo := types.ICAMemo{ - FeatureType: types.FeatureType_LIQUID_STAKE, - HostChainID: oldHC.ID, - } - memobz, err := json.Marshal(memo) + err := k.InstantiateLiquidStakeContract(ctx, oldHC.ICAAccount, oldHC.Features.LiquidStake, oldHC.ID, oldHC.ConnectionID, oldHC.TransferChannelID, oldHC.TransferPortID) if err != nil { return nil, err } - _, err = k.GenerateAndExecuteICATx(ctx, oldHC.ConnectionID, oldHC.ICAAccount.Owner, []proto.Message{msg}, string(memobz)) - if err != nil { - return nil, err - } - case types.InstantiationState_INSTANTIATION_COMPLETED: // just update oldhc, validate basic will take care of mismatch states. oldHC.Features.LiquidStake = msg.HostChain.Features.LiquidStake diff --git a/x/ratesync/types/contract.pb.go b/x/ratesync/types/contract.pb.go index e8ae3a805..af1364a1f 100644 --- a/x/ratesync/types/contract.pb.go +++ b/x/ratesync/types/contract.pb.go @@ -28,7 +28,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // msg blob for instantiate contract. type InstantiateLiquidStakeRateContract struct { - Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + TransferChannelID string `protobuf:"bytes,2,opt,name=transfer_channel_i_d,json=transferChannelID,proto3" json:"transfer_channel_i_d,omitempty"` + TransferPortID string `protobuf:"bytes,3,opt,name=transfer_port_i_d,json=transferPortID,proto3" json:"transfer_port_i_d,omitempty"` } func (m *InstantiateLiquidStakeRateContract) Reset() { *m = InstantiateLiquidStakeRateContract{} } @@ -71,7 +73,22 @@ func (m *InstantiateLiquidStakeRateContract) GetAdmin() string { return "" } -// wrapper for liquidstakerate as wasm msg should be marshalled as encodedMsg = { wasmMsg: { wasm MsgDetails } } +func (m *InstantiateLiquidStakeRateContract) GetTransferChannelID() string { + if m != nil { + return m.TransferChannelID + } + return "" +} + +func (m *InstantiateLiquidStakeRateContract) GetTransferPortID() string { + if m != nil { + return m.TransferPortID + } + return "" +} + +// wrapper for liquidstakerate as wasm msg should be marshalled as encodedMsg = +// { wasmMsg: { wasm MsgDetails } } type ExecuteLiquidStakeRate struct { LiquidStakeRate LiquidStakeRate `protobuf:"bytes,1,opt,name=liquid_stake_rate,json=liquidStakeRate,proto3" json:"liquid_stake_rate"` } @@ -191,36 +208,39 @@ func init() { } var fileDescriptor_11a849967ac18085 = []byte{ - // 452 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xc1, 0x6e, 0xd4, 0x30, - 0x10, 0x86, 0x37, 0xb4, 0x14, 0x6a, 0x0e, 0x85, 0x50, 0x60, 0x29, 0x52, 0xb6, 0xda, 0x43, 0xb5, - 0x07, 0x36, 0x56, 0x97, 0x23, 0x5c, 0xd8, 0x2e, 0x07, 0x24, 0x24, 0xa4, 0xb4, 0xe5, 0xd0, 0x4b, - 0xe4, 0xd8, 0xd3, 0xd4, 0xda, 0xc4, 0x0e, 0xf1, 0x24, 0x6a, 0xdf, 0x82, 0x87, 0xe9, 0x43, 0xf4, - 0x58, 0xf5, 0x84, 0x38, 0x54, 0x68, 0xf7, 0xc0, 0x6b, 0xa0, 0xd8, 0x46, 0x85, 0xa2, 0x9e, 0x12, - 0xcf, 0xff, 0x69, 0x66, 0xfe, 0xdf, 0x26, 0x3b, 0x95, 0x41, 0x36, 0x07, 0x5a, 0x33, 0x04, 0x73, - 0xa6, 0x38, 0x6d, 0x77, 0x33, 0x40, 0xb6, 0x4b, 0xb9, 0x56, 0x58, 0x33, 0x8e, 0x71, 0x55, 0x6b, - 0xd4, 0xe1, 0x0b, 0xc7, 0xc5, 0x7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x27, 0x1e, 0x92, 0x07, 0x3c, 0x6d, - 0x59, 0xd1, 0x40, 0x7f, 0xc5, 0xc6, 0xf0, 0xae, 0x5b, 0xe3, 0xc7, 0xf5, 0x60, 0x27, 0x97, 0x78, - 0xd2, 0x64, 0x31, 0xd7, 0xa5, 0x4f, 0xdf, 0x7f, 0xc6, 0x46, 0xcc, 0x29, 0x9e, 0x55, 0x60, 0xe2, - 0x19, 0xf0, 0xab, 0xf3, 0x31, 0xf1, 0xa1, 0xcd, 0x80, 0x27, 0x6b, 0xfc, 0x4b, 0xd7, 0x2b, 0x9c, - 0x90, 0x67, 0xf6, 0xfa, 0x75, 0x51, 0x40, 0x9d, 0xf2, 0x13, 0x26, 0x55, 0xda, 0xdd, 0x52, 0x7f, - 0x75, 0x3b, 0x18, 0xad, 0x24, 0x4f, 0x6f, 0xc4, 0xbd, 0x4e, 0x3b, 0x90, 0x25, 0x4c, 0x0f, 0x2f, - 0x16, 0x51, 0x70, 0xb9, 0x88, 0x82, 0x9f, 0x8b, 0x28, 0xf8, 0xb6, 0x8c, 0x7a, 0x97, 0xcb, 0xa8, - 0xf7, 0x7d, 0x19, 0xf5, 0x8e, 0xde, 0xfe, 0xb5, 0x4b, 0x05, 0xb5, 0x91, 0x06, 0x41, 0x71, 0xf8, - 0xac, 0x80, 0xba, 0x74, 0xc7, 0x8a, 0xa1, 0x6c, 0x81, 0xb6, 0x13, 0x7a, 0x7a, 0xf3, 0x10, 0xed, - 0x92, 0xd9, 0x9a, 0x7d, 0x13, 0x6f, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x3b, 0x03, 0x81, - 0xa8, 0x02, 0x00, 0x00, + // 499 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x86, 0x63, 0x5a, 0x0a, 0x5d, 0x24, 0x4a, 0x4d, 0x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 0x03, 0x19, 0x81, 0x88, 0x36, 0xc4, 0xa7, 0xea, 0x2e, + 0xbf, 0x4f, 0x1e, 0xd9, 0xdd, 0xd2, 0x69, 0xea, 0x26, 0x21, 0x15, 0xab, 0x56, 0xa0, 0xb5, 0xbe, + 0xeb, 0x75, 0xd7, 0xa2, 0x87, 0xd7, 0xe2, 0xb0, 0xd2, 0x3e, 0xca, 0x0c, 0x06, 0x87, 0xe7, 0x8b, + 0xc0, 0xbb, 0x58, 0x04, 0xde, 0x8f, 0x45, 0xe0, 0x7d, 0x59, 0x06, 0x8d, 0x8b, 0x65, 0xd0, 0xf8, + 0xb6, 0x0c, 0x1a, 0x47, 0xaf, 0xfe, 0xf0, 0x92, 0x43, 0x61, 0xa4, 0x41, 0x50, 0x02, 0xde, 0x2b, + 0xa0, 0x2e, 0xdd, 0x9e, 0xe2, 0x28, 0xe7, 0x40, 0xe7, 0x7d, 0x7a, 0x72, 0xbd, 0xe5, 0xd6, 0xe4, + 0x64, 0xc3, 0x2e, 0xdc, 0xcb, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe8, 0x7c, 0x44, 0xab, 0x05, + 0x03, 0x00, 0x00, } func (m *InstantiateLiquidStakeRateContract) Marshal() (dAtA []byte, err error) { @@ -243,6 +263,20 @@ func (m *InstantiateLiquidStakeRateContract) MarshalToSizedBuffer(dAtA []byte) ( _ = i var l int _ = l + if len(m.TransferPortID) > 0 { + i -= len(m.TransferPortID) + copy(dAtA[i:], m.TransferPortID) + i = encodeVarintContract(dAtA, i, uint64(len(m.TransferPortID))) + i-- + dAtA[i] = 0x1a + } + if len(m.TransferChannelID) > 0 { + i -= len(m.TransferChannelID) + copy(dAtA[i:], m.TransferChannelID) + i = encodeVarintContract(dAtA, i, uint64(len(m.TransferChannelID))) + i-- + dAtA[i] = 0x12 + } if len(m.Admin) > 0 { i -= len(m.Admin) copy(dAtA[i:], m.Admin) @@ -359,6 +393,14 @@ func (m *InstantiateLiquidStakeRateContract) Size() (n int) { if l > 0 { n += 1 + l + sovContract(uint64(l)) } + l = len(m.TransferChannelID) + if l > 0 { + n += 1 + l + sovContract(uint64(l)) + } + l = len(m.TransferPortID) + if l > 0 { + n += 1 + l + sovContract(uint64(l)) + } return n } @@ -462,6 +504,70 @@ func (m *InstantiateLiquidStakeRateContract) Unmarshal(dAtA []byte) error { } m.Admin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContract + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthContract + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthContract + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TransferChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferPortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContract + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthContract + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthContract + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TransferPortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipContract(dAtA[iNdEx:]) diff --git a/x/ratesync/types/msgs_test.go b/x/ratesync/types/msgs_test.go index 52059cf35..bb6b04426 100644 --- a/x/ratesync/types/msgs_test.go +++ b/x/ratesync/types/msgs_test.go @@ -41,6 +41,8 @@ var ValidHostChainInMsg = func(id uint64) HostChain { Enabled: false, }, }, + TransferChannelID: "channel-0", + TransferPortID: "transfer", } } diff --git a/x/ratesync/types/ratesync.pb.go b/x/ratesync/types/ratesync.pb.go index 8432a8ed6..73188494b 100644 --- a/x/ratesync/types/ratesync.pb.go +++ b/x/ratesync/types/ratesync.pb.go @@ -84,11 +84,13 @@ func (FeatureType) EnumDescriptor() ([]byte, []int) { // HostChain defines the ratesync module's HostChain state. type HostChain struct { // unique id - ID uint64 `protobuf:"varint,1,opt,name=i_d,json=iD,proto3" json:"i_d,omitempty"` - ChainID string `protobuf:"bytes,2,opt,name=chain_i_d,json=chainID,proto3" json:"chain_i_d,omitempty"` - ConnectionID string `protobuf:"bytes,3,opt,name=connection_i_d,json=connectionID,proto3" json:"connection_i_d,omitempty"` - ICAAccount types.ICAAccount `protobuf:"bytes,4,opt,name=i_c_a_account,json=iCAAccount,proto3" json:"i_c_a_account"` - Features Feature `protobuf:"bytes,5,opt,name=features,proto3" json:"features"` + ID uint64 `protobuf:"varint,1,opt,name=i_d,json=iD,proto3" json:"i_d,omitempty"` + ChainID string `protobuf:"bytes,2,opt,name=chain_i_d,json=chainID,proto3" json:"chain_i_d,omitempty"` + ConnectionID string `protobuf:"bytes,3,opt,name=connection_i_d,json=connectionID,proto3" json:"connection_i_d,omitempty"` + ICAAccount types.ICAAccount `protobuf:"bytes,4,opt,name=i_c_a_account,json=iCAAccount,proto3" json:"i_c_a_account"` + Features Feature `protobuf:"bytes,5,opt,name=features,proto3" json:"features"` + TransferChannelID string `protobuf:"bytes,6,opt,name=transfer_channel_i_d,json=transferChannelID,proto3" json:"transfer_channel_i_d,omitempty"` + TransferPortID string `protobuf:"bytes,7,opt,name=transfer_port_i_d,json=transferPortID,proto3" json:"transfer_port_i_d,omitempty"` } func (m *HostChain) Reset() { *m = HostChain{} } @@ -159,6 +161,20 @@ func (m *HostChain) GetFeatures() Feature { return Feature{} } +func (m *HostChain) GetTransferChannelID() string { + if m != nil { + return m.TransferChannelID + } + return "" +} + +func (m *HostChain) GetTransferPortID() string { + if m != nil { + return m.TransferPortID + } + return "" +} + type Feature struct { // triggers on hooks LiquidStakeIBC LiquidStake `protobuf:"bytes,1,opt,name=liquid_stake_i_b_c,json=liquidStakeIBC,proto3" json:"liquid_stake_i_b_c"` @@ -217,11 +233,13 @@ type LiquidStake struct { FeatureType FeatureType `protobuf:"varint,1,opt,name=feature_type,json=featureType,proto3,enum=pstake.ratesync.v1beta1.FeatureType" json:"feature_type,omitempty"` // needs to be uploaded before hand CodeID uint64 `protobuf:"varint,2,opt,name=code_i_d,json=codeID,proto3" json:"code_i_d,omitempty"` - // state of instantiation, do not support gov based instantiation. (need ICA to be at least admin) + // state of instantiation, do not support gov based instantiation. (need ICA + // to be at least admin) Instantiation InstantiationState `protobuf:"varint,3,opt,name=instantiation,proto3,enum=pstake.ratesync.v1beta1.InstantiationState" json:"instantiation,omitempty"` // address of instantiated contract. ContractAddress string `protobuf:"bytes,4,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - // allow * as default for all denoms in case of lsibc, or default bond denom in case of ls. + // allow * as default for all denoms in case of lsibc, or default bond denom + // in case of ls. Denoms []string `protobuf:"bytes,5,rep,name=denoms,proto3" json:"denoms,omitempty"` Enabled bool `protobuf:"varint,6,opt,name=enabled,proto3" json:"enabled,omitempty"` } @@ -368,48 +386,51 @@ func init() { } var fileDescriptor_429540018f2469ab = []byte{ - // 652 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x4f, 0x13, 0x4d, - 0x18, 0xef, 0x96, 0xbe, 0x2d, 0x9d, 0x2d, 0xa5, 0xef, 0x84, 0xbc, 0x34, 0x90, 0x94, 0xa6, 0x2f, - 0x31, 0x05, 0xe3, 0x6e, 0xa8, 0xf1, 0xe4, 0x69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0x92, 0xba, 0xbc, 0xae, 0xa4, 0xbe, 0x5e, - 0x57, 0x52, 0x2f, 0x1f, 0x9f, 0x70, 0x35, 0x98, 0xf4, 0x2d, 0x2a, 0x87, 0xf6, 0x88, 0x8d, 0x03, - 0x1e, 0x28, 0x26, 0x28, 0xeb, 0x08, 0x66, 0x47, 0x23, 0x7b, 0x20, 0x88, 0xe2, 0x67, 0xcc, 0x3e, - 0x6b, 0xd8, 0xef, 0x66, 0x2f, 0x5c, 0x38, 0xdb, 0xa0, 0x9f, 0xd5, 0x2f, 0xcc, 0xc3, 0x9f, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x91, 0xa4, 0xe0, 0x5b, 0x01, 0x05, 0x00, 0x00, + // 692 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x6f, 0x12, 0x41, + 0x14, 0x66, 0x29, 0x42, 0x19, 0x28, 0xa5, 0x93, 0xc6, 0x92, 0x36, 0xa1, 0x04, 0x1b, 0x43, 0x6b, + 0x64, 0x53, 0x8c, 0x27, 0x4f, 0xb0, 0x5b, 0xeb, 0xc4, 0x16, 0xda, 0x85, 0xc6, 0x44, 0x0f, 0x93, + 0x61, 0x98, 0x96, 0x89, 0x30, 0x83, 0xbb, 0x43, 0xb5, 0xff, 0xc2, 0x9f, 0xe0, 0xd1, 0xa3, 0x67, + 0x7f, 0x41, 0x8f, 0x3d, 0x7a, 0x30, 0xc6, 0xb4, 0x07, 0xff, 0x86, 0xd9, 0xd9, 0x05, 0x16, 0x9b, + 0x7a, 0x30, 0x5e, 0xc8, 0xbe, 0xef, 0xfb, 0xde, 0x37, 0xef, 0x3d, 0xde, 0x0c, 0x78, 0x38, 0xf2, + 0x14, 0x79, 0xcb, 0x4c, 0x97, 0x28, 0xe6, 0x5d, 0x08, 0x6a, 0x9e, 0xef, 0x76, 0x99, 0x22, 0xbb, + 0x53, 0xa0, 0x3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, 0xf8, 0x39, 0x33, 0xcf, 0x6b, 0xe6, 0x87, 0xd9, 0xeb, 0xe9, 0xcf, 0xd6, + 0xeb, 0x26, 0xf5, 0xeb, 0xf5, 0xe4, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x05, 0x21, 0xe8, 0x15, + 0x5d, 0x05, 0x00, 0x00, } func (m *HostChain) Marshal() (dAtA []byte, err error) { @@ -432,6 +453,20 @@ func (m *HostChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.TransferPortID) > 0 { + i -= len(m.TransferPortID) + copy(dAtA[i:], m.TransferPortID) + i = encodeVarintRatesync(dAtA, i, uint64(len(m.TransferPortID))) + i-- + dAtA[i] = 0x3a + } + if len(m.TransferChannelID) > 0 { + i -= len(m.TransferChannelID) + copy(dAtA[i:], m.TransferChannelID) + i = encodeVarintRatesync(dAtA, i, uint64(len(m.TransferChannelID))) + i-- + dAtA[i] = 0x32 + } { size, err := m.Features.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -646,6 +681,14 @@ func (m *HostChain) Size() (n int) { n += 1 + l + sovRatesync(uint64(l)) l = m.Features.Size() n += 1 + l + sovRatesync(uint64(l)) + l = len(m.TransferChannelID) + if l > 0 { + n += 1 + l + sovRatesync(uint64(l)) + } + l = len(m.TransferPortID) + if l > 0 { + n += 1 + l + sovRatesync(uint64(l)) + } return n } @@ -892,6 +935,70 @@ func (m *HostChain) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferChannelID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRatesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRatesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRatesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TransferChannelID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferPortID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRatesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRatesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRatesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TransferPortID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipRatesync(dAtA[iNdEx:]) diff --git a/x/ratesync/types/types.go b/x/ratesync/types/types.go index 3539d116c..0453563b2 100644 --- a/x/ratesync/types/types.go +++ b/x/ratesync/types/types.go @@ -62,6 +62,15 @@ func (hc HostChain) ValidateBasic() error { return err } + err = host.ChannelIdentifierValidator(hc.TransferChannelID) + if err != nil { + return err + } + + err = host.PortIdentifierValidator(hc.TransferPortID) + if err != nil { + return err + } return nil } diff --git a/x/ratesync/types/types_test.go b/x/ratesync/types/types_test.go index e38e6ccee..448f732fe 100644 --- a/x/ratesync/types/types_test.go +++ b/x/ratesync/types/types_test.go @@ -46,6 +46,13 @@ func TestTypes(t *testing.T) { hc2.Features.LiquidStake.Enabled = true require.True(t, hc2.IsActive()) + hc2 = ValidHostChainInMsg(0) + hc2.TransferChannelID = "@" + require.Error(t, hc2.ValidateBasic()) + + hc2 = ValidHostChainInMsg(0) + hc2.TransferPortID = "/@" + require.Error(t, hc2.ValidateBasic()) // features features := ValidHostChainInMsg(0).Features require.NoError(t, features.ValdidateBasic())