@opendatalabs/vana-sdk 0.1.0-alpha.5f8458e → 0.1.0-alpha.606fa2d

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 (50) hide show
  1. package/README.md +55 -4
  2. package/dist/{browser-cRpdLQ3-.d.ts → browser-Bb8gLWHp.d.ts} +61 -10
  3. package/dist/browser.d.ts +1 -1
  4. package/dist/browser.js +745 -113
  5. package/dist/browser.js.map +1 -1
  6. package/dist/chains.browser.cjs +2 -2
  7. package/dist/chains.browser.cjs.map +1 -1
  8. package/dist/chains.browser.js +2 -2
  9. package/dist/chains.browser.js.map +1 -1
  10. package/dist/chains.cjs +2 -2
  11. package/dist/chains.cjs.map +1 -1
  12. package/dist/chains.js +2 -2
  13. package/dist/chains.js.map +1 -1
  14. package/dist/chains.node.cjs +2 -2
  15. package/dist/chains.node.cjs.map +1 -1
  16. package/dist/chains.node.js +2 -2
  17. package/dist/chains.node.js.map +1 -1
  18. package/dist/index.browser.d.ts +1348 -243
  19. package/dist/index.browser.js +35080 -32770
  20. package/dist/index.browser.js.map +1 -1
  21. package/dist/index.node.cjs +35587 -33174
  22. package/dist/index.node.cjs.map +1 -1
  23. package/dist/index.node.d.cts +1136 -250
  24. package/dist/index.node.d.ts +1136 -250
  25. package/dist/index.node.js +35459 -33037
  26. package/dist/index.node.js.map +1 -1
  27. package/dist/{node-CkdgwBiv.d.cts → node-D9-F9uEP.d.cts} +3 -2
  28. package/dist/{node-CkdgwBiv.d.ts → node-D9-F9uEP.d.ts} +3 -2
  29. package/dist/node.cjs +704 -67
  30. package/dist/node.cjs.map +1 -1
  31. package/dist/node.d.cts +1 -1
  32. package/dist/node.d.ts +1 -1
  33. package/dist/node.js +716 -66
  34. package/dist/node.js.map +1 -1
  35. package/dist/platform.browser.d.ts +2 -2
  36. package/dist/platform.browser.js +808 -121
  37. package/dist/platform.browser.js.map +1 -1
  38. package/dist/platform.cjs +973 -186
  39. package/dist/platform.cjs.map +1 -1
  40. package/dist/platform.d.cts +1 -1
  41. package/dist/platform.d.ts +1 -1
  42. package/dist/platform.js +985 -186
  43. package/dist/platform.js.map +1 -1
  44. package/dist/platform.node.cjs +973 -186
  45. package/dist/platform.node.cjs.map +1 -1
  46. package/dist/platform.node.d.cts +63 -12
  47. package/dist/platform.node.d.ts +63 -12
  48. package/dist/platform.node.js +985 -186
  49. package/dist/platform.node.js.map +1 -1
  50. package/package.json +40 -23
@@ -1,4 +1,4 @@
1
- import { Chain, Address, Hash, WalletClient, Account, Abi, GetContractReturnType, PublicClient } from 'viem';
1
+ import { Chain, Address, Hash, WalletClient, Account, Abi, GetContractReturnType, TransactionReceipt as TransactionReceipt$1, PublicClient } from 'viem';
2
2
  export { Abi, Account, Address, Chain, GetContractReturnType, Hash, PublicClient, WalletClient } from 'viem';
3
3
  import { Abi as Abi$1 } from 'abitype';
4
4
 
