Skip to content

Commit

Permalink
Merge branch 'main' into sean/issue#868-new-packet-id
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Apr 11, 2022
2 parents b715686 + c7209a5 commit 1b73df5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
15 changes: 9 additions & 6 deletions modules/apps/29-fee/keeper/escrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, packetID channeltypes.PacketId,
// users may not escrow fees on this channel. Must send packets without a fee message
return sdkerrors.Wrap(types.ErrFeeNotEnabled, "cannot escrow fee for packet")
}
// check if the refund account exists
refundAcc, err := sdk.AccAddressFromBech32(packetFee.RefundAddress)

// check if the refund address is valid
refundAddr, err := sdk.AccAddressFromBech32(packetFee.RefundAddress)
if err != nil {
return err
}

hasRefundAcc := k.authKeeper.GetAccount(ctx, refundAcc)
if hasRefundAcc == nil {
return sdkerrors.Wrapf(types.ErrRefundAccNotFound, "account with address: %s not found", refundAcc)
refundAcc := k.authKeeper.GetAccount(ctx, refundAddr)
if refundAcc == nil {
return sdkerrors.Wrapf(types.ErrRefundAccNotFound, "account with address: %s not found", packetFee.RefundAddress)
}

coins := packetFee.Fee.Total()
if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, refundAcc, types.ModuleName, coins); err != nil {
if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, refundAddr, types.ModuleName, coins); err != nil {
return err
}

// multiple fees may be escrowed for a single packet, firstly create a slice containing the new fee
// retrieve any previous fees stored in escrow for the packet and append them to the list
fees := []types.PacketFee{packetFee}
if feesInEscrow, found := k.GetFeesInEscrow(ctx, packetID); found {
fees = append(fees, feesInEscrow.PacketFees...)
Expand Down
8 changes: 7 additions & 1 deletion modules/apps/29-fee/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
// RegisterInterfaces register the 29-fee module interfaces to protobuf
// Any.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgRegisterCounterpartyAddress{}, &MsgPayPacketFee{}, &MsgPayPacketFeeAsync{})
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgRegisterCounterpartyAddress{},
&MsgPayPacketFee{},
&MsgPayPacketFeeAsync{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

Expand Down

0 comments on commit 1b73df5

Please sign in to comment.