Skip to content

Commit

Permalink
Add fee_info function
Browse files Browse the repository at this point in the history
  • Loading branch information
cwlittle committed Oct 28, 2023
1 parent 9612665 commit 9877aae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,21 @@ pub async fn capacity_limit() -> Result<u64, JsError> {
.await?)
}

#[wasm_bindgen(js_name = feeInfo)]
pub async fn fee_info() -> Result<FeeInfo, JsError> {
Ok(app_client()
.query(|app: InnerApp| {
let building = app.bitcoin.checkpoints.building()?;
let est_miner_fee =
building.fee_rate * app.bitcoin.checkpoints.active_sigset()?.est_witness_vsize();
Ok(FeeInfo {
bridgeFeeRate: 0.015,
minerFeeRate: est_miner_fee,
})
})
.await?)
}

#[wasm_bindgen(js_name = depositsEnabled)]
pub async fn deposits_enabled() -> Result<bool, JsError> {
Ok(app_client()
Expand Down
6 changes: 6 additions & 0 deletions wasm/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ pub struct DepositAddress {
pub expiration: u64,
}

#[wasm_bindgen(getter_with_clone)]
pub struct FeeInfo {
pub minerFeeRate: u64,
pub bridgeFeeRate: f32,
}

#[wasm_bindgen(getter_with_clone)]
pub struct ValidatorQueryInfo {
pub jailed: bool,
Expand Down

0 comments on commit 9877aae

Please sign in to comment.