1+ use catalyst_toolbox:: rewards:: community_advisors:: {
2+ calculate_ca_rewards, ApprovedProposals , CommunityAdvisor , FundSetting , Funds ,
3+ ProposalRewardSlots , ProposalsReviews , Rewards , Seed ,
4+ } ;
5+ use catalyst_toolbox:: utils;
16use chain_crypto:: digest:: DigestOf ;
2- use color_eyre:: eyre:: bail;
7+ use color_eyre:: eyre:: { bail, eyre } ;
38use color_eyre:: Report ;
9+ use rust_decimal:: prelude:: ToPrimitive ;
410use serde:: Serialize ;
511use std:: collections:: { BTreeMap , BTreeSet } ;
612use std:: path:: { Path , PathBuf } ;
713use std:: str:: FromStr ;
814
9- use catalyst_toolbox:: rewards:: community_advisors:: {
10- calculate_ca_rewards, ApprovedProposals , CommunityAdvisor , FundSetting , Funds ,
11- ProposalRewardSlots , ProposalsReviews , Rewards , Seed ,
12- } ;
13- use catalyst_toolbox:: utils;
14-
1515use catalyst_toolbox:: community_advisors:: models:: {
1616 AdvisorReviewRow , ApprovedProposalRow , ProposalStatus ,
1717} ;
@@ -26,9 +26,9 @@ struct FundSettingOpt {
2626 /// % ratio, range in [0, 100]
2727 #[ structopt( long = "bonus-ratio" ) ]
2828 bonus_ratio : u8 ,
29- /// total amount of funds to be rewarded
29+ /// total amount of funds to be rewarded (integer value)
3030 #[ structopt( long = "funds" ) ]
31- total : Funds ,
31+ total : u64 ,
3232}
3333
3434#[ derive( StructOpt ) ]
@@ -171,7 +171,7 @@ impl From<FundSettingOpt> for FundSetting {
171171 Self {
172172 proposal_ratio : settings. proposal_ratio ,
173173 bonus_ratio : settings. bonus_ratio ,
174- total : settings. total ,
174+ total : Rewards :: from ( settings. total ) ,
175175 }
176176 }
177177}
@@ -187,34 +187,42 @@ impl From<ProposalRewardsSlotsOpt> for ProposalRewardSlots {
187187 }
188188}
189189
190- fn rewards_to_csv_data ( rewards : & BTreeMap < CommunityAdvisor , Rewards > ) -> Vec < impl Serialize > {
190+ fn rewards_to_csv_data (
191+ rewards : & BTreeMap < CommunityAdvisor , Rewards > ,
192+ ) -> Result < Vec < impl Serialize > , Report > {
191193 #[ derive( Serialize ) ]
192194 struct Entry {
193195 id : String ,
194- rewards : Rewards ,
196+ rewards : u64 ,
195197 }
196198
197199 rewards
198200 . iter ( )
199- . map ( |( id, rewards) | Entry {
200- id : id. clone ( ) ,
201- rewards : * rewards,
201+ . map ( |( id, rewards) | {
202+ Ok ( Entry {
203+ id : id. clone ( ) ,
204+ rewards : rewards. to_u64 ( ) . ok_or_else ( || eyre ! ( "Rewards overflow" ) ) ?,
205+ } )
202206 } )
203207 . collect ( )
204208}
205209
206- fn bonus_to_csv_data ( rewards : BTreeMap < String , Rewards > ) -> Vec < impl Serialize > {
210+ fn bonus_to_csv_data ( rewards : BTreeMap < String , Rewards > ) -> Result < Vec < impl Serialize > , Report > {
207211 #[ derive( Serialize ) ]
208212 struct Entry {
209213 proposal_id : String ,
210- bonus_rewards : Rewards ,
214+ bonus_rewards : u64 ,
211215 }
212216
213217 rewards
214218 . into_iter ( )
215- . map ( |( proposal_id, bonus_rewards) | Entry {
216- proposal_id,
217- bonus_rewards,
219+ . map ( |( proposal_id, bonus_rewards) | {
220+ Ok ( Entry {
221+ proposal_id,
222+ bonus_rewards : bonus_rewards
223+ . to_u64 ( )
224+ . ok_or_else ( || eyre ! ( "Rewards overflow" ) ) ?,
225+ } )
218226 } )
219227 . collect ( )
220228}
0 commit comments