@opendatalabs/vana-sdk 0.1.0-alpha.f2de4f7 → 0.1.0-alpha.f35bb9c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +33 -1
- package/dist/browser.js.map +1 -1
- package/dist/chains/index.cjs.map +1 -1
- package/dist/chains/index.d.ts +30 -1
- package/dist/chains/index.js.map +1 -1
- package/dist/config/chains.cjs.map +1 -1
- package/dist/config/chains.d.ts +99 -0
- package/dist/config/chains.js.map +1 -1
- package/dist/contracts/contractController.cjs.map +1 -1
- package/dist/contracts/contractController.d.ts +66 -10
- package/dist/contracts/contractController.js.map +1 -1
- package/dist/controllers/data.cjs +173 -141
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +213 -175
- package/dist/controllers/data.js +173 -141
- package/dist/controllers/data.js.map +1 -1
- package/dist/controllers/permissions.cjs +185 -191
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +29 -73
- package/dist/controllers/permissions.js +185 -191
- package/dist/controllers/permissions.js.map +1 -1
- package/dist/controllers/protocol.cjs.map +1 -1
- package/dist/controllers/protocol.d.ts +27 -28
- package/dist/controllers/protocol.js.map +1 -1
- package/dist/controllers/schemas.cjs +23 -21
- package/dist/controllers/schemas.cjs.map +1 -1
- package/dist/controllers/schemas.d.ts +47 -40
- package/dist/controllers/schemas.js +23 -21
- package/dist/controllers/schemas.js.map +1 -1
- package/dist/controllers/server.cjs +17 -15
- package/dist/controllers/server.cjs.map +1 -1
- package/dist/controllers/server.d.ts +46 -38
- package/dist/controllers/server.js +17 -15
- package/dist/controllers/server.js.map +1 -1
- package/dist/core/apiClient.cjs +53 -3
- package/dist/core/apiClient.cjs.map +1 -1
- package/dist/core/apiClient.d.ts +132 -7
- package/dist/core/apiClient.js +53 -3
- package/dist/core/apiClient.js.map +1 -1
- package/dist/core/generics.cjs +30 -3
- package/dist/core/generics.cjs.map +1 -1
- package/dist/core/generics.d.ts +95 -6
- package/dist/core/generics.js +30 -3
- package/dist/core/generics.js.map +1 -1
- package/dist/core.cjs +29 -12
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +2 -1
- package/dist/core.js +29 -12
- package/dist/core.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +3 -3
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +8 -9
- package/dist/index.node.js +2 -2
- package/dist/index.node.js.map +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +39 -1
- package/dist/node.js.map +1 -1
- package/dist/platform/browser.cjs +160 -2
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +232 -12
- package/dist/platform/browser.js +160 -2
- package/dist/platform/browser.js.map +1 -1
- package/dist/platform/interface.cjs.map +1 -1
- package/dist/platform/interface.d.ts +283 -90
- package/dist/platform/node.cjs +163 -2
- package/dist/platform/node.cjs.map +1 -1
- package/dist/platform/node.d.ts +69 -6
- package/dist/platform/node.js +163 -2
- package/dist/platform/node.js.map +1 -1
- package/dist/server/relayerHandler.cjs +214 -0
- package/dist/server/relayerHandler.cjs.map +1 -0
- package/dist/server/relayerHandler.d.ts +36 -0
- package/dist/server/relayerHandler.js +190 -0
- package/dist/server/relayerHandler.js.map +1 -0
- package/dist/storage/manager.cjs +108 -25
- package/dist/storage/manager.cjs.map +1 -1
- package/dist/storage/manager.d.ts +119 -25
- package/dist/storage/manager.js +108 -25
- package/dist/storage/manager.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +86 -15
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.d.ts +109 -20
- package/dist/storage/providers/callback-storage.js +86 -15
- package/dist/storage/providers/callback-storage.js.map +1 -1
- package/dist/storage/providers/pinata.cjs.map +1 -1
- package/dist/storage/providers/pinata.d.ts +12 -14
- package/dist/storage/providers/pinata.js.map +1 -1
- package/dist/tests/factories/mockFactory.d.ts +2 -2
- package/dist/tests/relayer-integration.test.d.ts +1 -0
- package/dist/tests/relayer-unified.test.d.ts +1 -0
- package/dist/tests/server-relayer-handler.test.d.ts +1 -0
- package/dist/types/blockchain.cjs.map +1 -1
- package/dist/types/blockchain.d.ts +39 -11
- package/dist/types/chains.cjs.map +1 -1
- package/dist/types/chains.d.ts +74 -7
- package/dist/types/chains.js.map +1 -1
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.ts +46 -191
- package/dist/types/config.js.map +1 -1
- package/dist/types/contracts.cjs.map +1 -1
- package/dist/types/contracts.d.ts +71 -7
- package/dist/types/controller-context.cjs.map +1 -1
- package/dist/types/controller-context.d.ts +3 -2
- package/dist/types/data.cjs.map +1 -1
- package/dist/types/data.d.ts +4 -6
- package/dist/types/generics.cjs.map +1 -1
- package/dist/types/generics.d.ts +80 -9
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +27 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/operations.cjs.map +1 -1
- package/dist/types/operations.d.ts +132 -15
- package/dist/types/operations.js.map +1 -1
- package/dist/types/permissions.cjs.map +1 -1
- package/dist/types/permissions.d.ts +15 -20
- package/dist/types/personal.cjs.map +1 -1
- package/dist/types/personal.d.ts +131 -14
- package/dist/types/relayer.cjs.map +1 -1
- package/dist/types/relayer.d.ts +262 -35
- package/dist/types/storage.cjs.map +1 -1
- package/dist/types/storage.d.ts +9 -21
- package/dist/types/storage.js.map +1 -1
- package/dist/utils/grantFiles.cjs.map +1 -1
- package/dist/utils/grantFiles.d.ts +10 -20
- package/dist/utils/grantFiles.js.map +1 -1
- package/dist/utils/grantValidation.cjs.map +1 -1
- package/dist/utils/grantValidation.d.ts +95 -16
- package/dist/utils/grantValidation.js.map +1 -1
- package/dist/utils/grants.cjs.map +1 -1
- package/dist/utils/grants.d.ts +93 -12
- package/dist/utils/grants.js.map +1 -1
- package/dist/utils/lazy-import.cjs.map +1 -1
- package/dist/utils/lazy-import.d.ts +32 -7
- package/dist/utils/lazy-import.js.map +1 -1
- package/dist/utils/signatureCache.cjs +8 -2
- package/dist/utils/signatureCache.cjs.map +1 -1
- package/dist/utils/signatureCache.d.ts +49 -8
- package/dist/utils/signatureCache.js +8 -2
- package/dist/utils/signatureCache.js.map +1 -1
- package/dist/utils/transactionHelpers.cjs.map +1 -1
- package/dist/utils/transactionHelpers.d.ts +12 -12
- package/dist/utils/transactionHelpers.js.map +1 -1
- package/dist/utils/typedDataConverter.cjs.map +1 -1
- package/dist/utils/typedDataConverter.d.ts +39 -3
- package/dist/utils/typedDataConverter.js.map +1 -1
- package/dist/utils/urlResolver.cjs +7 -0
- package/dist/utils/urlResolver.cjs.map +1 -1
- package/dist/utils/urlResolver.d.ts +22 -4
- package/dist/utils/urlResolver.js +7 -0
- package/dist/utils/urlResolver.js.map +1 -1
- package/dist/utils/wallet.cjs +2 -1
- package/dist/utils/wallet.cjs.map +1 -1
- package/dist/utils/wallet.d.ts +78 -16
- package/dist/utils/wallet.js +2 -1
- package/dist/utils/wallet.js.map +1 -1
- package/package.json +1 -1
- package/dist/server/handler.cjs +0 -101
- package/dist/server/handler.cjs.map +0 -1
- package/dist/server/handler.d.ts +0 -87
- package/dist/server/handler.js +0 -77
- package/dist/server/handler.js.map +0 -1
- /package/dist/tests/{server-handler.test.d.ts → permissions-revoke-relayer.test.d.ts} +0 -0
|
@@ -6,90 +6,106 @@ import type { ControllerContext } from "./permissions";
|
|
|
6
6
|
import { BaseController } from "./base";
|
|
7
7
|
import { type DataSchema } from "../utils/schemaValidation";
|
|
8
8
|
/**
|
|
9
|
-
* Manages encrypted user data files and
|
|
9
|
+
* Manages encrypted user data files and blockchain registration on the Vana network.
|
|
10
10
|
*
|
|
11
11
|
* @remarks
|
|
12
|
-
*
|
|
13
|
-
* blockchain registration
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* encryption before any data leaves the user's device.
|
|
12
|
+
* The DataController provides comprehensive file lifecycle management from encrypted upload
|
|
13
|
+
* through blockchain registration to decryption. Client-side encryption ensures data privacy
|
|
14
|
+
* before transmission. The controller integrates with multiple storage providers (IPFS, Pinata,
|
|
15
|
+
* Google Drive) and supports both gasless transactions via relayers and direct blockchain interaction.
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* **Architecture:**
|
|
18
|
+
* Files use dual storage: encrypted content on decentralized storage (IPFS/Pinata/Google Drive),
|
|
19
|
+
* metadata and permissions on blockchain. This design minimizes on-chain data while maintaining
|
|
20
|
+
* decentralization and access control.
|
|
22
21
|
*
|
|
23
22
|
* **Method Selection:**
|
|
24
|
-
* - `upload()`
|
|
25
|
-
* - `getUserFiles()`
|
|
26
|
-
* - `decryptFile()`
|
|
27
|
-
* - `getFileById()`
|
|
23
|
+
* - `upload()` - Complete workflow: encryption, storage, blockchain registration
|
|
24
|
+
* - `getUserFiles()` - Query file metadata from blockchain/subgraph
|
|
25
|
+
* - `decryptFile()` - Decrypt files you have permission to access
|
|
26
|
+
* - `getFileById()` - Retrieve specific file metadata by ID
|
|
28
27
|
*
|
|
29
28
|
* **Storage Requirements:**
|
|
30
|
-
* Methods requiring storage
|
|
31
|
-
* Methods working without storage: `getUserFiles()`, `decryptFile()`, `getFileById()`
|
|
29
|
+
* - Methods requiring storage: `upload()`, `encryptFile()`
|
|
30
|
+
* - Methods working without storage: `getUserFiles()`, `decryptFile()`, `getFileById()`
|
|
31
|
+
*
|
|
32
|
+
* **Permission Model:**
|
|
33
|
+
* - File permissions (decryption access) are handled during upload
|
|
34
|
+
* - Operation permissions (what can be done with data) use `vana.permissions.grant()`
|
|
35
|
+
*
|
|
32
36
|
* @example
|
|
33
37
|
* ```typescript
|
|
34
|
-
* // Upload
|
|
38
|
+
* // Upload encrypted file with schema validation
|
|
35
39
|
* const result = await vana.data.upload({
|
|
36
|
-
* content:
|
|
37
|
-
* filename: "
|
|
40
|
+
* content: { name: "Alice", age: 30 },
|
|
41
|
+
* filename: "profile.json",
|
|
42
|
+
* schemaId: 1
|
|
38
43
|
* });
|
|
44
|
+
* console.log(`File uploaded: ID ${result.fileId}, URL ${result.url}`);
|
|
39
45
|
*
|
|
40
|
-
* // Query files
|
|
46
|
+
* // Query user's files
|
|
41
47
|
* const files = await vana.data.getUserFiles({
|
|
42
|
-
* owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
48
|
+
* owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
43
49
|
* });
|
|
50
|
+
* files.forEach(file => console.log(`File ${file.id}: ${file.url}`));
|
|
44
51
|
*
|
|
45
|
-
* // Decrypt accessible file
|
|
52
|
+
* // Decrypt accessible file
|
|
46
53
|
* const decryptedData = await vana.data.decryptFile(files[0]);
|
|
54
|
+
* console.log("Decrypted content:", decryptedData);
|
|
47
55
|
* ```
|
|
56
|
+
*
|
|
48
57
|
* @category Data Management
|
|
49
|
-
* @see {@link https://docs.vana.
|
|
58
|
+
* @see For conceptual overview, visit {@link https://docs.vana.org/docs/data-registry}
|
|
50
59
|
*/
|
|
51
60
|
export declare class DataController extends BaseController {
|
|
52
61
|
constructor(context: ControllerContext);
|
|
53
62
|
/**
|
|
54
|
-
* Uploads
|
|
63
|
+
* Uploads data with automatic encryption and blockchain registration.
|
|
55
64
|
*
|
|
56
65
|
* @remarks
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* - Normalizes
|
|
63
|
-
* - Validates
|
|
64
|
-
* - Generates encryption keys
|
|
65
|
-
* - Uploads to
|
|
66
|
-
* - Grants
|
|
67
|
-
* - Registers
|
|
66
|
+
* Primary method for uploading data to Vana. Handles complete workflow:
|
|
67
|
+
* content normalization, schema validation, encryption, storage upload,
|
|
68
|
+
* permission granting, and blockchain registration.
|
|
69
|
+
*
|
|
70
|
+
* **Automatic Processing:**
|
|
71
|
+
* - Normalizes content to Blob format
|
|
72
|
+
* - Validates against schema if provided
|
|
73
|
+
* - Generates encryption keys
|
|
74
|
+
* - Uploads to configured storage
|
|
75
|
+
* - Grants decryption permissions
|
|
76
|
+
* - Registers on blockchain
|
|
68
77
|
*
|
|
69
78
|
* **TypeScript Overloads:**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* @param params -
|
|
82
|
-
*
|
|
83
|
-
* @param params.schemaId -
|
|
84
|
-
*
|
|
85
|
-
* @
|
|
86
|
-
*
|
|
87
|
-
* @
|
|
88
|
-
* @
|
|
89
|
-
*
|
|
90
|
-
* @
|
|
91
|
-
*
|
|
92
|
-
* @throws {Error}
|
|
79
|
+
* - `EncryptedUploadParams`: When `encrypt: true` (default), permissions require `publicKey`
|
|
80
|
+
* - `UnencryptedUploadParams`: When `encrypt: false`, permissions optional
|
|
81
|
+
* - `UploadParams`: General signature for runtime determination
|
|
82
|
+
*
|
|
83
|
+
* **Permission Separation:**
|
|
84
|
+
* - File permissions (here): Decryption access only
|
|
85
|
+
* - Operation permissions: Use `vana.permissions.grant()` separately
|
|
86
|
+
*
|
|
87
|
+
* @param params - Upload configuration object
|
|
88
|
+
* @param params.content - Data to upload (string, object, or Blob)
|
|
89
|
+
* @param params.filename - Name for the uploaded file
|
|
90
|
+
* @param params.permissions - Decryption access grants.
|
|
91
|
+
* Each requires `account` and `publicKey` for encryption.
|
|
92
|
+
* @param params.schemaId - Schema for validation.
|
|
93
|
+
* Obtain via `vana.schemas.list()`.
|
|
94
|
+
* @param params.owner - Owner address for delegation scenarios.
|
|
95
|
+
* Defaults to connected wallet address.
|
|
96
|
+
* @param params.encrypt - Enable encryption (default: `true`)
|
|
97
|
+
* @param params.providerName - Storage provider override
|
|
98
|
+
*
|
|
99
|
+
* @returns Upload result with file ID, URL, and transaction hash
|
|
100
|
+
*
|
|
101
|
+
* @throws {Error} Storage not configured.
|
|
102
|
+
* Configure storage providers in `VanaConfig`.
|
|
103
|
+
* @throws {Error} No wallet addresses available.
|
|
104
|
+
* Ensure wallet is connected.
|
|
105
|
+
* @throws {SchemaValidationError} Data doesn't match schema.
|
|
106
|
+
* Verify data structure matches schema from `vana.schemas.get(schemaId)`.
|
|
107
|
+
* @throws {Error} Upload failed with specific error message.
|
|
108
|
+
*
|
|
93
109
|
* @example
|
|
94
110
|
* ```typescript
|
|
95
111
|
* // Basic file upload
|
|
@@ -192,35 +208,33 @@ export declare class DataController extends BaseController {
|
|
|
192
208
|
*/
|
|
193
209
|
encryptFile(data: Blob | string | object, options?: EncryptFileOptions): Promise<EncryptFileResult>;
|
|
194
210
|
/**
|
|
195
|
-
* Decrypts a file
|
|
211
|
+
* Decrypts a file using wallet-derived decryption key.
|
|
196
212
|
*
|
|
197
213
|
* @remarks
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
214
|
+
* Counterpart to `upload()` for decrypting user files. Automatically
|
|
215
|
+
* generates decryption key from wallet, fetches encrypted content,
|
|
216
|
+
* and decrypts. Supports IPFS (with gateway fallback) and HTTP URLs.
|
|
217
|
+
*
|
|
218
|
+
* @param file - UserFile object from `getUserFiles()`
|
|
219
|
+
* @param options - Decryption options
|
|
220
|
+
* @param options.seed - Custom encryption seed.
|
|
221
|
+
* Defaults to standard Vana seed.
|
|
222
|
+
*
|
|
223
|
+
* @returns Decrypted content as Blob
|
|
224
|
+
*
|
|
225
|
+
* @throws {Error} No wallet connected.
|
|
226
|
+
* Connect wallet before decrypting.
|
|
227
|
+
* @throws {Error} Network error accessing file.
|
|
228
|
+
* Check CORS settings or server availability.
|
|
229
|
+
* @throws {Error} File not found (404).
|
|
230
|
+
* File no longer available at stored URL.
|
|
231
|
+
* @throws {Error} Access denied (403).
|
|
232
|
+
* No permission to access file.
|
|
233
|
+
* @throws {Error} Invalid file format.
|
|
234
|
+
* File not encrypted with Vana protocol.
|
|
235
|
+
* @throws {Error} Wrong encryption key.
|
|
236
|
+
* Verify seed matches upload or use default.
|
|
202
237
|
*
|
|
203
|
-
* The method automatically:
|
|
204
|
-
* - Generates the decryption key from the user's wallet signature
|
|
205
|
-
* - Determines the appropriate fetch method based on the file URL protocol
|
|
206
|
-
* - Fetches the encrypted content from IPFS or standard HTTP URLs
|
|
207
|
-
* - Decrypts the content using the generated key
|
|
208
|
-
*
|
|
209
|
-
* For IPFS URLs, the method uses gateway fallback for improved reliability. For
|
|
210
|
-
* standard HTTP URLs, it uses a simple fetch. If you need custom authentication
|
|
211
|
-
* headers or specific gateway configurations, use the low-level primitives directly.
|
|
212
|
-
*
|
|
213
|
-
* @param file - The user file to decrypt (typically from getUserFiles)
|
|
214
|
-
* @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
|
|
215
|
-
* @returns Promise resolving to the decrypted file content as a Blob
|
|
216
|
-
* @throws {Error} "No addresses available in wallet client" - When wallet is not connected
|
|
217
|
-
* @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
|
|
218
|
-
* @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
|
|
219
|
-
* @throws {Error} "Access denied" - When file returns 403 (no permission)
|
|
220
|
-
* @throws {Error} "File is empty or could not be retrieved" - When file has no content
|
|
221
|
-
* @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
|
|
222
|
-
* @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
|
|
223
|
-
* @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
|
|
224
238
|
* @example
|
|
225
239
|
* ```typescript
|
|
226
240
|
* // Basic file decryption
|
|
@@ -248,35 +262,38 @@ export declare class DataController extends BaseController {
|
|
|
248
262
|
*/
|
|
249
263
|
decryptFile(file: UserFile, options?: DecryptFileOptions): Promise<Blob>;
|
|
250
264
|
/**
|
|
251
|
-
* Retrieves all
|
|
265
|
+
* Retrieves all files owned by a specific user address.
|
|
252
266
|
*
|
|
253
267
|
* @remarks
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* @
|
|
265
|
-
*
|
|
266
|
-
* @
|
|
267
|
-
*
|
|
268
|
-
* @throws {Error}
|
|
269
|
-
*
|
|
270
|
-
* @throws {Error}
|
|
268
|
+
* Queries the Vana subgraph for files owned by the specified address.
|
|
269
|
+
* Automatically deduplicates by file ID, keeping the latest version
|
|
270
|
+
* when duplicates exist from re-indexing or chain reorganizations.
|
|
271
|
+
* Enriches results with DLP proof data when available.
|
|
272
|
+
*
|
|
273
|
+
* @param params - Query configuration
|
|
274
|
+
* @param params.owner - Wallet address of the file owner
|
|
275
|
+
* @param params.subgraphUrl - Subgraph endpoint override.
|
|
276
|
+
* Defaults to context configuration.
|
|
277
|
+
*
|
|
278
|
+
* @returns Array of UserFile objects sorted by timestamp (newest first)
|
|
279
|
+
*
|
|
280
|
+
* @throws {Error} Subgraph URL not configured.
|
|
281
|
+
* Provide `subgraphUrl` parameter or configure in Vana constructor.
|
|
282
|
+
* @throws {Error} Subgraph request failed.
|
|
283
|
+
* Check network connectivity and subgraph availability.
|
|
284
|
+
* @throws {Error} Subgraph returned errors.
|
|
285
|
+
* Review query parameters and subgraph logs.
|
|
286
|
+
*
|
|
271
287
|
* @example
|
|
272
288
|
* ```typescript
|
|
273
|
-
* // Query files for a specific user
|
|
274
289
|
* const files = await vana.data.getUserFiles({
|
|
275
|
-
* owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
290
|
+
* owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
276
291
|
* });
|
|
277
292
|
*
|
|
278
293
|
* files.forEach(file => {
|
|
279
|
-
* console.log(`File ${file.id}: ${file.url}
|
|
294
|
+
* console.log(`File ${file.id}: ${file.url}`);
|
|
295
|
+
* console.log(` Schema: ${file.schemaId}`);
|
|
296
|
+
* console.log(` DLPs: ${file.dlpIds?.join(", ") || "none"}`);
|
|
280
297
|
* });
|
|
281
298
|
* ```
|
|
282
299
|
*/
|
|
@@ -468,48 +485,56 @@ export declare class DataController extends BaseController {
|
|
|
468
485
|
*/
|
|
469
486
|
private _getUserTrustedServersViaRpc;
|
|
470
487
|
/**
|
|
471
|
-
*
|
|
488
|
+
* Retrieves total file count from Data Registry.
|
|
489
|
+
*
|
|
490
|
+
* @remarks
|
|
491
|
+
* Queries blockchain for complete file count across all users.
|
|
492
|
+
* Useful for pagination and network statistics.
|
|
493
|
+
*
|
|
494
|
+
* @returns Total number of registered files
|
|
495
|
+
*
|
|
496
|
+
* @throws {Error} Chain ID not available.
|
|
497
|
+
* Ensure network connection.
|
|
498
|
+
* @throws {Error} Contract read failed.
|
|
499
|
+
* Check RPC availability.
|
|
472
500
|
*
|
|
473
|
-
* @returns Promise resolving to the total file count
|
|
474
501
|
* @example
|
|
475
502
|
* ```typescript
|
|
476
|
-
* const
|
|
477
|
-
* console.log(`Total files
|
|
503
|
+
* const total = await vana.data.getTotalFilesCount();
|
|
504
|
+
* console.log(`Total files: ${total}`);
|
|
478
505
|
*
|
|
479
|
-
* //
|
|
480
|
-
* const
|
|
481
|
-
* const totalPages = Math.ceil(totalFiles / filesPerPage);
|
|
482
|
-
* console.log(`Total pages: ${totalPages}`);
|
|
506
|
+
* // Calculate pagination
|
|
507
|
+
* const pages = Math.ceil(total / 20);
|
|
483
508
|
* ```
|
|
484
509
|
*/
|
|
485
510
|
getTotalFilesCount(): Promise<number>;
|
|
486
511
|
/**
|
|
487
|
-
* Retrieves
|
|
512
|
+
* Retrieves file metadata by ID from the blockchain.
|
|
513
|
+
*
|
|
514
|
+
* @remarks
|
|
515
|
+
* Queries DataRegistry contract directly for file details.
|
|
516
|
+
* Works for any file ID regardless of ownership, enabling
|
|
517
|
+
* cross-user file discovery and verification.
|
|
518
|
+
*
|
|
519
|
+
* @param fileId - Numeric file ID to retrieve
|
|
520
|
+
*
|
|
521
|
+
* @returns UserFile object with metadata
|
|
522
|
+
*
|
|
523
|
+
* @throws {Error} Chain ID not available.
|
|
524
|
+
* Ensure proper network connection.
|
|
525
|
+
* @throws {Error} File not found.
|
|
526
|
+
* Verify file ID exists on-chain.
|
|
527
|
+
* @throws {Error} Contract call failed.
|
|
528
|
+
* Check network and RPC availability.
|
|
488
529
|
*
|
|
489
|
-
* @param fileId - The file ID to look up
|
|
490
|
-
* @returns Promise resolving to UserFile object
|
|
491
|
-
* @throws {Error} "Chain ID not available" - When wallet chain is not configured
|
|
492
|
-
* @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
|
|
493
|
-
* @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
|
|
494
530
|
* @example
|
|
495
531
|
* ```typescript
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
* owner: file.ownerAddress,
|
|
502
|
-
* addedAt: file.addedAtBlock
|
|
503
|
-
* });
|
|
504
|
-
* } catch (error) {
|
|
505
|
-
* console.error('File not found or error retrieving file:', error);
|
|
506
|
-
* }
|
|
532
|
+
* const file = await vana.data.getFileById(123);
|
|
533
|
+
* console.log(`File ${file.id}:`);
|
|
534
|
+
* console.log(` URL: ${file.url}`);
|
|
535
|
+
* console.log(` Owner: ${file.ownerAddress}`);
|
|
536
|
+
* console.log(` Block: ${file.addedAtBlock}`);
|
|
507
537
|
* ```
|
|
508
|
-
*
|
|
509
|
-
* This method queries the DataRegistry contract directly
|
|
510
|
-
* to get file details for any file ID, regardless of user ownership.
|
|
511
|
-
* This is useful for file lookup functionality where users can search
|
|
512
|
-
* for specific files by ID.
|
|
513
538
|
*/
|
|
514
539
|
getFileById(fileId: number): Promise<UserFile>;
|
|
515
540
|
/**
|
|
@@ -648,74 +673,87 @@ export declare class DataController extends BaseController {
|
|
|
648
673
|
key: string;
|
|
649
674
|
}>, schemaId?: number): Promise<TransactionResult<"DataRegistry", "addFileWithPermissionsAndSchema">>;
|
|
650
675
|
/**
|
|
651
|
-
*
|
|
676
|
+
* Registers a data refiner for processing templates.
|
|
652
677
|
*
|
|
653
678
|
* @remarks
|
|
654
|
-
* Refiners
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
* @param params - Refiner
|
|
660
|
-
* @param params.
|
|
661
|
-
*
|
|
662
|
-
* @param params.
|
|
663
|
-
*
|
|
664
|
-
* @returns
|
|
665
|
-
*
|
|
666
|
-
* @throws {Error}
|
|
679
|
+
* Refiners define data transformation rules for DLPs.
|
|
680
|
+
* Associates schema, instructions, and processing logic.
|
|
681
|
+
*
|
|
682
|
+
* @param params - Refiner configuration
|
|
683
|
+
* @param params.dlpId - Data Liquidity Pool ID
|
|
684
|
+
* @param params.name - Refiner display name
|
|
685
|
+
* @param params.schemaId - Output schema ID.
|
|
686
|
+
* Obtain via `vana.schemas.list()`.
|
|
687
|
+
* @param params.refinementInstructionUrl - Processing instructions URL
|
|
688
|
+
*
|
|
689
|
+
* @returns Refiner ID and transaction hash
|
|
690
|
+
*
|
|
691
|
+
* @throws {Error} Chain ID not available.
|
|
692
|
+
* Ensure network connection.
|
|
693
|
+
* @throws {Error} Transaction failed.
|
|
694
|
+
* Check wallet balance and network status.
|
|
695
|
+
*
|
|
667
696
|
* @example
|
|
668
697
|
* ```typescript
|
|
669
698
|
* const result = await vana.data.addRefiner({
|
|
670
699
|
* dlpId: 1,
|
|
671
|
-
* name: "
|
|
700
|
+
* name: "Sentiment Analyzer",
|
|
672
701
|
* schemaId: 42,
|
|
673
702
|
* refinementInstructionUrl: "ipfs://QmXxx..."
|
|
674
703
|
* });
|
|
675
|
-
* console.log(`
|
|
704
|
+
* console.log(`Refiner ${result.refinerId} created`);
|
|
676
705
|
* ```
|
|
677
706
|
*/
|
|
678
707
|
addRefiner(params: AddRefinerParams): Promise<AddRefinerResult>;
|
|
679
708
|
/**
|
|
680
|
-
* Retrieves
|
|
709
|
+
* Retrieves refiner configuration by ID.
|
|
681
710
|
*
|
|
682
711
|
* @remarks
|
|
683
|
-
* Queries
|
|
684
|
-
*
|
|
712
|
+
* Queries DataRefinerRegistry for refiner details.
|
|
713
|
+
* Returns DLP association, schema, and processing instructions.
|
|
714
|
+
*
|
|
715
|
+
* @param refinerId - Numeric refiner ID
|
|
716
|
+
*
|
|
717
|
+
* @returns Refiner configuration object
|
|
718
|
+
*
|
|
719
|
+
* @throws {Error} Chain ID not available.
|
|
720
|
+
* Ensure network connection.
|
|
721
|
+
* @throws {Error} Refiner not found.
|
|
722
|
+
* Verify refiner ID exists.
|
|
723
|
+
* @throws {Error} Contract read failed.
|
|
724
|
+
* Check network and RPC status.
|
|
685
725
|
*
|
|
686
|
-
* @param refinerId - The numeric refiner ID to retrieve
|
|
687
|
-
* @returns Promise resolving to the refiner information object
|
|
688
|
-
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
689
|
-
* @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
|
|
690
|
-
* @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
|
|
691
726
|
* @example
|
|
692
727
|
* ```typescript
|
|
693
728
|
* const refiner = await vana.data.getRefiner(1);
|
|
694
|
-
* console.log({
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
* schema: refiner.schemaId,
|
|
698
|
-
* instructions: refiner.refinementInstructionUrl
|
|
699
|
-
* });
|
|
729
|
+
* console.log(`Refiner: ${refiner.name}`);
|
|
730
|
+
* console.log(`DLP: ${refiner.dlpId}`);
|
|
731
|
+
* console.log(`Schema: ${refiner.schemaId}`);
|
|
700
732
|
* ```
|
|
701
733
|
*/
|
|
702
734
|
getRefiner(refinerId: number): Promise<Refiner>;
|
|
703
735
|
/**
|
|
704
|
-
* Validates
|
|
736
|
+
* Validates schema ID existence.
|
|
705
737
|
*
|
|
706
738
|
* @remarks
|
|
707
|
-
*
|
|
708
|
-
*
|
|
739
|
+
* Verifies schema registration in DataRegistry.
|
|
740
|
+
* Check before using schemas for uploads.
|
|
741
|
+
*
|
|
742
|
+
* @param schemaId - Numeric schema ID to validate
|
|
743
|
+
*
|
|
744
|
+
* @returns True if schema exists, false otherwise
|
|
745
|
+
*
|
|
746
|
+
* @throws {Error} Chain ID not available.
|
|
747
|
+
* Ensure network connection.
|
|
748
|
+
* @throws {Error} Contract read failed.
|
|
749
|
+
* Check RPC availability.
|
|
709
750
|
*
|
|
710
|
-
* @param schemaId - The numeric schema ID to validate
|
|
711
|
-
* @returns Promise resolving to true if schema exists, false otherwise
|
|
712
751
|
* @example
|
|
713
752
|
* ```typescript
|
|
714
|
-
* const
|
|
715
|
-
* if (
|
|
716
|
-
*
|
|
717
|
-
*
|
|
718
|
-
* console.log('Schema 42 does not exist');
|
|
753
|
+
* const valid = await vana.data.isValidSchemaId(42);
|
|
754
|
+
* if (valid) {
|
|
755
|
+
* // Safe to use schema 42
|
|
756
|
+
* await vana.data.upload({ schemaId: 42, ... });
|
|
719
757
|
* }
|
|
720
758
|
* ```
|
|
721
759
|
*/
|