@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
@@ -68,9 +68,8 @@ class DataController extends BaseController {
68
68
  } catch (error) {
69
69
  isValid = false;
70
70
  if (error instanceof Error) {
71
- const errorDetails = error.errors;
72
- if (errorDetails && Array.isArray(errorDetails)) {
73
- validationErrors = errorDetails;
71
+ if (typeof error === "object" && "errors" in error && Array.isArray(error.errors)) {
72
+ validationErrors = error.errors;
74
73
  } else {
75
74
  validationErrors = [error.message];
76
75
  }
@@ -109,27 +108,26 @@ class DataController extends BaseController {
109
108
  );
110
109
  }
111
110
  let result;
112
- if (this.context.relayerCallbacks?.submitFileAdditionComplete) {
113
- result = await this.context.relayerCallbacks.submitFileAdditionComplete(
114
- {
111
+ if (this.context.relayer) {
112
+ const request = {
113
+ type: "direct",
114
+ operation: "submitFileAdditionComplete",
115
+ params: {
115
116
  url: uploadResult.url,
116
117
  userAddress,
117
118
  permissions: encryptedPermissions,
118
119
  schemaId: schemaId ?? 0,
119
120
  ownerAddress: owner
120
121
  }
121
- );
122
- } else if (this.context.relayerCallbacks?.submitFileAddition) {
123
- const needsComplexRegistration = schemaId !== void 0 || encryptedPermissions.length > 0;
124
- if (needsComplexRegistration) {
125
- throw new Error(
126
- "The configured relay callback does not support schemas or permissions. Please update your relay server implementation to provide the `submitFileAdditionComplete` callback."
127
- );
122
+ };
123
+ const response = await this.context.relayer(request);
124
+ if (response.type === "error") {
125
+ throw new Error(response.error);
128
126
  }
129
- result = await this.context.relayerCallbacks.submitFileAddition(
130
- uploadResult.url,
131
- userAddress
132
- );
127
+ if (response.type !== "direct" || !("fileId" in response.result)) {
128
+ throw new Error("Invalid response from relayer");
129
+ }
130
+ result = response.result;
133
131
  } else {
134
132
  const txResult = await this.addFileWithEncryptedPermissionsAndSchema(
135
133
  uploadResult.url,
@@ -244,35 +242,33 @@ class DataController extends BaseController {
244
242
  }
245
243
  }
246
244
  /**
247
- * Decrypts a file owned by the user using their wallet signature.
245
+ * Decrypts a file using wallet-derived decryption key.
248
246
  *
249
247
  * @remarks
250
- * This is the high-level convenience method for decrypting user files, serving as the
251
- * symmetrical counterpart to the `upload` method. It handles the complete decryption
252
- * workflow including key generation, URL protocol detection, content fetching, and
253
- * decryption.
248
+ * Counterpart to `upload()` for decrypting user files. Automatically
249
+ * generates decryption key from wallet, fetches encrypted content,
250
+ * and decrypts. Supports IPFS (with gateway fallback) and HTTP URLs.
251
+ *
252
+ * @param file - UserFile object from `getUserFiles()`
253
+ * @param options - Decryption options
254
+ * @param options.seed - Custom encryption seed.
255
+ * Defaults to standard Vana seed.
256
+ *
257
+ * @returns Decrypted content as Blob
258
+ *
259
+ * @throws {Error} No wallet connected.
260
+ * Connect wallet before decrypting.
261
+ * @throws {Error} Network error accessing file.
262
+ * Check CORS settings or server availability.
263
+ * @throws {Error} File not found (404).
264
+ * File no longer available at stored URL.
265
+ * @throws {Error} Access denied (403).
266
+ * No permission to access file.
267
+ * @throws {Error} Invalid file format.
268
+ * File not encrypted with Vana protocol.
269
+ * @throws {Error} Wrong encryption key.
270
+ * Verify seed matches upload or use default.
254
271
  *
255
- * The method automatically:
256
- * - Generates the decryption key from the user's wallet signature
257
- * - Determines the appropriate fetch method based on the file URL protocol
258
- * - Fetches the encrypted content from IPFS or standard HTTP URLs
259
- * - Decrypts the content using the generated key
260
- *
261
- * For IPFS URLs, the method uses gateway fallback for improved reliability. For
262
- * standard HTTP URLs, it uses a simple fetch. If you need custom authentication
263
- * headers or specific gateway configurations, use the low-level primitives directly.
264
- *
265
- * @param file - The user file to decrypt (typically from getUserFiles)
266
- * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
267
- * @returns Promise resolving to the decrypted file content as a Blob
268
- * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
269
- * @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
270
- * @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
271
- * @throws {Error} "Access denied" - When file returns 403 (no permission)
272
- * @throws {Error} "File is empty or could not be retrieved" - When file has no content
273
- * @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
274
- * @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
275
- * @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
276
272
  * @example
277
273
  * ```typescript
278
274
  * // Basic file decryption
@@ -388,35 +384,38 @@ class DataController extends BaseController {
388
384
  }
389
385
  }
390
386
  /**
391
- * Retrieves all data files owned by a specific user address.
387
+ * Retrieves all files owned by a specific user address.
392
388
  *
393
389
  * @remarks
394
- * This method queries the Vana subgraph to find files directly owned by the user.
395
- * It efficiently handles large datasets by using the File entity's owner field
396
- * and returns complete file metadata without additional contract calls.
397
- *
398
- * **Deduplication Behavior:**
399
- * The method automatically deduplicates files by ID, keeping only the latest version
400
- * (highest timestamp) when duplicate file IDs are found. This handles cases where
401
- * the subgraph may contain multiple entries for the same file due to re-indexing
402
- * or blockchain reorganizations.
403
- * @param params - The query parameters object
404
- * @param params.owner - The wallet address of the file owner to query
405
- * @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
406
- * @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
407
- * @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
408
- * @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
409
- * @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
410
- * @throws {Error} When JSON parsing fails - "Failed to fetch user files from subgraph: {error}"
390
+ * Queries the Vana subgraph for files owned by the specified address.
391
+ * Automatically deduplicates by file ID, keeping the latest version
392
+ * when duplicates exist from re-indexing or chain reorganizations.
393
+ * Enriches results with DLP proof data when available.
394
+ *
395
+ * @param params - Query configuration
396
+ * @param params.owner - Wallet address of the file owner
397
+ * @param params.subgraphUrl - Subgraph endpoint override.
398
+ * Defaults to context configuration.
399
+ *
400
+ * @returns Array of UserFile objects sorted by timestamp (newest first)
401
+ *
402
+ * @throws {Error} Subgraph URL not configured.
403
+ * Provide `subgraphUrl` parameter or configure in Vana constructor.
404
+ * @throws {Error} Subgraph request failed.
405
+ * Check network connectivity and subgraph availability.
406
+ * @throws {Error} Subgraph returned errors.
407
+ * Review query parameters and subgraph logs.
408
+ *
411
409
  * @example
412
410
  * ```typescript
413
- * // Query files for a specific user
414
411
  * const files = await vana.data.getUserFiles({
415
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
412
+ * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
416
413
  * });
417
414
  *
418
415
  * files.forEach(file => {
419
- * console.log(`File ${file.id}: ${file.url} (Schema: ${file.schemaId})`);
416
+ * console.log(`File ${file.id}: ${file.url}`);
417
+ * console.log(` Schema: ${file.schemaId}`);
418
+ * console.log(` DLPs: ${file.dlpIds?.join(", ") || "none"}`);
420
419
  * });
421
420
  * ```
422
421
  */
@@ -1216,18 +1215,26 @@ class DataController extends BaseController {
1216
1215
  }
1217
1216
  }
1218
1217
  /**
1219
- * Gets the total number of files in the registry from the contract.
1218
+ * Retrieves total file count from Data Registry.
1219
+ *
1220
+ * @remarks
1221
+ * Queries blockchain for complete file count across all users.
1222
+ * Useful for pagination and network statistics.
1223
+ *
1224
+ * @returns Total number of registered files
1225
+ *
1226
+ * @throws {Error} Chain ID not available.
1227
+ * Ensure network connection.
1228
+ * @throws {Error} Contract read failed.
1229
+ * Check RPC availability.
1220
1230
  *
1221
- * @returns Promise resolving to the total file count
1222
1231
  * @example
1223
1232
  * ```typescript
1224
- * const totalFiles = await vana.data.getTotalFilesCount();
1225
- * console.log(`Total files in registry: ${totalFiles}`);
1233
+ * const total = await vana.data.getTotalFilesCount();
1234
+ * console.log(`Total files: ${total}`);
1226
1235
  *
1227
- * // Use for pagination calculations
1228
- * const filesPerPage = 20;
1229
- * const totalPages = Math.ceil(totalFiles / filesPerPage);
1230
- * console.log(`Total pages: ${totalPages}`);
1236
+ * // Calculate pagination
1237
+ * const pages = Math.ceil(total / 20);
1231
1238
  * ```
1232
1239
  */
1233
1240
  async getTotalFilesCount() {
@@ -1254,32 +1261,32 @@ class DataController extends BaseController {
1254
1261
  }
1255
1262
  }
1256
1263
  /**
1257
- * Retrieves details for a specific file by its ID.
1264
+ * Retrieves file metadata by ID from the blockchain.
1265
+ *
1266
+ * @remarks
1267
+ * Queries DataRegistry contract directly for file details.
1268
+ * Works for any file ID regardless of ownership, enabling
1269
+ * cross-user file discovery and verification.
1270
+ *
1271
+ * @param fileId - Numeric file ID to retrieve
1272
+ *
1273
+ * @returns UserFile object with metadata
1274
+ *
1275
+ * @throws {Error} Chain ID not available.
1276
+ * Ensure proper network connection.
1277
+ * @throws {Error} File not found.
1278
+ * Verify file ID exists on-chain.
1279
+ * @throws {Error} Contract call failed.
1280
+ * Check network and RPC availability.
1258
1281
  *
1259
- * @param fileId - The file ID to look up
1260
- * @returns Promise resolving to UserFile object
1261
- * @throws {Error} "Chain ID not available" - When wallet chain is not configured
1262
- * @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
1263
- * @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
1264
1282
  * @example
1265
1283
  * ```typescript
1266
- * try {
1267
- * const file = await vana.data.getFileById(123);
1268
- * console.log('File details:', {
1269
- * id: file.id,
1270
- * url: file.url,
1271
- * owner: file.ownerAddress,
1272
- * addedAt: file.addedAtBlock
1273
- * });
1274
- * } catch (error) {
1275
- * console.error('File not found or error retrieving file:', error);
1276
- * }
1284
+ * const file = await vana.data.getFileById(123);
1285
+ * console.log(`File ${file.id}:`);
1286
+ * console.log(` URL: ${file.url}`);
1287
+ * console.log(` Owner: ${file.ownerAddress}`);
1288
+ * console.log(` Block: ${file.addedAtBlock}`);
1277
1289
  * ```
1278
- *
1279
- * This method queries the DataRegistry contract directly
1280
- * to get file details for any file ID, regardless of user ownership.
1281
- * This is useful for file lookup functionality where users can search
1282
- * for specific files by ID.
1283
1290
  */
1284
1291
  async getFileById(fileId) {
1285
1292
  try {
@@ -1594,31 +1601,35 @@ class DataController extends BaseController {
1594
1601
  }
1595
1602
  }
1596
1603
  /**
1597
- * Adds a new refiner to the DataRefinerRegistry.
1604
+ * Registers a data refiner for processing templates.
1598
1605
  *
1599
1606
  * @remarks
1600
- * Refiners are data processing templates that define how raw data should be
1601
- * transformed into structured formats. Each refiner is associated with a DLP
1602
- * (Data Liquidity Pool), has a specific schema for output, and includes
1603
- * instructions for the refinement process.
1604
- *
1605
- * @param params - Refiner configuration parameters
1606
- * @param params.dlpId - The Data Liquidity Pool ID this refiner belongs to
1607
- * @param params.name - Human-readable name for the refiner
1608
- * @param params.schemaId - Schema ID that defines the output format
1609
- * @param params.refinementInstructionUrl - URL containing processing instructions
1610
- * @returns Promise resolving to the new refiner ID and transaction hash
1611
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1612
- * @throws {Error} When transaction fails - "Failed to add refiner: {error}"
1607
+ * Refiners define data transformation rules for DLPs.
1608
+ * Associates schema, instructions, and processing logic.
1609
+ *
1610
+ * @param params - Refiner configuration
1611
+ * @param params.dlpId - Data Liquidity Pool ID
1612
+ * @param params.name - Refiner display name
1613
+ * @param params.schemaId - Output schema ID.
1614
+ * Obtain via `vana.schemas.list()`.
1615
+ * @param params.refinementInstructionUrl - Processing instructions URL
1616
+ *
1617
+ * @returns Refiner ID and transaction hash
1618
+ *
1619
+ * @throws {Error} Chain ID not available.
1620
+ * Ensure network connection.
1621
+ * @throws {Error} Transaction failed.
1622
+ * Check wallet balance and network status.
1623
+ *
1613
1624
  * @example
1614
1625
  * ```typescript
1615
1626
  * const result = await vana.data.addRefiner({
1616
1627
  * dlpId: 1,
1617
- * name: "Social Media Sentiment Analyzer",
1628
+ * name: "Sentiment Analyzer",
1618
1629
  * schemaId: 42,
1619
1630
  * refinementInstructionUrl: "ipfs://QmXxx..."
1620
1631
  * });
1621
- * console.log(`Created refiner ${result.refinerId} in tx ${result.transactionHash}`);
1632
+ * console.log(`Refiner ${result.refinerId} created`);
1622
1633
  * ```
1623
1634
  */
1624
1635
  async addRefiner(params) {
@@ -1676,26 +1687,29 @@ class DataController extends BaseController {
1676
1687
  }
1677
1688
  }
1678
1689
  /**
1679
- * Retrieves a refiner by its ID.
1690
+ * Retrieves refiner configuration by ID.
1680
1691
  *
1681
1692
  * @remarks
1682
- * Queries the DataRefinerRegistry contract to get complete information about
1683
- * a specific refiner including its DLP association, schema, and instructions.
1693
+ * Queries DataRefinerRegistry for refiner details.
1694
+ * Returns DLP association, schema, and processing instructions.
1695
+ *
1696
+ * @param refinerId - Numeric refiner ID
1697
+ *
1698
+ * @returns Refiner configuration object
1699
+ *
1700
+ * @throws {Error} Chain ID not available.
1701
+ * Ensure network connection.
1702
+ * @throws {Error} Refiner not found.
1703
+ * Verify refiner ID exists.
1704
+ * @throws {Error} Contract read failed.
1705
+ * Check network and RPC status.
1684
1706
  *
1685
- * @param refinerId - The numeric refiner ID to retrieve
1686
- * @returns Promise resolving to the refiner information object
1687
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1688
- * @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
1689
- * @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
1690
1707
  * @example
1691
1708
  * ```typescript
1692
1709
  * const refiner = await vana.data.getRefiner(1);
1693
- * console.log({
1694
- * name: refiner.name,
1695
- * dlp: refiner.dlpId,
1696
- * schema: refiner.schemaId,
1697
- * instructions: refiner.refinementInstructionUrl
1698
- * });
1710
+ * console.log(`Refiner: ${refiner.name}`);
1711
+ * console.log(`DLP: ${refiner.dlpId}`);
1712
+ * console.log(`Schema: ${refiner.schemaId}`);
1699
1713
  * ```
1700
1714
  */
1701
1715
  async getRefiner(refinerId) {
@@ -1736,21 +1750,27 @@ class DataController extends BaseController {
1736
1750
  }
1737
1751
  }
1738
1752
  /**
1739
- * Validates if a schema ID exists in the registry.
1753
+ * Validates schema ID existence.
1740
1754
  *
1741
1755
  * @remarks
1742
- * Checks the DataRefinerRegistry contract to determine if a given schema ID
1743
- * has been registered and is available for use.
1756
+ * Verifies schema registration in DataRegistry.
1757
+ * Check before using schemas for uploads.
1758
+ *
1759
+ * @param schemaId - Numeric schema ID to validate
1760
+ *
1761
+ * @returns True if schema exists, false otherwise
1762
+ *
1763
+ * @throws {Error} Chain ID not available.
1764
+ * Ensure network connection.
1765
+ * @throws {Error} Contract read failed.
1766
+ * Check RPC availability.
1744
1767
  *
1745
- * @param schemaId - The numeric schema ID to validate
1746
- * @returns Promise resolving to true if schema exists, false otherwise
1747
1768
  * @example
1748
1769
  * ```typescript
1749
- * const isValid = await vana.data.isValidSchemaId(42);
1750
- * if (isValid) {
1751
- * console.log('Schema 42 is available for use');
1752
- * } else {
1753
- * console.log('Schema 42 does not exist');
1770
+ * const valid = await vana.data.isValidSchemaId(42);
1771
+ * if (valid) {
1772
+ * // Safe to use schema 42
1773
+ * await vana.data.upload({ schemaId: 42, ... });
1754
1774
  * }
1755
1775
  * ```
1756
1776
  */
@@ -1913,12 +1933,24 @@ class DataController extends BaseController {
1913
1933
  };
1914
1934
  })
1915
1935
  );
1916
- if (this.context.relayerCallbacks?.submitFileAdditionWithPermissions) {
1917
- const result = await this.context.relayerCallbacks.submitFileAdditionWithPermissions(
1918
- uploadResult.url,
1919
- userAddress,
1920
- encryptedPermissions
1921
- );
1936
+ if (this.context.relayer) {
1937
+ const request = {
1938
+ type: "direct",
1939
+ operation: "submitFileAdditionWithPermissions",
1940
+ params: {
1941
+ url: uploadResult.url,
1942
+ userAddress,
1943
+ permissions: encryptedPermissions
1944
+ }
1945
+ };
1946
+ const response = await this.context.relayer(request);
1947
+ if (response.type === "error") {
1948
+ throw new Error(response.error);
1949
+ }
1950
+ if (response.type !== "direct" || !("fileId" in response.result)) {
1951
+ throw new Error("Invalid response from relayer");
1952
+ }
1953
+ const result = response.result;
1922
1954
  return {
1923
1955
  fileId: result.fileId,
1924
1956
  url: uploadResult.url,
@@ -2007,7 +2039,7 @@ class DataController extends BaseController {
2007
2039
  );
2008
2040
  }
2009
2041
  }
2010
- const finalFilename = filename ?? `upload-${Date.now()}.dat`;
2042
+ const finalFilename = filename ?? encrypt ? `upload-${Date.now()}.enc` : `upload-${Date.now()}.dat`;
2011
2043
  const uploadResult = await this.context.storageManager.upload(
2012
2044
  finalBlob,
2013
2045
  finalFilename,