@@ -984,6 +984,8 @@ interface ServerFilesAndPermissionParams {
984
984
  grant: string;
985
985
  /** File URLs */
986
986
  fileUrls: string[];
987
+ /** Schema IDs for each file - use 0 for files without schema validation */
988
+ schemaIds: number[];
987
989
  /** Server address */
988
990
  serverAddress: Address;
989
991
  /** Server URL */
@@ -1009,6 +1011,8 @@ interface ServerFilesAndPermissionTypedData extends GenericTypedData {
1009
1011
  grant: string;
1010
1012
  /** File URLs */
1011
1013
  fileUrls: string[];
1014
+ /** Schema IDs for each file - use 0 for files without schema validation */
1015
+ schemaIds: bigint[];
1012
1016
  /** Server address */
1013
1017
  serverAddress: Address;
1014
1018
  /** Server URL */
@@ -2159,33 +2163,84 @@ interface BatchUploadResult {
2159
2163
  errors?: string[];
2160
2164
  }
2161
2165
  /**
2162
- * Represents a data schema in the refiner registry.
2166
+ * Schema metadata from the blockchain (without fetched definition).
2167
+ *
2168
+ * This represents the on-chain schema registration data before the
2169
+ * definition has been fetched from the storage URL.
2170
+ *
2171
+ * @category Data Management
2172
+ */
2173
+ interface SchemaMetadata {
2174
+ /** Schema ID */
2175
+ id: number;
2176
+ /** Schema name */
2177
+ name: string;
2178
+ /** Schema dialect ('json' or 'sqlite') */
2179
+ dialect: "json" | "sqlite";
2180
+ /** URL containing the schema definition */
2181
+ definitionUrl: string;
2182
+ }
2183
+ /**
2184
+ * Complete schema with all definition fields populated.
2185
+ * This is what schemas.get() returns - a schema with the definition fetched.
2186
+ */
2187
+ interface CompleteSchema extends SchemaMetadata {
2188
+ /** Version of the schema */
2189
+ version: string;
2190
+ /** Optional description of the schema */
2191
+ description?: string;
2192
+ /** Optional version of the dialect */
2193
+ dialectVersion?: string;
2194
+ /** The actual schema - JSON Schema object for 'json' dialect, DDL string for 'sqlite' */
2195
+ schema: object | string;
2196
+ }
2197
+ /**
2198
+ * Schema with optional definition fields.
2163
2199
  *
2164
2200
  * Schemas define the structure and validation rules for user data processed by refiners.
2165
2201
  * They ensure data quality and consistency across the Vana network by specifying how
2166
2202
  * raw user data should be formatted, validated, and processed.
2167
2203
  *
2204
+ * When the definition has been fetched (via schemas.get() or schemas.list() with includeDefinitions),
2205
+ * the version and schema fields will be populated. Otherwise, only the metadata fields are present.
2206
+ *
2168
2207
  * @category Data Management
2169
2208
  * @example
2170
2209
  * ```typescript
2171
- * const socialMediaSchema: Schema = {
2210
+ * // Complete schema from schemas.get()
2211
+ * const completeSchema: Schema = {
2212
+ * id: 5,
2213
+ * name: 'Social Media Profile',
2214
+ * dialect: 'json',
2215
+ * definitionUrl: 'ipfs://QmSchema...',
2216
+ * version: '1.0.0',
2217
+ * description: 'Schema for validating social media profile data',
2218
+ * schema: { // JSON Schema object
2219
+ * type: 'object',
2220
+ * properties: {
2221
+ * username: { type: 'string' }
2222
+ * }
2223
+ * }
2224
+ * };
2225
+ *
2226
+ * // Metadata-only schema from schemas.list() without includeDefinitions
2227
+ * const metadataSchema: Schema = {
2172
2228
  * id: 5,
2173
2229
  * name: 'Social Media Profile',
2174
- * type: 'JSON',
2175
- * url: 'ipfs://QmSchema...', // Schema definition file
2176
- * description: 'Schema for validating social media profile data'
2230
+ * dialect: 'json',
2231
+ * definitionUrl: 'ipfs://QmSchema...'
2177
2232
  * };
2178
2233
  * ```
2179
2234
  */
2180
- interface Schema {
2181
- /** Schema ID */
2182
- id: number;
2183
- /** Schema name */
2184
- name: string;
2185
- /** Schema type */
2186
- type: string;
2187
- /** URL containing the schema definition */
2188
- definitionUrl: string;
2235
+ interface Schema extends SchemaMetadata {
2236
+ /** Version of the schema (present when definition is fetched) */
2237
+ version?: string;
2238
+ /** Optional description of the schema */
2239
+ description?: string;
2240
+ /** Optional version of the dialect */
2241
+ dialectVersion?: string;
2242
+ /** The actual schema - JSON Schema object for 'json' dialect, DDL string for 'sqlite' (present when definition is fetched) */
2243
+ schema?: object | string;
2189
2244
  }
2190
2245
  /**
2191
2246
  * Represents a refiner with schema information
@@ -2214,8 +2269,8 @@ interface Refiner {
2214
2269
  interface AddSchemaParams {
2215
2270
  /** Schema name */
2216
2271
  name: string;
2217
- /** Schema type */
2218
- type: string;
2272
+ /** Schema dialect */
2273
+ dialect: string;
2219
2274
  /** URL containing the schema definition */
2220
2275
  definitionUrl: string;
2221
2276
  }
@@ -2290,13 +2345,7 @@ interface UpdateSchemaIdResult {
2290
2345
  transactionHash: Hash;
2291
2346
  }
2292
2347
  /**
2293
- * Query mode for trusted server retrieval
2294
- *
2295
- * @category Data Management
2296
- */
2297
- type TrustedServerQueryMode = "subgraph" | "rpc" | "auto";
2298
- /**
2299
- * Trusted server data structure (unified format for both subgraph and RPC modes)
2348
+ * Trusted server data structure
2300
2349
  *
2301
2350
  * @category Data Management
2302
2351
  */
@@ -2315,39 +2364,20 @@ interface TrustedServer {
2315
2364
  trustIndex?: number;
2316
2365
  }
2317
2366
  /**
2318
- * Parameters for getUserTrustedServers with dual-mode support
2367
+ * Parameters for getUserTrustedServers method
2319
2368
  *
2320
2369
  * @category Data Management
2321
2370
  */
2322
2371
  interface GetUserTrustedServersParams {
2323
- /** User address to query */
2372
+ /** User address to query trusted servers for */
2324
2373
  user: Address;
2325
- /** Query mode: 'subgraph' (fast, requires subgraph), 'rpc' (direct contract), or 'auto' (tries subgraph first) */
2326
- mode?: TrustedServerQueryMode;
2327
- /** Subgraph URL (required for subgraph mode) */
2374
+ /** Optional subgraph URL to override default */
2328
2375
  subgraphUrl?: string;
2329
- /** Pagination limit (applies to RPC mode) */
2376
+ /** Maximum number of results */
2330
2377
  limit?: number;
2331
- /** Pagination offset (applies to RPC mode) */
2378
+ /** Number of results to skip */
2332
2379
  offset?: number;
2333
2380
  }
2334
- /**
2335
- * Result of getUserTrustedServers query
2336
- *
2337
- * @category Data Management
2338
- */
2339
- interface GetUserTrustedServersResult {
2340
- /** Array of trusted servers */
2341
- servers: TrustedServer[];
2342
- /** Query mode that was actually used */
2343
- usedMode: TrustedServerQueryMode;
2344
- /** Total count (only available in RPC mode) */
2345
- total?: number;
2346
- /** Whether there are more servers (pagination info for RPC mode) */
2347
- hasMore?: boolean;
2348
- /** Any warnings or fallback information */
2349
- warnings?: string[];
2350
- }
2351
2381
 
2352
2382
  declare const contractAbis: {
2353
2383
  readonly DataPortabilityPermissions: readonly [{
@@ -2466,6 +2496,18 @@ declare const contractAbis: {
2466
2496
  }];
2467
2497
  readonly name: "InvalidPermissionsLength";
2468
2498
  readonly type: "error";
2499
+ }, {
2500
+ readonly inputs: readonly [{
2501
+ readonly internalType: "uint256";
2502
+ readonly name: "filesLength";
2503
+ readonly type: "uint256";
2504
+ }, {
2505
+ readonly internalType: "uint256";
2506
+ readonly name: "schemaIdsLength";
2507
+ readonly type: "uint256";
2508
+ }];
2509
+ readonly name: "InvalidSchemaIdsLength";
2510
+ readonly type: "error";
2469
2511
  }, {
2470
2512
  readonly inputs: readonly [];
2471
2513
  readonly name: "InvalidSignature";
@@ -2742,6 +2784,10 @@ declare const contractAbis: {
2742
2784
  readonly internalType: "string[]";
2743
2785
  readonly name: "fileUrls";
2744
2786
  readonly type: "string[]";
2787
+ }, {
2788
+ readonly internalType: "uint256[]";
2789
+ readonly name: "schemaIds";
2790
+ readonly type: "uint256[]";
2745
2791
  }, {
2746
2792
  readonly internalType: "address";
2747
2793
  readonly name: "serverAddress";
@@ -3724,7 +3770,7 @@ declare const contractAbis: {
3724
3770
  readonly name: "addServerInput";
3725
3771
  readonly type: "tuple";
3726
3772
  }];
3727
- readonly name: "addAndTrustServerOnBehalf";
3773
+ readonly name: "addAndTrustServerByManager";
3728
3774
  readonly outputs: readonly [];
3729
3775
  readonly stateMutability: "nonpayable";
3730
3776
  readonly type: "function";
@@ -4112,6 +4158,20 @@ declare const contractAbis: {
4112
4158
  readonly outputs: readonly [];
4113
4159
  readonly stateMutability: "nonpayable";
4114
4160
  readonly type: "function";
4161
+ }, {
4162
+ readonly inputs: readonly [{
4163
+ readonly internalType: "address";
4164
+ readonly name: "userAddress";
4165
+ readonly type: "address";
4166
+ }, {
4167
+ readonly internalType: "uint256";
4168
+ readonly name: "serverId";
4169
+ readonly type: "uint256";
4170
+ }];
4171
+ readonly name: "trustServerByManager";
4172
+ readonly outputs: readonly [];
4173
+ readonly stateMutability: "nonpayable";
4174
+ readonly type: "function";
4115
4175
  }, {
4116
4176
  readonly inputs: readonly [{
4117
4177
  readonly components: readonly [{
@@ -28735,6 +28795,95 @@ type VanaContract = keyof ContractAbis;
28735
28795
  */
28736
28796
  declare function getAbi<T extends VanaContract>(contract: T): ContractAbis[T];
28737
28797
 
28798
+ /**
28799
+ * Comprehensive mapping of SDK transaction operations to blockchain events.
28800
+ * Used by the generic transaction parser to know which contract and event
28801
+ * to look for when parsing transaction results.
28802
+ */
28803
+ declare const EVENT_MAPPINGS: {
28804
+ readonly grant: {
28805
+ readonly contract: "DataPortabilityPermissions";
28806
+ readonly event: "PermissionAdded";
28807
+ };
28808
+ readonly revoke: {
28809
+ readonly contract: "DataPortabilityPermissions";
28810
+ readonly event: "PermissionRevoked";
28811
+ };
28812
+ readonly revokePermission: {
28813
+ readonly contract: "DataPortabilityPermissions";
28814
+ readonly event: "PermissionRevoked";
28815
+ };
28816
+ readonly addServerFilesAndPermissions: {
28817
+ readonly contract: "DataPortabilityPermissions";
28818
+ readonly event: "PermissionAdded";
28819
+ };
28820
+ readonly trustServer: {
28821
+ readonly contract: "DataPortabilityServers";
28822
+ readonly event: "ServerTrusted";
28823
+ };
28824
+ readonly untrustServer: {
28825
+ readonly contract: "DataPortabilityServers";
28826
+ readonly event: "ServerUntrusted";
28827
+ };
28828
+ readonly registerServer: {
28829
+ readonly contract: "DataPortabilityServers";
28830
+ readonly event: "ServerRegistered";
28831
+ };
28832
+ readonly updateServer: {
28833
+ readonly contract: "DataPortabilityServers";
28834
+ readonly event: "ServerUpdated";
28835
+ };
28836
+ readonly addAndTrustServer: {
28837
+ readonly contract: "DataPortabilityServers";
28838
+ readonly event: "ServerTrusted";
28839
+ };
28840
+ readonly addFile: {
28841
+ readonly contract: "DataRegistry";
28842
+ readonly event: "FileAdded";
28843
+ };
28844
+ readonly addFileWithPermissionsAndSchema: {
28845
+ readonly contract: "DataRegistry";
28846
+ readonly event: "FileAdded";
28847
+ };
28848
+ readonly addFileWithSchema: {
28849
+ readonly contract: "DataRegistry";
28850
+ readonly event: "FileAdded";
28851
+ };
28852
+ readonly addFileWithPermissions: {
28853
+ readonly contract: "DataRegistry";
28854
+ readonly event: "FileAdded";
28855
+ };
28856
+ readonly addRefinement: {
28857
+ readonly contract: "DataRegistry";
28858
+ readonly event: "RefinementAdded";
28859
+ };
28860
+ readonly addRefiner: {
28861
+ readonly contract: "DataRefinerRegistry";
28862
+ readonly event: "RefinerAdded";
28863
+ };
28864
+ readonly updateSchemaId: {
28865
+ readonly contract: "DataRefinerRegistry";
28866
+ readonly event: "SchemaAdded";
28867
+ };
28868
+ readonly addSchema: {
28869
+ readonly contract: "DataRefinerRegistry";
28870
+ readonly event: "SchemaAdded";
28871
+ };
28872
+ readonly updateRefinement: {
28873
+ readonly contract: "DataRegistry";
28874
+ readonly event: "RefinementUpdated";
28875
+ };
28876
+ readonly addFilePermission: {
28877
+ readonly contract: "DataRegistry";
28878
+ readonly event: "PermissionGranted";
28879
+ };
28880
+ readonly registerGrantee: {
28881
+ readonly contract: "DataPortabilityGrantees";
28882
+ readonly event: "GranteeRegistered";
28883
+ };
28884
+ };
28885
+ type TransactionOperation = keyof typeof EVENT_MAPPINGS;
28886
+
28738
28887
  /**
28739
28888
  * Base interface for all transaction results.
28740
28889
  * Contains the event data plus transaction metadata.
@@ -28772,6 +28921,62 @@ interface PermissionRevokeResult extends BaseTransactionResult {
28772
28921
  /** ID of the permission that was revoked */
28773
28922
  permissionId: bigint;
28774
28923
  }
28924
+ /**
28925
+ * Result of a successful server trust operation.
28926
+ * Contains data from the ServerTrusted blockchain event.
28927
+ */
28928
+ interface ServerTrustResult extends BaseTransactionResult {
28929
+ /** Address of the user who trusted the server */
28930
+ user: Address;
28931
+ /** Address/ID of the trusted server */
28932
+ serverId: Address;
28933
+ /** URL of the trusted server */
28934
+ serverUrl: string;
28935
+ }
28936
+ /**
28937
+ * Result of a successful server untrust operation.
28938
+ * Contains data from the ServerUntrusted blockchain event.
28939
+ */
28940
+ interface ServerUntrustResult extends BaseTransactionResult {
28941
+ /** Address of the user who untrusted the server */
28942
+ user: Address;
28943
+ /** Address/ID of the untrusted server */
28944
+ serverId: Address;
28945
+ }
28946
+ /**
28947
+ * Result of a successful server update operation.
28948
+ * Contains data from the ServerUpdated blockchain event.
28949
+ */
28950
+ interface ServerUpdateResult extends BaseTransactionResult {
28951
+ /** ID of the server that was updated */
28952
+ serverId: bigint;
28953
+ /** New URL of the server */
28954
+ url: string;
28955
+ }
28956
+ /**
28957
+ * Result of a successful grantee registration operation.
28958
+ * Contains data from the GranteeRegistered blockchain event.
28959
+ */
28960
+ interface GranteeRegisterResult extends BaseTransactionResult {
28961
+ /** Unique grantee ID assigned by the registry */
28962
+ granteeId: bigint;
28963
+ /** Address of the registered grantee */
28964
+ granteeAddress: Address;
28965
+ /** Display name of the grantee */
28966
+ name: string;
28967
+ }
28968
+ /**
28969
+ * Result of a successful file addition operation.
28970
+ * Contains data from the FileAdded blockchain event.
28971
+ */
28972
+ interface FileAddedResult extends BaseTransactionResult {
28973
+ /** Unique file ID assigned by the registry */
28974
+ fileId: bigint;
28975
+ /** Address of the file owner */
28976
+ ownerAddress: Address;
28977
+ /** URL where the file is stored */
28978
+ url: string;
28979
+ }
28775
28980
  /**
28776
28981
  * Result of a successful file permission addition operation.
28777
28982
  * Contains data from the FilePermissionAdded blockchain event.
@@ -28785,6 +28990,80 @@ interface FilePermissionResult extends BaseTransactionResult {
28785
28990
  encryptedKey: string;
28786
28991
  }
28787
28992
 
28993
+ /**
28994
+ * Provides a unified interface for blockchain transaction results with lazy-loaded event parsing.
28995
+ *
28996
+ * @remarks
28997
+ * TransactionHandle enables immediate access to transaction hashes while providing optional
28998
+ * lazy-loaded access to receipts and parsed event data. All transaction-submitting methods
28999
+ * in the SDK return this handle, allowing developers to choose between immediate hash access
29000
+ * or waiting for event data. Results are memoized to prevent redundant network calls.
29001
+ *
29002
+ * @category Transactions
29003
+ * @example
29004
+ * ```typescript
29005
+ * // Immediate hash access
29006
+ * const tx = await sdk.permissions.submitSignedGrant(typedData, signature);
29007
+ * console.log(`Transaction submitted: ${tx.hash}`);
29008
+ *
29009
+ * // Wait for and parse events
29010
+ * const eventData = await tx.waitForEvents();
29011
+ * console.log(`Permission ID: ${eventData.permissionId}`);
29012
+ *
29013
+ * // Check receipt for gas usage
29014
+ * const receipt = await tx.waitForReceipt();
29015
+ * console.log(`Gas used: ${receipt.gasUsed}`);
29016
+ * ```
29017
+ */
29018
+ declare class TransactionHandle<TEventData = unknown> {
29019
+ private readonly context;
29020
+ readonly hash: Hash;
29021
+ private readonly operation?;
29022
+ private _receipt?;
29023
+ private _eventData?;
29024
+ private _receiptPromise?;
29025
+ private _eventPromise?;
29026
+ constructor(context: ControllerContext$1, hash: Hash, operation?: TransactionOperation | undefined);
29027
+ /**
29028
+ * Waits for transaction confirmation and returns the receipt.
29029
+ * Results are memoized - multiple calls return the same promise.
29030
+ *
29031
+ * @param options Optional timeout configuration
29032
+ * @param options.timeout Timeout in milliseconds (default: 30000)
29033
+ * @returns Transaction receipt with gas usage, logs, and status
29034
+ */
29035
+ waitForReceipt(options?: {
29036
+ timeout?: number;
29037
+ }): Promise<TransactionReceipt$1>;
29038
+ /**
29039
+ * Waits for transaction confirmation and parses emitted events.
29040
+ * Results are memoized - multiple calls return the same promise.
29041
+ *
29042
+ * @returns Parsed event data with transaction metadata
29043
+ * @throws {Error} If no operation was specified for event parsing
29044
+ */
29045
+ waitForEvents(): Promise<TEventData>;
29046
+ /**
29047
+ * Enables string coercion for backwards compatibility.
29048
+ * Allows TransactionHandle to be used anywhere a Hash is expected.
29049
+ *
29050
+ * @example
29051
+ * ```typescript
29052
+ * const hash: Hash = tx; // Works via toString()
29053
+ * console.log(`Transaction: ${tx}`); // Prints hash
29054
+ * ```
29055
+ * @returns The transaction hash as a string
29056
+ */
29057
+ toString(): string;
29058
+ /**
29059
+ * JSON serialization support.
29060
+ * Returns the hash when serialized to JSON.
29061
+ *
29062
+ * @returns The transaction hash for JSON serialization
29063
+ */
29064
+ toJSON(): string;
29065
+ }
29066
+
28788
29067
  /**
28789
29068
  * Google Drive Storage Provider for Vana SDK
28790
29069
  *
@@ -29823,30 +30102,31 @@ declare class PermissionsController {
29823
30102
  */
29824
30103
  grant(params: GrantPermissionParams$1): Promise<PermissionGrantResult>;
29825
30104
  /**
29826
- * Submits a permission grant transaction and returns the transaction hash immediately.
30105
+ * Submits a permission grant transaction and returns a handle for flexible result access.
29827
30106
  *
29828
- * This is the lower-level method that provides maximum control over transaction timing.
29829
- * Use this when you want to handle transaction confirmation and event parsing separately,
29830
- * or when submitting multiple transactions in batch.
30107
+ * @remarks
30108
+ * This lower-level method provides maximum control over transaction timing.
30109
+ * Returns a TransactionHandle that allows immediate hash access or optional event parsing.
30110
+ * Use this when handling multiple transactions or when you need granular control.
29831
30111
  *
29832
30112
  * @param params - The permission grant configuration object
29833
- * @returns Promise that resolves to the transaction hash when successfully submitted
30113
+ * @returns Promise resolving to TransactionHandle with hash and event parsing capabilities
29834
30114
  * @throws {RelayerError} When gasless transaction submission fails
29835
30115
  * @throws {SignatureError} When user rejects the signature request
29836
30116
  * @throws {SerializationError} When grant data cannot be serialized
29837
30117
  * @throws {BlockchainError} When permission grant preparation fails
29838
30118
  * @example
29839
30119
  * ```typescript
29840
- * // Submit transaction and handle confirmation later
29841
- * const txHash = await vana.permissions.submitPermissionGrant(params);
29842
- * console.log(`Transaction submitted: ${txHash}`);
30120
+ * // Submit transaction and get immediate hash access
30121
+ * const tx = await vana.permissions.submitPermissionGrant(params);
30122
+ * console.log(`Transaction submitted: ${tx.hash}`);
29843
30123
  *
29844
- * // Later, when you need the permission data:
29845
- * const result = await parseTransactionResult(context, txHash, 'grant');
29846
- * console.log(`Permission ID: ${result.permissionId}`);
30124
+ * // Optionally wait for and parse events
30125
+ * const eventData = await tx.waitForEvents();
30126
+ * console.log(`Permission ID: ${eventData.permissionId}`);
29847
30127
  * ```
29848
30128
  */
29849
- submitPermissionGrant(params: GrantPermissionParams$1): Promise<Hash>;
30129
+ submitPermissionGrant(params: GrantPermissionParams$1): Promise<TransactionHandle<PermissionGrantResult>>;
29850
30130
  /**
29851
30131
  * Prepares a permission grant with preview before signing.
29852
30132
  *
@@ -29874,15 +30154,21 @@ declare class PermissionsController {
29874
30154
  */
29875
30155
  prepareGrant(params: GrantPermissionParams$1): Promise<{
29876
30156
  preview: GrantFile;
29877
- confirm: () => Promise<Hash>;
30157
+ confirm: () => Promise<TransactionHandle<PermissionGrantResult>>;
29878
30158
  }>;
29879
30159
  /**
29880
- * Internal method to complete the grant process after user confirmation.
29881
- * This is called by the confirm() function returned from prepareGrant().
30160
+ * Completes the grant process after user confirmation.
30161
+ *
30162
+ * @remarks
30163
+ * This internal method is called by the confirm() function returned from prepareGrant().
30164
+ * It handles IPFS upload, signature creation, and transaction submission.
29882
30165
  *
29883
30166
  * @param params - The permission grant parameters containing user and operation details
29884
30167
  * @param grantFile - The prepared grant file with permissions and metadata
29885
- * @returns Promise resolving to the transaction hash
30168
+ * @returns Promise resolving to TransactionHandle for flexible result access
30169
+ * @throws {BlockchainError} When permission grant confirmation fails
30170
+ * @throws {NetworkError} When IPFS upload fails
30171
+ * @throws {SignatureError} When user rejects the signature
29886
30172
  */
29887
30173
  private confirmGrantInternal;
29888
30174
  /**
@@ -29938,49 +30224,106 @@ declare class PermissionsController {
29938
30224
  * );
29939
30225
  * ```
29940
30226
  */
29941
- submitSignedGrant(typedData: PermissionGrantTypedData, signature: Hash): Promise<Hash>;
30227
+ submitSignedGrant(typedData: PermissionGrantTypedData, signature: Hash): Promise<TransactionHandle<PermissionGrantResult>>;
29942
30228
  /**
29943
30229
  * Submits an already-signed trust server transaction to the blockchain.
30230
+ *
30231
+ * @remarks
29944
30232
  * This method extracts the trust server input from typed data and submits it directly.
30233
+ * Used internally by trust server methods after signature collection.
29945
30234
  *
29946
30235
  * @param typedData - The EIP-712 typed data for TrustServer
29947
- * @param signature - The user's signature
29948
- * @returns Promise resolving to the transaction hash
30236
+ * @param signature - The user's signature obtained via `signTypedData()`
30237
+ * @returns Promise resolving to TransactionHandle for transaction tracking
30238
+ * @throws {BlockchainError} When contract submission fails
30239
+ * @throws {NetworkError} When blockchain communication fails
30240
+ * @example
30241
+ * ```typescript
30242
+ * const txHandle = await vana.permissions.submitSignedTrustServer(
30243
+ * typedData,
30244
+ * "0x1234..."
30245
+ * );
30246
+ * const result = await txHandle.waitForEvents();
30247
+ * ```
29949
30248
  */
29950
- submitSignedTrustServer(typedData: TrustServerTypedData, signature: Hash): Promise<Hash>;
30249
+ submitSignedTrustServer(typedData: TrustServerTypedData, signature: Hash): Promise<TransactionHandle<ServerTrustResult>>;
29951
30250
  /**
29952
30251
  * Submits an already-signed add and trust server transaction to the blockchain.
30252
+ *
30253
+ * @remarks
29953
30254
  * This method extracts the add and trust server input from typed data and submits it directly.
30255
+ * Combines server registration and trust operations in a single transaction.
29954
30256
  *
29955
30257
  * @param typedData - The EIP-712 typed data for AddAndTrustServer
29956
- * @param signature - The user's signature
29957
- * @returns Promise resolving to the transaction hash
30258
+ * @param signature - The user's signature obtained via `signTypedData()`
30259
+ * @returns Promise resolving to TransactionHandle for transaction tracking
30260
+ * @throws {BlockchainError} When contract submission fails
30261
+ * @throws {NetworkError} When blockchain communication fails
30262
+ * @example
30263
+ * ```typescript
30264
+ * const txHandle = await vana.permissions.submitSignedAddAndTrustServer(
30265
+ * typedData,
30266
+ * "0x1234..."
30267
+ * );
30268
+ * const result = await txHandle.waitForEvents();
30269
+ * ```
29958
30270
  */
29959
- submitSignedAddAndTrustServer(typedData: AddAndTrustServerTypedData, signature: Hash): Promise<Hash>;
30271
+ submitSignedAddAndTrustServer(typedData: AddAndTrustServerTypedData, signature: Hash): Promise<TransactionHandle<ServerTrustResult>>;
29960
30272
  /**
29961
30273
  * Submits an already-signed permission revoke transaction to the blockchain.
30274
+ *
30275
+ * @remarks
29962
30276
  * This method handles the revocation of previously granted permissions.
30277
+ * Used internally by revocation methods after signature collection.
29963
30278
  *
29964
30279
  * @param typedData - The EIP-712 typed data for PermissionRevoke
29965
- * @param signature - The user's signature
29966
- * @returns Promise resolving to the transaction hash
30280
+ * @param signature - The user's signature obtained via `signTypedData()`
30281
+ * @returns Promise resolving to TransactionHandle for transaction tracking
30282
+ * @throws {BlockchainError} When contract submission fails
30283
+ * @throws {NetworkError} When blockchain communication fails
30284
+ * @example
30285
+ * ```typescript
30286
+ * const txHandle = await vana.permissions.submitSignedRevoke(
30287
+ * typedData,
30288
+ * "0x1234..."
30289
+ * );
30290
+ * const result = await txHandle.waitForEvents();
30291
+ * ```
29967
30292
  */
29968
- submitSignedRevoke(typedData: GenericTypedData, signature: Hash): Promise<Hash>;
30293
+ submitSignedRevoke(typedData: GenericTypedData, signature: Hash): Promise<TransactionHandle<PermissionRevokeResult>>;
29969
30294
  /**
29970
30295
  * Submits an already-signed untrust server transaction to the blockchain.
30296
+ *
30297
+ * @remarks
29971
30298
  * This method handles the removal of trusted servers.
30299
+ * Used internally by untrust server methods after signature collection.
29972
30300
  *
29973
30301
  * @param typedData - The EIP-712 typed data for UntrustServer
29974
- * @param signature - The user's signature
29975
- * @returns Promise resolving to the transaction hash
30302
+ * @param signature - The user's signature obtained via `signTypedData()`
30303
+ * @returns Promise resolving to TransactionHandle for transaction tracking
30304
+ * @throws {BlockchainError} When contract submission fails
30305
+ * @throws {NetworkError} When blockchain communication fails
30306
+ * @example
30307
+ * ```typescript
30308
+ * const txHandle = await vana.permissions.submitSignedUntrustServer(
30309
+ * typedData,
30310
+ * "0x1234..."
30311
+ * );
30312
+ * const result = await txHandle.waitForEvents();
30313
+ * ```
29976
30314
  */
29977
- submitSignedUntrustServer(typedData: GenericTypedData, signature: Hash): Promise<Hash>;
30315
+ submitSignedUntrustServer(typedData: GenericTypedData, signature: Hash): Promise<TransactionHandle<ServerUntrustResult>>;
29978
30316
  /**
29979
30317
  * Submits a signed transaction directly to the blockchain.
29980
30318
  *
30319
+ * @remarks
30320
+ * Internal method used when relayer callbacks are not available. Formats the signature
30321
+ * and submits the permission grant directly to the smart contract.
30322
+ *
29981
30323
  * @param typedData - The typed data structure for the permission grant
29982
30324
  * @param signature - The cryptographic signature authorizing the transaction
29983
30325
  * @returns Promise resolving to the transaction hash
30326
+ * @throws {BlockchainError} When contract submission fails
29984
30327
  */
29985
30328
  private submitDirectTransaction;
29986
30329
  /**
@@ -30027,19 +30370,33 @@ declare class PermissionsController {
30027
30370
  * console.log(`Revocation submitted: ${txHash}`);
30028
30371
  * ```
30029
30372
  */
30030
- submitPermissionRevoke(params: RevokePermissionParams): Promise<Hash>;
30373
+ submitPermissionRevoke(params: RevokePermissionParams): Promise<TransactionHandle<PermissionRevokeResult>>;
30031
30374
  /**
30032
- * Revokes a permission with a signature (gasless transaction).
30375
+ * Revokes a permission with a signature for gasless transactions.
30376
+ *
30377
+ * @remarks
30378
+ * This method creates an EIP-712 signature for permission revocation and submits
30379
+ * it either through relayer callbacks or directly to the blockchain. Provides
30380
+ * gasless revocation when relayer is configured.
30033
30381
  *
30034
30382
  * @param params - Parameters for revoking the permission
30035
- * @returns Promise resolving to transaction hash
30383
+ * @param params.permissionId - Permission identifier to revoke (accepts bigint, number, or string)
30384
+ * @returns Promise resolving to TransactionHandle for transaction tracking
30036
30385
  * @throws {BlockchainError} When chain ID is not available
30037
30386
  * @throws {NonceError} When retrieving user nonce fails
30038
30387
  * @throws {SignatureError} When user rejects the signature request
30039
30388
  * @throws {RelayerError} When gasless submission fails
30040
30389
  * @throws {PermissionError} When revocation fails for any other reason
30390
+ * @example
30391
+ * ```typescript
30392
+ * const txHandle = await vana.permissions.submitRevokeWithSignature({
30393
+ * permissionId: 123n
30394
+ * });
30395
+ * const result = await txHandle.waitForEvents();
30396
+ * console.log(`Permission ${result.permissionId} revoked`);
30397
+ * ```
30041
30398
  */
30042
- submitRevokeWithSignature(params: RevokePermissionParams): Promise<Hash>;
30399
+ submitRevokeWithSignature(params: RevokePermissionParams): Promise<TransactionHandle<PermissionRevokeResult>>;
30043
30400
  /**
30044
30401
  * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
30045
30402
  *
@@ -30064,6 +30421,18 @@ declare class PermissionsController {
30064
30421
  * const serversNonce = await this.getServersUserNonce();
30065
30422
  * ```
30066
30423
  */
30424
+ /**
30425
+ * @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
30426
+ *
30427
+ * Retrieves the user's current nonce from the DataPortabilityServers contract.
30428
+ *
30429
+ * @remarks
30430
+ * This method is deprecated in favor of more specific nonce methods that target
30431
+ * the appropriate contract for the operation being performed.
30432
+ *
30433
+ * @returns Promise resolving to the user's current nonce as a bigint
30434
+ * @throws {NonceError} When retrieving the nonce fails
30435
+ */
30067
30436
  private getUserNonce;
30068
30437
  /**
30069
30438
  * Retrieves the user's current nonce from the DataPortabilityServers contract.
@@ -30079,6 +30448,16 @@ declare class PermissionsController {
30079
30448
  * console.log(`Current servers nonce: ${nonce}`);
30080
30449
  * ```
30081
30450
  */
30451
+ /**
30452
+ * Retrieves the user's current nonce from the DataPortabilityServers contract.
30453
+ *
30454
+ * @remarks
30455
+ * Used for server-related operations (trust/untrust) to prevent replay attacks.
30456
+ * The nonce must be incremented with each server operation.
30457
+ *
30458
+ * @returns Promise resolving to the user's current nonce as a bigint
30459
+ * @throws {NonceError} When retrieving the nonce fails
30460
+ */
30082
30461
  private getServersUserNonce;
30083
30462
  /**
30084
30463
  * Retrieves the user's current nonce from the DataPortabilityPermissions contract.
@@ -30094,6 +30473,16 @@ declare class PermissionsController {
30094
30473
  * console.log(`Current permissions nonce: ${nonce}`);
30095
30474
  * ```
30096
30475
  */
30476
+ /**
30477
+ * Retrieves the user's current nonce from the DataPortabilityPermissions contract.
30478
+ *
30479
+ * @remarks
30480
+ * Used for permission-related operations (grant/revoke) to prevent replay attacks.
30481
+ * The nonce must be incremented with each permission operation.
30482
+ *
30483
+ * @returns Promise resolving to the user's current nonce as a bigint
30484
+ * @throws {NonceError} When retrieving the nonce fails
30485
+ */
30097
30486
  private getPermissionsUserNonce;
30098
30487
  /**
30099
30488
  * Composes the EIP-712 typed data for PermissionGrant (new simplified format).
@@ -30115,6 +30504,7 @@ declare class PermissionsController {
30115
30504
  * @param params.granteeId - Grantee ID
30116
30505
  * @param params.grant - Grant URL or grant data
30117
30506
  * @param params.fileUrls - Array of file URLs
30507
+ * @param params.schemaIds - Schema IDs for each file
30118
30508
  * @param params.serverAddress - Server address
30119
30509
  * @param params.serverUrl - Server URL
30120
30510
  * @param params.serverPublicKey - Server public key
@@ -30220,7 +30610,7 @@ declare class PermissionsController {
30220
30610
  * console.log('Now trusting servers:', trustedServers);
30221
30611
  * ```
30222
30612
  */
30223
- addAndTrustServer(params: AddAndTrustServerParams): Promise<Hash>;
30613
+ addAndTrustServer(params: AddAndTrustServerParams): Promise<TransactionHandle<ServerTrustResult>>;
30224
30614
  /**
30225
30615
  * Trusts a server for data processing (legacy method).
30226
30616
  *
@@ -30228,14 +30618,14 @@ declare class PermissionsController {
30228
30618
  * @returns Promise resolving to transaction hash
30229
30619
  * @deprecated Use addAndTrustServer instead
30230
30620
  */
30231
- submitTrustServer(params: TrustServerParams): Promise<Hash>;
30621
+ submitTrustServer(params: TrustServerParams): Promise<TransactionHandle<ServerTrustResult>>;
30232
30622
  /**
30233
30623
  * Adds and trusts a server using a signature (gasless transaction).
30234
30624
  *
30235
30625
  * @param params - Parameters for adding and trusting the server
30236
- * @returns Promise resolving to transaction hash
30626
+ * @returns Promise resolving to TransactionHandle with ServerTrustResult event data
30237
30627
  */
30238
- submitAddAndTrustServerWithSignature(params: AddAndTrustServerParams): Promise<Hash>;
30628
+ submitAddAndTrustServerWithSignature(params: AddAndTrustServerParams): Promise<TransactionHandle<ServerTrustResult>>;
30239
30629
  /**
30240
30630
  * Trusts a server using a signature (gasless transaction - legacy method).
30241
30631
  *
@@ -30249,13 +30639,24 @@ declare class PermissionsController {
30249
30639
  * @throws {ServerUrlMismatchError} When server URL doesn't match existing registration
30250
30640
  * @throws {BlockchainError} When trust operation fails for any other reason
30251
30641
  */
30252
- submitTrustServerWithSignature(params: TrustServerParams): Promise<Hash>;
30642
+ submitTrustServerWithSignature(params: TrustServerParams): Promise<TransactionHandle<ServerTrustResult>>;
30253
30643
  /**
30254
30644
  * Submits a direct untrust server transaction (without signature).
30255
30645
  *
30256
30646
  * @param params - The untrust server parameters containing server details
30257
30647
  * @returns Promise resolving to the transaction hash
30258
30648
  */
30649
+ /**
30650
+ * Submits an untrust server transaction directly to the blockchain.
30651
+ *
30652
+ * @remarks
30653
+ * Internal method used for direct blockchain submission of untrust server operations
30654
+ * when relayer callbacks are not available.
30655
+ *
30656
+ * @param params - The untrust server parameters
30657
+ * @returns Promise resolving to TransactionHandle for transaction tracking
30658
+ * @throws {BlockchainError} When contract submission fails
30659
+ */
30259
30660
  private submitDirectUntrustTransaction;
30260
30661
  /**
30261
30662
  * Removes a server from the user's trusted servers list in the DataPortabilityServers contract.
@@ -30285,7 +30686,7 @@ declare class PermissionsController {
30285
30686
  * console.log('Still trusting servers:', trustedServers);
30286
30687
  * ```
30287
30688
  */
30288
- submitUntrustServer(params: UntrustServerParams): Promise<Hash>;
30689
+ submitUntrustServer(params: UntrustServerParams): Promise<TransactionHandle<ServerUntrustResult>>;
30289
30690
  /**
30290
30691
  * Untrusts a server using a signature (gasless transaction).
30291
30692
  *
@@ -30298,7 +30699,7 @@ declare class PermissionsController {
30298
30699
  * @throws {RelayerError} When gasless submission fails
30299
30700
  * @throws {BlockchainError} When untrust transaction fails
30300
30701
  */
30301
- submitUntrustServerWithSignature(params: UntrustServerParams): Promise<Hash>;
30702
+ submitUntrustServerWithSignature(params: UntrustServerParams): Promise<TransactionHandle<ServerUntrustResult>>;
30302
30703
  /**
30303
30704
  * Retrieves all servers trusted by a user from the DataPortabilityServers contract.
30304
30705
  *
@@ -30349,22 +30750,60 @@ declare class PermissionsController {
30349
30750
  /**
30350
30751
  * Gets server information for multiple servers efficiently.
30351
30752
  *
30352
- * @param serverIds - Array of server IDs to query
30353
- * @returns Promise resolving to batch result with successes and failures
30753
+ * @remarks
30754
+ * This method uses multicall to fetch information for multiple servers in a single
30755
+ * blockchain call, improving performance when querying many servers. Failed lookups
30756
+ * are returned separately for error handling.
30757
+ *
30758
+ * @param serverIds - Array of numeric server IDs to query
30759
+ * @returns Promise resolving to batch result containing successful lookups and failed IDs
30354
30760
  * @throws {BlockchainError} When reading from contract fails or chain is unavailable
30761
+ * @example
30762
+ * ```typescript
30763
+ * const result = await vana.permissions.getServerInfoBatch([1, 2, 3, 999]);
30764
+ *
30765
+ * // Process successful lookups
30766
+ * result.servers.forEach((server, id) => {
30767
+ * console.log(`Server ${id}: ${server.url}`);
30768
+ * });
30769
+ *
30770
+ * // Handle failed lookups
30771
+ * if (result.failed.length > 0) {
30772
+ * console.log(`Failed to fetch: ${result.failed.join(', ')}`);
30773
+ * }
30774
+ * ```
30355
30775
  */
30356
30776
  getServerInfoBatch(serverIds: number[]): Promise<BatchServerInfoResult>;
30357
30777
  /**
30358
30778
  * Checks whether a specific server is trusted by a user.
30359
30779
  *
30360
- * @param serverId - Server ID to check (numeric)
30780
+ * @remarks
30781
+ * This method queries the user's trusted server list and checks if the specified
30782
+ * server is present. Returns both the trust status and the index in the trust list
30783
+ * if trusted.
30784
+ *
30785
+ * @param serverId - Numeric server ID to check
30361
30786
  * @param userAddress - Optional user address (defaults to current user)
30362
- * @returns Promise resolving to server trust status
30787
+ * @returns Promise resolving to server trust status with trust index if applicable
30788
+ * @throws {BlockchainError} When reading from contract fails
30789
+ * @example
30790
+ * ```typescript
30791
+ * const status = await vana.permissions.checkServerTrustStatus(1);
30792
+ * if (status.isTrusted) {
30793
+ * console.log(`Server is trusted at index ${status.trustIndex}`);
30794
+ * } else {
30795
+ * console.log('Server is not trusted');
30796
+ * }
30797
+ * ```
30363
30798
  */
30364
30799
  checkServerTrustStatus(serverId: number, userAddress?: Address): Promise<ServerTrustStatus>;
30365
30800
  /**
30366
30801
  * Composes EIP-712 typed data for AddAndTrustServer.
30367
30802
  *
30803
+ * @remarks
30804
+ * Creates the complete typed data structure required for EIP-712 signature generation
30805
+ * when adding and trusting a new server in a single transaction.
30806
+ *
30368
30807
  * @param input - The add and trust server input data containing server details
30369
30808
  * @returns Promise resolving to the typed data structure for server add and trust
30370
30809
  */
@@ -30446,7 +30885,7 @@ declare class PermissionsController {
30446
30885
  * console.log(`Grantee registered in transaction: ${txHash}`);
30447
30886
  * ```
30448
30887
  */
30449
- submitRegisterGrantee(params: RegisterGranteeParams): Promise<Hash>;
30888
+ submitRegisterGrantee(params: RegisterGranteeParams): Promise<TransactionHandle<GranteeRegisterResult>>;
30450
30889
  /**
30451
30890
  * Registers a grantee with a signature (gasless transaction)
30452
30891
  *
@@ -30462,7 +30901,7 @@ declare class PermissionsController {
30462
30901
  * });
30463
30902
  * ```
30464
30903
  */
30465
- submitRegisterGranteeWithSignature(params: RegisterGranteeParams): Promise<Hash>;
30904
+ submitRegisterGranteeWithSignature(params: RegisterGranteeParams): Promise<TransactionHandle<GranteeRegisterResult>>;
30466
30905
  /**
30467
30906
  * Submits a signed register grantee transaction via relayer
30468
30907
  *
@@ -30475,7 +30914,7 @@ declare class PermissionsController {
30475
30914
  * const result = await vana.permissions.submitSignedRegisterGrantee(typedData, signature);
30476
30915
  * ```
30477
30916
  */
30478
- submitSignedRegisterGrantee(typedData: RegisterGranteeTypedData, signature: Hash): Promise<Hash>;
30917
+ submitSignedRegisterGrantee(typedData: RegisterGranteeTypedData, signature: Hash): Promise<TransactionHandle<GranteeRegisterResult>>;
30479
30918
  /**
30480
30919
  * Retrieves all registered grantees from the DataPortabilityGrantees contract.
30481
30920
  *
@@ -30762,7 +31201,7 @@ declare class PermissionsController {
30762
31201
  * @param url - New URL for the server
30763
31202
  * @returns Promise resolving to transaction hash
30764
31203
  */
30765
- submitUpdateServer(serverId: bigint, url: string): Promise<Hash>;
31204
+ submitUpdateServer(serverId: bigint, url: string): Promise<TransactionHandle<ServerUpdateResult>>;
30766
31205
  /**
30767
31206
  * Get all permission IDs for a user
30768
31207
  *
@@ -30802,49 +31241,106 @@ declare class PermissionsController {
30802
31241
  * @throws {BlockchainError} When permission addition fails
30803
31242
  * @throws {NetworkError} When network communication fails
30804
31243
  */
30805
- submitAddPermission(params: ServerFilesAndPermissionParams): Promise<Hash>;
31244
+ submitAddPermission(params: ServerFilesAndPermissionParams): Promise<TransactionHandle<PermissionGrantResult>>;
30806
31245
  /**
30807
31246
  * Submits an already-signed add permission transaction to the blockchain.
30808
31247
  * This method supports both relayer-based gasless transactions and direct transactions.
30809
31248
  *
30810
31249
  * @param typedData - The EIP-712 typed data for AddPermission
30811
31250
  * @param signature - The user's signature
30812
- * @returns Promise resolving to the transaction hash
31251
+ * @returns Promise resolving to TransactionHandle with PermissionGrantResult event data
30813
31252
  * @throws {RelayerError} When gasless transaction submission fails
30814
31253
  * @throws {BlockchainError} When permission addition fails
30815
31254
  * @throws {NetworkError} When network communication fails
30816
31255
  */
30817
- submitSignedAddPermission(typedData: GenericTypedData, signature: Hash): Promise<Hash>;
31256
+ submitSignedAddPermission(typedData: GenericTypedData, signature: Hash): Promise<TransactionHandle<PermissionGrantResult>>;
30818
31257
  /**
30819
- * Submit server files and permissions with signature to the blockchain (supports gasless transactions)
31258
+ * Submits server files and permissions with signature to the blockchain, supporting schema validation and gasless transactions.
31259
+ *
31260
+ * @remarks
31261
+ * This method validates files against their specified schemas before submission.
31262
+ * Schema validation ensures data conforms to expected formats before on-chain registration.
31263
+ * Files with schemaId = 0 bypass validation. The method supports atomic batch operations
31264
+ * where all files and permissions are registered in a single transaction.
30820
31265
  *
30821
31266
  * @param params - Parameters for adding server files and permissions
30822
- * @returns Promise resolving to transaction hash
30823
- * @throws {RelayerError} When gasless transaction submission fails
31267
+ * @param params.granteeId - The ID of the permission grantee
31268
+ * @param params.grant - Grant URL containing permission parameters (typically IPFS)
31269
+ * @param params.fileUrls - Array of file URLs to register
31270
+ * @param params.schemaIds - Schema IDs for each file. Use 0 for files without schema validation.
31271
+ * Array length must match fileUrls length.
31272
+ * @param params.serverAddress - Server wallet address for decryption permissions
31273
+ * @param params.serverUrl - Server endpoint URL
31274
+ * @param params.serverPublicKey - Server's public key for encryption.
31275
+ * Obtain via `vana.server.getIdentity(userAddress).public_key`.
31276
+ * @param params.filePermissions - Nested array of permissions for each file
31277
+ * @returns TransactionHandle with immediate hash access and event parsing capability
31278
+ * @throws {Error} When schemaIds array length doesn't match fileUrls array length
31279
+ * @throws {SchemaValidationError} When file data doesn't match the specified schema.
31280
+ * Verify data structure matches schema definition from `vana.schemas.get(schemaId)`.
31281
+ * @throws {RelayerError} When gasless transaction submission fails.
31282
+ * Retry without relayer configuration to submit direct transaction.
30824
31283
  * @throws {SignatureError} When user rejects the signature request
30825
31284
  * @throws {BlockchainError} When server files and permissions addition fails
30826
- * @throws {NetworkError} When network communication fails
31285
+ * @throws {NetworkError} When network communication fails.
31286
+ * Check network connection or configure alternative gateways.
31287
+ *
31288
+ * @example
31289
+ * ```typescript
31290
+ * const result = await vana.permissions.submitAddServerFilesAndPermissions({
31291
+ * granteeId: BigInt(1),
31292
+ * grant: "ipfs://QmXxx...",
31293
+ * fileUrls: ["https://storage.example.com/data.json"],
31294
+ * schemaIds: [123], // LinkedIn profile schema ID
31295
+ * serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
31296
+ * serverUrl: "https://server.example.com",
31297
+ * serverPublicKey: serverInfo.public_key,
31298
+ * filePermissions: [[{
31299
+ * account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
31300
+ * key: encryptedKey
31301
+ * }]]
31302
+ * });
31303
+ * const events = await result.waitForEvents();
31304
+ * console.log(`Permission ID: ${events.permissionId}`);
31305
+ * ```
30827
31306
  */
30828
- submitAddServerFilesAndPermissions(params: ServerFilesAndPermissionParams): Promise<Hash>;
31307
+ submitAddServerFilesAndPermissions(params: ServerFilesAndPermissionParams): Promise<TransactionHandle<PermissionGrantResult>>;
30829
31308
  /**
30830
31309
  * Submits an already-signed add server files and permissions transaction to the blockchain.
30831
- * This method supports both relayer-based gasless transactions and direct transactions.
31310
+ *
31311
+ * @remarks
31312
+ * This method returns a TransactionHandle that provides immediate access to the transaction hash
31313
+ * while allowing lazy-loaded access to parsed event data. Use `waitForEvents()` to retrieve
31314
+ * the permission ID and other event details after transaction confirmation.
30832
31315
  *
30833
31316
  * @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
30834
31317
  * @param signature - The user's signature
30835
- * @returns Promise resolving to the transaction hash
31318
+ * @returns TransactionHandle with immediate hash access and optional event parsing
30836
31319
  * @throws {RelayerError} When gasless transaction submission fails
30837
31320
  * @throws {BlockchainError} When server files and permissions addition fails
30838
31321
  * @throws {NetworkError} When network communication fails
31322
+ *
31323
+ * @example
31324
+ * ```typescript
31325
+ * const tx = await vana.permissions.submitSignedAddServerFilesAndPermissions(
31326
+ * typedData,
31327
+ * signature
31328
+ * );
31329
+ * console.log(`Transaction submitted: ${tx.hash}`);
31330
+ *
31331
+ * // Wait for confirmation and get the permission ID
31332
+ * const { permissionId } = await tx.waitForEvents();
31333
+ * console.log(`Permission created with ID: ${permissionId}`);
31334
+ * ```
30839
31335
  */
30840
- submitSignedAddServerFilesAndPermissions(typedData: ServerFilesAndPermissionTypedData, signature: Hash): Promise<Hash>;
31336
+ submitSignedAddServerFilesAndPermissions(typedData: ServerFilesAndPermissionTypedData, signature: Hash): Promise<TransactionHandle<PermissionGrantResult>>;
30841
31337
  /**
30842
31338
  * Submit permission revocation with signature to the blockchain
30843
31339
  *
30844
31340
  * @param permissionId - Permission ID to revoke
30845
31341
  * @returns Promise resolving to transaction hash
30846
31342
  */
30847
- submitRevokePermission(permissionId: bigint): Promise<Hash>;
31343
+ submitRevokePermission(permissionId: bigint): Promise<TransactionHandle<PermissionRevokeResult>>;
30848
31344
  /**
30849
31345
  * Submits a signed add permission transaction directly to the blockchain.
30850
31346
  *
@@ -30874,10 +31370,10 @@ declare class PermissionsController {
30874
31370
  interface CreateSchemaParams {
30875
31371
  /** The name of the schema */
30876
31372
  name: string;
30877
- /** The type/category of the schema */
30878
- type: string;
31373
+ /** The dialect of the schema (e.g., 'json' or 'sqlite') */
31374
+ dialect: "json" | "sqlite";
30879
31375
  /** The schema definition object or JSON string */
30880
- definition: object | string;
31376
+ schema: object | string;
30881
31377
  }
30882
31378
  /**
30883
31379
  * Result of creating a new schema.
@@ -30922,8 +31418,8 @@ interface CreateSchemaResult {
30922
31418
  * // Create a new schema with automatic IPFS upload
30923
31419
  * const result = await vana.schemas.create({
30924
31420
  * name: "User Profile",
30925
- * type: "personal",
30926
- * definition: {
31421
+ * dialect: "json",
31422
+ * schema: {
30927
31423
  * type: "object",
30928
31424
  * properties: {
30929
31425
  * name: { type: "string" },
@@ -30958,7 +31454,7 @@ declare class SchemaController {
30958
31454
  * - Uploads the definition to IPFS to generate a permanent URL
30959
31455
  * - Registers the schema on the blockchain with the generated URL
30960
31456
  *
30961
- * @param params - Schema creation parameters including name, type, and definition
31457
+ * @param params - Schema creation parameters including name, dialect, and definition
30962
31458
  * @returns Promise resolving to creation results with schema ID and transaction hash
30963
31459
  * @throws {SchemaValidationError} When the schema definition is invalid
30964
31460
  * @throws {Error} When IPFS upload or blockchain registration fails
@@ -30967,8 +31463,8 @@ declare class SchemaController {
30967
31463
  * // Create a JSON schema for user profiles
30968
31464
  * const result = await vana.schemas.create({
30969
31465
  * name: "User Profile",
30970
- * type: "personal",
30971
- * definition: {
31466
+ * dialect: "json",
31467
+ * schema: {
30972
31468
  * type: "object",
30973
31469
  * properties: {
30974
31470
  * name: { type: "string" },
@@ -30983,42 +31479,66 @@ declare class SchemaController {
30983
31479
  */
30984
31480
  create(params: CreateSchemaParams): Promise<CreateSchemaResult>;
30985
31481
  /**
30986
- * Retrieves a schema by its ID.
31482
+ * Retrieves a complete schema by its ID with definition fetched and flattened.
30987
31483
  *
30988
31484
  * @param schemaId - The ID of the schema to retrieve
30989
- * @returns Promise resolving to the schema object
30990
- * @throws {Error} When the schema is not found or chain is unavailable
31485
+ * @param options - Optional parameters
31486
+ * @param options.subgraphUrl - Custom subgraph URL to use instead of default
31487
+ * @returns Promise resolving to the complete schema object with all fields populated
31488
+ * @throws {Error} When the schema is not found, definition cannot be fetched, or chain is unavailable
30991
31489
  * @example
30992
31490
  * ```typescript
30993
31491
  * const schema = await vana.schemas.get(1);
30994
- * console.log(`Schema: ${schema.name} (${schema.type})`);
31492
+ * console.log(`Schema: ${schema.name} (${schema.dialect})`);
31493
+ * console.log(`Version: ${schema.version}`);
31494
+ * console.log(`Description: ${schema.description}`);
31495
+ * console.log('Schema:', schema.schema);
31496
+ *
31497
+ * // Use directly with validator (schema has all required fields)
31498
+ * validator.validateDataAgainstSchema(data, schema);
30995
31499
  * ```
30996
31500
  */
30997
- get(schemaId: number): Promise<Schema>;
31501
+ get(schemaId: number, options?: {
31502
+ subgraphUrl?: string;
31503
+ }): Promise<CompleteSchema>;
30998
31504
  /**
30999
31505
  * Gets the total number of schemas registered on the network.
31000
31506
  *
31507
+ * @param options - Optional parameters
31508
+ * @param options.subgraphUrl - Custom subgraph URL to use instead of default
31001
31509
  * @returns Promise resolving to the total schema count
31002
31510
  * @throws {Error} When the count cannot be retrieved
31003
31511
  * @example
31004
31512
  * ```typescript
31005
31513
  * const count = await vana.schemas.count();
31006
31514
  * console.log(`Total schemas: ${count}`);
31515
+ *
31516
+ * // With custom subgraph
31517
+ * const count = await vana.schemas.count({
31518
+ * subgraphUrl: 'https://custom-subgraph.com/graphql'
31519
+ * });
31007
31520
  * ```
31008
31521
  */
31009
- count(): Promise<number>;
31522
+ count(options?: {
31523
+ subgraphUrl?: string;
31524
+ }): Promise<number>;
31010
31525
  /**
31011
31526
  * Lists all schemas with pagination.
31012
31527
  *
31013
31528
  * @param options - Optional parameters for listing schemas
31014
31529
  * @param options.limit - Maximum number of schemas to return
31015
31530
  * @param options.offset - Number of schemas to skip
31531
+ * @param options.subgraphUrl - Custom subgraph URL to use instead of default
31532
+ * @param options.includeDefinitions - Whether to fetch and include schema definitions (default: false for performance)
31016
31533
  * @returns Promise resolving to an array of schemas
31017
31534
  * @example
31018
31535
  * ```typescript
31019
- * // Get all schemas
31536
+ * // Get all schemas (without definitions for performance)
31020
31537
  * const schemas = await vana.schemas.list();
31021
31538
  *
31539
+ * // Get schemas with definitions
31540
+ * const schemas = await vana.schemas.list({ includeDefinitions: true });
31541
+ *
31022
31542
  * // Get schemas with pagination
31023
31543
  * const schemas = await vana.schemas.list({ limit: 10, offset: 0 });
31024
31544
  * ```
@@ -31026,6 +31546,8 @@ declare class SchemaController {
31026
31546
  list(options?: {
31027
31547
  limit?: number;
31028
31548
  offset?: number;
31549
+ subgraphUrl?: string;
31550
+ includeDefinitions?: boolean;
31029
31551
  }): Promise<Schema[]>;
31030
31552
  /**
31031
31553
  * Adds a schema using the legacy method (low-level API).
@@ -31035,6 +31557,36 @@ declare class SchemaController {
31035
31557
  * @returns Promise resolving to the add schema result
31036
31558
  */
31037
31559
  addSchema(params: AddSchemaParams): Promise<AddSchemaResult>;
31560
+ /**
31561
+ * Internal method: Query schema via subgraph
31562
+ *
31563
+ * @param params - Query parameters
31564
+ * @param params.schemaId - The ID of the schema to retrieve
31565
+ * @param params.subgraphUrl - The subgraph URL to query
31566
+ * @returns Promise resolving to the schema object
31567
+ * @private
31568
+ */
31569
+ private _getSchemaViaSubgraph;
31570
+ /**
31571
+ * Internal method: List schemas via subgraph
31572
+ *
31573
+ * @param params - Query parameters
31574
+ * @param params.limit - Maximum number of schemas to return
31575
+ * @param params.offset - Number of schemas to skip
31576
+ * @param params.subgraphUrl - The subgraph URL to query
31577
+ * @returns Promise resolving to an array of schemas
31578
+ * @private
31579
+ */
31580
+ private _listSchemasViaSubgraph;
31581
+ /**
31582
+ * Internal method: Count schemas via subgraph
31583
+ *
31584
+ * @param params - Query parameters
31585
+ * @param params.subgraphUrl - The subgraph URL to query
31586
+ * @returns Promise resolving to the total schema count
31587
+ * @private
31588
+ */
31589
+ private _countSchemasViaSubgraph;
31038
31590
  /**
31039
31591
  * Gets the user's wallet address.
31040
31592
  *
@@ -31042,6 +31594,13 @@ declare class SchemaController {
31042
31594
  * @returns Promise resolving to the user's address
31043
31595
  */
31044
31596
  private getUserAddress;
31597
+ /**
31598
+ * Fetches and attaches definitions to an array of schemas.
31599
+ *
31600
+ * @param schemas - Array of schemas to fetch definitions for
31601
+ * @private
31602
+ */
31603
+ private _fetchDefinitionsForSchemas;
31045
31604
  }
31046
31605
 
31047
31606
  /**
@@ -31116,34 +31675,30 @@ declare class SchemaValidator {
31116
31675
  */
31117
31676
  validateDataSchema(schema: unknown): asserts schema is DataSchema;
31118
31677
  /**
31119
- * Validates data against a JSON Schema from a data schema
31678
+ * Validates data against a JSON Schema from a schema
31120
31679
  *
31121
31680
  * @param data - The data to validate
31122
- * @param schema - The data schema containing the schema
31681
+ * @param schema - The schema containing the validation rules (DataSchema or Schema)
31123
31682
  * @throws SchemaValidationError if invalid
31124
31683
  * @example
31125
31684
  * ```typescript
31126
31685
  * const validator = new SchemaValidator();
31127
31686
  *
31128
- * const schema = {
31687
+ * // Works with Schema from schemas.get()
31688
+ * const schema = await vana.schemas.get(1);
31689
+ * validator.validateDataAgainstSchema(userData, schema);
31690
+ *
31691
+ * // Also works with DataSchema object
31692
+ * const dataSchema: DataSchema = {
31129
31693
  * name: "User Profile",
31130
31694
  * version: "1.0.0",
31131
31695
  * dialect: "json",
31132
- * schema: {
31133
- * type: "object",
31134
- * properties: {
31135
- * name: { type: "string" },
31136
- * age: { type: "number" }
31137
- * },
31138
- * required: ["name"]
31139
- * }
31696
+ * schema: { type: "object", properties: { name: { type: "string" } } }
31140
31697
  * };
31141
- *
31142
- * const userData = { name: "Alice", age: 30 };
31143
- * validator.validateDataAgainstSchema(userData, schema);
31698
+ * validator.validateDataAgainstSchema(userData, dataSchema);
31144
31699
  * ```
31145
31700
  */
31146
- validateDataAgainstSchema(data: unknown, schema: DataSchema): void;
31701
+ validateDataAgainstSchema(data: unknown, schema: DataSchema | Schema): void;
31147
31702
  /**
31148
31703
  * Validates a SQLite DDL string for basic syntax
31149
31704
  * Note: This is a basic validation, full SQL parsing would require a proper SQL parser
@@ -31187,7 +31742,7 @@ declare function validateDataSchema(schema: unknown): asserts schema is DataSche
31187
31742
  * @returns void - Function doesn't return a value
31188
31743
  * @throws SchemaValidationError if invalid
31189
31744
  */
31190
- declare function validateDataAgainstSchema(data: unknown, schema: DataSchema): void;
31745
+ declare function validateDataAgainstSchema(data: unknown, schema: DataSchema | Schema): void;
31191
31746
  /**
31192
31747
  * Convenience function to fetch and validate a schema from a URL
31193
31748
  *
@@ -33683,19 +34238,18 @@ declare class DataController {
33683
34238
  subgraphUrl?: string;
33684
34239
  }): Promise<UserFile$1[]>;
33685
34240
  /**
33686
- * Retrieves a list of permissions granted by a user using the new subgraph entities.
34241
+ * Retrieves a list of permissions granted by a user.
33687
34242
  *
33688
- * This method queries the Vana subgraph to find permissions directly granted by the user
33689
- * using the new Permission entity. It efficiently handles millions of permissions by:
33690
- * 1. Querying the subgraph for user's directly granted permissions
33691
- * 2. Returning complete permission information from subgraph
33692
- * 3. No need for additional contract calls as all data comes from subgraph
34243
+ * This method supports automatic fallback between subgraph and RPC modes:
34244
+ * - If subgraph URL is available, tries subgraph query first
34245
+ * - Falls back to direct contract queries via RPC if subgraph fails
34246
+ * - RPC mode uses gasAwareMulticall for efficient batch queries
33693
34247
  *
33694
34248
  * @param params - Object containing the user address and optional subgraph URL
33695
34249
  * @param params.user - The wallet address of the user to query permissions for
33696
34250
  * @param params.subgraphUrl - Optional subgraph URL to override the default
33697
34251
  * @returns Promise resolving to an array of permission objects
33698
- * @throws Error if subgraph is unavailable or returns invalid data
34252
+ * @throws Error if both subgraph and RPC queries fail
33699
34253
  */
33700
34254
  getUserPermissions(params: {
33701
34255
  user: Address;
@@ -33711,43 +34265,59 @@ declare class DataController {
33711
34265
  user: Address;
33712
34266
  }>>;
33713
34267
  /**
33714
- * Retrieves a list of trusted servers for a user using the new subgraph entities.
34268
+ * Internal method: Query user permissions via subgraph
34269
+ *
34270
+ * @param params - Query parameters object
34271
+ * @param params.user - The user address to query permissions for
34272
+ * @param params.subgraphUrl - The subgraph URL endpoint to query
34273
+ * @returns Promise resolving to an array of permission objects
34274
+ */
34275
+ private _getUserPermissionsViaSubgraph;
34276
+ /**
34277
+ * Internal method: Query user permissions via direct RPC
33715
34278
  *
33716
- * This method queries the Vana subgraph to find trusted servers directly associated with the user
33717
- * with support for both subgraph and direct RPC queries.
34279
+ * @param params - Query parameters object
34280
+ * @param params.user - The user address to query permissions for
34281
+ * @returns Promise resolving to an array of permission objects
34282
+ */
34283
+ private _getUserPermissionsViaRpc;
34284
+ /**
34285
+ * Retrieves a list of trusted servers for a user.
33718
34286
  *
33719
- * This method supports multiple query modes:
33720
- * - 'subgraph': Fast query via subgraph (requires subgraphUrl)
33721
- * - 'rpc': Direct contract queries (slower but no external dependencies)
33722
- * - 'auto': Try subgraph first, fallback to RPC if unavailable
34287
+ * This method supports automatic fallback between subgraph and RPC modes:
34288
+ * - If subgraph URL is available, tries subgraph query first for fast results
34289
+ * - Falls back to direct contract queries via RPC if subgraph fails
34290
+ * - RPC mode uses gasAwareMulticall for efficient batch queries
33723
34291
  *
33724
- * @param params - Query parameters including user address and mode selection
33725
- * @returns Promise resolving to trusted servers with metadata about the query
33726
- * @throws Error if query fails in both modes (when using 'auto')
34292
+ * @param params - Query parameters including user address and optional pagination
34293
+ * @param params.user - The wallet address of the user to query trusted servers for
34294
+ * @param params.subgraphUrl - Optional subgraph URL to override the default
34295
+ * @param params.limit - Maximum number of results to return (default: 50)
34296
+ * @param params.offset - Number of results to skip for pagination (default: 0)
34297
+ * @returns Promise resolving to an array of trusted server objects
34298
+ * @throws Error if both subgraph and RPC queries fail
33727
34299
  * @example
33728
34300
  * ```typescript
33729
- * // Use subgraph for fast queries
33730
- * const result = await vana.data.getUserTrustedServers({
33731
- * user: '0x...',
33732
- * mode: 'subgraph',
33733
- * subgraphUrl: 'https://...'
34301
+ * // Basic usage with automatic fallback
34302
+ * const servers = await vana.data.getUserTrustedServers({
34303
+ * user: '0x...'
33734
34304
  * });
33735
34305
  *
33736
- * // Use direct RPC (no external dependencies)
33737
- * const result = await vana.data.getUserTrustedServers({
34306
+ * // With pagination
34307
+ * const servers = await vana.data.getUserTrustedServers({
33738
34308
  * user: '0x...',
33739
- * mode: 'rpc',
33740
- * limit: 10
34309
+ * limit: 10,
34310
+ * offset: 20
33741
34311
  * });
33742
34312
  *
33743
- * // Auto-fallback mode
33744
- * const result = await vana.data.getUserTrustedServers({
34313
+ * // With custom subgraph URL
34314
+ * const servers = await vana.data.getUserTrustedServers({
33745
34315
  * user: '0x...',
33746
- * mode: 'auto' // tries subgraph first, falls back to RPC
34316
+ * subgraphUrl: 'https://custom-subgraph.com/graphql'
33747
34317
  * });
33748
34318
  * ```
33749
34319
  */
33750
- getUserTrustedServers(params: GetUserTrustedServersParams): Promise<GetUserTrustedServersResult>;
34320
+ getUserTrustedServers(params: GetUserTrustedServersParams): Promise<TrustedServer[]>;
33751
34321
  /**
33752
34322
  * Internal method: Query trusted servers via subgraph
33753
34323
  *
@@ -33815,12 +34385,25 @@ declare class DataController {
33815
34385
  /**
33816
34386
  * Registers a file URL directly on the blockchain with a schema ID.
33817
34387
  *
33818
- * @param url - The URL of the file to register
34388
+ * @remarks
34389
+ * This method registers an existing file URL on the DataRegistry contract
34390
+ * with a schema ID, without uploading any data. Useful when you have already
34391
+ * uploaded content to storage and just need to register it on-chain.
34392
+ *
34393
+ * @param url - The URL of the file to register (IPFS or HTTP/HTTPS)
33819
34394
  * @param schemaId - The schema ID to associate with the file
33820
34395
  * @returns Promise resolving to the file ID and transaction hash
33821
- *
33822
- * This method registers an existing file URL on the DataRegistry
33823
- * contract with a schema ID, without uploading any data.
34396
+ * @throws {Error} When chain ID is not available - "Chain ID not available"
34397
+ * @throws {Error} When wallet address is unavailable - "No addresses available"
34398
+ * @throws {Error} When transaction fails - "Failed to register file with schema"
34399
+ * @example
34400
+ * ```typescript
34401
+ * const { fileId, transactionHash } = await vana.data.registerFileWithSchema(
34402
+ * "ipfs://QmXxx...",
34403
+ * 1
34404
+ * );
34405
+ * console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
34406
+ * ```
33824
34407
  */
33825
34408
  registerFileWithSchema(url: string, schemaId: number): Promise<{
33826
34409
  fileId: number;
@@ -33880,35 +34463,112 @@ declare class DataController {
33880
34463
  /**
33881
34464
  * Adds a new refiner to the DataRefinerRegistry.
33882
34465
  *
33883
- * @param params - Refiner parameters including DLP ID, name, schema ID, and instruction URL
34466
+ * @remarks
34467
+ * Refiners are data processing templates that define how raw data should be
34468
+ * transformed into structured formats. Each refiner is associated with a DLP
34469
+ * (Data Liquidity Pool), has a specific schema for output, and includes
34470
+ * instructions for the refinement process.
34471
+ *
34472
+ * @param params - Refiner configuration parameters
34473
+ * @param params.dlpId - The Data Liquidity Pool ID this refiner belongs to
34474
+ * @param params.name - Human-readable name for the refiner
34475
+ * @param params.schemaId - Schema ID that defines the output format
34476
+ * @param params.refinementInstructionUrl - URL containing processing instructions
33884
34477
  * @returns Promise resolving to the new refiner ID and transaction hash
34478
+ * @throws {Error} When chain ID is not available - "Chain ID not available"
34479
+ * @throws {Error} When transaction fails - "Failed to add refiner: {error}"
34480
+ * @example
34481
+ * ```typescript
34482
+ * const result = await vana.data.addRefiner({
34483
+ * dlpId: 1,
34484
+ * name: "Social Media Sentiment Analyzer",
34485
+ * schemaId: 42,
34486
+ * refinementInstructionUrl: "ipfs://QmXxx..."
34487
+ * });
34488
+ * console.log(`Created refiner ${result.refinerId} in tx ${result.transactionHash}`);
34489
+ * ```
33885
34490
  */
33886
34491
  addRefiner(params: AddRefinerParams): Promise<AddRefinerResult>;
33887
34492
  /**
33888
34493
  * Retrieves a refiner by its ID.
33889
34494
  *
33890
- * @param refinerId - The refiner ID to retrieve
33891
- * @returns Promise resolving to the refiner information
34495
+ * @remarks
34496
+ * Queries the DataRefinerRegistry contract to get complete information about
34497
+ * a specific refiner including its DLP association, schema, and instructions.
34498
+ *
34499
+ * @param refinerId - The numeric refiner ID to retrieve
34500
+ * @returns Promise resolving to the refiner information object
34501
+ * @throws {Error} When chain ID is not available - "Chain ID not available"
34502
+ * @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
34503
+ * @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
34504
+ * @example
34505
+ * ```typescript
34506
+ * const refiner = await vana.data.getRefiner(1);
34507
+ * console.log({
34508
+ * name: refiner.name,
34509
+ * dlp: refiner.dlpId,
34510
+ * schema: refiner.schemaId,
34511
+ * instructions: refiner.refinementInstructionUrl
34512
+ * });
34513
+ * ```
33892
34514
  */
33893
34515
  getRefiner(refinerId: number): Promise<Refiner>;
33894
34516
  /**
33895
34517
  * Validates if a schema ID exists in the registry.
33896
34518
  *
33897
- * @param schemaId - The schema ID to validate
33898
- * @returns Promise resolving to boolean indicating if the schema ID is valid
34519
+ * @remarks
34520
+ * Checks the DataRefinerRegistry contract to determine if a given schema ID
34521
+ * has been registered and is available for use.
34522
+ *
34523
+ * @param schemaId - The numeric schema ID to validate
34524
+ * @returns Promise resolving to true if schema exists, false otherwise
34525
+ * @example
34526
+ * ```typescript
34527
+ * const isValid = await vana.data.isValidSchemaId(42);
34528
+ * if (isValid) {
34529
+ * console.log('Schema 42 is available for use');
34530
+ * } else {
34531
+ * console.log('Schema 42 does not exist');
34532
+ * }
34533
+ * ```
33899
34534
  */
33900
34535
  isValidSchemaId(schemaId: number): Promise<boolean>;
33901
34536
  /**
33902
34537
  * Gets the total number of refiners in the registry.
33903
34538
  *
34539
+ * @remarks
34540
+ * Queries the DataRefinerRegistry contract to get the total count of all
34541
+ * registered refiners across all DLPs.
34542
+ *
33904
34543
  * @returns Promise resolving to the total refiner count
34544
+ * @example
34545
+ * ```typescript
34546
+ * const count = await vana.data.getRefinersCount();
34547
+ * console.log(`Total refiners registered: ${count}`);
34548
+ * ```
33905
34549
  */
33906
34550
  getRefinersCount(): Promise<number>;
33907
34551
  /**
33908
34552
  * Updates the schema ID for an existing refiner.
33909
34553
  *
33910
- * @param params - Parameters including refiner ID and new schema ID
34554
+ * @remarks
34555
+ * Allows the owner of a refiner to update its associated schema ID.
34556
+ * This is useful when refiner output format needs to change.
34557
+ *
34558
+ * @param params - Update parameters
34559
+ * @param params.refinerId - The refiner ID to update
34560
+ * @param params.newSchemaId - The new schema ID to set
33911
34561
  * @returns Promise resolving to the transaction hash
34562
+ * @throws {Error} When chain ID is not available - "Chain ID not available"
34563
+ * @throws {Error} When transaction fails - "Failed to update schema ID: {error}"
34564
+ * @example
34565
+ * ```typescript
34566
+ * const result = await vana.data.updateSchemaId({
34567
+ * refinerId: 1,
34568
+ * newSchemaId: 55
34569
+ * });
34570
+ * console.log(`Schema updated in tx ${result.transactionHash}`);
34571
+ * ```
33912
34572
  */
33913
34573
  updateSchemaId(params: UpdateSchemaIdParams): Promise<UpdateSchemaIdResult>;
33914
34574
  /**
@@ -33967,7 +34627,7 @@ declare class DataController {
33967
34627
  * console.log(`Transaction: ${result.transactionHash}`);
33968
34628
  * ```
33969
34629
  */
33970
- addPermissionToFile(fileId: number, account: Address, publicKey: string): Promise<FilePermissionResult>;
34630
+ addPermissionToFile(fileId: number, account: Address, publicKey: string): Promise<TransactionHandle<FilePermissionResult>>;
33971
34631
  /**
33972
34632
  * Submits a file permission transaction and returns the transaction hash immediately.
33973
34633
  *
@@ -33984,7 +34644,7 @@ declare class DataController {
33984
34644
  * console.log(`Transaction submitted: ${txHash}`);
33985
34645
  * ```
33986
34646
  */
33987
- submitFilePermission(fileId: number, account: Address, publicKey: string): Promise<Hash>;
34647
+ submitFilePermission(fileId: number, account: Address, publicKey: string): Promise<TransactionHandle<FilePermissionResult>>;
33988
34648
  /**
33989
34649
  * Gets the encrypted key for a specific account's permission to access a file.
33990
34650
  *
@@ -34151,24 +34811,6 @@ declare class DataController {
34151
34811
  * ```
34152
34812
  */
34153
34813
  fetchAndValidateSchema(url: string): Promise<DataSchema>;
34154
- /**
34155
- * Retrieves a schema by ID and fetches its definition URL to get the full data schema.
34156
- *
34157
- * @param schemaId - The schema ID to retrieve and validate
34158
- * @returns The validated data schema
34159
- * @throws SchemaValidationError if schema is invalid
34160
- * @example
34161
- * ```typescript
34162
- * // Get schema from registry and validate its schema
34163
- * const schema = await vana.data.getValidatedSchema(123);
34164
- *
34165
- * // Use it to validate user data
34166
- * if (schema.dialect === "json") {
34167
- * vana.data.validateDataAgainstSchema(userData, schema);
34168
- * }
34169
- * ```
34170
- */
34171
- getValidatedSchema(schemaId: number): Promise<DataSchema>;
34172
34814
  }
34173
34815
 
34174
34816
  /**
@@ -34371,6 +35013,31 @@ interface Chains {
34371
35013
  }
34372
35014
  declare const chains: Chains;
34373
35015
 
35016
+ /**
35017
+ * Creates or retrieves a cached public client for blockchain read operations.
35018
+ *
35019
+ * @remarks
35020
+ * This function provides an optimized way to access blockchain data by maintaining
35021
+ * a cached client instance per chain. The client is used for reading contract state,
35022
+ * querying events, and other read-only blockchain operations. It automatically
35023
+ * handles HTTP transport configuration and chain switching.
35024
+ *
35025
+ * @param chainId - The chain ID to connect to (defaults to Moksha testnet)
35026
+ * @returns A public client configured for the specified chain with caching optimization
35027
+ * @throws {Error} When the specified chain ID is not supported by the SDK
35028
+ * @example
35029
+ * ```typescript
35030
+ * // Get client for default chain (Moksha testnet)
35031
+ * const client = createClient();
35032
+ *
35033
+ * // Get client for specific chain
35034
+ * const mainnetClient = createClient(14800);
35035
+ *
35036
+ * // Use client for blockchain reads
35037
+ * const blockNumber = await client.getBlockNumber();
35038
+ * ```
35039
+ * @category Blockchain
35040
+ */
34374
35041
  declare const createClient: (chainId?: keyof typeof chains) => PublicClient & {
34375
35042
  chain: Chain;
34376
35043
  };
@@ -35089,51 +35756,157 @@ declare class SerializationError extends VanaError {
35089
35756
  constructor(message: string);
35090
35757
  }
35091
35758
  /**
35092
- * Error thrown when a signature operation fails.
35759
+ * Thrown when a signature operation fails or cannot be completed.
35093
35760
  *
35094
35761
  * @remarks
35095
- * Recovery strategies: Check wallet connection and account unlock status,
35096
- * retry operation with explicit user interaction, or for gasless operations
35097
- * consider switching to direct transactions.
35762
+ * This error occurs when wallet signature operations fail due to disconnection,
35763
+ * locked accounts, or other wallet-related issues. It preserves the original
35764
+ * error for debugging while providing consistent error handling across the SDK.
35765
+ *
35766
+ * Recovery strategies:
35767
+ * - Check wallet connection and account unlock status
35768
+ * - Retry operation with explicit user interaction
35769
+ * - For gasless operations, consider switching to direct transactions
35770
+ *
35771
+ * @example
35772
+ * ```typescript
35773
+ * try {
35774
+ * await vana.permissions.grant({ grantee: '0x...' });
35775
+ * } catch (error) {
35776
+ * if (error instanceof SignatureError) {
35777
+ * // Prompt user to unlock wallet
35778
+ * await promptWalletUnlock();
35779
+ * // Retry operation
35780
+ * }
35781
+ * }
35782
+ * ```
35783
+ * @category Error Handling
35098
35784
  */
35099
35785
  declare class SignatureError extends VanaError {
35100
35786
  readonly originalError?: Error | undefined;
35101
35787
  constructor(message: string, originalError?: Error | undefined);
35102
35788
  }
35103
35789
  /**
35104
- * Error thrown when a network operation fails.
35790
+ * Thrown when network communication fails during API calls or blockchain interactions.
35105
35791
  *
35106
35792
  * @remarks
35107
- * Recovery strategies: Check network connectivity, retry with exponential backoff,
35108
- * verify API endpoints are accessible, or switch to alternative network providers.
35793
+ * This error encompasses network connectivity issues, API unavailability,
35794
+ * timeout errors, and CORS restrictions. It's commonly encountered during
35795
+ * IPFS operations, subgraph queries, or RPC calls.
35796
+ *
35797
+ * Recovery strategies:
35798
+ * - Check network connectivity
35799
+ * - Retry with exponential backoff
35800
+ * - Verify API endpoints are accessible
35801
+ * - Switch to alternative network providers or gateways
35802
+ *
35803
+ * @example
35804
+ * ```typescript
35805
+ * try {
35806
+ * const files = await vana.data.getUserFiles({ owner: '0x...' });
35807
+ * } catch (error) {
35808
+ * if (error instanceof NetworkError) {
35809
+ * // Implement retry with exponential backoff
35810
+ * await retryWithBackoff(() => vana.data.getUserFiles({ owner: '0x...' }));
35811
+ * }
35812
+ * }
35813
+ * ```
35814
+ * @category Error Handling
35109
35815
  */
35110
35816
  declare class NetworkError extends VanaError {
35111
35817
  readonly originalError?: Error | undefined;
35112
35818
  constructor(message: string, originalError?: Error | undefined);
35113
35819
  }
35114
35820
  /**
35115
- * Error thrown when the nonce retrieval fails.
35821
+ * Thrown when transaction nonce retrieval fails during gasless operations.
35116
35822
  *
35117
35823
  * @remarks
35118
- * Recovery strategies: Retry nonce retrieval after brief delay, check wallet connection
35119
- * and account status, or use manual nonce specification if supported by the operation.
35824
+ * This error occurs when the SDK cannot retrieve the user's current nonce from
35825
+ * smart contracts, preventing gasless transaction submission. Nonces are critical
35826
+ * for preventing replay attacks in signed transactions.
35827
+ *
35828
+ * Recovery strategies:
35829
+ * - Retry nonce retrieval after brief delay
35830
+ * - Check wallet connection and account status
35831
+ * - Use manual nonce specification if supported by the operation
35832
+ * - Switch to direct transactions as fallback
35833
+ *
35834
+ * @example
35835
+ * ```typescript
35836
+ * try {
35837
+ * await vana.permissions.grant({ grantee: '0x...' });
35838
+ * } catch (error) {
35839
+ * if (error instanceof NonceError) {
35840
+ * // Wait and retry
35841
+ * await delay(1000);
35842
+ * await vana.permissions.grant({ grantee: '0x...' });
35843
+ * }
35844
+ * }
35845
+ * ```
35846
+ * @category Error Handling
35120
35847
  */
35121
35848
  declare class NonceError extends VanaError {
35122
35849
  constructor(message: string);
35123
35850
  }
35124
35851
  /**
35125
- * Error thrown when a personal server operation fails.
35852
+ * Thrown when personal server operations fail or cannot be completed.
35126
35853
  *
35127
35854
  * @remarks
35128
- * Recovery strategies: Verify server URL accessibility, check server trust status via
35129
- * `vana.permissions.getUserTrustedServers()`, or retry after server becomes available.
35855
+ * This error occurs during interactions with personal servers for computation
35856
+ * requests, identity retrieval, or operation status checks. Common causes include
35857
+ * server unavailability, untrusted server status, or invalid permission grants.
35858
+ *
35859
+ * Recovery strategies:
35860
+ * - Verify server URL accessibility
35861
+ * - Check server trust status via `vana.permissions.getTrustedServers()`
35862
+ * - Ensure valid permissions exist for the operation
35863
+ * - Retry after server becomes available
35864
+ *
35865
+ * @example
35866
+ * ```typescript
35867
+ * try {
35868
+ * const result = await vana.server.createOperation({ permissionId: 123 });
35869
+ * } catch (error) {
35870
+ * if (error instanceof PersonalServerError) {
35871
+ * // Check if server is trusted
35872
+ * const trustedServers = await vana.permissions.getTrustedServers();
35873
+ * if (!trustedServers.includes(serverId)) {
35874
+ * await vana.permissions.trustServer({ serverId });
35875
+ * }
35876
+ * }
35877
+ * }
35878
+ * ```
35879
+ * @category Error Handling
35130
35880
  */
35131
35881
  declare class PersonalServerError extends VanaError {
35132
35882
  readonly originalError?: Error | undefined;
35133
35883
  constructor(message: string, originalError?: Error | undefined);
35134
35884
  }
35135
35885
  /**
35136
- * Error thrown when trying to register a server with a URL that doesn't match the existing registration.
35886
+ * Thrown when attempting to register a server with a URL different from its existing registration.
35887
+ *
35888
+ * @remarks
35889
+ * This error occurs when trying to add or trust a server that's already registered
35890
+ * on-chain with a different URL. Server URLs are immutable once registered to
35891
+ * maintain consistency and security. Applications should use the existing URL
35892
+ * or register a new server with a different ID.
35893
+ *
35894
+ * @example
35895
+ * ```typescript
35896
+ * try {
35897
+ * await vana.permissions.addAndTrustServer({
35898
+ * serverId: 1,
35899
+ * serverUrl: 'https://new-url.com',
35900
+ * publicKey: '0x...'
35901
+ * });
35902
+ * } catch (error) {
35903
+ * if (error instanceof ServerUrlMismatchError) {
35904
+ * console.log(`Server already registered with: ${error.existingUrl}`);
35905
+ * // Use existing URL or register new server
35906
+ * }
35907
+ * }
35908
+ * ```
35909
+ * @category Error Handling
35137
35910
  */
35138
35911
  declare class ServerUrlMismatchError extends VanaError {
35139
35912
  constructor(existingUrl: string, providedUrl: string, serverId: string);
@@ -35142,7 +35915,25 @@ declare class ServerUrlMismatchError extends VanaError {
35142
35915
  readonly serverId: string;
35143
35916
  }
35144
35917
  /**
35145
- * Error thrown when a permission operation fails.
35918
+ * Thrown when permission grant, revoke, or validation operations fail.
35919
+ *
35920
+ * @remarks
35921
+ * This error occurs during permission management operations including grants,
35922
+ * revocations, and permission validation checks. Common causes include invalid
35923
+ * grantee addresses, expired permissions, or insufficient privileges.
35924
+ *
35925
+ * @example
35926
+ * ```typescript
35927
+ * try {
35928
+ * await vana.permissions.revoke({ permissionId: 999999 });
35929
+ * } catch (error) {
35930
+ * if (error instanceof PermissionError) {
35931
+ * console.error('Permission operation failed:', error.message);
35932
+ * // Permission may not exist or user may not be owner
35933
+ * }
35934
+ * }
35935
+ * ```
35936
+ * @category Error Handling
35146
35937
  */
35147
35938
  declare class PermissionError extends VanaError {
35148
35939
  readonly originalError?: Error | undefined;
@@ -36108,12 +36899,12 @@ declare class SignatureCache {
36108
36899
  * Generate a deterministic hash of a message object for cache key generation
36109
36900
  *
36110
36901
  * @remarks
36111
- * Creates a consistent hash from complex objects including EIP-712 typed data.
36112
- * Handles BigInt serialization and produces a 32-character hash that balances
36113
- * uniqueness with key length constraints.
36902
+ * Creates a cryptographically secure hash from complex objects including EIP-712 typed data.
36903
+ * Uses SHA-256 for collision resistance and deterministic key generation.
36904
+ * Handles BigInt serialization and sorts object keys for consistency.
36114
36905
  *
36115
36906
  * @param message - The message object to hash (typically EIP-712 typed data)
36116
- * @returns A 32-character hash string suitable for cache keys
36907
+ * @returns A hex string hash (SHA-256) suitable for cache keys
36117
36908
  * @example
36118
36909
  * ```typescript
36119
36910
  * const typedData = {
@@ -36122,19 +36913,19 @@ declare class SignatureCache {
36122
36913
  * };
36123
36914
  *
36124
36915
  * const hash = SignatureCache.hashMessage(typedData);
36125
- * // Returns something like: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
36916
+ * // Returns SHA-256 hash like: "a1b2c3d4e5f6..."
36126
36917
  * ```
36127
36918
  */
36128
36919
  static hashMessage(message: object): string;
36129
36920
  /**
36130
- * Custom JSON replacer that converts BigInt values to strings for serialization
36131
- * This ensures deterministic cache key generation for EIP-712 typed data
36921
+ * Deterministic JSON replacer that handles BigInt values and sorts object keys
36922
+ * This ensures consistent cache key generation for EIP-712 typed data
36132
36923
  *
36133
36924
  * @param _key - The object key being serialized (unused)
36134
36925
  * @param value - The value to serialize
36135
- * @returns The serialized value
36926
+ * @returns The serialized value with sorted keys for objects
36136
36927
  */
36137
- private static bigIntReplacer;
36928
+ private static deterministicReplacer;
36138
36929
  }
36139
36930
  /**
36140
36931
  * Wrapper function to cache signature operations
@@ -36150,21 +36941,53 @@ declare function withSignatureCache(cache: VanaCacheAdapter, walletAddress: stri
36150
36941
 
36151
36942
  declare const CONTRACT_ADDRESSES: Record<number, Record<string, string>>;
36152
36943
  /**
36153
- * Retrieves the deployed contract address for a specific contract on a given chain.
36944
+ * Retrieves the deployed contract address for a specific Vana protocol contract on a given chain.
36154
36945
  *
36155
- * @param chainId - The chain ID to look up the contract on
36156
- * @param contract - The contract name to get the address for
36157
- * @returns The contract address as a hex string
36158
- * @throws {Error} When contract address not found for the specified contract and chain
36946
+ * @remarks
36947
+ * This function provides type-safe access to contract addresses across all supported Vana networks.
36948
+ * It automatically searches both current and legacy contract registries to ensure backwards
36949
+ * compatibility while providing clear error messages for unsupported combinations.
36950
+ *
36951
+ * The function validates that both the chain ID and contract name are supported before
36952
+ * attempting address lookup, helping developers identify deployment or configuration issues
36953
+ * early in the development process.
36954
+ *
36955
+ * **Supported Chains:**
36956
+ * - 14800: Vana Mainnet
36957
+ * - 1480: Moksha Testnet
36958
+ *
36959
+ * **Contract Categories:**
36960
+ * - Data Management: DataRegistry, DataRefinerRegistry
36961
+ * - Permissions: DataPortabilityPermissions, DataPortabilityServers, DataPortabilityGrantees
36962
+ * - Computing: TeePoolPhala, TeePoolDedicatedGpu, etc.
36963
+ * - Token & Governance: DATImplementation, VanaPoolStaking, etc.
36964
+ *
36965
+ * @param chainId - The chain ID to look up the contract on (14800 for mainnet, 1480 for testnet)
36966
+ * @param contract - The contract name to get the address for (use TypeScript autocomplete for available options)
36967
+ * @returns The contract address as a checksummed hex string (0x...)
36968
+ * @throws {Error} When contract address not found for the specified contract and chain combination.
36969
+ * This typically indicates the contract is not deployed on the requested network.
36159
36970
  * @example
36160
36971
  * ```typescript
36972
+ * // Get core protocol contract addresses
36973
+ * const dataRegistry = getContractAddress(14800, 'DataRegistry');
36974
+ * const permissions = getContractAddress(14800, 'DataPortabilityPermissions');
36975
+ * const trustedServers = getContractAddress(14800, 'DataPortabilityServers');
36976
+ *
36977
+ * // Handle unsupported combinations gracefully
36161
36978
  * try {
36162
- * const dataRegistryAddress = getContractAddress(1480, 'DataRegistry');
36163
- * console.log('DataRegistry address:', dataRegistryAddress);
36979
+ * const address = getContractAddress(1480, 'DataRegistry');
36980
+ * console.log('DataRegistry testnet address:', address);
36164
36981
  * } catch (error) {
36165
- * console.error('Contract not deployed on this chain:', error.message);
36982
+ * console.error('Contract not available on testnet:', error.message);
36983
+ * // Fallback to mainnet or show user-friendly error
36166
36984
  * }
36985
+ *
36986
+ * // TypeScript provides autocomplete for contract names
36987
+ * const poolAddress = getContractAddress(14800, 'TeePoolPhala'); // ✅ Valid
36988
+ * // const invalid = getContractAddress(14800, 'InvalidContract'); // ❌ TypeScript error
36167
36989
  * ```
36990
+ * @category Configuration
36168
36991
  */
36169
36992
  declare const getContractAddress: (chainId: keyof typeof CONTRACT_ADDRESSES, contract: VanaContract) => `0x${string}`;
36170
36993
 
@@ -36334,6 +37157,8 @@ declare class CircuitBreaker {
36334
37157
  reset(): void;
36335
37158
  }
36336
37159
 
37160
+ /** Union type of all possible transaction results from relayer operations */
37161
+ type RelayerTransactionResult = PermissionGrantResult | PermissionRevokeResult | ServerTrustResult | ServerUntrustResult | GranteeRegisterResult | FileAddedResult;
36337
37162
  /**
36338
37163
  * Payload structure for relayer requests.
36339
37164
  * Contains the EIP-712 typed data, signature, and optional expected user address for security verification.
@@ -36355,7 +37180,7 @@ interface RelayerRequestPayload {
36355
37180
  * 1. Verifies the signature against the typed data
36356
37181
  * 2. Optionally checks the signer matches the expected user address
36357
37182
  * 3. Routes to the appropriate SDK method based on primaryType
36358
- * 4. Returns the resulting transaction hash
37183
+ * 4. Returns the transaction handle with hash and event parsing capability
36359
37184
  *
36360
37185
  * Supported transaction types:
36361
37186
  * - Permission: Permission grants
@@ -36368,7 +37193,7 @@ interface RelayerRequestPayload {
36368
37193
  *
36369
37194
  * @param sdk - Initialized Vana SDK instance
36370
37195
  * @param payload - Request payload containing typed data, signature, and optional security check
36371
- * @returns Promise resolving to the transaction hash
37196
+ * @returns Promise resolving to TransactionHandle with hash and event parsing capability
36372
37197
  * @throws {SignatureError} When signature verification fails or signer mismatch occurs
36373
37198
  * @throws {Error} When primaryType is unsupported or SDK operations fail
36374
37199
  * @category Server
@@ -36382,15 +37207,24 @@ interface RelayerRequestPayload {
36382
37207
  * const body = await request.json();
36383
37208
  * const vana = await createRelayerVana();
36384
37209
  *
36385
- * const txHash = await handleRelayerRequest(vana, {
37210
+ * const tx = await handleRelayerRequest(vana, {
36386
37211
  * typedData: body.typedData,
36387
37212
  * signature: body.signature,
36388
37213
  * expectedUserAddress: body.expectedUserAddress
36389
37214
  * });
36390
37215
  *
37216
+ * // Option 1: Return just the hash immediately
37217
+ * return NextResponse.json({
37218
+ * success: true,
37219
+ * transactionHash: tx.hash
37220
+ * });
37221
+ *
37222
+ * // Option 2: Wait for transaction confirmation and return event data
37223
+ * const eventData = await tx.waitForEvents();
36391
37224
  * return NextResponse.json({
36392
37225
  * success: true,
36393
- * transactionHash: txHash
37226
+ * transactionHash: tx.hash,
37227
+ * ...eventData // Include parsed event data like permissionId, fileId, etc.
36394
37228
  * });
36395
37229
  * } catch (error) {
36396
37230
  * return NextResponse.json({
@@ -36401,13 +37235,14 @@ interface RelayerRequestPayload {
36401
37235
  * }
36402
37236
  * ```
36403
37237
  */
36404
- declare function handleRelayerRequest(sdk: VanaInstance, payload: RelayerRequestPayload): Promise<Hash>;
37238
+ declare function handleRelayerRequest(sdk: VanaInstance, payload: RelayerRequestPayload): Promise<TransactionHandle<RelayerTransactionResult>>;
36405
37239
 
36406
37240
  /**
36407
37241
  * Node.js implementation of the Vana Platform Adapter
36408
37242
  *
36409
- * This implementation uses Node.js-specific libraries and configurations
36410
- * to provide crypto, PGP, and HTTP functionality.
37243
+ * WARNING: Dependencies that access globals during init
37244
+ * MUST be dynamically imported to support Turbopack.
37245
+ * See: https://github.com/vercel/next.js/issues/82632
36411
37246
  */
36412
37247
 
36413
37248
  /**
@@ -36423,22 +37258,73 @@ declare class NodePlatformAdapter implements VanaPlatformAdapter {
36423
37258
  }
36424
37259
 
36425
37260
  /**
36426
- * Browser implementation of the Vana Platform Adapter
37261
+ * Browser implementation of the Vana Platform Adapter using Uint8Array
36427
37262
  *
36428
- * This implementation uses browser-compatible libraries and configurations
36429
- * to provide crypto, PGP, and HTTP functionality without Node.js dependencies.
37263
+ * This implementation uses browser-compatible libraries and native APIs
37264
+ * without requiring Buffer or other Node.js polyfills.
36430
37265
  */
36431
37266
 
36432
37267
  /**
36433
- * Complete browser platform adapter implementation
37268
+ * Browser implementation of crypto operations using Uint8Array
37269
+ */
37270
+ declare class BrowserCryptoAdapter implements VanaCryptoAdapter {
37271
+ private eciesProvider;
37272
+ private walletKeyEncryptionService;
37273
+ encryptWithPublicKey(data: string, publicKeyHex: string): Promise<string>;
37274
+ decryptWithPrivateKey(encryptedData: string, privateKeyHex: string): Promise<string>;
37275
+ encryptWithWalletPublicKey(data: string, publicKey: string): Promise<string>;
37276
+ decryptWithWalletPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
37277
+ generateKeyPair(): Promise<{
37278
+ privateKey: string;
37279
+ publicKey: string;
37280
+ }>;
37281
+ encryptWithPassword(data: Uint8Array, password: string): Promise<Uint8Array>;
37282
+ decryptWithPassword(encryptedData: Uint8Array, password: string): Promise<Uint8Array>;
37283
+ }
37284
+ /**
37285
+ * Browser implementation of PGP operations
37286
+ */
37287
+ declare class BrowserPGPAdapter implements VanaPGPAdapter {
37288
+ encrypt(data: string, publicKeyArmored: string): Promise<string>;
37289
+ decrypt(encryptedData: string, privateKeyArmored: string): Promise<string>;
37290
+ generateKeyPair(options?: {
37291
+ name?: string;
37292
+ email?: string;
37293
+ passphrase?: string;
37294
+ }): Promise<{
37295
+ publicKey: string;
37296
+ privateKey: string;
37297
+ }>;
37298
+ }
37299
+ /**
37300
+ * Browser implementation of HTTP operations using Fetch API
37301
+ */
37302
+ declare class BrowserHttpAdapter implements VanaHttpAdapter {
37303
+ fetch(url: string, options?: RequestInit): Promise<Response>;
37304
+ }
37305
+ /**
37306
+ * Browser implementation of caching using sessionStorage for security
37307
+ * SessionStorage is cleared when the tab closes, making it more secure for signature caching
37308
+ */
37309
+ declare class BrowserCacheAdapter implements VanaCacheAdapter {
37310
+ private readonly prefix;
37311
+ get(key: string): string | null;
37312
+ set(key: string, value: string): void;
37313
+ delete(key: string): void;
37314
+ clear(): void;
37315
+ }
37316
+ /**
37317
+ * Browser implementation of the Vana Platform Adapter
37318
+ *
37319
+ * This adapter provides all platform-specific functionality for browser environments
37320
+ * without requiring any Node.js polyfills.
36434
37321
  */
36435
37322
  declare class BrowserPlatformAdapter implements VanaPlatformAdapter {
36436
- crypto: VanaCryptoAdapter;
36437
- pgp: VanaPGPAdapter;
36438
- http: VanaHttpAdapter;
36439
- cache: VanaCacheAdapter;
36440
- platform: "browser";
36441
- constructor();
37323
+ readonly crypto: BrowserCryptoAdapter;
37324
+ readonly pgp: BrowserPGPAdapter;
37325
+ readonly http: BrowserHttpAdapter;
37326
+ readonly cache: BrowserCacheAdapter;
37327
+ readonly platform: "browser";
36442
37328
  }
36443
37329
 
36444
37330
  /**
@@ -36815,4 +37701,4 @@ declare function Vana(config: VanaConfig): VanaNodeImpl;
36815
37701
  */
36816
37702
  type VanaInstance = VanaNodeImpl;
36817
37703
 
36818
- export { type $defs, type APIResponse, type AddAndTrustServerInput, type AddAndTrustServerParams, type AddAndTrustServerTypedData, type AddRefinerParams, type AddRefinerResult, type AddSchemaParams, type AddSchemaResult, type AllKeys, ApiClient, type ApiClientConfig, type ApiResponse, AsyncQueue, type AsyncResult, type AuthenticationErrorResponse, type Awaited, type BaseConfig, type BaseConfigWithStorage, BaseController, type BatchServerInfoResult, type BatchUploadParams, type BatchUploadResult, type BlockRange, BlockchainError, type BlockchainErrorResponse, type Brand, BrowserPlatformAdapter, type Cache, type CacheConfig, CallbackStorage, type ChainConfig, type ChainConfigWithStorage, type CheckPermissionParams, CircuitBreaker, type ComputeErrorResponse, type ConditionalOptional, type ConfigValidationOptions, type ConfigValidationResult, type ContractAddresses, type ContractCall, type ContractDeployment, ContractFactory, type ContractInfo, type ContractMethodParams, type ContractMethodReturnType, ContractNotFoundError, type Controller, type ControllerContext, type CreateOperationParams, type CreateOperationRequest, type CreateOperationResponse, type CreateSchemaParams, type CreateSchemaResult, DEFAULT_ENCRYPTION_SEED, DEFAULT_IPFS_GATEWAY, DataController, type DataSchema, type DecryptionErrorResponse, type DeepPartial, type DeepReadonly, type DeleteFileParams, type DeleteFileResult, type DownloadFileParams, type DownloadFileResult, type EncryptedUploadParams, type EncryptionInfo, type ErrorResponse, EventEmitter, type EventFilter, type EventLog, type Factory, type FileAccessErrorResponse, type FileAccessPermissions, type FileMetadata, type FilePermissionParams, type FileSharingConfig, type GasEstimate, type GenericRequest, type GenericResponse, type GenericTypedData, type GetFileParams, type GetOperationResponse, type GetUserFilesParams, type GetUserPermissionsOptions, type GetUserTrustedServersParams, type GetUserTrustedServersResult, GoogleDriveStorage, GrantExpiredError, type GrantFile, type GrantPermissionParams, GrantSchemaError, GrantValidationError, type GrantValidationErrorResponse, type GrantValidationOptions, type GrantValidationResult, type GrantedPermission, type Grantee, type GranteeInfo, GranteeMismatchError, type GranteeQueryOptions, type HttpMethod, IPFS_GATEWAYS, type IdentityResponseModel, type InitPersonalServerParams, type InternalServerErrorResponse, InvalidConfigurationError, IpfsStorage, type LegacyPermissionParams, type MaybeArray, type MaybePromise, MemoryCache, type Middleware, MiddlewarePipeline, NetworkError, type NetworkInfo, NodePlatformAdapter, type Nominal, type NonNullable, NonceError, type NotFoundErrorResponse, type Observable, type Observer, type OmitByType, type OnChainPermissionGrant, type OperationErrorResponse, OperationNotAllowedError, type OptionalKeys, type PaginatedGrantees, type PaginatedTrustedServers, type PaginationParams, type PaginationResult, type PartialExcept, type Permission, type PermissionAnalytics, type PermissionCheckResult, PermissionError, type PermissionEvent, type PermissionGrantDomain, type PermissionGrantMessage, type PermissionGrantTypedData, type PermissionInfo, type PermissionInputMessage, type PermissionOperation, type PermissionQueryResult, type PermissionStatus, PermissionsController, PersonalServerError, type PersonalServerIdentity, type PersonalServerModel, type PickByType, type PinataListResponse, type PinataPin, PinataStorage, type PinataUploadResponse, type Plugin, type PostRequestParams, type PromiseResult, ProtocolController, type QueryPermissionsParams, type RateLimitInfo, RateLimiter, type RateLimiterConfig, type Refiner, type RegisterGranteeInput, type RegisterGranteeParams, type RegisterGranteeTypedData, type RelayerCallbacks, type RelayerConfig, RelayerError, type RelayerErrorResponse, type RelayerMetrics, type RelayerQueueInfo, type RelayerRequestOptions, type RelayerRequestPayload, type RelayerStatus, type RelayerStorageResponse, type RelayerStoreParams, type RelayerSubmitParams, type RelayerTransactionResponse, type RelayerTransactionStatus, type RelayerWebhookConfig, type RelayerWebhookPayload, type ReplicateAPIResponse, type ReplicateStatus, type Repository, type RequestOptions, type RequireKeys, type RequiredExcept, type RetryConfig, RetryUtility, type RevokePermissionInput, type RevokePermissionParams, type RuntimeConfig, type Schema, SchemaController, SchemaValidationError, SchemaValidator, SerializationError, type Server, type components as ServerComponents, ServerController, type $defs as ServerDefs, type ServerFilesAndPermissionParams, type ServerFilesAndPermissionTypedData, type ServerInfo, type operations as ServerOperations, type paths as ServerPaths, type ServerTrustStatus, ServerUrlMismatchError, type webhooks as ServerWebhooks, type Service, SignatureCache, SignatureError, type SimplifiedPermissionMessage, type StateMachine, type StatusInfo, type StorageCallbacks, type StorageConfig, type StorageDownloadOptions, StorageError, type StorageFile, type StorageListOptions, type StorageListResult, StorageManager, type StorageProvider, type StorageProviderConfig, type StorageRequiredMarker, type StorageUploadResult, type TimeRange, type TransactionOptions, type TransactionReceipt, type Transformer, type TrustServerInput, type TrustServerParams, type TrustServerTypedData, type TrustedServer, type TrustedServerInfo, type TrustedServerQueryMode, type TrustedServerQueryOptions, type UnencryptedUploadParams, type UntrustServerInput, type UntrustServerParams, type UntrustServerTypedData, type UpdateSchemaIdParams, type UpdateSchemaIdResult, type UploadEncryptedFileResult, type UploadFileParams, type UploadFileResult, type UploadParams, type UploadProgress, type UploadResult, type UserFile, UserRejectedRequestError, type ValidationErrorResponse, type ValidationResult, type Validator, Vana, type VanaChain, type VanaChainConfig, type VanaChainId, type VanaConfig, type VanaConfigWithStorage, type VanaContract, type VanaContract as VanaContractAbi, type VanaContractInstance, type VanaContractName, VanaCore, VanaCoreFactory, VanaError, type VanaInstance, VanaNodeImpl, type VanaPlatformAdapter, type WalletConfig, type WalletConfigWithStorage, __contractCache, chains, checkGrantAccess, clearContractCache, type components, convertIpfsUrl, convertIpfsUrlWithFallbacks, createAndStoreGrant, createBrowserPlatformAdapter, createGrantFile, createNodePlatformAdapter, createPlatformAdapter, createPlatformAdapterFor, createPlatformAdapterSafe, createValidatedGrant, decryptBlobWithSignedKey, decryptWithPrivateKey, decryptWithWalletPrivateKey, Vana as default, detectPlatform, encryptBlobWithSignedKey, encryptFileKey, encryptWithWalletPublicKey, extractIpfsHash, fetchAndValidateSchema, fetchWithFallbacks, formatEth, formatNumber, formatToken, generateEncryptionKey, generateEncryptionKeyPair, generatePGPKeyPair, getAbi, getAllChains, getChainConfig, getContractAddress, getContractController, getContractInfo, getEncryptionParameters, getGatewayUrls, getGrantFileHash, getGrantTimeRemaining, getPlatformCapabilities, handleRelayerRequest, hasStorageConfig, isAPIResponse, isChainConfig, isGrantExpired, isIpfsUrl, isPlatformSupported, isReplicateAPIResponse, isVanaChain, isVanaChainId, isWalletConfig, moksha, mokshaTestnet, type operations, parseReplicateOutput, type paths, retrieveAndValidateGrant, retrieveGrantFile, safeParseJSON, schemaValidator, shortenAddress, storeGrantFile, summarizeGrant, validateDataAgainstSchema, validateDataSchema, validateGrant, validateGrantExpiry, validateGrantFile, validateGranteeAccess, validateOperationAccess, vanaMainnet, type webhooks, withSignatureCache };
37704
+ export { type $defs, type APIResponse, type AddAndTrustServerInput, type AddAndTrustServerParams, type AddAndTrustServerTypedData, type AddRefinerParams, type AddRefinerResult, type AddSchemaParams, type AddSchemaResult, type AllKeys, ApiClient, type ApiClientConfig, type ApiResponse, AsyncQueue, type AsyncResult, type AuthenticationErrorResponse, type Awaited, type BaseConfig, type BaseConfigWithStorage, BaseController, type BatchServerInfoResult, type BatchUploadParams, type BatchUploadResult, type BlockRange, BlockchainError, type BlockchainErrorResponse, type Brand, BrowserPlatformAdapter, type Cache, type CacheConfig, CallbackStorage, type ChainConfig, type ChainConfigWithStorage, type CheckPermissionParams, CircuitBreaker, type CompleteSchema, type ComputeErrorResponse, type ConditionalOptional, type ConfigValidationOptions, type ConfigValidationResult, type ContractAddresses, type ContractCall, type ContractDeployment, ContractFactory, type ContractInfo, type ContractMethodParams, type ContractMethodReturnType, ContractNotFoundError, type Controller, type ControllerContext, type CreateOperationParams, type CreateOperationRequest, type CreateOperationResponse, type CreateSchemaParams, type CreateSchemaResult, DEFAULT_ENCRYPTION_SEED, DEFAULT_IPFS_GATEWAY, DataController, type DataSchema, type DecryptionErrorResponse, type DeepPartial, type DeepReadonly, type DeleteFileParams, type DeleteFileResult, type DownloadFileParams, type DownloadFileResult, type EncryptedUploadParams, type EncryptionInfo, type ErrorResponse, EventEmitter, type EventFilter, type EventLog, type Factory, type FileAccessErrorResponse, type FileAccessPermissions, type FileMetadata, type FilePermissionParams, type FileSharingConfig, type GasEstimate, type GenericRequest, type GenericResponse, type GenericTypedData, type GetFileParams, type GetOperationResponse, type GetUserFilesParams, type GetUserPermissionsOptions, type GetUserTrustedServersParams, GoogleDriveStorage, GrantExpiredError, type GrantFile, type GrantPermissionParams, GrantSchemaError, GrantValidationError, type GrantValidationErrorResponse, type GrantValidationOptions, type GrantValidationResult, type GrantedPermission, type Grantee, type GranteeInfo, GranteeMismatchError, type GranteeQueryOptions, type HttpMethod, IPFS_GATEWAYS, type IdentityResponseModel, type InitPersonalServerParams, type InternalServerErrorResponse, InvalidConfigurationError, IpfsStorage, type LegacyPermissionParams, type MaybeArray, type MaybePromise, MemoryCache, type Middleware, MiddlewarePipeline, NetworkError, type NetworkInfo, NodePlatformAdapter, type Nominal, type NonNullable, NonceError, type NotFoundErrorResponse, type Observable, type Observer, type OmitByType, type OnChainPermissionGrant, type OperationErrorResponse, OperationNotAllowedError, type OptionalKeys, type PaginatedGrantees, type PaginatedTrustedServers, type PaginationParams, type PaginationResult, type PartialExcept, type Permission, type PermissionAnalytics, type PermissionCheckResult, PermissionError, type PermissionEvent, type PermissionGrantDomain, type PermissionGrantMessage, type PermissionGrantTypedData, type PermissionInfo, type PermissionInputMessage, type PermissionOperation, type PermissionQueryResult, type PermissionStatus, PermissionsController, PersonalServerError, type PersonalServerIdentity, type PersonalServerModel, type PickByType, type PinataListResponse, type PinataPin, PinataStorage, type PinataUploadResponse, type Plugin, type PostRequestParams, type PromiseResult, ProtocolController, type QueryPermissionsParams, type RateLimitInfo, RateLimiter, type RateLimiterConfig, type Refiner, type RegisterGranteeInput, type RegisterGranteeParams, type RegisterGranteeTypedData, type RelayerCallbacks, type RelayerConfig, RelayerError, type RelayerErrorResponse, type RelayerMetrics, type RelayerQueueInfo, type RelayerRequestOptions, type RelayerRequestPayload, type RelayerStatus, type RelayerStorageResponse, type RelayerStoreParams, type RelayerSubmitParams, type RelayerTransactionResponse, type RelayerTransactionStatus, type RelayerWebhookConfig, type RelayerWebhookPayload, type ReplicateAPIResponse, type ReplicateStatus, type Repository, type RequestOptions, type RequireKeys, type RequiredExcept, type RetryConfig, RetryUtility, type RevokePermissionInput, type RevokePermissionParams, type RuntimeConfig, type Schema, SchemaController, type SchemaMetadata, SchemaValidationError, SchemaValidator, SerializationError, type Server, type components as ServerComponents, ServerController, type $defs as ServerDefs, type ServerFilesAndPermissionParams, type ServerFilesAndPermissionTypedData, type ServerInfo, type operations as ServerOperations, type paths as ServerPaths, type ServerTrustStatus, ServerUrlMismatchError, type webhooks as ServerWebhooks, type Service, SignatureCache, SignatureError, type SimplifiedPermissionMessage, type StateMachine, type StatusInfo, type StorageCallbacks, type StorageConfig, type StorageDownloadOptions, StorageError, type StorageFile, type StorageListOptions, type StorageListResult, StorageManager, type StorageProvider, type StorageProviderConfig, type StorageRequiredMarker, type StorageUploadResult, type TimeRange, TransactionHandle, type TransactionOptions, type TransactionReceipt, type Transformer, type TrustServerInput, type TrustServerParams, type TrustServerTypedData, type TrustedServer, type TrustedServerInfo, type TrustedServerQueryOptions, type UnencryptedUploadParams, type UntrustServerInput, type UntrustServerParams, type UntrustServerTypedData, type UpdateSchemaIdParams, type UpdateSchemaIdResult, type UploadEncryptedFileResult, type UploadFileParams, type UploadFileResult, type UploadParams, type UploadProgress, type UploadResult, type UserFile, UserRejectedRequestError, type ValidationErrorResponse, type ValidationResult, type Validator, Vana, type VanaChain, type VanaChainConfig, type VanaChainId, type VanaConfig, type VanaConfigWithStorage, type VanaContract, type VanaContract as VanaContractAbi, type VanaContractInstance, type VanaContractName, VanaCore, VanaCoreFactory, VanaError, type VanaInstance, VanaNodeImpl, type VanaPlatformAdapter, type WalletConfig, type WalletConfigWithStorage, __contractCache, chains, checkGrantAccess, clearContractCache, type components, convertIpfsUrl, convertIpfsUrlWithFallbacks, createAndStoreGrant, createBrowserPlatformAdapter, createGrantFile, createNodePlatformAdapter, createPlatformAdapter, createPlatformAdapterFor, createPlatformAdapterSafe, createValidatedGrant, decryptBlobWithSignedKey, decryptWithPrivateKey, decryptWithWalletPrivateKey, Vana as default, detectPlatform, encryptBlobWithSignedKey, encryptFileKey, encryptWithWalletPublicKey, extractIpfsHash, fetchAndValidateSchema, fetchWithFallbacks, formatEth, formatNumber, formatToken, generateEncryptionKey, generateEncryptionKeyPair, generatePGPKeyPair, getAbi, getAllChains, getChainConfig, getContractAddress, getContractController, getContractInfo, getEncryptionParameters, getGatewayUrls, getGrantFileHash, getGrantTimeRemaining, getPlatformCapabilities, handleRelayerRequest, hasStorageConfig, isAPIResponse, isChainConfig, isGrantExpired, isIpfsUrl, isPlatformSupported, isReplicateAPIResponse, isVanaChain, isVanaChainId, isWalletConfig, moksha, mokshaTestnet, type operations, parseReplicateOutput, type paths, retrieveAndValidateGrant, retrieveGrantFile, safeParseJSON, schemaValidator, shortenAddress, storeGrantFile, summarizeGrant, validateDataAgainstSchema, validateDataSchema, validateGrant, validateGrantExpiry, validateGrantFile, validateGranteeAccess, validateOperationAccess, vanaMainnet, type webhooks, withSignatureCache };