Skip to content

Commit

Permalink
nits: proto spacing + naming (#739)
Browse files Browse the repository at this point in the history
* nits: proto spacing + naming

* nit: update comment

* fix: go.mod

* nit: option above import proto

* fix: spacing
  • Loading branch information
seantking authored Jan 20, 2022
1 parent 26731ce commit 764df84
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 83 deletions.
4 changes: 2 additions & 2 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middl

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `receive_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
| `recv_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 | |

Expand Down Expand Up @@ -978,7 +978,7 @@ MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee
<a name="ibc.applications.fee.v1.MsgRegisterCounterpartyAddress"></a>

### MsgRegisterCounterpartyAddress
MsgRegisterCounterpartyAddress is the request type for registering the counter party address
MsgRegisterCounterpartyAddress is the request type for registering the counterparty address


| Field | Type | Label | Description |
Expand Down
10 changes: 5 additions & 5 deletions modules/apps/29-fee/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {
{
"success",
func() {
expectedRelayerBalance = identifiedFee.Fee.ReceiveFee.Add(identifiedFee.Fee.AckFee[0])
expectedRelayerBalance = identifiedFee.Fee.RecvFee.Add(identifiedFee.Fee.AckFee[0])
},
true,
},
Expand Down Expand Up @@ -603,7 +603,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {
identifiedFee = types.NewIdentifiedPacketFee(
packetId,
types.Fee{
ReceiveFee: validCoins,
RecvFee: validCoins,
AckFee: validCoins2,
TimeoutFee: validCoins3,
},
Expand Down Expand Up @@ -698,7 +698,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() {
relayerAddr = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()

expectedBalance = originalBalance.
Add(identifiedFee.Fee.ReceiveFee[0]).
Add(identifiedFee.Fee.RecvFee[0]).
Add(identifiedFee.Fee.AckFee[0]).
Add(ibctesting.TestCoin) // timeout refund for ics20 transfer
},
Expand Down Expand Up @@ -737,7 +737,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() {
identifiedFee = types.NewIdentifiedPacketFee(
packetId,
types.Fee{
ReceiveFee: validCoins,
RecvFee: validCoins,
AckFee: validCoins2,
TimeoutFee: validCoins3,
},
Expand All @@ -754,7 +754,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() {

// default to success case
expectedBalance = originalBalance.
Add(identifiedFee.Fee.ReceiveFee[0]).
Add(identifiedFee.Fee.RecvFee[0]).
Add(identifiedFee.Fee.AckFee[0]).
Add(coin) // timeout refund from ics20 transfer

Expand Down
8 changes: 4 additions & 4 deletions modules/apps/29-fee/keeper/escrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee *types.Identified
return sdkerrors.Wrap(types.ErrRefundAccNotFound, fmt.Sprintf("Account with address: %s not found", refundAcc))
}

coins := identifiedFee.Fee.ReceiveFee
coins := identifiedFee.Fee.RecvFee
coins = coins.Add(identifiedFee.Fee.AckFee...)
coins = coins.Add(identifiedFee.Fee.TimeoutFee...)

Expand All @@ -46,7 +46,7 @@ func (k Keeper) DistributePacketFees(ctx sdk.Context, refundAcc, forwardRelayer
// distribute fee for forward relaying
forward, err := sdk.AccAddressFromBech32(forwardRelayer)
if err == nil {
k.distributeFee(ctx, forward, feeInEscrow.Fee.ReceiveFee)
k.distributeFee(ctx, forward, feeInEscrow.Fee.RecvFee)
}

// distribute fee for reverse relaying
Expand Down Expand Up @@ -74,7 +74,7 @@ func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, refundAcc string,
}

// refund receive fee for unused forward relaying
k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.ReceiveFee)
k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.RecvFee)

// refund ack fee for unused reverse relaying
k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.AckFee)
Expand Down Expand Up @@ -117,7 +117,7 @@ func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) e
// refund all fees to refund address
// Use SendCoins rather than the module account send functions since refund address may be a user account or module address.
// if any `SendCoins` call returns an error, we return error and stop iteration
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.ReceiveFee)
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.RecvFee)
if err != nil {
refundErr = err
return true
Expand Down
20 changes: 10 additions & 10 deletions modules/apps/29-fee/keeper/escrow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() {

tc.malleate()
fee := types.Fee{
ReceiveFee: receiveFee,
RecvFee: receiveFee,
AckFee: ackFee,
TimeoutFee: timeoutFee,
}
Expand All @@ -87,7 +87,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() {
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.RecvFee.IsEqual(fee.RecvFee))
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)})
Expand Down Expand Up @@ -142,7 +142,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() {

packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, validSeq)
fee := types.Fee{
ReceiveFee: defaultReceiveFee,
RecvFee: defaultReceiveFee,
AckFee: defaultAckFee,
TimeoutFee: defaultTimeoutFee,
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() {
// check if the forward relayer is paid
forward, err := sdk.AccAddressFromBech32(forwardRelayer)
suite.Require().NoError(err)
hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forward, fee.ReceiveFee[0])
hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forward, fee.RecvFee[0])
suite.Require().True(hasBalance)

