@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
|
@@ -57,10 +57,14 @@ class PermissionsController extends BaseController {
|
|
|
57
57
|
* await vana.permissions.revoke({ permissionId: result.permissionId });
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
async grant(params) {
|
|
60
|
+
async grant(params, options) {
|
|
61
61
|
this.assertWallet();
|
|
62
62
|
const { typedData, signature } = await this.createAndSign(params);
|
|
63
|
-
const result = await this.submitSignedGrantWithEvents(
|
|
63
|
+
const result = await this.submitSignedGrantWithEvents(
|
|
64
|
+
typedData,
|
|
65
|
+
signature,
|
|
66
|
+
options
|
|
67
|
+
);
|
|
64
68
|
return result;
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
@@ -88,10 +92,10 @@ class PermissionsController extends BaseController {
|
|
|
88
92
|
* console.log(`Permission ID: ${eventData.permissionId}`);
|
|
89
93
|
* ```
|
|
90
94
|
*/
|
|
91
|
-
async submitPermissionGrant(params) {
|
|
95
|
+
async submitPermissionGrant(params, options) {
|
|
92
96
|
this.assertWallet();
|
|
93
97
|
const { typedData, signature } = await this.createAndSign(params);
|
|
94
|
-
return await this.submitSignedGrant(typedData, signature);
|
|
98
|
+
return await this.submitSignedGrant(typedData, signature, options);
|
|
95
99
|
}
|
|
96
100
|
/**
|
|
97
101
|
* Prepares a permission grant with preview before signing.
|
|
@@ -118,7 +122,7 @@ class PermissionsController extends BaseController {
|
|
|
118
122
|
* const transactionHash = await confirm();
|
|
119
123
|
* ```
|
|
120
124
|
*/
|
|
121
|
-
async prepareGrant(params) {
|
|
125
|
+
async prepareGrant(params, options) {
|
|
122
126
|
this.assertWallet();
|
|
123
127
|
try {
|
|
124
128
|
const grantFile = createGrantFile(params);
|
|
@@ -126,7 +130,11 @@ class PermissionsController extends BaseController {
|
|
|
126
130
|
return {
|
|
127
131
|
preview: grantFile,
|
|
128
132
|
confirm: async () => {
|
|
129
|
-
return await this.confirmGrantInternalWithEvents(
|
|
133
|
+
return await this.confirmGrantInternalWithEvents(
|
|
134
|
+
params,
|
|
135
|
+
grantFile,
|
|
136
|
+
options
|
|
137
|
+
);
|
|
130
138
|
}
|
|
131
139
|
};
|
|
132
140
|
} catch (error) {
|
|
@@ -158,7 +166,7 @@ class PermissionsController extends BaseController {
|
|
|
158
166
|
* @throws {NetworkError} When IPFS upload fails
|
|
159
167
|
* @throws {SignatureError} When user rejects the signature
|
|
160
168
|
*/
|
|
161
|
-
async confirmGrantInternal(params, grantFile) {
|
|
169
|
+
async confirmGrantInternal(params, grantFile, options) {
|
|
162
170
|
try {
|
|
163
171
|
let { grantUrl } = params;
|
|
164
172
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
@@ -219,7 +227,7 @@ class PermissionsController extends BaseController {
|
|
|
219
227
|
nonce
|
|
220
228
|
});
|
|
221
229
|
const signature = await this.signTypedData(typedData);
|
|
222
|
-
return await this.submitSignedGrant(typedData, signature);
|
|
230
|
+
return await this.submitSignedGrant(typedData, signature, options);
|
|
223
231
|
} catch (error) {
|
|
224
232
|
if (error instanceof Error) {
|
|
225
233
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -364,7 +372,7 @@ class PermissionsController extends BaseController {
|
|
|
364
372
|
* );
|
|
365
373
|
* ```
|
|
366
374
|
*/
|
|
367
|
-
async submitSignedGrant(typedData, signature) {
|
|
375
|
+
async submitSignedGrant(typedData, signature, options) {
|
|
368
376
|
try {
|
|
369
377
|
console.debug(
|
|
370
378
|
"\u{1F50D} Debug - submitSignedGrant called with typed data:",
|
|
@@ -382,26 +390,40 @@ class PermissionsController extends BaseController {
|
|
|
382
390
|
signature,
|
|
383
391
|
expectedUserAddress: this.context.userAddress
|
|
384
392
|
});
|
|
385
|
-
|
|
386
|
-
if (response.type === "signed") {
|
|
387
|
-
hash = response.hash;
|
|
388
|
-
} else if (response.type === "error") {
|
|
393
|
+
if (response.type === "error") {
|
|
389
394
|
throw new Error(`Relayer error: ${response.error}`);
|
|
395
|
+
}
|
|
396
|
+
let finalHash;
|
|
397
|
+
if (response.type === "submitted") {
|
|
398
|
+
finalHash = response.hash;
|
|
399
|
+
} else if (response.type === "pending") {
|
|
400
|
+
const pollResult = await this.pollRelayerForConfirmation(
|
|
401
|
+
response.operationId
|
|
402
|
+
);
|
|
403
|
+
finalHash = pollResult.hash;
|
|
404
|
+
} else if (response.type === "confirmed") {
|
|
405
|
+
finalHash = response.hash;
|
|
406
|
+
} else if (response.type === "signed") {
|
|
407
|
+
finalHash = response.hash;
|
|
390
408
|
} else {
|
|
391
409
|
throw new Error(
|
|
392
|
-
"Invalid response from relayer:
|
|
410
|
+
"Invalid response from relayer: unexpected response type"
|
|
393
411
|
);
|
|
394
412
|
}
|
|
395
413
|
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
396
414
|
const { tx } = await import("../utils/transactionHelpers");
|
|
397
415
|
return tx({
|
|
398
|
-
hash,
|
|
416
|
+
hash: finalHash,
|
|
399
417
|
from: typeof account === "string" ? account : account.address,
|
|
400
418
|
contract: "DataPortabilityPermissions",
|
|
401
419
|
fn: "addPermission"
|
|
402
420
|
});
|
|
403
421
|
} else {
|
|
404
|
-
return await this.submitDirectTransaction(
|
|
422
|
+
return await this.submitDirectTransaction(
|
|
423
|
+
typedData,
|
|
424
|
+
signature,
|
|
425
|
+
options
|
|
426
|
+
);
|
|
405
427
|
}
|
|
406
428
|
} catch (error) {
|
|
407
429
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
@@ -434,7 +456,7 @@ class PermissionsController extends BaseController {
|
|
|
434
456
|
* const result = await txHandle.waitForEvents();
|
|
435
457
|
* ```
|
|
436
458
|
*/
|
|
437
|
-
async submitSignedTrustServer(typedData, signature) {
|
|
459
|
+
async submitSignedTrustServer(typedData, signature, options) {
|
|
438
460
|
try {
|
|
439
461
|
const trustServerInput = {
|
|
440
462
|
nonce: BigInt(typedData.message.nonce),
|
|
@@ -442,7 +464,8 @@ class PermissionsController extends BaseController {
|
|
|
442
464
|
};
|
|
443
465
|
const hash = await this.submitTrustServerTransaction(
|
|
444
466
|
trustServerInput,
|
|
445
|
-
signature
|
|
467
|
+
signature,
|
|
468
|
+
options
|
|
446
469
|
);
|
|
447
470
|
const account = this.context.userAddress;
|
|
448
471
|
const { tx } = await import("../utils/transactionHelpers");
|
|
@@ -497,7 +520,7 @@ class PermissionsController extends BaseController {
|
|
|
497
520
|
* const result = await txHandle.waitForEvents();
|
|
498
521
|
* ```
|
|
499
522
|
*/
|
|
500
|
-
async submitSignedAddAndTrustServer(typedData, signature) {
|
|
523
|
+
async submitSignedAddAndTrustServer(typedData, signature, _options) {
|
|
501
524
|
try {
|
|
502
525
|
const addAndTrustServerInput = {
|
|
503
526
|
nonce: BigInt(typedData.message.nonce),
|
|
@@ -535,8 +558,12 @@ class PermissionsController extends BaseController {
|
|
|
535
558
|
* @param signature - The user's signature authorizing the transaction
|
|
536
559
|
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
537
560
|
*/
|
|
538
|
-
async submitSignedGrantWithEvents(typedData, signature) {
|
|
539
|
-
const txResult = await this.submitSignedGrant(
|
|
561
|
+
async submitSignedGrantWithEvents(typedData, signature, options) {
|
|
562
|
+
const txResult = await this.submitSignedGrant(
|
|
563
|
+
typedData,
|
|
564
|
+
signature,
|
|
565
|
+
options
|
|
566
|
+
);
|
|
540
567
|
if (!this.context.waitForTransactionEvents) {
|
|
541
568
|
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
542
569
|
}
|
|
@@ -568,8 +595,12 @@ class PermissionsController extends BaseController {
|
|
|
568
595
|
* @param grantFile - The pre-created grant file object
|
|
569
596
|
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
570
597
|
*/
|
|
571
|
-
async confirmGrantInternalWithEvents(params, grantFile) {
|
|
572
|
-
const txResult = await this.confirmGrantInternal(
|
|
598
|
+
async confirmGrantInternalWithEvents(params, grantFile, options) {
|
|
599
|
+
const txResult = await this.confirmGrantInternal(
|
|
600
|
+
params,
|
|
601
|
+
grantFile,
|
|
602
|
+
options
|
|
603
|
+
);
|
|
573
604
|
if (!this.context.waitForTransactionEvents) {
|
|
574
605
|
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
575
606
|
}
|
|
@@ -593,6 +624,39 @@ class PermissionsController extends BaseController {
|
|
|
593
624
|
fileIds: event.fileIds
|
|
594
625
|
};
|
|
595
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* Polls the relayer for confirmation of a pending operation.
|
|
629
|
+
*
|
|
630
|
+
* @param operationId - The operation ID to poll
|
|
631
|
+
* @returns Promise resolving to the confirmed hash
|
|
632
|
+
* @throws {Error} When the operation fails or times out
|
|
633
|
+
* @internal
|
|
634
|
+
*/
|
|
635
|
+
async pollRelayerForConfirmation(operationId, options = {}) {
|
|
636
|
+
const timeout = options.timeout ?? 3e4;
|
|
637
|
+
let interval = options.pollingInterval ?? 1e3;
|
|
638
|
+
const startTime = Date.now();
|
|
639
|
+
while (Date.now() - startTime < timeout) {
|
|
640
|
+
if (!this.context.relayer) {
|
|
641
|
+
throw new Error("Relayer not configured for polling");
|
|
642
|
+
}
|
|
643
|
+
const statusResponse = await this.context.relayer({
|
|
644
|
+
type: "status_check",
|
|
645
|
+
operationId
|
|
646
|
+
});
|
|
647
|
+
if (statusResponse.type === "confirmed") {
|
|
648
|
+
return { hash: statusResponse.hash };
|
|
649
|
+
}
|
|
650
|
+
if (statusResponse.type === "error") {
|
|
651
|
+
throw new Error(
|
|
652
|
+
`Operation ${operationId} failed: ${statusResponse.error}`
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
656
|
+
interval = Math.min(interval * 1.5, 5e3);
|
|
657
|
+
}
|
|
658
|
+
throw new Error(`Operation ${operationId} timed out after ${timeout}ms`);
|
|
659
|
+
}
|
|
596
660
|
/**
|
|
597
661
|
* Submits an already-signed permission revoke transaction to the blockchain.
|
|
598
662
|
*
|
|
@@ -614,7 +678,7 @@ class PermissionsController extends BaseController {
|
|
|
614
678
|
* const result = await txHandle.waitForEvents();
|
|
615
679
|
* ```
|
|
616
680
|
*/
|
|
617
|
-
async submitSignedRevoke(typedData, signature) {
|
|
681
|
+
async submitSignedRevoke(typedData, signature, _options) {
|
|
618
682
|
try {
|
|
619
683
|
let hash;
|
|
620
684
|
if (this.context.relayer) {
|
|
@@ -625,13 +689,23 @@ class PermissionsController extends BaseController {
|
|
|
625
689
|
signature,
|
|
626
690
|
expectedUserAddress: this.context.userAddress
|
|
627
691
|
});
|
|
628
|
-
if (response.type === "
|
|
629
|
-
hash = response.hash;
|
|
630
|
-
} else if (response.type === "error") {
|
|
692
|
+
if (response.type === "error") {
|
|
631
693
|
throw new Error(`Relayer error: ${response.error}`);
|
|
694
|
+
}
|
|
695
|
+
if (response.type === "submitted") {
|
|
696
|
+
hash = response.hash;
|
|
697
|
+
} else if (response.type === "pending") {
|
|
698
|
+
const pollResult = await this.pollRelayerForConfirmation(
|
|
699
|
+
response.operationId
|
|
700
|
+
);
|
|
701
|
+
hash = pollResult.hash;
|
|
702
|
+
} else if (response.type === "confirmed") {
|
|
703
|
+
hash = response.hash;
|
|
704
|
+
} else if (response.type === "signed") {
|
|
705
|
+
hash = response.hash;
|
|
632
706
|
} else {
|
|
633
707
|
throw new Error(
|
|
634
|
-
"Invalid response from relayer:
|
|
708
|
+
"Invalid response from relayer: unexpected response type"
|
|
635
709
|
);
|
|
636
710
|
}
|
|
637
711
|
} else {
|
|
@@ -679,7 +753,7 @@ class PermissionsController extends BaseController {
|
|
|
679
753
|
* const result = await txHandle.waitForEvents();
|
|
680
754
|
* ```
|
|
681
755
|
*/
|
|
682
|
-
async submitSignedUntrustServer(typedData, signature) {
|
|
756
|
+
async submitSignedUntrustServer(typedData, signature, _options) {
|
|
683
757
|
try {
|
|
684
758
|
let hash;
|
|
685
759
|
if (this.context.relayer) {
|
|
@@ -735,7 +809,7 @@ class PermissionsController extends BaseController {
|
|
|
735
809
|
* @returns Promise resolving to the transaction hash
|
|
736
810
|
* @throws {BlockchainError} When contract submission fails
|
|
737
811
|
*/
|
|
738
|
-
async submitDirectTransaction(typedData, signature) {
|
|
812
|
+
async submitDirectTransaction(typedData, signature, options) {
|
|
739
813
|
this.assertWallet();
|
|
740
814
|
const chainId = await this.context.publicClient.getChainId();
|
|
741
815
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
@@ -767,7 +841,8 @@ class PermissionsController extends BaseController {
|
|
|
767
841
|
functionName: "addPermission",
|
|
768
842
|
args: [permissionInput, formattedSignature],
|
|
769
843
|
account,
|
|
770
|
-
chain: this.context.walletClient?.chain ?? null
|
|
844
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
845
|
+
...this.spreadTransactionOptions(options)
|
|
771
846
|
});
|
|
772
847
|
const { tx } = await import("../utils/transactionHelpers");
|
|
773
848
|
return tx({
|
|
@@ -831,6 +906,7 @@ class PermissionsController extends BaseController {
|
|
|
831
906
|
* Use this when you want to handle transaction confirmation and event parsing separately.
|
|
832
907
|
*
|
|
833
908
|
* @param params - Parameters for revoking the permission
|
|
909
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
834
910
|
* @returns Promise resolving to the transaction hash when successfully submitted
|
|
835
911
|
* @throws {BlockchainError} When revocation transaction fails
|
|
836
912
|
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
@@ -843,7 +919,7 @@ class PermissionsController extends BaseController {
|
|
|
843
919
|
* console.log(`Revocation submitted: ${txHash}`);
|
|
844
920
|
* ```
|
|
845
921
|
*/
|
|
846
|
-
async submitPermissionRevoke(params) {
|
|
922
|
+
async submitPermissionRevoke(params, options) {
|
|
847
923
|
this.assertWallet();
|
|
848
924
|
try {
|
|
849
925
|
if (!this.context.walletClient?.chain?.id) {
|
|
@@ -864,7 +940,18 @@ class PermissionsController extends BaseController {
|
|
|
864
940
|
functionName: "revokePermission",
|
|
865
941
|
args: [params.permissionId],
|
|
866
942
|
account,
|
|
867
|
-
chain: this.context.walletClient?.chain ?? null
|
|
943
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
944
|
+
...options?.gas && { gas: options.gas },
|
|
945
|
+
...options?.nonce && { nonce: options.nonce },
|
|
946
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
947
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
948
|
+
...options.maxFeePerGas && {
|
|
949
|
+
maxFeePerGas: options.maxFeePerGas
|
|
950
|
+
},
|
|
951
|
+
...options.maxPriorityFeePerGas && {
|
|
952
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
953
|
+
}
|
|
954
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
868
955
|
});
|
|
869
956
|
const { tx } = await import("../utils/transactionHelpers");
|
|
870
957
|
return tx({
|
|
@@ -1674,7 +1761,7 @@ class PermissionsController extends BaseController {
|
|
|
1674
1761
|
* @returns Promise resolving to TransactionResult for transaction tracking
|
|
1675
1762
|
* @throws {BlockchainError} When contract submission fails
|
|
1676
1763
|
*/
|
|
1677
|
-
async submitDirectUntrustTransaction(params) {
|
|
1764
|
+
async submitDirectUntrustTransaction(params, options) {
|
|
1678
1765
|
this.assertWallet();
|
|
1679
1766
|
try {
|
|
1680
1767
|
const chainId = await this.context.walletClient.getChainId();
|
|
@@ -1690,7 +1777,18 @@ class PermissionsController extends BaseController {
|
|
|
1690
1777
|
functionName: "untrustServer",
|
|
1691
1778
|
args: [BigInt(params.serverId)],
|
|
1692
1779
|
account,
|
|
1693
|
-
chain: this.context.walletClient?.chain ?? null
|
|
1780
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
1781
|
+
...options?.gas && { gas: options.gas },
|
|
1782
|
+
...options?.nonce && { nonce: options.nonce },
|
|
1783
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
1784
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
1785
|
+
...options.maxFeePerGas && {
|
|
1786
|
+
maxFeePerGas: options.maxFeePerGas
|
|
1787
|
+
},
|
|
1788
|
+
...options.maxPriorityFeePerGas && {
|
|
1789
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
1790
|
+
}
|
|
1791
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
1694
1792
|
});
|
|
1695
1793
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1696
1794
|
return tx({
|
|
@@ -1717,6 +1815,7 @@ class PermissionsController extends BaseController {
|
|
|
1717
1815
|
*
|
|
1718
1816
|
* @param params - Parameters for untrusting the server
|
|
1719
1817
|
* @param params.serverId - The numeric ID of the server to untrust
|
|
1818
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
1720
1819
|
* @returns Promise resolving to transaction hash
|
|
1721
1820
|
* @throws {Error} When wallet account is not available
|
|
1722
1821
|
* @throws {NonceError} When retrieving user nonce fails
|
|
@@ -1737,14 +1836,17 @@ class PermissionsController extends BaseController {
|
|
|
1737
1836
|
* console.log('Still trusting servers:', trustedServers);
|
|
1738
1837
|
* ```
|
|
1739
1838
|
*/
|
|
1740
|
-
async submitUntrustServer(params) {
|
|
1839
|
+
async submitUntrustServer(params, options) {
|
|
1741
1840
|
this.assertWallet();
|
|
1742
1841
|
const nonce = await this.getServersUserNonce();
|
|
1743
1842
|
const untrustServerInput = {
|
|
1744
1843
|
nonce,
|
|
1745
1844
|
serverId: params.serverId
|
|
1746
1845
|
};
|
|
1747
|
-
return await this.submitDirectUntrustTransaction(
|
|
1846
|
+
return await this.submitDirectUntrustTransaction(
|
|
1847
|
+
untrustServerInput,
|
|
1848
|
+
options
|
|
1849
|
+
);
|
|
1748
1850
|
}
|
|
1749
1851
|
/**
|
|
1750
1852
|
* Untrusts a server using a signature (gasless transaction).
|
|
@@ -2271,7 +2373,7 @@ class PermissionsController extends BaseController {
|
|
|
2271
2373
|
* @param signature - The cryptographic signature for the transaction
|
|
2272
2374
|
* @returns Promise resolving to the transaction hash
|
|
2273
2375
|
*/
|
|
2274
|
-
async submitTrustServerTransaction(trustServerInput, signature) {
|
|
2376
|
+
async submitTrustServerTransaction(trustServerInput, signature, options) {
|
|
2275
2377
|
this.assertWallet();
|
|
2276
2378
|
const chainId = await this.context.walletClient.getChainId();
|
|
2277
2379
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -2292,7 +2394,8 @@ class PermissionsController extends BaseController {
|
|
|
2292
2394
|
formattedSignature
|
|
2293
2395
|
],
|
|
2294
2396
|
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2295
|
-
chain: this.context.walletClient?.chain ?? null
|
|
2397
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
2398
|
+
...this.spreadTransactionOptions(options)
|
|
2296
2399
|
});
|
|
2297
2400
|
return txHash;
|
|
2298
2401
|
}
|
|
@@ -2329,7 +2432,7 @@ class PermissionsController extends BaseController {
|
|
|
2329
2432
|
* @param signature - The cryptographic signature authorizing the untrust
|
|
2330
2433
|
* @returns Promise resolving to the transaction hash
|
|
2331
2434
|
*/
|
|
2332
|
-
async submitSignedUntrustTransaction(typedData, signature) {
|
|
2435
|
+
async submitSignedUntrustTransaction(typedData, signature, _options) {
|
|
2333
2436
|
this.assertWallet();
|
|
2334
2437
|
const chainId = await this.context.walletClient.getChainId();
|
|
2335
2438
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -2365,6 +2468,7 @@ class PermissionsController extends BaseController {
|
|
|
2365
2468
|
* @param params.owner - The Ethereum address that will own this grantee registration
|
|
2366
2469
|
* @param params.granteeAddress - The Ethereum address of the grantee (application)
|
|
2367
2470
|
* @param params.publicKey - The public key used for data encryption/decryption (hex string)
|
|
2471
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
2368
2472
|
* @returns Promise resolving to the transaction hash
|
|
2369
2473
|
* @throws {BlockchainError} When the grantee registration transaction fails
|
|
2370
2474
|
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
@@ -2380,7 +2484,7 @@ class PermissionsController extends BaseController {
|
|
|
2380
2484
|
* console.log(`Grantee registered in transaction: ${txHash}`);
|
|
2381
2485
|
* ```
|
|
2382
2486
|
*/
|
|
2383
|
-
async submitRegisterGrantee(params) {
|
|
2487
|
+
async submitRegisterGrantee(params, options) {
|
|
2384
2488
|
this.assertWallet();
|
|
2385
2489
|
const chainId = await this.context.walletClient.getChainId();
|
|
2386
2490
|
const DataPortabilityGranteesAddress = getContractAddress(
|
|
@@ -2397,7 +2501,8 @@ class PermissionsController extends BaseController {
|
|
|
2397
2501
|
functionName: "registerGrantee",
|
|
2398
2502
|
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
2399
2503
|
account,
|
|
2400
|
-
chain: this.context.walletClient?.chain ?? null
|
|
2504
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
2505
|
+
...this.spreadTransactionOptions(options)
|
|
2401
2506
|
});
|
|
2402
2507
|
const { tx } = await import("../utils/transactionHelpers");
|
|
2403
2508
|
return tx({
|
|
@@ -3315,9 +3420,10 @@ class PermissionsController extends BaseController {
|
|
|
3315
3420
|
*
|
|
3316
3421
|
* @param serverId - Server ID to update
|
|
3317
3422
|
* @param url - New URL for the server
|
|
3423
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
3318
3424
|
* @returns Promise resolving to transaction hash
|
|
3319
3425
|
*/
|
|
3320
|
-
async submitUpdateServer(serverId, url) {
|
|
3426
|
+
async submitUpdateServer(serverId, url, options) {
|
|
3321
3427
|
this.assertWallet();
|
|
3322
3428
|
try {
|
|
3323
3429
|
const chainId = await this.context.walletClient.getChainId();
|
|
@@ -3333,7 +3439,18 @@ class PermissionsController extends BaseController {
|
|
|
3333
3439
|
functionName: "updateServer",
|
|
3334
3440
|
args: [serverId, url],
|
|
3335
3441
|
chain: this.context.walletClient?.chain,
|
|
3336
|
-
account
|
|
3442
|
+
account,
|
|
3443
|
+
...options?.gas && { gas: options.gas },
|
|
3444
|
+
...options?.nonce && { nonce: options.nonce },
|
|
3445
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
3446
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
3447
|
+
...options.maxFeePerGas && {
|
|
3448
|
+
maxFeePerGas: options.maxFeePerGas
|
|
3449
|
+
},
|
|
3450
|
+
...options.maxPriorityFeePerGas && {
|
|
3451
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
3452
|
+
}
|
|
3453
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
3337
3454
|
});
|
|
3338
3455
|
const { tx } = await import("../utils/transactionHelpers");
|
|
3339
3456
|
return tx({
|
|
@@ -3529,7 +3646,7 @@ class PermissionsController extends BaseController {
|
|
|
3529
3646
|
* @throws {BlockchainError} When permission addition fails
|
|
3530
3647
|
* @throws {NetworkError} When network communication fails
|
|
3531
3648
|
*/
|
|
3532
|
-
async submitSignedAddPermission(typedData, signature) {
|
|
3649
|
+
async submitSignedAddPermission(typedData, signature, options) {
|
|
3533
3650
|
this.assertWallet();
|
|
3534
3651
|
try {
|
|
3535
3652
|
let hash;
|
|
@@ -3552,7 +3669,8 @@ class PermissionsController extends BaseController {
|
|
|
3552
3669
|
} else {
|
|
3553
3670
|
hash = await this.submitDirectAddPermissionTransaction(
|
|
3554
3671
|
typedData,
|
|
3555
|
-
signature
|
|
3672
|
+
signature,
|
|
3673
|
+
options
|
|
3556
3674
|
);
|
|
3557
3675
|
}
|
|
3558
3676
|
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
@@ -3593,6 +3711,9 @@ class PermissionsController extends BaseController {
|
|
|
3593
3711
|
* @param params.serverPublicKey - Server's public key for encryption.
|
|
3594
3712
|
* Obtain via `vana.server.getIdentity(userAddress).publicKey`.
|
|
3595
3713
|
* @param params.filePermissions - Nested array of permissions for each file
|
|
3714
|
+
* @param options - Optional transaction options for gas parameters and timeout.
|
|
3715
|
+
* Note: These options are only applied for direct blockchain transactions.
|
|
3716
|
+
* When using relayer callbacks (gasless transactions), these options are ignored.
|
|
3596
3717
|
* @returns TransactionResult with immediate hash access and optional event data
|
|
3597
3718
|
* @throws {Error} When schemaIds array length doesn't match fileUrls array length
|
|
3598
3719
|
* @throws {SchemaValidationError} When file data doesn't match the specified schema.
|
|
@@ -3606,6 +3727,7 @@ class PermissionsController extends BaseController {
|
|
|
3606
3727
|
*
|
|
3607
3728
|
* @example
|
|
3608
3729
|
* ```typescript
|
|
3730
|
+
* // Submit with custom gas parameters and timeout
|
|
3609
3731
|
* const result = await vana.permissions.submitAddServerFilesAndPermissions({
|
|
3610
3732
|
* granteeId: BigInt(1),
|
|
3611
3733
|
* grant: "ipfs://QmXxx...",
|
|
@@ -3618,12 +3740,19 @@ class PermissionsController extends BaseController {
|
|
|
3618
3740
|
* account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3619
3741
|
* key: encryptedKey
|
|
3620
3742
|
* }]]
|
|
3743
|
+
* }, {
|
|
3744
|
+
* maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
|
|
3745
|
+
* maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
|
|
3621
3746
|
* });
|
|
3622
|
-
*
|
|
3623
|
-
*
|
|
3747
|
+
*
|
|
3748
|
+
* // Wait for confirmation with custom timeout
|
|
3749
|
+
* const receipt = await vana.waitForTransactionReceipt(result, {
|
|
3750
|
+
* timeout: 180000 // 3 minutes
|
|
3751
|
+
* });
|
|
3752
|
+
* console.log(`Transaction confirmed: ${receipt.transactionHash}`);
|
|
3624
3753
|
* ```
|
|
3625
3754
|
*/
|
|
3626
|
-
async submitAddServerFilesAndPermissions(params) {
|
|
3755
|
+
async submitAddServerFilesAndPermissions(params, options) {
|
|
3627
3756
|
this.assertWallet();
|
|
3628
3757
|
try {
|
|
3629
3758
|
if (params.schemaIds.length !== params.fileUrls.length) {
|
|
@@ -3649,7 +3778,8 @@ class PermissionsController extends BaseController {
|
|
|
3649
3778
|
const signature = await this.signTypedData(typedData);
|
|
3650
3779
|
return await this.submitSignedAddServerFilesAndPermissions(
|
|
3651
3780
|
typedData,
|
|
3652
|
-
signature
|
|
3781
|
+
signature,
|
|
3782
|
+
options
|
|
3653
3783
|
);
|
|
3654
3784
|
} catch (error) {
|
|
3655
3785
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -3670,6 +3800,9 @@ class PermissionsController extends BaseController {
|
|
|
3670
3800
|
*
|
|
3671
3801
|
* @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
|
|
3672
3802
|
* @param signature - The user's signature
|
|
3803
|
+
* @param options - Optional transaction options for gas parameters and timeout.
|
|
3804
|
+
* Note: These options are only applied for direct blockchain transactions.
|
|
3805
|
+
* When using relayer callbacks (gasless transactions), these options are ignored.
|
|
3673
3806
|
* @returns TransactionResult with immediate hash access and optional event data
|
|
3674
3807
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
3675
3808
|
* @throws {BlockchainError} When server files and permissions addition fails
|
|
@@ -3688,7 +3821,7 @@ class PermissionsController extends BaseController {
|
|
|
3688
3821
|
* console.log(`Permission created with ID: ${permissionId}`);
|
|
3689
3822
|
* ```
|
|
3690
3823
|
*/
|
|
3691
|
-
async submitSignedAddServerFilesAndPermissions(typedData, signature) {
|
|
3824
|
+
async submitSignedAddServerFilesAndPermissions(typedData, signature, options) {
|
|
3692
3825
|
this.assertWallet();
|
|
3693
3826
|
try {
|
|
3694
3827
|
let hash;
|
|
@@ -3717,7 +3850,8 @@ class PermissionsController extends BaseController {
|
|
|
3717
3850
|
);
|
|
3718
3851
|
hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
|
|
3719
3852
|
typedData,
|
|
3720
|
-
signature
|
|
3853
|
+
signature,
|
|
3854
|
+
options
|
|
3721
3855
|
);
|
|
3722
3856
|
}
|
|
3723
3857
|
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
@@ -3742,9 +3876,10 @@ class PermissionsController extends BaseController {
|
|
|
3742
3876
|
* Submit permission revocation with signature to the blockchain
|
|
3743
3877
|
*
|
|
3744
3878
|
* @param permissionId - Permission ID to revoke
|
|
3879
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
3745
3880
|
* @returns Promise resolving to transaction hash
|
|
3746
3881
|
*/
|
|
3747
|
-
async submitRevokePermission(permissionId) {
|
|
3882
|
+
async submitRevokePermission(permissionId, options) {
|
|
3748
3883
|
this.assertWallet();
|
|
3749
3884
|
try {
|
|
3750
3885
|
const chainId = await this.context.walletClient.getChainId();
|
|
@@ -3765,7 +3900,18 @@ class PermissionsController extends BaseController {
|
|
|
3765
3900
|
functionName: "revokePermission",
|
|
3766
3901
|
args: [permissionId],
|
|
3767
3902
|
chain: this.context.walletClient?.chain,
|
|
3768
|
-
account
|
|
3903
|
+
account,
|
|
3904
|
+
...options?.gas && { gas: options.gas },
|
|
3905
|
+
...options?.nonce && { nonce: options.nonce },
|
|
3906
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
3907
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
3908
|
+
...options.maxFeePerGas && {
|
|
3909
|
+
maxFeePerGas: options.maxFeePerGas
|
|
3910
|
+
},
|
|
3911
|
+
...options.maxPriorityFeePerGas && {
|
|
3912
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
3913
|
+
}
|
|
3914
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
3769
3915
|
});
|
|
3770
3916
|
const { tx } = await import("../utils/transactionHelpers");
|
|
3771
3917
|
return tx({
|
|
@@ -3788,7 +3934,7 @@ class PermissionsController extends BaseController {
|
|
|
3788
3934
|
* @param signature - The cryptographic signature authorizing the transaction
|
|
3789
3935
|
* @returns Promise resolving to the transaction hash
|
|
3790
3936
|
*/
|
|
3791
|
-
async submitDirectAddPermissionTransaction(typedData, signature) {
|
|
3937
|
+
async submitDirectAddPermissionTransaction(typedData, signature, options) {
|
|
3792
3938
|
this.assertWallet();
|
|
3793
3939
|
const chainId = await this.context.walletClient.getChainId();
|
|
3794
3940
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
@@ -3809,7 +3955,8 @@ class PermissionsController extends BaseController {
|
|
|
3809
3955
|
functionName: "addPermission",
|
|
3810
3956
|
args: [permissionInput, formattedSignature],
|
|
3811
3957
|
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
3812
|
-
chain: this.context.walletClient?.chain ?? null
|
|
3958
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
3959
|
+
...this.spreadTransactionOptions(options)
|
|
3813
3960
|
});
|
|
3814
3961
|
return hash;
|
|
3815
3962
|
}
|
|
@@ -3820,7 +3967,7 @@ class PermissionsController extends BaseController {
|
|
|
3820
3967
|
* @param signature - The cryptographic signature authorizing the transaction
|
|
3821
3968
|
* @returns Promise resolving to the transaction hash
|
|
3822
3969
|
*/
|
|
3823
|
-
async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
|
|
3970
|
+
async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature, options) {
|
|
3824
3971
|
this.assertWallet();
|
|
3825
3972
|
const chainId = await this.context.publicClient.getChainId();
|
|
3826
3973
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
@@ -3844,10 +3991,11 @@ class PermissionsController extends BaseController {
|
|
|
3844
3991
|
address: DataPortabilityPermissionsAddress,
|
|
3845
3992
|
abi: DataPortabilityPermissionsAbi,
|
|
3846
3993
|
functionName: "addServerFilesAndPermissions",
|
|
3847
|
-
// @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
|
|
3848
3994
|
args: [serverFilesAndPermissionInput, formattedSignature],
|
|
3849
|
-
account: this.context.userAddress,
|
|
3850
|
-
chain: this.context.walletClient?.chain ?? null
|
|
3995
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
3996
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
3997
|
+
...options?.value && { value: options.value },
|
|
3998
|
+
...this.spreadTransactionOptions(options)
|
|
3851
3999
|
});
|
|
3852
4000
|
return hash;
|
|
3853
4001
|
}
|