Skip to content

Commit 8dcf2c0

Browse files
feat(synapse-sdk): expose paginated client dataset methods in WarmStorageService
1 parent cecc516 commit 8dcf2c0

1 file changed

Lines changed: 36 additions & 7 deletions

File tree

packages/synapse-sdk/src/warm-storage/service.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import {
2828
getAllDataSetMetadataCall,
2929
getAllPieceMetadata,
3030
getApprovedProviderIds,
31+
getClientDataSetIds,
3132
getClientDataSets,
33+
getClientDataSetsLength,
3234
getDataSet,
3335
getServicePrice,
3436
removeApprovedProvider,
@@ -106,13 +108,41 @@ export class WarmStorageService {
106108
* Get all data sets for a specific client
107109
* @param options - Options for the client data sets
108110
* @param options.address - The client address
111+
* @param options.offset - Starting index (0-based). Use 0 to start from beginning.
112+
* @param options.limit - Maximum number of data sets to return. Use 0 to get all remaining.
109113
* @returns Array of data set information {@link getClientDataSets.OutputType}
110114
* @throws Errors {@link getClientDataSets.ErrorType}
111115
*/
112-
async getClientDataSets(options: { address: Address }): Promise<getClientDataSets.OutputType> {
116+
async getClientDataSets(options: {
117+
address: Address
118+
offset?: bigint
119+
limit?: bigint
120+
}): Promise<getClientDataSets.OutputType> {
113121
return getClientDataSets(this._client, options)
114122
}
115123

124+
/**
125+
* Get total count of data sets for a specific client
126+
* @param options - Options for the client data sets length
127+
* @param options.address - The client address
128+
* @returns Total count of data sets
129+
*/
130+
async getClientDataSetsLength(options: { address: Address }): Promise<bigint> {
131+
return getClientDataSetsLength(this._client, options)
132+
}
133+
134+
/**
135+
* Get data set IDs for a specific client with optional pagination
136+
* @param options - Options for the client data set IDs
137+
* @param options.address - The client address
138+
* @param options.offset - Starting index (0-based). Use 0 to start from beginning.
139+
* @param options.limit - Maximum number of IDs to return. Use 0 to get all remaining.
140+
* @returns Array of data set IDs
141+
*/
142+
async getClientDataSetIds(options: { address: Address; offset?: bigint; limit?: bigint }): Promise<bigint[]> {
143+
return getClientDataSetIds(this._client, options)
144+
}
145+
116146
/**
117147
* Get all data sets for a client with enhanced details
118148
* This includes live status and management information
@@ -126,12 +156,11 @@ export class WarmStorageService {
126156
onlyManaged?: boolean
127157
}): Promise<EnhancedDataSetInfo[]> {
128158
const { address = this._client.account.address, onlyManaged = false } = options
129-
// Query dataset IDs directly from the view contract
130-
const ids = await readContract(this._client, {
131-
address: this._chain.contracts.fwssView.address,
132-
abi: this._chain.contracts.fwssView.abi,
133-
functionName: 'clientDataSets',
134-
args: [address],
159+
// Query dataset IDs (offset=0, limit=0 fetches all)
160+
const ids = await getClientDataSetIds(this._client, {
161+
address,
162+
offset: 0n,
163+
limit: 0n,
135164
})
136165
if (ids.length === 0) return []
137166

0 commit comments

Comments
 (0)