Skip to content

Commit

Permalink
remove legacy account support
Browse files Browse the repository at this point in the history
  • Loading branch information
simke9445 committed Dec 1, 2023
1 parent ad1e05f commit 2c3d37c
Show file tree
Hide file tree
Showing 34 changed files with 65 additions and 1,502 deletions.
39 changes: 0 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion contracts/warp-controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ cw-storage-plus = "0.16"
cw-utils = "0.16"
cw2 = "0.16"
cw20 = "0.16"
legacy-account = { path = "../../packages/legacy-account", default-features = false, version = "*" }
job-account = { path = "../../packages/job-account", default-features = false, version = "*" }
job-account-tracker = { path = "../../packages/job-account-tracker", default-features = false, version = "*" }
controller = { path = "../../packages/controller", default-features = false, version = "*" }
Expand Down
3 changes: 0 additions & 3 deletions contracts/warp-controller/examples/warp-controller-schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::env::current_dir;
use std::fs::create_dir_all;

use controller::{
account::{LegacyAccountResponse, LegacyAccountsResponse},
job::{JobResponse, JobsResponse},
QueryMsg, State, StateResponse, {Config, ConfigResponse, ExecuteMsg, InstantiateMsg},
};
Expand All @@ -23,6 +22,4 @@ fn main() {
export_schema(&schema_for!(StateResponse), &out_dir);
export_schema(&schema_for!(JobResponse), &out_dir);
export_schema(&schema_for!(JobsResponse), &out_dir);
export_schema(&schema_for!(LegacyAccountResponse), &out_dir);
export_schema(&schema_for!(LegacyAccountsResponse), &out_dir);
}
13 changes: 0 additions & 13 deletions contracts/warp-controller/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ pub fn execute(
nonpayable(&info).unwrap();
execute::controller::update_config(deps, env, info, data, config)
}
ExecuteMsg::MigrateLegacyAccounts(data) => {
nonpayable(&info).unwrap();
migrate::legacy_account::migrate_legacy_accounts(deps, info, data, config)
}
ExecuteMsg::MigrateFreeJobAccounts(data) => {
nonpayable(&info).unwrap();
migrate::job_account::migrate_free_job_accounts(deps.as_ref(), env, info, data, config)
Expand Down Expand Up @@ -165,15 +161,6 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::QueryJob(data) => to_binary(&query::job::query_job(deps, env, data)?),
QueryMsg::QueryJobs(data) => to_binary(&query::job::query_jobs(deps, env, data)?),

// For job account, please query it via the account tracker contract
QueryMsg::QueryLegacyAccount(data) => {
to_binary(&query::account::query_legacy_account(deps, env, data)?)
}
QueryMsg::QueryLegacyAccounts(data) => {
to_binary(&query::account::query_legacy_accounts(deps, env, data)?)
}

QueryMsg::QueryConfig(data) => {
to_binary(&query::controller::query_config(deps, env, data)?)
}
Expand Down
93 changes: 40 additions & 53 deletions contracts/warp-controller/src/execute/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ use cosmwasm_std::{
SubMsg, Uint128, Uint64, WasmMsg,
};

use crate::{
state::LEGACY_ACCOUNTS,
util::{
fee::deduct_from_native_funds,
legacy_account::is_legacy_account,
msg::{
build_account_withdraw_assets_msg, build_free_account_msg,
build_instantiate_warp_account_msg, build_taken_account_msg, build_transfer_cw20_msg,
build_transfer_cw721_msg, build_transfer_native_funds_msg,
},
use crate::util::{
fee::deduct_from_native_funds,
msg::{
build_account_withdraw_assets_msg, build_free_account_msg,
build_instantiate_warp_account_msg, build_taken_account_msg, build_transfer_cw20_msg,
build_transfer_cw721_msg, build_transfer_native_funds_msg,
},
};

Expand Down Expand Up @@ -358,7 +354,6 @@ pub fn delete_job(
fee_denom_paid_amount: Uint128,
) -> Result<Response, ContractError> {
let job = JobQueue::get(&deps, data.id.into())?;
let legacy_account = LEGACY_ACCOUNTS().may_load(deps.storage, job.owner.clone())?;
let job_account_addr = job.account.clone();

if job.status != JobStatus::Pending {
Expand Down Expand Up @@ -394,29 +389,27 @@ pub fn delete_job(
vec![Coin::new(fee.u128(), config.fee_denom.clone())],
));

if !is_legacy_account(legacy_account, job_account_addr.clone()) {
// Free account
msgs.push(build_free_account_msg(
// Free account
msgs.push(build_free_account_msg(
config.job_account_tracker_address.to_string(),
job.owner.to_string(),
job_account_addr.to_string(),
job.id,
));

if let Some(funding_account) = job.funding_account {
msgs.push(build_free_funding_account_msg(
config.job_account_tracker_address.to_string(),
job.owner.to_string(),
job_account_addr.to_string(),
funding_account.to_string(),
job.id,
));

if let Some(funding_account) = job.funding_account {
msgs.push(build_free_funding_account_msg(
config.job_account_tracker_address.to_string(),
job.owner.to_string(),
funding_account.to_string(),
job.id,
));

// withdraws all native funds from funding account
msgs.push(build_account_withdraw_assets_msg(
funding_account.to_string(),
vec![AssetInfo::Native(config.fee_denom)],
));
}
// withdraws all native funds from funding account
msgs.push(build_account_withdraw_assets_msg(
funding_account.to_string(),
vec![AssetInfo::Native(config.fee_denom)],
));
}

// Job owner withdraw all assets that are listed from warp account to itself
Expand Down Expand Up @@ -477,7 +470,6 @@ pub fn execute_job(
config: Config,
) -> Result<Response, ContractError> {
let job = JobQueue::get(&deps, data.id.into())?;
let legacy_account = LEGACY_ACCOUNTS().may_load(deps.storage, job.owner.clone())?;
let job_account_addr = job.account.clone();

if job.status != JobStatus::Pending {
Expand Down Expand Up @@ -548,23 +540,21 @@ pub fn execute_job(
vec![Coin::new(job.reward.u128(), config.fee_denom)],
));

if !is_legacy_account(legacy_account, job_account_addr.clone()) {
// Free account
msgs.push(build_free_account_msg(
// Free account
msgs.push(build_free_account_msg(
config.job_account_tracker_address.to_string(),
job.owner.to_string(),
job_account_addr.to_string(),
job.id,
));

if let Some(funding_account) = job.funding_account {
msgs.push(build_free_funding_account_msg(
config.job_account_tracker_address.to_string(),
job.owner.to_string(),
job_account_addr.to_string(),
funding_account.to_string(),
job.id,
));

if let Some(funding_account) = job.funding_account {
msgs.push(build_free_funding_account_msg(
config.job_account_tracker_address.to_string(),
job.owner.to_string(),
funding_account.to_string(),
job.id,
));
}
}

Ok(Response::new()
Expand All @@ -585,7 +575,6 @@ pub fn evict_job(
config: Config,
) -> Result<Response, ContractError> {
let job = JobQueue::get(&deps, data.id.into())?;
let legacy_account = LEGACY_ACCOUNTS().may_load(deps.storage, job.owner.clone())?;
let job_account_addr = job.account.clone();

if job.status != JobStatus::Pending {
Expand Down Expand Up @@ -618,15 +607,13 @@ pub fn evict_job(
)],
));

if !is_legacy_account(legacy_account, job_account_addr.clone()) {
// Free account
msgs.push(build_free_account_msg(
config.job_account_tracker_address.to_string(),
job.owner.to_string(),
job_account_addr.to_string(),
job.id,
));
}
// Free account
msgs.push(build_free_account_msg(
config.job_account_tracker_address.to_string(),
job.owner.to_string(),
job_account_addr.to_string(),
job.id,
));

Ok(Response::new()
.add_messages(msgs)
Expand Down
40 changes: 0 additions & 40 deletions contracts/warp-controller/src/migrate/legacy_account.rs

This file was deleted.

1 change: 0 additions & 1 deletion contracts/warp-controller/src/migrate/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub(crate) mod job;
pub(crate) mod job_account;
pub(crate) mod legacy_account;
40 changes: 0 additions & 40 deletions contracts/warp-controller/src/query/account.rs

This file was deleted.

1 change: 0 additions & 1 deletion contracts/warp-controller/src/query/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub(crate) mod account;
pub(crate) mod controller;
pub(crate) mod job;
Loading

0 comments on commit 2c3d37c

Please sign in to comment.