File tree Expand file tree Collapse file tree 5 files changed +39
-10
lines changed Expand file tree Collapse file tree 5 files changed +39
-10
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ name = "modify_campaign_request"
63
63
[[example ]]
64
64
name = " spender_response"
65
65
66
+ [[example ]]
67
+ name = " get_leaf_response"
68
+
66
69
[[example ]]
67
70
name = " validator_messages_create_request"
68
71
Original file line number Diff line number Diff line change
1
+ use primitives:: sentry:: GetLeafResponse ;
2
+ use serde_json:: { from_value, json} ;
3
+
4
+ fn main ( ) {
5
+ let json = json ! ( {
6
+ "merkleProof" : "8ea7760ca2dbbe00673372afbf8b05048717ce8a305f1f853afac8c244182e0c" ,
7
+ } ) ;
8
+
9
+ assert ! ( from_value:: <GetLeafResponse >( json) . is_ok( ) ) ;
10
+ }
Original file line number Diff line number Diff line change @@ -722,6 +722,13 @@ pub struct ValidationErrorResponse {
722
722
pub validation : Vec < String > ,
723
723
}
724
724
725
+ /// Returns the merkle_proof for the spender/earner
726
+ ///
727
+ /// # Examples
728
+ ///
729
+ /// ```
730
+ #[ doc = include_str ! ( "../examples/get_leaf_response.rs" ) ]
731
+ /// ```
725
732
#[ derive( Serialize , Deserialize , Debug ) ]
726
733
#[ serde( rename_all = "camelCase" ) ]
727
734
pub struct GetLeafResponse {
Original file line number Diff line number Diff line change 237
237
//! ```
238
238
//!
239
239
//!
240
- //! #### GET `/v5/channel/:id/get-leaf`
241
- //!
242
- //! TODO: implement and document as part of issue #382
240
+ //! #### GET `/v5/channel/:id/get-leaf/spender` and GET `/v5/channel/:id/get-leaf/earner`
243
241
//!
244
242
//! This route gets the latest approved state ([`NewState`]/[`ApproveState`] pair),
245
243
//! and finds the given `spender`/`earner` in the balances tree, and produce a merkle proof for it.
246
244
//! This is useful for the Platform to verify if a spender leaf really exists.
247
245
//!
248
- //! The route is handled by `todo`.
249
- //!
250
- //! Request query parameters:
251
- //!
252
- //! - `spender=[0x...]` or `earner=[0x...]` (required)
246
+ //! The route is handled by [`channel::get_leaf()`].
253
247
//!
254
248
//! Example Spender:
255
249
//!
256
- //! `/get-leaf? spender= 0x...`
250
+ //! `/get-leaf/ spender/ 0x...`
257
251
//!
258
252
//! Example Earner:
259
253
//!
260
- //! `/get-leaf?earner=0x....`
254
+ //! `/get-leaf/earner/0x....`
255
+ //!
256
+ //! Response: [`GetLeafResponse`](primitives::sentry::GetLeafResponse)
257
+ //!
258
+ //! ##### Examples:
259
+ //!
260
+ //! Response:
261
+ //!
262
+ //! ```
263
+ #![ doc = include_str ! ( "../../primitives/examples/spender_response.rs" ) ]
264
+ //! ```
265
+ //!
261
266
//! This module includes all routes for `Sentry` and the documentation of each Request/Response.
262
267
//!
263
268
//! #### POST `/v5/channel/dummy-deposit` (auth required)
Original file line number Diff line number Diff line change @@ -504,6 +504,10 @@ pub async fn channel_payout<C: Locked + 'static>(
504
504
Ok ( Json ( SuccessResponse { success : true } ) )
505
505
}
506
506
507
+ /// GET `/v5/channel/0xXXX.../get-leaf/spender` request and
508
+ /// GET `/v5/channel/0xXXX.../get-leaf/earner` request
509
+ ///
510
+ /// Response: [`GetLeafResponse`]
507
511
pub async fn get_leaf < C : Locked + ' static > (
508
512
Extension ( app) : Extension < Arc < Application < C > > > ,
509
513
Extension ( channel_context) : Extension < ChainOf < Channel > > ,
You can’t perform that action at this time.
0 commit comments