Skip to content

Commit 449c214

Browse files
author
Adrian Nagy
committed
feat(graphql): Add networkID and version queries
1 parent 2dd3d26 commit 449c214

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

node/native/src/graphql/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ use node::{
1515
SyncStatsQuery,
1616
},
1717
stats::sync::SyncKind,
18+
BuildEnv,
1819
};
1920
use o1_utils::field_helpers::FieldHelpersError;
2021
use openmina_core::{
21-
block::AppliedBlock, consensus::ConsensusConstants, constants::constraint_constants,
22+
block::AppliedBlock, consensus::ConsensusConstants, constants::constraint_constants, NetworkConfig
2223
};
2324
use openmina_node_common::rpc::RpcSender;
2425
use snark::GraphQLPendingSnarkWork;
@@ -27,6 +28,7 @@ use transaction::GraphQLTransactionStatus;
2728
use warp::{Filter, Rejection, Reply};
2829
use zkapp::GraphQLZkapp;
2930

31+
3032
pub mod account;
3133
pub mod block;
3234
pub mod constants;
@@ -433,6 +435,19 @@ impl Query {
433435
.map(GraphQLPendingSnarkWork::try_from)
434436
.collect::<Result<Vec<_>, _>>()?)
435437
}
438+
439+
/// The chain-agnostic identifier of the network
440+
#[graphql(name = "networkID")]
441+
async fn network_id(_context: &Context) -> juniper::FieldResult<String> {
442+
let res = format!("mina:{}", NetworkConfig::global().name);
443+
Ok(res)
444+
}
445+
446+
/// The version of the node (git commit hash)
447+
async fn version(_context: &Context) -> juniper::FieldResult<String> {
448+
let res = BuildEnv::get().git.commit_hash;
449+
Ok(res)
450+
}
436451
}
437452

438453
async fn inject_tx<R>(

0 commit comments

Comments
 (0)