@opendatalabs/vana-sdk 0.1.0-alpha.cb72de2 → 0.1.0-alpha.d44f792

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.
@@ -805,12 +805,16 @@ interface StorageRequiredMarker {
805
805
  * ```
806
806
  */
807
807
  interface StorageConfig {
808
- /** Map of provider name to storage provider instance.
808
+ /**
809
+ * Map of provider name to storage provider instance.
809
810
  * Common provider names: "ipfs", "pinata", "googledrive", "s3".
810
- * Custom names allowed for custom provider implementations. */
811
+ * Custom names allowed for custom provider implementations.
812
+ */
811
813
  providers: Record<string, StorageProvider>;
812
- /** Default provider name to use when none specified.
813
- * Must match a key in the providers map. Falls back to first provider if not specified. */
814
+ /**
815
+ * Default provider name to use when none specified.
816
+ * Must match a key in the providers map. Falls back to first provider if not specified.
817
+ */
814
818
  defaultProvider?: string;
815
819
  }
816
820
  /**
@@ -878,7 +882,21 @@ interface RelayerCallbacks {
878
882
  /**
879
883
  * Submit a file addition for relay
880
884
  *
881
- * @deprecated Use submitFileAdditionComplete for full support.
885
+ * @deprecated Since v2.0.0 - Use submitFileAdditionComplete() instead for full support.
886
+ * Will be removed in v3.0.0.
887
+ *
888
+ * Migration guide:
889
+ * ```typescript
890
+ * // Old:
891
+ * await submitFileAddition(url, userAddress);
892
+ *
893
+ * // New:
894
+ * await submitFileAdditionComplete({
895
+ * url,
896
+ * userAddress,
897
+ * permissions: [] // Optional
898
+ * });
899
+ * ```
882
900
  * @param url - The file URL to register
883
901
  * @param userAddress - The user's address
884
902
  * @returns Promise resolving to object with fileId and transactionHash
@@ -890,7 +908,21 @@ interface RelayerCallbacks {
890
908
  /**
891
909
  * Submit a file addition with permissions for relay
892
910
  *
893
- * @deprecated Use submitFileAdditionComplete for full support.
911
+ * @deprecated Since v2.0.0 - Use submitFileAdditionComplete() instead for full support.
912
+ * Will be removed in v3.0.0.
913
+ *
914
+ * Migration guide:
915
+ * ```typescript
916
+ * // Old:
917
+ * await submitFileAdditionWithPermissions(url, userAddress, permissions);
918
+ *
919
+ * // New:
920
+ * await submitFileAdditionComplete({
921
+ * url,
922
+ * userAddress,
923
+ * permissions
924
+ * });
925
+ * ```
894
926
  * @param url - The file URL to register
895
927
  * @param userAddress - The user's address
896
928
  * @param permissions - Array of encrypted permissions
@@ -1064,9 +1096,11 @@ interface BaseConfig {
1064
1096
  * Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.
1065
1097
  */
1066
1098
  relayerCallbacks?: RelayerCallbacks;
1067
- /** Optional storage providers configuration for file upload/download.
1099
+ /**
1100
+ * Optional storage providers configuration for file upload/download.
1068
1101
  * Required for: upload(), grant() without pre-stored URLs, schema operations.
1069
- * See StorageConfig for provider selection guidance. */
1102
+ * See StorageConfig for provider selection guidance.
1103
+ */
1070
1104
  storage?: StorageConfig;
1071
1105
  /**
1072
1106
  * Optional subgraph URL for querying user files and permissions.
@@ -1141,17 +1175,23 @@ interface WalletConfigWithStorage extends BaseConfigWithStorage {
1141
1175
  * @category Configuration
1142
1176
  */
1143
1177
  interface ChainConfig extends BaseConfig {
1144
- /** The chain ID for Vana network.
1178
+ /**
1179
+ * The chain ID for Vana network.
1145
1180
  * Supported: 14800 (Vana Mainnet), 14801 (Moksha Testnet), 31337 (Local Development).
1146
- * Use chain constants from '@vana/sdk' for type safety. */
1181
+ * Use chain constants from '@vana/sdk' for type safety.
1182
+ */
1147
1183
  chainId: VanaChainId;
1148
- /** RPC URL for the chain (optional, will use default for the chain if not provided).
1184
+ /**
1185
+ * RPC URL for the chain (optional, will use default for the chain if not provided).
1149
1186
  * Default URLs: mainnet (https://rpc.vana.org), testnet (https://rpc.moksha.vana.org).
1150
- * Override for custom nodes or local development. */
1187
+ * Override for custom nodes or local development.
1188
+ */
1151
1189
  rpcUrl?: string;
1152
- /** Optional account for signing transactions.
1190
+ /**
1191
+ * Optional account for signing transactions.
1153
1192
  * Can be: privateKeyToAccount(), mnemonicToAccount(), or custom Account implementation.
1154
- * Required for write operations; read-only operations work without account. */
1193
+ * Required for write operations; read-only operations work without account.
1194
+ */
1155
1195
  account?: Account;
1156
1196
  }
1157
1197
  /**
@@ -27442,7 +27482,7 @@ declare class CallbackStorage implements StorageProvider {
27442
27482
  * const result2 = await storage.upload(fileBlob, 'myfile.json', 'pinata');
27443
27483
  * ```
27444
27484
  * @category Storage
27445
- * @see {@link [URL_PLACEHOLDER] | Storage Providers Guide} for configuration details
27485
+ * @see {@link https://docs.vana.com/developer/vana-sdk-documentation/core-modules/storage-providers | Storage Providers Guide} for configuration details
27446
27486
  */
27447
27487
  declare class StorageManager {
27448
27488
  private providers;
@@ -27847,7 +27887,7 @@ interface ControllerContext$1 {
27847
27887
  * const permissions = await vana.permissions.getUserPermissionGrantsOnChain();
27848
27888
  * ```
27849
27889
  * @category Permissions
27850
- * @see {@link [URL_PLACEHOLDER] | Vana Permissions System} for conceptual overview
27890
+ * @see {@link https://docs.vana.com/developer/permissions | Vana Permissions System} for conceptual overview
27851
27891
  */
27852
27892
  declare class PermissionsController {
27853
27893
  private readonly context;
@@ -27922,6 +27962,8 @@ declare class PermissionsController {
27922
27962
  * until the returned `confirm()` function is called.
27923
27963
  * @param params - The permission grant parameters
27924
27964
  * @returns A promise resolving to a preview object and confirm function
27965
+ * @throws {SerializationError} When grant parameters are invalid or cannot be serialized
27966
+ * @throws {BlockchainError} When grant validation fails or preparation encounters an error
27925
27967
  * @example
27926
27968
  * ```typescript
27927
27969
  * const { preview, confirm } = await vana.permissions.prepareGrant({
@@ -28045,7 +28087,7 @@ declare class PermissionsController {
28045
28087
  * use `submitPermissionRevoke()` instead.
28046
28088
  *
28047
28089
  * @param params - Parameters for revoking the permission
28048
- * @param params.permissionId - Permission identifier as bigint for contract compatibility.
28090
+ * @param params.permissionId - Permission identifier (accepts bigint, number, or string).
28049
28091
  * Obtain from permission grants via `getUserPermissionGrantsOnChain()`.
28050
28092
  * @returns Promise resolving to revocation data from PermissionRevoked event
28051
28093
  * @throws {BlockchainError} When revocation fails or event parsing fails
@@ -28087,12 +28129,20 @@ declare class PermissionsController {
28087
28129
  *
28088
28130
  * @param params - Parameters for revoking the permission
28089
28131
  * @returns Promise resolving to transaction hash
28132
+ * @throws {BlockchainError} When chain ID is not available
28133
+ * @throws {NonceError} When retrieving user nonce fails
28134
+ * @throws {SignatureError} When user rejects the signature request
28135
+ * @throws {RelayerError} When gasless submission fails
28136
+ * @throws {PermissionError} When revocation fails for any other reason
28090
28137
  */
28091
28138
  revokeWithSignature(params: RevokePermissionParams): Promise<Hash>;
28092
28139
  /**
28093
28140
  * Retrieves the user's current nonce from the DataPermissions contract.
28094
28141
  *
28095
28142
  * @returns Promise resolving to the user's current nonce value
28143
+ * @throws {Error} When wallet account is not available
28144
+ * @throws {Error} When chain ID is not available
28145
+ * @throws {NonceError} When reading nonce from contract fails
28096
28146
  */
28097
28147
  private getUserNonce;
28098
28148
  /**
@@ -28168,6 +28218,7 @@ declare class PermissionsController {
28168
28218
  *
28169
28219
  * @param fileId - The file ID to query permissions for
28170
28220
  * @returns Promise resolving to array of permission IDs
28221
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28171
28222
  */
28172
28223
  getFilePermissionIds(fileId: bigint): Promise<bigint[]>;
28173
28224
  /**
@@ -28175,6 +28226,7 @@ declare class PermissionsController {
28175
28226
  *
28176
28227
  * @param permissionId - The permission ID to query files for
28177
28228
  * @returns Promise resolving to array of file IDs
28229
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28178
28230
  */
28179
28231
  getPermissionFileIds(permissionId: bigint): Promise<bigint[]>;
28180
28232
  /**
@@ -28182,6 +28234,7 @@ declare class PermissionsController {
28182
28234
  *
28183
28235
  * @param permissionId - The permission ID to check
28184
28236
  * @returns Promise resolving to boolean indicating if permission is active
28237
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28185
28238
  */
28186
28239
  isActivePermission(permissionId: bigint): Promise<boolean>;
28187
28240
  /**
@@ -28189,6 +28242,7 @@ declare class PermissionsController {
28189
28242
  *
28190
28243
  * @param permissionId - The permission ID to query
28191
28244
  * @returns Promise resolving to permission info
28245
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28192
28246
  */
28193
28247
  getPermissionInfo(permissionId: bigint): Promise<PermissionInfo>;
28194
28248
  /**
@@ -28203,7 +28257,12 @@ declare class PermissionsController {
28203
28257
  * Trusts a server for data processing.
28204
28258
  *
28205
28259
  * @param params - Parameters for trusting the server
28260
+ * @param params.serverId - The server's Ethereum address
28261
+ * @param params.serverUrl - The server's URL endpoint
28206
28262
  * @returns Promise resolving to transaction hash
28263
+ * @throws {UserRejectedRequestError} When user rejects the transaction
28264
+ * @throws {BlockchainError} When chain ID is unavailable or transaction fails
28265
+ * @throws {Error} When wallet account is not available
28207
28266
  * @example
28208
28267
  * ```typescript
28209
28268
  * // Trust a server by providing its ID and URL
@@ -28224,6 +28283,12 @@ declare class PermissionsController {
28224
28283
  *
28225
28284
  * @param params - Parameters for trusting the server
28226
28285
  * @returns Promise resolving to transaction hash
28286
+ * @throws {BlockchainError} When chain ID is not available
28287
+ * @throws {NonceError} When retrieving user nonce fails
28288
+ * @throws {SignatureError} When user rejects the signature request
28289
+ * @throws {RelayerError} When gasless submission fails
28290
+ * @throws {ServerUrlMismatchError} When server URL doesn't match existing registration
28291
+ * @throws {BlockchainError} When trust operation fails for any other reason
28227
28292
  */
28228
28293
  trustServerWithSignature(params: TrustServerParams): Promise<Hash>;
28229
28294
  /**
@@ -28237,14 +28302,25 @@ declare class PermissionsController {
28237
28302
  * Untrusts a server.
28238
28303
  *
28239
28304
  * @param params - Parameters for untrusting the server
28305
+ * @param params.serverId - The server's Ethereum address to untrust
28240
28306
  * @returns Promise resolving to transaction hash
28307
+ * @throws {Error} When wallet account is not available
28308
+ * @throws {NonceError} When retrieving user nonce fails
28309
+ * @throws {UserRejectedRequestError} When user rejects the transaction
28310
+ * @throws {BlockchainError} When untrust transaction fails
28241
28311
  */
28242
28312
  untrustServer(params: UntrustServerParams): Promise<Hash>;
28243
28313
  /**
28244
28314
  * Untrusts a server using a signature (gasless transaction).
28245
28315
  *
28246
28316
  * @param params - Parameters for untrusting the server
28317
+ * @param params.serverId - The server's Ethereum address to untrust
28247
28318
  * @returns Promise resolving to transaction hash
28319
+ * @throws {Error} When wallet account is not available
28320
+ * @throws {NonceError} When retrieving user nonce fails
28321
+ * @throws {SignatureError} When user rejects the signature request
28322
+ * @throws {RelayerError} When gasless submission fails
28323
+ * @throws {BlockchainError} When untrust transaction fails
28248
28324
  */
28249
28325
  untrustServerWithSignature(params: UntrustServerParams): Promise<Hash>;
28250
28326
  /**
@@ -28252,6 +28328,7 @@ declare class PermissionsController {
28252
28328
  *
28253
28329
  * @param userAddress - Optional user address (defaults to current user)
28254
28330
  * @returns Promise resolving to array of trusted server addresses
28331
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28255
28332
  */
28256
28333
  getTrustedServers(userAddress?: Address): Promise<Address[]>;
28257
28334
  /**
@@ -28259,6 +28336,7 @@ declare class PermissionsController {
28259
28336
  *
28260
28337
  * @param serverId - Server address
28261
28338
  * @returns Promise resolving to server information
28339
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28262
28340
  */
28263
28341
  getServerInfo(serverId: Address): Promise<Server>;
28264
28342
  /**
@@ -28266,6 +28344,7 @@ declare class PermissionsController {
28266
28344
  *
28267
28345
  * @param userAddress - Optional user address (defaults to current user)
28268
28346
  * @returns Promise resolving to the number of trusted servers
28347
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28269
28348
  */
28270
28349
  getTrustedServersCount(userAddress?: Address): Promise<number>;
28271
28350
  /**
@@ -28273,6 +28352,7 @@ declare class PermissionsController {
28273
28352
  *
28274
28353
  * @param options - Query options including pagination parameters
28275
28354
  * @returns Promise resolving to paginated trusted servers
28355
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28276
28356
  */
28277
28357
  getTrustedServersPaginated(options?: TrustedServerQueryOptions): Promise<PaginatedTrustedServers>;
28278
28358
  /**
@@ -28280,6 +28360,7 @@ declare class PermissionsController {
28280
28360
  *
28281
28361
  * @param options - Query options
28282
28362
  * @returns Promise resolving to array of trusted server info
28363
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28283
28364
  */
28284
28365
  getTrustedServersWithInfo(options?: TrustedServerQueryOptions): Promise<TrustedServerInfo[]>;
28285
28366
  /**
@@ -28287,6 +28368,7 @@ declare class PermissionsController {
28287
28368
  *
28288
28369
  * @param serverIds - Array of server IDs to query
28289
28370
  * @returns Promise resolving to batch result with successes and failures
28371
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
28290
28372
  */
28291
28373
  getServerInfoBatch(serverIds: Address[]): Promise<BatchServerInfoResult>;
28292
28374
  /**
@@ -29706,30 +29788,147 @@ interface RelayerWebhookPayload {
29706
29788
  /**
29707
29789
  * Makes all properties in T optional except for those in K
29708
29790
  *
29791
+ * @remarks
29792
+ * This utility type is useful when you want to create a variant of an interface
29793
+ * where most properties are optional, but specific properties remain required.
29794
+ * Commonly used for update operations where only certain fields must be provided.
29795
+ *
29796
+ * @example
29797
+ * ```typescript
29798
+ * interface User {
29799
+ * id: string;
29800
+ * name: string;
29801
+ * email: string;
29802
+ * age: number;
29803
+ * }
29804
+ *
29805
+ * // Only 'id' is required, all other properties are optional
29806
+ * type UserUpdate = PartialExcept<User, 'id'>;
29807
+ *
29808
+ * const update: UserUpdate = {
29809
+ * id: '123', // Required
29810
+ * name: 'John' // Optional
29811
+ * // email and age are also optional
29812
+ * };
29813
+ * ```
29709
29814
  * @category Reference
29710
29815
  */
29711
29816
  type PartialExcept<T, K extends keyof T> = Partial<T> & Pick<T, K>;
29712
29817
  /**
29713
29818
  * Makes all properties in T required except for those in K
29714
29819
  *
29820
+ * @remarks
29821
+ * This utility type is useful when you want to create a variant of an interface
29822
+ * where most properties are required, but specific properties remain optional.
29823
+ * Commonly used for creation operations where most fields are mandatory.
29824
+ *
29825
+ * @example
29826
+ * ```typescript
29827
+ * interface Config {
29828
+ * apiUrl: string;
29829
+ * timeout?: number;
29830
+ * retries?: number;
29831
+ * debug?: boolean;
29832
+ * }
29833
+ *
29834
+ * // All properties required except 'debug'
29835
+ * type StrictConfig = RequiredExcept<Config, 'debug'>;
29836
+ *
29837
+ * const config: StrictConfig = {
29838
+ * apiUrl: 'https://api.vana.com', // Required
29839
+ * timeout: 5000, // Required (was optional, now required)
29840
+ * retries: 3, // Required (was optional, now required)
29841
+ * // debug remains optional
29842
+ * };
29843
+ * ```
29715
29844
  * @category Reference
29716
29845
  */
29717
29846
  type RequiredExcept<T, K extends keyof T> = Required<T> & Partial<Pick<T, K>>;
29718
29847
  /**
29719
29848
  * Extracts the return type of a promise
29720
29849
  *
29850
+ * @remarks
29851
+ * This utility type unwraps the type contained within a Promise.
29852
+ * If the type is not a Promise, it returns the type unchanged.
29853
+ * Note: TypeScript 4.5+ includes a built-in Awaited type with similar functionality.
29854
+ *
29855
+ * @example
29856
+ * ```typescript
29857
+ * type AsyncString = Promise<string>;
29858
+ * type SyncString = string;
29859
+ *
29860
+ * // Extracts 'string' from Promise<string>
29861
+ * type Result1 = Awaited<AsyncString>; // string
29862
+ *
29863
+ * // Returns 'string' unchanged since it's not a Promise
29864
+ * type Result2 = Awaited<SyncString>; // string
29865
+ *
29866
+ * // Practical usage with async functions
29867
+ * async function fetchUser(): Promise<{ id: string; name: string }> {
29868
+ * // ...
29869
+ * }
29870
+ *
29871
+ * type User = Awaited<ReturnType<typeof fetchUser>>; // { id: string; name: string }
29872
+ * ```
29721
29873
  * @category Reference
29722
29874
  */
29723
29875
  type Awaited<T> = T extends Promise<infer U> ? U : T;
29724
29876
  /**
29725
29877
  * Creates a type that accepts either T or a Promise<T>
29726
29878
  *
29879
+ * @remarks
29880
+ * This utility type is useful for functions that can work with both
29881
+ * synchronous and asynchronous values. It allows flexible APIs that
29882
+ * can accept immediate values or promises that resolve to those values.
29883
+ *
29884
+ * @example
29885
+ * ```typescript
29886
+ * // Function that accepts either a value or a promise of that value
29887
+ * async function processData(data: MaybePromise<string>): Promise<string> {
29888
+ * // await works on both promises and regular values
29889
+ * const resolved = await data;
29890
+ * return resolved.toUpperCase();
29891
+ * }
29892
+ *
29893
+ * // Both calls are valid:
29894
+ * processData('hello'); // Synchronous value
29895
+ * processData(Promise.resolve('world')); // Asynchronous value
29896
+ *
29897
+ * // Common use case in SDK callbacks
29898
+ * interface StorageProvider {
29899
+ * // Provider can implement sync or async file reading
29900
+ * read(path: string): MaybePromise<Buffer>;
29901
+ * }
29902
+ * ```
29727
29903
  * @category Reference
29728
29904
  */
29729
29905
  type MaybePromise<T> = T | Promise<T>;
29730
29906
  /**
29731
29907
  * Creates a type that accepts either T or an array of T
29732
29908
  *
29909
+ * @remarks
29910
+ * This utility type is useful for functions that can accept either a single
29911
+ * value or an array of values, providing a more flexible API. The implementation
29912
+ * can normalize the input to always work with arrays internally.
29913
+ *
29914
+ * @example
29915
+ * ```typescript
29916
+ * // Function that accepts either a single ID or multiple IDs
29917
+ * function deleteItems(ids: MaybeArray<string>): void {
29918
+ * // Normalize to array
29919
+ * const idArray = Array.isArray(ids) ? ids : [ids];
29920
+ * idArray.forEach(id => console.log(`Deleting ${id}`));
29921
+ * }
29922
+ *
29923
+ * // Both calls are valid:
29924
+ * deleteItems('item-1'); // Single item
29925
+ * deleteItems(['item-1', 'item-2', 'item-3']); // Multiple items
29926
+ *
29927
+ * // Common use case in permissions
29928
+ * interface GrantPermissionsParams {
29929
+ * permissions: MaybeArray<Permission>;
29930
+ * }
29931
+ * ```
29733
29932
  * @category Reference
29734
29933
  */
29735
29934
  type MaybeArray<T> = T | T[];
@@ -29763,8 +29962,35 @@ interface PaginationParams {
29763
29962
  cursor?: string;
29764
29963
  }
29765
29964
  /**
29766
- * Pagination result
29965
+ * Pagination result containing items and metadata for navigating large datasets.
29966
+ *
29967
+ * @remarks
29968
+ * This interface standardizes paginated responses across the SDK, providing
29969
+ * consistent metadata for implementing pagination UI components and handling
29970
+ * multi-page data fetching. Supports both offset-based and cursor-based pagination.
29767
29971
  *
29972
+ * @example
29973
+ * ```typescript
29974
+ * // Fetching paginated user files
29975
+ * async function getAllUserFiles(userAddress: string): Promise<File[]> {
29976
+ * const allFiles: File[] = [];
29977
+ * let cursor: string | undefined;
29978
+ *
29979
+ * do {
29980
+ * const result: PaginationResult<File> = await vana.data.getUserFiles({
29981
+ * owner: userAddress,
29982
+ * pagination: { limit: 50, cursor }
29983
+ * });
29984
+ *
29985
+ * allFiles.push(...result.items);
29986
+ * cursor = result.nextCursor;
29987
+ *
29988
+ * console.log(`Fetched ${result.count} of ${result.total} files`);
29989
+ * } while (result.hasMore);
29990
+ *
29991
+ * return allFiles;
29992
+ * }
29993
+ * ```
29768
29994
  * @category Reference
29769
29995
  */
29770
29996
  interface PaginationResult<T> {
@@ -29780,8 +30006,33 @@ interface PaginationResult<T> {
29780
30006
  nextCursor?: string;
29781
30007
  }
29782
30008
  /**
29783
- * Block range parameters
30009
+ * Block range parameters for filtering blockchain events and transactions.
30010
+ *
30011
+ * @remarks
30012
+ * Used to specify a range of blocks when querying blockchain data.
30013
+ * Both parameters are optional - omitting fromBlock starts from genesis,
30014
+ * omitting toBlock goes to the latest block. Be cautious with large ranges
30015
+ * as they may result in heavy RPC loads or timeouts.
29784
30016
  *
30017
+ * @example
30018
+ * ```typescript
30019
+ * // Get events from the last 1000 blocks
30020
+ * const currentBlock = await vana.protocol.getBlockNumber();
30021
+ * const events = await vana.protocol.getEvents({
30022
+ * blockRange: {
30023
+ * fromBlock: currentBlock - 1000n,
30024
+ * toBlock: currentBlock
30025
+ * }
30026
+ * });
30027
+ *
30028
+ * // Get all historical events (use with caution)
30029
+ * const allEvents = await vana.protocol.getEvents({
30030
+ * blockRange: {
30031
+ * fromBlock: 0n
30032
+ * // toBlock omitted = up to latest
30033
+ * }
30034
+ * });
30035
+ * ```
29785
30036
  * @category Reference
29786
30037
  */
29787
30038
  interface BlockRange {
@@ -29791,8 +30042,34 @@ interface BlockRange {
29791
30042
  toBlock?: bigint;
29792
30043
  }
29793
30044
  /**
29794
- * Transaction options
30045
+ * Transaction options for customizing blockchain transaction parameters.
29795
30046
  *
30047
+ * @remarks
30048
+ * Provides fine-grained control over transaction execution. Supports both
30049
+ * legacy (gasPrice) and EIP-1559 (maxFeePerGas) transaction types. When
30050
+ * not specified, the SDK will use appropriate defaults based on network
30051
+ * conditions. Use these options to optimize for speed or cost.
30052
+ *
30053
+ * @example
30054
+ * ```typescript
30055
+ * // High priority transaction with EIP-1559 pricing
30056
+ * await vana.permissions.grant(params, {
30057
+ * maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
30058
+ * maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
30059
+ * });
30060
+ *
30061
+ * // Legacy transaction with specific gas limit
30062
+ * await vana.data.registerFile(params, {
30063
+ * gasLimit: 500000n,
30064
+ * gasPrice: 50n * 10n ** 9n // 50 gwei
30065
+ * });
30066
+ *
30067
+ * // Send ETH with the transaction
30068
+ * await vana.protocol.execute(params, {
30069
+ * value: 10n ** 18n, // 1 ETH
30070
+ * gasLimit: 21000n
30071
+ * });
30072
+ * ```
29796
30073
  * @category Reference
29797
30074
  */
29798
30075
  interface TransactionOptions {
@@ -29810,8 +30087,37 @@ interface TransactionOptions {
29810
30087
  value?: bigint;
29811
30088
  }
29812
30089
  /**
29813
- * Transaction receipt with additional metadata
30090
+ * Transaction receipt with additional metadata for tracking transaction results.
30091
+ *
30092
+ * @remarks
30093
+ * Provides comprehensive information about executed transactions including
30094
+ * gas usage, success status, and emitted events. Use the logs array to
30095
+ * decode events emitted by smart contracts during transaction execution.
30096
+ * The receipt is available after a transaction is mined and included in a block.
30097
+ *
30098
+ * @example
30099
+ * ```typescript
30100
+ * // Execute transaction and wait for receipt
30101
+ * const receipt = await vana.permissions.grant({
30102
+ * grantee: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',
30103
+ * dataId: 123
30104
+ * });
29814
30105
  *
30106
+ * // Check transaction success
30107
+ * if (receipt.status === 'success') {
30108
+ * console.log(`Gas used: ${receipt.gasUsed}`);
30109
+ * console.log(`Block: ${receipt.blockNumber}`);
30110
+ *
30111
+ * // Decode events from logs
30112
+ * receipt.logs.forEach(log => {
30113
+ * if (log.topics[0] === PERMISSION_GRANTED_TOPIC) {
30114
+ * console.log('Permission granted event detected');
30115
+ * }
30116
+ * });
30117
+ * } else {
30118
+ * console.error('Transaction reverted');
30119
+ * }
30120
+ * ```
29815
30121
  * @category Reference
29816
30122
  */
29817
30123
  interface TransactionReceipt {
@@ -29835,8 +30141,45 @@ interface TransactionReceipt {
29835
30141
  }>;
29836
30142
  }
29837
30143
  /**
29838
- * Response wrapper for API results
30144
+ * Response wrapper for API results providing consistent error handling.
30145
+ *
30146
+ * @remarks
30147
+ * Standardizes API responses across the SDK, making it easy to handle
30148
+ * both successful and failed requests. The generic type parameter T
30149
+ * represents the expected data type for successful responses. Check
30150
+ * the success flag before accessing data to ensure type safety.
29839
30151
  *
30152
+ * @example
30153
+ * ```typescript
30154
+ * // Handling API responses
30155
+ * async function fetchUserData(userId: string): Promise<User | null> {
30156
+ * const response: ApiResponse<User> = await api.getUser(userId);
30157
+ *
30158
+ * if (response.success) {
30159
+ * console.log('User fetched:', response.data.name);
30160
+ * // Access metadata if available
30161
+ * if (response.metadata?.cached) {
30162
+ * console.log('Data was cached');
30163
+ * }
30164
+ * return response.data;
30165
+ * } else {
30166
+ * console.error('Failed to fetch user:', response.error);
30167
+ * return null;
30168
+ * }
30169
+ * }
30170
+ *
30171
+ * // Type-safe error handling
30172
+ * interface UserData {
30173
+ * id: string;
30174
+ * name: string;
30175
+ * }
30176
+ *
30177
+ * const result: ApiResponse<UserData> = await api.call('/users/123');
30178
+ * if (result.success) {
30179
+ * // TypeScript knows result.data is UserData here
30180
+ * console.log(result.data.name);
30181
+ * }
30182
+ * ```
29840
30183
  * @category Reference
29841
30184
  */
29842
30185
  interface ApiResponse<T> {
@@ -29850,8 +30193,35 @@ interface ApiResponse<T> {
29850
30193
  metadata?: Record<string, unknown>;
29851
30194
  }
29852
30195
  /**
29853
- * Cache configuration
30196
+ * Cache configuration for optimizing repeated data fetches.
30197
+ *
30198
+ * @remarks
30199
+ * Configures in-memory caching behavior to reduce redundant API calls and
30200
+ * improve performance. The cache automatically evicts expired entries based
30201
+ * on TTL and removes least-recently-used items when maxSize is reached.
30202
+ * Use appropriate TTL values based on your data freshness requirements.
29854
30203
  *
30204
+ * @example
30205
+ * ```typescript
30206
+ * // Short-lived cache for frequently changing data
30207
+ * const userCache: CacheConfig = {
30208
+ * ttl: 60000, // 1 minute
30209
+ * maxSize: 100, // Store up to 100 users
30210
+ * prefix: 'user:' // Cache keys like 'user:123'
30211
+ * };
30212
+ *
30213
+ * // Long-lived cache for stable data
30214
+ * const schemaCache: CacheConfig = {
30215
+ * ttl: 3600000, // 1 hour
30216
+ * maxSize: 1000, // Store up to 1000 schemas
30217
+ * prefix: 'schema:'
30218
+ * };
30219
+ *
30220
+ * // Disable caching by setting TTL to 0
30221
+ * const noCache: CacheConfig = {
30222
+ * ttl: 0 // No caching
30223
+ * };
30224
+ * ```
29855
30225
  * @category Reference
29856
30226
  */
29857
30227
  interface CacheConfig {
@@ -29863,8 +30233,51 @@ interface CacheConfig {
29863
30233
  prefix?: string;
29864
30234
  }
29865
30235
  /**
29866
- * Validation result
30236
+ * Validation result for data integrity checks and schema validation.
30237
+ *
30238
+ * @remarks
30239
+ * Provides detailed feedback about validation outcomes, distinguishing between
30240
+ * errors (which prevent processing) and warnings (which indicate potential issues).
30241
+ * Used throughout the SDK for validating permissions, file formats, schemas,
30242
+ * and API parameters before operations.
30243
+ *
30244
+ * @example
30245
+ * ```typescript
30246
+ * // Validating user input
30247
+ * function validateFileUpload(file: File): ValidationResult {
30248
+ * const errors: string[] = [];
30249
+ * const warnings: string[] = [];
30250
+ *
30251
+ * // Check file size
30252
+ * if (file.size > 100 * 1024 * 1024) {
30253
+ * errors.push('File size exceeds 100MB limit');
30254
+ * } else if (file.size > 50 * 1024 * 1024) {
30255
+ * warnings.push('Large file may take time to upload');
30256
+ * }
30257
+ *
30258
+ * // Check file type
30259
+ * if (!file.type.startsWith('image/')) {
30260
+ * errors.push('Only image files are allowed');
30261
+ * }
30262
+ *
30263
+ * return {
30264
+ * valid: errors.length === 0,
30265
+ * errors,
30266
+ * warnings
30267
+ * };
30268
+ * }
29867
30269
  *
30270
+ * // Using validation result
30271
+ * const result = validateFileUpload(file);
30272
+ * if (!result.valid) {
30273
+ * console.error('Validation failed:', result.errors.join(', '));
30274
+ * } else {
30275
+ * if (result.warnings.length > 0) {
30276
+ * console.warn('Warnings:', result.warnings.join(', '));
30277
+ * }
30278
+ * // Proceed with upload
30279
+ * }
30280
+ * ```
29868
30281
  * @category Reference
29869
30282
  */
29870
30283
  interface ValidationResult {
@@ -29876,8 +30289,41 @@ interface ValidationResult {
29876
30289
  warnings: string[];
29877
30290
  }
29878
30291
  /**
29879
- * Status information
30292
+ * Status information for health checks and service monitoring.
30293
+ *
30294
+ * @remarks
30295
+ * Used to report the health status of various SDK components including
30296
+ * storage providers, RPC connections, and personal servers. The details
30297
+ * field can contain provider-specific information for debugging.
30298
+ * Timestamps use Unix epoch milliseconds.
30299
+ *
30300
+ * @example
30301
+ * ```typescript
30302
+ * // Checking storage provider health
30303
+ * const status: StatusInfo = await storage.getStatus();
30304
+ *
30305
+ * if (!status.healthy) {
30306
+ * console.error(`Storage unhealthy: ${status.message}`);
30307
+ * // Check how long the issue has persisted
30308
+ * const downtime = Date.now() - status.lastCheck;
30309
+ * if (downtime > 300000) { // 5 minutes
30310
+ * // Switch to backup provider
30311
+ * }
30312
+ * }
29880
30313
  *
30314
+ * // Detailed status with custom fields
30315
+ * const serverStatus: StatusInfo = {
30316
+ * healthy: true,
30317
+ * message: 'All systems operational',
30318
+ * lastCheck: Date.now(),
30319
+ * details: {
30320
+ * uptime: 3600000, // 1 hour
30321
+ * requestsServed: 1234,
30322
+ * avgResponseTime: 145, // ms
30323
+ * activeConnections: 23
30324
+ * }
30325
+ * };
30326
+ * ```
29881
30327
  * @category Reference
29882
30328
  */
29883
30329
  interface StatusInfo {
@@ -29891,8 +30337,34 @@ interface StatusInfo {
29891
30337
  details?: Record<string, unknown>;
29892
30338
  }
29893
30339
  /**
29894
- * Rate limit information
30340
+ * Rate limit information for API throttling and quota management.
30341
+ *
30342
+ * @remarks
30343
+ * Provides visibility into rate limiting status to help applications
30344
+ * implement appropriate backoff strategies. Rate limits protect services
30345
+ * from overload and ensure fair resource usage. Use this information
30346
+ * to pace requests and avoid hitting limits.
30347
+ *
30348
+ * @example
30349
+ * ```typescript
30350
+ * // Check rate limit before making requests
30351
+ * const rateLimit: RateLimitInfo = await api.getRateLimit();
30352
+ *
30353
+ * console.log(`Requests: ${rateLimit.requests}/${rateLimit.limit}`);
30354
+ * console.log(`Resets in: ${rateLimit.resetTime} seconds`);
29895
30355
  *
30356
+ * // Implement backoff if approaching limit
30357
+ * if (rateLimit.requests >= rateLimit.limit * 0.9) {
30358
+ * console.warn('Approaching rate limit, slowing down');
30359
+ * await new Promise(resolve =>
30360
+ * setTimeout(resolve, rateLimit.resetTime * 1000)
30361
+ * );
30362
+ * }
30363
+ *
30364
+ * // Calculate requests per second allowed
30365
+ * const rps = rateLimit.limit / rateLimit.window;
30366
+ * console.log(`Max ${rps} requests per second allowed`);
30367
+ * ```
29896
30368
  * @category Reference
29897
30369
  */
29898
30370
  interface RateLimitInfo {
@@ -29906,8 +30378,40 @@ interface RateLimitInfo {
29906
30378
  resetTime: number;
29907
30379
  }
29908
30380
  /**
29909
- * File upload progress
30381
+ * File upload progress tracking for user feedback and monitoring.
30382
+ *
30383
+ * @remarks
30384
+ * Provides real-time progress information during file uploads, enabling
30385
+ * applications to show progress bars and estimated completion times.
30386
+ * The speed calculation is typically based on a rolling average to
30387
+ * smooth out network fluctuations.
29910
30388
  *
30389
+ * @example
30390
+ * ```typescript
30391
+ * // Upload with progress tracking
30392
+ * await vana.data.upload(file, {
30393
+ * onProgress: (progress: UploadProgress) => {
30394
+ * // Update progress bar
30395
+ * progressBar.style.width = `${progress.percentage}%`;
30396
+ *
30397
+ * // Show upload speed
30398
+ * const speedMBps = (progress.speed / 1024 / 1024).toFixed(2);
30399
+ * speedDisplay.textContent = `${speedMBps} MB/s`;
30400
+ *
30401
+ * // Show time remaining
30402
+ * const minutes = Math.floor(progress.estimatedTimeRemaining / 60);
30403
+ * const seconds = progress.estimatedTimeRemaining % 60;
30404
+ * timeDisplay.textContent = `${minutes}:${seconds.toString().padStart(2, '0')}`;
30405
+ *
30406
+ * // Log progress milestones
30407
+ * if (progress.percentage === 25 ||
30408
+ * progress.percentage === 50 ||
30409
+ * progress.percentage === 75) {
30410
+ * console.log(`Upload ${progress.percentage}% complete`);
30411
+ * }
30412
+ * }
30413
+ * });
30414
+ * ```
29911
30415
  * @category Reference
29912
30416
  */
29913
30417
  interface UploadProgress {
@@ -29923,8 +30427,41 @@ interface UploadProgress {
29923
30427
  estimatedTimeRemaining: number;
29924
30428
  }
29925
30429
  /**
29926
- * Network information
30430
+ * Network information for blockchain connectivity and monitoring.
30431
+ *
30432
+ * @remarks
30433
+ * Provides comprehensive details about the connected blockchain network,
30434
+ * including configuration URLs and real-time status. Use this information
30435
+ * to verify network connectivity, display network details to users, and
30436
+ * construct explorer links for transactions.
30437
+ *
30438
+ * @example
30439
+ * ```typescript
30440
+ * // Get current network info
30441
+ * const network: NetworkInfo = await vana.protocol.getNetworkInfo();
30442
+ *
30443
+ * console.log(`Connected to: ${network.chainName} (ID: ${network.chainId})`);
30444
+ * console.log(`Current block: ${network.currentBlock}`);
30445
+ *
30446
+ * // Check network health
30447
+ * if (network.status !== 'healthy') {
30448
+ * console.warn(`Network ${network.status}: consider switching RPC`);
30449
+ * }
30450
+ *
30451
+ * // Generate explorer link for transaction
30452
+ * function getExplorerLink(txHash: string): string {
30453
+ * if (!network.explorerUrl) {
30454
+ * return `Transaction: ${txHash}`;
30455
+ * }
30456
+ * return `${network.explorerUrl}/tx/${txHash}`;
30457
+ * }
29927
30458
  *
30459
+ * // Verify expected network
30460
+ * const EXPECTED_CHAIN_ID = 1337; // Vana testnet
30461
+ * if (network.chainId !== EXPECTED_CHAIN_ID) {
30462
+ * throw new Error(`Wrong network! Expected ${EXPECTED_CHAIN_ID}, got ${network.chainId}`);
30463
+ * }
30464
+ * ```
29928
30465
  * @category Reference
29929
30466
  */
29930
30467
  interface NetworkInfo {
@@ -29942,8 +30479,39 @@ interface NetworkInfo {
29942
30479
  status: "healthy" | "degraded" | "down";
29943
30480
  }
29944
30481
  /**
29945
- * Gas estimate information
30482
+ * Gas estimate information for transaction cost prediction.
30483
+ *
30484
+ * @remarks
30485
+ * Provides detailed gas pricing estimates to help users understand transaction
30486
+ * costs before execution. Supports both legacy (gasPrice) and EIP-1559
30487
+ * (maxFeePerGas) pricing models. The estimatedCost is calculated based on
30488
+ * current network conditions and may vary by the time of actual execution.
30489
+ *
30490
+ * @example
30491
+ * ```typescript
30492
+ * // Get gas estimate before transaction
30493
+ * const estimate: GasEstimate = await vana.permissions.estimateGas({
30494
+ * grantee: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',
30495
+ * dataId: 123
30496
+ * });
30497
+ *
30498
+ * // Convert to human-readable format
30499
+ * const costInEth = Number(estimate.estimatedCost) / 1e18;
30500
+ * console.log(`Estimated cost: ${costInEth.toFixed(6)} ETH`);
29946
30501
  *
30502
+ * // Check if user has sufficient balance
30503
+ * const balance = await vana.protocol.getBalance(userAddress);
30504
+ * if (balance < estimate.estimatedCost) {
30505
+ * throw new Error(`Insufficient balance. Need ${costInEth} ETH`);
30506
+ * }
30507
+ *
30508
+ * // Use estimate for transaction with buffer
30509
+ * await vana.permissions.grant(params, {
30510
+ * gasLimit: estimate.gasLimit * 110n / 100n, // 10% buffer
30511
+ * maxFeePerGas: estimate.maxFeePerGas,
30512
+ * maxPriorityFeePerGas: estimate.maxPriorityFeePerGas
30513
+ * });
30514
+ * ```
29947
30515
  * @category Reference
29948
30516
  */
29949
30517
  interface GasEstimate {
@@ -30474,7 +31042,7 @@ interface GrantPermissionParams {
30474
31042
  * const decryptedData = await vana.data.decryptFile(files[0]);
30475
31043
  * ```
30476
31044
  * @category Data Management
30477
- * @see {@link [URL_PLACEHOLDER] | Vana Data Registry Documentation} for conceptual overview
31045
+ * @see {@link https://docs.vana.com/developer/data-registry | Vana Data Registry Documentation} for conceptual overview
30478
31046
  */
30479
31047
  declare class DataController {
30480
31048
  private readonly context;
@@ -30495,23 +31063,32 @@ declare class DataController {
30495
31063
  * - Grants file decryption permissions to specified accounts
30496
31064
  * - Registers the file on the blockchain
30497
31065
  *
31066
+ * **TypeScript Overloads:**
31067
+ * This method has three overloads to ensure type safety:
31068
+ * 1. `EncryptedUploadParams` - When `encrypt: true` (default), permissions require publicKey
31069
+ * 2. `UnencryptedUploadParams` - When `encrypt: false`, permissions are optional
31070
+ * 3. `UploadParams` - General signature for runtime determination
31071
+ *
30498
31072
  * IMPORTANT: The permissions parameter only grants decryption access to the file.
30499
31073
  * To grant operation permissions (like "llm_inference"), use vana.permissions.grant()
30500
31074
  * after uploading. This separation ensures clear distinction between:
30501
- * - File permissions: Who can decrypt and read the encrypted file
30502
- * - Operation permissions: What operations can be performed on the data
31075
+ * - File permissions: Who can decrypt and read the encrypted file (handled here)
31076
+ * - Operation permissions: What operations can be performed on the data (handled separately)
30503
31077
  *
30504
31078
  * @param params - Upload parameters including content, filename, schema, and permissions
30505
- * @param params.permissions.publicKey - The recipient's public key for encryption.
31079
+ * @param params.permissions[].account - The recipient's wallet address that will access the data.
31080
+ * @param params.permissions[].publicKey - The recipient's public key for encryption (hex string with 0x prefix).
30506
31081
  * Obtain via `vana.server.getIdentity(userAddress).public_key` for personal servers.
30507
- * @param params.permissions.grantee - The application's wallet address that will access the data.
31082
+ * @param params.schemaId - Optional schema ID for data validation. Get available schemas from `vana.schemas.list()`.
31083
+ * @param params.owner - Optional owner address if uploading on behalf of another user (requires delegation).
30508
31084
  * @returns Promise resolving to upload results with file ID and transaction hash
30509
- * @throws {Error} When wallet is not connected or storage is not configured.
30510
- * Configure storage providers in VanaConfig or check wallet connection.
30511
- * @throws {SchemaValidationError} When data format doesn't match the specified schema.
30512
- * Verify data structure matches schema definition from `vana.schemas.get(schemaId)`.
30513
- * @throws {Error} When upload or blockchain registration fails.
30514
- * Check network connection and storage provider availability.
31085
+ * @throws {Error} When storage manager is not configured - "Storage manager not configured. Please provide storage providers in VanaConfig."
31086
+ * @throws {Error} When no wallet addresses available - "No addresses available in wallet client"
31087
+ * @throws {Error} When chain ID is not available - "Chain ID not available"
31088
+ * @throws {Error} When relay callback doesn't support required features - "The configured relay callback does not support schemas or permissions"
31089
+ * @throws {Error} When schema fetch fails - "Failed to fetch schema definition: {status}"
31090
+ * @throws {SchemaValidationError} When data doesn't match schema - includes specific validation errors
31091
+ * @throws {Error} General upload failures - "Upload failed: {specific error message}"
30515
31092
  * @example
30516
31093
  * ```typescript
30517
31094
  * // Basic file upload
@@ -30546,12 +31123,12 @@ declare class DataController {
30546
31123
  * // });
30547
31124
  *
30548
31125
  * // Upload without encryption (public data)
31126
+ * // Note: Cast to UnencryptedUploadParams for TypeScript
30549
31127
  * const result = await vana.data.upload({
30550
31128
  * content: "Public data",
30551
31129
  * filename: "public.txt",
30552
31130
  * encrypt: false
30553
- * // No permissions needed for public unencrypted data
30554
- * });
31131
+ * } as const); // 'as const' ensures TypeScript infers encrypt: false literally
30555
31132
  *
30556
31133
  * // Upload on behalf of another user (delegation)
30557
31134
  * const result = await vana.data.upload({
@@ -30559,10 +31136,8 @@ declare class DataController {
30559
31136
  * filename: "delegated.txt",
30560
31137
  * owner: "0x5678...", // Different from connected wallet
30561
31138
  * permissions: [{
30562
- * grantee: "0x1234...",
30563
- * operation: "process",
30564
- * parameters: { type: "analysis" },
30565
- * publicKey: "0x04..."
31139
+ * account: "0x1234...", // Address that can decrypt
31140
+ * publicKey: "0x04..." // Their public key for encryption
30566
31141
  * }]
30567
31142
  * });
30568
31143
  * ```
@@ -30592,9 +31167,14 @@ declare class DataController {
30592
31167
  * @param file - The user file to decrypt (typically from getUserFiles)
30593
31168
  * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
30594
31169
  * @returns Promise resolving to the decrypted file content as a Blob
30595
- * @throws {Error} When the wallet is not connected
30596
- * @throws {Error} When fetching the encrypted content fails
30597
- * @throws {Error} When decryption fails (wrong key or corrupted data)
31170
+ * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
31171
+ * @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
31172
+ * @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
31173
+ * @throws {Error} "Access denied" - When file returns 403 (no permission)
31174
+ * @throws {Error} "File is empty or could not be retrieved" - When file has no content
31175
+ * @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
31176
+ * @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
31177
+ * @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
30598
31178
  * @example
30599
31179
  * ```typescript
30600
31180
  * // Basic file decryption
@@ -30628,11 +31208,20 @@ declare class DataController {
30628
31208
  * This method queries the Vana subgraph to find files directly owned by the user.
30629
31209
  * It efficiently handles large datasets by using the File entity's owner field
30630
31210
  * and returns complete file metadata without additional contract calls.
31211
+ *
31212
+ * **Deduplication Behavior:**
31213
+ * The method automatically deduplicates files by ID, keeping only the latest version
31214
+ * (highest timestamp) when duplicate file IDs are found. This handles cases where
31215
+ * the subgraph may contain multiple entries for the same file due to re-indexing
31216
+ * or blockchain reorganizations.
30631
31217
  * @param params - The query parameters object
30632
31218
  * @param params.owner - The wallet address of the file owner to query
30633
31219
  * @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
30634
- * @returns A Promise that resolves to an array of UserFile objects with metadata
30635
- * @throws {Error} When the subgraph is unavailable or returns invalid data
31220
+ * @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
31221
+ * @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
31222
+ * @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
31223
+ * @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
31224
+ * @throws {Error} When JSON parsing fails - "Failed to fetch user files from subgraph: {error}"
30636
31225
  * @example
30637
31226
  * ```typescript
30638
31227
  * // Query files for a specific user
@@ -30755,6 +31344,9 @@ declare class DataController {
30755
31344
  *
30756
31345
  * @param fileId - The file ID to look up
30757
31346
  * @returns Promise resolving to UserFile object
31347
+ * @throws {Error} "Chain ID not available" - When wallet chain is not configured
31348
+ * @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
31349
+ * @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
30758
31350
  * @example
30759
31351
  * ```typescript
30760
31352
  * try {
@@ -30779,7 +31371,21 @@ declare class DataController {
30779
31371
  /**
30780
31372
  * Uploads an encrypted file to storage and registers it on the blockchain.
30781
31373
  *
30782
- * @deprecated Use vana.data.upload() instead for the high-level API with automatic encryption
31374
+ * @deprecated Since v2.0.0 - Use vana.data.upload() instead for the high-level API with automatic encryption
31375
+ *
31376
+ * Migration guide:
31377
+ * ```typescript
31378
+ * // Old way (deprecated):
31379
+ * const encrypted = await encryptBlob(data, key);
31380
+ * const result = await vana.data.uploadEncryptedFile(encrypted, filename);
31381
+ *
31382
+ * // New way:
31383
+ * const result = await vana.data.upload({
31384
+ * content: data,
31385
+ * filename: filename,
31386
+ * encrypt: true // Handles encryption automatically
31387
+ * });
31388
+ * ```
30783
31389
  * @param encryptedFile - The encrypted file blob to upload
30784
31390
  * @param filename - Optional filename for the upload
30785
31391
  * @param providerName - Optional storage provider to use
@@ -30794,7 +31400,22 @@ declare class DataController {
30794
31400
  /**
30795
31401
  * Uploads an encrypted file to storage and registers it on the blockchain with a schema.
30796
31402
  *
30797
- * @deprecated Use vana.data.upload() instead for the high-level API with automatic encryption and schema validation
31403
+ * @deprecated Since v2.0.0 - Use vana.data.upload() instead for the high-level API with automatic encryption and schema validation
31404
+ *
31405
+ * Migration guide:
31406
+ * ```typescript
31407
+ * // Old way (deprecated):
31408
+ * const encrypted = await encryptBlob(data, key);
31409
+ * const result = await vana.data.uploadEncryptedFileWithSchema(encrypted, schemaId, filename);
31410
+ *
31411
+ * // New way:
31412
+ * const result = await vana.data.upload({
31413
+ * content: data,
31414
+ * filename: filename,
31415
+ * schemaId: schemaId, // Automatic validation
31416
+ * encrypt: true
31417
+ * });
31418
+ * ```
30798
31419
  * @param encryptedFile - The encrypted file blob to upload
30799
31420
  * @param schemaId - The schema ID to associate with the file
30800
31421
  * @param filename - Optional filename for the upload
@@ -30866,7 +31487,24 @@ declare class DataController {
30866
31487
  /**
30867
31488
  * Adds a new schema to the DataRefinerRegistry.
30868
31489
  *
30869
- * @deprecated Use vana.schemas.create() instead for the high-level API with automatic IPFS upload
31490
+ * @deprecated Since v2.0.0 - Use vana.schemas.create() instead for the high-level API with automatic IPFS upload
31491
+ *
31492
+ * Migration guide:
31493
+ * ```typescript
31494
+ * // Old way (deprecated):
31495
+ * const result = await vana.data.addSchema({
31496
+ * name: "UserProfile",
31497
+ * type: "JSON",
31498
+ * definitionUrl: "ipfs://..."
31499
+ * });
31500
+ *
31501
+ * // New way:
31502
+ * const result = await vana.schemas.create({
31503
+ * name: "UserProfile",
31504
+ * type: "JSON",
31505
+ * definition: schemaObject // Automatically uploads to IPFS
31506
+ * });
31507
+ * ```
30870
31508
  * @param params - Schema parameters including name, type, and definition URL
30871
31509
  * @returns Promise resolving to the new schema ID and transaction hash
30872
31510
  */
@@ -30874,7 +31512,16 @@ declare class DataController {
30874
31512
  /**
30875
31513
  * Retrieves a schema by its ID.
30876
31514
  *
30877
- * @deprecated Use vana.schemas.get() instead
31515
+ * @deprecated Since v2.0.0 - Use vana.schemas.get() instead
31516
+ *
31517
+ * Migration guide:
31518
+ * ```typescript
31519
+ * // Old way (deprecated):
31520
+ * const schema = await vana.data.getSchema(schemaId);
31521
+ *
31522
+ * // New way:
31523
+ * const schema = await vana.schemas.get(schemaId);
31524
+ * ```
30878
31525
  * @param schemaId - The schema ID to retrieve
30879
31526
  * @returns Promise resolving to the schema information
30880
31527
  */
@@ -30882,7 +31529,16 @@ declare class DataController {
30882
31529
  /**
30883
31530
  * Gets the total number of schemas in the registry.
30884
31531
  *
30885
- * @deprecated Use vana.schemas.count() instead
31532
+ * @deprecated Since v2.0.0 - Use vana.schemas.count() instead
31533
+ *
31534
+ * Migration guide:
31535
+ * ```typescript
31536
+ * // Old way (deprecated):
31537
+ * const count = await vana.data.getSchemasCount();
31538
+ *
31539
+ * // New way:
31540
+ * const count = await vana.schemas.count();
31541
+ * ```
30886
31542
  * @returns Promise resolving to the total schema count
30887
31543
  */
30888
31544
  getSchemasCount(): Promise<number>;
@@ -30953,8 +31609,11 @@ declare class DataController {
30953
31609
  *
30954
31610
  * @param fileId - The ID of the file to add permissions for
30955
31611
  * @param account - The address of the account to grant permission to
30956
- * @param publicKey - The public key to encrypt the user's encryption key with
31612
+ * @param publicKey - The public key to encrypt the user's encryption key with (hex string with 0x prefix)
30957
31613
  * @returns Promise resolving to permission data from PermissionGranted event
31614
+ * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
31615
+ * @throws {Error} "Chain ID not available" - When wallet chain is not configured
31616
+ * @throws {Error} "Failed to add permission to file: {error}" - When transaction fails or user doesn't own file
30958
31617
  * @example
30959
31618
  * ```typescript
30960
31619
  * const result = await vana.data.addPermissionToFile(fileId, account, publicKey);
@@ -31012,7 +31671,9 @@ declare class DataController {
31012
31671
  *
31013
31672
  * @param url - The URL to fetch content from
31014
31673
  * @returns Promise resolving to the fetched content as a Blob
31015
- * @throws {Error} When the fetch fails or returns a non-ok response
31674
+ * @throws {Error} "HTTP error! status: {status} {statusText}" - When server returns error status
31675
+ * @throws {Error} "Empty response" - When server returns no content
31676
+ * @throws {Error} "Network error: Failed to fetch from {url}" - When network request fails
31016
31677
  *
31017
31678
  * @example
31018
31679
  * ```typescript
@@ -31043,7 +31704,10 @@ declare class DataController {
31043
31704
  * @param options - Optional configuration
31044
31705
  * @param options.gateways - Array of IPFS gateway URLs to try (must end with /)
31045
31706
  * @returns Promise resolving to the fetched content as a Blob
31046
- * @throws {Error} When all gateways fail to fetch the content
31707
+ * @throws {Error} "Invalid IPFS URL format" - When URL is not ipfs:// or valid CID
31708
+ * @throws {Error} "Empty response" - When gateway returns no content
31709
+ * @throws {Error} "HTTP error! status: {status}" - When gateway returns error status
31710
+ * @throws {Error} "Failed to fetch IPFS content {cid} from all gateways" - When all gateways fail
31047
31711
  *
31048
31712
  * @example
31049
31713
  * ```typescript
@@ -31200,7 +31864,7 @@ declare class DataController {
31200
31864
  * const result = await vana.server.getOperation(response.id);
31201
31865
  * ```
31202
31866
  * @category Server Management
31203
- * @see {@link [URL_PLACEHOLDER] | Vana Personal Servers} for conceptual overview
31867
+ * @see {@link https://docs.vana.com/developer/personal-servers | Vana Personal Servers} for conceptual overview
31204
31868
  */
31205
31869
  declare class ServerController {
31206
31870
  private readonly context;
@@ -31483,7 +32147,7 @@ declare function clearContractCache(contract?: VanaContract, chainId?: number):
31483
32147
  * const fileCount = await contract.read.filesCount();
31484
32148
  * ```
31485
32149
  * @category Advanced
31486
- * @see {@link [URL_PLACEHOLDER] | Vana Protocol Contracts} for contract specifications
32150
+ * @see {@link https://docs.vana.com/developer/protocol/contracts | Vana Protocol Contracts} for contract specifications
31487
32151
  */
31488
32152
  declare class ProtocolController {
31489
32153
  private readonly context;
@@ -31562,12 +32226,14 @@ declare class ProtocolController {
31562
32226
  * Gets the current chain ID from the wallet client.
31563
32227
  *
31564
32228
  * @returns The chain ID
32229
+ * @throws {Error} When chain ID is not available from wallet client
31565
32230
  */
31566
32231
  getChainId(): number;
31567
32232
  /**
31568
32233
  * Gets the current chain name from the wallet client.
31569
32234
  *
31570
32235
  * @returns The chain name
32236
+ * @throws {Error} When chain name is not available from wallet client
31571
32237
  */
31572
32238
  getChainName(): string;
31573
32239
  }
@@ -32410,6 +33076,10 @@ declare function decryptBlobWithSignedKey(encryptedData: string | Blob, key: str
32410
33076
  /**
32411
33077
  * Format a bigint or BigNumber to a regular number
32412
33078
  *
33079
+ * @remarks
33080
+ * This function converts blockchain-specific large number types to standard JavaScript
33081
+ * numbers. Use with caution for values that may exceed safe integer range.
33082
+ *
32413
33083
  * **Edge Cases:**
32414
33084
  * - Values exceeding JavaScript's MAX_SAFE_INTEGER (2^53-1) lose precision
32415
33085
  * - Negative values are supported
@@ -32417,11 +33087,26 @@ declare function decryptBlobWithSignedKey(encryptedData: string | Blob, key: str
32417
33087
  *
32418
33088
  * @param value BigInt, BigNumber or numeric string to convert
32419
33089
  * @returns Regular JavaScript number
33090
+ * @example
33091
+ * ```typescript
33092
+ * formatNumber(1000000000000000000n) // Returns: 1000000000000000000
33093
+ * formatNumber("123456789") // Returns: 123456789
33094
+ * formatNumber(-100n) // Returns: -100
33095
+ *
33096
+ * // Precision loss example:
33097
+ * const bigValue = 9007199254740993n; // MAX_SAFE_INTEGER + 2
33098
+ * formatNumber(bigValue) // Returns: 9007199254740992 (lost precision)
33099
+ * ```
32420
33100
  */
32421
33101
  declare function formatNumber(value: bigint | string | number): number;
32422
33102
  /**
32423
33103
  * Format wei value to ETH with specified decimal places
32424
33104
  *
33105
+ * @remarks
33106
+ * Converts wei (smallest ETH unit) to human-readable ETH format.
33107
+ * 1 ETH = 10^18 wei. The function truncates rather than rounds
33108
+ * to ensure predictable display in financial contexts.
33109
+ *
32425
33110
  * **Edge Cases:**
32426
33111
  * - Truncates (not rounds) to specified decimal places
32427
33112
  * - Negative values are supported
@@ -32431,20 +33116,57 @@ declare function formatNumber(value: bigint | string | number): number;
32431
33116
  * @param wei Value in wei (as bigint, string, or number)
32432
33117
  * @param decimals Number of decimal places to display (default: 4)
32433
33118
  * @returns Formatted ETH value as string
33119
+ * @example
33120
+ * ```typescript
33121
+ * // Standard conversions
33122
+ * formatEth(1000000000000000000n) // Returns: "1.0000"
33123
+ * formatEth(1500000000000000000n, 2) // Returns: "1.50"
33124
+ * formatEth("2000000000000000000") // Returns: "2.0000"
33125
+ *
33126
+ * // Edge cases
33127
+ * formatEth(1000000000000000n) // Returns: "0.0010" (0.001 ETH)
33128
+ * formatEth(100000000000000n) // Returns: "0.0001"
33129
+ * formatEth(10000000000000n) // Returns: "0.0000" (truncated)
33130
+ * formatEth(-1000000000000000000n) // Returns: "-1.000"
33131
+ * ```
32434
33132
  */
32435
33133
  declare function formatEth(wei: bigint | string | number, decimals?: number): string;
32436
33134
  /**
32437
33135
  * Format a token amount based on its decimals
32438
33136
  *
33137
+ * @remarks
33138
+ * Generic token formatter that handles any ERC20-style token with
33139
+ * configurable decimal places. Most tokens use 18 decimals like ETH,
33140
+ * but some use different values (e.g., USDC uses 6).
33141
+ *
32439
33142
  * @param amount Raw token amount
32440
33143
  * @param decimals Token decimals (default: 18)
32441
33144
  * @param displayDecimals Decimals to show in formatted output (default: 4)
32442
33145
  * @returns Formatted token amount as string
33146
+ * @example
33147
+ * ```typescript
33148
+ * // 18 decimal token (like ETH)
33149
+ * formatToken(1000000000000000000n) // Returns: "1.0000"
33150
+ * formatToken(1500000000000000000n, 18, 2) // Returns: "1.50"
33151
+ *
33152
+ * // 6 decimal token (like USDC)
33153
+ * formatToken(1000000n, 6) // Returns: "1.0000"
33154
+ * formatToken(1500000n, 6, 2) // Returns: "1.50"
33155
+ *
33156
+ * // Whole numbers
33157
+ * formatToken(5000000000000000000n) // Returns: "5"
33158
+ * formatToken(5123456789000000000n, 18, 6) // Returns: "5.123456"
33159
+ * ```
32443
33160
  */
32444
33161
  declare function formatToken(amount: bigint | string | number, decimals?: number, displayDecimals?: number): string;
32445
33162
  /**
32446
33163
  * Format an address for display (showing first 6 and last 4 characters)
32447
33164
  *
33165
+ * @remarks
33166
+ * Creates a human-readable abbreviated version of Ethereum addresses
33167
+ * for UI display. Preserves enough characters to maintain uniqueness
33168
+ * while saving screen space. Does not validate address format.
33169
+ *
32448
33170
  * **Edge Cases:**
32449
33171
  * - Addresses shorter than 10 characters are returned unchanged
32450
33172
  * - Works with both checksummed and lowercase addresses
@@ -32452,22 +33174,80 @@ declare function formatToken(amount: bigint | string | number, decimals?: number
32452
33174
  *
32453
33175
  * @param address EVM address
32454
33176
  * @returns Shortened address string
33177
+ * @example
33178
+ * ```typescript
33179
+ * // Standard addresses
33180
+ * shortenAddress("0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36")
33181
+ * // Returns: "0x742d...Bd36"
33182
+ *
33183
+ * // Checksummed address
33184
+ * shortenAddress("0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36")
33185
+ * // Returns: "0x742d...Bd36"
33186
+ *
33187
+ * // Edge cases
33188
+ * shortenAddress("0x123") // Returns: "0x123" (too short)
33189
+ * shortenAddress("") // Returns: ""
33190
+ * shortenAddress("not-an-address") // Returns: "not-an...ress"
33191
+ * ```
32455
33192
  */
32456
33193
  declare function shortenAddress(address: string): string;
32457
33194
 
32458
33195
  /**
32459
33196
  * Creates a grant file structure from permission parameters.
32460
33197
  *
33198
+ * @remarks
33199
+ * This function constructs the JSON structure that represents a permission grant
33200
+ * in the Vana protocol. The grant file contains all necessary information for
33201
+ * a grantee to perform operations on behalf of the grantor.
33202
+ *
32461
33203
  * @param params - The permission parameters to create the grant file from
32462
33204
  * @returns The constructed grant file object
33205
+ * @example
33206
+ * ```typescript
33207
+ * const grantFile = createGrantFile({
33208
+ * grantee: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',
33209
+ * operation: 'llm_inference',
33210
+ * parameters: {
33211
+ * model: 'gpt-4',
33212
+ * maxTokens: 1000
33213
+ * },
33214
+ * expiresAt: Date.now() + 86400000 // 24 hours
33215
+ * });
33216
+ *
33217
+ * console.log(grantFile);
33218
+ * // {
33219
+ * // grantee: '0x742d...',
33220
+ * // operation: 'llm_inference',
33221
+ * // parameters: { model: 'gpt-4', maxTokens: 1000 },
33222
+ * // expires: 1234567890
33223
+ * // }
33224
+ * ```
32463
33225
  */
32464
33226
  declare function createGrantFile(params: GrantPermissionParams$1): GrantFile;
32465
33227
  /**
32466
33228
  * Stores a grant file in IPFS via the relayer service.
32467
33229
  *
33230
+ * @remarks
33231
+ * This function uploads the grant file to IPFS through the relayer's upload endpoint.
33232
+ * The returned URL can be stored on-chain as part of the permission grant, allowing
33233
+ * anyone to retrieve the detailed permission parameters later.
33234
+ *
32468
33235
  * @param grantFile - The grant file to store
32469
33236
  * @param relayerUrl - URL of the relayer service
32470
33237
  * @returns Promise resolving to the IPFS URL
33238
+ * @throws {NetworkError} When the upload fails or relayer is unavailable
33239
+ * @example
33240
+ * ```typescript
33241
+ * const grantFile = createGrantFile(params);
33242
+ *
33243
+ * try {
33244
+ * const ipfsUrl = await storeGrantFile(grantFile, 'https://relayer.vana.com');
33245
+ * console.log(`Grant file stored at: ${ipfsUrl}`);
33246
+ * // ipfsUrl: "ipfs://QmHash123..."
33247
+ * } catch (error) {
33248
+ * console.error('Failed to store grant file:', error);
33249
+ * }
33250
+ * ```
32471
33251
  */
32472
33252
  declare function storeGrantFile(grantFile: GrantFile, relayerUrl: string): Promise<string>;
32473
33253
  /**
@@ -32513,15 +33293,80 @@ declare function retrieveGrantFile(grantUrl: string, _relayerUrl?: string): Prom
32513
33293
  * Generates a content hash for a grant file.
32514
33294
  * This can be used for integrity verification.
32515
33295
  *
33296
+ * @remarks
33297
+ * Creates a deterministic keccak256 hash of the grant file by first sorting
33298
+ * all object keys recursively to ensure consistent hashing regardless of
33299
+ * property order. This hash can be used to verify grant file integrity
33300
+ * or as a unique identifier.
33301
+ *
32516
33302
  * @param grantFile - The grant file to generate a hash for
32517
33303
  * @returns The keccak256 hash of the grant file as a hex string
33304
+ * @throws {SerializationError} When the grant file cannot be serialized
33305
+ * @example
33306
+ * ```typescript
33307
+ * const grantFile = {
33308
+ * grantee: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',
33309
+ * operation: 'read',
33310
+ * parameters: { version: '1.0', mode: 'full' }
33311
+ * };
33312
+ *
33313
+ * const hash = getGrantFileHash(grantFile);
33314
+ * console.log(`Grant file hash: ${hash}`);
33315
+ * // "0x1234567890abcdef..."
33316
+ *
33317
+ * // Same grant file with different property order produces same hash
33318
+ * const grantFile2 = {
33319
+ * operation: 'read',
33320
+ * parameters: { mode: 'full', version: '1.0' },
33321
+ * grantee: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36'
33322
+ * };
33323
+ *
33324
+ * const hash2 = getGrantFileHash(grantFile2);
33325
+ * console.log(hash === hash2); // true
33326
+ * ```
32518
33327
  */
32519
33328
  declare function getGrantFileHash(grantFile: GrantFile): string;
32520
33329
  /**
32521
33330
  * Validates that a grant file has the required structure.
32522
33331
  *
33332
+ * @remarks
33333
+ * Performs runtime validation to ensure data conforms to the GrantFile interface.
33334
+ * Checks for required fields (grantee, operation, parameters) and validates their
33335
+ * types and formats. This is a type guard function that enables TypeScript to
33336
+ * narrow the type when it returns true.
33337
+ *
32523
33338
  * @param data - The data to validate as a grant file
32524
33339
  * @returns True if the data is a valid grant file, false otherwise
33340
+ * @example
33341
+ * ```typescript
33342
+ * const unknownData = await fetch(url).then(r => r.json());
33343
+ *
33344
+ * if (validateGrantFile(unknownData)) {
33345
+ * // TypeScript now knows unknownData is a GrantFile
33346
+ * console.log(`Grant for operation: ${unknownData.operation}`);
33347
+ * console.log(`Grantee: ${unknownData.grantee}`);
33348
+ * } else {
33349
+ * throw new Error('Invalid grant file format');
33350
+ * }
33351
+ *
33352
+ * // Validation examples:
33353
+ * validateGrantFile({
33354
+ * grantee: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',
33355
+ * operation: 'read',
33356
+ * parameters: {}
33357
+ * }); // true
33358
+ *
33359
+ * validateGrantFile({
33360
+ * grantee: 'invalid-address',
33361
+ * operation: 'read',
33362
+ * parameters: {}
33363
+ * }); // false (invalid address format)
33364
+ *
33365
+ * validateGrantFile({
33366
+ * operation: 'read',
33367
+ * parameters: {}
33368
+ * }); // false (missing grantee)
33369
+ * ```
32525
33370
  */
32526
33371
  declare function validateGrantFile(data: unknown): data is GrantFile;
32527
33372
 
@@ -32829,32 +33674,118 @@ declare function fetchWithFallbacks(url: string, options?: RequestInit): Promise
32829
33674
  /**
32830
33675
  * Simple signature cache using platform cache adapter to avoid repeated signing of identical messages.
32831
33676
  *
33677
+ * @remarks
33678
+ * This cache significantly improves UX by avoiding repeated wallet signature prompts
33679
+ * for identical operations. It's particularly useful for operations that may be
33680
+ * retried or called multiple times with the same parameters.
33681
+ *
32832
33682
  * Features:
32833
33683
  * - Platform-appropriate storage (sessionStorage in browser, memory in Node.js)
32834
33684
  * - Configurable TTL (default 2 hours)
32835
33685
  * - Automatic cleanup of expired entries
32836
33686
  * - Cache keys based on wallet address + message hash
33687
+ *
33688
+ * @example
33689
+ * ```typescript
33690
+ * // Check cache before requesting signature
33691
+ * const cached = SignatureCache.get(cache, walletAddress, messageHash);
33692
+ * if (cached) {
33693
+ * return cached;
33694
+ * }
33695
+ *
33696
+ * // Request signature and cache it
33697
+ * const signature = await wallet.signTypedData(typedData);
33698
+ * SignatureCache.set(cache, walletAddress, messageHash, signature);
33699
+ * ```
33700
+ * @category Utilities
32837
33701
  */
32838
33702
  declare class SignatureCache {
32839
33703
  private static readonly PREFIX;
32840
33704
  private static readonly DEFAULT_TTL_HOURS;
32841
33705
  /**
32842
33706
  * Get a cached signature if it exists and hasn't expired
33707
+ *
33708
+ * @param cache - Platform cache adapter instance
33709
+ * @param walletAddress - Wallet address that created the signature
33710
+ * @param messageHash - Hash of the message that was signed
33711
+ * @returns The cached signature if valid, null if expired or not found
33712
+ * @example
33713
+ * ```typescript
33714
+ * const messageHash = SignatureCache.hashMessage(typedData);
33715
+ * const cached = SignatureCache.get(cache, '0x123...', messageHash);
33716
+ * if (cached) {
33717
+ * console.log('Using cached signature:', cached);
33718
+ * }
33719
+ * ```
32843
33720
  */
32844
33721
  static get(cache: VanaCacheAdapter, walletAddress: string, messageHash: string): Hash | null;
32845
33722
  /**
32846
- * Store a signature in the cache
33723
+ * Store a signature in the cache with configurable TTL
33724
+ *
33725
+ * @param cache - Platform cache adapter instance
33726
+ * @param walletAddress - Wallet address that created the signature
33727
+ * @param messageHash - Hash of the message that was signed
33728
+ * @param signature - The signature to cache
33729
+ * @param ttlHours - Time to live in hours (default: 2)
33730
+ * @example
33731
+ * ```typescript
33732
+ * const signature = await wallet.signTypedData(typedData);
33733
+ * const messageHash = SignatureCache.hashMessage(typedData);
33734
+ *
33735
+ * // Cache for default 2 hours
33736
+ * SignatureCache.set(cache, walletAddress, messageHash, signature);
33737
+ *
33738
+ * // Cache for 24 hours
33739
+ * SignatureCache.set(cache, walletAddress, messageHash, signature, 24);
33740
+ * ```
32847
33741
  */
32848
33742
  static set(cache: VanaCacheAdapter, walletAddress: string, messageHash: string, signature: Hash, ttlHours?: number): void;
32849
33743
  /**
32850
33744
  * Clear all cached signatures (useful for testing or explicit cleanup)
33745
+ *
33746
+ * @param cache - Platform cache adapter instance
33747
+ * @example
33748
+ * ```typescript
33749
+ * // Clear all signatures when user logs out
33750
+ * SignatureCache.clear(cache);
33751
+ *
33752
+ * // Clear before running tests
33753
+ * beforeEach(() => {
33754
+ * SignatureCache.clear(cache);
33755
+ * });
33756
+ * ```
32851
33757
  */
32852
33758
  static clear(cache: VanaCacheAdapter): void;
32853
33759
  private static getCacheKey;
33760
+ /**
33761
+ * Generate a deterministic hash of a message object for cache key generation
33762
+ *
33763
+ * @remarks
33764
+ * Creates a consistent hash from complex objects including EIP-712 typed data.
33765
+ * Handles BigInt serialization and produces a 32-character hash that balances
33766
+ * uniqueness with key length constraints.
33767
+ *
33768
+ * @param message - The message object to hash (typically EIP-712 typed data)
33769
+ * @returns A 32-character hash string suitable for cache keys
33770
+ * @example
33771
+ * ```typescript
33772
+ * const typedData = {
33773
+ * domain: { name: 'Vana', version: '1' },
33774
+ * message: { nonce: 123n, grant: '...' }
33775
+ * };
33776
+ *
33777
+ * const hash = SignatureCache.hashMessage(typedData);
33778
+ * // Returns something like: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
33779
+ * ```
33780
+ */
32854
33781
  static hashMessage(message: object): string;
32855
33782
  /**
32856
33783
  * Custom JSON replacer that converts BigInt values to strings for serialization
32857
33784
  * This ensures deterministic cache key generation for EIP-712 typed data
33785
+ *
33786
+ * @param _key - The object key being serialized (unused)
33787
+ * @param value - The value to serialize
33788
+ * @returns The serialized value
32858
33789
  */
32859
33790
  private static bigIntReplacer;
32860
33791
  }
@@ -32868,7 +33799,7 @@ declare class SignatureCache {
32868
33799
  * @param ttlHours - Cache TTL in hours (default 2)
32869
33800
  * @returns The signature (cached or newly generated)
32870
33801
  */
32871
- declare function withSignatureCache(cache: VanaCacheAdapter, walletAddress: string, typedData: any, signFn: () => Promise<Hash>, ttlHours?: number): Promise<Hash>;
33802
+ declare function withSignatureCache(cache: VanaCacheAdapter, walletAddress: string, typedData: Record<string, unknown>, signFn: () => Promise<Hash>, ttlHours?: number): Promise<Hash>;
32872
33803
 
32873
33804
  declare const CONTRACT_ADDRESSES: Record<number, Record<string, string>>;
32874
33805
  /**