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