@opendatalabs/vana-sdk 2.2.2 → 2.2.3-canary.046cb7e
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/controllers/permissions.cjs +19 -14
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.js +19 -14
- package/dist/controllers/permissions.js.map +1 -1
- package/dist/controllers/staking.cjs +539 -0
- package/dist/controllers/staking.cjs.map +1 -0
- package/dist/controllers/staking.d.ts +404 -0
- package/dist/controllers/staking.js +515 -0
- package/dist/controllers/staking.js.map +1 -0
- package/dist/core.cjs +4 -0
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +3 -0
- package/dist/core.js +4 -0
- package/dist/core.js.map +1 -1
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs +37 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -1
- package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +29 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js +37 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs +156 -19
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +120 -14
- package/dist/generated/abi/VanaPoolStakingImplementation.js +156 -19
- package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -1
- package/dist/generated/abi/index.d.ts +149 -14
- package/dist/generated/event-types.cjs.map +1 -1
- package/dist/generated/event-types.d.ts +4 -0
- package/dist/generated/eventRegistry.cjs +24 -0
- package/dist/generated/eventRegistry.cjs.map +1 -1
- package/dist/generated/eventRegistry.js +24 -0
- package/dist/generated/eventRegistry.js.map +1 -1
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.browser.js +2 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +3 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +2 -0
- package/dist/index.node.js +2 -0
- package/dist/index.node.js.map +1 -1
- package/dist/tests/staking.test.d.ts +1 -0
- package/dist/types/permissions.cjs.map +1 -1
- package/dist/types/permissions.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.browser.d.ts
CHANGED
|
@@ -125,6 +125,8 @@ export { ServerController } from "./controllers/server";
|
|
|
125
125
|
export { ProtocolController } from "./controllers/protocol";
|
|
126
126
|
export { SchemaController } from "./controllers/schemas";
|
|
127
127
|
export { OperationsController } from "./controllers/operations";
|
|
128
|
+
export { StakingController } from "./controllers/staking";
|
|
129
|
+
export type { EntityInfo, StakerEntityInfo, StakerEntitySummary, } from "./controllers/staking";
|
|
128
130
|
export * from "./contracts/contractController";
|
|
129
131
|
export * from "./utils/encryption";
|
|
130
132
|
export * from "./utils/formatters";
|
package/dist/index.browser.js
CHANGED
|
@@ -28,6 +28,7 @@ import { ServerController } from "./controllers/server";
|
|
|
28
28
|
import { ProtocolController } from "./controllers/protocol";
|
|
29
29
|
import { SchemaController } from "./controllers/schemas";
|
|
30
30
|
import { OperationsController } from "./controllers/operations";
|
|
31
|
+
import { StakingController } from "./controllers/staking";
|
|
31
32
|
export * from "./contracts/contractController";
|
|
32
33
|
export * from "./utils/encryption";
|
|
33
34
|
export * from "./utils/formatters";
|
|
@@ -104,6 +105,7 @@ export {
|
|
|
104
105
|
RetryUtility,
|
|
105
106
|
SchemaController,
|
|
106
107
|
ServerController,
|
|
108
|
+
StakingController,
|
|
107
109
|
Vana,
|
|
108
110
|
VanaBrowserImpl,
|
|
109
111
|
VanaCore2 as VanaCore,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.browser.ts"],"sourcesContent":["/**\n * @module Browser\n * Browser-specific implementation of the Vana SDK\n */\n\nimport { BrowserPlatformAdapter } from \"./platform/browser\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n} from \"./types\";\n\n/**\n * Internal implementation class for browser environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaBrowserImpl extends VanaCore {\n constructor(config: VanaConfig) {\n super(new BrowserPlatformAdapter(), config);\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for browser environments.\n *\n * @remarks\n * This is the primary entry point for browser applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The SDK supports multiple wallet configurations (direct WalletClient or chain config),\n * various storage providers (IPFS, Pinata, Google Drive), and gasless transactions via relayers.\n * All operations are optimized for browser environments with proper bundle size optimization.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for browser use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/browser';\n * import { createWalletClient, custom } from 'viem';\n * import { IPFSStorage } from '@opendatalabs/vana-sdk/browser';\n *\n * // Complete setup with storage and wallet\n * const walletClient = createWalletClient({\n * chain: mokshaTestnet,\n * transport: custom(window.ethereum)\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' }),\n * pinata: new PinataStorage({ apiKey: process.env.PINATA_KEY })\n * },\n * defaultProvider: 'ipfs'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * const response = await fetch('/api/relay/grant', {\n * method: 'POST',\n * body: JSON.stringify({ typedData, signature })\n * });\n * return (await response.json()).transactionHash;\n * }\n * }\n * });\n *\n * // All operations now available\n * const files = await vana.data.getUserFiles();\n * const permissions = await vana.permissions.getUserPermissions();\n * await vana.data.upload({ content: 'My data', filename: 'data.txt' });\n * ```\n *\n * @example\n * ```typescript\n * // Minimal setup without storage (read-only operations)\n * const vanaReadOnly = Vana({ walletClient });\n *\n * // These work without storage\n * const files = await vanaReadOnly.data.getUserFiles();\n * const permissions = await vanaReadOnly.permissions.getUserPermissions();\n *\n * // This would throw a runtime error\n * // await vanaReadOnly.data.upload(params); // ❌ InvalidConfigurationError\n *\n * // Safe runtime check\n * if (vanaReadOnly.isStorageEnabled()) {\n * await vanaReadOnly.data.upload(params); // ✅ TypeScript allows this\n * } else {\n * console.log('Storage not configured - upload unavailable');\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Using chain configuration instead of wallet client\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',\n * rpcUrl: 'https://rpc.moksha.vana.org',\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/getting-started | Getting Started Guide} for setup tutorials\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\nexport function Vana(\n config: VanaConfigWithStorage,\n): VanaBrowserImpl & StorageRequiredMarker;\nexport function Vana(config: VanaConfig): VanaBrowserImpl;\n/**\n * Creates a new Vana SDK instance.\n *\n * @param config - The configuration for the Vana SDK\n * @returns A new Vana SDK instance\n */\nexport function Vana(config: VanaConfig) {\n return new VanaBrowserImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in browser environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaBrowserImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\n\n// Types - modular exports\nexport type * from \"./types\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Platform adapters - browser-safe exports\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { BrowserECIESUint8Provider as BrowserECIESProvider } from \"./crypto/ecies/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// ECIES utilities and types (exported via module index for consistency)\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./crypto/ecies\";\nexport type {\n ECIESProvider,\n ECIESEncrypted,\n ECIESOptions,\n} from \"./crypto/ecies\";\n\n// Browser-only platform adapter utilities\nexport {\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-only\";\n\n// Note: createNodePlatformAdapter is not exported in browser bundle to avoid Node.js dependencies\n\n// NodePlatformAdapter is available through dynamic import to avoid bundling Node.js dependencies\n// Use createNodePlatformAdapter() for dynamic import\n\n// Platform utilities - browser-safe only\nexport {\n detectPlatform,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n\n// For testing purposes, we also export the implementation class\nexport { VanaBrowserImpl };\n"],"mappings":"AAKA,SAAS,8BAA8B;AACvC,SAAS,gBAAgB;AAWzB,MAAM,wBAAwB,SAAS;AAAA,EACrC,YAAY,QAAoB;AAC9B,UAAM,IAAI,uBAAuB,GAAG,MAAM;AAAA,EAC5C;AACF;AAwGO,SAAS,KAAK,QAAoB;AACvC,SAAO,IAAI,gBAAgB,MAAM;AACnC;AAWA,IAAO,wBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAM1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAGrC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAWd,cAAc;AAGd,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,0BAAAC,+BAA8B;AACvC,SAAsC,iCAA4B;AAIlE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","BrowserPlatformAdapter"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.browser.ts"],"sourcesContent":["/**\n * @module Browser\n * Browser-specific implementation of the Vana SDK\n */\n\nimport { BrowserPlatformAdapter } from \"./platform/browser\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n} from \"./types\";\n\n/**\n * Internal implementation class for browser environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaBrowserImpl extends VanaCore {\n constructor(config: VanaConfig) {\n super(new BrowserPlatformAdapter(), config);\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for browser environments.\n *\n * @remarks\n * This is the primary entry point for browser applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The SDK supports multiple wallet configurations (direct WalletClient or chain config),\n * various storage providers (IPFS, Pinata, Google Drive), and gasless transactions via relayers.\n * All operations are optimized for browser environments with proper bundle size optimization.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for browser use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/browser';\n * import { createWalletClient, custom } from 'viem';\n * import { IPFSStorage } from '@opendatalabs/vana-sdk/browser';\n *\n * // Complete setup with storage and wallet\n * const walletClient = createWalletClient({\n * chain: mokshaTestnet,\n * transport: custom(window.ethereum)\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' }),\n * pinata: new PinataStorage({ apiKey: process.env.PINATA_KEY })\n * },\n * defaultProvider: 'ipfs'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * const response = await fetch('/api/relay/grant', {\n * method: 'POST',\n * body: JSON.stringify({ typedData, signature })\n * });\n * return (await response.json()).transactionHash;\n * }\n * }\n * });\n *\n * // All operations now available\n * const files = await vana.data.getUserFiles();\n * const permissions = await vana.permissions.getUserPermissions();\n * await vana.data.upload({ content: 'My data', filename: 'data.txt' });\n * ```\n *\n * @example\n * ```typescript\n * // Minimal setup without storage (read-only operations)\n * const vanaReadOnly = Vana({ walletClient });\n *\n * // These work without storage\n * const files = await vanaReadOnly.data.getUserFiles();\n * const permissions = await vanaReadOnly.permissions.getUserPermissions();\n *\n * // This would throw a runtime error\n * // await vanaReadOnly.data.upload(params); // ❌ InvalidConfigurationError\n *\n * // Safe runtime check\n * if (vanaReadOnly.isStorageEnabled()) {\n * await vanaReadOnly.data.upload(params); // ✅ TypeScript allows this\n * } else {\n * console.log('Storage not configured - upload unavailable');\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Using chain configuration instead of wallet client\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',\n * rpcUrl: 'https://rpc.moksha.vana.org',\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/getting-started | Getting Started Guide} for setup tutorials\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\nexport function Vana(\n config: VanaConfigWithStorage,\n): VanaBrowserImpl & StorageRequiredMarker;\nexport function Vana(config: VanaConfig): VanaBrowserImpl;\n/**\n * Creates a new Vana SDK instance.\n *\n * @param config - The configuration for the Vana SDK\n * @returns A new Vana SDK instance\n */\nexport function Vana(config: VanaConfig) {\n return new VanaBrowserImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in browser environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaBrowserImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\n\n// Types - modular exports\nexport type * from \"./types\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\nexport { StakingController } from \"./controllers/staking\";\nexport type {\n EntityInfo,\n StakerEntityInfo,\n StakerEntitySummary,\n} from \"./controllers/staking\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Platform adapters - browser-safe exports\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { BrowserECIESUint8Provider as BrowserECIESProvider } from \"./crypto/ecies/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// ECIES utilities and types (exported via module index for consistency)\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./crypto/ecies\";\nexport type {\n ECIESProvider,\n ECIESEncrypted,\n ECIESOptions,\n} from \"./crypto/ecies\";\n\n// Browser-only platform adapter utilities\nexport {\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-only\";\n\n// Note: createNodePlatformAdapter is not exported in browser bundle to avoid Node.js dependencies\n\n// NodePlatformAdapter is available through dynamic import to avoid bundling Node.js dependencies\n// Use createNodePlatformAdapter() for dynamic import\n\n// Platform utilities - browser-safe only\nexport {\n detectPlatform,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n\n// For testing purposes, we also export the implementation class\nexport { VanaBrowserImpl };\n"],"mappings":"AAKA,SAAS,8BAA8B;AACvC,SAAS,gBAAgB;AAWzB,MAAM,wBAAwB,SAAS;AAAA,EACrC,YAAY,QAAoB;AAC9B,UAAM,IAAI,uBAAuB,GAAG,MAAM;AAAA,EAC5C;AACF;AAwGO,SAAS,KAAK,QAAoB;AACvC,SAAO,IAAI,gBAAgB,MAAM;AACnC;AAWA,IAAO,wBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAM1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAQlC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAWd,cAAc;AAGd,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,0BAAAC,+BAA8B;AACvC,SAAsC,iCAA4B;AAIlE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","BrowserPlatformAdapter"]}
|
package/dist/index.node.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __export(index_node_exports, {
|
|
|
43
43
|
RetryUtility: () => import_generics.RetryUtility,
|
|
44
44
|
SchemaController: () => import_schemas.SchemaController,
|
|
45
45
|
ServerController: () => import_server.ServerController,
|
|
46
|
+
StakingController: () => import_staking.StakingController,
|
|
46
47
|
SystemHealthChecker: () => import_health.SystemHealthChecker,
|
|
47
48
|
Vana: () => Vana,
|
|
48
49
|
VanaCore: () => import_core2.VanaCore,
|
|
@@ -97,6 +98,7 @@ var import_server = require("./controllers/server");
|
|
|
97
98
|
var import_protocol = require("./controllers/protocol");
|
|
98
99
|
var import_schemas = require("./controllers/schemas");
|
|
99
100
|
var import_operations = require("./controllers/operations");
|
|
101
|
+
var import_staking = require("./controllers/staking");
|
|
100
102
|
__reExport(index_node_exports, require("./contracts/contractController"), module.exports);
|
|
101
103
|
__reExport(index_node_exports, require("./utils/encryption"), module.exports);
|
|
102
104
|
__reExport(index_node_exports, require("./utils/formatters"), module.exports);
|
|
@@ -161,6 +163,7 @@ var index_node_default = Vana;
|
|
|
161
163
|
RetryUtility,
|
|
162
164
|
SchemaController,
|
|
163
165
|
ServerController,
|
|
166
|
+
StakingController,
|
|
164
167
|
SystemHealthChecker,
|
|
165
168
|
Vana,
|
|
166
169
|
VanaCore,
|
package/dist/index.node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { NodeECIESUint8Provider as NodeECIESProvider } from \"./crypto/ecies/node\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// ECIES utilities and types (platform-agnostic, exported via module index)\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./crypto/ecies\";\nexport type {\n ECIESProvider,\n ECIESEncrypted,\n ECIESOptions,\n} from \"./crypto/ecies\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,kBAAoC;AACpC,kBAAyB;AA2MzB,IAAAA,eAA0C;AAC1C,0BAAwC;AACxC,kCAAqC;AACrC,oBAAoC;AAUpC,8BAAiC;AAcjC,2BAKO;AAMP,8BAIO;AAGP,+BAAc,qBA9Pd;AAiQA,yBAAsC;AACtC,kBAA+B;AAC/B,oBAAiC;AACjC,sBAAmC;AACnC,qBAAiC;AACjC,wBAAqC;AAGrC,+BAAc,2CAzQd;AA4QA,+BAAc,+BA5Qd;AA6QA,+BAAc,+BA7Qd;AA8QA,+BAAc,+BA9Qd;AA+QA,+BAAc,oCA/Qd;AAgRA,+BAAc,2BAhRd;AAiRA,+BAAc,yBAjRd;AAkRA,+BAAc,qCAlRd;AAmRA,+BAAc,mCAnRd;AAsRA,+BAAc,sBAtRd;AAyRA,uBAA8C;AAC9C,oBAAuB;AACvB,8BAMO;AAGP,IAAAC,iBAOO;AACP,+BAAc,qBA5Sd;AA+SA,iBAAuB;AAIvB,sBASO;AAGP,4BAGO;AAeP,IAAAC,eAAoC;AACpC,qBAAuC;AACvC,IAAAA,eAA4D;AAI5D,mBAKO;AAQP,mBAMO;AAGP,0BAIO;AAEP,uBAA0B;AAvU1B,MAAM,qBAAqB,qBAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,gCAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;","names":["import_core","import_chains","import_node"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\nexport { StakingController } from \"./controllers/staking\";\nexport type {\n EntityInfo,\n StakerEntityInfo,\n StakerEntitySummary,\n} from \"./controllers/staking\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { NodeECIESUint8Provider as NodeECIESProvider } from \"./crypto/ecies/node\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// ECIES utilities and types (platform-agnostic, exported via module index)\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./crypto/ecies\";\nexport type {\n ECIESProvider,\n ECIESEncrypted,\n ECIESOptions,\n} from \"./crypto/ecies\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,kBAAoC;AACpC,kBAAyB;AA2MzB,IAAAA,eAA0C;AAC1C,0BAAwC;AACxC,kCAAqC;AACrC,oBAAoC;AAUpC,8BAAiC;AAcjC,2BAKO;AAMP,8BAIO;AAGP,+BAAc,qBA9Pd;AAiQA,yBAAsC;AACtC,kBAA+B;AAC/B,oBAAiC;AACjC,sBAAmC;AACnC,qBAAiC;AACjC,wBAAqC;AACrC,qBAAkC;AAQlC,+BAAc,2CA/Qd;AAkRA,+BAAc,+BAlRd;AAmRA,+BAAc,+BAnRd;AAoRA,+BAAc,+BApRd;AAqRA,+BAAc,oCArRd;AAsRA,+BAAc,2BAtRd;AAuRA,+BAAc,yBAvRd;AAwRA,+BAAc,qCAxRd;AAyRA,+BAAc,mCAzRd;AA4RA,+BAAc,sBA5Rd;AA+RA,uBAA8C;AAC9C,oBAAuB;AACvB,8BAMO;AAGP,IAAAC,iBAOO;AACP,+BAAc,qBAlTd;AAqTA,iBAAuB;AAIvB,sBASO;AAGP,4BAGO;AAeP,IAAAC,eAAoC;AACpC,qBAAuC;AACvC,IAAAA,eAA4D;AAI5D,mBAKO;AAQP,mBAMO;AAGP,0BAIO;AAEP,uBAA0B;AA7U1B,MAAM,qBAAqB,qBAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,gCAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;","names":["import_core","import_chains","import_node"]}
|
package/dist/index.node.d.ts
CHANGED
|
@@ -188,6 +188,8 @@ export { ServerController } from "./controllers/server";
|
|
|
188
188
|
export { ProtocolController } from "./controllers/protocol";
|
|
189
189
|
export { SchemaController } from "./controllers/schemas";
|
|
190
190
|
export { OperationsController } from "./controllers/operations";
|
|
191
|
+
export { StakingController } from "./controllers/staking";
|
|
192
|
+
export type { EntityInfo, StakerEntityInfo, StakerEntitySummary, } from "./controllers/staking";
|
|
191
193
|
export * from "./contracts/contractController";
|
|
192
194
|
export * from "./utils/encryption";
|
|
193
195
|
export * from "./utils/formatters";
|
package/dist/index.node.js
CHANGED
|
@@ -36,6 +36,7 @@ import { ServerController } from "./controllers/server";
|
|
|
36
36
|
import { ProtocolController } from "./controllers/protocol";
|
|
37
37
|
import { SchemaController } from "./controllers/schemas";
|
|
38
38
|
import { OperationsController } from "./controllers/operations";
|
|
39
|
+
import { StakingController } from "./controllers/staking";
|
|
39
40
|
export * from "./contracts/contractController";
|
|
40
41
|
export * from "./utils/encryption";
|
|
41
42
|
export * from "./utils/formatters";
|
|
@@ -123,6 +124,7 @@ export {
|
|
|
123
124
|
RetryUtility,
|
|
124
125
|
SchemaController,
|
|
125
126
|
ServerController,
|
|
127
|
+
StakingController,
|
|
126
128
|
SystemHealthChecker,
|
|
127
129
|
Vana,
|
|
128
130
|
VanaCore2 as VanaCore,
|
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { NodeECIESUint8Provider as NodeECIESProvider } from \"./crypto/ecies/node\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// ECIES utilities and types (platform-agnostic, exported via module index)\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./crypto/ecies\";\nexport type {\n ECIESProvider,\n ECIESEncrypted,\n ECIESOptions,\n} from \"./crypto/ecies\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":"AAKA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AAsCzB,MAAM,qBAAqB,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,oBAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAC1C,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AAUpC,SAAS,wBAAwB;AAcjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAGrC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,OAEK;AAeP,SAAS,uBAAAC,4BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAmC,8BAAyB;AAI5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","NodePlatformAdapter"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\nexport { StakingController } from \"./controllers/staking\";\nexport type {\n EntityInfo,\n StakerEntityInfo,\n StakerEntitySummary,\n} from \"./controllers/staking\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport { NodeECIESUint8Provider as NodeECIESProvider } from \"./crypto/ecies/node\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// ECIES utilities and types (platform-agnostic, exported via module index)\nexport {\n ECIESError,\n isECIESEncrypted,\n serializeECIES,\n deserializeECIES,\n} from \"./crypto/ecies\";\nexport type {\n ECIESProvider,\n ECIESEncrypted,\n ECIESOptions,\n} from \"./crypto/ecies\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":"AAKA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AAsCzB,MAAM,qBAAqB,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,oBAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAC1C,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AAUpC,SAAS,wBAAwB;AAcjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAQlC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,OAEK;AAeP,SAAS,uBAAAC,4BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAmC,8BAAyB;AAI5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","NodePlatformAdapter"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/permissions.ts"],"sourcesContent":["import type { Address, Hash } from \"viem\";\n\n/**\n * Base interface for types that need to be compatible with Record<string, unknown>\n *\n * @category Permissions\n */\nexport interface RecordCompatible {\n [key: string]: unknown;\n}\n\n/**\n * Contains on-chain permission data for efficient retrieval.\n *\n * @remarks\n * Provides fast access to permission metadata from subgraph without\n * IPFS calls. For detailed parameters, resolve `grantUrl` separately.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const grants = await vana.permissions.getUserPermissionGrantsOnChain();\n *\n * // Resolve details when needed\n * const details = await retrieveGrantFile(grants[0].grantUrl);\n * console.log(`Operation: ${details.operation}`);\n * ```\n */\nexport interface OnChainPermissionGrant {\n /** Unique identifier for the permission */\n id: bigint;\n /** The grant URL containing detailed permission parameters (IPFS link) */\n grantUrl: string;\n /** Cryptographic signature that authorized this permission */\n grantSignature: string;\n /** Nonce used when granting the permission */\n nonce: bigint;\n /** Block number when permission started */\n startBlock: bigint;\n /** Block number when permission was granted */\n addedAtBlock: bigint;\n /** Timestamp when permission was added */\n addedAtTimestamp: bigint;\n /** Transaction hash of the grant transaction */\n transactionHash: string;\n /** Address that granted the permission */\n grantor: Address;\n /** Grantee information */\n grantee: {\n /** Grantee ID */\n id: string;\n /** Grantee address */\n address: string;\n };\n /** Whether the permission is still active (not revoked) */\n active: boolean;\n}\n\n/**\n * Options for retrieving user permissions\n *\n * @category Permissions\n */\nexport interface GetUserPermissionsOptions {\n /** Maximum number of permissions to retrieve */\n limit?: number;\n /** Whether to fetch all permissions (ignores limit) */\n fetchAll?: boolean;\n /** Custom subgraph URL to use for querying */\n subgraphUrl?: string;\n}\n\n/**\n * Defines parameters for granting file access permissions.\n *\n * @remarks\n * Specifies application, operation, files, and parameters for\n * permission grants via `vana.permissions.grant()`.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const params: GrantPermissionParams = {\n * grantee: '0x1234...',\n * operation: 'llm_inference',\n * files: [1, 2, 3],\n * parameters: { model: 'gpt-4', maxTokens: 1000 }\n * };\n * const result = await vana.permissions.grant(params);\n * ```\n */\nexport interface GrantPermissionParams {\n /** The on-chain identity of the application */\n grantee: Address;\n /** The class of computation, e.g., \"llm_inference\" */\n operation: string;\n /**\n * Array of file IDs to grant permission for.\n * Obtain file IDs from `vana.data.getUserFiles()` or from upload results via `vana.data.upload().fileId`.\n */\n files: number[];\n /** The full, off-chain parameters (e.g., LLM prompt) */\n parameters: Record<string, unknown>;\n /** Optional JSONPath filters to apply to files, keyed by file ID */\n filters?: Record<string, string>;\n /** Optional pre-stored grant URL to avoid duplicate IPFS storage */\n grantUrl?: string;\n /** Optional nonce for the permission */\n nonce?: bigint;\n /** Optional expiration time for the permission */\n expiresAt?: number;\n}\n\n/**\n * Parameters for revoking a previously granted data access permission.\n *\n * Used with `PermissionsController.revoke()` to remove an application's access\n * to user data. Once revoked, the application can no longer use the permission\n * to access the specified files.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const revokeParams: RevokePermissionParams = {\n * permissionId: 123n // Permission ID to revoke\n * };\n *\n * await vana.permissions.revoke(revokeParams);\n * ```\n */\nexport interface RevokePermissionParams {\n /** The permission ID to revoke */\n permissionId: bigint;\n}\n\n/**\n * Parameters for checking if a specific permission exists and is valid.\n *\n * Used to verify whether an application has active permission to access\n * specific user files for a particular operation before attempting to use the data.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const checkParams: CheckPermissionParams = {\n * application: '0x1234...', // App address\n * operation: 'llm_inference',\n * files: [1, 2, 3], // File IDs to check\n * parameters: { model: 'gpt-4' }, // Operation parameters\n * user: '0xabcd...' // Optional specific user\n * };\n *\n * const hasPermission = await vana.permissions.check(checkParams);\n * ```\n */\nexport interface CheckPermissionParams {\n /** The application address */\n application: Address;\n /** The operation type */\n operation: string;\n /** The file IDs */\n files: number[];\n /** The grant parameters */\n parameters: Record<string, unknown>;\n /** The user address */\n user?: Address;\n}\n\n/**\n * Permission check result\n *\n * @category Permissions\n */\nexport interface PermissionCheckResult {\n /** Whether the permission exists and is valid */\n exists: boolean;\n /** The permission details if it exists */\n permission?: GrantedPermission;\n /** Reason why permission is invalid (if applicable) */\n reason?: string;\n}\n\n/**\n * EIP-712 domain definition for PermissionGrant signatures\n *\n * @category Permissions\n */\nexport interface PermissionGrantDomain {\n /** Domain name */\n name: string;\n /** Domain version */\n version: string;\n /** Chain ID */\n chainId: number;\n /** Verifying contract address */\n verifyingContract: Address;\n}\n\n/**\n * EIP-712 Permission message structure (current contract format)\n *\n * @category Permissions\n */\nexport interface PermissionGrantMessage {\n /** Application address */\n application: Address;\n /** File IDs */\n files: number[];\n /** Operation type */\n operation: string;\n /** Grant URL */\n grant: string;\n /** Parameters as JSON string */\n parameters: string;\n /** Nonce */\n nonce: bigint;\n}\n\n/**\n * EIP-712 PermissionInput message structure (new simplified format)\n *\n * @category Permissions\n */\nexport interface PermissionInputMessage extends RecordCompatible {\n /** Nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File IDs */\n fileIds: bigint[];\n}\n\n/**\n * Contract PermissionInput structure\n *\n * @category Permissions\n */\nexport interface PermissionInput {\n /** Nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File IDs to grant permission for */\n fileIds: bigint[];\n}\n\n/**\n * Contract RevokePermissionInput structure\n *\n * @category Permissions\n */\nexport interface RevokePermissionInput extends RecordCompatible {\n /** Nonce */\n nonce: bigint;\n /** Permission ID to revoke */\n permissionId: bigint;\n}\n\n/**\n * Contract Permission Info structure returned from the contract\n *\n * @category Permissions\n */\nexport interface PermissionInfo {\n /** Permission ID */\n id: bigint;\n /** Address that granted the permission */\n grantor: Address;\n /** Nonce used when creating */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** Signature bytes (removed in newer contract versions) */\n signature?: `0x${string}`;\n /** Start block */\n startBlock: bigint;\n /** End block */\n endBlock: bigint;\n /** File IDs associated with this permission */\n fileIds: readonly bigint[];\n}\n\n/**\n * EIP-712 Permission message structure (simplified future format)\n *\n * @category Permissions\n */\nexport interface SimplifiedPermissionMessage {\n /** Application address */\n application: Address;\n /** Grant URL */\n grant: string;\n /** Nonce */\n nonce: bigint;\n}\n\n/**\n * Grant file structure containing permission details.\n *\n * Grant files contain the complete specification of what an application is permitted\n * to do with user data, including operation parameters and file access rights.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const grantFile: GrantFile = {\n * grantee: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',\n * operation: 'llm_inference',\n * parameters: {\n * prompt: 'Analyze this data: {{data}}',\n * model: 'gpt-4',\n * maxTokens: 2000,\n * temperature: 0.7\n * },\n * expires: 1736467579\n * };\n * ```\n */\nexport interface GrantFile {\n /** EVM address of the application authorized to use this grant */\n grantee: Address;\n /** Operation the grantee is authorized to perform */\n operation: string;\n /** Operation-specific parameters */\n parameters: Record<string, unknown>;\n /** Optional Unix timestamp when grant expires (seconds since epoch per POSIX.1-2008) */\n expires?: number;\n}\n\n/**\n * EIP-712 typed data structure for Permission\n *\n * @category Permissions\n */\nexport interface PermissionGrantTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n Permission: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"Permission\";\n /** Message to sign */\n message: PermissionInputMessage;\n}\n\n/**\n * Generic EIP-712 typed data structure\n *\n * @category Permissions\n */\nexport interface GenericTypedData extends RecordCompatible {\n /** EIP-712 domain */\n domain: PermissionGrantDomain;\n /** EIP-712 types */\n types: Record<string, Array<{ name: string; type: string }>>;\n /** Primary type */\n primaryType: string;\n /** Message to sign */\n message: Record<string, unknown>;\n}\n\n/**\n * Represents EIP-712 typed data for permission revocation.\n *\n * @remarks\n * Used when revoking previously granted permissions through gasless transactions.\n * The message contains a nonce and the permission ID to revoke.\n *\n * @category Permissions\n */\nexport interface RevokePermissionTypedData extends GenericTypedData {\n /** EIP-712 type definitions for the RevokePermission structure */\n types: {\n RevokePermission: Array<{\n name: string;\n type: string;\n }>;\n };\n /** The primary type identifier for revocation operations */\n primaryType: \"RevokePermission\";\n /** The structured message containing revocation parameters */\n message: RevokePermissionInput;\n}\n\n/**\n * Defines all valid primary types for EIP-712 typed data in the Vana SDK.\n *\n * @remarks\n * These literal types ensure compile-time safety when handling typed data operations.\n * Each corresponds to a specific blockchain operation type.\n *\n * @category Permissions\n */\nexport type TypedDataPrimaryType =\n | \"Permission\"\n | \"RevokePermission\"\n | \"TrustServer\"\n | \"UntrustServer\"\n | \"AddServer\"\n | \"RegisterGrantee\"\n | \"ServerFilesAndPermission\";\n\n/**\n * Represents the union of all specific typed data interfaces.\n *\n * @remarks\n * Enables type-safe handling of any typed data structure in the SDK.\n * Used internally by relayer handlers and signature verification.\n *\n * @category Permissions\n */\nexport type SpecificTypedData =\n | PermissionGrantTypedData\n | RevokePermissionTypedData\n | TrustServerTypedData\n | UntrustServerTypedData\n | AddAndTrustServerTypedData\n | RegisterGranteeTypedData\n | ServerFilesAndPermissionTypedData;\n\n/**\n * Permission operation types\n *\n * @category Permissions\n */\nexport type PermissionOperation =\n | \"llm_inference\"\n | \"data_analysis\"\n | \"model_training\"\n | \"data_sharing\"\n | \"compute_task\"\n | string;\n\n/**\n * Permission status\n *\n * @category Permissions\n */\nexport type PermissionStatus = \"active\" | \"revoked\" | \"expired\" | \"pending\";\n\n/**\n * Parameters for querying permissions\n *\n * @category Permissions\n */\nexport interface QueryPermissionsParams {\n /** Filter by grantor address */\n grantor?: Address;\n /** Filter by grantee address */\n grantee?: Address;\n /** Filter by operation type */\n operation?: PermissionOperation;\n /** Filter by file IDs */\n files?: number[];\n /** Filter by status */\n status?: PermissionStatus;\n /** Starting block number */\n fromBlock?: bigint;\n /** Ending block number */\n toBlock?: bigint;\n /** Maximum number of results */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n}\n\n/**\n * Granted permission details\n *\n * @category Permissions\n */\nexport interface GrantedPermission {\n /** Unique identifier for the permission */\n id: bigint;\n /** Array of file IDs that the permission applies to */\n files: number[];\n /** The type of operation being granted permission for */\n operation: string;\n /** Grant file reference (IPFS hash or URL) */\n grant: string;\n /** Address of the application granted permission */\n grantee: Address;\n /** Address of the user who granted permission */\n grantor: Address;\n /** Custom parameters for the operation */\n parameters: Record<string, unknown>;\n /** Whether the permission is still active */\n active: boolean;\n /** Data status for the permission */\n dataStatus?: string;\n /** Nonce used for the permission */\n nonce?: number;\n /** Timestamp when permission was granted */\n grantedAt?: number;\n /** Optional expiration timestamp */\n expiresAt?: number;\n /** Transaction hash of the grant transaction */\n transactionHash?: string;\n /** Block number when permission was granted */\n blockNumber?: bigint;\n}\n\n/**\n * Permission query result\n *\n * @category Permissions\n */\nexport interface PermissionQueryResult {\n /** Array of permissions matching the query */\n permissions: GrantedPermission[];\n /** Total number of permissions (for pagination) */\n total: number;\n /** Whether there are more results available */\n hasMore: boolean;\n}\n\n/**\n * Permission analytics data\n *\n * @category Permissions\n */\nexport interface PermissionAnalytics {\n /** Total number of permissions granted */\n totalPermissions: number;\n /** Number of active permissions */\n activePermissions: number;\n /** Number of revoked permissions */\n revokedPermissions: number;\n /** Number of expired permissions */\n expiredPermissions: number;\n /** Most common operation types */\n topOperations: Array<{\n operation: PermissionOperation;\n count: number;\n }>;\n /** Most active applications */\n topApplications: Array<{\n application: Address;\n count: number;\n }>;\n}\n\n/**\n * Server information\n *\n * @category Permissions\n */\nexport interface Server {\n /** Server ID (numeric) */\n id: number;\n /** Server owner address */\n owner: Address;\n /** Server URL */\n url: string;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Contract ServerInfo structure returned from the contract\n *\n * @category Permissions\n */\nexport interface ServerInfo {\n /** Server ID */\n id: bigint;\n /** Server owner address */\n owner: Address;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n /** Server URL */\n url: string;\n}\n\n/**\n * Parameters for adding and trusting a server\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerParams {\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Parameters for trusting a server (legacy)\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerParams instead\n */\nexport interface TrustServerParams {\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Parameters for untrusting a server\n *\n * @category Permissions\n */\nexport interface UntrustServerParams {\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Input for adding and trusting a server with signature (gasless)\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Input for trusting a server with signature (gasless)\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerInput instead\n */\nexport interface TrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Input for untrusting a server with signature (gasless)\n *\n * @category Permissions\n */\nexport interface UntrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * EIP-712 typed data for AddAndTrustServer\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n AddServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"AddServer\";\n /** Message to sign */\n message: AddAndTrustServerInput;\n}\n\n/**\n * EIP-712 typed data for TrustServer\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerTypedData instead\n */\nexport interface TrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n TrustServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"TrustServer\";\n /** Message to sign */\n message: TrustServerInput;\n}\n\n/**\n * EIP-712 typed data for UntrustServer\n *\n * @category Permissions\n */\nexport interface UntrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n UntrustServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"UntrustServer\";\n /** Message to sign */\n message: UntrustServerInput;\n}\n\n/**\n * Permission event data\n *\n * @category Permissions\n */\nexport interface PermissionEvent {\n /** Event type */\n type: \"granted\" | \"revoked\" | \"expired\";\n /** Permission details */\n permission: GrantedPermission;\n /** Block number where event occurred */\n blockNumber: bigint;\n /** Transaction hash */\n transactionHash: Hash;\n /** Event timestamp */\n timestamp: number;\n}\n\n/**\n * Enhanced trusted server information with trust status\n *\n * @category Permissions\n */\nexport interface TrustedServerInfo {\n /** Server ID */\n id: bigint;\n /** Server owner address */\n owner: Address;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n /** Server URL */\n url: string;\n /** Start block when trust relationship began */\n startBlock: bigint;\n /** End block when trust relationship ended (0 if still active) */\n endBlock: bigint;\n}\n\n/**\n * Paginated result for trusted server queries\n *\n * @category Permissions\n */\nexport interface PaginatedTrustedServers {\n /** Array of server IDs (numeric) */\n servers: number[];\n /** Total number of trusted servers */\n total: number;\n /** Offset used for this query */\n offset: number;\n /** Limit used for this query */\n limit: number;\n /** Whether there are more servers beyond this page */\n hasMore: boolean;\n}\n\n/**\n * Options for querying trusted servers\n *\n * @category Permissions\n */\nexport interface TrustedServerQueryOptions {\n /** User address to query (defaults to current user) */\n userAddress?: Address;\n /** Maximum number of servers to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n /** Whether to include full server info or just IDs */\n includeServerInfo?: boolean;\n}\n\n/**\n * Result of batch server info requests\n *\n * @category Permissions\n */\nexport interface BatchServerInfoResult {\n /** Successfully retrieved server info */\n servers: Map<number, Server>;\n /** Server IDs that failed to retrieve */\n failed: number[];\n}\n\n/**\n * Server trust status information\n *\n * @category Permissions\n */\nexport interface ServerTrustStatus {\n /** Server ID being checked (numeric) */\n serverId: number;\n /** Whether the server is trusted by the user */\n isTrusted: boolean;\n /** Index in user's trusted server list (if trusted) */\n trustIndex?: number;\n}\n\n/**\n * Grantee information\n *\n * @category Permissions\n */\nexport interface Grantee {\n /** Grantee ID (numeric) */\n id: number;\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n address: Address;\n /** Grantee public key */\n publicKey: string;\n /** Permission IDs associated with this grantee */\n permissionIds: number[];\n}\n\n/**\n * Contract GranteeInfo structure returned from the contract\n *\n * @category Permissions\n */\nexport interface GranteeInfo {\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n /** Permission IDs associated with this grantee */\n permissionIds: readonly bigint[];\n}\n\n/**\n * Parameters for registering a grantee\n *\n * @category Permissions\n */\nexport interface RegisterGranteeParams {\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n}\n\n/**\n * Input for registering a grantee with signature (gasless)\n *\n * @category Permissions\n */\nexport interface RegisterGranteeInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n}\n\n/**\n * EIP-712 typed data for RegisterGrantee\n *\n * @category Permissions\n */\nexport interface RegisterGranteeTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n RegisterGrantee: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"RegisterGrantee\";\n /** Message to sign */\n message: RegisterGranteeInput;\n}\n\n/**\n * Options for querying grantees\n *\n * @category Permissions\n */\nexport interface GranteeQueryOptions {\n /** Maximum number of grantees to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n /** Whether to include permission info or just basic info */\n includePermissions?: boolean;\n}\n\n/**\n * Paginated result for grantee queries\n *\n * @category Permissions\n */\nexport interface PaginatedGrantees {\n /** Array of grantees */\n grantees: Grantee[];\n /** Total number of grantees */\n total: number;\n /** Offset used for this query */\n offset: number;\n /** Limit used for this query */\n limit: number;\n /** Whether there are more grantees beyond this page */\n hasMore: boolean;\n}\n\n/**\n * Contract Permission structure as used in ServerFilesAndPermissionInput\n *\n * @category Permissions\n */\nexport interface Permission {\n /** Account address for the permission */\n account: Address;\n /** Permission key */\n key: string;\n}\n\n/**\n * Contract ServerFilesAndPermissionInput structure\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionInput {\n /** User nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n}\n\n/**\n * Parameters for server files and permissions operations\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionParams {\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL or grant data */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Schema IDs for each file - use 0 for files without schema validation */\n schemaIds: number[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n}\n\n/**\n * EIP-712 typed data for server files and permissions messages\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionTypedData extends GenericTypedData {\n /** Message data structure */\n message: {\n /** User nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Schema IDs for each file - use 0 for files without schema validation */\n schemaIds: bigint[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/permissions.ts"],"sourcesContent":["import type { Address, Hash } from \"viem\";\n\n/**\n * Base interface for types that need to be compatible with Record<string, unknown>\n *\n * @category Permissions\n */\nexport interface RecordCompatible {\n [key: string]: unknown;\n}\n\n/**\n * Contains on-chain permission data for efficient retrieval.\n *\n * @remarks\n * Provides fast access to permission metadata from subgraph without\n * IPFS calls. For detailed parameters, resolve `grantUrl` separately.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const grants = await vana.permissions.getUserPermissionGrantsOnChain();\n *\n * // Resolve details when needed\n * const details = await retrieveGrantFile(grants[0].grantUrl);\n * console.log(`Operation: ${details.operation}`);\n * ```\n */\nexport interface OnChainPermissionGrant {\n /** Unique identifier for the permission */\n id: bigint;\n /** The grant URL containing detailed permission parameters (IPFS link) */\n grantUrl: string;\n /** Cryptographic signature that authorized this permission */\n grantSignature: string;\n /** Nonce used when granting the permission */\n nonce: bigint;\n /** Block number when permission started */\n startBlock: bigint;\n /** Block number when permission ends (0 or MAX_UINT256 means no expiry) */\n endBlock: bigint;\n /** Block number when permission was granted */\n addedAtBlock: bigint;\n /** Timestamp when permission was added */\n addedAtTimestamp: bigint;\n /** Transaction hash of the grant transaction */\n transactionHash: string;\n /** Address that granted the permission */\n grantor: Address;\n /** Grantee information */\n grantee: {\n /** Grantee ID */\n id: string;\n /** Grantee address */\n address: string;\n };\n /** Whether the permission is still active (not revoked) */\n active: boolean;\n}\n\n/**\n * Options for retrieving user permissions\n *\n * @category Permissions\n */\nexport interface GetUserPermissionsOptions {\n /** Maximum number of permissions to retrieve */\n limit?: number;\n /** Whether to fetch all permissions (ignores limit) */\n fetchAll?: boolean;\n /** Custom subgraph URL to use for querying */\n subgraphUrl?: string;\n}\n\n/**\n * Defines parameters for granting file access permissions.\n *\n * @remarks\n * Specifies application, operation, files, and parameters for\n * permission grants via `vana.permissions.grant()`.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const params: GrantPermissionParams = {\n * grantee: '0x1234...',\n * operation: 'llm_inference',\n * files: [1, 2, 3],\n * parameters: { model: 'gpt-4', maxTokens: 1000 }\n * };\n * const result = await vana.permissions.grant(params);\n * ```\n */\nexport interface GrantPermissionParams {\n /** The on-chain identity of the application */\n grantee: Address;\n /** The class of computation, e.g., \"llm_inference\" */\n operation: string;\n /**\n * Array of file IDs to grant permission for.\n * Obtain file IDs from `vana.data.getUserFiles()` or from upload results via `vana.data.upload().fileId`.\n */\n files: number[];\n /** The full, off-chain parameters (e.g., LLM prompt) */\n parameters: Record<string, unknown>;\n /** Optional JSONPath filters to apply to files, keyed by file ID */\n filters?: Record<string, string>;\n /** Optional pre-stored grant URL to avoid duplicate IPFS storage */\n grantUrl?: string;\n /** Optional nonce for the permission */\n nonce?: bigint;\n /** Optional expiration time for the permission */\n expiresAt?: number;\n}\n\n/**\n * Parameters for revoking a previously granted data access permission.\n *\n * Used with `PermissionsController.revoke()` to remove an application's access\n * to user data. Once revoked, the application can no longer use the permission\n * to access the specified files.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const revokeParams: RevokePermissionParams = {\n * permissionId: 123n // Permission ID to revoke\n * };\n *\n * await vana.permissions.revoke(revokeParams);\n * ```\n */\nexport interface RevokePermissionParams {\n /** The permission ID to revoke */\n permissionId: bigint;\n}\n\n/**\n * Parameters for checking if a specific permission exists and is valid.\n *\n * Used to verify whether an application has active permission to access\n * specific user files for a particular operation before attempting to use the data.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const checkParams: CheckPermissionParams = {\n * application: '0x1234...', // App address\n * operation: 'llm_inference',\n * files: [1, 2, 3], // File IDs to check\n * parameters: { model: 'gpt-4' }, // Operation parameters\n * user: '0xabcd...' // Optional specific user\n * };\n *\n * const hasPermission = await vana.permissions.check(checkParams);\n * ```\n */\nexport interface CheckPermissionParams {\n /** The application address */\n application: Address;\n /** The operation type */\n operation: string;\n /** The file IDs */\n files: number[];\n /** The grant parameters */\n parameters: Record<string, unknown>;\n /** The user address */\n user?: Address;\n}\n\n/**\n * Permission check result\n *\n * @category Permissions\n */\nexport interface PermissionCheckResult {\n /** Whether the permission exists and is valid */\n exists: boolean;\n /** The permission details if it exists */\n permission?: GrantedPermission;\n /** Reason why permission is invalid (if applicable) */\n reason?: string;\n}\n\n/**\n * EIP-712 domain definition for PermissionGrant signatures\n *\n * @category Permissions\n */\nexport interface PermissionGrantDomain {\n /** Domain name */\n name: string;\n /** Domain version */\n version: string;\n /** Chain ID */\n chainId: number;\n /** Verifying contract address */\n verifyingContract: Address;\n}\n\n/**\n * EIP-712 Permission message structure (current contract format)\n *\n * @category Permissions\n */\nexport interface PermissionGrantMessage {\n /** Application address */\n application: Address;\n /** File IDs */\n files: number[];\n /** Operation type */\n operation: string;\n /** Grant URL */\n grant: string;\n /** Parameters as JSON string */\n parameters: string;\n /** Nonce */\n nonce: bigint;\n}\n\n/**\n * EIP-712 PermissionInput message structure (new simplified format)\n *\n * @category Permissions\n */\nexport interface PermissionInputMessage extends RecordCompatible {\n /** Nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File IDs */\n fileIds: bigint[];\n}\n\n/**\n * Contract PermissionInput structure\n *\n * @category Permissions\n */\nexport interface PermissionInput {\n /** Nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File IDs to grant permission for */\n fileIds: bigint[];\n}\n\n/**\n * Contract RevokePermissionInput structure\n *\n * @category Permissions\n */\nexport interface RevokePermissionInput extends RecordCompatible {\n /** Nonce */\n nonce: bigint;\n /** Permission ID to revoke */\n permissionId: bigint;\n}\n\n/**\n * Contract Permission Info structure returned from the contract\n *\n * @category Permissions\n */\nexport interface PermissionInfo {\n /** Permission ID */\n id: bigint;\n /** Address that granted the permission */\n grantor: Address;\n /** Nonce used when creating */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** Signature bytes (removed in newer contract versions) */\n signature?: `0x${string}`;\n /** Start block */\n startBlock: bigint;\n /** End block */\n endBlock: bigint;\n /** File IDs associated with this permission */\n fileIds: readonly bigint[];\n}\n\n/**\n * EIP-712 Permission message structure (simplified future format)\n *\n * @category Permissions\n */\nexport interface SimplifiedPermissionMessage {\n /** Application address */\n application: Address;\n /** Grant URL */\n grant: string;\n /** Nonce */\n nonce: bigint;\n}\n\n/**\n * Grant file structure containing permission details.\n *\n * Grant files contain the complete specification of what an application is permitted\n * to do with user data, including operation parameters and file access rights.\n *\n * @category Permissions\n * @example\n * ```typescript\n * const grantFile: GrantFile = {\n * grantee: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',\n * operation: 'llm_inference',\n * parameters: {\n * prompt: 'Analyze this data: {{data}}',\n * model: 'gpt-4',\n * maxTokens: 2000,\n * temperature: 0.7\n * },\n * expires: 1736467579\n * };\n * ```\n */\nexport interface GrantFile {\n /** EVM address of the application authorized to use this grant */\n grantee: Address;\n /** Operation the grantee is authorized to perform */\n operation: string;\n /** Operation-specific parameters */\n parameters: Record<string, unknown>;\n /** Optional Unix timestamp when grant expires (seconds since epoch per POSIX.1-2008) */\n expires?: number;\n}\n\n/**\n * EIP-712 typed data structure for Permission\n *\n * @category Permissions\n */\nexport interface PermissionGrantTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n Permission: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"Permission\";\n /** Message to sign */\n message: PermissionInputMessage;\n}\n\n/**\n * Generic EIP-712 typed data structure\n *\n * @category Permissions\n */\nexport interface GenericTypedData extends RecordCompatible {\n /** EIP-712 domain */\n domain: PermissionGrantDomain;\n /** EIP-712 types */\n types: Record<string, Array<{ name: string; type: string }>>;\n /** Primary type */\n primaryType: string;\n /** Message to sign */\n message: Record<string, unknown>;\n}\n\n/**\n * Represents EIP-712 typed data for permission revocation.\n *\n * @remarks\n * Used when revoking previously granted permissions through gasless transactions.\n * The message contains a nonce and the permission ID to revoke.\n *\n * @category Permissions\n */\nexport interface RevokePermissionTypedData extends GenericTypedData {\n /** EIP-712 type definitions for the RevokePermission structure */\n types: {\n RevokePermission: Array<{\n name: string;\n type: string;\n }>;\n };\n /** The primary type identifier for revocation operations */\n primaryType: \"RevokePermission\";\n /** The structured message containing revocation parameters */\n message: RevokePermissionInput;\n}\n\n/**\n * Defines all valid primary types for EIP-712 typed data in the Vana SDK.\n *\n * @remarks\n * These literal types ensure compile-time safety when handling typed data operations.\n * Each corresponds to a specific blockchain operation type.\n *\n * @category Permissions\n */\nexport type TypedDataPrimaryType =\n | \"Permission\"\n | \"RevokePermission\"\n | \"TrustServer\"\n | \"UntrustServer\"\n | \"AddServer\"\n | \"RegisterGrantee\"\n | \"ServerFilesAndPermission\";\n\n/**\n * Represents the union of all specific typed data interfaces.\n *\n * @remarks\n * Enables type-safe handling of any typed data structure in the SDK.\n * Used internally by relayer handlers and signature verification.\n *\n * @category Permissions\n */\nexport type SpecificTypedData =\n | PermissionGrantTypedData\n | RevokePermissionTypedData\n | TrustServerTypedData\n | UntrustServerTypedData\n | AddAndTrustServerTypedData\n | RegisterGranteeTypedData\n | ServerFilesAndPermissionTypedData;\n\n/**\n * Permission operation types\n *\n * @category Permissions\n */\nexport type PermissionOperation =\n | \"llm_inference\"\n | \"data_analysis\"\n | \"model_training\"\n | \"data_sharing\"\n | \"compute_task\"\n | string;\n\n/**\n * Permission status\n *\n * @category Permissions\n */\nexport type PermissionStatus = \"active\" | \"revoked\" | \"expired\" | \"pending\";\n\n/**\n * Parameters for querying permissions\n *\n * @category Permissions\n */\nexport interface QueryPermissionsParams {\n /** Filter by grantor address */\n grantor?: Address;\n /** Filter by grantee address */\n grantee?: Address;\n /** Filter by operation type */\n operation?: PermissionOperation;\n /** Filter by file IDs */\n files?: number[];\n /** Filter by status */\n status?: PermissionStatus;\n /** Starting block number */\n fromBlock?: bigint;\n /** Ending block number */\n toBlock?: bigint;\n /** Maximum number of results */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n}\n\n/**\n * Granted permission details\n *\n * @category Permissions\n */\nexport interface GrantedPermission {\n /** Unique identifier for the permission */\n id: bigint;\n /** Array of file IDs that the permission applies to */\n files: number[];\n /** The type of operation being granted permission for */\n operation: string;\n /** Grant file reference (IPFS hash or URL) */\n grant: string;\n /** Address of the application granted permission */\n grantee: Address;\n /** Address of the user who granted permission */\n grantor: Address;\n /** Custom parameters for the operation */\n parameters: Record<string, unknown>;\n /** Whether the permission is still active */\n active: boolean;\n /** Data status for the permission */\n dataStatus?: string;\n /** Nonce used for the permission */\n nonce?: number;\n /** Timestamp when permission was granted */\n grantedAt?: number;\n /** Optional expiration timestamp */\n expiresAt?: number;\n /** Transaction hash of the grant transaction */\n transactionHash?: string;\n /** Block number when permission was granted */\n blockNumber?: bigint;\n}\n\n/**\n * Permission query result\n *\n * @category Permissions\n */\nexport interface PermissionQueryResult {\n /** Array of permissions matching the query */\n permissions: GrantedPermission[];\n /** Total number of permissions (for pagination) */\n total: number;\n /** Whether there are more results available */\n hasMore: boolean;\n}\n\n/**\n * Permission analytics data\n *\n * @category Permissions\n */\nexport interface PermissionAnalytics {\n /** Total number of permissions granted */\n totalPermissions: number;\n /** Number of active permissions */\n activePermissions: number;\n /** Number of revoked permissions */\n revokedPermissions: number;\n /** Number of expired permissions */\n expiredPermissions: number;\n /** Most common operation types */\n topOperations: Array<{\n operation: PermissionOperation;\n count: number;\n }>;\n /** Most active applications */\n topApplications: Array<{\n application: Address;\n count: number;\n }>;\n}\n\n/**\n * Server information\n *\n * @category Permissions\n */\nexport interface Server {\n /** Server ID (numeric) */\n id: number;\n /** Server owner address */\n owner: Address;\n /** Server URL */\n url: string;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Contract ServerInfo structure returned from the contract\n *\n * @category Permissions\n */\nexport interface ServerInfo {\n /** Server ID */\n id: bigint;\n /** Server owner address */\n owner: Address;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n /** Server URL */\n url: string;\n}\n\n/**\n * Parameters for adding and trusting a server\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerParams {\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Parameters for trusting a server (legacy)\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerParams instead\n */\nexport interface TrustServerParams {\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Parameters for untrusting a server\n *\n * @category Permissions\n */\nexport interface UntrustServerParams {\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Input for adding and trusting a server with signature (gasless)\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n publicKey: string;\n}\n\n/**\n * Input for trusting a server with signature (gasless)\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerInput instead\n */\nexport interface TrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * Input for untrusting a server with signature (gasless)\n *\n * @category Permissions\n */\nexport interface UntrustServerInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Server ID (numeric) */\n serverId: number;\n}\n\n/**\n * EIP-712 typed data for AddAndTrustServer\n *\n * @category Permissions\n */\nexport interface AddAndTrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n AddServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"AddServer\";\n /** Message to sign */\n message: AddAndTrustServerInput;\n}\n\n/**\n * EIP-712 typed data for TrustServer\n *\n * @category Permissions\n * @deprecated Use AddAndTrustServerTypedData instead\n */\nexport interface TrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n TrustServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"TrustServer\";\n /** Message to sign */\n message: TrustServerInput;\n}\n\n/**\n * EIP-712 typed data for UntrustServer\n *\n * @category Permissions\n */\nexport interface UntrustServerTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n UntrustServer: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"UntrustServer\";\n /** Message to sign */\n message: UntrustServerInput;\n}\n\n/**\n * Permission event data\n *\n * @category Permissions\n */\nexport interface PermissionEvent {\n /** Event type */\n type: \"granted\" | \"revoked\" | \"expired\";\n /** Permission details */\n permission: GrantedPermission;\n /** Block number where event occurred */\n blockNumber: bigint;\n /** Transaction hash */\n transactionHash: Hash;\n /** Event timestamp */\n timestamp: number;\n}\n\n/**\n * Enhanced trusted server information with trust status\n *\n * @category Permissions\n */\nexport interface TrustedServerInfo {\n /** Server ID */\n id: bigint;\n /** Server owner address */\n owner: Address;\n /** Server address */\n serverAddress: Address;\n /** Server public key */\n publicKey: string;\n /** Server URL */\n url: string;\n /** Start block when trust relationship began */\n startBlock: bigint;\n /** End block when trust relationship ended (0 if still active) */\n endBlock: bigint;\n}\n\n/**\n * Paginated result for trusted server queries\n *\n * @category Permissions\n */\nexport interface PaginatedTrustedServers {\n /** Array of server IDs (numeric) */\n servers: number[];\n /** Total number of trusted servers */\n total: number;\n /** Offset used for this query */\n offset: number;\n /** Limit used for this query */\n limit: number;\n /** Whether there are more servers beyond this page */\n hasMore: boolean;\n}\n\n/**\n * Options for querying trusted servers\n *\n * @category Permissions\n */\nexport interface TrustedServerQueryOptions {\n /** User address to query (defaults to current user) */\n userAddress?: Address;\n /** Maximum number of servers to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n /** Whether to include full server info or just IDs */\n includeServerInfo?: boolean;\n}\n\n/**\n * Result of batch server info requests\n *\n * @category Permissions\n */\nexport interface BatchServerInfoResult {\n /** Successfully retrieved server info */\n servers: Map<number, Server>;\n /** Server IDs that failed to retrieve */\n failed: number[];\n}\n\n/**\n * Server trust status information\n *\n * @category Permissions\n */\nexport interface ServerTrustStatus {\n /** Server ID being checked (numeric) */\n serverId: number;\n /** Whether the server is trusted by the user */\n isTrusted: boolean;\n /** Index in user's trusted server list (if trusted) */\n trustIndex?: number;\n}\n\n/**\n * Grantee information\n *\n * @category Permissions\n */\nexport interface Grantee {\n /** Grantee ID (numeric) */\n id: number;\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n address: Address;\n /** Grantee public key */\n publicKey: string;\n /** Permission IDs associated with this grantee */\n permissionIds: number[];\n}\n\n/**\n * Contract GranteeInfo structure returned from the contract\n *\n * @category Permissions\n */\nexport interface GranteeInfo {\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n /** Permission IDs associated with this grantee */\n permissionIds: readonly bigint[];\n}\n\n/**\n * Parameters for registering a grantee\n *\n * @category Permissions\n */\nexport interface RegisterGranteeParams {\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n}\n\n/**\n * Input for registering a grantee with signature (gasless)\n *\n * @category Permissions\n */\nexport interface RegisterGranteeInput extends RecordCompatible {\n /** User nonce */\n nonce: bigint;\n /** Grantee owner address */\n owner: Address;\n /** Grantee address */\n granteeAddress: Address;\n /** Grantee public key */\n publicKey: string;\n}\n\n/**\n * EIP-712 typed data for RegisterGrantee\n *\n * @category Permissions\n */\nexport interface RegisterGranteeTypedData extends GenericTypedData {\n /** EIP-712 types */\n types: {\n RegisterGrantee: Array<{\n name: string;\n type: string;\n }>;\n };\n /** Primary type */\n primaryType: \"RegisterGrantee\";\n /** Message to sign */\n message: RegisterGranteeInput;\n}\n\n/**\n * Options for querying grantees\n *\n * @category Permissions\n */\nexport interface GranteeQueryOptions {\n /** Maximum number of grantees to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n /** Whether to include permission info or just basic info */\n includePermissions?: boolean;\n}\n\n/**\n * Paginated result for grantee queries\n *\n * @category Permissions\n */\nexport interface PaginatedGrantees {\n /** Array of grantees */\n grantees: Grantee[];\n /** Total number of grantees */\n total: number;\n /** Offset used for this query */\n offset: number;\n /** Limit used for this query */\n limit: number;\n /** Whether there are more grantees beyond this page */\n hasMore: boolean;\n}\n\n/**\n * Contract Permission structure as used in ServerFilesAndPermissionInput\n *\n * @category Permissions\n */\nexport interface Permission {\n /** Account address for the permission */\n account: Address;\n /** Permission key */\n key: string;\n}\n\n/**\n * Contract ServerFilesAndPermissionInput structure\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionInput {\n /** User nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n}\n\n/**\n * Parameters for server files and permissions operations\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionParams {\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL or grant data */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Schema IDs for each file - use 0 for files without schema validation */\n schemaIds: number[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n}\n\n/**\n * EIP-712 typed data for server files and permissions messages\n *\n * @category Permissions\n */\nexport interface ServerFilesAndPermissionTypedData extends GenericTypedData {\n /** Message data structure */\n message: {\n /** User nonce */\n nonce: bigint;\n /** Grantee ID */\n granteeId: bigint;\n /** Grant URL */\n grant: string;\n /** File URLs */\n fileUrls: string[];\n /** Schema IDs for each file - use 0 for files without schema validation */\n schemaIds: bigint[];\n /** Server address */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Server public key */\n serverPublicKey: string;\n /** File permissions array - permissions for each file */\n filePermissions: Permission[][];\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -35,6 +35,8 @@ export interface OnChainPermissionGrant {
|
|
|
35
35
|
nonce: bigint;
|
|
36
36
|
/** Block number when permission started */
|
|
37
37
|
startBlock: bigint;
|
|
38
|
+
/** Block number when permission ends (0 or MAX_UINT256 means no expiry) */
|
|
39
|
+
endBlock: bigint;
|
|
38
40
|
/** Block number when permission was granted */
|
|
39
41
|
addedAtBlock: bigint;
|
|
40
42
|
/** Timestamp when permission was added */
|