// check if the refund acc has been refunded the timeoutFee
Expand All @@ -185,7 +185,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() {
suite.Require().True(hasBalance)
} else {
// check the module acc wallet still has forward relaying balance
hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), fee.ReceiveFee[0])
hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), fee.RecvFee[0])
suite.Require().True(hasBalance)
}
})
Expand All @@ -206,7 +206,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() {
)

fee := types.Fee{
ReceiveFee: defaultReceiveFee,
RecvFee: defaultReceiveFee,
AckFee: defaultAckFee,
TimeoutFee: defaultTimeoutFee,
}
Expand Down Expand Up @@ -237,7 +237,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() {

// check if the refund acc has been refunded the recv & ack fees
expectedRefundAccBal := refundAccBal.Add(fee.AckFee[0])
expectedRefundAccBal = refundAccBal.Add(fee.ReceiveFee[0])
expectedRefundAccBal = refundAccBal.Add(fee.RecvFee[0])
hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal)
suite.Require().True(hasBalance)

Expand All @@ -256,7 +256,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() {
for i := 0; i < 5; i++ {
packetId := channeltypes.NewPacketId("channel-0", transfertypes.PortID, uint64(i))
fee := types.Fee{
ReceiveFee: defaultReceiveFee,
RecvFee: defaultReceiveFee,
AckFee: defaultAckFee,
TimeoutFee: defaultTimeoutFee,
}
Expand All @@ -270,7 +270,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() {
// send a packet over a different channel to ensure this fee is not refunded
packetId := channeltypes.NewPacketId("channel-1", transfertypes.PortID, 1)
fee := types.Fee{
ReceiveFee: defaultReceiveFee,
RecvFee: defaultReceiveFee,
AckFee: defaultAckFee,
TimeoutFee: defaultTimeoutFee,
}
Expand All @@ -286,7 +286,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() {

// add fee sent to channel-1 to after balance to recover original balance
afterBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), refundAcc)
suite.Require().Equal(prevBal, afterBal.Add(fee.ReceiveFee...).Add(fee.AckFee...).Add(fee.TimeoutFee...), "refund account not back to original balance after refunding all tokens")
suite.Require().Equal(prevBal, afterBal.Add(fee.RecvFee...).Add(fee.AckFee...).Add(fee.TimeoutFee...), "refund account not back to original balance after refunding all tokens")

// create escrow and then change module account balance to cause error on refund
packetId = channeltypes.NewPacketId("channel-0", transfertypes.PortID, uint64(6))
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/29-fee/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() {
validPacketId,
types.Fee{
AckFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))),
ReceiveFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))),
RecvFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))),
TimeoutFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))),
},
"", // leave empty here and then populate on each testcase since suite resets
Expand Down Expand Up @@ -94,7 +94,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() {

fee := types.Fee{
AckFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}},
ReceiveFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}},
RecvFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}},
TimeoutFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}},
}

Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestKeeperTestSuite(t *testing.T) {
}

func (suite *KeeperTestSuite) TestFeeInEscrow() {
fee := types.Fee{ReceiveFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee}
fee := types.Fee{RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee}

// set some fees
for i := 1; i < 6; i++ {
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/29-fee/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (suite *KeeperTestSuite) TestPayPacketFee() {
refundAcc := suite.chainA.SenderAccount.GetAddress()
channelID := suite.path.EndpointA.ChannelID
fee := types.Fee{
ReceiveFee: defaultReceiveFee,
RecvFee: defaultReceiveFee,
AckFee: defaultAckFee,
TimeoutFee: defaultTimeoutFee,
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() {
// build packetId
channelID := suite.path.EndpointA.ChannelID
fee := types.Fee{
ReceiveFee: defaultReceiveFee,
RecvFee: defaultReceiveFee,
AckFee: defaultAckFee,
TimeoutFee: defaultTimeoutFee,
}
Expand Down
86 changes: 43 additions & 43 deletions modules/apps/29-fee/types/fee.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 764df84

Please sign in to comment.