Skip to content

Commit 76a2e0e

Browse files
authored
feat: added default archival rpc (#138)
1 parent 0a1db8a commit 76a2e0e

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

api/src/common/query/mod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,27 @@ where
282282
self.fetch_from(&network).await
283283
}
284284

285+
/// Fetch the queries from the default mainnet archival network configuration.
286+
pub async fn fetch_from_mainnet_archival(
287+
self,
288+
) -> ResultWithMethod<Handler::Response, Query::Error> {
289+
let network = NetworkConfig::mainnet_archival();
290+
self.fetch_from(&network).await
291+
}
292+
285293
/// Fetch the queries from the default testnet network configuration.
286294
pub async fn fetch_from_testnet(self) -> ResultWithMethod<Handler::Response, Query::Error> {
287295
let network = NetworkConfig::testnet();
288296
self.fetch_from(&network).await
289297
}
298+
299+
/// Fetch the queries from the default testnet archival network configuration.
300+
pub async fn fetch_from_testnet_archival(
301+
self,
302+
) -> ResultWithMethod<Handler::Response, Query::Error> {
303+
let network = NetworkConfig::testnet_archival();
304+
self.fetch_from(&network).await
305+
}
290306
}
291307

292308
pub struct RpcBuilder<Query, Handler>
@@ -445,9 +461,25 @@ where
445461
self.fetch_from(&network).await
446462
}
447463

464+
/// Fetch the query from the default mainnet archival network configuration.
465+
pub async fn fetch_from_mainnet_archival(
466+
self,
467+
) -> ResultWithMethod<Handler::Response, Query::Error> {
468+
let network = NetworkConfig::mainnet_archival();
469+
self.fetch_from(&network).await
470+
}
471+
448472
/// Fetch the query from the default testnet network configuration.
449473
pub async fn fetch_from_testnet(self) -> ResultWithMethod<Handler::Response, Query::Error> {
450474
let network = NetworkConfig::testnet();
451475
self.fetch_from(&network).await
452476
}
477+
478+
/// Fetch the query from the default testnet archival network configuration.
479+
pub async fn fetch_from_testnet_archival(
480+
self,
481+
) -> ResultWithMethod<Handler::Response, Query::Error> {
482+
let network = NetworkConfig::testnet_archival();
483+
self.fetch_from(&network).await
484+
}
453485
}

api/src/config.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,21 @@ impl RPCEndpoint {
5959
Self::new("https://free.rpc.fastnear.com".parse().unwrap())
6060
}
6161

62+
/// Constructs default mainnet archival configuration.
63+
pub fn mainnet_archival() -> Self {
64+
Self::new("https://archival-rpc.mainnet.fastnear.com".parse().unwrap())
65+
}
66+
6267
/// Constructs default testnet configuration.
6368
pub fn testnet() -> Self {
6469
Self::new("https://test.rpc.fastnear.com".parse().unwrap())
6570
}
6671

72+
/// Constructs default testnet archival configuration.
73+
pub fn testnet_archival() -> Self {
74+
Self::new("https://archival-rpc.testnet.fastnear.com".parse().unwrap())
75+
}
76+
6777
/// Set API key for the endpoint.
6878
pub fn with_api_key(mut self, api_key: String) -> Self {
6979
self.bearer_header = Some(format!("Bearer {api_key}"));
@@ -177,6 +187,20 @@ impl NetworkConfig {
177187
}
178188
}
179189

190+
/// Constructs default mainnet archival configuration.
191+
pub fn mainnet_archival() -> Self {
192+
Self {
193+
network_name: "mainnet-archival".to_string(),
194+
rpc_endpoints: vec![RPCEndpoint::mainnet_archival()],
195+
linkdrop_account_id: Some("near".parse().unwrap()),
196+
near_social_db_contract_account_id: Some("social.near".parse().unwrap()),
197+
faucet_url: None,
198+
meta_transaction_relayer_url: None,
199+
fastnear_url: Some("https://api.fastnear.com/".parse().unwrap()),
200+
staking_pools_factory_account_id: Some("poolv1.near".parse().unwrap()),
201+
}
202+
}
203+
180204
/// Constructs default testnet configuration.
181205
pub fn testnet() -> Self {
182206
Self {
@@ -191,6 +215,20 @@ impl NetworkConfig {
191215
}
192216
}
193217

218+
/// Constructs default testnet archival configuration.
219+
pub fn testnet_archival() -> Self {
220+
Self {
221+
network_name: "testnet-archival".to_string(),
222+
rpc_endpoints: vec![RPCEndpoint::testnet_archival()],
223+
linkdrop_account_id: Some("testnet".parse().unwrap()),
224+
near_social_db_contract_account_id: Some("v1.social08.testnet".parse().unwrap()),
225+
faucet_url: Some("https://helper.nearprotocol.com/account".parse().unwrap()),
226+
meta_transaction_relayer_url: None,
227+
fastnear_url: None,
228+
staking_pools_factory_account_id: Some("pool.f863973.m0".parse().unwrap()),
229+
}
230+
}
231+
194232
pub fn from_rpc_url(name: &str, rpc_url: Url) -> Self {
195233
Self {
196234
network_name: name.to_string(),

0 commit comments

Comments
 (0)