@@ -3,14 +3,14 @@ use std::sync::Arc;
33use ain_macros:: ocean_endpoint;
44use axum:: { extract:: Path , routing:: get, Extension , Router } ;
55use bitcoin:: Txid ;
6- use defichain_rpc:: { json:: governance:: * , Client , GovernanceRPC } ;
6+ use defichain_rpc:: { json:: governance:: * , GovernanceRPC } ;
77use serde:: Deserialize ;
88
99use super :: response:: { ApiPagedResponse , Response } ;
1010use crate :: {
1111 api_query:: { PaginationQuery , Query } ,
1212 error:: { ApiError , NotFoundKind , OceanError } ,
13- Result ,
13+ Result , Services ,
1414} ;
1515
1616#[ derive( Deserialize , Default ) ]
@@ -27,7 +27,7 @@ pub struct GovernanceQuery {
2727#[ ocean_endpoint]
2828async fn list_gov_proposals (
2929 Query ( query) : Query < GovernanceQuery > ,
30- Extension ( client ) : Extension < Arc < Client > > ,
30+ Extension ( services ) : Extension < Arc < Services > > ,
3131) -> Result < ApiPagedResponse < ProposalInfo > > {
3232 let size = match query. all {
3333 Some ( true ) => 0 ,
@@ -43,7 +43,7 @@ async fn list_gov_proposals(
4343 r#type : query. r#type ,
4444 cycle : query. cycle ,
4545 } ;
46- let proposals = client. list_gov_proposals ( Some ( opts) ) ?;
46+ let proposals = services . client . list_gov_proposals ( Some ( opts) ) ?;
4747
4848 Ok ( ApiPagedResponse :: of ( proposals, size, |proposal| {
4949 proposal. proposal_id . to_string ( )
@@ -53,21 +53,21 @@ async fn list_gov_proposals(
5353#[ ocean_endpoint]
5454async fn get_gov_proposal (
5555 Path ( proposal_id) : Path < String > ,
56- Extension ( client ) : Extension < Arc < Client > > ,
56+ Extension ( services ) : Extension < Arc < Services > > ,
5757) -> Result < Response < ProposalInfo > > {
5858 let txid: Txid = proposal_id
5959 . parse ( )
6060 . map_err ( |_| OceanError :: NotFound ( NotFoundKind :: Proposal ) ) ?;
6161
62- let proposal = client. get_gov_proposal ( txid) ?;
62+ let proposal = services . client . get_gov_proposal ( txid) ?;
6363 Ok ( Response :: new ( proposal) )
6464}
6565
6666#[ ocean_endpoint]
6767async fn list_gov_proposal_votes (
6868 Path ( proposal_id) : Path < String > ,
6969 Query ( query) : Query < GovernanceQuery > ,
70- Extension ( client ) : Extension < Arc < Client > > ,
70+ Extension ( services ) : Extension < Arc < Services > > ,
7171) -> Result < ApiPagedResponse < ListVotesResult > > {
7272 let proposal_id: Txid = proposal_id
7373 . parse ( )
@@ -96,7 +96,7 @@ async fn list_gov_proposal_votes(
9696 aggregate : None ,
9797 valid : None ,
9898 } ;
99- let votes = client. list_gov_proposal_votes ( Some ( opts) ) ?;
99+ let votes = services . client . list_gov_proposal_votes ( Some ( opts) ) ?;
100100 let len = votes. len ( ) ;
101101 Ok ( ApiPagedResponse :: of ( votes, size, |_| {
102102 if let Some ( next) = start {
@@ -107,10 +107,10 @@ async fn list_gov_proposal_votes(
107107 } ) )
108108}
109109
110- pub fn router ( state : Arc < Client > ) -> Router {
110+ pub fn router ( services : Arc < Services > ) -> Router {
111111 Router :: new ( )
112112 . route ( "/proposals" , get ( list_gov_proposals) )
113113 . route ( "/proposals/:id" , get ( get_gov_proposal) )
114114 . route ( "/proposals/:id/votes" , get ( list_gov_proposal_votes) )
115- . layer ( Extension ( state ) )
115+ . layer ( Extension ( services ) )
116116}
0 commit comments