Skip to content

Commit 5e24bd0

Browse files
authored
Accept, Reject Offer and Mint on Accept (#528)
1 parent b8ba3e7 commit 5e24bd0

File tree

12 files changed

+417
-265
lines changed

12 files changed

+417
-265
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Added timestamps for status
66
* Call mint endpoint for cancelling
77
* Use mint nostr relays from network and fall back to identity ones
8+
* Add endpoints to accept, or reject an offer from a mint
89

910
# 0.3.13
1011

crates/bcr-ebill-api/src/external/mint.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ impl MintClientApi for MintClient {
149149
Ok(reply.into())
150150
}
151151

152-
#[allow(dead_code)]
153152
async fn resolve_quote_for_mint(
154153
&self,
155154
mint_url: &str,

crates/bcr-ebill-api/src/service/bill_service/error.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ pub enum Error {
6666
#[error("Mint request can only be cancelled if it's pending.")]
6767
CancelMintRequestNotPending,
6868

69+
/// errors that stem from trying to reject a mint request that's not offered
70+
#[error("Mint request can only be rejected if it's offered.")]
71+
RejectMintRequestNotOffered,
72+
73+
/// errors that stem from trying to accept a mint request that's not offered
74+
#[error("Mint request can only be accepted if it's offered.")]
75+
AcceptMintRequestNotOffered,
76+
77+
/// errors that stem from trying to accept a mint request that's expired
78+
#[error("Mint request can only be accepted if it's not expired.")]
79+
AcceptMintOfferExpired,
80+
6981
/// errors that stem from bill validation errors
7082
#[error("bill validation error {0}")]
7183
Validation(#[from] bcr_ebill_core::ValidationError),

crates/bcr-ebill-api/src/service/bill_service/mod.rs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,6 @@ pub trait BillServiceApi: ServiceTraitBounds {
110110
timestamp: u64,
111111
) -> Result<BillBlockchain>;
112112

113-
/// request to mint a bill
114-
async fn request_to_mint(
115-
&self,
116-
bill_id: &str,
117-
mint_node_id: &str,
118-
signer_public_data: &BillParticipant,
119-
signer_keys: &BcrKeys,
120-
timestamp: u64,
121-
) -> Result<()>;
122-
123113
/// Check payment status of bills that are requested to pay and not expired and not paid yet, updating their
124114
/// paid status if they were paid
125115
async fn check_bills_payment(&self) -> Result<()>;
@@ -180,6 +170,19 @@ pub trait BillServiceApi: ServiceTraitBounds {
180170
current_identity_node_id: &str,
181171
) -> Result<Vec<Endorsement>>;
182172

173+
/// Clear the bill cache
174+
async fn clear_bill_cache(&self) -> Result<()>;
175+
176+
/// request to mint a bill
177+
async fn request_to_mint(
178+
&self,
179+
bill_id: &str,
180+
mint_node_id: &str,
181+
signer_public_data: &BillParticipant,
182+
signer_keys: &BcrKeys,
183+
timestamp: u64,
184+
) -> Result<()>;
185+
183186
/// Returns the mint state for a given bill
184187
async fn get_mint_state(
185188
&self,
@@ -194,14 +197,27 @@ pub trait BillServiceApi: ServiceTraitBounds {
194197
current_identity_node_id: &str,
195198
) -> Result<()>;
196199

200+
/// Accept a mint offer for a given request to mint
201+
async fn accept_mint_offer(
202+
&self,
203+
mint_request_id: &str,
204+
signer_public_data: &BillParticipant,
205+
signer_keys: &BcrKeys,
206+
timestamp: u64,
207+
) -> Result<()>;
208+
209+
/// Reject a mint offer for a given request to mint
210+
async fn reject_mint_offer(
211+
&self,
212+
mint_request_id: &str,
213+
current_identity_node_id: &str,
214+
) -> Result<()>;
215+
197216
/// Check mint state for a given bill
198217
async fn check_mint_state(&self, bill_id: &str, current_identity_node_id: &str) -> Result<()>;
199218

200219
/// Check mint state for all bills
201220
async fn check_mint_state_for_all_bills(&self) -> Result<()>;
202-
203-
/// Clear the bill cache
204-
async fn clear_bill_cache(&self) -> Result<()>;
205221
}
206222

207223
#[cfg(test)]

0 commit comments

Comments
 (0)