@@ -12,7 +12,7 @@ use std::sync::Arc;
1212use sp_api:: ProvideRuntimeApi ;
1313
1414pub use subtensor_custom_rpc_runtime_api:: {
15- DelegateInfoRuntimeApi , NeuronInfoRuntimeApi , SubnetInfoRuntimeApi ,
15+ ColdkeySwapRuntimeApi , DelegateInfoRuntimeApi , NeuronInfoRuntimeApi , SubnetInfoRuntimeApi ,
1616 SubnetRegistrationRuntimeApi ,
1717} ;
1818
@@ -51,6 +51,24 @@ pub trait SubtensorCustomApi<BlockHash> {
5151
5252 #[ method( name = "subnetInfo_getLockCost" ) ]
5353 fn get_network_lock_cost ( & self , at : Option < BlockHash > ) -> RpcResult < u64 > ;
54+ #[ method( name = "coldkeySwap_getScheduledColdkeySwap" ) ]
55+ fn get_scheduled_coldkey_swap (
56+ & self ,
57+ coldkey_account_vec : Vec < u8 > ,
58+ at : Option < BlockHash > ,
59+ ) -> RpcResult < Vec < u8 > > ;
60+ #[ method( name = "coldkeySwap_getRemainingArbitrationPeriod" ) ]
61+ fn get_remaining_arbitration_period (
62+ & self ,
63+ coldkey_account_vec : Vec < u8 > ,
64+ at : Option < BlockHash > ,
65+ ) -> RpcResult < Vec < u8 > > ;
66+ #[ method( name = "coldkeySwap_getColdkeySwapDestinations" ) ]
67+ fn get_coldkey_swap_destinations (
68+ & self ,
69+ coldkey_account_vec : Vec < u8 > ,
70+ at : Option < BlockHash > ,
71+ ) -> RpcResult < Vec < u8 > > ;
5472}
5573
5674pub struct SubtensorCustom < C , P > {
99117 C :: Api : NeuronInfoRuntimeApi < Block > ,
100118 C :: Api : SubnetInfoRuntimeApi < Block > ,
101119 C :: Api : SubnetRegistrationRuntimeApi < Block > ,
120+ C :: Api : ColdkeySwapRuntimeApi < Block > ,
102121{
103122 fn get_delegates ( & self , at : Option < <Block as BlockT >:: Hash > ) -> RpcResult < Vec < u8 > > {
104123 let api = self . client . runtime_api ( ) ;
@@ -223,4 +242,51 @@ where
223242 Error :: RuntimeError ( format ! ( "Unable to get subnet lock cost: {:?}" , e) ) . into ( )
224243 } )
225244 }
245+
246+ fn get_scheduled_coldkey_swap (
247+ & self ,
248+ coldkey_account_vec : Vec < u8 > ,
249+ at : Option < <Block as BlockT >:: Hash > ,
250+ ) -> RpcResult < Vec < u8 > > {
251+ let api = self . client . runtime_api ( ) ;
252+ let at = at. unwrap_or_else ( || self . client . info ( ) . best_hash ) ;
253+
254+ api. get_scheduled_coldkey_swap ( at, coldkey_account_vec)
255+ . map_err ( |e| {
256+ Error :: RuntimeError ( format ! ( "Unable to get scheduled coldkey swap: {:?}" , e) ) . into ( )
257+ } )
258+ }
259+
260+ fn get_remaining_arbitration_period (
261+ & self ,
262+ coldkey_account_vec : Vec < u8 > ,
263+ at : Option < <Block as BlockT >:: Hash > ,
264+ ) -> RpcResult < Vec < u8 > > {
265+ let api = self . client . runtime_api ( ) ;
266+ let at = at. unwrap_or_else ( || self . client . info ( ) . best_hash ) ;
267+
268+ api. get_remaining_arbitration_period ( at, coldkey_account_vec)
269+ . map_err ( |e| {
270+ Error :: RuntimeError ( format ! (
271+ "Unable to get remaining arbitration period: {:?}" ,
272+ e
273+ ) )
274+ . into ( )
275+ } )
276+ }
277+
278+ fn get_coldkey_swap_destinations (
279+ & self ,
280+ coldkey_account_vec : Vec < u8 > ,
281+ at : Option < <Block as BlockT >:: Hash > ,
282+ ) -> RpcResult < Vec < u8 > > {
283+ let api = self . client . runtime_api ( ) ;
284+ let at = at. unwrap_or_else ( || self . client . info ( ) . best_hash ) ;
285+
286+ api. get_coldkey_swap_destinations ( at, coldkey_account_vec)
287+ . map_err ( |e| {
288+ Error :: RuntimeError ( format ! ( "Unable to get coldkey swap destinations: {:?}" , e) )
289+ . into ( )
290+ } )
291+ }
226292}
0 commit comments