@opendatalabs/vana-sdk 0.1.0-alpha.2b6935d → 0.1.0-alpha.2e77fcc

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 (171) 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/base.cjs +33 -0
  14. package/dist/controllers/base.cjs.map +1 -1
  15. package/dist/controllers/base.d.ts +10 -0
  16. package/dist/controllers/base.js +33 -0
  17. package/dist/controllers/base.js.map +1 -1
  18. package/dist/controllers/data.cjs +162 -133
  19. package/dist/controllers/data.cjs.map +1 -1
  20. package/dist/controllers/data.d.ts +222 -184
  21. package/dist/controllers/data.js +162 -133
  22. package/dist/controllers/data.js.map +1 -1
  23. package/dist/controllers/permissions.cjs +208 -60
  24. package/dist/controllers/permissions.cjs.map +1 -1
  25. package/dist/controllers/permissions.d.ts +75 -45
  26. package/dist/controllers/permissions.js +208 -60
  27. package/dist/controllers/permissions.js.map +1 -1
  28. package/dist/controllers/protocol.cjs.map +1 -1
  29. package/dist/controllers/protocol.d.ts +27 -28
  30. package/dist/controllers/protocol.js.map +1 -1
  31. package/dist/controllers/schemas.cjs +23 -21
  32. package/dist/controllers/schemas.cjs.map +1 -1
  33. package/dist/controllers/schemas.d.ts +47 -40
  34. package/dist/controllers/schemas.js +23 -21
  35. package/dist/controllers/schemas.js.map +1 -1
  36. package/dist/controllers/server.cjs +17 -15
  37. package/dist/controllers/server.cjs.map +1 -1
  38. package/dist/controllers/server.d.ts +46 -38
  39. package/dist/controllers/server.js +17 -15
  40. package/dist/controllers/server.js.map +1 -1
  41. package/dist/core/apiClient.cjs +53 -3
  42. package/dist/core/apiClient.cjs.map +1 -1
  43. package/dist/core/apiClient.d.ts +132 -7
  44. package/dist/core/apiClient.js +53 -3
  45. package/dist/core/apiClient.js.map +1 -1
  46. package/dist/core/generics.cjs +30 -3
  47. package/dist/core/generics.cjs.map +1 -1
  48. package/dist/core/generics.d.ts +95 -6
  49. package/dist/core/generics.js +30 -3
  50. package/dist/core/generics.js.map +1 -1
  51. package/dist/core.cjs +4 -1
  52. package/dist/core.cjs.map +1 -1
  53. package/dist/core.d.ts +2 -1
  54. package/dist/core.js +4 -1
  55. package/dist/core.js.map +1 -1
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/index.node.cjs +2 -3
  59. package/dist/index.node.cjs.map +1 -1
  60. package/dist/index.node.d.ts +33 -13
  61. package/dist/index.node.js +2 -2
  62. package/dist/index.node.js.map +1 -1
  63. package/dist/node.cjs.map +1 -1
  64. package/dist/node.d.ts +39 -1
  65. package/dist/node.js.map +1 -1
  66. package/dist/platform/browser.cjs +160 -2
  67. package/dist/platform/browser.cjs.map +1 -1
  68. package/dist/platform/browser.d.ts +232 -12
  69. package/dist/platform/browser.js +160 -2
  70. package/dist/platform/browser.js.map +1 -1
  71. package/dist/platform/interface.cjs.map +1 -1
  72. package/dist/platform/interface.d.ts +283 -90
  73. package/dist/platform/node.cjs +163 -2
  74. package/dist/platform/node.cjs.map +1 -1
  75. package/dist/platform/node.d.ts +69 -6
  76. package/dist/platform/node.js +163 -2
  77. package/dist/platform/node.js.map +1 -1
  78. package/dist/server/relayerHandler.cjs +136 -98
  79. package/dist/server/relayerHandler.cjs.map +1 -1
  80. package/dist/server/relayerHandler.d.ts +3 -2
  81. package/dist/server/relayerHandler.js +135 -96
  82. package/dist/server/relayerHandler.js.map +1 -1
  83. package/dist/storage/manager.cjs +108 -25
  84. package/dist/storage/manager.cjs.map +1 -1
  85. package/dist/storage/manager.d.ts +119 -25
  86. package/dist/storage/manager.js +108 -25
  87. package/dist/storage/manager.js.map +1 -1
  88. package/dist/storage/providers/callback-storage.cjs +86 -15
  89. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  90. package/dist/storage/providers/callback-storage.d.ts +109 -20
  91. package/dist/storage/providers/callback-storage.js +86 -15
  92. package/dist/storage/providers/callback-storage.js.map +1 -1
  93. package/dist/storage/providers/pinata.cjs.map +1 -1
  94. package/dist/storage/providers/pinata.d.ts +12 -14
  95. package/dist/storage/providers/pinata.js.map +1 -1
  96. package/dist/types/blockchain.cjs.map +1 -1
  97. package/dist/types/blockchain.d.ts +39 -11
  98. package/dist/types/chains.cjs.map +1 -1
  99. package/dist/types/chains.d.ts +74 -7
  100. package/dist/types/chains.js.map +1 -1
  101. package/dist/types/config.cjs.map +1 -1
  102. package/dist/types/config.d.ts +38 -4
  103. package/dist/types/config.js.map +1 -1
  104. package/dist/types/contracts.cjs.map +1 -1
  105. package/dist/types/contracts.d.ts +71 -7
  106. package/dist/types/controller-context.cjs.map +1 -1
  107. package/dist/types/controller-context.d.ts +3 -1
  108. package/dist/types/data.cjs.map +1 -1
  109. package/dist/types/data.d.ts +4 -6
  110. package/dist/types/generics.cjs.map +1 -1
  111. package/dist/types/generics.d.ts +81 -10
  112. package/dist/types/index.cjs.map +1 -1
  113. package/dist/types/index.d.ts +28 -2
  114. package/dist/types/index.js.map +1 -1
  115. package/dist/types/operations.cjs.map +1 -1
  116. package/dist/types/operations.d.ts +178 -15
  117. package/dist/types/operations.js.map +1 -1
  118. package/dist/types/permissions.cjs.map +1 -1
  119. package/dist/types/permissions.d.ts +15 -20
  120. package/dist/types/personal.cjs.map +1 -1
  121. package/dist/types/personal.d.ts +131 -14
  122. package/dist/types/relayer.cjs.map +1 -1
  123. package/dist/types/relayer.d.ts +114 -18
  124. package/dist/types/storage.cjs.map +1 -1
  125. package/dist/types/storage.d.ts +9 -21
  126. package/dist/types/storage.js.map +1 -1
  127. package/dist/types/utils.cjs.map +1 -1
  128. package/dist/types/utils.d.ts +5 -1
  129. package/dist/utils/grantFiles.cjs.map +1 -1
  130. package/dist/utils/grantFiles.d.ts +10 -20
  131. package/dist/utils/grantFiles.js.map +1 -1
  132. package/dist/utils/grantValidation.cjs.map +1 -1
  133. package/dist/utils/grantValidation.d.ts +95 -16
  134. package/dist/utils/grantValidation.js.map +1 -1
  135. package/dist/utils/grants.cjs.map +1 -1
  136. package/dist/utils/grants.d.ts +93 -12
  137. package/dist/utils/grants.js.map +1 -1
  138. package/dist/utils/ipfs.cjs +2 -4
  139. package/dist/utils/ipfs.cjs.map +1 -1
  140. package/dist/utils/ipfs.d.ts +1 -1
  141. package/dist/utils/ipfs.js +2 -4
  142. package/dist/utils/ipfs.js.map +1 -1
  143. package/dist/utils/lazy-import.cjs.map +1 -1
  144. package/dist/utils/lazy-import.d.ts +32 -7
  145. package/dist/utils/lazy-import.js.map +1 -1
  146. package/dist/utils/signatureCache.cjs +8 -2
  147. package/dist/utils/signatureCache.cjs.map +1 -1
  148. package/dist/utils/signatureCache.d.ts +49 -8
  149. package/dist/utils/signatureCache.js +8 -2
  150. package/dist/utils/signatureCache.js.map +1 -1
  151. package/dist/utils/transactionHelpers.cjs.map +1 -1
  152. package/dist/utils/transactionHelpers.d.ts +12 -12
  153. package/dist/utils/transactionHelpers.js.map +1 -1
  154. package/dist/utils/typedDataConverter.cjs.map +1 -1
  155. package/dist/utils/typedDataConverter.d.ts +39 -3
  156. package/dist/utils/typedDataConverter.js.map +1 -1
  157. package/dist/utils/urlResolver.cjs +7 -0
  158. package/dist/utils/urlResolver.cjs.map +1 -1
  159. package/dist/utils/urlResolver.d.ts +22 -4
  160. package/dist/utils/urlResolver.js +7 -0
  161. package/dist/utils/urlResolver.js.map +1 -1
  162. package/dist/utils/wallet.cjs.map +1 -1
  163. package/dist/utils/wallet.d.ts +78 -16
  164. package/dist/utils/wallet.js.map +1 -1
  165. package/package.json +3 -1
  166. package/dist/server/handler.cjs +0 -103
  167. package/dist/server/handler.cjs.map +0 -1
  168. package/dist/server/handler.d.ts +0 -95
  169. package/dist/server/handler.js +0 -79
  170. package/dist/server/handler.js.map +0 -1
  171. /package/dist/tests/{server-handler.test.d.ts → permissions-transaction-options.test.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/controllers/base.ts"],"sourcesContent":["/**\n * Base controller class providing common functionality for all controllers.\n *\n * @remarks\n * This abstract class establishes the foundation for all Vana SDK controllers,\n * providing shared utilities like wallet validation and context management.\n * All controllers should extend this base class to ensure consistency and\n * shared behavior across the SDK.\n *\n * The class follows the Single Responsibility Principle by handling only\n * the core controller concerns while leaving specific functionality to\n * implementing classes.\n *\n * @category Controllers\n */\n\nimport type { WalletClient } from \"viem\";\nimport type { ControllerContext } from \"../types/controller-context\";\nimport { ReadOnlyError } from \"../errors\";\n\n/**\n * Abstract base controller that all Vana SDK controllers extend.\n *\n * @remarks\n * Provides common functionality and patterns used across all controllers,\n * including wallet validation and context management. This ensures\n * consistency and reduces code duplication throughout the SDK.\n *\n * Key features:\n * - Wallet client validation with TypeScript assertion signatures\n * - Consistent error handling for read-only scenarios\n * - Shared context management patterns\n * - Type-safe wallet operations\n *\n * @example\n * ```typescript\n * class MyController extends BaseController {\n * async performWalletOperation() {\n * this.assertWallet(); // Ensures wallet is available\n * // Now this.context.walletClient is guaranteed to be available\n * const address = await this.context.walletClient.getAddresses();\n * return address[0];\n * }\n * }\n * ```\n */\nexport abstract class BaseController {\n /**\n * Creates a new controller instance with the provided context.\n *\n * @param context - The controller context containing clients and configuration\n */\n constructor(protected readonly context: ControllerContext) {}\n\n /**\n * Asserts that a wallet client with an account is available for operations requiring signing.\n *\n * @remarks\n * This method uses TypeScript assertion signatures to narrow the type of\n * `this.context` to guarantee that `walletClient` with an account is available\n * after the call succeeds. This provides compile-time safety for wallet operations\n * while enabling clear error messages for read-only scenarios.\n *\n * The assertion signature ensures that after calling this method,\n * TypeScript knows that `this.context.walletClient` is definitely available\n * with a configured account.\n *\n * @throws {ReadOnlyError} When no wallet client is configured\n * @throws {Error} When wallet client exists but no account is configured\n *\n * @example\n * ```typescript\n * async performWalletOperation() {\n * this.assertWallet(); // Type assertion + runtime check\n *\n * // TypeScript now knows walletClient and account are available\n * const account = this.context.walletClient.account;\n * const address = typeof account === 'string' ? account : account.address;\n * }\n * ```\n */\n protected assertWallet(): asserts this is {\n context: ControllerContext & { walletClient: WalletClient };\n } {\n if (!this.context.walletClient) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new ReadOnlyError(\n callingMethod,\n \"Initialize the SDK with a walletClient to perform this operation\",\n );\n }\n\n if (!this.context.walletClient.account) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new Error(\n `No wallet account connected. Cannot perform ${callingMethod} without an account.`,\n );\n }\n }\n}\n"],"mappings":"AAkBA,SAAS,qBAAqB;AA4BvB,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,YAA+B,SAA4B;AAA5B;AAAA,EAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BlD,eAER;AACA,QAAI,CAAC,KAAK,QAAQ,cAAc;AAE9B,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,QAAQ,aAAa,SAAS;AAEtC,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR,+CAA+C,aAAa;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/controllers/base.ts"],"sourcesContent":["/**\n * Base controller class providing common functionality for all controllers.\n *\n * @remarks\n * This abstract class establishes the foundation for all Vana SDK controllers,\n * providing shared utilities like wallet validation and context management.\n * All controllers should extend this base class to ensure consistency and\n * shared behavior across the SDK.\n *\n * The class follows the Single Responsibility Principle by handling only\n * the core controller concerns while leaving specific functionality to\n * implementing classes.\n *\n * @category Controllers\n */\n\nimport type { WalletClient } from \"viem\";\nimport type { ControllerContext } from \"../types/controller-context\";\nimport type { TransactionOptions } from \"../types/operations\";\nimport { ReadOnlyError } from \"../errors\";\n\n/**\n * Abstract base controller that all Vana SDK controllers extend.\n *\n * @remarks\n * Provides common functionality and patterns used across all controllers,\n * including wallet validation and context management. This ensures\n * consistency and reduces code duplication throughout the SDK.\n *\n * Key features:\n * - Wallet client validation with TypeScript assertion signatures\n * - Consistent error handling for read-only scenarios\n * - Shared context management patterns\n * - Type-safe wallet operations\n *\n * @example\n * ```typescript\n * class MyController extends BaseController {\n * async performWalletOperation() {\n * this.assertWallet(); // Ensures wallet is available\n * // Now this.context.walletClient is guaranteed to be available\n * const address = await this.context.walletClient.getAddresses();\n * return address[0];\n * }\n * }\n * ```\n */\nexport abstract class BaseController {\n /**\n * Creates a new controller instance with the provided context.\n *\n * @param context - The controller context containing clients and configuration\n */\n constructor(protected readonly context: ControllerContext) {}\n\n /**\n * Asserts that a wallet client with an account is available for operations requiring signing.\n *\n * @remarks\n * This method uses TypeScript assertion signatures to narrow the type of\n * `this.context` to guarantee that `walletClient` with an account is available\n * after the call succeeds. This provides compile-time safety for wallet operations\n * while enabling clear error messages for read-only scenarios.\n *\n * The assertion signature ensures that after calling this method,\n * TypeScript knows that `this.context.walletClient` is definitely available\n * with a configured account.\n *\n * @throws {ReadOnlyError} When no wallet client is configured\n * @throws {Error} When wallet client exists but no account is configured\n *\n * @example\n * ```typescript\n * async performWalletOperation() {\n * this.assertWallet(); // Type assertion + runtime check\n *\n * // TypeScript now knows walletClient and account are available\n * const account = this.context.walletClient.account;\n * const address = typeof account === 'string' ? account : account.address;\n * }\n * ```\n */\n protected assertWallet(): asserts this is {\n context: ControllerContext & { walletClient: WalletClient };\n } {\n if (!this.context.walletClient) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new ReadOnlyError(\n callingMethod,\n \"Initialize the SDK with a walletClient to perform this operation\",\n );\n }\n\n if (!this.context.walletClient.account) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new Error(\n `No wallet account connected. Cannot perform ${callingMethod} without an account.`,\n );\n }\n }\n\n /**\n * Helper to safely spread transaction options for viem compatibility.\n * Handles EIP-1559 vs legacy gas pricing correctly.\n *\n * @param options - Transaction options to spread\n * @returns Properly formatted options for viem\n * @internal\n */\n protected spreadTransactionOptions(options?: TransactionOptions) {\n if (!options) return {};\n\n const baseOptions: any = {\n ...(options.nonce !== undefined && { nonce: options.nonce }),\n ...(options.gas !== undefined && { gas: options.gas }),\n };\n\n // EIP-1559 and legacy gasPrice are mutually exclusive in viem\n // If EIP-1559 params are provided, use them and exclude gasPrice\n if (\n options.maxFeePerGas !== undefined ||\n options.maxPriorityFeePerGas !== undefined\n ) {\n return {\n ...baseOptions,\n ...(options.maxFeePerGas !== undefined && {\n maxFeePerGas: options.maxFeePerGas,\n }),\n ...(options.maxPriorityFeePerGas !== undefined && {\n maxPriorityFeePerGas: options.maxPriorityFeePerGas,\n }),\n };\n }\n\n // Otherwise, use legacy gasPrice if provided\n if (options.gasPrice !== undefined) {\n return {\n ...baseOptions,\n gasPrice: options.gasPrice,\n };\n }\n\n return baseOptions;\n }\n}\n"],"mappings":"AAmBA,SAAS,qBAAqB;AA4BvB,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,YAA+B,SAA4B;AAA5B;AAAA,EAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BlD,eAER;AACA,QAAI,CAAC,KAAK,QAAQ,cAAc;AAE9B,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,QAAQ,aAAa,SAAS;AAEtC,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR,+CAA+C,aAAa;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUU,yBAAyB,SAA8B;AAC/D,QAAI,CAAC,QAAS,QAAO,CAAC;AAEtB,UAAM,cAAmB;AAAA,MACvB,GAAI,QAAQ,UAAU,UAAa,EAAE,OAAO,QAAQ,MAAM;AAAA,MAC1D,GAAI,QAAQ,QAAQ,UAAa,EAAE,KAAK,QAAQ,IAAI;AAAA,IACtD;AAIA,QACE,QAAQ,iBAAiB,UACzB,QAAQ,yBAAyB,QACjC;AACA,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAI,QAAQ,iBAAiB,UAAa;AAAA,UACxC,cAAc,QAAQ;AAAA,QACxB;AAAA,QACA,GAAI,QAAQ,yBAAyB,UAAa;AAAA,UAChD,sBAAsB,QAAQ;AAAA,QAChC;AAAA,MACF;AAAA,IACF;AAGA,QAAI,QAAQ,aAAa,QAAW;AAClC,aAAO;AAAA,QACL,GAAG;AAAA,QACH,UAAU,QAAQ;AAAA,MACpB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -258,35 +258,33 @@ class DataController extends import_base.BaseController {
