spark_rust/wallet/utils/
mutations.rs

1pub(crate) const REQUEST_LIGHTNING_RECEIVE_MUTATION: &str = r#"
2        mutation RequestLightningReceive(
3            $network: BitcoinNetwork!
4            $amount_sats: Long!
5            $payment_hash: Hash32!
6            $expiry_secs: Int
7            $memo: String
8        ) {
9            request_lightning_receive(input: {
10                network: $network
11                amount_sats: $amount_sats
12                payment_hash: $payment_hash
13                expiry_secs: $expiry_secs
14                memo: $memo
15            }) {
16                request {
17                    id
18                    created_at
19                    updated_at
20                    invoice {
21                        encoded_envoice
22                    }
23                    fee {
24                        original_value
25                        original_unit
26                    }
27                }
28            }
29        }"#;
30
31pub(crate) const REQUEST_LIGHTNING_SEND_MUTATION: &str = r#"
32        mutation RequestLightningSend($encoded_invoice: String!, $idempotency_key: String!) {
33            request_lightning_send(input: {
34                encoded_invoice: $encoded_invoice,
35                idempotency_key: $idempotency_key
36            }) {
37                request {
38                    id
39                    created_at
40                    updated_at
41                    encoded_invoice
42                    fee {
43                        original_value
44                        original_unit
45                    }
46                    status
47                }
48            }
49        }"#;
50
51pub(crate) const REQUEST_LEAVES_SWAP_MUTATION: &str = r#"
52        mutation RequestLeavesSwap(
53            $adaptor_pubkey: String!
54            $total_amount_sats: Long!
55            $target_amount_sats: Long!
56            $fee_sats: Long!
57            $user_leaves: [UserLeafInput!]!
58        ) {
59            request_leaves_swap(input: {
60                adaptor_pubkey: $adaptor_pubkey
61                total_amount_sats: $total_amount_sats
62                target_amount_sats: $target_amount_sats
63                fee_sats: $fee_sats
64                user_leaves: $user_leaves
65            }) {
66                request {
67                    id
68                    swap_leaves {
69                        leaf_id
70                        raw_unsigned_refund_transaction
71                        adaptor_signed_signature
72                    }
73                }
74            }
75        }"#;
76
77pub(crate) const COMPLETE_LEAVES_SWAP_MUTATION: &str = r#"
78        mutation CompleteLeavesSwap(
79            $adaptor_secret_key: String!
80            $user_outbound_transfer_external_id: UUID!
81            $leaves_swap_request_id: ID!
82        ) {
83            complete_leaves_swap(input: {
84                adaptor_secret_key: $adaptor_secret_key
85                user_outbound_transfer_external_id: $user_outbound_transfer_external_id
86                leaves_swap_request_id: $leaves_swap_request_id
87            }) {
88                request {
89                    id
90                }
91            }
92        }"#;
93
94pub(crate) const REQUEST_COOP_EXIT_MUTATION: &str = r#"
95        mutation RequestCoopExit(
96            $leaf_external_ids: [UUID!]!
97            $withdrawal_address: String!
98        ) {
99            request_coop_exit(input: {
100                leaf_external_ids: $leaf_external_ids
101                withdrawal_address: $withdrawal_address
102            }) {
103                request {
104                    id
105                    created_at
106                    updated_at
107                    fee {
108                        original_value
109                        original_unit
110                    }
111                    status
112                    raw_connector_transaction
113                    expires_at
114                }
115            }
116        }"#;
117
118pub(crate) const COMPLETE_COOP_EXIT_MUTATION: &str = r#"
119        mutation CompleteCoopExit(
120            $user_outbound_transfer_external_id: UUID!
121            $coop_exit_request_id: ID!
122        ) {
123            complete_coop_exit(input: {
124                user_outbound_transfer_external_id: $user_outbound_transfer_external_id
125                coop_exit_request_id: $coop_exit_request_id
126            }) {
127                request {
128                    id
129                    status
130                    created_at
131                    updated_at
132                }
133            }
134        }"#;
135
136pub(crate) const GET_LIGHTNING_RECEIVE_FEE_ESTIMATE_QUERY: &str = r#"
137        query GetLightningReceiveFeeEstimate($network: BitcoinNetwork!, $amount_sats: Long!) {
138            lightning_receive_fee_estimate(input: {
139                network: $network,
140                amount_sats: $amount_sats
141            }) {
142                fee_estimate {
143                    original_value
144                    original_unit
145                }
146            }
147        }"#;
148
149pub(crate) const GET_LIGHTNING_SEND_FEE_ESTIMATE_QUERY: &str = r#"
150        query GetLightningSendFeeEstimate($encoded_invoice: String!) {
151            lightning_send_fee_estimate(input: {
152                encoded_invoice: $encoded_invoice
153            }) {
154                fee_estimate {
155                    original_value
156                    original_unit
157                }
158            }
159        }"#;
160
161pub(crate) const GET_COOP_EXIT_FEE_ESTIMATE_QUERY: &str = r#"
162        query GetCoopExitFeeEstimate(
163          $leaf_external_ids: [UUID!]!
164          $withdrawal_address: String!
165        ) {
166          coop_exit_fee_estimate(input: {
167            leaf_external_ids: $leaf_external_ids
168            withdrawal_address: $withdrawal_address
169          }) {
170            fee_estimate {
171              original_value
172              original_unit
173            }
174          }
175        }"#;
176
177pub(crate) const GET_LEAVES_SWAP_FEE_ESTIMATE_QUERY: &str = r#"
178        query LeavesSwapFeeEstimate($total_amount_sats: Int!) {
179            leaves_swap_fee_estimate(input: {
180                total_amount_sats: $total_amount_sats
181            }) {
182                fee_estimate {
183                    original_value
184                    original_unit
185                    preferred_currency_unit
186                    preferred_currency_value_rounded
187                    preferred_currency_value_approx
188                }
189            }
190        }"#;