diff --git a/api/regen/ecocredit/marketplace/v1/tx.pulsar.go b/api/regen/ecocredit/marketplace/v1/tx.pulsar.go index ef081c6d13..3dfb4393d6 100644 --- a/api/regen/ecocredit/marketplace/v1/tx.pulsar.go +++ b/api/regen/ecocredit/marketplace/v1/tx.pulsar.go @@ -9344,8 +9344,6 @@ type MsgBuyDirect_Order struct { RetirementReason string `protobuf:"bytes,7,opt,name=retirement_reason,json=retirementReason,proto3" json:"retirement_reason,omitempty"` // max_fee_amount is the maximum amount of buyer side fees being paid to the marketplace. // If the marketplace fees end up being greater than this amount, the transaction will fail. - // If this field is left empty, the marketplace fees will be calculated based on the bid price - // and quantity and automatically deducted from the buyer's account. // Fees are always paid in the same denomination as the bid price. // // Since Revision 3 diff --git a/proto/regen/ecocredit/marketplace/v1/tx.proto b/proto/regen/ecocredit/marketplace/v1/tx.proto index d1f8bc721a..cb5cfcdfb3 100644 --- a/proto/regen/ecocredit/marketplace/v1/tx.proto +++ b/proto/regen/ecocredit/marketplace/v1/tx.proto @@ -184,8 +184,6 @@ message MsgBuyDirect { // max_fee_amount is the maximum amount of buyer side fees being paid to the marketplace. // If the marketplace fees end up being greater than this amount, the transaction will fail. - // If this field is left empty, the marketplace fees will be calculated based on the bid price - // and quantity and automatically deducted from the buyer's account. // Fees are always paid in the same denomination as the bid price. // // Since Revision 3 diff --git a/x/ecocredit/marketplace/keeper/features/msg_buy_direct.feature b/x/ecocredit/marketplace/keeper/features/msg_buy_direct.feature index bacfcd50a3..ae755f06e1 100644 --- a/x/ecocredit/marketplace/keeper/features/msg_buy_direct.feature +++ b/x/ecocredit/marketplace/keeper/features/msg_buy_direct.feature @@ -409,6 +409,7 @@ Feature: Msg/BuyDirect * bob has bank balance "110foo" * alice has bank balance "0foo" * buyer fees are 0.1 and seller fees are 0.05 + * bob sets a max fee of "10foo" When bob attempts to buy credits with quantity "10" and bid price "10foo" Then expect no error * expect alice bank balance "95foo" @@ -438,6 +439,7 @@ Feature: Msg/BuyDirect * bob has bank balance "240uregen" * alice has bank balance "0regen" * buyer fees are 0.2 and seller fees are 0.1 + * bob sets a max fee of "40uregen" When bob attempts to buy credits with quantity "10" and bid price "20uregen" Then expect no error * expect alice bank balance "180uregen" diff --git a/x/ecocredit/marketplace/keeper/msg_buy_direct.go b/x/ecocredit/marketplace/keeper/msg_buy_direct.go index 7be39f457d..5ba4b1d3e8 100644 --- a/x/ecocredit/marketplace/keeper/msg_buy_direct.go +++ b/x/ecocredit/marketplace/keeper/msg_buy_direct.go @@ -110,14 +110,16 @@ func (k Keeper) BuyDirect(ctx context.Context, req *types.MsgBuyDirect) (*types. totalCost := sdk.Coin{Amount: total.SdkIntTrim(), Denom: market.BankDenom} // check max fee - if maxFee := order.MaxFeeAmount; maxFee != nil { - buyerFeeCoin := sdk.Coin{Amount: buyerFee.SdkIntTrim(), Denom: market.BankDenom} - if maxFee.IsLT(buyerFeeCoin) { - return nil, sdkerrors.ErrInvalidRequest.Wrapf( - "%s: max fee: %s, required fee: %s", - orderIndex, maxFee, buyerFeeCoin, - ) - } + maxFee := order.MaxFeeAmount + if maxFee == nil { + maxFee = &sdk.Coin{Amount: sdk.NewInt(0), Denom: market.BankDenom} + } + buyerFeeCoin := sdk.Coin{Amount: buyerFee.SdkIntTrim(), Denom: market.BankDenom} + if maxFee.IsLT(buyerFeeCoin) { + return nil, sdkerrors.ErrInvalidRequest.Wrapf( + "%s: max fee: %s, required fee: %s", + orderIndex, maxFee, buyerFeeCoin, + ) } // check address has the total cost diff --git a/x/ecocredit/marketplace/types/v1/tx.pb.go b/x/ecocredit/marketplace/types/v1/tx.pb.go index 50e94b6b53..56f768dbe7 100644 --- a/x/ecocredit/marketplace/types/v1/tx.pb.go +++ b/x/ecocredit/marketplace/types/v1/tx.pb.go @@ -576,8 +576,6 @@ type MsgBuyDirect_Order struct { RetirementReason string `protobuf:"bytes,7,opt,name=retirement_reason,json=retirementReason,proto3" json:"retirement_reason,omitempty"` // max_fee_amount is the maximum amount of buyer side fees being paid to the marketplace. // If the marketplace fees end up being greater than this amount, the transaction will fail. - // If this field is left empty, the marketplace fees will be calculated based on the bid price - // and quantity and automatically deducted from the buyer's account. // Fees are always paid in the same denomination as the bid price. // // Since Revision 3