diff --git a/api/src/common/query/mod.rs b/api/src/common/query/mod.rs index d0626bd4..3ee8d1f4 100644 --- a/api/src/common/query/mod.rs +++ b/api/src/common/query/mod.rs @@ -282,11 +282,27 @@ where self.fetch_from(&network).await } + /// Fetch the queries from the default mainnet archival network configuration. + pub async fn fetch_from_mainnet_archival( + self, + ) -> ResultWithMethod { + let network = NetworkConfig::mainnet_archival(); + self.fetch_from(&network).await + } + /// Fetch the queries from the default testnet network configuration. pub async fn fetch_from_testnet(self) -> ResultWithMethod { let network = NetworkConfig::testnet(); self.fetch_from(&network).await } + + /// Fetch the queries from the default testnet archival network configuration. + pub async fn fetch_from_testnet_archival( + self, + ) -> ResultWithMethod { + let network = NetworkConfig::testnet_archival(); + self.fetch_from(&network).await + } } pub struct RpcBuilder @@ -445,9 +461,25 @@ where self.fetch_from(&network).await } + /// Fetch the query from the default mainnet archival network configuration. + pub async fn fetch_from_mainnet_archival( + self, + ) -> ResultWithMethod { + let network = NetworkConfig::mainnet_archival(); + self.fetch_from(&network).await + } + /// Fetch the query from the default testnet network configuration. pub async fn fetch_from_testnet(self) -> ResultWithMethod { let network = NetworkConfig::testnet(); self.fetch_from(&network).await } + + /// Fetch the query from the default testnet archival network configuration. + pub async fn fetch_from_testnet_archival( + self, + ) -> ResultWithMethod { + let network = NetworkConfig::testnet_archival(); + self.fetch_from(&network).await + } } diff --git a/api/src/config.rs b/api/src/config.rs index 975a5702..06478645 100644 --- a/api/src/config.rs +++ b/api/src/config.rs @@ -59,11 +59,21 @@ impl RPCEndpoint { Self::new("https://free.rpc.fastnear.com".parse().unwrap()) } + /// Constructs default mainnet archival configuration. + pub fn mainnet_archival() -> Self { + Self::new("https://archival-rpc.mainnet.fastnear.com".parse().unwrap()) + } + /// Constructs default testnet configuration. pub fn testnet() -> Self { Self::new("https://test.rpc.fastnear.com".parse().unwrap()) } + /// Constructs default testnet archival configuration. + pub fn testnet_archival() -> Self { + Self::new("https://archival-rpc.testnet.fastnear.com".parse().unwrap()) + } + /// Set API key for the endpoint. pub fn with_api_key(mut self, api_key: String) -> Self { self.bearer_header = Some(format!("Bearer {api_key}")); @@ -177,6 +187,20 @@ impl NetworkConfig { } } + /// Constructs default mainnet archival configuration. + pub fn mainnet_archival() -> Self { + Self { + network_name: "mainnet-archival".to_string(), + rpc_endpoints: vec![RPCEndpoint::mainnet_archival()], + linkdrop_account_id: Some("near".parse().unwrap()), + near_social_db_contract_account_id: Some("social.near".parse().unwrap()), + faucet_url: None, + meta_transaction_relayer_url: None, + fastnear_url: Some("https://api.fastnear.com/".parse().unwrap()), + staking_pools_factory_account_id: Some("poolv1.near".parse().unwrap()), + } + } + /// Constructs default testnet configuration. pub fn testnet() -> Self { Self { @@ -191,6 +215,20 @@ impl NetworkConfig { } } + /// Constructs default testnet archival configuration. + pub fn testnet_archival() -> Self { + Self { + network_name: "testnet-archival".to_string(), + rpc_endpoints: vec![RPCEndpoint::testnet_archival()], + linkdrop_account_id: Some("testnet".parse().unwrap()), + near_social_db_contract_account_id: Some("v1.social08.testnet".parse().unwrap()), + faucet_url: Some("https://helper.nearprotocol.com/account".parse().unwrap()), + meta_transaction_relayer_url: None, + fastnear_url: None, + staking_pools_factory_account_id: Some("pool.f863973.m0".parse().unwrap()), + } + } + pub fn from_rpc_url(name: &str, rpc_url: Url) -> Self { Self { network_name: name.to_string(),