fedimint_gwv2_client/
api.rs
1use fedimint_api_client::api::{FederationApiExt, FederationResult, IModuleFederationApi};
2use fedimint_core::module::ApiRequestErased;
3use fedimint_core::task::{MaybeSend, MaybeSync};
4use fedimint_core::{OutPoint, apply, async_trait_maybe_send};
5use fedimint_lnv2_common::ContractId;
6use fedimint_lnv2_common::endpoint_constants::OUTGOING_CONTRACT_EXPIRATION_ENDPOINT;
7
8#[apply(async_trait_maybe_send!)]
9pub trait GatewayFederationApi {
10 async fn outgoing_contract_expiration(
11 &self,
12 outpoint: OutPoint,
13 ) -> FederationResult<Option<(ContractId, u64)>>;
14}
15
16#[apply(async_trait_maybe_send!)]
17impl<T: ?Sized> GatewayFederationApi for T
18where
19 T: IModuleFederationApi + MaybeSend + MaybeSync + 'static,
20{
21 async fn outgoing_contract_expiration(
22 &self,
23 outpoint: OutPoint,
24 ) -> FederationResult<Option<(ContractId, u64)>> {
25 self.request_current_consensus(
26 OUTGOING_CONTRACT_EXPIRATION_ENDPOINT.to_string(),
27 ApiRequestErased::new(outpoint),
28 )
29 .await
30 }
31}