You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pubtypeDonationId=u64; // auto-incrementing ID for donations
214
216
215
217
pubstructDonation {
216
-
/// ID of the donor
218
+
/// ID of the donor
217
219
pubdonor_id:AccountId,
218
-
/// Amount donated
220
+
/// Amount donated
219
221
pubtotal_amount:u128,
220
222
/// Amount after all fees/expenses (incl. storage)
221
223
pubnet_amount:u128,
222
-
/// Optional message from the donor
224
+
/// Optional message from the donor
223
225
pubmessage:Option<String>,
224
226
/// Timestamp when the donation was made
225
227
pubdonated_at:TimestampMs,
@@ -241,13 +243,13 @@ pub struct Donation {
241
243
pubstructDonationExternal {
242
244
/// ID of the donation
243
245
pubid:DonationId,
244
-
/// ID of the donor
246
+
/// ID of the donor
245
247
pubdonor_id:AccountId,
246
-
/// Amount donated
248
+
/// Amount donated
247
249
pubtotal_amount:U128,
248
250
/// Amount after all fees/expenses (incl. storage)
249
251
pubnet_amount:U128,
250
-
/// Optional message from the donor
252
+
/// Optional message from the donor
251
253
pubmessage:Option<String>,
252
254
/// Timestamp when the donation was made
253
255
pubdonated_at:TimestampMs,
@@ -523,6 +525,7 @@ pub fn donate(
523
525
referrer_id:Option<AccountId>,
524
526
matching_pool:Option<bool>,
525
527
bypass_protocol_fee:Option<bool>, // Allows donor to bypass protocol fee if they wish. Defaults to "false".
528
+
custom_chef_fee_basis_points:Option<u32>, // Allows donor to set custom chef fee % if they wish. If provided value is greater than self.chef_fee_basis_points, the smaller value will be used.
let protocol_config_provider_result = call_result.unwrap();
@@ -474,6 +488,7 @@ impl Contract {
474
488
message,
475
489
referrer_id,
476
490
matching_pool,
491
+
custom_chef_fee_basis_points,
477
492
)
478
493
}
479
494
}
@@ -488,6 +503,7 @@ impl Contract {
488
503
message:Option<String>,
489
504
referrer_id:Option<AccountId>,
490
505
matching_pool:bool,
506
+
custom_chef_fee_basis_points:Option<u32>,
491
507
) -> DonationExternal{
492
508
let initial_storage_usage = env::storage_usage();
493
509
@@ -497,15 +513,14 @@ impl Contract {
497
513
deposit, protocol_fee,
498
514
));
499
515
500
-
// subtract chef fee
501
-
// TODO: consider adding to Donation struct
516
+
// subtract chef fee, unless bypassed
502
517
letmut chef_fee:Option<U128> = None;
503
518
letmut chef_id:Option<AccountId> = None;
504
519
ifletSome(chef) = self.chef.get(){
505
-
// chef fee only applies to public round donations
506
-
if!matching_pool{
520
+
let chef_fee_basis_points = std::cmp::min(custom_chef_fee_basis_points.unwrap_or(self.chef_fee_basis_points),self.chef_fee_basis_points);// can't provide a chef fee basis points greater than the contract's
0 commit comments