-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create event module, split out cursor into ev_cursor, lift bytea into…
… respective types rename ev_cursor to just cursor use bytea_literal in pg module instead of individually in digest and sui_address logic for constructing the raw query, which is a single roundtrip consisting of multiple ctes to determine the tx and ev range i think its working? time for some tests and cleanup introduce new cte field to RawQuery remove unused code for now, fetch checkpoint_viewed_at's tx upper split things out so hopefully its easier to review and makes more sense compartmentalized like this? tx digest - test digest no events, and then digest with events test base case of no filter also works
- Loading branch information
Showing
11 changed files
with
928 additions
and
253 deletions.
There are no files selected for viewing
249 changes: 249 additions & 0 deletions
249
crates/sui-graphql-e2e-tests/tests/event_connection/no_filter.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,249 @@ | ||
processed 6 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 6-25: | ||
created: object(1,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 4970400, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'run'. lines 27-27: | ||
events: Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [0, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [1, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [2, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [3, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [4, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [5, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [6, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [7, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [8, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [9, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [10, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [11, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [12, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [13, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [14, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [15, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [16, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [17, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [18, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [19, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [20, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [21, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [22, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [23, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [24, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [25, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [26, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [27, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [28, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [29, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [30, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [31, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [32, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [33, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [34, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [35, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [36, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [37, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [38, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [39, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [40, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [41, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [42, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [43, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [44, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [45, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [46, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [47, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [48, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [49, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [50, 0, 0, 0, 0, 0, 0, 0] } | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 3 'create-checkpoint'. lines 29-29: | ||
Checkpoint created: 1 | ||
|
||
task 4 'run-graphql'. lines 31-44: | ||
Response: { | ||
"data": { | ||
"events": { | ||
"pageInfo": { | ||
"hasPreviousPage": false, | ||
"hasNextPage": true, | ||
"startCursor": "eyJ0eCI6MiwiZSI6MCwiYyI6MX0", | ||
"endCursor": "eyJ0eCI6MiwiZSI6MTksImMiOjF9" | ||
}, | ||
"nodes": [ | ||
{ | ||
"json": { | ||
"new_value": "0" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "1" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "2" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "3" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "4" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "5" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "6" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "7" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "8" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "9" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "10" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "11" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "12" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "13" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "14" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "15" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "16" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "17" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "18" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "19" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
task 5 'run-graphql'. lines 46-59: | ||
Response: { | ||
"data": { | ||
"events": { | ||
"pageInfo": { | ||
"hasPreviousPage": true, | ||
"hasNextPage": true, | ||
"startCursor": "eyJ0eCI6MiwiZSI6MjAsImMiOjF9", | ||
"endCursor": "eyJ0eCI6MiwiZSI6MzksImMiOjF9" | ||
}, | ||
"nodes": [ | ||
{ | ||
"json": { | ||
"new_value": "20" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "21" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "22" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "23" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "24" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "25" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "26" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "27" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "28" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "29" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "30" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "31" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "32" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "33" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "34" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "35" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "36" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "37" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "38" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "39" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
crates/sui-graphql-e2e-tests/tests/event_connection/no_filter.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --protocol-version 48 --addresses Test=0x0 --accounts A --simulator | ||
|
||
//# publish | ||
module Test::M1 { | ||
use sui::event; | ||
|
||
public struct EventA has copy, drop { | ||
new_value: u64 | ||
} | ||
|
||
public entry fun no_emit(value: u64): u64 { | ||
value | ||
} | ||
|
||
public entry fun emit(value: u64) { | ||
let mut i = 0; | ||
while (i < 51) { | ||
event::emit(EventA { new_value: value + i }); | ||
i = i + 1; | ||
} | ||
} | ||
} | ||
|
||
//# run Test::M1::emit --sender A --args 0 | ||
|
||
//# create-checkpoint | ||
|
||
//# run-graphql | ||
{ | ||
events { | ||
pageInfo { | ||
hasPreviousPage | ||
hasNextPage | ||
startCursor | ||
endCursor | ||
} | ||
nodes { | ||
json | ||
} | ||
} | ||
} | ||
|
||
//# run-graphql --cursors {"tx":2,"e":19,"c":1} | ||
{ | ||
events(after: "@{cursor_0}") { | ||
pageInfo { | ||
hasPreviousPage | ||
hasNextPage | ||
startCursor | ||
endCursor | ||
} | ||
nodes { | ||
json | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
crates/sui-graphql-e2e-tests/tests/event_connection/tx_digest.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
processed 8 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 10-26: | ||
created: object(1,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 4795600, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'run'. lines 28-28: | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 3 'run'. lines 30-30: | ||
events: Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [2, 0, 0, 0, 0, 0, 0, 0] }, Event { package_id: Test, transaction_module: Identifier("M1"), sender: A, type_: StructTag { address: Test, module: Identifier("M1"), name: Identifier("EventA"), type_params: [] }, contents: [3, 0, 0, 0, 0, 0, 0, 0] } | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 4 'create-checkpoint'. lines 32-32: | ||
Checkpoint created: 1 | ||
|
||
task 5 'run-graphql'. lines 34-41: | ||
Response: { | ||
"data": { | ||
"transactionBlocks": { | ||
"nodes": [ | ||
{ | ||
"digest": "4U25VGAB2VkWrQVcYHmhcJ1auBMoR6wGJ1XkAVWThvRR" | ||
}, | ||
{ | ||
"digest": "8f5zsvxPTNvfW9HoQReViqMC8aWKfwQvP2UFt2uWxQs3" | ||
}, | ||
{ | ||
"digest": "5qVugAqZ6ANMTadHevvJaUyU2c65paKm1n6UGCJHTAbD" | ||
}, | ||
{ | ||
"digest": "Ar4ascrErFfQAEPEcNxhMfJok8FvkhSocVjPBm9vUQa2" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
task 6 'run-graphql'. lines 43-50: | ||
Response: { | ||
"data": { | ||
"events": { | ||
"nodes": [] | ||
} | ||
} | ||
} | ||
|
||
task 7 'run-graphql'. lines 52-59: | ||
Response: { | ||
"data": { | ||
"events": { | ||
"nodes": [ | ||
{ | ||
"json": { | ||
"new_value": "2" | ||
} | ||
}, | ||
{ | ||
"json": { | ||
"new_value": "3" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.