Skip to content

Commit d874174

Browse files
committed
runtime: Pass EnsLookup to host exports
1 parent 1ea500d commit d874174

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

runtime/test/src/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ fn mock_host_exports(
5050
}];
5151

5252
let network = data_source.network.clone().unwrap();
53+
let ens_lookup = store.ens_lookup();
5354
HostExports::new(
5455
subgraph_id,
5556
&data_source,
5657
network,
5758
Arc::new(templates),
5859
Arc::new(graph_core::LinkResolver::from(IpfsClient::localhost())),
5960
store,
61+
ens_lookup,
6062
)
6163
}
6264

runtime/wasm/src/host.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use futures03::channel::oneshot::channel;
88
use graph::blockchain::RuntimeAdapter;
99
use graph::blockchain::{Blockchain, DataSource};
1010
use graph::blockchain::{HostFn, TriggerWithHandler};
11-
use graph::components::store::SubgraphStore;
11+
use graph::components::store::{EnsLookup, SubgraphStore};
1212
use graph::components::subgraph::{MappingError, SharedProofOfIndexing};
1313
use graph::prelude::{
1414
RuntimeHost as RuntimeHostTrait, RuntimeHostBuilder as RuntimeHostBuilderTrait, *,
@@ -100,6 +100,7 @@ impl<C: Blockchain> RuntimeHostBuilderTrait<C> for RuntimeHostBuilder<C> {
100100
templates,
101101
mapping_request_sender,
102102
metrics,
103+
self.store.ens_lookup(),
103104
)
104105
}
105106
}
@@ -126,6 +127,7 @@ where
126127
templates: Arc<Vec<C::DataSourceTemplate>>,
127128
mapping_request_sender: Sender<MappingRequest<C>>,
128129
metrics: Arc<HostMetrics>,
130+
ens_lookup: Arc<dyn EnsLookup>,
129131
) -> Result<Self, Error> {
130132
// Create new instance of externally hosted functions invoker. The `Arc` is simply to avoid
131133
// implementing `Clone` for `HostExports`.
@@ -136,6 +138,7 @@ where
136138
templates,
137139
link_resolver,
138140
store,
141+
ens_lookup,
139142
));
140143

141144
let host_fns = Arc::new(runtime_adapter.host_fns(&data_source)?);

runtime/wasm/src/host_exports.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::{error::DeterminismLevel, module::IntoTrap};
22
use graph::blockchain::DataSource;
33
use graph::blockchain::{Blockchain, DataSourceTemplate as _};
4-
use graph::components::store::EntityKey;
54
use graph::components::store::EntityType;
5+
use graph::components::store::{EnsLookup, EntityKey};
66
use graph::components::subgraph::{CausalityRegion, ProofOfIndexingEvent, SharedProofOfIndexing};
77
use graph::data::store;
88
use graph::prelude::ethabi::param_type::Reader;
@@ -69,6 +69,7 @@ pub struct HostExports<C: Blockchain> {
6969
templates: Arc<Vec<C::DataSourceTemplate>>,
7070
pub(crate) link_resolver: Arc<dyn LinkResolver>,
7171
store: Arc<dyn SubgraphStore>,
72+
ens_lookup: Arc<dyn EnsLookup>,
7273
}
7374

7475
impl<C: Blockchain> HostExports<C> {
@@ -79,6 +80,7 @@ impl<C: Blockchain> HostExports<C> {
7980
templates: Arc<Vec<C::DataSourceTemplate>>,
8081
link_resolver: Arc<dyn LinkResolver>,
8182
store: Arc<dyn SubgraphStore>,
83+
ens_lookup: Arc<dyn EnsLookup>,
8284
) -> Self {
8385
Self {
8486
subgraph_id,
@@ -91,6 +93,7 @@ impl<C: Blockchain> HostExports<C> {
9193
templates,
9294
link_resolver,
9395
store,
96+
ens_lookup,
9497
}
9598
}
9699

@@ -670,7 +673,7 @@ impl<C: Blockchain> HostExports<C> {
670673
}
671674

672675
pub(crate) fn ens_name_by_hash(&self, hash: &str) -> Result<Option<String>, anyhow::Error> {
673-
Ok(self.store.find_ens_name(hash)?)
676+
Ok(self.ens_lookup.find_name(hash)?)
674677
}
675678

676679
pub(crate) fn log_log(

0 commit comments

Comments
 (0)