Skip to content

Commit

Permalink
Add open_btc_deposit_channels method to broker api.
Browse files Browse the repository at this point in the history
  • Loading branch information
MxmUrw committed Oct 29, 2024
1 parent 9ea7e6f commit 010772d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 21 additions & 1 deletion api/bin/chainflip-broker-api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use chainflip_api::{
primitives::{AccountRole, Affiliates, Asset, BasisPoints, CcmChannelMetadata, DcaParameters},
settings::StateChain,
AccountId32, AddressString, BrokerApi, DepositMonitorApi, OperatorApi, RefundParameters,
StateChainApi, SwapDepositAddress, SwapPayload, WithdrawFeesDetail,
SignedExtrinsicApi, StateChainApi, SwapDepositAddress, SwapPayload, WithdrawFeesDetail,
};
use clap::Parser;
use custom_rpc::CustomApiClient;
use futures::FutureExt;
use jsonrpsee::{
core::{async_trait, ClientError},
Expand Down Expand Up @@ -103,6 +104,11 @@ pub trait Rpc {

#[method(name = "mark_btc_transaction_as_tainted", aliases = ["broker_markBtcTransactionAsTainted"])]
async fn mark_btc_transaction_as_tainted(&self, tx_id: cf_chains::btc::Hash) -> RpcResult<()>;

#[method(name = "open_btc_deposit_channels", aliases = ["broker_openBtcDepositChannels"])]
async fn open_btc_deposit_channels(
&self,
) -> RpcResult<Vec<<cf_chains::Bitcoin as cf_chains::Chain>::ChainAccount>>;
}

pub struct RpcServerImpl {
Expand Down Expand Up @@ -205,6 +211,20 @@ impl RpcServer for RpcServerImpl {
.await
.map_err(BrokerApiError::Other)
}

async fn open_btc_deposit_channels(
&self,
) -> RpcResult<Vec<<cf_chains::Bitcoin as cf_chains::Chain>::ChainAccount>> {
let account_id = self.api.state_chain_client.account_id();

self.api
.state_chain_client
.base_rpc_client
.raw_rpc_client
.cf_open_btc_deposit_channels(account_id, None)
.await
.map_err(BrokerApiError::ClientError)
}
}

#[derive(Parser, Debug, Clone, Default)]
Expand Down
4 changes: 1 addition & 3 deletions state-chain/custom-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,9 +1751,7 @@ where
false, /* only_on_changes */
true, /* end_on_error */
sink,
|client, hash| {
Ok(client.runtime_api().cf_tainted_btc_transaction_events(hash)?)
},
|client, hash| Ok(client.runtime_api().cf_tainted_btc_transaction_events(hash)?),
)
}
}
Expand Down

0 comments on commit 010772d

Please sign in to comment.