@opendatalabs/vana-sdk 0.1.0-alpha.81526eb → 0.1.0-alpha.82bbb39
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/chains.browser.cjs +2 -2
- package/dist/chains.browser.cjs.map +1 -1
- package/dist/chains.browser.js +2 -2
- package/dist/chains.browser.js.map +1 -1
- package/dist/chains.cjs +2 -2
- package/dist/chains.cjs.map +1 -1
- package/dist/chains.js +2 -2
- package/dist/chains.js.map +1 -1
- package/dist/chains.node.cjs +2 -2
- package/dist/chains.node.cjs.map +1 -1
- package/dist/chains.node.js +2 -2
- package/dist/chains.node.js.map +1 -1
- package/dist/index.browser.d.ts +187 -26
- package/dist/index.browser.js +224 -57
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +224 -57
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +187 -26
- package/dist/index.node.d.ts +187 -26
- package/dist/index.node.js +224 -57
- package/dist/index.node.js.map +1 -1
- package/package.json +1 -1
package/dist/index.node.cjs
CHANGED
|
@@ -36963,10 +36963,19 @@ var PermissionsController = class {
|
|
|
36963
36963
|
/**
|
|
36964
36964
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
36965
36965
|
*
|
|
36966
|
-
*
|
|
36966
|
+
* The nonce is used to prevent replay attacks in signed transactions and must
|
|
36967
|
+
* be incremented with each transaction to maintain security.
|
|
36968
|
+
*
|
|
36969
|
+
* @returns Promise resolving to the user's current nonce value as a bigint
|
|
36967
36970
|
* @throws {Error} When wallet account is not available
|
|
36968
36971
|
* @throws {Error} When chain ID is not available
|
|
36969
36972
|
* @throws {NonceError} When reading nonce from contract fails
|
|
36973
|
+
* @private
|
|
36974
|
+
* @example
|
|
36975
|
+
* ```typescript
|
|
36976
|
+
* const nonce = await this.getUserNonce();
|
|
36977
|
+
* console.log(`Current nonce: ${nonce}`);
|
|
36978
|
+
* ```
|
|
36970
36979
|
*/
|
|
36971
36980
|
async getUserNonce() {
|
|
36972
36981
|
try {
|
|
@@ -37161,9 +37170,15 @@ var PermissionsController = class {
|
|
|
37161
37170
|
grant
|
|
37162
37171
|
nonce
|
|
37163
37172
|
signature
|
|
37173
|
+
startBlock
|
|
37174
|
+
endBlock
|
|
37164
37175
|
addedAtBlock
|
|
37165
37176
|
addedAtTimestamp
|
|
37166
37177
|
transactionHash
|
|
37178
|
+
grantee {
|
|
37179
|
+
id
|
|
37180
|
+
address
|
|
37181
|
+
}
|
|
37167
37182
|
}
|
|
37168
37183
|
}
|
|
37169
37184
|
}
|
|
@@ -37198,15 +37213,16 @@ var PermissionsController = class {
|
|
|
37198
37213
|
const onChainGrants = userData.permissions.slice(0, limit).map((permission) => ({
|
|
37199
37214
|
id: BigInt(permission.id),
|
|
37200
37215
|
grantUrl: permission.grant,
|
|
37201
|
-
grantSignature: permission.
|
|
37202
|
-
grantHash:
|
|
37216
|
+
grantSignature: permission.signature,
|
|
37217
|
+
grantHash: "",
|
|
37218
|
+
// Not available in new schema, compute if needed
|
|
37203
37219
|
nonce: BigInt(permission.nonce),
|
|
37204
37220
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
37205
37221
|
addedAtTimestamp: BigInt(permission.addedAtTimestamp || "0"),
|
|
37206
37222
|
transactionHash: permission.transactionHash || "",
|
|
37207
37223
|
grantor: userAddress,
|
|
37208
|
-
active:
|
|
37209
|
-
//
|
|
37224
|
+
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
37225
|
+
// Active if no end block or end block is 0
|
|
37210
37226
|
}));
|
|
37211
37227
|
return onChainGrants.sort((a, b) => {
|
|
37212
37228
|
if (a.id < b.id) return 1;
|
|
@@ -37359,23 +37375,37 @@ var PermissionsController = class {
|
|
|
37359
37375
|
}
|
|
37360
37376
|
}
|
|
37361
37377
|
/**
|
|
37362
|
-
*
|
|
37378
|
+
* Registers a new server and immediately trusts it in the DataPortabilityServers contract.
|
|
37379
|
+
*
|
|
37380
|
+
* This is a combined operation that both registers a new data portability server
|
|
37381
|
+
* and adds it to the user's trusted servers list in a single transaction.
|
|
37382
|
+
* Trusted servers can handle data export and portability requests from the user.
|
|
37363
37383
|
*
|
|
37364
37384
|
* @param params - Parameters for adding and trusting the server
|
|
37385
|
+
* @param params.owner - Ethereum address that will own this server registration
|
|
37386
|
+
* @param params.serverAddress - Ethereum address of the server
|
|
37387
|
+
* @param params.serverUrl - HTTPS URL where the server can be reached
|
|
37388
|
+
* @param params.publicKey - Server's public key for encryption (hex string)
|
|
37365
37389
|
* @returns Promise resolving to transaction hash
|
|
37366
37390
|
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
37367
37391
|
* @throws {BlockchainError} When chain ID is unavailable or transaction fails
|
|
37392
|
+
* @throws {ServerAlreadyRegisteredError} When server address is already registered
|
|
37368
37393
|
* @throws {Error} When wallet account is not available
|
|
37394
|
+
*
|
|
37369
37395
|
* @example
|
|
37370
37396
|
* ```typescript
|
|
37371
37397
|
* // Add and trust a server by providing all required details
|
|
37372
37398
|
* const txHash = await vana.permissions.addAndTrustServer({
|
|
37373
|
-
* owner: '
|
|
37399
|
+
* owner: '0x1234567890abcdef1234567890abcdef12345678',
|
|
37374
37400
|
* serverAddress: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
|
|
37375
37401
|
* serverUrl: 'https://myserver.example.com',
|
|
37376
|
-
* publicKey: '
|
|
37402
|
+
* publicKey: '0x456789abcdef456789abcdef456789abcdef456789abcdef'
|
|
37377
37403
|
* });
|
|
37378
37404
|
* console.log('Server added and trusted in transaction:', txHash);
|
|
37405
|
+
*
|
|
37406
|
+
* // Verify the server is now trusted
|
|
37407
|
+
* const trustedServers = await vana.permissions.getTrustedServers();
|
|
37408
|
+
* console.log('Now trusting servers:', trustedServers);
|
|
37379
37409
|
* ```
|
|
37380
37410
|
*/
|
|
37381
37411
|
async addAndTrustServer(params) {
|
|
@@ -37569,15 +37599,32 @@ var PermissionsController = class {
|
|
|
37569
37599
|
}
|
|
37570
37600
|
}
|
|
37571
37601
|
/**
|
|
37572
|
-
*
|
|
37602
|
+
* Removes a server from the user's trusted servers list in the DataPortabilityServers contract.
|
|
37603
|
+
*
|
|
37604
|
+
* This revokes the server's authorization to handle data portability requests for the user.
|
|
37605
|
+
* The server remains registered in the system but will no longer be trusted by this user.
|
|
37573
37606
|
*
|
|
37574
37607
|
* @param params - Parameters for untrusting the server
|
|
37575
|
-
* @param params.serverId - The
|
|
37608
|
+
* @param params.serverId - The numeric ID of the server to untrust
|
|
37576
37609
|
* @returns Promise resolving to transaction hash
|
|
37577
37610
|
* @throws {Error} When wallet account is not available
|
|
37578
37611
|
* @throws {NonceError} When retrieving user nonce fails
|
|
37579
37612
|
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
37613
|
+
* @throws {ServerNotTrustedError} When the server is not currently trusted
|
|
37580
37614
|
* @throws {BlockchainError} When untrust transaction fails
|
|
37615
|
+
*
|
|
37616
|
+
* @example
|
|
37617
|
+
* ```typescript
|
|
37618
|
+
* // Untrust a specific server
|
|
37619
|
+
* const txHash = await vana.permissions.untrustServer({
|
|
37620
|
+
* serverId: 1
|
|
37621
|
+
* });
|
|
37622
|
+
* console.log('Server untrusted in transaction:', txHash);
|
|
37623
|
+
*
|
|
37624
|
+
* // Verify the server is no longer trusted
|
|
37625
|
+
* const trustedServers = await vana.permissions.getTrustedServers();
|
|
37626
|
+
* console.log('Still trusting servers:', trustedServers);
|
|
37627
|
+
* ```
|
|
37581
37628
|
*/
|
|
37582
37629
|
async untrustServer(params) {
|
|
37583
37630
|
const nonce = await this.getUserNonce();
|
|
@@ -37635,11 +37682,26 @@ var PermissionsController = class {
|
|
|
37635
37682
|
}
|
|
37636
37683
|
}
|
|
37637
37684
|
/**
|
|
37638
|
-
*
|
|
37685
|
+
* Retrieves all servers trusted by a user from the DataPortabilityServers contract.
|
|
37639
37686
|
*
|
|
37640
|
-
*
|
|
37687
|
+
* Returns an array of server IDs that the specified user has explicitly trusted.
|
|
37688
|
+
* Trusted servers are those that users have authorized to handle their data portability requests.
|
|
37689
|
+
*
|
|
37690
|
+
* @param userAddress - Optional user address to query (defaults to current wallet user)
|
|
37641
37691
|
* @returns Promise resolving to array of trusted server IDs (numeric)
|
|
37642
37692
|
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
37693
|
+
* @throws {NetworkError} When unable to connect to the blockchain network
|
|
37694
|
+
*
|
|
37695
|
+
* @example
|
|
37696
|
+
* ```typescript
|
|
37697
|
+
* // Get trusted servers for current user
|
|
37698
|
+
* const myServers = await vana.permissions.getTrustedServers();
|
|
37699
|
+
* console.log(`I trust ${myServers.length} servers: ${myServers.join(', ')}`);
|
|
37700
|
+
*
|
|
37701
|
+
* // Get trusted servers for another user
|
|
37702
|
+
* const userServers = await vana.permissions.getTrustedServers("0x1234...");
|
|
37703
|
+
* console.log(`User trusts servers: ${userServers.join(', ')}`);
|
|
37704
|
+
* ```
|
|
37643
37705
|
*/
|
|
37644
37706
|
async getTrustedServers(userAddress) {
|
|
37645
37707
|
try {
|
|
@@ -37665,11 +37727,27 @@ var PermissionsController = class {
|
|
|
37665
37727
|
}
|
|
37666
37728
|
}
|
|
37667
37729
|
/**
|
|
37668
|
-
*
|
|
37730
|
+
* Retrieves detailed information about a specific server from the DataPortabilityServers contract.
|
|
37669
37731
|
*
|
|
37670
|
-
*
|
|
37671
|
-
*
|
|
37732
|
+
* Returns complete server information including owner, address, public key, and URL.
|
|
37733
|
+
* This information is used to establish secure connections and verify server identity.
|
|
37734
|
+
*
|
|
37735
|
+
* @param serverId - The unique numeric ID of the server to query
|
|
37736
|
+
* @returns Promise resolving to complete server information
|
|
37672
37737
|
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
37738
|
+
* @throws {NetworkError} When unable to connect to the blockchain network
|
|
37739
|
+
* @throws {ServerNotFoundError} When the server ID does not exist
|
|
37740
|
+
*
|
|
37741
|
+
* @example
|
|
37742
|
+
* ```typescript
|
|
37743
|
+
* const server = await vana.permissions.getServerInfo(1);
|
|
37744
|
+
*
|
|
37745
|
+
* console.log(`Server ${server.id}:`);
|
|
37746
|
+
* console.log(` Owner: ${server.owner}`);
|
|
37747
|
+
* console.log(` Address: ${server.serverAddress}`);
|
|
37748
|
+
* console.log(` URL: ${server.url}`);
|
|
37749
|
+
* console.log(` Public Key: ${server.publicKey}`);
|
|
37750
|
+
* ```
|
|
37673
37751
|
*/
|
|
37674
37752
|
async getServerInfo(serverId) {
|
|
37675
37753
|
try {
|
|
@@ -37700,10 +37778,26 @@ var PermissionsController = class {
|
|
|
37700
37778
|
}
|
|
37701
37779
|
}
|
|
37702
37780
|
/**
|
|
37703
|
-
* Checks if a server is active.
|
|
37781
|
+
* Checks if a specific server is active in the DataPortabilityServers contract.
|
|
37704
37782
|
*
|
|
37705
|
-
*
|
|
37706
|
-
*
|
|
37783
|
+
* An active server is one that is properly registered and operational, meaning
|
|
37784
|
+
* it can receive and process data portability requests from users.
|
|
37785
|
+
*
|
|
37786
|
+
* @param serverId - The unique numeric ID of the server to check
|
|
37787
|
+
* @returns Promise resolving to true if server is active, false otherwise
|
|
37788
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
37789
|
+
* @throws {NetworkError} When unable to connect to the blockchain network
|
|
37790
|
+
*
|
|
37791
|
+
* @example
|
|
37792
|
+
* ```typescript
|
|
37793
|
+
* const isActive = await vana.permissions.isActiveServer(1);
|
|
37794
|
+
*
|
|
37795
|
+
* if (isActive) {
|
|
37796
|
+
* console.log('Server 1 is active and ready to process requests');
|
|
37797
|
+
* } else {
|
|
37798
|
+
* console.log('Server 1 is inactive or not found');
|
|
37799
|
+
* }
|
|
37800
|
+
* ```
|
|
37707
37801
|
*/
|
|
37708
37802
|
async isActiveServer(serverId) {
|
|
37709
37803
|
try {
|
|
@@ -38175,10 +38269,19 @@ var PermissionsController = class {
|
|
|
38175
38269
|
// GRANTEE METHODS
|
|
38176
38270
|
// ===========================
|
|
38177
38271
|
/**
|
|
38178
|
-
* Registers a new grantee
|
|
38272
|
+
* Registers a new grantee in the DataPortabilityGrantees contract.
|
|
38273
|
+
*
|
|
38274
|
+
* A grantee is an entity (like an application) that can receive data permissions
|
|
38275
|
+
* from users. Once registered, users can grant the grantee access to their data.
|
|
38179
38276
|
*
|
|
38180
38277
|
* @param params - Parameters for registering the grantee
|
|
38278
|
+
* @param params.owner - The Ethereum address that will own this grantee registration
|
|
38279
|
+
* @param params.granteeAddress - The Ethereum address of the grantee (application)
|
|
38280
|
+
* @param params.publicKey - The public key used for data encryption/decryption (hex string)
|
|
38181
38281
|
* @returns Promise resolving to the transaction hash
|
|
38282
|
+
* @throws {BlockchainError} When the grantee registration transaction fails
|
|
38283
|
+
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
38284
|
+
* @throws {ContractError} When grantee is already registered
|
|
38182
38285
|
*
|
|
38183
38286
|
* @example
|
|
38184
38287
|
* ```typescript
|
|
@@ -38187,6 +38290,7 @@ var PermissionsController = class {
|
|
|
38187
38290
|
* granteeAddress: "0xApp1234567890123456789012345678901234567890",
|
|
38188
38291
|
* publicKey: "0x1234567890abcdef..."
|
|
38189
38292
|
* });
|
|
38293
|
+
* console.log(`Grantee registered in transaction: ${txHash}`);
|
|
38190
38294
|
* ```
|
|
38191
38295
|
*/
|
|
38192
38296
|
async registerGrantee(params) {
|
|
@@ -38249,17 +38353,35 @@ var PermissionsController = class {
|
|
|
38249
38353
|
return this.submitSignedRegisterGranteeTransaction(typedData, signature);
|
|
38250
38354
|
}
|
|
38251
38355
|
/**
|
|
38252
|
-
*
|
|
38356
|
+
* Retrieves all registered grantees from the DataPortabilityGrantees contract.
|
|
38253
38357
|
*
|
|
38254
|
-
*
|
|
38255
|
-
*
|
|
38358
|
+
* Returns a paginated list of all grantees (applications) that have been registered
|
|
38359
|
+
* in the system and can receive data permissions from users.
|
|
38360
|
+
*
|
|
38361
|
+
* @param options - Query options for pagination and filtering
|
|
38362
|
+
* @param options.limit - Maximum number of grantees to return (default: 50)
|
|
38363
|
+
* @param options.offset - Number of grantees to skip for pagination (default: 0)
|
|
38364
|
+
* @returns Promise resolving to paginated grantees with metadata
|
|
38365
|
+
* @throws {BlockchainError} When contract read operation fails
|
|
38366
|
+
* @throws {NetworkError} When unable to connect to the blockchain network
|
|
38256
38367
|
*
|
|
38257
38368
|
* @example
|
|
38258
38369
|
* ```typescript
|
|
38370
|
+
* // Get first 10 grantees
|
|
38259
38371
|
* const result = await vana.permissions.getGrantees({
|
|
38260
38372
|
* limit: 10,
|
|
38261
38373
|
* offset: 0
|
|
38262
38374
|
* });
|
|
38375
|
+
*
|
|
38376
|
+
* console.log(`Found ${result.total} total grantees`);
|
|
38377
|
+
* result.grantees.forEach(grantee => {
|
|
38378
|
+
* console.log(`Grantee ${grantee.id}: ${grantee.granteeAddress}`);
|
|
38379
|
+
* });
|
|
38380
|
+
*
|
|
38381
|
+
* // Check if there are more results
|
|
38382
|
+
* if (result.hasMore) {
|
|
38383
|
+
* console.log('More grantees available');
|
|
38384
|
+
* }
|
|
38263
38385
|
* ```
|
|
38264
38386
|
*/
|
|
38265
38387
|
async getGrantees(options = {}) {
|
|
@@ -38308,14 +38430,29 @@ var PermissionsController = class {
|
|
|
38308
38430
|
};
|
|
38309
38431
|
}
|
|
38310
38432
|
/**
|
|
38311
|
-
*
|
|
38433
|
+
* Retrieves a specific grantee by their Ethereum address from the DataPortabilityGrantees contract.
|
|
38434
|
+
*
|
|
38435
|
+
* Looks up a registered grantee (application) using their Ethereum address
|
|
38436
|
+
* and returns their complete registration information including permissions.
|
|
38312
38437
|
*
|
|
38313
|
-
* @param granteeAddress - The grantee
|
|
38314
|
-
* @returns Promise resolving to the grantee
|
|
38438
|
+
* @param granteeAddress - The Ethereum address of the grantee to look up
|
|
38439
|
+
* @returns Promise resolving to the grantee information, or null if not found
|
|
38440
|
+
* @throws {BlockchainError} When contract read operation fails
|
|
38441
|
+
* @throws {NetworkError} When unable to connect to the blockchain network
|
|
38315
38442
|
*
|
|
38316
38443
|
* @example
|
|
38317
38444
|
* ```typescript
|
|
38318
|
-
* const
|
|
38445
|
+
* const granteeAddress = "0xApp1234567890123456789012345678901234567890";
|
|
38446
|
+
* const grantee = await vana.permissions.getGranteeByAddress(granteeAddress);
|
|
38447
|
+
*
|
|
38448
|
+
* if (grantee) {
|
|
38449
|
+
* console.log(`Found grantee ${grantee.id}`);
|
|
38450
|
+
* console.log(`Owner: ${grantee.owner}`);
|
|
38451
|
+
* console.log(`Public Key: ${grantee.publicKey}`);
|
|
38452
|
+
* console.log(`Permissions: ${grantee.permissionIds.join(', ')}`);
|
|
38453
|
+
* } else {
|
|
38454
|
+
* console.log('Grantee not found');
|
|
38455
|
+
* }
|
|
38319
38456
|
* ```
|
|
38320
38457
|
*/
|
|
38321
38458
|
async getGranteeByAddress(granteeAddress) {
|
|
@@ -38351,14 +38488,28 @@ var PermissionsController = class {
|
|
|
38351
38488
|
}
|
|
38352
38489
|
}
|
|
38353
38490
|
/**
|
|
38354
|
-
*
|
|
38491
|
+
* Retrieves a specific grantee by their unique ID from the DataPortabilityGrantees contract.
|
|
38492
|
+
*
|
|
38493
|
+
* Looks up a registered grantee (application) using their numeric ID assigned during
|
|
38494
|
+
* registration and returns their complete information including permissions.
|
|
38355
38495
|
*
|
|
38356
|
-
* @param granteeId - The grantee
|
|
38357
|
-
* @returns Promise resolving to the grantee
|
|
38496
|
+
* @param granteeId - The unique numeric ID of the grantee (1-indexed)
|
|
38497
|
+
* @returns Promise resolving to the grantee information, or null if not found
|
|
38498
|
+
* @throws {BlockchainError} When contract read operation fails
|
|
38499
|
+
* @throws {NetworkError} When unable to connect to the blockchain network
|
|
38358
38500
|
*
|
|
38359
38501
|
* @example
|
|
38360
38502
|
* ```typescript
|
|
38361
38503
|
* const grantee = await vana.permissions.getGranteeById(1);
|
|
38504
|
+
*
|
|
38505
|
+
* if (grantee) {
|
|
38506
|
+
* console.log(`Grantee ID: ${grantee.id}`);
|
|
38507
|
+
* console.log(`Address: ${grantee.granteeAddress}`);
|
|
38508
|
+
* console.log(`Owner: ${grantee.owner}`);
|
|
38509
|
+
* console.log(`Total permissions: ${grantee.permissionIds.length}`);
|
|
38510
|
+
* } else {
|
|
38511
|
+
* console.log('Grantee with ID 1 not found');
|
|
38512
|
+
* }
|
|
38362
38513
|
* ```
|
|
38363
38514
|
*/
|
|
38364
38515
|
async getGranteeById(granteeId) {
|
|
@@ -39213,11 +39364,18 @@ var DataController = class {
|
|
|
39213
39364
|
query GetUserTrustedServers($userId: ID!) {
|
|
39214
39365
|
user(id: $userId) {
|
|
39215
39366
|
id
|
|
39216
|
-
|
|
39367
|
+
serverTrusts {
|
|
39217
39368
|
id
|
|
39218
|
-
|
|
39219
|
-
|
|
39369
|
+
server {
|
|
39370
|
+
id
|
|
39371
|
+
serverAddress
|
|
39372
|
+
url
|
|
39373
|
+
publicKey
|
|
39374
|
+
}
|
|
39220
39375
|
trustedAt
|
|
39376
|
+
trustedAtBlock
|
|
39377
|
+
untrustedAtBlock
|
|
39378
|
+
transactionHash
|
|
39221
39379
|
}
|
|
39222
39380
|
}
|
|
39223
39381
|
}
|
|
@@ -39249,12 +39407,14 @@ var DataController = class {
|
|
|
39249
39407
|
if (!result.data?.user) {
|
|
39250
39408
|
return [];
|
|
39251
39409
|
}
|
|
39252
|
-
return (result.data.user.
|
|
39253
|
-
id: server.id,
|
|
39254
|
-
serverAddress: server.serverAddress,
|
|
39255
|
-
serverUrl: server.
|
|
39256
|
-
trustedAt: BigInt(
|
|
39257
|
-
user
|
|
39410
|
+
return (result.data.user.serverTrusts || []).filter((trust) => !trust.untrustedAtBlock).map((trust) => ({
|
|
39411
|
+
id: trust.server.id,
|
|
39412
|
+
serverAddress: trust.server.serverAddress,
|
|
39413
|
+
serverUrl: trust.server.url,
|
|
39414
|
+
trustedAt: BigInt(trust.trustedAt),
|
|
39415
|
+
user,
|
|
39416
|
+
name: ""
|
|
39417
|
+
// Not available in new schema, will be empty
|
|
39258
39418
|
}));
|
|
39259
39419
|
} catch (error) {
|
|
39260
39420
|
console.error("Failed to query trusted servers from subgraph:", error);
|
|
@@ -41081,7 +41241,14 @@ var ServerController = class {
|
|
|
41081
41241
|
constructor(context) {
|
|
41082
41242
|
this.context = context;
|
|
41083
41243
|
}
|
|
41084
|
-
|
|
41244
|
+
get personalServerBaseUrl() {
|
|
41245
|
+
if (!this.context.defaultPersonalServerUrl) {
|
|
41246
|
+
throw new PersonalServerError(
|
|
41247
|
+
"Personal server URL is required for server operations. Please configure defaultPersonalServerUrl in your VanaConfig."
|
|
41248
|
+
);
|
|
41249
|
+
}
|
|
41250
|
+
return this.context.defaultPersonalServerUrl;
|
|
41251
|
+
}
|
|
41085
41252
|
/**
|
|
41086
41253
|
* Retrieves the cryptographic identity of a personal server.
|
|
41087
41254
|
*
|
|
@@ -41118,7 +41285,7 @@ var ServerController = class {
|
|
|
41118
41285
|
async getIdentity(request) {
|
|
41119
41286
|
try {
|
|
41120
41287
|
const response = await fetch(
|
|
41121
|
-
`${this.
|
|
41288
|
+
`${this.personalServerBaseUrl}/identity?address=${request.userAddress}`,
|
|
41122
41289
|
{
|
|
41123
41290
|
method: "GET",
|
|
41124
41291
|
headers: {
|
|
@@ -41138,7 +41305,7 @@ var ServerController = class {
|
|
|
41138
41305
|
kind: serverResponse.personal_server.kind,
|
|
41139
41306
|
address: serverResponse.personal_server.address,
|
|
41140
41307
|
public_key: serverResponse.personal_server.public_key,
|
|
41141
|
-
base_url: this.
|
|
41308
|
+
base_url: this.personalServerBaseUrl,
|
|
41142
41309
|
name: "Hosted Vana Server"
|
|
41143
41310
|
};
|
|
41144
41311
|
} catch (error) {
|
|
@@ -41234,7 +41401,7 @@ var ServerController = class {
|
|
|
41234
41401
|
try {
|
|
41235
41402
|
console.debug("Polling Operation Status:", operationId);
|
|
41236
41403
|
const response = await fetch(
|
|
41237
|
-
`${this.
|
|
41404
|
+
`${this.personalServerBaseUrl}/operations/${operationId}`,
|
|
41238
41405
|
{
|
|
41239
41406
|
method: "GET",
|
|
41240
41407
|
headers: {
|
|
@@ -41312,7 +41479,7 @@ var ServerController = class {
|
|
|
41312
41479
|
async cancelOperation(operationId) {
|
|
41313
41480
|
try {
|
|
41314
41481
|
const response = await fetch(
|
|
41315
|
-
`${this.
|
|
41482
|
+
`${this.personalServerBaseUrl}/operations/${operationId}/cancel`,
|
|
41316
41483
|
{
|
|
41317
41484
|
method: "POST"
|
|
41318
41485
|
}
|
|
@@ -41341,23 +41508,20 @@ var ServerController = class {
|
|
|
41341
41508
|
async makeRequest(requestBody) {
|
|
41342
41509
|
try {
|
|
41343
41510
|
console.debug("Personal Server Request:", {
|
|
41344
|
-
url: `${this.
|
|
41511
|
+
url: `${this.personalServerBaseUrl}/operations`,
|
|
41345
41512
|
method: "POST",
|
|
41346
41513
|
headers: {
|
|
41347
41514
|
"Content-Type": "application/json"
|
|
41348
41515
|
},
|
|
41349
41516
|
body: requestBody
|
|
41350
41517
|
});
|
|
41351
|
-
const response = await fetch(
|
|
41352
|
-
|
|
41353
|
-
{
|
|
41354
|
-
|
|
41355
|
-
|
|
41356
|
-
|
|
41357
|
-
|
|
41358
|
-
body: JSON.stringify(requestBody)
|
|
41359
|
-
}
|
|
41360
|
-
);
|
|
41518
|
+
const response = await fetch(`${this.personalServerBaseUrl}/operations`, {
|
|
41519
|
+
method: "POST",
|
|
41520
|
+
headers: {
|
|
41521
|
+
"Content-Type": "application/json"
|
|
41522
|
+
},
|
|
41523
|
+
body: JSON.stringify(requestBody)
|
|
41524
|
+
});
|
|
41361
41525
|
if (!response.ok) {
|
|
41362
41526
|
const errorText = await response.text();
|
|
41363
41527
|
console.debug("Personal Server Error Response:", {
|
|
@@ -43131,7 +43295,7 @@ var vanaMainnet2 = {
|
|
|
43131
43295
|
url: "https://vanascan.io"
|
|
43132
43296
|
}
|
|
43133
43297
|
},
|
|
43134
|
-
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/vana/7.0.
|
|
43298
|
+
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/vana/7.0.6/gn"
|
|
43135
43299
|
};
|
|
43136
43300
|
var moksha = {
|
|
43137
43301
|
id: 14800,
|
|
@@ -43152,7 +43316,7 @@ var moksha = {
|
|
|
43152
43316
|
url: "https://moksha.vanascan.io"
|
|
43153
43317
|
}
|
|
43154
43318
|
},
|
|
43155
|
-
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/moksha/7.0.
|
|
43319
|
+
subgraphUrl: "https://api.goldsky.com/api/public/project_cm168cz887zva010j39il7a6p/subgraphs/moksha/7.0.6/gn"
|
|
43156
43320
|
};
|
|
43157
43321
|
function getChainConfig(chainId) {
|
|
43158
43322
|
switch (chainId) {
|
|
@@ -43228,6 +43392,7 @@ var VanaCore = class {
|
|
|
43228
43392
|
storageManager;
|
|
43229
43393
|
hasRequiredStorage;
|
|
43230
43394
|
ipfsGateways;
|
|
43395
|
+
defaultPersonalServerUrl;
|
|
43231
43396
|
/**
|
|
43232
43397
|
* Initializes a new VanaCore client instance with the provided configuration.
|
|
43233
43398
|
*
|
|
@@ -43254,6 +43419,7 @@ var VanaCore = class {
|
|
|
43254
43419
|
this.validateConfig(config);
|
|
43255
43420
|
this.relayerCallbacks = config.relayerCallbacks;
|
|
43256
43421
|
this.ipfsGateways = config.ipfsGateways;
|
|
43422
|
+
this.defaultPersonalServerUrl = config.defaultPersonalServerUrl;
|
|
43257
43423
|
this.hasRequiredStorage = hasStorageConfig(config);
|
|
43258
43424
|
if (config.storage?.providers) {
|
|
43259
43425
|
this.storageManager = new StorageManager();
|
|
@@ -43313,7 +43479,8 @@ var VanaCore = class {
|
|
|
43313
43479
|
// Pass the platform adapter to controllers
|
|
43314
43480
|
validateStorageRequired: this.validateStorageRequired.bind(this),
|
|
43315
43481
|
hasStorage: this.hasStorage.bind(this),
|
|
43316
|
-
ipfsGateways: this.ipfsGateways
|
|
43482
|
+
ipfsGateways: this.ipfsGateways,
|
|
43483
|
+
defaultPersonalServerUrl: this.defaultPersonalServerUrl
|
|
43317
43484
|
};
|
|
43318
43485
|
this.permissions = new PermissionsController(sharedContext);
|
|
43319
43486
|
this.data = new DataController(sharedContext);
|