Skip to content

Commit

Permalink
[GraphQL][EASY] Remove MovePackage.checkpoint_viewed_at
Browse files Browse the repository at this point in the history
## Description

The same data is available as
`MovePackage.super_.checkpoint_viewed_at` and has been exposed as
`MovePackage.checkpoint_viewed_at_impl()`.

## Test plan

```
sui$ cargo nextest run -p sui-graphql-e2e-tests --features pg_integration
```
  • Loading branch information
amnn committed May 13, 2024
1 parent a7f0bf8 commit 9a57f4f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions crates/sui-graphql-rpc/src/types/move_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ pub(crate) struct MovePackage {
/// Move-object-specific data, extracted from the native representation at
/// `graphql_object.native_object.data`.
pub native: NativeMovePackage,

/// The checkpoint sequence number this package was viewed at.
pub checkpoint_viewed_at: u64,
}

/// Information used by a package to link to a specific version of its dependency.
Expand Down Expand Up @@ -276,7 +273,8 @@ impl MovePackage {

let page = Page::from_params(ctx.data_unchecked(), first, after, last, before)?;
let cursor_viewed_at = page.validate_cursor_consistency()?;
let checkpoint_viewed_at = cursor_viewed_at.unwrap_or(self.checkpoint_viewed_at);
let checkpoint_viewed_at =
cursor_viewed_at.unwrap_or_else(|| self.checkpoint_viewed_at_impl());

let parsed = self.parsed_package()?;
let module_range = parsed.modules().range::<String, _>((
Expand Down Expand Up @@ -391,6 +389,12 @@ impl MovePackage {
.map_err(|e| Error::Internal(format!("Error reading package: {e}")))
}

/// This package was viewed at a snapshot of the chain state at this checkpoint (identified by
/// its sequence number).
fn checkpoint_viewed_at_impl(&self) -> u64 {
self.super_.checkpoint_viewed_at
}

pub(crate) fn module_impl(&self, name: &str) -> Result<Option<MoveModule>, Error> {
use PackageCacheError as E;
match (
Expand All @@ -401,7 +405,7 @@ impl MovePackage {
storage_id: self.super_.address,
native: native.clone(),
parsed: parsed.clone(),
checkpoint_viewed_at: self.checkpoint_viewed_at,
checkpoint_viewed_at: self.checkpoint_viewed_at_impl(),
})),

(None, _) | (_, Err(E::ModuleNotFound(_, _))) => Ok(None),
Expand Down Expand Up @@ -438,7 +442,6 @@ impl TryFrom<&Object> for MovePackage {
Ok(Self {
super_: object.clone(),
native: move_package.clone(),
checkpoint_viewed_at: object.checkpoint_viewed_at,
})
} else {
Err(MovePackageDowncastError)
Expand Down

0 comments on commit 9a57f4f

Please sign in to comment.