Skip to content

Commit d9c4ecd

Browse files
committed
graph, chain/ethereum: migrate ContractCall to use alloy address
1 parent 2e97467 commit d9c4ecd

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

chain/ethereum/src/ethereum_adapter.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,7 @@ impl EthereumAdapter {
615615
.input(TransactionInput::both(alloy::primitives::Bytes::from(
616616
call_data.encoded_call.to_vec(),
617617
)))
618-
.to(alloy::primitives::Address::from(
619-
call_data.address.as_fixed_bytes(),
620-
));
618+
.to(call_data.address);
621619

622620
if let Some(gas) = gas {
623621
req = req.gas_limit(gas as u64);

chain/ethereum/src/runtime/runtime_adapter.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use graph::data::store::scalar::BigInt;
1616
use graph::data::subgraph::API_VERSION_0_0_9;
1717
use graph::data_source;
1818
use graph::data_source::common::{ContractCall, MappingABI};
19-
use graph::prelude::web3::types::Address;
2019
use graph::runtime::gas::Gas;
2120
use graph::runtime::{AscIndexId, IndexForAscTypeId};
2221
use graph::slog::debug;
@@ -390,7 +389,7 @@ fn eth_call(
390389
#[derive(Clone, Debug)]
391390
pub struct UnresolvedContractCall {
392391
pub contract_name: String,
393-
pub contract_address: Address,
392+
pub contract_address: alloy::primitives::Address,
394393
pub function_name: String,
395394
pub function_signature: Option<String>,
396395
pub function_args: Vec<abi::DynSolValue>,

graph/src/cheap_clone.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,4 @@ cheap_clone_is_copy!(
119119
std::time::Duration
120120
);
121121
cheap_clone_is_copy!(web3::types::Address);
122+
cheap_clone_is_copy!(alloy::primitives::Address);

graph/src/data/store/ethereum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ pub mod call {
104104
/// on the call's return value
105105
#[derive(Debug, Clone, CheapClone)]
106106
pub struct Request {
107-
pub address: web3::types::Address,
107+
pub address: alloy::primitives::Address,
108108
pub encoded_call: Arc<Bytes>,
109109
/// The index is set by the caller and is used to identify the
110110
/// request in related data structures that the caller might have
111111
pub index: u32,
112112
}
113113

114114
impl Request {
115-
pub fn new(address: web3::types::Address, encoded_call: Vec<u8>, index: u32) -> Self {
115+
pub fn new(address: alloy::primitives::Address, encoded_call: Vec<u8>, index: u32) -> Self {
116116
Request {
117117
address,
118118
encoded_call: Arc::new(Bytes::from(encoded_call)),

graph/src/data_source/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ impl DeclaredCall {
643643
(
644644
ContractCall {
645645
contract_name: self.contract_name,
646-
address: self.address,
646+
address: alloy::primitives::Address::from(self.address.as_fixed_bytes()),
647647
block_ptr,
648648
function: self.function,
649649
args: self.args,
@@ -656,7 +656,7 @@ impl DeclaredCall {
656656
#[derive(Clone, Debug)]
657657
pub struct ContractCall {
658658
pub contract_name: String,
659-
pub address: Address,
659+
pub address: alloy::primitives::Address,
660660
pub block_ptr: BlockPtr,
661661
pub function: abi::Function,
662662
pub args: Vec<abi::DynSolValue>,

store/test-store/tests/postgres/chain_head.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ use graph::futures03::executor;
99
use std::future::Future;
1010
use std::sync::Arc;
1111

12+
use graph::cheap_clone::CheapClone;
1213
use graph::prelude::web3::types::H256;
14+
use graph::prelude::{alloy, serde_json as json, EthereumBlock};
1315
use graph::prelude::{anyhow::anyhow, anyhow::Error};
14-
use graph::prelude::{serde_json as json, EthereumBlock};
1516
use graph::prelude::{BlockNumber, QueryStoreManager, QueryTarget};
16-
use graph::{cheap_clone::CheapClone, prelude::web3::types::H160};
1717
use graph::{components::store::BlockStore as _, prelude::DeploymentHash};
1818
use graph::{
1919
components::store::ChainHeadStore as _, components::store::ChainStore as _,
@@ -430,7 +430,9 @@ fn eth_call_cache() {
430430
call::Retval::Value(Bytes::from(value))
431431
}
432432

433-
let address = H160([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
433+
let address = alloy::primitives::Address::from_slice(&[
434+
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
435+
]);
434436
let call: [u8; 6] = [1, 2, 3, 4, 5, 6];
435437
let return_value: [u8; 3] = [7, 8, 9];
436438

0 commit comments

Comments
 (0)