Skip to content

Commit

Permalink
docs(graphql): [easy] document transaction, event filters
Browse files Browse the repository at this point in the history
## Description

Document the various filter options for transactions and events (and
tweak the docs for object filters slightly).

## Test plan

:eyes:
  • Loading branch information
amnn committed Sep 13, 2024
1 parent 5c5d6ce commit 5bff902
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 20 deletions.
41 changes: 36 additions & 5 deletions crates/sui-graphql-rpc/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,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
Expand Down Expand Up @@ -2836,11 +2842,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>`.
Expand Down Expand Up @@ -4288,18 +4291,46 @@ 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 signed by the given address.
"""
signAddress: 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!]
}

Expand Down
10 changes: 5 additions & 5 deletions crates/sui-graphql-rpc/src/types/event/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ use async_graphql::*;

#[derive(InputObject, Clone, Default)]
pub(crate) struct EventFilter {
/// Filter down to events from transactions sent by this address.
pub sender: Option<SuiAddress>,

/// Filter down to the events from this transaction (given by its transaction digest).
pub transaction_digest: Option<Digest>,

// Enhancement (post-MVP)
// after_checkpoint
// at_checkpoint
// before_checkpoint
/// Events emitted by a particular module. An event is emitted by a
/// particular module if some function in the module is called by a
Expand All @@ -36,9 +41,4 @@ pub(crate) struct EventFilter {
// Enhancement (post-MVP)
// pub start_time
// pub end_time

// Enhancement (post-MVP)
// pub any
// pub all
// pub not
}
7 changes: 2 additions & 5 deletions crates/sui-graphql-rpc/src/types/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,8 @@ pub(crate) struct ObjectRef {
/// - AND, whose ID is in `objectIds` OR whose ID and version is in `objectKeys`.
#[derive(InputObject, Default, Debug, Clone, Eq, PartialEq)]
pub(crate) struct 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>`.
Expand Down
15 changes: 15 additions & 0 deletions crates/sui-graphql-rpc/src/types/transaction_block/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,35 @@ use sui_types::base_types::SuiAddress as NativeSuiAddress;

#[derive(InputObject, Debug, Default, Clone)]
pub(crate) struct TransactionBlockFilter {
/// Filter transactions by move function called. Calls can be filtered by the `package`,
/// `package::module`, or the `package::module::name` of their function.
pub function: Option<FqNameFilter>,

/// An input filter selecting for either system or programmable transactions.
pub kind: Option<TransactionBlockKindInput>,

/// Limit to transactions that occured strictly after the given checkpoint.
pub after_checkpoint: Option<UInt53>,

/// Limit to transactions in the given checkpoint.
pub at_checkpoint: Option<UInt53>,

/// Limit to transaction that occured strictly before the given checkpoint.
pub before_checkpoint: Option<UInt53>,

/// Limit to transactions that were signed by the given address.
pub sign_address: Option<SuiAddress>,

/// Limit to transactions that sent an object to the given address.
pub recv_address: Option<SuiAddress>,

/// Limit to transactions that accepted the given object as an input.
pub input_object: Option<SuiAddress>,

/// Limit to transactions that output a versioon of this object.
pub changed_object: Option<SuiAddress>,

/// Select transactions by their digest.
pub transaction_ids: Option<Vec<Digest>>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,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
Expand Down Expand Up @@ -2840,11 +2846,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>`.
Expand Down Expand Up @@ -4292,18 +4295,46 @@ 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 signed by the given address.
"""
signAddress: 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!]
}
Expand Down

0 comments on commit 5bff902

Please sign in to comment.