Skip to content

Commit

Permalink
feat : refactored proxy structure & changed the functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun Jangra authored and Arun Jangra committed Jul 2, 2024
1 parent 4365a45 commit 4770a16
Show file tree
Hide file tree
Showing 19 changed files with 502 additions and 845 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::sync::Arc;

use crate::interfaces::manager::StarkgateManager;
use starknet_proxy_client::proxy_support::ProxySupport;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

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

pub struct StarkgateManagerContractClient {
manager: StarkgateManager<LocalWalletSignerMiddleware>,
Expand Down
28 changes: 17 additions & 11 deletions crates/l2/starkgate-manager-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::sync::Arc;

use clients::starkgate_manager::StarkgateManagerContractClient;
use starknet_proxy_client::deploy::{
deploy_contract_behind_safe_proxy, deploy_contract_behind_unsafe_proxy, Error,
};
use starknet_proxy_client::deploy::{deploy_contract_behind_proxy, Error, ProxyVersion};
use utils::{LocalWalletSignerMiddleware, NO_CONSTRUCTOR_ARG};
pub mod clients;
pub mod interfaces;
Expand All @@ -14,24 +12,32 @@ pub async fn deploy_starkgate_manager_behind_unsafe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarkgateManagerContractClient, Error> {
// Deploy the Starkgate Manager contract (no explicit constructor)
let manager_contract =
deploy_contract_behind_unsafe_proxy(client.clone(), STARKGATE_MANAGER, NO_CONSTRUCTOR_ARG)
.await?;
let manager_contract = deploy_contract_behind_proxy(
client.clone(),
STARKGATE_MANAGER,
NO_CONSTRUCTOR_ARG,
ProxyVersion::SafeProxy,
)
.await?;

Ok(StarkgateManagerContractClient::new(
manager_contract.address(),
manager_contract.0.address(),
client.clone(),
manager_contract.address(),
manager_contract.1.address(),
))
}

pub async fn deploy_starkgate_manager_behind_safe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarkgateManagerContractClient, Error> {
// Deploy the Starkgate Manager contract (no explicit constructor)
let (manager_contract, manager_contract_implementation) =
deploy_contract_behind_safe_proxy(client.clone(), STARKGATE_MANAGER, NO_CONSTRUCTOR_ARG)
.await?;
let (manager_contract, manager_contract_implementation) = deploy_contract_behind_proxy(
client.clone(),
STARKGATE_MANAGER,
NO_CONSTRUCTOR_ARG,
ProxyVersion::SafeProxy,
)
.await?;

Ok(StarkgateManagerContractClient::new(
manager_contract.address(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::sync::Arc;

use crate::interfaces::registry::StarkgateRegistry;
use starknet_proxy_client::proxy_support::ProxySupport;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

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

pub struct StarkgateRegistryContractClient {
registry: StarkgateRegistry<LocalWalletSignerMiddleware>,
Expand Down
28 changes: 17 additions & 11 deletions crates/l2/starkgate-registry-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::sync::Arc;

use clients::starkgate_registry::StarkgateRegistryContractClient;
use starknet_proxy_client::deploy::{
deploy_contract_behind_safe_proxy, deploy_contract_behind_unsafe_proxy, Error,
};
use starknet_proxy_client::deploy::{deploy_contract_behind_proxy, Error, ProxyVersion};
use utils::{LocalWalletSignerMiddleware, NO_CONSTRUCTOR_ARG};

pub mod clients;
Expand All @@ -15,24 +13,32 @@ pub async fn deploy_starkgate_registry_behind_unsafe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarkgateRegistryContractClient, Error> {
// Deploy the Starkgate Registry contract (no explicit constructor)
let registry_contract =
deploy_contract_behind_unsafe_proxy(client.clone(), STARKGATE_REGISTRY, NO_CONSTRUCTOR_ARG)
.await?;
let registry_contract = deploy_contract_behind_proxy(
client.clone(),
STARKGATE_REGISTRY,
NO_CONSTRUCTOR_ARG,
ProxyVersion::UnsafeProxy,
)
.await?;

Ok(StarkgateRegistryContractClient::new(
registry_contract.address(),
registry_contract.0.address(),
client.clone(),
registry_contract.address(),
registry_contract.1.address(),
))
}

pub async fn deploy_starkgate_registry_behind_safe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarkgateRegistryContractClient, Error> {
// Deploy the Starkgate Registry contract (no explicit constructor)
let (registry_contract, registry_contract_implementation) =
deploy_contract_behind_safe_proxy(client.clone(), STARKGATE_REGISTRY, NO_CONSTRUCTOR_ARG)
.await?;
let (registry_contract, registry_contract_implementation) = deploy_contract_behind_proxy(
client.clone(),
STARKGATE_REGISTRY,
NO_CONSTRUCTOR_ARG,
ProxyVersion::SafeProxy,
)
.await?;

Ok(StarkgateRegistryContractClient::new(
registry_contract.address(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::interfaces::{
GovernedFinalizable, Operator, StarknetGovernance, StarknetMessaging, StarknetSovereignContract,
};
use ethers::types::Address;
use starknet_proxy_client::proxy_support::ProxySupport;
use starknet_proxy_client::clients::proxy_3_0_2::ProxySupport;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

/// Client to interact with a Starknet core contract running in `Sovereign` mode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::sync::Arc;

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

use crate::interfaces::{
GovernedFinalizable, Operator, StarknetGovernance, StarknetMessaging, StarknetValidityContract,
};
use starknet_proxy_client::proxy_support::ProxySupport;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

/// Client to interact with a Starknet core contract running in `Validity` mode
Expand Down
50 changes: 33 additions & 17 deletions crates/l2/starknet-core-contract-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use std::sync::Arc;

use crate::clients::StarknetValidityContractClient;
use clients::StarknetSovereignContractClient;
use starknet_proxy_client::deploy::{
deploy_contract_behind_safe_proxy, deploy_contract_behind_unsafe_proxy, Error,
};
use starknet_proxy_client::deploy::{deploy_contract_behind_proxy, Error, ProxyVersion};
use utils::{LocalWalletSignerMiddleware, NO_CONSTRUCTOR_ARG};

pub mod clients;
Expand All @@ -19,14 +17,18 @@ pub async fn deploy_starknet_sovereign_behind_unsafe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarknetSovereignContractClient, Error> {
// Deploy the Starknet Core contract (no explicit constructor)
let core_contract =
deploy_contract_behind_unsafe_proxy(client.clone(), STARKNET_SOVEREIGN, NO_CONSTRUCTOR_ARG)
.await?;
let core_contract = deploy_contract_behind_proxy(
client.clone(),
STARKNET_SOVEREIGN,
NO_CONSTRUCTOR_ARG,
ProxyVersion::UnsafeProxy,
)
.await?;

Ok(StarknetSovereignContractClient::new(
core_contract.address(),
core_contract.0.address(),
client.clone(),
core_contract.address(),
core_contract.1.address(),
))
}

Expand All @@ -36,9 +38,13 @@ pub async fn deploy_starknet_sovereign_behind_safe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarknetSovereignContractClient, Error> {
// Deploy the Starknet Core contract (no explicit constructor)
let (core_contract, core_contract_implementation) =
deploy_contract_behind_safe_proxy(client.clone(), STARKNET_SOVEREIGN, NO_CONSTRUCTOR_ARG)
.await?;
let (core_contract, core_contract_implementation) = deploy_contract_behind_proxy(
client.clone(),
STARKNET_SOVEREIGN,
NO_CONSTRUCTOR_ARG,
ProxyVersion::SafeProxy,
)
.await?;

Ok(StarknetSovereignContractClient::new(
core_contract.address(),
Expand All @@ -53,13 +59,18 @@ pub async fn deploy_starknet_validity_behind_unsafe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarknetValidityContractClient, Error> {
// Deploy the Starknet Core contract (no explicit constructor)
let core_contract =
deploy_contract_behind_unsafe_proxy(client.clone(), STARKNET, NO_CONSTRUCTOR_ARG).await?;
let core_contract = deploy_contract_behind_proxy(
client.clone(),
STARKNET,
NO_CONSTRUCTOR_ARG,
ProxyVersion::UnsafeProxy,
)
.await?;

Ok(StarknetValidityContractClient::new(
core_contract.address(),
core_contract.0.address(),
client.clone(),
core_contract.address(),
core_contract.1.address(),
))
}

Expand All @@ -69,8 +80,13 @@ pub async fn deploy_starknet_validity_behind_safe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarknetValidityContractClient, Error> {
// Deploy the Starknet Core contract (no explicit constructor)
let (core_contract, core_contract_implementation) =
deploy_contract_behind_safe_proxy(client.clone(), STARKNET, NO_CONSTRUCTOR_ARG).await?;
let (core_contract, core_contract_implementation) = deploy_contract_behind_proxy(
client.clone(),
STARKNET,
NO_CONSTRUCTOR_ARG,
ProxyVersion::SafeProxy,
)
.await?;

Ok(StarknetValidityContractClient::new(
core_contract.address(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::sync::Arc;

use crate::interfaces::eth_bridge::StarknetEthBridge;
use starknet_proxy_client::proxy_support::ProxySupport;
use utils::{LocalWalletSignerMiddleware, StarknetContractClient};

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

/// Client to interact with a Starknet Eth Bridge
pub struct StarknetEthBridgeContractClient {
Expand Down
21 changes: 12 additions & 9 deletions crates/l2/starknet-eth-bridge-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::sync::Arc;

use clients::eth_bridge::StarknetEthBridgeContractClient;
use starknet_proxy_client::deploy::{
deploy_contract_behind_safe_proxy, deploy_contract_behind_unsafe_proxy, Error,
};
use starknet_proxy_client::deploy::{deploy_contract_behind_proxy, Error, ProxyVersion};
use utils::{LocalWalletSignerMiddleware, NO_CONSTRUCTOR_ARG};
pub mod clients;
pub mod interfaces;
Expand All @@ -14,27 +12,32 @@ pub async fn deploy_starknet_eth_bridge_behind_unsafe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarknetEthBridgeContractClient, Error> {
// Deploy the Eth Bridge contract (no explicit constructor)
let eth_bridge_contract = deploy_contract_behind_unsafe_proxy(
let eth_bridge_contract = deploy_contract_behind_proxy(
client.clone(),
STARKNET_ETH_BRIDGE,
NO_CONSTRUCTOR_ARG,
ProxyVersion::UnsafeProxy,
)
.await?;

Ok(StarknetEthBridgeContractClient::new(
eth_bridge_contract.address(),
eth_bridge_contract.0.address(),
client.clone(),
eth_bridge_contract.address(),
eth_bridge_contract.1.address(),
))
}

pub async fn deploy_starknet_eth_bridge_behind_safe_proxy(
client: Arc<LocalWalletSignerMiddleware>,
) -> Result<StarknetEthBridgeContractClient, Error> {
// Deploy the Eth Bridge contract (no explicit constructor)
let (eth_bridge_contract, eth_bridge_contract_implementation) =
deploy_contract_behind_safe_proxy(client.clone(), STARKNET_ETH_BRIDGE, NO_CONSTRUCTOR_ARG)
.await?;
let (eth_bridge_contract, eth_bridge_contract_implementation) = deploy_contract_behind_proxy(
client.clone(),
STARKNET_ETH_BRIDGE,
NO_CONSTRUCTOR_ARG,
ProxyVersion::SafeProxy,
)
.await?;

Ok(StarknetEthBridgeContractClient::new(
eth_bridge_contract.address(),
Expand Down
468 changes: 0 additions & 468 deletions crates/l2/starknet-proxy-client/src/artifacts/Proxy.json

This file was deleted.

3 changes: 3 additions & 0 deletions crates/l2/starknet-proxy-client/src/clients/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod proxy;
pub mod proxy_3_0_2;
pub mod proxy_5_0_0;
Loading

0 comments on commit 4770a16

Please sign in to comment.