Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Madara Compatibility #12

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 243 additions & 84 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ starknet-token-bridge-client = { git = "https://github.com/keep-starknet-strange
zaun-utils = { git = "https://github.com/keep-starknet-strange/zaun", package = "utils", branch = "main" }

# Starknet Deps
starknet-accounts = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "2d59636911628260fa460179010bbd00e89de06e" }
starknet-core = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "2d59636911628260fa460179010bbd00e89de06e" }
starknet-crypto = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "2d59636911628260fa460179010bbd00e89de06e" }
starknet-ff = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "2d59636911628260fa460179010bbd00e89de06e" }
starknet-providers = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "2d59636911628260fa460179010bbd00e89de06e" }
starknet-signers = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "2d59636911628260fa460179010bbd00e89de06e" }
starknet = "0.11.0"
starknet-accounts = "0.11.0"
starknet-core = "0.11"
starknet-crypto = "0.7"
starknet-providers = "0.11"
starknet-signers = "0.9"
starknet-types-core = { version = "0.1.5", default-features = false, features = [
"hash",
] }
starknet_api = { git = "https://github.com/bidzyyys/starknet-api.git", branch = "feature/scale-codec" }

# Third Party
Expand Down
Binary file removed bin/madara
Binary file not shown.
5 changes: 2 additions & 3 deletions src/contract_clients/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use ethereum_instance::EthereumClient;
use starknet_providers::jsonrpc::HttpTransport;
use starknet_providers::JsonRpcClient;
use url::Url;
use starknet::providers::jsonrpc::{HttpTransport, JsonRpcClient};
use starknet::providers::Url;

use crate::CliArgs;

Expand Down
37 changes: 18 additions & 19 deletions src/contract_clients/core_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use async_trait::async_trait;
use ethers::abi::AbiEncode;
use ethers::addressbook::Address;
use ethers::prelude::{Bytes, I256, U256};
use starknet_api::hash::{StarkFelt, StarkHash};
use starknet_ff::FieldElement;
use starknet::core::types::Felt;
use starknet_proxy_client::interfaces::proxy::{CoreContractInitData, CoreContractState};
use zaun_utils::LocalWalletSignerMiddleware;

