Skip to content

Commit

Permalink
refactoring and renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdbytes committed Jul 3, 2024
1 parent 6d53b51 commit 06f4def
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use crate::interfaces::manager::StarkgateManager;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

use ethers::types::Address;
use starknet_proxy_client::clients::proxy_5_0_0::ProxySupportLatest;
use starknet_proxy_client::clients::proxy_5_0_0::ProxySupport5_0_0;

pub struct StarkgateManagerContractClient {
manager: StarkgateManager<LocalWalletSignerMiddleware>,
proxy_support: ProxySupportLatest<LocalWalletSignerMiddleware>,
proxy_support: ProxySupport5_0_0<LocalWalletSignerMiddleware>,
manager_implementation: Address,
}

Expand All @@ -20,7 +20,7 @@ impl StarkgateManagerContractClient {
) -> Self {
Self {
manager: StarkgateManager::new(address, client.clone()),
proxy_support: ProxySupportLatest::new(address, client.clone()),
proxy_support: ProxySupport5_0_0::new(address, client.clone()),
manager_implementation: implementation_address,
}
}
Expand All @@ -32,8 +32,8 @@ impl AsRef<StarkgateManager<LocalWalletSignerMiddleware>> for StarkgateManagerCo
}
}

impl AsRef<ProxySupportLatest<LocalWalletSignerMiddleware>> for StarkgateManagerContractClient {
fn as_ref(&self) -> &ProxySupportLatest<LocalWalletSignerMiddleware> {
impl AsRef<ProxySupport5_0_0<LocalWalletSignerMiddleware>> for StarkgateManagerContractClient {
fn as_ref(&self) -> &ProxySupport5_0_0<LocalWalletSignerMiddleware> {
&self.proxy_support
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use crate::interfaces::registry::StarkgateRegistry;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

use ethers::types::Address;
use starknet_proxy_client::clients::proxy_5_0_0::ProxySupportLatest;
use starknet_proxy_client::clients::proxy_5_0_0::ProxySupport5_0_0;

pub struct StarkgateRegistryContractClient {
registry: StarkgateRegistry<LocalWalletSignerMiddleware>,
proxy_support: ProxySupportLatest<LocalWalletSignerMiddleware>,
proxy_support: ProxySupport5_0_0<LocalWalletSignerMiddleware>,
registry_implementation: Address,
}

Expand All @@ -20,7 +20,7 @@ impl StarkgateRegistryContractClient {
) -> Self {
Self {
registry: StarkgateRegistry::new(address, client.clone()),
proxy_support: ProxySupportLatest::new(address, client.clone()),
proxy_support: ProxySupport5_0_0::new(address, client.clone()),
registry_implementation: implementation_address,
}
}
Expand All @@ -31,8 +31,8 @@ impl AsRef<StarkgateRegistry<LocalWalletSignerMiddleware>> for StarkgateRegistry
}
}

impl AsRef<ProxySupportLatest<LocalWalletSignerMiddleware>> for StarkgateRegistryContractClient {
fn as_ref(&self) -> &ProxySupportLatest<LocalWalletSignerMiddleware> {
impl AsRef<ProxySupport5_0_0<LocalWalletSignerMiddleware>> for StarkgateRegistryContractClient {
fn as_ref(&self) -> &ProxySupport5_0_0<LocalWalletSignerMiddleware> {
&self.proxy_support
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/l2/starknet-core-contract-client/src/clients/sovereign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ use crate::interfaces::{
GovernedFinalizable, Operator, StarknetGovernance, StarknetMessaging, StarknetSovereignContract,
};
use ethers::types::Address;
use starknet_proxy_client::clients::proxy_3_0_2::ProxySupport;
use starknet_proxy_client::clients::proxy_3_0_2::ProxySupport3_0_2;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

/// Client to interact with a Starknet core contract running in `Sovereign` mode
pub struct StarknetSovereignContractClient {
core_contract: StarknetSovereignContract<LocalWalletSignerMiddleware>,
messaging: StarknetMessaging<LocalWalletSignerMiddleware>,
operator: Operator<LocalWalletSignerMiddleware>,
proxy_support: ProxySupport<LocalWalletSignerMiddleware>,
proxy_support: ProxySupport3_0_2<LocalWalletSignerMiddleware>,
governance: StarknetGovernance<LocalWalletSignerMiddleware>,
governed_finalizable: GovernedFinalizable<LocalWalletSignerMiddleware>,
core_contract_implementation: Address,
Expand All @@ -28,7 +28,7 @@ impl StarknetSovereignContractClient {
core_contract: StarknetSovereignContract::new(address, client.clone()),
messaging: StarknetMessaging::new(address, client.clone()),
operator: Operator::new(address, client.clone()),
proxy_support: ProxySupport::new(address, client.clone()),
proxy_support: ProxySupport3_0_2::new(address, client.clone()),
governance: StarknetGovernance::new(address, client.clone()),
governed_finalizable: GovernedFinalizable::new(address, client.clone()),
core_contract_implementation: implementation_address,
Expand All @@ -48,8 +48,8 @@ impl AsRef<StarknetMessaging<LocalWalletSignerMiddleware>> for StarknetSovereign
&self.messaging
}
}
impl AsRef<ProxySupport<LocalWalletSignerMiddleware>> for StarknetSovereignContractClient {
fn as_ref(&self) -> &ProxySupport<LocalWalletSignerMiddleware> {
impl AsRef<ProxySupport3_0_2<LocalWalletSignerMiddleware>> for StarknetSovereignContractClient {
fn as_ref(&self) -> &ProxySupport3_0_2<LocalWalletSignerMiddleware> {
&self.proxy_support
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/l2/starknet-core-contract-client/src/clients/validity.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use ethers::abi::Address;
use starknet_proxy_client::clients::proxy_3_0_2::ProxySupport;
use starknet_proxy_client::clients::proxy_3_0_2::ProxySupport3_0_2;

use crate::interfaces::{
GovernedFinalizable, Operator, StarknetGovernance, StarknetMessaging, StarknetValidityContract,
Expand All @@ -13,7 +13,7 @@ pub struct StarknetValidityContractClient {
core_contract: StarknetValidityContract<LocalWalletSignerMiddleware>,
messaging: StarknetMessaging<LocalWalletSignerMiddleware>,
operator: Operator<LocalWalletSignerMiddleware>,
proxy_support: ProxySupport<LocalWalletSignerMiddleware>,
proxy_support: ProxySupport3_0_2<LocalWalletSignerMiddleware>,
governance: StarknetGovernance<LocalWalletSignerMiddleware>,
governed_finalizable: GovernedFinalizable<LocalWalletSignerMiddleware>,
core_contract_implementation: ethers::addressbook::Address,
Expand All @@ -29,7 +29,7 @@ impl StarknetValidityContractClient {
core_contract: StarknetValidityContract::new(address, client.clone()),
messaging: StarknetMessaging::new(address, client.clone()),
operator: Operator::new(address, client.clone()),
proxy_support: ProxySupport::new(address, client.clone()),
proxy_support: ProxySupport3_0_2::new(address, client.clone()),
governance: StarknetGovernance::new(address, client.clone()),
governed_finalizable: GovernedFinalizable::new(address, client.clone()),
core_contract_implementation: implementation_address,
Expand All @@ -49,8 +49,8 @@ impl AsRef<StarknetMessaging<LocalWalletSignerMiddleware>> for StarknetValidityC
&self.messaging
}
}
impl AsRef<ProxySupport<LocalWalletSignerMiddleware>> for StarknetValidityContractClient {
fn as_ref(&self) -> &ProxySupport<LocalWalletSignerMiddleware> {
impl AsRef<ProxySupport3_0_2<LocalWalletSignerMiddleware>> for StarknetValidityContractClient {
fn as_ref(&self) -> &ProxySupport3_0_2<LocalWalletSignerMiddleware> {
&self.proxy_support
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/l2/starknet-eth-bridge-client/src/clients/eth_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use crate::interfaces::eth_bridge::StarknetEthBridge;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

use ethers::types::Address;
use starknet_proxy_client::clients::proxy_3_0_2::ProxySupport;
use starknet_proxy_client::clients::proxy_3_0_2::ProxySupport3_0_2;

/// Client to interact with a Starknet Eth Bridge
pub struct StarknetEthBridgeContractClient {
eth_bridge: StarknetEthBridge<LocalWalletSignerMiddleware>,
proxy_support: ProxySupport<LocalWalletSignerMiddleware>,
proxy_support: ProxySupport3_0_2<LocalWalletSignerMiddleware>,
eth_bridge_implementation: Address,
}

Expand All @@ -21,7 +21,7 @@ impl StarknetEthBridgeContractClient {
) -> Self {
Self {
eth_bridge: StarknetEthBridge::new(address, client.clone()),
proxy_support: ProxySupport::new(address, client.clone()),
proxy_support: ProxySupport3_0_2::new(address, client.clone()),
eth_bridge_implementation: implementation_address,
}
}
Expand All @@ -33,8 +33,8 @@ impl AsRef<StarknetEthBridge<LocalWalletSignerMiddleware>> for StarknetEthBridge
}
}

impl AsRef<ProxySupport<LocalWalletSignerMiddleware>> for StarknetEthBridgeContractClient {
fn as_ref(&self) -> &ProxySupport<LocalWalletSignerMiddleware> {
impl AsRef<ProxySupport3_0_2<LocalWalletSignerMiddleware>> for StarknetEthBridgeContractClient {
fn as_ref(&self) -> &ProxySupport3_0_2<LocalWalletSignerMiddleware> {
&self.proxy_support
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/l2/starknet-proxy-client/src/clients/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod proxy;
pub mod proxy_3_0_2;
pub mod proxy_5_0_0;
6 changes: 3 additions & 3 deletions crates/l2/starknet-proxy-client/src/clients/proxy_3_0_2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::clients::proxy::{ProxyInitializeData, ProxySupportTrait};
use crate::interfaces::proxy::{ProxyInitializeData, ProxySupportTrait};
use async_trait::async_trait;
use ethers::addressbook::Address;
use ethers::contract::{abigen, ContractError};
Expand All @@ -7,7 +7,7 @@ use ethers::prelude::{Bytes, TransactionReceipt};
use utils::errors::Error;

abigen!(
ProxySupport,
ProxySupport3_0_2,
r#"[
function isFrozen() external view virtual returns (bool)
function initialize(bytes calldata data) external notCalledDirectly
Expand All @@ -22,7 +22,7 @@ abigen!(
#[async_trait]
impl<T, M: Middleware> ProxySupportTrait<M> for T
where
T: AsRef<ProxySupport<M>> + Send + Sync,
T: AsRef<ProxySupport3_0_2<M>> + Send + Sync,
{
async fn is_frozen(&self) -> Result<bool, Error<M>> {
self.as_ref().is_frozen().call().await.map_err(Into::into)
Expand Down
6 changes: 3 additions & 3 deletions crates/l2/starknet-proxy-client/src/clients/proxy_5_0_0.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::clients::proxy::{ProxyInitializeData, ProxySupportLatestTrait};
use crate::interfaces::proxy::{ProxyInitializeData, ProxySupportLatestTrait};
use async_trait::async_trait;
use ethers::addressbook::Address;
use ethers::contract::{abigen, ContractError};
Expand All @@ -7,7 +7,7 @@ use ethers::prelude::{Bytes, TransactionReceipt};
use utils::errors::Error;

abigen!(
ProxySupportLatest,
ProxySupport5_0_0,
r#"[
function isFrozen() external view virtual returns (bool)
function initialize(bytes calldata data) external notCalledDirectly
Expand All @@ -31,7 +31,7 @@ abigen!(
#[async_trait]
impl<T, M: Middleware> ProxySupportLatestTrait<M> for T
where
T: AsRef<ProxySupportLatest<M>> + Send + Sync,
T: AsRef<ProxySupport5_0_0<M>> + Send + Sync,
{
async fn is_frozen(&self) -> Result<bool, Error<M>> {
self.as_ref().is_frozen().call().await.map_err(Into::into)
Expand Down
4 changes: 2 additions & 2 deletions crates/l2/starknet-proxy-client/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ pub async fn deploy_contract_behind_proxy<T: Tokenize>(

log::debug!("ℹ️ Contract deployed : {:?}", contract.address().clone());

let type_of_proxy = match proxy_type {
let proxy_code = match proxy_type {
ProxyVersion::SafeProxy3_0_2 => SAFE_PROXY_3_0_2,
ProxyVersion::SafeProxy5_0_0 => SAFE_PROXY_5_0_0,
ProxyVersion::UnsafeProxy => UNSAFE_PROXY,
};

let proxy_contract =
deploy_contract(client.clone(), type_of_proxy, Token::Uint(U256::from(0))).await?;
deploy_contract(client.clone(), proxy_code, Token::Uint(U256::from(0))).await?;

log::debug!(
"ℹ️ Proxy for contract [{:?}] deployed : {:?}",
Expand Down
1 change: 1 addition & 0 deletions crates/l2/starknet-proxy-client/src/interfaces/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod proxy;
1 change: 1 addition & 0 deletions crates/l2/starknet-proxy-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod clients;
pub mod deploy;
pub mod interfaces;
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use crate::interfaces::token_bridge::StarknetTokenBridge;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

use ethers::types::Address;
use starknet_proxy_client::clients::proxy_5_0_0::ProxySupportLatest;
use starknet_proxy_client::clients::proxy_5_0_0::ProxySupport5_0_0;

/// Client to interact with a Token Bridge (ERC20)
pub struct StarknetTokenBridgeContractClient {
token_bridge: StarknetTokenBridge<LocalWalletSignerMiddleware>,
proxy_support: ProxySupportLatest<LocalWalletSignerMiddleware>,
proxy_support: ProxySupport5_0_0<LocalWalletSignerMiddleware>,
token_bridge_implementation: Address,
}

Expand All @@ -21,7 +21,7 @@ impl StarknetTokenBridgeContractClient {
) -> Self {
Self {
token_bridge: StarknetTokenBridge::new(address, client.clone()),
proxy_support: ProxySupportLatest::new(address, client.clone()),
proxy_support: ProxySupport5_0_0::new(address, client.clone()),
token_bridge_implementation: implementation_address,
}
}
Expand All @@ -33,8 +33,8 @@ impl AsRef<StarknetTokenBridge<LocalWalletSignerMiddleware>> for StarknetTokenBr
}
}

impl AsRef<ProxySupportLatest<LocalWalletSignerMiddleware>> for StarknetTokenBridgeContractClient {
fn as_ref(&self) -> &ProxySupportLatest<LocalWalletSignerMiddleware> {
impl AsRef<ProxySupport5_0_0<LocalWalletSignerMiddleware>> for StarknetTokenBridgeContractClient {
fn as_ref(&self) -> &ProxySupport5_0_0<LocalWalletSignerMiddleware> {
&self.proxy_support
}
}
Expand Down

0 comments on commit 06f4def

Please sign in to comment.