Skip to content

Commit

Permalink
Extract upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Oct 2, 2024
1 parent 498716b commit 444746a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
8 changes: 6 additions & 2 deletions packages/account-wasm/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::fmt;

use account_sdk::{errors::ControllerError, provider::ExecuteFromOutsideError, signers::DeviceError};
use account_sdk::{
errors::ControllerError, provider::ExecuteFromOutsideError, signers::DeviceError,
};
use serde::Serialize;
use starknet::{accounts::AccountError, core::types::StarknetError, providers::ProviderError};
use starknet_types_core::felt::FromStrError;
Expand Down Expand Up @@ -178,7 +180,9 @@ impl From<ExecuteFromOutsideError> for JsControllerError {
ErrorCode::PaymasterNotSupported,
"Paymaster not supported".to_string(),
),
ExecuteFromOutsideError::Serialization(e) => (ErrorCode::PaymasterSerialization, e.to_string()),
ExecuteFromOutsideError::Serialization(e) => {
(ErrorCode::PaymasterSerialization, e.to_string())
}
ExecuteFromOutsideError::ProviderError(e) => return e.into(),
};

Expand Down
4 changes: 0 additions & 4 deletions packages/account_sdk/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ where
let signature = self.owner.sign(&hash).await?;
Ok(Vec::<SignerSignature>::cairo_serialize(&vec![signature]))
}

pub fn upgrade(&self, new_class_hash: Felt) -> Call {
self.contract().upgrade_getcall(&new_class_hash.into())
}
}

impl_account!(Controller<P: CartridgeProvider, B: Backend>, |account: &Controller<P, B>, context| {
Expand Down
3 changes: 2 additions & 1 deletion packages/account_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ pub mod artifacts;
pub mod constants;
pub mod controller;
pub mod errors;
pub mod execute_from_outside;
pub mod factory;
pub mod hash;
pub mod execute_from_outside;
pub mod provider;
pub mod session;
pub mod signers;
pub mod storage;
pub mod typed_data;
pub mod upgrade;
pub mod utils;

#[cfg(not(target_arch = "wasm32"))]
Expand Down
1 change: 0 additions & 1 deletion packages/account_sdk/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ mod external_owners_test;
mod guardian_test;
mod outside_execution_test;
mod owner_test;
mod upgrade_test;

#[derive(Error, Debug)]
pub enum EnsureTxnError<S> {
Expand Down
18 changes: 18 additions & 0 deletions packages/account_sdk/src/upgrade.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use starknet::core::types::Call;
use starknet_crypto::Felt;

use crate::{controller::Controller, provider::CartridgeProvider, Backend};

#[cfg(test)]
#[path = "upgrade_test.rs"]
mod upgrade_test;

impl<P, B> Controller<P, B>
where
P: CartridgeProvider + Send + Sync + Clone,
B: Backend + Clone,
{
pub fn upgrade(&self, new_class_hash: Felt) -> Call {
self.contract().upgrade_getcall(&new_class_hash.into())
}
}
File renamed without changes.

0 comments on commit 444746a

Please sign in to comment.