Expand All @@ -26,10 +25,10 @@ pub trait CoreContract {
#[allow(clippy::too_many_arguments)]
async fn add_implementation_core_contract(
&self,
block_number: StarkFelt,
state_root: StarkFelt,
program_hash: FieldElement,
config_hash: StarkHash,
block_number: Felt,
state_root: Felt,
program_hash: Felt,
config_hash: Felt,
implementation_address: Address,
verifier_address: Address,
finalized: bool,
Expand All @@ -38,10 +37,10 @@ pub trait CoreContract {
#[allow(clippy::too_many_arguments)]
async fn upgrade_to_core_contract(
&self,
block_number: StarkFelt,
state_root: StarkFelt,
program_hash: FieldElement,
config_hash: StarkHash,
block_number: Felt,
state_root: Felt,
program_hash: Felt,
config_hash: Felt,
implementation_address: Address,
verifier_address: Address,
finalized: bool,
Expand All @@ -53,14 +52,14 @@ pub trait CoreContract {

async fn nominate_governor_core_contract_proxy(&self, l1_governor_address: Address);

async fn initialize(&self, program_hash: StarkFelt, config_hash: StarkFelt);
async fn initialize(&self, program_hash: Felt, config_hash: Felt);

async fn initialize_core_contract(
&self,
block_number: StarkFelt,
state_root: StarkFelt,
program_hash: FieldElement,
config_hash: StarkHash,
block_number: Felt,
state_root: Felt,
program_hash: Felt,
config_hash: Felt,
verifer_address: Address,
);
}
Expand All @@ -70,10 +69,10 @@ pub trait CoreContractDeploy<T> {
}

pub fn get_init_data_core_contract(
block_number: StarkFelt,
state_root: StarkFelt,
program_hash: StarkFelt,
config_hash: StarkHash,
block_number: Felt,
state_root: Felt,
program_hash: Felt,
config_hash: Felt,
verifier_address: Address,
) -> CoreContractInitData {
CoreContractInitData {
Expand Down
26 changes: 13 additions & 13 deletions src/contract_clients/eth_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use async_trait::async_trait;
use ethers::addressbook::Address;
use ethers::providers::Middleware;
use ethers::types::{Bytes, U256};
use starknet_accounts::{Account, ConnectedAccount};
use starknet::accounts::{Account, ConnectedAccount};
use starknet::core::types::Felt;
use starknet_eth_bridge_client::clients::eth_bridge::StarknetEthBridgeContractClient;
use starknet_eth_bridge_client::interfaces::eth_bridge::StarknetEthBridgeTrait;
use starknet_eth_bridge_client::{
deploy_starknet_eth_bridge_behind_safe_proxy, deploy_starknet_eth_bridge_behind_unsafe_proxy,
};
use starknet_ff::FieldElement;
use starknet_providers::jsonrpc::HttpTransport;
use starknet_providers::JsonRpcClient;
use starknet_proxy_client::interfaces::proxy::ProxySupport3_0_2Trait;
Expand Down Expand Up @@ -60,15 +60,15 @@ impl StarknetLegacyEthBridge {

pub async fn deploy_l2_contracts(
rpc_provider_l2: &JsonRpcClient<HttpTransport>,
legacy_eth_bridge_class_hash: FieldElement,
legacy_eth_bridge_proxy_address: FieldElement,
legacy_eth_bridge_class_hash: Felt,
legacy_eth_bridge_proxy_address: Felt,
account: &RpcAccount<'_>,
) -> FieldElement {
) -> Felt {
let deploy_tx = account
.invoke_contract(
account.address(),
"deploy_contract",
vec![legacy_eth_bridge_class_hash, FieldElement::ZERO, FieldElement::ZERO, FieldElement::ZERO],
vec![legacy_eth_bridge_class_hash, Felt::ZERO, Felt::ZERO, Felt::ZERO],
None,
)
.send()
Expand All @@ -88,7 +88,7 @@ impl StarknetLegacyEthBridge {
let add_implementation_txn = invoke_contract(
legacy_eth_bridge_proxy_address,
"add_implementation",
vec![contract_address, FieldElement::ZERO, FieldElement::ONE, account.address(), FieldElement::ZERO],
vec![contract_address, Felt::ZERO, Felt::ONE, account.address(), Felt::ZERO],
account,
)
.await;
Expand All @@ -104,7 +104,7 @@ impl StarknetLegacyEthBridge {
let upgrade_to_txn = invoke_contract(
legacy_eth_bridge_proxy_address,
"upgrade_to",
vec![contract_address, FieldElement::ZERO, FieldElement::ONE, account.address(), FieldElement::ZERO],
vec![contract_address, Felt::ZERO, Felt::ONE, account.address(), Felt::ZERO],
account,
)
.await;
Expand Down Expand Up @@ -198,7 +198,7 @@ impl StarknetLegacyEthBridge {
&self,
max_total_balance: &str,
max_deposit: &str,
l2_bridge: FieldElement,
l2_bridge: Felt,
l1_multisig_address: Address,
is_dev: bool,
) {
Expand All @@ -215,15 +215,15 @@ impl StarknetLegacyEthBridge {
pub async fn setup_l2_bridge(
&self,
rpc_provider: &JsonRpcClient<HttpTransport>,
l2_bridge_address: FieldElement,
erc20_address: FieldElement,
l2_bridge_address: Felt,
erc20_address: Felt,
l2_deployer_address: &str,
account: &RpcAccount<'_>,
) {
let tx = invoke_contract(
l2_bridge_address,
"initialize",
vec![FieldElement::from_dec_str("1").unwrap(), FieldElement::from_hex_be(l2_deployer_address).unwrap()],
vec![Felt::from_dec_str("1").unwrap(), Felt::from_hex(l2_deployer_address).unwrap()],
account,
)
.await;
Expand All @@ -239,7 +239,7 @@ impl StarknetLegacyEthBridge {
let tx = invoke_contract(
l2_bridge_address,
"set_l1_bridge",
vec![FieldElement::from_byte_slice_be(self.eth_bridge.address().as_bytes()).unwrap()],
vec![Felt::from_bytes_be_slice(self.eth_bridge.address().as_bytes())],
account,
)
.await;
Expand Down
Loading
Loading