Skip to main content

canic_core/api/
icp_refill.rs

1use crate::{
2    dto::{
3        error::Error,
4        icp_refill::{IcpRefillEndpointResponse, IcpRefillRequest},
5    },
6    workflow::ic::icp_refill::IcpRefillWorkflow,
7};
8
9///
10/// IcpRefillApi
11///
12
13pub struct IcpRefillApi;
14
15impl IcpRefillApi {
16    pub async fn refill(request: IcpRefillRequest) -> Result<IcpRefillEndpointResponse, Error> {
17        if request.dry_run {
18            return IcpRefillWorkflow::dry_run_manual_refill(request)
19                .await
20                .map(IcpRefillEndpointResponse::DryRun)
21                .map_err(Error::from);
22        }
23
24        IcpRefillWorkflow::execute_manual_refill(request)
25            .await
26            .map(IcpRefillEndpointResponse::Refill)
27            .map_err(Error::from)
28    }
29}