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

test: setup staging/prod envs + cleanup code #8

Merged
merged 1 commit into from
Oct 22, 2024
Merged
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
33 changes: 33 additions & 0 deletions config.stage.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[canonical_network]
type = "evm"
name = "Sepolia Mainnet"
address = "0xb2ead588f14e69266d1b87936b75325181377076"
provider = { rpc_endpoint = "https://eth.llamarpc.com" }
wallet = { type = "mnemonic", mnemonic = "your mnemonic here" }

[[bridged_networks]]
type = "evm"
name = "World Chain Sepolia"
address = "0xb2ead588f14e69266d1b87936b75325181377076"
state_bridge_address = "0x2F418Aa7D500B525EE8B80BB5F643A877ef82e09"
world_id_address = "0xE177F37AF0A862A02edFEa4F59C02668E9d0aAA4"
provider = { rpc_endpoint = "https://eth.llamarpc.com" }
wallet = { type = "mnemonic", mnemonic = "your mnemonic here" }

[[bridged_networks]]
type = "evm"
name = "Optimism Sepolia"
address = "0xb2ead588f14e69266d1b87936b75325181377076"
state_bridge_address = "0x158379286D7083dDA05930CD3C6374954Fb511aA"
world_id_address = "0xf07d3efadD82A1F0b4C5Cc3476806d9a170147Ba"
provider = { rpc_endpoint = "https://eth.llamarpc.com" }
wallet = { type = "mnemonic", mnemonic = "your mnemonic here" }

[[bridged_networks]]
type = "evm"
name = "Base Sepolia"
address = "0xb2ead588f14e69266d1b87936b75325181377076"
state_bridge_address = "0x5fFe37995158528d97A819bA390C1F81d74eB2b9"
world_id_address = "0x163b09b4fE21177c455D850BD815B6D583732432"
provider = { rpc_endpoint = "https://eth.llamarpc.com" }
wallet = { type = "mnemonic", mnemonic = "your mnemonic here" }
21 changes: 15 additions & 6 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ wallet = { type = "mnemonic", mnemonic = "your mnemonic here" }

[[bridged_networks]]
type = "evm"
name = "Ethereum Mainnet"
name = "World Chain Mainnet"
address = "0xf7134CE138832c146F2a91D64621eE90c2bddEa"
state_bridge_address = "0x4c175eE61C3c1da847E339e1158D61BBd2537046"
world_id_address = "0x047eE5313F98E26Cc8177fA38877cB36292D2364"
provider = { rpc_endpoint = "https://eth.llamarpc.com" }
wallet = { type = "mnemonic", mnemonic = "your mnemonic here" }

[[bridged_networks]]
type = "evm"
name = "Optimism Mainnet"
address = "0xf7134CE138832c1456F2a91D64621eE90c2bddEa"
state_bridge_address = "0x87584289Fac5116180938bB0921caC1848A3d6fE"
world_id_address = "0x87584289Fac5116180938bB0921caC1848A3d6fE"
state_bridge_address = "0xa6d85F3b3bE6Ff6DC52C3aaBe9A35d0ce252b79F"
world_id_address = "0xB3E7771a6e2d7DD8C0666042B7a07C39b938eb7d"
provider = { rpc_endpoint = "https://eth.llamarpc.com" }
wallet = { type = "mnemonic", mnemonic = "your mnemonic here" }

[[bridged_networks]]
type = "evm"
name = "Ethereum Mainnet"
name = "Polygon Mainnet"
address = "0xf7134CE138832c1456F2a91D64621eE90c2bddEa"
state_bridge_address = "0x87584289Fac5116180938bB0921caC1848A3d6fE"
world_id_address = "0x87584289Fac5116180938bB0921caC1848A3d6fE"
state_bridge_address = "0x76Db75dc752305E2deBd44c479680352F3Bb766f"
world_id_address = "0xa6d85F3b3bE6Ff6DC52C3aaBe9A35d0ce252b79F"
provider = { rpc_endpoint = "https://eth.llamarpc.com" }
wallet = { type = "mnemonic", mnemonic = "your mnemonic here" }
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,57 +161,57 @@

