ActivityClient
ActivityClient is a virtual view over all threads a wallet has participated in. It queries Light Protocol's compressed account index — no separate on-chain account needs to be created.
Access it via client.activity():
const activity = client.activity();
await activity.load();
const threads = await activity.loadThreads({ limit: 20 });
Static Methods
ActivityClient.Load({ client, owner? })
Loads compressed thread accounts for the given owner.
const activity = await ActivityClient.Load({
client,
owner: wallet.publicKey, // defaults to connected wallet
});
Returns Promise<ActivityClient>
Instance Methods
activity.load(options?)
Fetches compressed thread accounts from the index. Safe to call multiple times — subsequent calls are incremental by default.
await activity.load();
| Field | Type | Default | Description |
|---|---|---|---|
pageLimit | number | 100 | Compressed accounts per RPC page |
maxPages | number | unlimited | Stop after this many RPC pages |
incremental | boolean | false | Continue from last cursor instead of rebuilding |
Returns Promise<this>
activity.refresh(options?)
Re-fetches thread accounts. Use incremental: true to append new results, or clearPages: true to start over.
// Pick up new threads since last load
await activity.refresh({ incremental: true });
// Full reload
await activity.refresh({ clearPages: true });
Returns Promise<this>
activity.loadThreads(options?)
Returns ThreadClient instances for all tracked threads, sorted by recency. Fetches from the index if not already loaded.
const threads = await activity.loadThreads({
limit: 30,
includeLastMessage: true,
});
| Field | Type | Description |
|---|---|---|
offset | number | Skip the first N results |
limit | number | Max threads to return |
includeLastMessage | boolean | Also load the last message for each thread |
concurrentFetchLimit | number | Max parallel thread fetches (default 10) |
concurrentMessageFetchLimit | number | Max parallel last-message fetches (default 10) |
pageLimit | number | Compressed accounts per RPC page |
maxPages | number | Max RPC pages to walk |
incremental | boolean | Append new results instead of reloading |
inbox | Inbox | InboxClient | Shared inbox to attach to all returned threads |
Returns Promise<ThreadClient[]>
activity.loadThreadsAcrossHistory(options)
Loads a bounded history of threads, walking back through multiple RPC pages until the limit is met.
const threads = await activity.loadThreadsAcrossHistory({
limit: 50,
includeLastMessage: true,
maxPages: 5,
});
| Field | Type | Description |
|---|---|---|
limit | number | Target thread count |
includeLastMessage | boolean | Pre-load last message |
maxPages | number | Max RPC pages (default 5) |
pageLimit | number | Compressed accounts per page |
concurrentFetchLimit | number | Parallel thread fetches |
concurrentMessageFetchLimit | number | Parallel message fetches |
Returns Promise<ThreadClient[]>
activity.exists()
Returns true if the wallet has any threads.
if (await activity.exists()) {
const threads = await activity.loadThreads({ limit: 20 });
}
Returns Promise<boolean>
activity.getThreadAccounts(options?)
Returns raw decoded thread account data without creating ThreadClient instances. Useful for lightweight reads.
| Field | Type | Description |
|---|---|---|
offset | number | Skip the first N results |
limit | number | Max accounts to return |
Returns DecodedThreadAccount[]
Properties
| Property | Type | Description |
|---|---|---|
owner | PublicKey | The wallet this activity belongs to |
len | number | Number of unique threads currently in the local index |
cursorsState | ActivityCursorState | Current RPC pagination cursors (for incremental loads) |
ActivityCursorState
type ActivityCursorState = {
from?: string;
to?: string;
};
Tracks cursor positions for the two scan directions (from and to). Used internally for incremental loading.