diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md
index ff79278b80a..52f2a145f8f 100644
--- a/docs/ibc/proto-docs.md
+++ b/docs/ibc/proto-docs.md
@@ -47,8 +47,10 @@
- [Query](#ibc.applications.fee.v1.Query)
- [ibc/applications/fee/v1/tx.proto](#ibc/applications/fee/v1/tx.proto)
- - [MsgEscrowPacketFee](#ibc.applications.fee.v1.MsgEscrowPacketFee)
- - [MsgEscrowPacketFeeResponse](#ibc.applications.fee.v1.MsgEscrowPacketFeeResponse)
+ - [MsgPayPacketFee](#ibc.applications.fee.v1.MsgPayPacketFee)
+ - [MsgPayPacketFeeAsync](#ibc.applications.fee.v1.MsgPayPacketFeeAsync)
+ - [MsgPayPacketFeeAsyncResponse](#ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse)
+ - [MsgPayPacketFeeResponse](#ibc.applications.fee.v1.MsgPayPacketFeeResponse)
- [MsgRegisterCounterpartyAddress](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddress)
- [MsgRegisterCounterpartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse)
@@ -628,7 +630,9 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middl
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
+| `receive_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
+| `ack_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
+| `timeout_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
@@ -644,9 +648,7 @@ Fee associated with a packet_id
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | |
-| `receive_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | |
-| `ack_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | |
-| `timeout_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | |
+| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | |
| `relayers` | [string](#string) | repeated | |
@@ -676,11 +678,6 @@ Fee associated with a packet_id
GenesisState defines the fee middleware genesis state
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| `packets_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | A mapping of packets -> escrowed fees |
-
-
@@ -889,15 +886,20 @@ Query provides defines the gRPC querier service.
-
+
-### MsgEscrowPacketFee
-MsgEscrowPacketFee defines the request type EscrowPacketFee RPC
+### MsgPayPacketFee
+MsgPayPacketFee defines the request type PayPacketFee RPC
+This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be
+paid for
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| `incentivized_packet` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | |
+| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | |
+| `source_port_id` | [string](#string) | | source channel port identifier |
+| `source_channel_id` | [string](#string) | | source channel unique identifier |
+| `signer` | [string](#string) | | account address to refund fee if necessary |
| `relayers` | [string](#string) | repeated | |
@@ -905,10 +907,37 @@ MsgEscrowPacketFee defines the request type EscrowPacketFee RPC
-
+
+
+### MsgPayPacketFeeAsync
+MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC
+This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send)
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| `identified_packet_fee` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | packet to pay fee for |
+| `signer` | [string](#string) | | account address to refund fee if necessary |
+
+
+
+
+
+
+
+
+### MsgPayPacketFeeAsyncResponse
+MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync
+
+
+
+
+
+
+
-### MsgEscrowPacketFeeResponse
-MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee
+### MsgPayPacketFeeResponse
+MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee
@@ -955,7 +984,8 @@ Msg defines the ibc/fee Msg service.
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `RegisterCounterpartyAddress` | [MsgRegisterCounterpartyAddress](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddress) | [MsgRegisterCounterpartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse) | RegisterCounterpartyAddress defines a rpc handler method for MsgRegisterCounterpartyAddress RegisterCounterpartyAddress is called by the relayer on each channelEnd and allows them to specify their counterparty address before relaying. This ensures they will be properly compensated for forward relaying since destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function may be called more than once by a relayer, in which case, latest counterparty address is always used. | |
-| `EscrowPacketFee` | [MsgEscrowPacketFee](#ibc.applications.fee.v1.MsgEscrowPacketFee) | [MsgEscrowPacketFeeResponse](#ibc.applications.fee.v1.MsgEscrowPacketFeeResponse) | EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to incentivize the relaying of the given packet. | |
+| `PayPacketFee` | [MsgPayPacketFee](#ibc.applications.fee.v1.MsgPayPacketFee) | [MsgPayPacketFeeResponse](#ibc.applications.fee.v1.MsgPayPacketFeeResponse) | PayPacketFee defines a rpc handler method for MsgPayPacketFee PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to incentivize the relaying of the packet at the next sequence | |
+| `PayPacketFeeAsync` | [MsgPayPacketFeeAsync](#ibc.applications.fee.v1.MsgPayPacketFeeAsync) | [MsgPayPacketFeeAsyncResponse](#ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse) | PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to incentivize the relaying of a known packet | |
diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go
new file mode 100644
index 00000000000..cddb3be047a
--- /dev/null
+++ b/modules/apps/29-fee/keeper/escrow.go
@@ -0,0 +1,106 @@
+package keeper
+
+import (
+ "fmt"
+
+ sdk "github.com/cosmos/cosmos-sdk/types"
+
+ sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
+
+ "github.com/cosmos/ibc-go/modules/apps/29-fee/types"
+ channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
+)
+
+// EscrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow
+func (k Keeper) EscrowPacketFee(ctx sdk.Context, refundAcc sdk.AccAddress, identifiedFee *types.IdentifiedPacketFee) error {
+ // check if the refund account exists
+ hasRefundAcc := k.authKeeper.GetAccount(ctx, refundAcc)
+ if hasRefundAcc == nil {
+ return sdkerrors.Wrap(types.ErrRefundAccNotFound, fmt.Sprintf("Account with address: %s not found", refundAcc))
+ }
+
+ coins := identifiedFee.Fee.ReceiveFee
+ coins = coins.Add(identifiedFee.Fee.AckFee...)
+ coins = coins.Add(identifiedFee.Fee.TimeoutFee...)
+
+ if err := k.bankKeeper.SendCoinsFromAccountToModule(
+ ctx, refundAcc, types.ModuleName, coins,
+ ); err != nil {
+ return err
+ }
+
+ // Store fee in state for reference later
+ // feeInEscrow///packet// -> Fee (timeout, ack, onrecv)
+ k.SetFeeInEscrow(ctx, identifiedFee)
+ return nil
+}
+
+// DistributeFee pays the acknowledgement fee & receive fee for a given packetId while refunding the timeout fee to the refund account associated with the Fee
+func (k Keeper) DistributeFee(ctx sdk.Context, refundAcc, forwardRelayer, reverseRelayer sdk.AccAddress, packetID *channeltypes.PacketId) error {
+ // check if there is a Fee in escrow for the given packetId
+ feeInEscrow, found := k.GetFeeInEscrow(ctx, packetID)
+ if !found {
+ return sdkerrors.Wrapf(types.ErrFeeNotFound, "with channelID %s, sequence %d", packetID.ChannelId, packetID.Sequence)
+ }
+
+ // get module accAddr
+ feeModuleAccAddr := k.authKeeper.GetModuleAddress(types.ModuleName)
+
+ // send receive fee to forward relayer
+ err := k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, forwardRelayer, feeInEscrow.Fee.ReceiveFee)
+ if err != nil {
+ return sdkerrors.Wrap(err, "failed to send fee to forward relayer")
+ }
+
+ // send ack fee to reverse relayer
+ err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, reverseRelayer, feeInEscrow.Fee.AckFee)
+ if err != nil {
+ return sdkerrors.Wrap(err, "error sending fee to reverse relayer")
+ }
+
+ // refund timeout fee to refundAddr
+ err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAcc, feeInEscrow.Fee.TimeoutFee)
+ if err != nil {
+ return sdkerrors.Wrap(err, "error refunding timeout fee")
+ }
+
+ // removes the fee from the store as fee is now paid
+ k.DeleteFeeInEscrow(ctx, packetID)
+
+ return nil
+}
+
+// DistributeFeeTimeout pays the timeout fee for a given packetId while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee
+func (k Keeper) DistributeFeeTimeout(ctx sdk.Context, refundAcc, timeoutRelayer sdk.AccAddress, packetID *channeltypes.PacketId) error {
+ // check if there is a Fee in escrow for the given packetId
+ feeInEscrow, found := k.GetFeeInEscrow(ctx, packetID)
+ if !found {
+ return sdkerrors.Wrap(types.ErrFeeNotFound, refundAcc.String())
+ }
+
+ // get module accAddr
+ feeModuleAccAddr := k.authKeeper.GetModuleAddress(types.ModuleName)
+
+ // refund the receive fee
+ err := k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAcc, feeInEscrow.Fee.ReceiveFee)
+ if err != nil {
+ return sdkerrors.Wrap(err, "error refunding receive fee")
+ }
+
+ // refund the ack fee
+ err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAcc, feeInEscrow.Fee.AckFee)
+ if err != nil {
+ return sdkerrors.Wrap(err, "error refunding ack fee")
+ }
+
+ // pay the timeout fee to the reverse relayer
+ err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, timeoutRelayer, feeInEscrow.Fee.TimeoutFee)
+ if err != nil {
+ return sdkerrors.Wrap(err, "error sending fee to timeout relayer")
+ }
+
+ // removes the fee from the store as fee is now paid
+ k.DeleteFeeInEscrow(ctx, packetID)
+
+ return nil
+}
diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go
new file mode 100644
index 00000000000..d5600c964e3
--- /dev/null
+++ b/modules/apps/29-fee/keeper/escrow_test.go
@@ -0,0 +1,284 @@
+package keeper_test
+
+import (
+ "github.com/tendermint/tendermint/crypto/secp256k1"
+
+ sdk "github.com/cosmos/cosmos-sdk/types"
+
+ "github.com/cosmos/ibc-go/modules/apps/29-fee/types"
+ channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
+)
+
+var (
+ validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}
+ validCoins2 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}}
+ validCoins3 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}}
+ invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdk.NewInt(100)}}
+)
+
+func (suite *KeeperTestSuite) TestEscrowPacketFee() {
+ var (
+ err error
+ refundAcc sdk.AccAddress
+ ackFee sdk.Coins
+ receiveFee sdk.Coins
+ timeoutFee sdk.Coins
+ )
+
+ // refundAcc does not have balance for the following Coin
+ validChannelId := "channel-0"
+
+ testCases := []struct {
+ name string
+ malleate func()
+ expPass bool
+ }{
+ {
+ "success", func() {}, true,
+ },
+ {
+ "refundAcc does not exist", func() {
+ // this acc does not exist on chainA
+ refundAcc = suite.chainB.SenderAccount.GetAddress()
+ }, false,
+ },
+ {
+ "ackFee balance not found", func() {
+ ackFee = invalidCoins
+ }, false,
+ },
+ {
+ "receive balance not found", func() {
+ receiveFee = invalidCoins
+ }, false,
+ },
+ {
+ "timeout balance not found", func() {
+ timeoutFee = invalidCoins
+ }, false,
+ },
+ }
+
+ for _, tc := range testCases {
+ tc := tc
+
+ suite.Run(tc.name, func() {
+ suite.SetupTest() // reset
+
+ // setup
+ refundAcc = suite.chainA.SenderAccount.GetAddress()
+ ackFee = validCoins
+ receiveFee = validCoins2
+ timeoutFee = validCoins3
+ packetId := &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: uint64(1)}
+
+ tc.malleate()
+ fee := types.Fee{ackFee, receiveFee, timeoutFee}
+ identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}}
+
+ // refundAcc balance before escrow
+ originalBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom)
+
+ // escrow the packet fee
+ err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, identifiedPacketFee)
+
+ if tc.expPass {
+ feeInEscrow, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeInEscrow(suite.chainA.GetContext(), packetId)
+ // check if the escrowed fee is set in state
+ suite.Require().True(feeInEscrow.Fee.AckFee.IsEqual(fee.AckFee))
+ suite.Require().True(feeInEscrow.Fee.ReceiveFee.IsEqual(fee.ReceiveFee))
+ suite.Require().True(feeInEscrow.Fee.TimeoutFee.IsEqual(fee.TimeoutFee))
+ // check if the fee is escrowed correctly
+ hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(600)})
+ suite.Require().True(hasBalance)
+ expectedBal := originalBal.Amount.Sub(sdk.NewInt(600))
+ // check if the refund acc has sent the fee
+ hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: expectedBal})
+ suite.Require().True(hasBalance)
+ suite.Require().NoError(err)
+ } else {
+ suite.Require().Error(err)
+ }
+ })
+ }
+}
+
+func (suite *KeeperTestSuite) TestDistributeFee() {
+ var (
+ err error
+ ackFee sdk.Coins
+ receiveFee sdk.Coins
+ timeoutFee sdk.Coins
+ packetId *channeltypes.PacketId
+ reverseRelayer sdk.AccAddress
+ forwardRelayer sdk.AccAddress
+ refundAcc sdk.AccAddress
+ )
+
+ // refundAcc does not have balance for the following Coin
+ validChannelId := "channel-0"
+ validSeq := uint64(1)
+
+ testCases := []struct {
+ name string
+ malleate func()
+ expPass bool
+ }{
+ {
+ "success", func() {}, true,
+ },
+ {
+ "fee not found for packet", func() {
+ // setting packetId with an invalid sequence of 2
+ packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: uint64(2)}
+ }, false,
+ },
+ }
+
+ for _, tc := range testCases {
+ tc := tc
+
+ suite.Run(tc.name, func() {
+ suite.SetupTest() // reset
+
+ // setup
+ refundAcc = suite.chainA.SenderAccount.GetAddress()
+ reverseRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
+ forwardRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
+
+ ackFee = validCoins
+ receiveFee = validCoins2
+ timeoutFee = validCoins3
+ packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: validSeq}
+ fee := types.Fee{receiveFee, ackFee, timeoutFee}
+
+ // escrow the packet fee & store the fee in state
+ identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}}
+
+ err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, &identifiedPacketFee)
+ suite.Require().NoError(err)
+
+ tc.malleate()
+
+ // refundAcc balance after escrow
+ refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom)
+
+ err = suite.chainA.GetSimApp().IBCFeeKeeper.DistributeFee(suite.chainA.GetContext(), refundAcc, forwardRelayer, reverseRelayer, packetId)
+
+ if tc.expPass {
+ suite.Require().NoError(err)
+ hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId)
+ // there should no longer be a fee in escrow for this packet
+ suite.Require().False(hasFeeInEscrow)
+ // check if the reverse relayer is paid
+ hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, ackFee[0])
+ suite.Require().True(hasBalance)
+ // check if the forward relayer is paid
+ hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forwardRelayer, receiveFee[0])
+ suite.Require().True(hasBalance)
+ // check if the refund acc has been refunded the timeoutFee
+ expectedRefundAccBal := refundAccBal.Add(timeoutFee[0])
+ hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal)
+ suite.Require().True(hasBalance)
+ // check the module acc wallet is now empty
+ hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(0)})
+ suite.Require().True(hasBalance)
+
+ suite.Require().NoError(err)
+
+ } else {
+ suite.Require().Error(err)
+ invalidPacketID := &channeltypes.PacketId{PortId: types.PortKey, ChannelId: validChannelId, Sequence: 1}
+ hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID)
+ // there should still be a fee in escrow for this packet
+ suite.Require().True(hasFeeInEscrow)
+ }
+ })
+ }
+}
+
+func (suite *KeeperTestSuite) TestDistributeTimeoutFee() {
+ var (
+ err error
+ ackFee sdk.Coins
+ receiveFee sdk.Coins
+ timeoutFee sdk.Coins
+ packetId *channeltypes.PacketId
+ refundAcc sdk.AccAddress
+ )
+
+ // refundAcc does not have balance for the following Coin
+ validChannelId := "channel-0"
+ validSeq := uint64(1)
+
+ testCases := []struct {
+ name string
+ malleate func()
+ expPass bool
+ }{
+ {
+ "success", func() {}, true,
+ },
+ {
+ "fee not found for packet", func() {
+ // setting packetId with an invalid sequence of 2
+ packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: uint64(2)}
+ }, false,
+ },
+ }
+
+ for _, tc := range testCases {
+ tc := tc
+
+ suite.Run(tc.name, func() {
+ suite.SetupTest() // reset
+
+ // setup
+ refundAcc = suite.chainA.SenderAccount.GetAddress()
+ timeoutRelayer := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
+
+ ackFee = validCoins
+ receiveFee = validCoins2
+ timeoutFee = validCoins3
+ packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: validSeq}
+ fee := types.Fee{receiveFee, ackFee, timeoutFee}
+
+ // escrow the packet fee & store the fee in state
+ identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}}
+ err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, &identifiedPacketFee)
+ suite.Require().NoError(err)
+
+ tc.malleate()
+
+ // refundAcc balance after escrow
+ refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom)
+
+ err = suite.chainA.GetSimApp().IBCFeeKeeper.DistributeFeeTimeout(suite.chainA.GetContext(), refundAcc, timeoutRelayer, packetId)
+
+ if tc.expPass {
+ suite.Require().NoError(err)
+ hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId)
+ // there should no longer be a fee in escrow for this packet
+ suite.Require().False(hasFeeInEscrow)
+ // check if the timeoutRelayer has been paid
+ hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), timeoutRelayer, timeoutFee[0])
+ suite.Require().True(hasBalance)
+ // check if the refund acc has been refunded the recv & ack fees
+ expectedRefundAccBal := refundAccBal.Add(ackFee[0])
+ expectedRefundAccBal = refundAccBal.Add(receiveFee[0])
+ hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal)
+ suite.Require().True(hasBalance)
+ // check the module acc wallet is now empty
+ hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(0)})
+ suite.Require().True(hasBalance)
+
+ } else {
+ suite.Require().Error(err)
+ invalidPacketID := &channeltypes.PacketId{PortId: types.PortKey, ChannelId: validChannelId, Sequence: 1}
+ hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID)
+ // there should still be a fee in escrow for this packet
+ suite.Require().True(hasFeeInEscrow)
+ }
+ })
+ }
+}
diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go
index eb14e1a3a1f..3691204d2a6 100644
--- a/modules/apps/29-fee/keeper/keeper.go
+++ b/modules/apps/29-fee/keeper/keeper.go
@@ -26,14 +26,16 @@ type Keeper struct {
storeKey sdk.StoreKey
cdc codec.BinaryCodec
+ authKeeper types.AccountKeeper
channelKeeper types.ChannelKeeper
portKeeper types.PortKeeper
+ bankKeeper types.BankKeeper
}
// NewKeeper creates a new 29-fee Keeper instance
func NewKeeper(
cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
- channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper,
+ channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper,
) Keeper {
return Keeper{
@@ -41,6 +43,8 @@ func NewKeeper(
storeKey: key,
channelKeeper: channelKeeper,
portKeeper: portKeeper,
+ authKeeper: authKeeper,
+ bankKeeper: bankKeeper,
}
}
@@ -70,6 +74,11 @@ func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (
return k.channelKeeper.GetNextSequenceSend(ctx, portID, channelID)
}
+// GetFeeAccount returns the ICS29 Fee ModuleAccount address
+func (k Keeper) GetFeeModuleAddress() sdk.AccAddress {
+ return k.authKeeper.GetModuleAddress(types.ModuleName)
+}
+
// SendPacket wraps IBC ChannelKeeper's SendPacket function
func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) error {
return k.channelKeeper.SendPacket(ctx, chanCap, packet)
@@ -103,13 +112,63 @@ func (k Keeper) SetCounterpartyAddress(ctx sdk.Context, address, counterpartyAdd
}
// GetCounterpartyAddress gets the relayer counterparty address given a destination relayer address
-func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address sdk.AccAddress) (sdk.AccAddress, bool) {
+func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address string) (string, bool) {
store := ctx.KVStore(k.storeKey)
- key := types.KeyRelayerAddress(address.String())
+ key := types.KeyRelayerAddress(address)
if !store.Has(key) {
- return []byte{}, false
+ return "", false
}
- return store.Get(key), true
+ addr := string(store.Get(key))
+ return addr, true
+}
+
+// Stores a Fee for a given packet in state
+func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee *types.IdentifiedPacketFee) {
+ store := ctx.KVStore(k.storeKey)
+ bz := k.MustMarshalFee(fee)
+ store.Set(types.KeyFeeInEscrow(fee.PacketId), bz)
+}
+
+// Gets a Fee for a given packet
+func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) (types.IdentifiedPacketFee, bool) {
+ store := ctx.KVStore(k.storeKey)
+ key := types.KeyFeeInEscrow(packetId)
+ bz := store.Get(key)
+ if bz == nil {
+ return types.IdentifiedPacketFee{}, false
+ }
+ fee := k.MustUnmarshalFee(bz)
+
+ return fee, true
+}
+
+// Deletes the fee associated with the given packetId
+func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) {
+ store := ctx.KVStore(k.storeKey)
+ key := types.KeyFeeInEscrow(packetId)
+ store.Delete(key)
+}
+
+// GetFeeInEscrow returns true if there is a Fee still to be escrowed for a given packet
+func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) bool {
+ store := ctx.KVStore(k.storeKey)
+ key := types.KeyFeeInEscrow(packetId)
+
+ return store.Has(key)
+}
+
+// MustMarshalFee attempts to encode a Fee object and returns the
+// raw encoded bytes. It panics on error.
+func (k Keeper) MustMarshalFee(fee *types.IdentifiedPacketFee) []byte {
+ return k.cdc.MustMarshal(fee)
+}
+
+// MustUnmarshalFee attempts to decode and return a Fee object from
+// raw encoded bytes. It panics on error.
+func (k Keeper) MustUnmarshalFee(bz []byte) types.IdentifiedPacketFee {
+ var fee types.IdentifiedPacketFee
+ k.cdc.MustUnmarshal(bz, &fee)
+ return fee
}
diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go
index f227c98171c..ab4ce879a29 100644
--- a/modules/apps/29-fee/keeper/keeper_test.go
+++ b/modules/apps/29-fee/keeper/keeper_test.go
@@ -5,6 +5,9 @@ import (
"github.com/stretchr/testify/suite"
+ "github.com/cosmos/ibc-go/modules/apps/29-fee/types"
+ transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types"
+ channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/testing"
)
@@ -16,14 +19,42 @@ type KeeperTestSuite struct {
// testing chains used for convenience and readability
chainA *ibctesting.TestChain
chainB *ibctesting.TestChain
- chainC *ibctesting.TestChain
+
+ path *ibctesting.Path
}
func (suite *KeeperTestSuite) SetupTest() {
- suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3)
+ suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1))
- suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(2))
+
+ path := ibctesting.NewPath(suite.chainA, suite.chainB)
+ feeTransferVersion := channeltypes.MergeChannelVersions(types.Version, transfertypes.Version)
+ path.EndpointA.ChannelConfig.Version = feeTransferVersion
+ path.EndpointB.ChannelConfig.Version = feeTransferVersion
+ path.EndpointA.ChannelConfig.PortID = transfertypes.PortID
+ path.EndpointB.ChannelConfig.PortID = transfertypes.PortID
+ suite.path = path
+}
+
+func SetupFeePath(path *ibctesting.Path) error {
+ if err := path.EndpointA.ChanOpenInit(); err != nil {
+ return err
+ }
+
+ if err := path.EndpointB.ChanOpenTry(); err != nil {
+ return err
+ }
+
+ if err := path.EndpointA.ChanOpenAck(); err != nil {
+ return err
+ }
+
+ if err := path.EndpointB.ChanOpenConfirm(); err != nil {
+ return err
+ }
+
+ return nil
}
func TestKeeperTestSuite(t *testing.T) {
diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go
index 54b0dadbc37..4b81a870eea 100644
--- a/modules/apps/29-fee/keeper/msg_server.go
+++ b/modules/apps/29-fee/keeper/msg_server.go
@@ -6,6 +6,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/modules/apps/29-fee/types"
+ channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
)
var _ types.MsgServer = Keeper{}
@@ -25,9 +26,52 @@ func (k Keeper) RegisterCounterpartyAddress(goCtx context.Context, msg *types.Ms
return &types.MsgRegisterCounterpartyAddressResponse{}, nil
}
-// EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee
-// EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to
-// incentivize the relaying of the given packet.
-func (k Keeper) EscrowPacketFee(goCtx context.Context, msg *types.MsgEscrowPacketFee) (*types.MsgEscrowPacketFeeResponse, error) {
- return &types.MsgEscrowPacketFeeResponse{}, nil
+// PayPacketFee defines a rpc handler method for MsgPayPacketFee
+// PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to relay the packet with the next sequence
+func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) (*types.MsgPayPacketFeeResponse, error) {
+ ctx := sdk.UnwrapSDKContext(goCtx)
+
+ // get the next sequence
+ sequence, found := k.GetNextSequenceSend(ctx, msg.SourcePortId, msg.SourceChannelId)
+ if !found {
+ return nil, channeltypes.ErrSequenceSendNotFound
+ }
+
+ packetId := &channeltypes.PacketId{
+ PortId: msg.SourcePortId,
+ ChannelId: msg.SourceChannelId,
+ Sequence: sequence,
+ }
+
+ refundAccAddr, err := sdk.AccAddressFromBech32(msg.Signer)
+ if err != nil {
+ return nil, err
+ }
+
+ identifiedPacket := types.NewIdentifiedPacketFee(packetId, msg.Fee, msg.Relayers)
+ err = k.EscrowPacketFee(ctx, refundAccAddr, identifiedPacket)
+ if err != nil {
+ return nil, err
+ }
+
+ return &types.MsgPayPacketFeeResponse{}, nil
+}
+
+// PayPacketFee defines a rpc handler method for MsgPayPacketFee
+// PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to
+// incentivize the relaying of a known packet
+func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) {
+ ctx := sdk.UnwrapSDKContext(goCtx)
+
+ refundAccAddr, err := sdk.AccAddressFromBech32(msg.Signer)
+ if err != nil {
+ return nil, err
+ }
+
+ err = k.EscrowPacketFee(ctx, refundAccAddr, &msg.IdentifiedPacketFee)
+ if err != nil {
+ return nil, err
+ }
+
+ return &types.MsgPayPacketFeeAsyncResponse{}, nil
}
diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go
new file mode 100644
index 00000000000..face4c4c905
--- /dev/null
+++ b/modules/apps/29-fee/keeper/msg_server_test.go
@@ -0,0 +1,131 @@
+package keeper_test
+
+import (
+ "github.com/cosmos/ibc-go/modules/apps/29-fee/types"
+ channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
+)
+
+func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() {
+ var (
+ sender string
+ counterparty string
+ )
+
+ testCases := []struct {
+ name string
+ expPass bool
+ malleate func()
+ }{
+ {
+ "success",
+ true,
+ func() {},
+ },
+ {
+ "success",
+ true,
+ func() { counterparty = "arbitrary-string" },
+ },
+ }
+
+ for _, tc := range testCases {
+ suite.SetupTest()
+ ctx := suite.chainA.GetContext()
+
+ sender = suite.chainA.SenderAccount.GetAddress().String()
+ counterparty = suite.chainB.SenderAccount.GetAddress().String()
+ tc.malleate()
+ msg := types.NewMsgRegisterCounterpartyAddress(sender, counterparty)
+
+ _, err := suite.chainA.SendMsgs(msg)
+
+ if tc.expPass {
+ suite.Require().NoError(err) // message committed
+
+ counterpartyAddress, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(ctx, suite.chainA.SenderAccount.GetAddress().String())
+ suite.Require().Equal(counterparty, counterpartyAddress)
+ } else {
+ suite.Require().Error(err)
+ }
+ }
+}
+
+func (suite *KeeperTestSuite) TestPayPacketFee() {
+ testCases := []struct {
+ name string
+ expPass bool
+ malleate func()
+ }{
+ {
+ "success",
+ true,
+ func() {},
+ },
+ }
+
+ for _, tc := range testCases {
+ suite.SetupTest()
+ suite.coordinator.SetupConnections(suite.path)
+ err := SetupFeePath(suite.path)
+ suite.Require().NoError(err)
+
+ refundAcc := suite.chainA.SenderAccount.GetAddress()
+ channelID := suite.path.EndpointA.ChannelID
+ fee := types.Fee{validCoins, validCoins, validCoins}
+ msg := types.NewMsgPayPacketFee(fee, suite.path.EndpointA.ChannelConfig.PortID, channelID, refundAcc.String(), []string{})
+
+ tc.malleate()
+ _, err = suite.chainA.SendMsgs(msg)
+
+ if tc.expPass {
+ suite.Require().NoError(err) // message committed
+ } else {
+ suite.Require().Error(err)
+ }
+ }
+}
+
+func (suite *KeeperTestSuite) TestPayPacketFeeAsync() {
+ testCases := []struct {
+ name string
+ expPass bool
+ malleate func()
+ }{
+ {
+ "success",
+ true,
+ func() {},
+ },
+ }
+
+ for _, tc := range testCases {
+ suite.SetupTest()
+ suite.coordinator.SetupConnections(suite.path)
+ err := SetupFeePath(suite.path)
+ suite.Require().NoError(err)
+
+ ctxA := suite.chainA.GetContext()
+
+ refundAcc := suite.chainA.SenderAccount.GetAddress()
+
+ // build packetId
+ channelID := suite.path.EndpointA.ChannelID
+ fee := types.Fee{validCoins, validCoins, validCoins}
+ seq, _ := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(ctxA, suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)
+
+ // build fee
+ packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: suite.path.EndpointA.ChannelConfig.PortID, Sequence: seq}
+ identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}}
+
+ tc.malleate()
+
+ msg := types.NewMsgPayPacketFeeAsync(identifiedPacketFee, refundAcc.String())
+ _, err = suite.chainA.SendMsgs(msg)
+
+ if tc.expPass {
+ suite.Require().NoError(err) // message committed
+ } else {
+ suite.Require().Error(err)
+ }
+ }
+}
diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go
index 6e73a3b9b08..61e39846584 100644
--- a/modules/apps/29-fee/module.go
+++ b/modules/apps/29-fee/module.go
@@ -45,7 +45,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {}
// RegisterInterfaces registers module concrete types into protobuf Any.
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- // types.RegisterInterfaces(registry)
+ types.RegisterInterfaces(registry)
}
// DefaultGenesis returns default genesis state as raw bytes for the ibc
@@ -120,7 +120,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier {
// RegisterServices registers module services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
- // types.RegisterMsgServer(cfg.MsgServer(), am.keeper)
+ types.RegisterMsgServer(cfg.MsgServer(), am.keeper)
// types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
}
diff --git a/modules/apps/29-fee/types/codec.go b/modules/apps/29-fee/types/codec.go
index c9dac580ea5..846716d740f 100644
--- a/modules/apps/29-fee/types/codec.go
+++ b/modules/apps/29-fee/types/codec.go
@@ -1,16 +1,42 @@
package types
-/*
import (
+ "github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
+ sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
+// RegisterLegacyAminoCodec registers the necessary x/ibc 29-fee interfaces and concrete types
+// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
+func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
+ cdc.RegisterConcrete(&MsgRegisterCounterpartyAddress{}, "cosmos-sdk/MsgRegisterCounterpartyAddress", nil)
+ cdc.RegisterConcrete(&MsgPayPacketFee{}, "cosmos-sdk/MsgPayPacketFee", nil)
+ cdc.RegisterConcrete(&MsgPayPacketFeeAsync{}, "cosmos-sdk/MsgPayPacketFeeAsync", nil)
+}
+
// RegisterInterfaces register the 29-fee module interfaces to protobuf
// Any.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
- // registry.RegisterImplementations((*sdk.Msg)(nil), &Msg{})
-
+ registry.RegisterImplementations((*sdk.Msg)(nil), &MsgRegisterCounterpartyAddress{}, &MsgPayPacketFee{}, &MsgPayPacketFeeAsync{})
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
-*/
+
+var (
+ amino = codec.NewLegacyAmino()
+
+ // ModuleCdc references the global x/ibc-transfer module codec. Note, the codec
+ // should ONLY be used in certain instances of tests and for JSON encoding.
+ //
+ // The actual codec used for serialization should be provided to x/ibc transfer and
+ // defined at the application level.
+ ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
+
+ // AminoCdc is a amino codec created to support amino json compatible msgs.
+ AminoCdc = codec.NewAminoCodec(amino)
+)
+
+func init() {
+ RegisterLegacyAminoCodec(amino)
+ amino.Seal()
+}
diff --git a/modules/apps/29-fee/types/errors.go b/modules/apps/29-fee/types/errors.go
index 5536d326fc0..b5e8203ec9f 100644
--- a/modules/apps/29-fee/types/errors.go
+++ b/modules/apps/29-fee/types/errors.go
@@ -6,5 +6,10 @@ import (
// 29-fee sentinel errors
var (
- ErrInvalidVersion = sdkerrors.Register(ModuleName, 2, "invalid ICS29 middleware version")
+ ErrInvalidVersion = sdkerrors.Register(ModuleName, 2, "invalid ICS29 middleware version")
+ ErrRefundAccNotFound = sdkerrors.Register(ModuleName, 3, "no account found for given refund address")
+ ErrBalanceNotFound = sdkerrors.Register(ModuleName, 4, "balance not found for given account address")
+ ErrFeeNotFound = sdkerrors.Register(ModuleName, 5, "there is no fee escrowed for the given packetID")
+ ErrRelayersNotNil = sdkerrors.Register(ModuleName, 6, "relayers must be nil. This feature is not supported")
+ ErrCounterpartyAddressEmpty = sdkerrors.Register(ModuleName, 7, "counterparty address must not be empty")
)
diff --git a/modules/apps/29-fee/types/expected_keepers.go b/modules/apps/29-fee/types/expected_keepers.go
index 8e49bbe8ab0..33edb1c01ce 100644
--- a/modules/apps/29-fee/types/expected_keepers.go
+++ b/modules/apps/29-fee/types/expected_keepers.go
@@ -2,11 +2,18 @@ package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
+ "github.com/cosmos/cosmos-sdk/x/auth/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/modules/core/exported"
)
+// AccountKeeper defines the contract required for account APIs.
+type AccountKeeper interface {
+ GetModuleAddress(name string) sdk.AccAddress
+ GetAccount(sdk.Context, sdk.AccAddress) types.AccountI
+}
+
// ChannelKeeper defines the expected IBC channel keeper
type ChannelKeeper interface {
GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool)
@@ -19,3 +26,10 @@ type ChannelKeeper interface {
type PortKeeper interface {
BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability
}
+
+// BankKeeper defines the expected bank keeper
+type BankKeeper interface {
+ HasBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin) bool
+ SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
+ SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
+}
diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go
index d6597e1c0f8..23c7abecd4d 100644
--- a/modules/apps/29-fee/types/fee.pb.go
+++ b/modules/apps/29-fee/types/fee.pb.go
@@ -30,7 +30,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// See Fee Payment Middleware spec:
// https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract
type Fee struct {
- Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"`
+ ReceiveFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=receive_fee,json=receiveFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"receive_fee" yaml:"receive_fee"`
+ AckFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=ack_fee,json=ackFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"ack_fee" yaml:"ack_fee"`
+ TimeoutFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=timeout_fee,json=timeoutFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"timeout_fee" yaml:"timeout_fee"`
}
func (m *Fee) Reset() { *m = Fee{} }
@@ -66,20 +68,32 @@ func (m *Fee) XXX_DiscardUnknown() {
var xxx_messageInfo_Fee proto.InternalMessageInfo
-func (m *Fee) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins {
+func (m *Fee) GetReceiveFee() github_com_cosmos_cosmos_sdk_types.Coins {
if m != nil {
- return m.Amount
+ return m.ReceiveFee
+ }
+ return nil
+}
+
+func (m *Fee) GetAckFee() github_com_cosmos_cosmos_sdk_types.Coins {
+ if m != nil {
+ return m.AckFee
+ }
+ return nil
+}
+
+func (m *Fee) GetTimeoutFee() github_com_cosmos_cosmos_sdk_types.Coins {
+ if m != nil {
+ return m.TimeoutFee
}
return nil
}
// Fee associated with a packet_id
type IdentifiedPacketFee struct {
- PacketId *types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"`
- ReceiveFee *Fee `protobuf:"bytes,2,opt,name=receive_fee,json=receiveFee,proto3" json:"receive_fee,omitempty" yaml:"receive_fee"`
- AckFee *Fee `protobuf:"bytes,3,opt,name=ack_fee,json=ackFee,proto3" json:"ack_fee,omitempty" yaml:"ack_fee"`
- TimeoutFee *Fee `protobuf:"bytes,4,opt,name=timeout_fee,json=timeoutFee,proto3" json:"timeout_fee,omitempty" yaml:"timeout_fee"`
- Relayers []string `protobuf:"bytes,5,rep,name=relayers,proto3" json:"relayers,omitempty"`
+ PacketId *types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"`
+ Fee Fee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee"`
+ Relayers []string `protobuf:"bytes,3,rep,name=relayers,proto3" json:"relayers,omitempty"`
}
func (m *IdentifiedPacketFee) Reset() { *m = IdentifiedPacketFee{} }
@@ -122,25 +136,11 @@ func (m *IdentifiedPacketFee) GetPacketId() *types1.PacketId {
return nil
}
-func (m *IdentifiedPacketFee) GetReceiveFee() *Fee {
+func (m *IdentifiedPacketFee) GetFee() Fee {
if m != nil {
- return m.ReceiveFee
+ return m.Fee
}
- return nil
-}
-
-func (m *IdentifiedPacketFee) GetAckFee() *Fee {
- if m != nil {
- return m.AckFee
- }
- return nil
-}
-
-func (m *IdentifiedPacketFee) GetTimeoutFee() *Fee {
- if m != nil {
- return m.TimeoutFee
- }
- return nil
+ return Fee{}
}
func (m *IdentifiedPacketFee) GetRelayers() []string {
@@ -159,34 +159,34 @@ func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescri
var fileDescriptor_cb3319f1af2a53e5 = []byte{
// 443 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x3f, 0x8f, 0xd3, 0x30,
- 0x18, 0xc6, 0x9b, 0x2b, 0x94, 0x3b, 0x57, 0x42, 0x28, 0x9c, 0xa0, 0x54, 0x90, 0x94, 0x4c, 0x5d,
- 0x6a, 0xd3, 0x32, 0xc1, 0x18, 0xa4, 0x93, 0x2a, 0x31, 0x9c, 0x22, 0xdd, 0xc2, 0x72, 0x72, 0x9c,
- 0xb7, 0x39, 0x93, 0x3f, 0x8e, 0x62, 0x27, 0x52, 0xbf, 0x05, 0x9f, 0x83, 0x4f, 0x72, 0xe3, 0x8d,
- 0x4c, 0x01, 0xb5, 0xdf, 0xa0, 0x33, 0x03, 0xb2, 0x63, 0x4e, 0x95, 0x10, 0x12, 0x4c, 0x7e, 0x5f,
- 0xdb, 0xcf, 0xef, 0x79, 0x64, 0xbf, 0xe8, 0x35, 0x8f, 0x19, 0xa1, 0x55, 0x95, 0x73, 0x46, 0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xd8, 0x1a, 0x3a, 0x65, 0x0b, 0x74, 0x92, 0x3e, 0xec, 0x93, 0x4f, 0x37, 0xdb, 0x08, 0xdd, 0x6e,
+ 0x23, 0xf4, 0x7b, 0x1b, 0xa1, 0x6f, 0xbb, 0x68, 0x70, 0xbb, 0x8b, 0x06, 0x3f, 0x77, 0xd1, 0xe0,
+ 0xf3, 0xfc, 0xef, 0x5a, 0x88, 0x8c, 0x4f, 0x0b, 0x49, 0x6b, 0x99, 0xaf, 0x2a, 0x50, 0x66, 0x22,
+ 0x14, 0x9d, 0xbf, 0x9f, 0x9a, 0x61, 0xb0, 0xb5, 0xc9, 0x8e, 0x6c, 0x6b, 0xbe, 0xfd, 0x13, 0x00,
+ 0x00, 0xff, 0xff, 0x80, 0x3a, 0xb6, 0x74, 0x31, 0x03, 0x00, 0x00,
}
func (m *Fee) Marshal() (dAtA []byte, err error) {
@@ -209,10 +209,38 @@ func (m *Fee) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
- if len(m.Amount) > 0 {
- for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- {
+ if len(m.TimeoutFee) > 0 {
+ for iNdEx := len(m.TimeoutFee) - 1; iNdEx >= 0; iNdEx-- {
{
- size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i])
+ size, err := m.TimeoutFee[iNdEx].MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintFee(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x1a
+ }
+ }
+ if len(m.AckFee) > 0 {
+ for iNdEx := len(m.AckFee) - 1; iNdEx >= 0; iNdEx-- {
+ {
+ size, err := m.AckFee[iNdEx].MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintFee(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x12
+ }
+ }
+ if len(m.ReceiveFee) > 0 {
+ for iNdEx := len(m.ReceiveFee) - 1; iNdEx >= 0; iNdEx-- {
+ {
+ size, err := m.ReceiveFee[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
@@ -252,45 +280,19 @@ func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.Relayers[iNdEx])
i = encodeVarintFee(dAtA, i, uint64(len(m.Relayers[iNdEx])))
i--
- dAtA[i] = 0x2a
+ dAtA[i] = 0x1a
}
}
- if m.TimeoutFee != nil {
- {
- size, err := m.TimeoutFee.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintFee(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x22
- }
- if m.AckFee != nil {
- {
- size, err := m.AckFee.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintFee(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0x1a
- }
- if m.ReceiveFee != nil {
- {
- size, err := m.ReceiveFee.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintFee(dAtA, i, uint64(size))
+ {
+ size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
}
- i--
- dAtA[i] = 0x12
+ i -= size
+ i = encodeVarintFee(dAtA, i, uint64(size))
}
+ i--
+ dAtA[i] = 0x12
if m.PacketId != nil {
{
size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i])
@@ -323,8 +325,20 @@ func (m *Fee) Size() (n int) {
}
var l int
_ = l
- if len(m.Amount) > 0 {
- for _, e := range m.Amount {
+ if len(m.ReceiveFee) > 0 {
+ for _, e := range m.ReceiveFee {
+ l = e.Size()
+ n += 1 + l + sovFee(uint64(l))
+ }
+ }
+ if len(m.AckFee) > 0 {
+ for _, e := range m.AckFee {
+ l = e.Size()
+ n += 1 + l + sovFee(uint64(l))
+ }
+ }
+ if len(m.TimeoutFee) > 0 {
+ for _, e := range m.TimeoutFee {
l = e.Size()
n += 1 + l + sovFee(uint64(l))
}
@@ -342,18 +356,8 @@ func (m *IdentifiedPacketFee) Size() (n int) {
l = m.PacketId.Size()
n += 1 + l + sovFee(uint64(l))
}
- if m.ReceiveFee != nil {
- l = m.ReceiveFee.Size()
- n += 1 + l + sovFee(uint64(l))
- }
- if m.AckFee != nil {
- l = m.AckFee.Size()
- n += 1 + l + sovFee(uint64(l))
- }
- if m.TimeoutFee != nil {
- l = m.TimeoutFee.Size()
- n += 1 + l + sovFee(uint64(l))
- }
+ l = m.Fee.Size()
+ n += 1 + l + sovFee(uint64(l))
if len(m.Relayers) > 0 {
for _, s := range m.Relayers {
l = len(s)
@@ -400,7 +404,7 @@ func (m *Fee) Unmarshal(dAtA []byte) error {
switch fieldNum {
case 1:
if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
+ return fmt.Errorf("proto: wrong wireType = %d for field ReceiveFee", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@@ -427,64 +431,14 @@ func (m *Fee) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
- m.Amount = append(m.Amount, types.Coin{})
- if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ m.ReceiveFee = append(m.ReceiveFee, types.Coin{})
+ if err := m.ReceiveFee[len(m.ReceiveFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipFee(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthFee
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error {
- l := len(dAtA)
- iNdEx := 0
- for iNdEx < l {
- preIndex := iNdEx
- var wire uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowFee
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- wire |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- fieldNum := int32(wire >> 3)
- wireType := int(wire & 0x7)
- if wireType == 4 {
- return fmt.Errorf("proto: IdentifiedPacketFee: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: IdentifiedPacketFee: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
+ case 2:
if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType)
+ return fmt.Errorf("proto: wrong wireType = %d for field AckFee", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@@ -511,16 +465,14 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
- if m.PacketId == nil {
- m.PacketId = &types1.PacketId{}
- }
- if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ m.AckFee = append(m.AckFee, types.Coin{})
+ if err := m.AckFee[len(m.AckFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
- case 2:
+ case 3:
if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field ReceiveFee", wireType)
+ return fmt.Errorf("proto: wrong wireType = %d for field TimeoutFee", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@@ -547,16 +499,64 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
- if m.ReceiveFee == nil {
- m.ReceiveFee = &Fee{}
- }
- if err := m.ReceiveFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ m.TimeoutFee = append(m.TimeoutFee, types.Coin{})
+ if err := m.TimeoutFee[len(m.TimeoutFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
- case 3:
+ default:
+ iNdEx = preIndex
+ skippy, err := skipFee(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
+ return ErrInvalidLengthFee
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowFee
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: IdentifiedPacketFee: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: IdentifiedPacketFee: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field AckFee", wireType)
+ return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@@ -583,16 +583,16 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
- if m.AckFee == nil {
- m.AckFee = &Fee{}
+ if m.PacketId == nil {
+ m.PacketId = &types1.PacketId{}
}
- if err := m.AckFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
- case 4:
+ case 2:
if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field TimeoutFee", wireType)
+ return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@@ -619,14 +619,11 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
- if m.TimeoutFee == nil {
- m.TimeoutFee = &Fee{}
- }
- if err := m.TimeoutFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
- case 5:
+ case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType)
}
diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go
index e108131adfc..b07a497011f 100644
--- a/modules/apps/29-fee/types/genesis.pb.go
+++ b/modules/apps/29-fee/types/genesis.pb.go
@@ -25,8 +25,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the fee middleware genesis state
type GenesisState struct {
- // A mapping of packets -> escrowed fees
- PacketsFees []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=packets_fees,json=packetsFees,proto3" json:"packets_fees,omitempty" yaml:"packets_fees"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
@@ -62,13 +60,6 @@ func (m *GenesisState) XXX_DiscardUnknown() {
var xxx_messageInfo_GenesisState proto.InternalMessageInfo
-func (m *GenesisState) GetPacketsFees() []*IdentifiedPacketFee {
- if m != nil {
- return m.PacketsFees
- }
- return nil
-}
-
func init() {
proto.RegisterType((*GenesisState)(nil), "ibc.applications.fee.v1.GenesisState")
}
@@ -78,24 +69,19 @@ func init() {
}
var fileDescriptor_7191992e856dff95 = []byte{
- // 260 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x8f, 0xb1, 0x4a, 0xc3, 0x50,
- 0x14, 0x86, 0x13, 0x04, 0x87, 0xb4, 0x53, 0x15, 0x2a, 0x1d, 0xae, 0x1a, 0x10, 0x1c, 0xec, 0xbd,
- 0x34, 0x4e, 0x3a, 0x76, 0xa8, 0x08, 0x0e, 0xa2, 0x9b, 0x8b, 0xe4, 0xde, 0x9c, 0xdc, 0x1e, 0x4c,
- 0x72, 0x2e, 0x9e, 0xdb, 0x62, 0xdf, 0xc2, 0xc7, 0x72, 0xec, 0xe8, 0x24, 0x92, 0xbc, 0x81, 0x4f,
- 0x20, 0x49, 0x3b, 0x74, 0xe9, 0x76, 0x0e, 0x7c, 0xff, 0xff, 0xf3, 0x45, 0x17, 0xa8, 0x8d, 0x4a,
- 0x9d, 0x2b, 0xd0, 0xa4, 0x1e, 0xa9, 0x62, 0x95, 0x03, 0xa8, 0xe5, 0x44, 0x59, 0xa8, 0x80, 0x91,
- 0xa5, 0x7b, 0x27, 0x4f, 0x83, 0x21, 0x6a, 0x23, 0x77, 0x31, 0x99, 0x03, 0xc8, 0xe5, 0x64, 0x74,
- 0x6c, 0xc9, 0x52, 0xc7, 0xa8, 0xf6, 0xda, 0xe0, 0xa3, 0xf3, 0x7d, 0xad, 0x6d, 0xaa, 0x43, 0xe2,
- 0x8f, 0xa8, 0x7f, 0xb7, 0x99, 0x78, 0xf6, 0xa9, 0x87, 0xc1, 0x3c, 0xea, 0xbb, 0xd4, 0xbc, 0x81,
- 0xe7, 0xd7, 0x1c, 0x80, 0x4f, 0xc2, 0xb3, 0x83, 0xcb, 0x5e, 0x72, 0x25, 0xf7, 0x0c, 0xcb, 0xfb,
- 0x0c, 0x2a, 0x8f, 0x39, 0x42, 0xf6, 0xd8, 0xc5, 0x66, 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0xa4, 0x0b, 0xac, 0x44, 0x89, 0x8f, 0x8b, 0xc7, 0x1d, 0x62, 0x45, 0x70, 0x49, 0x62,
+ 0x49, 0xaa, 0x93, 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7,
+ 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5,
+ 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17,
+ 0xeb, 0x67, 0x26, 0x25, 0xeb, 0xa6, 0xe7, 0xeb, 0xe7, 0xe6, 0xa7, 0x94, 0xe6, 0xa4, 0x16, 0x83,
+ 0x6c, 0x2a, 0xd6, 0x37, 0xb2, 0xd4, 0x05, 0x59, 0x52, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06,
+ 0xb6, 0xc4, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x90, 0xf8, 0xaf, 0x33, 0xdf, 0x00, 0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@@ -118,20 +104,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
- if len(m.PacketsFees) > 0 {
- for iNdEx := len(m.PacketsFees) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.PacketsFees[iNdEx].MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintGenesis(dAtA, i, uint64(size))
- }
- i--
- dAtA[i] = 0xa
- }
- }
return len(dAtA) - i, nil
}
@@ -152,12 +124,6 @@ func (m *GenesisState) Size() (n int) {
}
var l int
_ = l
- if len(m.PacketsFees) > 0 {
- for _, e := range m.PacketsFees {
- l = e.Size()
- n += 1 + l + sovGenesis(uint64(l))
- }
- }
return n
}
@@ -196,40 +162,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field PacketsFees", wireType)
- }
- var msglen int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- msglen |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- if msglen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + msglen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.PacketsFees = append(m.PacketsFees, &IdentifiedPacketFee{})
- if err := m.PacketsFees[len(m.PacketsFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go
index 39bbfe5ff85..174168a32b0 100644
--- a/modules/apps/29-fee/types/keys.go
+++ b/modules/apps/29-fee/types/keys.go
@@ -1,6 +1,10 @@
package types
-import "fmt"
+import (
+ "fmt"
+
+ channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
+)
const (
// ModuleName defines the 29-fee name
@@ -25,6 +29,9 @@ const (
// RelayerAddressKeyPrefix is the key prefix for relayer address mapping
RelayerAddressKeyPrefix = "relayerAddress"
+
+ // FeeInEscrowPrefix is the key prefix for fee in escrow mapping
+ FeeInEscrowPrefix = "feeInEscrow"
)
// FeeEnabledKey returns the key that stores a flag to determine if fee logic should
@@ -37,3 +44,8 @@ func FeeEnabledKey(portID, channelID string) []byte {
func KeyRelayerAddress(address string) []byte {
return []byte(fmt.Sprintf("%s/%s", RelayerAddressKeyPrefix, address))
}
+
+// KeyFeeInEscrow returns the key for escrowed fees
+func KeyFeeInEscrow(packetID *channeltypes.PacketId) []byte {
+ return []byte(fmt.Sprintf("%s/%s/%s/packet/%d", FeeInEscrowPrefix, packetID.PortId, packetID.ChannelId, packetID.Sequence))
+}
diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go
index 7e330d547bb..ef9e49901fd 100644
--- a/modules/apps/29-fee/types/msgs.go
+++ b/modules/apps/29-fee/types/msgs.go
@@ -3,6 +3,9 @@ package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
+
+ channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
+ host "github.com/cosmos/ibc-go/modules/core/24-host"
)
// msg types
@@ -25,9 +28,8 @@ func (msg MsgRegisterCounterpartyAddress) ValidateBasic() error {
return sdkerrors.Wrap(err, "failed to convert msg.Address into sdk.AccAddress")
}
- _, err = sdk.AccAddressFromBech32(msg.CounterpartyAddress)
- if err != nil {
- return sdkerrors.Wrap(err, "failed to convert msg.CounterpartyAddress into sdk.AccAddress")
+ if msg.CounterpartyAddress == "" {
+ return ErrCounterpartyAddressEmpty
}
return nil
@@ -41,3 +43,129 @@ func (msg MsgRegisterCounterpartyAddress) GetSigners() []sdk.AccAddress {
}
return []sdk.AccAddress{signer}
}
+
+// NewMsgPayPacketFee creates a new instance of MsgPayPacketFee
+func NewMsgPayPacketFee(fee Fee, sourcePortId, sourceChannelId, signer string, relayers []string) *MsgPayPacketFee {
+ return &MsgPayPacketFee{
+ Fee: fee,
+ SourcePortId: sourcePortId,
+ SourceChannelId: sourceChannelId,
+ Signer: signer,
+ Relayers: relayers,
+ }
+}
+
+// ValidateBasic performs a basic check of the MsgPayPacketFee fields
+func (msg MsgPayPacketFee) ValidateBasic() error {
+ // validate channelId
+ err := host.ChannelIdentifierValidator(msg.SourceChannelId)
+ if err != nil {
+ return err
+ }
+
+ // validate portId
+ err = host.PortIdentifierValidator(msg.SourcePortId)
+ if err != nil {
+ return err
+ }
+
+ // signer check
+ _, err = sdk.AccAddressFromBech32(msg.Signer)
+ if err != nil {
+ return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress")
+ }
+
+ // enforce relayer is nil
+ if msg.Relayers != nil {
+ return ErrRelayersNotNil
+ }
+
+ // if any of the fee's are invalid return an error
+ if !msg.Fee.AckFee.IsValid() || !msg.Fee.ReceiveFee.IsValid() || !msg.Fee.TimeoutFee.IsValid() {
+ return sdkerrors.ErrInvalidCoins
+ }
+
+ // if all three fee's are zero or empty return an error
+ if msg.Fee.AckFee.IsZero() && msg.Fee.ReceiveFee.IsZero() && msg.Fee.TimeoutFee.IsZero() {
+ return sdkerrors.ErrInvalidCoins
+ }
+
+ return nil
+}
+
+// GetSigners implements sdk.Msg
+func (msg MsgPayPacketFee) GetSigners() []sdk.AccAddress {
+ signer, err := sdk.AccAddressFromBech32(msg.Signer)
+ if err != nil {
+ panic(err)
+ }
+ return []sdk.AccAddress{signer}
+}
+
+// NewMsgPayPacketAsync creates a new instance of MsgPayPacketFee
+func NewMsgPayPacketFeeAsync(identifiedPacketFee IdentifiedPacketFee, signer string) *MsgPayPacketFeeAsync {
+ return &MsgPayPacketFeeAsync{
+ IdentifiedPacketFee: identifiedPacketFee,
+ Signer: signer,
+ }
+}
+
+// ValidateBasic performs a basic check of the MsgPayPacketFeeAsync fields
+func (msg MsgPayPacketFeeAsync) ValidateBasic() error {
+ // validate channelId
+ err := host.ChannelIdentifierValidator(msg.IdentifiedPacketFee.PacketId.ChannelId)
+ if err != nil {
+ return err
+ }
+
+ // validate portId
+ err = host.PortIdentifierValidator(msg.IdentifiedPacketFee.PacketId.PortId)
+ if err != nil {
+ return err
+ }
+
+ // signer check
+ _, err = sdk.AccAddressFromBech32(msg.Signer)
+ if err != nil {
+ return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress")
+ }
+
+ // enforce relayer is nil
+ if msg.IdentifiedPacketFee.Relayers != nil {
+ return ErrRelayersNotNil
+ }
+
+ // ensure sequence is not 0
+ if msg.IdentifiedPacketFee.PacketId.Sequence == 0 {
+ return sdkerrors.ErrInvalidSequence
+ }
+
+ // if any of the fee's are invalid return an error
+ if !msg.IdentifiedPacketFee.Fee.AckFee.IsValid() || !msg.IdentifiedPacketFee.Fee.ReceiveFee.IsValid() || !msg.IdentifiedPacketFee.Fee.TimeoutFee.IsValid() {
+ return sdkerrors.ErrInvalidCoins
+ }
+
+ // if all three fee's are zero or empty return an error
+ if msg.IdentifiedPacketFee.Fee.AckFee.IsZero() && msg.IdentifiedPacketFee.Fee.ReceiveFee.IsZero() && msg.IdentifiedPacketFee.Fee.TimeoutFee.IsZero() {
+ return sdkerrors.ErrInvalidCoins
+ }
+
+ return nil
+}
+
+// GetSigners implements sdk.Msg
+func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress {
+ signer, err := sdk.AccAddressFromBech32(msg.Signer)
+ if err != nil {
+ panic(err)
+ }
+ return []sdk.AccAddress{signer}
+}
+
+func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, relayers []string) *IdentifiedPacketFee {
+ return &IdentifiedPacketFee{
+ PacketId: packetId,
+ Fee: fee,
+ Relayers: relayers,
+ }
+}
diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go
index d29073f75a7..480eedcc403 100644
--- a/modules/apps/29-fee/types/msgs_test.go
+++ b/modules/apps/29-fee/types/msgs_test.go
@@ -4,13 +4,19 @@ import (
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
+ channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/secp256k1"
)
var (
- validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String()
- invalidAddr = "invalid_address"
+ validChannelID = "channel-1"
+ validPortID = "validPortId"
+ invalidID = "this identifier is too long to be used as a valid identifier"
+ validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}
+ invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdk.NewInt(-2)}}
+ validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String()
+ invalidAddr = "invalid_address"
)
// TestMsgTransferValidation tests ValidateBasic for MsgTransfer
@@ -22,7 +28,7 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) {
}{
{"validate with correct sdk.AccAddress", NewMsgRegisterCounterpartyAddress(validAddr, validAddr), true},
{"validate with incorrect destination relayer address", NewMsgRegisterCounterpartyAddress(invalidAddr, validAddr), false},
- {"validate with incorrect counterparty relayer address", NewMsgRegisterCounterpartyAddress(validAddr, invalidAddr), false},
+ {"invalid counterparty address", NewMsgRegisterCounterpartyAddress(validAddr, ""), false},
}
for i, tc := range testCases {
@@ -34,3 +40,313 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) {
}
}
}
+
+// TestRegisterCounterpartyAddressGetSigners tests GetSigners
+func TestRegisterCountepartyAddressGetSigners(t *testing.T) {
+ addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
+ // build message
+ msg := NewMsgRegisterCounterpartyAddress(addr.String(), "counterparty")
+
+ // GetSigners
+ res := msg.GetSigners()
+
+ require.Equal(t, []sdk.AccAddress{addr}, res)
+}
+
+// TestMsgPayPacketFeeValidation tests ValidateBasic
+func TestMsgPayPacketFeeValidation(t *testing.T) {
+ var (
+ signer string
+ channelID string
+ portID string
+ fee Fee
+ relayers []string
+ ackFee sdk.Coins
+ receiveFee sdk.Coins
+ timeoutFee sdk.Coins
+ )
+
+ testCases := []struct {
+ name string
+ malleate func()
+ expPass bool
+ }{
+ {
+ "success",
+ func() {},
+ true,
+ },
+ {
+ "invalid channelID",
+ func() {
+ channelID = invalidID
+ },
+ false,
+ },
+ {
+ "invalid portID",
+ func() {
+ portID = invalidID
+ },
+ false,
+ },
+ {
+ "relayers is not nil",
+ func() {
+ relayers = []string{validAddr}
+ },
+ false,
+ },
+ {
+ "invalid signer address",
+ func() {
+ signer = "invalid-addr"
+ },
+ false,
+ },
+ {
+ "should fail when all fees are invalid",
+ func() {
+ ackFee = invalidCoins
+ receiveFee = invalidCoins
+ timeoutFee = invalidCoins
+ },
+ false,
+ },
+ {
+ "should fail with single invalid fee",
+ func() {
+ ackFee = invalidCoins
+ },
+ false,
+ },
+ {
+ "should fail with two invalid fees",
+ func() {
+ timeoutFee = invalidCoins
+ ackFee = invalidCoins
+ },
+ false,
+ },
+ {
+ "should pass with two empty fees",
+ func() {
+ timeoutFee = sdk.Coins{}
+ ackFee = sdk.Coins{}
+ },
+ true,
+ },
+ {
+ "should pass with one empty fee",
+ func() {
+ timeoutFee = sdk.Coins{}
+ },
+ true,
+ },
+ {
+ "should fail if all fees are empty",
+ func() {
+ ackFee = sdk.Coins{}
+ receiveFee = sdk.Coins{}
+ timeoutFee = sdk.Coins{}
+ },
+ false,
+ },
+ }
+
+ for _, tc := range testCases {
+ // build message
+ signer = validAddr
+ channelID = validChannelID
+ portID = validPortID
+ ackFee = validCoins
+ receiveFee = validCoins
+ timeoutFee = validCoins
+ relayers = nil
+
+ // malleate
+ tc.malleate()
+ fee = Fee{receiveFee, ackFee, timeoutFee}
+ msg := NewMsgPayPacketFee(fee, portID, channelID, signer, relayers)
+
+ err := msg.ValidateBasic()
+
+ if tc.expPass {
+ require.NoError(t, err)
+ } else {
+ require.Error(t, err)
+ }
+ }
+}
+
+// TestPayPacketFeeGetSigners tests GetSigners
+func TestPayPacketFeeGetSigners(t *testing.T) {
+ addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
+ // build message
+ signer := addr.String()
+ channelID := validChannelID
+ portID := validPortID
+ fee := Fee{validCoins, validCoins, validCoins}
+ msg := NewMsgPayPacketFee(fee, portID, channelID, signer, nil)
+
+ // GetSigners
+ res := msg.GetSigners()
+
+ require.Equal(t, []sdk.AccAddress{addr}, res)
+}
+
+// TestMsgPayPacketFeeAsyncValidation tests ValidateBasic
+func TestMsgPayPacketFeeAsyncValidation(t *testing.T) {
+ var (
+ signer string
+ channelID string
+ portID string
+ fee Fee
+ relayers []string
+ seq uint64
+ ackFee sdk.Coins
+ receiveFee sdk.Coins
+ timeoutFee sdk.Coins
+ )
+
+ testCases := []struct {
+ name string
+ malleate func()
+ expPass bool
+ }{
+ {
+ "success",
+ func() {},
+ true,
+ },
+ {
+ "invalid channelID",
+ func() {
+ channelID = invalidID
+ },
+ false,
+ },
+ {
+ "invalid portID",
+ func() {
+ portID = invalidID
+ },
+ false,
+ },
+ {
+ "relayers is not nil",
+ func() {
+ relayers = []string{validAddr}
+ },
+ false,
+ },
+ {
+ "invalid signer address",
+ func() {
+ signer = "invalid-addr"
+ },
+ false,
+ },
+ {
+ "invalid sequence",
+ func() {
+ seq = 0
+ },
+ false,
+ },
+ {
+ "should fail when all fees are invalid",
+ func() {
+ ackFee = invalidCoins
+ receiveFee = invalidCoins
+ timeoutFee = invalidCoins
+ },
+ false,
+ },
+ {
+ "should fail with single invalid fee",
+ func() {
+ ackFee = invalidCoins
+ },
+ false,
+ },
+ {
+ "should fail with two invalid fees",
+ func() {
+ timeoutFee = invalidCoins
+ ackFee = invalidCoins
+ },
+ false,
+ },
+ {
+ "should pass with two empty fees",
+ func() {
+ timeoutFee = sdk.Coins{}
+ ackFee = sdk.Coins{}
+ },
+ true,
+ },
+ {
+ "should pass with one empty fee",
+ func() {
+ timeoutFee = sdk.Coins{}
+ },
+ true,
+ },
+ {
+ "should fail if all fees are empty",
+ func() {
+ ackFee = sdk.Coins{}
+ receiveFee = sdk.Coins{}
+ timeoutFee = sdk.Coins{}
+ },
+ false,
+ },
+ }
+
+ for _, tc := range testCases {
+ // build message
+ signer = validAddr
+ channelID = validChannelID
+ portID = validPortID
+ ackFee = validCoins
+ receiveFee = validCoins
+ timeoutFee = validCoins
+ relayers = nil
+ seq = 1
+
+ // malleate
+ tc.malleate()
+ fee = Fee{receiveFee, ackFee, timeoutFee}
+
+ packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: portID, Sequence: seq}
+ identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: relayers}
+ msg := NewMsgPayPacketFeeAsync(identifiedPacketFee, signer)
+
+ err := msg.ValidateBasic()
+
+ if tc.expPass {
+ require.NoError(t, err)
+ } else {
+ require.Error(t, err)
+ }
+ }
+}
+
+// TestRegisterCounterpartyAddressGetSigners tests GetSigners
+func TestPayPacketFeeAsyncGetSigners(t *testing.T) {
+ addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
+ // build message
+ channelID := validChannelID
+ portID := validPortID
+ fee := Fee{validCoins, validCoins, validCoins}
+ seq := uint64(1)
+ packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: portID, Sequence: seq}
+ identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: nil}
+ msg := NewMsgPayPacketFeeAsync(identifiedPacketFee, addr.String())
+
+ // GetSigners
+ res := msg.GetSigners()
+
+ require.Equal(t, []sdk.AccAddress{addr}, res)
+}
diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go
index c9fb330d12b..7e27acc666a 100644
--- a/modules/apps/29-fee/types/tx.pb.go
+++ b/modules/apps/29-fee/types/tx.pb.go
@@ -107,24 +107,32 @@ func (m *MsgRegisterCounterpartyAddressResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgRegisterCounterpartyAddressResponse proto.InternalMessageInfo
-// MsgEscrowPacketFee defines the request type EscrowPacketFee RPC
-type MsgEscrowPacketFee struct {
- IncentivizedPacket *IdentifiedPacketFee `protobuf:"bytes,1,opt,name=incentivized_packet,json=incentivizedPacket,proto3" json:"incentivized_packet,omitempty" yaml:"incentivized_packet"`
- Relayers []string `protobuf:"bytes,2,rep,name=relayers,proto3" json:"relayers,omitempty"`
+// MsgPayPacketFee defines the request type PayPacketFee RPC
+// This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be
+// paid for
+type MsgPayPacketFee struct {
+ Fee Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee"`
+ // source channel port identifier
+ SourcePortId string `protobuf:"bytes,2,opt,name=source_port_id,json=sourcePortId,proto3" json:"source_port_id,omitempty" yaml:"source_port_id"`
+ // source channel unique identifier
+ SourceChannelId string `protobuf:"bytes,3,opt,name=source_channel_id,json=sourceChannelId,proto3" json:"source_channel_id,omitempty" yaml:"source_channel_id"`
+ // account address to refund fee if necessary
+ Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"`
+ Relayers []string `protobuf:"bytes,5,rep,name=relayers,proto3" json:"relayers,omitempty"`
}
-func (m *MsgEscrowPacketFee) Reset() { *m = MsgEscrowPacketFee{} }
-func (m *MsgEscrowPacketFee) String() string { return proto.CompactTextString(m) }
-func (*MsgEscrowPacketFee) ProtoMessage() {}
-func (*MsgEscrowPacketFee) Descriptor() ([]byte, []int) {
+func (m *MsgPayPacketFee) Reset() { *m = MsgPayPacketFee{} }
+func (m *MsgPayPacketFee) String() string { return proto.CompactTextString(m) }
+func (*MsgPayPacketFee) ProtoMessage() {}
+func (*MsgPayPacketFee) Descriptor() ([]byte, []int) {
return fileDescriptor_05c93128649f1b96, []int{2}
}
-func (m *MsgEscrowPacketFee) XXX_Unmarshal(b []byte) error {
+func (m *MsgPayPacketFee) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
-func (m *MsgEscrowPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+func (m *MsgPayPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
- return xxx_messageInfo_MsgEscrowPacketFee.Marshal(b, m, deterministic)
+ return xxx_messageInfo_MsgPayPacketFee.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
@@ -134,34 +142,34 @@ func (m *MsgEscrowPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte,
return b[:n], nil
}
}
-func (m *MsgEscrowPacketFee) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEscrowPacketFee.Merge(m, src)
+func (m *MsgPayPacketFee) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_MsgPayPacketFee.Merge(m, src)
}
-func (m *MsgEscrowPacketFee) XXX_Size() int {
+func (m *MsgPayPacketFee) XXX_Size() int {
return m.Size()
}
-func (m *MsgEscrowPacketFee) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEscrowPacketFee.DiscardUnknown(m)
+func (m *MsgPayPacketFee) XXX_DiscardUnknown() {
+ xxx_messageInfo_MsgPayPacketFee.DiscardUnknown(m)
}
-var xxx_messageInfo_MsgEscrowPacketFee proto.InternalMessageInfo
+var xxx_messageInfo_MsgPayPacketFee proto.InternalMessageInfo
-// MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee
-type MsgEscrowPacketFeeResponse struct {
+// MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee
+type MsgPayPacketFeeResponse struct {
}
-func (m *MsgEscrowPacketFeeResponse) Reset() { *m = MsgEscrowPacketFeeResponse{} }
-func (m *MsgEscrowPacketFeeResponse) String() string { return proto.CompactTextString(m) }
-func (*MsgEscrowPacketFeeResponse) ProtoMessage() {}
-func (*MsgEscrowPacketFeeResponse) Descriptor() ([]byte, []int) {
+func (m *MsgPayPacketFeeResponse) Reset() { *m = MsgPayPacketFeeResponse{} }
+func (m *MsgPayPacketFeeResponse) String() string { return proto.CompactTextString(m) }
+func (*MsgPayPacketFeeResponse) ProtoMessage() {}
+func (*MsgPayPacketFeeResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_05c93128649f1b96, []int{3}
}
-func (m *MsgEscrowPacketFeeResponse) XXX_Unmarshal(b []byte) error {
+func (m *MsgPayPacketFeeResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
-func (m *MsgEscrowPacketFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+func (m *MsgPayPacketFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
- return xxx_messageInfo_MsgEscrowPacketFeeResponse.Marshal(b, m, deterministic)
+ return xxx_messageInfo_MsgPayPacketFeeResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
@@ -171,58 +179,147 @@ func (m *MsgEscrowPacketFeeResponse) XXX_Marshal(b []byte, deterministic bool) (
return b[:n], nil
}
}
-func (m *MsgEscrowPacketFeeResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_MsgEscrowPacketFeeResponse.Merge(m, src)
+func (m *MsgPayPacketFeeResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_MsgPayPacketFeeResponse.Merge(m, src)
}
-func (m *MsgEscrowPacketFeeResponse) XXX_Size() int {
+func (m *MsgPayPacketFeeResponse) XXX_Size() int {
return m.Size()
}
-func (m *MsgEscrowPacketFeeResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_MsgEscrowPacketFeeResponse.DiscardUnknown(m)
+func (m *MsgPayPacketFeeResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_MsgPayPacketFeeResponse.DiscardUnknown(m)
}
-var xxx_messageInfo_MsgEscrowPacketFeeResponse proto.InternalMessageInfo
+var xxx_messageInfo_MsgPayPacketFeeResponse proto.InternalMessageInfo
+
+// MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC
+// This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send)
+type MsgPayPacketFeeAsync struct {
+ // packet to pay fee for
+ IdentifiedPacketFee IdentifiedPacketFee `protobuf:"bytes,1,opt,name=identified_packet_fee,json=identifiedPacketFee,proto3" json:"identified_packet_fee" yaml:"identified_packet_fee"`
+ // account address to refund fee if necessary
+ Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"`
+}
+
+func (m *MsgPayPacketFeeAsync) Reset() { *m = MsgPayPacketFeeAsync{} }
+func (m *MsgPayPacketFeeAsync) String() string { return proto.CompactTextString(m) }
+func (*MsgPayPacketFeeAsync) ProtoMessage() {}
+func (*MsgPayPacketFeeAsync) Descriptor() ([]byte, []int) {
+ return fileDescriptor_05c93128649f1b96, []int{4}
+}
+func (m *MsgPayPacketFeeAsync) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *MsgPayPacketFeeAsync) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_MsgPayPacketFeeAsync.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *MsgPayPacketFeeAsync) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_MsgPayPacketFeeAsync.Merge(m, src)
+}
+func (m *MsgPayPacketFeeAsync) XXX_Size() int {
+ return m.Size()
+}
+func (m *MsgPayPacketFeeAsync) XXX_DiscardUnknown() {
+ xxx_messageInfo_MsgPayPacketFeeAsync.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_MsgPayPacketFeeAsync proto.InternalMessageInfo
+
+// MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync
+type MsgPayPacketFeeAsyncResponse struct {
+}
+
+func (m *MsgPayPacketFeeAsyncResponse) Reset() { *m = MsgPayPacketFeeAsyncResponse{} }
+func (m *MsgPayPacketFeeAsyncResponse) String() string { return proto.CompactTextString(m) }
+func (*MsgPayPacketFeeAsyncResponse) ProtoMessage() {}
+func (*MsgPayPacketFeeAsyncResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_05c93128649f1b96, []int{5}
+}
+func (m *MsgPayPacketFeeAsyncResponse) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *MsgPayPacketFeeAsyncResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_MsgPayPacketFeeAsyncResponse.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *MsgPayPacketFeeAsyncResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_MsgPayPacketFeeAsyncResponse.Merge(m, src)
+}
+func (m *MsgPayPacketFeeAsyncResponse) XXX_Size() int {
+ return m.Size()
+}
+func (m *MsgPayPacketFeeAsyncResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_MsgPayPacketFeeAsyncResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_MsgPayPacketFeeAsyncResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*MsgRegisterCounterpartyAddress)(nil), "ibc.applications.fee.v1.MsgRegisterCounterpartyAddress")
proto.RegisterType((*MsgRegisterCounterpartyAddressResponse)(nil), "ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse")
- proto.RegisterType((*MsgEscrowPacketFee)(nil), "ibc.applications.fee.v1.MsgEscrowPacketFee")
- proto.RegisterType((*MsgEscrowPacketFeeResponse)(nil), "ibc.applications.fee.v1.MsgEscrowPacketFeeResponse")
+ proto.RegisterType((*MsgPayPacketFee)(nil), "ibc.applications.fee.v1.MsgPayPacketFee")
+ proto.RegisterType((*MsgPayPacketFeeResponse)(nil), "ibc.applications.fee.v1.MsgPayPacketFeeResponse")
+ proto.RegisterType((*MsgPayPacketFeeAsync)(nil), "ibc.applications.fee.v1.MsgPayPacketFeeAsync")
+ proto.RegisterType((*MsgPayPacketFeeAsyncResponse)(nil), "ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse")
}
func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) }
var fileDescriptor_05c93128649f1b96 = []byte{
- // 451 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x41, 0x6b, 0xd4, 0x40,
- 0x14, 0xc7, 0x93, 0x16, 0xb4, 0x1d, 0x0f, 0xc2, 0xb4, 0x60, 0x49, 0x25, 0xa9, 0x39, 0xc8, 0x82,
- 0x36, 0x43, 0xb7, 0x07, 0xb1, 0x17, 0x71, 0x45, 0x41, 0x70, 0x41, 0x72, 0xf4, 0x52, 0x26, 0x93,
- 0xb7, 0xd3, 0xc1, 0x6c, 0x26, 0xcc, 0x9b, 0x5d, 0x5d, 0xc1, 0xbb, 0x47, 0x0f, 0x82, 0x1e, 0xfb,
- 0x35, 0xfc, 0x06, 0x1e, 0x7b, 0xf4, 0x54, 0x64, 0xf7, 0xe2, 0xb9, 0x9f, 0x40, 0x66, 0x63, 0x4a,
- 0x68, 0x77, 0x17, 0xf4, 0xf6, 0x26, 0xf3, 0xfb, 0xbf, 0x79, 0xff, 0x7f, 0x78, 0x64, 0x4f, 0x65,
- 0x82, 0xf1, 0xaa, 0x2a, 0x94, 0xe0, 0x56, 0xe9, 0x12, 0xd9, 0x00, 0x80, 0x8d, 0x0f, 0x98, 0x7d,
- 0x9f, 0x54, 0x46, 0x5b, 0x4d, 0xef, 0xa8, 0x4c, 0x24, 0x6d, 0x22, 0x19, 0x00, 0x24, 0xe3, 0x83,
- 0x60, 0x5b, 0x6a, 0xa9, 0xe7, 0x0c, 0x73, 0x55, 0x8d, 0x07, 0xf7, 0x96, 0x35, 0x74, 0xaa, 0x16,
- 0x22, 0xb4, 0x01, 0x26, 0x4e, 0x78, 0x59, 0x42, 0xe1, 0xae, 0xff, 0x96, 0x35, 0x12, 0x7f, 0xf3,
- 0x49, 0xd8, 0x47, 0x99, 0x82, 0x54, 0x68, 0xc1, 0x3c, 0xd3, 0xa3, 0xd2, 0x82, 0xa9, 0xb8, 0xb1,
- 0x93, 0xa7, 0x79, 0x6e, 0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, 0x69, 0xeb, 0x29, 0x7b, 0x1a, 0xca, 0xcf, 0xb3,
+ 0x30, 0xf6, 0x58, 0xbe, 0xcc, 0xa0, 0x4c, 0x8d, 0x7b, 0xca, 0x37, 0x19, 0x1d, 0x2c, 0x7b, 0xdb,
+ 0x6f, 0x17, 0x5a, 0x5a, 0xfe, 0xf4, 0xd4, 0xe3, 0x7f, 0x6c, 0x1c, 0x9f, 0x50, 0xf9, 0x84, 0x36,
+ 0xa7, 0xde, 0x6b, 0x71, 0x99, 0x60, 0x9a, 0x54, 0x5f, 0x3e, 0x94, 0x9c, 0xec, 0x15, 0xa2, 0xed,
+ 0xd9, 0xdb, 0x2e, 0x3d, 0x54, 0x26, 0xc6, 0xd5, 0x37, 0x7f, 0x85, 0x8f, 0xb7, 0xae, 0x7c, 0xb8,
+ 0xe9, 0x6b, 0xf2, 0x6d, 0x5f, 0x93, 0x7f, 0xf5, 0x35, 0xf9, 0x6a, 0xa0, 0x49, 0xb7, 0x03, 0x4d,
+ 0xfa, 0x39, 0xd0, 0xa4, 0x8f, 0x65, 0x8f, 0x88, 0xf3, 0x6e, 0xd3, 0xc4, 0xb4, 0x63, 0x61, 0xca,
+ 0x3b, 0x94, 0x5b, 0xa4, 0x89, 0x4b, 0x1e, 0xb5, 0x3a, 0xd4, 0xed, 0xb6, 0x81, 0x47, 0x9f, 0x1b,
+ 0xb7, 0xca, 0xef, 0x4a, 0xd1, 0xbf, 0x26, 0xc2, 0x00, 0x78, 0x73, 0x2d, 0xfe, 0xb4, 0x5e, 0xfd,
+ 0x09, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xcb, 0x98, 0x2b, 0x4d, 0x05, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -243,10 +340,14 @@ type MsgClient interface {
// destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function
// may be called more than once by a relayer, in which case, latest counterparty address is always used.
RegisterCounterpartyAddress(ctx context.Context, in *MsgRegisterCounterpartyAddress, opts ...grpc.CallOption) (*MsgRegisterCounterpartyAddressResponse, error)
- // EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee
- // EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to
- // incentivize the relaying of the given packet.
- EscrowPacketFee(ctx context.Context, in *MsgEscrowPacketFee, opts ...grpc.CallOption) (*MsgEscrowPacketFeeResponse, error)
+ // PayPacketFee defines a rpc handler method for MsgPayPacketFee
+ // PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to
+ // incentivize the relaying of the packet at the next sequence
+ PayPacketFee(ctx context.Context, in *MsgPayPacketFee, opts ...grpc.CallOption) (*MsgPayPacketFeeResponse, error)
+ // PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync
+ // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to
+ // incentivize the relaying of a known packet
+ PayPacketFeeAsync(ctx context.Context, in *MsgPayPacketFeeAsync, opts ...grpc.CallOption) (*MsgPayPacketFeeAsyncResponse, error)
}
type msgClient struct {
@@ -266,9 +367,18 @@ func (c *msgClient) RegisterCounterpartyAddress(ctx context.Context, in *MsgRegi
return out, nil
}
-func (c *msgClient) EscrowPacketFee(ctx context.Context, in *MsgEscrowPacketFee, opts ...grpc.CallOption) (*MsgEscrowPacketFeeResponse, error) {
- out := new(MsgEscrowPacketFeeResponse)
- err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Msg/EscrowPacketFee", in, out, opts...)
+func (c *msgClient) PayPacketFee(ctx context.Context, in *MsgPayPacketFee, opts ...grpc.CallOption) (*MsgPayPacketFeeResponse, error) {
+ out := new(MsgPayPacketFeeResponse)
+ err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Msg/PayPacketFee", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *msgClient) PayPacketFeeAsync(ctx context.Context, in *MsgPayPacketFeeAsync, opts ...grpc.CallOption) (*MsgPayPacketFeeAsyncResponse, error) {
+ out := new(MsgPayPacketFeeAsyncResponse)
+ err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Msg/PayPacketFeeAsync", in, out, opts...)
if err != nil {
return nil, err
}
@@ -283,10 +393,14 @@ type MsgServer interface {
// destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function
// may be called more than once by a relayer, in which case, latest counterparty address is always used.
RegisterCounterpartyAddress(context.Context, *MsgRegisterCounterpartyAddress) (*MsgRegisterCounterpartyAddressResponse, error)
- // EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee
- // EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to
- // incentivize the relaying of the given packet.
- EscrowPacketFee(context.Context, *MsgEscrowPacketFee) (*MsgEscrowPacketFeeResponse, error)
+ // PayPacketFee defines a rpc handler method for MsgPayPacketFee
+ // PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to
+ // incentivize the relaying of the packet at the next sequence
+ PayPacketFee(context.Context, *MsgPayPacketFee) (*MsgPayPacketFeeResponse, error)
+ // PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync
+ // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to
+ // incentivize the relaying of a known packet
+ PayPacketFeeAsync(context.Context, *MsgPayPacketFeeAsync) (*MsgPayPacketFeeAsyncResponse, error)
}
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
@@ -296,8 +410,11 @@ type UnimplementedMsgServer struct {
func (*UnimplementedMsgServer) RegisterCounterpartyAddress(ctx context.Context, req *MsgRegisterCounterpartyAddress) (*MsgRegisterCounterpartyAddressResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RegisterCounterpartyAddress not implemented")
}
-func (*UnimplementedMsgServer) EscrowPacketFee(ctx context.Context, req *MsgEscrowPacketFee) (*MsgEscrowPacketFeeResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EscrowPacketFee not implemented")
+func (*UnimplementedMsgServer) PayPacketFee(ctx context.Context, req *MsgPayPacketFee) (*MsgPayPacketFeeResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method PayPacketFee not implemented")
+}
+func (*UnimplementedMsgServer) PayPacketFeeAsync(ctx context.Context, req *MsgPayPacketFeeAsync) (*MsgPayPacketFeeAsyncResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method PayPacketFeeAsync not implemented")
}
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
@@ -322,20 +439,38 @@ func _Msg_RegisterCounterpartyAddress_Handler(srv interface{}, ctx context.Conte
return interceptor(ctx, in, info, handler)
}
-func _Msg_EscrowPacketFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(MsgEscrowPacketFee)
+func _Msg_PayPacketFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(MsgPayPacketFee)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
- return srv.(MsgServer).EscrowPacketFee(ctx, in)
+ return srv.(MsgServer).PayPacketFee(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
- FullMethod: "/ibc.applications.fee.v1.Msg/EscrowPacketFee",
+ FullMethod: "/ibc.applications.fee.v1.Msg/PayPacketFee",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(MsgServer).EscrowPacketFee(ctx, req.(*MsgEscrowPacketFee))
+ return srv.(MsgServer).PayPacketFee(ctx, req.(*MsgPayPacketFee))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Msg_PayPacketFeeAsync_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(MsgPayPacketFeeAsync)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(MsgServer).PayPacketFeeAsync(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/ibc.applications.fee.v1.Msg/PayPacketFeeAsync",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(MsgServer).PayPacketFeeAsync(ctx, req.(*MsgPayPacketFeeAsync))
}
return interceptor(ctx, in, info, handler)
}
@@ -349,8 +484,12 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
Handler: _Msg_RegisterCounterpartyAddress_Handler,
},
{
- MethodName: "EscrowPacketFee",
- Handler: _Msg_EscrowPacketFee_Handler,
+ MethodName: "PayPacketFee",
+ Handler: _Msg_PayPacketFee_Handler,
+ },
+ {
+ MethodName: "PayPacketFeeAsync",
+ Handler: _Msg_PayPacketFeeAsync_Handler,
},
},
Streams: []grpc.StreamDesc{},
@@ -417,7 +556,7 @@ func (m *MsgRegisterCounterpartyAddressResponse) MarshalToSizedBuffer(dAtA []byt
return len(dAtA) - i, nil
}
-func (m *MsgEscrowPacketFee) Marshal() (dAtA []byte, err error) {
+func (m *MsgPayPacketFee) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
@@ -427,12 +566,12 @@ func (m *MsgEscrowPacketFee) Marshal() (dAtA []byte, err error) {
return dAtA[:n], nil
}
-func (m *MsgEscrowPacketFee) MarshalTo(dAtA []byte) (int, error) {
+func (m *MsgPayPacketFee) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
-func (m *MsgEscrowPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+func (m *MsgPayPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
@@ -443,25 +582,107 @@ func (m *MsgEscrowPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.Relayers[iNdEx])
i = encodeVarintTx(dAtA, i, uint64(len(m.Relayers[iNdEx])))
i--
- dAtA[i] = 0x12
+ dAtA[i] = 0x2a
}
}
- if m.IncentivizedPacket != nil {
- {
- size, err := m.IncentivizedPacket.MarshalToSizedBuffer(dAtA[:i])
- if err != nil {
- return 0, err
- }
- i -= size
- i = encodeVarintTx(dAtA, i, uint64(size))
+ if len(m.Signer) > 0 {
+ i -= len(m.Signer)
+ copy(dAtA[i:], m.Signer)
+ i = encodeVarintTx(dAtA, i, uint64(len(m.Signer)))
+ i--
+ dAtA[i] = 0x22
+ }
+ if len(m.SourceChannelId) > 0 {
+ i -= len(m.SourceChannelId)
+ copy(dAtA[i:], m.SourceChannelId)
+ i = encodeVarintTx(dAtA, i, uint64(len(m.SourceChannelId)))
+ i--
+ dAtA[i] = 0x1a
+ }
+ if len(m.SourcePortId) > 0 {
+ i -= len(m.SourcePortId)
+ copy(dAtA[i:], m.SourcePortId)
+ i = encodeVarintTx(dAtA, i, uint64(len(m.SourcePortId)))
+ i--
+ dAtA[i] = 0x12
+ }
+ {
+ size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
}
+ i -= size
+ i = encodeVarintTx(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0xa
+ return len(dAtA) - i, nil
+}
+
+func (m *MsgPayPacketFeeResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MsgPayPacketFeeResponse) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *MsgPayPacketFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ return len(dAtA) - i, nil
+}
+
+func (m *MsgPayPacketFeeAsync) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *MsgPayPacketFeeAsync) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *MsgPayPacketFeeAsync) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if len(m.Signer) > 0 {
+ i -= len(m.Signer)
+ copy(dAtA[i:], m.Signer)
+ i = encodeVarintTx(dAtA, i, uint64(len(m.Signer)))
i--
- dAtA[i] = 0xa
+ dAtA[i] = 0x12
}
+ {
+ size, err := m.IdentifiedPacketFee.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintTx(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0xa
return len(dAtA) - i, nil
}
-func (m *MsgEscrowPacketFeeResponse) Marshal() (dAtA []byte, err error) {
+func (m *MsgPayPacketFeeAsyncResponse) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
@@ -471,12 +692,12 @@ func (m *MsgEscrowPacketFeeResponse) Marshal() (dAtA []byte, err error) {
return dAtA[:n], nil
}
-func (m *MsgEscrowPacketFeeResponse) MarshalTo(dAtA []byte) (int, error) {
+func (m *MsgPayPacketFeeAsyncResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
-func (m *MsgEscrowPacketFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+func (m *MsgPayPacketFeeAsyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
@@ -521,14 +742,24 @@ func (m *MsgRegisterCounterpartyAddressResponse) Size() (n int) {
return n
}
-func (m *MsgEscrowPacketFee) Size() (n int) {
+func (m *MsgPayPacketFee) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
- if m.IncentivizedPacket != nil {
- l = m.IncentivizedPacket.Size()
+ l = m.Fee.Size()
+ n += 1 + l + sovTx(uint64(l))
+ l = len(m.SourcePortId)
+ if l > 0 {
+ n += 1 + l + sovTx(uint64(l))
+ }
+ l = len(m.SourceChannelId)
+ if l > 0 {
+ n += 1 + l + sovTx(uint64(l))
+ }
+ l = len(m.Signer)
+ if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
if len(m.Relayers) > 0 {
@@ -540,7 +771,31 @@ func (m *MsgEscrowPacketFee) Size() (n int) {
return n
}
-func (m *MsgEscrowPacketFeeResponse) Size() (n int) {
+func (m *MsgPayPacketFeeResponse) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ return n
+}
+
+func (m *MsgPayPacketFeeAsync) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = m.IdentifiedPacketFee.Size()
+ n += 1 + l + sovTx(uint64(l))
+ l = len(m.Signer)
+ if l > 0 {
+ n += 1 + l + sovTx(uint64(l))
+ }
+ return n
+}
+
+func (m *MsgPayPacketFeeAsyncResponse) Size() (n int) {
if m == nil {
return 0
}
@@ -719,7 +974,7 @@ func (m *MsgRegisterCounterpartyAddressResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
-func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error {
+func (m *MsgPayPacketFee) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
@@ -742,15 +997,15 @@ func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error {
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
- return fmt.Errorf("proto: MsgEscrowPacketFee: wiretype end group for non-group")
+ return fmt.Errorf("proto: MsgPayPacketFee: wiretype end group for non-group")
}
if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEscrowPacketFee: illegal tag %d (wire type %d)", fieldNum, wire)
+ return fmt.Errorf("proto: MsgPayPacketFee: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field IncentivizedPacket", wireType)
+ return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@@ -777,14 +1032,107 @@ func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
- if m.IncentivizedPacket == nil {
- m.IncentivizedPacket = &IdentifiedPacketFee{}
- }
- if err := m.IncentivizedPacket.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field SourcePortId", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowTx
+ }
+ 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 ErrInvalidLengthTx
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthTx
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.SourcePortId = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field SourceChannelId", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowTx
+ }
+ 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 ErrInvalidLengthTx
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthTx
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.SourceChannelId = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowTx
+ }
+ 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 ErrInvalidLengthTx
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthTx
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Signer = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType)
}
@@ -837,7 +1185,172 @@ func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error {
}
return nil
}
-func (m *MsgEscrowPacketFeeResponse) Unmarshal(dAtA []byte) error {
+func (m *MsgPayPacketFeeResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowTx
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MsgPayPacketFeeResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MsgPayPacketFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipTx(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
+ return ErrInvalidLengthTx
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MsgPayPacketFeeAsync) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowTx
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: MsgPayPacketFeeAsync: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: MsgPayPacketFeeAsync: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field IdentifiedPacketFee", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowTx
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthTx
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthTx
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if err := m.IdentifiedPacketFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowTx
+ }
+ 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 ErrInvalidLengthTx
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthTx
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Signer = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipTx(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if (skippy < 0) || (iNdEx+skippy) < 0 {
+ return ErrInvalidLengthTx
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *MsgPayPacketFeeAsyncResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
@@ -860,10 +1373,10 @@ func (m *MsgEscrowPacketFeeResponse) Unmarshal(dAtA []byte) error {
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
- return fmt.Errorf("proto: MsgEscrowPacketFeeResponse: wiretype end group for non-group")
+ return fmt.Errorf("proto: MsgPayPacketFeeAsyncResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
- return fmt.Errorf("proto: MsgEscrowPacketFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ return fmt.Errorf("proto: MsgPayPacketFeeAsyncResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto
index 888ade35acb..121eae2dca4 100644
--- a/proto/ibc/applications/fee/v1/fee.proto
+++ b/proto/ibc/applications/fee/v1/fee.proto
@@ -10,15 +10,25 @@ option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types";
// See Fee Payment Middleware spec:
// https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract
message Fee {
- repeated cosmos.base.v1beta1.Coin amount = 1
- [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
+ repeated cosmos.base.v1beta1.Coin receive_fee = 1 [
+ (gogoproto.moretags) = "yaml:\"receive_fee\"",
+ (gogoproto.nullable) = false,
+ (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
+ ];
+ repeated cosmos.base.v1beta1.Coin ack_fee = 2 [
+ (gogoproto.moretags) = "yaml:\"ack_fee\"",
+ (gogoproto.nullable) = false,
+ (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
+ ];
+ repeated cosmos.base.v1beta1.Coin timeout_fee = 3 [
+ (gogoproto.moretags) = "yaml:\"timeout_fee\"",
+ (gogoproto.nullable) = false,
+ (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
+ ];
}
-
// Fee associated with a packet_id
message IdentifiedPacketFee {
- ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""];
- Fee receive_fee = 2 [(gogoproto.moretags) = "yaml:\"receive_fee\""];
- Fee ack_fee = 3 [(gogoproto.moretags) = "yaml:\"ack_fee\""];
- Fee timeout_fee = 4 [(gogoproto.moretags) = "yaml:\"timeout_fee\""];
- repeated string relayers = 5;
+ ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""];
+ Fee fee = 2 [(gogoproto.nullable) = false];
+ repeated string relayers = 3;
}
diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto
index 373fd7786c4..4006b5fdc9d 100644
--- a/proto/ibc/applications/fee/v1/genesis.proto
+++ b/proto/ibc/applications/fee/v1/genesis.proto
@@ -7,7 +7,5 @@ option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types";
// GenesisState defines the fee middleware genesis state
message GenesisState {
- // A mapping of packets -> escrowed fees
- repeated ibc.applications.fee.v1.IdentifiedPacketFee packets_fees = 1
- [(gogoproto.moretags) = "yaml:\"packets_fees\""];
+ // TODO
}
diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto
index f9b56cf5011..31163483d4d 100644
--- a/proto/ibc/applications/fee/v1/tx.proto
+++ b/proto/ibc/applications/fee/v1/tx.proto
@@ -15,10 +15,14 @@ service Msg {
// destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function
// may be called more than once by a relayer, in which case, latest counterparty address is always used.
rpc RegisterCounterpartyAddress(MsgRegisterCounterpartyAddress) returns (MsgRegisterCounterpartyAddressResponse);
- // EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee
- // EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to
- // incentivize the relaying of the given packet.
- rpc EscrowPacketFee(MsgEscrowPacketFee) returns (MsgEscrowPacketFeeResponse);
+ // PayPacketFee defines a rpc handler method for MsgPayPacketFee
+ // PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to
+ // incentivize the relaying of the packet at the next sequence
+ rpc PayPacketFee(MsgPayPacketFee) returns (MsgPayPacketFeeResponse);
+ // PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync
+ // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to
+ // incentivize the relaying of a known packet
+ rpc PayPacketFeeAsync(MsgPayPacketFeeAsync) returns (MsgPayPacketFeeAsyncResponse);
}
// MsgRegisterCounterpartyAddress is the request type for registering the counter party address
@@ -33,15 +37,38 @@ message MsgRegisterCounterpartyAddress {
// MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type
message MsgRegisterCounterpartyAddressResponse {}
-// MsgEscrowPacketFee defines the request type EscrowPacketFee RPC
-message MsgEscrowPacketFee {
+// MsgPayPacketFee defines the request type PayPacketFee RPC
+// This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be
+// paid for
+message MsgPayPacketFee {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
- ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packet = 1
- [(gogoproto.moretags) = "yaml:\"incentivized_packet\""];
- repeated string relayers = 2;
+ ibc.applications.fee.v1.Fee fee = 1 [(gogoproto.nullable) = false];
+ // source channel port identifier
+ string source_port_id = 2 [(gogoproto.moretags) = "yaml:\"source_port_id\""];
+ // source channel unique identifier
+ string source_channel_id = 3 [(gogoproto.moretags) = "yaml:\"source_channel_id\""];
+ // account address to refund fee if necessary
+ string signer = 4;
+ repeated string relayers = 5;
}
-// MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee
-message MsgEscrowPacketFeeResponse {}
+// MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee
+message MsgPayPacketFeeResponse {}
+
+// MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC
+// This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send)
+message MsgPayPacketFeeAsync {
+ option (gogoproto.equal) = false;
+ option (gogoproto.goproto_getters) = false;
+
+ // packet to pay fee for
+ ibc.applications.fee.v1.IdentifiedPacketFee identified_packet_fee = 1
+ [(gogoproto.moretags) = "yaml:\"identified_packet_fee\"", (gogoproto.nullable) = false];
+ // account address to refund fee if necessary
+ string signer = 2;
+}
+
+// MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync
+message MsgPayPacketFeeAsyncResponse {}
diff --git a/testing/simapp/app.go b/testing/simapp/app.go
index 83cdf6ff2a7..58b2a79006d 100644
--- a/testing/simapp/app.go
+++ b/testing/simapp/app.go
@@ -147,6 +147,7 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
+ ibcfeetypes.ModuleName: nil,
}
)
@@ -322,7 +323,7 @@ func NewSimApp(
)
app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(appCodec, keys[ibcfeetypes.StoreKey], app.GetSubspace(ibcfeetypes.ModuleName),
- app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
+ app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper,
)
// Create Transfer Keeper and pass IBCFeeKeeper as expected Channel and PortKeeper