@dynamic-labs-sdk/solana 1.17.1 → 1.19.0

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 (64) hide show
  1. package/dist/addSolanaExtension/addSolanaExtension.d.ts +10 -1
  2. package/dist/addSolanaExtension/addSolanaExtension.d.ts.map +1 -1
  3. package/dist/{addSolanaWalletStandardExtension-D_WVyVEx.esm.js → addSolanaWalletStandardExtension-CbR1BbPB.esm.js} +3 -3
  4. package/dist/{addSolanaWalletStandardExtension-D_WVyVEx.esm.js.map → addSolanaWalletStandardExtension-CbR1BbPB.esm.js.map} +1 -1
  5. package/dist/{addSolanaWalletStandardExtension-Dtf-b3fq.cjs → addSolanaWalletStandardExtension-CyYa03dG.cjs} +3 -3
  6. package/dist/{addSolanaWalletStandardExtension-Dtf-b3fq.cjs.map → addSolanaWalletStandardExtension-CyYa03dG.cjs.map} +1 -1
  7. package/dist/{addWaasSolanaExtension-BwdvB_-W.esm.js → addWaasSolanaExtension-DVuz2ISz.esm.js} +2 -2
  8. package/dist/{addWaasSolanaExtension-BwdvB_-W.esm.js.map → addWaasSolanaExtension-DVuz2ISz.esm.js.map} +1 -1
  9. package/dist/{addWaasSolanaExtension-av0ucGCH.cjs → addWaasSolanaExtension-wH_cvxuL.cjs} +2 -2
  10. package/dist/{addWaasSolanaExtension-av0ucGCH.cjs.map → addWaasSolanaExtension-wH_cvxuL.cjs.map} +1 -1
  11. package/dist/{createWalletProviderFromSolanaStandardWallet-Dtio4xHn.esm.js → createWalletProviderFromSolanaStandardWallet-B7jh3I6k.esm.js} +2 -2
  12. package/dist/{createWalletProviderFromSolanaStandardWallet-Dtio4xHn.esm.js.map → createWalletProviderFromSolanaStandardWallet-B7jh3I6k.esm.js.map} +1 -1
  13. package/dist/{createWalletProviderFromSolanaStandardWallet-CN-opURQ.cjs → createWalletProviderFromSolanaStandardWallet-Bt5TP7Lt.cjs} +2 -2
  14. package/dist/{createWalletProviderFromSolanaStandardWallet-CN-opURQ.cjs.map → createWalletProviderFromSolanaStandardWallet-Bt5TP7Lt.cjs.map} +1 -1
  15. package/dist/getSolanaConnection/getSolanaConnection.d.ts +7 -1
  16. package/dist/getSolanaConnection/getSolanaConnection.d.ts.map +1 -1
  17. package/dist/index.cjs +466 -18
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.esm.js +466 -18
  20. package/dist/index.esm.js.map +1 -1
  21. package/dist/isSolanaGasSponsorshipEnabled/isSolanaGasSponsorshipEnabled.d.ts +10 -1
  22. package/dist/isSolanaGasSponsorshipEnabled/isSolanaGasSponsorshipEnabled.d.ts.map +1 -1
  23. package/dist/isSolanaNetworkProvider/isSolanaNetworkProvider.d.ts +10 -1
  24. package/dist/isSolanaNetworkProvider/isSolanaNetworkProvider.d.ts.map +1 -1
  25. package/dist/isSolanaWalletAccount/isSolanaWalletAccount.d.ts +9 -1
  26. package/dist/isSolanaWalletAccount/isSolanaWalletAccount.d.ts.map +1 -1
  27. package/dist/metamask.cjs +2 -2
  28. package/dist/metamask.esm.js +2 -2
  29. package/dist/phantomRedirect/addPhantomRedirectSolanaExtension/addPhantomRedirectSolanaExtension.d.ts +11 -0
  30. package/dist/phantomRedirect/addPhantomRedirectSolanaExtension/addPhantomRedirectSolanaExtension.d.ts.map +1 -1
  31. package/dist/phantomRedirect/completePhantomRedirect/completePhantomRedirect.d.ts +14 -0
  32. package/dist/phantomRedirect/completePhantomRedirect/completePhantomRedirect.d.ts.map +1 -1
  33. package/dist/phantomRedirect/detectPhantomRedirect/detectPhantomRedirect.d.ts +9 -1
  34. package/dist/phantomRedirect/detectPhantomRedirect/detectPhantomRedirect.d.ts.map +1 -1
  35. package/dist/phantomRedirect/errors/PhantomInvalidEncryptionPublicKeyError.d.ts +5 -0
  36. package/dist/phantomRedirect/errors/PhantomInvalidEncryptionPublicKeyError.d.ts.map +1 -0
  37. package/dist/phantomRedirect/utils/crypto/createNaClSharedSecret/createNaClSharedSecret.d.ts +6 -1
  38. package/dist/phantomRedirect/utils/crypto/createNaClSharedSecret/createNaClSharedSecret.d.ts.map +1 -1
  39. package/dist/signAllTransactions/signAllTransactions.d.ts +17 -5
  40. package/dist/signAllTransactions/signAllTransactions.d.ts.map +1 -1
  41. package/dist/signAndSendSponsoredTransaction/signAndSendSponsoredTransaction.d.ts +16 -6
  42. package/dist/signAndSendSponsoredTransaction/signAndSendSponsoredTransaction.d.ts.map +1 -1
  43. package/dist/signAndSendTransaction/signAndSendTransaction.d.ts +15 -3
  44. package/dist/signAndSendTransaction/signAndSendTransaction.d.ts.map +1 -1
  45. package/dist/signTransaction/signTransaction.d.ts +17 -5
  46. package/dist/signTransaction/signTransaction.d.ts.map +1 -1
  47. package/dist/simulateSolanaTransaction/simulateSolanaTransaction.d.ts +3 -1
  48. package/dist/simulateSolanaTransaction/simulateSolanaTransaction.d.ts.map +1 -1
  49. package/dist/{solanaTransferAmount-CgovN61n.cjs → solanaTransferAmount-B4keau5s.cjs} +40 -5
  50. package/dist/solanaTransferAmount-B4keau5s.cjs.map +1 -0
  51. package/dist/{solanaTransferAmount-BSu_bMZ6.esm.js → solanaTransferAmount-CdkPbAES.esm.js} +40 -5
  52. package/dist/solanaTransferAmount-CdkPbAES.esm.js.map +1 -0
  53. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  54. package/dist/utils/calculateSolanaTransactionFee/calculateSolanaTransactionFee.d.ts +12 -1
  55. package/dist/utils/calculateSolanaTransactionFee/calculateSolanaTransactionFee.d.ts.map +1 -1
  56. package/dist/waas.cjs +2 -2
  57. package/dist/waas.esm.js +2 -2
  58. package/dist/walletConnect.cjs +1 -1
  59. package/dist/walletConnect.esm.js +1 -1
  60. package/dist/walletStandard.cjs +3 -3
  61. package/dist/walletStandard.esm.js +3 -3
  62. package/package.json +6 -6
  63. package/dist/solanaTransferAmount-BSu_bMZ6.esm.js.map +0 -1
  64. package/dist/solanaTransferAmount-CgovN61n.cjs.map +0 -1
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
- import { a as NotSolanaProviderError, c as isSolanaWalletAccount, d as registerSolanaNetworkProviderBuilder, f as name, i as isSolanaGasSponsorshipEnabled, l as isVersionedTransaction, n as solanaExecuteSwapTransaction, o as isSolanaWalletProvider, p as version, r as signAndSendTransaction, s as solanaConfirmTransaction, t as solanaTransferAmount, u as getSolanaConnection } from "./solanaTransferAmount-BSu_bMZ6.esm.js";
1
+ import { a as NotSolanaProviderError, c as isSolanaWalletAccount, d as registerSolanaNetworkProviderBuilder, f as name, i as isSolanaGasSponsorshipEnabled, l as isVersionedTransaction, n as solanaExecuteSwapTransaction, o as isSolanaWalletProvider, p as version, r as signAndSendTransaction, s as solanaConfirmTransaction, t as solanaTransferAmount, u as getSolanaConnection } from "./solanaTransferAmount-CdkPbAES.esm.js";
2
2
  import { t as assertBufferAvailable } from "./assertBufferAvailable-b4xOlERy.esm.js";
