canic_core/workflow/icrc/
query.rs1use crate::{
2 cdk::spec::standards::icrc::icrc21::{ConsentMessageRequest, ConsentMessageResponse},
3 config::Config,
4 dispatch::icrc21::Icrc21Dispatcher,
5 domain::icrc::icrc10::Icrc10Registry,
6 ops::runtime::env::EnvOps,
7};
8
9pub struct Icrc10Query;
14
15impl Icrc10Query {
16 #[must_use]
17 pub fn supported_standards() -> Vec<(String, String)> {
18 let (icrc21_enabled, icrc103_enabled) = Config::try_get().map_or((false, false), |cfg| {
19 let global_standards = cfg.standards.as_ref();
20 let canister_standards = EnvOps::subnet_role().ok().and_then(|subnet_role| {
21 EnvOps::canister_role().ok().and_then(|canister_role| {
22 cfg.subnets
23 .get(&subnet_role)?
24 .canisters
25 .get(&canister_role)
26 .map(|canister_cfg| &canister_cfg.standards)
27 })
28 });
29
30 (
31 global_standards.is_some_and(|standards| standards.icrc21)
32 && canister_standards.is_some_and(|standards| standards.icrc21),
33 global_standards.is_some_and(|standards| standards.icrc103),
34 )
35 });
36
37 Icrc10Registry::supported_standards(icrc21_enabled, icrc103_enabled)
38 }
39}
40
41pub struct Icrc21Query;
46
47impl Icrc21Query {
48 #[must_use]
49 pub fn consent_message(req: ConsentMessageRequest) -> ConsentMessageResponse {
50 Icrc21Dispatcher::consent_message(req)
51 }
52}