sui_graphql_client/query_types/
object.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::query_types::schema;
5use crate::query_types::Address;
6use crate::query_types::Base64;
7use crate::query_types::MoveObjectContents;
8use crate::query_types::PageInfo;
9
10// ===========================================================================
11// Object(s) Queries
12// ===========================================================================
13
14#[derive(cynic::QueryFragment, Debug)]
15#[cynic(schema = "rpc", graphql_type = "Query", variables = "ObjectQueryArgs")]
16pub struct ObjectQuery {
17    #[arguments(address: $address, version: $version)]
18    pub object: Option<Object>,
19}
20
21#[derive(cynic::QueryFragment, Debug)]
22#[cynic(schema = "rpc", graphql_type = "Query", variables = "ObjectsQueryArgs")]
23pub struct ObjectsQuery {
24    #[arguments(after: $after, before: $before, filter: $filter, first: $first, last: $last)]
25    pub objects: ObjectConnection,
26}
27
28// ===========================================================================
29// Object(s) Query Args
30// ===========================================================================
31
32#[derive(cynic::QueryVariables, Debug)]
33pub struct ObjectQueryArgs {
34    pub address: Address,
35    pub version: Option<u64>,
36}
37
38#[derive(cynic::QueryVariables, Debug)]
39pub struct ObjectsQueryArgs<'a> {
40    pub after: Option<&'a str>,
41    pub before: Option<&'a str>,
42    pub filter: Option<ObjectFilter<'a>>,
43    pub first: Option<i32>,
44    pub last: Option<i32>,
45}
46
47// ===========================================================================
48// Object(s) Types
49// ===========================================================================
50
51#[derive(cynic::QueryFragment, Debug)]
52#[cynic(schema = "rpc", graphql_type = "Object")]
53pub struct Object {
54    pub as_move_object: Option<MoveObjectContents>,
55    pub bcs: Option<Base64>,
56}
57
58#[derive(Clone, Default, cynic::InputObject, Debug)]
59#[cynic(schema = "rpc", graphql_type = "ObjectFilter")]
60pub struct ObjectFilter<'a> {
61    #[cynic(rename = "type")]
62    pub type_: Option<&'a str>,
63    pub owner: Option<Address>,
64    pub object_ids: Option<Vec<Address>>,
65}
66
67#[derive(Clone, cynic::InputObject, Debug)]
68#[cynic(schema = "rpc", graphql_type = "ObjectKey")]
69pub struct ObjectKey {
70    pub object_id: Address,
71    pub version: u64,
72}
73
74#[derive(cynic::QueryFragment, Debug)]
75#[cynic(schema = "rpc", graphql_type = "ObjectConnection")]
76pub struct ObjectConnection {
77    pub page_info: PageInfo,
78    pub nodes: Vec<Object>,
79}