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