258
258
  }
259
259
  }
260
260
  /**
261
- * Decrypts a file owned by the user using their wallet signature.
261
+ * Decrypts a file using wallet-derived decryption key.
262
262
  *
263
263
  * @remarks
264
- * This is the high-level convenience method for decrypting user files, serving as the
265
- * symmetrical counterpart to the `upload` method. It handles the complete decryption
266
- * workflow including key generation, URL protocol detection, content fetching, and
267
- * 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.
268
287
  *
269
- * The method automatically:
270
- * - Generates the decryption key from the user's wallet signature
271
- * - Determines the appropriate fetch method based on the file URL protocol
272
- * - Fetches the encrypted content from IPFS or standard HTTP URLs
273
- * - Decrypts the content using the generated key
274
- *
275
- * For IPFS URLs, the method uses gateway fallback for improved reliability. For
276
- * standard HTTP URLs, it uses a simple fetch. If you need custom authentication
277
- * headers or specific gateway configurations, use the low-level primitives directly.
278
- *
279
- * @param file - The user file to decrypt (typically from getUserFiles)
280
- * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
281
- * @returns Promise resolving to the decrypted file content as a Blob
282
- * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
283
- * @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
284
- * @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
285
- * @throws {Error} "Access denied" - When file returns 403 (no permission)
286
- * @throws {Error} "File is empty or could not be retrieved" - When file has no content
287
- * @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
288
- * @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
289
- * @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
290
288
  * @example
291
289
  * ```typescript
292
290
  * // Basic file decryption
@@ -402,35 +400,38 @@ class DataController extends import_base.BaseController {
402
400
  }
403
401
  }
404
402
  /**
405
- * Retrieves all data files owned by a specific user address.
403
+ * Retrieves all files owned by a specific user address.
406
404
  *
407
405
  * @remarks
408
- * This method queries the Vana subgraph to find files directly owned by the user.
409
- * It efficiently handles large datasets by using the File entity's owner field
410
- * and returns complete file metadata without additional contract calls.
411
- *
412
- * **Deduplication Behavior:**
413
- * The method automatically deduplicates files by ID, keeping only the latest version
414
- * (highest timestamp) when duplicate file IDs are found. This handles cases where
415
- * the subgraph may contain multiple entries for the same file due to re-indexing
416
- * or blockchain reorganizations.
417
- * @param params - The query parameters object
418
- * @param params.owner - The wallet address of the file owner to query
419
- * @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
420
- * @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
421
- * @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
422
- * @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
423
- * @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
424
- * @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
+ *
425
425
  * @example
426
426
  * ```typescript
427
- * // Query files for a specific user
428
427
  * const files = await vana.data.getUserFiles({
429
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
428
+ * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
430
429
  * });
431
430
  *
432
431
  * files.forEach(file => {
433
- * 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"}`);
434
435
  * });
435
436
  * ```
436
437
  */
