diff --git a/Package.resolved b/Package.resolved index 0520ae4..70ff7ee 100644 --- a/Package.resolved +++ b/Package.resolved @@ -9,6 +9,15 @@ "version" : "0.6.7" } }, + { + "identity" : "apollo-ios", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apollographql/apollo-ios.git", + "state" : { + "revision" : "7e28eb75e9970edaba346a3c1eab1f8fc479a04d", + "version" : "1.7.1" + } + }, { "identity" : "bigint", "kind" : "remoteSourceControl", @@ -63,6 +72,15 @@ "version" : "3.1.0" } }, + { + "identity" : "sqlite.swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/stephencelis/SQLite.swift.git", + "state" : { + "revision" : "7a2e3cd27de56f6d396e84f63beefd0267b55ccb", + "version" : "0.14.1" + } + }, { "identity" : "swiftyjson", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index 9e39543..866057a 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,8 @@ let package = Package( .package(url: "https://github.com/Flight-School/AnyCodable", from: "0.6.0"), .package(url: "https://github.com/tesseract-one/Bip39.swift.git", from: "0.1.1"), .package(url: "https://github.com/web3swift-team/web3swift.git", from: "3.2.0"), - .package(url: "https://github.com/auth0/JWTDecode.swift", from: "3.1.0") + .package(url: "https://github.com/auth0/JWTDecode.swift", from: "3.1.0"), + .package(url: "https://github.com/apollographql/apollo-ios.git", .upToNextMajor(from: "1.0.0")) ], targets: [ .target( @@ -31,7 +32,8 @@ let package = Package( .product(name: "AnyCodable", package: "AnyCodable"), .product(name: "Bip39", package: "Bip39.swift"), .product(name: "web3swift", package: "web3swift"), - .product(name: "JWTDecode", package: "JWTDecode.swift") + .product(name: "JWTDecode", package: "JWTDecode.swift"), + .product(name: "Apollo", package: "apollo-ios") ], path: "Sources" ), diff --git a/Package@swift-5.5.swift b/Package@swift-5.5.swift deleted file mode 100644 index d6bdc4b..0000000 --- a/Package@swift-5.5.swift +++ /dev/null @@ -1,46 +0,0 @@ -// swift-tools-version: 5.5 - -import PackageDescription - -let package = Package( - name: "SuiKit", - platforms: [.iOS(.v13), .macOS(.v11), .watchOS(.v6), .tvOS(.v13), .custom("xros", versionString: "1.0")], - products: [ - .library( - name: "SuiKit", - targets: ["SuiKit"]), - ], - dependencies: [ - .package(url: "https://github.com/hyugit/UInt256.git", from: "0.2.2"), - .package(url: "https://github.com/pebble8888/ed25519swift.git", from: "1.2.7"), - .package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "4.0.0"), - .package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"), - .package(url: "https://github.com/Flight-School/AnyCodable", from: "0.6.0"), - .package(url: "https://github.com/tesseract-one/Bip39.swift.git", from: "0.1.1"), - .package(url: "https://github.com/web3swift-team/web3swift.git", from: "3.2.0"), - .package(url: "https://github.com/auth0/JWTDecode.swift", from: "3.1.0") - ], - targets: [ - .target( - name: "SuiKit", - dependencies: [ - .product(name: "UInt256", package: "UInt256"), - .product(name: "ed25519swift", package: "ed25519swift"), - .product(name: "SwiftyJSON", package: "swiftyjson"), - .product(name: "Blake2", package: "Blake2.swift"), - .product(name: "AnyCodable", package: "AnyCodable"), - .product(name: "Bip39", package: "Bip39.swift"), - .product(name: "web3swift", package: "web3swift"), - .product(name: "JWTDecode", package: "JWTDecode.swift") - ], - path: "Sources" - ), - .testTarget( - name: "SuiKitTests", - dependencies: ["SuiKit"], - path: "Tests", - resources: [.copy("Resources")] - ), - ], - swiftLanguageVersions: [.v5] -) diff --git a/Package@swift-5.6.swift b/Package@swift-5.6.swift deleted file mode 100644 index d258b4f..0000000 --- a/Package@swift-5.6.swift +++ /dev/null @@ -1,46 +0,0 @@ -// swift-tools-version: 5.6 - -import PackageDescription - -let package = Package( - name: "SuiKit", - platforms: [.iOS(.v13), .macOS(.v11), .watchOS(.v6), .tvOS(.v13), .custom("xros", versionString: "1.0")], - products: [ - .library( - name: "SuiKit", - targets: ["SuiKit"]), - ], - dependencies: [ - .package(url: "https://github.com/hyugit/UInt256.git", from: "0.2.2"), - .package(url: "https://github.com/pebble8888/ed25519swift.git", from: "1.2.7"), - .package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "4.0.0"), - .package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"), - .package(url: "https://github.com/Flight-School/AnyCodable", from: "0.6.0"), - .package(url: "https://github.com/tesseract-one/Bip39.swift.git", from: "0.1.1"), - .package(url: "https://github.com/web3swift-team/web3swift.git", from: "3.2.0"), - .package(url: "https://github.com/auth0/JWTDecode.swift", from: "3.1.0") - ], - targets: [ - .target( - name: "SuiKit", - dependencies: [ - .product(name: "UInt256", package: "UInt256"), - .product(name: "ed25519swift", package: "ed25519swift"), - .product(name: "SwiftyJSON", package: "swiftyjson"), - .product(name: "Blake2", package: "Blake2.swift"), - .product(name: "AnyCodable", package: "AnyCodable"), - .product(name: "Bip39", package: "Bip39.swift"), - .product(name: "web3swift", package: "web3swift"), - .product(name: "JWTDecode", package: "JWTDecode.swift") - ], - path: "Sources" - ), - .testTarget( - name: "SuiKitTests", - dependencies: ["SuiKit"], - path: "Tests", - resources: [.copy("Resources")] - ), - ], - swiftLanguageVersions: [.v5] -) diff --git a/Sources/SuiKit/Extensions/AnyHashable.swift b/Sources/SuiKit/Extensions/AnyHashable.swift new file mode 100644 index 0000000..553bdbb --- /dev/null +++ b/Sources/SuiKit/Extensions/AnyHashable.swift @@ -0,0 +1,22 @@ +// +// File.swift +// +// +// Created by Marcus Arnett on 1/17/24. +// + +import Foundation + +extension AnyHashable: ScalarType, OutputTypeConvertible, AnyScalarType { + public init(_jsonValue value: JSONValue) throws { + self = value + } + + public static var _asOutputType: ApolloAPI.Selection.Field.OutputType { + .scalar(AnyHashable.self) + } + + public var _jsonValue: ApolloAPI.JSONValue { + self + } +} diff --git a/Sources/SuiKit/Extensions/DateFormatter.swift b/Sources/SuiKit/Extensions/DateFormatter.swift new file mode 100644 index 0000000..604ca4b --- /dev/null +++ b/Sources/SuiKit/Extensions/DateFormatter.swift @@ -0,0 +1,20 @@ +// +// File.swift +// +// +// Created by Marcus Arnett on 1/29/24. +// + +import Foundation + +extension DateFormatter { + static func unixTimestamp(from dateString: String) -> Int? { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" + dateFormatter.locale = Locale(identifier: "en_US_POSIX") + guard let date = dateFormatter.date(from: dateString) else { + return nil + } + return Int(date.timeIntervalSince1970 * 1_000) + } +} diff --git a/Sources/SuiKit/Protocols/Sui/ConnectionProtocol.swift b/Sources/SuiKit/Protocols/Sui/ConnectionProtocol.swift index 71ef02e..9cc8fb8 100644 --- a/Sources/SuiKit/Protocols/Sui/ConnectionProtocol.swift +++ b/Sources/SuiKit/Protocols/Sui/ConnectionProtocol.swift @@ -33,6 +33,8 @@ public protocol ConnectionProtocol { /// Optional URL for a faucet service to obtain tokens. /// Default is nil, meaning no faucet is configured. var faucet: String? { get } + + var graphql: String? { get } /// Optional URL for a WebSocket connection. /// Default is nil, meaning no WebSocket is configured. diff --git a/Sources/SuiKit/Types/Enums/Errors/SuiError.swift b/Sources/SuiKit/Types/Enums/Errors/SuiError.swift index 796f371..bfdb691 100644 --- a/Sources/SuiKit/Types/Enums/Errors/SuiError.swift +++ b/Sources/SuiKit/Types/Enums/Errors/SuiError.swift @@ -165,4 +165,7 @@ public enum SuiError: Error, Equatable { /// The Kiosk Data is invalid. case invalidKioskData + + /// The result for the GraphQL query is missing + case missingGraphQLData } diff --git a/Sources/SuiKit/Types/Enums/Objects/ObjectOwner.swift b/Sources/SuiKit/Types/Enums/Objects/ObjectOwner.swift index 9bd9bf4..b9575ac 100644 --- a/Sources/SuiKit/Types/Enums/Objects/ObjectOwner.swift +++ b/Sources/SuiKit/Types/Enums/Objects/ObjectOwner.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// `ObjectOwner` represents the possible types of ownership for objects. -public enum ObjectOwner: KeyProtocol { +public enum ObjectOwner: KeyProtocol, Equatable { /// Represents an object owned by an address. The associated value is a `String` containing the address. case addressOwner(String) diff --git a/Sources/SuiKit/Types/Enums/Objects/RawData.swift b/Sources/SuiKit/Types/Enums/Objects/RawData.swift index 95bde9f..ccadd69 100644 --- a/Sources/SuiKit/Types/Enums/Objects/RawData.swift +++ b/Sources/SuiKit/Types/Enums/Objects/RawData.swift @@ -30,13 +30,57 @@ import SwiftyJSON /// /// This enum allows for either a `MoveObjectRaw` or `PackageRaw` data type, capturing /// the raw information for either a Move object or a package object. -public enum RawData { +public enum RawData: Equatable { /// Represents raw data for a Move object. The associated value is a `MoveObjectRaw` containing the Move object's raw data. case moveObject(MoveObjectRaw) /// Represents raw data for a package object. The associated value is a `PackageRaw` containing the package object's raw data. case packageObject(PackageRaw) + public init(graphql: TryGetPastObjectQuery.Data.Object.AsMoveObject, version: String) { + self = .moveObject( + MoveObjectRaw( + bcsBytes: JSON(graphql.ifShowBcs!.contents!.bcs).stringValue, + hasPublicTransfer: graphql.ifShowBcs!.hasPublicTransfer, + type: graphql.ifShowBcs!.contents!.type.repr, + version: version + ) + ) + } + + public init(graphql: GetOwnedObjectsQuery.Data.Address.ObjectConnection.Node.AsMoveObject, version: String) { + self = .moveObject( + MoveObjectRaw( + bcsBytes: JSON(graphql.ifShowBcs!.contents!.bcs).stringValue, + hasPublicTransfer: graphql.ifShowBcs!.hasPublicTransfer, + type: graphql.ifShowBcs!.contents!.type.repr, + version: version + ) + ) + } + + public init(graphql: MultiGetObjectsQuery.Data.ObjectConnection.Node.AsMoveObject, version: String) { + self = .moveObject( + MoveObjectRaw( + bcsBytes: JSON(graphql.ifShowBcs!.contents!.bcs).stringValue, + hasPublicTransfer: graphql.ifShowBcs!.hasPublicTransfer, + type: graphql.ifShowBcs!.contents!.type.repr, + version: version + ) + ) + } + + public init(graphql: GetObjectQuery.Data.Object.AsMoveObject, version: String) { + self = .moveObject( + MoveObjectRaw( + bcsBytes: JSON(graphql.ifShowBcs!.contents!.bcs).stringValue, + hasPublicTransfer: graphql.ifShowBcs!.hasPublicTransfer, + type: graphql.ifShowBcs!.contents!.type.repr, + version: version + ) + ) + } + /// Parses a `JSON` object to determine the type of raw data it contains and returns a corresponding `RawData` instance. /// /// - Parameters: diff --git a/Sources/SuiKit/Types/Enums/Objects/SuiParsedData.swift b/Sources/SuiKit/Types/Enums/Objects/SuiParsedData.swift index a1428ec..d988be4 100644 --- a/Sources/SuiKit/Types/Enums/Objects/SuiParsedData.swift +++ b/Sources/SuiKit/Types/Enums/Objects/SuiParsedData.swift @@ -30,13 +30,69 @@ import SwiftyJSON /// /// The enum handles two main types of parsed data: `MoveObject` and `MovePackage`, which represent /// different kinds of data structures commonly used in Sui-related operations. -public enum SuiParsedData { +public enum SuiParsedData: Equatable { /// Represents a parsed Move object. The associated value is a `MoveObject` that holds the parsed fields and other relevant data for a Move object. case moveObject(MoveObject) /// Represents a parsed Move package. The associated value is a `MovePackage` containing the disassembled or decomposed package information. case movePackage(MovePackage) + public init(graphql: TryGetPastObjectQuery.Data.Object.AsMoveObject) { + let fields: [String: AnyHashable] = [ + "data": graphql.ifShowContent!.contents!.data, + "layout": graphql.ifShowContent!.contents!.type.layout + ] + self = .moveObject( + MoveObject( + fields: JSON(fields), + hasPublicTransfer: graphql.ifShowContent!.hasPublicTransfer, + type: graphql.ifShowContent!.contents!.type.repr + ) + ) + } + + public init(graphql: GetOwnedObjectsQuery.Data.Address.ObjectConnection.Node.AsMoveObject) { + let fields: [String: AnyHashable] = [ + "data": graphql.ifShowContent!.contents!.data, + "layout": graphql.ifShowContent!.contents!.type.layout + ] + self = .moveObject( + MoveObject( + fields: JSON(fields), + hasPublicTransfer: graphql.ifShowContent!.hasPublicTransfer, + type: graphql.ifShowContent!.contents!.type.repr + ) + ) + } + + public init(graphql: MultiGetObjectsQuery.Data.ObjectConnection.Node.AsMoveObject) { + let fields: [String: AnyHashable] = [ + "data": graphql.ifShowContent!.contents!.data, + "layout": graphql.ifShowContent!.contents!.type.layout + ] + self = .moveObject( + MoveObject( + fields: JSON(fields), + hasPublicTransfer: graphql.ifShowContent!.hasPublicTransfer, + type: graphql.ifShowContent!.contents!.type.repr + ) + ) + } + + public init(graphql: GetObjectQuery.Data.Object.AsMoveObject) { + let fields: [String: AnyHashable] = [ + "data": graphql.ifShowContent!.contents!.data, + "layout": graphql.ifShowContent!.contents!.type.layout + ] + self = .moveObject( + MoveObject( + fields: JSON(fields), + hasPublicTransfer: graphql.ifShowContent!.hasPublicTransfer, + type: graphql.ifShowContent!.contents!.type.repr + ) + ) + } + /// Parses a JSON object to determine the type of parsed data and returns an instance of `SuiParsedData`. /// /// - Parameters: diff --git a/Sources/SuiKit/Types/Enums/Provider/Responses/SuiMoveFunctionArgType.swift b/Sources/SuiKit/Types/Enums/Provider/Responses/SuiMoveFunctionArgType.swift index 7a4a930..b13fefc 100644 --- a/Sources/SuiKit/Types/Enums/Provider/Responses/SuiMoveFunctionArgType.swift +++ b/Sources/SuiKit/Types/Enums/Provider/Responses/SuiMoveFunctionArgType.swift @@ -24,6 +24,7 @@ // import Foundation +import SwiftyJSON /// `SuiMoveFunctionArgType` represents the type of an argument in a Move function. /// @@ -32,8 +33,34 @@ import Foundation public enum SuiMoveFunctionArgType: Equatable { /// The argument is a pure value and doesn't involve any object references. case pure - + /// The argument is an object. The kind of the object (immutable/mutable reference or by value) is specified. case object(ObjectValueKind) + + public init(graphql: GetMoveFunctionArgTypesQuery.Data.Object.AsMovePackage.Module.Function.Parameter) { + self = Self.fromHashable(hash: graphql.signature) + } + + public init(graphql: RPC_MOVE_STRUCT_FIELDS.Field.Type_SelectionSet) { + self = Self.fromHashable(hash: graphql.signature) + } + + private static func fromHashable(hash: AnyHashable) -> SuiMoveFunctionArgType { + let jsonGraphQL = JSON(hash) + + if !(jsonGraphQL["body"]["datatype"].exists()) { + return .pure + } + + if jsonGraphQL["ref"].stringValue == "&" { + return .object(.byImmutableReference) + } + + if jsonGraphQL["ref"].stringValue == "&mut" { + return .object(.byMutableReference) + } + + return .object(.byValue) + } } diff --git a/Sources/SuiKit/Types/Enums/Sui/Cryptography/SignatureScheme.swift b/Sources/SuiKit/Types/Enums/Sui/Cryptography/SignatureScheme.swift index 62a10c3..4906a82 100644 --- a/Sources/SuiKit/Types/Enums/Sui/Cryptography/SignatureScheme.swift +++ b/Sources/SuiKit/Types/Enums/Sui/Cryptography/SignatureScheme.swift @@ -29,12 +29,14 @@ import Foundation /// /// - `ED25519`: Represents the Ed25519 cryptographic algorithm. /// - `SECP256K1`: Represents the SECP256K1 cryptographic algorithm. +/// - `SECP256R1`: Represents the SECP256R1 (P256) cryptographic algorithm. public enum SignatureScheme: String { /// Represents the Ed25519 cryptographic algorithm. case ED25519 /// Represents the SECP256K1 cryptographic algorithm. case SECP256K1 - + + /// Represents the SECP256R1 cryptographic algorithm. case SECP256R1 } diff --git a/Sources/SuiKit/Types/Enums/Sui/Normalized/SuiMoveNormalizedType.swift b/Sources/SuiKit/Types/Enums/Sui/Normalized/SuiMoveNormalizedType.swift index 85bd669..2267f8d 100644 --- a/Sources/SuiKit/Types/Enums/Sui/Normalized/SuiMoveNormalizedType.swift +++ b/Sources/SuiKit/Types/Enums/Sui/Normalized/SuiMoveNormalizedType.swift @@ -180,6 +180,63 @@ public indirect enum SuiMoveNormalizedType: Equatable, KeyProtocol { } } + public static func parseGraphQL(_ data: AnyHashable) -> SuiMoveNormalizedType? { + if JSON(data)["ref"].exists() && JSON(data)["ref"].string == "&mut" { + guard let mutableReference = Self.parseGraphQLInner(data) else { return nil } + return .mutableReference(mutableReference) + } + if JSON(data)["ref"].exists() && JSON(data)["ref"].string == "&" { + guard let reference = Self.parseGraphQLInner(data) else { return nil } + return .reference(reference) + } + return parseGraphQLInner(data) + } + + internal static func parseGraphQLInner(_ data: AnyHashable? = nil, _ override: JSON? = nil) -> SuiMoveNormalizedType? { + let json = data != nil ? JSON(data!) : JSON() + var body = json["body"] + if override != nil { body = override! } + switch body.stringValue { + case "bool": + return .bool + case "u8": + return .u8 + case "u16": + return .u16 + case "u32": + return .u32 + case "u64": + return .u64 + case "u128": + return .u128 + case "u256": + return .u256 + case "address": + return .address + default: + break + } + if body["datatype"].exists() { + guard let structure = SuiMoveNormalizedStructType(graphQLInput: body["datatype"]) else { return nil } + return .structure( + structure + ) + } + if body["vector"].exists() { + guard let vector = Self.parseGraphQLInner(nil, body["vector"]) else { return nil } + return .vector(vector) + } + if body["typeParameter"].exists() { + return .typeParameter( + TypeParameter( + typeParameter: UInt16(body["typeParameter"].int16Value) + ) + ) + } + + return nil + } + /// Function to parse JSON into a `SuiMoveNormalizedType`. /// - Parameter data: The JSON data to parse. /// - Returns: Returns a `SuiMoveNormalizedType` if it could be parsed, otherwise returns `nil`. diff --git a/Sources/SuiKit/Types/Enums/Sui/Normalized/SuiMoveVisibility.swift b/Sources/SuiKit/Types/Enums/Sui/Normalized/SuiMoveVisibility.swift index fee3e59..f176d6f 100644 --- a/Sources/SuiKit/Types/Enums/Sui/Normalized/SuiMoveVisibility.swift +++ b/Sources/SuiKit/Types/Enums/Sui/Normalized/SuiMoveVisibility.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// Enumeration representing visibility levels in the SuiMove environment. -public enum SuiMoveVisibility: String { +public enum SuiMoveVisibility: String, Equatable { /// Represents a private visibility level, accessible only within the same module. case Private @@ -48,5 +48,15 @@ public enum SuiMoveVisibility: String { default: return nil } } + + public static func parseGraphQL(_ data: GraphQLEnum?) -> SuiMoveVisibility? { + guard data != nil else { return nil } + switch data! { + case .friend: return .Friend + case .public: return .Public + case .private: return .Private + default: return nil + } + } } diff --git a/Sources/SuiKit/Types/Enums/Sui/Transactions/ProtocolConfigValue.swift b/Sources/SuiKit/Types/Enums/Sui/Transactions/ProtocolConfigValue.swift index 0324d97..fcdba60 100644 --- a/Sources/SuiKit/Types/Enums/Sui/Transactions/ProtocolConfigValue.swift +++ b/Sources/SuiKit/Types/Enums/Sui/Transactions/ProtocolConfigValue.swift @@ -26,7 +26,7 @@ import Foundation /// Enumeration representing different types of values that can be stored in a protocol configuration. -public enum ProtocolConfigValue { +public enum ProtocolConfigValue: Equatable { /// Represents a 32-bit unsigned integer value in the configuration. /// The associated `String` holds the actual value in string format. case u32(String) @@ -38,4 +38,6 @@ public enum ProtocolConfigValue { /// Represents a 64-bit floating-point value in the configuration. /// The associated `String` holds the actual value in string format. case f64(String) + + case u16(String) } diff --git a/Sources/SuiKit/Types/Structs/Builders/Transactions/TransactionBlock/ResolveStructs/ProtocolConfig.swift b/Sources/SuiKit/Types/Structs/Builders/Transactions/TransactionBlock/ResolveStructs/ProtocolConfig.swift index 071c3d5..ab87133 100644 --- a/Sources/SuiKit/Types/Structs/Builders/Transactions/TransactionBlock/ResolveStructs/ProtocolConfig.swift +++ b/Sources/SuiKit/Types/Structs/Builders/Transactions/TransactionBlock/ResolveStructs/ProtocolConfig.swift @@ -25,7 +25,7 @@ import Foundation -public struct ProtocolConfig { +public struct ProtocolConfig: Equatable { /// A dictionary containing attributes related to the protocol configuration. /// The keys are strings representing the name of the attribute, /// and the values are optional `ProtocolConfigValue` instances representing the value of the attribute. @@ -66,5 +66,38 @@ public struct ProtocolConfig { self.minSupportedProtocolVersion = minSupportedProtocolVersion self.protocolVersion = protocolVersion } + + public init(graphql: GetProtocolConfigQuery.Data.ProtocolConfig) { + var attributesDict: [String: ProtocolConfigValue?] = [:] + let attributeTypeMap: [String: (String) -> ProtocolConfigValue] = [ + "max_arguments": { .u32($0) }, + "max_gas_payment_objects": { .u32($0) }, + "max_modules_in_publish": { .u32($0) }, + "max_programmable_tx_commands": { .u32($0) }, + "max_pure_argument_size": { .u32($0) }, + "max_type_argument_depth": { .u32($0) }, + "max_type_arguments": { .u32($0) }, + "move_binary_format_version": { .u32($0) }, + "random_beacon_reduction_allowed_delta": { .u16($0) }, + "scoring_decision_cutoff_value": { .f64($0) }, + "scoring_decision_mad_divisor": { .f64($0) } + ] + graphql.configs.forEach { feature in + if feature.value != nil, feature.key != "random_beacon_reduction_allowed_delta" { + if let variableType = attributeTypeMap[feature.key] { + attributesDict[feature.key] = variableType(feature.value!) + } else { + attributesDict[feature.key] = .u64(feature.value!) + } + } + } + self.attributes = attributesDict + self.maxSupportedProtocolVersion = "\(graphql.protocolVersion)" + self.minSupportedProtocolVersion = "1" + self.protocolVersion = "\(graphql.protocolVersion)" + self.featureFlags = graphql.featureFlags.reduce(into: [String: Bool]()) { (flags, obj) in + flags[obj.key] = obj.value + } + } } diff --git a/Sources/SuiKit/Types/Structs/Builders/Transactions/TransactionBlock/TransactionBlock.swift b/Sources/SuiKit/Types/Structs/Builders/Transactions/TransactionBlock/TransactionBlock.swift index de0fcf9..12dfae0 100644 --- a/Sources/SuiKit/Types/Structs/Builders/Transactions/TransactionBlock/TransactionBlock.swift +++ b/Sources/SuiKit/Types/Structs/Builders/Transactions/TransactionBlock/TransactionBlock.swift @@ -581,7 +581,7 @@ public class TransactionBlock { } self.setGasPrice( price: BigInt( - try await provider.getGasPrice() + try await provider.getReferenceGasPrice() ) ) } diff --git a/Sources/SuiKit/Types/Structs/Checkpoints/Checkpoint.swift b/Sources/SuiKit/Types/Structs/Checkpoints/Checkpoint.swift index 2b9b60f..69e1b97 100644 --- a/Sources/SuiKit/Types/Structs/Checkpoints/Checkpoint.swift +++ b/Sources/SuiKit/Types/Structs/Checkpoints/Checkpoint.swift @@ -70,4 +70,40 @@ public struct Checkpoint: Equatable { self.validatorSignature = input["validatorSignature"].string self.transactions = input["transactions"].arrayValue.map { $0.stringValue } } + + /// Initialize a new instance of `Checkpoint` from a GraphQL object. + /// - Parameter graphql: A GraphQL object containing values for initalizing a new Checkpoint. + public init(graphql: GetCheckpointQuery.Data) { + self.epoch = "\(graphql.checkpoint!.epoch!.epochId)" + self.sequenceNumber = "\(graphql.checkpoint!.sequenceNumber)" + self.digest = graphql.checkpoint!.digest + self.networkTotalTransactions = graphql.checkpoint!.networkTotalTransactions != nil ? + "\(graphql.checkpoint!.networkTotalTransactions!)" : + nil + self.previousDigest = graphql.checkpoint!.previousCheckpointDigest + self.epochRollingGasCostSummary = graphql.checkpoint!.rollingGasSummary != nil ? + GasCostSummary(graphql: graphql.checkpoint!.rollingGasSummary!) : + nil + self.timestampMs = "\(DateFormatter.unixTimestamp(from: graphql.checkpoint!.timestamp)!)" + self.validatorSignature = graphql.checkpoint!.validatorSignatures + self.transactions = graphql.checkpoint!.transactionBlockConnection!.nodes.map { $0.digest } + } + + /// Initialize a new instance of `Checkpoint` from a GraphQL object. + /// - Parameter graphql: A GraphQL object containing values for initalizing a new Checkpoint. + public init(graphql: GetCheckpointsQuery.Data.Checkpoints.Node) { + self.epoch = "\(graphql.epoch!.epochId)" + self.sequenceNumber = "\(graphql.sequenceNumber)" + self.digest = graphql.digest + self.networkTotalTransactions = graphql.networkTotalTransactions != nil ? + "\(graphql.networkTotalTransactions!)" : + nil + self.previousDigest = graphql.previousCheckpointDigest + self.epochRollingGasCostSummary = graphql.rollingGasSummary != nil ? + GasCostSummary(graphql: graphql.rollingGasSummary!) : + nil + self.timestampMs = "\(DateFormatter.unixTimestamp(from: graphql.timestamp)!)" + self.validatorSignature = graphql.validatorSignatures + self.transactions = graphql.transactionBlockConnection!.nodes.map { $0.digest } + } } diff --git a/Sources/SuiKit/Types/Structs/Checkpoints/CheckpointPage.swift b/Sources/SuiKit/Types/Structs/Checkpoints/CheckpointPage.swift index 9ad4fd0..e916898 100644 --- a/Sources/SuiKit/Types/Structs/Checkpoints/CheckpointPage.swift +++ b/Sources/SuiKit/Types/Structs/Checkpoints/CheckpointPage.swift @@ -31,8 +31,23 @@ public struct CheckpointPage { public let data: [Checkpoint] /// A string representing the cursor for the next page of checkpoints. This can be used to request the next set of checkpoints in pagination. - public let nextCursor: String + public let nextCursor: String? + + /// Object containing the metadata info regarding the current checkpoint page. + public let pageInfo: PageInfo? /// A boolean indicating whether there is another page of checkpoints available after the current page. - public let hasNextPage: Bool + public let hasNextPage: Bool? + + public init( + data: [Checkpoint], + nextCursor: String? = nil, + pageInfo: PageInfo? = nil, + hasNextPage: Bool? = nil + ) { + self.data = data + self.nextCursor = nextCursor + self.hasNextPage = hasNextPage + self.pageInfo = pageInfo + } } diff --git a/Sources/SuiKit/Types/Structs/Checkpoints/GasCostSummary.swift b/Sources/SuiKit/Types/Structs/Checkpoints/GasCostSummary.swift index c21e843..87c78b1 100644 --- a/Sources/SuiKit/Types/Structs/Checkpoints/GasCostSummary.swift +++ b/Sources/SuiKit/Types/Structs/Checkpoints/GasCostSummary.swift @@ -53,4 +53,11 @@ public struct GasCostSummary: Equatable { self.storageRebate = input["storageRebate"].stringValue self.nonRefundableStorageFee = input["nonRefundableStorageFee"].stringValue } + + public init(graphql: RPC_Checkpoint_Fields.RollingGasSummary) { + self.computationCost = graphql.computationCost ?? "" + self.storageCost = graphql.storageCost ?? "" + self.storageRebate = graphql.storageRebate ?? "" + self.nonRefundableStorageFee = graphql.nonRefundableStorageFee ?? "" + } } diff --git a/Sources/SuiKit/Types/Structs/Checkpoints/PageInfo.swift b/Sources/SuiKit/Types/Structs/Checkpoints/PageInfo.swift new file mode 100644 index 0000000..1edb4a0 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/Checkpoints/PageInfo.swift @@ -0,0 +1,69 @@ +// +// PageInfo.swift +// SuiKit +// +// Copyright (c) 2024 OpenDive +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation + +/// An object that contains information regarding the current page query from a given requests. +public struct PageInfo: Equatable { + /// The starting point of the array within the context of the entire list of objecs. + public var startCursor: String? + + /// The ending point of the array within the context of the entire list of objects. + public var endCursor: String? + + /// Whether or not there is another page ahead of the current page. + public var hasNextPage: Bool + + /// Whether or not there is another page before the current page. + public var hasPreviousPage: Bool + + public init(graphql: GetCheckpointsQuery.Data.Checkpoints.PageInfo) { + self.startCursor = graphql.startCursor + self.endCursor = graphql.endCursor + self.hasNextPage = graphql.hasNextPage + self.hasPreviousPage = graphql.hasPreviousPage + } + + public init(graphql: QueryEventsQuery.Data.EventConnection.PageInfo) { + self.startCursor = graphql.startCursor + self.endCursor = graphql.endCursor + self.hasNextPage = graphql.hasNextPage + self.hasPreviousPage = graphql.hasPreviousPage + } + + public init(graphql: GetCoinsQuery.Data.Address.CoinConnection.PageInfo) { + self.startCursor = nil + self.endCursor = graphql.endCursor + self.hasNextPage = graphql.hasNextPage + self.hasPreviousPage = false + } + + public init(graphql: GetOwnedObjectsQuery.Data.Address.ObjectConnection.PageInfo) { + self.startCursor = nil + self.endCursor = graphql.endCursor + self.hasNextPage = graphql.hasNextPage + self.hasPreviousPage = false + } +} diff --git a/Sources/SuiKit/Types/Structs/Coin/CoinBalance.swift b/Sources/SuiKit/Types/Structs/Coin/CoinBalance.swift index 4451205..d085be1 100644 --- a/Sources/SuiKit/Types/Structs/Coin/CoinBalance.swift +++ b/Sources/SuiKit/Types/Structs/Coin/CoinBalance.swift @@ -26,10 +26,10 @@ import Foundation /// Represents the balance details of a specific coin type in a user's account or wallet. -public struct CoinBalance { +public struct CoinBalance: Equatable { /// A string that represents the type of coin. /// This could be the name or the identifier of the coin/cryptocurrency. - public let coinType: String + public let coinType: StructTag /// An integer representing the count of coin objects within the specified coin type. /// Coin objects are instances or units of the coin type. @@ -42,4 +42,30 @@ public struct CoinBalance { /// An optional `LockedBalance` instance representing any locked balance of the coin type. /// Locked balance is the portion of the total balance that is restricted or not readily available for use. public let lockedBalance: LockedBalance? + + public init( + coinType: String, + coinObjectCount: Int, + totalBalance: String, + lockedBalance: LockedBalance? + ) throws { + self.coinType = try StructTag.fromStr(coinType) + self.coinObjectCount = coinObjectCount + self.totalBalance = totalBalance + self.lockedBalance = lockedBalance + } + + public init(graphql: GetBalanceQuery.Data.Address.Balance) throws { + self.coinType = try StructTag.fromStr(graphql.coinType!.repr) + self.coinObjectCount = graphql.coinObjectCount! + self.totalBalance = graphql.totalBalance! + self.lockedBalance = nil + } + + public init(graphql: GetAllBalancesQuery.Data.Address.BalanceConnection.Node) throws { + self.coinType = try StructTag.fromStr(graphql.coinType!.repr) + self.coinObjectCount = graphql.coinObjectCount! + self.totalBalance = graphql.totalBalance! + self.lockedBalance = nil + } } diff --git a/Sources/SuiKit/Types/Structs/Coin/CoinStruct.swift b/Sources/SuiKit/Types/Structs/Coin/CoinStruct.swift index 4db7d7f..c0fb788 100644 --- a/Sources/SuiKit/Types/Structs/Coin/CoinStruct.swift +++ b/Sources/SuiKit/Types/Structs/Coin/CoinStruct.swift @@ -8,9 +8,9 @@ import Foundation /// Represents the details of a specific coin object. -public struct CoinStruct { +public struct CoinStruct: Equatable { /// A string representing the type of the coin, e.g., Bitcoin, Ethereum. - public let coinType: String + public let coinType: StructTag /// An `objectId` representing the unique identifier of the coin object. public let coinObjectId: objectId @@ -56,6 +56,31 @@ public struct CoinStruct { digest: self.digest ) } + + public init( + coinType: String, + coinObjectId: objectId, + version: String, + digest: TransactionDigest, + balance: String, + previousTransaction: TransactionDigest + ) throws { + self.coinType = try StructTag.fromStr(coinType) + self.coinObjectId = coinObjectId + self.version = version + self.digest = digest + self.balance = balance + self.previousTransaction = previousTransaction + } + + public init(graphql: GetCoinsQuery.Data.Address.CoinConnection.Node) throws { + self.balance = graphql.balance! + self.coinObjectId = graphql.asMoveObject.asObject.coinObjectId + self.coinType = try StructTag.fromStr(graphql.asMoveObject.contents!.type.repr) + self.digest = graphql.asMoveObject.asObject.digest + self.previousTransaction = graphql.asMoveObject.asObject.previousTransactionBlock!.digest + self.version = "\(graphql.asMoveObject.asObject.version)" + } } public typealias objectId = String diff --git a/Sources/SuiKit/Types/Structs/Coin/LockedBalance.swift b/Sources/SuiKit/Types/Structs/Coin/LockedBalance.swift index 6f1649a..bc5a136 100644 --- a/Sources/SuiKit/Types/Structs/Coin/LockedBalance.swift +++ b/Sources/SuiKit/Types/Structs/Coin/LockedBalance.swift @@ -26,7 +26,7 @@ import Foundation /// Represents a balance that is locked and cannot be accessed until a certain condition is met. -public struct LockedBalance { +public struct LockedBalance: Equatable { /// An integer representing the identifier of the epoch /// during which the balance is locked. public let epochId: Int diff --git a/Sources/SuiKit/Types/Structs/Coin/PaginatedCoins.swift b/Sources/SuiKit/Types/Structs/Coin/PaginatedCoins.swift index 0b629b8..919914f 100644 --- a/Sources/SuiKit/Types/Structs/Coin/PaginatedCoins.swift +++ b/Sources/SuiKit/Types/Structs/Coin/PaginatedCoins.swift @@ -27,14 +27,29 @@ import Foundation /// Represents a paginated set of `CoinStruct`, often used to handle large sets of coins /// and retrieve them page by page to minimize load and optimize performance. -public struct PaginatedCoins { +public struct PaginatedCoins: Equatable { /// An array of `CoinStruct` representing the coin structures contained in the current page. public let data: [CoinStruct] /// A string representing the object identifier (objectId) for the next cursor in the pagination. /// It is used to retrieve the next page of `CoinStruct` objects. - public let nextCursor: objectId + public let nextCursor: objectId? + + /// The object corresponding to the information of the current coin page. + public let pageInfo: PageInfo? /// A boolean value indicating whether there is a next page available in the pagination. - public let hasNextPage: Bool + public let hasNextPage: Bool? + + public init( + data: [CoinStruct], + nextCursor: objectId? = nil, + pageInfo: PageInfo? = nil, + hasNextPage: Bool? = nil + ) { + self.data = data + self.nextCursor = nextCursor + self.pageInfo = pageInfo + self.hasNextPage = hasNextPage + } } diff --git a/Sources/SuiKit/Types/Structs/Cryptography/Signature.swift b/Sources/SuiKit/Types/Structs/Cryptography/Signature.swift index bc48bfe..d5555ef 100644 --- a/Sources/SuiKit/Types/Structs/Cryptography/Signature.swift +++ b/Sources/SuiKit/Types/Structs/Cryptography/Signature.swift @@ -100,6 +100,19 @@ public struct Signature: Equatable, KeyProtocol { let pubKeyBytes = Array(bytes[(1 + signature.count)...]) let pubKey = try SECP256K1PublicKey(data: Data(pubKeyBytes)) return Signature(signature: Data(signature), publickey: pubKey.key, signatureScheme: .SECP256K1) + } else if signatureScheme == "SECP256R1" { + if #available(macOS 13.0, *) { + let signature = Array(bytes[1...(bytes.count - SECP256R1PublicKey.LENGTH)]) + let pubKeyBytes = Array(bytes[(1 + signature.count)...]) + let pubKey = try SECP256R1PublicKey(data: Data(pubKeyBytes)) + return Signature( + signature: Data(signature), + publickey: pubKey.key.compressedRepresentation, + signatureScheme: .SECP256R1 + ) + } else { + throw AccountError.cannotBeDeserialized + } } else { throw AccountError.cannotBeDeserialized } diff --git a/Sources/SuiKit/Types/Structs/Cryptography/SignatureSchemeFlags.swift b/Sources/SuiKit/Types/Structs/Cryptography/SignatureSchemeFlags.swift index b3a6800..76653ec 100644 --- a/Sources/SuiKit/Types/Structs/Cryptography/SignatureSchemeFlags.swift +++ b/Sources/SuiKit/Types/Structs/Cryptography/SignatureSchemeFlags.swift @@ -31,15 +31,15 @@ public struct SignatureSchemeFlags { public static var SIGNATURE_SCHEME_TO_FLAG: [String: UInt8] = [ "ED25519": 0x00, // Represents the Ed25519 signature scheme. "SECP256K1": 0x01, // Represents the SECP256K1 signature scheme. - "SECP256R1": 0x02, - "ZkLogin": 0x05 + "SECP256R1": 0x02, // Represents the SECP256R1 (P256) signature scheme. + "ZkLogin": 0x05 // Represents the zkLogin signature scheme. ] /// A dictionary mapping the flags of signature schemes to their associated names. public static var SIGNATURE_FLAG_TO_SCHEME: [UInt8: String] = [ 0x00: "ED25519", // Represents the flag for the Ed25519 signature scheme. 0x01: "SECP256K1", // Represents the flag for the SECP256K1 signature scheme. - 0x02: "SECP256R1", - 0x05: "ZkLogin" + 0x02: "SECP256R1", // Represents the flag for the SECP256R1 (P256) signature scheme. + 0x05: "ZkLogin" // Represents the flag for the zkLogin signature scheme. ] } diff --git a/Sources/SuiKit/Types/Structs/Faucet/Event/PaginatedSuiMoveEvent.swift b/Sources/SuiKit/Types/Structs/Faucet/Event/PaginatedSuiMoveEvent.swift index 85ece1b..592e4fc 100644 --- a/Sources/SuiKit/Types/Structs/Faucet/Event/PaginatedSuiMoveEvent.swift +++ b/Sources/SuiKit/Types/Structs/Faucet/Event/PaginatedSuiMoveEvent.swift @@ -31,8 +31,17 @@ public struct PaginatedSuiMoveEvent { public let data: [SuiEvent] /// An `EventId` object representing the cursor to the next page of events. - public let nextCursor: EventId + public let nextCursor: EventId? + + public let pageInfo: PageInfo? /// A Boolean value indicating whether there is a next page of events available. - public let hasNextPage: Bool + public let hasNextPage: Bool? + + public init(data: [SuiEvent], nextCursor: EventId? = nil, pageInfo: PageInfo? = nil, hasNextPage: Bool? = nil) { + self.data = data + self.nextCursor = nextCursor + self.pageInfo = pageInfo + self.hasNextPage = hasNextPage + } } diff --git a/Sources/SuiKit/Types/Structs/Faucet/Event/SuiEvent.swift b/Sources/SuiKit/Types/Structs/Faucet/Event/SuiEvent.swift index 970aeb9..0936f6a 100644 --- a/Sources/SuiKit/Types/Structs/Faucet/Event/SuiEvent.swift +++ b/Sources/SuiKit/Types/Structs/Faucet/Event/SuiEvent.swift @@ -28,7 +28,7 @@ import SwiftyJSON public struct SuiEvent { /// The unique identifier of the event. - public let id: EventId + public let id: EventId? /// The identifier of the package associated with the event. public let packageId: objectId @@ -65,4 +65,15 @@ public struct SuiEvent { self.bcs = input["bcs"].string self.timestampMs = input["timestampMs"].string } + + public init(graphql: QueryEventsQuery.Data.EventConnection.Node) { + self.id = nil // TODO: Turn ID into an Object + self.bcs = graphql.bcs + self.packageId = graphql.sendingModule!.package.asObject.address + self.parsedJson = JSON(parseJSON: graphql.JSONApollo) + self.sender = try! AccountAddress.fromHex(graphql.senders![0].address) + self.timestampMs = graphql.timestamp + self.transactionModule = graphql.sendingModule != nil ? graphql.sendingModule!.name : "NONE" + self.type = graphql.type.repr + } } diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_CREDENTIAL_FIELDS.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_CREDENTIAL_FIELDS.graphql.swift new file mode 100644 index 0000000..3e2477e --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_CREDENTIAL_FIELDS.graphql.swift @@ -0,0 +1,35 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public struct RPC_CREDENTIAL_FIELDS: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_CREDENTIAL_FIELDS on ValidatorCredentials { __typename netAddress networkPubKey p2PAddress primaryAddress workerPubKey workerAddress proofOfPossession protocolPubKey }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorCredentials } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("netAddress", String?.self), + .field("networkPubKey", SuiKit.Base64Apollo?.self), + .field("p2PAddress", String?.self), + .field("primaryAddress", String?.self), + .field("workerPubKey", SuiKit.Base64Apollo?.self), + .field("workerAddress", String?.self), + .field("proofOfPossession", SuiKit.Base64Apollo?.self), + .field("protocolPubKey", SuiKit.Base64Apollo?.self), + ] } + + public var netAddress: String? { __data["netAddress"] } + public var networkPubKey: SuiKit.Base64Apollo? { __data["networkPubKey"] } + public var p2PAddress: String? { __data["p2PAddress"] } + public var primaryAddress: String? { __data["primaryAddress"] } + public var workerPubKey: SuiKit.Base64Apollo? { __data["workerPubKey"] } + public var workerAddress: String? { __data["workerAddress"] } + public var proofOfPossession: SuiKit.Base64Apollo? { __data["proofOfPossession"] } + public var protocolPubKey: SuiKit.Base64Apollo? { __data["protocolPubKey"] } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_Checkpoint_Fields.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_Checkpoint_Fields.graphql.swift new file mode 100644 index 0000000..da32f46 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_Checkpoint_Fields.graphql.swift @@ -0,0 +1,134 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public struct RPC_Checkpoint_Fields: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_Checkpoint_Fields on Checkpoint { __typename digest epoch { __typename epochId } rollingGasSummary { __typename computationCost storageCost storageRebate nonRefundableStorageFee } networkTotalTransactions previousCheckpointDigest sequenceNumber timestamp transactionBlocks { __typename nodes { __typename digest } } validatorSignatures }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Checkpoint } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("digest", String.self), + .field("epoch", Epoch?.self), + .field("rollingGasSummary", RollingGasSummary?.self), + .field("networkTotalTransactions", Int?.self), + .field("previousCheckpointDigest", String?.self), + .field("sequenceNumber", Int.self), + .field("timestamp", SuiKit.DateTimeApollo.self), + .field("transactionBlocks", TransactionBlocks?.self), + .field("validatorSignatures", SuiKit.Base64Apollo.self), + ] } + + /// A 32-byte hash that uniquely identifies the checkpoint contents, encoded in Base58. This + /// hash can be used to verify checkpoint contents by checking signatures against the committee, + /// Hashing contents to match digest, and checking that the previous checkpoint digest matches. + public var digest: String { __data["digest"] } + /// The epoch this checkpoint is part of. + public var epoch: Epoch? { __data["epoch"] } + /// The computation cost, storage cost, storage rebate, and non-refundable storage fee + /// accumulated during this epoch, up to and including this checkpoint. These values increase + /// monotonically across checkpoints in the same epoch, and reset on epoch boundaries. + public var rollingGasSummary: RollingGasSummary? { __data["rollingGasSummary"] } + /// The total number of transaction blocks in the network by the end of this checkpoint. + public var networkTotalTransactions: Int? { __data["networkTotalTransactions"] } + /// The digest of the checkpoint at the previous sequence number. + public var previousCheckpointDigest: String? { __data["previousCheckpointDigest"] } + /// This checkpoint's position in the total order of finalized checkpoints, agreed upon by + /// consensus. + public var sequenceNumber: Int { __data["sequenceNumber"] } + /// The timestamp at which the checkpoint is agreed to have happened according to consensus. + /// Transactions that access time in this checkpoint will observe this timestamp. + public var timestamp: SuiKit.DateTimeApollo { __data["timestamp"] } + /// Transactions in this checkpoint. + public var transactionBlocks: TransactionBlocks? { __data["transactionBlocks"] } + /// This is an aggregation of signatures from a quorum of validators for the checkpoint + /// proposal. + public var validatorSignatures: SuiKit.Base64Apollo { __data["validatorSignatures"] } + + /// Epoch + /// + /// Parent Type: `Epoch` + public struct Epoch: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Epoch } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("epochId", Int.self), + ] } + + /// The epoch's id as a sequence number that starts at 0 and is incremented by one at every epoch change + public var epochId: Int { __data["epochId"] } + } + + /// RollingGasSummary + /// + /// Parent Type: `GasCostSummary` + public struct RollingGasSummary: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.GasCostSummary } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("computationCost", SuiKit.BigIntApollo?.self), + .field("storageCost", SuiKit.BigIntApollo?.self), + .field("storageRebate", SuiKit.BigIntApollo?.self), + .field("nonRefundableStorageFee", SuiKit.BigIntApollo?.self), + ] } + + /// Gas paid for executing this transaction (in MIST). + public var computationCost: SuiKit.BigIntApollo? { __data["computationCost"] } + /// Gas paid for the data stored on-chain by this transaction (in MIST). + public var storageCost: SuiKit.BigIntApollo? { __data["storageCost"] } + /// Part of storage cost that can be reclaimed by cleaning up data created by this transaction + /// (when objects are deleted or an object is modified, which is treated as a deletion followed + /// by a creation) (in MIST). + public var storageRebate: SuiKit.BigIntApollo? { __data["storageRebate"] } + /// Part of storage cost that is not reclaimed when data created by this transaction is cleaned + /// up (in MIST). + public var nonRefundableStorageFee: SuiKit.BigIntApollo? { __data["nonRefundableStorageFee"] } + } + + /// TransactionBlockConnection + /// + /// Parent Type: `TransactionBlockConnection` + public struct TransactionBlocks: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlockConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("nodes", [Node].self), + ] } + + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// TransactionBlockConnection.Node + /// + /// Parent Type: `TransactionBlock` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlock } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("digest", String.self), + ] } + + /// A 32-byte hash that uniquely identifies the transaction block contents, encoded in Base58. + /// This serves as a unique id for the block on chain. + public var digest: String { __data["digest"] } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_EVENTS_FIELDS.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_EVENTS_FIELDS.graphql.swift new file mode 100644 index 0000000..2db5d4a --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_EVENTS_FIELDS.graphql.swift @@ -0,0 +1,136 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public struct RPC_EVENTS_FIELDS: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_EVENTS_FIELDS on Event { __typename sendingModule { __typename package { __typename asObject { __typename address } } name } senders { __typename address } type { __typename repr } JSONApollo bcs timestamp }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Event } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("sendingModule", SendingModule?.self), + .field("senders", [Sender]?.self), + .field("type", Type_SelectionSet.self), + .field("JSONApollo", SuiKit.JSONApollo.self), + .field("bcs", SuiKit.Base64Apollo.self), + .field("timestamp", SuiKit.DateTimeApollo?.self), + ] } + + /// The Move module containing some function that when called by + /// a programmable transaction block (PTB) emitted this event. + /// For example, if a PTB invokes A::m1::foo, which internally + /// calls A::m2::emit_event to emit an event, + /// the sending module would be A::m1. + public var sendingModule: SendingModule? { __data["sendingModule"] } + /// Addresses of the senders of the event + public var senders: [Sender]? { __data["senders"] } + public var type: Type_SelectionSet { __data["type"] } + /// Representation of a Move value in JSONApollo, where: + /// + /// - Addresses, IDs, and UIDs are represented in canonical form, as JSONApollo strings. + /// - Bools are represented by JSONApollo boolean literals. + /// - u8, u16, and u32 are represented as JSONApollo numbers. + /// - u64, u128, and u256 are represented as JSONApollo strings. + /// - Vectors are represented by JSONApollo arrays. + /// - Structs are represented by JSONApollo objects. + /// - Empty optional values are represented by `null`. + /// + /// This form is offered as a less verbose convenience in cases where the layout of the type is + /// known by the client. + public var JSONApollo: SuiKit.JSONApollo { __data["JSONApollo"] } + public var bcs: SuiKit.Base64Apollo { __data["bcs"] } + /// UTC timestamp in milliseconds since epoch (1/1/1970) + public var timestamp: SuiKit.DateTimeApollo? { __data["timestamp"] } + + /// SendingModule + /// + /// Parent Type: `MoveModule` + public struct SendingModule: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModule } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("package", Package.self), + .field("name", String.self), + ] } + + /// The package that this Move module was defined in + public var package: Package { __data["package"] } + /// The module's (unqualified) name. + public var name: String { __data["name"] } + + /// SendingModule.Package + /// + /// Parent Type: `MovePackage` + public struct Package: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MovePackage } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asObject", AsObject.self), + ] } + + public var asObject: AsObject { __data["asObject"] } + + /// SendingModule.Package.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + } + + /// Sender + /// + /// Parent Type: `Address` + public struct Sender: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_MOVE_FUNCTION_FIELDS.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_MOVE_FUNCTION_FIELDS.graphql.swift new file mode 100644 index 0000000..0738066 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_MOVE_FUNCTION_FIELDS.graphql.swift @@ -0,0 +1,92 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI +import SwiftyJSON + +public struct RPC_MOVE_FUNCTION_FIELDS: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_MOVE_FUNCTION_FIELDS on MoveFunction { name visibility isEntry parameters { signature } typeParameters { constraints } return { repr signature } }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveFunction } + public static var __selections: [ApolloAPI.Selection] { [ + .field("name", String.self), + .field("visibility", GraphQLEnum?.self), + .field("isEntry", Bool?.self), + .field("parameters", [Parameter]?.self), + .field("typeParameters", [TypeParameter]?.self), + .field("return", [Return]?.self), + ] } + + /// The function's (unqualified) name. + public var name: String { __data["name"] } + /// The function's visibility: `public`, `public(friend)`, or `private`. + public var visibility: GraphQLEnum? { __data["visibility"] } + /// Whether the function has the `entry` modifier or not. + public var isEntry: Bool? { __data["isEntry"] } + /// The function's parameter types. These types can reference type parameters introduce by this + /// function (see `typeParameters`). + public var parameters: [Parameter]? { __data["parameters"] } + /// Constraints on the function's formal type parameters. Move bytecode does not name type + /// parameters, so when they are referenced (e.g. in parameter and return types) they are + /// identified by their index in this list. + public var typeParameters: [TypeParameter]? { __data["typeParameters"] } + /// The function's return types. There can be multiple because functions in Move can return + /// multiple values. These types can reference type parameters introduced by this function (see + /// `typeParameters`). + public var `return`: [Return]? { __data["return"] } + + /// Parameter + /// + /// Parent Type: `OpenMoveType` + public struct Parameter: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.OpenMoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("signature", AnyHashable.self), + ] } + + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + + /// TypeParameter + /// + /// Parent Type: `MoveFunctionTypeParameter` + public struct TypeParameter: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveFunctionTypeParameter } + public static var __selections: [ApolloAPI.Selection] { [ + .field("constraints", [GraphQLEnum].self), + ] } + + public var constraints: [GraphQLEnum] { __data["constraints"] } + } + + /// Return + /// + /// Parent Type: `OpenMoveType` + public struct Return: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.OpenMoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("repr", String.self), + .field("signature", AnyHashable.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_MOVE_MODULE_FIELDS.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_MOVE_MODULE_FIELDS.graphql.swift new file mode 100644 index 0000000..4f29c20 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_MOVE_MODULE_FIELDS.graphql.swift @@ -0,0 +1,209 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public struct RPC_MOVE_MODULE_FIELDS: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_MOVE_MODULE_FIELDS on MoveModule { name friends(first: 50) { nodes { name package { asObject { address } } } } structs(first: 50) { nodes { ...RPC_MOVE_STRUCT_FIELDS } } fileFormatVersion functions(first: 50) { nodes { ...RPC_MOVE_FUNCTION_FIELDS } } }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModule } + public static var __selections: [ApolloAPI.Selection] { [ + .field("name", String.self), + .field("friends", Friends.self, arguments: ["first": .scalar(50)]), + .field("structs", Structs?.self, arguments: ["first": .scalar(50)]), + .field("fileFormatVersion", Int.self), + .field("functions", Functions?.self, arguments: ["first": .scalar(50)]), + ] } + + /// The module's (unqualified) name. + public var name: String { __data["name"] } + /// Modules that this module considers friends (these modules can access `public(friend)` + /// functions from this module). + public var friends: Friends { __data["friends"] } + /// Iterate through the structs defined in this module. + public var structs: Structs? { __data["structs"] } + /// Format version of this module's bytecode. + public var fileFormatVersion: Int { __data["fileFormatVersion"] } + /// Iterate through the signatures of functions defined in this module. + public var functions: Functions? { __data["functions"] } + + /// Friends + /// + /// Parent Type: `MoveModuleConnection` + public struct Friends: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModuleConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("nodes", [Node].self), + ] } + + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Friends.Node + /// + /// Parent Type: `MoveModule` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModule } + public static var __selections: [ApolloAPI.Selection] { [ + .field("name", String.self), + .field("package", Package.self), + ] } + + /// The module's (unqualified) name. + public var name: String { __data["name"] } + /// The package that this Move module was defined in + public var package: Package { __data["package"] } + + /// Friends.Node.Package + /// + /// Parent Type: `MovePackage` + public struct Package: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MovePackage } + public static var __selections: [ApolloAPI.Selection] { [ + .field("asObject", AsObject.self), + ] } + + public var asObject: AsObject { __data["asObject"] } + + /// Friends.Node.Package.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + } + } + + /// Structs + /// + /// Parent Type: `MoveStructConnection` + public struct Structs: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveStructConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("nodes", [Node].self), + ] } + + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Structs.Node + /// + /// Parent Type: `MoveStruct` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveStruct } + public static var __selections: [ApolloAPI.Selection] { [ + .fragment(RPC_MOVE_STRUCT_FIELDS.self), + ] } + + /// The struct's (unqualified) type name. + public var name: String { __data["name"] } + /// Abilities this struct has. + public var abilities: [GraphQLEnum]? { __data["abilities"] } + /// The names and types of the struct's fields. Field types reference type parameters, by their + /// index in the defining struct's `typeParameters` list. + public var fields: [RPC_MOVE_STRUCT_FIELDS.Field]? { __data["fields"] } + /// Constraints on the struct's formal type parameters. Move bytecode does not name type + /// parameters, so when they are referenced (e.g. in field types) they are identified by their + /// index in this list. + public var typeParameters: [RPC_MOVE_STRUCT_FIELDS.TypeParameter]? { __data["typeParameters"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_MOVE_STRUCT_FIELDS: RPC_MOVE_STRUCT_FIELDS { _toFragment() } + } + } + } + + /// Functions + /// + /// Parent Type: `MoveFunctionConnection` + public struct Functions: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveFunctionConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("nodes", [Node].self), + ] } + + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + public func filterUsable() -> [Node] { + return self.nodes.filter { + ($0.visibility != nil && ($0.visibility! == .public || $0.visibility! == .friend)) || + ($0.isEntry != nil && $0.isEntry!) + } + } + + /// Functions.Node + /// + /// Parent Type: `MoveFunction` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveFunction } + public static var __selections: [ApolloAPI.Selection] { [ + .fragment(RPC_MOVE_FUNCTION_FIELDS.self), + ] } + + /// The function's (unqualified) name. + public var name: String { __data["name"] } + /// The function's visibility: `public`, `public(friend)`, or `private`. + public var visibility: GraphQLEnum? { __data["visibility"] } + /// Whether the function has the `entry` modifier or not. + public var isEntry: Bool? { __data["isEntry"] } + /// The function's parameter types. These types can reference type parameters introduce by this + /// function (see `typeParameters`). + public var parameters: [RPC_MOVE_FUNCTION_FIELDS.Parameter]? { __data["parameters"] } + /// Constraints on the function's formal type parameters. Move bytecode does not name type + /// parameters, so when they are referenced (e.g. in parameter and return types) they are + /// identified by their index in this list. + public var typeParameters: [RPC_MOVE_FUNCTION_FIELDS.TypeParameter]? { __data["typeParameters"] } + /// The function's return types. There can be multiple because functions in Move can return + /// multiple values. These types can reference type parameters introduced by this function (see + /// `typeParameters`). + public var `return`: [RPC_MOVE_FUNCTION_FIELDS.Return]? { __data["return"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_MOVE_FUNCTION_FIELDS: RPC_MOVE_FUNCTION_FIELDS { _toFragment() } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_MOVE_STRUCT_FIELDS.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_MOVE_STRUCT_FIELDS.graphql.swift new file mode 100644 index 0000000..3a409a1 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_MOVE_STRUCT_FIELDS.graphql.swift @@ -0,0 +1,87 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public struct RPC_MOVE_STRUCT_FIELDS: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_MOVE_STRUCT_FIELDS on MoveStruct { __typename name abilities fields { __typename name type { __typename signature } } typeParameters { __typename isPhantom constraints } }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveStruct } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("name", String.self), + .field("abilities", [GraphQLEnum]?.self), + .field("fields", [Field]?.self), + .field("typeParameters", [TypeParameter]?.self), + ] } + + /// The struct's (unqualified) type name. + public var name: String { __data["name"] } + /// Abilities this struct has. + public var abilities: [GraphQLEnum]? { __data["abilities"] } + /// The names and types of the struct's fields. Field types reference type parameters, by their + /// index in the defining struct's `typeParameters` list. + public var fields: [Field]? { __data["fields"] } + /// Constraints on the struct's formal type parameters. Move bytecode does not name type + /// parameters, so when they are referenced (e.g. in field types) they are identified by their + /// index in this list. + public var typeParameters: [TypeParameter]? { __data["typeParameters"] } + + /// Field + /// + /// Parent Type: `MoveField` + public struct Field: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveField } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("name", String.self), + .field("type", Type_SelectionSet?.self), + ] } + + public var name: String { __data["name"] } + public var type: Type_SelectionSet? { __data["type"] } + + /// Field.Type_SelectionSet + /// + /// Parent Type: `OpenMoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.OpenMoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("signature", AnyHashable.self), + ] } + + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + + /// TypeParameter + /// + /// Parent Type: `MoveStructTypeParameter` + public struct TypeParameter: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveStructTypeParameter } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("isPhantom", Bool.self), + .field("constraints", [GraphQLEnum].self), + ] } + + public var isPhantom: Bool { __data["isPhantom"] } + public var constraints: [GraphQLEnum] { __data["constraints"] } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_OBJECT_FIELDS.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_OBJECT_FIELDS.graphql.swift new file mode 100644 index 0000000..b353e3f --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_OBJECT_FIELDS.graphql.swift @@ -0,0 +1,357 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public struct RPC_OBJECT_FIELDS: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_OBJECT_FIELDS on Object { objectId: address bcs @include(if: $showBcs) version asMoveObject @include(if: $showType) { contents { type { repr } } } asMoveObject @include(if: $showContent) { hasPublicTransfer contents { data type { repr layout signature } } } asMoveObject @include(if: $showBcs) { hasPublicTransfer contents { bcs type { repr } } } owner @include(if: $showOwner) { ... on AddressOwner { owner { address asAddress { address } asObject { address } } } } previousTransactionBlock @include(if: $showPreviousTransaction) { digest } storageRebate @include(if: $showStorageRebate) digest version display @include(if: $showDisplay) { key value error } }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", alias: "objectId", SuiKit.SuiAddressApollo.self), + .field("version", Int.self), + .field("digest", String.self), + .include(if: "showBcs", .field("bcs", SuiKit.Base64Apollo?.self)), + .include(if: "showType" || "showContent" || "showBcs", .field("asMoveObject", AsMoveObject?.self)), + .include(if: "showOwner", .field("owner", AnyHashable?.self)), + .include(if: "showPreviousTransaction", .field("previousTransactionBlock", PreviousTransactionBlock?.self)), + .include(if: "showStorageRebate", .field("storageRebate", SuiKit.BigIntApollo?.self)), + .include(if: "showDisplay", .field("display", [Display]?.self)), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var objectId: SuiKit.SuiAddressApollo { __data["objectId"] } + /// The Base64Apollo encoded bcs serialization of the object's content. + public var bcs: SuiKit.Base64Apollo? { __data["bcs"] } + public var version: Int { __data["version"] } + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: AnyHashable? { __data["owner"] } + /// The transaction block that created this version of the object. + public var previousTransactionBlock: PreviousTransactionBlock? { __data["previousTransactionBlock"] } + /// The amount of SUI we would rebate if this object gets deleted or mutated. + /// This number is recalculated based on the present storage gas price. + public var storageRebate: SuiKit.BigIntApollo? { __data["storageRebate"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The set of named templates defined on-chain for the type of this object, + /// to be handled off-chain. The server substitutes data from the object + /// into these templates to generate a display string per template. + public var display: [Display]? { __data["display"] } + + /// AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .include(if: "showType", .inlineFragment(IfShowType.self)), + .include(if: "showContent", .inlineFragment(IfShowContent.self)), + .include(if: "showBcs", .inlineFragment(IfShowBcs.self)), + ] } + + public var ifShowType: IfShowType? { _asInlineFragment() } + public var ifShowContent: IfShowContent? { _asInlineFragment() } + public var ifShowBcs: IfShowBcs? { _asInlineFragment() } + + /// AsMoveObject.IfShowType + /// + /// Parent Type: `MoveObject` + public struct IfShowType: SuiKit.InlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = RPC_OBJECT_FIELDS.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("contents", Contents?.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("type", Type_SelectionSet.self), + ] } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// AsMoveObject.IfShowContent + /// + /// Parent Type: `MoveObject` + public struct IfShowContent: SuiKit.InlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = RPC_OBJECT_FIELDS.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("hasPublicTransfer", Bool.self), + .field("contents", Contents?.self), + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("data", AnyHashable.self), + .field("bcs", AnyHashable.self), + .field("type", Type_SelectionSet.self) + ] } + + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var type: Type_SelectionSet { __data["type"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("repr", String.self), + .field("layout", AnyHashable.self), + .field("signature", AnyHashable.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// AsMoveObject.IfShowBcs + /// + /// Parent Type: `MoveObject` + public struct IfShowBcs: SuiKit.InlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = RPC_OBJECT_FIELDS.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("hasPublicTransfer", Bool.self), + .field("contents", Contents?.self), + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("bcs", SuiKit.Base64Apollo.self), + .field("data", AnyHashable.self), + .field("type", Type_SelectionSet.self) + ] } + + public var bcs: AnyHashable { __data["bcs"] } + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + + /// AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("repr", String.self), + .field("layout", AnyHashable.self), + .field("signature", AnyHashable.self) + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + } + + public struct OuterOwner: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Owner } + public static var __selections: [ApolloAPI.Selection] { [ + .field("owner", Owner.self), + ] } + + public var owner: Owner { __data["owner"] } + } + + /// Owner + /// + /// Parent Type: `Owner` + public struct Owner: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Owner } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", AnyHashable.self), + .field("asAddress", AnyHashable?.self), + .field("asObject", AnyHashable?.self), + ] } + + public var address: AnyHashable { __data["address"] } + public var asAddress: AnyHashable? { __data["asAddress"] } + public var asObject: AnyHashable? { __data["asObject"] } + + /// Owner.AsAddress + /// + /// Parent Type: `Address` + public struct AsAddress: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Owner.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + + /// PreviousTransactionBlock + /// + /// Parent Type: `TransactionBlock` + public struct PreviousTransactionBlock: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlock } + public static var __selections: [ApolloAPI.Selection] { [ + .field("digest", String.self), + ] } + + /// A 32-byte hash that uniquely identifies the transaction block contents, encoded in Base58. + /// This serves as a unique id for the block on chain. + public var digest: String { __data["digest"] } + } + + /// Display + /// + /// Parent Type: `DisplayEntry` + public struct Display: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.DisplayEntry } + public static var __selections: [ApolloAPI.Selection] { [ + .field("key", String.self), + .field("value", String?.self), + .field("error", String?.self), + ] } + + /// The identifier for a particular template string of the Display object. + public var key: String { __data["key"] } + /// The template string for the key with placeholder values substituted. + public var value: String? { __data["value"] } + /// An error string describing why the template could not be rendered. + public var error: String? { __data["error"] } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_STAKE_FIELDS.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_STAKE_FIELDS.graphql.swift new file mode 100644 index 0000000..41b16cb --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_STAKE_FIELDS.graphql.swift @@ -0,0 +1,148 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public struct RPC_STAKE_FIELDS: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_STAKE_FIELDS on StakedSui { __typename principal activatedEpoch { __typename epochId referenceGasPrice } requestedEpoch { __typename epochId } asMoveObject { __typename contents { __typename JSONApollo } asObject { __typename address } } estimatedReward }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.StakedSui } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("principal", SuiKit.BigIntApollo?.self), + .field("activatedEpoch", ActivatedEpoch?.self), + .field("requestedEpoch", RequestedEpoch?.self), + .field("asMoveObject", AsMoveObject.self), + .field("estimatedReward", SuiKit.BigIntApollo?.self), + ] } + + /// The SUI that was initially staked. + public var principal: SuiKit.BigIntApollo? { __data["principal"] } + /// The epoch at which this stake became active + public var activatedEpoch: ActivatedEpoch? { __data["activatedEpoch"] } + /// The epoch at which this object was requested to join a stake pool + public var requestedEpoch: RequestedEpoch? { __data["requestedEpoch"] } + /// The corresponding `0x3::staking_pool::StakedSui` Move object. + public var asMoveObject: AsMoveObject { __data["asMoveObject"] } + /// The estimated reward for this stake object, calculated as: + /// + /// principal * (initial_stake_rate / current_stake_rate - 1.0) + /// + /// Or 0, if this value is negative, where: + /// + /// - `initial_stake_rate` is the stake rate at the epoch this stake was activated at. + /// - `current_stake_rate` is the stake rate in the current epoch. + /// + /// This value is only available if the stake is active. + public var estimatedReward: SuiKit.BigIntApollo? { __data["estimatedReward"] } + + /// ActivatedEpoch + /// + /// Parent Type: `Epoch` + public struct ActivatedEpoch: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Epoch } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("epochId", Int.self), + .field("referenceGasPrice", SuiKit.BigIntApollo?.self), + ] } + + /// The epoch's id as a sequence number that starts at 0 and is incremented by one at every epoch change + public var epochId: Int { __data["epochId"] } + /// The minimum gas price that a quorum of validators are guaranteed to sign a transaction for + public var referenceGasPrice: SuiKit.BigIntApollo? { __data["referenceGasPrice"] } + } + + /// RequestedEpoch + /// + /// Parent Type: `Epoch` + public struct RequestedEpoch: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Epoch } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("epochId", Int.self), + ] } + + /// The epoch's id as a sequence number that starts at 0 and is incremented by one at every epoch change + public var epochId: Int { __data["epochId"] } + } + + /// AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("contents", Contents?.self), + .field("asObject", AsObject.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + /// Attempts to convert the Move object into an Object + /// This provides additional information such as version and digest on the top-level + public var asObject: AsObject { __data["asObject"] } + + /// AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("JSONApollo", SuiKit.JSONApollo.self), + ] } + + /// Representation of a Move value in JSONApollo, where: + /// + /// - Addresses, IDs, and UIDs are represented in canonical form, as JSONApollo strings. + /// - Bools are represented by JSONApollo boolean literals. + /// - u8, u16, and u32 are represented as JSONApollo numbers. + /// - u64, u128, and u256 are represented as JSONApollo strings. + /// - Vectors are represented by JSONApollo arrays. + /// - Structs are represented by JSONApollo objects. + /// - Empty optional values are represented by `null`. + /// + /// This form is offered as a less verbose convenience in cases where the layout of the type is + /// known by the client. + public var JSONApollo: SuiKit.JSONApollo { __data["JSONApollo"] } + } + + /// AsMoveObject.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_TRANSACTION_FIELDS.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_TRANSACTION_FIELDS.graphql.swift new file mode 100644 index 0000000..6c763c2 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_TRANSACTION_FIELDS.graphql.swift @@ -0,0 +1,1024 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public struct RPC_TRANSACTION_FIELDS: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_TRANSACTION_FIELDS on TransactionBlock { __typename digest rawTransaction: bcs @include(if: $showInput) rawTransaction: bcs @include(if: $showRawInput) sender { __typename address } signatures events(first: 50) @include(if: $showEvents) { __typename nodes { __typename ...RPC_EVENTS_FIELDS } } effects { __typename checkpoint { __typename sequenceNumber } timestamp balanceChanges @include(if: $showBalanceChanges) { __typename coinType { __typename repr } owner { __typename asAddress { __typename address } asObject { __typename address } } amount } dependencies @include(if: $showEffects) { __typename digest } status @include(if: $showEffects) gasEffects @include(if: $showEffects) { __typename gasObject { __typename owner { __typename asAddress { __typename address } asObject { __typename address } } digest version address } gasSummary { __typename storageCost storageRebate nonRefundableStorageFee computationCost } } executedEpoch: epoch @include(if: $showEffects) { __typename epochId } objectChanges @include(if: $showEffects) { __typename idCreated idDeleted inputState { __typename version digest address } outputState { __typename version digest address owner { __typename asAddress { __typename address } asObject { __typename address } } } } objectChanges @include(if: $showObjectChanges) { __typename idCreated idDeleted inputState { __typename version digest address asMoveObject { __typename contents { __typename type { __typename repr } } } owner { __typename asAddress { __typename address } asObject { __typename address } } } outputState { __typename version digest address asMoveObject { __typename contents { __typename type { __typename repr } } } owner { __typename asAddress { __typename address } asObject { __typename address } } } } } }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlock } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("digest", String.self), + .field("sender", Sender?.self), + .field("signatures", [SuiKit.Base64Apollo]?.self), + .field("effects", Effects?.self), + .include(if: "showInput" || "showRawInput", .field("bcs", alias: "rawTransaction", SuiKit.Base64Apollo?.self)), + .include(if: "showEvents", .field("events", Events.self, arguments: ["first": 50])), + ] } + + /// A 32-byte hash that uniquely identifies the transaction block contents, encoded in Base58. + /// This serves as a unique id for the block on chain. + public var digest: String { __data["digest"] } + /// Serialized form of this transaction's `SenderSignedData`, BCS serialized and Base64Apollo encoded. + public var rawTransaction: SuiKit.Base64Apollo? { __data["rawTransaction"] } + /// The address corresponding to the public key that signed this transaction. System + /// transactions do not have senders. + public var sender: Sender? { __data["sender"] } + /// A list of all signatures, Base64Apollo-encoded, from senders, and potentially the gas owner if + /// this is a sponsored transaction. + public var signatures: [SuiKit.Base64Apollo]? { __data["signatures"] } + /// Events emitted by this transaction block. + public var events: Events? { __data["events"] } + /// The effects field captures the results to the chain of executing this transaction. + public var effects: Effects? { __data["effects"] } + + /// Sender + /// + /// Parent Type: `Address` + public struct Sender: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Events + /// + /// Parent Type: `EventConnection` + public struct Events: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.EventConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("nodes", [Node].self), + ] } + + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Events.Node + /// + /// Parent Type: `Event` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Event } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_EVENTS_FIELDS.self), + ] } + + /// The Move module containing some function that when called by + /// a programmable transaction block (PTB) emitted this event. + /// For example, if a PTB invokes A::m1::foo, which internally + /// calls A::m2::emit_event to emit an event, + /// the sending module would be A::m1. + public var sendingModule: RPC_EVENTS_FIELDS.SendingModule? { __data["sendingModule"] } + /// Addresses of the senders of the event + public var senders: [RPC_EVENTS_FIELDS.Sender]? { __data["senders"] } + public var type: RPC_EVENTS_FIELDS.Type_SelectionSet { __data["type"] } + /// Representation of a Move value in JSONApollo, where: + /// + /// - Addresses, IDs, and UIDs are represented in canonical form, as JSONApollo strings. + /// - Bools are represented by JSONApollo boolean literals. + /// - u8, u16, and u32 are represented as JSONApollo numbers. + /// - u64, u128, and u256 are represented as JSONApollo strings. + /// - Vectors are represented by JSONApollo arrays. + /// - Structs are represented by JSONApollo objects. + /// - Empty optional values are represented by `null`. + /// + /// This form is offered as a less verbose convenience in cases where the layout of the type is + /// known by the client. + public var JSONApollo: SuiKit.JSONApollo { __data["JSONApollo"] } + public var bcs: SuiKit.Base64Apollo { __data["bcs"] } + /// UTC timestamp in milliseconds since epoch (1/1/1970) + public var timestamp: SuiKit.DateTimeApollo? { __data["timestamp"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_EVENTS_FIELDS: RPC_EVENTS_FIELDS { _toFragment() } + } + } + } + + /// Effects + /// + /// Parent Type: `TransactionBlockEffects` + public struct Effects: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlockEffects } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("checkpoint", Checkpoint?.self), + .field("timestamp", SuiKit.DateTimeApollo?.self), + .include(if: "showBalanceChanges", .field("balanceChanges", [BalanceChange]?.self)), + .include(if: "showEffects", [ + .field("dependencies", [Dependency]?.self), + .field("status", GraphQLEnum?.self), + .field("gasEffects", GasEffects?.self), + .field("epoch", alias: "executedEpoch", ExecutedEpoch?.self), + ]), + .include(if: "showEffects" || "showObjectChanges", .field("objectChanges", [ObjectChange]?.self)), + ] } + + /// The checkpoint this transaction was finalized in. + public var checkpoint: Checkpoint? { __data["checkpoint"] } + /// Timestamp corresponding to the checkpoint this transaction was finalized in. + public var timestamp: SuiKit.DateTimeApollo? { __data["timestamp"] } + /// The effect this transaction had on the balances (sum of coin values per coin type) of + /// addresses and objects. + public var balanceChanges: [BalanceChange]? { __data["balanceChanges"] } + /// Transactions whose outputs this transaction depends upon. + public var dependencies: [Dependency]? { __data["dependencies"] } + /// Whether the transaction executed successfully or not. + public var status: GraphQLEnum? { __data["status"] } + /// Effects to the gas object. + public var gasEffects: GasEffects? { __data["gasEffects"] } + /// The epoch this transaction was finalized in. + public var executedEpoch: ExecutedEpoch? { __data["executedEpoch"] } + /// The effect this transaction had on objects on-chain. + public var objectChanges: [ObjectChange]? { __data["objectChanges"] } + + /// Effects.Checkpoint + /// + /// Parent Type: `Checkpoint` + public struct Checkpoint: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Checkpoint } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("sequenceNumber", Int.self), + ] } + + /// This checkpoint's position in the total order of finalized checkpoints, agreed upon by + /// consensus. + public var sequenceNumber: Int { __data["sequenceNumber"] } + } + + /// Effects.BalanceChange + /// + /// Parent Type: `BalanceChange` + public struct BalanceChange: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.BalanceChange } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("coinType", CoinType?.self), + .field("owner", Owner?.self), + .field("amount", SuiKit.BigIntApollo?.self), + ] } + + /// The inner type of the coin whose balance has changed (e.g. `0x2::sui::SUI`). + public var coinType: CoinType? { __data["coinType"] } + /// The address or object whose balance has changed. + public var owner: Owner? { __data["owner"] } + /// The signed balance change. + public var amount: SuiKit.BigIntApollo? { __data["amount"] } + + /// Effects.BalanceChange.CoinType + /// + /// Parent Type: `MoveType` + public struct CoinType: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + + /// Effects.BalanceChange.Owner + /// + /// Parent Type: `Owner` + public struct Owner: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Owner } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asAddress", AsAddress?.self), + .field("asObject", AsObject?.self), + ] } + + public var asAddress: AsAddress? { __data["asAddress"] } + public var asObject: AsObject? { __data["asObject"] } + + /// Effects.BalanceChange.Owner.AsAddress + /// + /// Parent Type: `Address` + public struct AsAddress: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Effects.BalanceChange.Owner.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + } + + /// Effects.Dependency + /// + /// Parent Type: `TransactionBlock` + public struct Dependency: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlock } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("digest", String.self), + ] } + + /// A 32-byte hash that uniquely identifies the transaction block contents, encoded in Base58. + /// This serves as a unique id for the block on chain. + public var digest: String { __data["digest"] } + } + + /// Effects.GasEffects + /// + /// Parent Type: `GasEffects` + public struct GasEffects: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.GasEffects } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("gasObject", GasObject?.self), + .field("gasSummary", GasSummary?.self), + ] } + + public var gasObject: GasObject? { __data["gasObject"] } + public var gasSummary: GasSummary? { __data["gasSummary"] } + + /// Effects.GasEffects.GasObject + /// + /// Parent Type: `Object` + public struct GasObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("owner", Owner?.self), + .field("digest", String.self), + .field("version", Int.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: Owner? { __data["owner"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + public var version: Int { __data["version"] } + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + + /// Effects.GasEffects.GasObject.Owner + /// + /// Parent Type: `Owner` + public struct Owner: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Owner } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asAddress", AsAddress?.self), + .field("asObject", AsObject?.self), + ] } + + public var asAddress: AsAddress? { __data["asAddress"] } + public var asObject: AsObject? { __data["asObject"] } + + /// Effects.GasEffects.GasObject.Owner.AsAddress + /// + /// Parent Type: `Address` + public struct AsAddress: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Effects.GasEffects.GasObject.Owner.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + } + + /// Effects.GasEffects.GasSummary + /// + /// Parent Type: `GasCostSummary` + public struct GasSummary: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.GasCostSummary } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("storageCost", SuiKit.BigIntApollo?.self), + .field("storageRebate", SuiKit.BigIntApollo?.self), + .field("nonRefundableStorageFee", SuiKit.BigIntApollo?.self), + .field("computationCost", SuiKit.BigIntApollo?.self), + ] } + + /// Gas paid for the data stored on-chain by this transaction (in MIST). + public var storageCost: SuiKit.BigIntApollo? { __data["storageCost"] } + /// Part of storage cost that can be reclaimed by cleaning up data created by this transaction + /// (when objects are deleted or an object is modified, which is treated as a deletion followed + /// by a creation) (in MIST). + public var storageRebate: SuiKit.BigIntApollo? { __data["storageRebate"] } + /// Part of storage cost that is not reclaimed when data created by this transaction is cleaned + /// up (in MIST). + public var nonRefundableStorageFee: SuiKit.BigIntApollo? { __data["nonRefundableStorageFee"] } + /// Gas paid for executing this transaction (in MIST). + public var computationCost: SuiKit.BigIntApollo? { __data["computationCost"] } + } + } + + /// Effects.ExecutedEpoch + /// + /// Parent Type: `Epoch` + public struct ExecutedEpoch: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Epoch } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("epochId", Int.self), + ] } + + /// The epoch's id as a sequence number that starts at 0 and is incremented by one at every epoch change + public var epochId: Int { __data["epochId"] } + } + + /// Effects.ObjectChange + /// + /// Parent Type: `ObjectChange` + public struct ObjectChange: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ObjectChange } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .include(if: "showEffects", .inlineFragment(IfShowEffects.self)), + .include(if: "showObjectChanges", .inlineFragment(IfShowObjectChanges.self)), + ] } + + public var ifShowEffects: IfShowEffects? { _asInlineFragment() } + public var ifShowObjectChanges: IfShowObjectChanges? { _asInlineFragment() } + + /// Effects.ObjectChange.IfShowEffects + /// + /// Parent Type: `ObjectChange` + public struct IfShowEffects: SuiKit.InlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = RPC_TRANSACTION_FIELDS.Effects.ObjectChange + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ObjectChange } + public static var __selections: [ApolloAPI.Selection] { [ + .field("idCreated", Bool?.self), + .field("idDeleted", Bool?.self), + .field("inputState", InputState?.self), + .field("outputState", OutputState?.self), + ] } + + /// Whether the ID was created in this transaction. + public var idCreated: Bool? { __data["idCreated"] } + /// Whether the ID was deleted in this transaction. + public var idDeleted: Bool? { __data["idDeleted"] } + /// The contents of the object immediately before the transaction. + public var inputState: InputState? { __data["inputState"] } + /// The contents of the object immediately after the transaction. + public var outputState: OutputState? { __data["outputState"] } + + /// Effects.ObjectChange.InputState + /// + /// Parent Type: `Object` + public struct InputState: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("version", Int.self), + .field("digest", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var version: Int { __data["version"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: Owner? { __data["owner"] } + } + + /// Effects.ObjectChange.OutputState.Owner + /// + /// Parent Type: `Owner` + public struct Owner: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Owner } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asAddress", AsAddress?.self), + .field("asObject", AsObject?.self), + ] } + + public var asAddress: AsAddress? { __data["asAddress"] } + public var asObject: AsObject? { __data["asObject"] } + + /// Effects.ObjectChange.OutputState.Owner.AsAddress + /// + /// Parent Type: `Address` + public struct AsAddress: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Effects.ObjectChange.OutputState.Owner.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + + /// Effects.ObjectChange.InputState.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("contents", Contents?.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Effects.ObjectChange.InputState.AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("type", Type_SelectionSet.self), + ] } + + public var type: Type_SelectionSet { __data["type"] } + + /// Effects.ObjectChange.InputState.AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + } + + /// Effects.ObjectChange.OutputState + /// + /// Parent Type: `Object` + public struct OutputState: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("version", Int.self), + .field("digest", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + .field("owner", Owner?.self), + ] } + + public var version: Int { __data["version"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: Owner? { __data["owner"] } + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + + /// Effects.ObjectChange.InputState.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("contents", Contents?.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Effects.ObjectChange.InputState.AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("type", Type_SelectionSet.self), + ] } + + public var type: Type_SelectionSet { __data["type"] } + + /// Effects.ObjectChange.InputState.AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + } + + /// Effects.ObjectChange.OutputState.Owner + /// + /// Parent Type: `Owner` + public struct Owner: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Owner } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asAddress", AsAddress?.self), + .field("asObject", AsObject?.self), + ] } + + public var asAddress: AsAddress? { __data["asAddress"] } + public var asObject: AsObject? { __data["asObject"] } + + /// Effects.ObjectChange.OutputState.Owner.AsAddress + /// + /// Parent Type: `Address` + public struct AsAddress: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Effects.ObjectChange.OutputState.Owner.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + } + } + + /// Effects.ObjectChange.IfShowObjectChanges + /// + /// Parent Type: `ObjectChange` + public struct IfShowObjectChanges: SuiKit.InlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = RPC_TRANSACTION_FIELDS.Effects.ObjectChange + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ObjectChange } + public static var __selections: [ApolloAPI.Selection] { [ + .field("idCreated", Bool?.self), + .field("idDeleted", Bool?.self), + .field("inputState", InputState?.self), + .field("outputState", OutputState?.self), + ] } + + /// Whether the ID was created in this transaction. + public var idCreated: Bool? { __data["idCreated"] } + /// Whether the ID was deleted in this transaction. + public var idDeleted: Bool? { __data["idDeleted"] } + /// The contents of the object immediately before the transaction. + public var inputState: InputState? { __data["inputState"] } + /// The contents of the object immediately after the transaction. + public var outputState: OutputState? { __data["outputState"] } + + /// Effects.ObjectChange.InputState + /// + /// Parent Type: `Object` + public struct InputState: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("version", Int.self), + .field("digest", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + .field("asMoveObject", AsMoveObject?.self), + .field("owner", Owner?.self), + ] } + + public var version: Int { __data["version"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: Owner? { __data["owner"] } + + /// Effects.ObjectChange.InputState.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("contents", Contents?.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Effects.ObjectChange.InputState.AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("type", Type_SelectionSet.self), + ] } + + public var type: Type_SelectionSet { __data["type"] } + + /// Effects.ObjectChange.InputState.AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + } + + /// Effects.ObjectChange.InputState.Owner + /// + /// Parent Type: `Owner` + public struct Owner: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Owner } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asAddress", AsAddress?.self), + .field("asObject", AsObject?.self), + ] } + + public var asAddress: AsAddress? { __data["asAddress"] } + public var asObject: AsObject? { __data["asObject"] } + + /// Effects.ObjectChange.InputState.Owner.AsAddress + /// + /// Parent Type: `Address` + public struct AsAddress: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Effects.ObjectChange.InputState.Owner.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + } + + /// Effects.ObjectChange.OutputState + /// + /// Parent Type: `Object` + public struct OutputState: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("version", Int.self), + .field("digest", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + .field("asMoveObject", AsMoveObject?.self), + .field("owner", Owner?.self), + ] } + + public var version: Int { __data["version"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: Owner? { __data["owner"] } + + /// Effects.ObjectChange.OutputState.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("contents", Contents?.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Effects.ObjectChange.OutputState.AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("type", Type_SelectionSet.self), + ] } + + public var type: Type_SelectionSet { __data["type"] } + + /// Effects.ObjectChange.OutputState.AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + } + + /// Effects.ObjectChange.OutputState.Owner + /// + /// Parent Type: `Owner` + public struct Owner: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Owner } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asAddress", AsAddress?.self), + .field("asObject", AsObject?.self), + ] } + + public var asAddress: AsAddress? { __data["asAddress"] } + public var asObject: AsObject? { __data["asObject"] } + + /// Effects.ObjectChange.OutputState.Owner.AsAddress + /// + /// Parent Type: `Address` + public struct AsAddress: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Effects.ObjectChange.OutputState.Owner.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_VALIDATOR_FIELDS.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_VALIDATOR_FIELDS.graphql.swift new file mode 100644 index 0000000..fa69fd7 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Fragments/RPC_VALIDATOR_FIELDS.graphql.swift @@ -0,0 +1,333 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public struct RPC_VALIDATOR_FIELDS: SuiKit.SelectionSet, Fragment { + public static var fragmentDefinition: StaticString { + #"fragment RPC_VALIDATOR_FIELDS on Validator { __typename atRisk commissionRate exchangeRatesSize exchangeRates { __typename contents { __typename JSONApollo } asObject { __typename address } } description gasPrice imageUrl name credentials { __typename ...RPC_CREDENTIAL_FIELDS } nextEpochCommissionRate nextEpochGasPrice nextEpochCredentials { __typename ...RPC_CREDENTIAL_FIELDS } nextEpochStake nextEpochCommissionRate operationCap { __typename asObject { __typename address } } pendingPoolTokenWithdraw pendingStake pendingTotalSuiWithdraw poolTokenBalance projectUrl rewardsPool stakingPool { __typename asObject { __typename address } } stakingPoolActivationEpoch stakingPoolSuiBalance address { __typename address } votingPower reportRecords { __typename address } }"# + } + + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Validator } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("atRisk", Int?.self), + .field("commissionRate", Int?.self), + .field("exchangeRatesSize", Int?.self), + .field("exchangeRates", ExchangeRates?.self), + .field("description", String?.self), + .field("gasPrice", SuiKit.BigIntApollo?.self), + .field("imageUrl", String?.self), + .field("name", String?.self), + .field("credentials", Credentials?.self), + .field("nextEpochCommissionRate", Int?.self), + .field("nextEpochGasPrice", SuiKit.BigIntApollo?.self), + .field("nextEpochCredentials", NextEpochCredentials?.self), + .field("nextEpochStake", SuiKit.BigIntApollo?.self), + .field("operationCap", OperationCap?.self), + .field("pendingPoolTokenWithdraw", SuiKit.BigIntApollo?.self), + .field("pendingStake", SuiKit.BigIntApollo?.self), + .field("pendingTotalSuiWithdraw", SuiKit.BigIntApollo?.self), + .field("poolTokenBalance", SuiKit.BigIntApollo?.self), + .field("projectUrl", String?.self), + .field("rewardsPool", SuiKit.BigIntApollo?.self), + .field("stakingPool", StakingPool?.self), + .field("stakingPoolActivationEpoch", Int?.self), + .field("stakingPoolSuiBalance", SuiKit.BigIntApollo?.self), + .field("address", Address.self), + .field("votingPower", Int?.self), + .field("reportRecords", [ReportRecord]?.self), + ] } + + /// The number of epochs for which this validator has been below the + /// low stake threshold. + public var atRisk: Int? { __data["atRisk"] } + /// The fee charged by the validator for staking services. + public var commissionRate: Int? { __data["commissionRate"] } + /// Number of exchange rates in the table. + public var exchangeRatesSize: Int? { __data["exchangeRatesSize"] } + /// The validator's current exchange object. The exchange rate is used to determine + /// the amount of SUI tokens that each past SUI staker can withdraw in the future. + public var exchangeRates: ExchangeRates? { __data["exchangeRates"] } + /// Validator's description. + public var description: String? { __data["description"] } + /// The reference gas price for this epoch. + public var gasPrice: SuiKit.BigIntApollo? { __data["gasPrice"] } + /// Validator's url containing their custom image. + public var imageUrl: String? { __data["imageUrl"] } + /// Validator's name. + public var name: String? { __data["name"] } + /// Validator's set of credentials. + public var credentials: Credentials? { __data["credentials"] } + /// The proposed next epoch fee for the validator's staking services. + public var nextEpochCommissionRate: Int? { __data["nextEpochCommissionRate"] } + /// The validator's gas price quote for the next epoch. + public var nextEpochGasPrice: SuiKit.BigIntApollo? { __data["nextEpochGasPrice"] } + /// Validator's set of credentials for the next epoch. + public var nextEpochCredentials: NextEpochCredentials? { __data["nextEpochCredentials"] } + /// The total number of SUI tokens in this pool plus + /// the pending stake amount for this epoch. + public var nextEpochStake: SuiKit.BigIntApollo? { __data["nextEpochStake"] } + /// The validator's current valid `Cap` object. Validators can delegate + /// the operation ability to another address. The address holding this `Cap` object + /// can then update the reference gas price and tallying rule on behalf of the validator. + public var operationCap: OperationCap? { __data["operationCap"] } + /// Pending pool token withdrawn during the current epoch, emptied at epoch boundaries. + public var pendingPoolTokenWithdraw: SuiKit.BigIntApollo? { __data["pendingPoolTokenWithdraw"] } + /// Pending stake amount for this epoch. + public var pendingStake: SuiKit.BigIntApollo? { __data["pendingStake"] } + /// Pending stake withdrawn during the current epoch, emptied at epoch boundaries. + public var pendingTotalSuiWithdraw: SuiKit.BigIntApollo? { __data["pendingTotalSuiWithdraw"] } + /// Total number of pool tokens issued by the pool. + public var poolTokenBalance: SuiKit.BigIntApollo? { __data["poolTokenBalance"] } + /// Validator's homepage URL. + public var projectUrl: String? { __data["projectUrl"] } + /// The epoch stake rewards will be added here at the end of each epoch. + public var rewardsPool: SuiKit.BigIntApollo? { __data["rewardsPool"] } + /// The validator's current staking pool object, used to track the amount of stake + /// and to compound staking rewards. + public var stakingPool: StakingPool? { __data["stakingPool"] } + /// The epoch at which this pool became active. + public var stakingPoolActivationEpoch: Int? { __data["stakingPoolActivationEpoch"] } + /// The total number of SUI tokens in this pool. + public var stakingPoolSuiBalance: SuiKit.BigIntApollo? { __data["stakingPoolSuiBalance"] } + /// Validator's address. + public var address: Address { __data["address"] } + /// The voting power of this validator in basis points (e.g., 100 = 1% voting power). + public var votingPower: Int? { __data["votingPower"] } + /// The addresses of other validators this validator has reported. + public var reportRecords: [ReportRecord]? { __data["reportRecords"] } + + /// ExchangeRates + /// + /// Parent Type: `MoveObject` + public struct ExchangeRates: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("contents", Contents?.self), + .field("asObject", AsObject.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + /// Attempts to convert the Move object into an Object + /// This provides additional information such as version and digest on the top-level + public var asObject: AsObject { __data["asObject"] } + + /// ExchangeRates.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("JSONApollo", SuiKit.JSONApollo.self), + ] } + + /// Representation of a Move value in JSONApollo, where: + /// + /// - Addresses, IDs, and UIDs are represented in canonical form, as JSONApollo strings. + /// - Bools are represented by JSONApollo boolean literals. + /// - u8, u16, and u32 are represented as JSONApollo numbers. + /// - u64, u128, and u256 are represented as JSONApollo strings. + /// - Vectors are represented by JSONApollo arrays. + /// - Structs are represented by JSONApollo objects. + /// - Empty optional values are represented by `null`. + /// + /// This form is offered as a less verbose convenience in cases where the layout of the type is + /// known by the client. + public var JSONApollo: SuiKit.JSONApollo { __data["JSONApollo"] } + } + + /// ExchangeRates.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + + /// Credentials + /// + /// Parent Type: `ValidatorCredentials` + public struct Credentials: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorCredentials } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_CREDENTIAL_FIELDS.self), + ] } + + public var netAddress: String? { __data["netAddress"] } + public var networkPubKey: SuiKit.Base64Apollo? { __data["networkPubKey"] } + public var p2PAddress: String? { __data["p2PAddress"] } + public var primaryAddress: String? { __data["primaryAddress"] } + public var workerPubKey: SuiKit.Base64Apollo? { __data["workerPubKey"] } + public var workerAddress: String? { __data["workerAddress"] } + public var proofOfPossession: SuiKit.Base64Apollo? { __data["proofOfPossession"] } + public var protocolPubKey: SuiKit.Base64Apollo? { __data["protocolPubKey"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_CREDENTIAL_FIELDS: RPC_CREDENTIAL_FIELDS { _toFragment() } + } + } + + /// NextEpochCredentials + /// + /// Parent Type: `ValidatorCredentials` + public struct NextEpochCredentials: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorCredentials } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_CREDENTIAL_FIELDS.self), + ] } + + public var netAddress: String? { __data["netAddress"] } + public var networkPubKey: SuiKit.Base64Apollo? { __data["networkPubKey"] } + public var p2PAddress: String? { __data["p2PAddress"] } + public var primaryAddress: String? { __data["primaryAddress"] } + public var workerPubKey: SuiKit.Base64Apollo? { __data["workerPubKey"] } + public var workerAddress: String? { __data["workerAddress"] } + public var proofOfPossession: SuiKit.Base64Apollo? { __data["proofOfPossession"] } + public var protocolPubKey: SuiKit.Base64Apollo? { __data["protocolPubKey"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_CREDENTIAL_FIELDS: RPC_CREDENTIAL_FIELDS { _toFragment() } + } + } + + /// OperationCap + /// + /// Parent Type: `MoveObject` + public struct OperationCap: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asObject", AsObject.self), + ] } + + /// Attempts to convert the Move object into an Object + /// This provides additional information such as version and digest on the top-level + public var asObject: AsObject { __data["asObject"] } + + /// OperationCap.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + + /// StakingPool + /// + /// Parent Type: `MoveObject` + public struct StakingPool: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asObject", AsObject.self), + ] } + + /// Attempts to convert the Move object into an Object + /// This provides additional information such as version and digest on the top-level + public var asObject: AsObject { __data["asObject"] } + + /// StakingPool.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + + /// Address + /// + /// Parent Type: `Address` + public struct Address: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// ReportRecord + /// + /// Parent Type: `Address` + public struct ReportRecord: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/GraphQLClient.swift b/Sources/SuiKit/Types/Structs/GraphQL/GraphQLClient.swift new file mode 100644 index 0000000..d908861 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/GraphQLClient.swift @@ -0,0 +1,49 @@ +// +// GraphQLClient.swift +// SuiKit +// +// Copyright (c) 2023 OpenDive +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation +import Apollo +import ApolloAPI + +/// A wrapper struct for being able to query data from the GraphQL node. +internal struct GraphQLClient { + /// Given the Apollo client and a query that conforms to the GraphQLQuery type, fetch data from that endpoint and return the conformed object representing the data. + /// - Parameters: + /// - client: The Apollo client used for sending the query out. + /// - query: The query itself containing information such as user inputs parameters, the endpoint itself, and various other metadata for making the GraphQL client functional. + /// - Returns: A GraphQLResult object of either T.Data type, or throws an error. + internal static func fetchQuery(client: ApolloClient, query: T) async throws -> GraphQLResult { + return try await withCheckedThrowingContinuation { (con: CheckedContinuation, Error>) in + let _ = client.fetch(query: query) { result in + switch result { + case .success(let graphQLresult): + con.resume(returning: graphQLresult) + case .failure(let err): + con.resume(throwing: err) + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetAllBalancesQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetAllBalancesQuery.graphql.swift new file mode 100644 index 0000000..b81ec88 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetAllBalancesQuery.graphql.swift @@ -0,0 +1,143 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetAllBalancesQuery: GraphQLQuery { + public static let operationName: String = "getAllBalances" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getAllBalances($owner: SuiAddress!, $limit: Int, $cursor: String) { address(address: $owner) { __typename balanceConnection(first: $limit, after: $cursor) { __typename pageInfo { __typename hasNextPage endCursor } nodes { __typename coinType { __typename repr } coinObjectCount totalBalance } } } }"# + )) + + public var owner: SuiAddressApollo + public var limit: GraphQLNullable + public var cursor: GraphQLNullable + + public init( + owner: SuiAddressApollo, + limit: GraphQLNullable, + cursor: GraphQLNullable + ) { + self.owner = owner + self.limit = limit + self.cursor = cursor + } + + public var __variables: Variables? { [ + "owner": owner, + "limit": limit, + "cursor": cursor + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", Address?.self, arguments: ["address": .variable("owner")]), + ] } + + public var address: Address? { __data["address"] } + + /// Address + /// + /// Parent Type: `Address` + public struct Address: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("balanceConnection", BalanceConnection?.self, arguments: [ + "first": .variable("limit"), + "after": .variable("cursor") + ]), + ] } + + public var balanceConnection: BalanceConnection? { __data["balanceConnection"] } + + /// Address.BalanceConnection + /// + /// Parent Type: `BalanceConnection` + public struct BalanceConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.BalanceConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Address.BalanceConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// Address.BalanceConnection.Node + /// + /// Parent Type: `Balance` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Balance } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("coinType", CoinType?.self), + .field("coinObjectCount", Int?.self), + .field("totalBalance", SuiKit.BigIntApollo?.self), + ] } + + /// Coin type for the balance, such as 0x2::sui::SUI + public var coinType: CoinType? { __data["coinType"] } + /// How many coins of this type constitute the balance + public var coinObjectCount: Int? { __data["coinObjectCount"] } + /// Total balance across all coin objects of the coin type + public var totalBalance: SuiKit.BigIntApollo? { __data["totalBalance"] } + + /// Address.BalanceConnection.Node.CoinType + /// + /// Parent Type: `MoveType` + public struct CoinType: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetBalanceQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetBalanceQuery.graphql.swift new file mode 100644 index 0000000..7c7a197 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetBalanceQuery.graphql.swift @@ -0,0 +1,96 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetBalanceQuery: GraphQLQuery { + public static let operationName: String = "getBalance" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getBalance($owner: SuiAddress!, $type: String = "0x2::sui::SUI") { address(address: $owner) { __typename balance(type: $type) { __typename coinType { __typename repr } coinObjectCount totalBalance } } }"# + )) + + public var owner: SuiAddressApollo + public var type: GraphQLNullable + + public init( + owner: SuiAddressApollo, + type: GraphQLNullable = "0x2::sui::SUI" + ) { + self.owner = owner + self.type = type + } + + public var __variables: Variables? { [ + "owner": owner, + "type": type + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", Address?.self, arguments: ["address": .variable("owner")]), + ] } + + public var address: Address? { __data["address"] } + + /// Address + /// + /// Parent Type: `Address` + public struct Address: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("balance", Balance?.self, arguments: ["type": .variable("type")]), + ] } + + public var balance: Balance? { __data["balance"] } + + /// Address.Balance + /// + /// Parent Type: `Balance` + public struct Balance: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Balance } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("coinType", CoinType?.self), + .field("coinObjectCount", Int?.self), + .field("totalBalance", SuiKit.BigIntApollo?.self), + ] } + + /// Coin type for the balance, such as 0x2::sui::SUI + public var coinType: CoinType? { __data["coinType"] } + /// How many coins of this type constitute the balance + public var coinObjectCount: Int? { __data["coinObjectCount"] } + /// Total balance across all coin objects of the coin type + public var totalBalance: SuiKit.BigIntApollo? { __data["totalBalance"] } + + /// Address.Balance.CoinType + /// + /// Parent Type: `MoveType` + public struct CoinType: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetChainIdentifierQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetChainIdentifierQuery.graphql.swift new file mode 100644 index 0000000..8a51334 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetChainIdentifierQuery.graphql.swift @@ -0,0 +1,28 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetChainIdentifierQuery: GraphQLQuery { + public static let operationName: String = "getChainIdentifier" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getChainIdentifier { chainIdentifier }"# + )) + + public init() {} + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("chainIdentifier", String.self), + ] } + + /// First four bytes of the network's genesis checkpoint digest (uniquely identifies the + /// network). + public var chainIdentifier: String { __data["chainIdentifier"] } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCheckpointQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCheckpointQuery.graphql.swift new file mode 100644 index 0000000..162f48e --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCheckpointQuery.graphql.swift @@ -0,0 +1,82 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetCheckpointQuery: GraphQLQuery { + public static let operationName: String = "getCheckpoint" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getCheckpoint($id: CheckpointId) { checkpoint(id: $id) { __typename ...RPC_Checkpoint_Fields } }"#, + fragments: [RPC_Checkpoint_Fields.self] + )) + + public var id: GraphQLNullable + + public init(id: GraphQLNullable) { + self.id = id + } + + public var __variables: Variables? { ["id": id] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("checkpoint", Checkpoint?.self, arguments: ["id": .variable("id")]), + ] } + + /// Fetch checkpoint information by sequence number or digest (defaults to the latest available + /// checkpoint). + public var checkpoint: Checkpoint? { __data["checkpoint"] } + + /// Checkpoint + /// + /// Parent Type: `Checkpoint` + public struct Checkpoint: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Checkpoint } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_Checkpoint_Fields.self), + ] } + + /// A 32-byte hash that uniquely identifies the checkpoint contents, encoded in Base58. This + /// hash can be used to verify checkpoint contents by checking signatures against the committee, + /// Hashing contents to match digest, and checking that the previous checkpoint digest matches. + public var digest: String { __data["digest"] } + /// The epoch this checkpoint is part of. + public var epoch: RPC_Checkpoint_Fields.Epoch? { __data["epoch"] } + /// The computation cost, storage cost, storage rebate, and non-refundable storage fee + /// accumulated during this epoch, up to and including this checkpoint. These values increase + /// monotonically across checkpoints in the same epoch, and reset on epoch boundaries. + public var rollingGasSummary: RPC_Checkpoint_Fields.RollingGasSummary? { __data["rollingGasSummary"] } + /// The total number of transaction blocks in the network by the end of this checkpoint. + public var networkTotalTransactions: Int? { __data["networkTotalTransactions"] } + /// The digest of the checkpoint at the previous sequence number. + public var previousCheckpointDigest: String? { __data["previousCheckpointDigest"] } + /// This checkpoint's position in the total order of finalized checkpoints, agreed upon by + /// consensus. + public var sequenceNumber: Int { __data["sequenceNumber"] } + /// The timestamp at which the checkpoint is agreed to have happened according to consensus. + /// Transactions that access time in this checkpoint will observe this timestamp. + public var timestamp: SuiKit.DateTimeApollo { __data["timestamp"] } + /// Transactions in this checkpoint. + public var transactionBlockConnection: RPC_Checkpoint_Fields.TransactionBlocks? { __data["transactionBlocks"] } + /// This is an aggregation of signatures from a quorum of validators for the checkpoint + /// proposal. + public var validatorSignatures: SuiKit.Base64Apollo { __data["validatorSignatures"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_Checkpoint_Fields: RPC_Checkpoint_Fields { _toFragment() } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCheckpointsQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCheckpointsQuery.graphql.swift new file mode 100644 index 0000000..ec17c2f --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCheckpointsQuery.graphql.swift @@ -0,0 +1,147 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetCheckpointsQuery: GraphQLQuery { + public static let operationName: String = "getCheckpoints" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getCheckpoints($first: Int, $before: String, $last: Int, $after: String) { checkpoints(first: $first, after: $after, last: $last, before: $before) { __typename pageInfo { __typename startCursor endCursor hasNextPage hasPreviousPage } nodes { __typename ...RPC_Checkpoint_Fields } } }"#, + fragments: [RPC_Checkpoint_Fields.self] + )) + + public var first: GraphQLNullable + public var before: GraphQLNullable + public var last: GraphQLNullable + public var after: GraphQLNullable + + public init( + first: GraphQLNullable, + before: GraphQLNullable, + last: GraphQLNullable, + after: GraphQLNullable + ) { + self.first = first + self.before = before + self.last = last + self.after = after + } + + public var __variables: Variables? { [ + "first": first, + "before": before, + "last": last, + "after": after + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("checkpoints", Checkpoints.self, arguments: [ + "first": .variable("first"), + "after": .variable("after"), + "last": .variable("last"), + "before": .variable("before") + ]), + ] } + + public var checkpoints: Checkpoints { __data["checkpoints"] } + + /// Checkpoints + /// + /// Parent Type: `CheckpointConnection` + public struct Checkpoints: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.CheckpointConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Checkpoints.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("startCursor", String?.self), + .field("endCursor", String?.self), + .field("hasNextPage", Bool.self), + .field("hasPreviousPage", Bool.self), + ] } + + /// When paginating backwards, the cursor to continue. + public var startCursor: String? { __data["startCursor"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating backwards, are there more items? + public var hasPreviousPage: Bool { __data["hasPreviousPage"] } + } + + /// Checkpoints.Node + /// + /// Parent Type: `Checkpoint` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Checkpoint } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_Checkpoint_Fields.self), + ] } + + /// A 32-byte hash that uniquely identifies the checkpoint contents, encoded in Base58. This + /// hash can be used to verify checkpoint contents by checking signatures against the committee, + /// Hashing contents to match digest, and checking that the previous checkpoint digest matches. + public var digest: String { __data["digest"] } + /// The epoch this checkpoint is part of. + public var epoch: RPC_Checkpoint_Fields.Epoch? { __data["epoch"] } + /// The computation cost, storage cost, storage rebate, and non-refundable storage fee + /// accumulated during this epoch, up to and including this checkpoint. These values increase + /// monotonically across checkpoints in the same epoch, and reset on epoch boundaries. + public var rollingGasSummary: RPC_Checkpoint_Fields.RollingGasSummary? { __data["rollingGasSummary"] } + /// The total number of transaction blocks in the network by the end of this checkpoint. + public var networkTotalTransactions: Int? { __data["networkTotalTransactions"] } + /// The digest of the checkpoint at the previous sequence number. + public var previousCheckpointDigest: String? { __data["previousCheckpointDigest"] } + /// This checkpoint's position in the total order of finalized checkpoints, agreed upon by + /// consensus. + public var sequenceNumber: Int { __data["sequenceNumber"] } + /// The timestamp at which the checkpoint is agreed to have happened according to consensus. + /// Transactions that access time in this checkpoint will observe this timestamp. + public var timestamp: SuiKit.DateTimeApollo { __data["timestamp"] } + /// Transactions in this checkpoint. + public var transactionBlockConnection: RPC_Checkpoint_Fields.TransactionBlocks? { __data["transactionBlocks"] } + /// This is an aggregation of signatures from a quorum of validators for the checkpoint + /// proposal. + public var validatorSignatures: SuiKit.Base64Apollo { __data["validatorSignatures"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_Checkpoint_Fields: RPC_Checkpoint_Fields { _toFragment() } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCoinMetadataQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCoinMetadataQuery.graphql.swift new file mode 100644 index 0000000..7c2572a --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCoinMetadataQuery.graphql.swift @@ -0,0 +1,98 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetCoinMetadataQuery: GraphQLQuery { + public static let operationName: String = "getCoinMetadata" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getCoinMetadata($coinType: String!) { coinMetadata(coinType: $coinType) { __typename decimals name symbol description iconUrl asMoveObject { __typename asObject { __typename address } } } }"# + )) + + public var coinType: String + + public init(coinType: String) { + self.coinType = coinType + } + + public var __variables: Variables? { ["coinType": coinType] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("coinMetadata", CoinMetadata?.self, arguments: ["coinType": .variable("coinType")]), + ] } + + public var coinMetadata: CoinMetadata? { __data["coinMetadata"] } + + /// CoinMetadata + /// + /// Parent Type: `CoinMetadata` + public struct CoinMetadata: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.CoinMetadata } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("decimals", Int?.self), + .field("name", String?.self), + .field("symbol", String?.self), + .field("description", String?.self), + .field("iconUrl", String?.self), + .field("asMoveObject", AsMoveObject.self), + ] } + + /// The number of decimal places used to represent the token. + public var decimals: Int? { __data["decimals"] } + /// Full, official name of the token. + public var name: String? { __data["name"] } + /// The token's identifying abbreviation. + public var symbol: String? { __data["symbol"] } + /// Optional description of the token, provided by the creator of the token. + public var description: String? { __data["description"] } + public var iconUrl: String? { __data["iconUrl"] } + /// Convert the coin metadata object into a Move object. + public var asMoveObject: AsMoveObject { __data["asMoveObject"] } + + /// CoinMetadata.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asObject", AsObject.self), + ] } + + /// Attempts to convert the Move object into an Object + /// This provides additional information such as version and digest on the top-level + public var asObject: AsObject { __data["asObject"] } + + /// CoinMetadata.AsMoveObject.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCoinsQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCoinsQuery.graphql.swift new file mode 100644 index 0000000..b6338f8 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCoinsQuery.graphql.swift @@ -0,0 +1,232 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetCoinsQuery: GraphQLQuery { + public static let operationName: String = "getCoins" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getCoins($owner: SuiAddress!, $first: Int, $cursor: String, $type: String = "0x2::sui::SUI") { address(address: $owner) { __typename address coinConnection(first: $first, after: $cursor, type: $type) { __typename pageInfo { __typename hasNextPage endCursor } nodes { __typename balance asMoveObject { __typename contents { __typename type { __typename repr } } asObject { __typename coinObjectId: address version digest previousTransactionBlock { __typename digest } } } } } } }"# + )) + + public var owner: SuiAddressApollo + public var first: GraphQLNullable + public var cursor: GraphQLNullable + public var type: GraphQLNullable + + public init( + owner: SuiAddressApollo, + first: GraphQLNullable, + cursor: GraphQLNullable, + type: GraphQLNullable = "0x2::sui::SUI" + ) { + self.owner = owner + self.first = first + self.cursor = cursor + self.type = type + } + + public var __variables: Variables? { [ + "owner": owner, + "first": first, + "cursor": cursor, + "type": type + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", Address?.self, arguments: ["address": .variable("owner")]), + ] } + + public var address: Address? { __data["address"] } + + /// Address + /// + /// Parent Type: `Address` + public struct Address: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + .field("coinConnection", CoinConnection?.self, arguments: [ + "first": .variable("first"), + "after": .variable("cursor"), + "type": .variable("type") + ]), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + /// The coin objects for the given address. + /// The type field is a string of the inner type of the coin + /// by which to filter (e.g., 0x2::sui::SUI). + public var coinConnection: CoinConnection? { __data["coinConnection"] } + + /// Address.CoinConnection + /// + /// Parent Type: `CoinConnection` + public struct CoinConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.CoinConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Address.CoinConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// Address.CoinConnection.Node + /// + /// Parent Type: `Coin` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Coin } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("balance", SuiKit.BigIntApollo?.self), + .field("asMoveObject", AsMoveObject.self), + ] } + + /// Balance of the coin object + public var balance: SuiKit.BigIntApollo? { __data["balance"] } + /// Convert the coin object into a Move object + public var asMoveObject: AsMoveObject { __data["asMoveObject"] } + + /// Address.CoinConnection.Node.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("contents", Contents?.self), + .field("asObject", AsObject.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + /// Attempts to convert the Move object into an Object + /// This provides additional information such as version and digest on the top-level + public var asObject: AsObject { __data["asObject"] } + + /// Address.CoinConnection.Node.AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("type", Type_SelectionSet.self), + ] } + + public var type: Type_SelectionSet { __data["type"] } + + /// Address.CoinConnection.Node.AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + + /// Address.CoinConnection.Node.AsMoveObject.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", alias: "coinObjectId", SuiKit.SuiAddressApollo.self), + .field("version", Int.self), + .field("digest", String.self), + .field("previousTransactionBlock", PreviousTransactionBlock?.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var coinObjectId: SuiKit.SuiAddressApollo { __data["coinObjectId"] } + public var version: Int { __data["version"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The transaction block that created this version of the object. + public var previousTransactionBlock: PreviousTransactionBlock? { __data["previousTransactionBlock"] } + + /// Address.CoinConnection.Node.AsMoveObject.AsObject.PreviousTransactionBlock + /// + /// Parent Type: `TransactionBlock` + public struct PreviousTransactionBlock: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlock } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("digest", String.self), + ] } + + /// A 32-byte hash that uniquely identifies the transaction block contents, encoded in Base58. + /// This serves as a unique id for the block on chain. + public var digest: String { __data["digest"] } + } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCurrentEpochQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCurrentEpochQuery.graphql.swift new file mode 100644 index 0000000..a1e0d42 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetCurrentEpochQuery.graphql.swift @@ -0,0 +1,244 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetCurrentEpochQuery: GraphQLQuery { + public static let operationName: String = "getCurrentEpoch" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getCurrentEpoch { epoch { __typename epochId validatorSet { __typename activeValidators { __typename ...RPC_VALIDATOR_FIELDS } } firstCheckpoint: checkpoints(first: 1) { __typename nodes { __typename sequenceNumber } } startTimestamp endTimestamp referenceGasPrice } }"#, + fragments: [RPC_CREDENTIAL_FIELDS.self, RPC_VALIDATOR_FIELDS.self] + )) + + public init() {} + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("epoch", Epoch?.self), + ] } + + /// Fetch epoch information by ID (defaults to the latest epoch). + public var epoch: Epoch? { __data["epoch"] } + + /// Epoch + /// + /// Parent Type: `Epoch` + public struct Epoch: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Epoch } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("epochId", Int.self), + .field("validatorSet", ValidatorSet?.self), + .field("checkpoints", alias: "firstCheckpoint", FirstCheckpoint.self, arguments: ["first": 1]), + .field("startTimestamp", SuiKit.DateTimeApollo.self), + .field("endTimestamp", SuiKit.DateTimeApollo?.self), + .field("referenceGasPrice", SuiKit.BigIntApollo?.self), + ] } + + /// The epoch's id as a sequence number that starts at 0 and is incremented by one at every epoch change + public var epochId: Int { __data["epochId"] } + /// Validator related properties, including the active validators + public var validatorSet: ValidatorSet? { __data["validatorSet"] } + /// The epoch's corresponding checkpoints + public var firstCheckpoint: FirstCheckpoint { __data["firstCheckpoint"] } + /// The epoch's starting timestamp + public var startTimestamp: SuiKit.DateTimeApollo { __data["startTimestamp"] } + /// The epoch's ending timestamp + public var endTimestamp: SuiKit.DateTimeApollo? { __data["endTimestamp"] } + /// The minimum gas price that a quorum of validators are guaranteed to sign a transaction for + public var referenceGasPrice: SuiKit.BigIntApollo? { __data["referenceGasPrice"] } + + /// Epoch.ValidatorSet + /// + /// Parent Type: `ValidatorSet` + public struct ValidatorSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorSet } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("activeValidators", [ActiveValidator]?.self), + ] } + + /// The current list of active validators. + public var activeValidators: [ActiveValidator]? { __data["activeValidators"] } + + /// Epoch.ValidatorSet.ActiveValidator + /// + /// Parent Type: `Validator` + public struct ActiveValidator: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Validator } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_VALIDATOR_FIELDS.self), + ] } + + /// The number of epochs for which this validator has been below the + /// low stake threshold. + public var atRisk: Int? { __data["atRisk"] } + /// The fee charged by the validator for staking services. + public var commissionRate: Int? { __data["commissionRate"] } + /// Number of exchange rates in the table. + public var exchangeRatesSize: Int? { __data["exchangeRatesSize"] } + /// The validator's current exchange object. The exchange rate is used to determine + /// the amount of SUI tokens that each past SUI staker can withdraw in the future. + public var exchangeRates: RPC_VALIDATOR_FIELDS.ExchangeRates? { __data["exchangeRates"] } + /// Validator's description. + public var description: String? { __data["description"] } + /// The reference gas price for this epoch. + public var gasPrice: SuiKit.BigIntApollo? { __data["gasPrice"] } + /// Validator's url containing their custom image. + public var imageUrl: String? { __data["imageUrl"] } + /// Validator's name. + public var name: String? { __data["name"] } + /// Validator's set of credentials. + public var credentials: Credentials? { __data["credentials"] } + /// The proposed next epoch fee for the validator's staking services. + public var nextEpochCommissionRate: Int? { __data["nextEpochCommissionRate"] } + /// The validator's gas price quote for the next epoch. + public var nextEpochGasPrice: SuiKit.BigIntApollo? { __data["nextEpochGasPrice"] } + /// Validator's set of credentials for the next epoch. + public var nextEpochCredentials: NextEpochCredentials? { __data["nextEpochCredentials"] } + /// The total number of SUI tokens in this pool plus + /// the pending stake amount for this epoch. + public var nextEpochStake: SuiKit.BigIntApollo? { __data["nextEpochStake"] } + /// The validator's current valid `Cap` object. Validators can delegate + /// the operation ability to another address. The address holding this `Cap` object + /// can then update the reference gas price and tallying rule on behalf of the validator. + public var operationCap: RPC_VALIDATOR_FIELDS.OperationCap? { __data["operationCap"] } + /// Pending pool token withdrawn during the current epoch, emptied at epoch boundaries. + public var pendingPoolTokenWithdraw: SuiKit.BigIntApollo? { __data["pendingPoolTokenWithdraw"] } + /// Pending stake amount for this epoch. + public var pendingStake: SuiKit.BigIntApollo? { __data["pendingStake"] } + /// Pending stake withdrawn during the current epoch, emptied at epoch boundaries. + public var pendingTotalSuiWithdraw: SuiKit.BigIntApollo? { __data["pendingTotalSuiWithdraw"] } + /// Total number of pool tokens issued by the pool. + public var poolTokenBalance: SuiKit.BigIntApollo? { __data["poolTokenBalance"] } + /// Validator's homepage URL. + public var projectUrl: String? { __data["projectUrl"] } + /// The epoch stake rewards will be added here at the end of each epoch. + public var rewardsPool: SuiKit.BigIntApollo? { __data["rewardsPool"] } + /// The validator's current staking pool object, used to track the amount of stake + /// and to compound staking rewards. + public var stakingPool: RPC_VALIDATOR_FIELDS.StakingPool? { __data["stakingPool"] } + /// The epoch at which this pool became active. + public var stakingPoolActivationEpoch: Int? { __data["stakingPoolActivationEpoch"] } + /// The total number of SUI tokens in this pool. + public var stakingPoolSuiBalance: SuiKit.BigIntApollo? { __data["stakingPoolSuiBalance"] } + /// Validator's address. + public var address: RPC_VALIDATOR_FIELDS.Address { __data["address"] } + /// The voting power of this validator in basis points (e.g., 100 = 1% voting power). + public var votingPower: Int? { __data["votingPower"] } + /// The addresses of other validators this validator has reported. + public var reportRecords: [RPC_VALIDATOR_FIELDS.ReportRecord]? { __data["reportRecords"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_VALIDATOR_FIELDS: RPC_VALIDATOR_FIELDS { _toFragment() } + } + + /// Epoch.ValidatorSet.ActiveValidator.Credentials + /// + /// Parent Type: `ValidatorCredentials` + public struct Credentials: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorCredentials } + + public var netAddress: String? { __data["netAddress"] } + public var networkPubKey: SuiKit.Base64Apollo? { __data["networkPubKey"] } + public var p2PAddress: String? { __data["p2PAddress"] } + public var primaryAddress: String? { __data["primaryAddress"] } + public var workerPubKey: SuiKit.Base64Apollo? { __data["workerPubKey"] } + public var workerAddress: String? { __data["workerAddress"] } + public var proofOfPossession: SuiKit.Base64Apollo? { __data["proofOfPossession"] } + public var protocolPubKey: SuiKit.Base64Apollo? { __data["protocolPubKey"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_CREDENTIAL_FIELDS: RPC_CREDENTIAL_FIELDS { _toFragment() } + } + } + + /// Epoch.ValidatorSet.ActiveValidator.NextEpochCredentials + /// + /// Parent Type: `ValidatorCredentials` + public struct NextEpochCredentials: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorCredentials } + + public var netAddress: String? { __data["netAddress"] } + public var networkPubKey: SuiKit.Base64Apollo? { __data["networkPubKey"] } + public var p2PAddress: String? { __data["p2PAddress"] } + public var primaryAddress: String? { __data["primaryAddress"] } + public var workerPubKey: SuiKit.Base64Apollo? { __data["workerPubKey"] } + public var workerAddress: String? { __data["workerAddress"] } + public var proofOfPossession: SuiKit.Base64Apollo? { __data["proofOfPossession"] } + public var protocolPubKey: SuiKit.Base64Apollo? { __data["protocolPubKey"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_CREDENTIAL_FIELDS: RPC_CREDENTIAL_FIELDS { _toFragment() } + } + } + } + } + + /// Epoch.FirstCheckpoint + /// + /// Parent Type: `CheckpointConnection` + public struct FirstCheckpoint: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.CheckpointConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("nodes", [Node].self), + ] } + + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Epoch.FirstCheckpoint.Node + /// + /// Parent Type: `Checkpoint` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Checkpoint } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("sequenceNumber", Int.self), + ] } + + /// This checkpoint's position in the total order of finalized checkpoints, agreed upon by + /// consensus. + public var sequenceNumber: Int { __data["sequenceNumber"] } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetDynamicFieldObjectQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetDynamicFieldObjectQuery.graphql.swift new file mode 100644 index 0000000..791264c --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetDynamicFieldObjectQuery.graphql.swift @@ -0,0 +1,250 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetDynamicFieldObjectQuery: GraphQLQuery { + public static let operationName: String = "getDynamicFieldObject" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getDynamicFieldObject($parentId: SuiAddress!, $name: DynamicFieldNameApollo!) { object(address: $parentId) { __typename dynamicObjectField(name: $name) { __typename name { __typename type { __typename repr } } value { __typename ... on MoveObject { contents { __typename data type { __typename layout repr } } hasPublicTransfer asObject { __typename address digest version display { __typename key value error } } } } } } }"# + )) + + public var parentId: SuiAddressApollo + public var name: DynamicFieldNameApollo + + public init( + parentId: SuiAddressApollo, + name: DynamicFieldNameApollo + ) { + self.parentId = parentId + self.name = name + } + + public var __variables: Variables? { [ + "parentId": parentId, + "name": name + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("object", Object?.self, arguments: ["address": .variable("parentId")]), + ] } + + public var object: Object? { __data["object"] } + + /// Object + /// + /// Parent Type: `Object` + public struct Object: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("dynamicObjectField", DynamicObjectField?.self, arguments: ["name": .variable("name")]), + ] } + + /// Access a dynamic object field on an object using its name. + /// Names are arbitrary Move values whose type have `copy`, `drop`, and `store`, and are specified + /// using their type, and their BCS contents, Base64Apollo encoded. + /// The value of a dynamic object field can also be accessed off-chain directly via its address (e.g. using `Query.object`). + /// Dynamic fields on wrapped objects can be accessed by using the same API under the Owner type. + public var dynamicObjectField: DynamicObjectField? { __data["dynamicObjectField"] } + + /// Object.DynamicObjectField + /// + /// Parent Type: `DynamicField` + public struct DynamicObjectField: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.DynamicField } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("name", Name?.self), + .field("value", Value?.self), + ] } + + /// The string type, data, and serialized value of the DynamicField's 'name' field. + /// This field is used to uniquely identify a child of the parent object. + public var name: Name? { __data["name"] } + /// The actual data stored in the dynamic field. + /// The returned dynamic field is an object if its return type is MoveObject, + /// in which case it is also accessible off-chain via its address. + public var value: Value? { __data["value"] } + + /// Object.DynamicObjectField.Name + /// + /// Parent Type: `MoveValue` + public struct Name: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("type", Type_SelectionSet.self), + ] } + + public var type: Type_SelectionSet { __data["type"] } + + /// Object.DynamicObjectField.Name.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + + /// Object.DynamicObjectField.Value + /// + /// Parent Type: `DynamicFieldValue` + public struct Value: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Unions.DynamicFieldValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .inlineFragment(AsMoveObject.self), + ] } + + public var asMoveObject: AsMoveObject? { _asInlineFragment() } + + /// Object.DynamicObjectField.Value.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.InlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = GetDynamicFieldObjectQuery.Data.Object.DynamicObjectField.Value + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("contents", Contents?.self), + .field("hasPublicTransfer", Bool.self), + .field("asObject", AsObject.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Attempts to convert the Move object into an Object + /// This provides additional information such as version and digest on the top-level + public var asObject: AsObject { __data["asObject"] } + + /// Object.DynamicObjectField.Value.AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("data", SuiKit.MoveDataApollo.self), + .field("type", Type_SelectionSet.self), + ] } + + /// Structured contents of a Move value. + public var data: SuiKit.MoveDataApollo { __data["data"] } + public var type: Type_SelectionSet { __data["type"] } + + /// Object.DynamicObjectField.Value.AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("layout", SuiKit.MoveTypeLayoutApollo.self), + .field("repr", String.self), + ] } + + /// Structured representation of the "shape" of values that match this type. + public var layout: SuiKit.MoveTypeLayoutApollo { __data["layout"] } + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + + /// Object.DynamicObjectField.Value.AsMoveObject.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + .field("digest", String.self), + .field("version", Int.self), + .field("display", [Display]?.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + public var version: Int { __data["version"] } + /// The set of named templates defined on-chain for the type of this object, + /// to be handled off-chain. The server substitutes data from the object + /// into these templates to generate a display string per template. + public var display: [Display]? { __data["display"] } + + /// Object.DynamicObjectField.Value.AsMoveObject.AsObject.Display + /// + /// Parent Type: `DisplayEntry` + public struct Display: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.DisplayEntry } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("key", String.self), + .field("value", String?.self), + .field("error", String?.self), + ] } + + /// The identifier for a particular template string of the Display object. + public var key: String { __data["key"] } + /// The template string for the key with placeholder values substituted. + public var value: String? { __data["value"] } + /// An error string describing why the template could not be rendered. + public var error: String? { __data["error"] } + } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetDynamicFieldsQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetDynamicFieldsQuery.graphql.swift new file mode 100644 index 0000000..b831225 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetDynamicFieldsQuery.graphql.swift @@ -0,0 +1,292 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetDynamicFieldsQuery: GraphQLQuery { + public static let operationName: String = "getDynamicFields" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getDynamicFields($parentId: SuiAddress!, $first: Int, $cursor: String) { object(address: $parentId) { __typename dynamicFieldConnection(first: $first, after: $cursor) { __typename pageInfo { __typename hasNextPage endCursor } nodes { __typename name { __typename bcs JSONApollo type { __typename layout repr } } value { __typename ... on MoveObject { contents { __typename type { __typename repr } JSONApollo } asObject { __typename storageRebate address digest version } } } } } } }"# + )) + + public var parentId: SuiAddressApollo + public var first: GraphQLNullable + public var cursor: GraphQLNullable + + public init( + parentId: SuiAddressApollo, + first: GraphQLNullable, + cursor: GraphQLNullable + ) { + self.parentId = parentId + self.first = first + self.cursor = cursor + } + + public var __variables: Variables? { [ + "parentId": parentId, + "first": first, + "cursor": cursor + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("object", Object?.self, arguments: ["address": .variable("parentId")]), + ] } + + public var object: Object? { __data["object"] } + + /// Object + /// + /// Parent Type: `Object` + public struct Object: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("dynamicFieldConnection", DynamicFieldConnection?.self, arguments: [ + "first": .variable("first"), + "after": .variable("cursor") + ]), + ] } + + /// The dynamic fields on an object. + /// Dynamic fields on wrapped objects can be accessed by using the same API under the Owner type. + public var dynamicFieldConnection: DynamicFieldConnection? { __data["dynamicFieldConnection"] } + + /// Object.DynamicFieldConnection + /// + /// Parent Type: `DynamicFieldConnection` + public struct DynamicFieldConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.DynamicFieldConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Object.DynamicFieldConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// Object.DynamicFieldConnection.Node + /// + /// Parent Type: `DynamicField` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.DynamicField } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("name", Name?.self), + .field("value", Value?.self), + ] } + + /// The string type, data, and serialized value of the DynamicField's 'name' field. + /// This field is used to uniquely identify a child of the parent object. + public var name: Name? { __data["name"] } + /// The actual data stored in the dynamic field. + /// The returned dynamic field is an object if its return type is MoveObject, + /// in which case it is also accessible off-chain via its address. + public var value: Value? { __data["value"] } + + /// Object.DynamicFieldConnection.Node.Name + /// + /// Parent Type: `MoveValue` + public struct Name: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("bcs", SuiKit.Base64Apollo.self), + .field("JSONApollo", SuiKit.JSONApollo.self), + .field("type", Type_SelectionSet.self), + ] } + + public var bcs: SuiKit.Base64Apollo { __data["bcs"] } + /// Representation of a Move value in JSONApollo, where: + /// + /// - Addresses, IDs, and UIDs are represented in canonical form, as JSONApollo strings. + /// - Bools are represented by JSONApollo boolean literals. + /// - u8, u16, and u32 are represented as JSONApollo numbers. + /// - u64, u128, and u256 are represented as JSONApollo strings. + /// - Vectors are represented by JSONApollo arrays. + /// - Structs are represented by JSONApollo objects. + /// - Empty optional values are represented by `null`. + /// + /// This form is offered as a less verbose convenience in cases where the layout of the type is + /// known by the client. + public var JSONApollo: SuiKit.JSONApollo { __data["JSONApollo"] } + public var type: Type_SelectionSet { __data["type"] } + + /// Object.DynamicFieldConnection.Node.Name.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("layout", SuiKit.MoveTypeLayoutApollo.self), + .field("repr", String.self), + ] } + + /// Structured representation of the "shape" of values that match this type. + public var layout: SuiKit.MoveTypeLayoutApollo { __data["layout"] } + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + + /// Object.DynamicFieldConnection.Node.Value + /// + /// Parent Type: `DynamicFieldValue` + public struct Value: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Unions.DynamicFieldValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .inlineFragment(AsMoveObject.self), + ] } + + public var asMoveObject: AsMoveObject? { _asInlineFragment() } + + /// Object.DynamicFieldConnection.Node.Value.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.InlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = GetDynamicFieldsQuery.Data.Object.DynamicFieldConnection.Node.Value + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("contents", Contents?.self), + .field("asObject", AsObject.self), + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + /// Attempts to convert the Move object into an Object + /// This provides additional information such as version and digest on the top-level + public var asObject: AsObject { __data["asObject"] } + + /// Object.DynamicFieldConnection.Node.Value.AsMoveObject.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("type", Type_SelectionSet.self), + .field("JSONApollo", SuiKit.JSONApollo.self), + ] } + + public var type: Type_SelectionSet { __data["type"] } + /// Representation of a Move value in JSONApollo, where: + /// + /// - Addresses, IDs, and UIDs are represented in canonical form, as JSONApollo strings. + /// - Bools are represented by JSONApollo boolean literals. + /// - u8, u16, and u32 are represented as JSONApollo numbers. + /// - u64, u128, and u256 are represented as JSONApollo strings. + /// - Vectors are represented by JSONApollo arrays. + /// - Structs are represented by JSONApollo objects. + /// - Empty optional values are represented by `null`. + /// + /// This form is offered as a less verbose convenience in cases where the layout of the type is + /// known by the client. + public var JSONApollo: SuiKit.JSONApollo { __data["JSONApollo"] } + + /// Object.DynamicFieldConnection.Node.Value.AsMoveObject.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("repr", String.self), + ] } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + } + } + + /// Object.DynamicFieldConnection.Node.Value.AsMoveObject.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("storageRebate", SuiKit.BigIntApollo?.self), + .field("address", SuiKit.SuiAddressApollo.self), + .field("digest", String.self), + .field("version", Int.self), + ] } + + /// The amount of SUI we would rebate if this object gets deleted or mutated. + /// This number is recalculated based on the present storage gas price. + public var storageRebate: SuiKit.BigIntApollo? { __data["storageRebate"] } + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + public var version: Int { __data["version"] } + } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetLatestCheckpointSequenceNumberQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetLatestCheckpointSequenceNumberQuery.graphql.swift new file mode 100644 index 0000000..75a71ba --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetLatestCheckpointSequenceNumberQuery.graphql.swift @@ -0,0 +1,46 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetLatestCheckpointSequenceNumberQuery: GraphQLQuery { + public static let operationName: String = "getLatestCheckpointSequenceNumber" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getLatestCheckpointSequenceNumber { checkpoint { __typename sequenceNumber } }"# + )) + + public init() {} + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("checkpoint", Checkpoint?.self), + ] } + + /// Fetch checkpoint information by sequence number or digest (defaults to the latest available + /// checkpoint). + public var checkpoint: Checkpoint? { __data["checkpoint"] } + + /// Checkpoint + /// + /// Parent Type: `Checkpoint` + public struct Checkpoint: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Checkpoint } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("sequenceNumber", Int.self), + ] } + + /// This checkpoint's position in the total order of finalized checkpoints, agreed upon by + /// consensus. + public var sequenceNumber: Int { __data["sequenceNumber"] } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetLatestSuiSystemStateQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetLatestSuiSystemStateQuery.graphql.swift new file mode 100644 index 0000000..deece34 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetLatestSuiSystemStateQuery.graphql.swift @@ -0,0 +1,410 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetLatestSuiSystemStateQuery: GraphQLQuery { + public static let operationName: String = "getLatestSuiSystemState" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getLatestSuiSystemState { epoch { __typename epochId startTimestamp endTimestamp referenceGasPrice safeMode { __typename enabled gasSummary { __typename computationCost nonRefundableStorageFee storageCost storageRebate } } systemStakeSubsidy { __typename balance currentDistributionAmount decreaseRate distributionCounter periodLength } storageFund { __typename nonRefundableBalance totalObjectStorageRebates } systemStateVersion systemParameters { __typename minValidatorCount maxValidatorCount minValidatorJoiningStake durationMs validatorLowStakeThreshold validatorLowStakeGracePeriod validatorVeryLowStakeThreshold stakeSubsidyStartEpoch } protocolConfigs { __typename protocolVersion } validatorSet { __typename activeValidators { __typename ...RPC_VALIDATOR_FIELDS } inactivePoolsSize pendingActiveValidatorsSize stakePoolMappingsSize validatorCandidatesSize pendingRemovals totalStake } } }"#, + fragments: [RPC_CREDENTIAL_FIELDS.self, RPC_VALIDATOR_FIELDS.self] + )) + + public init() {} + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("epoch", Epoch?.self), + ] } + + /// Fetch epoch information by ID (defaults to the latest epoch). + public var epoch: Epoch? { __data["epoch"] } + + /// Epoch + /// + /// Parent Type: `Epoch` + public struct Epoch: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Epoch } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("epochId", Int.self), + .field("startTimestamp", SuiKit.DateTimeApollo.self), + .field("endTimestamp", SuiKit.DateTimeApollo?.self), + .field("referenceGasPrice", SuiKit.BigIntApollo?.self), + .field("safeMode", SafeMode?.self), + .field("systemStakeSubsidy", SystemStakeSubsidy?.self), + .field("storageFund", StorageFund?.self), + .field("systemStateVersion", Int?.self), + .field("systemParameters", SystemParameters?.self), + .field("protocolConfigs", ProtocolConfigs.self), + .field("validatorSet", ValidatorSet?.self), + ] } + + /// The epoch's id as a sequence number that starts at 0 and is incremented by one at every epoch change + public var epochId: Int { __data["epochId"] } + /// The epoch's starting timestamp + public var startTimestamp: SuiKit.DateTimeApollo { __data["startTimestamp"] } + /// The epoch's ending timestamp + public var endTimestamp: SuiKit.DateTimeApollo? { __data["endTimestamp"] } + /// The minimum gas price that a quorum of validators are guaranteed to sign a transaction for + public var referenceGasPrice: SuiKit.BigIntApollo? { __data["referenceGasPrice"] } + /// Information about whether this epoch was started in safe mode, which happens if the full epoch + /// change logic fails for some reason. + public var safeMode: SafeMode? { __data["safeMode"] } + /// Parameters related to the subsidy that supplements staking rewards + public var systemStakeSubsidy: SystemStakeSubsidy? { __data["systemStakeSubsidy"] } + /// SUI set aside to account for objects stored on-chain, at the start of the epoch. + /// This is also used for storage rebates. + public var storageFund: StorageFund? { __data["storageFund"] } + /// The value of the `version` field of `0x5`, the `0x3::sui::SuiSystemState` object. This + /// version changes whenever the fields contained in the system state object (held in a dynamic + /// field attached to `0x5`) change. + public var systemStateVersion: Int? { __data["systemStateVersion"] } + /// Details of the system that are decided during genesis. + public var systemParameters: SystemParameters? { __data["systemParameters"] } + /// The epoch's corresponding protocol configuration, including the feature flags and the configuration options + public var protocolConfigs: ProtocolConfigs { __data["protocolConfigs"] } + /// Validator related properties, including the active validators + public var validatorSet: ValidatorSet? { __data["validatorSet"] } + + /// Epoch.SafeMode + /// + /// Parent Type: `SafeMode` + public struct SafeMode: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.SafeMode } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("enabled", Bool?.self), + .field("gasSummary", GasSummary?.self), + ] } + + /// Whether safe mode was used for the last epoch change. The system will retry a full epoch + /// change on every epoch boundary and automatically reset this flag if so. + public var enabled: Bool? { __data["enabled"] } + /// Accumulated fees for computation and cost that have not been added to the various reward + /// pools, because the full epoch change did not happen. + public var gasSummary: GasSummary? { __data["gasSummary"] } + + /// Epoch.SafeMode.GasSummary + /// + /// Parent Type: `GasCostSummary` + public struct GasSummary: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.GasCostSummary } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("computationCost", SuiKit.BigIntApollo?.self), + .field("nonRefundableStorageFee", SuiKit.BigIntApollo?.self), + .field("storageCost", SuiKit.BigIntApollo?.self), + .field("storageRebate", SuiKit.BigIntApollo?.self), + ] } + + /// Gas paid for executing this transaction (in MIST). + public var computationCost: SuiKit.BigIntApollo? { __data["computationCost"] } + /// Part of storage cost that is not reclaimed when data created by this transaction is cleaned + /// up (in MIST). + public var nonRefundableStorageFee: SuiKit.BigIntApollo? { __data["nonRefundableStorageFee"] } + /// Gas paid for the data stored on-chain by this transaction (in MIST). + public var storageCost: SuiKit.BigIntApollo? { __data["storageCost"] } + /// Part of storage cost that can be reclaimed by cleaning up data created by this transaction + /// (when objects are deleted or an object is modified, which is treated as a deletion followed + /// by a creation) (in MIST). + public var storageRebate: SuiKit.BigIntApollo? { __data["storageRebate"] } + } + } + + /// Epoch.SystemStakeSubsidy + /// + /// Parent Type: `StakeSubsidy` + public struct SystemStakeSubsidy: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.StakeSubsidy } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("balance", SuiKit.BigIntApollo?.self), + .field("currentDistributionAmount", SuiKit.BigIntApollo?.self), + .field("decreaseRate", Int?.self), + .field("distributionCounter", Int?.self), + .field("periodLength", Int?.self), + ] } + + /// SUI set aside for stake subsidies -- reduces over time as stake subsidies are paid out over + /// time. + public var balance: SuiKit.BigIntApollo? { __data["balance"] } + /// Amount of stake subsidy deducted from the balance per distribution -- decays over time. + public var currentDistributionAmount: SuiKit.BigIntApollo? { __data["currentDistributionAmount"] } + /// Percentage of the current distribution amount to deduct at the end of the current subsidy + /// period, expressed in basis points. + public var decreaseRate: Int? { __data["decreaseRate"] } + /// Number of times stake subsidies have been distributed subsidies are distributed with other + /// staking rewards, at the end of the epoch. + public var distributionCounter: Int? { __data["distributionCounter"] } + /// Maximum number of stake subsidy distributions that occur with the same distribution amount + /// (before the amount is reduced). + public var periodLength: Int? { __data["periodLength"] } + } + + /// Epoch.StorageFund + /// + /// Parent Type: `StorageFund` + public struct StorageFund: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.StorageFund } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("nonRefundableBalance", SuiKit.BigIntApollo?.self), + .field("totalObjectStorageRebates", SuiKit.BigIntApollo?.self), + ] } + + /// The portion of the storage fund that will never be refunded through storage rebates. + /// + /// The system maintains an invariant that the sum of all storage fees into the storage fund is + /// equal to the sum of of all storage rebates out, the total storage rebates remaining, and the + /// non-refundable balance. + public var nonRefundableBalance: SuiKit.BigIntApollo? { __data["nonRefundableBalance"] } + /// Sum of storage rebates of live objects on chain. + public var totalObjectStorageRebates: SuiKit.BigIntApollo? { __data["totalObjectStorageRebates"] } + } + + /// Epoch.SystemParameters + /// + /// Parent Type: `SystemParameters` + public struct SystemParameters: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.SystemParameters } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("minValidatorCount", Int?.self), + .field("maxValidatorCount", Int?.self), + .field("minValidatorJoiningStake", SuiKit.BigIntApollo?.self), + .field("durationMs", SuiKit.BigIntApollo?.self), + .field("validatorLowStakeThreshold", SuiKit.BigIntApollo?.self), + .field("validatorLowStakeGracePeriod", SuiKit.BigIntApollo?.self), + .field("validatorVeryLowStakeThreshold", SuiKit.BigIntApollo?.self), + .field("stakeSubsidyStartEpoch", Int?.self), + ] } + + /// The minimum number of active validators that the system supports. + public var minValidatorCount: Int? { __data["minValidatorCount"] } + /// The maximum number of active validators that the system supports. + public var maxValidatorCount: Int? { __data["maxValidatorCount"] } + /// Minimum stake needed to become a new validator. + public var minValidatorJoiningStake: SuiKit.BigIntApollo? { __data["minValidatorJoiningStake"] } + /// Target duration of an epoch, in milliseconds. + public var durationMs: SuiKit.BigIntApollo? { __data["durationMs"] } + /// Validators with stake below this threshold will enter the grace period (see + /// `validatorLowStakeGracePeriod`), after which they are removed from the active validator set. + public var validatorLowStakeThreshold: SuiKit.BigIntApollo? { __data["validatorLowStakeThreshold"] } + /// The number of epochs that a validator has to recover from having less than + /// `validatorLowStakeThreshold` stake. + public var validatorLowStakeGracePeriod: SuiKit.BigIntApollo? { __data["validatorLowStakeGracePeriod"] } + /// Validators with stake below this threshold will be removed from the the active validator set + /// at the next epoch boundary, without a grace period. + public var validatorVeryLowStakeThreshold: SuiKit.BigIntApollo? { __data["validatorVeryLowStakeThreshold"] } + /// The epoch at which stake subsidies start being paid out. + public var stakeSubsidyStartEpoch: Int? { __data["stakeSubsidyStartEpoch"] } + } + + /// Epoch.ProtocolConfigs + /// + /// Parent Type: `ProtocolConfigs` + public struct ProtocolConfigs: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ProtocolConfigs } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("protocolVersion", Int.self), + ] } + + /// The protocol is not required to change on every epoch boundary, so the protocol version + /// tracks which change to the protocol these configs are from. + public var protocolVersion: Int { __data["protocolVersion"] } + } + + /// Epoch.ValidatorSet + /// + /// Parent Type: `ValidatorSet` + public struct ValidatorSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorSet } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("activeValidators", [ActiveValidator]?.self), + .field("inactivePoolsSize", Int?.self), + .field("pendingActiveValidatorsSize", Int?.self), + .field("stakePoolMappingsSize", Int?.self), + .field("validatorCandidatesSize", Int?.self), + .field("pendingRemovals", [Int]?.self), + .field("totalStake", SuiKit.BigIntApollo?.self), + ] } + + /// The current list of active validators. + public var activeValidators: [ActiveValidator]? { __data["activeValidators"] } + public var inactivePoolsSize: Int? { __data["inactivePoolsSize"] } + public var pendingActiveValidatorsSize: Int? { __data["pendingActiveValidatorsSize"] } + public var stakePoolMappingsSize: Int? { __data["stakePoolMappingsSize"] } + public var validatorCandidatesSize: Int? { __data["validatorCandidatesSize"] } + /// Validators that are pending removal from the active validator set, expressed as indices in + /// to `activeValidators`. + public var pendingRemovals: [Int]? { __data["pendingRemovals"] } + /// Total amount of stake for all active validators at the beginning of the epoch. + public var totalStake: SuiKit.BigIntApollo? { __data["totalStake"] } + + /// Epoch.ValidatorSet.ActiveValidator + /// + /// Parent Type: `Validator` + public struct ActiveValidator: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Validator } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_VALIDATOR_FIELDS.self), + ] } + + /// The number of epochs for which this validator has been below the + /// low stake threshold. + public var atRisk: Int? { __data["atRisk"] } + /// The fee charged by the validator for staking services. + public var commissionRate: Int? { __data["commissionRate"] } + /// Number of exchange rates in the table. + public var exchangeRatesSize: Int? { __data["exchangeRatesSize"] } + /// The validator's current exchange object. The exchange rate is used to determine + /// the amount of SUI tokens that each past SUI staker can withdraw in the future. + public var exchangeRates: RPC_VALIDATOR_FIELDS.ExchangeRates? { __data["exchangeRates"] } + /// Validator's description. + public var description: String? { __data["description"] } + /// The reference gas price for this epoch. + public var gasPrice: SuiKit.BigIntApollo? { __data["gasPrice"] } + /// Validator's url containing their custom image. + public var imageUrl: String? { __data["imageUrl"] } + /// Validator's name. + public var name: String? { __data["name"] } + /// Validator's set of credentials. + public var credentials: Credentials? { __data["credentials"] } + /// The proposed next epoch fee for the validator's staking services. + public var nextEpochCommissionRate: Int? { __data["nextEpochCommissionRate"] } + /// The validator's gas price quote for the next epoch. + public var nextEpochGasPrice: SuiKit.BigIntApollo? { __data["nextEpochGasPrice"] } + /// Validator's set of credentials for the next epoch. + public var nextEpochCredentials: NextEpochCredentials? { __data["nextEpochCredentials"] } + /// The total number of SUI tokens in this pool plus + /// the pending stake amount for this epoch. + public var nextEpochStake: SuiKit.BigIntApollo? { __data["nextEpochStake"] } + /// The validator's current valid `Cap` object. Validators can delegate + /// the operation ability to another address. The address holding this `Cap` object + /// can then update the reference gas price and tallying rule on behalf of the validator. + public var operationCap: RPC_VALIDATOR_FIELDS.OperationCap? { __data["operationCap"] } + /// Pending pool token withdrawn during the current epoch, emptied at epoch boundaries. + public var pendingPoolTokenWithdraw: SuiKit.BigIntApollo? { __data["pendingPoolTokenWithdraw"] } + /// Pending stake amount for this epoch. + public var pendingStake: SuiKit.BigIntApollo? { __data["pendingStake"] } + /// Pending stake withdrawn during the current epoch, emptied at epoch boundaries. + public var pendingTotalSuiWithdraw: SuiKit.BigIntApollo? { __data["pendingTotalSuiWithdraw"] } + /// Total number of pool tokens issued by the pool. + public var poolTokenBalance: SuiKit.BigIntApollo? { __data["poolTokenBalance"] } + /// Validator's homepage URL. + public var projectUrl: String? { __data["projectUrl"] } + /// The epoch stake rewards will be added here at the end of each epoch. + public var rewardsPool: SuiKit.BigIntApollo? { __data["rewardsPool"] } + /// The validator's current staking pool object, used to track the amount of stake + /// and to compound staking rewards. + public var stakingPool: RPC_VALIDATOR_FIELDS.StakingPool? { __data["stakingPool"] } + /// The epoch at which this pool became active. + public var stakingPoolActivationEpoch: Int? { __data["stakingPoolActivationEpoch"] } + /// The total number of SUI tokens in this pool. + public var stakingPoolSuiBalance: SuiKit.BigIntApollo? { __data["stakingPoolSuiBalance"] } + /// Validator's address. + public var address: RPC_VALIDATOR_FIELDS.Address { __data["address"] } + /// The voting power of this validator in basis points (e.g., 100 = 1% voting power). + public var votingPower: Int? { __data["votingPower"] } + /// The addresses of other validators this validator has reported. + public var reportRecords: [RPC_VALIDATOR_FIELDS.ReportRecord]? { __data["reportRecords"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_VALIDATOR_FIELDS: RPC_VALIDATOR_FIELDS { _toFragment() } + } + + /// Epoch.ValidatorSet.ActiveValidator.Credentials + /// + /// Parent Type: `ValidatorCredentials` + public struct Credentials: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorCredentials } + + public var netAddress: String? { __data["netAddress"] } + public var networkPubKey: SuiKit.Base64Apollo? { __data["networkPubKey"] } + public var p2PAddress: String? { __data["p2PAddress"] } + public var primaryAddress: String? { __data["primaryAddress"] } + public var workerPubKey: SuiKit.Base64Apollo? { __data["workerPubKey"] } + public var workerAddress: String? { __data["workerAddress"] } + public var proofOfPossession: SuiKit.Base64Apollo? { __data["proofOfPossession"] } + public var protocolPubKey: SuiKit.Base64Apollo? { __data["protocolPubKey"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_CREDENTIAL_FIELDS: RPC_CREDENTIAL_FIELDS { _toFragment() } + } + } + + /// Epoch.ValidatorSet.ActiveValidator.NextEpochCredentials + /// + /// Parent Type: `ValidatorCredentials` + public struct NextEpochCredentials: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorCredentials } + + public var netAddress: String? { __data["netAddress"] } + public var networkPubKey: SuiKit.Base64Apollo? { __data["networkPubKey"] } + public var p2PAddress: String? { __data["p2PAddress"] } + public var primaryAddress: String? { __data["primaryAddress"] } + public var workerPubKey: SuiKit.Base64Apollo? { __data["workerPubKey"] } + public var workerAddress: String? { __data["workerAddress"] } + public var proofOfPossession: SuiKit.Base64Apollo? { __data["proofOfPossession"] } + public var protocolPubKey: SuiKit.Base64Apollo? { __data["protocolPubKey"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_CREDENTIAL_FIELDS: RPC_CREDENTIAL_FIELDS { _toFragment() } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetMoveFunctionArgTypesQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetMoveFunctionArgTypesQuery.graphql.swift new file mode 100644 index 0000000..5c9a832 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetMoveFunctionArgTypesQuery.graphql.swift @@ -0,0 +1,135 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI +import SwiftyJSON + +public class GetMoveFunctionArgTypesQuery: GraphQLQuery { + public static let operationName: String = "getMoveFunctionArgTypes" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getMoveFunctionArgTypes($packageId: SuiAddress!, $module: String!, $function: String!) { object(address: $packageId) { __typename asMovePackage { __typename module(name: $module) { __typename fileFormatVersion function(name: $function) { __typename parameters { __typename signature } } } } } }"# + )) + + public var packageId: SuiAddressApollo + public var module: String + public var function: String + + public init( + packageId: SuiAddressApollo, + module: String, + function: String + ) { + self.packageId = packageId + self.module = module + self.function = function + } + + public var __variables: Variables? { [ + "packageId": packageId, + "module": module, + "function": function + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("object", Object?.self, arguments: ["address": .variable("packageId")]), + ] } + + public var object: Object? { __data["object"] } + + /// Object + /// + /// Parent Type: `Object` + public struct Object: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asMovePackage", AsMovePackage?.self), + ] } + + /// Attempts to convert the object into a MovePackage + public var asMovePackage: AsMovePackage? { __data["asMovePackage"] } + + /// Object.AsMovePackage + /// + /// Parent Type: `MovePackage` + public struct AsMovePackage: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MovePackage } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("module", Module?.self, arguments: ["name": .variable("module")]), + ] } + + /// A representation of the module called `name` in this package, including the + /// structs and functions it defines. + public var module: Module? { __data["module"] } + + /// Object.AsMovePackage.Module + /// + /// Parent Type: `MoveModule` + public struct Module: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModule } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("fileFormatVersion", Int.self), + .field("function", Function?.self, arguments: ["name": .variable("function")]), + ] } + + /// Format version of this module's bytecode. + public var fileFormatVersion: Int { __data["fileFormatVersion"] } + /// Look-up the signature of a function defined in this module, by its name. + public var function: Function? { __data["function"] } + + /// Object.AsMovePackage.Module.Function + /// + /// Parent Type: `MoveFunction` + public struct Function: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveFunction } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("parameters", [Parameter]?.self), + ] } + + /// The function's parameter types. These types can reference type parameters introduce by this + /// function (see `typeParameters`). + public var parameters: [Parameter]? { __data["parameters"] } + + /// Object.AsMovePackage.Module.Function.Parameter + /// + /// Parent Type: `OpenMoveType` + public struct Parameter: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.OpenMoveType } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("signature", AnyHashable.self), + ] } + + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveFunctionQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveFunctionQuery.graphql.swift new file mode 100644 index 0000000..29b3c7d --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveFunctionQuery.graphql.swift @@ -0,0 +1,142 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetNormalizedMoveFunctionQuery: GraphQLQuery { + public static let operationName: String = "getNormalizedMoveFunction" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getNormalizedMoveFunction($packageId: SuiAddress!, $module: String!, $function: String!) { object(address: $packageId) { __typename address asMovePackage { __typename module(name: $module) { __typename fileFormatVersion function(name: $function) { __typename ...RPC_MOVE_FUNCTION_FIELDS } } } } }"#, + fragments: [RPC_MOVE_FUNCTION_FIELDS.self] + )) + + public var packageId: SuiAddressApollo + public var module: String + public var function: String + + public init( + packageId: SuiAddressApollo, + module: String, + function: String + ) { + self.packageId = packageId + self.module = module + self.function = function + } + + public var __variables: Variables? { [ + "packageId": packageId, + "module": module, + "function": function + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("object", Object?.self, arguments: ["address": .variable("packageId")]), + ] } + + public var object: Object? { __data["object"] } + + /// Object + /// + /// Parent Type: `Object` + public struct Object: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + .field("asMovePackage", AsMovePackage?.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + /// Attempts to convert the object into a MovePackage + public var asMovePackage: AsMovePackage? { __data["asMovePackage"] } + + /// Object.AsMovePackage + /// + /// Parent Type: `MovePackage` + public struct AsMovePackage: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MovePackage } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("module", Module?.self, arguments: ["name": .variable("module")]), + ] } + + /// A representation of the module called `name` in this package, including the + /// structs and functions it defines. + public var module: Module? { __data["module"] } + + /// Object.AsMovePackage.Module + /// + /// Parent Type: `MoveModule` + public struct Module: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModule } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("fileFormatVersion", Int.self), + .field("function", Function?.self, arguments: ["name": .variable("function")]), + ] } + + /// Format version of this module's bytecode. + public var fileFormatVersion: Int { __data["fileFormatVersion"] } + /// Look-up the signature of a function defined in this module, by its name. + public var function: Function? { __data["function"] } + + /// Object.AsMovePackage.Module.Function + /// + /// Parent Type: `MoveFunction` + public struct Function: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveFunction } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_MOVE_FUNCTION_FIELDS.self), + ] } + + /// The function's (unqualified) name. + public var name: String { __data["name"] } + /// The function's visibility: `public`, `public(friend)`, or `private`. + public var visibility: GraphQLEnum? { __data["visibility"] } + /// Whether the function has the `entry` modifier or not. + public var isEntry: Bool? { __data["isEntry"] } + /// The function's parameter types. These types can reference type parameters introduce by this + /// function (see `typeParameters`). + public var parameters: [RPC_MOVE_FUNCTION_FIELDS.Parameter]? { __data["parameters"] } + /// Constraints on the function's formal type parameters. Move bytecode does not name type + /// parameters, so when they are referenced (e.g. in parameter and return types) they are + /// identified by their index in this list. + public var typeParameters: [RPC_MOVE_FUNCTION_FIELDS.TypeParameter]? { __data["typeParameters"] } + /// The function's return types. There can be multiple because functions in Move can return + /// multiple values. These types can reference type parameters introduced by this function (see + /// `typeParameters`). + public var `return`: [RPC_MOVE_FUNCTION_FIELDS.Return]? { __data["return"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_MOVE_FUNCTION_FIELDS: RPC_MOVE_FUNCTION_FIELDS { _toFragment() } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveModuleQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveModuleQuery.graphql.swift new file mode 100644 index 0000000..9d42886 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveModuleQuery.graphql.swift @@ -0,0 +1,109 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetNormalizedMoveModuleQuery: GraphQLQuery { + public static let operationName: String = "getNormalizedMoveModule" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getNormalizedMoveModule($packageId: SuiAddress!, $module: String!) { object(address: $packageId) { __typename asMovePackage { __typename module(name: $module) { __typename ...RPC_MOVE_MODULE_FIELDS } } } }"#, + fragments: [RPC_MOVE_FUNCTION_FIELDS.self, RPC_MOVE_MODULE_FIELDS.self, RPC_MOVE_STRUCT_FIELDS.self] + )) + + public var packageId: SuiAddressApollo + public var module: String + + public init( + packageId: SuiAddressApollo, + module: String + ) { + self.packageId = packageId + self.module = module + } + + public var __variables: Variables? { [ + "packageId": packageId, + "module": module + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("object", Object?.self, arguments: ["address": .variable("packageId")]), + ] } + + public var object: Object? { __data["object"] } + + /// Object + /// + /// Parent Type: `Object` + public struct Object: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asMovePackage", AsMovePackage?.self), + ] } + + /// Attempts to convert the object into a MovePackage + public var asMovePackage: AsMovePackage? { __data["asMovePackage"] } + + /// Object.AsMovePackage + /// + /// Parent Type: `MovePackage` + public struct AsMovePackage: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MovePackage } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("module", Module?.self, arguments: ["name": .variable("module")]), + ] } + + /// A representation of the module called `name` in this package, including the + /// structs and functions it defines. + public var module: Module? { __data["module"] } + + /// Object.AsMovePackage.Module + /// + /// Parent Type: `MoveModule` + public struct Module: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModule } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_MOVE_MODULE_FIELDS.self), + ] } + + /// The module's (unqualified) name. + public var name: String { __data["name"] } + /// Modules that this module considers friends (these modules can access `public(friend)` + /// functions from this module). + public var friends: RPC_MOVE_MODULE_FIELDS.Friends { __data["friends"] } + /// Iterate through the structs defined in this module. + public var structs: RPC_MOVE_MODULE_FIELDS.Structs? { __data["structs"] } + /// Format version of this module's bytecode. + public var fileFormatVersion: Int { __data["fileFormatVersion"] } + /// Iterate through the signatures of functions defined in this module. + public var functions: RPC_MOVE_MODULE_FIELDS.Functions? { __data["functions"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_MOVE_MODULE_FIELDS: RPC_MOVE_MODULE_FIELDS { _toFragment() } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveModulesByPackageQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveModulesByPackageQuery.graphql.swift new file mode 100644 index 0000000..41ee547 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveModulesByPackageQuery.graphql.swift @@ -0,0 +1,161 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetNormalizedMoveModulesByPackageQuery: GraphQLQuery { + public static let operationName: String = "getNormalizedMoveModulesByPackage" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getNormalizedMoveModulesByPackage($packageId: SuiAddress!, $limit: Int = 50) { object(address: $packageId) { asMovePackage { asObject { address } modules(first: $limit) { pageInfo { hasNextPage endCursor } nodes { ...RPC_MOVE_MODULE_FIELDS } } } } }"#, + fragments: [RPC_MOVE_FUNCTION_FIELDS.self, RPC_MOVE_MODULE_FIELDS.self, RPC_MOVE_STRUCT_FIELDS.self] + )) + + public var packageId: SuiAddressApollo + public var limit: GraphQLNullable + + public init( + packageId: SuiAddressApollo, + limit: GraphQLNullable = 50 + ) { + self.packageId = packageId + self.limit = limit + } + + public var __variables: Variables? { [ + "packageId": packageId, + "limit": limit + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("object", Object?.self, arguments: ["address": .variable("packageId"), "first": .variable("limit")]), + ] } + + public var object: Object? { __data["object"] } + + /// Object + /// + /// Parent Type: `Object` + public struct Object: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("asMovePackage", AsMovePackage?.self), + ] } + + /// Attempts to convert the object into a MovePackage + public var asMovePackage: AsMovePackage? { __data["asMovePackage"] } + + /// Object.AsMovePackage + /// + /// Parent Type: `MovePackage` + public struct AsMovePackage: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MovePackage } + public static var __selections: [ApolloAPI.Selection] { [ + .field("asObject", AsObject.self), + .field("modules", Modules?.self), + ] } + + public var asObject: AsObject { __data["asObject"] } + /// Paginate through the MoveModules defined in this package. + public var modules: Modules? { __data["modules"] } + + /// Object.AsMovePackage.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Object.AsMovePackage.Modules + /// + /// Parent Type: `MoveModuleConnection` + public struct Modules: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModuleConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Object.AsMovePackage.Modules.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("hasNextPage", Bool.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// Object.AsMovePackage.Modules.Node + /// + /// Parent Type: `MoveModule` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModule } + public static var __selections: [ApolloAPI.Selection] { [ + .fragment(RPC_MOVE_MODULE_FIELDS.self), + ] } + + /// The module's (unqualified) name. + public var name: String { __data["name"] } + /// Modules that this module considers friends (these modules can access `public(friend)` + /// functions from this module). + public var friends: RPC_MOVE_MODULE_FIELDS.Friends { __data["friends"] } + /// Iterate through the structs defined in this module. + public var structs: RPC_MOVE_MODULE_FIELDS.Structs? { __data["structs"] } + /// Format version of this module's bytecode. + public var fileFormatVersion: Int { __data["fileFormatVersion"] } + /// Iterate through the signatures of functions defined in this module. + public var functions: RPC_MOVE_MODULE_FIELDS.Functions? { __data["functions"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_MOVE_MODULE_FIELDS: RPC_MOVE_MODULE_FIELDS { _toFragment() } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveStructQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveStructQuery.graphql.swift new file mode 100644 index 0000000..2363d43 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetNormalizedMoveStructQuery.graphql.swift @@ -0,0 +1,152 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetNormalizedMoveStructQuery: GraphQLQuery { + public static let operationName: String = "getNormalizedMoveStruct" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getNormalizedMoveStruct($packageId: SuiAddress!, $module: String!, $struct: String!) { object(address: $packageId) { __typename asMovePackage { __typename asObject { __typename address } module(name: $module) { __typename fileFormatVersion struct(name: $struct) { __typename ...RPC_MOVE_STRUCT_FIELDS } } } } }"#, + fragments: [RPC_MOVE_STRUCT_FIELDS.self] + )) + + public var packageId: SuiAddressApollo + public var module: String + public var `struct`: String + + public init( + packageId: SuiAddressApollo, + module: String, + `struct`: String + ) { + self.packageId = packageId + self.module = module + self.`struct` = `struct` + } + + public var __variables: Variables? { [ + "packageId": packageId, + "module": module, + "struct": `struct` + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("object", Object?.self, arguments: ["address": .variable("packageId")]), + ] } + + public var object: Object? { __data["object"] } + + /// Object + /// + /// Parent Type: `Object` + public struct Object: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asMovePackage", AsMovePackage?.self), + ] } + + /// Attempts to convert the object into a MovePackage + public var asMovePackage: AsMovePackage? { __data["asMovePackage"] } + + /// Object.AsMovePackage + /// + /// Parent Type: `MovePackage` + public struct AsMovePackage: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MovePackage } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asObject", AsObject.self), + .field("module", Module?.self, arguments: ["name": .variable("module")]), + ] } + + public var asObject: AsObject { __data["asObject"] } + /// A representation of the module called `name` in this package, including the + /// structs and functions it defines. + public var module: Module? { __data["module"] } + + /// Object.AsMovePackage.AsObject + /// + /// Parent Type: `Object` + public struct AsObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + + /// Object.AsMovePackage.Module + /// + /// Parent Type: `MoveModule` + public struct Module: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveModule } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("fileFormatVersion", Int.self), + .field("struct", Struct?.self, arguments: ["name": .variable("struct")]), + ] } + + /// Format version of this module's bytecode. + public var fileFormatVersion: Int { __data["fileFormatVersion"] } + /// Look-up the definition of a struct defined in this module, by its name. + public var `struct`: Struct? { __data["struct"] } + + /// Object.AsMovePackage.Module.Struct + /// + /// Parent Type: `MoveStruct` + public struct Struct: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveStruct } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_MOVE_STRUCT_FIELDS.self), + ] } + + /// The struct's (unqualified) type name. + public var name: String { __data["name"] } + /// Abilities this struct has. + public var abilities: [GraphQLEnum]? { __data["abilities"] } + /// The names and types of the struct's fields. Field types reference type parameters, by their + /// index in the defining struct's `typeParameters` list. + public var fields: [RPC_MOVE_STRUCT_FIELDS.Field]? { __data["fields"] } + /// Constraints on the struct's formal type parameters. Move bytecode does not name type + /// parameters, so when they are referenced (e.g. in field types) they are identified by their + /// index in this list. + public var typeParameters: [RPC_MOVE_STRUCT_FIELDS.TypeParameter]? { __data["typeParameters"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_MOVE_STRUCT_FIELDS: RPC_MOVE_STRUCT_FIELDS { _toFragment() } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetObjectQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetObjectQuery.graphql.swift new file mode 100644 index 0000000..385b358 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetObjectQuery.graphql.swift @@ -0,0 +1,282 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetObjectQuery: GraphQLQuery { + public static let operationName: String = "getObject" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getObject($id: SuiAddress!, $showBcs: Boolean = false, $showOwner: Boolean = false, $showPreviousTransaction: Boolean = false, $showContent: Boolean = false, $showDisplay: Boolean = false, $showType: Boolean = false, $showStorageRebate: Boolean = false) { object(address: $id) { ...RPC_OBJECT_FIELDS } }"#, + fragments: [RPC_OBJECT_FIELDS.self] + )) + + public var id: SuiAddressApollo + public var showBcs: GraphQLNullable + public var showOwner: GraphQLNullable + public var showPreviousTransaction: GraphQLNullable + public var showContent: GraphQLNullable + public var showDisplay: GraphQLNullable + public var showType: GraphQLNullable + public var showStorageRebate: GraphQLNullable + + public init( + id: SuiAddressApollo, + showBcs: GraphQLNullable = false, + showOwner: GraphQLNullable = false, + showPreviousTransaction: GraphQLNullable = false, + showContent: GraphQLNullable = false, + showDisplay: GraphQLNullable = false, + showType: GraphQLNullable = false, + showStorageRebate: GraphQLNullable = false + ) { + self.id = id + self.showBcs = showBcs + self.showOwner = showOwner + self.showPreviousTransaction = showPreviousTransaction + self.showContent = showContent + self.showDisplay = showDisplay + self.showType = showType + self.showStorageRebate = showStorageRebate + } + + public var __variables: Variables? { [ + "id": id, + "showBcs": showBcs, + "showOwner": showOwner, + "showPreviousTransaction": showPreviousTransaction, + "showContent": showContent, + "showDisplay": showDisplay, + "showType": showType, + "showStorageRebate": showStorageRebate + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("object", Object?.self, arguments: ["address": .variable("id")]), + ] } + + public var object: Object? { __data["object"] } + + /// Object + /// + /// Parent Type: `Object` + public struct Object: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .fragment(RPC_OBJECT_FIELDS.self) + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var objectId: SuiKit.SuiAddressApollo { __data["objectId"] } + /// The Base64Apollo encoded bcs serialization of the object's content. + public var bcs: SuiKit.Base64Apollo? { __data["bcs"] } + public var version: Int { __data["version"] } + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: AnyHashable? { __data["owner"] } + /// The transaction block that created this version of the object. + public var previousTransactionBlock: RPC_OBJECT_FIELDS.PreviousTransactionBlock? { __data["previousTransactionBlock"] } + /// The amount of SUI we would rebate if this object gets deleted or mutated. + /// This number is recalculated based on the present storage gas price. + public var storageRebate: SuiKit.BigIntApollo? { __data["storageRebate"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The set of named templates defined on-chain for the type of this object, + /// to be handled off-chain. The server substitutes data from the object + /// into these templates to generate a display string per template. + public var display: [RPC_OBJECT_FIELDS.Display]? { __data["display"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_OBJECT_FIELDS: RPC_OBJECT_FIELDS { _toFragment() } + } + + /// Object.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + + public var ifShowType: IfShowType? { _asInlineFragment() } + public var ifShowContent: IfShowContent? { _asInlineFragment() } + public var ifShowBcs: IfShowBcs? { _asInlineFragment() } + + /// Object.AsMoveObject.IfShowType + /// + /// Parent Type: `MoveObject` + public struct IfShowType: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = GetObjectQuery.Data.Object.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Object.AsMoveObject.IfShowType.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// Object.AsMoveObject.IfShowType.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// Object.AsMoveObject.IfShowContent + /// + /// Parent Type: `MoveObject` + public struct IfShowContent: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = GetObjectQuery.Data.Object.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Object.AsMoveObject.IfShowContent.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// Object.AsMoveObject.IfShowContent.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// Object.AsMoveObject.IfShowBcs + /// + /// Parent Type: `MoveObject` + public struct IfShowBcs: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = GetObjectQuery.Data.Object.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Object.AsMoveObject.IfShowBcs.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// Object.AsMoveObject.IfShowBcs.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetOwnedObjectsQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetOwnedObjectsQuery.graphql.swift new file mode 100644 index 0000000..e813964 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetOwnedObjectsQuery.graphql.swift @@ -0,0 +1,351 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetOwnedObjectsQuery: GraphQLQuery { + public static let operationName: String = "getOwnedObjects" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getOwnedObjects($owner: SuiAddress!, $limit: Int, $cursor: String, $showBcs: Boolean = false, $showContent: Boolean = false, $showDisplay: Boolean = false, $showType: Boolean = false, $showOwner: Boolean = false, $showPreviousTransaction: Boolean = false, $showStorageRebate: Boolean = false, $filter: ObjectFilter) { address(address: $owner) { objects(first: $limit, after: $cursor, filter: $filter) { pageInfo { hasNextPage endCursor } nodes { ...RPC_OBJECT_FIELDS } } } }"#, + fragments: [RPC_OBJECT_FIELDS.self] + )) + + public var owner: SuiAddressApollo + public var limit: GraphQLNullable + public var cursor: GraphQLNullable + public var showBcs: GraphQLNullable + public var showContent: GraphQLNullable + public var showDisplay: GraphQLNullable + public var showType: GraphQLNullable + public var showOwner: GraphQLNullable + public var showPreviousTransaction: GraphQLNullable + public var showStorageRebate: GraphQLNullable + public var filter: GraphQLNullable + + public init( + owner: SuiAddressApollo, + limit: GraphQLNullable, + cursor: GraphQLNullable, + showBcs: GraphQLNullable = false, + showContent: GraphQLNullable = false, + showDisplay: GraphQLNullable = false, + showType: GraphQLNullable = false, + showOwner: GraphQLNullable = false, + showPreviousTransaction: GraphQLNullable = false, + showStorageRebate: GraphQLNullable = false, + filter: GraphQLNullable + ) { + self.owner = owner + self.limit = limit + self.cursor = cursor + self.showBcs = showBcs + self.showContent = showContent + self.showDisplay = showDisplay + self.showType = showType + self.showOwner = showOwner + self.showPreviousTransaction = showPreviousTransaction + self.showStorageRebate = showStorageRebate + self.filter = filter + } + + public var __variables: Variables? { [ + "owner": owner, + "limit": limit, + "cursor": cursor, + "showBcs": showBcs, + "showContent": showContent, + "showDisplay": showDisplay, + "showType": showType, + "showOwner": showOwner, + "showPreviousTransaction": showPreviousTransaction, + "showStorageRebate": showStorageRebate, + "filter": filter + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", Address?.self, arguments: ["address": .variable("owner")]), + ] } + + public var address: Address? { __data["address"] } + + /// Address + /// + /// Parent Type: `Address` + public struct Address: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("objects", ObjectConnection?.self, arguments: [ + "first": .variable("limit"), + "after": .variable("cursor"), + "filter": .variable("filter") + ]), + ] } + + public var objectConnection: ObjectConnection? { __data["objects"] } + + /// Address.ObjectConnection + /// + /// Parent Type: `ObjectConnection` + public struct ObjectConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ObjectConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Address.ObjectConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("hasNextPage", Bool.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// Address.ObjectConnection.Node + /// + /// Parent Type: `Object` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .fragment(RPC_OBJECT_FIELDS.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var objectId: SuiKit.SuiAddressApollo { __data["objectId"] } + /// The Base64Apollo encoded bcs serialization of the object's content. + public var bcs: SuiKit.Base64Apollo? { __data["bcs"] } + public var version: Int { __data["version"] } + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: AnyHashable? { __data["owner"] } + /// The transaction block that created this version of the object. + public var previousTransactionBlock: RPC_OBJECT_FIELDS.PreviousTransactionBlock? { __data["previousTransactionBlock"] } + /// The amount of SUI we would rebate if this object gets deleted or mutated. + /// This number is recalculated based on the present storage gas price. + public var storageRebate: SuiKit.BigIntApollo? { __data["storageRebate"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The set of named templates defined on-chain for the type of this object, + /// to be handled off-chain. The server substitutes data from the object + /// into these templates to generate a display string per template. + public var display: [RPC_OBJECT_FIELDS.Display]? { __data["display"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_OBJECT_FIELDS: RPC_OBJECT_FIELDS { _toFragment() } + } + + /// Address.ObjectConnection.Node.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + + public var ifShowType: IfShowType? { _asInlineFragment() } + public var ifShowContent: IfShowContent? { _asInlineFragment() } + public var ifShowBcs: IfShowBcs? { _asInlineFragment() } + + /// Address.ObjectConnection.Node.AsMoveObject.IfShowType + /// + /// Parent Type: `MoveObject` + public struct IfShowType: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = GetOwnedObjectsQuery.Data.Address.ObjectConnection.Node.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Address.ObjectConnection.Node.AsMoveObject.IfShowType.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// Address.ObjectConnection.Node.AsMoveObject.IfShowType.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// Address.ObjectConnection.Node.AsMoveObject.IfShowContent + /// + /// Parent Type: `MoveObject` + public struct IfShowContent: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = GetOwnedObjectsQuery.Data.Address.ObjectConnection.Node.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Address.ObjectConnection.Node.AsMoveObject.IfShowContent.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// Address.ObjectConnection.Node.AsMoveObject.IfShowContent.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// Address.ObjectConnection.Node.AsMoveObject.IfShowBcs + /// + /// Parent Type: `MoveObject` + public struct IfShowBcs: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = GetOwnedObjectsQuery.Data.Address.ObjectConnection.Node.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Address.ObjectConnection.Node.AsMoveObject.IfShowBcs.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// Address.ObjectConnection.Node.AsMoveObject.IfShowBcs.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetProtocolConfigQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetProtocolConfigQuery.graphql.swift new file mode 100644 index 0000000..578f238 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetProtocolConfigQuery.graphql.swift @@ -0,0 +1,97 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetProtocolConfigQuery: GraphQLQuery { + public static let operationName: String = "getProtocolConfig" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getProtocolConfig($protocolVersion: Int) { protocolConfig(protocolVersion: $protocolVersion) { __typename protocolVersion configs { __typename key value } featureFlags { __typename key value } } }"# + )) + + public var protocolVersion: GraphQLNullable + + public init(protocolVersion: GraphQLNullable) { + self.protocolVersion = protocolVersion + } + + public var __variables: Variables? { ["protocolVersion": protocolVersion] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("protocolConfig", ProtocolConfig.self, arguments: ["protocolVersion": .variable("protocolVersion")]), + ] } + + /// Fetch the protocol config by protocol version (defaults to the latest protocol + /// version known to the GraphQL) + public var protocolConfig: ProtocolConfig { __data["protocolConfig"] } + + /// ProtocolConfig + /// + /// Parent Type: `ProtocolConfigs` + public struct ProtocolConfig: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ProtocolConfigs } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("protocolVersion", Int.self), + .field("configs", [Config].self), + .field("featureFlags", [FeatureFlag].self), + ] } + + /// The protocol is not required to change on every epoch boundary, so the protocol version + /// tracks which change to the protocol these configs are from. + public var protocolVersion: Int { __data["protocolVersion"] } + /// List all available configurations and their values. These configurations can take any value + /// (but they will all be represented in string form), and do not include feature flags. + public var configs: [Config] { __data["configs"] } + /// List all available feature flags and their values. Feature flags are a form of boolean + /// configuration that are usually used to gate features while they are in development. Once a + /// flag has been enabled, it is rare for it to be disabled. + public var featureFlags: [FeatureFlag] { __data["featureFlags"] } + + /// ProtocolConfig.Config + /// + /// Parent Type: `ProtocolConfigAttr` + public struct Config: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ProtocolConfigAttr } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("key", String.self), + .field("value", String?.self), + ] } + + public var key: String { __data["key"] } + public var value: String? { __data["value"] } + } + + /// ProtocolConfig.FeatureFlag + /// + /// Parent Type: `ProtocolConfigFeatureFlag` + public struct FeatureFlag: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ProtocolConfigFeatureFlag } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("key", String.self), + .field("value", Bool.self), + ] } + + public var key: String { __data["key"] } + public var value: Bool { __data["value"] } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetReferenceGasPriceQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetReferenceGasPriceQuery.graphql.swift new file mode 100644 index 0000000..3589e66 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetReferenceGasPriceQuery.graphql.swift @@ -0,0 +1,44 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetReferenceGasPriceQuery: GraphQLQuery { + public static let operationName: String = "getReferenceGasPrice" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getReferenceGasPrice { epoch { __typename referenceGasPrice } }"# + )) + + public init() {} + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("epoch", Epoch?.self), + ] } + + /// Fetch epoch information by ID (defaults to the latest epoch). + public var epoch: Epoch? { __data["epoch"] } + + /// Epoch + /// + /// Parent Type: `Epoch` + public struct Epoch: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Epoch } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("referenceGasPrice", SuiKit.BigIntApollo?.self), + ] } + + /// The minimum gas price that a quorum of validators are guaranteed to sign a transaction for + public var referenceGasPrice: SuiKit.BigIntApollo? { __data["referenceGasPrice"] } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetStakesByIdsQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetStakesByIdsQuery.graphql.swift new file mode 100644 index 0000000..c7c4197 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetStakesByIdsQuery.graphql.swift @@ -0,0 +1,164 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetStakesByIdsQuery: GraphQLQuery { + public static let operationName: String = "getStakesByIds" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getStakesByIds($ids: [SuiAddress!]!, $limit: Int, $cursor: String) { objectConnection(first: $limit, after: $cursor, filter: { objectIds: $ids }) { __typename pageInfo { __typename hasNextPage endCursor } nodes { __typename asMoveObject { __typename asStakedSui { __typename ...RPC_STAKE_FIELDS } } } } }"#, + fragments: [RPC_STAKE_FIELDS.self] + )) + + public var ids: [SuiAddressApollo] + public var limit: GraphQLNullable + public var cursor: GraphQLNullable + + public init( + ids: [SuiAddressApollo], + limit: GraphQLNullable, + cursor: GraphQLNullable + ) { + self.ids = ids + self.limit = limit + self.cursor = cursor + } + + public var __variables: Variables? { [ + "ids": ids, + "limit": limit, + "cursor": cursor + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("objectConnection", ObjectConnection?.self, arguments: [ + "first": .variable("limit"), + "after": .variable("cursor"), + "filter": ["objectIds": .variable("ids")] + ]), + ] } + + public var objectConnection: ObjectConnection? { __data["objectConnection"] } + + /// ObjectConnection + /// + /// Parent Type: `ObjectConnection` + public struct ObjectConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ObjectConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// ObjectConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// ObjectConnection.Node + /// + /// Parent Type: `Object` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asMoveObject", AsMoveObject?.self), + ] } + + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + + /// ObjectConnection.Node.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("asStakedSui", AsStakedSui?.self), + ] } + + /// Attempts to convert the Move object into a `0x3::staking_pool::StakedSui`. + public var asStakedSui: AsStakedSui? { __data["asStakedSui"] } + + /// ObjectConnection.Node.AsMoveObject.AsStakedSui + /// + /// Parent Type: `StakedSui` + public struct AsStakedSui: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.StakedSui } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_STAKE_FIELDS.self), + ] } + + /// The SUI that was initially staked. + public var principal: SuiKit.BigIntApollo? { __data["principal"] } + /// The epoch at which this stake became active + public var activatedEpoch: RPC_STAKE_FIELDS.ActivatedEpoch? { __data["activatedEpoch"] } + /// The epoch at which this object was requested to join a stake pool + public var requestedEpoch: RPC_STAKE_FIELDS.RequestedEpoch? { __data["requestedEpoch"] } + /// The corresponding `0x3::staking_pool::StakedSui` Move object. + public var asMoveObject: RPC_STAKE_FIELDS.AsMoveObject { __data["asMoveObject"] } + /// The estimated reward for this stake object, calculated as: + /// + /// principal * (initial_stake_rate / current_stake_rate - 1.0) + /// + /// Or 0, if this value is negative, where: + /// + /// - `initial_stake_rate` is the stake rate at the epoch this stake was activated at. + /// - `current_stake_rate` is the stake rate in the current epoch. + /// + /// This value is only available if the stake is active. + public var estimatedReward: SuiKit.BigIntApollo? { __data["estimatedReward"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_STAKE_FIELDS: RPC_STAKE_FIELDS { _toFragment() } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetStakesQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetStakesQuery.graphql.swift new file mode 100644 index 0000000..e8364d4 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetStakesQuery.graphql.swift @@ -0,0 +1,146 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetStakesQuery: GraphQLQuery { + public static let operationName: String = "getStakes" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getStakes($owner: SuiAddress!, $limit: Int, $cursor: String) { address(address: $owner) { __typename stakedSuiConnection(first: $limit, after: $cursor) { __typename pageInfo { __typename hasNextPage endCursor } nodes { __typename ...RPC_STAKE_FIELDS } } } }"#, + fragments: [RPC_STAKE_FIELDS.self] + )) + + public var owner: SuiAddressApollo + public var limit: GraphQLNullable + public var cursor: GraphQLNullable + + public init( + owner: SuiAddressApollo, + limit: GraphQLNullable, + cursor: GraphQLNullable + ) { + self.owner = owner + self.limit = limit + self.cursor = cursor + } + + public var __variables: Variables? { [ + "owner": owner, + "limit": limit, + "cursor": cursor + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", Address?.self, arguments: ["address": .variable("owner")]), + ] } + + public var address: Address? { __data["address"] } + + /// Address + /// + /// Parent Type: `Address` + public struct Address: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("stakedSuiConnection", StakedSuiConnection?.self, arguments: [ + "first": .variable("limit"), + "after": .variable("cursor") + ]), + ] } + + /// The `0x3::staking_pool::StakedSui` objects owned by the given address. + public var stakedSuiConnection: StakedSuiConnection? { __data["stakedSuiConnection"] } + + /// Address.StakedSuiConnection + /// + /// Parent Type: `StakedSuiConnection` + public struct StakedSuiConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.StakedSuiConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Address.StakedSuiConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// Address.StakedSuiConnection.Node + /// + /// Parent Type: `StakedSui` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.StakedSui } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_STAKE_FIELDS.self), + ] } + + /// The SUI that was initially staked. + public var principal: SuiKit.BigIntApollo? { __data["principal"] } + /// The epoch at which this stake became active + public var activatedEpoch: RPC_STAKE_FIELDS.ActivatedEpoch? { __data["activatedEpoch"] } + /// The epoch at which this object was requested to join a stake pool + public var requestedEpoch: RPC_STAKE_FIELDS.RequestedEpoch? { __data["requestedEpoch"] } + /// The corresponding `0x3::staking_pool::StakedSui` Move object. + public var asMoveObject: RPC_STAKE_FIELDS.AsMoveObject { __data["asMoveObject"] } + /// The estimated reward for this stake object, calculated as: + /// + /// principal * (initial_stake_rate / current_stake_rate - 1.0) + /// + /// Or 0, if this value is negative, where: + /// + /// - `initial_stake_rate` is the stake rate at the epoch this stake was activated at. + /// - `current_stake_rate` is the stake rate in the current epoch. + /// + /// This value is only available if the stake is active. + public var estimatedReward: SuiKit.BigIntApollo? { __data["estimatedReward"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_STAKE_FIELDS: RPC_STAKE_FIELDS { _toFragment() } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetTotalSupplyQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetTotalSupplyQuery.graphql.swift new file mode 100644 index 0000000..e815ac4 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetTotalSupplyQuery.graphql.swift @@ -0,0 +1,52 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetTotalSupplyQuery: GraphQLQuery { + public static let operationName: String = "getTotalSupply" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getTotalSupply($coinType: String!) { coinMetadata(coinType: $coinType) { __typename supply decimals } }"# + )) + + public var coinType: String + + public init(coinType: String) { + self.coinType = coinType + } + + public var __variables: Variables? { ["coinType": coinType] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("coinMetadata", CoinMetadata?.self, arguments: ["coinType": .variable("coinType")]), + ] } + + public var coinMetadata: CoinMetadata? { __data["coinMetadata"] } + + /// CoinMetadata + /// + /// Parent Type: `CoinMetadata` + public struct CoinMetadata: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.CoinMetadata } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("supply", SuiKit.BigIntApollo?.self), + .field("decimals", Int?.self), + ] } + + /// The overall quantity of tokens that will be issued. + public var supply: SuiKit.BigIntApollo? { __data["supply"] } + /// The number of decimal places used to represent the token. + public var decimals: Int? { __data["decimals"] } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetTotalTransactionBlocksQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetTotalTransactionBlocksQuery.graphql.swift new file mode 100644 index 0000000..3afd1cc --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetTotalTransactionBlocksQuery.graphql.swift @@ -0,0 +1,45 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetTotalTransactionBlocksQuery: GraphQLQuery { + public static let operationName: String = "getTotalTransactionBlocks" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getTotalTransactionBlocks { checkpoint { __typename networkTotalTransactions } }"# + )) + + public init() {} + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("checkpoint", Checkpoint?.self), + ] } + + /// Fetch checkpoint information by sequence number or digest (defaults to the latest available + /// checkpoint). + public var checkpoint: Checkpoint? { __data["checkpoint"] } + + /// Checkpoint + /// + /// Parent Type: `Checkpoint` + public struct Checkpoint: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Checkpoint } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("networkTotalTransactions", Int?.self), + ] } + + /// The total number of transaction blocks in the network by the end of this checkpoint. + public var networkTotalTransactions: Int? { __data["networkTotalTransactions"] } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetTransactionBlockQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetTransactionBlockQuery.graphql.swift new file mode 100644 index 0000000..9cfccd7 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetTransactionBlockQuery.graphql.swift @@ -0,0 +1,99 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetTransactionBlockQuery: GraphQLQuery { + public static let operationName: String = "getTransactionBlock" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getTransactionBlock($digest: String!, $showBalanceChanges: Boolean = false, $showEffects: Boolean = false, $showEvents: Boolean = false, $showInput: Boolean = false, $showObjectChanges: Boolean = false, $showRawInput: Boolean = false) { transactionBlock(digest: $digest) { __typename ...RPC_TRANSACTION_FIELDS } }"#, + fragments: [RPC_EVENTS_FIELDS.self, RPC_TRANSACTION_FIELDS.self] + )) + + public var digest: String + public var showBalanceChanges: GraphQLNullable + public var showEffects: GraphQLNullable + public var showEvents: GraphQLNullable + public var showInput: GraphQLNullable + public var showObjectChanges: GraphQLNullable + public var showRawInput: GraphQLNullable + + public init( + digest: String, + showBalanceChanges: GraphQLNullable = false, + showEffects: GraphQLNullable = false, + showEvents: GraphQLNullable = false, + showInput: GraphQLNullable = false, + showObjectChanges: GraphQLNullable = false, + showRawInput: GraphQLNullable = false + ) { + self.digest = digest + self.showBalanceChanges = showBalanceChanges + self.showEffects = showEffects + self.showEvents = showEvents + self.showInput = showInput + self.showObjectChanges = showObjectChanges + self.showRawInput = showRawInput + } + + public var __variables: Variables? { [ + "digest": digest, + "showBalanceChanges": showBalanceChanges, + "showEffects": showEffects, + "showEvents": showEvents, + "showInput": showInput, + "showObjectChanges": showObjectChanges, + "showRawInput": showRawInput + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("transactionBlock", TransactionBlock?.self, arguments: ["digest": .variable("digest")]), + ] } + + /// Fetch a transaction block by its transaction digest. + public var transactionBlock: TransactionBlock? { __data["transactionBlock"] } + + /// TransactionBlock + /// + /// Parent Type: `TransactionBlock` + public struct TransactionBlock: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlock } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_TRANSACTION_FIELDS.self), + ] } + + /// A 32-byte hash that uniquely identifies the transaction block contents, encoded in Base58. + /// This serves as a unique id for the block on chain. + public var digest: String { __data["digest"] } + /// Serialized form of this transaction's `SenderSignedData`, BCS serialized and Base64Apollo encoded. + public var rawTransaction: SuiKit.Base64Apollo? { __data["rawTransaction"] } + /// The address corresponding to the public key that signed this transaction. System + /// transactions do not have senders. + public var sender: RPC_TRANSACTION_FIELDS.Sender? { __data["sender"] } + /// A list of all signatures, Base64Apollo-encoded, from senders, and potentially the gas owner if + /// this is a sponsored transaction. + public var signatures: [SuiKit.Base64Apollo]? { __data["signatures"] } + /// Events emitted by this transaction block. + public var events: RPC_TRANSACTION_FIELDS.Events? { __data["events"] } + /// The effects field captures the results to the chain of executing this transaction. + public var effects: RPC_TRANSACTION_FIELDS.Effects? { __data["effects"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_TRANSACTION_FIELDS: RPC_TRANSACTION_FIELDS { _toFragment() } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetValidatorsApyQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetValidatorsApyQuery.graphql.swift new file mode 100644 index 0000000..e4e5282 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/GetValidatorsApyQuery.graphql.swift @@ -0,0 +1,101 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class GetValidatorsApyQuery: GraphQLQuery { + public static let operationName: String = "getValidatorsApy" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query getValidatorsApy { epoch { __typename epochId validatorSet { __typename activeValidators { __typename address { __typename address } apy } } } }"# + )) + + public init() {} + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("epoch", Epoch?.self), + ] } + + /// Fetch epoch information by ID (defaults to the latest epoch). + public var epoch: Epoch? { __data["epoch"] } + + /// Epoch + /// + /// Parent Type: `Epoch` + public struct Epoch: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Epoch } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("epochId", Int.self), + .field("validatorSet", ValidatorSet?.self), + ] } + + /// The epoch's id as a sequence number that starts at 0 and is incremented by one at every epoch change + public var epochId: Int { __data["epochId"] } + /// Validator related properties, including the active validators + public var validatorSet: ValidatorSet? { __data["validatorSet"] } + + /// Epoch.ValidatorSet + /// + /// Parent Type: `ValidatorSet` + public struct ValidatorSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ValidatorSet } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("activeValidators", [ActiveValidator]?.self), + ] } + + /// The current list of active validators. + public var activeValidators: [ActiveValidator]? { __data["activeValidators"] } + + /// Epoch.ValidatorSet.ActiveValidator + /// + /// Parent Type: `Validator` + public struct ActiveValidator: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Validator } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", Address.self), + .field("apy", Int?.self), + ] } + + /// Validator's address. + public var address: Address { __data["address"] } + /// The APY of this validator in basis points. + /// To get the APY in percentage, divide by 100. + public var apy: Int? { __data["apy"] } + + /// Epoch.ValidatorSet.ActiveValidator.Address + /// + /// Parent Type: `Address` + public struct Address: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/MultiGetObjectsQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/MultiGetObjectsQuery.graphql.swift new file mode 100644 index 0000000..bc0c0e8 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/MultiGetObjectsQuery.graphql.swift @@ -0,0 +1,335 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class MultiGetObjectsQuery: GraphQLQuery { + public static let operationName: String = "multiGetObjects" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query multiGetObjects($ids: [SuiAddress!]!, $limit: Int, $cursor: String, $showBcs: Boolean = false, $showContent: Boolean = false, $showDisplay: Boolean = false, $showType: Boolean = false, $showOwner: Boolean = false, $showPreviousTransaction: Boolean = false, $showStorageRebate: Boolean = false) { objects(first: $limit, after: $cursor, filter: { objectIds: $ids }) { __typename pageInfo { __typename hasNextPage endCursor } nodes { __typename ...RPC_OBJECT_FIELDS } } }"#, + fragments: [RPC_OBJECT_FIELDS.self] + )) + + public var ids: [SuiAddressApollo] + public var limit: GraphQLNullable + public var cursor: GraphQLNullable + public var showBcs: GraphQLNullable + public var showContent: GraphQLNullable + public var showDisplay: GraphQLNullable + public var showType: GraphQLNullable + public var showOwner: GraphQLNullable + public var showPreviousTransaction: GraphQLNullable + public var showStorageRebate: GraphQLNullable + + public init( + ids: [SuiAddressApollo], + limit: GraphQLNullable, + cursor: GraphQLNullable, + showBcs: GraphQLNullable = false, + showContent: GraphQLNullable = false, + showDisplay: GraphQLNullable = false, + showType: GraphQLNullable = false, + showOwner: GraphQLNullable = false, + showPreviousTransaction: GraphQLNullable = false, + showStorageRebate: GraphQLNullable = false + ) { + self.ids = ids + self.limit = limit + self.cursor = cursor + self.showBcs = showBcs + self.showContent = showContent + self.showDisplay = showDisplay + self.showType = showType + self.showOwner = showOwner + self.showPreviousTransaction = showPreviousTransaction + self.showStorageRebate = showStorageRebate + } + + public var __variables: Variables? { [ + "ids": ids, + "limit": limit, + "cursor": cursor, + "showBcs": showBcs, + "showContent": showContent, + "showDisplay": showDisplay, + "showType": showType, + "showOwner": showOwner, + "showPreviousTransaction": showPreviousTransaction, + "showStorageRebate": showStorageRebate + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("objects", ObjectConnection?.self, arguments: [ + "first": .variable("limit"), + "after": .variable("cursor"), + "filter": ["objectIds": .variable("ids")] + ]), + ] } + + public var objectConnection: ObjectConnection? { __data["objects"] } + + /// ObjectConnection + /// + /// Parent Type: `ObjectConnection` + public struct ObjectConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.ObjectConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// ObjectConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// ObjectConnection.Node + /// + /// Parent Type: `Object` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_OBJECT_FIELDS.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var objectId: SuiKit.SuiAddressApollo { __data["objectId"] } + /// The Base64Apollo encoded bcs serialization of the object's content. + public var bcs: SuiKit.Base64Apollo? { __data["bcs"] } + public var version: Int { __data["version"] } + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: AnyHashable? { __data["owner"] } + /// The transaction block that created this version of the object. + public var previousTransactionBlock: RPC_OBJECT_FIELDS.PreviousTransactionBlock? { __data["previousTransactionBlock"] } + /// The amount of SUI we would rebate if this object gets deleted or mutated. + /// This number is recalculated based on the present storage gas price. + public var storageRebate: SuiKit.BigIntApollo? { __data["storageRebate"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The set of named templates defined on-chain for the type of this object, + /// to be handled off-chain. The server substitutes data from the object + /// into these templates to generate a display string per template. + public var display: [RPC_OBJECT_FIELDS.Display]? { __data["display"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_OBJECT_FIELDS: RPC_OBJECT_FIELDS { _toFragment() } + } + + /// ObjectConnection.Node.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + + public var ifShowType: IfShowType? { _asInlineFragment() } + public var ifShowContent: IfShowContent? { _asInlineFragment() } + public var ifShowBcs: IfShowBcs? { _asInlineFragment() } + + /// ObjectConnection.Node.AsMoveObject.IfShowType + /// + /// Parent Type: `MoveObject` + public struct IfShowType: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = MultiGetObjectsQuery.Data.ObjectConnection.Node.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// ObjectConnection.Node.AsMoveObject.IfShowType.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// ObjectConnection.Node.AsMoveObject.IfShowType.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// ObjectConnection.Node.AsMoveObject.IfShowContent + /// + /// Parent Type: `MoveObject` + public struct IfShowContent: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = MultiGetObjectsQuery.Data.ObjectConnection.Node.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// ObjectConnection.Node.AsMoveObject.IfShowContent.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// ObjectConnection.Node.AsMoveObject.IfShowContent.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// ObjectConnection.Node.AsMoveObject.IfShowBcs + /// + /// Parent Type: `MoveObject` + public struct IfShowBcs: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = MultiGetObjectsQuery.Data.ObjectConnection.Node.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// ObjectConnection.Node.AsMoveObject.IfShowBcs.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// ObjectConnection.Node.AsMoveObject.IfShowBcs.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/MultiGetTransactionBlocksQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/MultiGetTransactionBlocksQuery.graphql.swift new file mode 100644 index 0000000..22ef268 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/MultiGetTransactionBlocksQuery.graphql.swift @@ -0,0 +1,156 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class MultiGetTransactionBlocksQuery: GraphQLQuery { + public static let operationName: String = "multiGetTransactionBlocks" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query multiGetTransactionBlocks($digests: [String!]!, $limit: Int, $cursor: String, $showBalanceChanges: Boolean = false, $showEffects: Boolean = false, $showEvents: Boolean = false, $showInput: Boolean = false, $showObjectChanges: Boolean = false, $showRawInput: Boolean = false) { transactionBlockConnection( first: $limit after: $cursor filter: { transactionIds: $digests } ) { __typename pageInfo { __typename hasNextPage hasPreviousPage startCursor endCursor } nodes { __typename ...RPC_TRANSACTION_FIELDS } } }"#, + fragments: [RPC_EVENTS_FIELDS.self, RPC_TRANSACTION_FIELDS.self] + )) + + public var digests: [String] + public var limit: GraphQLNullable + public var cursor: GraphQLNullable + public var showBalanceChanges: GraphQLNullable + public var showEffects: GraphQLNullable + public var showEvents: GraphQLNullable + public var showInput: GraphQLNullable + public var showObjectChanges: GraphQLNullable + public var showRawInput: GraphQLNullable + + public init( + digests: [String], + limit: GraphQLNullable, + cursor: GraphQLNullable, + showBalanceChanges: GraphQLNullable = false, + showEffects: GraphQLNullable = false, + showEvents: GraphQLNullable = false, + showInput: GraphQLNullable = false, + showObjectChanges: GraphQLNullable = false, + showRawInput: GraphQLNullable = false + ) { + self.digests = digests + self.limit = limit + self.cursor = cursor + self.showBalanceChanges = showBalanceChanges + self.showEffects = showEffects + self.showEvents = showEvents + self.showInput = showInput + self.showObjectChanges = showObjectChanges + self.showRawInput = showRawInput + } + + public var __variables: Variables? { [ + "digests": digests, + "limit": limit, + "cursor": cursor, + "showBalanceChanges": showBalanceChanges, + "showEffects": showEffects, + "showEvents": showEvents, + "showInput": showInput, + "showObjectChanges": showObjectChanges, + "showRawInput": showRawInput + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("transactionBlockConnection", TransactionBlockConnection?.self, arguments: [ + "first": .variable("limit"), + "after": .variable("cursor"), + "filter": ["transactionIds": .variable("digests")] + ]), + ] } + + public var transactionBlockConnection: TransactionBlockConnection? { __data["transactionBlockConnection"] } + + /// TransactionBlockConnection + /// + /// Parent Type: `TransactionBlockConnection` + public struct TransactionBlockConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlockConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// TransactionBlockConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("hasPreviousPage", Bool.self), + .field("startCursor", String?.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating backwards, are there more items? + public var hasPreviousPage: Bool { __data["hasPreviousPage"] } + /// When paginating backwards, the cursor to continue. + public var startCursor: String? { __data["startCursor"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// TransactionBlockConnection.Node + /// + /// Parent Type: `TransactionBlock` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlock } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_TRANSACTION_FIELDS.self), + ] } + + /// A 32-byte hash that uniquely identifies the transaction block contents, encoded in Base58. + /// This serves as a unique id for the block on chain. + public var digest: String { __data["digest"] } + /// Serialized form of this transaction's `SenderSignedData`, BCS serialized and Base64Apollo encoded. + public var rawTransaction: SuiKit.Base64Apollo? { __data["rawTransaction"] } + /// The address corresponding to the public key that signed this transaction. System + /// transactions do not have senders. + public var sender: RPC_TRANSACTION_FIELDS.Sender? { __data["sender"] } + /// A list of all signatures, Base64Apollo-encoded, from senders, and potentially the gas owner if + /// this is a sponsored transaction. + public var signatures: [SuiKit.Base64Apollo]? { __data["signatures"] } + /// Events emitted by this transaction block. + public var events: RPC_TRANSACTION_FIELDS.Events? { __data["events"] } + /// The effects field captures the results to the chain of executing this transaction. + public var effects: RPC_TRANSACTION_FIELDS.Effects? { __data["effects"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_TRANSACTION_FIELDS: RPC_TRANSACTION_FIELDS { _toFragment() } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/QueryEventsQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/QueryEventsQuery.graphql.swift new file mode 100644 index 0000000..e699666 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/QueryEventsQuery.graphql.swift @@ -0,0 +1,152 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class QueryEventsQuery: GraphQLQuery { + public static let operationName: String = "queryEvents" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query queryEvents($filter: EventFilter!, $before: String, $after: String, $first: Int, $last: Int) { eventConnection( filter: $filter first: $first after: $after last: $last before: $before ) { __typename pageInfo { __typename hasNextPage hasPreviousPage endCursor startCursor } nodes { __typename ...RPC_EVENTS_FIELDS } } }"#, + fragments: [RPC_EVENTS_FIELDS.self] + )) + + public var filter: EventFilter + public var before: GraphQLNullable + public var after: GraphQLNullable + public var first: GraphQLNullable + public var last: GraphQLNullable + + public init( + filter: EventFilter, + before: GraphQLNullable, + after: GraphQLNullable, + first: GraphQLNullable, + last: GraphQLNullable + ) { + self.filter = filter + self.before = before + self.after = after + self.first = first + self.last = last + } + + public var __variables: Variables? { [ + "filter": filter, + "before": before, + "after": after, + "first": first, + "last": last + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("eventConnection", EventConnection?.self, arguments: [ + "filter": .variable("filter"), + "first": .variable("first"), + "after": .variable("after"), + "last": .variable("last"), + "before": .variable("before") + ]), + ] } + + public var eventConnection: EventConnection? { __data["eventConnection"] } + + /// EventConnection + /// + /// Parent Type: `EventConnection` + public struct EventConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.EventConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// EventConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("hasPreviousPage", Bool.self), + .field("endCursor", String?.self), + .field("startCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating backwards, are there more items? + public var hasPreviousPage: Bool { __data["hasPreviousPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + /// When paginating backwards, the cursor to continue. + public var startCursor: String? { __data["startCursor"] } + } + + /// EventConnection.Node + /// + /// Parent Type: `Event` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Event } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_EVENTS_FIELDS.self), + ] } + + /// The Move module containing some function that when called by + /// a programmable transaction block (PTB) emitted this event. + /// For example, if a PTB invokes A::m1::foo, which internally + /// calls A::m2::emit_event to emit an event, + /// the sending module would be A::m1. + public var sendingModule: RPC_EVENTS_FIELDS.SendingModule? { __data["sendingModule"] } + /// Addresses of the senders of the event + public var senders: [RPC_EVENTS_FIELDS.Sender]? { __data["senders"] } + public var type: RPC_EVENTS_FIELDS.Type_SelectionSet { __data["type"] } + /// Representation of a Move value in JSONApollo, where: + /// + /// - Addresses, IDs, and UIDs are represented in canonical form, as JSONApollo strings. + /// - Bools are represented by JSONApollo boolean literals. + /// - u8, u16, and u32 are represented as JSONApollo numbers. + /// - u64, u128, and u256 are represented as JSONApollo strings. + /// - Vectors are represented by JSONApollo arrays. + /// - Structs are represented by JSONApollo objects. + /// - Empty optional values are represented by `null`. + /// + /// This form is offered as a less verbose convenience in cases where the layout of the type is + /// known by the client. + public var JSONApollo: SuiKit.JSONApollo { __data["JSONApollo"] } + public var bcs: SuiKit.Base64Apollo { __data["bcs"] } + /// UTC timestamp in milliseconds since epoch (1/1/1970) + public var timestamp: SuiKit.DateTimeApollo? { __data["timestamp"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_EVENTS_FIELDS: RPC_EVENTS_FIELDS { _toFragment() } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/QueryTransactionBlocksQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/QueryTransactionBlocksQuery.graphql.swift new file mode 100644 index 0000000..62ac8a2 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/QueryTransactionBlocksQuery.graphql.swift @@ -0,0 +1,166 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class QueryTransactionBlocksQuery: GraphQLQuery { + public static let operationName: String = "queryTransactionBlocks" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query queryTransactionBlocks($first: Int, $last: Int, $before: String, $after: String, $showBalanceChanges: Boolean = false, $showEffects: Boolean = false, $showEvents: Boolean = false, $showInput: Boolean = false, $showObjectChanges: Boolean = false, $showRawInput: Boolean = false, $filter: TransactionBlockFilter) { transactionBlockConnection( first: $first after: $after last: $last before: $before filter: $filter ) { __typename pageInfo { __typename hasNextPage hasPreviousPage startCursor endCursor } nodes { __typename ...RPC_TRANSACTION_FIELDS } } }"#, + fragments: [RPC_EVENTS_FIELDS.self, RPC_TRANSACTION_FIELDS.self] + )) + + public var first: GraphQLNullable + public var last: GraphQLNullable + public var before: GraphQLNullable + public var after: GraphQLNullable + public var showBalanceChanges: GraphQLNullable + public var showEffects: GraphQLNullable + public var showEvents: GraphQLNullable + public var showInput: GraphQLNullable + public var showObjectChanges: GraphQLNullable + public var showRawInput: GraphQLNullable + public var filter: GraphQLNullable + + public init( + first: GraphQLNullable, + last: GraphQLNullable, + before: GraphQLNullable, + after: GraphQLNullable, + showBalanceChanges: GraphQLNullable = false, + showEffects: GraphQLNullable = false, + showEvents: GraphQLNullable = false, + showInput: GraphQLNullable = false, + showObjectChanges: GraphQLNullable = false, + showRawInput: GraphQLNullable = false, + filter: GraphQLNullable + ) { + self.first = first + self.last = last + self.before = before + self.after = after + self.showBalanceChanges = showBalanceChanges + self.showEffects = showEffects + self.showEvents = showEvents + self.showInput = showInput + self.showObjectChanges = showObjectChanges + self.showRawInput = showRawInput + self.filter = filter + } + + public var __variables: Variables? { [ + "first": first, + "last": last, + "before": before, + "after": after, + "showBalanceChanges": showBalanceChanges, + "showEffects": showEffects, + "showEvents": showEvents, + "showInput": showInput, + "showObjectChanges": showObjectChanges, + "showRawInput": showRawInput, + "filter": filter + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("transactionBlockConnection", TransactionBlockConnection?.self, arguments: [ + "first": .variable("first"), + "after": .variable("after"), + "last": .variable("last"), + "before": .variable("before"), + "filter": .variable("filter") + ]), + ] } + + public var transactionBlockConnection: TransactionBlockConnection? { __data["transactionBlockConnection"] } + + /// TransactionBlockConnection + /// + /// Parent Type: `TransactionBlockConnection` + public struct TransactionBlockConnection: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlockConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// TransactionBlockConnection.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("hasPreviousPage", Bool.self), + .field("startCursor", String?.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating backwards, are there more items? + public var hasPreviousPage: Bool { __data["hasPreviousPage"] } + /// When paginating backwards, the cursor to continue. + public var startCursor: String? { __data["startCursor"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// TransactionBlockConnection.Node + /// + /// Parent Type: `TransactionBlock` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.TransactionBlock } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_TRANSACTION_FIELDS.self), + ] } + + /// A 32-byte hash that uniquely identifies the transaction block contents, encoded in Base58. + /// This serves as a unique id for the block on chain. + public var digest: String { __data["digest"] } + /// Serialized form of this transaction's `SenderSignedData`, BCS serialized and Base64Apollo encoded. + public var rawTransaction: SuiKit.Base64Apollo? { __data["rawTransaction"] } + /// The address corresponding to the public key that signed this transaction. System + /// transactions do not have senders. + public var sender: RPC_TRANSACTION_FIELDS.Sender? { __data["sender"] } + /// A list of all signatures, Base64Apollo-encoded, from senders, and potentially the gas owner if + /// this is a sponsored transaction. + public var signatures: [SuiKit.Base64Apollo]? { __data["signatures"] } + /// Events emitted by this transaction block. + public var events: RPC_TRANSACTION_FIELDS.Events? { __data["events"] } + /// The effects field captures the results to the chain of executing this transaction. + public var effects: RPC_TRANSACTION_FIELDS.Effects? { __data["effects"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_TRANSACTION_FIELDS: RPC_TRANSACTION_FIELDS { _toFragment() } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/ResolveNameServiceAddressQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/ResolveNameServiceAddressQuery.graphql.swift new file mode 100644 index 0000000..886f5ed --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/ResolveNameServiceAddressQuery.graphql.swift @@ -0,0 +1,49 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class ResolveNameServiceAddressQuery: GraphQLQuery { + public static let operationName: String = "resolveNameServiceAddress" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query resolveNameServiceAddress($name: String!) { resolveNameServiceAddress(name: $name) { __typename address } }"# + )) + + public var name: String + + public init(name: String) { + self.name = name + } + + public var __variables: Variables? { ["name": name] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("resolveNameServiceAddress", ResolveNameServiceAddress?.self, arguments: ["name": .variable("name")]), + ] } + + /// Resolves the owner address of the provided domain name + public var resolveNameServiceAddress: ResolveNameServiceAddress? { __data["resolveNameServiceAddress"] } + + /// ResolveNameServiceAddress + /// + /// Parent Type: `Address` + public struct ResolveNameServiceAddress: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("address", SuiKit.SuiAddressApollo.self), + ] } + + public var address: SuiKit.SuiAddressApollo { __data["address"] } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/ResolveNameServiceNamesQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/ResolveNameServiceNamesQuery.graphql.swift new file mode 100644 index 0000000..8f1caba --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/ResolveNameServiceNamesQuery.graphql.swift @@ -0,0 +1,122 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class ResolveNameServiceNamesQuery: GraphQLQuery { + public static let operationName: String = "resolveNameServiceNames" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query resolveNameServiceNames($address: SuiAddress!, $limit: Int, $cursor: String) { address(address: $address) { __typename suinsRegistrations(first: $limit, after: $cursor) { __typename pageInfo { __typename hasNextPage endCursor } nodes { __typename domain } } } }"# + )) + + public var address: SuiAddressApollo + public var limit: GraphQLNullable + public var cursor: GraphQLNullable + + public init( + address: SuiAddressApollo, + limit: GraphQLNullable, + cursor: GraphQLNullable + ) { + self.address = address + self.limit = limit + self.cursor = cursor + } + + public var __variables: Variables? { [ + "address": address, + "limit": limit, + "cursor": cursor + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("address", Address?.self, arguments: ["address": .variable("address")]), + ] } + + public var address: Address? { __data["address"] } + + /// Address + /// + /// Parent Type: `Address` + public struct Address: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Address } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("suinsRegistrations", SuinsRegistrations?.self, arguments: [ + "first": .variable("limit"), + "after": .variable("cursor") + ]), + ] } + + /// The SuinsRegistration NFTs owned by the given object. These grant the owner + /// the capability to manage the associated domain. + public var suinsRegistrations: SuinsRegistrations? { __data["suinsRegistrations"] } + + /// Address.SuinsRegistrations + /// + /// Parent Type: `SuinsRegistrationConnection` + public struct SuinsRegistrations: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.SuinsRegistrationConnection } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("pageInfo", PageInfo.self), + .field("nodes", [Node].self), + ] } + + /// Information to aid in pagination. + public var pageInfo: PageInfo { __data["pageInfo"] } + /// A list of nodes. + public var nodes: [Node] { __data["nodes"] } + + /// Address.SuinsRegistrations.PageInfo + /// + /// Parent Type: `PageInfo` + public struct PageInfo: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.PageInfo } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("hasNextPage", Bool.self), + .field("endCursor", String?.self), + ] } + + /// When paginating forwards, are there more items? + public var hasNextPage: Bool { __data["hasNextPage"] } + /// When paginating forwards, the cursor to continue. + public var endCursor: String? { __data["endCursor"] } + } + + /// Address.SuinsRegistrations.Node + /// + /// Parent Type: `SuinsRegistration` + public struct Node: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.SuinsRegistration } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .field("domain", String.self), + ] } + + /// Domain name of the SuinsRegistration object + public var domain: String { __data["domain"] } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/TryGetPastObjectQuery.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/TryGetPastObjectQuery.graphql.swift new file mode 100644 index 0000000..1bba07f --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Operations/Queries/TryGetPastObjectQuery.graphql.swift @@ -0,0 +1,290 @@ +// @generated +// This file was automatically generated and should not be edited. + +@_exported import ApolloAPI + +public class TryGetPastObjectQuery: GraphQLQuery { + public static let operationName: String = "tryGetPastObject" + public static let operationDocument: ApolloAPI.OperationDocument = .init( + definition: .init( + #"query tryGetPastObject($id: SuiAddress!, $version: Int, $showBcs: Boolean = false, $showOwner: Boolean = false, $showPreviousTransaction: Boolean = false, $showContent: Boolean = false, $showDisplay: Boolean = false, $showType: Boolean = false, $showStorageRebate: Boolean = false) { object(address: $id, version: $version) { __typename ...RPC_OBJECT_FIELDS } }"#, + fragments: [RPC_OBJECT_FIELDS.self] + )) + + public var id: SuiAddressApollo + public var version: GraphQLNullable + public var showBcs: GraphQLNullable + public var showOwner: GraphQLNullable + public var showPreviousTransaction: GraphQLNullable + public var showContent: GraphQLNullable + public var showDisplay: GraphQLNullable + public var showType: GraphQLNullable + public var showStorageRebate: GraphQLNullable + + public init( + id: SuiAddressApollo, + version: GraphQLNullable, + showBcs: GraphQLNullable = false, + showOwner: GraphQLNullable = false, + showPreviousTransaction: GraphQLNullable = false, + showContent: GraphQLNullable = false, + showDisplay: GraphQLNullable = false, + showType: GraphQLNullable = false, + showStorageRebate: GraphQLNullable = false + ) { + self.id = id + self.version = version + self.showBcs = showBcs + self.showOwner = showOwner + self.showPreviousTransaction = showPreviousTransaction + self.showContent = showContent + self.showDisplay = showDisplay + self.showType = showType + self.showStorageRebate = showStorageRebate + } + + public var __variables: Variables? { [ + "id": id, + "version": version, + "showBcs": showBcs, + "showOwner": showOwner, + "showPreviousTransaction": showPreviousTransaction, + "showContent": showContent, + "showDisplay": showDisplay, + "showType": showType, + "showStorageRebate": showStorageRebate + ] } + + public struct Data: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Query } + public static var __selections: [ApolloAPI.Selection] { [ + .field("object", Object?.self, arguments: [ + "address": .variable("id"), + "version": .variable("version") + ]), + ] } + + public var object: Object? { __data["object"] } + + /// Object + /// + /// Parent Type: `Object` + public struct Object: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.Object } + public static var __selections: [ApolloAPI.Selection] { [ + .field("__typename", String.self), + .fragment(RPC_OBJECT_FIELDS.self), + ] } + + /// The address of the object, named as such to avoid conflict with the address type. + public var objectId: SuiKit.SuiAddressApollo { __data["objectId"] } + /// The Base64Apollo encoded bcs serialization of the object's content. + public var bcs: SuiKit.Base64Apollo? { __data["bcs"] } + public var version: Int { __data["version"] } + /// Attempts to convert the object into a MoveObject + public var asMoveObject: AsMoveObject? { __data["asMoveObject"] } + /// The Address or Object that owns this Object. Immutable and Shared Objects do not have + /// owners. + public var owner: AnyHashable? { __data["owner"] } + /// The transaction block that created this version of the object. + public var previousTransactionBlock: RPC_OBJECT_FIELDS.PreviousTransactionBlock? { __data["previousTransactionBlock"] } + /// The amount of SUI we would rebate if this object gets deleted or mutated. + /// This number is recalculated based on the present storage gas price. + public var storageRebate: SuiKit.BigIntApollo? { __data["storageRebate"] } + /// 32-byte hash that identifies the object's current contents, encoded as a Base58 string. + public var digest: String { __data["digest"] } + /// The set of named templates defined on-chain for the type of this object, + /// to be handled off-chain. The server substitutes data from the object + /// into these templates to generate a display string per template. + public var display: [RPC_OBJECT_FIELDS.Display]? { __data["display"] } + + public struct Fragments: FragmentContainer { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public var rPC_OBJECT_FIELDS: RPC_OBJECT_FIELDS { _toFragment() } + } + + /// Object.AsMoveObject + /// + /// Parent Type: `MoveObject` + public struct AsMoveObject: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + + public var ifShowType: IfShowType? { _asInlineFragment() } + public var ifShowContent: IfShowContent? { _asInlineFragment() } + public var ifShowBcs: IfShowBcs? { _asInlineFragment() } + + /// Object.AsMoveObject.IfShowType + /// + /// Parent Type: `MoveObject` + public struct IfShowType: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = TryGetPastObjectQuery.Data.Object.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Object.AsMoveObject.IfShowType.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// Object.AsMoveObject.IfShowType.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// Object.AsMoveObject.IfShowContent + /// + /// Parent Type: `MoveObject` + public struct IfShowContent: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = TryGetPastObjectQuery.Data.Object.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Object.AsMoveObject.IfShowContent.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: AnyHashable { __data["data"] } + public var bcs: AnyHashable { __data["bcs"] } + + /// Object.AsMoveObject.IfShowContent.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: AnyHashable { __data["layout"] } + /// Structured representation of the type signature. + public var signature: AnyHashable { __data["signature"] } + } + } + } + + /// Object.AsMoveObject.IfShowBcs + /// + /// Parent Type: `MoveObject` + public struct IfShowBcs: SuiKit.InlineFragment, ApolloAPI.CompositeInlineFragment { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public typealias RootEntityType = TryGetPastObjectQuery.Data.Object.AsMoveObject + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveObject } + public static var __mergedSources: [any ApolloAPI.SelectionSet.Type] { [ + RPC_OBJECT_FIELDS.AsMoveObject.self + ] } + + /// Determines whether a transaction can transfer this object, using the TransferObjects + /// transaction command or `sui::transfer::public_transfer`, both of which require the object to + /// have the `key` and `store` abilities. + public var hasPublicTransfer: Bool { __data["hasPublicTransfer"] } + /// Displays the contents of the MoveObject in a JSONApollo string and through graphql types. Also + /// provides the flat representation of the type signature, and the bcs of the corresponding + /// data + public var contents: Contents? { __data["contents"] } + + /// Object.AsMoveObject.IfShowBcs.Contents + /// + /// Parent Type: `MoveValue` + public struct Contents: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveValue } + + public var type: Type_SelectionSet { __data["type"] } + /// Structured contents of a Move value. + public var data: SuiKit.MoveDataApollo { __data["data"] } + public var bcs: SuiKit.Base64Apollo { __data["bcs"] } + + /// Object.AsMoveObject.IfShowBcs.Contents.Type_SelectionSet + /// + /// Parent Type: `MoveType` + public struct Type_SelectionSet: SuiKit.SelectionSet { + public let __data: DataDict + public init(_dataDict: DataDict) { __data = _dataDict } + + public static var __parentType: ApolloAPI.ParentType { SuiKit.Objects.MoveType } + + /// Flat representation of the type signature, as a displayable string. + public var repr: String { __data["repr"] } + /// Structured representation of the "shape" of values that match this type. + public var layout: SuiKit.MoveTypeLayoutApollo { __data["layout"] } + /// Structured representation of the type signature. + public var signature: SuiKit.MoveTypeSignatureApollo { __data["signature"] } + } + } + } + } + } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/Base64.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/Base64.swift new file mode 100644 index 0000000..4874d9c --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/Base64.swift @@ -0,0 +1,10 @@ +// @generated +// This file was automatically generated and can be edited to +// implement advanced custom scalar functionality. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +public typealias Base64Apollo = String diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/BigInt.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/BigInt.swift new file mode 100644 index 0000000..280fde3 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/BigInt.swift @@ -0,0 +1,10 @@ +// @generated +// This file was automatically generated and can be edited to +// implement advanced custom scalar functionality. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +public typealias BigIntApollo = String diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/DateTime.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/DateTime.swift new file mode 100644 index 0000000..9711ec5 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/DateTime.swift @@ -0,0 +1,10 @@ +// @generated +// This file was automatically generated and can be edited to +// implement advanced custom scalar functionality. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +public typealias DateTimeApollo = String diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/JSON.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/JSON.swift new file mode 100644 index 0000000..f6e457c --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/JSON.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and can be edited to +// implement advanced custom scalar functionality. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +/// Arbitrary JSONApollo data. +public typealias JSONApollo = String diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/MoveData.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/MoveData.swift new file mode 100644 index 0000000..bad77bf --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/MoveData.swift @@ -0,0 +1,21 @@ +// @generated +// This file was automatically generated and can be edited to +// implement advanced custom scalar functionality. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +/// The contents of a Move Value, corresponding to the following recursive type: +/// +/// type MoveDataApollo = +/// { Address: SuiAddressApolloApollo } +/// | { UID: SuiAddressApolloApollo } +/// | { Bool: bool } +/// | { Number: BigIntApollo } +/// | { String: string } +/// | { Vector: [MoveDataApollo] } +/// | { Option: MoveDataApollo? } +/// | { Struct: [{ name: string, value: MoveDataApollo }] } +public typealias MoveDataApollo = String diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/MoveTypeLayout.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/MoveTypeLayout.swift new file mode 100644 index 0000000..879967f --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/MoveTypeLayout.swift @@ -0,0 +1,18 @@ +// @generated +// This file was automatically generated and can be edited to +// implement advanced custom scalar functionality. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +/// The shape of a concrete Move Type (a type with all its type parameters instantiated with concrete types), corresponding to the following recursive type: +/// +/// type MoveTypeLayoutApollo = +/// "address" +/// | "bool" +/// | "u8" | "u16" | ... | "u256" +/// | { vector: MoveTypeLayoutApollo } +/// | { struct: [{ name: string, layout: MoveTypeLayoutApollo }] } +public typealias MoveTypeLayoutApollo = String diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/MoveTypeSignature.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/MoveTypeSignature.swift new file mode 100644 index 0000000..6397607 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/MoveTypeSignature.swift @@ -0,0 +1,25 @@ +// @generated +// This file was automatically generated and can be edited to +// implement advanced custom scalar functionality. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +/// The signature of a concrete Move Type (a type with all its type parameters instantiated with concrete types, that contains no references), corresponding to the following recursive type: +/// +/// type MoveTypeSignatureApollo = +/// "address" +/// | "bool" +/// | "u8" | "u16" | ... | "u256" +/// | { vector: MoveTypeSignatureApollo } +/// | { +/// struct: { +/// package: string, +/// module: string, +/// type: string, +/// typeParameters: [MoveTypeSignatureApollo], +/// } +/// } +public typealias MoveTypeSignatureApollo = String diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/OpenMoveTypeSignature.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/OpenMoveTypeSignature.swift new file mode 100644 index 0000000..6aa7ea8 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/OpenMoveTypeSignature.swift @@ -0,0 +1,31 @@ +// @generated +// This file was automatically generated and can be edited to +// implement advanced custom scalar functionality. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +/// The shape of an abstract Move Type (a type that can contain free type parameters, and can optionally be taken by reference), corresponding to the following recursive type: +/// +/// type OpenMoveTypeSignatureApollo = { +/// ref: ("&" | "&mut")?, +/// body: OpenMoveTypeSignatureApolloBody, +/// } +/// +/// type OpenMoveTypeSignatureApolloBody = +/// "address" +/// | "bool" +/// | "u8" | "u16" | ... | "u256" +/// | { vector: OpenMoveTypeSignatureApolloBody } +/// | { +/// datatype { +/// package: string, +/// module: string, +/// type: string, +/// typeParameters: [OpenMoveTypeSignatureApolloBody] +/// } +/// } +/// | { typeParameter: number } +public typealias OpenMoveTypeSignatureApollo = String diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/SuiAddress.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/SuiAddress.swift new file mode 100644 index 0000000..3aae59b --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/CustomScalars/SuiAddress.swift @@ -0,0 +1,10 @@ +// @generated +// This file was automatically generated and can be edited to +// implement advanced custom scalar functionality. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +public typealias SuiAddressApollo = String diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/ExecutionStatus.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/ExecutionStatus.graphql.swift new file mode 100644 index 0000000..cdcc15a --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/ExecutionStatus.graphql.swift @@ -0,0 +1,9 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public enum ExecutionStatusApollo: String, EnumType { + case success = "SUCCESS" + case failure = "FAILURE" +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/MoveAbility.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/MoveAbility.graphql.swift new file mode 100644 index 0000000..18d0966 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/MoveAbility.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public enum MoveAbility: String, EnumType { + case copy = "COPY" + case drop = "DROP" + case key = "KEY" + case store = "STORE" +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/MoveVisibility.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/MoveVisibility.graphql.swift new file mode 100644 index 0000000..910b953 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/MoveVisibility.graphql.swift @@ -0,0 +1,10 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public enum MoveVisibility: String, EnumType { + case `public` = "PUBLIC" + case `private` = "PRIVATE" + case friend = "FRIEND" +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/TransactionBlockKindInput.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/TransactionBlockKindInput.graphql.swift new file mode 100644 index 0000000..b52230b --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Enums/TransactionBlockKindInput.graphql.swift @@ -0,0 +1,9 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public enum TransactionBlockKindInput: String, EnumType { + case systemTx = "SYSTEM_TX" + case programmableTx = "PROGRAMMABLE_TX" +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/CheckpointId.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/CheckpointId.graphql.swift new file mode 100644 index 0000000..8406b1c --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/CheckpointId.graphql.swift @@ -0,0 +1,40 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +/// Filter either by the digest, or the sequence number, or neither, to get the latest checkpoint. +public struct CheckpointId: InputObject { + public private(set) var __data: InputDict + + public init(_ data: InputDict) { + __data = data + } + + public init( + digest: GraphQLNullable = nil, + sequenceNumber: GraphQLNullable = nil + ) { + __data = InputDict([ + "digest": digest, + "sequenceNumber": sequenceNumber + ]) + } + + public init(digest: String? = nil, sequenceNumber: Int? = nil) { + __data = InputDict([ + "digest": digest != nil ? GraphQLNullable.some(digest) : GraphQLNullable.none, + "sequenceNumber": sequenceNumber != nil ? GraphQLNullable.some(sequenceNumber) : GraphQLNullable.none + ]) + } + + public var digest: GraphQLNullable { + get { __data["digest"] } + set { __data["digest"] = newValue } + } + + public var sequenceNumber: GraphQLNullable { + get { __data["sequenceNumber"] } + set { __data["sequenceNumber"] = newValue } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/DynamicFieldName.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/DynamicFieldName.graphql.swift new file mode 100644 index 0000000..fa98ce5 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/DynamicFieldName.graphql.swift @@ -0,0 +1,35 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public struct DynamicFieldNameApollo: InputObject { + public private(set) var __data: InputDict + + public init(_ data: InputDict) { + __data = data + } + + public init( + type: String, + bcs: Base64Apollo + ) { + __data = InputDict([ + "type": type, + "bcs": bcs + ]) + } + + /// The string type of the DynamicField's 'name' field. + /// A string representation of a Move primitive like 'u64', or a struct type like '0x2::kiosk::Listing' + public var type: String { + get { __data["type"] } + set { __data["type"] = newValue } + } + + /// The Base64Apollo encoded bcs serialization of the DynamicField's 'name' field. + public var bcs: Base64Apollo { + get { __data["bcs"] } + set { __data["bcs"] = newValue } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/EventFilter.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/EventFilter.graphql.swift new file mode 100644 index 0000000..3ffebfe --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/EventFilter.graphql.swift @@ -0,0 +1,76 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public struct EventFilter: InputObject { + public private(set) var __data: InputDict + + public init(_ data: InputDict) { + __data = data + } + + public init( + sender: GraphQLNullable = nil, + transactionDigest: GraphQLNullable = nil, + emittingModule: GraphQLNullable = nil, + eventType: GraphQLNullable = nil + ) { + __data = InputDict([ + "sender": sender, + "transactionDigest": transactionDigest, + "emittingModule": emittingModule, + "eventType": eventType + ]) + } + + public init( + suiEventFilter: SuiEventFilter + ) throws { + switch suiEventFilter { + case .sender(let sender): + __data = InputDict(["sender": sender]) + case .transaction(let transaction): + __data = InputDict(["transactionDigest": transaction]) + case .moveModule(let moveModuleFilter): + __data = InputDict(["eventModule": "\(moveModuleFilter.package)::\(moveModuleFilter.module)"]) + case .moveEventType(let moveEventType): + __data = InputDict(["eventType": moveEventType]) + default: + throw SuiError.notImplemented + } + } + + public var sender: GraphQLNullable { + get { __data["sender"] } + set { __data["sender"] = newValue } + } + + public var transactionDigest: GraphQLNullable { + get { __data["transactionDigest"] } + set { __data["transactionDigest"] = newValue } + } + + /// Events emitted by a particular module. An event is emitted by a + /// particular module if some function in the module is called by a + /// PTB and emits an event. + /// + /// Modules can be filtered by their package, or package::module. + public var emittingModule: GraphQLNullable { + get { __data["emittingModule"] } + set { __data["emittingModule"] = newValue } + } + + /// This field is used to specify the type of event emitted. + /// + /// Events can be filtered by their type's package, package::module, + /// or their fully qualified type name. + /// + /// Generic types can be queried by either the generic type name, e.g. + /// `0x2::coin::Coin`, or by the full type name, such as + /// `0x2::coin::Coin<0x2::sui::SUI>`. + public var eventType: GraphQLNullable { + get { __data["eventType"] } + set { __data["eventType"] = newValue } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/ObjectFilter.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/ObjectFilter.graphql.swift new file mode 100644 index 0000000..3f2a856 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/ObjectFilter.graphql.swift @@ -0,0 +1,79 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public struct ObjectFilter: InputObject { + public private(set) var __data: InputDict + + public init(_ data: InputDict) { + __data = data + } + + public init( + type: GraphQLNullable = nil, + owner: GraphQLNullable = nil, + objectIds: GraphQLNullable<[SuiAddressApollo]> = nil, + objectKeys: GraphQLNullable<[ObjectKey]> = nil + ) { + __data = InputDict([ + "type": type, + "owner": owner, + "objectIds": objectIds, + "objectKeys": objectKeys + ]) + } + + public init(filter: SuiObjectDataFilter) throws { + __data = InputDict([:]) + switch filter { + case .structType(let structType): + __data["type"] = structType + case .addressOwner(let addressOwner): + __data["owner"] = addressOwner + case .objectOwner(let objectOwner): + __data["owner"] = objectOwner + case .objectId(let objectId): + __data["objectIds"] = [objectId] + case .objectIds(let objectIds): + __data["objectIds"] = objectIds + default: + throw SuiError.notImplemented + } + } + + public init() { + __data = InputDict([:]) + } + + /// This field is used to specify the type of objects that should be included in the query + /// results. + /// + /// Objects can be filtered by their type's package, package::module, or their fully qualified + /// type name. + /// + /// Generic types can be queried by either the generic type name, e.g. `0x2::coin::Coin`, or by + /// the full type name, such as `0x2::coin::Coin<0x2::sui::SUI>`. + public var type: GraphQLNullable { + get { __data["type"] } + set { __data["type"] = newValue } + } + + /// Filter for live objects by their current owners. + public var owner: GraphQLNullable { + get { __data["owner"] } + set { __data["owner"] = newValue } + } + + /// Filter for live objects by their IDs. + public var objectIds: GraphQLNullable<[SuiAddressApollo]> { + get { __data["objectIds"] } + set { __data["objectIds"] = newValue } + } + + /// Filter for live or potentially historical objects by their ID and version. + public var objectKeys: GraphQLNullable<[ObjectKey]> { + get { __data["objectKeys"] } + set { __data["objectKeys"] = newValue } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/ObjectKey.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/ObjectKey.graphql.swift new file mode 100644 index 0000000..14ec312 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/ObjectKey.graphql.swift @@ -0,0 +1,32 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public struct ObjectKey: InputObject { + public private(set) var __data: InputDict + + public init(_ data: InputDict) { + __data = data + } + + public init( + objectId: SuiAddressApollo, + version: Int + ) { + __data = InputDict([ + "objectId": objectId, + "version": version + ]) + } + + public var objectId: SuiAddressApollo { + get { __data["objectId"] } + set { __data["objectId"] = newValue } + } + + public var version: Int { + get { __data["version"] } + set { __data["version"] = newValue } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/TransactionBlockFilter.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/TransactionBlockFilter.graphql.swift new file mode 100644 index 0000000..08a418b --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/InputObjects/TransactionBlockFilter.graphql.swift @@ -0,0 +1,116 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public struct TransactionBlockFilter: InputObject { + public private(set) var __data: InputDict + + public init(_ data: InputDict) { + __data = data + } + + public init( + package: GraphQLNullable = nil, + module: GraphQLNullable = nil, + function: GraphQLNullable = nil, + kind: GraphQLNullable> = nil, + afterCheckpoint: GraphQLNullable = nil, + atCheckpoint: GraphQLNullable = nil, + beforeCheckpoint: GraphQLNullable = nil, + signAddress: GraphQLNullable = nil, + sentAddress: GraphQLNullable = nil, + recvAddress: GraphQLNullable = nil, + paidAddress: GraphQLNullable = nil, + inputObject: GraphQLNullable = nil, + changedObject: GraphQLNullable = nil, + transactionIds: GraphQLNullable<[String]> = nil + ) { + __data = InputDict([ + "package": package, + "module": module, + "function": function, + "kind": kind, + "afterCheckpoint": afterCheckpoint, + "atCheckpoint": atCheckpoint, + "beforeCheckpoint": beforeCheckpoint, + "signAddress": signAddress, + "sentAddress": sentAddress, + "recvAddress": recvAddress, + "paidAddress": paidAddress, + "inputObject": inputObject, + "changedObject": changedObject, + "transactionIds": transactionIds + ]) + } + + public var package: GraphQLNullable { + get { __data["package"] } + set { __data["package"] = newValue } + } + + public var module: GraphQLNullable { + get { __data["module"] } + set { __data["module"] = newValue } + } + + public var function: GraphQLNullable { + get { __data["function"] } + set { __data["function"] = newValue } + } + + public var kind: GraphQLNullable> { + get { __data["kind"] } + set { __data["kind"] = newValue } + } + + public var afterCheckpoint: GraphQLNullable { + get { __data["afterCheckpoint"] } + set { __data["afterCheckpoint"] = newValue } + } + + public var atCheckpoint: GraphQLNullable { + get { __data["atCheckpoint"] } + set { __data["atCheckpoint"] = newValue } + } + + public var beforeCheckpoint: GraphQLNullable { + get { __data["beforeCheckpoint"] } + set { __data["beforeCheckpoint"] = newValue } + } + + public var signAddress: GraphQLNullable { + get { __data["signAddress"] } + set { __data["signAddress"] = newValue } + } + + public var sentAddress: GraphQLNullable { + get { __data["sentAddress"] } + set { __data["sentAddress"] = newValue } + } + + public var recvAddress: GraphQLNullable { + get { __data["recvAddress"] } + set { __data["recvAddress"] = newValue } + } + + public var paidAddress: GraphQLNullable { + get { __data["paidAddress"] } + set { __data["paidAddress"] = newValue } + } + + public var inputObject: GraphQLNullable { + get { __data["inputObject"] } + set { __data["inputObject"] = newValue } + } + + public var changedObject: GraphQLNullable { + get { __data["changedObject"] } + set { __data["changedObject"] = newValue } + } + + public var transactionIds: GraphQLNullable<[String]> { + get { __data["transactionIds"] } + set { __data["transactionIds"] = newValue } + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Interfaces/ObjectOwner.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Interfaces/ObjectOwner.graphql.swift new file mode 100644 index 0000000..4d049b7 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Interfaces/ObjectOwner.graphql.swift @@ -0,0 +1,8 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Interfaces { + static let ObjectOwner = Interface(name: "ObjectOwner") +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Address.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Address.graphql.swift new file mode 100644 index 0000000..33aff2d --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Address.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Address = ApolloAPI.Object( + typename: "Address", + implementedInterfaces: [Interfaces.ObjectOwner.self] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Balance.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Balance.graphql.swift new file mode 100644 index 0000000..f3786a7 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Balance.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Balance = ApolloAPI.Object( + typename: "Balance", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/BalanceChange.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/BalanceChange.graphql.swift new file mode 100644 index 0000000..00bb010 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/BalanceChange.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Effects to the balance (sum of coin values per coin type) owned by an address or object. + static let BalanceChange = ApolloAPI.Object( + typename: "BalanceChange", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/BalanceConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/BalanceConnection.graphql.swift new file mode 100644 index 0000000..206d16e --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/BalanceConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let BalanceConnection = ApolloAPI.Object( + typename: "BalanceConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Checkpoint.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Checkpoint.graphql.swift new file mode 100644 index 0000000..f333bbf --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Checkpoint.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Checkpoint = ApolloAPI.Object( + typename: "Checkpoint", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/CheckpointConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/CheckpointConnection.graphql.swift new file mode 100644 index 0000000..c35e46d --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/CheckpointConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let CheckpointConnection = ApolloAPI.Object( + typename: "CheckpointConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Coin.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Coin.graphql.swift new file mode 100644 index 0000000..5371c22 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Coin.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Coin = ApolloAPI.Object( + typename: "Coin", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/CoinConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/CoinConnection.graphql.swift new file mode 100644 index 0000000..1eab267 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/CoinConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let CoinConnection = ApolloAPI.Object( + typename: "CoinConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/CoinMetadata.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/CoinMetadata.graphql.swift new file mode 100644 index 0000000..e4ae090 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/CoinMetadata.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let CoinMetadata = ApolloAPI.Object( + typename: "CoinMetadata", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/DisplayEntry.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/DisplayEntry.graphql.swift new file mode 100644 index 0000000..e5f8674 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/DisplayEntry.graphql.swift @@ -0,0 +1,14 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// The set of named templates defined on-chain for the type of this object, + /// to be handled off-chain. The server substitutes data from the object + /// into these templates to generate a display string per template. + static let DisplayEntry = ApolloAPI.Object( + typename: "DisplayEntry", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/DynamicField.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/DynamicField.graphql.swift new file mode 100644 index 0000000..7ea42a8 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/DynamicField.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let DynamicField = ApolloAPI.Object( + typename: "DynamicField", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/DynamicFieldConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/DynamicFieldConnection.graphql.swift new file mode 100644 index 0000000..81769d4 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/DynamicFieldConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let DynamicFieldConnection = ApolloAPI.Object( + typename: "DynamicFieldConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Epoch.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Epoch.graphql.swift new file mode 100644 index 0000000..b703d20 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Epoch.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Epoch = ApolloAPI.Object( + typename: "Epoch", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Event.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Event.graphql.swift new file mode 100644 index 0000000..736b51d --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Event.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Event = ApolloAPI.Object( + typename: "Event", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/EventConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/EventConnection.graphql.swift new file mode 100644 index 0000000..7998dc2 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/EventConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let EventConnection = ApolloAPI.Object( + typename: "EventConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/GasCostSummary.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/GasCostSummary.graphql.swift new file mode 100644 index 0000000..b11ed23 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/GasCostSummary.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let GasCostSummary = ApolloAPI.Object( + typename: "GasCostSummary", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/GasEffects.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/GasEffects.graphql.swift new file mode 100644 index 0000000..24abdbe --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/GasEffects.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let GasEffects = ApolloAPI.Object( + typename: "GasEffects", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveField.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveField.graphql.swift new file mode 100644 index 0000000..4140f15 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveField.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let MoveField = ApolloAPI.Object( + typename: "MoveField", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveFunction.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveFunction.graphql.swift new file mode 100644 index 0000000..2ed3bbe --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveFunction.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Signature of a function, defined in a Move module. + static let MoveFunction = ApolloAPI.Object( + typename: "MoveFunction", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveFunctionConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveFunctionConnection.graphql.swift new file mode 100644 index 0000000..e6e42bf --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveFunctionConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let MoveFunctionConnection = ApolloAPI.Object( + typename: "MoveFunctionConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveFunctionTypeParameter.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveFunctionTypeParameter.graphql.swift new file mode 100644 index 0000000..d1dd6e8 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveFunctionTypeParameter.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let MoveFunctionTypeParameter = ApolloAPI.Object( + typename: "MoveFunctionTypeParameter", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveModule.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveModule.graphql.swift new file mode 100644 index 0000000..d165da2 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveModule.graphql.swift @@ -0,0 +1,13 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Represents a module in Move, a library that defines struct types + /// and functions that operate on these types. + static let MoveModule = ApolloAPI.Object( + typename: "MoveModule", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveModuleConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveModuleConnection.graphql.swift new file mode 100644 index 0000000..e8cc24f --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveModuleConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let MoveModuleConnection = ApolloAPI.Object( + typename: "MoveModuleConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveObject.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveObject.graphql.swift new file mode 100644 index 0000000..9c0375f --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveObject.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let MoveObject = ApolloAPI.Object( + typename: "MoveObject", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MovePackage.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MovePackage.graphql.swift new file mode 100644 index 0000000..981cb3f --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MovePackage.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let MovePackage = ApolloAPI.Object( + typename: "MovePackage", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveStruct.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveStruct.graphql.swift new file mode 100644 index 0000000..5e1c330 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveStruct.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Description of a type, defined in a Move module. + static let MoveStruct = ApolloAPI.Object( + typename: "MoveStruct", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveStructConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveStructConnection.graphql.swift new file mode 100644 index 0000000..3715bdc --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveStructConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let MoveStructConnection = ApolloAPI.Object( + typename: "MoveStructConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveStructTypeParameter.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveStructTypeParameter.graphql.swift new file mode 100644 index 0000000..e78af27 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveStructTypeParameter.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let MoveStructTypeParameter = ApolloAPI.Object( + typename: "MoveStructTypeParameter", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveType.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveType.graphql.swift new file mode 100644 index 0000000..a6d6394 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveType.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Represents concrete types (no type parameters, no references) + static let MoveType = ApolloAPI.Object( + typename: "MoveType", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveValue.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveValue.graphql.swift new file mode 100644 index 0000000..45b85a9 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/MoveValue.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let MoveValue = ApolloAPI.Object( + typename: "MoveValue", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Object.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Object.graphql.swift new file mode 100644 index 0000000..a4bc03d --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Object.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Object = ApolloAPI.Object( + typename: "Object", + implementedInterfaces: [Interfaces.ObjectOwner.self] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ObjectChange.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ObjectChange.graphql.swift new file mode 100644 index 0000000..1805332 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ObjectChange.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Effect on an individual Object (keyed by its ID). + static let ObjectChange = ApolloAPI.Object( + typename: "ObjectChange", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ObjectConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ObjectConnection.graphql.swift new file mode 100644 index 0000000..7ba4ff8 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ObjectConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let ObjectConnection = ApolloAPI.Object( + typename: "ObjectConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/OpenMoveType.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/OpenMoveType.graphql.swift new file mode 100644 index 0000000..e1fe14c --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/OpenMoveType.graphql.swift @@ -0,0 +1,23 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Represents types that could contain references or free type parameters. Such types can appear + /// as function parameters, in fields of structs, or as actual type parameter. + static let OpenMoveType = ApolloAPI.Object( + typename: "OpenMoveType", + implementedInterfaces: [] + ) + + static let Signature = ApolloAPI.Object( + typename: "Signature", + implementedInterfaces: [] + ) + + static let Body = ApolloAPI.Object( + typename: "Body", + implementedInterfaces: [] + ) +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Owner.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Owner.graphql.swift new file mode 100644 index 0000000..0bc713f --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Owner.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Owner = ApolloAPI.Object( + typename: "Owner", + implementedInterfaces: [Interfaces.ObjectOwner.self] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/PageInfo.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/PageInfo.graphql.swift new file mode 100644 index 0000000..6ce3f29 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/PageInfo.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Information about pagination in a connection + static let PageInfo = ApolloAPI.Object( + typename: "PageInfo", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ProtocolConfigAttr.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ProtocolConfigAttr.graphql.swift new file mode 100644 index 0000000..dc98c48 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ProtocolConfigAttr.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// A single protocol configuration value. + static let ProtocolConfigAttr = ApolloAPI.Object( + typename: "ProtocolConfigAttr", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ProtocolConfigFeatureFlag.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ProtocolConfigFeatureFlag.graphql.swift new file mode 100644 index 0000000..ca5a48e --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ProtocolConfigFeatureFlag.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Whether or not a single feature is enabled in the protocol config. + static let ProtocolConfigFeatureFlag = ApolloAPI.Object( + typename: "ProtocolConfigFeatureFlag", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ProtocolConfigs.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ProtocolConfigs.graphql.swift new file mode 100644 index 0000000..f7c8840 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ProtocolConfigs.graphql.swift @@ -0,0 +1,14 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Constants that control how the chain operates. + /// + /// These can only change during protocol upgrades which happen on epoch boundaries. + static let ProtocolConfigs = ApolloAPI.Object( + typename: "ProtocolConfigs", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Query.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Query.graphql.swift new file mode 100644 index 0000000..a4155e4 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Query.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Query = ApolloAPI.Object( + typename: "Query", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SafeMode.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SafeMode.graphql.swift new file mode 100644 index 0000000..6982e2e --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SafeMode.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Information about whether epoch changes are using safe mode. + static let SafeMode = ApolloAPI.Object( + typename: "SafeMode", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StakeSubsidy.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StakeSubsidy.graphql.swift new file mode 100644 index 0000000..3539558 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StakeSubsidy.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Parameters related to subsiding staking rewards + static let StakeSubsidy = ApolloAPI.Object( + typename: "StakeSubsidy", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StakedSui.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StakedSui.graphql.swift new file mode 100644 index 0000000..90b1b39 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StakedSui.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let StakedSui = ApolloAPI.Object( + typename: "StakedSui", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StakedSuiConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StakedSuiConnection.graphql.swift new file mode 100644 index 0000000..fa349a0 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StakedSuiConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let StakedSuiConnection = ApolloAPI.Object( + typename: "StakedSuiConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StorageFund.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StorageFund.graphql.swift new file mode 100644 index 0000000..2118693 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/StorageFund.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// SUI set aside to account for objects stored on-chain. + static let StorageFund = ApolloAPI.Object( + typename: "StorageFund", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SuinsRegistration.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SuinsRegistration.graphql.swift new file mode 100644 index 0000000..af42c5b --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SuinsRegistration.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let SuinsRegistration = ApolloAPI.Object( + typename: "SuinsRegistration", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SuinsRegistrationConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SuinsRegistrationConnection.graphql.swift new file mode 100644 index 0000000..973622f --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SuinsRegistrationConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let SuinsRegistrationConnection = ApolloAPI.Object( + typename: "SuinsRegistrationConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SystemParameters.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SystemParameters.graphql.swift new file mode 100644 index 0000000..9a2da6c --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/SystemParameters.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Details of the system that are decided during genesis. + static let SystemParameters = ApolloAPI.Object( + typename: "SystemParameters", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/TransactionBlock.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/TransactionBlock.graphql.swift new file mode 100644 index 0000000..975ffe9 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/TransactionBlock.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let TransactionBlock = ApolloAPI.Object( + typename: "TransactionBlock", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/TransactionBlockConnection.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/TransactionBlockConnection.graphql.swift new file mode 100644 index 0000000..1cf3ca2 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/TransactionBlockConnection.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let TransactionBlockConnection = ApolloAPI.Object( + typename: "TransactionBlockConnection", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/TransactionBlockEffects.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/TransactionBlockEffects.graphql.swift new file mode 100644 index 0000000..dcf5a62 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/TransactionBlockEffects.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let TransactionBlockEffects = ApolloAPI.Object( + typename: "TransactionBlockEffects", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Validator.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Validator.graphql.swift new file mode 100644 index 0000000..af67f49 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/Validator.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let Validator = ApolloAPI.Object( + typename: "Validator", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ValidatorCredentials.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ValidatorCredentials.graphql.swift new file mode 100644 index 0000000..d7d89de --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ValidatorCredentials.graphql.swift @@ -0,0 +1,11 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + static let ValidatorCredentials = ApolloAPI.Object( + typename: "ValidatorCredentials", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ValidatorSet.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ValidatorSet.graphql.swift new file mode 100644 index 0000000..303cacc --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Objects/ValidatorSet.graphql.swift @@ -0,0 +1,12 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Objects { + /// Representation of `0x3::validator_set::ValidatorSet`. + static let ValidatorSet = ApolloAPI.Object( + typename: "ValidatorSet", + implementedInterfaces: [] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/SchemaConfiguration.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/SchemaConfiguration.swift new file mode 100644 index 0000000..f50ff61 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/SchemaConfiguration.swift @@ -0,0 +1,15 @@ +// @generated +// This file was automatically generated and can be edited to +// provide custom configuration for a generated GraphQL schema. +// +// Any changes to this file will not be overwritten by future +// code generation execution. + +import ApolloAPI + +public enum SchemaConfiguration: ApolloAPI.SchemaConfiguration { + public static func cacheKeyInfo(for type: ApolloAPI.Object, object: ObjectData) -> CacheKeyInfo? { + // Implement this function to configure cache key resolution for your schema types. + return nil + } +} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/SchemaMetadata.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/SchemaMetadata.graphql.swift new file mode 100644 index 0000000..f5b5469 --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/SchemaMetadata.graphql.swift @@ -0,0 +1,86 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public typealias ID = String + +public protocol SelectionSet: ApolloAPI.SelectionSet & ApolloAPI.RootSelectionSet +where Schema == SuiKit.SchemaMetadata {} + +public protocol InlineFragment: ApolloAPI.SelectionSet & ApolloAPI.InlineFragment +where Schema == SuiKit.SchemaMetadata {} + +public protocol MutableSelectionSet: ApolloAPI.MutableRootSelectionSet +where Schema == SuiKit.SchemaMetadata {} + +public protocol MutableInlineFragment: ApolloAPI.MutableSelectionSet & ApolloAPI.InlineFragment +where Schema == SuiKit.SchemaMetadata {} + +public enum SchemaMetadata: ApolloAPI.SchemaMetadata { + public static let configuration: ApolloAPI.SchemaConfiguration.Type = SchemaConfiguration.self + + public static func objectType(forTypename typename: String) -> ApolloAPI.Object? { + switch typename { + case "Query": return SuiKit.Objects.Query + case "TransactionBlockConnection": return SuiKit.Objects.TransactionBlockConnection + case "PageInfo": return SuiKit.Objects.PageInfo + case "TransactionBlock": return SuiKit.Objects.TransactionBlock + case "Address": return SuiKit.Objects.Address + case "Object": return SuiKit.Objects.Object + case "Owner": return SuiKit.Objects.Owner + case "EventConnection": return SuiKit.Objects.EventConnection + case "Event": return SuiKit.Objects.Event + case "MoveModule": return SuiKit.Objects.MoveModule + case "MovePackage": return SuiKit.Objects.MovePackage + case "MoveType": return SuiKit.Objects.MoveType + case "TransactionBlockEffects": return SuiKit.Objects.TransactionBlockEffects + case "Checkpoint": return SuiKit.Objects.Checkpoint + case "BalanceChange": return SuiKit.Objects.BalanceChange + case "GasEffects": return SuiKit.Objects.GasEffects + case "GasCostSummary": return SuiKit.Objects.GasCostSummary + case "Epoch": return SuiKit.Objects.Epoch + case "ObjectChange": return SuiKit.Objects.ObjectChange + case "MoveObject": return SuiKit.Objects.MoveObject + case "MoveValue": return SuiKit.Objects.MoveValue + case "CoinConnection": return SuiKit.Objects.CoinConnection + case "Coin": return SuiKit.Objects.Coin + case "ValidatorSet": return SuiKit.Objects.ValidatorSet + case "Validator": return SuiKit.Objects.Validator + case "ValidatorCredentials": return SuiKit.Objects.ValidatorCredentials + case "CheckpointConnection": return SuiKit.Objects.CheckpointConnection + case "SuinsRegistrationConnection": return SuiKit.Objects.SuinsRegistrationConnection + case "SuinsRegistration": return SuiKit.Objects.SuinsRegistration + case "MoveStruct": return SuiKit.Objects.MoveStruct + case "MoveField": return SuiKit.Objects.MoveField + case "OpenMoveType": return SuiKit.Objects.OpenMoveType + case "MoveStructTypeParameter": return SuiKit.Objects.MoveStructTypeParameter + case "DynamicFieldConnection": return SuiKit.Objects.DynamicFieldConnection + case "DynamicField": return SuiKit.Objects.DynamicField + case "DisplayEntry": return SuiKit.Objects.DisplayEntry + case "MoveFunction": return SuiKit.Objects.MoveFunction + case "MoveFunctionTypeParameter": return SuiKit.Objects.MoveFunctionTypeParameter + case "CoinMetadata": return SuiKit.Objects.CoinMetadata + case "ObjectConnection": return SuiKit.Objects.ObjectConnection + case "MoveModuleConnection": return SuiKit.Objects.MoveModuleConnection + case "MoveStructConnection": return SuiKit.Objects.MoveStructConnection + case "MoveFunctionConnection": return SuiKit.Objects.MoveFunctionConnection + case "ProtocolConfigs": return SuiKit.Objects.ProtocolConfigs + case "ProtocolConfigAttr": return SuiKit.Objects.ProtocolConfigAttr + case "ProtocolConfigFeatureFlag": return SuiKit.Objects.ProtocolConfigFeatureFlag + case "SafeMode": return SuiKit.Objects.SafeMode + case "StakeSubsidy": return SuiKit.Objects.StakeSubsidy + case "StorageFund": return SuiKit.Objects.StorageFund + case "SystemParameters": return SuiKit.Objects.SystemParameters + case "Balance": return SuiKit.Objects.Balance + case "BalanceConnection": return SuiKit.Objects.BalanceConnection + case "StakedSuiConnection": return SuiKit.Objects.StakedSuiConnection + case "StakedSui": return SuiKit.Objects.StakedSui + default: return nil + } + } +} + +public enum Objects {} +public enum Interfaces {} +public enum Unions {} diff --git a/Sources/SuiKit/Types/Structs/GraphQL/Schema/Unions/DynamicFieldValue.graphql.swift b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Unions/DynamicFieldValue.graphql.swift new file mode 100644 index 0000000..a1f4e8b --- /dev/null +++ b/Sources/SuiKit/Types/Structs/GraphQL/Schema/Unions/DynamicFieldValue.graphql.swift @@ -0,0 +1,14 @@ +// @generated +// This file was automatically generated and should not be edited. + +import ApolloAPI + +public extension Unions { + static let DynamicFieldValue = Union( + name: "DynamicFieldValue", + possibleTypes: [ + Objects.MoveObject.self, + Objects.MoveValue.self + ] + ) +} \ No newline at end of file diff --git a/Sources/SuiKit/Types/Structs/Kiosk/KioskUtilities.swift b/Sources/SuiKit/Types/Structs/Kiosk/KioskUtilities.swift index 50244f3..13e0274 100644 --- a/Sources/SuiKit/Types/Structs/Kiosk/KioskUtilities.swift +++ b/Sources/SuiKit/Types/Structs/Kiosk/KioskUtilities.swift @@ -248,7 +248,7 @@ public struct KioskUtilities { limit: limit ) data.append(contentsOf: result.data) - hasNextPage = result.hasNextPage + hasNextPage = result.hasNextPage! cursor = result.nextCursor } diff --git a/Sources/SuiKit/Types/Structs/Kiosk/Query/KioskQuery.swift b/Sources/SuiKit/Types/Structs/Kiosk/Query/KioskQuery.swift index fbca43c..5edf7da 100644 --- a/Sources/SuiKit/Types/Structs/Kiosk/Query/KioskQuery.swift +++ b/Sources/SuiKit/Types/Structs/Kiosk/Query/KioskQuery.swift @@ -167,7 +167,7 @@ public struct KioskQuery { kioskOwnerCaps: ownerCaps, kioskIds: kioskIdList, nextCursor: fetchedOwnedKioskCaps.nextCursor, - hasNextPage: fetchedOwnedKioskCaps.hasNextPage + hasNextPage: fetchedOwnedKioskCaps.hasNextPage! ) } diff --git a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveAbilitySet.swift b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveAbilitySet.swift index dc7716c..2178bc9 100644 --- a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveAbilitySet.swift +++ b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveAbilitySet.swift @@ -27,19 +27,23 @@ import Foundation import SwiftyJSON /// Represents the set of abilities of a SuiMove in the ecosystem. -public struct SuiMoveAbilitySet { +public struct SuiMoveAbilitySet: Equatable { /// Holds the abilities of the SuiMove. public let abilities: [String] /// Initializes a new instance of `SuiMoveAbilitySet` with the provided abilities. /// - Parameter abilities: An array of abilities in string format. public init(abilities: [String]) { - self.abilities = abilities + self.abilities = abilities.map { $0.capitalized } } /// Initializes a new instance of `SuiMoveAbilitySet` with the abilities extracted from the given JSON. /// - Parameter input: A `JSON` object containing the abilities. public init(input: JSON) { - self.abilities = input["abilities"].arrayValue.map { $0.stringValue } + self.abilities = input["abilities"].arrayValue.map { $0.stringValue.capitalized } + } + + public init(graphql: RPC_MOVE_FUNCTION_FIELDS.TypeParameter) { + self.abilities = graphql.constraints.map { $0.value!.rawValue.capitalized } } } diff --git a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveModuleId.swift b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveModuleId.swift index 338b1dc..0846930 100644 --- a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveModuleId.swift +++ b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveModuleId.swift @@ -26,7 +26,7 @@ import Foundation /// Represents the unique identifier for a SuiMove module. -public struct SuiMoveModuleId { +public struct SuiMoveModuleId: Equatable { /// Holds the address of the SuiMove module, serving as a part of its unique identifier. public let address: String diff --git a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedField.swift b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedField.swift index 4b135d6..f3750e8 100644 --- a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedField.swift +++ b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedField.swift @@ -26,7 +26,7 @@ import Foundation /// Represents a normalized field within a SuiMove structure or contract. -public struct SuiMoveNormalizedField { +public struct SuiMoveNormalizedField: Equatable { /// Holds the name of the field, serving as an identifier within its containing entity. public let name: String diff --git a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedFunction.swift b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedFunction.swift index 761afed..5492f90 100644 --- a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedFunction.swift +++ b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedFunction.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// Represents a normalized function within a SuiMove entity. -public struct SuiMoveNormalizedFunction { +public struct SuiMoveNormalizedFunction: Equatable { /// Defines the visibility of the function (e.g. public, private). public let visibility: SuiMoveVisibility @@ -65,6 +65,25 @@ public struct SuiMoveNormalizedFunction { self.returnValues = returnValues } + public init?(graphql: GetNormalizedMoveFunctionQuery.Data) { + let function = graphql.object!.asMovePackage!.module!.function! + guard let visibility = SuiMoveVisibility.parseGraphQL(function.visibility) else { return nil } + self.visibility = visibility + self.isEntry = function.isEntry ?? false + self.typeParameters = function.typeParameters != nil ? function.typeParameters!.compactMap { SuiMoveAbilitySet(graphql: $0) } : [] + self.parameters = function.parameters != nil ? function.parameters!.compactMap { SuiMoveNormalizedType.parseGraphQL($0.signature) } : [] + self.returnValues = function.return != nil ? function.return!.compactMap { SuiMoveNormalizedType.parseGraphQL($0.signature) } : [] + } + + public init?(function: RPC_MOVE_MODULE_FIELDS.Functions.Node) { + guard let visibility = SuiMoveVisibility.parseGraphQL(function.visibility) else { return nil } + self.visibility = visibility + self.isEntry = function.isEntry ?? false + self.typeParameters = function.typeParameters != nil ? function.typeParameters!.compactMap { SuiMoveAbilitySet(graphql: $0) } : [] + self.parameters = function.parameters != nil ? function.parameters!.compactMap { SuiMoveNormalizedType.parseGraphQL($0.signature) } : [] + self.returnValues = function.return != nil ? function.return!.compactMap { SuiMoveNormalizedType.parseGraphQL($0.signature) } : [] + } + /// Initializes a new instance of `SuiMoveNormalizedFunction` from a JSON representation. /// Returns `nil` if there is an issue with the JSON input. /// @@ -75,7 +94,7 @@ public struct SuiMoveNormalizedFunction { self.isEntry = input["isEntry"].boolValue self.typeParameters = input["typeParameters"].arrayValue.map { SuiMoveAbilitySet(input: $0) } self.parameters = input["parameters"].arrayValue.compactMap { SuiMoveNormalizedType.parseJSON($0) } - self.returnValues = input["returnValues"].arrayValue.compactMap { SuiMoveNormalizedType.parseJSON($0) } + self.returnValues = input["return"].arrayValue.compactMap { SuiMoveNormalizedType.parseJSON($0) } } /// Determines if the function has transaction context. diff --git a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedModule.swift b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedModule.swift index 896ba46..371f334 100644 --- a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedModule.swift +++ b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedModule.swift @@ -28,7 +28,7 @@ import SwiftyJSON /// Represents a normalized SuiMove Module, containing various details about the module including its address, /// name, friend modules, structs, and exposed functions. -public struct SuiMoveNormalizedModule { +public struct SuiMoveNormalizedModule: Equatable { /// Specifies the file format version of the module. public let fileFormatVersion: Int @@ -60,7 +60,11 @@ public struct SuiMoveNormalizedModule { } for (exposedKey, exposedValue) in input["exposedFunctions"].dictionaryValue { - exposedFunctions[exposedKey] = SuiMoveNormalizedFunction(input: exposedValue) + if + (exposedValue["visibility"].stringValue == "Friend" || exposedValue["visibility"].stringValue == "Public") || + (exposedValue["isEntry"].boolValue) { + exposedFunctions[exposedKey] = SuiMoveNormalizedFunction(input: exposedValue) + } } self.fileFormatVersion = input["fileFormatVersion"].intValue @@ -75,4 +79,66 @@ public struct SuiMoveNormalizedModule { self.structs = structs self.exposedFunctions = exposedFunctions } + + public init(graphql: GetNormalizedMoveModuleQuery.Data.Object.AsMovePackage.Module, package: String) { + let module = graphql + var structs: [String: SuiMoveNormalizedStruct] = [:] + var exposedFunctions: [String: SuiMoveNormalizedFunction] = [:] + + if let structures = module.structs { + for structure in structures.nodes { + structs[structure.name] = SuiMoveNormalizedStruct( + structure: structure + ) + } + } + + if let functions = module.functions { + for function in functions.filterUsable() { + if let value = SuiMoveNormalizedFunction(function: function) { + exposedFunctions[function.name] = value + } + } + } + + self.fileFormatVersion = module.fileFormatVersion + self.address = package + self.name = module.name + self.friends = module.friends.nodes.map { + SuiMoveModuleId(address: $0.package.asObject.address, name: $0.name) + } + self.structs = structs + self.exposedFunctions = exposedFunctions + } + + public init(graphql: GetNormalizedMoveModulesByPackageQuery.Data.Object.AsMovePackage.Modules.Node, package: String) { + let module = graphql + var structs: [String: SuiMoveNormalizedStruct] = [:] + var exposedFunctions: [String: SuiMoveNormalizedFunction] = [:] + + if let structures = module.structs { + for structure in structures.nodes { + structs[structure.name] = SuiMoveNormalizedStruct( + structure: structure + ) + } + } + + if let functions = module.functions { + for function in functions.filterUsable() { + if let value = SuiMoveNormalizedFunction(function: function) { + exposedFunctions[function.name] = value + } + } + } + + self.fileFormatVersion = module.fileFormatVersion + self.address = package + self.name = module.name + self.friends = module.friends.nodes.map { + SuiMoveModuleId(address: $0.package.asObject.address, name: $0.name) + } + self.structs = structs + self.exposedFunctions = exposedFunctions + } } diff --git a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedStruct.swift b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedStruct.swift index d8942bb..0973863 100644 --- a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedStruct.swift +++ b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedStruct.swift @@ -28,7 +28,7 @@ import SwiftyJSON /// Represents a normalized SuiMove Struct, containing details about the struct including its abilities, /// type parameters, and fields. -public struct SuiMoveNormalizedStruct { +public struct SuiMoveNormalizedStruct: Equatable { /// A `SuiMoveAbilitySet` representing the abilities of the struct. public let abilities: SuiMoveAbilitySet @@ -53,6 +53,54 @@ public struct SuiMoveNormalizedStruct { self.typeParameters = typeParameters self.fields = fields } + + public init(structure: GetNormalizedMoveStructQuery.Data.Object.AsMovePackage.Module.Struct) { + self.abilities = structure.abilities != nil ? + SuiMoveAbilitySet(abilities: structure.abilities!.compactMap { $0.value?.rawValue }) : + SuiMoveAbilitySet(abilities: []) + + self.typeParameters = structure.typeParameters != nil ? + structure.typeParameters!.map { + SuiMoveStructTypeParameter( + constraints: SuiMoveAbilitySet(abilities: $0.constraints.compactMap { $0.value?.rawValue }), + isPhantom: $0.isPhantom + ) + } : + [] + + self.fields = structure.fields != nil ? + structure.fields!.map { + SuiMoveNormalizedField( + name: $0.name, + type: SuiMoveNormalizedType.parseGraphQL($0.type!.signature)! + ) + }: + [] + } + + public init(structure: RPC_MOVE_MODULE_FIELDS.Structs.Node) { + self.abilities = structure.abilities != nil ? + SuiMoveAbilitySet(abilities: structure.abilities!.compactMap { $0.value?.rawValue }) : + SuiMoveAbilitySet(abilities: []) + + self.typeParameters = structure.typeParameters != nil ? + structure.typeParameters!.map { + SuiMoveStructTypeParameter( + constraints: SuiMoveAbilitySet(abilities: $0.constraints.compactMap { $0.value?.rawValue }), + isPhantom: $0.isPhantom + ) + } : + [] + + self.fields = structure.fields != nil ? + structure.fields!.map { + SuiMoveNormalizedField( + name: $0.name, + type: SuiMoveNormalizedType.parseGraphQL($0.type!.signature)! + ) + }: + [] + } /// Initializes a new instance of `SuiMoveNormalizedStruct` from a JSON representation. /// Returns `nil` if there is an issue with the JSON input. diff --git a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedStructType.swift b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedStructType.swift index 8b3f3a7..ccc78ba 100644 --- a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedStructType.swift +++ b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveNormalizedStructType.swift @@ -89,8 +89,29 @@ public struct SuiMoveNormalizedStructType: Equatable, KeyProtocol, CustomStringC } } + public init?(graphQLInput: JSON) { + guard let address = try? AccountAddress.fromHex( + graphQLInput["package"].stringValue + ) else { return nil } + + self.address = address + self.module = graphQLInput["module"].stringValue + self.name = graphQLInput["type"].stringValue + self.typeArguments = graphQLInput["typeParameters"].arrayValue.compactMap { + SuiMoveNormalizedType.parseGraphQLInner(nil, $0) + } + } + public var description: String { - "\(self.address.hex())::\(self.module)::\(self.name)" + "\(self.address.hex())::\(self.module)::\(self.name)" + (self.typeArguments.isEmpty ? "" : "<\(self.typeArguments.map { "\($0), " })>") + } + + public static func ==(lhs: SuiMoveNormalizedStructType, rhs: SuiMoveNormalizedStructType) -> Bool { + return + lhs.address == rhs.address && + lhs.module == rhs.module && + lhs.name == rhs.name && + lhs.typeArguments == rhs.typeArguments } /// Compares the current struct with another to determine if they are of the same struct. diff --git a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveStructTypeParameter.swift b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveStructTypeParameter.swift index c3f351e..ee19798 100644 --- a/Sources/SuiKit/Types/Structs/Normalized/SuiMoveStructTypeParameter.swift +++ b/Sources/SuiKit/Types/Structs/Normalized/SuiMoveStructTypeParameter.swift @@ -26,7 +26,7 @@ import Foundation /// Represents a type parameter in a SuiMove structure, along with its constraints and whether it's a phantom type parameter. -public struct SuiMoveStructTypeParameter { +public struct SuiMoveStructTypeParameter: Equatable { /// A `SuiMoveAbilitySet` representing the constraints on the type parameter in the SuiMove structure. public let constraints: SuiMoveAbilitySet diff --git a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MoveObject.swift b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MoveObject.swift index ff6cf02..c43fd92 100644 --- a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MoveObject.swift +++ b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MoveObject.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// Represents a Move Object in Move programming language, detailing its fields, type, and whether it has public transfer enabled. -public struct MoveObject { +public struct MoveObject: Equatable { /// An optional `MoveStruct` representing the fields of the Move object. /// It is `nil` if the Move object does not have any fields. public var fields: JSON? @@ -37,4 +37,10 @@ public struct MoveObject { /// A `String` representing the type of the Move object. public var type: String + + public init(fields: JSON? = nil, hasPublicTransfer: Bool, type: String) { + self.fields = fields + self.hasPublicTransfer = hasPublicTransfer + self.type = type + } } diff --git a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MoveObjectRaw.swift b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MoveObjectRaw.swift index 2fa8362..3bca7a8 100644 --- a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MoveObjectRaw.swift +++ b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MoveObjectRaw.swift @@ -26,7 +26,7 @@ import Foundation /// Represents a raw Move Object in the Move programming language, containing its BCS (Binary Canonical Serialization) representation, type, version, and whether it has public transfer enabled. -public struct MoveObjectRaw { +public struct MoveObjectRaw: Equatable { /// A `String` representing the BCS (Binary Canonical Serialization) bytes of the Move object. /// BCS is a binary format used for encoding structured data. public var bcsBytes: String @@ -39,4 +39,11 @@ public struct MoveObjectRaw { /// A `String` representing the version of the Move object. public var version: String + + public init(bcsBytes: String, hasPublicTransfer: Bool, type: String, version: String) { + self.bcsBytes = bcsBytes + self.hasPublicTransfer = hasPublicTransfer + self.type = type + self.version = version + } } diff --git a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MovePackage.swift b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MovePackage.swift index 5750003..93fa178 100644 --- a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MovePackage.swift +++ b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/MovePackage.swift @@ -28,7 +28,7 @@ import SwiftyJSON /// Represents a Move Package in the Move programming language. /// A Move Package is a container for Move Modules, where each module contains Move Scripts and Move Structs. -public struct MovePackage { +public struct MovePackage: Equatable { /// A dictionary where the key is a `String` representing the name of a module, script, or struct, /// and the value is a `String` representing the disassembled bytecode of that entity. public var disassembled: [String: String] diff --git a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/PackageRaw.swift b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/PackageRaw.swift index 06c1a3b..5e9399f 100644 --- a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/PackageRaw.swift +++ b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/PackageRaw.swift @@ -26,7 +26,7 @@ import Foundation /// Represents the raw data structure for a Package in the Move programming language. -public struct PackageRaw { +public struct PackageRaw: Equatable { /// A `String` representing the unique identifier of the package. public var id: String diff --git a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/TypeOrigin.swift b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/TypeOrigin.swift index c7d8e62..da6c5b5 100644 --- a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/TypeOrigin.swift +++ b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/TypeOrigin.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// Represents the origin of a type in terms of module, package, and struct names. -public struct TypeOrigin { +public struct TypeOrigin: Equatable { /// A `String` representing the name of the module where the type is defined. public var moduleName: String diff --git a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/UpgradeInfo.swift b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/UpgradeInfo.swift index 8ddb56f..553b223 100644 --- a/Sources/SuiKit/Types/Structs/Objects/MoveObjects/UpgradeInfo.swift +++ b/Sources/SuiKit/Types/Structs/Objects/MoveObjects/UpgradeInfo.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// Represents information related to an upgrade. -public struct UpgradeInfo { +public struct UpgradeInfo: Equatable { /// A `String` representing the ID of the upgraded element. public var upgradedId: String diff --git a/Sources/SuiKit/Types/Structs/Provider/GraphQLSuiProvider.swift b/Sources/SuiKit/Types/Structs/Provider/GraphQLSuiProvider.swift new file mode 100644 index 0000000..be366de --- /dev/null +++ b/Sources/SuiKit/Types/Structs/Provider/GraphQLSuiProvider.swift @@ -0,0 +1,892 @@ +// +// GraphQLSuiProvider.swift +// SuiKit +// +// Copyright (c) 2023 OpenDive +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation +import SwiftyJSON +import AnyCodable +import Blake2 +import Web3Core +import Apollo +import ApolloAPI +import BigInt + +public struct GraphQLSuiProvider { + private var apollo: ApolloClient + + public init(connection: any ConnectionProtocol) { + self.apollo = ApolloClient(url: URL(string: connection.graphql!)!) + } + + // TODO: Implement function when write becomes available + /// Runs the transaction in dev-inspect mode. Which allows for nearly any transaction (or Move call) with any arguments. Detailed results are provided, including both the transaction effects and any return values. + /// - Parameters: + /// - transactionBlock: BCS encoded TransactionKind(as opposed to TransactionData, which include gasBudget and gasPrice). + /// - sender: The account that sends the transaction. + /// - gasPrice: Gas is not charged, but gas usage is still calculated. Default to use reference gas price. + /// - epoch: The epoch to perform the call. Will be set from the system state object if not provided. + /// - Returns: The results of the inspection, encapsulated in a `DevInspectResults` object, if successful. + /// - Throws: Throws an error if inspection fails, or if any error occurs during the process. + public func devInspectTransactionBlock( + transactionBlock: inout TransactionBlock, + sender: Account, + gasPrice: Int? = nil, + epoch: String? = nil + ) async throws -> DevInspectResults? { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Return transaction execution effects including the gas cost summary, while the effects are not committed to the chain. + /// - Parameter transactionBlock: The bytes representing the transaction block to be dry run. + /// - Returns: A `SuiTransactionBlockResponse` representing the outcome of the dry run. + /// - Throws: Throws an error if the dry run fails or if any error occurs during the process. + public func dryRunTransactionBlock( + transactionBlock: [UInt8] + ) async throws -> SuiTransactionBlockResponse { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Function to sign and execute a transaction block, making the transactions within + /// the block occur on the blockchain. + /// - Parameters: + /// - transactionBlock: The transaction block to be signed and executed. + /// - signer: The account that signs the transaction block. + /// - options: Additional options for the response of the executed transaction block. + /// - requestType: The type of the Sui request being made. + /// - Returns: A `SuiTransactionBlockResponse` representing the outcome of the executed transaction block. + /// - Throws: Throws an error if signing or executing the transaction block fails, or if any error occurs during the process. + public func signAndExecuteTransactionBlock( + transactionBlock: inout TransactionBlock, + signer: Account, + options: SuiTransactionBlockResponseOptions? = nil, + requestType: SuiRequestType? = nil + ) async throws -> SuiTransactionBlockResponse { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Execute the transaction and wait for results if desired. Request types: 1. WaitForEffectsCert: waits for TransactionEffectsCert and then return to client. + /// + /// This mode is a proxy for transaction finality. 2. WaitForLocalExecution: waits for TransactionEffectsCert and make sure the node executed the transaction + /// locally before returning the client. The local execution makes sure this node is aware of this transaction when client fires subsequent queries. + /// However if the node fails to execute the transaction locally in a timely manner, a bool type in the response is set to false to indicated the case. + /// request_type is default to be `WaitForEffectsCert` unless options.show_events or options.show_effects is true. + /// - Parameters: + /// - transactionBlock: BCS serialized transaction data bytes without its type tag, as base-64 encoded string. + /// - signature: A list of signatures (`flag || signature || pubkey` bytes, as base-64 encoded string). Signature is committed to the intent message of the transaction data, as base-64 encoded string. + /// - options: options for specifying the content to be returned + /// - requestType: The request type, derived from `SuiTransactionBlockResponseOptions` if None + /// - Returns: A `SuiTransactionBlockResponse` representing the outcome of the executed transaction block. + /// - Throws: Throws an error if executing the transaction block fails or if any error occurs during the process. + public func executeTransactionBlock( + transactionBlock: String, + signature: String, + options: SuiTransactionBlockResponseOptions? = nil, + requestType: SuiRequestType? = nil + ) async throws -> SuiTransactionBlockResponse { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Execute the transaction and wait for results if desired. Request types: 1. WaitForEffectsCert: waits for TransactionEffectsCert and then return to client. + /// + /// This mode is a proxy for transaction finality. 2. WaitForLocalExecution: waits for TransactionEffectsCert and make sure the node executed the transaction + /// locally before returning the client. The local execution makes sure this node is aware of this transaction when client fires subsequent queries. + /// However if the node fails to execute the transaction locally in a timely manner, a bool type in the response is set to false to indicated the case. + /// request_type is default to be `WaitForEffectsCert` unless options.show_events or options.show_effects is true. + /// - Parameters: + /// - transactionBlock: BCS serialized transaction data bytes without its type tag, as base-64 encoded string. + /// - signature: A list of signatures (`flag || signature || pubkey` bytes, as base-64 encoded string). Signature is committed to the intent message of the transaction data, as base-64 encoded string. + /// - options: options for specifying the content to be returned + /// - requestType: The request type, derived from `SuiTransactionBlockResponseOptions` if None + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `SuiTransactionBlockResponse` containing the results of the executed transaction block. + public func executeTransactionBlock( + transactionBlock: [UInt8], + signature: String, + options: SuiTransactionBlockResponseOptions? = nil, + requestType: SuiRequestType? = nil + ) async throws -> SuiTransactionBlockResponse { + throw SuiError.notImplemented + } + + /// Return the first four bytes of the chain's genesis checkpoint digest. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `String` representing the chain identifier. + public func getChainIdentifier() async throws -> String { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetChainIdentifierQuery() + ) + return result.data!.chainIdentifier + } + + /// Return a checkpoint. + /// - Parameter digest: Checkpoint digest + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `Checkpoint` object representing the retrieved checkpoint. + public func getCheckpoint(digest: String) async throws -> Checkpoint { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetCheckpointQuery( + id: .init( + CheckpointId(digest: digest) + ) + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return Checkpoint(graphql: data) + } + + /// Return a checkpoint. + /// - Parameter id: Checkpoint sequence number + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `Checkpoint` object representing the retrieved checkpoint. + public func getCheckpoint(sequenceNumber: Int) async throws -> Checkpoint { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetCheckpointQuery( + id: .init( + CheckpointId(sequenceNumber: sequenceNumber) + ) + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return Checkpoint(graphql: data) + } + + /// Return paginated list of checkpoints. + /// - Parameters: + /// - cursor: An optional paging cursor. If provided, the query will start from the next item after the specified cursor. Default to start from the first item if not specified. + /// - limit: Maximum item returned per page, default to [QUERY_MAX_RESULT_LIMIT_CHECKPOINTS] if not specified. + /// - order: A `SortOrder` enum value indicating the order of the results, defaulting to descending, defaults to ascending order, oldest record first. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `CheckpointPage` object containing a list of retrieved checkpoints and pagination information. + public func getCheckpoints( + cursor: String? = nil, + limit: Int? = nil, + order: SortOrder = .descending + ) async throws -> CheckpointPage { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: order == .descending ? + GetCheckpointsQuery( + first: .none, + before: (cursor != nil ? .init(stringLiteral: cursor!) : .none), + last: (limit != nil ? .init(integerLiteral: limit!) : .none), + after: .none + ) : + GetCheckpointsQuery( + first: (limit != nil ? .init(integerLiteral: limit!) : .none), + before: .none, + last: .none, + after: (cursor != nil ? .init(stringLiteral: cursor!) : .none) + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return CheckpointPage( + data: data.checkpoints.nodes.map { Checkpoint(graphql: $0) }, + pageInfo: PageInfo(graphql: data.checkpoints.pageInfo) + ) + } + + // TODO: Implement endpoint function + /// Return transaction events. + /// - Parameter transactionDigest: The digest of the transaction for which to retrieve events. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `PaginatedSuiMoveEvent` object containing a list of retrieved events and pagination information. + public func getEvents( + transactionDigest: String + ) async throws -> PaginatedSuiMoveEvent { + throw SuiError.notImplemented + } + + /// Return the sequence number of the latest checkpoint that has been executed. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `String` representing the latest checkpoint sequence number. + public func getLatestCheckpointSequenceNumber() async throws -> String { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetLatestCheckpointSequenceNumberQuery() + ) + return "\(result.data!.checkpoint!.sequenceNumber)" + } + + // TODO: Implement function when write becomes available + /// Retrieves the loaded child objects associated with a given digest from the Sui blockchain. + /// - Parameter digest: The digest string of the parent object. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: An array of `TransactionEffectsModifiedAtVersions` representing the loaded child objects. + public func getLoadedChildObjects( + digest: String + ) async throws -> [TransactionEffectsModifiedAtVersions] { + throw SuiError.notImplemented + } + + /// Return the argument types of a Move function, based on normalized Type. + /// - Parameters: + /// - package: The string identifier of the package containing the module and function. + /// - module: The string identifier of the module containing the function. + /// - function: The string identifier of the function whose argument types are to be retrieved. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: An array of `SuiMoveFunctionArgType` representing the argument types of the specified Move function. + public func getMoveFunctionArgTypes( + package: String, + module: String, + function: String + ) async throws -> [SuiMoveFunctionArgType] { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetMoveFunctionArgTypesQuery(packageId: package, module: module, function: function) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return data.object!.asMovePackage!.module!.function!.parameters!.map { + SuiMoveFunctionArgType(graphql: $0) + } + } + + /// Return a structured representation of Move function. + /// - Parameters: + /// - package: The string identifier of the package containing the module and function. + /// - moduleName: The string identifier of the module containing the function. + /// - functionName: The string identifier of the function to be normalized. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `SuiMoveNormalizedFunction` object representing the normalized representation of the specified Move function, or `nil` if not found. + public func getNormalizedMoveFunction( + package: String, + moduleName: String, + functionName: String + ) async throws -> SuiMoveNormalizedFunction? { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetNormalizedMoveFunctionQuery( + packageId: package, + module: moduleName, + function: functionName + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return SuiMoveNormalizedFunction(graphql: data) + } + + /// Return a structured representation of Move module. + /// - Parameters: + /// - package: The string identifier of the package containing the module. + /// - module: The string identifier of the module to be normalized. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `SuiMoveNormalizedModule` object representing the normalized representation of the specified Move module, or `nil` if not found. + public func getNormalizedMoveModule( + package: String, + module: String + ) async throws -> SuiMoveNormalizedModule? { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetNormalizedMoveModuleQuery( + packageId: package, + module: module + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return SuiMoveNormalizedModule(graphql: data.object!.asMovePackage!.module!, package: package) + } + + /// Return structured representations of all modules in the given package. + /// - Parameter package: The string identifier of the package containing the modules. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `SuiMoveNormalizedModules` object representing the normalized representation of the specified Move modules. + public func getNormalizedMoveModulesByPackage( + package: String + ) async throws -> SuiMoveNormalizedModules { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetNormalizedMoveModulesByPackageQuery( + packageId: package + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return data.object!.asMovePackage!.modules?.nodes.reduce(into: [String: SuiMoveNormalizedModule]()) { + $0[$1.name] = SuiMoveNormalizedModule(graphql: $1, package: package) + } ?? [:] + } + + /// Return a structured representation of Move struct. + /// - Parameters: + /// - package: The string identifier of the package containing the module and struct. + /// - module: The string identifier of the module containing the struct. + /// - structure: The string identifier of the struct to be normalized. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `SuiMoveNormalizedStruct` object representing the normalized representation of the specified Move struct, or `nil` if not found. + public func getNormalizedMoveStruct( + package: String, + module: String, + structure: String + ) async throws -> SuiMoveNormalizedStruct? { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetNormalizedMoveStructQuery( + packageId: package, + module: module, + struct: structure + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return SuiMoveNormalizedStruct(structure: data.object!.asMovePackage!.module!.struct!) + } + + /// Return the object information for a specified object. + /// - Parameters: + /// - objectId: The string identifier of the object to be retrieved. + /// - options: The optional `SuiObjectDataOptions` to customize the retrieval. + /// - Throws: A `SuiError` if the address is invalid or if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `SuiObjectResponse` object representing the retrieved Sui object, or `nil` if not found. + public func getObject( + objectId: String, + options: SuiObjectDataOptions? = nil + ) async throws -> SuiObjectResponse? { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetObjectQuery( + id: objectId, + showBcs: options?.showBcs ?? false, + showOwner: options?.showOwner ?? false, + showPreviousTransaction: options?.showPreviousTransaction ?? false, + showContent: options?.showContent ?? false, + showType: options?.showType ?? false, + showStorageRebate: options?.showStorageRebate ?? false + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return SuiObjectResponse(error: nil, data: SuiObjectData(graphql: data.object!)) + } + + /// Return the protocol config table for the given version number. If the version number is not specified, If none is specified, the node uses the version of the latest epoch it has processed. + /// - Parameter version: An optional protocol version specifier. If omitted, the latest protocol config table for the node will be returned. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `ProtocolConfig` object representing the protocol configuration. + public func getProtocolConfig( + version: String? = nil + ) async throws -> ProtocolConfig { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetProtocolConfigQuery( + protocolVersion: version != nil ? .init(integerLiteral: Int(version!)!) : .none + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return ProtocolConfig(graphql: data.protocolConfig) + } + + /// Return the total number of transaction blocks known to the server. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `UInt64` representing the total number of transaction blocks. + public func getTotalTransactionBlocks() async throws -> BigInt { + let result = try await GraphQLClient.fetchQuery(client: self.apollo, query: GetTotalTransactionBlocksQuery()) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return BigInt(data.checkpoint!.networkTotalTransactions!) + } + + // TODO: Implement function when write becomes available + /// Return the transaction response object. + /// - Parameters: + /// - digest: A `String` representing the digest of the queried transaction. + /// - options: An optional `SuiTransactionBlockResponseOptions` to customize the retrieval. + /// - Throws: A `SuiError` if the digest is invalid or if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: A `SuiTransactionBlockResponse` object representing the retrieved transaction block. + public func getTransactionBlock( + digest: String, + options: SuiTransactionBlockResponseOptions? = nil + ) async throws -> SuiTransactionBlockResponse { + throw SuiError.notImplemented + } + + /// Return the object data for a list of objects. + /// - Parameters: + /// - ids: An array of `objectId` representing the ids of the objects to be retrieved. + /// - options: An optional `SuiObjectDataOptions` to customize the retrieval. + /// - Throws: A `SuiError` if any address is invalid or if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: An array of `SuiObjectResponse` representing the retrieved Sui objects. + public func getMultiObjects( + ids: [objectId], + options: SuiObjectDataOptions? = nil + ) async throws -> [SuiObjectResponse] { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: MultiGetObjectsQuery( + ids: ids, + limit: .init(integerLiteral: ids.count), + cursor: .none, + showBcs: options?.showBcs ?? false, + showContent: options?.showContent ?? false, + showDisplay: options?.showDisplay ?? false, + showType: options?.showType ?? false, + showOwner: options?.showOwner ?? false, + showPreviousTransaction: options?.showPreviousTransaction ?? false, + showStorageRebate: options?.showStorageRebate ?? false + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return data.objectConnection!.nodes.map { object in + SuiObjectResponse(error: nil, data: SuiObjectData( + graphql: object, + showBcs: options?.showBcs ?? false + )) + } + } + + // TODO: Implement function when write becomes available + /// Returns an ordered list of transaction responses The method will throw an error if the input contains any duplicate or the input size exceeds `QUERY_MAX_RESULT_LIMIT`. + /// - Parameters: + /// - digests: An array of `String` representing the digests of the transaction blocks to be retrieved. + /// - options: An optional `SuiTransactionBlockResponseOptions` to customize the retrieval. + /// - Throws: A `SuiError` if any digest is invalid, if there are duplicate digests, or if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: An array of `SuiTransactionBlockResponse` representing the retrieved transaction blocks. + public func multiGetTransactionBlocks( + digests: [String], + options: SuiTransactionBlockResponseOptions? = nil + ) async throws -> [SuiTransactionBlockResponse] { + throw SuiError.notImplemented + } + + /// Return the object information for a specified version. + /// + /// There is no software-level guarantee/SLA that objects with past versions can be retrieved by this API, even if the object and version exists/existed. The result may vary across nodes depending on their pruning policies. + /// - Parameters: + /// - id: A `String` representing the id of the object to be retrieved. + /// - version: An `Int` representing the version of the object to be retrieved. + /// - options: An optional `SuiObjectDataOptions` to customize the retrieval. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: An `ObjectRead` object representing the retrieved past object, or `nil` if not found. + public func tryGetPastObject( + id: String, + version: Int, + options: SuiObjectDataOptions? = nil + ) async throws -> ObjectRead? { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: TryGetPastObjectQuery( + id: id, + version: .init(integerLiteral: version), + showBcs: options?.showBcs ?? false, + showOwner: options?.showOwner ?? false, + showPreviousTransaction: options?.showPreviousTransaction ?? false, + showContent: options?.showContent ?? false, + showType: options?.showType ?? false, + showStorageRebate: options?.showStorageRebate ?? false + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + // TODO: Implement proper error handling. + return .versionFound(SuiObjectData(graphql: data.object!, showBcs: options?.showBcs ?? false)) + } + + // TODO: Implement function when write becomes available + /// Return the object information for a specified version. + /// + /// There is no software-level guarantee/SLA that objects with past versions can be retrieved by this API, even if the object and version exists/existed. The result may vary across nodes depending on their pruning policies. + /// - Parameters: + /// - objects: An array of `GetPastObjectRequest` representing the requests for the objects to be retrieved. + /// - options: An optional `SuiObjectDataOptions` to customize the retrieval. + /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. + /// - Returns: An array of `ObjectRead` representing the retrieved past objects. + public func tryMultiGetPastObjects( + objects: [GetPastObjectRequest], + options: SuiObjectDataOptions? = nil + ) async throws -> [ObjectRead] { + throw SuiError.notImplemented + } + + /// Return the total coin balance for all coin type, owned by the address owner. + /// - Parameter account: The account whose balances are to be retrieved. + /// - Throws: `SuiError` if there is any error in the JSON RPC call or the response. + /// - Returns: An array of `CoinBalance` representing the balances of different coins in the account. + public func getAllBalances( + account: Account + ) async throws -> [CoinBalance] { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetAllBalancesQuery( + owner: try account.address(), + limit: .none, + cursor: .none + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return try data.address!.balanceConnection!.nodes.map { try CoinBalance(graphql: $0) } + } + + /// Return all Coin objects owned by an address. + /// - Parameters: + /// - account: Any object conforming to `PublicKeyProtocol` whose associated coins are to be retrieved. + /// - cursor: Optional. A cursor for pagination. + /// - limit: Optional. A limit on the number of coins to be retrieved. + /// - Throws: `SuiError` if there is any error in the JSON RPC call or the response. + /// - Returns: A `PaginatedCoins` object containing the retrieved coins and pagination information. + public func getAllCoins( + account: any PublicKeyProtocol, + cursor: String? = nil, + limit: UInt? = nil + ) async throws -> PaginatedCoins { + return try await self.getCoins( + account: try account.toSuiAddress(), + cursor: cursor, + limit: limit + ) + } + + /// Return the total coin balance for one coin type, owned by the address owner. + /// - Parameters: + /// - account: Any object conforming to `PublicKeyProtocol` whose balance is to be retrieved. + /// - coinType: Optional. The type of the coin whose balance is to be retrieved. + /// - Throws: `SuiError` if there is any error in the JSON RPC call or the response. + /// - Returns: A `CoinBalance` object representing the balance of the specified coin in the account. + public func getBalance( + account: any PublicKeyProtocol, + coinType: String? = nil + ) async throws -> CoinBalance { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetBalanceQuery( + owner: try account.toSuiAddress(), + type: coinType != nil ? .init(stringLiteral: coinType!) : .none + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return try CoinBalance(graphql: data.address!.balance!) + } + + /// Return metadata (e.g., symbol, decimals) for a coin. + /// - Parameter coinType: type name for the coin (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC) + /// - Throws: `SuiError` if there is any error in the JSON RPC call or the response, or if the coinType is invalid. + /// - Returns: A `SuiCoinMetadata` object representing the metadata of the specified coin. + public func getCoinMetadata( + coinType: String + ) async throws -> SuiCoinMetadata { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetCoinMetadataQuery(coinType: coinType) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return SuiCoinMetadata(graphql: data.coinMetadata!) + } + + /// Return all Coin<`coin_type`> objects owned by an address. + /// - Parameters: + /// - account: The account whose coins are to be retrieved. + /// - coinType: Optional type name for the coin (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC), default to 0x2::sui::SUI if not specified. + /// - cursor: Optional. A cursor for pagination. + /// - limit: Optional. A limit on the number of coins to be retrieved. + /// - Throws: `SuiError` if there is any error in the JSON RPC call or the response. + /// - Returns: A `PaginatedCoins` object containing the retrieved coins and pagination information. + public func getCoins( + account: String, + coinType: String? = nil, + cursor: String? = nil, + limit: UInt? = nil + ) async throws -> PaginatedCoins { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetCoinsQuery( + owner: account, + first: limit != nil ? .init(integerLiteral: Int(limit!)) : .null, + cursor: cursor != nil ? .init(stringLiteral: cursor!) : .null, + type: coinType != nil ? .init(stringLiteral: coinType!) : .null + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return PaginatedCoins( + data: try data.address!.coinConnection!.nodes.map { try CoinStruct(graphql: $0) }, + pageInfo: PageInfo(graphql: data.address!.coinConnection!.pageInfo) + ) + } + + // TODO: Implement function when write becomes available + /// Return the committee information for the asked `epoch`. + /// - Parameter epoch: he epoch of interest. If None, default to the latest epoch. + /// - Returns: A `CommitteeInfo` object containing the information of the committee for the specified epoch. + /// - Throws: `SuiError.rpcError` if there are errors in the JSON RPC response. + public func getCommitteeInfo( + epoch: String + ) async throws -> CommitteeInfo { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Return the dynamic field object information for a specified object. + /// - Parameters: + /// - parentId: The ID of the queried parent object. + /// - name: The Name of the dynamic field. + /// - Returns: An optional `SuiObjectResponse` containing the information of the dynamic field object, `nil` if not found. + /// - Throws: `SuiError.rpcError` if there are errors in the JSON RPC response. + public func getDynamicFieldObject( + parentId: String, + name: String + ) async throws -> SuiObjectResponse? { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Return the dynamic field object information for a specified object. + /// - Parameters: + /// - parentId: The ID of the queried parent object. + /// - name: The Name of the dynamic field. + /// - Returns: An optional `SuiObjectResponse` containing the information of the dynamic field object, `nil` if not found. + /// - Throws: `SuiError.rpcError` if there are errors in the JSON RPC response. + public func getDynamicFieldObject( + parentId: String, + name: DynamicFieldName + ) async throws -> SuiObjectResponse? { + throw SuiError.notImplemented + } + + /// Return the list of dynamic field objects owned by an object. + /// - Parameters: + /// - parentId: The ID of the parent object. + /// - filter: An optional filter to apply to the dynamic fields. + /// - options: An optional set of options to apply to the dynamic fields. + /// - limit: Maximum item returned per page, default to [QUERY_MAX_RESULT_LIMIT] if not specified. + /// - cursor: An optional paging cursor. If provided, the query will start from the next item after the specified cursor. Default to start from the first item if not specified. + /// - Returns: A `DynamicFieldPage` containing the paginated dynamic fields. + /// - Throws: `SuiError.unableToValidateAddress` if the parent ID is not a valid Sui address. + /// `SuiError.rpcError` if there are errors in the JSON RPC response. + public func getDynamicFields( + parentId: String, + filter: SuiObjectDataFilter? = nil, + options: SuiObjectDataOptions? = nil, + limit: Int? = nil, + cursor: String? = nil + ) async throws -> DynamicFieldPage { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Return the latest SUI system state object on-chain. + /// - Returns: A `JSON` object containing the information of the latest Sui system state. + /// - Throws: `SuiError.rpcError` if there are errors in the JSON RPC response. + public func info() async throws -> JSON { + throw SuiError.notImplemented + } + + /// Return the list of objects owned by an address. + /// + /// If the address owns more than `QUERY_MAX_RESULT_LIMIT` objects, the pagination is not accurate, because previous page may have been updated when the next page is fetched. + /// Please use suix_queryObjects if this is a concern. + /// - Parameters: + /// - owner: The identifier of the owner. + /// - filter: An optional filter to apply to the owned objects. + /// - options: An optional set of options to apply to the owned objects. + /// - cursor: An optional cursor for paginating through owned objects. + /// - limit: An optional limit to the number of owned objects returned. + /// - Returns: A `PaginatedObjectsResponse` containing the paginated owned objects. + /// - Throws: `SuiError.unableToValidateAddress` if the owner is not a valid Sui address. + /// `SuiError.rpcError` if there are errors in the JSON RPC response. + public func getOwnedObjects( + owner: String, + filter: SuiObjectDataFilter? = nil, + options: SuiObjectDataOptions? = nil, + cursor: String? = nil, + limit: Int? = nil + ) async throws -> PaginatedObjectsResponse { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetOwnedObjectsQuery( + owner: owner, + limit: limit != nil ? .init(integerLiteral: limit!) : .none, + cursor: cursor != nil ? .init(stringLiteral: cursor!) : .none, + showBcs: options?.showBcs ?? false, + showContent: options?.showContent ?? false, + showType: options?.showType ?? false, + showOwner: options?.showOwner ?? false, + showPreviousTransaction: options?.showPreviousTransaction ?? false, + showStorageRebate: options?.showStorageRebate ?? false, + filter: filter != nil ? .init(ObjectFilter(filter: filter!)) : .none + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return PaginatedObjectsResponse( + data: data.address!.objectConnection!.nodes.map { + SuiObjectResponse( + error: nil, + data: SuiObjectData(graphql: $0, showBcs: options?.showBcs ?? false) + ) + }, + pageInfo: PageInfo( + graphql: data.address!.objectConnection!.pageInfo + ) + ) + } + + /// Return the reference gas price for the network. + /// - Returns: A UInt64 representing the reference gas price. + /// - Throws: An error if the RPC request fails. + public func getReferenceGasPrice() async throws -> BigInt { + let result = try await GraphQLClient.fetchQuery(client: self.apollo, query: GetReferenceGasPriceQuery()) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return BigInt(data.epoch!.referenceGasPrice!, radix: 10)! + } + + // TODO: Implement function when write becomes available + /// Retrieves the staking information for a given owner. + /// - Parameter owner: The address of the owner whose staking information is to be retrieved. + /// - Returns: An array of `DelegatedStake` objects representing the staking information. + /// - Throws: An error if the RPC request fails or JSON parsing errors occur. + public func getStakes( + owner: String + ) async throws -> [DelegatedStake] { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Retrieves the staking information for given stake IDs. + /// + /// If a Stake was withdrawn its status will be Unstaked. + /// - Parameter stakes: An array of stake IDs whose staking information is to be retrieved. + /// - Returns: An array of `DelegatedStake` objects representing the staking information. + /// - Throws: An error if the RPC request fails or JSON parsing errors occur. + public func getStakesByIds( + stakes: [String] + ) async throws -> [DelegatedStake] { + throw SuiError.notImplemented + } + + /// Retrieves the total supply of a coin type. + /// - Parameter coinType: The type of the coin whose total supply is to be retrieved. + /// - Returns: A UInt64 representing the total supply of the coin type. + /// - Throws: An error if the RPC request fails. + public func totalSupply(_ coinType: String) async throws -> BigInt { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetTotalSupplyQuery(coinType: coinType) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return BigInt(data.coinMetadata!.supply!, radix: 10)! * BigInt(10).power(data.coinMetadata!.decimals!) + } + + /// Retrieves the annual percentage yield (APY) of validators. + /// - Returns: A `ValidatorApys` object representing the APYs of validators. + /// - Throws: An error if the RPC request fails. + public func getValidatorsApy() async throws -> ValidatorApys { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: GetValidatorsApyQuery() + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return ValidatorApys(graphql: data) + } + + /// Queries events from the blockchain with provided filters. + /// - Parameters: + /// - query: An optional `SuiEventFilter` to filter the events. + /// - cursor: An optional `EventId` to fetch events after a specific event ID. + /// - limit: An optional integer to limit the number of events fetched. + /// - order: An optional `SortOrder` enum to sort the fetched events. + /// - Returns: A `PaginatedSuiMoveEvent` object representing the fetched events. + /// - Throws: An error if the RPC request fails or the event parsing fails. + public func queryEvents( + query: SuiEventFilter? = nil, + cursor: EventId? = nil, + limit: Int? = nil, + order: SortOrder? = nil + ) async throws -> PaginatedSuiMoveEvent { + let result = try await GraphQLClient.fetchQuery( + client: self.apollo, + query: order == .ascending ? + QueryEventsQuery( + filter: query != nil ? EventFilter(suiEventFilter: query!) : EventFilter(), + before: .none, + after: .none, + first: (limit != nil ? .init(integerLiteral: limit!) : .none), + last: .none + ) : + QueryEventsQuery( + filter: query != nil ? EventFilter(suiEventFilter: query!) : EventFilter(), + before: .none, + after: .none, + first: .none, + last: (limit != nil ? .init(integerLiteral: limit!) : .none) + ) + ) + guard let data = result.data else { throw SuiError.missingGraphQLData } + return PaginatedSuiMoveEvent( + data: data.eventConnection!.nodes.map { SuiEvent(graphql: $0) }, + pageInfo: PageInfo(graphql: data.eventConnection!.pageInfo) + ) + } + + /// Queries transaction blocks based on provided parameters. + /// - Parameters: + /// - cursor: An optional string used as a starting point to fetch transaction blocks. + /// - limit: An optional integer representing the maximum number of transaction blocks to fetch. + /// - order: An optional `SortOrder` enum to sort the fetched transaction blocks. + /// - filter: An optional `TransactionFilter` to filter the fetched transaction blocks. + /// - options: An optional `SuiTransactionBlockResponseOptions` to specify response options. + /// - Returns: A `PaginatedTransactionResponse` object containing the transaction blocks that meet the given criteria. + /// - Throws: An error if the RPC request fails or if the parsing of the received data fails. + public func queryTransactionBlocks( + cursor: String? = nil, + limit: Int? = nil, + order: SortOrder? = nil, + filter: TransactionFilter? = nil, + options: SuiTransactionBlockResponseOptions? = nil + ) async throws -> PaginatedTransactionResponse { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Resolves a nameservice address to its corresponding account address. + /// - Parameter name: A string representing the nameservice address to resolve. + /// - Returns: An `AccountAddress` representing the resolved account address. + /// - Throws: An error if the RPC request fails or if the conversion from hexadecimal fails. + public func resolveNameserviceAddress(name: String) async throws -> AccountAddress { + throw SuiError.notImplemented + } + + // TODO: Implement Resolve Name Service Names + /// Waits for a transaction to be processed and retrieves the transaction block. + /// - Parameters: + /// - tx: A string representing the transaction hash. + /// - options: An optional `SuiTransactionBlockResponseOptions` to specify response options. + /// - Returns: A `SuiTransactionBlockResponse` object containing the information of the processed transaction block. + /// - Throws: A `SuiError.transactionTimedOut` error if the transaction does not get processed within a certain time frame, or other errors if the RPC request fails. + public func waitForTransaction( + tx: String, + options: SuiTransactionBlockResponseOptions? = nil + ) async throws -> SuiTransactionBlockResponse { + throw SuiError.notImplemented + } + + // TODO: Implement function when write becomes available + /// Checks if a transaction block is valid by ensuring it has a timestamp. + /// - Parameters: + /// - tx: A string representing the transaction hash. + /// - options: An optional `SuiTransactionBlockResponseOptions` to specify response options. + /// - Returns: A Boolean indicating whether the transaction block is valid. + private func isValidTransactionBlock( + tx: String, + options: SuiTransactionBlockResponseOptions? = nil + ) async -> Bool { + return false + } +} diff --git a/Sources/SuiKit/Types/Structs/Provider/Responses/DisplayFieldsResponse.swift b/Sources/SuiKit/Types/Structs/Provider/Responses/DisplayFieldsResponse.swift index bbbc74c..f90ba9b 100644 --- a/Sources/SuiKit/Types/Structs/Provider/Responses/DisplayFieldsResponse.swift +++ b/Sources/SuiKit/Types/Structs/Provider/Responses/DisplayFieldsResponse.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// A structure representing the response containing display fields. -public struct DisplayFieldsResponse { +public struct DisplayFieldsResponse: Equatable { /// An optional dictionary containing the display data. /// The keys are `String` representing the field names and the values are `String` representing the field values. /// This will be `nil` if there is no display data to represent. @@ -37,6 +37,25 @@ public struct DisplayFieldsResponse { /// This will be `nil` if there is no error to report. public var error: ObjectResponseError? + public init(data: [String : String]? = nil, error: ObjectResponseError? = nil) { + self.data = data + self.error = error + } + + public init(graphql: [RPC_OBJECT_FIELDS.Display]) { + var data: [String: String] = [:] + var error: ObjectResponseError? = nil + for displayItem in graphql { + if displayItem.error != nil { + error = ObjectResponseError.parseJSON(JSON(displayItem.error!)) + } else if displayItem.value != nil { + data[displayItem.key] = displayItem.value! + } + } + self.data = data.isEmpty ? nil : data + self.error = error + } + public static func parseJSON(_ input: JSON) -> DisplayFieldsResponse? { var error: ObjectResponseError? = nil if input["error"].exists() { diff --git a/Sources/SuiKit/Types/Structs/Provider/Responses/DynamicFieldName.swift b/Sources/SuiKit/Types/Structs/Provider/Responses/DynamicFieldName.swift index 9656976..a888ad5 100644 --- a/Sources/SuiKit/Types/Structs/Provider/Responses/DynamicFieldName.swift +++ b/Sources/SuiKit/Types/Structs/Provider/Responses/DynamicFieldName.swift @@ -25,6 +25,7 @@ import Foundation import SwiftyJSON +import ApolloAPI /// A structure representing the name of a dynamic field, conforming to `Codable` protocol. public struct DynamicFieldName: Codable { diff --git a/Sources/SuiKit/Types/Structs/Provider/Responses/Object/SuiObjectData.swift b/Sources/SuiKit/Types/Structs/Provider/Responses/Object/SuiObjectData.swift index 0533a41..09308bb 100644 --- a/Sources/SuiKit/Types/Structs/Provider/Responses/Object/SuiObjectData.swift +++ b/Sources/SuiKit/Types/Structs/Provider/Responses/Object/SuiObjectData.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// A structure representing SuiObjectData, containing various information about an object. -public struct SuiObjectData { +public struct SuiObjectData: Equatable { /// An optional `RawData` representing the Binary Canonical Serialization (BCS) of the object. public let bcs: RawData? @@ -50,7 +50,7 @@ public struct SuiObjectData { public let previousTransaction: String? /// An optional `Int` representing the storage rebate of the object. - public let storageRebate: Int? + public let storageRebate: String? /// An optional `String` representing the type of the object. public let type: String? @@ -58,6 +58,82 @@ public struct SuiObjectData { /// A `String` representing the version of the object. public let version: String + public init(graphql: TryGetPastObjectQuery.Data.Object, showBcs: Bool = false) { + self.bcs = showBcs ? RawData(graphql: graphql.asMoveObject!, version: "\(graphql.version)") : nil + self.content = graphql.asMoveObject!.ifShowContent != nil ? SuiParsedData(graphql: graphql.asMoveObject!) : nil + self.digest = graphql.digest + self.display = graphql.display != nil ? DisplayFieldsResponse(graphql: graphql.display!) : nil + self.objectId = graphql.objectId + self.owner = graphql.owner != nil ? + JSON(graphql.owner!)["owner"]["asObject"]["address"].exists() ? + .objectOwner(JSON(graphql.owner!)["owner"]["asObject"]["address"].stringValue) : + JSON(graphql.owner!)["owner"]["asAddress"]["address"].exists() ? + .addressOwner(JSON(graphql.owner!)["owner"]["asAddress"]["address"].stringValue) : + nil : + nil + self.previousTransaction = graphql.previousTransactionBlock != nil ? graphql.previousTransactionBlock!.digest : nil + self.storageRebate = graphql.storageRebate + self.type = graphql.asMoveObject!.ifShowType != nil ? graphql.asMoveObject!.ifShowType!.contents!.type.repr : nil + self.version = "\(graphql.version)" + } + + public init(graphql: GetObjectQuery.Data.Object, showBcs: Bool = false) { + self.bcs = showBcs ? RawData(graphql: graphql.asMoveObject!, version: "\(graphql.version)") : nil + self.content = graphql.asMoveObject!.ifShowContent != nil ? SuiParsedData(graphql: graphql.asMoveObject!) : nil + self.digest = graphql.digest + self.display = graphql.display != nil ? DisplayFieldsResponse(graphql: graphql.display!) : nil + self.objectId = graphql.objectId + self.owner = graphql.owner != nil ? + JSON(graphql.owner!)["owner"]["asObject"]["address"].exists() ? + .objectOwner(JSON(graphql.owner!)["owner"]["asObject"]["address"].stringValue) : + JSON(graphql.owner!)["owner"]["asAddress"]["address"].exists() ? + .addressOwner(JSON(graphql.owner!)["owner"]["asAddress"]["address"].stringValue) : + nil : + nil + self.previousTransaction = graphql.previousTransactionBlock != nil ? graphql.previousTransactionBlock!.digest : nil + self.storageRebate = graphql.storageRebate + self.type = graphql.asMoveObject!.ifShowType != nil ? graphql.asMoveObject!.ifShowType!.contents!.type.repr : nil + self.version = "\(graphql.version)" + } + + public init(graphql: MultiGetObjectsQuery.Data.ObjectConnection.Node, showBcs: Bool = false) { + self.bcs = showBcs ? RawData(graphql: graphql.asMoveObject!, version: "\(graphql.version)") : nil + self.content = graphql.asMoveObject!.ifShowContent != nil ? SuiParsedData(graphql: graphql.asMoveObject!) : nil + self.digest = graphql.digest + self.display = graphql.display != nil ? DisplayFieldsResponse(graphql: graphql.display!) : nil + self.objectId = graphql.objectId + self.owner = graphql.owner != nil ? + JSON(graphql.owner!)["owner"]["asObject"]["address"].exists() ? + .objectOwner(JSON(graphql.owner!)["owner"]["asObject"]["address"].stringValue) : + JSON(graphql.owner!)["owner"]["asAddress"]["address"].exists() ? + .addressOwner(JSON(graphql.owner!)["owner"]["asAddress"]["address"].stringValue) : + nil : + nil + self.previousTransaction = graphql.previousTransactionBlock != nil ? graphql.previousTransactionBlock!.digest : nil + self.storageRebate = graphql.storageRebate + self.type = graphql.asMoveObject!.ifShowType != nil ? graphql.asMoveObject!.ifShowType!.contents!.type.repr : nil + self.version = "\(graphql.version)" + } + + public init(graphql: GetOwnedObjectsQuery.Data.Address.ObjectConnection.Node, showBcs: Bool = false) { + self.bcs = showBcs ? RawData(graphql: graphql.asMoveObject!, version: "\(graphql.version)") : nil + self.content = graphql.asMoveObject!.ifShowContent != nil ? SuiParsedData(graphql: graphql.asMoveObject!) : nil + self.digest = graphql.digest + self.display = graphql.display != nil ? DisplayFieldsResponse(graphql: graphql.display!) : nil + self.objectId = graphql.objectId + self.owner = graphql.owner != nil ? + JSON(graphql.owner!)["owner"]["asObject"]["address"].exists() ? + .objectOwner(JSON(graphql.owner!)["owner"]["asObject"]["address"].stringValue) : + JSON(graphql.owner!)["owner"]["asAddress"]["address"].exists() ? + .addressOwner(JSON(graphql.owner!)["owner"]["asAddress"]["address"].stringValue) : + nil : + nil + self.previousTransaction = graphql.previousTransactionBlock != nil ? graphql.previousTransactionBlock!.digest : nil + self.storageRebate = graphql.storageRebate + self.type = graphql.asMoveObject!.ifShowType != nil ? graphql.asMoveObject!.ifShowType!.contents!.type.repr : nil + self.version = "\(graphql.version)" + } + public init( bcs: RawData?, content: SuiParsedData?, @@ -77,7 +153,7 @@ public struct SuiObjectData { self.objectId = objectId self.owner = owner self.previousTransaction = previousTransaction - self.storageRebate = storageRebate + self.storageRebate = storageRebate != nil ? "\(storageRebate!)" : nil self.type = type self.version = version } @@ -90,7 +166,7 @@ public struct SuiObjectData { self.objectId = data["objectId"].stringValue self.owner = ObjectOwner.parseJSON(data["owner"]) self.previousTransaction = data["previousTransaction"].stringValue - self.storageRebate = data["storageRebate"].int + self.storageRebate = data["storageRebate"].string self.type = data["type"].string self.version = data["version"].stringValue } diff --git a/Sources/SuiKit/Types/Structs/Provider/Responses/Object/SuiObjectResponse.swift b/Sources/SuiKit/Types/Structs/Provider/Responses/Object/SuiObjectResponse.swift index 1fbcf0b..84865b3 100644 --- a/Sources/SuiKit/Types/Structs/Provider/Responses/Object/SuiObjectResponse.swift +++ b/Sources/SuiKit/Types/Structs/Provider/Responses/Object/SuiObjectResponse.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// A structure representing the response from a request for a SuiObject, containing either the object data or an error. -public struct SuiObjectResponse { +public struct SuiObjectResponse: Equatable { /// An optional `ObjectResponseError` representing any error that occurred during the request for the SuiObject. public var error: ObjectResponseError? diff --git a/Sources/SuiKit/Types/Structs/Provider/Responses/PaginatedObjectsResponse.swift b/Sources/SuiKit/Types/Structs/Provider/Responses/PaginatedObjectsResponse.swift index d834523..25290bd 100644 --- a/Sources/SuiKit/Types/Structs/Provider/Responses/PaginatedObjectsResponse.swift +++ b/Sources/SuiKit/Types/Structs/Provider/Responses/PaginatedObjectsResponse.swift @@ -35,9 +35,19 @@ public struct PaginatedObjectsResponse { /// A Boolean value indicating whether there are more pages of objects available to be retrieved. /// `true` if there are more pages available, otherwise `false`. - public var hasNextPage: Bool + public var hasNextPage: Bool? /// An optional string representing the cursor for the next page of objects. /// `nil` if there are no more pages available. public var nextCursor: String? + + /// Page info object for the given Object Response page. + public var pageInfo: PageInfo? + + public init(data: [SuiObjectResponse], pageInfo: PageInfo? = nil, hasNextPage: Bool? = nil, nextCursor: String? = nil) { + self.data = data + self.hasNextPage = hasNextPage + self.nextCursor = nextCursor + self.pageInfo = pageInfo + } } diff --git a/Sources/SuiKit/Types/Structs/Provider/Responses/SuiCoinMetadata.swift b/Sources/SuiKit/Types/Structs/Provider/Responses/SuiCoinMetadata.swift index d31af0b..153da9f 100644 --- a/Sources/SuiKit/Types/Structs/Provider/Responses/SuiCoinMetadata.swift +++ b/Sources/SuiKit/Types/Structs/Provider/Responses/SuiCoinMetadata.swift @@ -27,7 +27,7 @@ import Foundation /// Represents metadata associated with a SuiCoin, providing details and information /// related to a specific coin in the system. -public struct SuiCoinMetadata { +public struct SuiCoinMetadata: Equatable { /// An `UInt8` value representing the number of decimals to which the coin can be divided. /// This attribute is useful for representing fractional values of the coin. let decimals: UInt8 @@ -51,4 +51,22 @@ public struct SuiCoinMetadata { /// A `String` serving as a unique identifier for the coin, allowing for differentiation and /// reference to this specific coin instance within the system. let id: String + + public init(decimals: UInt8, description: String, iconUrl: String?, name: String, symbol: String, id: String) { + self.decimals = decimals + self.description = description + self.iconUrl = iconUrl + self.name = name + self.symbol = symbol + self.id = id + } + + public init(graphql: GetCoinMetadataQuery.Data.CoinMetadata) { + self.decimals = UInt8(graphql.decimals!) + self.name = graphql.name! + self.symbol = graphql.symbol! + self.description = graphql.description! + self.iconUrl = graphql.iconUrl + self.id = graphql.asMoveObject.asObject.address + } } diff --git a/Sources/SuiKit/Types/Structs/Provider/Responses/ValidatorApy.swift b/Sources/SuiKit/Types/Structs/Provider/Responses/ValidatorApy.swift index 1e0f2f5..ee61962 100644 --- a/Sources/SuiKit/Types/Structs/Provider/Responses/ValidatorApy.swift +++ b/Sources/SuiKit/Types/Structs/Provider/Responses/ValidatorApy.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// Represents the Annual Percentage Yield (APY) related information for a validator. -public struct ValidatorApy { +public struct ValidatorApy: Equatable { /// A `String` representing the address of the validator. This is a unique identifier /// used to reference a specific validator within the network. public var address: String @@ -35,10 +35,15 @@ public struct ValidatorApy { /// A `UInt64` value representing the Annual Percentage Yield (APY) of the validator. /// The APY is a percentage that indicates the profitability of the validator on an annual basis, /// allowing delegators to assess the potential return on their staked assets. - public var apy: UInt64 + public var apy: UInt64? + + public init(address: String, apy: UInt64? = nil) { + self.address = address + self.apy = apy + } public init(input: JSON) { self.address = input["address"].stringValue - self.apy = input["apy"].uInt64Value + self.apy = input["apy"].uInt64 ?? 0 } } diff --git a/Sources/SuiKit/Types/Structs/Provider/Responses/ValidatorApys.swift b/Sources/SuiKit/Types/Structs/Provider/Responses/ValidatorApys.swift index 07d5026..89407fd 100644 --- a/Sources/SuiKit/Types/Structs/Provider/Responses/ValidatorApys.swift +++ b/Sources/SuiKit/Types/Structs/Provider/Responses/ValidatorApys.swift @@ -27,7 +27,7 @@ import Foundation import SwiftyJSON /// Represents a collection of `ValidatorApy` instances associated with a specific epoch. -public struct ValidatorApys { +public struct ValidatorApys: Equatable { /// An array containing `ValidatorApy` instances, each of which represents /// the Annual Percentage Yield (APY) of a specific validator. public var apys: [ValidatorApy] @@ -42,4 +42,14 @@ public struct ValidatorApys { self.apys = input["apys"].arrayValue.map { ValidatorApy(input: $0) } self.epoch = input["epoch"].stringValue } + + public init(graphql: GetValidatorsApyQuery.Data) { + self.apys = graphql.epoch!.validatorSet!.activeValidators!.map { validator in + ValidatorApy( + address: validator.address.address, + apy: validator.apy != nil ? UInt64((validator.apy! / 100)) : nil + ) + } + self.epoch = "\(graphql.epoch!.epochId)" + } } diff --git a/Sources/SuiKit/Types/Structs/Provider/SuiProvider.swift b/Sources/SuiKit/Types/Structs/Provider/SuiProvider.swift index ac34f90..6f20385 100644 --- a/Sources/SuiKit/Types/Structs/Provider/SuiProvider.swift +++ b/Sources/SuiKit/Types/Structs/Provider/SuiProvider.swift @@ -27,6 +27,7 @@ import Foundation import SwiftyJSON import AnyCodable import Blake2 +import BigInt import Web3Core /// The RPC Provider used to interact with the Sui blockchain. @@ -402,7 +403,7 @@ public struct SuiProvider { /// - module: The string identifier of the module to be normalized. /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. /// - Returns: A `SuiMoveNormalizedModule` object representing the normalized representation of the specified Move module, or `nil` if not found. - public func getNormalizedModuleModule( + public func getNormalizedMoveModule( package: String, module: String ) async throws -> SuiMoveNormalizedModule? { @@ -545,12 +546,12 @@ public struct SuiProvider { /// Return the total number of transaction blocks known to the server. /// - Throws: A `SuiError` if an error occurs during the JSON RPC call or if there are errors in the response data. /// - Returns: A `UInt64` representing the total number of transaction blocks. - public func getTotalTransactionBlocks() async throws -> UInt64 { + public func getTotalTransactionBlocks() async throws -> BigInt { let data = try await JsonRpcClient.sendSuiJsonRpc( try self.getServerUrl(), SuiRequest("sui_getTotalTransactionBlocks", []) ) - return JSON(data)["result"].uInt64Value + return BigInt(JSON(data)["result"].stringValue, radix: 10)! } /// Return the transaction response object. @@ -722,7 +723,7 @@ public struct SuiProvider { for (_, value):(String, JSON) in try JSONDecoder().decode(JSON.self, from: data)["result"] { let lockedBalance = value["lockedBalance"] balances.append( - CoinBalance( + try CoinBalance( coinType: value["coinType"].stringValue, coinObjectCount: value["coinObjectCount"].intValue, totalBalance: value["totalBalance"].stringValue, @@ -762,7 +763,7 @@ public struct SuiProvider { let result = try JSONDecoder().decode(JSON.self, from: data)["result"] for (_, value):(String, JSON) in try JSONDecoder().decode(JSON.self, from: data)["result"]["data"] { coinPages.append( - CoinStruct( + try CoinStruct( coinType: value["coinType"].stringValue, coinObjectId: value["coinObjectId"].stringValue, version: value["version"].stringValue, @@ -800,7 +801,7 @@ public struct SuiProvider { guard !(errorValue.hasError) else { throw SuiError.rpcError(error: errorValue) } let value = try JSONDecoder().decode(JSON.self, from: data)["result"] let lockedBalance = value["lockedBalance"] - return CoinBalance( + return try CoinBalance( coinType: value["coinType"].stringValue, coinObjectCount: value["coinObjectCount"].intValue, totalBalance: value["totalBalance"].stringValue, @@ -871,9 +872,9 @@ public struct SuiProvider { guard !(errorValue.hasError) else { throw SuiError.rpcError(error: errorValue) } var coinPages: [CoinStruct] = [] let result = try JSONDecoder().decode(JSON.self, from: data)["result"] - for (_, value): (String, JSON) in result["data"] { + for value in result["data"].arrayValue { coinPages.append( - CoinStruct( + try CoinStruct( coinType: value["coinType"].stringValue, coinObjectId: value["coinObjectId"].stringValue, version: value["version"].stringValue, @@ -1099,12 +1100,12 @@ public struct SuiProvider { /// Return the reference gas price for the network. /// - Returns: A UInt64 representing the reference gas price. /// - Throws: An error if the RPC request fails. - public func getGasPrice() async throws -> UInt64 { + public func getReferenceGasPrice() async throws -> BigInt { let data = try await JsonRpcClient.sendSuiJsonRpc( try self.getServerUrl(), SuiRequest("suix_getReferenceGasPrice", []) ) - return JSON(data)["result"].uInt64Value + return BigInt(JSON(data)["result"].stringValue, radix: 10)! } /// Retrieves the staking information for a given owner. @@ -1217,12 +1218,15 @@ public struct SuiProvider { /// - Parameter coinType: The type of the coin whose total supply is to be retrieved. /// - Returns: A UInt64 representing the total supply of the coin type. /// - Throws: An error if the RPC request fails. - public func totalSupply(_ coinType: String) async throws -> UInt64 { + public func totalSupply(_ coinType: String) async throws -> BigInt { let data = try await JsonRpcClient.sendSuiJsonRpc( try self.getServerUrl(), SuiRequest("suix_getTotalSupply", [AnyCodable(coinType)]) ) - return try JSONDecoder().decode(JSON.self, from: data)["result"]["value"].uInt64Value + let resultString = try JSONDecoder().decode(JSON.self, from: data)["result"]["value"].stringValue + guard let result = BigInt(resultString, radix: 10) else { throw NSError(domain: "Unable to convert to BigInt", code: -1) } + // return (BigInt(data.coinMetadata!.supply!, radix: 10)! * 10).power(data.coinMetadata!.decimals!) + return result } /// Retrieves the annual percentage yield (APY) of validators. @@ -1233,7 +1237,7 @@ public struct SuiProvider { try self.getServerUrl(), SuiRequest("suix_getValidatorsApy", []) ) - let result = JSON(data)["reslt"] + let result = JSON(data)["result"] return ValidatorApys(input: result) } diff --git a/Sources/SuiKit/Types/Structs/RPC/Connections/DevnetConnection.swift b/Sources/SuiKit/Types/Structs/RPC/Connections/DevnetConnection.swift index fb784c9..d407fbb 100644 --- a/Sources/SuiKit/Types/Structs/RPC/Connections/DevnetConnection.swift +++ b/Sources/SuiKit/Types/Structs/RPC/Connections/DevnetConnection.swift @@ -28,6 +28,7 @@ import Foundation public struct DevnetConnection: ConnectionProtocol { public var fullNode: String = "https://fullnode.devnet.sui.io:443/" public var faucet: String? = "https://faucet.devnet.sui.io/gas" + public var graphql: String? = nil public init() { } } diff --git a/Sources/SuiKit/Types/Structs/RPC/Connections/LocalnetConnection.swift b/Sources/SuiKit/Types/Structs/RPC/Connections/LocalnetConnection.swift index 8d1f074..97d14f5 100644 --- a/Sources/SuiKit/Types/Structs/RPC/Connections/LocalnetConnection.swift +++ b/Sources/SuiKit/Types/Structs/RPC/Connections/LocalnetConnection.swift @@ -28,6 +28,7 @@ import Foundation public struct LocalnetConnection: ConnectionProtocol { public var fullNode: String = "http://127.0.0.1:9000/" public var faucet: String? = "http://127.0.0.1:9123/gas" + public var graphql: String? = "http://127.0.0.1:9124/" public init() { } } diff --git a/Sources/SuiKit/Types/Structs/RPC/Connections/MainnetConnection.swift b/Sources/SuiKit/Types/Structs/RPC/Connections/MainnetConnection.swift index 8d7b8e8..c22b747 100644 --- a/Sources/SuiKit/Types/Structs/RPC/Connections/MainnetConnection.swift +++ b/Sources/SuiKit/Types/Structs/RPC/Connections/MainnetConnection.swift @@ -27,6 +27,7 @@ import Foundation public struct MainnetConnection: ConnectionProtocol { public var fullNode: String = "https://fullnode.mainnet.sui.io:443/" + public var graphql: String? = "https://graphql-beta.mainnet.sui.io" public init() { } } diff --git a/Sources/SuiKit/Types/Structs/RPC/Connections/TestnetConnection.swift b/Sources/SuiKit/Types/Structs/RPC/Connections/TestnetConnection.swift index 0485ae2..38be17b 100644 --- a/Sources/SuiKit/Types/Structs/RPC/Connections/TestnetConnection.swift +++ b/Sources/SuiKit/Types/Structs/RPC/Connections/TestnetConnection.swift @@ -28,6 +28,7 @@ import Foundation public struct TestnetConnection: ConnectionProtocol { public var fullNode: String = "https://fullnode.testnet.sui.io:443/" public var faucet: String? = "https://faucet.testnet.sui.io/gas" + public var graphql: String? = "https://graphql-beta.testnet.sui.io/" public init() { } } diff --git a/Tests/SuiKitTests/E2E/CheckpointTest.swift b/Tests/SuiKitTests/E2E/CheckpointTest.swift index 37c502c..9a290ac 100644 --- a/Tests/SuiKitTests/E2E/CheckpointTest.swift +++ b/Tests/SuiKitTests/E2E/CheckpointTest.swift @@ -74,12 +74,12 @@ final class CheckpointTest: XCTestCase { XCTAssertEqual(checkpoints.nextCursor, "0") XCTAssertEqual(checkpoints.data.count, 1) - XCTAssertTrue(checkpoints.hasNextPage) + XCTAssertTrue(checkpoints.hasNextPage!) let checkpoints1 = try await toolBox.client.getCheckpoints(cursor: checkpoints.nextCursor, limit: 1, order: .ascending) XCTAssertEqual(checkpoints1.nextCursor, "1") XCTAssertEqual(checkpoints1.data.count, 1) - XCTAssertTrue(checkpoints1.hasNextPage) + XCTAssertTrue(checkpoints1.hasNextPage!) } } diff --git a/Tests/SuiKitTests/E2E/CoinReadTest.swift b/Tests/SuiKitTests/E2E/CoinReadTest.swift index ba01027..5154c76 100644 --- a/Tests/SuiKitTests/E2E/CoinReadTest.swift +++ b/Tests/SuiKitTests/E2E/CoinReadTest.swift @@ -87,11 +87,11 @@ final class CoinReadTest: XCTestCase { let allCoins = try await toolBox.client.getAllCoins(account: toolBox.account.publicKey) XCTAssertEqual(allCoins.data.count, 5) - XCTAssertFalse(allCoins.hasNextPage) + XCTAssertFalse(allCoins.hasNextPage!) let publisherAllCoins = try await publisherToolBox.client.getAllCoins(account: publisherToolBox.account.publicKey) XCTAssertEqual(publisherAllCoins.data.count, 3) - XCTAssertFalse(publisherAllCoins.hasNextPage) + XCTAssertFalse(publisherAllCoins.hasNextPage!) let someSuiCoins = try await toolBox.client.getCoins( account: try toolBox.account.publicKey.toSuiAddress(), @@ -100,7 +100,7 @@ final class CoinReadTest: XCTestCase { limit: 3 ) XCTAssertEqual(someSuiCoins.data.count, 3) - XCTAssertTrue(someSuiCoins.hasNextPage) + XCTAssertTrue(someSuiCoins.hasNextPage!) } func testThatGettingBalanceWithAndWithoutTypeWorksAsIntended() async throws { @@ -108,7 +108,7 @@ final class CoinReadTest: XCTestCase { let publisherToolBox = try self.fetchPublisherToolBox() let suiBalance = try await toolBox.client.getBalance(account: toolBox.account.publicKey) - XCTAssertEqual(suiBalance.coinType, "0x2::sui::SUI") + XCTAssertEqual(suiBalance.coinType, try StructTag.fromStr("0x2::sui::SUI")) XCTAssertEqual(suiBalance.coinObjectCount, 5) XCTAssertGreaterThan(Int(suiBalance.totalBalance) ?? 0, 0) @@ -116,7 +116,7 @@ final class CoinReadTest: XCTestCase { account: publisherToolBox.account.publicKey, coinType: try self.fetchTestType() ) - XCTAssertEqual(testBalance.coinType, try self.fetchTestType()) + XCTAssertEqual(testBalance.coinType, try StructTag.fromStr(try self.fetchTestType())) XCTAssertEqual(testBalance.coinObjectCount, 2) XCTAssertEqual(Int(testBalance.totalBalance) ?? -1, 11) diff --git a/Tests/SuiKitTests/E2E/CoinTest.swift b/Tests/SuiKitTests/E2E/CoinTest.swift index 2f1e0fa..3c59c21 100644 --- a/Tests/SuiKitTests/E2E/CoinTest.swift +++ b/Tests/SuiKitTests/E2E/CoinTest.swift @@ -44,6 +44,6 @@ final class CoinTest: XCTestCase { typeArguments: [] ) let coins = try await toolbox.getCoins() - XCTAssertEqual(try Coin.getCoinStructTag(coinTypeArg: coins.data[0].coinType), suiStructTag) + XCTAssertEqual(try Coin.getCoinStructTag(coinTypeArg: coins.data[0].coinType.toString()), suiStructTag) } } diff --git a/Tests/SuiKitTests/E2E/GraphQLProviderTest.swift b/Tests/SuiKitTests/E2E/GraphQLProviderTest.swift new file mode 100644 index 0000000..2d1c165 --- /dev/null +++ b/Tests/SuiKitTests/E2E/GraphQLProviderTest.swift @@ -0,0 +1,345 @@ +// +// GraphQLProviderTest.swift +// SuiKit +// +// Copyright (c) 2023 OpenDive +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation +import XCTest +import SwiftyJSON +@testable import SuiKit + +final class GraphQLProviderTest: XCTestCase { + var toolBox: TestToolbox? + var packageId: String? + var parentObjectId: String? + + override func setUp() async throws { + self.toolBox = try await TestToolbox(true) + } + + private func setUpWithPackage() async throws { + self.packageId = try await self.fetchToolBox().publishPackage("dynamic-fields").packageId + + let ownedObjects = try await self.fetchToolBox() + .client.getOwnedObjects( + owner: try self.fetchToolBox().account.publicKey.toSuiAddress(), + filter: SuiObjectDataFilter.structType( + "\(try self.fetchPackageId())::dynamic_fields_test::Test" + ), + options: SuiObjectDataOptions(showType: true) + ) + self.parentObjectId = ownedObjects.data[0].data!.objectId + } + + private func setUpWithTransaction() async throws { + let toolBox = try self.fetchToolBox() + try await toolBox.setup() + var tx = try TransactionBlock() + let coin = try tx.splitCoin( + coin: tx.gas, + amounts: [tx.pure(value: .number(1))] + ) + let _ = try tx.transferObject(objects: [coin], address: toolBox.defaultRecipient) + try tx.setSenderIfNotSet(sender: try toolBox.account.publicKey.toSuiAddress()) + + let result = try await toolBox.client.signAndExecuteTransactionBlock( + transactionBlock: &tx, + signer: toolBox.account + ) + let _ = try await self.fetchToolBox().client.waitForTransaction(tx: result.digest) + // TODO: Remove once the GraphQL endpoint becomes default with the example validator. + try await Task.sleep(nanoseconds: 10_000_000_000) // Buffer for waiting on the Sui Indexer to catch up with the RPC Node + } + + private func fetchToolBox() throws -> TestToolbox { + guard let toolBox = self.toolBox else { + XCTFail("Failed to get Toolbox") + throw NSError(domain: "Failed to get Toolbox", code: -1) + } + return toolBox + } + + private func fetchPackageId() throws -> String { + guard let packageId = self.packageId else { + XCTFail("Failed to get Package ID") + throw NSError(domain: "Failed to get Package ID", code: -1) + } + return packageId + } + + func testThatGettingCoinsWorksAsIntendedFromGraphQL() async throws { + try await self.setUpWithTransaction() + let toolBox = try self.fetchToolBox() + let rpcCoins = try await toolBox.client.getCoins(account: try toolBox.account.address()) + let graphQLCoins = try await toolBox.graphQLProvider.getCoins(account: try toolBox.account.address()) + XCTAssertEqual(graphQLCoins.data.map { $0.previousTransaction }, rpcCoins.data.map { $0.previousTransaction }) + } + + func testThatGettingAllCoinsWorksAsIntendedFromGraphQL() async throws { + try await self.setUpWithTransaction() + let toolBox = try self.fetchToolBox() + let rpcCoins = try await toolBox.client.getAllCoins(account: toolBox.account.publicKey) + let graphQLCoins = try await toolBox.graphQLProvider.getAllCoins(account: toolBox.account.publicKey) + XCTAssertEqual(graphQLCoins.data.map { $0.previousTransaction }, rpcCoins.data.map { $0.previousTransaction }) + } + + func testThatGettingBalanceWorksAsIntendedFromGraphQL() async throws { + try await self.setUpWithTransaction() + let toolBox = try self.fetchToolBox() + let rpcBalance = try await toolBox.client.getBalance(account: toolBox.account.publicKey) + let graphQLBalance = try await toolBox.graphQLProvider.getBalance(account: toolBox.account.publicKey) + XCTAssertEqual(rpcBalance, graphQLBalance) + } + + func testThatGettingAllBalancesWorksAsIntendedFromGraphQL() async throws { + try await self.setUpWithTransaction() + let toolBox = try self.fetchToolBox() + let rpcBalances = try await toolBox.client.getAllBalances(account: toolBox.account) + let graphQLBalances = try await toolBox.graphQLProvider.getAllBalances(account: toolBox.account) + XCTAssertEqual(rpcBalances, graphQLBalances) + } + + func testThatGettingCoinMetadataWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let rpcMetadata = try await toolBox.client.getCoinMetadata(coinType: "0x2::sui::SUI") + let graphQLMetadata = try await toolBox.graphQLProvider.getCoinMetadata(coinType: "0x2::sui::SUI") + XCTAssertEqual(rpcMetadata, graphQLMetadata) + } + + func testThatGettingTotalSupplyWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let rpcSupply = try await toolBox.client.totalSupply("0x2::sui::SUI") + let graphQLSupply = try await toolBox.graphQLProvider.totalSupply("0x2::sui::SUI") + XCTAssertEqual(rpcSupply, graphQLSupply) + } + + func testThatGettingMoveFunctionArgTypesWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let rpcMoveFunction = try await toolBox.client.getMoveFunctionArgTypes( + package: "0x2", + module: "coin", + function: "balance" + ) + let graphQLMoveFunction = try await toolBox.graphQLProvider.getMoveFunctionArgTypes( + package: "0x2", + module: "coin", + function: "balance" + ) + XCTAssertEqual(rpcMoveFunction, graphQLMoveFunction) + } + + func testThatGettingMoveFunctionWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let rpcMoveFunction = try await toolBox.client.getNormalizedMoveFunction( + package: "0x2", + moduleName: "coin", + functionName: "balance" + ) + let graphQLMoveFunction = try await toolBox.graphQLProvider.getNormalizedMoveFunction( + package: "0x2", + moduleName: "coin", + functionName: "balance" + ) + XCTAssertEqual(rpcMoveFunction, graphQLMoveFunction) + } + + func testThatGettingNormalizedMoveModulesByPackageWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let rpcMovePackage = try await toolBox.client.getNormalizedMoveModulesByPackage(package: "0x2") + let graphqlMovePackage = try await toolBox.graphQLProvider.getNormalizedMoveModulesByPackage(package: "0x2") + XCTAssertEqual(graphqlMovePackage["coin"], rpcMovePackage["coin"]) + } + + func testThatGettingNormalizedMoveModuleWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let rpcMoveModule = try await toolBox.client.getNormalizedMoveModule(package: "0x2", module: "coin") + let graphqlMoveModule = try await toolBox.graphQLProvider.getNormalizedMoveModule(package: "0x2", module: "coin") + XCTAssertEqual(graphqlMoveModule, rpcMoveModule) + } + + func testThatGettingNormalizedMoveStructWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let rpcMoveStruct = try await toolBox.client.getNormalizedMoveStruct( + package: "0x2", + module: "coin", + structure: "Coin" + ) + let graphqlMoveStruct = try await toolBox.graphQLProvider.getNormalizedMoveStruct( + package: "0x2", + module: "coin", + structure: "Coin" + ) + XCTAssertEqual(graphqlMoveStruct, rpcMoveStruct) + } + + func testThatGettingOwnedObjectsWorksAsIntendedFromGraphql() async throws { + try await self.setUpWithTransaction() + let toolBox = try self.fetchToolBox() + let objectOptions = SuiObjectDataOptions( + showBcs: true, + showContent: true, + showDisplay: true, + showOwner: true, + showPreviousTransaction: true, + showStorageRebate: true, + showType: true + ) + let rpcObjects = try await toolBox.client.getOwnedObjects(owner: try toolBox.address(), options: objectOptions) + let graphQLObjects = try await toolBox.graphQLProvider.getOwnedObjects(owner: try toolBox.address(), options: objectOptions) + + XCTAssertEqual(rpcObjects.data.map { $0.data?.owner }, graphQLObjects.data.map { $0.data?.owner }) + XCTAssertEqual(rpcObjects.data.map { $0.data?.digest }, graphQLObjects.data.map { $0.data?.digest }) + XCTAssertEqual(rpcObjects.data.map { $0.data?.previousTransaction }, graphQLObjects.data.map { $0.data?.previousTransaction }) + } + + func testThatGettingObjectWorksAsIntendedFromGraphQL() async throws { + try await self.setUpWithTransaction() + let toolBox = try self.fetchToolBox() + let gasCoin = try await toolBox.getCoins() + let objectOptions = SuiObjectDataOptions( + showBcs: true, + showContent: true, + showDisplay: true, + showOwner: true, + showPreviousTransaction: true, + showStorageRebate: true, + showType: true + ) + + let rpcObject = try await toolBox.client.getObject(objectId: gasCoin.data[0].coinObjectId, options: objectOptions) + let graphQLObject = try await toolBox.graphQLProvider.getObject(objectId: gasCoin.data[0].coinObjectId, options: objectOptions) + + XCTAssertEqual(rpcObject?.data?.objectId, graphQLObject?.data?.objectId) + XCTAssertEqual(rpcObject?.data?.digest, graphQLObject?.data?.digest) + XCTAssertEqual(rpcObject?.data?.previousTransaction, graphQLObject?.data?.previousTransaction) + } + + func testThatGettingProtocolConfigWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let protocolRpc = try await toolBox.client.getProtocolConfig() + let protocolGraphQL = try await toolBox.graphQLProvider.getProtocolConfig() + XCTAssertEqual(protocolRpc, protocolGraphQL) + } + + func testThatGettingCheckpointWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let checkpointRpc = try await toolBox.client.getCheckpoint(id: "3") + let checkpointGraphQL = try await toolBox.graphQLProvider.getCheckpoint(sequenceNumber: 3) + XCTAssertEqual(checkpointRpc, checkpointGraphQL) + } + + func testThatGettingCheckpointsWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let checkpointsRpc = try await toolBox.client.getCheckpoints(cursor: "0", limit: 5, order: .ascending) + let checkpointsGraphQL = try await toolBox.graphQLProvider.getCheckpoints(cursor: "MA", limit: 5, order: .ascending) + XCTAssertEqual(checkpointsRpc.data, checkpointsGraphQL.data) + } + + func testThatGettingTotalTransactionBlocksWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let totalTxBlocksRpc = try await toolBox.client.getTotalTransactionBlocks() + let totalTxBlocksGraphQL = try await toolBox.graphQLProvider.getTotalTransactionBlocks() + XCTAssertGreaterThanOrEqual(totalTxBlocksRpc, totalTxBlocksGraphQL) + } + + func testThatGettingReferenceGasPriceWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let referenceRpc = try await toolBox.client.getReferenceGasPrice() + let referenceGraphQL = try await toolBox.graphQLProvider.getReferenceGasPrice() + XCTAssertEqual(referenceRpc, referenceGraphQL) + } + + func testThatGettingLastestCheckpointSequenceNumberWorksAsIntendedFromGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let sequenceeRpc = try await toolBox.client.getLatestCheckpointSequenceNumber() + let sequenceGraphQL = try await toolBox.graphQLProvider.getLatestCheckpointSequenceNumber() + XCTAssertGreaterThanOrEqual(sequenceeRpc, sequenceGraphQL) + } + + func testThatGettingChainIdentifiersWorksAsIntendedForGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let chainRpc = try await toolBox.client.getChainIdentifier() + let chainGraphQL = try await toolBox.graphQLProvider.getChainIdentifier() + XCTAssertEqual(chainRpc, chainGraphQL) + } + + func testThatGettingValidatorAPYsWorksAsIntendedForGraphQL() async throws { + let toolBox = try self.fetchToolBox() + let apyRpc = try await toolBox.client.getValidatorsApy() + let apyGraphQL = try await toolBox.graphQLProvider.getValidatorsApy() + XCTAssertEqual(apyRpc, apyGraphQL) + } + + func testThatGettingMultipleObjectsWorksAsIntendedFromGraphQL() async throws { + try await self.setUpWithTransaction() + let toolBox = try self.fetchToolBox() + let gasCoin = try await toolBox.getCoins() + let objectOptions = SuiObjectDataOptions( + showBcs: true, + showContent: true, + showDisplay: true, + showOwner: true, + showPreviousTransaction: true, + showStorageRebate: true, + showType: true + ) + + let rpcObject = try await toolBox.client.getMultiObjects(ids: [gasCoin.data[0].coinObjectId], options: objectOptions) + let graphQLObject = try await toolBox.graphQLProvider.getMultiObjects(ids: [gasCoin.data[0].coinObjectId], options: objectOptions) + + XCTAssertEqual(rpcObject[0].data?.objectId, graphQLObject[0].data?.objectId) + XCTAssertEqual(rpcObject[0].data?.digest, graphQLObject[0].data?.digest) + XCTAssertEqual(rpcObject[0].data?.previousTransaction, graphQLObject[0].data?.previousTransaction) + } + + func testThatGettingPastObjectWorksAsIntendedFromGraphQL() async throws { + try await self.setUpWithTransaction() + let toolBox = try self.fetchToolBox() + let gasCoin = try await toolBox.getCoins() + let objectOptions = SuiObjectDataOptions( + showBcs: true, + showContent: true, + showDisplay: true, + showOwner: true, + showPreviousTransaction: true, + showStorageRebate: true, + showType: true + ) + + let rpcObject = try await toolBox.client.tryGetPastObject( + id: gasCoin.data[0].coinObjectId, version: 2, options: objectOptions + ) + let graphQLObject = try await toolBox.graphQLProvider.tryGetPastObject( + id: gasCoin.data[0].coinObjectId, version: 2, options: objectOptions + ) + + if + case .versionFound(let rpcFound) = rpcObject!, + case .versionFound(let graphQlFound) = graphQLObject + { + XCTAssertEqual(rpcFound.objectId, graphQlFound.objectId) + XCTAssertEqual(rpcFound.digest, graphQlFound.digest) + XCTAssertEqual(rpcFound.previousTransaction, graphQlFound.previousTransaction) + } + } +} diff --git a/Tests/SuiKitTests/E2E/NormalizedModuleTest.swift b/Tests/SuiKitTests/E2E/NormalizedModuleTest.swift index 979d94a..bbe2adb 100644 --- a/Tests/SuiKitTests/E2E/NormalizedModuleTest.swift +++ b/Tests/SuiKitTests/E2E/NormalizedModuleTest.swift @@ -65,7 +65,7 @@ final class NormalizedModuleTest: XCTestCase { func testThatGettingNormalizedModuleModulesWorksAsIntended() async throws { let toolBox = try self.fetchToolBox() - guard let normalized = try await toolBox.client.getNormalizedModuleModule( + guard let normalized = try await toolBox.client.getNormalizedMoveModule( package: self.defaultPackage, module: self.defaultModule ) else { diff --git a/Tests/SuiKitTests/E2E/ReadEventTest.swift b/Tests/SuiKitTests/E2E/ReadEventTest.swift index 5842d06..5a33d05 100644 --- a/Tests/SuiKitTests/E2E/ReadEventTest.swift +++ b/Tests/SuiKitTests/E2E/ReadEventTest.swift @@ -51,8 +51,8 @@ final class ReadEventTest: XCTestCase { func testThatGettingAllEventsWithPageWorksAsIntended() async throws { let toolBox = try self.fetchToolBox() let page1 = try await toolBox.client.queryEvents(limit: 2) - XCTAssertNotEqual(page1.nextCursor.eventSeq, "") - XCTAssertNotEqual(page1.nextCursor.txDigest, "") + XCTAssertNotEqual(page1.nextCursor!.eventSeq, "") + XCTAssertNotEqual(page1.nextCursor!.txDigest, "") } func testThatGettingEventsBySenderPaginatedWorksAsIntended() async throws { diff --git a/Tests/SuiKitTests/E2E/Utils/TestToolbox.swift b/Tests/SuiKitTests/E2E/Utils/TestToolbox.swift index 7f6c97d..67efd37 100644 --- a/Tests/SuiKitTests/E2E/Utils/TestToolbox.swift +++ b/Tests/SuiKitTests/E2E/Utils/TestToolbox.swift @@ -34,10 +34,17 @@ internal class TestToolbox { let account: Account let client: SuiProvider - - init(account: Account, client: SuiProvider = SuiProvider(connection: LocalnetConnection()), _ needsFunds: Bool = true) async throws { + let graphQLProvider: GraphQLSuiProvider + + init( + account: Account, + client: SuiProvider = SuiProvider(connection: LocalnetConnection()), + graphQLClient: GraphQLSuiProvider = GraphQLSuiProvider(connection: LocalnetConnection()), + _ needsFunds: Bool = true + ) async throws { self.account = account self.client = client + self.graphQLProvider = graphQLClient if needsFunds { try await self.setup() } } @@ -45,6 +52,7 @@ internal class TestToolbox { init(_ needsFunds: Bool = true) async throws { self.account = try Account() self.client = SuiProvider(connection: LocalnetConnection()) + self.graphQLProvider = GraphQLSuiProvider(connection: LocalnetConnection()) if needsFunds { try await self.setup() } } diff --git a/apollo-codegen-config.json b/apollo-codegen-config.json new file mode 100644 index 0000000..aebc513 --- /dev/null +++ b/apollo-codegen-config.json @@ -0,0 +1,28 @@ +{ + "schemaNamespace" : "sui-graphql", + "input" : { + "operationSearchPaths" : [ + "**/*.graphql" + ], + "schemaSearchPaths" : [ + "**/*.graphqls" + ] + }, + "output" : { + "testMocks" : { + "none" : { + } + }, + "schemaTypes" : { + "path" : "./sui-graphql", + "moduleType" : { + "swiftPackageManager" : { + } + } + }, + "operations" : { + "inSchemaModule" : { + } + } + } +} \ No newline at end of file diff --git a/apollo-ios-cli b/apollo-ios-cli new file mode 100755 index 0000000..1c56976 Binary files /dev/null and b/apollo-ios-cli differ