@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.
Files changed (171) hide show
  1. package/dist/browser.cjs.map +1 -1
  2. package/dist/browser.d.ts +33 -1
  3. package/dist/browser.js.map +1 -1
  4. package/dist/chains/index.cjs.map +1 -1
  5. package/dist/chains/index.d.ts +30 -1
  6. package/dist/chains/index.js.map +1 -1
  7. package/dist/config/chains.cjs.map +1 -1
  8. package/dist/config/chains.d.ts +99 -0
  9. package/dist/config/chains.js.map +1 -1
  10. package/dist/contracts/contractController.cjs.map +1 -1
  11. package/dist/contracts/contractController.d.ts +66 -10
  12. package/dist/contracts/contractController.js.map +1 -1
  13. package/dist/controllers/base.cjs +33 -0
  14. package/dist/controllers/base.cjs.map +1 -1
  15. package/dist/controllers/base.d.ts +10 -0
  16. package/dist/controllers/base.js +33 -0
  17. package/dist/controllers/base.js.map +1 -1
  18. package/dist/controllers/data.cjs +162 -133
  19. package/dist/controllers/data.cjs.map +1 -1
  20. package/dist/controllers/data.d.ts +222 -184
  21. package/dist/controllers/data.js +162 -133
  22. package/dist/controllers/data.js.map +1 -1
  23. package/dist/controllers/permissions.cjs +208 -60
  24. package/dist/controllers/permissions.cjs.map +1 -1
  25. package/dist/controllers/permissions.d.ts +75 -45
  26. package/dist/controllers/permissions.js +208 -60
  27. package/dist/controllers/permissions.js.map +1 -1
  28. package/dist/controllers/protocol.cjs.map +1 -1
  29. package/dist/controllers/protocol.d.ts +27 -28
  30. package/dist/controllers/protocol.js.map +1 -1
  31. package/dist/controllers/schemas.cjs +23 -21
  32. package/dist/controllers/schemas.cjs.map +1 -1
  33. package/dist/controllers/schemas.d.ts +47 -40
  34. package/dist/controllers/schemas.js +23 -21
  35. package/dist/controllers/schemas.js.map +1 -1
  36. package/dist/controllers/server.cjs +17 -15
  37. package/dist/controllers/server.cjs.map +1 -1
  38. package/dist/controllers/server.d.ts +46 -38
  39. package/dist/controllers/server.js +17 -15
  40. package/dist/controllers/server.js.map +1 -1
  41. package/dist/core/apiClient.cjs +53 -3
  42. package/dist/core/apiClient.cjs.map +1 -1
  43. package/dist/core/apiClient.d.ts +132 -7
  44. package/dist/core/apiClient.js +53 -3
  45. package/dist/core/apiClient.js.map +1 -1
  46. package/dist/core/generics.cjs +30 -3
  47. package/dist/core/generics.cjs.map +1 -1
  48. package/dist/core/generics.d.ts +95 -6
  49. package/dist/core/generics.js +30 -3
  50. package/dist/core/generics.js.map +1 -1
  51. package/dist/core.cjs +4 -1
  52. package/dist/core.cjs.map +1 -1
  53. package/dist/core.d.ts +2 -1
  54. package/dist/core.js +4 -1
  55. package/dist/core.js.map +1 -1
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/index.node.cjs +2 -3
  59. package/dist/index.node.cjs.map +1 -1
  60. package/dist/index.node.d.ts +33 -13
  61. package/dist/index.node.js +2 -2
  62. package/dist/index.node.js.map +1 -1
  63. package/dist/node.cjs.map +1 -1
  64. package/dist/node.d.ts +39 -1
  65. package/dist/node.js.map +1 -1
  66. package/dist/platform/browser.cjs +160 -2
  67. package/dist/platform/browser.cjs.map +1 -1
  68. package/dist/platform/browser.d.ts +232 -12
  69. package/dist/platform/browser.js +160 -2
  70. package/dist/platform/browser.js.map +1 -1
  71. package/dist/platform/interface.cjs.map +1 -1
  72. package/dist/platform/interface.d.ts +283 -90
  73. package/dist/platform/node.cjs +163 -2
  74. package/dist/platform/node.cjs.map +1 -1
  75. package/dist/platform/node.d.ts +69 -6
  76. package/dist/platform/node.js +163 -2
  77. package/dist/platform/node.js.map +1 -1
  78. package/dist/server/relayerHandler.cjs +136 -98
  79. package/dist/server/relayerHandler.cjs.map +1 -1
  80. package/dist/server/relayerHandler.d.ts +3 -2
  81. package/dist/server/relayerHandler.js +135 -96
  82. package/dist/server/relayerHandler.js.map +1 -1
  83. package/dist/storage/manager.cjs +108 -25
  84. package/dist/storage/manager.cjs.map +1 -1
  85. package/dist/storage/manager.d.ts +119 -25
  86. package/dist/storage/manager.js +108 -25
  87. package/dist/storage/manager.js.map +1 -1
  88. package/dist/storage/providers/callback-storage.cjs +86 -15
  89. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  90. package/dist/storage/providers/callback-storage.d.ts +109 -20
  91. package/dist/storage/providers/callback-storage.js +86 -15
  92. package/dist/storage/providers/callback-storage.js.map +1 -1
  93. package/dist/storage/providers/pinata.cjs.map +1 -1
  94. package/dist/storage/providers/pinata.d.ts +12 -14
  95. package/dist/storage/providers/pinata.js.map +1 -1
  96. package/dist/types/blockchain.cjs.map +1 -1
  97. package/dist/types/blockchain.d.ts +39 -11
  98. package/dist/types/chains.cjs.map +1 -1
  99. package/dist/types/chains.d.ts +74 -7
  100. package/dist/types/chains.js.map +1 -1
  101. package/dist/types/config.cjs.map +1 -1
  102. package/dist/types/config.d.ts +38 -4
  103. package/dist/types/config.js.map +1 -1
  104. package/dist/types/contracts.cjs.map +1 -1
  105. package/dist/types/contracts.d.ts +71 -7
  106. package/dist/types/controller-context.cjs.map +1 -1
  107. package/dist/types/controller-context.d.ts +3 -1
  108. package/dist/types/data.cjs.map +1 -1
  109. package/dist/types/data.d.ts +4 -6
  110. package/dist/types/generics.cjs.map +1 -1
  111. package/dist/types/generics.d.ts +81 -10
  112. package/dist/types/index.cjs.map +1 -1
  113. package/dist/types/index.d.ts +28 -2
  114. package/dist/types/index.js.map +1 -1
  115. package/dist/types/operations.cjs.map +1 -1
  116. package/dist/types/operations.d.ts +178 -15
  117. package/dist/types/operations.js.map +1 -1
  118. package/dist/types/permissions.cjs.map +1 -1
  119. package/dist/types/permissions.d.ts +15 -20
  120. package/dist/types/personal.cjs.map +1 -1
  121. package/dist/types/personal.d.ts +131 -14
  122. package/dist/types/relayer.cjs.map +1 -1
  123. package/dist/types/relayer.d.ts +114 -18
  124. package/dist/types/storage.cjs.map +1 -1
  125. package/dist/types/storage.d.ts +9 -21
  126. package/dist/types/storage.js.map +1 -1
  127. package/dist/types/utils.cjs.map +1 -1
  128. package/dist/types/utils.d.ts +5 -1
  129. package/dist/utils/grantFiles.cjs.map +1 -1
  130. package/dist/utils/grantFiles.d.ts +10 -20
  131. package/dist/utils/grantFiles.js.map +1 -1
  132. package/dist/utils/grantValidation.cjs.map +1 -1
  133. package/dist/utils/grantValidation.d.ts +95 -16
  134. package/dist/utils/grantValidation.js.map +1 -1
  135. package/dist/utils/grants.cjs.map +1 -1
  136. package/dist/utils/grants.d.ts +93 -12
  137. package/dist/utils/grants.js.map +1 -1
  138. package/dist/utils/ipfs.cjs +2 -4
  139. package/dist/utils/ipfs.cjs.map +1 -1
  140. package/dist/utils/ipfs.d.ts +1 -1
  141. package/dist/utils/ipfs.js +2 -4
  142. package/dist/utils/ipfs.js.map +1 -1
  143. package/dist/utils/lazy-import.cjs.map +1 -1
  144. package/dist/utils/lazy-import.d.ts +32 -7
  145. package/dist/utils/lazy-import.js.map +1 -1
  146. package/dist/utils/signatureCache.cjs +8 -2
  147. package/dist/utils/signatureCache.cjs.map +1 -1
  148. package/dist/utils/signatureCache.d.ts +49 -8
  149. package/dist/utils/signatureCache.js +8 -2
  150. package/dist/utils/signatureCache.js.map +1 -1
  151. package/dist/utils/transactionHelpers.cjs.map +1 -1
  152. package/dist/utils/transactionHelpers.d.ts +12 -12
  153. package/dist/utils/transactionHelpers.js.map +1 -1
  154. package/dist/utils/typedDataConverter.cjs.map +1 -1
  155. package/dist/utils/typedDataConverter.d.ts +39 -3
  156. package/dist/utils/typedDataConverter.js.map +1 -1
  157. package/dist/utils/urlResolver.cjs +7 -0
  158. package/dist/utils/urlResolver.cjs.map +1 -1
  159. package/dist/utils/urlResolver.d.ts +22 -4
  160. package/dist/utils/urlResolver.js +7 -0
  161. package/dist/utils/urlResolver.js.map +1 -1
  162. package/dist/utils/wallet.cjs.map +1 -1
  163. package/dist/utils/wallet.d.ts +78 -16
  164. package/dist/utils/wallet.js.map +1 -1
  165. package/package.json +3 -1
  166. package/dist/server/handler.cjs +0 -103
  167. package/dist/server/handler.cjs.map +0 -1
  168. package/dist/server/handler.d.ts +0 -95
  169. package/dist/server/handler.js +0 -79
  170. package/dist/server/handler.js.map +0 -1
  171. /package/dist/tests/{server-handler.test.d.ts → permissions-transaction-options.test.d.ts} +0 -0