@@ -1230,18 +1231,26 @@ class DataController extends import_base.BaseController {
1230
1231
  }
1231
1232
  }
1232
1233
  /**
1233
- * 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.
1234
1246
  *
1235
- * @returns Promise resolving to the total file count
1236
1247
  * @example
1237
1248
  * ```typescript
1238
- * const totalFiles = await vana.data.getTotalFilesCount();
1239
- * console.log(`Total files in registry: ${totalFiles}`);
1249
+ * const total = await vana.data.getTotalFilesCount();
1250
+ * console.log(`Total files: ${total}`);
1240
1251
  *
1241
- * // Use for pagination calculations
1242
- * const filesPerPage = 20;
1243
- * const totalPages = Math.ceil(totalFiles / filesPerPage);
1244
- * console.log(`Total pages: ${totalPages}`);
1252
+ * // Calculate pagination
1253
+ * const pages = Math.ceil(total / 20);
1245
1254
  * ```
1246
1255
  */
1247
1256
  async getTotalFilesCount() {
@@ -1268,32 +1277,32 @@ class DataController extends import_base.BaseController {
1268
1277
  }
1269
1278
  }
1270
1279
  /**
1271
- * 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.
1272
1297
  *
1273
- * @param fileId - The file ID to look up
1274
- * @returns Promise resolving to UserFile object
1275
- * @throws {Error} "Chain ID not available" - When wallet chain is not configured
1276
- * @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
1277
- * @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
1278
1298
  * @example
1279
1299
  * ```typescript
1280
- * try {
1281
- * const file = await vana.data.getFileById(123);
1282
- * console.log('File details:', {
1283
- * id: file.id,
1284
- * url: file.url,
1285
- * owner: file.ownerAddress,
1286
- * addedAt: file.addedAtBlock
1287
- * });
1288
- * } catch (error) {
1289
- * console.error('File not found or error retrieving file:', error);
1290
- * }
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}`);
1291
1305
  * ```
1292
- *
1293
- * This method queries the DataRegistry contract directly
1294
- * to get file details for any file ID, regardless of user ownership.
1295
- * This is useful for file lookup functionality where users can search
1296
- * for specific files by ID.
1297
1306
  */
