@opendatalabs/vana-sdk 0.1.0-alpha.f2de4f7 → 0.1.0-alpha.f35bb9c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/dist/browser.cjs.map +1 -1
  2. package/dist/browser.d.ts +33 -1
  3. package/dist/browser.js.map +1 -1
  4. package/dist/chains/index.cjs.map +1 -1
  5. package/dist/chains/index.d.ts +30 -1
  6. package/dist/chains/index.js.map +1 -1
  7. package/dist/config/chains.cjs.map +1 -1
  8. package/dist/config/chains.d.ts +99 -0
  9. package/dist/config/chains.js.map +1 -1
  10. package/dist/contracts/contractController.cjs.map +1 -1
  11. package/dist/contracts/contractController.d.ts +66 -10
  12. package/dist/contracts/contractController.js.map +1 -1
  13. package/dist/controllers/data.cjs +173 -141
  14. package/dist/controllers/data.cjs.map +1 -1
  15. package/dist/controllers/data.d.ts +213 -175
  16. package/dist/controllers/data.js +173 -141
  17. package/dist/controllers/data.js.map +1 -1
  18. package/dist/controllers/permissions.cjs +185 -191
  19. package/dist/controllers/permissions.cjs.map +1 -1
  20. package/dist/controllers/permissions.d.ts +29 -73
  21. package/dist/controllers/permissions.js +185 -191
  22. package/dist/controllers/permissions.js.map +1 -1
  23. package/dist/controllers/protocol.cjs.map +1 -1
  24. package/dist/controllers/protocol.d.ts +27 -28
  25. package/dist/controllers/protocol.js.map +1 -1
  26. package/dist/controllers/schemas.cjs +23 -21
  27. package/dist/controllers/schemas.cjs.map +1 -1
  28. package/dist/controllers/schemas.d.ts +47 -40
  29. package/dist/controllers/schemas.js +23 -21
  30. package/dist/controllers/schemas.js.map +1 -1
  31. package/dist/controllers/server.cjs +17 -15
  32. package/dist/controllers/server.cjs.map +1 -1
  33. package/dist/controllers/server.d.ts +46 -38
  34. package/dist/controllers/server.js +17 -15
  35. package/dist/controllers/server.js.map +1 -1
  36. package/dist/core/apiClient.cjs +53 -3
  37. package/dist/core/apiClient.cjs.map +1 -1
  38. package/dist/core/apiClient.d.ts +132 -7
  39. package/dist/core/apiClient.js +53 -3
  40. package/dist/core/apiClient.js.map +1 -1
  41. package/dist/core/generics.cjs +30 -3
  42. package/dist/core/generics.cjs.map +1 -1
  43. package/dist/core/generics.d.ts +95 -6
  44. package/dist/core/generics.js +30 -3
  45. package/dist/core/generics.js.map +1 -1
  46. package/dist/core.cjs +29 -12
  47. package/dist/core.cjs.map +1 -1
  48. package/dist/core.d.ts +2 -1
  49. package/dist/core.js +29 -12
  50. package/dist/core.js.map +1 -1
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/index.node.cjs +3 -3
  54. package/dist/index.node.cjs.map +1 -1
  55. package/dist/index.node.d.ts +8 -9
  56. package/dist/index.node.js +2 -2
  57. package/dist/index.node.js.map +1 -1
  58. package/dist/node.cjs.map +1 -1
  59. package/dist/node.d.ts +39 -1
  60. package/dist/node.js.map +1 -1
  61. package/dist/platform/browser.cjs +160 -2
  62. package/dist/platform/browser.cjs.map +1 -1
  63. package/dist/platform/browser.d.ts +232 -12
  64. package/dist/platform/browser.js +160 -2
  65. package/dist/platform/browser.js.map +1 -1
  66. package/dist/platform/interface.cjs.map +1 -1
  67. package/dist/platform/interface.d.ts +283 -90
  68. package/dist/platform/node.cjs +163 -2
  69. package/dist/platform/node.cjs.map +1 -1
  70. package/dist/platform/node.d.ts +69 -6
  71. package/dist/platform/node.js +163 -2
  72. package/dist/platform/node.js.map +1 -1
  73. package/dist/server/relayerHandler.cjs +214 -0
  74. package/dist/server/relayerHandler.cjs.map +1 -0
  75. package/dist/server/relayerHandler.d.ts +36 -0
  76. package/dist/server/relayerHandler.js +190 -0
  77. package/dist/server/relayerHandler.js.map +1 -0
  78. package/dist/storage/manager.cjs +108 -25
  79. package/dist/storage/manager.cjs.map +1 -1
  80. package/dist/storage/manager.d.ts +119 -25
  81. package/dist/storage/manager.js +108 -25
  82. package/dist/storage/manager.js.map +1 -1
  83. package/dist/storage/providers/callback-storage.cjs +86 -15
  84. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  85. package/dist/storage/providers/callback-storage.d.ts +109 -20
  86. package/dist/storage/providers/callback-storage.js +86 -15
  87. package/dist/storage/providers/callback-storage.js.map +1 -1
  88. package/dist/storage/providers/pinata.cjs.map +1 -1
  89. package/dist/storage/providers/pinata.d.ts +12 -14
  90. package/dist/storage/providers/pinata.js.map +1 -1
  91. package/dist/tests/factories/mockFactory.d.ts +2 -2
  92. package/dist/tests/relayer-integration.test.d.ts +1 -0
  93. package/dist/tests/relayer-unified.test.d.ts +1 -0
  94. package/dist/tests/server-relayer-handler.test.d.ts +1 -0
  95. package/dist/types/blockchain.cjs.map +1 -1
  96. package/dist/types/blockchain.d.ts +39 -11
  97. package/dist/types/chains.cjs.map +1 -1
  98. package/dist/types/chains.d.ts +74 -7
  99. package/dist/types/chains.js.map +1 -1
  100. package/dist/types/config.cjs.map +1 -1
  101. package/dist/types/config.d.ts +46 -191
  102. package/dist/types/config.js.map +1 -1
  103. package/dist/types/contracts.cjs.map +1 -1
  104. package/dist/types/contracts.d.ts +71 -7
  105. package/dist/types/controller-context.cjs.map +1 -1
  106. package/dist/types/controller-context.d.ts +3 -2
  107. package/dist/types/data.cjs.map +1 -1
  108. package/dist/types/data.d.ts +4 -6
  109. package/dist/types/generics.cjs.map +1 -1
  110. package/dist/types/generics.d.ts +80 -9
  111. package/dist/types/index.cjs.map +1 -1
  112. package/dist/types/index.d.ts +27 -2
  113. package/dist/types/index.js.map +1 -1
  114. package/dist/types/operations.cjs.map +1 -1
  115. package/dist/types/operations.d.ts +132 -15
  116. package/dist/types/operations.js.map +1 -1
  117. package/dist/types/permissions.cjs.map +1 -1
  118. package/dist/types/permissions.d.ts +15 -20
  119. package/dist/types/personal.cjs.map +1 -1
  120. package/dist/types/personal.d.ts +131 -14
  121. package/dist/types/relayer.cjs.map +1 -1
  122. package/dist/types/relayer.d.ts +262 -35
  123. package/dist/types/storage.cjs.map +1 -1
  124. package/dist/types/storage.d.ts +9 -21
  125. package/dist/types/storage.js.map +1 -1
  126. package/dist/utils/grantFiles.cjs.map +1 -1
  127. package/dist/utils/grantFiles.d.ts +10 -20
  128. package/dist/utils/grantFiles.js.map +1 -1
  129. package/dist/utils/grantValidation.cjs.map +1 -1
  130. package/dist/utils/grantValidation.d.ts +95 -16
  131. package/dist/utils/grantValidation.js.map +1 -1
  132. package/dist/utils/grants.cjs.map +1 -1
  133. package/dist/utils/grants.d.ts +93 -12
  134. package/dist/utils/grants.js.map +1 -1
  135. package/dist/utils/lazy-import.cjs.map +1 -1
  136. package/dist/utils/lazy-import.d.ts +32 -7
  137. package/dist/utils/lazy-import.js.map +1 -1
  138. package/dist/utils/signatureCache.cjs +8 -2
  139. package/dist/utils/signatureCache.cjs.map +1 -1
  140. package/dist/utils/signatureCache.d.ts +49 -8
  141. package/dist/utils/signatureCache.js +8 -2
  142. package/dist/utils/signatureCache.js.map +1 -1
  143. package/dist/utils/transactionHelpers.cjs.map +1 -1
  144. package/dist/utils/transactionHelpers.d.ts +12 -12
  145. package/dist/utils/transactionHelpers.js.map +1 -1
  146. package/dist/utils/typedDataConverter.cjs.map +1 -1
  147. package/dist/utils/typedDataConverter.d.ts +39 -3
  148. package/dist/utils/typedDataConverter.js.map +1 -1
  149. package/dist/utils/urlResolver.cjs +7 -0
  150. package/dist/utils/urlResolver.cjs.map +1 -1
  151. package/dist/utils/urlResolver.d.ts +22 -4
  152. package/dist/utils/urlResolver.js +7 -0
  153. package/dist/utils/urlResolver.js.map +1 -1
  154. package/dist/utils/wallet.cjs +2 -1
  155. package/dist/utils/wallet.cjs.map +1 -1
  156. package/dist/utils/wallet.d.ts +78 -16
  157. package/dist/utils/wallet.js +2 -1
  158. package/dist/utils/wallet.js.map +1 -1
  159. package/package.json +1 -1
  160. package/dist/server/handler.cjs +0 -101
  161. package/dist/server/handler.cjs.map +0 -1
  162. package/dist/server/handler.d.ts +0 -87
  163. package/dist/server/handler.js +0 -77
  164. package/dist/server/handler.js.map +0 -1
  165. /package/dist/tests/{server-handler.test.d.ts → permissions-revoke-relayer.test.d.ts} +0 -0
