-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ecocredit): specify fee in CreateClass
#912
Conversation
Codecov Report
@@ Coverage Diff @@
## master #912 +/- ##
==========================================
+ Coverage 72.39% 72.59% +0.19%
==========================================
Files 194 185 -9
Lines 22880 22754 -126
==========================================
- Hits 16565 16518 -47
+ Misses 5072 5026 -46
+ Partials 1243 1210 -33
Flags with carried forward coverage won't be shown. Click here to find out more. |
// Charge the admin a fee to create the credit class | ||
err = k.chargeCreditClassFee(sdkCtx, adminAddress, params.CreditClassFee) | ||
err = k.chargeCreditClassFee(sdkCtx, adminAddress, sdk.Coins{sdk.Coin{Denom: req.Fee.Denom, Amount: feeAmt}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
force the fee to the amount specified by the params, rather than the amount passed, seemed like the proper thing to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. We don't want to charge more than the amount in the params but we also don't want to fail if more is provided by the user so we charge the amount specified in the params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, related to my earlier review. I think we should adjust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. A couple minor suggestions. Pre-approving.
// Charge the admin a fee to create the credit class | ||
err = k.chargeCreditClassFee(sdkCtx, adminAddress, params.CreditClassFee) | ||
err = k.chargeCreditClassFee(sdkCtx, adminAddress, sdk.Coins{sdk.Coin{Denom: req.Fee.Denom, Amount: feeAmt}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. We don't want to charge more than the amount in the params but we also don't want to fail if more is provided by the user so we charge the amount specified in the params.
Co-authored-by: Ryan Christoffersen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that we use use a bare denom instead of Fee/ Coin. And definitely let's remove the Fee type.
proto/regen/ecocredit/v1/tx.proto
Outdated
|
||
// fee specifies the fee to pay for the creation of the credit class. | ||
// acceptable fees for creating a credit class can be found in the governance parameters for the ecocredit module. | ||
Fee fee = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- why someone would pay a different fee than the required one? Maybe we can use only
string denom
here and charge the required fee. - If we really need to use both denom and amount, then let's use
Coin
type and remove Fee message. We can make it required (it's very small, so we in fact optimize the performance) to avoid null checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
i believe the intent was to ensure users aren't being charged fees that they are not explicitly setting. i had shared your concern while impl this PR, so might be nice to get more opinions in here. cc: @aaronc @clevinson @ryanchristo
-
i changed it to coin, but im not sure about the nullable thing. pulsar doesn't support that (not sure if thats planned either?). it might be best to leave out the option knowing we we will switch fully to pulsar eventually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why someone would pay a different fee than the required one? Maybe we can use only string denom here and charge the required fee.
The intention was to have the user explicitly set the fee so that they are aware of the charges incurred for creating a credit class. This currently happens in the background and in some cases the user might overlook the cost of creating a credit class, so having them explicitly set the fee prevents this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are automatically adjusting, then maybe let's update the docs if we want to keep this attribute.
proto/regen/ecocredit/v1/types.proto
Outdated
|
||
// amount is the amount of fees to pay in the specified denom. | ||
string amount = 2; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need that type. Let's use Coin
instead.
@@ -46,6 +46,17 @@ func (m *MsgCreateClass) ValidateBasic() error { | |||
} | |||
} | |||
|
|||
if m.Fee != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, if it's required, and a struct is small (even if we use Coin), then we can add option for nullable = false
.
Description
ref #728
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change