ChainSafe / ChainSafe/open-creator-rails.unity

Add GetActiveSubscriptions and GetExpiringSubscriptions to IIndexerProvider

Open
#41 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**What**

Add two new methods to `IIndexerProvider` (and implemented in `PonderIndexerProvider`) to query filtered subscription lists directly from the Ponder indexer:

```csharp
UniTask GetActiveSubscriptions(string assetIdHash, EthereumAddress registryAddress);
UniTask GetExpiringSubscriptions(string assetIdHash, EthereumAddress registryAddress, TimeSpan expiresIn);
```

**Why**

Currently `GetAsset` returns all subscriptions unfiltered and callers must manually filter by `IsActive`. These dedicated methods:
- Allow purpose-built, indexer-side filtering — more efficient and scalable.
- `GetExpiringSubscriptions` requires a time-window check (`endTime < now + expiresIn`) that can be expressed as a GraphQL `where` clause, avoiding fetching the full subscription list just to filter client-side.
- Enables use cases like expiry notifications or dashboards showing only live subscribers.

**How**

1. Add both method signatures to `IIndexerProvider`.
2. Implement dedicated GraphQL queries in `PonderIndexerProvider`:
- `GetActiveSubscriptions`: filter `where: { isActive: true }` under the asset's subscriptions.
- `GetExpiringSubscriptions`: filter `where: { isActive: true, endTime_lte: \ }` — returns active subscriptions whose `endTime` falls within the given `TimeSpan` from now.
3. Both methods return `SubscriptionDto[]` (same DTO already used by `GetAsset`).
4. Add integration tests in `PonderIndexerProviderTests` covering:
- `GetActiveSubscriptions` returns only active subscriptions.
- `GetExpiringSubscriptions` returns only active subscriptions expiring within the window.
- Edge cases: no active subscriptions, window of zero, expired/revoked records excluded.

**Acceptance Criteria**

- [ ] `IIndexerProvider` declares both new methods.
- [ ] `PonderIndexerProvider` implements both with indexer-side GraphQL filtering (not client-side).
- [ ] `GetExpiringSubscriptions` only returns subscriptions that are currently active (`isActive=true`) AND whose `endTime` is within `now + expiresIn`.
- [ ] Unit/integration tests pass for both methods.
- [ ] No changes required to `IAsset` or `Asset` (out of scope).

**Estimation**

3

**Dependencies**

None. The Ponder indexer already exposes `isActive`, `endTime`, `isExpired`, and `isRevoked` fields per the existing `GetAsset` GraphQL query.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with IIndexerProvider and its PonderIndexerProvider implementation, then inspect the existing GetAsset GraphQL query and SubscriptionDto usage. Add the two filtered provider methods and integration coverage in PonderIndexerProviderTests, including empty, zero-window, expired, and revoked cases. Done means indexer-side filtering returns only active subscriptions and tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, graphql, unity
Domain
api, backend-api-design, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.