@opendatalabs/vana-sdk 0.1.0-alpha.2b6935d → 0.1.0-alpha.2e77fcc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +33 -1
- package/dist/browser.js.map +1 -1
- package/dist/chains/index.cjs.map +1 -1
- package/dist/chains/index.d.ts +30 -1
- package/dist/chains/index.js.map +1 -1
- package/dist/config/chains.cjs.map +1 -1
- package/dist/config/chains.d.ts +99 -0
- package/dist/config/chains.js.map +1 -1
- package/dist/contracts/contractController.cjs.map +1 -1
- package/dist/contracts/contractController.d.ts +66 -10
- package/dist/contracts/contractController.js.map +1 -1
- package/dist/controllers/base.cjs +33 -0
- package/dist/controllers/base.cjs.map +1 -1
- package/dist/controllers/base.d.ts +10 -0
- package/dist/controllers/base.js +33 -0
- package/dist/controllers/base.js.map +1 -1
- package/dist/controllers/data.cjs +162 -133
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +222 -184
- package/dist/controllers/data.js +162 -133
- package/dist/controllers/data.js.map +1 -1
- package/dist/controllers/permissions.cjs +208 -60
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +75 -45
- package/dist/controllers/permissions.js +208 -60
- package/dist/controllers/permissions.js.map +1 -1
- package/dist/controllers/protocol.cjs.map +1 -1
- package/dist/controllers/protocol.d.ts +27 -28
- package/dist/controllers/protocol.js.map +1 -1
- package/dist/controllers/schemas.cjs +23 -21
- package/dist/controllers/schemas.cjs.map +1 -1
- package/dist/controllers/schemas.d.ts +47 -40
- package/dist/controllers/schemas.js +23 -21
- package/dist/controllers/schemas.js.map +1 -1
- package/dist/controllers/server.cjs +17 -15
- package/dist/controllers/server.cjs.map +1 -1
- package/dist/controllers/server.d.ts +46 -38
- package/dist/controllers/server.js +17 -15
- package/dist/controllers/server.js.map +1 -1
- package/dist/core/apiClient.cjs +53 -3
- package/dist/core/apiClient.cjs.map +1 -1
- package/dist/core/apiClient.d.ts +132 -7
- package/dist/core/apiClient.js +53 -3
- package/dist/core/apiClient.js.map +1 -1
- package/dist/core/generics.cjs +30 -3
- package/dist/core/generics.cjs.map +1 -1
- package/dist/core/generics.d.ts +95 -6
- package/dist/core/generics.js +30 -3
- package/dist/core/generics.js.map +1 -1
- package/dist/core.cjs +4 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +2 -1
- package/dist/core.js +4 -1
- package/dist/core.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +2 -3
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +33 -13
- package/dist/index.node.js +2 -2
- package/dist/index.node.js.map +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +39 -1
- package/dist/node.js.map +1 -1
- package/dist/platform/browser.cjs +160 -2
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +232 -12
- package/dist/platform/browser.js +160 -2
- package/dist/platform/browser.js.map +1 -1
- package/dist/platform/interface.cjs.map +1 -1
- package/dist/platform/interface.d.ts +283 -90
- package/dist/platform/node.cjs +163 -2
- package/dist/platform/node.cjs.map +1 -1
- package/dist/platform/node.d.ts +69 -6
- package/dist/platform/node.js +163 -2
- package/dist/platform/node.js.map +1 -1
- package/dist/server/relayerHandler.cjs +136 -98
- package/dist/server/relayerHandler.cjs.map +1 -1
- package/dist/server/relayerHandler.d.ts +3 -2
- package/dist/server/relayerHandler.js +135 -96
- package/dist/server/relayerHandler.js.map +1 -1
- package/dist/storage/manager.cjs +108 -25
- package/dist/storage/manager.cjs.map +1 -1
- package/dist/storage/manager.d.ts +119 -25
- package/dist/storage/manager.js +108 -25
- package/dist/storage/manager.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +86 -15
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.d.ts +109 -20
- package/dist/storage/providers/callback-storage.js +86 -15
- package/dist/storage/providers/callback-storage.js.map +1 -1
- package/dist/storage/providers/pinata.cjs.map +1 -1
- package/dist/storage/providers/pinata.d.ts +12 -14
- package/dist/storage/providers/pinata.js.map +1 -1
- package/dist/types/blockchain.cjs.map +1 -1
- package/dist/types/blockchain.d.ts +39 -11
- package/dist/types/chains.cjs.map +1 -1
- package/dist/types/chains.d.ts +74 -7
- package/dist/types/chains.js.map +1 -1
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.ts +38 -4
- package/dist/types/config.js.map +1 -1
- package/dist/types/contracts.cjs.map +1 -1
- package/dist/types/contracts.d.ts +71 -7
- package/dist/types/controller-context.cjs.map +1 -1
- package/dist/types/controller-context.d.ts +3 -1
- package/dist/types/data.cjs.map +1 -1
- package/dist/types/data.d.ts +4 -6
- package/dist/types/generics.cjs.map +1 -1
- package/dist/types/generics.d.ts +81 -10
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +28 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/operations.cjs.map +1 -1
- package/dist/types/operations.d.ts +178 -15
- package/dist/types/operations.js.map +1 -1
- package/dist/types/permissions.cjs.map +1 -1
- package/dist/types/permissions.d.ts +15 -20
- package/dist/types/personal.cjs.map +1 -1
- package/dist/types/personal.d.ts +131 -14
- package/dist/types/relayer.cjs.map +1 -1
- package/dist/types/relayer.d.ts +114 -18
- package/dist/types/storage.cjs.map +1 -1
- package/dist/types/storage.d.ts +9 -21
- package/dist/types/storage.js.map +1 -1
- package/dist/types/utils.cjs.map +1 -1
- package/dist/types/utils.d.ts +5 -1
- package/dist/utils/grantFiles.cjs.map +1 -1
- package/dist/utils/grantFiles.d.ts +10 -20
- package/dist/utils/grantFiles.js.map +1 -1
- package/dist/utils/grantValidation.cjs.map +1 -1
- package/dist/utils/grantValidation.d.ts +95 -16
- package/dist/utils/grantValidation.js.map +1 -1
- package/dist/utils/grants.cjs.map +1 -1
- package/dist/utils/grants.d.ts +93 -12
- package/dist/utils/grants.js.map +1 -1
- package/dist/utils/ipfs.cjs +2 -4
- package/dist/utils/ipfs.cjs.map +1 -1
- package/dist/utils/ipfs.d.ts +1 -1
- package/dist/utils/ipfs.js +2 -4
- package/dist/utils/ipfs.js.map +1 -1
- package/dist/utils/lazy-import.cjs.map +1 -1
- package/dist/utils/lazy-import.d.ts +32 -7
- package/dist/utils/lazy-import.js.map +1 -1
- package/dist/utils/signatureCache.cjs +8 -2
- package/dist/utils/signatureCache.cjs.map +1 -1
- package/dist/utils/signatureCache.d.ts +49 -8
- package/dist/utils/signatureCache.js +8 -2
- package/dist/utils/signatureCache.js.map +1 -1
- package/dist/utils/transactionHelpers.cjs.map +1 -1
- package/dist/utils/transactionHelpers.d.ts +12 -12
- package/dist/utils/transactionHelpers.js.map +1 -1
- package/dist/utils/typedDataConverter.cjs.map +1 -1
- package/dist/utils/typedDataConverter.d.ts +39 -3
- package/dist/utils/typedDataConverter.js.map +1 -1
- package/dist/utils/urlResolver.cjs +7 -0
- package/dist/utils/urlResolver.cjs.map +1 -1
- package/dist/utils/urlResolver.d.ts +22 -4
- package/dist/utils/urlResolver.js +7 -0
- package/dist/utils/urlResolver.js.map +1 -1
- package/dist/utils/wallet.cjs.map +1 -1
- package/dist/utils/wallet.d.ts +78 -16
- package/dist/utils/wallet.js.map +1 -1
- package/package.json +3 -1
- package/dist/server/handler.cjs +0 -103
- package/dist/server/handler.cjs.map +0 -1
- package/dist/server/handler.d.ts +0 -95
- package/dist/server/handler.js +0 -79
- package/dist/server/handler.js.map +0 -1
- /package/dist/tests/{server-handler.test.d.ts → permissions-transaction-options.test.d.ts} +0 -0
package/dist/types/personal.d.ts
CHANGED
|
@@ -1,38 +1,155 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Defines parameters for posting data requests to personal servers.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Used to initiate data access requests that require user permission.
|
|
6
|
+
* The permission ID references a previously granted permission that
|
|
7
|
+
* authorizes the requester to access specific user data.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const params: PostRequestParams = {
|
|
12
|
+
* permissionId: 123
|
|
13
|
+
* };
|
|
14
|
+
*
|
|
15
|
+
* const response = await vana.personal.postRequest(params);
|
|
16
|
+
* console.log('Request posted:', response.requestId);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @category Personal Server
|
|
3
20
|
*/
|
|
4
21
|
export interface PostRequestParams {
|
|
5
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* References a granted permission authorizing data access.
|
|
24
|
+
* Obtain via permission granting flow or query existing permissions.
|
|
25
|
+
* @throws {PermissionNotFoundError} If permission ID is invalid.
|
|
26
|
+
*/
|
|
6
27
|
permissionId: number;
|
|
7
28
|
}
|
|
8
29
|
/**
|
|
9
|
-
*
|
|
30
|
+
* Defines parameters for creating server-side operations.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Initiates asynchronous operations on the personal server that
|
|
34
|
+
* process user data according to granted permissions. Operations
|
|
35
|
+
* run in the background and can be monitored via their operation ID.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const params: CreateOperationParams = {
|
|
40
|
+
* permissionId: 456
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* const operation = await vana.server.createOperation(params);
|
|
44
|
+
* // Monitor operation status
|
|
45
|
+
* const status = await vana.server.getOperationStatus(operation.id);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @category Personal Server
|
|
10
49
|
*/
|
|
11
50
|
export interface CreateOperationParams {
|
|
12
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* References the permission scope for this operation.
|
|
53
|
+
* Determines what data and actions are allowed.
|
|
54
|
+
* @throws {InsufficientPermissionsError} If permission scope is inadequate.
|
|
55
|
+
*/
|
|
13
56
|
permissionId: number;
|
|
14
57
|
}
|
|
15
58
|
/**
|
|
16
|
-
*
|
|
59
|
+
* Defines parameters for initializing personal server connections.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Establishes secure communication channels with a user's personal
|
|
63
|
+
* data server. The server manages encrypted user data and enforces
|
|
64
|
+
* permission-based access control. Initialization includes key exchange
|
|
65
|
+
* and session establishment.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const params: InitPersonalServerParams = {
|
|
70
|
+
* userAddress: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36'
|
|
71
|
+
* };
|
|
72
|
+
*
|
|
73
|
+
* const server = await vana.personal.initServer(params);
|
|
74
|
+
* console.log('Connected to server:', server.baseUrl);
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @category Personal Server
|
|
17
78
|
*/
|
|
18
79
|
export interface InitPersonalServerParams {
|
|
19
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Identifies the user whose personal server to connect to.
|
|
82
|
+
* Must be a valid Ethereum address in hex format.
|
|
83
|
+
* @example '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36'
|
|
84
|
+
*/
|
|
20
85
|
userAddress: string;
|
|
21
86
|
}
|
|
22
87
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
88
|
+
* Represents comprehensive personal server identity and connection information.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* Combines core server identity with connection metadata required for
|
|
92
|
+
* establishing secure communication. Personal servers are user-controlled
|
|
93
|
+
* nodes that store and serve encrypted personal data according to
|
|
94
|
+
* user-defined permissions. This interface provides all necessary
|
|
95
|
+
* information to connect to and interact with a personal server.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const identity: PersonalServerIdentity = {
|
|
100
|
+
* kind: 'PersonalServer',
|
|
101
|
+
* address: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',
|
|
102
|
+
* publicKey: '0x04...', // 65-byte uncompressed public key
|
|
103
|
+
* baseUrl: 'https://ps.user.vana.com',
|
|
104
|
+
* name: 'User Personal Server #1'
|
|
105
|
+
* };
|
|
106
|
+
*
|
|
107
|
+
* // Use identity to establish encrypted connection
|
|
108
|
+
* const encrypted = await crypto.encrypt(data, identity.publicKey);
|
|
109
|
+
* const response = await fetch(`${identity.baseUrl}/api/data`, {
|
|
110
|
+
* method: 'POST',
|
|
111
|
+
* body: encrypted
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @category Personal Server
|
|
26
116
|
*/
|
|
27
117
|
export interface PersonalServerIdentity {
|
|
28
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Identifies the resource type for API disambiguation.
|
|
120
|
+
* Always 'PersonalServer' for personal server instances.
|
|
121
|
+
*/
|
|
29
122
|
kind: string;
|
|
30
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Uniquely identifies the server on the blockchain.
|
|
125
|
+
* Used for permission verification and identity proofs.
|
|
126
|
+
* @example '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36'
|
|
127
|
+
*/
|
|
31
128
|
address: string;
|
|
32
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Enables end-to-end encryption for data transmission.
|
|
131
|
+
* Must be in uncompressed format (65 bytes with 0x04 prefix).
|
|
132
|
+
* @example '0x04...' (130 hex characters)
|
|
133
|
+
*/
|
|
33
134
|
publicKey: string;
|
|
34
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Provides the HTTPS endpoint for server API requests.
|
|
137
|
+
* Should not include trailing slashes or API paths.
|
|
138
|
+
* @example 'https://ps.user.vana.com'
|
|
139
|
+
*/
|
|
35
140
|
baseUrl: string;
|
|
36
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Displays a user-friendly identifier for the server.
|
|
143
|
+
* Used in UI components and logging for clarity.
|
|
144
|
+
* @example 'Primary Data Server'
|
|
145
|
+
*/
|
|
37
146
|
name: string;
|
|
38
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* @remarks
|
|
150
|
+
* Additional server response types are auto-generated from the OpenAPI
|
|
151
|
+
* specification and available in the server-exports module. Import those
|
|
152
|
+
* types directly when working with server API responses.
|
|
153
|
+
*
|
|
154
|
+
* @see {@link ../types/server-exports | Server Export Types}
|
|
155
|
+
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/relayer.ts"],"sourcesContent":["import type { Hash, Address } from \"viem\";\nimport type {\n GrantFile,\n PermissionGrantTypedData,\n GenericTypedData,\n} from \"./permissions\";\n\n/**\n * Response from the relayer service for grant file storage\n *\n * @category Advanced\n */\nexport interface RelayerStorageResponse {\n /** The IPFS URL where the grant file is stored */\n grantUrl: string;\n /** Success status */\n success: boolean;\n /** Optional error message */\n error?: string;\n /** Storage metadata */\n metadata?: {\n /** IPFS hash */\n ipfsHash: string;\n /** File size in bytes */\n size: number;\n /** Upload timestamp */\n timestamp: number;\n };\n}\n\n/**\n * Response from the relayer service for transaction submission\n *\n * @category Advanced\n */\nexport interface RelayerTransactionResponse {\n /** The transaction hash of the submitted transaction */\n transactionHash: Hash;\n /** Success status */\n success: boolean;\n /** Optional error message */\n error?: string;\n /** Transaction metadata */\n metadata?: {\n /** Gas used */\n gasUsed?: bigint;\n /** Gas price */\n gasPrice?: bigint;\n /** Block number */\n blockNumber?: bigint;\n /** Transaction status */\n status?: \"pending\" | \"confirmed\" | \"failed\";\n };\n}\n\n/**\n * Parameters for storing a grant file via relayer\n *\n * @category Advanced\n */\nexport interface RelayerStoreParams {\n /** The grant file to store */\n grantFile: GrantFile;\n /** Optional storage options */\n options?: {\n /** IPFS pin duration in seconds */\n pinDuration?: number;\n /** Whether to use encryption */\n encrypt?: boolean;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n };\n}\n\n/**\n * Parameters for submitting a transaction via relayer\n *\n * @category Advanced\n */\nexport interface RelayerSubmitParams {\n /** The signed typed data */\n typedData: PermissionGrantTypedData;\n /** The signature */\n signature: string;\n /** Optional transaction options */\n options?: {\n /** Gas limit */\n gasLimit?: bigint;\n /** Priority level */\n priority?: \"low\" | \"medium\" | \"high\";\n /** Whether to wait for confirmation */\n waitForConfirmation?: boolean;\n };\n}\n\n/**\n * Relayer service status\n *\n * @category Advanced\n */\nexport interface RelayerStatus {\n /** Whether the relayer is online */\n online: boolean;\n /** Service version */\n version: string;\n /** Supported chains */\n supportedChains: number[];\n /** Current chain status */\n chainStatus: Record<\n number,\n {\n /** Whether the chain is supported */\n supported: boolean;\n /** Current block number */\n currentBlock: bigint;\n /** Gas price estimation */\n gasPrice: bigint;\n /** Queue size */\n queueSize: number;\n }\n >;\n /** Rate limit information */\n rateLimits: {\n /** Requests per minute */\n requestsPerMinute: number;\n /** Storage requests per hour */\n storageRequestsPerHour: number;\n /** Transaction requests per hour */\n transactionRequestsPerHour: number;\n };\n}\n\n/**\n * Relayer request options\n *\n * @category Advanced\n */\nexport interface RelayerRequestOptions {\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Whether to retry on failure */\n retry?: boolean;\n /** Custom headers */\n headers?: Record<string, string>;\n /** Request priority */\n priority?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * Relayer error response\n *\n * @category Advanced\n */\nexport interface RelayerErrorResponse {\n /** Error code */\n code: string;\n /** Error message */\n message: string;\n /** Additional error details */\n details?: Record<string, unknown>;\n /** Request ID for debugging */\n requestId?: string;\n /** Timestamp of error */\n timestamp: number;\n}\n\n/**\n * Relayer queue information\n *\n * @category Advanced\n */\nexport interface RelayerQueueInfo {\n /** Current queue size */\n size: number;\n /** Estimated processing time in seconds */\n estimatedProcessingTime: number;\n /** Queue position for a specific request */\n position?: number;\n /** Processing statistics */\n stats: {\n /** Average processing time in seconds */\n averageProcessingTime: number;\n /** Requests processed in last hour */\n requestsProcessedHour: number;\n /** Success rate percentage */\n successRate: number;\n };\n}\n\n/**\n * Relayer transaction status\n *\n * @category Advanced\n */\nexport interface RelayerTransactionStatus {\n /** Transaction hash */\n transactionHash: Hash;\n /** Current status */\n status: \"pending\" | \"confirmed\" | \"failed\";\n /** Block number if confirmed */\n blockNumber?: bigint;\n /** Gas used */\n gasUsed?: bigint;\n /** Error message if failed */\n error?: string;\n /** Status checks performed */\n checks: Array<{\n /** Check timestamp */\n timestamp: number;\n /** Status at time of check */\n status: string;\n /** Block number at time of check */\n blockNumber: bigint;\n }>;\n}\n\n/**\n * Relayer metrics\n *\n * @category Advanced\n */\nexport interface RelayerMetrics {\n /** Total transactions processed */\n totalTransactions: number;\n /** Successful transactions */\n successfulTransactions: number;\n /** Failed transactions */\n failedTransactions: number;\n /** Average processing time in seconds */\n averageProcessingTime: number;\n /** Current queue size */\n queueSize: number;\n /** Uptime percentage */\n uptime: number;\n /** Last 24 hour statistics */\n last24Hours: {\n /** Transactions processed */\n transactions: number;\n /** Success rate */\n successRate: number;\n /** Average response time */\n averageResponseTime: number;\n };\n}\n\n/**\n * Relayer webhook configuration\n *\n * @category Advanced\n */\nexport interface RelayerWebhookConfig {\n /** Webhook URL */\n url: string;\n /** Events to subscribe to */\n events: Array<\n \"transaction_confirmed\" | \"transaction_failed\" | \"storage_complete\"\n >;\n /** Webhook secret for signature verification */\n secret?: string;\n /** Whether webhook is active */\n active: boolean;\n}\n\n/**\n * Relayer webhook payload\n *\n * @category Advanced\n */\nexport interface RelayerWebhookPayload {\n /** Event type */\n event: string;\n /** Event data */\n data: Record<string, unknown>;\n /** Timestamp */\n timestamp: number;\n /** Webhook ID */\n webhookId: string;\n /** Signature for verification */\n signature: string;\n}\n\n// ===== NEW SIMPLIFIED RELAYER TYPES (v2) =====\n\n/**\n * Handles both EIP-712 signed operations and direct server operations through a single interface.\n *\n * @remarks\n * This discriminated union provides type safety through TypeScript's narrowing.\n * The `type` field determines which operation variant is being used.\n * Signed operations require blockchain transactions, while direct operations\n * handle auxiliary tasks like file storage.\n *\n * @category Relayer\n * @see {@link https://docs.vana.org/docs/gasless-transactions | Gasless Transactions Guide}\n */\nexport type UnifiedRelayerRequest = SignedRelayerRequest | DirectRelayerRequest;\n\n/**\n * Represents an EIP-712 signed operation for gasless transaction submission.\n *\n * @remarks\n * Signed requests contain typed data and signatures that are verified\n * on-chain by smart contracts. The relayer pays gas fees on behalf of users.\n *\n * @category Relayer\n */\nexport interface SignedRelayerRequest {\n /** Discriminator field identifying this as a signed operation */\n type: \"signed\";\n /** Operation identifier for routing (e.g., 'submitAddPermission') */\n operation: SignedOperationType;\n /** EIP-712 typed data structure for the operation */\n typedData: GenericTypedData;\n /** User's signature of the typed data */\n signature: Hash;\n /** Optional address for additional signer verification */\n expectedUserAddress?: Address;\n}\n\n/**\n * Supported signed operation types.\n * @category Relayer\n */\nexport type SignedOperationType =\n | \"submitAddPermission\"\n | \"submitPermissionRevoke\"\n | \"submitTrustServer\"\n | \"submitAddAndTrustServer\"\n | \"submitUntrustServer\"\n | \"submitAddServerFilesAndPermissions\"\n | \"submitRegisterGrantee\";\n\n/**\n * Represents direct server operations that don't require blockchain signatures.\n *\n * @remarks\n * Direct requests handle auxiliary operations like file uploads and grant storage.\n * These operations may still result in blockchain transactions but don't require\n * user signatures for gasless submission.\n *\n * @category Relayer\n */\nexport type DirectRelayerRequest =\n | {\n type: \"direct\";\n operation: \"submitFileAddition\";\n params: {\n url: string;\n userAddress: Address;\n };\n }\n | {\n type: \"direct\";\n operation: \"submitFileAdditionWithPermissions\";\n params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n };\n }\n | {\n type: \"direct\";\n operation: \"submitFileAdditionComplete\";\n params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n schemaId: number;\n ownerAddress?: Address;\n };\n }\n | {\n type: \"direct\";\n operation: \"storeGrantFile\";\n params: GrantFile;\n };\n\n/**\n * Provides type-safe responses for all relayer operations.\n *\n * @remarks\n * The discriminated union ensures proper error handling and result typing.\n * Check the `type` field to determine success or failure before accessing results.\n *\n * @category Relayer\n */\nexport type UnifiedRelayerResponse =\n | {\n type: \"signed\";\n hash: Hash;\n }\n | {\n type: \"direct\";\n result: { fileId: number; transactionHash: Hash } | { url: string } | any;\n }\n | {\n type: \"error\";\n error: string;\n };\n\n/**\n * Simplified relayer configuration.\n * Can be a URL string for convenience, or a callback for full control.\n *\n * @category Configuration\n * @example\n * ```typescript\n * // Option 1: Simple URL (SDK handles the transport)\n * const vana = Vana({\n * walletClient,\n * relayer: '/api/relay'\n * });\n *\n * // Option 2: Full control with callback\n * const vana = Vana({\n * walletClient,\n * relayer: async (request) => {\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * });\n * ```\n */\nexport type RelayerConfig =\n | string\n | ((request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>);\n\n/**\n * Simplified relayer callbacks interface (v2).\n * A single callback handles all relayer operations.\n *\n * @category Configuration\n * @example\n * ```typescript\n * const relayerCallbacks: RelayerCallbacksV2 = {\n * submit: async (request) => {\n * // Send to your server endpoint\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * };\n * ```\n */\nexport interface RelayerCallbacksV2 {\n /**\n * Submit any relayer operation.\n *\n * This single callback handles all operations:\n * - EIP-712 signed operations (permissions, server trust, etc.)\n * - Direct operations (file additions, grant storage)\n *\n * On your server, pass the entire request object to the SDK's\n * `handleRelayerOperation` helper function.\n *\n * @param request - The unified request object\n * @returns Promise resolving to operation-specific response\n */\n submit: (request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/relayer.ts"],"sourcesContent":["/**\n * Defines types for gasless transaction relayers and server operations.\n *\n * @remarks\n * This module provides comprehensive type definitions for interacting with\n * relayer services that enable gasless transactions and auxiliary operations.\n * It includes both legacy v1 types and the simplified v2 unified interface.\n *\n * @category Types\n * @module types/relayer\n */\n\nimport type { Hash, Address, TransactionReceipt } from \"viem\";\nimport type {\n GrantFile,\n PermissionGrantTypedData,\n GenericTypedData,\n} from \"./permissions\";\n\n/**\n * Represents the response from storing grant files via relayer.\n *\n * @remarks\n * Contains storage location, metadata, and error information for\n * grant file upload operations.\n *\n * @category Advanced\n */\nexport interface RelayerStorageResponse {\n /** The IPFS URL where the grant file is stored */\n grantUrl: string;\n /** Success status */\n success: boolean;\n /** Optional error message */\n error?: string;\n /** Storage metadata */\n metadata?: {\n /** IPFS hash */\n ipfsHash: string;\n /** File size in bytes */\n size: number;\n /** Upload timestamp */\n timestamp: number;\n };\n}\n\n/**\n * Represents the response from submitting transactions via relayer.\n *\n * @remarks\n * Contains transaction hash, status, and metadata for gasless\n * transaction submissions.\n *\n * @category Advanced\n */\nexport interface RelayerTransactionResponse {\n /** The transaction hash of the submitted transaction */\n transactionHash: Hash;\n /** Success status */\n success: boolean;\n /** Optional error message */\n error?: string;\n /** Transaction metadata */\n metadata?: {\n /** Gas used */\n gasUsed?: bigint;\n /** Gas price */\n gasPrice?: bigint;\n /** Block number */\n blockNumber?: bigint;\n /** Transaction status */\n status?: \"pending\" | \"confirmed\" | \"failed\";\n };\n}\n\n/**\n * Specifies parameters for storing grant files via relayer.\n *\n * @remarks\n * Includes the grant file and optional storage configuration\n * such as encryption and pinning duration.\n *\n * @category Advanced\n */\nexport interface RelayerStoreParams {\n /** The grant file to store */\n grantFile: GrantFile;\n /** Optional storage options */\n options?: {\n /** IPFS pin duration in seconds */\n pinDuration?: number;\n /** Whether to use encryption */\n encrypt?: boolean;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n };\n}\n\n/**\n * Specifies parameters for submitting gasless transactions.\n *\n * @remarks\n * Contains signed typed data and transaction configuration options\n * for relayer submission.\n *\n * @category Advanced\n */\nexport interface RelayerSubmitParams {\n /** The signed typed data */\n typedData: PermissionGrantTypedData;\n /** The signature */\n signature: string;\n /** Optional transaction options */\n options?: {\n /** Gas limit */\n gasLimit?: bigint;\n /** Priority level */\n priority?: \"low\" | \"medium\" | \"high\";\n /** Whether to wait for confirmation */\n waitForConfirmation?: boolean;\n };\n}\n\n/**\n * Represents the current status and capabilities of a relayer service.\n *\n * @remarks\n * Provides information about supported chains, rate limits, and\n * current operational status for monitoring and decision-making.\n *\n * @category Advanced\n */\nexport interface RelayerStatus {\n /** Whether the relayer is online */\n online: boolean;\n /** Service version */\n version: string;\n /** Supported chains */\n supportedChains: number[];\n /** Current chain status */\n chainStatus: Record<\n number,\n {\n /** Whether the chain is supported */\n supported: boolean;\n /** Current block number */\n currentBlock: bigint;\n /** Gas price estimation */\n gasPrice: bigint;\n /** Queue size */\n queueSize: number;\n }\n >;\n /** Rate limit information */\n rateLimits: {\n /** Requests per minute */\n requestsPerMinute: number;\n /** Storage requests per hour */\n storageRequestsPerHour: number;\n /** Transaction requests per hour */\n transactionRequestsPerHour: number;\n };\n}\n\n/**\n * Configures behavior for relayer requests.\n *\n * @remarks\n * Controls timeout, retry logic, headers, and priority for\n * relayer operation requests.\n *\n * @category Advanced\n */\nexport interface RelayerRequestOptions {\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Whether to retry on failure */\n retry?: boolean;\n /** Custom headers */\n headers?: Record<string, string>;\n /** Request priority */\n priority?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * Represents an error response from the relayer service.\n *\n * @remarks\n * Provides structured error information including codes, messages,\n * and debugging details for error handling and recovery.\n *\n * @category Advanced\n */\nexport interface RelayerErrorResponse {\n /** Error code */\n code: string;\n /** Error message */\n message: string;\n /** Additional error details */\n details?: Record<string, unknown>;\n /** Request ID for debugging */\n requestId?: string;\n /** Timestamp of error */\n timestamp: number;\n}\n\n/**\n * Provides information about the relayer's processing queue.\n *\n * @remarks\n * Includes queue size, position, estimated processing time, and\n * performance statistics for queue monitoring.\n *\n * @category Advanced\n */\nexport interface RelayerQueueInfo {\n /** Current queue size */\n size: number;\n /** Estimated processing time in seconds */\n estimatedProcessingTime: number;\n /** Queue position for a specific request */\n position?: number;\n /** Processing statistics */\n stats: {\n /** Average processing time in seconds */\n averageProcessingTime: number;\n /** Requests processed in last hour */\n requestsProcessedHour: number;\n /** Success rate percentage */\n successRate: number;\n };\n}\n\n/**\n * Tracks the status of a transaction submitted via relayer.\n *\n * @remarks\n * Provides detailed tracking information including confirmation status,\n * gas usage, and historical status checks.\n *\n * @category Advanced\n */\nexport interface RelayerTransactionStatus {\n /** Transaction hash */\n transactionHash: Hash;\n /** Current status */\n status: \"pending\" | \"confirmed\" | \"failed\";\n /** Block number if confirmed */\n blockNumber?: bigint;\n /** Gas used */\n gasUsed?: bigint;\n /** Error message if failed */\n error?: string;\n /** Status checks performed */\n checks: Array<{\n /** Check timestamp */\n timestamp: number;\n /** Status at time of check */\n status: string;\n /** Block number at time of check */\n blockNumber: bigint;\n }>;\n}\n\n/**\n * Provides performance metrics for the relayer service.\n *\n * @remarks\n * Includes transaction statistics, success rates, processing times,\n * and uptime information for monitoring and optimization.\n *\n * @category Advanced\n */\nexport interface RelayerMetrics {\n /** Total transactions processed */\n totalTransactions: number;\n /** Successful transactions */\n successfulTransactions: number;\n /** Failed transactions */\n failedTransactions: number;\n /** Average processing time in seconds */\n averageProcessingTime: number;\n /** Current queue size */\n queueSize: number;\n /** Uptime percentage */\n uptime: number;\n /** Last 24 hour statistics */\n last24Hours: {\n /** Transactions processed */\n transactions: number;\n /** Success rate */\n successRate: number;\n /** Average response time */\n averageResponseTime: number;\n };\n}\n\n/**\n * Configures webhook notifications for relayer events.\n *\n * @remarks\n * Enables asynchronous notifications for transaction confirmations,\n * failures, and storage completions.\n *\n * @category Advanced\n */\nexport interface RelayerWebhookConfig {\n /** Webhook URL */\n url: string;\n /** Events to subscribe to */\n events: Array<\n \"transaction_confirmed\" | \"transaction_failed\" | \"storage_complete\"\n >;\n /** Webhook secret for signature verification */\n secret?: string;\n /** Whether webhook is active */\n active: boolean;\n}\n\n/**\n * Represents a webhook event payload from the relayer.\n *\n * @remarks\n * Contains event data, timestamp, and signature for verification\n * of webhook authenticity.\n *\n * @category Advanced\n */\nexport interface RelayerWebhookPayload {\n /** Event type */\n event: string;\n /** Event data */\n data: Record<string, unknown>;\n /** Timestamp */\n timestamp: number;\n /** Webhook ID */\n webhookId: string;\n /** Signature for verification */\n signature: string;\n}\n\n// ===== NEW SIMPLIFIED RELAYER TYPES (v2) =====\n\n/**\n * Handles both EIP-712 signed operations and direct server operations through a single interface.\n *\n * @remarks\n * This discriminated union provides type safety through TypeScript's narrowing.\n * The `type` field determines which operation variant is being used.\n * Signed operations require blockchain transactions, while direct operations\n * handle auxiliary tasks like file storage.\n *\n * @category Relayer\n * @see {@link https://docs.vana.org/docs/gasless-transactions | Gasless Transactions Guide}\n */\nexport type UnifiedRelayerRequest =\n | SignedRelayerRequest\n | DirectRelayerRequest\n | {\n type: \"status_check\";\n operationId: string;\n };\n\n/**\n * Represents an EIP-712 signed operation for gasless transaction submission.\n *\n * @remarks\n * Signed requests contain typed data and signatures that are verified\n * on-chain by smart contracts. The relayer pays gas fees on behalf of users.\n *\n * @category Relayer\n */\nexport interface SignedRelayerRequest {\n /** Discriminator field identifying this as a signed operation */\n type: \"signed\";\n /** Operation identifier for routing (e.g., 'submitAddPermission') */\n operation: SignedOperationType;\n /** EIP-712 typed data structure for the operation */\n typedData: GenericTypedData;\n /** User's signature of the typed data */\n signature: Hash;\n /** Optional address for additional signer verification */\n expectedUserAddress?: Address;\n}\n\n/**\n * Enumerates supported EIP-712 signed operation types.\n *\n * @remarks\n * Each operation type corresponds to a specific smart contract\n * function that accepts gasless transactions.\n *\n * @category Relayer\n */\nexport type SignedOperationType =\n | \"submitAddPermission\"\n | \"submitPermissionRevoke\"\n | \"submitTrustServer\"\n | \"submitAddAndTrustServer\"\n | \"submitUntrustServer\"\n | \"submitAddServerFilesAndPermissions\"\n | \"submitRegisterGrantee\";\n\n/**\n * Represents direct server operations that don't require blockchain signatures.\n *\n * @remarks\n * Direct requests handle auxiliary operations like file uploads and grant storage.\n * These operations may still result in blockchain transactions but don't require\n * user signatures for gasless submission.\n *\n * @category Relayer\n */\nexport type DirectRelayerRequest =\n | {\n type: \"direct\";\n operation: \"submitFileAddition\";\n params: {\n url: string;\n userAddress: Address;\n };\n }\n | {\n type: \"direct\";\n operation: \"submitFileAdditionWithPermissions\";\n params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n };\n }\n | {\n type: \"direct\";\n operation: \"submitFileAdditionComplete\";\n params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n schemaId: number;\n ownerAddress?: Address;\n };\n }\n | {\n type: \"direct\";\n operation: \"storeGrantFile\";\n params: GrantFile;\n };\n\n/**\n * Provides type-safe responses for all relayer operations.\n *\n * @remarks\n * The discriminated union ensures proper error handling and result typing.\n * Check the `type` field to determine success or failure before accessing results.\n * The new async pattern returns pending operations with operationIds for polling.\n *\n * @category Relayer\n */\nexport type UnifiedRelayerResponse =\n | {\n type: \"pending\";\n operationId: string;\n }\n | {\n type: \"submitted\";\n hash: Hash;\n }\n | {\n type: \"confirmed\";\n hash: Hash;\n // Receipt is optional; a performance hint for the client SDK's polling logic.\n receipt?: TransactionReceipt;\n }\n | {\n type: \"signed\";\n hash: Hash;\n }\n | {\n type: \"direct\";\n result: { fileId: number; transactionHash: Hash } | { url: string };\n }\n | {\n /** Non-transactional operations that don't require tracking (e.g., IPFS uploads) */\n type: \"direct_result_untracked\";\n /** The result data from the operation, structure depends on the specific operation */\n result: unknown;\n }\n | {\n type: \"error\";\n error: string;\n };\n\n/**\n * Simplified relayer configuration.\n * Can be a URL string for convenience, or a callback for full control.\n *\n * @category Configuration\n * @example\n * ```typescript\n * // Option 1: Simple URL (SDK handles the transport)\n * const vana = Vana({\n * walletClient,\n * relayer: '/api/relay'\n * });\n *\n * // Option 2: Full control with callback\n * const vana = Vana({\n * walletClient,\n * relayer: async (request) => {\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * });\n * ```\n */\nexport type RelayerConfig =\n | string\n | ((request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>);\n\n/**\n * Simplified relayer callbacks interface (v2).\n * A single callback handles all relayer operations.\n *\n * @category Configuration\n * @example\n * ```typescript\n * const relayerCallbacks: RelayerCallbacksV2 = {\n * submit: async (request) => {\n * // Send to your server endpoint\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * };\n * ```\n */\nexport interface RelayerCallbacksV2 {\n /**\n * Submits any relayer operation to the server.\n *\n * @remarks\n * This single callback handles all operations:\n * - EIP-712 signed operations (permissions, server trust, etc.)\n * - Direct operations (file additions, grant storage)\n *\n * On your server, pass the entire request object to the SDK's\n * `handleRelayerOperation` helper function.\n *\n * @param request - The unified request object.\n * Check `type` field to determine operation variant.\n * @returns Promise resolving to operation-specific response\n *\n * @example\n * ```typescript\n * async submit(request) {\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * ```\n */\n submit: (request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types/relayer.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Defines types for gasless transaction relayers and server operations.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module provides comprehensive type definitions for interacting with
|
|
6
|
+
* relayer services that enable gasless transactions and auxiliary operations.
|
|
7
|
+
* It includes both legacy v1 types and the simplified v2 unified interface.
|
|
8
|
+
*
|
|
9
|
+
* @category Types
|
|
10
|
+
* @module types/relayer
|
|
11
|
+
*/
|
|
12
|
+
import type { Hash, Address, TransactionReceipt } from "viem";
|
|
2
13
|
import type { GrantFile, PermissionGrantTypedData, GenericTypedData } from "./permissions";
|
|
3
14
|
/**
|
|
4
|
-
*
|
|
15
|
+
* Represents the response from storing grant files via relayer.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Contains storage location, metadata, and error information for
|
|
19
|
+
* grant file upload operations.
|
|
5
20
|
*
|
|
6
21
|
* @category Advanced
|
|
7
22
|
*/
|
|
@@ -23,7 +38,11 @@ export interface RelayerStorageResponse {
|
|
|
23
38
|
};
|
|
24
39
|
}
|
|
25
40
|
/**
|
|
26
|
-
*
|
|
41
|
+
* Represents the response from submitting transactions via relayer.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Contains transaction hash, status, and metadata for gasless
|
|
45
|
+
* transaction submissions.
|
|
27
46
|
*
|
|
28
47
|
* @category Advanced
|
|
29
48
|
*/
|
|
@@ -47,7 +66,11 @@ export interface RelayerTransactionResponse {
|
|
|
47
66
|
};
|
|
48
67
|
}
|
|
49
68
|
/**
|
|
50
|
-
*
|
|
69
|
+
* Specifies parameters for storing grant files via relayer.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Includes the grant file and optional storage configuration
|
|
73
|
+
* such as encryption and pinning duration.
|
|
51
74
|
*
|
|
52
75
|
* @category Advanced
|
|
53
76
|
*/
|
|
@@ -65,7 +88,11 @@ export interface RelayerStoreParams {
|
|
|
65
88
|
};
|
|
66
89
|
}
|
|
67
90
|
/**
|
|
68
|
-
*
|
|
91
|
+
* Specifies parameters for submitting gasless transactions.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* Contains signed typed data and transaction configuration options
|
|
95
|
+
* for relayer submission.
|
|
69
96
|
*
|
|
70
97
|
* @category Advanced
|
|
71
98
|
*/
|
|
@@ -85,7 +112,11 @@ export interface RelayerSubmitParams {
|
|
|
85
112
|
};
|
|
86
113
|
}
|
|
87
114
|
/**
|
|
88
|
-
*
|
|
115
|
+
* Represents the current status and capabilities of a relayer service.
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* Provides information about supported chains, rate limits, and
|
|
119
|
+
* current operational status for monitoring and decision-making.
|
|
89
120
|
*
|
|
90
121
|
* @category Advanced
|
|
91
122
|
*/
|
|
@@ -118,7 +149,11 @@ export interface RelayerStatus {
|
|
|
118
149
|
};
|
|
119
150
|
}
|
|
120
151
|
/**
|
|
121
|
-
*
|
|
152
|
+
* Configures behavior for relayer requests.
|
|
153
|
+
*
|
|
154
|
+
* @remarks
|
|
155
|
+
* Controls timeout, retry logic, headers, and priority for
|
|
156
|
+
* relayer operation requests.
|
|
122
157
|
*
|
|
123
158
|
* @category Advanced
|
|
124
159
|
*/
|
|
@@ -133,7 +168,11 @@ export interface RelayerRequestOptions {
|
|
|
133
168
|
priority?: "low" | "medium" | "high";
|
|
134
169
|
}
|
|
135
170
|
/**
|
|
136
|
-
*
|
|
171
|
+
* Represents an error response from the relayer service.
|
|
172
|
+
*
|
|
173
|
+
* @remarks
|
|
174
|
+
* Provides structured error information including codes, messages,
|
|
175
|
+
* and debugging details for error handling and recovery.
|
|
137
176
|
*
|
|
138
177
|
* @category Advanced
|
|
139
178
|
*/
|
|
@@ -150,7 +189,11 @@ export interface RelayerErrorResponse {
|
|
|
150
189
|
timestamp: number;
|
|
151
190
|
}
|
|
152
191
|
/**
|
|
153
|
-
*
|
|
192
|
+
* Provides information about the relayer's processing queue.
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* Includes queue size, position, estimated processing time, and
|
|
196
|
+
* performance statistics for queue monitoring.
|
|
154
197
|
*
|
|
155
198
|
* @category Advanced
|
|
156
199
|
*/
|
|
@@ -172,7 +215,11 @@ export interface RelayerQueueInfo {
|
|
|
172
215
|
};
|
|
173
216
|
}
|
|
174
217
|
/**
|
|
175
|
-
*
|
|
218
|
+
* Tracks the status of a transaction submitted via relayer.
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* Provides detailed tracking information including confirmation status,
|
|
222
|
+
* gas usage, and historical status checks.
|
|
176
223
|
*
|
|
177
224
|
* @category Advanced
|
|
178
225
|
*/
|
|
@@ -198,7 +245,11 @@ export interface RelayerTransactionStatus {
|
|
|
198
245
|
}>;
|
|
199
246
|
}
|
|
200
247
|
/**
|
|
201
|
-
*
|
|
248
|
+
* Provides performance metrics for the relayer service.
|
|
249
|
+
*
|
|
250
|
+
* @remarks
|
|
251
|
+
* Includes transaction statistics, success rates, processing times,
|
|
252
|
+
* and uptime information for monitoring and optimization.
|
|
202
253
|
*
|
|
203
254
|
* @category Advanced
|
|
204
255
|
*/
|
|
@@ -226,7 +277,11 @@ export interface RelayerMetrics {
|
|
|
226
277
|
};
|
|
227
278
|
}
|
|
228
279
|
/**
|
|
229
|
-
*
|
|
280
|
+
* Configures webhook notifications for relayer events.
|
|
281
|
+
*
|
|
282
|
+
* @remarks
|
|
283
|
+
* Enables asynchronous notifications for transaction confirmations,
|
|
284
|
+
* failures, and storage completions.
|
|
230
285
|
*
|
|
231
286
|
* @category Advanced
|
|
232
287
|
*/
|
|
@@ -241,7 +296,11 @@ export interface RelayerWebhookConfig {
|
|
|
241
296
|
active: boolean;
|
|
242
297
|
}
|
|
243
298
|
/**
|
|
244
|
-
*
|
|
299
|
+
* Represents a webhook event payload from the relayer.
|
|
300
|
+
*
|
|
301
|
+
* @remarks
|
|
302
|
+
* Contains event data, timestamp, and signature for verification
|
|
303
|
+
* of webhook authenticity.
|
|
245
304
|
*
|
|
246
305
|
* @category Advanced
|
|
247
306
|
*/
|
|
@@ -269,7 +328,10 @@ export interface RelayerWebhookPayload {
|
|
|
269
328
|
* @category Relayer
|
|
270
329
|
* @see {@link https://docs.vana.org/docs/gasless-transactions | Gasless Transactions Guide}
|
|
271
330
|
*/
|
|
272
|
-
export type UnifiedRelayerRequest = SignedRelayerRequest | DirectRelayerRequest
|
|
331
|
+
export type UnifiedRelayerRequest = SignedRelayerRequest | DirectRelayerRequest | {
|
|
332
|
+
type: "status_check";
|
|
333
|
+
operationId: string;
|
|
334
|
+
};
|
|
273
335
|
/**
|
|
274
336
|
* Represents an EIP-712 signed operation for gasless transaction submission.
|
|
275
337
|
*
|
|
@@ -292,7 +354,12 @@ export interface SignedRelayerRequest {
|
|
|
292
354
|
expectedUserAddress?: Address;
|
|
293
355
|
}
|
|
294
356
|
/**
|
|
295
|
-
*
|
|
357
|
+
* Enumerates supported EIP-712 signed operation types.
|
|
358
|
+
*
|
|
359
|
+
* @remarks
|
|
360
|
+
* Each operation type corresponds to a specific smart contract
|
|
361
|
+
* function that accepts gasless transactions.
|
|
362
|
+
*
|
|
296
363
|
* @category Relayer
|
|
297
364
|
*/
|
|
298
365
|
export type SignedOperationType = "submitAddPermission" | "submitPermissionRevoke" | "submitTrustServer" | "submitAddAndTrustServer" | "submitUntrustServer" | "submitAddServerFilesAndPermissions" | "submitRegisterGrantee";
|
|
@@ -348,10 +415,21 @@ export type DirectRelayerRequest = {
|
|
|
348
415
|
* @remarks
|
|
349
416
|
* The discriminated union ensures proper error handling and result typing.
|
|
350
417
|
* Check the `type` field to determine success or failure before accessing results.
|
|
418
|
+
* The new async pattern returns pending operations with operationIds for polling.
|
|
351
419
|
*
|
|
352
420
|
* @category Relayer
|
|
353
421
|
*/
|
|
354
422
|
export type UnifiedRelayerResponse = {
|
|
423
|
+
type: "pending";
|
|
424
|
+
operationId: string;
|
|
425
|
+
} | {
|
|
426
|
+
type: "submitted";
|
|
427
|
+
hash: Hash;
|
|
428
|
+
} | {
|
|
429
|
+
type: "confirmed";
|
|
430
|
+
hash: Hash;
|
|
431
|
+
receipt?: TransactionReceipt;
|
|
432
|
+
} | {
|
|
355
433
|
type: "signed";
|
|
356
434
|
hash: Hash;
|
|
357
435
|
} | {
|
|
@@ -361,7 +439,12 @@ export type UnifiedRelayerResponse = {
|
|
|
361
439
|
transactionHash: Hash;
|
|
362
440
|
} | {
|
|
363
441
|
url: string;
|
|
364
|
-
}
|
|
442
|
+
};
|
|
443
|
+
} | {
|
|
444
|
+
/** Non-transactional operations that don't require tracking (e.g., IPFS uploads) */
|
|
445
|
+
type: "direct_result_untracked";
|
|
446
|
+
/** The result data from the operation, structure depends on the specific operation */
|
|
447
|
+
result: unknown;
|
|
365
448
|
} | {
|
|
366
449
|
type: "error";
|
|
367
450
|
error: string;
|
|
@@ -415,8 +498,9 @@ export type RelayerConfig = string | ((request: UnifiedRelayerRequest) => Promis
|
|
|
415
498
|
*/
|
|
416
499
|
export interface RelayerCallbacksV2 {
|
|
417
500
|
/**
|
|
418
|
-
*
|
|
501
|
+
* Submits any relayer operation to the server.
|
|
419
502
|
*
|
|
503
|
+
* @remarks
|
|
420
504
|
* This single callback handles all operations:
|
|
421
505
|
* - EIP-712 signed operations (permissions, server trust, etc.)
|
|
422
506
|
* - Direct operations (file additions, grant storage)
|
|
@@ -424,8 +508,20 @@ export interface RelayerCallbacksV2 {
|
|
|
424
508
|
* On your server, pass the entire request object to the SDK's
|
|
425
509
|
* `handleRelayerOperation` helper function.
|
|
426
510
|
*
|
|
427
|
-
* @param request - The unified request object
|
|
511
|
+
* @param request - The unified request object.
|
|
512
|
+
* Check `type` field to determine operation variant.
|
|
428
513
|
* @returns Promise resolving to operation-specific response
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* ```typescript
|
|
517
|
+
* async submit(request) {
|
|
518
|
+
* const response = await fetch('/api/relay', {
|
|
519
|
+
* method: 'POST',
|
|
520
|
+
* body: JSON.stringify(request)
|
|
521
|
+
* });
|
|
522
|
+
* return response.json();
|
|
523
|
+
* }
|
|
524
|
+
* ```
|
|
429
525
|
*/
|
|
430
526
|
submit: (request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>;
|
|
431
527
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/storage.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/types/storage.ts"],"sourcesContent":["/**\n * Defines interface for storage provider implementations.\n *\n * @remarks\n * Abstracts storage backends (IPFS, Google Drive, Pinata) behind\n * common interface for encrypted file operations.\n *\n * @category Storage\n * @example\n * ```typescript\n * class MyStorage implements StorageProvider {\n * async upload(file: Blob): Promise<StorageUploadResult> {\n * const url = await uploadToService(file);\n * return { url, size: file.size, contentType: file.type };\n * }\n *\n * async download(url: string): Promise<Blob> {\n * return fetch(url).then(r => r.blob());\n * }\n * }\n * ```\n */\nexport interface StorageProvider {\n /**\n * Upload a file to the storage provider\n *\n * @param file - The file to upload\n * @param filename - Optional custom filename\n * @returns Promise with storage URL and metadata\n */\n upload(file: Blob, filename?: string): Promise<StorageUploadResult>;\n\n /**\n * Download a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with file blob\n */\n download(url: string): Promise<Blob>;\n\n /**\n * List files from the storage provider\n *\n * @param options - Optional filtering and pagination\n * @returns Promise with file list\n */\n list(options?: StorageListOptions): Promise<StorageFile[]>;\n\n /**\n * Delete a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with success status\n */\n delete(url: string): Promise<boolean>;\n\n /**\n * Get provider-specific configuration\n *\n * @returns Provider configuration object\n */\n getConfig(): StorageProviderConfig;\n}\n\nexport interface StorageUploadResult {\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageFile {\n /** File identifier */\n id: string;\n /** File name */\n name: string;\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Upload timestamp */\n createdAt: Date;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageListOptions {\n /** Maximum number of files to return */\n limit?: number;\n /** Pagination cursor/offset */\n offset?: string | number;\n /** Filter by file name pattern */\n namePattern?: string;\n /** Filter by content type */\n contentType?: string;\n}\n\nexport interface StorageProviderConfig {\n /** Provider name */\n name: string;\n /** Provider type */\n type: string;\n /** Whether authentication is required */\n requiresAuth: boolean;\n /** Supported features */\n features: {\n upload: boolean;\n download: boolean;\n list: boolean;\n delete: boolean;\n };\n}\n\nexport class StorageError extends Error {\n public readonly code: string;\n public readonly provider: string;\n // The 'cause' property is now inherited from the base Error class\n\n constructor(\n message: string,\n code: string,\n provider: string,\n options?: { cause?: Error },\n ) {\n // Pass the options object with 'cause' to the super constructor\n super(message, options);\n this.name = \"StorageError\";\n this.code = code;\n this.provider = provider;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuHO,MAAM,qBAAqB,MAAM;AAAA,EACtB;AAAA,EACA;AAAA;AAAA,EAGhB,YACE,SACA,MACA,UACA,SACA;AAEA,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;","names":[]}
|
package/dist/types/storage.d.ts
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Defines interface for storage provider implementations.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Abstracts storage backends (IPFS, Google Drive, Pinata) behind
|
|
6
|
+
* common interface for encrypted file operations.
|
|
7
7
|
*
|
|
8
8
|
* @category Storage
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* return { url: 'https://my-storage.com/file.dat', size: file.size };
|
|
11
|
+
* class MyStorage implements StorageProvider {
|
|
12
|
+
* async upload(file: Blob): Promise<StorageUploadResult> {
|
|
13
|
+
* const url = await uploadToService(file);
|
|
14
|
+
* return { url, size: file.size, contentType: file.type };
|
|
16
15
|
* }
|
|
17
16
|
*
|
|
18
17
|
* async download(url: string): Promise<Blob> {
|
|
19
|
-
*
|
|
20
|
-
* const response = await fetch(url);
|
|
21
|
-
* return response.blob();
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* async list(options?: StorageListOptions): Promise<StorageFile[]> {
|
|
25
|
-
* // Return list of files
|
|
26
|
-
* return [];
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* async delete(url: string): Promise<void> {
|
|
30
|
-
* // Delete file implementation
|
|
18
|
+
* return fetch(url).then(r => r.blob());
|
|
31
19
|
* }
|
|
32
20
|
* }
|
|
33
21
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/storage.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/types/storage.ts"],"sourcesContent":["/**\n * Defines interface for storage provider implementations.\n *\n * @remarks\n * Abstracts storage backends (IPFS, Google Drive, Pinata) behind\n * common interface for encrypted file operations.\n *\n * @category Storage\n * @example\n * ```typescript\n * class MyStorage implements StorageProvider {\n * async upload(file: Blob): Promise<StorageUploadResult> {\n * const url = await uploadToService(file);\n * return { url, size: file.size, contentType: file.type };\n * }\n *\n * async download(url: string): Promise<Blob> {\n * return fetch(url).then(r => r.blob());\n * }\n * }\n * ```\n */\nexport interface StorageProvider {\n /**\n * Upload a file to the storage provider\n *\n * @param file - The file to upload\n * @param filename - Optional custom filename\n * @returns Promise with storage URL and metadata\n */\n upload(file: Blob, filename?: string): Promise<StorageUploadResult>;\n\n /**\n * Download a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with file blob\n */\n download(url: string): Promise<Blob>;\n\n /**\n * List files from the storage provider\n *\n * @param options - Optional filtering and pagination\n * @returns Promise with file list\n */\n list(options?: StorageListOptions): Promise<StorageFile[]>;\n\n /**\n * Delete a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with success status\n */\n delete(url: string): Promise<boolean>;\n\n /**\n * Get provider-specific configuration\n *\n * @returns Provider configuration object\n */\n getConfig(): StorageProviderConfig;\n}\n\nexport interface StorageUploadResult {\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageFile {\n /** File identifier */\n id: string;\n /** File name */\n name: string;\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Upload timestamp */\n createdAt: Date;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageListOptions {\n /** Maximum number of files to return */\n limit?: number;\n /** Pagination cursor/offset */\n offset?: string | number;\n /** Filter by file name pattern */\n namePattern?: string;\n /** Filter by content type */\n contentType?: string;\n}\n\nexport interface StorageProviderConfig {\n /** Provider name */\n name: string;\n /** Provider type */\n type: string;\n /** Whether authentication is required */\n requiresAuth: boolean;\n /** Supported features */\n features: {\n upload: boolean;\n download: boolean;\n list: boolean;\n delete: boolean;\n };\n}\n\nexport class StorageError extends Error {\n public readonly code: string;\n public readonly provider: string;\n // The 'cause' property is now inherited from the base Error class\n\n constructor(\n message: string,\n code: string,\n provider: string,\n options?: { cause?: Error },\n ) {\n // Pass the options object with 'cause' to the super constructor\n super(message, options);\n this.name = \"StorageError\";\n this.code = code;\n this.provider = provider;\n }\n}\n"],"mappings":"AAuHO,MAAM,qBAAqB,MAAM;AAAA,EACtB;AAAA,EACA;AAAA;AAAA,EAGhB,YACE,SACA,MACA,UACA,SACA;AAEA,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;","names":[]}
|