@@ -80,10 +80,14 @@ 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, options) {
84
84
  this.assertWallet();
85
85
  const { typedData, signature } = await this.createAndSign(params);
86
- const result = await this.submitSignedGrantWithEvents(typedData, signature);
86
+ const result = await this.submitSignedGrantWithEvents(
87
+ typedData,
88
+ signature,
89
+ options
90
+ );
87
91
  return result;
88
92
  }
89
93
  /**
@@ -111,10 +115,10 @@ class PermissionsController extends import_base.BaseController {
111
115
  * console.log(`Permission ID: ${eventData.permissionId}`);
112
116
  * ```
113
117
  */
114
- async submitPermissionGrant(params) {
118
+ async submitPermissionGrant(params, options) {
115
119
  this.assertWallet();
116
120
  const { typedData, signature } = await this.createAndSign(params);
117
- return await this.submitSignedGrant(typedData, signature);
121
+ return await this.submitSignedGrant(typedData, signature, options);
118
122
  }
119
123
  /**
120
124
  * Prepares a permission grant with preview before signing.
@@ -141,7 +145,7 @@ class PermissionsController extends import_base.BaseController {
141
145
  * const transactionHash = await confirm();
142
146
  * ```
143
147
  */
144
- async prepareGrant(params) {
148
+ async prepareGrant(params, options) {
145
149
  this.assertWallet();
146
150
  try {
147
151
  const grantFile = (0, import_grantFiles.createGrantFile)(params);
@@ -149,7 +153,11 @@ class PermissionsController extends import_base.BaseController {
149
153
  return {
150
154
  preview: grantFile,
151
155
  confirm: async () => {
152
- return await this.confirmGrantInternalWithEvents(params, grantFile);
156
+ return await this.confirmGrantInternalWithEvents(
157
+ params,
158
+ grantFile,
159
+ options
160
+ );
153
161
  }
154
162
  };
155
163
  } catch (error) {
@@ -181,7 +189,7 @@ class PermissionsController extends import_base.BaseController {
181
189
  * @throws {NetworkError} When IPFS upload fails
182
190
  * @throws {SignatureError} When user rejects the signature
183
191
  */
184
- async confirmGrantInternal(params, grantFile) {
192
+ async confirmGrantInternal(params, grantFile, options) {
185
193
  try {
186
194
  let { grantUrl } = params;
187
195
  console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
@@ -242,7 +250,7 @@ class PermissionsController extends import_base.BaseController {
242
250
  nonce
243
251
  });
244
252
  const signature = await this.signTypedData(typedData);
245
- return await this.submitSignedGrant(typedData, signature);
253
+ return await this.submitSignedGrant(typedData, signature, options);
246
254
  } catch (error) {
247
255
  if (error instanceof Error) {
248
256
  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) {
@@ -387,7 +395,7 @@ class PermissionsController extends import_base.BaseController {
387
395
  * );
388
396
  * ```
389
397
  */
390
- async submitSignedGrant(typedData, signature) {
398
+ async submitSignedGrant(typedData, signature, options) {
391
399
  try {
392
400
  console.debug(
393
401
  "\u{1F50D} Debug - submitSignedGrant called with typed data:",
@@ -405,26 +413,40 @@ class PermissionsController extends import_base.BaseController {
405
413
  signature,
406
414
  expectedUserAddress: this.context.userAddress
407
415
  });
408
- let hash;
409
- if (response.type === "signed") {
410
- hash = response.hash;
411
- } else if (response.type === "error") {
416
+ if (response.type === "error") {
412
417
  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;
413
431
  } else {
414
432
  throw new Error(
415
- "Invalid response from relayer: expected signed transaction"
433
+ "Invalid response from relayer: unexpected response type"
416
434
  );
417
435
  }
418
436
  const account = this.context.walletClient?.account ?? this.context.userAddress;
419
437
  const { tx } = await import("../utils/transactionHelpers");
420
438
  return tx({
421
- hash,
439
+ hash: finalHash,
422
440
  from: typeof account === "string" ? account : account.address,
423
441
  contract: "DataPortabilityPermissions",
424
442
  fn: "addPermission"
425
443
  });
426
444
  } else {
427
- return await this.submitDirectTransaction(typedData, signature);
445
+ return await this.submitDirectTransaction(
446
+ typedData,
447
+ signature,
448
+ options
449
+ );
428
450
  }
429
451
  } catch (error) {
430
452
  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) {
@@ -457,7 +479,7 @@ class PermissionsController extends import_base.BaseController {
457
479
  * const result = await txHandle.waitForEvents();
458
480
  * ```
459
481
  */
460
- async submitSignedTrustServer(typedData, signature) {
482
+ async submitSignedTrustServer(typedData, signature, options) {
461
483
  try {
462
484
  const trustServerInput = {
463
485
  nonce: BigInt(typedData.message.nonce),
@@ -465,7 +487,8 @@ class PermissionsController extends import_base.BaseController {
465
487
  };
466
488
  const hash = await this.submitTrustServerTransaction(
467
489
  trustServerInput,
468
- signature
490
+ signature,
491
+ options
469
492
  );
470
493
  const account = this.context.userAddress;
471
494
  const { tx } = await import("../utils/transactionHelpers");
@@ -520,7 +543,7 @@ class PermissionsController extends import_base.BaseController {
520
543
  * const result = await txHandle.waitForEvents();
521
544
  * ```
522
545
  */
523
- async submitSignedAddAndTrustServer(typedData, signature) {
546
+ async submitSignedAddAndTrustServer(typedData, signature, _options) {
524
547
  try {
525
548
  const addAndTrustServerInput = {
526
549
  nonce: BigInt(typedData.message.nonce),
@@ -558,8 +581,12 @@ class PermissionsController extends import_base.BaseController {
558
581
  * @param signature - The user's signature authorizing the transaction
559
582
  * @returns Promise resolving to PermissionGrantResult with parsed events
560
583
  */
561
- async submitSignedGrantWithEvents(typedData, signature) {
562
- const txResult = await this.submitSignedGrant(typedData, signature);
584
+ async submitSignedGrantWithEvents(typedData, signature, options) {
585
+ const txResult = await this.submitSignedGrant(
586
+ typedData,
587
+ signature,
588
+ options
589
+ );
563
590
  if (!this.context.waitForTransactionEvents) {
564
591
  throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
565
592
  }
@@ -591,8 +618,12 @@ class PermissionsController extends import_base.BaseController {
591
618
  * @param grantFile - The pre-created grant file object
592
619
  * @returns Promise resolving to PermissionGrantResult with parsed events
593
620
  */
594
- async confirmGrantInternalWithEvents(params, grantFile) {
595
- const txResult = await this.confirmGrantInternal(params, grantFile);
621
+ async confirmGrantInternalWithEvents(params, grantFile, options) {
622
+ const txResult = await this.confirmGrantInternal(
623
+ params,
624
+ grantFile,
625
+ options
626
+ );
596
627
  if (!this.context.waitForTransactionEvents) {
597
628
  throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
598
629
  }
@@ -616,6 +647,39 @@ class PermissionsController extends import_base.BaseController {
616
647
  fileIds: event.fileIds
617
648
  };
618
649
  }
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
+ }
619
683
  /**
620
684
  * Submits an already-signed permission revoke transaction to the blockchain.
621
685
  *
@@ -637,7 +701,7 @@ class PermissionsController extends import_base.BaseController {
637
701
  * const result = await txHandle.waitForEvents();
638
702
  * ```
639
703
  */
640
- async submitSignedRevoke(typedData, signature) {
704
+ async submitSignedRevoke(typedData, signature, _options) {
641
705
  try {
642
706
  let hash;
643
707
  if (this.context.relayer) {
@@ -648,13 +712,23 @@ class PermissionsController extends import_base.BaseController {
648
712
  signature,
649
713
  expectedUserAddress: this.context.userAddress
650
714
  });
651
- if (response.type === "signed") {
652
- hash = response.hash;
653
- } else if (response.type === "error") {
715
+ if (response.type === "error") {
654
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") {
728
+ hash = response.hash;
655
729
  } else {
656
730
  throw new Error(
657
- "Invalid response from relayer: expected signed transaction"
731
+ "Invalid response from relayer: unexpected response type"
658
732
  );
659
733
  }
660
734
  } else {
@@ -702,7 +776,7 @@ class PermissionsController extends import_base.BaseController {
702
776
  * const result = await txHandle.waitForEvents();
703
777
  * ```
704
778
  */
705
- async submitSignedUntrustServer(typedData, signature) {
779
+ async submitSignedUntrustServer(typedData, signature, _options) {
706
780
  try {
707
781
  let hash;
708
782
  if (this.context.relayer) {
@@ -758,7 +832,7 @@ class PermissionsController extends import_base.BaseController {
758
832
  * @returns Promise resolving to the transaction hash
759
833
  * @throws {BlockchainError} When contract submission fails
760
834
  */
761
- async submitDirectTransaction(typedData, signature) {
835
+ async submitDirectTransaction(typedData, signature, options) {
762
836
  this.assertWallet();
763
837
  const chainId = await this.context.publicClient.getChainId();
764
838
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
@@ -790,7 +864,8 @@ class PermissionsController extends import_base.BaseController {
790
864
  functionName: "addPermission",
791
865
  args: [permissionInput, formattedSignature],
792
866
  account,
793
- chain: this.context.walletClient?.chain ?? null
867
+ chain: this.context.walletClient?.chain ?? null,
868
+ ...this.spreadTransactionOptions(options)
794
869
  });
795
870
  const { tx } = await import("../utils/transactionHelpers");
796
871
  return tx({
@@ -854,6 +929,7 @@ class PermissionsController extends import_base.BaseController {
854
929
  * Use this when you want to handle transaction confirmation and event parsing separately.
855
930
  *
856
931
  * @param params - Parameters for revoking the permission
932
+ * @param options - Optional transaction options for gas parameters and timeout
857
933
  * @returns Promise resolving to the transaction hash when successfully submitted
858
934
  * @throws {BlockchainError} When revocation transaction fails
859
935
  * @throws {UserRejectedRequestError} When user rejects the transaction
@@ -866,7 +942,7 @@ class PermissionsController extends import_base.BaseController {
866
942
  * console.log(`Revocation submitted: ${txHash}`);
867
943
  * ```
868
944
  */
869
- async submitPermissionRevoke(params) {
945
+ async submitPermissionRevoke(params, options) {
870
946
  this.assertWallet();
871
947
  try {
872
948
  if (!this.context.walletClient?.chain?.id) {
@@ -887,7 +963,18 @@ class PermissionsController extends import_base.BaseController {
887
963
  functionName: "revokePermission",
888
964
  args: [params.permissionId],
889
965
  account,
890
- chain: this.context.walletClient?.chain ?? null
966
+ chain: this.context.walletClient?.chain ?? null,
967
+ ...options?.gas && { gas: options.gas },
968
+ ...options?.nonce && { nonce: options.nonce },
969
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
970
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
971
+ ...options.maxFeePerGas && {
972
+ maxFeePerGas: options.maxFeePerGas
973
+ },
974
+ ...options.maxPriorityFeePerGas && {
975
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
976
+ }
977
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
891
978
  });
892
979
  const { tx } = await import("../utils/transactionHelpers");
893
980
  return tx({
@@ -1697,7 +1784,7 @@ class PermissionsController extends import_base.BaseController {
1697
1784
  * @returns Promise resolving to TransactionResult for transaction tracking
1698
1785
  * @throws {BlockchainError} When contract submission fails
1699
1786
  */
1700
- async submitDirectUntrustTransaction(params) {
1787
+ async submitDirectUntrustTransaction(params, options) {
1701
1788
  this.assertWallet();
1702
1789
  try {
1703
1790
  const chainId = await this.context.walletClient.getChainId();
@@ -1713,7 +1800,18 @@ class PermissionsController extends import_base.BaseController {
1713
1800
  functionName: "untrustServer",
1714
1801
  args: [BigInt(params.serverId)],
1715
1802
  account,
1716
- chain: this.context.walletClient?.chain ?? null
1803
+ chain: this.context.walletClient?.chain ?? null,
1804
+ ...options?.gas && { gas: options.gas },
1805
+ ...options?.nonce && { nonce: options.nonce },
1806
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
1807
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
1808
+ ...options.maxFeePerGas && {
1809
+ maxFeePerGas: options.maxFeePerGas
1810
+ },
1811
+ ...options.maxPriorityFeePerGas && {
1812
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
1813
+ }
1814
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
1717
1815
  });
1718
1816
  const { tx } = await import("../utils/transactionHelpers");
1719
1817
  return tx({
@@ -1740,6 +1838,7 @@ class PermissionsController extends import_base.BaseController {
1740
1838
  *
1741
1839
  * @param params - Parameters for untrusting the server
1742
1840
  * @param params.serverId - The numeric ID of the server to untrust
1841
+ * @param options - Optional transaction options for gas parameters and timeout
1743
1842
  * @returns Promise resolving to transaction hash
1744
1843
  * @throws {Error} When wallet account is not available
1745
1844
  * @throws {NonceError} When retrieving user nonce fails
@@ -1760,14 +1859,17 @@ class PermissionsController extends import_base.BaseController {
1760
1859
  * console.log('Still trusting servers:', trustedServers);
1761
1860
  * ```
1762
1861
  */
1763
- async submitUntrustServer(params) {
1862
+ async submitUntrustServer(params, options) {
1764
1863
  this.assertWallet();
1765
1864
  const nonce = await this.getServersUserNonce();
1766
1865
  const untrustServerInput = {
1767
1866
  nonce,
1768
1867
  serverId: params.serverId
1769
1868
  };
1770
- return await this.submitDirectUntrustTransaction(untrustServerInput);
1869
+ return await this.submitDirectUntrustTransaction(
1870
+ untrustServerInput,
1871
+ options
1872
+ );
1771
1873
  }
1772
1874
  /**
1773
1875
  * Untrusts a server using a signature (gasless transaction).
@@ -2294,7 +2396,7 @@ class PermissionsController extends import_base.BaseController {
2294
2396
  * @param signature - The cryptographic signature for the transaction
2295
2397
  * @returns Promise resolving to the transaction hash
2296
2398
  */
2297
- async submitTrustServerTransaction(trustServerInput, signature) {
2399
+ async submitTrustServerTransaction(trustServerInput, signature, options) {
2298
2400
  this.assertWallet();
2299
2401
  const chainId = await this.context.walletClient.getChainId();
2300
2402
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -2315,7 +2417,8 @@ class PermissionsController extends import_base.BaseController {
2315
2417
  formattedSignature
2316
2418
  ],
2317
2419
  account: this.context.walletClient?.account ?? this.context.userAddress,
2318
- chain: this.context.walletClient?.chain ?? null
2420
+ chain: this.context.walletClient?.chain ?? null,
2421
+ ...this.spreadTransactionOptions(options)
2319
2422
  });
2320
2423
  return txHash;
2321
2424
  }
@@ -2352,7 +2455,7 @@ class PermissionsController extends import_base.BaseController {
2352
2455
  * @param signature - The cryptographic signature authorizing the untrust
2353
2456
  * @returns Promise resolving to the transaction hash
2354
2457
  */
2355
- async submitSignedUntrustTransaction(typedData, signature) {
2458
+ async submitSignedUntrustTransaction(typedData, signature, _options) {
2356
2459
  this.assertWallet();
2357
2460
  const chainId = await this.context.walletClient.getChainId();
2358
2461
  const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
@@ -2388,6 +2491,7 @@ class PermissionsController extends import_base.BaseController {
2388
2491
  * @param params.owner - The Ethereum address that will own this grantee registration
2389
2492
  * @param params.granteeAddress - The Ethereum address of the grantee (application)
2390
2493
  * @param params.publicKey - The public key used for data encryption/decryption (hex string)
2494
+ * @param options - Optional transaction options for gas parameters and timeout
2391
2495
  * @returns Promise resolving to the transaction hash
2392
2496
  * @throws {BlockchainError} When the grantee registration transaction fails
2393
2497
  * @throws {UserRejectedRequestError} When user rejects the transaction
@@ -2403,7 +2507,7 @@ class PermissionsController extends import_base.BaseController {
2403
2507
  * console.log(`Grantee registered in transaction: ${txHash}`);
2404
2508
  * ```
2405
2509
  */
2406
- async submitRegisterGrantee(params) {
2510
+ async submitRegisterGrantee(params, options) {
2407
2511
  this.assertWallet();
2408
2512
  const chainId = await this.context.walletClient.getChainId();
2409
2513
  const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
@@ -2420,7 +2524,8 @@ class PermissionsController extends import_base.BaseController {
2420
2524
  functionName: "registerGrantee",
2421
2525
  args: [ownerAddress, granteeAddress, params.publicKey],
2422
2526
  account,
2423
- chain: this.context.walletClient?.chain ?? null
2527
+ chain: this.context.walletClient?.chain ?? null,
2528
+ ...this.spreadTransactionOptions(options)
2424
2529
  });
2425
2530
  const { tx } = await import("../utils/transactionHelpers");
2426
2531
  return tx({
@@ -3338,9 +3443,10 @@ class PermissionsController extends import_base.BaseController {
3338
3443
  *
3339
3444
  * @param serverId - Server ID to update
3340
3445
  * @param url - New URL for the server
3446
+ * @param options - Optional transaction options for gas parameters and timeout
3341
3447
  * @returns Promise resolving to transaction hash
3342
3448
  */
3343
- async submitUpdateServer(serverId, url) {
3449
+ async submitUpdateServer(serverId, url, options) {
3344
3450
  this.assertWallet();
3345
3451
  try {
3346
3452
  const chainId = await this.context.walletClient.getChainId();
@@ -3356,7 +3462,18 @@ class PermissionsController extends import_base.BaseController {
3356
3462
  functionName: "updateServer",
3357
3463
  args: [serverId, url],
3358
3464
  chain: this.context.walletClient?.chain,
3359
- account
3465
+ account,
3466
+ ...options?.gas && { gas: options.gas },
3467
+ ...options?.nonce && { nonce: options.nonce },
3468
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
3469
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
3470
+ ...options.maxFeePerGas && {
3471
+ maxFeePerGas: options.maxFeePerGas
3472
+ },
3473
+ ...options.maxPriorityFeePerGas && {
3474
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
3475
+ }
3476
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3360
3477
  });
3361
3478
  const { tx } = await import("../utils/transactionHelpers");
3362
3479
  return tx({
@@ -3552,7 +3669,7 @@ class PermissionsController extends import_base.BaseController {
3552
3669
  * @throws {BlockchainError} When permission addition fails
3553
3670
  * @throws {NetworkError} When network communication fails
3554
3671
  */
3555
- async submitSignedAddPermission(typedData, signature) {
3672
+ async submitSignedAddPermission(typedData, signature, options) {
3556
3673
  this.assertWallet();
3557
3674
  try {
3558
3675
  let hash;
@@ -3575,7 +3692,8 @@ class PermissionsController extends import_base.BaseController {
3575
3692
  } else {
3576
3693
  hash = await this.submitDirectAddPermissionTransaction(
3577
3694
  typedData,
3578
- signature
3695
+ signature,
3696
+ options
3579
3697
  );
3580
3698
  }
3581
3699
  const account = this.context.walletClient?.account ?? this.context.userAddress;
@@ -3616,6 +3734,9 @@ class PermissionsController extends import_base.BaseController {
3616
3734
  * @param params.serverPublicKey - Server's public key for encryption.
3617
3735
  * Obtain via `vana.server.getIdentity(userAddress).publicKey`.
3618
3736
  * @param params.filePermissions - Nested array of permissions for each file
3737
+ * @param options - Optional transaction options for gas parameters and timeout.
3738
+ * Note: These options are only applied for direct blockchain transactions.
3739
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3619
3740
  * @returns TransactionResult with immediate hash access and optional event data
3620
3741
  * @throws {Error} When schemaIds array length doesn't match fileUrls array length
3621
3742
  * @throws {SchemaValidationError} When file data doesn't match the specified schema.
@@ -3629,6 +3750,7 @@ class PermissionsController extends import_base.BaseController {
3629
3750
  *
3630
3751
  * @example
3631
3752
  * ```typescript
3753
+ * // Submit with custom gas parameters and timeout
3632
3754
  * const result = await vana.permissions.submitAddServerFilesAndPermissions({
3633
3755
  * granteeId: BigInt(1),
3634
3756
  * grant: "ipfs://QmXxx...",
@@ -3641,12 +3763,19 @@ class PermissionsController extends import_base.BaseController {
3641
3763
  * account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
3642
3764
  * key: encryptedKey
3643
3765
  * }]]
3766
+ * }, {
3767
+ * maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
3768
+ * maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
3644
3769
  * });
3645
- * const events = await result.waitForEvents();
3646
- * console.log(`Permission ID: ${events.permissionId}`);
3770
+ *
3771
+ * // Wait for confirmation with custom timeout
3772
+ * const receipt = await vana.waitForTransactionReceipt(result, {
3773
+ * timeout: 180000 // 3 minutes
3774
+ * });
3775
+ * console.log(`Transaction confirmed: ${receipt.transactionHash}`);
3647
3776
  * ```
3648
3777
  */
3649
- async submitAddServerFilesAndPermissions(params) {
3778
+ async submitAddServerFilesAndPermissions(params, options) {
3650
3779
  this.assertWallet();
3651
3780
  try {
3652
3781
  if (params.schemaIds.length !== params.fileUrls.length) {
@@ -3672,7 +3801,8 @@ class PermissionsController extends import_base.BaseController {
3672
3801
  const signature = await this.signTypedData(typedData);
3673
3802
  return await this.submitSignedAddServerFilesAndPermissions(
3674
3803
  typedData,
3675
- signature
3804
+ signature,
3805
+ options
3676
3806
  );
3677
3807
  } catch (error) {
3678
3808
  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) {
@@ -3693,6 +3823,9 @@ class PermissionsController extends import_base.BaseController {
3693
3823
  *
3694
3824
  * @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
3695
3825
  * @param signature - The user's signature
3826
+ * @param options - Optional transaction options for gas parameters and timeout.
3827
+ * Note: These options are only applied for direct blockchain transactions.
3828
+ * When using relayer callbacks (gasless transactions), these options are ignored.
3696
3829
  * @returns TransactionResult with immediate hash access and optional event data
3697
3830
  * @throws {RelayerError} When gasless transaction submission fails
3698
3831
  * @throws {BlockchainError} When server files and permissions addition fails
@@ -3711,7 +3844,7 @@ class PermissionsController extends import_base.BaseController {
3711
3844
  * console.log(`Permission created with ID: ${permissionId}`);
3712
3845
  * ```
3713
3846
  */
3714
- async submitSignedAddServerFilesAndPermissions(typedData, signature) {
3847
+ async submitSignedAddServerFilesAndPermissions(typedData, signature, options) {
3715
3848
  this.assertWallet();
3716
3849
  try {
3717
3850
  let hash;
@@ -3740,7 +3873,8 @@ class PermissionsController extends import_base.BaseController {
3740
3873
  );
3741
3874
  hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
3742
3875
  typedData,
3743
- signature
3876
+ signature,
3877
+ options
3744
3878
  );
3745
3879
  }
3746
3880
  const account = this.context.walletClient?.account ?? this.context.userAddress;
@@ -3765,9 +3899,10 @@ class PermissionsController extends import_base.BaseController {
3765
3899
  * Submit permission revocation with signature to the blockchain
3766
3900
  *
3767
3901
  * @param permissionId - Permission ID to revoke
3902
+ * @param options - Optional transaction options for gas parameters and timeout
3768
3903
  * @returns Promise resolving to transaction hash
3769
3904
  */
3770
- async submitRevokePermission(permissionId) {
3905
+ async submitRevokePermission(permissionId, options) {
3771
3906
  this.assertWallet();
3772
3907
  try {
3773
3908
  const chainId = await this.context.walletClient.getChainId();
@@ -3788,7 +3923,18 @@ class PermissionsController extends import_base.BaseController {
3788
3923
  functionName: "revokePermission",
3789
3924
  args: [permissionId],
3790
3925
  chain: this.context.walletClient?.chain,
3791
- account
3926
+ account,
3927
+ ...options?.gas && { gas: options.gas },
3928
+ ...options?.nonce && { nonce: options.nonce },
3929
+ // Use EIP-1559 if available, otherwise fall back to legacy gasPrice
3930
+ ...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
3931
+ ...options.maxFeePerGas && {
3932
+ maxFeePerGas: options.maxFeePerGas
3933
+ },
3934
+ ...options.maxPriorityFeePerGas && {
3935
+ maxPriorityFeePerGas: options.maxPriorityFeePerGas
3936
+ }
3937
+ } : options?.gasPrice && { gasPrice: options.gasPrice }
3792
3938
  });
3793
3939
  const { tx } = await import("../utils/transactionHelpers");
3794
3940
  return tx({
@@ -3811,7 +3957,7 @@ class PermissionsController extends import_base.BaseController {
3811
3957
  * @param signature - The cryptographic signature authorizing the transaction
3812
3958
  * @returns Promise resolving to the transaction hash
3813
3959
  */
3814
- async submitDirectAddPermissionTransaction(typedData, signature) {
3960
+ async submitDirectAddPermissionTransaction(typedData, signature, options) {
3815
3961
  this.assertWallet();
3816
3962
  const chainId = await this.context.walletClient.getChainId();
3817
3963
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
@@ -3832,7 +3978,8 @@ class PermissionsController extends import_base.BaseController {
3832
3978
  functionName: "addPermission",
3833
3979
  args: [permissionInput, formattedSignature],
3834
3980
  account: this.context.walletClient?.account ?? this.context.userAddress,
3835
- chain: this.context.walletClient?.chain ?? null
3981
+ chain: this.context.walletClient?.chain ?? null,
3982
+ ...this.spreadTransactionOptions(options)
3836
3983
  });
3837
3984
  return hash;
3838
3985
  }
@@ -3843,7 +3990,7 @@ class PermissionsController extends import_base.BaseController {
3843
3990
  * @param signature - The cryptographic signature authorizing the transaction
3844
3991
  * @returns Promise resolving to the transaction hash
3845
3992
  */
3846
- async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
3993
+ async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature, options) {
3847
3994
  this.assertWallet();
3848
3995
  const chainId = await this.context.publicClient.getChainId();
3849
3996
  const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
@@ -3867,10 +4014,11 @@ class PermissionsController extends import_base.BaseController {
3867
4014
  address: DataPortabilityPermissionsAddress,
3868
4015
  abi: DataPortabilityPermissionsAbi,
3869
4016
  functionName: "addServerFilesAndPermissions",
3870
- // @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
3871
4017
  args: [serverFilesAndPermissionInput, formattedSignature],
3872
- account: this.context.userAddress,
3873
- chain: this.context.walletClient?.chain ?? null
4018
+ account: this.context.walletClient?.account ?? this.context.userAddress,
4019
+ chain: this.context.walletClient?.chain ?? null,
4020
+ ...options?.value && { value: options.value },
4021
+ ...this.spreadTransactionOptions(options)
3874
4022
  });
3875
4023
  return hash;
3876
4024
  }