linera_execution/
graphql.rs1use std::collections::BTreeMap;
5
6use linera_base::{
7 crypto::ValidatorPublicKey,
8 data_types::{Amount, ChainDescription, Epoch, Timestamp},
9 doc_scalar,
10 identifiers::{AccountOwner, ChainId},
11 ownership::ChainOwnership,
12};
13use linera_views::{context::Context, map_view::MapView};
14
15use crate::{
16 committee::{Committee, ValidatorState},
17 policy::ResourceControlPolicy,
18 system::UserData,
19 ExecutionStateView, SystemExecutionStateView,
20};
21
22doc_scalar!(UserData, "Optional user message attached to a transfer");
23
24async_graphql::scalar!(
25 ResourceControlPolicy,
26 "ResourceControlPolicyScalar",
27 "A collection of prices and limits associated with block execution"
28);
29
30#[async_graphql::Object(cache_control(no_cache))]
31impl Committee {
32 #[graphql(derived(name = "validators"))]
33 async fn _validators(&self) -> &BTreeMap<ValidatorPublicKey, ValidatorState> {
34 self.validators()
35 }
36
37 #[graphql(derived(name = "total_votes"))]
38 async fn _total_votes(&self) -> u64 {
39 self.total_votes()
40 }
41
42 #[graphql(derived(name = "quorum_threshold"))]
43 async fn _quorum_threshold(&self) -> u64 {
44 self.quorum_threshold()
45 }
46
47 #[graphql(derived(name = "validity_threshold"))]
48 async fn _validity_threshold(&self) -> u64 {
49 self.validity_threshold()
50 }
51
52 #[graphql(derived(name = "policy"))]
53 async fn _policy(&self) -> &ResourceControlPolicy {
54 self.policy()
55 }
56}
57
58#[async_graphql::Object(cache_control(no_cache))]
59impl<C: Send + Sync + Context> ExecutionStateView<C> {
60 #[graphql(derived(name = "system"))]
61 async fn _system(&self) -> &SystemExecutionStateView<C> {
62 &self.system
63 }
64}
65
66#[async_graphql::Object(cache_control(no_cache))]
67impl<C: Send + Sync + Context> SystemExecutionStateView<C> {
68 #[graphql(derived(name = "description"))]
69 async fn _description(&self) -> &Option<ChainDescription> {
70 self.description.get()
71 }
72
73 #[graphql(derived(name = "epoch"))]
74 async fn _epoch(&self) -> &Epoch {
75 self.epoch.get()
76 }
77
78 #[graphql(derived(name = "admin_id"))]
79 async fn _admin_id(&self) -> &Option<ChainId> {
80 self.admin_id.get()
81 }
82
83 #[graphql(derived(name = "committees"))]
84 async fn _committees(&self) -> &BTreeMap<Epoch, Committee> {
85 self.committees.get()
86 }
87
88 #[graphql(derived(name = "ownership"))]
89 async fn _ownership(&self) -> &ChainOwnership {
90 self.ownership.get()
91 }
92
93 #[graphql(derived(name = "balance"))]
94 async fn _balance(&self) -> &Amount {
95 self.balance.get()
96 }
97
98 #[graphql(derived(name = "balances"))]
99 async fn _balances(&self) -> &MapView<C, AccountOwner, Amount> {
100 &self.balances
101 }
102
103 #[graphql(derived(name = "timestamp"))]
104 async fn _timestamp(&self) -> &Timestamp {
105 self.timestamp.get()
106 }
107}