From 0831932abe64314f929a7a03612c992e82d9f33d Mon Sep 17 00:00:00 2001 From: bitful-pannul Date: Tue, 7 May 2024 16:22:30 -0400 Subject: [PATCH] fakechain: update local address --- .../packages/app_store/app_store/src/lib.rs | 5 +++- .../kns_indexer/kns_indexer/src/lib.rs | 23 +++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/kinode/packages/app_store/app_store/src/lib.rs b/kinode/packages/app_store/app_store/src/lib.rs index 63d39a75..2198597e 100644 --- a/kinode/packages/app_store/app_store/src/lib.rs +++ b/kinode/packages/app_store/app_store/src/lib.rs @@ -39,14 +39,17 @@ use ft_worker_lib::{ const ICON: &str = include_str!("icon"); +#[cfg(not(feature = "simulation-mode"))] const CHAIN_ID: u64 = 10; // optimism #[cfg(feature = "simulation-mode")] const CHAIN_ID: u64 = 31337; // local +#[cfg(not(feature = "simulation-mode"))] const CONTRACT_ADDRESS: &str = "0x52185B6a6017E6f079B994452F234f7C2533787B"; // optimism #[cfg(feature = "simulation-mode")] -const CONTRACT_ADDRESS: &str = "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6"; // local +const CONTRACT_ADDRESS: &str = "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"; // local +#[cfg(not(feature = "simulation-mode"))] const CONTRACT_FIRST_BLOCK: u64 = 118_590_088; #[cfg(feature = "simulation-mode")] const CONTRACT_FIRST_BLOCK: u64 = 1; diff --git a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs index 14ccd9ed..17c8891f 100644 --- a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs +++ b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs @@ -14,17 +14,20 @@ wit_bindgen::generate!({ world: "process", }); -const KNS_ADDRESS: &'static str = "0xca5b5811c0c40aab3295f932b1b5112eb7bb4bd6"; +#[cfg(not(feature = "simulation-mode"))] +const KNS_ADDRESS: &'static str = "0xca5b5811c0c40aab3295f932b1b5112eb7bb4bd6"; // optimism #[cfg(feature = "simulation-mode")] -const KNS_ADDRESS: &'static str = "0x5FbDB2315678afecb367f032d93F642f64180aa3"; +const KNS_ADDRESS: &'static str = "0x5FbDB2315678afecb367f032d93F642f64180aa3"; // local -const CHAIN_ID: u64 = 10; +#[cfg(not(feature = "simulation-mode"))] +const CHAIN_ID: u64 = 10; // optimism #[cfg(feature = "simulation-mode")] -const CHAIN_ID: u64 = 31337; +const CHAIN_ID: u64 = 31337; // local -const KNS_FIRST_BLOCK: u64 = 114_923_786; +#[cfg(not(feature = "simulation-mode"))] +const KNS_FIRST_BLOCK: u64 = 114_923_786; // optimism #[cfg(feature = "simulation-mode")] -const KNS_FIRST_BLOCK: u64 = 1; +const KNS_FIRST_BLOCK: u64 = 1; // local #[derive(Clone, Debug, Serialize, Deserialize)] struct State { @@ -123,17 +126,17 @@ fn subscribe_to_logs(eth_provider: ð::Provider, from_block: u64, filter: eth: call_init!(init); fn init(our: Address) { - println!("indexing on contract address {}", KNS_CONTRACT_ADDRESS); + println!("indexing on contract address {}", KNS_ADDRESS); // if we have state, load it in let state: State = match get_typed_state(|bytes| Ok(bincode::deserialize::(bytes)?)) { Some(s) => { // if chain id or contract address changed from a previous run, reset state - if s.chain_id != CHAIN_ID || s.contract_address != KNS_CONTRACT_ADDRESS { + if s.chain_id != CHAIN_ID || s.contract_address != KNS_ADDRESS { println!("resetting state because runtime contract address or chain ID changed"); State { chain_id: CHAIN_ID, - contract_address: KNS_CONTRACT_ADDRESS, + contract_address: KNS_ADDRESS.to_string(), names: HashMap::new(), nodes: HashMap::new(), block: KNS_FIRST_BLOCK, @@ -145,7 +148,7 @@ fn init(our: Address) { } None => State { chain_id: CHAIN_ID, - contract_address: KNS_CONTRACT_ADDRESS, + contract_address: KNS_ADDRESS.to_string(), names: HashMap::new(), nodes: HashMap::new(), block: KNS_FIRST_BLOCK,