fn init_relays(cfg: Config) -> Result<Vec<Relayer>> {
let mut relayers = Vec::new();
cfg.bridged_networks.iter().for_each(|n| match n.ty {
NetworkType::Evm => {
match &cfg.canonical_network.wallet {
WalletConfig::Mnemonic { mnemonic } => {
let signer = MnemonicBuilder::<English>::default()
.phrase(mnemonic)
.index(0)
.unwrap()
.build()
.expect("Failed to build wallet");
let wallet = EthereumWallet::new(signer);
let l1_provider = ProviderBuilder::default()
.with_recommended_fillers()
.wallet(wallet)
.on_http(
cfg.canonical_network.provider.rpc_endpoint.clone(),
);
let state_bridge = IStateBridgeInstance::new(
n.state_bridge_address,
l1_provider,
);

let signer = AlloySigner::new(state_bridge);

relayers.push(Relayer::Evm(EVMRelay::new(
Signer::Alloy(signer),
Signer::AlloySigner(signer),
n.world_id_address,
n.provider.rpc_endpoint.clone(),
)));
}
WalletConfig::TxSitter {
url,
address: _,
gas_limit,
} => {
let signer = TxSitterSigner::new(
url.as_str(),
n.state_bridge_address,
*gas_limit,
);

relayers.push(Relayer::Evm(EVMRelay::new(
Signer::TxSitter(signer),
Signer::TxSitterSigner(signer),
n.world_id_address,
n.provider.rpc_endpoint.clone(),
)));
}
};
}
_ => {}
});

Check warning on line 214 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> src/main.rs:164:46 | 164 | cfg.bridged_networks.iter().for_each(|n| match n.ty { | ______________________________________________^ 165 | | NetworkType::Evm => { 166 | | match &cfg.canonical_network.wallet { 167 | | WalletConfig::Mnemonic { mnemonic } => { ... | 213 | | _ => {} 214 | | }); | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match = note: `#[warn(clippy::single_match)]` on by default help: try | 164 ~ cfg.bridged_networks.iter().for_each(|n| if let NetworkType::Evm = n.ty { 165 + match &cfg.canonical_network.wallet { 166 + WalletConfig::Mnemonic { mnemonic } => { 167 + let signer = MnemonicBuilder::<English>::default() 168 + .phrase(mnemonic) 169 + .index(0) 170 + .unwrap() 171 + .build() 172 + .expect("Failed to build wallet"); 173 + let wallet = EthereumWallet::new(signer); 174 + let l1_provider = ProviderBuilder::default() 175 + .with_recommended_fillers() 176 + .wallet(wallet) 177 + .on_http( 178 + cfg.canonical_network.provider.rpc_endpoint.clone(), 179 + ); 180 + let state_bridge = IStateBridgeInstance::new( 181 + n.state_bridge_address, 182 + l1_provider, 183 + ); 184 + 185 + let signer = AlloySigner::new(state_bridge); 186 + 187 + relayers.push(Relayer::Evm(EVMRelay::new( 188 + Signer::AlloySigner(signer), 189 + n.world_id_address, 190 + n.provider.rpc_endpoint.clone(), 191 + ))); 192 + } 193 + WalletConfig::TxSitter { 194 + url, 195 + address: _, 196 + gas_limit, 197 + } => { 198 + let signer = TxSitterSigner::new( 199 + url.as_str(), 200 + n.state_bridge_address, 201 + *gas_limit, 202 + ); 203 + 204 + relayers.push(Relayer::Evm(EVMRelay::new( 205 + Signer::TxSitterSigner(signer), 206 + n.world_id_address, 207 + n.provider.rpc_endpoint.clone(), 208 + ))); 209 + } 210 + }; 211 ~ }); |

Check warning on line 214 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> src/main.rs:164:46 | 164 | cfg.bridged_networks.iter().for_each(|n| match n.ty { | ______________________________________________^ 165 | | NetworkType::Evm => { 166 | | match &cfg.canonical_network.wallet { 167 | | WalletConfig::Mnemonic { mnemonic } => { ... | 213 | | _ => {} 214 | | }); | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match = note: `#[warn(clippy::single_match)]` on by default help: try | 164 ~ cfg.bridged_networks.iter().for_each(|n| if let NetworkType::Evm = n.ty { 165 + match &cfg.canonical_network.wallet { 166 + WalletConfig::Mnemonic { mnemonic } => { 167 + let signer = MnemonicBuilder::<English>::default() 168 + .phrase(mnemonic) 169 + .index(0) 170 + .unwrap() 171 + .build() 172 + .expect("Failed to build wallet"); 173 + let wallet = EthereumWallet::new(signer); 174 + let l1_provider = ProviderBuilder::default() 175 + .with_recommended_fillers() 176 + .wallet(wallet) 177 + .on_http( 178 + cfg.canonical_network.provider.rpc_endpoint.clone(), 179 + ); 180 + let state_bridge = IStateBridgeInstance::new( 181 + n.state_bridge_address, 182 + l1_provider, 183 + ); 184 + 185 + let signer = AlloySigner::new(state_bridge); 186 + 187 + relayers.push(Relayer::Evm(EVMRelay::new( 188 + Signer::AlloySigner(signer), 189 + n.world_id_address, 190 + n.provider.rpc_endpoint.clone(), 191 + ))); 192 + } 193 + WalletConfig::TxSitter { 194 + url, 195 + address: _, 196 + gas_limit, 197 + } => { 198 + let signer = TxSitterSigner::new( 199 + url.as_str(), 200 + n.state_bridge_address, 201 + *gas_limit, 202 + ); 203 + 204 + relayers.push(Relayer::Evm(EVMRelay::new( 205 + Signer::TxSitterSigner(signer), 206 + n.world_id_address, 207 + n.provider.rpc_endpoint.clone(), 208 + ))); 209 + } 210 + }; 211 ~ }); |

Ok(relayers)
}
23 changes: 13 additions & 10 deletions src/relay/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ pub(crate) trait RelaySigner {
async fn propagate_root(&self) -> Result<()>;
}

pub enum Signer {
Alloy(AlloySigner),
TxSitter(TxSitterSigner),
}

impl RelaySigner for Signer {
async fn propagate_root(&self) -> Result<()> {
match self {
Signer::Alloy(signer) => signer.propagate_root().await,
Signer::TxSitter(signer) => signer.propagate_root().await,
macro_rules! signer {
($($signer_type:ident),+ $(,)?) => {
pub enum Signer {
$($signer_type($signer_type),)+
}
impl RelaySigner for Signer {
async fn propagate_root(&self) -> Result<()> {
match self {
$(Signer::$signer_type(signer) => signer.propagate_root().await,)+
}
}
}
}
}
Expand Down Expand Up @@ -172,3 +173,5 @@ impl RelaySigner for TxSitterSigner {
Ok(())
}
}

signer!(AlloySigner, TxSitterSigner);
72 changes: 0 additions & 72 deletions src/transaction.rs

This file was deleted.

Loading