From 010772dcf3db43d58d9066c8348cb80db928c981 Mon Sep 17 00:00:00 2001 From: Maxim Urschumzew Date: Tue, 29 Oct 2024 13:56:07 +0100 Subject: [PATCH] Add `open_btc_deposit_channels` method to broker api. --- api/bin/chainflip-broker-api/src/main.rs | 22 +++++++++++++++++++++- state-chain/custom-rpc/src/lib.rs | 4 +--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/api/bin/chainflip-broker-api/src/main.rs b/api/bin/chainflip-broker-api/src/main.rs index ceac4428735..d29c10af6a4 100644 --- a/api/bin/chainflip-broker-api/src/main.rs +++ b/api/bin/chainflip-broker-api/src/main.rs @@ -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}, @@ -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::ChainAccount>>; } pub struct RpcServerImpl { @@ -205,6 +211,20 @@ impl RpcServer for RpcServerImpl { .await .map_err(BrokerApiError::Other) } + + async fn open_btc_deposit_channels( + &self, + ) -> RpcResult::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)] diff --git a/state-chain/custom-rpc/src/lib.rs b/state-chain/custom-rpc/src/lib.rs index d9586a212dd..688caf5e21d 100644 --- a/state-chain/custom-rpc/src/lib.rs +++ b/state-chain/custom-rpc/src/lib.rs @@ -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)?), ) } }