graph_native/contract.rs
1use crate::abi::DecodedParam;
2use crate::types::{Address, BigInt};
3
4/// Result of a try_call — mirrors graph-ts ethereum.CallResult
5pub struct CallResult {
6 pub reverted: bool,
7 pub value: DecodedParam,
8}
9
10/// Bound contract for making eth_call.
11///
12/// PHASE C BLOCKER: call() and try_call() are stubs returning fake values.
13/// They need graph-node's EthereumAdapter (or the HostFn interface) to make
14/// real eth_call RPC requests. This requires:
15/// - Access to the chain adapter via HostFn[] passed through MappingContext
16/// - The block pointer for the call context
17/// - ABI encoding/decoding of function args and return values
18///
19/// Until Phase C wiring, any handler using Contract.call/try_call will get
20/// wrong results. The transpiler's call-graph analysis already marks these
21/// handlers as unsupported (WASM fallback), so stubs are never hit in practice.
22///
23/// Tests for contract calls are also blocked on Phase C — they require a
24/// running Ethereum node or mock adapter.
25pub struct Contract {
26 #[allow(dead_code)]
27 contract_type: String,
28 #[allow(dead_code)]
29 address: Address,
30}
31
32impl Contract {
33 pub fn bind(contract_type: &str, address: &Address) -> Self {
34 Contract {
35 contract_type: contract_type.to_string(),
36 address: address.clone(),
37 }
38 }
39
40 /// STUB: Always returns zero. Phase C will wire to EthereumAdapter via HostFn.
41 pub fn call(&self, _method: &str, _args: &[DecodedParam]) -> DecodedParam {
42 DecodedParam::Uint(BigInt::zero())
43 }
44
45 /// STUB: Always returns reverted. Phase C will wire to EthereumAdapter via HostFn.
46 pub fn try_call(&self, _method: &str, _args: &[DecodedParam]) -> CallResult {
47 CallResult {
48 reverted: true,
49 value: DecodedParam::Uint(BigInt::zero()),
50 }
51 }
52}