@@ -20,11 +20,11 @@ use crate::{
20
20
21
21
use self :: application:: file:: {
22
22
AllocationRequest , AllocationRequestType , AppState , ApplicationFile , NotaryInput ,
23
- ValidNotaryList , ValidGovTeamList ,
23
+ ValidVerifierList ,
24
24
} ;
25
25
use rayon:: prelude:: * ;
26
26
use crate :: core:: application:: file:: Allocation ;
27
-
27
+ use fplus_database :: database ;
28
28
pub mod application;
29
29
30
30
#[ derive( Deserialize ) ]
@@ -518,43 +518,21 @@ impl LDNApplication {
518
518
}
519
519
}
520
520
521
- pub async fn fetch_notaries ( ) -> Result < ValidNotaryList , LDNError > {
522
- let gh = GithubWrapper :: new ( ) ;
523
- let notaries = gh
524
- . get_file ( "data/notaries.json" , "main" )
525
- . await
526
- . map_err ( |e| LDNError :: Load ( format ! ( "Failed to retrieve notaries /// {}" , e) ) ) ?;
527
-
528
- let notaries = & notaries. items [ 0 ]
529
- . content
530
- . clone ( )
531
- . and_then ( |f| base64:: decode_notary ( & f. replace ( "\n " , "" ) ) )
532
- . and_then ( |f| Some ( f) ) ;
533
- if let Some ( notaries) = notaries {
534
- return Ok ( notaries. clone ( ) ) ;
535
- } else {
536
- return Err ( LDNError :: Load ( format ! ( "Failed to retrieve notaries ///" ) ) ) ;
521
+ pub async fn fetch_verifiers ( ) -> Result < ValidVerifierList , LDNError > {
522
+ let allocators = database:: get_allocators ( ) . await . map_err ( |e| LDNError :: Load ( format ! ( "Failed to retrieve allocators /// {}" , e) ) ) ?;
523
+
524
+ let mut gov_team_handles = Vec :: new ( ) ;
525
+ for allocator in allocators {
526
+ if let Some ( handles) = allocator. verifiers_gh_handles {
527
+ gov_team_handles. extend ( handles. split ( ',' ) . map ( String :: from) ) ;
528
+ }
537
529
}
538
- }
539
-
540
- pub async fn fetch_gov ( ) -> Result < ValidGovTeamList , LDNError > {
541
- let gh = GithubWrapper :: new ( ) ;
542
- let gov_team = gh
543
- . get_file ( "data/govteam.json" , "main" )
544
- . await
545
- . map_err ( |e| LDNError :: Load ( format ! ( "Failed to retrieve gov team /// {}" , e) ) ) ?;
546
-
547
- let gov_team = & gov_team. items [ 0 ]
548
- . content
549
- . clone ( )
550
- . and_then ( |f| base64:: decode_gov_team ( & f. replace ( "\n " , "" ) ) )
551
- . and_then ( |f| Some ( f) ) ;
552
-
553
- if let Some ( gov_team) = gov_team {
554
- return Ok ( gov_team. clone ( ) ) ;
555
- } else {
556
- return Err ( LDNError :: Load ( format ! ( "Failed to retrieve gov team ///" ) ) ) ;
530
+
531
+ if gov_team_handles. is_empty ( ) {
532
+ return Err ( LDNError :: Load ( "No governance team found" . into ( ) ) ) ;
557
533
}
534
+
535
+ Ok ( ValidVerifierList { gov_team : gov_team_handles } )
558
536
}
559
537
560
538
async fn single_merged ( application_id : String ) -> Result < ( Content , ApplicationFile ) , LDNError > {
@@ -802,7 +780,7 @@ impl LDNApplication {
802
780
let validated_at = application_file. lifecycle . validated_at . clone ( ) ;
803
781
let app_state = application_file. lifecycle . get_state ( ) ;
804
782
let active_request_id = application_file. lifecycle . active_request . clone ( ) ;
805
- let valid_gov_team = Self :: fetch_gov ( ) . await ?;
783
+ let valid_gov_team = Self :: fetch_verifiers ( ) . await ?;
806
784
let bot_user = get_env_var_or_default ( "BOT_USER" , "filplus-github-bot-read-write[bot]" ) ;
807
785
808
786
let res: bool = match app_state {
@@ -970,8 +948,8 @@ impl LDNApplication {
970
948
}
971
949
let signer = signers. 0 . get ( 1 ) . unwrap ( ) ;
972
950
let signer_address = signer. signing_address . clone ( ) ;
973
- let valid_notaries = Self :: fetch_notaries ( ) . await ?;
974
- if valid_notaries . is_valid ( & signer_address) {
951
+ let valid_verifiers = Self :: fetch_verifiers ( ) . await ?;
952
+ if valid_verifiers . is_valid ( & signer_address) {
975
953
log:: info!( "- Validated!" ) ;
976
954
Self :: issue_datacap_request_signature ( application_file. clone ( ) , "approved" . to_string ( ) ) . await ?;
977
955
Self :: update_issue_labels ( application_file. issue_number . clone ( ) , & [ AppState :: Granted . as_str ( ) ] ) . await ?;
@@ -1021,8 +999,8 @@ impl LDNApplication {
1021
999
}
1022
1000
let signer = signers. 0 . get ( 0 ) . unwrap ( ) ;
1023
1001
let signer_address = signer. signing_address . clone ( ) ;
1024
- let valid_notaries = Self :: fetch_notaries ( ) . await ?;
1025
- if valid_notaries . is_valid ( & signer_address) {
1002
+ let valid_verifiers = Self :: fetch_verifiers ( ) . await ?;
1003
+ if valid_verifiers . is_valid ( & signer_address) {
1026
1004
Self :: issue_start_sign_dc ( application_file. issue_number . clone ( ) ) . await ?;
1027
1005
Self :: issue_datacap_request_signature ( application_file. clone ( ) , "proposed" . to_string ( ) ) . await ?;
1028
1006
Self :: update_issue_labels ( application_file. issue_number . clone ( ) , & [ AppState :: StartSignDatacap . as_str ( ) ] ) . await ?;
@@ -1298,25 +1276,6 @@ Your Datacap Allocation Request has been {} by the Notary
1298
1276
Ok ( true )
1299
1277
}
1300
1278
1301
- pub async fn fetch_gov_and_notary_gh_users ( ) -> Result < ( Vec < String > , Vec < String > ) , LDNError > {
1302
- let gov_team_list = Self :: fetch_gov ( )
1303
- . await
1304
- . map_err ( |e| LDNError :: Load ( format ! ( "Failed to retrieve gov team: {}" , e) ) ) ?;
1305
-
1306
- let notary_list = Self :: fetch_notaries ( )
1307
- . await
1308
- . map_err ( |e| LDNError :: Load ( format ! ( "Failed to retrieve notaries: {}" , e) ) ) ?;
1309
-
1310
- let notary_gh_names = notary_list
1311
- . notaries
1312
- . into_iter ( )
1313
- . flat_map ( |notary| notary. github_user )
1314
- . filter ( |username| !username. is_empty ( ) )
1315
- . collect ( ) ;
1316
-
1317
- Ok ( ( gov_team_list. gov_team , notary_gh_names) )
1318
- }
1319
-
1320
1279
async fn add_error_label ( issue_number : String , comment : String ) -> Result < ( ) , LDNError > {
1321
1280
let gh = GithubWrapper :: new ( ) ;
1322
1281
let num: u64 = issue_number. parse ( ) . expect ( "Not a valid integer" ) ;
0 commit comments