ic_query/icrc/model/contracts/requests/
account.rs1use super::IcrcLedgerRequest;
8
9#[derive(Clone, Debug, Eq, PartialEq)]
16pub struct IcrcBalanceRequest {
17 pub ledger: IcrcLedgerRequest,
19 pub account_owner: String,
20 pub subaccount_hex: Option<String>,
21}
22
23impl IcrcBalanceRequest {
24 #[must_use]
25 pub fn new(ledger: IcrcLedgerRequest, account_owner: impl Into<String>) -> Self {
26 Self {
27 ledger,
28 account_owner: account_owner.into(),
29 subaccount_hex: None,
30 }
31 }
32
33 #[must_use]
34 pub fn with_subaccount_hex(mut self, subaccount_hex: impl Into<String>) -> Self {
35 self.subaccount_hex = Some(subaccount_hex.into());
36 self
37 }
38}
39
40#[derive(Clone, Debug, Eq, PartialEq)]
47pub struct IcrcAllowanceRequest {
48 pub ledger: IcrcLedgerRequest,
50 pub account_owner: String,
51 pub account_subaccount_hex: Option<String>,
52 pub spender_owner: String,
53 pub spender_subaccount_hex: Option<String>,
54}
55
56impl IcrcAllowanceRequest {
57 #[must_use]
58 pub fn new(
59 ledger: IcrcLedgerRequest,
60 account_owner: impl Into<String>,
61 spender_owner: impl Into<String>,
62 ) -> Self {
63 Self {
64 ledger,
65 account_owner: account_owner.into(),
66 account_subaccount_hex: None,
67 spender_owner: spender_owner.into(),
68 spender_subaccount_hex: None,
69 }
70 }
71
72 #[must_use]
73 pub fn with_account_subaccount_hex(
74 mut self,
75 account_subaccount_hex: impl Into<String>,
76 ) -> Self {
77 self.account_subaccount_hex = Some(account_subaccount_hex.into());
78 self
79 }
80
81 #[must_use]
82 pub fn with_spender_subaccount_hex(
83 mut self,
84 spender_subaccount_hex: impl Into<String>,
85 ) -> Self {
86 self.spender_subaccount_hex = Some(spender_subaccount_hex.into());
87 self
88 }
89}