Skip to content

Commit eb3e299

Browse files
committed
ChannelPayRequest examples
1 parent 299adfd commit eb3e299

File tree

5 files changed

+31
-49
lines changed

5 files changed

+31
-49
lines changed

primitives/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ required-features = ["test-util"]
4444
name = "channel_list_query"
4545
required-features = ["test-util"]
4646

47+
[[example]]
48+
name = "channel_pay_request"
49+
4750
[[example]]
4851
name = "create_campaign_request"
4952
required-features = ["test-util"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use primitives::sentry::ChannelPayRequest;
2+
use serde_json::json;
3+
use std::str::FromStr;
4+
5+
fn main() {
6+
let channel_pay_json = json!({
7+
"payouts": {
8+
"0x80690751969B234697e9059e04ed72195c3507fa": "10000000000",
9+
"0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7": "20000000000",
10+
"0x0e880972A4b216906F05D67EeaaF55d16B5EE4F1": "30000000000",
11+
},
12+
});
13+
14+
let channel_pay_json = serde_json::to_string(&channel_pay_json).expect("should serialize");
15+
16+
assert!(serde_json::from_str::<ChannelPayRequest>(&channel_pay_json).is_ok());
17+
}

primitives/examples/validator_messages_create_request.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

primitives/src/sentry.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,13 @@ pub struct AllSpendersQuery {
633633
pub page: u64,
634634
}
635635

636+
/// Includes all the payouts that need to be done for that channel
637+
///
638+
/// # Examples
639+
///
640+
/// ```
641+
#[doc = include_str!("../examples/channel_pay_request.rs")]
642+
/// ```
636643
#[derive(Debug, Serialize, Deserialize)]
637644
pub struct ChannelPayRequest {
638645
pub payouts: UnifiedMap,

sentry/src/routes.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@
155155
//!
156156
//! The route is handled by [`channel::channel_payout()`].
157157
//!
158-
//! Request JSON body: [`ChannelPayRequest`](primitives::sentry::ChannelPayRequest)
158+
//! Request JSON body:
159159
//!
160+
//! ```
161+
#![doc = include_str!("../../primitives/examples/channel_pay_request.rs")]
162+
//! ```
160163
//! Response: [`SuccessResponse`](primitives::sentry::SuccessResponse)
161164
//!
162165
//!

0 commit comments

Comments
 (0)