Skip to content

Commit

Permalink
EVM: Add eth endpoints for the uniswap scritpt. (#827)
Browse files Browse the repository at this point in the history
* Add missing endpoints

* Add eth_accounts & eth_estimateGas

* eth_blockNumber not implemented
  • Loading branch information
bkolad authored and preston-evans98 committed Sep 14, 2023
1 parent 9e420b9 commit 95bed12
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions examples/demo-rollup/tests/evm/uniswap/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ module.exports = {
},
}
},
networks: {
sov: {
url: "http://127.0.0.1:12345"
},
},
};
1 change: 1 addition & 0 deletions full-node/sov-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ borsh = { workspace = true }
serde_json = { workspace = true }

reth-primitives = { workspace = true }
reth-rpc-types = { workspace = true }
reth-rpc = { workspace = true }

ethers = { workspace = true }
Expand Down
21 changes: 18 additions & 3 deletions full-node/sov-ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ pub mod experimental {
use ethers::types::{Bytes, H256};
use jsonrpsee::types::ErrorObjectOwned;
use jsonrpsee::RpcModule;
use reth_primitives::{Address, TransactionSignedNoHash as RethTransactionSignedNoHash};
use reth_primitives::{
Address as RethAddress, TransactionSignedNoHash as RethTransactionSignedNoHash,
};
use reth_rpc::eth::error::EthApiError;
use sov_evm::call::CallMessage;
use sov_evm::evm::RlpEvmTransaction;
Expand Down Expand Up @@ -48,15 +50,15 @@ pub mod experimental {
}

pub struct Ethereum<Da: DaService> {
nonces: Mutex<HashMap<Address, u64>>,
nonces: Mutex<HashMap<RethAddress, u64>>,
da_service: Da,
batch_builder: Arc<Mutex<EthBatchBuilder>>,
eth_rpc_config: EthRpcConfig,
}

impl<Da: DaService> Ethereum<Da> {
fn new(
nonces: Mutex<HashMap<Address, u64>>,
nonces: Mutex<HashMap<RethAddress, u64>>,
da_service: Da,
batch_builder: Arc<Mutex<EthBatchBuilder>>,
eth_rpc_config: EthRpcConfig,
Expand Down Expand Up @@ -169,6 +171,19 @@ pub mod experimental {
},
)?;

rpc.register_async_method("eth_accounts", |_parameters, _ethereum| async move {
#[allow(unreachable_code)]
Ok::<_, ErrorObjectOwned>(todo!())
})?;

rpc.register_async_method("eth_estimateGas", |parameters, _ethereum| async move {
let mut params = parameters.sequence();
let _data: reth_rpc_types::CallRequest = params.next()?;
let _block_number: Option<reth_primitives::BlockId> = params.optional_next()?;
#[allow(unreachable_code)]
Ok::<_, ErrorObjectOwned>(todo!())
})?;

Ok(())
}
}

0 comments on commit 95bed12

Please sign in to comment.