3
- import { n as SponsorTransactionError, t as addWaasSolanaExtension } from "./addWaasSolanaExtension-BwdvB_-W.esm.js";
4
- import "./createWalletProviderFromSolanaStandardWallet-Dtio4xHn.esm.js";
5
- import { t as addSolanaWalletStandardExtension } from "./addSolanaWalletStandardExtension-D_WVyVEx.esm.js";
3
+ import { n as SponsorTransactionError, t as addWaasSolanaExtension } from "./addWaasSolanaExtension-DVuz2ISz.esm.js";
4
+ import "./createWalletProviderFromSolanaStandardWallet-B7jh3I6k.esm.js";
5
+ import { t as addSolanaWalletStandardExtension } from "./addSolanaWalletStandardExtension-CbR1BbPB.esm.js";
6
6
  import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
7
7
  import { MethodNotImplementedError, WalletProviderPriority, assertDefined, createApiClient, createDeferredPromise, createRuntimeServiceAccessKey, createStorageKeySchema, emitEvent, formatWalletProviderGroupKey, formatWalletProviderKey, getActiveNetworkIdFromLastKnownRegistry, getBuffer, getCore, getDefaultClient, getNetworkProviders, getWalletProviderFromWalletAccount, getWalletProviderRegistry, hasExtension, randomString, registerExtension } from "@dynamic-labs-sdk/client/core";
