@opendatalabs/vana-sdk 0.1.0-alpha.b390e7f → 0.1.0-alpha.d6bebb0
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/index.browser.d.ts +683 -104
- package/dist/index.browser.js +188 -26
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +188 -26
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +710 -104
- package/dist/index.node.d.ts +710 -104
- package/dist/index.node.js +188 -26
- package/dist/index.node.js.map +1 -1
- package/dist/platform.browser.d.ts +35 -0
- package/dist/platform.node.d.cts +35 -0
- package/dist/platform.node.d.ts +35 -0
- package/package.json +1 -1
package/dist/index.browser.d.ts
CHANGED
|
@@ -236,7 +236,8 @@ interface GrantPermissionParams$1 {
|
|
|
236
236
|
grantee: Address;
|
|
237
237
|
/** The class of computation, e.g., "llm_inference" */
|
|
238
238
|
operation: string;
|
|
239
|
-
/** Array of file IDs to grant permission for
|
|
239
|
+
/** Array of file IDs to grant permission for.
|
|
240
|
+
* Obtain file IDs from `vana.data.getUserFiles()` or from upload results via `vana.data.upload().fileId`. */
|
|
240
241
|
files: number[];
|
|
241
242
|
/** The full, off-chain parameters (e.g., LLM prompt) */
|
|
242
243
|
parameters: Record<string, unknown>;
|
|
@@ -246,6 +247,8 @@ interface GrantPermissionParams$1 {
|
|
|
246
247
|
nonce?: bigint;
|
|
247
248
|
/** Optional expiration time for the permission */
|
|
248
249
|
expiresAt?: number;
|
|
250
|
+
/** Optional grantee ID to use instead of resolving from address */
|
|
251
|
+
granteeId?: number;
|
|
249
252
|
}
|
|
250
253
|
/**
|
|
251
254
|
* Parameters for revoking a previously granted data access permission.
|
|
@@ -359,6 +362,8 @@ interface PermissionInputMessage {
|
|
|
359
362
|
grant: string;
|
|
360
363
|
/** File IDs */
|
|
361
364
|
fileIds: bigint[];
|
|
365
|
+
/** Grantee ID */
|
|
366
|
+
granteeId: bigint;
|
|
362
367
|
}
|
|
363
368
|
/**
|
|
364
369
|
* Contract RevokePermissionInput structure
|
|
@@ -785,6 +790,12 @@ interface StorageRequiredMarker {
|
|
|
785
790
|
* Allows you to configure multiple storage backends (IPFS, Pinata, Google Drive, etc.)
|
|
786
791
|
* and specify which one to use by default for file operations.
|
|
787
792
|
*
|
|
793
|
+
* **Provider Selection:**
|
|
794
|
+
* - IPFS: Decentralized, permanent storage ideal for production
|
|
795
|
+
* - Pinata: Managed IPFS with guaranteed availability
|
|
796
|
+
* - Google Drive: Centralized, suitable for development/testing
|
|
797
|
+
* - Custom providers: Implement StorageProvider interface
|
|
798
|
+
*
|
|
788
799
|
* @category Configuration
|
|
789
800
|
* @example
|
|
790
801
|
* ```typescript
|
|
@@ -798,9 +809,12 @@ interface StorageRequiredMarker {
|
|
|
798
809
|
* ```
|
|
799
810
|
*/
|
|
800
811
|
interface StorageConfig {
|
|
801
|
-
/** Map of provider name to storage provider instance
|
|
812
|
+
/** Map of provider name to storage provider instance.
|
|
813
|
+
* Common provider names: "ipfs", "pinata", "googledrive", "s3".
|
|
814
|
+
* Custom names allowed for custom provider implementations. */
|
|
802
815
|
providers: Record<string, StorageProvider>;
|
|
803
|
-
/** Default provider name to use when none specified
|
|
816
|
+
/** Default provider name to use when none specified.
|
|
817
|
+
* Must match a key in the providers map. Falls back to first provider if not specified. */
|
|
804
818
|
defaultProvider?: string;
|
|
805
819
|
}
|
|
806
820
|
/**
|
|
@@ -901,9 +915,10 @@ interface RelayerCallbacks {
|
|
|
901
915
|
*
|
|
902
916
|
* @param params - Complete parameters for file addition
|
|
903
917
|
* @param params.url - The file URL to register
|
|
904
|
-
* @param params.userAddress - The user's address
|
|
918
|
+
* @param params.userAddress - The user's address (defaults to connected wallet if not specified)
|
|
905
919
|
* @param params.permissions - Array of encrypted permissions (empty array if none)
|
|
906
920
|
* @param params.schemaId - Schema ID for validation (0 if none)
|
|
921
|
+
* @param params.ownerAddress - Optional owner address (defaults to userAddress if not specified)
|
|
907
922
|
* @returns Promise resolving to object with fileId and transactionHash
|
|
908
923
|
*/
|
|
909
924
|
submitFileAdditionComplete?: (params: {
|
|
@@ -914,6 +929,7 @@ interface RelayerCallbacks {
|
|
|
914
929
|
key: string;
|
|
915
930
|
}>;
|
|
916
931
|
schemaId: number;
|
|
932
|
+
ownerAddress?: Address;
|
|
917
933
|
}) => Promise<{
|
|
918
934
|
fileId: number;
|
|
919
935
|
transactionHash: Hash;
|
|
@@ -1052,18 +1068,22 @@ interface BaseConfig {
|
|
|
1052
1068
|
* Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.
|
|
1053
1069
|
*/
|
|
1054
1070
|
relayerCallbacks?: RelayerCallbacks;
|
|
1055
|
-
/** Optional storage providers configuration for file upload/download
|
|
1071
|
+
/** Optional storage providers configuration for file upload/download.
|
|
1072
|
+
* Required for: upload(), grant() without pre-stored URLs, schema operations.
|
|
1073
|
+
* See StorageConfig for provider selection guidance. */
|
|
1056
1074
|
storage?: StorageConfig;
|
|
1057
1075
|
/**
|
|
1058
1076
|
* Optional subgraph URL for querying user files and permissions.
|
|
1059
1077
|
* If not provided, defaults to the built-in subgraph URL for the current chain.
|
|
1060
1078
|
* Can be overridden per method call if needed.
|
|
1079
|
+
* Obtain chain-specific URLs from Vana documentation or deployment info.
|
|
1061
1080
|
*/
|
|
1062
1081
|
subgraphUrl?: string;
|
|
1063
1082
|
/**
|
|
1064
1083
|
* Optional default IPFS gateways to use for fetching files.
|
|
1065
1084
|
* These gateways will be used by default in fetchFromIPFS unless overridden per-call.
|
|
1066
1085
|
* If not provided, the SDK will use public gateways.
|
|
1086
|
+
* Order matters: first successful gateway is used.
|
|
1067
1087
|
*
|
|
1068
1088
|
* @example ['https://gateway.pinata.cloud', 'https://ipfs.io']
|
|
1069
1089
|
*/
|
|
@@ -1125,11 +1145,17 @@ interface WalletConfigWithStorage extends BaseConfigWithStorage {
|
|
|
1125
1145
|
* @category Configuration
|
|
1126
1146
|
*/
|
|
1127
1147
|
interface ChainConfig extends BaseConfig {
|
|
1128
|
-
/** The chain ID for Vana network
|
|
1148
|
+
/** The chain ID for Vana network.
|
|
1149
|
+
* Supported: 14800 (Vana Mainnet), 14801 (Moksha Testnet), 31337 (Local Development).
|
|
1150
|
+
* Use chain constants from '@vana/sdk' for type safety. */
|
|
1129
1151
|
chainId: VanaChainId;
|
|
1130
|
-
/** RPC URL for the chain (optional, will use default for the chain if not provided)
|
|
1152
|
+
/** RPC URL for the chain (optional, will use default for the chain if not provided).
|
|
1153
|
+
* Default URLs: mainnet (https://rpc.vana.org), testnet (https://rpc.moksha.vana.org).
|
|
1154
|
+
* Override for custom nodes or local development. */
|
|
1131
1155
|
rpcUrl?: string;
|
|
1132
|
-
/** Optional account for signing transactions
|
|
1156
|
+
/** Optional account for signing transactions.
|
|
1157
|
+
* Can be: privateKeyToAccount(), mnemonicToAccount(), or custom Account implementation.
|
|
1158
|
+
* Required for write operations; read-only operations work without account. */
|
|
1133
1159
|
account?: Account;
|
|
1134
1160
|
}
|
|
1135
1161
|
/**
|
|
@@ -1387,7 +1413,8 @@ interface UserFile$1 {
|
|
|
1387
1413
|
ownerAddress: Address;
|
|
1388
1414
|
/** Block number when this file was registered on-chain. */
|
|
1389
1415
|
addedAtBlock: bigint;
|
|
1390
|
-
/** Schema identifier for data validation and structure definition.
|
|
1416
|
+
/** Schema identifier for data validation and structure definition.
|
|
1417
|
+
* Obtain schema IDs from `vana.schemas.list()` or when creating schemas via `vana.schemas.create()`. */
|
|
1391
1418
|
schemaId?: number;
|
|
1392
1419
|
/** Unix timestamp when the file was registered on-chain. */
|
|
1393
1420
|
addedAtTimestamp?: bigint;
|
|
@@ -1483,6 +1510,8 @@ interface UploadParams {
|
|
|
1483
1510
|
encrypt?: boolean;
|
|
1484
1511
|
/** Optional storage provider name. */
|
|
1485
1512
|
providerName?: string;
|
|
1513
|
+
/** Optional owner address (defaults to current wallet address). */
|
|
1514
|
+
owner?: Address;
|
|
1486
1515
|
}
|
|
1487
1516
|
/**
|
|
1488
1517
|
* Upload parameters with encryption enabled (requires EncryptedPermissionParams).
|
|
@@ -1518,15 +1547,16 @@ interface UnencryptedUploadParams extends Omit<UploadParams, "encrypt"> {
|
|
|
1518
1547
|
interface PermissionParams {
|
|
1519
1548
|
/** The address of the application to grant permission to. */
|
|
1520
1549
|
grantee: Address;
|
|
1521
|
-
/** The operation type (e.g., "llm_inference"). */
|
|
1550
|
+
/** The operation type (e.g., "llm_inference", "data_analysis", "compute_task"). */
|
|
1522
1551
|
operation: string;
|
|
1523
|
-
/** Additional parameters for the permission. */
|
|
1552
|
+
/** Additional parameters for the permission (operation-specific configuration). */
|
|
1524
1553
|
parameters: Record<string, unknown>;
|
|
1525
|
-
/** Optional nonce for the permission. */
|
|
1554
|
+
/** Optional nonce for the permission (auto-generated if not provided). */
|
|
1526
1555
|
nonce?: bigint;
|
|
1527
|
-
/** Optional expiration timestamp. */
|
|
1556
|
+
/** Optional expiration timestamp (Unix seconds, no expiration if not provided). */
|
|
1528
1557
|
expiresAt?: number;
|
|
1529
|
-
/** Public key of the recipient to encrypt the data key for (required for upload with permissions).
|
|
1558
|
+
/** Public key of the recipient to encrypt the data key for (required for upload with permissions).
|
|
1559
|
+
* Obtain via `vana.server.getIdentity(recipientAddress).public_key` for personal servers. */
|
|
1530
1560
|
publicKey?: string;
|
|
1531
1561
|
}
|
|
1532
1562
|
/**
|
|
@@ -1594,11 +1624,11 @@ interface UploadFileParams {
|
|
|
1594
1624
|
content: Uint8Array | Buffer | string;
|
|
1595
1625
|
/** Descriptive metadata for file organization and tracking. */
|
|
1596
1626
|
metadata?: FileMetadata;
|
|
1597
|
-
/** Storage provider name or uses configured default if unspecified. */
|
|
1627
|
+
/** Storage provider name ("ipfs" or custom provider, uses configured default if unspecified). */
|
|
1598
1628
|
storageProvider?: string;
|
|
1599
|
-
/** Enables automatic encryption before upload to storage. */
|
|
1629
|
+
/** Enables automatic encryption before upload to storage (defaults to false). */
|
|
1600
1630
|
encrypt?: boolean;
|
|
1601
|
-
/** Custom encryption key
|
|
1631
|
+
/** Custom encryption key (auto-generated if encryption enabled and not provided). */
|
|
1602
1632
|
encryptionKey?: string;
|
|
1603
1633
|
}
|
|
1604
1634
|
/**
|
|
@@ -2681,6 +2711,15 @@ declare class StorageManager {
|
|
|
2681
2711
|
*
|
|
2682
2712
|
* This interface abstracts all environment-specific dependencies to ensure
|
|
2683
2713
|
* the SDK works seamlessly across Node.js and browser/SSR environments.
|
|
2714
|
+
*
|
|
2715
|
+
* **Implementation Context:**
|
|
2716
|
+
* - Node.js: Uses native crypto modules and full OpenPGP support
|
|
2717
|
+
* - Browser: Uses Web Crypto API and browser-compatible libraries
|
|
2718
|
+
* - SSR: Automatically selects appropriate implementation based on runtime
|
|
2719
|
+
*
|
|
2720
|
+
* **Usage Notes:**
|
|
2721
|
+
* Platform adapters are automatically selected by the SDK. Direct usage is only
|
|
2722
|
+
* needed for custom implementations or testing.
|
|
2684
2723
|
*/
|
|
2685
2724
|
/**
|
|
2686
2725
|
* Platform type identifier
|
|
@@ -2693,6 +2732,11 @@ interface VanaCryptoAdapter {
|
|
|
2693
2732
|
/**
|
|
2694
2733
|
* Encrypt data with a public key using asymmetric cryptography
|
|
2695
2734
|
*
|
|
2735
|
+
* **Usage Context:**
|
|
2736
|
+
* - Used internally for file encryption before storage
|
|
2737
|
+
* - Public key format: Armored PGP public key string
|
|
2738
|
+
* - Returns base64-encoded encrypted data
|
|
2739
|
+
*
|
|
2696
2740
|
* @param data The data to encrypt
|
|
2697
2741
|
* @param publicKey The public key for encryption
|
|
2698
2742
|
* @returns Promise resolving to encrypted data
|
|
@@ -2719,6 +2763,11 @@ interface VanaCryptoAdapter {
|
|
|
2719
2763
|
* Encrypt data with a wallet's public key using ECDH cryptography
|
|
2720
2764
|
* Uses platform-appropriate ECDH implementation (eccrypto vs eccrypto-js)
|
|
2721
2765
|
*
|
|
2766
|
+
* **Usage Context:**
|
|
2767
|
+
* - Used for sharing encryption keys with permission recipients
|
|
2768
|
+
* - Public key format: Compressed or uncompressed secp256k1 hex string
|
|
2769
|
+
* - Compatible with Ethereum wallet public keys
|
|
2770
|
+
*
|
|
2722
2771
|
* @param data The data to encrypt (string)
|
|
2723
2772
|
* @param publicKey The wallet's public key (secp256k1)
|
|
2724
2773
|
* @returns Promise resolving to encrypted data as hex string
|
|
@@ -2805,6 +2854,22 @@ interface VanaHttpAdapter {
|
|
|
2805
2854
|
}
|
|
2806
2855
|
/**
|
|
2807
2856
|
* Main platform adapter interface that combines all platform-specific functionality
|
|
2857
|
+
*
|
|
2858
|
+
* **Implementation Guidelines:**
|
|
2859
|
+
* 1. All methods must maintain consistent behavior across platforms
|
|
2860
|
+
* 2. Error types and messages should be unified
|
|
2861
|
+
* 3. Data formats (encoding, serialization) must be identical
|
|
2862
|
+
* 4. Performance characteristics can vary but API must be consistent
|
|
2863
|
+
*
|
|
2864
|
+
* **Custom Implementation Example:**
|
|
2865
|
+
* ```typescript
|
|
2866
|
+
* class CustomPlatformAdapter implements VanaPlatformAdapter {
|
|
2867
|
+
* crypto = new CustomCryptoAdapter();
|
|
2868
|
+
* pgp = new CustomPGPAdapter();
|
|
2869
|
+
* http = new CustomHttpAdapter();
|
|
2870
|
+
* platform = 'browser' as const;
|
|
2871
|
+
* }
|
|
2872
|
+
* ```
|
|
2808
2873
|
*/
|
|
2809
2874
|
interface VanaPlatformAdapter {
|
|
2810
2875
|
/**
|
|
@@ -2868,15 +2933,27 @@ interface ControllerContext$1 {
|
|
|
2868
2933
|
* The controller also manages trusted servers that can process user data and provides
|
|
2869
2934
|
* methods for revoking permissions when access is no longer needed.
|
|
2870
2935
|
*
|
|
2871
|
-
*
|
|
2872
|
-
*
|
|
2873
|
-
*
|
|
2936
|
+
* **Permission Architecture:**
|
|
2937
|
+
* Permissions use dual storage: detailed parameters stored on IPFS, references stored on blockchain.
|
|
2938
|
+
* This enables complex permissions while maintaining minimal on-chain data.
|
|
2939
|
+
*
|
|
2940
|
+
* **Method Selection:**
|
|
2941
|
+
* - `grant()` creates new permissions with automatic IPFS upload and blockchain registration
|
|
2942
|
+
* - `prepareGrant()` allows preview before signing for interactive applications
|
|
2943
|
+
* - `revoke()` removes permissions by ID, supporting both gasless and direct transactions
|
|
2944
|
+
* - `getUserPermissionGrantsOnChain()` queries existing permissions efficiently
|
|
2945
|
+
* - `trustServer()` and `untrustServer()` manage server access for data processing
|
|
2946
|
+
*
|
|
2947
|
+
* **Transaction Types:**
|
|
2948
|
+
* Methods with gasless support: `grant()`, `revoke()`, `trustServer()`, `untrustServer()`
|
|
2949
|
+
* Methods requiring direct transactions: none (all support both gasless and direct)
|
|
2874
2950
|
* @example
|
|
2875
2951
|
* ```typescript
|
|
2876
2952
|
* // Grant permission for an app to access your data
|
|
2877
2953
|
* const txHash = await vana.permissions.grant({
|
|
2878
2954
|
* grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
2879
2955
|
* operation: "llm_inference",
|
|
2956
|
+
* files: [1, 2, 3],
|
|
2880
2957
|
* parameters: { model: "gpt-4", maxTokens: 1000 },
|
|
2881
2958
|
* });
|
|
2882
2959
|
*
|
|
@@ -2887,7 +2964,7 @@ interface ControllerContext$1 {
|
|
|
2887
2964
|
* });
|
|
2888
2965
|
*
|
|
2889
2966
|
* // Query current permissions
|
|
2890
|
-
* const permissions = await vana.permissions.
|
|
2967
|
+
* const permissions = await vana.permissions.getUserPermissionGrantsOnChain();
|
|
2891
2968
|
* ```
|
|
2892
2969
|
* @category Permissions
|
|
2893
2970
|
* @see {@link [URL_PLACEHOLDER] | Vana Permissions System} for conceptual overview
|
|
@@ -3055,6 +3132,8 @@ declare class PermissionsController {
|
|
|
3055
3132
|
* Revokes a previously granted permission.
|
|
3056
3133
|
*
|
|
3057
3134
|
* @param params - Parameters for revoking the permission
|
|
3135
|
+
* @param params.permissionId - Permission identifier as bigint for contract compatibility.
|
|
3136
|
+
* Obtain from permission grants via `getUserPermissionGrantsOnChain()`.
|
|
3058
3137
|
* @returns Promise resolving to transaction hash
|
|
3059
3138
|
* @example
|
|
3060
3139
|
* ```typescript
|
|
@@ -3093,6 +3172,7 @@ declare class PermissionsController {
|
|
|
3093
3172
|
* @param params.grantUrl - URL where the grant details are stored
|
|
3094
3173
|
* @param params.serializedParameters - Serialized parameters for the operation
|
|
3095
3174
|
* @param params.nonce - Unique number to prevent replay attacks
|
|
3175
|
+
* @param params.granteeId - The ID of the grantee from the registry
|
|
3096
3176
|
* @returns Promise resolving to the typed data structure
|
|
3097
3177
|
*/
|
|
3098
3178
|
private composePermissionGrantMessage;
|
|
@@ -3364,9 +3444,20 @@ interface CreateSchemaResult {
|
|
|
3364
3444
|
* validation, IPFS upload, and blockchain registration. It provides methods for managing
|
|
3365
3445
|
* both schemas (data structure definitions) and refiners (data processing definitions).
|
|
3366
3446
|
*
|
|
3367
|
-
*
|
|
3368
|
-
*
|
|
3369
|
-
*
|
|
3447
|
+
* **Schema Storage:**
|
|
3448
|
+
* Schemas are stored unencrypted on IPFS for public access and reusability across the network.
|
|
3449
|
+
* Schema definitions use JSON Schema format for data validation and structure definition.
|
|
3450
|
+
*
|
|
3451
|
+
* **Method Selection:**
|
|
3452
|
+
* - `create()` validates, uploads to IPFS, and registers new schemas on blockchain
|
|
3453
|
+
* - `get()` retrieves existing schema metadata by ID from blockchain contracts
|
|
3454
|
+
* - `count()` returns total number of registered schemas for pagination
|
|
3455
|
+
* - `list()` provides paginated access to all schemas with optional filtering
|
|
3456
|
+
* - `addSchema()` provides lower-level schema registration with pre-uploaded URLs
|
|
3457
|
+
*
|
|
3458
|
+
* **Storage Requirements:**
|
|
3459
|
+
* Methods requiring storage configuration: `create()`
|
|
3460
|
+
* Methods working without storage: `get()`, `count()`, `list()`, `addSchema()`
|
|
3370
3461
|
*
|
|
3371
3462
|
* @example
|
|
3372
3463
|
* ```typescript
|
|
@@ -5408,6 +5499,12 @@ interface GrantPermissionParams {
|
|
|
5408
5499
|
parameters: Record<string, unknown>;
|
|
5409
5500
|
/** Optional pre-stored grant URL to avoid duplicate IPFS storage */
|
|
5410
5501
|
grantUrl?: string;
|
|
5502
|
+
/** Optional nonce for the permission */
|
|
5503
|
+
nonce?: bigint;
|
|
5504
|
+
/** Optional expiration time for the permission */
|
|
5505
|
+
expiresAt?: number;
|
|
5506
|
+
/** Optional grantee ID to use instead of resolving from address */
|
|
5507
|
+
granteeId?: number;
|
|
5411
5508
|
}
|
|
5412
5509
|
|
|
5413
5510
|
/**
|
|
@@ -5424,13 +5521,23 @@ interface GrantPermissionParams {
|
|
|
5424
5521
|
* and supports both gasless transactions via relayers and direct blockchain interaction.
|
|
5425
5522
|
* File metadata and access permissions are stored on the Vana blockchain while encrypted
|
|
5426
5523
|
* file content is stored on decentralized storage networks.
|
|
5524
|
+
*
|
|
5525
|
+
* **Method Selection:**
|
|
5526
|
+
* - `upload()` handles encryption, storage, and blockchain registration automatically
|
|
5527
|
+
* - `getUserFiles()` queries existing file metadata from blockchain and subgraph
|
|
5528
|
+
* - `decryptFile()` decrypts files for which you have access permissions
|
|
5529
|
+
* - `getFileById()` retrieves specific file metadata when you have the file ID
|
|
5530
|
+
*
|
|
5531
|
+
* **Storage Requirements:**
|
|
5532
|
+
* Methods requiring storage configuration: `upload()`
|
|
5533
|
+
* Methods working without storage: `getUserFiles()`, `decryptFile()`, `getFileById()`
|
|
5427
5534
|
* @example
|
|
5428
5535
|
* ```typescript
|
|
5429
5536
|
* // Upload an encrypted file with automatic schema validation
|
|
5430
|
-
* const result = await vana.data.
|
|
5431
|
-
*
|
|
5432
|
-
* "personal-data.json"
|
|
5433
|
-
* );
|
|
5537
|
+
* const result = await vana.data.upload({
|
|
5538
|
+
* content: "My personal data",
|
|
5539
|
+
* filename: "personal-data.json"
|
|
5540
|
+
* });
|
|
5434
5541
|
*
|
|
5435
5542
|
* // Query files owned by a user
|
|
5436
5543
|
* const files = await vana.data.getUserFiles({
|
|
@@ -5466,10 +5573,16 @@ declare class DataController {
|
|
|
5466
5573
|
* for each permission recipient.
|
|
5467
5574
|
*
|
|
5468
5575
|
* @param params - Upload parameters including content, filename, schema, and permissions
|
|
5576
|
+
* @param params.permissions.publicKey - The recipient's public key for encryption.
|
|
5577
|
+
* Obtain via `vana.server.getIdentity(userAddress).public_key` for personal servers.
|
|
5578
|
+
* @param params.permissions.grantee - The application's wallet address that will access the data.
|
|
5469
5579
|
* @returns Promise resolving to upload results with file ID and transaction hash
|
|
5470
|
-
* @throws {Error} When wallet is not connected or storage is not configured
|
|
5471
|
-
*
|
|
5472
|
-
* @throws {
|
|
5580
|
+
* @throws {Error} When wallet is not connected or storage is not configured.
|
|
5581
|
+
* Configure storage providers in VanaConfig or check wallet connection.
|
|
5582
|
+
* @throws {SchemaValidationError} When data format doesn't match the specified schema.
|
|
5583
|
+
* Verify data structure matches schema definition from `vana.schemas.get(schemaId)`.
|
|
5584
|
+
* @throws {Error} When upload or blockchain registration fails.
|
|
5585
|
+
* Check network connection and storage provider availability.
|
|
5473
5586
|
* @example
|
|
5474
5587
|
* ```typescript
|
|
5475
5588
|
* // Basic file upload
|
|
@@ -5493,7 +5606,7 @@ declare class DataController {
|
|
|
5493
5606
|
* grantee: "0x1234...",
|
|
5494
5607
|
* operation: "llm_inference",
|
|
5495
5608
|
* parameters: { model: "gpt-4" },
|
|
5496
|
-
* publicKey: "0x04..." //
|
|
5609
|
+
* publicKey: "0x04..." // Obtain via vana.server.getIdentity(userAddress).public_key
|
|
5497
5610
|
* }]
|
|
5498
5611
|
* });
|
|
5499
5612
|
*
|
|
@@ -5508,6 +5621,19 @@ declare class DataController {
|
|
|
5508
5621
|
* parameters: {}
|
|
5509
5622
|
* }]
|
|
5510
5623
|
* });
|
|
5624
|
+
*
|
|
5625
|
+
* // Upload on behalf of another user (delegation)
|
|
5626
|
+
* const result = await vana.data.upload({
|
|
5627
|
+
* content: "User's data",
|
|
5628
|
+
* filename: "delegated.txt",
|
|
5629
|
+
* owner: "0x5678...", // Different from connected wallet
|
|
5630
|
+
* permissions: [{
|
|
5631
|
+
* grantee: "0x1234...",
|
|
5632
|
+
* operation: "process",
|
|
5633
|
+
* parameters: { type: "analysis" },
|
|
5634
|
+
* publicKey: "0x04..."
|
|
5635
|
+
* }]
|
|
5636
|
+
* });
|
|
5511
5637
|
* ```
|
|
5512
5638
|
*/
|
|
5513
5639
|
upload(params: EncryptedUploadParams): Promise<UploadResult>;
|
|
@@ -6087,23 +6213,33 @@ declare class DataController {
|
|
|
6087
6213
|
* cryptographic keys for secure data sharing. All server interactions use the
|
|
6088
6214
|
* Replicate API infrastructure with proper authentication and error handling.
|
|
6089
6215
|
*
|
|
6090
|
-
*
|
|
6091
|
-
* servers
|
|
6092
|
-
* requiring servers to be online during key retrieval.
|
|
6216
|
+
* **Server Identity System:**
|
|
6217
|
+
* Personal servers use deterministic key derivation: each user address maps to a specific server identity.
|
|
6218
|
+
* This enables secure communication without requiring servers to be online during key retrieval.
|
|
6219
|
+
*
|
|
6220
|
+
* **Method Selection:**
|
|
6221
|
+
* - `getIdentity()` retrieves server public keys and addresses for encryption setup
|
|
6222
|
+
* - `createOperation()` submits computation requests with signed permission verification
|
|
6223
|
+
* - `getOperation()` polls operation status and retrieves results when complete
|
|
6224
|
+
* - `cancelOperation()` stops running operations when cancellation is supported
|
|
6225
|
+
*
|
|
6226
|
+
* **Workflow Pattern:**
|
|
6227
|
+
* Typical flow: Get identity → Create operation → Poll status → Retrieve results
|
|
6228
|
+
*
|
|
6093
6229
|
* @example
|
|
6094
6230
|
* ```typescript
|
|
6095
|
-
* //
|
|
6096
|
-
* const
|
|
6097
|
-
*
|
|
6231
|
+
* // Get a server's identity including public key for encryption
|
|
6232
|
+
* const identity = await vana.server.getIdentity({
|
|
6233
|
+
* userAddress: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
6098
6234
|
* });
|
|
6099
6235
|
*
|
|
6100
|
-
* //
|
|
6101
|
-
* const
|
|
6102
|
-
*
|
|
6103
|
-
* );
|
|
6236
|
+
* // Create an operation using a granted permission
|
|
6237
|
+
* const response = await vana.server.createOperation({
|
|
6238
|
+
* permissionId: 123,
|
|
6239
|
+
* });
|
|
6104
6240
|
*
|
|
6105
6241
|
* // Poll for computation results
|
|
6106
|
-
* const result = await vana.server.
|
|
6242
|
+
* const result = await vana.server.getOperation(response.id);
|
|
6107
6243
|
* ```
|
|
6108
6244
|
* @category Server Management
|
|
6109
6245
|
* @see {@link [URL_PLACEHOLDER] | Vana Personal Servers} for conceptual overview
|
|
@@ -6112,6 +6248,39 @@ declare class ServerController {
|
|
|
6112
6248
|
private readonly context;
|
|
6113
6249
|
readonly PERSONAL_SERVER_BASE_URL: string | undefined;
|
|
6114
6250
|
constructor(context: ControllerContext$1);
|
|
6251
|
+
/**
|
|
6252
|
+
* Retrieves the cryptographic identity of a personal server.
|
|
6253
|
+
*
|
|
6254
|
+
* @remarks
|
|
6255
|
+
* This method fetches the public key and metadata for a personal server,
|
|
6256
|
+
* which is required for encrypting data before sharing with the server.
|
|
6257
|
+
* The identity includes the server's public key, address, and operational
|
|
6258
|
+
* details needed for secure communication. This information is cached
|
|
6259
|
+
* by identity servers to enable offline key retrieval.
|
|
6260
|
+
*
|
|
6261
|
+
* @param request - Parameters containing the user address
|
|
6262
|
+
* @param request.userAddress - The wallet address associated with the personal server
|
|
6263
|
+
* @returns Promise resolving to the server's identity information
|
|
6264
|
+
* @throws {NetworkError} When the identity service is unavailable or returns invalid data
|
|
6265
|
+
* @throws {PersonalServerError} When server identity cannot be retrieved
|
|
6266
|
+
* @example
|
|
6267
|
+
* ```typescript
|
|
6268
|
+
* // Get server identity for data encryption
|
|
6269
|
+
* const identity = await vana.server.getIdentity({
|
|
6270
|
+
* userAddress: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
6271
|
+
* });
|
|
6272
|
+
*
|
|
6273
|
+
* console.log(`Server: ${identity.name}`);
|
|
6274
|
+
* console.log(`Address: ${identity.address}`);
|
|
6275
|
+
* console.log(`Public Key: ${identity.public_key}`);
|
|
6276
|
+
*
|
|
6277
|
+
* // Use the public key for encrypting data to share with this server
|
|
6278
|
+
* const encryptedData = await encryptWithWalletPublicKey(
|
|
6279
|
+
* userData,
|
|
6280
|
+
* identity.public_key
|
|
6281
|
+
* );
|
|
6282
|
+
* ```
|
|
6283
|
+
*/
|
|
6115
6284
|
getIdentity(request: InitPersonalServerParams): Promise<PersonalServerIdentity>;
|
|
6116
6285
|
/**
|
|
6117
6286
|
* Creates an operation via the personal server API.
|
|
@@ -6120,10 +6289,13 @@ declare class ServerController {
|
|
|
6120
6289
|
* This method submits a computation request to the personal server API.
|
|
6121
6290
|
* The response includes the operation ID.
|
|
6122
6291
|
* @param params - The request parameters object
|
|
6123
|
-
* @param params.permissionId - The permission ID authorizing this operation
|
|
6292
|
+
* @param params.permissionId - The permission ID authorizing this operation.
|
|
6293
|
+
* Obtain from granted permissions via `vana.permissions.getUserPermissionGrantsOnChain()`.
|
|
6124
6294
|
* @returns A Promise that resolves to an operation response with status and control URLs
|
|
6125
|
-
* @throws {PersonalServerError} When server request fails or parameters are invalid
|
|
6126
|
-
*
|
|
6295
|
+
* @throws {PersonalServerError} When server request fails or parameters are invalid.
|
|
6296
|
+
* Verify permissionId exists and is active for the target server.
|
|
6297
|
+
* @throws {NetworkError} When personal server API communication fails.
|
|
6298
|
+
* Check server URL configuration and network connectivity.
|
|
6127
6299
|
* @example
|
|
6128
6300
|
* ```typescript
|
|
6129
6301
|
* const response = await vana.server.createOperation({
|
|
@@ -6163,6 +6335,50 @@ declare class ServerController {
|
|
|
6163
6335
|
* ```
|
|
6164
6336
|
*/
|
|
6165
6337
|
getOperation(operationId: string): Promise<GetOperationResponse>;
|
|
6338
|
+
/**
|
|
6339
|
+
* Cancels a running operation on the personal server.
|
|
6340
|
+
*
|
|
6341
|
+
* @remarks
|
|
6342
|
+
* This method attempts to cancel an operation that is currently processing
|
|
6343
|
+
* on the personal server. The operation must be in a cancellable state
|
|
6344
|
+
* (typically `starting` or `processing`). Not all operations support
|
|
6345
|
+
* cancellation, and cancellation may not be immediate. The server will
|
|
6346
|
+
* attempt to stop the operation and update its status to `canceled`.
|
|
6347
|
+
*
|
|
6348
|
+
* **Cancellation Behavior:**
|
|
6349
|
+
* - Operations in `succeeded` or `failed` states cannot be canceled
|
|
6350
|
+
* - Some long-running operations may take time to respond to cancellation
|
|
6351
|
+
* - Always verify cancellation by polling the operation status afterward
|
|
6352
|
+
*
|
|
6353
|
+
* @param operationId - The unique identifier of the operation to cancel,
|
|
6354
|
+
* obtained from `createOperation()` response
|
|
6355
|
+
* @returns Promise that resolves when the cancellation request is accepted
|
|
6356
|
+
* @throws {PersonalServerError} When the operation cannot be canceled or doesn't exist.
|
|
6357
|
+
* Check operation status - it may already be completed or failed.
|
|
6358
|
+
* @throws {NetworkError} When unable to reach the personal server API.
|
|
6359
|
+
* Verify server URL and network connectivity.
|
|
6360
|
+
* @example
|
|
6361
|
+
* ```typescript
|
|
6362
|
+
* // Start a long-running operation
|
|
6363
|
+
* const operation = await vana.server.createOperation({
|
|
6364
|
+
* permissionId: 123
|
|
6365
|
+
* });
|
|
6366
|
+
*
|
|
6367
|
+
* // Cancel if needed
|
|
6368
|
+
* try {
|
|
6369
|
+
* await vana.server.cancelOperation(operation.id);
|
|
6370
|
+
* console.log("Cancellation requested");
|
|
6371
|
+
*
|
|
6372
|
+
* // Verify cancellation
|
|
6373
|
+
* const status = await vana.server.getOperation(operation.id);
|
|
6374
|
+
* if (status.status === "canceled") {
|
|
6375
|
+
* console.log("Operation successfully canceled");
|
|
6376
|
+
* }
|
|
6377
|
+
* } catch (error) {
|
|
6378
|
+
* console.error("Failed to cancel:", error);
|
|
6379
|
+
* }
|
|
6380
|
+
* ```
|
|
6381
|
+
*/
|
|
6166
6382
|
cancelOperation(operationId: string): Promise<void>;
|
|
6167
6383
|
/**
|
|
6168
6384
|
* Makes the request to the personal server API.
|
|
@@ -31058,19 +31274,26 @@ declare function clearContractCache(contract?: VanaContract, chainId?: number):
|
|
|
31058
31274
|
* Most developers should use the higher-level DataController and PermissionsController
|
|
31059
31275
|
* instead of this advanced API.
|
|
31060
31276
|
*
|
|
31277
|
+
* **Contract Selection:**
|
|
31061
31278
|
* The controller automatically handles chain detection and provides only contracts that
|
|
31062
31279
|
* are deployed on the current network. All contract instances are fully typed for
|
|
31063
31280
|
* enhanced developer experience and type safety.
|
|
31064
31281
|
*
|
|
31065
|
-
* **
|
|
31066
|
-
* -
|
|
31067
|
-
* -
|
|
31068
|
-
* -
|
|
31069
|
-
* -
|
|
31282
|
+
* **Method Selection:**
|
|
31283
|
+
* - `getContract()` retrieves contract address and ABI for manual interaction
|
|
31284
|
+
* - `createContract()` returns fully typed contract instance with read/write methods
|
|
31285
|
+
* - `getAvailableContracts()` lists all contracts deployed on current chain
|
|
31286
|
+
* - `isContractAvailable()` checks if specific contract exists on current chain
|
|
31287
|
+
* - `getChainId()` and `getChainName()` provide current network information
|
|
31288
|
+
*
|
|
31289
|
+
* **Usage Guidelines:**
|
|
31290
|
+
* Use this controller when high-level controllers don't provide needed functionality.
|
|
31291
|
+
* Most developers should use `vana.data.*` for files and `vana.permissions.*` for access control.
|
|
31292
|
+
*
|
|
31293
|
+
* **Type Safety:**
|
|
31294
|
+
* Use `as const` assertion with contract names for full TypeScript type inference.
|
|
31295
|
+
* Contract instances provide complete typing for all methods, parameters, and return values.
|
|
31070
31296
|
*
|
|
31071
|
-
* **Most developers should use instead:**
|
|
31072
|
-
* - `vana.data.*` for file management operations
|
|
31073
|
-
* - `vana.permissions.*` for access control workflows
|
|
31074
31297
|
* @example
|
|
31075
31298
|
* ```typescript
|
|
31076
31299
|
* // Get contract info for direct interaction
|
|
@@ -31101,7 +31324,8 @@ declare class ProtocolController {
|
|
|
31101
31324
|
* are actually deployed on the current network.
|
|
31102
31325
|
* @param contractName - The name of the Vana contract to retrieve (use const assertion for full typing)
|
|
31103
31326
|
* @returns An object containing the contract's address and fully typed ABI
|
|
31104
|
-
* @throws {ContractNotFoundError} When the contract is not deployed on the current chain
|
|
31327
|
+
* @throws {ContractNotFoundError} When the contract is not deployed on the current chain.
|
|
31328
|
+
* Verify contract name spelling and check current network with `getChainId()`.
|
|
31105
31329
|
* @example
|
|
31106
31330
|
* ```typescript
|
|
31107
31331
|
* // Get contract info with full type inference
|
|
@@ -31218,19 +31442,43 @@ declare class VanaCoreFactory {
|
|
|
31218
31442
|
* @remarks
|
|
31219
31443
|
* This environment-agnostic class contains all SDK logic and accepts a platform
|
|
31220
31444
|
* adapter to handle environment-specific operations. It initializes all controllers
|
|
31221
|
-
* and manages shared context between them
|
|
31445
|
+
* and manages shared context between them, providing a unified interface for
|
|
31446
|
+
* data management, permissions, smart contracts, and storage operations.
|
|
31222
31447
|
*
|
|
31223
31448
|
* The class uses TypeScript overloading to enforce storage requirements at compile time.
|
|
31224
|
-
*
|
|
31449
|
+
* Methods that require storage will throw `InvalidConfigurationError` at runtime if
|
|
31450
|
+
* storage providers are not configured, implementing a fail-fast approach to prevent
|
|
31451
|
+
* errors during expensive operations.
|
|
31452
|
+
*
|
|
31453
|
+
* **Core Architecture:**
|
|
31454
|
+
* - **Controllers**: Specialized modules for different Vana features (data, permissions, etc.)
|
|
31455
|
+
* - **Platform Adapters**: Environment-specific implementations (browser vs Node.js)
|
|
31456
|
+
* - **Storage Managers**: Abstraction layer for multiple storage providers
|
|
31457
|
+
* - **Context Sharing**: Unified configuration and services across all controllers
|
|
31458
|
+
*
|
|
31459
|
+
* For public usage, use the platform-specific factory functions:
|
|
31460
|
+
* - Browser: `import { Vana } from '@opendatalabs/vana-sdk/browser'`
|
|
31461
|
+
* - Node.js: `import { Vana } from '@opendatalabs/vana-sdk/node'`
|
|
31225
31462
|
*
|
|
31226
|
-
* For public usage, use the platform-specific Vana classes that extend this core:
|
|
31227
|
-
* - Use `Vana({config)` from the main package import
|
|
31228
31463
|
* @example
|
|
31229
31464
|
* ```typescript
|
|
31230
|
-
* // Direct instantiation (
|
|
31231
|
-
*
|
|
31465
|
+
* // Direct instantiation (advanced usage)
|
|
31466
|
+
* import { VanaCore, BrowserPlatformAdapter } from '@opendatalabs/vana-sdk/browser';
|
|
31467
|
+
*
|
|
31468
|
+
* const core = new VanaCore(new BrowserPlatformAdapter(), {
|
|
31232
31469
|
* walletClient: myWalletClient,
|
|
31233
|
-
*
|
|
31470
|
+
* storage: {
|
|
31471
|
+
* providers: { ipfs: new IPFSStorage() },
|
|
31472
|
+
* defaultProvider: 'ipfs'
|
|
31473
|
+
* }
|
|
31474
|
+
* });
|
|
31475
|
+
*
|
|
31476
|
+
* // Access all controllers
|
|
31477
|
+
* const files = await core.data.getUserFiles();
|
|
31478
|
+
* const permissions = await core.permissions.grant({
|
|
31479
|
+
* grantee: '0x742d35...',
|
|
31480
|
+
* operation: 'read'
|
|
31481
|
+
* });
|
|
31234
31482
|
* ```
|
|
31235
31483
|
* @category Core SDK
|
|
31236
31484
|
*/
|
|
@@ -31403,30 +31651,86 @@ declare class VanaCore {
|
|
|
31403
31651
|
getPlatformAdapter(): VanaPlatformAdapter;
|
|
31404
31652
|
/**
|
|
31405
31653
|
* Encrypts data using the Vana protocol standard encryption.
|
|
31406
|
-
* This method automatically uses the correct platform adapter for the current environment.
|
|
31407
31654
|
*
|
|
31408
|
-
* @
|
|
31409
|
-
*
|
|
31410
|
-
*
|
|
31655
|
+
* @remarks
|
|
31656
|
+
* This method implements the Vana network's standard encryption protocol using
|
|
31657
|
+
* platform-appropriate cryptographic libraries. It automatically handles different
|
|
31658
|
+
* input types (string or Blob) and produces encrypted output suitable for secure
|
|
31659
|
+
* storage or transmission. The encryption is compatible with the network's
|
|
31660
|
+
* decryption protocols and can be decrypted by authorized parties.
|
|
31661
|
+
*
|
|
31662
|
+
* @param data - The data to encrypt (string or Blob)
|
|
31663
|
+
* @param key - The encryption key (typically generated via `generateEncryptionKey`)
|
|
31664
|
+
* @returns The encrypted data as a Blob
|
|
31665
|
+
* @throws {Error} When encryption fails due to invalid key or data format
|
|
31411
31666
|
* @example
|
|
31412
31667
|
* ```typescript
|
|
31413
|
-
*
|
|
31414
|
-
*
|
|
31668
|
+
* import { generateEncryptionKey } from '@opendatalabs/vana-sdk/node';
|
|
31669
|
+
*
|
|
31670
|
+
* // Generate encryption key from wallet signature
|
|
31671
|
+
* const encryptionKey = await generateEncryptionKey(vana.walletClient);
|
|
31672
|
+
*
|
|
31673
|
+
* // Encrypt string data
|
|
31674
|
+
* const sensitiveData = "User's private information";
|
|
31675
|
+
* const encrypted = await vana.encryptBlob(sensitiveData, encryptionKey);
|
|
31676
|
+
*
|
|
31677
|
+
* // Encrypt file data
|
|
31678
|
+
* const fileBlob = new Blob([fileContent], { type: 'application/json' });
|
|
31679
|
+
* const encryptedFile = await vana.encryptBlob(fileBlob, encryptionKey);
|
|
31680
|
+
*
|
|
31681
|
+
* // Store encrypted data safely
|
|
31682
|
+
* await storageProvider.upload(encrypted, 'encrypted-data.bin');
|
|
31415
31683
|
* ```
|
|
31416
31684
|
*/
|
|
31417
31685
|
encryptBlob(data: string | Blob, key: string): Promise<Blob>;
|
|
31418
31686
|
/**
|
|
31419
31687
|
* Decrypts data that was encrypted using the Vana protocol.
|
|
31420
|
-
* This method automatically uses the correct platform adapter for the current environment.
|
|
31421
31688
|
*
|
|
31422
|
-
* @
|
|
31423
|
-
*
|
|
31424
|
-
*
|
|
31689
|
+
* @remarks
|
|
31690
|
+
* This method decrypts data that was previously encrypted using the Vana network's
|
|
31691
|
+
* standard encryption protocol. It requires the same wallet signature that was used
|
|
31692
|
+
* for encryption and automatically uses the appropriate platform adapter for
|
|
31693
|
+
* cryptographic operations. The decrypted output maintains the original data format.
|
|
31694
|
+
*
|
|
31695
|
+
* @param encryptedData - The encrypted data (string or Blob)
|
|
31696
|
+
* @param walletSignature - The wallet signature used as decryption key
|
|
31697
|
+
* @returns The decrypted data as a Blob
|
|
31698
|
+
* @throws {Error} When decryption fails due to invalid signature or corrupted data
|
|
31425
31699
|
* @example
|
|
31426
31700
|
* ```typescript
|
|
31427
|
-
*
|
|
31428
|
-
*
|
|
31429
|
-
*
|
|
31701
|
+
* import { generateEncryptionKey } from '@opendatalabs/vana-sdk/node';
|
|
31702
|
+
*
|
|
31703
|
+
* // Retrieve encrypted data from storage
|
|
31704
|
+
* const encryptedBlob = await storageProvider.download('encrypted-data.bin');
|
|
31705
|
+
*
|
|
31706
|
+
* // Generate the same key used for encryption
|
|
31707
|
+
* const decryptionKey = await generateEncryptionKey(vana.walletClient);
|
|
31708
|
+
*
|
|
31709
|
+
* // Decrypt the data
|
|
31710
|
+
* const decrypted = await vana.decryptBlob(encryptedBlob, decryptionKey);
|
|
31711
|
+
*
|
|
31712
|
+
* // Convert back to original format
|
|
31713
|
+
* const originalText = await decrypted.text();
|
|
31714
|
+
* const originalJson = JSON.parse(originalText);
|
|
31715
|
+
*
|
|
31716
|
+
* console.log('Decrypted data:', originalJson);
|
|
31717
|
+
* ```
|
|
31718
|
+
*
|
|
31719
|
+
* @example
|
|
31720
|
+
* ```typescript
|
|
31721
|
+
* // Decrypt file downloaded from Vana network
|
|
31722
|
+
* const userFiles = await vana.data.getUserFiles();
|
|
31723
|
+
* const file = userFiles[0];
|
|
31724
|
+
*
|
|
31725
|
+
* // Download encrypted content
|
|
31726
|
+
* const encrypted = await fetch(file.url).then(r => r.blob());
|
|
31727
|
+
*
|
|
31728
|
+
* // Decrypt with user's key
|
|
31729
|
+
* const decryptionKey = await generateEncryptionKey(vana.walletClient);
|
|
31730
|
+
* const decrypted = await vana.decryptBlob(encrypted, decryptionKey);
|
|
31731
|
+
*
|
|
31732
|
+
* // Process original data
|
|
31733
|
+
* const fileContent = await decrypted.arrayBuffer();
|
|
31430
31734
|
* ```
|
|
31431
31735
|
*/
|
|
31432
31736
|
decryptBlob(encryptedData: string | Blob, walletSignature: string): Promise<Blob>;
|
|
@@ -31474,7 +31778,32 @@ declare class UserRejectedRequestError extends VanaError {
|
|
|
31474
31778
|
constructor(message?: string);
|
|
31475
31779
|
}
|
|
31476
31780
|
/**
|
|
31477
|
-
*
|
|
31781
|
+
* Thrown when the SDK configuration contains invalid or missing parameters.
|
|
31782
|
+
*
|
|
31783
|
+
* @remarks
|
|
31784
|
+
* This error occurs during SDK initialization when required configuration
|
|
31785
|
+
* parameters are missing, invalid, or incompatible. Common causes include
|
|
31786
|
+
* missing wallet clients, invalid chain IDs, malformed storage provider
|
|
31787
|
+
* configurations, or incompatible parameter combinations.
|
|
31788
|
+
*
|
|
31789
|
+
* Applications should catch this error during initialization and provide
|
|
31790
|
+
* clear feedback to users about configuration requirements.
|
|
31791
|
+
*
|
|
31792
|
+
* @example
|
|
31793
|
+
* ```typescript
|
|
31794
|
+
* try {
|
|
31795
|
+
* const vana = Vana({
|
|
31796
|
+
* chainId: 999999, // Invalid chain ID
|
|
31797
|
+
* account: null // Missing account
|
|
31798
|
+
* });
|
|
31799
|
+
* } catch (error) {
|
|
31800
|
+
* if (error instanceof InvalidConfigurationError) {
|
|
31801
|
+
* console.error('Configuration error:', error.message);
|
|
31802
|
+
* // Show user-friendly configuration help
|
|
31803
|
+
* }
|
|
31804
|
+
* }
|
|
31805
|
+
* ```
|
|
31806
|
+
* @category Error Handling
|
|
31478
31807
|
*/
|
|
31479
31808
|
declare class InvalidConfigurationError extends VanaError {
|
|
31480
31809
|
constructor(message: string);
|
|
@@ -31492,20 +31821,92 @@ declare class ContractNotFoundError extends VanaError {
|
|
|
31492
31821
|
constructor(contractName: string, chainId: number);
|
|
31493
31822
|
}
|
|
31494
31823
|
/**
|
|
31495
|
-
*
|
|
31824
|
+
* Thrown when blockchain operations fail due to network, contract, or transaction issues.
|
|
31825
|
+
*
|
|
31826
|
+
* @remarks
|
|
31827
|
+
* This error encompasses various blockchain-related failures including network
|
|
31828
|
+
* connectivity issues, contract execution failures, insufficient gas, invalid
|
|
31829
|
+
* transaction parameters, or smart contract reverts. The original error is
|
|
31830
|
+
* preserved to provide detailed debugging information while maintaining a
|
|
31831
|
+
* consistent SDK error interface.
|
|
31832
|
+
*
|
|
31833
|
+
* Common causes:
|
|
31834
|
+
* - Network connectivity problems
|
|
31835
|
+
* - Insufficient gas or gas price too low
|
|
31836
|
+
* - Contract function reverts
|
|
31837
|
+
* - Invalid transaction parameters
|
|
31838
|
+
* - Blockchain congestion or downtime
|
|
31839
|
+
*
|
|
31840
|
+
* @example
|
|
31841
|
+
* ```typescript
|
|
31842
|
+
* try {
|
|
31843
|
+
* await vana.permissions.grant({
|
|
31844
|
+
* grantee: '0x742d35...',
|
|
31845
|
+
* operation: 'read'
|
|
31846
|
+
* });
|
|
31847
|
+
* } catch (error) {
|
|
31848
|
+
* if (error instanceof BlockchainError) {
|
|
31849
|
+
* console.error('Blockchain operation failed:', error.message);
|
|
31850
|
+
*
|
|
31851
|
+
* // Check if it's a network issue
|
|
31852
|
+
* if (error.originalError?.message.includes('network')) {
|
|
31853
|
+
* // Retry with exponential backoff
|
|
31854
|
+
* await retryOperation();
|
|
31855
|
+
* }
|
|
31856
|
+
* }
|
|
31857
|
+
* }
|
|
31858
|
+
* ```
|
|
31859
|
+
* @category Error Handling
|
|
31496
31860
|
*/
|
|
31497
31861
|
declare class BlockchainError extends VanaError {
|
|
31498
31862
|
readonly originalError?: Error | undefined;
|
|
31499
31863
|
constructor(message: string, originalError?: Error | undefined);
|
|
31500
31864
|
}
|
|
31501
31865
|
/**
|
|
31502
|
-
*
|
|
31866
|
+
* Thrown when data serialization or deserialization operations fail.
|
|
31867
|
+
*
|
|
31868
|
+
* @remarks
|
|
31869
|
+
* This error occurs when the SDK cannot properly serialize parameters for
|
|
31870
|
+
* blockchain transactions, IPFS storage, or API calls. Common causes include
|
|
31871
|
+
* circular references in objects, unsupported data types, or malformed JSON.
|
|
31872
|
+
* It's typically encountered during grant file creation, storage operations,
|
|
31873
|
+
* or when preparing transaction data.
|
|
31874
|
+
*
|
|
31875
|
+
* @example
|
|
31876
|
+
* ```typescript
|
|
31877
|
+
* try {
|
|
31878
|
+
* // Object with circular reference causes serialization error
|
|
31879
|
+
* const obj = { name: 'test' };
|
|
31880
|
+
* obj.self = obj; // Circular reference
|
|
31881
|
+
*
|
|
31882
|
+
* await vana.data.upload({
|
|
31883
|
+
* content: obj,
|
|
31884
|
+
* filename: 'data.json'
|
|
31885
|
+
* });
|
|
31886
|
+
* } catch (error) {
|
|
31887
|
+
* if (error instanceof SerializationError) {
|
|
31888
|
+
* console.error('Data serialization failed:', error.message);
|
|
31889
|
+
* // Clean data before retry
|
|
31890
|
+
* const cleanedData = removeCircularReferences(obj);
|
|
31891
|
+
* await vana.data.upload({
|
|
31892
|
+
* content: cleanedData,
|
|
31893
|
+
* filename: 'data.json'
|
|
31894
|
+
* });
|
|
31895
|
+
* }
|
|
31896
|
+
* }
|
|
31897
|
+
* ```
|
|
31898
|
+
* @category Error Handling
|
|
31503
31899
|
*/
|
|
31504
31900
|
declare class SerializationError extends VanaError {
|
|
31505
31901
|
constructor(message: string);
|
|
31506
31902
|
}
|
|
31507
31903
|
/**
|
|
31508
31904
|
* Error thrown when a signature operation fails.
|
|
31905
|
+
*
|
|
31906
|
+
* @remarks
|
|
31907
|
+
* Recovery strategies: Check wallet connection and account unlock status,
|
|
31908
|
+
* retry operation with explicit user interaction, or for gasless operations
|
|
31909
|
+
* consider switching to direct transactions.
|
|
31509
31910
|
*/
|
|
31510
31911
|
declare class SignatureError extends VanaError {
|
|
31511
31912
|
readonly originalError?: Error | undefined;
|
|
@@ -31513,6 +31914,10 @@ declare class SignatureError extends VanaError {
|
|
|
31513
31914
|
}
|
|
31514
31915
|
/**
|
|
31515
31916
|
* Error thrown when a network operation fails.
|
|
31917
|
+
*
|
|
31918
|
+
* @remarks
|
|
31919
|
+
* Recovery strategies: Check network connectivity, retry with exponential backoff,
|
|
31920
|
+
* verify API endpoints are accessible, or switch to alternative network providers.
|
|
31516
31921
|
*/
|
|
31517
31922
|
declare class NetworkError extends VanaError {
|
|
31518
31923
|
readonly originalError?: Error | undefined;
|
|
@@ -31520,12 +31925,20 @@ declare class NetworkError extends VanaError {
|
|
|
31520
31925
|
}
|
|
31521
31926
|
/**
|
|
31522
31927
|
* Error thrown when the nonce retrieval fails.
|
|
31928
|
+
*
|
|
31929
|
+
* @remarks
|
|
31930
|
+
* Recovery strategies: Retry nonce retrieval after brief delay, check wallet connection
|
|
31931
|
+
* and account status, or use manual nonce specification if supported by the operation.
|
|
31523
31932
|
*/
|
|
31524
31933
|
declare class NonceError extends VanaError {
|
|
31525
31934
|
constructor(message: string);
|
|
31526
31935
|
}
|
|
31527
31936
|
/**
|
|
31528
31937
|
* Error thrown when a personal server operation fails.
|
|
31938
|
+
*
|
|
31939
|
+
* @remarks
|
|
31940
|
+
* Recovery strategies: Verify server URL accessibility, check server trust status via
|
|
31941
|
+
* `vana.permissions.getUserTrustedServers()`, or retry after server becomes available.
|
|
31529
31942
|
*/
|
|
31530
31943
|
declare class PersonalServerError extends VanaError {
|
|
31531
31944
|
readonly originalError?: Error | undefined;
|
|
@@ -31584,21 +31997,93 @@ declare const DEFAULT_ENCRYPTION_SEED = "Please sign to retrieve your encryption
|
|
|
31584
31997
|
*/
|
|
31585
31998
|
declare function generateEncryptionKey(wallet: WalletClient, seed?: string): Promise<string>;
|
|
31586
31999
|
/**
|
|
31587
|
-
*
|
|
32000
|
+
* Encrypts data using a wallet's public key for secure sharing with specific recipients.
|
|
31588
32001
|
*
|
|
31589
|
-
* @
|
|
31590
|
-
*
|
|
31591
|
-
*
|
|
31592
|
-
*
|
|
32002
|
+
* @remarks
|
|
32003
|
+
* This function implements asymmetric encryption using the recipient's public key,
|
|
32004
|
+
* enabling secure data sharing where only the holder of the corresponding private key
|
|
32005
|
+
* can decrypt the data. It automatically handles different data types and uses
|
|
32006
|
+
* platform-appropriate cryptographic libraries for maximum compatibility.
|
|
32007
|
+
*
|
|
32008
|
+
* This is commonly used when granting permissions to applications or servers,
|
|
32009
|
+
* where the data needs to be encrypted for a specific recipient's public key.
|
|
32010
|
+
*
|
|
32011
|
+
* @param data - The data to encrypt (string or Blob)
|
|
32012
|
+
* @param publicKey - The recipient's public key in hexadecimal format
|
|
32013
|
+
* @param platformAdapter - The platform adapter providing cryptographic operations
|
|
32014
|
+
* @returns Promise resolving to the encrypted data as a string
|
|
32015
|
+
* @throws {Error} When encryption fails due to invalid key or data format
|
|
32016
|
+
* @example
|
|
32017
|
+
* ```typescript
|
|
32018
|
+
* // Encrypt data for a specific application's public key
|
|
32019
|
+
* const appPublicKey = "0x04a1b2c3..."; // Application's public key
|
|
32020
|
+
* const sensitiveData = "User's private information";
|
|
32021
|
+
*
|
|
32022
|
+
* const encrypted = await encryptWithWalletPublicKey(
|
|
32023
|
+
* sensitiveData,
|
|
32024
|
+
* appPublicKey,
|
|
32025
|
+
* platformAdapter
|
|
32026
|
+
* );
|
|
32027
|
+
*
|
|
32028
|
+
* console.log('Encrypted for app:', encrypted);
|
|
32029
|
+
*
|
|
32030
|
+
* // Encrypt file data for server processing
|
|
32031
|
+
* const fileBlob = new File(['{"name":"John","age":30}'], 'profile.json');
|
|
32032
|
+
* const encryptedFile = await encryptWithWalletPublicKey(
|
|
32033
|
+
* fileBlob,
|
|
32034
|
+
* serverPublicKey,
|
|
32035
|
+
* platformAdapter
|
|
32036
|
+
* );
|
|
32037
|
+
* ```
|
|
31593
32038
|
*/
|
|
31594
32039
|
declare function encryptWithWalletPublicKey(data: string | Blob, publicKey: string, platformAdapter: VanaPlatformAdapter): Promise<string>;
|
|
31595
32040
|
/**
|
|
31596
|
-
*
|
|
32041
|
+
* Decrypts data that was encrypted with the corresponding public key.
|
|
31597
32042
|
*
|
|
31598
|
-
* @
|
|
31599
|
-
*
|
|
31600
|
-
*
|
|
31601
|
-
*
|
|
32043
|
+
* @remarks
|
|
32044
|
+
* This function performs asymmetric decryption using the recipient's private key
|
|
32045
|
+
* to decrypt data that was encrypted with the corresponding public key. It's the
|
|
32046
|
+
* counterpart to `encryptWithWalletPublicKey` and is typically used by applications
|
|
32047
|
+
* or servers to decrypt data that was shared with them by users.
|
|
32048
|
+
*
|
|
32049
|
+
* The function automatically handles platform-specific cryptographic operations
|
|
32050
|
+
* and provides consistent behavior across browser and Node.js environments.
|
|
32051
|
+
*
|
|
32052
|
+
* @param encryptedData - The encrypted data string to decrypt
|
|
32053
|
+
* @param privateKey - The private key corresponding to the public key used for encryption
|
|
32054
|
+
* @param platformAdapter - The platform adapter providing cryptographic operations
|
|
32055
|
+
* @returns Promise resolving to the decrypted data as a string
|
|
32056
|
+
* @throws {Error} When decryption fails due to invalid key, corrupted data, or key mismatch
|
|
32057
|
+
* @example
|
|
32058
|
+
* ```typescript
|
|
32059
|
+
* // Decrypt data received from a user (server-side)
|
|
32060
|
+
* const encryptedUserData = "encrypted_string_from_user";
|
|
32061
|
+
* const serverPrivateKey = process.env.SERVER_PRIVATE_KEY;
|
|
32062
|
+
*
|
|
32063
|
+
* const decrypted = await decryptWithWalletPrivateKey(
|
|
32064
|
+
* encryptedUserData,
|
|
32065
|
+
* serverPrivateKey,
|
|
32066
|
+
* platformAdapter
|
|
32067
|
+
* );
|
|
32068
|
+
*
|
|
32069
|
+
* const userData = JSON.parse(decrypted);
|
|
32070
|
+
* console.log('User data:', userData);
|
|
32071
|
+
*
|
|
32072
|
+
* // Handle decryption errors gracefully
|
|
32073
|
+
* try {
|
|
32074
|
+
* const result = await decryptWithWalletPrivateKey(
|
|
32075
|
+
* encryptedData,
|
|
32076
|
+
* privateKey,
|
|
32077
|
+
* platformAdapter
|
|
32078
|
+
* );
|
|
32079
|
+
* } catch (error) {
|
|
32080
|
+
* if (error.message.includes('invalid key')) {
|
|
32081
|
+
* console.error('Key mismatch - data not encrypted for this recipient');
|
|
32082
|
+
* } else {
|
|
32083
|
+
* console.error('Decryption failed:', error.message);
|
|
32084
|
+
* }
|
|
32085
|
+
* }
|
|
32086
|
+
* ```
|
|
31602
32087
|
*/
|
|
31603
32088
|
declare function decryptWithWalletPrivateKey(encryptedData: string, privateKey: string, platformAdapter: VanaPlatformAdapter): Promise<string>;
|
|
31604
32089
|
/**
|
|
@@ -31749,6 +32234,11 @@ declare function decryptBlobWithSignedKey(encryptedData: string | Blob, key: str
|
|
|
31749
32234
|
/**
|
|
31750
32235
|
* Format a bigint or BigNumber to a regular number
|
|
31751
32236
|
*
|
|
32237
|
+
* **Edge Cases:**
|
|
32238
|
+
* - Values exceeding JavaScript's MAX_SAFE_INTEGER (2^53-1) lose precision
|
|
32239
|
+
* - Negative values are supported
|
|
32240
|
+
* - String values must be valid numeric strings or will return NaN
|
|
32241
|
+
*
|
|
31752
32242
|
* @param value BigInt, BigNumber or numeric string to convert
|
|
31753
32243
|
* @returns Regular JavaScript number
|
|
31754
32244
|
*/
|
|
@@ -31756,6 +32246,12 @@ declare function formatNumber(value: bigint | string | number): number;
|
|
|
31756
32246
|
/**
|
|
31757
32247
|
* Format wei value to ETH with specified decimal places
|
|
31758
32248
|
*
|
|
32249
|
+
* **Edge Cases:**
|
|
32250
|
+
* - Truncates (not rounds) to specified decimal places
|
|
32251
|
+
* - Negative values are supported
|
|
32252
|
+
* - Zero values return "0.0000" (based on decimals)
|
|
32253
|
+
* - Very small values may display as "0.0000" due to truncation
|
|
32254
|
+
*
|
|
31759
32255
|
* @param wei Value in wei (as bigint, string, or number)
|
|
31760
32256
|
* @param decimals Number of decimal places to display (default: 4)
|
|
31761
32257
|
* @returns Formatted ETH value as string
|
|
@@ -31773,6 +32269,11 @@ declare function formatToken(amount: bigint | string | number, decimals?: number
|
|
|
31773
32269
|
/**
|
|
31774
32270
|
* Format an address for display (showing first 6 and last 4 characters)
|
|
31775
32271
|
*
|
|
32272
|
+
* **Edge Cases:**
|
|
32273
|
+
* - Addresses shorter than 10 characters are returned unchanged
|
|
32274
|
+
* - Works with both checksummed and lowercase addresses
|
|
32275
|
+
* - Does not validate address format
|
|
32276
|
+
*
|
|
31776
32277
|
* @param address EVM address
|
|
31777
32278
|
* @returns Shortened address string
|
|
31778
32279
|
*/
|
|
@@ -32100,6 +32601,12 @@ declare function convertIpfsUrl(url: string, gateway?: string): string;
|
|
|
32100
32601
|
/**
|
|
32101
32602
|
* Extract IPFS hash from various URL formats
|
|
32102
32603
|
*
|
|
32604
|
+
* **Edge Cases:**
|
|
32605
|
+
* - Returns null for non-IPFS URLs or malformed hashes
|
|
32606
|
+
* - Handles both CIDv0 (starts with Qm) and CIDv1 formats
|
|
32607
|
+
* - Minimum 46 characters required for standalone hash detection
|
|
32608
|
+
* - Gateway paths with subdirectories are not supported
|
|
32609
|
+
*
|
|
32103
32610
|
* @param url - The URL to extract hash from
|
|
32104
32611
|
* @returns The IPFS hash or null if not found
|
|
32105
32612
|
* @example
|
|
@@ -32107,6 +32614,8 @@ declare function convertIpfsUrl(url: string, gateway?: string): string;
|
|
|
32107
32614
|
* extractIpfsHash("ipfs://QmHash123") // Returns: "QmHash123"
|
|
32108
32615
|
* extractIpfsHash("https://gateway.pinata.cloud/ipfs/QmHash123") // Returns: "QmHash123"
|
|
32109
32616
|
* extractIpfsHash("QmHash123456789012345678901234567890123456") // Returns: "QmHash123456789012345678901234567890123456"
|
|
32617
|
+
* extractIpfsHash("https://example.com/file.json") // Returns: null (not IPFS)
|
|
32618
|
+
* extractIpfsHash("ipfs://QmHash/subdirectory") // Returns: null (subdirectories not supported)
|
|
32110
32619
|
* ```
|
|
32111
32620
|
*/
|
|
32112
32621
|
declare function extractIpfsHash(url: string): string | null;
|
|
@@ -32127,6 +32636,13 @@ declare function convertIpfsUrlWithFallbacks(url: string): string[];
|
|
|
32127
32636
|
/**
|
|
32128
32637
|
* Fetch content from IPFS with automatic gateway fallbacks
|
|
32129
32638
|
*
|
|
32639
|
+
* **Edge Cases:**
|
|
32640
|
+
* - Non-IPFS URLs are fetched directly without fallback
|
|
32641
|
+
* - 10-second timeout per gateway attempt to prevent hanging
|
|
32642
|
+
* - Rate-limited gateways (429) are skipped immediately
|
|
32643
|
+
* - Exponential backoff between retries (1s, 2s, 3s, etc.)
|
|
32644
|
+
* - AbortSignal in options is merged with timeout signal
|
|
32645
|
+
*
|
|
32130
32646
|
* @param url - The IPFS URL to fetch
|
|
32131
32647
|
* @param options - Optional fetch options
|
|
32132
32648
|
* @returns Promise resolving to Response object
|
|
@@ -32565,31 +33081,94 @@ declare class VanaBrowserImpl extends VanaCore {
|
|
|
32565
33081
|
/**
|
|
32566
33082
|
* Creates a new Vana SDK instance configured for browser environments.
|
|
32567
33083
|
*
|
|
32568
|
-
*
|
|
32569
|
-
*
|
|
32570
|
-
*
|
|
32571
|
-
*
|
|
32572
|
-
*
|
|
32573
|
-
*
|
|
33084
|
+
* @remarks
|
|
33085
|
+
* This is the primary entry point for browser applications using the Vana SDK. The function
|
|
33086
|
+
* automatically detects your configuration type and provides compile-time type safety:
|
|
33087
|
+
* - **With storage configured**: All methods including file upload/download are available
|
|
33088
|
+
* - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript
|
|
33089
|
+
*
|
|
33090
|
+
* The SDK supports multiple wallet configurations (direct WalletClient or chain config),
|
|
33091
|
+
* various storage providers (IPFS, Pinata, Google Drive), and gasless transactions via relayers.
|
|
33092
|
+
* All operations are optimized for browser environments with proper bundle size optimization.
|
|
33093
|
+
*
|
|
33094
|
+
* @param config - Configuration object containing wallet, storage, and relayer settings
|
|
33095
|
+
* @returns A fully configured Vana SDK instance for browser use
|
|
33096
|
+
* @throws {InvalidConfigurationError} When configuration parameters are invalid or missing
|
|
32574
33097
|
* @example
|
|
32575
33098
|
* ```typescript
|
|
32576
|
-
*
|
|
33099
|
+
* import { Vana } from '@opendatalabs/vana-sdk/browser';
|
|
33100
|
+
* import { createWalletClient, custom } from 'viem';
|
|
33101
|
+
* import { IPFSStorage } from '@opendatalabs/vana-sdk/browser';
|
|
33102
|
+
*
|
|
33103
|
+
* // Complete setup with storage and wallet
|
|
33104
|
+
* const walletClient = createWalletClient({
|
|
33105
|
+
* chain: mokshaTestnet,
|
|
33106
|
+
* transport: custom(window.ethereum)
|
|
33107
|
+
* });
|
|
33108
|
+
*
|
|
32577
33109
|
* const vana = Vana({
|
|
32578
33110
|
* walletClient,
|
|
32579
|
-
* storage: {
|
|
33111
|
+
* storage: {
|
|
33112
|
+
* providers: {
|
|
33113
|
+
* ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' }),
|
|
33114
|
+
* pinata: new PinataStorage({ apiKey: process.env.PINATA_KEY })
|
|
33115
|
+
* },
|
|
33116
|
+
* defaultProvider: 'ipfs'
|
|
33117
|
+
* },
|
|
33118
|
+
* relayerCallbacks: {
|
|
33119
|
+
* async submitPermissionGrant(typedData, signature) {
|
|
33120
|
+
* const response = await fetch('/api/relay/grant', {
|
|
33121
|
+
* method: 'POST',
|
|
33122
|
+
* body: JSON.stringify({ typedData, signature })
|
|
33123
|
+
* });
|
|
33124
|
+
* return (await response.json()).transactionHash;
|
|
33125
|
+
* }
|
|
33126
|
+
* }
|
|
32580
33127
|
* });
|
|
32581
|
-
* await vana.data.uploadFile(file); // ✅ Works - TypeScript knows storage is available
|
|
32582
33128
|
*
|
|
32583
|
-
* //
|
|
32584
|
-
* const
|
|
32585
|
-
*
|
|
33129
|
+
* // All operations now available
|
|
33130
|
+
* const files = await vana.data.getUserFiles();
|
|
33131
|
+
* const permissions = await vana.permissions.getUserPermissions();
|
|
33132
|
+
* await vana.data.upload({ content: 'My data', filename: 'data.txt' });
|
|
33133
|
+
* ```
|
|
33134
|
+
*
|
|
33135
|
+
* @example
|
|
33136
|
+
* ```typescript
|
|
33137
|
+
* // Minimal setup without storage (read-only operations)
|
|
33138
|
+
* const vanaReadOnly = Vana({ walletClient });
|
|
33139
|
+
*
|
|
33140
|
+
* // These work without storage
|
|
33141
|
+
* const files = await vanaReadOnly.data.getUserFiles();
|
|
33142
|
+
* const permissions = await vanaReadOnly.permissions.getUserPermissions();
|
|
32586
33143
|
*
|
|
32587
|
-
* //
|
|
32588
|
-
*
|
|
32589
|
-
*
|
|
32590
|
-
*
|
|
33144
|
+
* // This would throw a runtime error
|
|
33145
|
+
* // await vanaReadOnly.data.upload(params); // ❌ InvalidConfigurationError
|
|
33146
|
+
*
|
|
33147
|
+
* // Safe runtime check
|
|
33148
|
+
* if (vanaReadOnly.isStorageEnabled()) {
|
|
33149
|
+
* await vanaReadOnly.data.upload(params); // ✅ TypeScript allows this
|
|
33150
|
+
* } else {
|
|
33151
|
+
* console.log('Storage not configured - upload unavailable');
|
|
32591
33152
|
* }
|
|
32592
33153
|
* ```
|
|
33154
|
+
*
|
|
33155
|
+
* @example
|
|
33156
|
+
* ```typescript
|
|
33157
|
+
* // Using chain configuration instead of wallet client
|
|
33158
|
+
* const vana = Vana({
|
|
33159
|
+
* chainId: 14800, // Moksha testnet
|
|
33160
|
+
* account: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',
|
|
33161
|
+
* rpcUrl: 'https://rpc.moksha.vana.org',
|
|
33162
|
+
* storage: {
|
|
33163
|
+
* providers: { ipfs: new IPFSStorage() },
|
|
33164
|
+
* defaultProvider: 'ipfs'
|
|
33165
|
+
* }
|
|
33166
|
+
* });
|
|
33167
|
+
* ```
|
|
33168
|
+
*
|
|
33169
|
+
* @see {@link https://docs.vana.org/docs/sdk/getting-started | Getting Started Guide} for setup tutorials
|
|
33170
|
+
* @see {@link VanaCore} for the underlying implementation details
|
|
33171
|
+
* @category Core SDK
|
|
32593
33172
|
*/
|
|
32594
33173
|
declare function Vana(config: VanaConfigWithStorage): VanaBrowserImpl & StorageRequiredMarker;
|
|
32595
33174
|
declare function Vana(config: VanaConfig): VanaBrowserImpl;
|