@@ -131,13 +131,11 @@ pub struct AllocatorUpdateInfo {
131
131
pub multisig_threshold : Option < i32 > ,
132
132
}
133
133
134
-
135
134
#[ derive( Deserialize ) ]
136
135
pub struct InstallationIdUpdateInfo {
137
136
pub installation_id : i64 ,
138
137
}
139
138
140
-
141
139
#[ derive( Deserialize ) ]
142
140
pub struct GithubQueryParams {
143
141
pub owner : String ,
@@ -694,10 +692,11 @@ impl LDNApplication {
694
692
repo : String ,
695
693
) -> Result < ApplicationFile , LDNError > {
696
694
// Get multisig threshold from blockchain
697
- let blockchain_threshold = match get_multisig_threshold_for_actor ( & signer. signing_address ) . await {
698
- Ok ( threshold) => Some ( threshold) ,
699
- Err ( _) => None ,
700
- } ;
695
+ let blockchain_threshold =
696
+ match get_multisig_threshold_for_actor ( & signer. signing_address ) . await {
697
+ Ok ( threshold) => Some ( threshold) ,
698
+ Err ( _) => None ,
699
+ } ;
701
700
// TODO: Convert DB errors to LDN Error
702
701
// Get multisig threshold from the database
703
702
let db_allocator = match get_allocator ( & owner, & repo) . await {
@@ -810,10 +809,11 @@ impl LDNApplication {
810
809
repo : String ,
811
810
) -> Result < ApplicationFile , LDNError > {
812
811
// Get multisig threshold from blockchain
813
- let blockchain_threshold = match get_multisig_threshold_for_actor ( & signer. signing_address ) . await {
814
- Ok ( threshold) => Some ( threshold) ,
815
- Err ( _) => None ,
816
- } ;
812
+ let blockchain_threshold =
813
+ match get_multisig_threshold_for_actor ( & signer. signing_address ) . await {
814
+ Ok ( threshold) => Some ( threshold) ,
815
+ Err ( _) => None ,
816
+ } ;
817
817
818
818
// Get multisig threshold from the database
819
819
let db_allocator = match get_allocator ( & owner, & repo) . await {
@@ -1653,7 +1653,32 @@ impl LDNApplication {
1653
1653
}
1654
1654
} ;
1655
1655
let signers: application:: file:: Verifiers = active_request. signers . clone ( ) ;
1656
- let signer = signers. 0 . get ( 1 ) . unwrap ( ) ;
1656
+ let num_signers = signers. 0 . len ( ) ;
1657
+ // Default to first signer for validation
1658
+ let mut signer_index = 0 ;
1659
+
1660
+ // If there are multiple signers, fetch the multisig threshold to determine which signer to validate
1661
+ if num_signers > 1 {
1662
+ let blockchain_threshold =
1663
+ get_multisig_threshold_for_actor ( & signers. 0 [ 0 ] . signing_address ) . await ;
1664
+ let multisig_threshold = match blockchain_threshold {
1665
+ Ok ( threshold) => threshold as usize ,
1666
+ Err ( _) => {
1667
+ let db_allocator =
1668
+ get_allocator ( & owner, & repo) . await . map_err ( |e| {
1669
+ LDNError :: Load ( format ! ( "Database error: {}" , e) )
1670
+ } ) ?;
1671
+ db_allocator
1672
+ . as_ref ( )
1673
+ . and_then ( |allocator| allocator. multisig_threshold )
1674
+ . unwrap_or ( 2 ) as usize
1675
+ }
1676
+ } ;
1677
+ // Adjust signer index based on multisig threshold
1678
+ signer_index = if multisig_threshold <= 1 { 0 } else { 1 } ;
1679
+ }
1680
+
1681
+ let signer = signers. 0 . get ( signer_index) . unwrap ( ) ;
1657
1682
1658
1683
// Try getting the multisig threshold from the blockchain
1659
1684
let blockchain_threshold =
@@ -1663,21 +1688,22 @@ impl LDNApplication {
1663
1688
let multisig_threshold = match blockchain_threshold {
1664
1689
Ok ( threshold) => threshold as usize ,
1665
1690
Err ( _) => {
1666
- let db_allocator = get_allocator ( & owner, & repo) . await
1667
- . map_err ( |e| LDNError :: Load ( format ! ( "Database error: {}" , e) ) ) ?;
1691
+ let db_allocator = get_allocator ( & owner, & repo)
1692
+ . await
1693
+ . map_err ( |e| LDNError :: Load ( format ! ( "Database error: {}" , e) ) ) ?;
1668
1694
db_allocator
1669
1695
. as_ref ( )
1670
1696
. and_then ( |allocator| allocator. multisig_threshold )
1671
1697
. unwrap_or ( 2 ) as usize
1672
1698
}
1673
1699
} ;
1674
-
1700
+
1675
1701
// Check if the number of signers meets or exceeds the multisig threshold
1676
1702
if signers. 0 . len ( ) < multisig_threshold {
1677
1703
log:: warn!( "Not enough signers for approval" ) ;
1678
1704
return Ok ( false ) ;
1679
1705
}
1680
- let signer_index = if multisig_threshold <= 1 { 0 } else { 1 } ;
1706
+ let signer_index = if multisig_threshold <= 1 { 0 } else { 1 } ;
1681
1707
1682
1708
let signer = signers. 0 . get ( signer_index) . unwrap ( ) ;
1683
1709
let signer_gh_handle = signer. github_username . clone ( ) ;
@@ -1795,17 +1821,16 @@ impl LDNApplication {
1795
1821
}
1796
1822
}
1797
1823
1798
- pub async fn delete_merged_branch ( owner : String , repo : String , branch_name : String ) -> Result < bool , LDNError > {
1824
+ pub async fn delete_merged_branch (
1825
+ owner : String ,
1826
+ repo : String ,
1827
+ branch_name : String ,
1828
+ ) -> Result < bool , LDNError > {
1799
1829
let gh = github_async_new ( owner, repo) . await ;
1800
1830
let request = gh. build_remove_ref_request ( branch_name. clone ( ) ) . unwrap ( ) ;
1801
1831
1802
- gh. remove_branch ( request)
1803
- . await
1804
- . map_err ( |e| {
1805
- return LDNError :: New ( format ! (
1806
- "Error deleting branch {} /// {}" ,
1807
- branch_name, e
1808
- ) ) ;
1832
+ gh. remove_branch ( request) . await . map_err ( |e| {
1833
+ return LDNError :: New ( format ! ( "Error deleting branch {} /// {}" , branch_name, e) ) ;
1809
1834
} ) ?;
1810
1835
1811
1836
Ok ( true )
0 commit comments