Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
cache-on-failure: true
- name: cargo hack
run: |
cargo hack build --workspace --target wasm32-unknown-unknown --exclude op-alloy-network --exclude op-alloy-rpc-jsonrpsee --exclude op-alloy-provider
cargo hack build --workspace --target wasm32-unknown-unknown --exclude op-alloy-network --exclude op-alloy-rpc-jsonrpsee --exclude op-alloy-provider --exclude op-alloy-rpc-types

wasm-wasi:
runs-on: ubuntu-latest
Expand Down
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ tokio = "1"
rstest = "0.24.0"

[patch.crates-io]
# alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
# alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
# alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
# alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
# alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
# alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
# alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
# alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
# alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
# alloy-network-primitives = { git = "https://github.com/alloy-rs/alloy", rev = "2390e6cd5" }
alloy-eips = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
alloy-serde = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
alloy-signer = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
alloy-network = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
alloy-provider = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
alloy-transport = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
alloy-consensus = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
alloy-rpc-types-eth = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
alloy-rpc-types-engine = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
alloy-network-primitives = { git = "https://github.com/lean-apple/alloy.git", branch = "tx-builder-split" }
2 changes: 1 addition & 1 deletion crates/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ workspace = true
[dependencies]
# Workspace
op-alloy-consensus = { workspace = true, features = ["alloy-compat"] }
op-alloy-rpc-types.workspace = true
op-alloy-rpc-types = { workspace = true, features = ["std"] }

# Alloy
alloy-consensus.workspace = true
Expand Down
109 changes: 2 additions & 107 deletions crates/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
pub use alloy_network::*;

use alloy_consensus::{ReceiptWithBloom, TxEnvelope, TxType, TypedTransaction};
use alloy_primitives::{Address, Bytes, ChainId, TxKind, U256};
use alloy_rpc_types_eth::AccessList;
use alloy_primitives::Address;
use op_alloy_consensus::{OpReceipt, OpTxEnvelope, OpTxType, OpTypedTransaction};
use op_alloy_rpc_types::OpTransactionRequest;

Expand Down Expand Up @@ -43,103 +42,7 @@ impl Network for Optimism {
alloy_rpc_types_eth::Block<Self::TransactionResponse, Self::HeaderResponse>;
}

