@@ -6,6 +6,8 @@ use mina_p2p_messages::v2::{
6
6
conv, LedgerHash , MinaBaseSignedCommandStableV2 , MinaBaseUserCommandStableV2 ,
7
7
MinaBaseZkappCommandTStableV1WireStableV1 , TokenIdKeyHash , TransactionHash ,
8
8
} ;
9
+ use mina_signer:: CompressedPubKey ;
10
+ use node:: rpc:: RpcSnarkerConfig ;
9
11
use node:: {
10
12
account:: AccountPublicKey ,
11
13
ledger:: read:: LedgerStatus ,
@@ -26,7 +28,7 @@ use openmina_core::{
26
28
NetworkConfig ,
27
29
} ;
28
30
use openmina_node_common:: rpc:: RpcSender ;
29
- use snark:: GraphQLPendingSnarkWork ;
31
+ use snark:: { GraphQLPendingSnarkWork , GraphQLSnarkWorker } ;
30
32
use std:: str:: FromStr ;
31
33
use tokio:: sync:: OnceCell ;
32
34
use transaction:: GraphQLTransactionStatus ;
@@ -41,6 +43,8 @@ pub mod transaction;
41
43
pub mod user_command;
42
44
pub mod zkapp;
43
45
46
+ pub type PublicKey = String ;
47
+
44
48
#[ derive( Debug , thiserror:: Error ) ]
45
49
pub enum Error {
46
50
#[ error( "Conversion error: {0}" ) ]
@@ -534,6 +538,34 @@ impl Query {
534
538
let res = BuildEnv :: get ( ) . git . commit_hash ;
535
539
Ok ( res)
536
540
}
541
+
542
+ async fn current_snark_worker (
543
+ & self ,
544
+ context : & Context ,
545
+ ) -> juniper:: FieldResult < Option < GraphQLSnarkWorker > > {
546
+ let config: Option < RpcSnarkerConfig > = context
547
+ . rpc_sender
548
+ . oneshot_request ( RpcRequest :: SnarkerConfig )
549
+ . await
550
+ . ok_or ( Error :: StateMachineEmptyResponse ) ?;
551
+
552
+ let Some ( config) = config else {
553
+ return Ok ( None ) ;
554
+ } ;
555
+
556
+ let account = context
557
+ . load_account ( AccountId {
558
+ public_key : CompressedPubKey :: try_from ( & config. public_key ) ?,
559
+ token_id : TokenIdKeyHash :: default ( ) . into ( ) ,
560
+ } )
561
+ . await ;
562
+
563
+ Ok ( Some ( GraphQLSnarkWorker {
564
+ key : config. public_key . to_string ( ) ,
565
+ account,
566
+ fee : config. fee . to_string ( ) ,
567
+ } ) )
568
+ }
537
569
}
538
570
539
571
async fn inject_tx < R > (
0 commit comments