1298
1307
  async getFileById(fileId) {
1299
1308
  try {
@@ -1364,7 +1373,7 @@ class DataController extends import_base.BaseController {
1364
1373
  * console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
1365
1374
  * ```
1366
1375
  */
1367
- async registerFileWithSchema(url, schemaId) {
1376
+ async registerFileWithSchema(url, schemaId, options) {
1368
1377
  this.assertWallet();
1369
1378
  try {
1370
1379
  const chainId = this.context.publicClient.chain?.id;
@@ -1382,7 +1391,8 @@ class DataController extends import_base.BaseController {
1382
1391
  functionName: "addFileWithSchema",
1383
1392
  args: [url, BigInt(schemaId)],
1384
1393
  account,
1385
- chain: this.context.walletClient.chain ?? null
1394
+ chain: this.context.walletClient.chain ?? null,
1395
+ ...this.spreadTransactionOptions(options)
1386
1396
  });
1387
1397
  const { tx } = await import("../utils/transactionHelpers");
1388
1398
  return tx({
@@ -1420,7 +1430,7 @@ class DataController extends import_base.BaseController {
1420
1430
  * with specific permissions on the DataRegistry contract. It can be used
1421
1431
  * by both direct transactions and relayer services.
1422
1432
  */
1423
- async addFileWithPermissions(url, ownerAddress, permissions = []) {
1433
+ async addFileWithPermissions(url, ownerAddress, permissions = [], options) {
1424
1434
  this.assertWallet();
1425
1435
  try {
1426
1436
  const chainId = this.context.publicClient.chain?.id;
@@ -1438,7 +1448,8 @@ class DataController extends import_base.BaseController {
1438
1448
  functionName: "addFileWithPermissions",
1439
1449
  args: [url, ownerAddress, permissions],
1440
1450
  account,
1441
- chain: this.context.walletClient.chain ?? null
1451
+ chain: this.context.walletClient.chain ?? null,
1452
+ ...this.spreadTransactionOptions(options)
1442
1453
  });
1443
1454
  const { tx } = await import("../utils/transactionHelpers");
1444
1455
  return tx({
@@ -1493,7 +1504,7 @@ class DataController extends import_base.BaseController {
1493
1504
  * console.log(`File ${result.fileId} registered in tx ${result.hash}`);
1494
1505
  * ```
1495
1506
  */
1496
- async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0) {
1507
+ async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1497
1508
  this.assertWallet();
1498
1509
  try {
1499
1510
  let encryptedPermissions = [];
@@ -1527,7 +1538,8 @@ class DataController extends import_base.BaseController {
1527
1538
  url,
1528
1539
  ownerAddress,
1529
1540
  encryptedPermissions,
1530
- schemaId
1541
+ schemaId,
1542
+ options
1531
1543
  );
1532
1544
  } catch (error) {
1533
1545
  console.error("Failed to add file with permissions and schema:", error);
@@ -1574,7 +1586,7 @@ class DataController extends import_base.BaseController {
1574
1586
  * console.log(`File registered in tx ${result.hash}`);
1575
1587
  * ```
1576
1588
  */
1577
- async addFileWithEncryptedPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0) {
1589
+ async addFileWithEncryptedPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1578
1590
  try {
1579
1591
  const chainId = this.context.publicClient.chain?.id;
1580
1592
  if (!chainId) {
@@ -1591,7 +1603,8 @@ class DataController extends import_base.BaseController {
1591
1603
  functionName: "addFileWithPermissionsAndSchema",
1592
1604
  args: [url, ownerAddress, permissions, BigInt(schemaId)],
1593
1605
  account,
1594
- chain: this.context.walletClient.chain ?? null
1606
+ chain: this.context.walletClient.chain ?? null,
1607
+ ...this.spreadTransactionOptions(options)
1595
1608
  });
1596
1609
  const { tx } = await import("../utils/transactionHelpers");
1597
1610
  return tx({
@@ -1608,34 +1621,38 @@ class DataController extends import_base.BaseController {
1608
1621
  }
1609
1622
  }
1610
1623
  /**
1611
- * Adds a new refiner to the DataRefinerRegistry.
1624
+ * Registers a data refiner for processing templates.
1612
1625
  *
1613
1626
  * @remarks
1614
- * Refiners are data processing templates that define how raw data should be
1615
- * transformed into structured formats. Each refiner is associated with a DLP
1616
- * (Data Liquidity Pool), has a specific schema for output, and includes
1617
- * instructions for the refinement process.
1618
- *
1619
- * @param params - Refiner configuration parameters
1620
- * @param params.dlpId - The Data Liquidity Pool ID this refiner belongs to
1621
- * @param params.name - Human-readable name for the refiner
1622
- * @param params.schemaId - Schema ID that defines the output format
1623
- * @param params.refinementInstructionUrl - URL containing processing instructions
1624
- * @returns Promise resolving to the new refiner ID and transaction hash
1625
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1626
- * @throws {Error} When transaction fails - "Failed to add refiner: {error}"
1627
+ * Refiners define data transformation rules for DLPs.
1628
+ * Associates schema, instructions, and processing logic.
1629
+ *
1630
+ * @param params - Refiner configuration
1631
+ * @param params.dlpId - Data Liquidity Pool ID
1632
+ * @param params.name - Refiner display name
1633
+ * @param params.schemaId - Output schema ID.
1634
+ * Obtain via `vana.schemas.list()`.
1635
+ * @param params.refinementInstructionUrl - Processing instructions URL
1636
+ *
1637
+ * @returns Refiner ID and transaction hash
1638
+ *
1639
+ * @throws {Error} Chain ID not available.
1640
+ * Ensure network connection.
1641
+ * @throws {Error} Transaction failed.
1642
+ * Check wallet balance and network status.
1643
+ *
1627
1644
  * @example
1628
1645
  * ```typescript
1629
1646
  * const result = await vana.data.addRefiner({
1630
1647
  * dlpId: 1,
1631
- * name: "Social Media Sentiment Analyzer",
1648
+ * name: "Sentiment Analyzer",
1632
1649
  * schemaId: 42,
1633
1650
  * refinementInstructionUrl: "ipfs://QmXxx..."
1634
1651
  * });
1635
- * console.log(`Created refiner ${result.refinerId} in tx ${result.transactionHash}`);
1652
+ * console.log(`Refiner ${result.refinerId} created`);
1636
1653
  * ```
1637
1654
  */
1638
- async addRefiner(params) {
1655
+ async addRefiner(params, options) {
1639
1656
  this.assertWallet();
1640
1657
  try {
1641
1658
  const chainId = this.context.publicClient.chain?.id;
@@ -1661,7 +1678,8 @@ class DataController extends import_base.BaseController {
1661
1678
  params.refinementInstructionUrl
1662
1679
  ],
1663
1680
  account,
1664
- chain: this.context.walletClient.chain ?? null
1681
+ chain: this.context.walletClient.chain ?? null,
1682
+ ...this.spreadTransactionOptions(options)
1665
1683
  });
1666
1684
  const { tx } = await import("../utils/transactionHelpers");
1667
1685
  const txResult = tx({
@@ -1690,26 +1708,29 @@ class DataController extends import_base.BaseController {
1690
1708
  }
1691
1709
  }
1692
1710
  /**
1693
- * Retrieves a refiner by its ID.
1711
+ * Retrieves refiner configuration by ID.
1694
1712
  *
1695
1713
  * @remarks
1696
- * Queries the DataRefinerRegistry contract to get complete information about
1697
- * a specific refiner including its DLP association, schema, and instructions.
1714
+ * Queries DataRefinerRegistry for refiner details.
1715
+ * Returns DLP association, schema, and processing instructions.
1716
+ *
1717
+ * @param refinerId - Numeric refiner ID
1718
+ *
1719
+ * @returns Refiner configuration object
1720
+ *
1721
+ * @throws {Error} Chain ID not available.
1722
+ * Ensure network connection.
1723
+ * @throws {Error} Refiner not found.
1724
+ * Verify refiner ID exists.
1725
+ * @throws {Error} Contract read failed.
1726
+ * Check network and RPC status.
1698
1727
  *
1699
- * @param refinerId - The numeric refiner ID to retrieve
1700
- * @returns Promise resolving to the refiner information object
1701
- * @throws {Error} When chain ID is not available - "Chain ID not available"
1702
- * @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
1703
- * @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
1704
1728
  * @example
1705
1729
  * ```typescript
1706
1730
  * const refiner = await vana.data.getRefiner(1);
1707
- * console.log({
1708
- * name: refiner.name,
1709
- * dlp: refiner.dlpId,
1710
- * schema: refiner.schemaId,
1711
- * instructions: refiner.refinementInstructionUrl
1712
- * });
1731
+ * console.log(`Refiner: ${refiner.name}`);
1732
+ * console.log(`DLP: ${refiner.dlpId}`);
1733
+ * console.log(`Schema: ${refiner.schemaId}`);
1713
1734
  * ```
1714
1735
  */
1715
1736
  async getRefiner(refinerId) {
@@ -1750,21 +1771,27 @@ class DataController extends import_base.BaseController {
1750
1771
  }
1751
1772
  }
1752
1773
  /**
1753
- * Validates if a schema ID exists in the registry.
1774
+ * Validates schema ID existence.
1754
1775
  *
1755
1776
  * @remarks
1756
- * Checks the DataRefinerRegistry contract to determine if a given schema ID
1757
- * has been registered and is available for use.
1777
+ * Verifies schema registration in DataRegistry.
1778
+ * Check before using schemas for uploads.
1779
+ *
1780
+ * @param schemaId - Numeric schema ID to validate
1781
+ *
1782
+ * @returns True if schema exists, false otherwise
1783
+ *
1784
+ * @throws {Error} Chain ID not available.
1785
+ * Ensure network connection.
1786
+ * @throws {Error} Contract read failed.
1787
+ * Check RPC availability.
1758
1788
  *
1759
- * @param schemaId - The numeric schema ID to validate
1760
- * @returns Promise resolving to true if schema exists, false otherwise
1761
1789
  * @example
1762
1790
  * ```typescript
1763
- * const isValid = await vana.data.isValidSchemaId(42);
1764
- * if (isValid) {
1765
- * console.log('Schema 42 is available for use');
1766
- * } else {
1767
- * console.log('Schema 42 does not exist');
1791
+ * const valid = await vana.data.isValidSchemaId(42);
1792
+ * if (valid) {
1793
+ * // Safe to use schema 42
1794
+ * await vana.data.upload({ schemaId: 42, ... });
1768
1795
  * }
1769
1796
  * ```
1770
1797
  */
@@ -1852,7 +1879,7 @@ class DataController extends import_base.BaseController {
1852
1879
  * console.log(`Schema updated in tx ${result.transactionHash}`);
1853
1880
  * ```
1854
1881
  */
1855
- async updateSchemaId(params) {
1882
+ async updateSchemaId(params, options) {
1856
1883
  this.assertWallet();
1857
1884
  try {
1858
1885
  const chainId = this.context.publicClient.chain?.id;
@@ -1872,7 +1899,8 @@ class DataController extends import_base.BaseController {
1872
1899
  functionName: "updateSchemaId",
1873
1900
  args: [BigInt(params.refinerId), BigInt(params.newSchemaId)],
1874
1901
  account,
1875
- chain: this.context.walletClient.chain ?? null
1902
+ chain: this.context.walletClient.chain ?? null,
1903
+ ...this.spreadTransactionOptions(options)
1876
1904
  });
1877
1905
  await this.context.publicClient.waitForTransactionReceipt({ hash });
1878
1906
  return {
@@ -2078,10 +2106,10 @@ class DataController extends import_base.BaseController {
2078
2106
  * console.log(`Transaction: ${result.transactionHash}`);
2079
2107
  * ```
2080
2108
  */
2081
- async addPermissionToFile(params) {
2109
+ async addPermissionToFile(params, options) {
2082
2110
  this.assertWallet();
2083
2111
  const { fileId, account, publicKey } = params;
2084
- return await this.submitFilePermission(fileId, account, publicKey);
2112
+ return await this.submitFilePermission(fileId, account, publicKey, options);
2085
2113
  }
2086
2114
  /**
2087
2115
  * Submits a file permission transaction to the blockchain.
@@ -2111,7 +2139,7 @@ class DataController extends import_base.BaseController {
2111
2139
  * console.log(`Permission granted with ID: ${result.permissionId}`);
2112
2140
  * ```
2113
2141
  */
2114
- async submitFilePermission(fileId, account, publicKey) {
2142
+ async submitFilePermission(fileId, account, publicKey, options) {
2115
2143
  this.assertWallet();
2116
2144
  try {
2117
2145
  const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
@@ -2138,7 +2166,8 @@ class DataController extends import_base.BaseController {
2138
2166
  functionName: "addFilePermission",
2139
2167
  args: [BigInt(fileId), account, encryptedKey],
2140
2168
  account: walletAccount,
2141
- chain: this.context.walletClient.chain ?? null
2169
+ chain: this.context.walletClient.chain ?? null,
2170
+ ...this.spreadTransactionOptions(options)
2142
2171
  });
2143
2172
  const { tx } = await import("../utils/transactionHelpers");
2144
2173
  return tx({