diff --git a/crates/sui-graphql-client/Cargo.toml b/crates/sui-graphql-client/Cargo.toml index 9d6d5b08..b27c9e5d 100644 --- a/crates/sui-graphql-client/Cargo.toml +++ b/crates/sui-graphql-client/Cargo.toml @@ -21,3 +21,4 @@ tokio = { version = "1.39.2", features = ["full"] } [build-dependencies] cynic-codegen = { version = "3.7.3" } + diff --git a/crates/sui-graphql-client/schema/graphql_rpc.graphql b/crates/sui-graphql-client/schema/graphql_rpc.graphql index cbde89c2..177346bb 100644 --- a/crates/sui-graphql-client/schema/graphql_rpc.graphql +++ b/crates/sui-graphql-client/schema/graphql_rpc.graphql @@ -97,9 +97,28 @@ type Address implements IOwner { suinsRegistrations(first: Int, after: String, last: Int, before: String): SuinsRegistrationConnection! """ Similar behavior to the `transactionBlocks` in Query but supporting the additional - `AddressTransactionBlockRelationship` filter, which defaults to `SIGN`. + `AddressTransactionBlockRelationship` filter, which defaults to `SENT`. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range includes all transactions known to GraphQL, but it can be + restricted by the `after` and `before` cursors, and the `beforeCheckpoint`, + `afterCheckpoint` and `atCheckpoint` filters. """ - transactionBlocks(first: Int, after: String, last: Int, before: String, relation: AddressTransactionBlockRelationship, filter: TransactionBlockFilter): TransactionBlockConnection! + transactionBlocks(first: Int, after: String, last: Int, before: String, relation: AddressTransactionBlockRelationship, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! } type AddressConnection { @@ -141,14 +160,22 @@ type AddressOwner { } """ -The possible relationship types for a transaction block: sign, sent, received, or paid. +The possible relationship types for a transaction block: sent, or received. """ enum AddressTransactionBlockRelationship { """ - Transactions this address has signed either as a sender or as a sponsor. + Transactions this address has sent. NOTE: this input filter has been deprecated in favor of + `SENT` which behaves identically but is named more clearly. Both filters restrict + transactions by their sender, only, not signers in general. + + This filter will be removed after 1.36.0 (2024-10-14). """ SIGN """ + Transactions this address has sent. + """ + SENT + """ Transactions that sent objects to this address. """ RECV @@ -409,8 +436,25 @@ type Checkpoint { epoch: Epoch """ Transactions in this checkpoint. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range consists of all transactions in this checkpoint. """ - transactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + transactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! } type CheckpointConnection { @@ -517,8 +561,27 @@ type Coin implements IMoveObject & IObject & IOwner { storageRebate: BigInt """ The transaction blocks that sent objects to this object. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range includes all transactions known to GraphQL, but it can be + restricted by the `after` and `before` cursors, and the `beforeCheckpoint`, + `afterCheckpoint` and `atCheckpoint` filters. """ - receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! """ The Base64-encoded BCS serialization of the object's content. """ @@ -676,8 +739,27 @@ type CoinMetadata implements IMoveObject & IObject & IOwner { storageRebate: BigInt """ The transaction blocks that sent objects to this object. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range includes all transactions known to GraphQL, but it can be + restricted by the `after` and `before` cursors, and the `beforeCheckpoint`, + `afterCheckpoint` and `atCheckpoint` filters. """ - receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! """ The Base64-encoded BCS serialization of the object's content. """ @@ -1093,8 +1175,25 @@ type Epoch { checkpoints(first: Int, after: String, last: Int, before: String): CheckpointConnection! """ The epoch's corresponding transaction blocks. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range consists of all transactions in this epoch. """ - transactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + transactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! } type Event { @@ -1173,7 +1272,13 @@ type EventEdge { } input EventFilter { + """ + Filter down to events from transactions sent by this address. + """ sender: SuiAddress + """ + Filter down to the events from this transaction (given by its transaction digest). + """ transactionDigest: String """ Events emitted by a particular module. An event is emitted by a @@ -1181,6 +1286,8 @@ input EventFilter { PTB and emits an event. Modules can be filtered by their package, or package::module. + We currently do not support filtering by emitting module and event type + at the same time so if both are provided in one filter, the query will error. """ emittingModule: String """ @@ -1256,6 +1363,10 @@ enum Feature { validators either directly, or through system transactions. """ SYSTEM_STATE + """ + Named packages service (utilizing dotmove package registry). + """ + MOVE_REGISTRY } @@ -1429,7 +1540,7 @@ interface IObject { """ The transaction blocks that sent objects to this object. """ - receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! """ The Base64-encoded BCS serialization of the object's content. """ @@ -1972,8 +2083,27 @@ type MoveObject implements IMoveObject & IObject & IOwner { storageRebate: BigInt """ The transaction blocks that sent objects to this object. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range includes all transactions known to GraphQL, but it can be + restricted by the `after` and `before` cursors, and the `beforeCheckpoint`, + `afterCheckpoint` and `atCheckpoint` filters. """ - receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! """ The Base64-encoded BCS serialization of the object's content. """ @@ -2161,13 +2291,48 @@ type MovePackage implements IObject & IOwner { The transaction blocks that sent objects to this package. Note that objects that have been sent to a package become inaccessible. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range includes all transactions known to GraphQL, but it can be + restricted by the `after` and `before` cursors, and the `beforeCheckpoint`, + `afterCheckpoint` and `atCheckpoint` filters. """ - receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! """ The Base64-encoded BCS serialization of the package's content. """ bcs: Base64 """ + Fetch another version of this package (the package that shares this package's original ID, + but has the specified `version`). + """ + packageAtVersion(version: Int!): MovePackage + """ + Fetch all versions of this package (packages that share this package's original ID), + optionally bounding the versions exclusively from below with `afterVersion`, or from above + with `beforeVersion`. + """ + packageVersions(first: Int, after: String, last: Int, before: String, filter: MovePackageVersionFilter): MovePackageConnection! + """ + Fetch the latest version of this package (the package with the highest `version` that shares + this packages's original ID) + """ + latestPackage: MovePackage! + """ A representation of the module called `name` in this package, including the structs and functions it defines. """ @@ -2191,6 +2356,22 @@ type MovePackage implements IObject & IOwner { moduleBcs: Base64 } +""" +Filter for paginating `MovePackage`s that were created within a range of checkpoints. +""" +input MovePackageCheckpointFilter { + """ + Fetch packages that were published strictly after this checkpoint. Omitting this fetches + packages published since genesis. + """ + afterCheckpoint: UInt53 + """ + Fetch packages that were published strictly before this checkpoint. Omitting this fetches + packages published up to the latest checkpoint (inclusive). + """ + beforeCheckpoint: UInt53 +} + type MovePackageConnection { """ Information to aid in pagination. @@ -2220,6 +2401,22 @@ type MovePackageEdge { cursor: String! } +""" +Filter for paginating versions of a given `MovePackage`. +""" +input MovePackageVersionFilter { + """ + Fetch versions of this package that are strictly newer than this version. Omitting this + fetches versions since the original version. + """ + afterVersion: UInt53 + """ + Fetch versions of this package that are strictly older than this version. Omitting this + fetches versions up to the latest version (inclusive). + """ + beforeVersion: UInt53 +} + """ Description of a struct type, defined in a Move module. """ @@ -2492,8 +2689,27 @@ type Object implements IObject & IOwner { storageRebate: BigInt """ The transaction blocks that sent objects to this object. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range includes all transactions known to GraphQL, but it can be + restricted by the `after` and `before` cursors, and the `beforeCheckpoint`, + `afterCheckpoint` and `atCheckpoint` filters. """ - receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! """ The Base64-encoded BCS serialization of the object's content. """ @@ -2634,11 +2850,8 @@ objects are ones whose """ input ObjectFilter { """ - 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. + Filter objects 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>`. @@ -3040,6 +3253,26 @@ type Query { """ object(address: SuiAddress!, version: UInt53): Object """ + The package corresponding to the given address (at the optionally given version). + + When no version is given, the package is loaded directly from the address given. Otherwise, + the address is translated before loading to point to the package whose original ID matches + the package at `address`, but whose version is `version`. For non-system packages, this + might result in a different address than `address` because different versions of a package, + introduced by upgrades, exist at distinct addresses. + + Note that this interpretation of `version` is different from a historical object read (the + interpretation of `version` for the `object` query). + """ + package(address: SuiAddress!, version: UInt53): MovePackage + """ + The latest version of the package at `address`. + + This corresponds to the package with the highest `version` that shares its original ID with + the package at `address`. + """ + latestPackage(address: SuiAddress!): MovePackage + """ Look-up an Account by its SuiAddress. """ address(address: SuiAddress!): Address @@ -3074,10 +3307,31 @@ type Query { checkpoints(first: Int, after: String, last: Int, before: String): CheckpointConnection! """ The transaction blocks that exist in the network. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range includes all transactions known to GraphQL, but it can be + restricted by the `after` and `before` cursors, and the `beforeCheckpoint`, + `afterCheckpoint` and `atCheckpoint` filters. """ - transactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + transactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! """ - The events that exist in the network. + Query events that are emitted in the network. + We currently do not support filtering by emitting module and event type + at the same time so if both are provided in one filter, the query will error. """ events(first: Int, after: String, last: Int, before: String, filter: EventFilter): EventConnection! """ @@ -3085,6 +3339,20 @@ type Query { """ objects(first: Int, after: String, last: Int, before: String, filter: ObjectFilter): ObjectConnection! """ + The Move packages that exist in the network, optionally filtered to be strictly before + `beforeCheckpoint` and/or strictly after `afterCheckpoint`. + + This query returns all versions of a given user package that appear between the specified + checkpoints, but only records the latest versions of system packages. + """ + packages(first: Int, after: String, last: Int, before: String, filter: MovePackageCheckpointFilter): MovePackageConnection! + """ + Fetch all versions of package at `address` (packages that share this package's original ID), + optionally bounding the versions exclusively from below with `afterVersion`, or from above + with `beforeVersion`. + """ + packageVersions(first: Int, after: String, last: Int, before: String, address: SuiAddress!, filter: MovePackageVersionFilter): MovePackageConnection! + """ Fetch the protocol config by protocol version (defaults to the latest protocol version known to the GraphQL service). """ @@ -3094,6 +3362,14 @@ type Query { """ resolveSuinsAddress(domain: String!): Address """ + Fetch a package by its name (using dot move service) + """ + packageByName(name: String!): MovePackage + """ + Fetch a type that includes dot move service names in it. + """ + typeByName(name: String!): MoveType! + """ The coin metadata associated with the given coin type. """ coinMetadata(coinType: String!): CoinMetadata @@ -3205,10 +3481,6 @@ type ServiceConfig { """ isEnabled(feature: Feature!): Boolean! """ - List the available versions for this GraphQL service. - """ - availableVersions: [String!]! - """ List of all features that are enabled on this GraphQL service. """ enabledFeatures: [Feature!]! @@ -3258,7 +3530,18 @@ type ServiceConfig { """ requestTimeoutMs: Int! """ - Maximum length of a query payload string. + The maximum bytes allowed for the `txBytes` and `signatures` fields of the GraphQL mutation + `executeTransactionBlock` node, or for the `txBytes` of a `dryRunTransactionBlock`. + + It is the value of the maximum transaction bytes (including the signatures) allowed by the + protocol, plus the Base64 overhead (roughly 1/3 of the original string). + """ + maxTransactionPayloadSize: Int! + """ + The maximum bytes allowed for the JSON object in the request body of a GraphQL query, for + the read part of the query. + In case of mutations or dryRunTransactionBlocks the txBytes and signatures are not + included in this limit. """ maxQueryPayloadSize: Int! """ @@ -3279,6 +3562,14 @@ type ServiceConfig { Maximum nesting allowed in struct fields when calculating the layout of a single Move Type. """ maxMoveValueDepth: Int! + """ + Maximum number of transaction ids that can be passed to a `TransactionBlockFilter`. + """ + maxTransactionIds: Int! + """ + Maximum number of candidates to scan when gathering a page of results. + """ + maxScanLimit: Int! } """ @@ -3496,8 +3787,27 @@ type StakedSui implements IMoveObject & IObject & IOwner { storageRebate: BigInt """ The transaction blocks that sent objects to this object. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range includes all transactions known to GraphQL, but it can be + restricted by the `after` and `before` cursors, and the `beforeCheckpoint`, + `afterCheckpoint` and `atCheckpoint` filters. """ - receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! """ The Base64-encoded BCS serialization of the object's content. """ @@ -3698,8 +4008,27 @@ type SuinsRegistration implements IMoveObject & IObject & IOwner { storageRebate: BigInt """ The transaction blocks that sent objects to this object. + + `scanLimit` restricts the number of candidate transactions scanned when gathering a page of + results. It is required for queries that apply more than two complex filters (on function, + kind, sender, recipient, input object, changed object, or ids), and can be at most + `serviceConfig.maxScanLimit`. + + When the scan limit is reached the page will be returned even if it has fewer than `first` + results when paginating forward (`last` when paginating backwards). If there are more + transactions to scan, `pageInfo.hasNextPage` (or `pageInfo.hasPreviousPage`) will be set to + `true`, and `PageInfo.endCursor` (or `PageInfo.startCursor`) will be set to the last + transaction that was scanned as opposed to the last (or first) transaction in the page. + + Requesting the next (or previous) page after this cursor will resume the search, scanning + the next `scanLimit` many transactions in the direction of pagination, and so on until all + transactions in the scanning range have been visited. + + By default, the scanning range includes all transactions known to GraphQL, but it can be + restricted by the `after` and `before` cursors, and the `beforeCheckpoint`, + `afterCheckpoint` and `atCheckpoint` filters. """ - receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter): TransactionBlockConnection! + receivedTransactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection! """ The Base64-encoded BCS serialization of the object's content. """ @@ -3970,18 +4299,54 @@ type TransactionBlockEffects { } input TransactionBlockFilter { + """ + Filter transactions by move function called. Calls can be filtered by the `package`, + `package::module`, or the `package::module::name` of their function. + """ function: String """ An input filter selecting for either system or programmable transactions. """ kind: TransactionBlockKindInput + """ + Limit to transactions that occured strictly after the given checkpoint. + """ afterCheckpoint: UInt53 + """ + Limit to transactions in the given checkpoint. + """ atCheckpoint: UInt53 + """ + Limit to transaction that occured strictly before the given checkpoint. + """ beforeCheckpoint: UInt53 + """ + Limit to transactions that were sent by the given address. NOTE: this input filter has been + deprecated in favor of `sentAddress` which behaves identically but is named more clearly. + Both filters restrict transactions by their sender, only, not signers in general. + + This filter will be removed after 1.36.0 (2024-10-14). + """ signAddress: SuiAddress + """ + Limit to transactions that were sent by the given address. + """ + sentAddress: SuiAddress + """ + Limit to transactions that sent an object to the given address. + """ recvAddress: SuiAddress + """ + Limit to transactions that accepted the given object as an input. + """ inputObject: SuiAddress + """ + Limit to transactions that output a versioon of this object. + """ changedObject: SuiAddress + """ + Select transactions by their digest. + """ transactionIds: [String!] } diff --git a/crates/sui-graphql-client/src/lib.rs b/crates/sui-graphql-client/src/lib.rs index 54b3d280..b7eaa69b 100644 --- a/crates/sui-graphql-client/src/lib.rs +++ b/crates/sui-graphql-client/src/lib.rs @@ -221,7 +221,7 @@ impl Client { seq_num: Option, ) -> Result, Error> { ensure!( - digest.is_some() != seq_num.is_some(), + !(digest.is_some() && seq_num.is_some()), "Either digest or seq_num must be provided" ); @@ -551,6 +551,7 @@ impl Client { #[cfg(test)] mod tests { use crate::{Client, DEFAULT_LOCAL_HOST, DEVNET_HOST, MAINNET_HOST, TESTNET_HOST}; + const NETWORKS: [&str; 3] = [MAINNET_HOST, TESTNET_HOST, DEVNET_HOST]; #[test] fn test_rpc_server() { @@ -566,4 +567,195 @@ mod tests { assert!(client.set_rpc_server("localhost:9125/graphql").is_ok()); assert!(client.set_rpc_server("9125/graphql").is_err()); } + + #[tokio::test] + async fn test_chain_id() { + for n in NETWORKS.iter() { + let client = Client::new(n).unwrap(); + let chain_id = client.chain_id().await; + assert!(chain_id.is_ok()); + if *n == "http://sui-mainnet.mystenlabs.com/graphql" { + assert!(chain_id.unwrap() == "35834a8a"); + } + } + } + + #[tokio::test] + async fn test_reference_gas_price_query() { + for n in NETWORKS.iter() { + let client = Client::new(n).unwrap(); + let rgp = client.reference_gas_price(None).await; + assert!( + rgp.is_ok(), + "Reference gas price query failed for network: {n}" + ); + } + } + + #[tokio::test] + async fn test_protocol_config_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let pc = client.protocol_config(None).await; + assert!(pc.is_ok()); + + // test specific version + let pc = client.protocol_config(Some(50)).await; + assert!(pc.is_ok()); + let pc = pc.unwrap(); + if let Some(pc) = pc { + assert_eq!( + pc.protocol_version.0, 50, + "Protocol version query mismatch for network: {n}. Expected: 50, received: {}", + pc.protocol_version.0 + ); + } + } + } + + #[tokio::test] + async fn test_service_config_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let sc = client.service_config().await; + assert!(sc.is_ok(), "Service config query failed for network: {n}"); + } + } + + #[tokio::test] + async fn test_coin_metadata_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let cm = client.coin_metadata("0x2::sui::SUI").await; + assert!(cm.is_ok(), "Coin metadata query failed for network: {n}"); + } + } + + #[tokio::test] + async fn test_checkpoint_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let c = client.checkpoint(None, None).await; + assert!( + c.is_ok(), + "Checkpoint query failed for network: {n}. Error: {}", + c.unwrap_err() + ); + } + } + + #[tokio::test] + async fn test_latest_checkpoint_sequence_number_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let last_checkpoint = client.latest_checkpoint_sequence_number().await; + assert!( + last_checkpoint.is_ok(), + "Latest checkpoint sequence number query failed for network: {n}. Error: {}", + last_checkpoint.unwrap_err() + ); + } + } + + #[tokio::test] + async fn test_epoch_total_checkpoints_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let e = client.epoch_total_checkpoints(None).await; + assert!( + e.is_ok(), + "Epoch total checkpoints query failed for network: {n}. Error: {}", + e.unwrap_err() + ); + } + } + + #[tokio::test] + async fn test_epoch_total_transaction_blocks_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let e = client.epoch_total_transaction_blocks(None).await; + assert!( + e.is_ok(), + "Epoch total transaction blocks query failed for network: {n}. Error: {}", + e.unwrap_err() + ); + } + } + + #[tokio::test] + async fn test_epoch_summary_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let e = client.epoch_summary(None).await; + assert!( + e.is_ok(), + "Epoch summary query failed for network: {n}. Error: {}", + e.unwrap_err() + ); + } + } + + #[tokio::test] + async fn test_events_query() { + let client = Client::new_devnet(); + let events = client.events(None, None, None, None, None).await; + assert!( + events.is_ok(), + "Events query failed for network: {DEVNET_HOST}. Error: {}", + events.unwrap_err() + ); + } + + #[tokio::test] + async fn test_objects_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let objects = client.objects(None, None, None, None, None).await; + assert!( + objects.is_ok(), + "Objects query failed for network: {n}. Error: {}", + objects.unwrap_err() + ); + } + } + + #[tokio::test] + async fn test_object_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let object = client.object("0x5".parse().unwrap(), None).await; + assert!( + object.is_ok(), + "Object query failed for network: {n}. Error: {}", + object.unwrap_err() + ); + } + } + + #[tokio::test] + async fn test_object_bcs_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let object_bcs = client.object_bcs("0x5".parse().unwrap()).await; + assert!( + object_bcs.is_ok(), + "Object bcs query failed for network: {n}. Error: {}", + object_bcs.unwrap_err() + ); + } + } + + #[tokio::test] + async fn test_transactions_query() { + for n in NETWORKS { + let client = Client::new(n).unwrap(); + let transactions = client.transactions(None, None, None, None, None).await; + assert!( + transactions.is_ok(), + "Transactions query failed for network: {n}. Error: {}", + transactions.unwrap_err() + ); + } + } } diff --git a/crates/sui-graphql-client/src/query_types/service_config.rs b/crates/sui-graphql-client/src/query_types/service_config.rs index 4265c27c..facc0956 100644 --- a/crates/sui-graphql-client/src/query_types/service_config.rs +++ b/crates/sui-graphql-client/src/query_types/service_config.rs @@ -21,8 +21,6 @@ pub struct ServiceConfigQuery { #[derive(cynic::QueryFragment, Debug)] #[cynic(schema = "rpc", graphql_type = "ServiceConfig")] pub struct ServiceConfig { - /// List the available versions for this GraphQL service. - pub available_versions: Vec, /// Default number of elements allowed on a single page of a connection. pub default_page_size: i32, /// List of all features that are enabled on this RPC service. @@ -80,4 +78,5 @@ pub enum Feature { NameService, Subscriptions, SystemState, + MoveRegistry, }