Skip to content

Commit 8f7c03c

Browse files
committed
deploy success
1 parent f1dbb13 commit 8f7c03c

3 files changed

Lines changed: 24 additions & 37 deletions

File tree

cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async fn main() -> anyhow::Result<()> {
113113
} => {
114114
let wallet = get_wallet_from_keystore(path.as_str(), password).await?;
115115
let addr = deployer::deploy_contract(&contract, provider, wallet).await?;
116-
println!("Deployed `{}` at {}\n", contract, addr);
116+
println!("Deployed `{}` at {:?}\n", contract, addr);
117117
}
118118
Commands::Compile => {
119119
println!("Compiling contract...");

core/src/deployer.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
use crate::artifacts;
22
use anyhow::Result;
3-
use ethers::{abi::Token, prelude::*};
3+
use ethers::prelude::*;
44
use std::sync::Arc;
55

66
pub async fn deploy_contract(
77
contract_name: &str,
88
provider: Provider<Http>,
99
wallet: LocalWallet,
1010
) -> Result<Address> {
11-
let endpoint_address = "0x0000000000000000000000000000000000000001".parse::<Address>()?;
12-
let constructor_args = vec![
13-
abi::Token::Address(endpoint_address),
14-
abi::Token::Address(endpoint_address),
15-
];
11+
// TODO Extract
12+
let endpoint_address = "0x6EDCE65403992e310A62460808c4b910D972f10f".parse::<Address>()?;
13+
let delegator_address = "0x6EDCE65403992e310A62460808c4b910D972f10f".parse::<Address>()?;
1614

17-
let abi = artifacts::load_abi(contract_name)?;
18-
let bytecode = artifacts::load_bytecode(contract_name)?;
19-
println!("ABI {:?}\nBytecode {:?}", abi, bytecode);
20-
let client = Arc::new(SignerMiddleware::new(provider, wallet));
21-
22-
let factory = ContractFactory::new(abi, bytecode, Arc::new(client.clone()));
15+
// FIXME abi is not used, is replaced by abigen! macro. Remove from artifacts module
16+
// let abi = artifacts::load_abi(contract_name)?;
17+
// TODO Move closer to artifact reading
18+
abigen!(MyOApp, "core/src/solidity/artifacts/MyOApp.sol/MyOApp.json");
2319

24-
println!("Factory {:?}", factory);
20+
// FIXME bytecode is not used, is replaced by abigen! macro. Remove from artifacts module
21+
// let bytecode = artifacts::load_bytecode(contract_name)?;
22+
let client = Arc::new(SignerMiddleware::new(provider, wallet));
2523

26-
let deployed = factory.deploy(constructor_args)?.send().await?;
24+
// Tuples are used.
25+
let deployed = MyOApp::deploy(client, (endpoint_address, delegator_address))
26+
.map_err(|e| {
27+
println!("Deployment preparation error: {:?}", e);
28+
anyhow::Error::from(e)
29+
})?
30+
.send()
31+
.await
32+
.map_err(|e| {
33+
println!("Deployment execution error: {:?}", e);
34+
anyhow::Error::from(e)
35+
})?;
2736

2837
Ok(deployed.address())
2938
}

core/src/solidity/contracts/SimpleIncrement.sol

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)