@@ -688,6 +688,13 @@ pub async fn channel_payout<C: Locked + 'static>(
688
688
} ) ?) )
689
689
}
690
690
691
+ /// POST `/v5/channel/dummy-deposit` request
692
+ ///
693
+ /// Full details about the route's API and intend can be found in the [`routes`](crate::routes#post-v5channeldummy-deposit-auth-required) module
694
+ ///
695
+ /// Request body (json): [`ChannelDummyDeposit`]
696
+ ///
697
+ /// Response: [`SuccessResponse`]
691
698
pub async fn channel_dummy_deposit_axum < C : Locked + ' static > (
692
699
Extension ( app) : Extension < Arc < Application < C > > > ,
693
700
Extension ( auth) : Extension < Auth > ,
@@ -778,7 +785,10 @@ pub async fn channel_dummy_deposit<C: Locked + 'static>(
778
785
/// starting with `/v5/channel/0xXXX.../validator-messages`
779
786
///
780
787
pub mod validator_message {
788
+ use std:: sync:: Arc ;
789
+
781
790
use crate :: {
791
+ application:: Qs ,
782
792
db:: validator_message:: { get_validator_messages, insert_validator_message} ,
783
793
Auth ,
784
794
} ;
@@ -787,15 +797,17 @@ pub mod validator_message {
787
797
Application ,
788
798
} ;
789
799
use adapter:: client:: Locked ;
800
+ use axum:: { extract:: Path , Extension , Json } ;
790
801
use futures:: future:: try_join_all;
791
802
use hyper:: { Body , Request , Response } ;
792
803
use primitives:: {
793
804
sentry:: {
794
805
SuccessResponse , ValidatorMessagesCreateRequest , ValidatorMessagesListQuery ,
795
806
ValidatorMessagesListResponse ,
796
807
} ,
797
- ChainOf , Channel , DomainError , ValidatorId ,
808
+ ChainOf , Channel , ChannelId , DomainError , ValidatorId ,
798
809
} ;
810
+ use serde:: Deserialize ;
799
811
800
812
pub fn extract_params (
801
813
from_path : & str ,
@@ -827,6 +839,72 @@ pub mod validator_message {
827
839
Ok ( ( validator_id, message_types. unwrap_or_default ( ) ) )
828
840
}
829
841
842
+ #[ derive( Debug , Deserialize ) ]
843
+ pub struct MessagesListParams {
844
+ pub id : ChannelId ,
845
+ // Optional filtering by ValidatorId
846
+ #[ serde( default ) ]
847
+ pub address : Option < ValidatorId > ,
848
+ /// List of validator message types separated by `+` (urlencoded):
849
+ /// e.g. `ApproveState+NewState`
850
+ #[ serde( default ) ]
851
+ pub message_types : String ,
852
+ }
853
+
854
+ /// GET `/v5/channel/0xXXX.../validator-messages`
855
+ ///
856
+ /// Full details about the route's API and intend can be found in the [`routes`](crate::routes#get-v5channelidvalidator-messages) module
857
+ ///
858
+ /// Request query parameters: [`ValidatorMessagesListQuery`]
859
+ ///
860
+ /// Response: [`ValidatorMessagesListResponse`]
861
+ ///
862
+ pub async fn list_validator_messages_axum < C : Locked + ' static > (
863
+ Extension ( app) : Extension < Arc < Application < C > > > ,
864
+ Extension ( channel_context) : Extension < ChainOf < Channel > > ,
865
+ Path ( params) : Path < MessagesListParams > ,
866
+ Qs ( query) : Qs < ValidatorMessagesListQuery > ,
867
+ ) -> Result < Json < ValidatorMessagesListResponse > , ResponseError > {
868
+ let message_types = {
869
+ // We need to strip the `/` prefix from axum
870
+ let stripped = params
871
+ . message_types
872
+ . strip_prefix ( '/' )
873
+ . unwrap_or ( & params. message_types ) ;
874
+
875
+ if !stripped. is_empty ( ) {
876
+ stripped
877
+ . split ( '+' )
878
+ . map ( |s| s. to_string ( ) )
879
+ . collect :: < Vec < _ > > ( )
880
+ } else {
881
+ vec ! [ ]
882
+ }
883
+ } ;
884
+
885
+ let channel = channel_context. context ;
886
+
887
+ let config_limit = app. config . msgs_find_limit as u64 ;
888
+ let limit = query
889
+ . limit
890
+ . filter ( |n| * n >= 1 )
891
+ . unwrap_or ( config_limit)
892
+ . min ( config_limit) ;
893
+
894
+ let validator_messages = get_validator_messages (
895
+ & app. pool ,
896
+ & channel. id ( ) ,
897
+ & params. address ,
898
+ & message_types,
899
+ limit,
900
+ )
901
+ . await ?;
902
+
903
+ Ok ( Json ( ValidatorMessagesListResponse {
904
+ messages : validator_messages,
905
+ } ) )
906
+ }
907
+
830
908
/// GET `/v5/channel/0xXXX.../validator-messages`
831
909
///
832
910
/// Full details about the route's API and intend can be found in the [`routes`](crate::routes#get-v5channelidvalidator-messages) module
0 commit comments