sui_package_dump/
query.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
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use cynic::Operation;
use cynic::QueryBuilder;

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

#[derive(cynic::Scalar, Debug)]
pub(crate) struct SuiAddress(pub String);

#[derive(cynic::Scalar, Debug)]
pub(crate) struct Base64(pub String);

#[derive(cynic::Scalar, Debug)]
pub(crate) struct UInt53(pub u64);

/// Query types related to GraphQL service limits.
pub(crate) mod limits {
    use super::*;

    pub(crate) fn build() -> Operation<Query> {
        Query::build(())
    }

    #[derive(cynic::QueryFragment, Debug)]
    pub(crate) struct Query {
        pub(crate) service_config: ServiceConfig,
    }

    #[derive(cynic::QueryFragment, Debug)]
    pub(crate) struct ServiceConfig {
        pub(crate) max_page_size: i32,
    }
}

/// Query types related to fetching packages.
pub(crate) mod packages {
    use super::*;

    pub(crate) fn build(
        first: i32,
        after: Option<String>,
        after_checkpoint: Option<UInt53>,
        before_checkpoint: Option<UInt53>,
    ) -> Operation<Query, Vars> {
        Query::build(Vars {
            first,
            after,
            filter: Some(MovePackageCheckpointFilter {
                after_checkpoint,
                before_checkpoint,
            }),
        })
    }

    #[derive(cynic::QueryVariables, Debug)]
    pub(crate) struct Vars {
        pub(crate) first: i32,
        pub(crate) after: Option<String>,
        pub(crate) filter: Option<MovePackageCheckpointFilter>,
    }

    #[derive(cynic::InputObject, Debug)]
    pub(crate) struct MovePackageCheckpointFilter {
        pub(crate) after_checkpoint: Option<UInt53>,
        pub(crate) before_checkpoint: Option<UInt53>,
    }

    #[derive(cynic::QueryFragment, Debug)]
    #[cynic(variables = "Vars")]
    pub(crate) struct Query {
        pub(crate) checkpoint: Option<Checkpoint>,
        #[arguments(
            first: $first,
            after: $after,
            filter: $filter,
        )]
        pub(crate) packages: MovePackageConnection,
    }

    #[derive(cynic::QueryFragment, Debug)]
    pub(crate) struct Checkpoint {
        pub(crate) sequence_number: UInt53,
    }

    #[derive(cynic::QueryFragment, Debug)]
    pub(crate) struct MovePackageConnection {
        pub(crate) page_info: PageInfo,
        pub(crate) nodes: Vec<MovePackage>,
    }

    #[derive(cynic::QueryFragment, Debug)]
    pub(crate) struct PageInfo {
        pub(crate) has_next_page: bool,
        pub(crate) end_cursor: Option<String>,
    }

    #[derive(cynic::QueryFragment, Debug)]
    pub(crate) struct MovePackage {
        pub(crate) address: SuiAddress,
        pub(crate) bcs: Option<Base64>,
    }
}