Skip to content

Commit 2d6fe1b

Browse files
committed
Multisig support
Database added multisig threshold Multisig threshold using in propose and approve
1 parent c9196d5 commit 2d6fe1b

File tree

6 files changed

+395
-212
lines changed

6 files changed

+395
-212
lines changed

fplus-database/src/database/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ pub async fn create_or_update_allocator(
9292
installation_id: Option<i64>,
9393
multisig_address: Option<String>,
9494
verifiers_gh_handles: Option<String>,
95+
multisig_threshold: Option<i32>
9596
) -> Result<AllocatorModel, sea_orm::DbErr> {
9697

9798
let existing_allocator = get_allocator(&owner, &repo).await?;
@@ -113,6 +114,7 @@ pub async fn create_or_update_allocator(
113114
installation_id: Set(installation_id),
114115
multisig_address: Set(multisig_address),
115116
verifiers_gh_handles: Set(verifiers_gh_handles),
117+
multisig_threshold: Set(multisig_threshold),
116118
..Default::default()
117119
};
118120

fplus-database/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ mod tests {
102102
let installation_id = Some(1234);
103103
let multisig_address = Some("0x1234567890".to_string());
104104
let verifiers_gh_handles = Some("test_verifier_1, test_verifier_2".to_string());
105+
let multisig_threshold = Some(2);
105106

106107
let result = database::create_or_update_allocator(
107108
owner,
108109
repo,
109110
installation_id,
110111
multisig_address,
111112
verifiers_gh_handles,
113+
multisig_threshold
112114
).await;
113115
assert!(result.is_ok());
114116
}
@@ -149,13 +151,15 @@ mod tests {
149151
let multisig_address = Some
150152
("0x1234567890".to_string());
151153
let verifiers_gh_handles = Some("test_verifier_1, test_verifier_2".to_string());
154+
let multisig_threshold = Some(2);
152155

153156
let result = database::create_or_update_allocator(
154157
owner.clone(),
155158
repo.clone(),
156159
installation_id,
157160
multisig_address,
158161
verifiers_gh_handles,
162+
multisig_threshold
159163
).await;
160164
assert!(result.is_ok());
161165
}
@@ -216,13 +220,15 @@ mod tests {
216220
let installation_id = Some(1234);
217221
let multisig_address = Some("0x1234567890".to_string());
218222
let verifiers_gh_handles = Some("test_verifier_1, test_verifier_2".to_string());
223+
let multisig_threshold = Some(2);
219224

220225
let result = database::create_or_update_allocator(
221226
owner.clone(),
222227
repo.clone(),
223228
installation_id,
224229
multisig_address,
225230
verifiers_gh_handles,
231+
multisig_threshold
226232
).await;
227233

228234
assert!(result.is_ok());

fplus-database/src/models/allocators.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct Model {
1414
pub multisig_address: Option<String>,
1515
#[sea_orm(column_type = "Text", nullable)]
1616
pub verifiers_gh_handles: Option<String>,
17+
pub multisig_threshold: Option<i32>,
1718
}
1819

1920
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

fplus-http-server/src/router/allocator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub async fn create_from_json(file: web::Json<ChangedAllocator>) -> actix_web::R
5050
Some(model.installation_id as i64),
5151
Some(model.multisig_address),
5252
verifiers_gh_handles,
53+
model.multisig_threshold
5354
).await {
5455
Ok(allocator_model) => Ok(HttpResponse::Ok().json(allocator_model)),
5556
Err(e) => Ok(HttpResponse::BadRequest().body(e.to_string())),

fplus-lib/src/core/allocator/file.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub struct AllocatorModel {
1111
pub application: Application,
1212
#[serde(rename = "common_ui_install_id")]
1313
pub installation_id: u64,
14+
#[serde(rename = "multisig_threshold")]
15+
pub multisig_threshold: Option<i32>,
1416
}
1517

1618
#[derive(Serialize, Deserialize, Debug)]

0 commit comments

Comments
 (0)