impl TransactionBuilder<Optimism> for OpTransactionRequest {
fn chain_id(&self) -> Option<ChainId> {
self.as_ref().chain_id()
}

fn set_chain_id(&mut self, chain_id: ChainId) {
self.as_mut().set_chain_id(chain_id);
}

fn nonce(&self) -> Option<u64> {
self.as_ref().nonce()
}

fn set_nonce(&mut self, nonce: u64) {
self.as_mut().set_nonce(nonce);
}

fn take_nonce(&mut self) -> Option<u64> {
self.as_mut().nonce.take()
}

fn input(&self) -> Option<&Bytes> {
self.as_ref().input()
}

fn set_input<T: Into<Bytes>>(&mut self, input: T) {
self.as_mut().set_input(input);
}

fn from(&self) -> Option<Address> {
self.as_ref().from()
}

fn set_from(&mut self, from: Address) {
self.as_mut().set_from(from);
}

fn kind(&self) -> Option<TxKind> {
self.as_ref().kind()
}

fn clear_kind(&mut self) {
self.as_mut().clear_kind();
}

fn set_kind(&mut self, kind: TxKind) {
self.as_mut().set_kind(kind);
}

fn value(&self) -> Option<U256> {
self.as_ref().value()
}

fn set_value(&mut self, value: U256) {
self.as_mut().set_value(value);
}

fn gas_price(&self) -> Option<u128> {
self.as_ref().gas_price()
}

fn set_gas_price(&mut self, gas_price: u128) {
self.as_mut().set_gas_price(gas_price);
}

fn max_fee_per_gas(&self) -> Option<u128> {
self.as_ref().max_fee_per_gas()
}

fn set_max_fee_per_gas(&mut self, max_fee_per_gas: u128) {
self.as_mut().set_max_fee_per_gas(max_fee_per_gas);
}

fn max_priority_fee_per_gas(&self) -> Option<u128> {
self.as_ref().max_priority_fee_per_gas()
}

fn set_max_priority_fee_per_gas(&mut self, max_priority_fee_per_gas: u128) {
self.as_mut().set_max_priority_fee_per_gas(max_priority_fee_per_gas);
}

fn gas_limit(&self) -> Option<u64> {
self.as_ref().gas_limit()
}

fn set_gas_limit(&mut self, gas_limit: u64) {
self.as_mut().set_gas_limit(gas_limit);
}

fn access_list(&self) -> Option<&AccessList> {
self.as_ref().access_list()
}

fn set_access_list(&mut self, access_list: AccessList) {
self.as_mut().set_access_list(access_list);
}

impl NetworkTransactionBuilder<Optimism> for OpTransactionRequest {
fn complete_type(&self, ty: OpTxType) -> Result<(), Vec<&'static str>> {
match ty {
OpTxType::Deposit => Err(vec!["not implemented for deposit tx"]),
Expand All @@ -150,14 +53,6 @@ impl TransactionBuilder<Optimism> for OpTransactionRequest {
}
}

fn can_submit(&self) -> bool {
self.as_ref().can_submit()
}

fn can_build(&self) -> bool {
self.as_ref().can_build()
}

#[doc(alias = "output_transaction_type")]
fn output_tx_type(&self) -> OpTxType {
match self.as_ref().preferred_type() {
Expand Down
2 changes: 2 additions & 0 deletions crates/rpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ op-alloy-consensus = { workspace = true, features = ["serde"] }
# Alloy
alloy-serde.workspace = true
alloy-consensus.workspace = true
alloy-network = { workspace = true, optional = true }
alloy-network-primitives.workspace = true
alloy-eips = { workspace = true, features = ["serde"] }
alloy-rpc-types-eth = { workspace = true, features = ["serde"] }
Expand Down Expand Up @@ -51,6 +52,7 @@ similar-asserts.workspace = true
[features]
default = ["std"]
std = [
"dep:alloy-network",
"alloy-network-primitives/std",
"alloy-eips/std",
"alloy-primitives/std",
Expand Down
112 changes: 112 additions & 0 deletions crates/rpc-types/src/builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
//! Transaction builder for [`OpTransactionRequest`].

use crate::OpTransactionRequest;
use alloy_network::TransactionBuilder;
use alloy_primitives::{Address, Bytes, ChainId, TxKind, U256};
use alloy_rpc_types_eth::AccessList;

impl TransactionBuilder for OpTransactionRequest {
fn chain_id(&self) -> Option<ChainId> {
self.as_ref().chain_id()
}

fn set_chain_id(&mut self, chain_id: ChainId) {
self.as_mut().set_chain_id(chain_id);
}

fn nonce(&self) -> Option<u64> {
self.as_ref().nonce()
}

fn set_nonce(&mut self, nonce: u64) {
self.as_mut().set_nonce(nonce);
}

fn take_nonce(&mut self) -> Option<u64> {
self.as_mut().nonce.take()
}

fn input(&self) -> Option<&Bytes> {
self.as_ref().input()
}

fn set_input<T: Into<Bytes>>(&mut self, input: T) {
self.as_mut().set_input(input);
}

fn from(&self) -> Option<Address> {
self.as_ref().from()
}

fn set_from(&mut self, from: Address) {
self.as_mut().set_from(from);
}

fn kind(&self) -> Option<TxKind> {
self.as_ref().kind()
}

fn clear_kind(&mut self) {
self.as_mut().clear_kind();
}

fn set_kind(&mut self, kind: TxKind) {
self.as_mut().set_kind(kind);
}

fn value(&self) -> Option<U256> {
self.as_ref().value()
}

fn set_value(&mut self, value: U256) {
self.as_mut().set_value(value);
}

fn gas_price(&self) -> Option<u128> {
self.as_ref().gas_price()
}

fn set_gas_price(&mut self, gas_price: u128) {
self.as_mut().set_gas_price(gas_price);
}

fn max_fee_per_gas(&self) -> Option<u128> {
self.as_ref().max_fee_per_gas()
}

fn set_max_fee_per_gas(&mut self, max_fee_per_gas: u128) {
self.as_mut().set_max_fee_per_gas(max_fee_per_gas);
}

fn max_priority_fee_per_gas(&self) -> Option<u128> {
self.as_ref().max_priority_fee_per_gas()
}

fn set_max_priority_fee_per_gas(&mut self, max_priority_fee_per_gas: u128) {
self.as_mut().set_max_priority_fee_per_gas(max_priority_fee_per_gas);
}

fn gas_limit(&self) -> Option<u64> {
self.as_ref().gas_limit()
}

fn set_gas_limit(&mut self, gas_limit: u64) {
self.as_mut().set_gas_limit(gas_limit);
}

fn access_list(&self) -> Option<&AccessList> {
self.as_ref().access_list()
}

fn set_access_list(&mut self, access_list: AccessList) {
self.as_mut().set_access_list(access_list);
}

fn can_submit(&self) -> bool {
self.as_ref().can_submit()
}

fn can_build(&self) -> bool {
self.as_ref().can_build()
}
}
3 changes: 3 additions & 0 deletions crates/rpc-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ pub use receipt::{L1BlockInfo, OpTransactionReceipt, OpTransactionReceiptFields}
mod transaction;
pub use transaction::{OpTransactionFields, OpTransactionRequest, Transaction};

#[cfg(feature = "std")]
mod builder;

pub mod error;
pub use error::SuperchainDAError;