diff --git a/cli/src/processor/delegation.rs b/cli/src/processor/delegation.rs index fd83dcf28..6c7f637fa 100644 --- a/cli/src/processor/delegation.rs +++ b/cli/src/processor/delegation.rs @@ -1,4 +1,4 @@ -use anchor_lang::AnchorDeserialize; +use anchor_lang::AccountDeserialize; use clockwork_client::{ network::state::{Config, Delegation, Worker}, Client, @@ -13,7 +13,7 @@ pub fn create(client: &Client, worker_id: u64) -> Result<(), CliError> { let config_data = client .get_account_data(&config_pubkey) .map_err(|_err| CliError::AccountNotFound(config_pubkey.to_string()))?; - let config = Config::try_from_slice(config_data.as_slice()) + let config = Config::try_deserialize(&mut config_data.as_slice()) .map_err(|_err| CliError::AccountDataNotParsable(config_pubkey.to_string()))?; // Get worker @@ -21,7 +21,7 @@ pub fn create(client: &Client, worker_id: u64) -> Result<(), CliError> { let worker_data = client .get_account_data(&worker_pubkey) .map_err(|_err| CliError::AccountNotFound(worker_pubkey.to_string()))?; - let worker = Worker::try_from_slice(worker_data.as_slice()) + let worker = Worker::try_deserialize(&mut worker_data.as_slice()) .map_err(|_err| CliError::AccountDataNotParsable(worker_pubkey.to_string()))?; // Build ix @@ -48,7 +48,7 @@ pub fn deposit( let config_data = client .get_account_data(&config_pubkey) .map_err(|_err| CliError::AccountNotFound(config_pubkey.to_string()))?; - let config = Config::try_from_slice(config_data.as_slice()) + let config = Config::try_deserialize(&mut config_data.as_slice()) .map_err(|_err| CliError::AccountDataNotParsable(config_pubkey.to_string()))?; // TODO Map the amount using the mint's decimals. @@ -78,7 +78,7 @@ pub fn withdraw( let config_data = client .get_account_data(&config_pubkey) .map_err(|_err| CliError::AccountNotFound(config_pubkey.to_string()))?; - let config = Config::try_from_slice(config_data.as_slice()) + let config = Config::try_deserialize(&mut config_data.as_slice()) .map_err(|_err| CliError::AccountDataNotParsable(config_pubkey.to_string()))?; // TODO Map the amount using the mint's decimals. @@ -103,7 +103,7 @@ pub fn get(client: &Client, delegation_id: u64, worker_id: u64) -> Result<(), Cl let config_data = client .get_account_data(&config_pubkey) .map_err(|_err| CliError::AccountNotFound(config_pubkey.to_string()))?; - let config = Config::try_from_slice(config_data.as_slice()) + let config = Config::try_deserialize(&mut config_data.as_slice()) .map_err(|_err| CliError::AccountDataNotParsable(config_pubkey.to_string()))?; // Get the delegation account. @@ -112,7 +112,7 @@ pub fn get(client: &Client, delegation_id: u64, worker_id: u64) -> Result<(), Cl let delegation_data = client .get_account_data(&delegation_pubkey) .map_err(|_err| CliError::AccountNotFound(delegation_pubkey.to_string()))?; - let delegation = Delegation::try_from_slice(delegation_data.as_slice()) + let delegation = Delegation::try_deserialize(&mut delegation_data.as_slice()) .map_err(|_err| CliError::AccountDataNotParsable(delegation_pubkey.to_string()))?; // Get the delegation's token account. diff --git a/cli/src/processor/worker.rs b/cli/src/processor/worker.rs index a9b27fdbf..604a5a36f 100644 --- a/cli/src/processor/worker.rs +++ b/cli/src/processor/worker.rs @@ -1,4 +1,4 @@ -use anchor_lang::AnchorDeserialize; +use anchor_lang::AccountDeserialize; use clockwork_client::{ network::state::{ Config, Fee, Penalty, Registry, Snapshot, SnapshotFrame, Worker, WorkerSettings, @@ -47,7 +47,7 @@ pub fn get(client: &Client, id: u64) -> Result<(), CliError> { let registry_data = client .get_account_data(®istry_pubkey) .map_err(|_err| CliError::AccountNotFound(registry_pubkey.to_string()))?; - let registry = Registry::try_from_slice(registry_data.as_slice()) + let registry = Registry::try_deserialize(&mut registry_data.as_slice()) .map_err(|_err| CliError::AccountDataNotParsable(registry_pubkey.to_string()))?; // Get snapshot frame @@ -56,8 +56,10 @@ pub fn get(client: &Client, id: u64) -> Result<(), CliError> { match client.get_account_data(&snapshot_frame_pubkey) { Err(_err) => {} Ok(snapshot_frame_data) => { - let snapshot_frame = SnapshotFrame::try_from_slice(snapshot_frame_data.as_slice()) - .map_err(|_err| CliError::AccountDataNotParsable(registry_pubkey.to_string()))?; + let snapshot_frame = SnapshotFrame::try_deserialize( + &mut snapshot_frame_data.as_slice(), + ) + .map_err(|_err| CliError::AccountDataNotParsable(registry_pubkey.to_string()))?; println!("{:#?}", snapshot_frame); } } @@ -71,7 +73,7 @@ pub fn create(client: &Client, signatory: Keypair, silent: bool) -> Result<(), C let config_data = client .get_account_data(&config_pubkey) .map_err(|_err| CliError::AccountNotFound(config_pubkey.to_string()))?; - let config = Config::try_from_slice(config_data.as_slice()) + let config = Config::try_deserialize(&mut config_data.as_slice()) .map_err(|_err| CliError::AccountDataNotParsable(config_pubkey.to_string()))?; // Get registry @@ -79,7 +81,7 @@ pub fn create(client: &Client, signatory: Keypair, silent: bool) -> Result<(), C let registry_data = client .get_account_data(®istry_pubkey) .map_err(|_err| CliError::AccountNotFound(registry_pubkey.to_string()))?; - let registry = Registry::try_from_slice(registry_data.as_slice()) + let registry = Registry::try_deserialize(&mut registry_data.as_slice()) .map_err(|_err| CliError::AccountDataNotParsable(registry_pubkey.to_string()))?; // Build ix