Skip to content

Commit d1a5aeb

Browse files
committed
feat: adjusted allocator model for new allocator json file changes
1 parent 1be5e67 commit d1a5aeb

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,24 @@ pub async fn create_from_json(file: web::Json<ChangedAllocator>) -> actix_web::R
3737

3838
match process_allocator_file(file_name).await {
3939
Ok(model) => {
40-
if model.multisig_address.is_empty() {
40+
if model.pathway_addresses.msig.is_empty() {
4141
return Ok(HttpResponse::BadRequest().body("Missing or invalid multisig_address"));
4242
}
4343
let verifiers_gh_handles = if model.application.verifiers_gh_handles.is_empty() {
4444
None
4545
} else {
4646
Some(model.application.verifiers_gh_handles.join(", ")) // Join verifiers in a string if exists
4747
};
48-
48+
49+
let owner_repo_parts: Vec<&str> = model.application.allocation_bookkeeping.split('/').collect();
50+
let owner = parts[3];
51+
let repo = parts[4];
52+
4953
let allocator_model = match allocators_db::create_or_update_allocator(
50-
model.owner.clone(),
51-
model.repo.clone(),
54+
owner.to_string(),
55+
owner.to_string(),
5256
None,
53-
Some(model.multisig_address),
57+
Some(model.pathway_addresses.msig),
5458
verifiers_gh_handles,
5559
model.multisig_threshold
5660
).await {

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@ use serde::{Serialize, Deserialize};
22

33
#[derive(Serialize, Deserialize, Debug)]
44
pub struct AllocatorModel {
5-
#[serde(rename = "slug")]
6-
pub repo: String,
7-
#[serde(rename = "organization")]
8-
pub owner: String,
9-
#[serde(rename = "address")]
10-
pub multisig_address: String,
115
pub application: Application,
126
#[serde(rename = "multisig_threshold")]
137
pub multisig_threshold: Option<i32>,
8+
pub pathway_addresses: AllocatorModelPathwayAddresses
9+
}
10+
11+
#[derive(Serialize, Deserialize, Debug)]
12+
pub struct AllocatorModelPathwayAddresses {
13+
pub msig: String,
1414
}
1515

1616
#[derive(Serialize, Deserialize, Debug)]
1717
pub struct Application {
1818
#[serde(rename = "github_handles")]
19-
pub verifiers_gh_handles: Vec<String>
19+
pub verifiers_gh_handles: Vec<String>,
20+
pub allocation_bookkeeping: String,
2021
}
2122

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

0 commit comments

Comments
 (0)