sui_graphql_client/query_types/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

mod active_validators;
mod balance;
mod chain;
mod checkpoint;
mod coin;
mod dry_run;
mod dynamic_fields;
mod epoch;
mod events;
mod execute_tx;
mod normalized_move;
mod object;
mod packages;
mod protocol_config;
mod service_config;
mod suins;
mod transaction;

pub use active_validators::ActiveValidatorsArgs;
pub use active_validators::ActiveValidatorsQuery;
pub use active_validators::EpochValidator;
pub use active_validators::Validator;
pub use active_validators::ValidatorConnection;
pub use active_validators::ValidatorSet;
pub use balance::Balance;
pub use balance::BalanceArgs;
pub use balance::BalanceQuery;
pub use balance::Owner;
pub use chain::ChainIdentifierQuery;
pub use checkpoint::CheckpointArgs;
pub use checkpoint::CheckpointId;
pub use checkpoint::CheckpointQuery;
pub use checkpoint::CheckpointTotalTxQuery;
pub use checkpoint::CheckpointsArgs;
pub use checkpoint::CheckpointsQuery;
pub use coin::CoinMetadata;
pub use coin::CoinMetadataArgs;
pub use coin::CoinMetadataQuery;
pub use dry_run::DryRunArgs;
pub use dry_run::DryRunQuery;
pub use dry_run::DryRunResult;
pub use dry_run::TransactionMetadata;
pub use dynamic_fields::DynamicFieldArgs;
pub use dynamic_fields::DynamicFieldConnectionArgs;
pub use dynamic_fields::DynamicFieldName;
pub use dynamic_fields::DynamicFieldQuery;
pub use dynamic_fields::DynamicFieldsOwnerQuery;
pub use dynamic_fields::DynamicObjectFieldQuery;
pub use epoch::Epoch;
pub use epoch::EpochArgs;
pub use epoch::EpochQuery;
pub use epoch::EpochSummaryQuery;
pub use epoch::EpochsArgs;
pub use epoch::EpochsQuery;
pub use events::Event;
pub use events::EventConnection;
pub use events::EventFilter;
pub use events::EventsQuery;
pub use events::EventsQueryArgs;
pub use execute_tx::ExecuteTransactionArgs;
pub use execute_tx::ExecuteTransactionQuery;
pub use execute_tx::ExecutionResult;
pub use normalized_move::MoveAbility;
pub use normalized_move::MoveFunction;
pub use normalized_move::MoveFunctionTypeParameter;
pub use normalized_move::MoveModule;
pub use normalized_move::MoveVisibility;
pub use normalized_move::NormalizedMoveFunctionQuery;
pub use normalized_move::NormalizedMoveFunctionQueryArgs;
pub use normalized_move::NormalizedMoveModuleQuery;
pub use normalized_move::NormalizedMoveModuleQueryArgs;
pub use normalized_move::OpenMoveType;
pub use object::ObjectFilter;
pub use object::ObjectKey;
pub use object::ObjectQuery;
pub use object::ObjectQueryArgs;
pub use object::ObjectsQuery;
pub use object::ObjectsQueryArgs;
pub use packages::LatestPackageQuery;
pub use packages::MovePackage;
pub use packages::MovePackageConnection;
pub use packages::MovePackageVersionFilter;
pub use packages::PackageArgs;
pub use packages::PackageByNameArgs;
pub use packages::PackageByNameQuery;
pub use packages::PackageCheckpointFilter;
pub use packages::PackageQuery;
pub use packages::PackageVersionsArgs;
pub use packages::PackageVersionsQuery;
pub use packages::PackagesQuery;
pub use packages::PackagesQueryArgs;
pub use protocol_config::ProtocolConfigQuery;
pub use protocol_config::ProtocolConfigs;
pub use protocol_config::ProtocolVersionArgs;
pub use service_config::Feature;
pub use service_config::ServiceConfig;
pub use service_config::ServiceConfigQuery;
pub use suins::DefaultSuinsNameQuery;
pub use suins::DefaultSuinsNameQueryArgs;
pub use suins::ResolveSuinsQuery;
pub use suins::ResolveSuinsQueryArgs;
pub use transaction::TransactionBlock;
pub use transaction::TransactionBlockArgs;
pub use transaction::TransactionBlockEffectsQuery;
pub use transaction::TransactionBlockQuery;
pub use transaction::TransactionBlockWithEffects;
pub use transaction::TransactionBlockWithEffectsQuery;
pub use transaction::TransactionBlocksEffectsQuery;
pub use transaction::TransactionBlocksQuery;
pub use transaction::TransactionBlocksQueryArgs;
pub use transaction::TransactionBlocksWithEffectsQuery;
pub use transaction::TransactionsFilter;

use sui_types::Address;

use cynic::impl_scalar;
use serde_json::Value as JsonValue;

use crate::error;

#[cynic::schema("rpc")]
pub mod schema {}

// ===========================================================================
// Scalars
// ===========================================================================

impl_scalar!(Address, schema::SuiAddress);
impl_scalar!(u64, schema::UInt53);
impl_scalar!(JsonValue, schema::JSON);

#[derive(cynic::Scalar, Debug, Clone)]
#[cynic(graphql_type = "Base64")]
pub struct Base64(pub String);

#[derive(cynic::Scalar, Debug, Clone)]
#[cynic(graphql_type = "BigInt")]
pub struct BigInt(pub String);

#[derive(cynic::Scalar, Debug, Clone)]
#[cynic(graphql_type = "DateTime")]
pub struct DateTime(pub String);

// ===========================================================================
// Types used in several queries
// ===========================================================================

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema = "rpc", graphql_type = "Address")]
pub struct GQLAddress {
    pub address: Address,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema = "rpc", graphql_type = "MoveObject")]
pub struct MoveObject {
    pub bcs: Option<Base64>,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema = "rpc", graphql_type = "MoveObject")]
pub struct MoveObjectContents {
    pub contents: Option<MoveValue>,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema = "rpc", graphql_type = "MoveValue")]
pub struct MoveValue {
    pub type_: MoveType,
    pub bcs: Base64,
    pub json: Option<JsonValue>,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(schema = "rpc", graphql_type = "MoveType")]
pub struct MoveType {
    pub repr: String,
}
// ===========================================================================
// Utility Types
// ===========================================================================

#[derive(Clone, Default, cynic::QueryFragment, Debug)]
#[cynic(schema = "rpc", graphql_type = "PageInfo")]
/// Information about pagination in a connection.
pub struct PageInfo {
    /// When paginating backwards, are there more items?
    pub has_previous_page: bool,
    /// Are there more items when paginating forwards?
    pub has_next_page: bool,
    /// When paginating backwards, the cursor to continue.
    pub start_cursor: Option<String>,
    /// When paginating forwards, the cursor to continue.
    pub end_cursor: Option<String>,
}

impl TryFrom<BigInt> for u64 {
    type Error = error::Error;

    fn try_from(value: BigInt) -> Result<Self, Self::Error> {
        Ok(value.0.parse::<u64>()?)
    }
}