canic_core/workflow/icrc/
query.rs1use crate::{
8 config::Config,
9 dispatch::icrc21::Icrc21Dispatcher,
10 domain::icrc::icrc10::supported_standards,
11 dto::icrc21::{ConsentMessageRequest, ConsentMessageResponse},
12 ops::runtime::env::EnvOps,
13};
14
15pub struct Icrc10Query;
20
21impl Icrc10Query {
22 #[must_use]
23 pub fn supported_standards() -> Vec<(String, String)> {
24 let icrc21_enabled = Config::try_get().is_some_and(|cfg| {
25 let global_standards = cfg.standards.as_ref();
26 let canister_standards = EnvOps::component_spec().ok().and_then(|component_spec| {
27 EnvOps::canister_role().ok().and_then(|canister_role| {
28 cfg.component_specs
29 .get(&component_spec)?
30 .get_canister(&canister_role)
31 .map(|canister_cfg| canister_cfg.standards)
32 })
33 });
34
35 global_standards.is_some_and(|standards| standards.icrc21)
36 && canister_standards.is_some_and(|standards| standards.icrc21)
37 });
38
39 supported_standards(icrc21_enabled)
40 }
41}
42
43pub struct Icrc21Query;
48
49impl Icrc21Query {
50 #[must_use]
51 pub fn consent_message(req: ConsentMessageRequest) -> ConsentMessageResponse {
52 Icrc21Dispatcher::consent_message(req)
53 }
54}