8
8
  import { BaseError, FeeEstimationFailedError, InvalidParamError, SimulationFailedError, getActiveNetworkData, getDefaultClient as getDefaultClient$1, onEvent, onceEvent } from "@dynamic-labs-sdk/client";
@@ -20,7 +20,16 @@ import nacl from "tweetnacl";
20
20
  * and the Dynamic WaaS Solana extension, enabling support for all Solana wallet types
21
21
  * including standard wallets and embedded wallets managed by Dynamic's infrastructure.
22
22
  *
23
+ * @example
24
+ * ```ts
25
+ * const client = createDynamicClient({ environmentId: 'env-123' });
26
+ * addSolanaExtension(client);
27
+ * ```
28
+ *
23
29
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
30
+ * @returns void
31
+ * @see isSolanaWalletAccount
32
+ * @see isSolanaNetworkProvider
24
33
  * @notInstrumented
25
34
  */
26
35
  const addSolanaExtension = (client = getDefaultClient()) => {
@@ -34,8 +43,17 @@ const addSolanaExtension = (client = getDefaultClient()) => {
34
43
  /**
35
44
  * Type guard function to check if a network provider is a Solana network provider.
36
45
  *
46
+ * @example
47
+ * ```ts
48
+ * if (isSolanaNetworkProvider(networkProvider)) {
49
+ * const connection = getSolanaConnection({ networkData });
50
+ * }
51
+ * ```
52
+ *
37
53
  * @param networkProvider - The network provider to check.
38
54
  * @returns True if the network provider is a Solana network provider, false otherwise.
55
+ * @see isSolanaWalletAccount
56
+ * @see addSolanaExtension
39
57
  * @notInstrumented
40
58
  */
41
59
  const isSolanaNetworkProvider = (networkProvider) => networkProvider.chain === "SOL";
@@ -54,11 +72,22 @@ const sleep = (ms) => new Promise((resolve) => {
54
72
  * and querying the network. It handles both legacy Transaction and VersionedTransaction
55
73
  * formats and includes retry logic for network requests.
56
74
  *
75
+ * @example
76
+ * ```ts
77
+ * const feeData = await calculateSolanaTransactionFee({
78
+ * transaction,
79
+ * networkData,
80
+ * nativeTokenPriceUsd: 150,
81
+ * });
82
+ * ```
83
+ *
57
84
  * @param params.transaction - The Solana transaction to estimate fees for.
58
85
  * @param params.networkData - Network configuration for RPC connection.
59
86
  * @param params.nativeTokenPriceUsd - Optional USD price of SOL for fee conversion.
60
87
  * @returns Fee data in lamports and human-readable SOL format.
61
88
  * @throws {FeeEstimationFailedError} If fee retrieval fails after retries.
89
+ * @see simulateSolanaTransaction
90
+ * @see getSolanaConnection
62
91
  * @notInstrumented
63
92
  */
64
93
  const calculateSolanaTransactionFee = async ({ transaction, networkData, nativeTokenPriceUsd }) => {
@@ -137,6 +166,8 @@ const calculateSolanaTransactionFee = async ({ transaction, networkData, nativeT
137
166
  * @throws {InvalidParamError} If wallet account is not a Solana account.
138
167
  * @throws {SimulationFailedError} If the simulation API call fails.
139
168
  * @throws {FeeEstimationFailedError} If includeFees is true and fee calculation fails.
169
+ * @see calculateSolanaTransactionFee
170
+ * @see isSolanaWalletAccount
140
171
  * @notInstrumented
141
172
  */
142
173
  const simulateSolanaTransaction = async ({ walletAccount, transaction, includeFees = false }, client = getDefaultClient$1()) => {
@@ -331,18 +362,368 @@ const broadcastPhantomEvent = ({ args, event }, client) => {
331
362
  });
332
363
  };
333
364
 
365
+ //#endregion
366
+ //#region src/phantomRedirect/errors/PhantomInvalidEncryptionPublicKeyError.ts
367
+ var PhantomInvalidEncryptionPublicKeyError = class extends BaseError {
368
+ constructor() {
369
+ super({
370
+ cause: null,
371
+ code: "phantom_invalid_encryption_public_key_error",
372
+ docsUrl: null,
373
+ name: "PhantomInvalidEncryptionPublicKeyError",
374
+ shortMessage: "Invalid Phantom encryption public key (low-order point rejected)."
375
+ });
376
+ }
377
+ };
378
+
334
379
  //#endregion
335
380
  //#region src/phantomRedirect/utils/crypto/createNaClSharedSecret/createNaClSharedSecret.ts
336
381
  /**
382
+ * The length, in bytes, of a Curve25519 public key.
383
+ */
384
+ const CURVE25519_PUBLIC_KEY_LENGTH = 32;
385
+ /**
386
+ * The complete set of known Curve25519 low-order point encodings.
387
+ *
388
+ * A malicious Phantom redirect can supply one of these as
389
+ * `phantom_encryption_public_key`. X25519 with a low-order base point produces
390
+ * a small, universally-known shared secret (independent of our secret key),
391
+ * letting an attacker decrypt/forge the connect response and overwrite the
392
+ * connected wallet address. We reject them before deriving the box secret.
393
+ *
394
+ * Source: RFC 7748 / the canonical list of the 8 Curve25519 low-order points.
395
+ */
396
+ const CURVE25519_LOW_ORDER_POINTS = [
397
+ new Uint8Array([
398
+ 0,
399
+ 0,
400
+ 0,
401
+ 0,
402
+ 0,
403
+ 0,
404
+ 0,
405
+ 0,
406
+ 0,
407
+ 0,
408
+ 0,
409
+ 0,
410
+ 0,
411
+ 0,
412
+ 0,
413
+ 0,
414
+ 0,
415
+ 0,
416
+ 0,
417
+ 0,
418
+ 0,
419
+ 0,
420
+ 0,
421
+ 0,
422
+ 0,
423
+ 0,
424
+ 0,
425
+ 0,
426
+ 0,
427
+ 0,
428
+ 0,
429
+ 0
430
+ ]),
431
+ new Uint8Array([
432
+ 1,
433
+ 0,
434
+ 0,
435
+ 0,
436
+ 0,
437
+ 0,
438
+ 0,
439
+ 0,
440
+ 0,
441
+ 0,
442
+ 0,
443
+ 0,
444
+ 0,
445
+ 0,
446
+ 0,
447
+ 0,
448
+ 0,
449
+ 0,
450
+ 0,
451
+ 0,
452
+ 0,
453
+ 0,
454
+ 0,
455
+ 0,
456
+ 0,
457
+ 0,
458
+ 0,
459
+ 0,
460
+ 0,
461
+ 0,
462
+ 0,
463
+ 0
464
+ ]),
465
+ new Uint8Array([
466
+ 224,
467
+ 235,
468
+ 122,
469
+ 124,
470
+ 59,
471
+ 65,
472
+ 184,
473
+ 174,
474
+ 22,
475
+ 86,
476
+ 227,
477
+ 250,
478
+ 241,
479
+ 159,
480
+ 196,
481
+ 106,
482
+ 218,
483
+ 9,
484
+ 141,
485
+ 235,
486
+ 156,
487
+ 50,
488
+ 177,
489
+ 253,
490
+ 134,
491
+ 98,
492
+ 5,
493
+ 22,
494
+ 95,
495
+ 73,
496
+ 184,
497
+ 0
498
+ ]),
499
+ new Uint8Array([
500
+ 95,
501
+ 156,
502
+ 149,
503
+ 188,
504
+ 163,
505
+ 80,
506
+ 140,
507
+ 36,
508
+ 177,
509
+ 208,
510
+ 177,
511
+ 85,
512
+ 156,
513
+ 131,
514
+ 239,
515
+ 91,
516
+ 4,
517
+ 68,
518
+ 92,
519
+ 196,
520
+ 88,
521
+ 28,
522
+ 142,
523
+ 134,
524
+ 216,
525
+ 34,
526
+ 78,
527
+ 221,
528
+ 208,
529
+ 159,
530
+ 17,
531
+ 87
532
+ ]),
533
+ new Uint8Array([
534
+ 236,
535
+ 255,
536
+ 255,
537
+ 255,
538
+ 255,
539
+ 255,
540
+ 255,
541
+ 255,
542
+ 255,
543
+ 255,
544
+ 255,
545
+ 255,
546
+ 255,
547
+ 255,
548
+ 255,
549
+ 255,
550
+ 255,
551
+ 255,
552
+ 255,
553
+ 255,
554
+ 255,
555
+ 255,
556
+ 255,
557
+ 255,
558
+ 255,
559
+ 255,
560
+ 255,
561
+ 255,
562
+ 255,
563
+ 255,
564
+ 255,
565
+ 127
566
+ ]),
567
+ new Uint8Array([
568
+ 237,
569
+ 255,
570
+ 255,
571
+ 255,
572
+ 255,
573
+ 255,
574
+ 255,
575
+ 255,
576
+ 255,
577
+ 255,
578
+ 255,
579
+ 255,
580
+ 255,
581
+ 255,
582
+ 255,
583
+ 255,
584
+ 255,
585
+ 255,
586
+ 255,
587
+ 255,
588
+ 255,
589
+ 255,
590
+ 255,
591
+ 255,
592
+ 255,
593
+ 255,
594
+ 255,
595
+ 255,
596
+ 255,
597
+ 255,
598
+ 255,
599
+ 127
600
+ ]),
601
+ new Uint8Array([
602
+ 238,
603
+ 255,
604
+ 255,
605
+ 255,
606
+ 255,
607
+ 255,
608
+ 255,
609
+ 255,
610
+ 255,
611
+ 255,
612
+ 255,
613
+ 255,
614
+ 255,
615
+ 255,
616
+ 255,
617
+ 255,
618
+ 255,
619
+ 255,
620
+ 255,
621
+ 255,
622
+ 255,
623
+ 255,
624
+ 255,
625
+ 255,
626
+ 255,
627
+ 255,
628
+ 255,
629
+ 255,
630
+ 255,
631
+ 255,
632
+ 255,
633
+ 127
634
+ ]),
635
+ new Uint8Array([
636
+ 205,
637
+ 235,
638
+ 122,
639
+ 124,
640
+ 59,
641
+ 65,
642
+ 184,
643
+ 174,
644
+ 22,
645
+ 86,
646
+ 227,
647
+ 250,
648
+ 241,
649
+ 159,
650
+ 196,
651
+ 106,
652
+ 218,
653
+ 9,
654
+ 141,
655
+ 235,
656
+ 156,
657
+ 50,
658
+ 177,
659
+ 253,
660
+ 134,
661
+ 98,
662
+ 5,
663
+ 22,
664
+ 95,
665
+ 73,
666
+ 184,
667
+ 128
668
+ ])
669
+ ];
670
+ /**
671
+ * Constant-time equality check for two byte arrays. No early-exit branches so
672
+ * comparison duration does not leak the content being compared.
673
+ */
674
+ const bytesEqual = ({ a, b }) => {
675
+ let diff = a.length ^ b.length;
676
+ const length = Math.min(a.length, b.length);
677
+ for (let i = 0; i < length; i += 1) diff |= a[i] ^ b[i];
678
+ return diff === 0;
679
+ };
680
+ /**
681
+ * Validates that a decoded Curve25519 public key is safe to use for X25519 key
682
+ * agreement, rejecting low-order / contributory points.
683
+ *
684
+ * Defense in depth:
685
+ * 1. Enforce the canonical 32-byte length.
686
+ * 2. Reject the known small set of low-order point encodings (blocklist).
687
+ * 3. Reject any input whose raw X25519 output (`nacl.scalarMult`) is all-zero,
688
+ * which catches low-order inputs regardless of encoding.
689
+ *
690
+ * @param params.theirPublicKey - The decoded (32-byte) peer public key
691
+ * @param params.ourSecretKey - The decoded (32-byte) local secret key
692
+ * @throws {PhantomInvalidEncryptionPublicKeyError} If the key is invalid or low-order
693
+ */
694
+ const assertValidCurve25519PublicKey = ({ theirPublicKey, ourSecretKey }) => {
695
+ if (theirPublicKey.length !== CURVE25519_PUBLIC_KEY_LENGTH) throw new PhantomInvalidEncryptionPublicKeyError();
696
+ for (const lowOrderPoint of CURVE25519_LOW_ORDER_POINTS) if (bytesEqual({
697
+ a: theirPublicKey,
698
+ b: lowOrderPoint
699
+ })) throw new PhantomInvalidEncryptionPublicKeyError();
700
+ const scalarMultOutput = nacl.scalarMult(ourSecretKey, theirPublicKey);
701
+ if (bytesEqual({
702
+ a: scalarMultOutput,
703
+ b: new Uint8Array(scalarMultOutput.length)
704
+ })) throw new PhantomInvalidEncryptionPublicKeyError();
705
+ };
706
+ /**
337
707
  * Creates a shared secret for NaCl box encryption using our secret key and their public key.
338
708
  *
709
+ * Rejects low-order / invalid Curve25519 public keys before deriving the shared
710
+ * secret, preventing an attacker from forcing the X25519 output to a known
711
+ * constant via a malicious `phantom_encryption_public_key`.
712
+ *
339
713
  * @param params.ourSecretKey - Our base58-encoded secret key
340
714
  * @param params.theirPublicKey - Their base58-encoded public key
341
715
  * @returns The base58-encoded shared secret
716
+ * @throws {PhantomInvalidEncryptionPublicKeyError} If their public key is invalid or a low-order point
342
717
  * @notInstrumented
343
718
  */
344
719
  const createNaClSharedSecret = ({ ourSecretKey, theirPublicKey }) => {
345
- const sharedSecret = nacl.box.before(bs58.decode(theirPublicKey), bs58.decode(ourSecretKey));
720
+ const theirPublicKeyBytes = bs58.decode(theirPublicKey);
721
+ const ourSecretKeyBytes = bs58.decode(ourSecretKey);
722
+ assertValidCurve25519PublicKey({
723
+ ourSecretKey: ourSecretKeyBytes,
724
+ theirPublicKey: theirPublicKeyBytes
725
+ });
726
+ const sharedSecret = nacl.box.before(theirPublicKeyBytes, ourSecretKeyBytes);
346
727
  return bs58.encode(sharedSecret);
347
728
  };
348
729
 
@@ -506,6 +887,17 @@ const completeAndEmitPhantomRedirectEvent = async ({ args, event }, client) => {
506
887
  * is returned to the originating tab. See the `phantomRedirectCloseTab` event
507
888
  * JSDoc for details on how to handle tab closing.
508
889
  *
890
+ * @example
891
+ * ```ts
892
+ * const url = new URL(window.location.href);
893
+ * if (await detectPhantomRedirect({ url })) {
894
+ * await completePhantomRedirect({ url });
895
+ * // Close this clone tab; the originating tab already received the result
896
+ * // via BroadcastChannel and will resolve its pending promise.
897
+ * window.close();
898
+ * }
899
+ * ```
900
+ *
509
901
  * @param params.url - The callback URL received from Phantom
510
902
  * @param client - The Dynamic client instance
511
903
  * @throws {NoPendingPhantomRequestError} If no pending request is found in storage
@@ -513,6 +905,9 @@ const completeAndEmitPhantomRedirectEvent = async ({ args, event }, client) => {
513
905
  * required encryption parameters (`phantom_encryption_public_key`, `data`,
514
906
  * `nonce`) and does not carry an error code either
515
907
  * @throws {PhantomRedirectRejectedError} If the user rejected the request in Phantom
908
+ * @returns void
909
+ * @see detectPhantomRedirect
910
+ * @see addPhantomRedirectSolanaExtension
516
911
  * @notInstrumented
517
912
  */
518
913
  const completePhantomRedirect = async ({ url }, client = getDefaultClient()) => {
@@ -1095,9 +1490,17 @@ const createPhantomRedirectWalletProvider = ({ baseRedirectUrl, dynamicClient })
1095
1490
  * we fall back to checking whether a pending disconnect request exists in
1096
1491
  * storage.
1097
1492
  *
1493
+ * @example
1494
+ * ```ts
1495
+ * const url = new URL(window.location.href);
1496
+ * const isPhantomRedirect = await detectPhantomRedirect({ url });
1497
+ * ```
1498
+ *
1098
1499
  * @param params.url - The URL to check for Phantom redirect parameters
1099
1500
  * @param client - The Dynamic client instance
1100
1501
  * @returns A promise that resolves to true if the URL is a valid Phantom redirect, false otherwise
1502
+ * @see completePhantomRedirect
1503
+ * @see addPhantomRedirectSolanaExtension
1101
1504
  * @notInstrumented
1102
1505
  */
1103
1506
  const detectPhantomRedirect = async ({ url }, client = getDefaultClient()) => {
@@ -1151,10 +1554,21 @@ const PHANTOM_REDIRECT_SOLANA_EXTENSION_KEY = "phantomRedirectSolana";
1151
1554
  * marker written during request initiation and does **not** emit
1152
1555
  * `phantomRedirectCloseTab`.
1153
1556
  *
1557
+ * @example
1558
+ * ```ts
1559
+ * addPhantomRedirectSolanaExtension({
1560
+ * url: new URL(window.location.href),
1561
+ * onCloseTab: () => window.close(),
1562
+ * });
1563
+ * ```
1564
+ *
1154
1565
  * @param params.url - The current page URL
1155
1566
  * @param params.onCloseTab - Callback invoked when the clone tab should close
1156
1567
  * @param params.disableAutoRedirectCompletion - Skip auto detection/completion
1157
1568
  * @param [client] - The Dynamic client. Only required for multiple clients.
1569
+ * @returns void
1570
+ * @see completePhantomRedirect
1571
+ * @see detectPhantomRedirect
1158
1572
  * @notInstrumented
1159
1573
  */
1160
1574
  const addPhantomRedirectSolanaExtension = async ({ disableAutoRedirectCompletion, onCloseTab, url }, client = getDefaultClient()) => {
@@ -1210,11 +1624,23 @@ const addPhantomRedirectSolanaExtension = async ({ disableAutoRedirectCompletion
1210
1624
  //#endregion
1211
1625
  //#region src/signAllTransactions/signAllTransactions.ts
1212
1626
  /**
1213
- * Signs multiple Solana transactions
1214
- * @param params.transactions - The transactions to sign
1215
- * @param params.walletAccount - The wallet account to sign the transactions with
1627
+ * Signs multiple Solana transactions in a single call.
1628
+ *
1629
+ * @example
1630
+ * ```ts
1631
+ * const { signedTransactions } = await signAllTransactions({
1632
+ * walletAccount: solAccount,
1633
+ * transactions: [tx1, tx2, tx3],
1634
+ * });
1635
+ * ```
1636
+ *
1637
+ * @param params.transactions - The transactions to sign.
1638
+ * @param params.walletAccount - The wallet account to sign the transactions with.
1216
1639
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1217
- * @returns An object containing the signed transactions
1640
+ * @returns An object containing the signed transactions.
1641
+ * @throws {NotSolanaProviderError} If the wallet provider is not a Solana provider.
1642
+ * @see signTransaction
1643
+ * @see signAndSendTransaction
1218
1644
  * @notInstrumented
1219
1645
  */
1220
1646
  const signAllTransactions = async ({ walletAccount, transactions }, client = getDefaultClient$1()) => {
@@ -1232,12 +1658,22 @@ const signAllTransactions = async ({ walletAccount, transactions }, client = get
1232
1658
  * Signs and sends a sponsored Solana transaction.
1233
1659
  * The transaction will be sponsored via Dynamic's gas sponsorship API.
1234
1660
  *
1235
- * @param params.transaction - The transaction to sponsor, sign, and send
1236
- * @param params.walletAccount - The wallet account to sign and send the transaction with
1661
+ * @example
1662
+ * ```ts
1663
+ * const { signature } = await signAndSendSponsoredTransaction({
1664
+ * walletAccount: solAccount,
1665
+ * transaction,
1666
+ * });
1667
+ * ```
1668
+ *
1669
+ * @param params.transaction - The transaction to sponsor, sign, and send.
1670
+ * @param params.walletAccount - The wallet account to sign and send the transaction with.
1237
1671
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1238
- * @returns An object containing the signature
1239
- * @throws {NotSolanaProviderError} If the wallet provider is not a Solana provider
1240
- * @throws {MethodNotImplementedError} If the wallet provider does not implement signAndSendSponsoredTransaction
1672
+ * @returns An object containing the signature.
1673
+ * @throws {NotSolanaProviderError} If the wallet provider is not a Solana provider.
1674
+ * @throws {MethodNotImplementedError} If the wallet provider does not implement signAndSendSponsoredTransaction.
1675
+ * @see signAndSendTransaction
1676
+ * @see isSolanaGasSponsorshipEnabled
1241
1677
  * @notInstrumented
1242
1678
  */
1243
1679
  const signAndSendSponsoredTransaction = async ({ walletAccount, transaction, options }, client = getDefaultClient$1()) => {
@@ -1254,11 +1690,23 @@ const signAndSendSponsoredTransaction = async ({ walletAccount, transaction, opt
1254
1690
  //#endregion
1255
1691
  //#region src/signTransaction/signTransaction.ts
1256
1692
  /**
1257
- * Signs a Solana transaction
1258
- * @param params.transaction - The transaction to sign
1259
- * @param params.walletAccount - The wallet account to sign the transaction with
1693
+ * Signs a Solana transaction without sending it.
1694
+ *
1695
+ * @example
1696
+ * ```ts
1697
+ * const { signedTransaction } = await signTransaction({
1698
+ * walletAccount: solAccount,
1699
+ * transaction,
1700
+ * });
1701
+ * ```
1702
+ *
1703
+ * @param params.transaction - The transaction to sign.
1704
+ * @param params.walletAccount - The wallet account to sign the transaction with.
1260
1705
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1261
- * @returns An object containing the signed transaction
1706
+ * @returns An object containing the signed transaction.
1707
+ * @throws {NotSolanaProviderError} If the wallet provider is not a Solana provider.
1708
+ * @see signAndSendTransaction
1709
+ * @see signAllTransactions
1262
1710
  * @notInstrumented
1263
1711
  */
1264
1712
  const signTransaction = async ({ walletAccount, transaction }, client = getDefaultClient$1()) => {