Skip to content

Commit

Permalink
pick(19708): graphql: unstage affected_addresses (#19809)
Browse files Browse the repository at this point in the history
## Description

Ungate access to the parts of the GraphQL schema that depend on
`tx_affected_addresses` as this has now been fully rolled out in the
indexer

## Test plan

```
sui$ cargo nextest run -p sui-graphql-rpc
sui$ cargo nextest run -p sui-graphql-e2e-tests
```

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: Adds support for
`TransactionBlockFilter.affectedAddress`, and
`AddressTransactionBlockRelationship.AFFECTED` to find transactions
associated with any address they touch (sender, recipient, or payer).
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
amnn authored Oct 10, 2024
1 parent ad41ab4 commit 44dc614
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 12 deletions.
10 changes: 10 additions & 0 deletions crates/sui-graphql-rpc/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ enum AddressTransactionBlockRelationship {
`AFFECTED` is introduced, whichever is later.
"""
RECV
"""
Transactions that this address was involved in, either as the sender, sponsor, or as the
owner of some object that was created, modified or transfered.
"""
AFFECTED
}

"""
Expand Down Expand Up @@ -4326,6 +4331,11 @@ input TransactionBlockFilter {
"""
beforeCheckpoint: UInt53
"""
Limit to transactions that interacted with the given address. The address could be a
sender, sponsor, or recipient of the transaction.
"""
affectedAddress: SuiAddress
"""
Limit to transactions that were sent by the given address. NOTE: this input filter has been
deprecated in favor of `sentAddress` which behaves identically but is named more clearly.
Both filters restrict transactions by their sender, only, not signers in general.
Expand Down
2 changes: 0 additions & 2 deletions crates/sui-graphql-rpc/src/types/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub(crate) enum AddressTransactionBlockRelationship {
Recv,
/// Transactions that this address was involved in, either as the sender, sponsor, or as the
/// owner of some object that was created, modified or transfered.
#[cfg(feature = "staging")]
Affected,
}

Expand Down Expand Up @@ -196,7 +195,6 @@ impl Address {
..Default::default()
},

#[cfg(feature = "staging")]
Some(R::Affected) => TransactionBlockFilter {
affected_address: Some(self.address),
..Default::default()
Expand Down
12 changes: 4 additions & 8 deletions crates/sui-graphql-rpc/src/types/transaction_block/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub(crate) struct TransactionBlockFilter {

/// Limit to transactions that interacted with the given address. The address could be a
/// sender, sponsor, or recipient of the transaction.
#[cfg(feature = "staging")]
pub affected_address: Option<SuiAddress>,

/// Limit to transactions that interacted with the given object. The object could have been
Expand Down Expand Up @@ -94,7 +93,6 @@ impl TransactionBlockFilter {
at_checkpoint: intersect!(at_checkpoint, intersect::by_eq)?,
before_checkpoint: intersect!(before_checkpoint, intersect::by_min)?,

#[cfg(feature = "staging")]
affected_address: intersect!(affected_address, intersect::by_eq)?,
#[cfg(feature = "staging")]
affected_object: intersect!(affected_object, intersect::by_eq)?,
Expand All @@ -119,7 +117,6 @@ impl TransactionBlockFilter {
[
self.function.is_some(),
self.kind.is_some(),
#[cfg(feature = "staging")]
self.affected_address.is_some(),
#[cfg(feature = "staging")]
self.affected_object.is_some(),
Expand All @@ -140,14 +137,13 @@ impl TransactionBlockFilter {
pub(crate) fn explicit_sender(&self) -> Option<SuiAddress> {
let missing_implicit_sender = self.function.is_none()
&& self.kind.is_none()
&& self.affected_address.is_none()
&& self.recv_address.is_none()
&& self.input_object.is_none()
&& self.changed_object.is_none();

#[cfg(feature = "staging")]
let missing_implicit_sender = missing_implicit_sender
&& self.affected_address.is_none()
&& self.affected_object.is_none();
let missing_implicit_sender = missing_implicit_sender && self.affected_object.is_none();

missing_implicit_sender
.then_some(self.sent_address.or(self.sign_address))
Expand All @@ -162,13 +158,13 @@ impl TransactionBlockFilter {
|| self.sign_address.is_some()
|| self.sent_address.is_some()
|| self.recv_address.is_some()
|| self.affected_address.is_some()
|| self.input_object.is_some()
|| self.changed_object.is_some()
|| self.transaction_ids.is_some();

#[cfg(feature = "staging")]
let has_filters =
has_filters || self.affected_address.is_some() || self.affected_object.is_some();
let has_filters = has_filters || self.affected_object.is_some();

has_filters
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ pub(crate) fn subqueries(filter: &TransactionBlockFilter, tx_bounds: TxBounds) -
subqueries.push(("tx_kinds", select_kind(*kind, sender, tx_bounds)));
}

#[cfg(feature = "staging")]
if let Some(affected) = &filter.affected_address {
subqueries.push((
"tx_affected_addresses",
Expand Down Expand Up @@ -463,7 +462,6 @@ fn select_kind(
}
}

#[cfg(feature = "staging")]
fn select_affected_address(
affected: &SuiAddress,
sender: Option<SuiAddress>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ enum AddressTransactionBlockRelationship {
`AFFECTED` is introduced, whichever is later.
"""
RECV
"""
Transactions that this address was involved in, either as the sender, sponsor, or as the
owner of some object that was created, modified or transfered.
"""
AFFECTED
}

"""
Expand Down Expand Up @@ -4330,6 +4335,11 @@ input TransactionBlockFilter {
"""
beforeCheckpoint: UInt53
"""
Limit to transactions that interacted with the given address. The address could be a
sender, sponsor, or recipient of the transaction.
"""
affectedAddress: SuiAddress
"""
Limit to transactions that were sent by the given address. NOTE: this input filter has been
deprecated in favor of `sentAddress` which behaves identically but is named more clearly.
Both filters restrict transactions by their sender, only, not signers in general.
Expand Down

0 comments on commit 44dc614

Please sign in to comment.