Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graphql): Docs fixes from #17543 #19046

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/sui-graphql-rpc/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3088,12 +3088,12 @@ type Query {
"""
object(address: SuiAddress!, version: UInt53): Object
"""
The package corresponding to the given address at the (optionally) given version.
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 may
result in a different address than `address` because different versions of a package,
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
Expand Down Expand Up @@ -3156,8 +3156,8 @@ type Query {
The Move packages that exist in the network, optionally filtered to be strictly before
`beforeCheckpoint` and/or strictly after `afterCheckpoint`.

This query will return all versions of a given user package that appear between the
specified checkpoints, but only records the latest versions of system packages.
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!
"""
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-graphql-rpc/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum Command {
/// Output a TOML config (suitable for passing into the --config parameter of the start-server
/// command) with all values set to their defaults.
GenerateConfig {
/// Optional path to a file to output to. Prints to stdout if none is provided.
/// Optional path to an output file. Prints to `stdout` if not provided.
output: Option<PathBuf>,
},

Expand Down
2 changes: 1 addition & 1 deletion crates/sui-graphql-rpc/src/data/package_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) type PackageResolver = Arc<Resolver<PackageCache>>;
/// to `fetch`
pub struct DbPackageStore(DataLoader);

/// DataLoader key for fetching the latest version of a `Package` by its ID.
/// `DataLoader` key for fetching the latest version of a `Package` by its ID.
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
struct PackageKey(AccountAddress);

Expand Down
4 changes: 2 additions & 2 deletions crates/sui-graphql-rpc/src/types/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) struct CheckpointId {
pub sequence_number: Option<UInt53>,
}

/// DataLoader key for fetching a `Checkpoint` by its sequence number, constrained by a consistency
/// `DataLoader` key for fetching a `Checkpoint` by its sequence number, constrained by a consistency
/// cursor.
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
struct SeqNumKey {
Expand All @@ -47,7 +47,7 @@ struct SeqNumKey {
pub checkpoint_viewed_at: u64,
}

/// DataLoader key for fetching a `Checkpoint` by its digest, constrained by a consistency cursor.
/// `DataLoader` key for fetching a `Checkpoint` by its digest, constrained by a consistency cursor.
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
struct DigestKey {
pub digest: Digest,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-graphql-rpc/src/types/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) struct Epoch {
pub checkpoint_viewed_at: u64,
}

/// DataLoader key for fetching an `Epoch` by its ID, optionally constrained by a consistency
/// `DataLoader` key for fetching an `Epoch` by its ID, optionally constrained by a consistency
/// cursor.
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
struct EpochKey {
Expand Down
11 changes: 5 additions & 6 deletions crates/sui-graphql-rpc/src/types/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,12 @@ impl Event {
/// checkpoint sequence numbers as the cursor to determine the correct page of results. The
/// query can optionally be further `filter`-ed by the `EventFilter`.
///
/// The `checkpoint_viewed_at` parameter represents the checkpoint sequence number at which this
/// page was queried. Each entity returned in the connection will inherit this checkpoint, so
/// that when viewing that entity's state, it will be as if it is being viewed at this
/// checkpoint.
/// The `checkpoint_viewed_at` parameter represents the checkpoint sequence number at which
/// this page was queried. Each entity returned in the connection inherits this checkpoint, so
/// that when viewing that entity's state, it's as if it's being viewed at this checkpoint.
///
/// The cursors in `page` may also include checkpoint viewed at fields. If these are set, they
/// take precedence over the checkpoint that pagination is being conducted in.
/// The cursors in `page` might also include checkpoint viewed at fields. If these are set,
/// they take precedence over the checkpoint that pagination is being conducted in.
pub(crate) async fn paginate(
db: &Db,
page: Page<Cursor>,
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-graphql-rpc/src/types/move_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub(crate) struct PackageCursor {
pub checkpoint_viewed_at: u64,
}

/// DataLoader key for fetching the storage ID of the (user) package that shares an original (aka
/// `DataLoader` key for fetching the storage ID of the (user) package that shares an original (aka
/// runtime) ID with the package stored at `package_id`, and whose version is `version`.
///
/// Note that this is different from looking up the historical version of an object -- the query
Expand All @@ -154,7 +154,7 @@ struct PackageVersionKey {
version: u64,
}

/// DataLoader key for fetching the latest version of a user package: The package with the largest
/// `DataLoader` key for fetching the latest version of a user package: The package with the largest
/// version whose original ID matches the original ID of the package at `address`.
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
struct LatestKey {
Expand Down
10 changes: 5 additions & 5 deletions crates/sui-graphql-rpc/src/types/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ pub(crate) struct AddressOwner {
/// Filter for a point query of an Object.
pub(crate) enum ObjectLookup {
LatestAt {
/// The checkpoint sequence number at which this was viewed at
/// The checkpoint sequence number at which this was viewed at.
checkpoint_viewed_at: u64,
},

UnderParent {
/// The parent version to be used as an upper bound for the query. Look for the latest
/// version of a child object whose version is less than or equal to this upper bound.
parent_version: u64,
/// The checkpoint sequence number at which this was viewed at
/// The checkpoint sequence number at which this was viewed at.
checkpoint_viewed_at: u64,
},

Expand Down Expand Up @@ -280,7 +280,7 @@ pub(crate) enum IObject {
SuinsRegistration(SuinsRegistration),
}

/// DataLoader key for fetching an `Object` at a specific version, constrained by a consistency
/// `DataLoader` key for fetching an `Object` at a specific version, constrained by a consistency
/// cursor (if that version was created after the checkpoint the query is viewing at, then it will
/// fail).
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
Expand All @@ -290,7 +290,7 @@ struct HistoricalKey {
checkpoint_viewed_at: u64,
}

/// DataLoader key for fetching the latest version of an object whose parent object has version
/// `DataLoader` key for fetching the latest version of an object whose parent object has version
/// `parent_version`, as of `checkpoint_viewed_at`. This look-up can fail to find a valid object if
/// the key is not self-consistent, for example if the `parent_version` is set to a higher version
/// than the object's actual parent as of `checkpoint_viewed_at`.
Expand All @@ -301,7 +301,7 @@ struct ParentVersionKey {
checkpoint_viewed_at: u64,
}

/// DataLoader key for fetching the latest version of an `Object` as of a consistency cursor.
/// `DataLoader` key for fetching the latest version of an object as of a given checkpoint.
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
struct LatestAtKey {
id: SuiAddress,
Expand Down
10 changes: 5 additions & 5 deletions crates/sui-graphql-rpc/src/types/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ impl Query {
Object::query(ctx, address, key).await.extend()
}

/// The package corresponding to the given address at the (optionally) given version.
/// 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 may
/// result in a different address than `address` because different versions of a package,
/// 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
Expand Down Expand Up @@ -440,8 +440,8 @@ impl Query {
/// The Move packages that exist in the network, optionally filtered to be strictly before
/// `beforeCheckpoint` and/or strictly after `afterCheckpoint`.
///
/// This query will return all versions of a given user package that appear between the
/// specified checkpoints, but only records the latest versions of system packages.
/// 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.
async fn packages(
&self,
ctx: &Context<'_>,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-graphql-rpc/src/types/transaction_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub(crate) struct TransactionBlockCursor {
pub tx_checkpoint_number: u64,
}

/// DataLoader key for fetching a `TransactionBlock` by its digest, optionally constrained by a
/// `DataLoader` key for fetching a `TransactionBlock` by its digest, optionally constrained by a
/// consistency cursor.
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
struct DigestKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3092,12 +3092,12 @@ type Query {
"""
object(address: SuiAddress!, version: UInt53): Object
"""
The package corresponding to the given address at the (optionally) given version.
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 may
result in a different address than `address` because different versions of a package,
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
Expand Down Expand Up @@ -3160,8 +3160,8 @@ type Query {
The Move packages that exist in the network, optionally filtered to be strictly before
`beforeCheckpoint` and/or strictly after `afterCheckpoint`.

This query will return all versions of a given user package that appear between the
specified checkpoints, but only records the latest versions of system packages.
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!
"""
Expand Down
13 changes: 6 additions & 7 deletions crates/sui-json-rpc-tests/tests/transaction_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,23 @@ async fn test_get_fullnode_transaction() -> Result<(), anyhow::Error> {
assert!(second_page.data.len() > 5);
assert!(!second_page.has_next_page);

let mut all_txs_rev = first_page.data.clone();
all_txs_rev.extend(second_page.data);
all_txs_rev.reverse();
let mut all_txs = first_page.data.clone();
all_txs.extend(second_page.data);

// test get 10 latest transactions paged
// test get 10 transactions paged
let latest = client
.read_api()
.query_transaction_blocks(
SuiTransactionBlockResponseQuery::default(),
None,
Some(10),
true,
false,
)
.await
.unwrap();
assert_eq!(10, latest.data.len());
assert_eq!(Some(all_txs_rev[9].digest), latest.next_cursor);
assert_eq!(all_txs_rev[0..10], latest.data);
assert_eq!(Some(all_txs[9].digest), latest.next_cursor);
assert_eq!(all_txs[0..10], latest.data);
assert!(latest.has_next_page);

// test get from address txs in ascending order
Expand Down
19 changes: 10 additions & 9 deletions crates/sui-package-dump/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ mod query;
/// Ensure all packages created before `before_checkpoint` are written to the `output_dir`ectory,
/// from the GraphQL service at `rpc_url`.
///
/// `output_dir` can be a path to a non-existent directory, in which case it will be created, or an
/// existing empty directory (in which case it will be filled), or an existing directory that has
/// been written to in the past (in which case this invocation will pick back up from where the
/// previous invocation left off).
/// `output_dir` can be a path to a non-existent directory, an existing empty directory, or an
/// existing directory written to in the past. If the path is non-existent, the invocation creates
/// it. If the path exists but is empty, the invocation writes to the directory. If the directory
/// has been written to in the past, the invocation picks back up where the previous invocation
/// left off.
pub async fn dump(
rpc_url: String,
output_dir: PathBuf,
Expand Down Expand Up @@ -116,8 +117,8 @@ async fn max_page_size(client: &Client) -> Result<i32> {
/// Read all the packages between `after_checkpoint` and `before_checkpoint`, in batches of
/// `page_size` from the `client` connected to a GraphQL service.
///
/// If `after_checkpoint` is not provided, packages will be read from genesis. If
/// `before_checkpoint` is not provided, packages will be read until the latest checkpoint.
/// If `after_checkpoint` is not provided, packages are read from genesis. If `before_checkpoint`
/// is not provided, packages are read until the latest checkpoint.
///
/// Returns the latest checkpoint that was read from in this fetch, and a list of all the packages
/// that were read.
Expand Down Expand Up @@ -198,10 +199,10 @@ async fn fetch_packages(
///
/// - `linkage.json` -- a JSON serialization of the package's linkage table, mapping dependency
/// original IDs to the version of the dependency being depended on and the ID of the object
/// on-chain that contains that version.
/// on chain that contains that version.
///
/// - `origins.json` -- a JSON serialize of the type origin table, mapping type names contained in
/// this package to the version of the package that first introduced that type.
/// - `origins.json` -- a JSON serialization of the type origin table, mapping type names contained
/// in this package to the version of the package that first introduced that type.
///
/// - `*.mv` -- a BCS serialization of each compiled module in the package.
fn dump_package(output_dir: &Path, pkg: &packages::MovePackage) -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-tool/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub enum ToolCommand {
},

/// Download all packages to the local filesystem from a GraphQL service. Each package gets its
/// own sub-directory, named for its ID on-chain and version containing two metadata files
/// own sub-directory, named for its ID on chain and version containing two metadata files
/// (linkage.json and origins.json), a file containing the overall object and a file for every
/// module it contains. Each module file is named for its module name, with a .mv suffix, and
/// contains Move bytecode (suitable for passing into a disassembler).
Expand Down
Loading