@opendatalabs/vana-sdk 0.1.0-alpha.f2a82f7 → 0.1.0-alpha.f35bb9c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/base.cjs +0 -33
- package/dist/controllers/base.cjs.map +1 -1
- package/dist/controllers/base.d.ts +0 -10
- package/dist/controllers/base.js +0 -33
- package/dist/controllers/base.js.map +1 -1
- package/dist/controllers/data.cjs +19 -26
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +9 -9
- package/dist/controllers/data.js +19 -26
- package/dist/controllers/data.js.map +1 -1
- package/dist/controllers/permissions.cjs +65 -124
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +11 -20
- package/dist/controllers/permissions.js +65 -124
- package/dist/controllers/permissions.js.map +1 -1
- package/dist/core.cjs +1 -4
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +1 -2
- package/dist/core.js +1 -4
- package/dist/core.js.map +1 -1
- package/dist/index.node.cjs +0 -2
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +4 -27
- package/dist/index.node.js +0 -2
- package/dist/index.node.js.map +1 -1
- package/dist/server/relayerHandler.cjs +87 -201
- package/dist/server/relayerHandler.cjs.map +1 -1
- package/dist/server/relayerHandler.d.ts +1 -3
- package/dist/server/relayerHandler.js +87 -201
- package/dist/server/relayerHandler.js.map +1 -1
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.ts +0 -32
- package/dist/types/config.js.map +1 -1
- package/dist/types/controller-context.cjs.map +1 -1
- package/dist/types/controller-context.d.ts +1 -3
- package/dist/types/generics.cjs.map +1 -1
- package/dist/types/generics.d.ts +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/operations.cjs.map +1 -1
- package/dist/types/operations.d.ts +0 -46
- package/dist/types/operations.js.map +1 -1
- package/dist/types/relayer.cjs.map +1 -1
- package/dist/types/relayer.d.ts +8 -19
- package/dist/utils/ipfs.cjs +4 -2
- package/dist/utils/ipfs.cjs.map +1 -1
- package/dist/utils/ipfs.d.ts +1 -1
- package/dist/utils/ipfs.js +4 -2
- package/dist/utils/ipfs.js.map +1 -1
- package/package.json +1 -3
|
@@ -80,14 +80,10 @@ class PermissionsController extends import_base.BaseController {
|
|
|
80
80
|
* await vana.permissions.revoke({ permissionId: result.permissionId });
|
|
81
81
|
* ```
|
|
82
82
|
*/
|
|
83
|
-
async grant(params
|
|
83
|
+
async grant(params) {
|
|
84
84
|
this.assertWallet();
|
|
85
85
|
const { typedData, signature } = await this.createAndSign(params);
|
|
86
|
-
const result = await this.submitSignedGrantWithEvents(
|
|
87
|
-
typedData,
|
|
88
|
-
signature,
|
|
89
|
-
options
|
|
90
|
-
);
|
|
86
|
+
const result = await this.submitSignedGrantWithEvents(typedData, signature);
|
|
91
87
|
return result;
|
|
92
88
|
}
|
|
93
89
|
/**
|
|
@@ -115,10 +111,10 @@ class PermissionsController extends import_base.BaseController {
|
|
|
115
111
|
* console.log(`Permission ID: ${eventData.permissionId}`);
|
|
116
112
|
* ```
|
|
117
113
|
*/
|
|
118
|
-
async submitPermissionGrant(params
|
|
114
|
+
async submitPermissionGrant(params) {
|
|
119
115
|
this.assertWallet();
|
|
120
116
|
const { typedData, signature } = await this.createAndSign(params);
|
|
121
|
-
return await this.submitSignedGrant(typedData, signature
|
|
117
|
+
return await this.submitSignedGrant(typedData, signature);
|
|
122
118
|
}
|
|
123
119
|
/**
|
|
124
120
|
* Prepares a permission grant with preview before signing.
|
|
@@ -145,7 +141,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
145
141
|
* const transactionHash = await confirm();
|
|
146
142
|
* ```
|
|
147
143
|
*/
|
|
148
|
-
async prepareGrant(params
|
|
144
|
+
async prepareGrant(params) {
|
|
149
145
|
this.assertWallet();
|
|
150
146
|
try {
|
|
151
147
|
const grantFile = (0, import_grantFiles.createGrantFile)(params);
|
|
@@ -153,11 +149,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
153
149
|
return {
|
|
154
150
|
preview: grantFile,
|
|
155
151
|
confirm: async () => {
|
|
156
|
-
return await this.confirmGrantInternalWithEvents(
|
|
157
|
-
params,
|
|
158
|
-
grantFile,
|
|
159
|
-
options
|
|
160
|
-
);
|
|
152
|
+
return await this.confirmGrantInternalWithEvents(params, grantFile);
|
|
161
153
|
}
|
|
162
154
|
};
|
|
163
155
|
} catch (error) {
|
|
@@ -189,7 +181,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
189
181
|
* @throws {NetworkError} When IPFS upload fails
|
|
190
182
|
* @throws {SignatureError} When user rejects the signature
|
|
191
183
|
*/
|
|
192
|
-
async confirmGrantInternal(params, grantFile
|
|
184
|
+
async confirmGrantInternal(params, grantFile) {
|
|
193
185
|
try {
|
|
194
186
|
let { grantUrl } = params;
|
|
195
187
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
@@ -214,7 +206,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
214
206
|
if (response.type === "error") {
|
|
215
207
|
throw new Error(response.error);
|
|
216
208
|
}
|
|
217
|
-
if (response.type === "direct" && typeof response.result === "object" &&
|
|
209
|
+
if (response.type === "direct" && typeof response.result === "object" && "url" in response.result) {
|
|
218
210
|
grantUrl = response.result.url;
|
|
219
211
|
} else {
|
|
220
212
|
throw new Error("Invalid response from relayer for grant storage");
|
|
@@ -250,7 +242,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
250
242
|
nonce
|
|
251
243
|
});
|
|
252
244
|
const signature = await this.signTypedData(typedData);
|
|
253
|
-
return await this.submitSignedGrant(typedData, signature
|
|
245
|
+
return await this.submitSignedGrant(typedData, signature);
|
|
254
246
|
} catch (error) {
|
|
255
247
|
if (error instanceof Error) {
|
|
256
248
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
|
|
@@ -322,7 +314,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
322
314
|
if (response.type === "error") {
|
|
323
315
|
throw new Error(response.error);
|
|
324
316
|
}
|
|
325
|
-
if (response.type === "direct" && typeof response.result === "object" &&
|
|
317
|
+
if (response.type === "direct" && typeof response.result === "object" && "url" in response.result) {
|
|
326
318
|
grantUrl = response.result.url;
|
|
327
319
|
} else {
|
|
328
320
|
throw new Error("Invalid response from relayer for grant storage");
|
|
@@ -395,7 +387,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
395
387
|
* );
|
|
396
388
|
* ```
|
|
397
389
|
*/
|
|
398
|
-
async submitSignedGrant(typedData, signature
|
|
390
|
+
async submitSignedGrant(typedData, signature) {
|
|
399
391
|
try {
|
|
400
392
|
console.debug(
|
|
401
393
|
"\u{1F50D} Debug - submitSignedGrant called with typed data:",
|
|
@@ -413,40 +405,26 @@ class PermissionsController extends import_base.BaseController {
|
|
|
413
405
|
signature,
|
|
414
406
|
expectedUserAddress: this.context.userAddress
|
|
415
407
|
});
|
|
416
|
-
|
|
408
|
+
let hash;
|
|
409
|
+
if (response.type === "signed") {
|
|
410
|
+
hash = response.hash;
|
|
411
|
+
} else if (response.type === "error") {
|
|
417
412
|
throw new Error(`Relayer error: ${response.error}`);
|
|
418
|
-
}
|
|
419
|
-
let finalHash;
|
|
420
|
-
if (response.type === "submitted") {
|
|
421
|
-
finalHash = response.hash;
|
|
422
|
-
} else if (response.type === "pending") {
|
|
423
|
-
const pollResult = await this.pollRelayerForConfirmation(
|
|
424
|
-
response.operationId
|
|
425
|
-
);
|
|
426
|
-
finalHash = pollResult.hash;
|
|
427
|
-
} else if (response.type === "confirmed") {
|
|
428
|
-
finalHash = response.hash;
|
|
429
|
-
} else if (response.type === "signed") {
|
|
430
|
-
finalHash = response.hash;
|
|
431
413
|
} else {
|
|
432
414
|
throw new Error(
|
|
433
|
-
"Invalid response from relayer:
|
|
415
|
+
"Invalid response from relayer: expected signed transaction"
|
|
434
416
|
);
|
|
435
417
|
}
|
|
436
418
|
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
437
419
|
const { tx } = await import("../utils/transactionHelpers");
|
|
438
420
|
return tx({
|
|
439
|
-
hash
|
|
421
|
+
hash,
|
|
440
422
|
from: typeof account === "string" ? account : account.address,
|
|
441
423
|
contract: "DataPortabilityPermissions",
|
|
442
424
|
fn: "addPermission"
|
|
443
425
|
});
|
|
444
426
|
} else {
|
|
445
|
-
return await this.submitDirectTransaction(
|
|
446
|
-
typedData,
|
|
447
|
-
signature,
|
|
448
|
-
options
|
|
449
|
-
);
|
|
427
|
+
return await this.submitDirectTransaction(typedData, signature);
|
|
450
428
|
}
|
|
451
429
|
} catch (error) {
|
|
452
430
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
|
|
@@ -479,7 +457,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
479
457
|
* const result = await txHandle.waitForEvents();
|
|
480
458
|
* ```
|
|
481
459
|
*/
|
|
482
|
-
async submitSignedTrustServer(typedData, signature
|
|
460
|
+
async submitSignedTrustServer(typedData, signature) {
|
|
483
461
|
try {
|
|
484
462
|
const trustServerInput = {
|
|
485
463
|
nonce: BigInt(typedData.message.nonce),
|
|
@@ -487,8 +465,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
487
465
|
};
|
|
488
466
|
const hash = await this.submitTrustServerTransaction(
|
|
489
467
|
trustServerInput,
|
|
490
|
-
signature
|
|
491
|
-
options
|
|
468
|
+
signature
|
|
492
469
|
);
|
|
493
470
|
const account = this.context.userAddress;
|
|
494
471
|
const { tx } = await import("../utils/transactionHelpers");
|
|
@@ -543,7 +520,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
543
520
|
* const result = await txHandle.waitForEvents();
|
|
544
521
|
* ```
|
|
545
522
|
*/
|
|
546
|
-
async submitSignedAddAndTrustServer(typedData, signature
|
|
523
|
+
async submitSignedAddAndTrustServer(typedData, signature) {
|
|
547
524
|
try {
|
|
548
525
|
const addAndTrustServerInput = {
|
|
549
526
|
nonce: BigInt(typedData.message.nonce),
|
|
@@ -581,12 +558,8 @@ class PermissionsController extends import_base.BaseController {
|
|
|
581
558
|
* @param signature - The user's signature authorizing the transaction
|
|
582
559
|
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
583
560
|
*/
|
|
584
|
-
async submitSignedGrantWithEvents(typedData, signature
|
|
585
|
-
const txResult = await this.submitSignedGrant(
|
|
586
|
-
typedData,
|
|
587
|
-
signature,
|
|
588
|
-
options
|
|
589
|
-
);
|
|
561
|
+
async submitSignedGrantWithEvents(typedData, signature) {
|
|
562
|
+
const txResult = await this.submitSignedGrant(typedData, signature);
|
|
590
563
|
if (!this.context.waitForTransactionEvents) {
|
|
591
564
|
throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
|
|
592
565
|
}
|
|
@@ -618,12 +591,8 @@ class PermissionsController extends import_base.BaseController {
|
|
|
618
591
|
* @param grantFile - The pre-created grant file object
|
|
619
592
|
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
620
593
|
*/
|
|
621
|
-
async confirmGrantInternalWithEvents(params, grantFile
|
|
622
|
-
const txResult = await this.confirmGrantInternal(
|
|
623
|
-
params,
|
|
624
|
-
grantFile,
|
|
625
|
-
options
|
|
626
|
-
);
|
|
594
|
+
async confirmGrantInternalWithEvents(params, grantFile) {
|
|
595
|
+
const txResult = await this.confirmGrantInternal(params, grantFile);
|
|
627
596
|
if (!this.context.waitForTransactionEvents) {
|
|
628
597
|
throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
|
|
629
598
|
}
|
|
@@ -647,39 +616,6 @@ class PermissionsController extends import_base.BaseController {
|
|
|
647
616
|
fileIds: event.fileIds
|
|
648
617
|
};
|
|
649
618
|
}
|
|
650
|
-
/**
|
|
651
|
-
* Polls the relayer for confirmation of a pending operation.
|
|
652
|
-
*
|
|
653
|
-
* @param operationId - The operation ID to poll
|
|
654
|
-
* @returns Promise resolving to the confirmed hash
|
|
655
|
-
* @throws {Error} When the operation fails or times out
|
|
656
|
-
* @internal
|
|
657
|
-
*/
|
|
658
|
-
async pollRelayerForConfirmation(operationId, options = {}) {
|
|
659
|
-
const timeout = options.timeout ?? 3e4;
|
|
660
|
-
let interval = options.pollingInterval ?? 1e3;
|
|
661
|
-
const startTime = Date.now();
|
|
662
|
-
while (Date.now() - startTime < timeout) {
|
|
663
|
-
if (!this.context.relayer) {
|
|
664
|
-
throw new Error("Relayer not configured for polling");
|
|
665
|
-
}
|
|
666
|
-
const statusResponse = await this.context.relayer({
|
|
667
|
-
type: "status_check",
|
|
668
|
-
operationId
|
|
669
|
-
});
|
|
670
|
-
if (statusResponse.type === "confirmed") {
|
|
671
|
-
return { hash: statusResponse.hash };
|
|
672
|
-
}
|
|
673
|
-
if (statusResponse.type === "error") {
|
|
674
|
-
throw new Error(
|
|
675
|
-
`Operation ${operationId} failed: ${statusResponse.error}`
|
|
676
|
-
);
|
|
677
|
-
}
|
|
678
|
-
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
679
|
-
interval = Math.min(interval * 1.5, 5e3);
|
|
680
|
-
}
|
|
681
|
-
throw new Error(`Operation ${operationId} timed out after ${timeout}ms`);
|
|
682
|
-
}
|
|
683
619
|
/**
|
|
684
620
|
* Submits an already-signed permission revoke transaction to the blockchain.
|
|
685
621
|
*
|
|
@@ -701,7 +637,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
701
637
|
* const result = await txHandle.waitForEvents();
|
|
702
638
|
* ```
|
|
703
639
|
*/
|
|
704
|
-
async submitSignedRevoke(typedData, signature
|
|
640
|
+
async submitSignedRevoke(typedData, signature) {
|
|
705
641
|
try {
|
|
706
642
|
let hash;
|
|
707
643
|
if (this.context.relayer) {
|
|
@@ -712,23 +648,13 @@ class PermissionsController extends import_base.BaseController {
|
|
|
712
648
|
signature,
|
|
713
649
|
expectedUserAddress: this.context.userAddress
|
|
714
650
|
});
|
|
715
|
-
if (response.type === "
|
|
716
|
-
throw new Error(`Relayer error: ${response.error}`);
|
|
717
|
-
}
|
|
718
|
-
if (response.type === "submitted") {
|
|
719
|
-
hash = response.hash;
|
|
720
|
-
} else if (response.type === "pending") {
|
|
721
|
-
const pollResult = await this.pollRelayerForConfirmation(
|
|
722
|
-
response.operationId
|
|
723
|
-
);
|
|
724
|
-
hash = pollResult.hash;
|
|
725
|
-
} else if (response.type === "confirmed") {
|
|
726
|
-
hash = response.hash;
|
|
727
|
-
} else if (response.type === "signed") {
|
|
651
|
+
if (response.type === "signed") {
|
|
728
652
|
hash = response.hash;
|
|
653
|
+
} else if (response.type === "error") {
|
|
654
|
+
throw new Error(`Relayer error: ${response.error}`);
|
|
729
655
|
} else {
|
|
730
656
|
throw new Error(
|
|
731
|
-
"Invalid response from relayer:
|
|
657
|
+
"Invalid response from relayer: expected signed transaction"
|
|
732
658
|
);
|
|
733
659
|
}
|
|
734
660
|
} else {
|
|
@@ -776,7 +702,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
776
702
|
* const result = await txHandle.waitForEvents();
|
|
777
703
|
* ```
|
|
778
704
|
*/
|
|
779
|
-
async submitSignedUntrustServer(typedData, signature
|
|
705
|
+
async submitSignedUntrustServer(typedData, signature) {
|
|
780
706
|
try {
|
|
781
707
|
let hash;
|
|
782
708
|
if (this.context.relayer) {
|
|
@@ -832,7 +758,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
832
758
|
* @returns Promise resolving to the transaction hash
|
|
833
759
|
* @throws {BlockchainError} When contract submission fails
|
|
834
760
|
*/
|
|
835
|
-
async submitDirectTransaction(typedData, signature
|
|
761
|
+
async submitDirectTransaction(typedData, signature) {
|
|
836
762
|
this.assertWallet();
|
|
837
763
|
const chainId = await this.context.publicClient.getChainId();
|
|
838
764
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -864,8 +790,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
864
790
|
functionName: "addPermission",
|
|
865
791
|
args: [permissionInput, formattedSignature],
|
|
866
792
|
account,
|
|
867
|
-
chain: this.context.walletClient?.chain ?? null
|
|
868
|
-
...this.spreadTransactionOptions(options)
|
|
793
|
+
chain: this.context.walletClient?.chain ?? null
|
|
869
794
|
});
|
|
870
795
|
const { tx } = await import("../utils/transactionHelpers");
|
|
871
796
|
return tx({
|
|
@@ -964,7 +889,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
964
889
|
args: [params.permissionId],
|
|
965
890
|
account,
|
|
966
891
|
chain: this.context.walletClient?.chain ?? null,
|
|
967
|
-
...options?.
|
|
892
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
968
893
|
...options?.nonce && { nonce: options.nonce },
|
|
969
894
|
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
970
895
|
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
@@ -1801,7 +1726,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
1801
1726
|
args: [BigInt(params.serverId)],
|
|
1802
1727
|
account,
|
|
1803
1728
|
chain: this.context.walletClient?.chain ?? null,
|
|
1804
|
-
...options?.
|
|
1729
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
1805
1730
|
...options?.nonce && { nonce: options.nonce },
|
|
1806
1731
|
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
1807
1732
|
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
@@ -2396,7 +2321,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
2396
2321
|
* @param signature - The cryptographic signature for the transaction
|
|
2397
2322
|
* @returns Promise resolving to the transaction hash
|
|
2398
2323
|
*/
|
|
2399
|
-
async submitTrustServerTransaction(trustServerInput, signature
|
|
2324
|
+
async submitTrustServerTransaction(trustServerInput, signature) {
|
|
2400
2325
|
this.assertWallet();
|
|
2401
2326
|
const chainId = await this.context.walletClient.getChainId();
|
|
2402
2327
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -2417,8 +2342,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
2417
2342
|
formattedSignature
|
|
2418
2343
|
],
|
|
2419
2344
|
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2420
|
-
chain: this.context.walletClient?.chain ?? null
|
|
2421
|
-
...this.spreadTransactionOptions(options)
|
|
2345
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2422
2346
|
});
|
|
2423
2347
|
return txHash;
|
|
2424
2348
|
}
|
|
@@ -2455,7 +2379,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
2455
2379
|
* @param signature - The cryptographic signature authorizing the untrust
|
|
2456
2380
|
* @returns Promise resolving to the transaction hash
|
|
2457
2381
|
*/
|
|
2458
|
-
async submitSignedUntrustTransaction(typedData, signature
|
|
2382
|
+
async submitSignedUntrustTransaction(typedData, signature) {
|
|
2459
2383
|
this.assertWallet();
|
|
2460
2384
|
const chainId = await this.context.walletClient.getChainId();
|
|
2461
2385
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -2525,7 +2449,15 @@ class PermissionsController extends import_base.BaseController {
|
|
|
2525
2449
|
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
2526
2450
|
account,
|
|
2527
2451
|
chain: this.context.walletClient?.chain ?? null,
|
|
2528
|
-
...
|
|
2452
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
2453
|
+
...options?.nonce && { nonce: options.nonce },
|
|
2454
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
2455
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
2456
|
+
...options.maxFeePerGas && { maxFeePerGas: options.maxFeePerGas },
|
|
2457
|
+
...options.maxPriorityFeePerGas && {
|
|
2458
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
2459
|
+
}
|
|
2460
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
2529
2461
|
});
|
|
2530
2462
|
const { tx } = await import("../utils/transactionHelpers");
|
|
2531
2463
|
return tx({
|
|
@@ -3463,7 +3395,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
3463
3395
|
args: [serverId, url],
|
|
3464
3396
|
chain: this.context.walletClient?.chain,
|
|
3465
3397
|
account,
|
|
3466
|
-
...options?.
|
|
3398
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
3467
3399
|
...options?.nonce && { nonce: options.nonce },
|
|
3468
3400
|
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
3469
3401
|
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
@@ -3669,7 +3601,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
3669
3601
|
* @throws {BlockchainError} When permission addition fails
|
|
3670
3602
|
* @throws {NetworkError} When network communication fails
|
|
3671
3603
|
*/
|
|
3672
|
-
async submitSignedAddPermission(typedData, signature
|
|
3604
|
+
async submitSignedAddPermission(typedData, signature) {
|
|
3673
3605
|
this.assertWallet();
|
|
3674
3606
|
try {
|
|
3675
3607
|
let hash;
|
|
@@ -3692,8 +3624,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
3692
3624
|
} else {
|
|
3693
3625
|
hash = await this.submitDirectAddPermissionTransaction(
|
|
3694
3626
|
typedData,
|
|
3695
|
-
signature
|
|
3696
|
-
options
|
|
3627
|
+
signature
|
|
3697
3628
|
);
|
|
3698
3629
|
}
|
|
3699
3630
|
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
@@ -3924,7 +3855,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
3924
3855
|
args: [permissionId],
|
|
3925
3856
|
chain: this.context.walletClient?.chain,
|
|
3926
3857
|
account,
|
|
3927
|
-
...options?.
|
|
3858
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
3928
3859
|
...options?.nonce && { nonce: options.nonce },
|
|
3929
3860
|
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
3930
3861
|
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
@@ -3957,7 +3888,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
3957
3888
|
* @param signature - The cryptographic signature authorizing the transaction
|
|
3958
3889
|
* @returns Promise resolving to the transaction hash
|
|
3959
3890
|
*/
|
|
3960
|
-
async submitDirectAddPermissionTransaction(typedData, signature
|
|
3891
|
+
async submitDirectAddPermissionTransaction(typedData, signature) {
|
|
3961
3892
|
this.assertWallet();
|
|
3962
3893
|
const chainId = await this.context.walletClient.getChainId();
|
|
3963
3894
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -3978,8 +3909,7 @@ class PermissionsController extends import_base.BaseController {
|
|
|
3978
3909
|
functionName: "addPermission",
|
|
3979
3910
|
args: [permissionInput, formattedSignature],
|
|
3980
3911
|
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
3981
|
-
chain: this.context.walletClient?.chain ?? null
|
|
3982
|
-
...this.spreadTransactionOptions(options)
|
|
3912
|
+
chain: this.context.walletClient?.chain ?? null
|
|
3983
3913
|
});
|
|
3984
3914
|
return hash;
|
|
3985
3915
|
}
|
|
@@ -4014,11 +3944,22 @@ class PermissionsController extends import_base.BaseController {
|
|
|
4014
3944
|
address: DataPortabilityPermissionsAddress,
|
|
4015
3945
|
abi: DataPortabilityPermissionsAbi,
|
|
4016
3946
|
functionName: "addServerFilesAndPermissions",
|
|
3947
|
+
// @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
|
|
4017
3948
|
args: [serverFilesAndPermissionInput, formattedSignature],
|
|
4018
3949
|
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
4019
3950
|
chain: this.context.walletClient?.chain ?? null,
|
|
3951
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
3952
|
+
...options?.nonce && { nonce: options.nonce },
|
|
4020
3953
|
...options?.value && { value: options.value },
|
|
4021
|
-
|
|
3954
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
3955
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
3956
|
+
...options.maxFeePerGas && {
|
|
3957
|
+
maxFeePerGas: options.maxFeePerGas
|
|
3958
|
+
},
|
|
3959
|
+
...options.maxPriorityFeePerGas && {
|
|
3960
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
3961
|
+
}
|
|
3962
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
4022
3963
|
});
|
|
4023
3964
|
return hash;
|
|
4024
3965
|
}
|