Skip to content

Commit

Permalink
add funding_account to job
Browse files Browse the repository at this point in the history
  • Loading branch information
simke9445 committed Nov 20, 2023
1 parent 99f9f5d commit ca91a3f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions contracts/warp-controller/src/execute/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub fn create_job(
assets_to_withdraw: data.assets_to_withdraw.unwrap_or(vec![]),
duration_days: data.duration_days,
created_at_time: Uint64::from(env.block.time.seconds()),
funding_account: data.funding_account,
},
)?;

Expand Down
4 changes: 4 additions & 0 deletions contracts/warp-controller/src/migrate/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ pub fn migrate_pending_jobs(
assets_to_withdraw: old_job.assets_to_withdraw,
duration_days: Uint64::from(30u64),
created_at_time: old_job.last_update_time,
// TODO: update to old_job.funding_account
funding_account: None,
},
)?;
}
Expand Down Expand Up @@ -169,6 +171,8 @@ pub fn migrate_finished_jobs(
assets_to_withdraw: old_job.assets_to_withdraw,
duration_days: Uint64::from(30u64),
created_at_time: old_job.last_update_time,
// TODO: update to old_job.funding_account
funding_account: None,
},
)?;
}
Expand Down
1 change: 1 addition & 0 deletions contracts/warp-controller/src/reply/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ pub fn execute_job(
assets_to_withdraw: finished_job.assets_to_withdraw.clone(),
duration_days: finished_job.duration_days,
created_at_time: Uint64::from(env.block.time.seconds()),
funding_account: finished_job.funding_account,
},
)?;

Expand Down
3 changes: 3 additions & 0 deletions contracts/warp-controller/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl JobQueue {
assets_to_withdraw: job.assets_to_withdraw,
duration_days: job.duration_days,
created_at_time: Uint64::from(env.block.time.seconds()),
funding_account: job.funding_account,
}),
})
}
Expand All @@ -154,6 +155,7 @@ impl JobQueue {
assets_to_withdraw: job.assets_to_withdraw,
duration_days: job.duration_days,
created_at_time: job.created_at_time,
funding_account: job.funding_account,
}),
})
}
Expand Down Expand Up @@ -188,6 +190,7 @@ impl JobQueue {
assets_to_withdraw: job.assets_to_withdraw,
duration_days: job.duration_days,
created_at_time: job.created_at_time,
funding_account: job.funding_account,
};

FINISHED_JOBS().update(deps.storage, job_id, |j| match j {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use std::env::current_dir;
use std::fs::create_dir_all;

use controller::{
account::{FundingAccountResponse, FundingAccountsResponse},
job::{JobResponse, JobsResponse},
};
use cosmwasm_schema::{export_schema, remove_schemas, schema_for};
use funding_account::{Config, ExecuteMsg, InstantiateMsg};

Expand All @@ -17,8 +13,4 @@ fn main() {
export_schema(&schema_for!(InstantiateMsg), &out_dir);
export_schema(&schema_for!(ExecuteMsg), &out_dir);
export_schema(&schema_for!(Config), &out_dir);
export_schema(&schema_for!(JobResponse), &out_dir);
export_schema(&schema_for!(JobsResponse), &out_dir);
export_schema(&schema_for!(FundingAccountResponse), &out_dir);
export_schema(&schema_for!(FundingAccountsResponse), &out_dir);
}
2 changes: 2 additions & 0 deletions packages/controller/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Job {
// As job creator can have infinite job accounts, each job account can only be used by up to 1 active job
// So each job's fund is isolated
pub account: Addr,
pub funding_account: Option<Addr>,
pub last_update_time: Uint64,
pub name: String,
pub description: String,
Expand Down Expand Up @@ -67,6 +68,7 @@ pub struct CreateJobMsg {
pub assets_to_withdraw: Option<Vec<AssetInfo>>,
pub account_msgs: Option<Vec<WarpMsg>>,
pub cw_funds: Option<Vec<CwFund>>,
pub funding_account: Option<Addr>,
}

#[cw_serde]
Expand Down

0 comments on commit ca91a3f

Please sign in to comment.