@@ -84,9 +84,8 @@ class DataController extends import_base.BaseController {
84
84
  } catch (error) {
85
85
  isValid = false;
86
86
  if (error instanceof Error) {
87
- const errorDetails = error.errors;
88
- if (errorDetails && Array.isArray(errorDetails)) {
89
- validationErrors = errorDetails;
87
+ if (typeof error === "object" && "errors" in error && Array.isArray(error.errors)) {
88
+ validationErrors = error.errors;
90
89
  } else {
91
90
  validationErrors = [error.message];
92
91
  }
@@ -125,27 +124,26 @@ class DataController extends import_base.BaseController {
125
124
  );
126
125
  }
127
126
  let result;
128
- if (this.context.relayerCallbacks?.submitFileAdditionComplete) {
129
- result = await this.context.relayerCallbacks.submitFileAdditionComplete(
130
- {
127
+ if (this.context.relayer) {
128
+ const request = {
129
+ type: "direct",
130
+ operation: "submitFileAdditionComplete",
131
+ params: {
131
132
  url: uploadResult.url,
132
133
  userAddress,
133
134
  permissions: encryptedPermissions,
134
135
  schemaId: schemaId ?? 0,
135
136
  ownerAddress: owner
136
137
  }
137
- );
138
- } else if (this.context.relayerCallbacks?.submitFileAddition) {
139
- const needsComplexRegistration = schemaId !== void 0 || encryptedPermissions.length > 0;
140
- if (needsComplexRegistration) {
141
- throw new Error(
142
- "The configured relay callback does not support schemas or permissions. Please update your relay server implementation to provide the `submitFileAdditionComplete` callback."
143
- );
138
+ };
139
+ const response = await this.context.relayer(request);
140
+ if (response.type === "error") {
141
+ throw new Error(response.error);
144
142
  }
145
- result = await this.context.relayerCallbacks.submitFileAddition(
146
- uploadResult.url,
147
- userAddress
148
- );
143
+ if (response.type !== "direct" || !("fileId" in response.result)) {
144
+ throw new Error("Invalid response from relayer");
145
+ }
146
+ result = response.result;
149
147
  } else {
150
148
  const txResult = await this.addFileWithEncryptedPermissionsAndSchema(
151
149
  uploadResult.url,
@@ -260,35 +258,33 @@ class DataController extends import_base.BaseController {
260
258
  }
261
259
  }
262
260
  /**
263
- * Decrypts a file owned by the user using their wallet signature.
261
+ * Decrypts a file using wallet-derived decryption key.
264
262
  *
265
263
  * @remarks
266
- * This is the high-level convenience method for decrypting user files, serving as the
267
- * symmetrical counterpart to the `upload` method. It handles the complete decryption
268
- * workflow including key generation, URL protocol detection, content fetching, and
269
- * decryption.
264
+ * Counterpart to `upload()` for decrypting user files. Automatically
265
+ * generates decryption key from wallet, fetches encrypted content,
266
+ * and decrypts. Supports IPFS (with gateway fallback) and HTTP URLs.
267
+ *
268
+ * @param file - UserFile object from `getUserFiles()`
269
+ * @param options - Decryption options
270
+ * @param options.seed - Custom encryption seed.
271
+ * Defaults to standard Vana seed.
272
+ *
273
+ * @returns Decrypted content as Blob
274
+ *
275
+ * @throws {Error} No wallet connected.
276
+ * Connect wallet before decrypting.
277
+ * @throws {Error} Network error accessing file.
278
+ * Check CORS settings or server availability.
279
+ * @throws {Error} File not found (404).
280
+ * File no longer available at stored URL.
281
+ * @throws {Error} Access denied (403).
282
+ * No permission to access file.
283
+ * @throws {Error} Invalid file format.
284
+ * File not encrypted with Vana protocol.
285
+ * @throws {Error} Wrong encryption key.
286
+ * Verify seed matches upload or use default.
270
287
  *
271
- * The method automatically:
272
- * - Generates the decryption key from the user's wallet signature
273
- * - Determines the appropriate fetch method based on the file URL protocol
274
- * - Fetches the encrypted content from IPFS or standard HTTP URLs
275
- * - Decrypts the content using the generated key
276
- *
277
- * For IPFS URLs, the method uses gateway fallback for improved reliability. For
278
- * standard HTTP URLs, it uses a simple fetch. If you need custom authentication
279
- * headers or specific gateway configurations, use the low-level primitives directly.
280
- *
281
- * @param file - The user file to decrypt (typically from getUserFiles)
282
- * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
283
- * @returns Promise resolving to the decrypted file content as a Blob
284
- * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
285
- * @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
286
- * @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
287
- * @throws {Error} "Access denied" - When file returns 403 (no permission)
288
- * @throws {Error} "File is empty or could not be retrieved" - When file has no content
289
- * @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
290
- * @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
291
- * @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
292
288
  * @example
293
289
  * ```typescript
294
290
  * // Basic file decryption
@@ -404,35 +400,38 @@ class DataController extends import_base.BaseController {
404
400
  }
405
401
  }
406
402
  /**
407
- * Retrieves all data files owned by a specific user address.
403
+ * Retrieves all files owned by a specific user address.
408
404
  *
409
405
  * @remarks
410
- * This method queries the Vana subgraph to find files directly owned by the user.
411
- * It efficiently handles large datasets by using the File entity's owner field
412
- * and returns complete file metadata without additional contract calls.
413
- *
414
- * **Deduplication Behavior:**
415
- * The method automatically deduplicates files by ID, keeping only the latest version
416
- * (highest timestamp) when duplicate file IDs are found. This handles cases where
417
- * the subgraph may contain multiple entries for the same file due to re-indexing
418
- * or blockchain reorganizations.
419
- * @param params - The query parameters object
420
- * @param params.owner - The wallet address of the file owner to query
421
- * @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
422
- * @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
423
- * @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
424
- * @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
425
- * @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
426
- * @throws {Error} When JSON parsing fails - "Failed to fetch user files from subgraph: {error}"
406
+ * Queries the Vana subgraph for files owned by the specified address.
407
+ * Automatically deduplicates by file ID, keeping the latest version
408
+ * when duplicates exist from re-indexing or chain reorganizations.
409
+ * Enriches results with DLP proof data when available.
410
+ *
411
+ * @param params - Query configuration
412
+ * @param params.owner - Wallet address of the file owner
413
+ * @param params.subgraphUrl - Subgraph endpoint override.
414
+ * Defaults to context configuration.
415
+ *
416
+ * @returns Array of UserFile objects sorted by timestamp (newest first)
417
+ *
418
+ * @throws {Error} Subgraph URL not configured.
419
+ * Provide `subgraphUrl` parameter or configure in Vana constructor.
420
+ * @throws {Error} Subgraph request failed.
421
+ * Check network connectivity and subgraph availability.
422
+ * @throws {Error} Subgraph returned errors.
423
+ * Review query parameters and subgraph logs.
424
+ *
427
425
  * @example
428
426
  * ```typescript
429
- * // Query files for a specific user
430
427
  * const files = await vana.data.getUserFiles({
431
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
428
+ * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
432
429
  * });
433
430
  *
434
431
  * files.forEach(file => {
435
- * console.log(`File ${file.id}: ${file.url} (Schema: ${file.schemaId})`);
432
+ * console.log(`File ${file.id}: ${file.url}`);
433
+ * console.log(` Schema: ${file.schemaId}`);
434
+ * console.log(` DLPs: ${file.dlpIds?.join(", ") || "none"}`);
436
435
  * });
437
436
  * ```
438
437
  */
@@ -1232,18 +1231,26 @@ class DataController extends import_base.BaseController {
1232
1231
  }
1233
1232
  }
1234
1233
  /**
1235
- * Gets the total number of files in the registry from the contract.
1234
+ * Retrieves total file count from Data Registry.
1235
+ *
1236
+ * @remarks
1237
+ * Queries blockchain for complete file count across all users.
1238
+ * Useful for pagination and network statistics.
1239
+ *
1240
+ * @returns Total number of registered files
1241
+ *
1242
+ * @throws {Error} Chain ID not available.
1243
+ * Ensure network connection.
1244
+ * @throws {Error} Contract read failed.
1245
+ * Check RPC availability.
1236
1246
  *
1237
- * @returns Promise resolving to the total file count
1238
1247
  * @example
1239
1248
  * ```typescript
1240
- * const totalFiles = await vana.data.getTotalFilesCount();
1241
- * console.log(`Total files in registry: ${totalFiles}`);
1249
+ * const total = await vana.data.getTotalFilesCount();
1250
+ * console.log(`Total files: ${total}`);
1242
1251
  *
1243
- * // Use for pagination calculations
1244
- * const filesPerPage = 20;
1245
- * const totalPages = Math.ceil(totalFiles / filesPerPage);
1246
- * console.log(`Total pages: ${totalPages}`);
1252
+ * // Calculate pagination
1253
+ * const pages = Math.ceil(total / 20);
1247
1254
  * ```
1248
1255
  */
1249
1256
  async getTotalFilesCount() {
@@ -1270,32 +1277,32 @@ class DataController extends import_base.BaseController {
1270
1277
  }
1271
1278
  }
1272
1279
  /**
1273
- * Retrieves details for a specific file by its ID.
1280
+ * Retrieves file metadata by ID from the blockchain.
1281
+ *
1282
+ * @remarks
1283
+ * Queries DataRegistry contract directly for file details.
1284
+ * Works for any file ID regardless of ownership, enabling
1285
+ * cross-user file discovery and verification.
1286
+ *
1287
+ * @param fileId - Numeric file ID to retrieve
1288
+ *
1289
+ * @returns UserFile object with metadata
1290
+ *
1291
+ * @throws {Error} Chain ID not available.
1292
+ * Ensure proper network connection.
1293
+ * @throws {Error} File not found.
1294
+ * Verify file ID exists on-chain.
1295
+ * @throws {Error} Contract call failed.
1296
+ * Check network and RPC availability.
1274
1297
  *
1275
- * @param fileId - The file ID to look up
1276
- * @returns Promise resolving to UserFile object
1277
- * @throws {Error} "Chain ID not available" - When wallet chain is not configured
1278
- * @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
1279
- * @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
1280
1298
  * @example
1281
1299
  * ```typescript
1282
- * try {
1283
- * const file = await vana.data.getFileById(123);
1284
- * console.log('File details:', {
1285
- * id: file.id,
1286
- * url: file.url,
1287
- * owner: file.ownerAddress,
1288
- * addedAt: file.addedAtBlock
1289
- * });
1290
- * } catch (error) {
1291
- * console.error('File not found or error retrieving file:', error);
1292
- * }
1300
+ * const file = await vana.data.getFileById(123);
1301
+ * console.log(`File ${file.id}:`);
1302
+ * console.log(` URL: ${file.url}`);
1303
+ * console.log(` Owner: ${file.ownerAddress}`);
1304
+ * console.log(` Block: ${file.addedAtBlock}`);
1293
1305
  * ```
1294
- *
1295
- * This method queries the DataRegistry contract directly
1296
- * to get file details for any file ID, regardless of user ownership.
1297
- * This is useful for file lookup functionality where users can search
1298
- * for specific files by ID.
1299
1306
  */
1300
1307
  async getFileById(fileId) {
1301
1308
  try {
@@ -1610,31 +1617,35 @@ class DataController extends import_base.BaseController {
1610
1617
  }
1611
1618
  }
1612
1619
  /**
1613
- * Adds a new refiner to the DataRefinerRegistry.
1620
+ * Registers a data refiner for processing templates.
1614
1621
  *
1615
1622
  * @remarks
1616
- * Refiners are data processing templates that define how raw data should be
1617
- * transformed into structured formats. Each refiner is associated with a DLP
1618
- * (Data Liquidity Pool), has a specific schema for output, and includes
1619
- * instructions for the refinement process.
1620
- *
1621
- * @param params - Refiner configuration parameters
1622
- * @param params.dlpId - The Data Liquidity Pool ID this refiner belongs to
1623
- * @param params.name - Human-readable name for the refiner
1624
- * @param params.schemaId - Schema ID that defines the output format
1625
- * @param params.refinementInstructionUrl - URL containing processing instructions
1626
- * @returns Promise resolving to the new refiner ID and transaction hash
1627
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1628
- * @throws {Error} When transaction fails - "Failed to add refiner: {error}"
1623
+ * Refiners define data transformation rules for DLPs.
1624
+ * Associates schema, instructions, and processing logic.
1625
+ *
1626
+ * @param params - Refiner configuration
1627
+ * @param params.dlpId - Data Liquidity Pool ID
1628
+ * @param params.name - Refiner display name
1629
+ * @param params.schemaId - Output schema ID.
1630
+ * Obtain via `vana.schemas.list()`.
1631
+ * @param params.refinementInstructionUrl - Processing instructions URL
1632
+ *
1633
+ * @returns Refiner ID and transaction hash
1634
+ *
1635
+ * @throws {Error} Chain ID not available.
1636
+ * Ensure network connection.
1637
+ * @throws {Error} Transaction failed.
1638
+ * Check wallet balance and network status.
1639
+ *
1629
1640
  * @example
1630
1641
  * ```typescript
1631
1642
  * const result = await vana.data.addRefiner({
1632
1643
  * dlpId: 1,
1633
- * name: "Social Media Sentiment Analyzer",
1644
+ * name: "Sentiment Analyzer",
1634
1645
  * schemaId: 42,
1635
1646
  * refinementInstructionUrl: "ipfs://QmXxx..."
1636
1647
  * });
1637
- * console.log(`Created refiner ${result.refinerId} in tx ${result.transactionHash}`);
1648
+ * console.log(`Refiner ${result.refinerId} created`);
1638
1649
  * ```
1639
1650
  */
1640
1651
  async addRefiner(params) {
@@ -1692,26 +1703,29 @@ class DataController extends import_base.BaseController {
1692
1703
  }
1693
1704
  }
1694
1705
  /**
1695
- * Retrieves a refiner by its ID.
1706
+ * Retrieves refiner configuration by ID.
1696
1707
  *
1697
1708
  * @remarks
1698
- * Queries the DataRefinerRegistry contract to get complete information about
1699
- * a specific refiner including its DLP association, schema, and instructions.
1709
+ * Queries DataRefinerRegistry for refiner details.
1710
+ * Returns DLP association, schema, and processing instructions.
1711
+ *
1712
+ * @param refinerId - Numeric refiner ID
1713
+ *
1714
+ * @returns Refiner configuration object
1715
+ *
1716
+ * @throws {Error} Chain ID not available.
1717
+ * Ensure network connection.
1718
+ * @throws {Error} Refiner not found.
1719
+ * Verify refiner ID exists.
1720
+ * @throws {Error} Contract read failed.
1721
+ * Check network and RPC status.
1700
1722
  *
1701
- * @param refinerId - The numeric refiner ID to retrieve
1702
- * @returns Promise resolving to the refiner information object
1703
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1704
- * @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
1705
- * @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
1706
1723
  * @example
1707
1724
  * ```typescript
1708
1725
  * const refiner = await vana.data.getRefiner(1);
1709
- * console.log({
1710
- * name: refiner.name,
1711
- * dlp: refiner.dlpId,
1712
- * schema: refiner.schemaId,
1713
- * instructions: refiner.refinementInstructionUrl
1714
- * });
1726
+ * console.log(`Refiner: ${refiner.name}`);
1727
+ * console.log(`DLP: ${refiner.dlpId}`);
1728
+ * console.log(`Schema: ${refiner.schemaId}`);
1715
1729
  * ```
1716
1730
  */
1717
1731
  async getRefiner(refinerId) {
@@ -1752,21 +1766,27 @@ class DataController extends import_base.BaseController {
1752
1766
  }
1753
1767
  }
1754
1768
  /**
1755
- * Validates if a schema ID exists in the registry.
1769
+ * Validates schema ID existence.
1756
1770
  *
1757
1771
  * @remarks
1758
- * Checks the DataRefinerRegistry contract to determine if a given schema ID
1759
- * has been registered and is available for use.
1772
+ * Verifies schema registration in DataRegistry.
1773
+ * Check before using schemas for uploads.
1774
+ *
1775
+ * @param schemaId - Numeric schema ID to validate
1776
+ *
1777
+ * @returns True if schema exists, false otherwise
1778
+ *
1779
+ * @throws {Error} Chain ID not available.
1780
+ * Ensure network connection.
1781
+ * @throws {Error} Contract read failed.
1782
+ * Check RPC availability.
1760
1783
  *
1761
- * @param schemaId - The numeric schema ID to validate
1762
- * @returns Promise resolving to true if schema exists, false otherwise
1763
1784
  * @example
1764
1785
  * ```typescript
1765
- * const isValid = await vana.data.isValidSchemaId(42);
1766
- * if (isValid) {
1767
- * console.log('Schema 42 is available for use');
1768
- * } else {
1769
- * console.log('Schema 42 does not exist');
1786
+ * const valid = await vana.data.isValidSchemaId(42);
1787
+ * if (valid) {
1788
+ * // Safe to use schema 42
1789
+ * await vana.data.upload({ schemaId: 42, ... });
1770
1790
  * }
1771
1791
  * ```
1772
1792
  */
@@ -1929,12 +1949,24 @@ class DataController extends import_base.BaseController {
1929
1949
  };
1930
1950
  })
1931
1951
  );
1932
- if (this.context.relayerCallbacks?.submitFileAdditionWithPermissions) {
1933
- const result = await this.context.relayerCallbacks.submitFileAdditionWithPermissions(
1934
- uploadResult.url,
1935
- userAddress,
1936
- encryptedPermissions
1937
- );
1952
+ if (this.context.relayer) {
1953
+ const request = {
1954
+ type: "direct",
1955
+ operation: "submitFileAdditionWithPermissions",
1956
+ params: {
1957
+ url: uploadResult.url,
1958
+ userAddress,
1959
+ permissions: encryptedPermissions
1960
+ }
1961
+ };
1962
+ const response = await this.context.relayer(request);
1963
+ if (response.type === "error") {
1964
+ throw new Error(response.error);
1965
+ }
1966
+ if (response.type !== "direct" || !("fileId" in response.result)) {
1967
+ throw new Error("Invalid response from relayer");
1968
+ }
1969
+ const result = response.result;
1938
1970
  return {
1939
1971
  fileId: result.fileId,
1940
1972
  url: uploadResult.url,
@@ -2023,7 +2055,7 @@ class DataController extends import_base.BaseController {
2023
2055
  );
2024
2056
  }
2025
2057
  }
2026
- const finalFilename = filename ?? `upload-${Date.now()}.dat`;
2058
+ const finalFilename = filename ?? encrypt ? `upload-${Date.now()}.enc` : `upload-${Date.now()}.dat`;
2027
2059
  const uploadResult = await this.context.storageManager.upload(
2028
2060
  finalBlob,
2029
2061
  finalFilename,