canic_core/api/rpc/
mod.rs1mod capability;
2
3use crate::{
4 cdk::{candid::CandidType, types::Principal},
5 dto::{
6 capability::{RootCapabilityEnvelopeV1, RootCapabilityResponseV1},
7 error::Error,
8 rpc::{CreateCanisterParent, CreateCanisterResponse, UpgradeCanisterResponse},
9 },
10 ids::CanisterRole,
11 workflow::rpc::request::RpcRequestWorkflow,
12};
13
14pub struct RpcApi;
34
35impl RpcApi {
36 pub async fn create_canister_request<A>(
37 canister_role: &CanisterRole,
38 parent: CreateCanisterParent,
39 extra: Option<A>,
40 ) -> Result<CreateCanisterResponse, Error>
41 where
42 A: CandidType + Send + Sync,
43 {
44 RpcRequestWorkflow::create_canister_request(canister_role, parent, extra)
45 .await
46 .map_err(Error::from)
47 }
48
49 pub async fn upgrade_canister_request(
50 canister_pid: Principal,
51 ) -> Result<UpgradeCanisterResponse, Error> {
52 RpcRequestWorkflow::upgrade_canister_request(canister_pid)
53 .await
54 .map_err(Error::from)
55 }
56
57 pub async fn response_capability_v1(
58 envelope: RootCapabilityEnvelopeV1,
59 ) -> Result<RootCapabilityResponseV1, Error> {
60 capability::response_capability_v1(envelope).await
61 }
62}