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

[GraphQL/MovePackage] Query for latest version #17693

Merged
merged 1 commit into from
Aug 19, 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
147 changes: 136 additions & 11 deletions crates/sui-graphql-e2e-tests/tests/packages/versioning.exp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
processed 9 tasks
processed 14 tasks

init:
A: object(0,0)
Expand All @@ -9,23 +9,97 @@ created: object(1,0), object(1,1)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 5076800, storage_rebate: 0, non_refundable_storage_fee: 0

task 2, lines 11-15:
task 2, line 11:
//# create-checkpoint
Checkpoint created: 1

task 3, lines 13-21:
//# run-graphql
Response: {
"data": {
"latestPackage": {
"version": 1,
"module": {
"functions": {
"nodes": [
{
"name": "f"
}
]
}
}
}
}
}

task 4, lines 23-27:
//# upgrade --package P0 --upgrade-capability 1,1 --sender A
created: object(2,0)
created: object(4,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5251600, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 3, lines 17-22:
task 5, line 29:
//# create-checkpoint
Checkpoint created: 2

task 6, lines 31-39:
//# run-graphql
Response: {
"data": {
"latestPackage": {
"version": 2,
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
}
]
}
}
}
}
}

task 7, lines 41-46:
//# upgrade --package P1 --upgrade-capability 1,1 --sender A
created: object(3,0)
created: object(7,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 5426400, storage_rebate: 2595780, non_refundable_storage_fee: 26220

task 4, line 24:
task 8, line 48:
//# create-checkpoint
Checkpoint created: 1
Checkpoint created: 3

task 5, lines 26-45:
task 9, lines 50-58:
//# run-graphql
Response: {
"data": {
"latestPackage": {
"version": 3,
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
}
}
}

task 10, lines 60-97:
//# run-graphql
Response: {
"data": {
Expand All @@ -38,6 +112,23 @@ Response: {
}
]
}
},
"latestPackage": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
}
},
"v2": {
Expand All @@ -52,6 +143,23 @@ Response: {
}
]
}
},
"latestPackage": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
}
},
"v3": {
Expand All @@ -69,12 +177,29 @@ Response: {
}
]
}
},
"latestPackage": {
"module": {
"functions": {
"nodes": [
{
"name": "f"
},
{
"name": "g"
},
{
"name": "h"
}
]
}
}
}
}
}
}

task 6, lines 47-84:
task 11, lines 99-136:
//# run-graphql
Response: {
"data": {
Expand Down Expand Up @@ -165,7 +290,7 @@ Response: {
}
}

task 7, lines 86-141:
task 12, lines 138-193:
//# run-graphql
Response: {
"data": {
Expand Down Expand Up @@ -304,7 +429,7 @@ Response: {
}
}

task 8, lines 143-171:
task 13, lines 195-223:
//# run-graphql
Response: {
"data": {
Expand Down
52 changes: 52 additions & 0 deletions crates/sui-graphql-e2e-tests/tests/packages/versioning.move
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,36 @@ module P0::m {
public fun f(): u64 { 42 }
}

//# create-checkpoint

//# run-graphql
{
latestPackage(address: "@{P0}") {
version
module(name: "m") {
functions { nodes { name } }
}
}
}

//# upgrade --package P0 --upgrade-capability 1,1 --sender A
module P1::m {
public fun f(): u64 { 42 }
public fun g(): u64 { 43 }
}

//# create-checkpoint

//# run-graphql
{
latestPackage(address: "@{P0}") {
version
module(name: "m") {
functions { nodes { name } }
}
}
}

//# upgrade --package P1 --upgrade-capability 1,1 --sender A
module P2::m {
public fun f(): u64 { 42 }
Expand All @@ -23,24 +47,52 @@ module P2::m {

//# create-checkpoint

//# run-graphql
{
latestPackage(address: "@{P0}") {
version
module(name: "m") {
functions { nodes { name } }
}
}
}

//# run-graphql
{ # Test fetching by ID
v1: package(address: "@{P0}") {
module(name: "m") {
functions { nodes { name } }
}

latestPackage {
module(name: "m") {
functions { nodes { name } }
}
}
}

v2: package(address: "@{P1}") {
module(name: "m") {
functions { nodes { name } }
}

latestPackage {
module(name: "m") {
functions { nodes { name } }
}
}
}

v3: package(address: "@{P2}") {
module(name: "m") {
functions { nodes { name } }
}

latestPackage {
module(name: "m") {
functions { nodes { name } }
}
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions crates/sui-graphql-rpc/schema/current_progress_schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,11 @@ type MovePackage implements IObject & IOwner {
"""
packageAtVersion(version: Int!): MovePackage
"""
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.
"""
Expand Down Expand Up @@ -3058,6 +3063,13 @@ type 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
Expand Down
Loading
Loading