@dubsdotapp/expo 0.2.18 → 0.2.20

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/index.mjs CHANGED
@@ -490,7 +490,7 @@ function createSecureStoreStorage() {
490
490
 
491
491
  // src/provider.tsx
492
492
  import { createContext as createContext3, useContext as useContext3, useMemo, useCallback as useCallback12, useState as useState12, useEffect as useEffect7 } from "react";
493
- import { Connection } from "@solana/web3.js";
493
+ import { Connection as Connection2 } from "@solana/web3.js";
494
494
 
495
495
  // src/managed-wallet.tsx
496
496
  import { createContext, useContext, useState, useEffect, useRef, useCallback } from "react";
@@ -831,7 +831,8 @@ var PhantomDeeplinkAdapter = class {
831
831
  console.log(TAG2, "Using app_url:", appUrl);
832
832
  const params = new URLSearchParams({
833
833
  dapp_encryption_public_key: dappPubBase58,
834
- cluster: this.config.cluster || "mainnet-beta",
834
+ // Force mainnet-beta for deeplink session — devnet sessions cause -32603 on signMessage
835
+ cluster: "mainnet-beta",
835
836
  redirect_link: redirectLink,
836
837
  app_url: appUrl
837
838
  });
@@ -906,38 +907,6 @@ var PhantomDeeplinkAdapter = class {
906
907
  console.log(TAG2, "Decrypted signed transaction, length:", data.transaction?.length);
907
908
  return Transaction2.from(bs582.decode(data.transaction));
908
909
  }
909
- async signAndSendTransaction(transaction) {
910
- this.assertConnected();
911
- console.log(TAG2, "signAndSendTransaction() \u2014 serializing transaction");
912
- const serializedTx = bs582.encode(
913
- transaction.serialize({ requireAllSignatures: false, verifySignatures: false })
914
- );
915
- console.log(TAG2, "Transaction serialized, length:", serializedTx.length);
916
- const { nonce, ciphertext } = encryptPayload(
917
- { transaction: serializedTx, session: this._sessionToken },
918
- this._sharedSecret
919
- );
920
- const requestId = nextRequestId();
921
- const redirectLink = this.config.redirectUri;
922
- console.log(TAG2, `signAndSendTransaction() requestId=${requestId}`);
923
- const params = new URLSearchParams({
924
- dapp_encryption_public_key: bs582.encode(this._dappKeyPair.publicKey),
925
- nonce,
926
- payload: ciphertext,
927
- redirect_link: redirectLink
928
- });
929
- const url = `https://phantom.app/ul/v1/signAndSendTransaction?${params.toString()}`;
930
- console.log(TAG2, "Opening Phantom signAndSendTransaction deeplink...");
931
- const response = await this.handler.send(url, requestId, this.timeout);
932
- console.log(TAG2, "Received signAndSendTransaction response");
933
- const data = decryptPayload(
934
- response.params.data,
935
- response.params.nonce,
936
- this._sharedSecret
937
- );
938
- console.log(TAG2, "Transaction sent! Signature:", data.signature);
939
- return data.signature;
940
- }
941
910
  async signMessage(message) {
942
911
  this.assertConnected();
943
912
  console.log(TAG2, "signMessage() \u2014 message length:", message.length);
@@ -1269,12 +1238,23 @@ function ManagedWalletProvider({
1269
1238
  }
1270
1239
  return;
1271
1240
  }
1272
- console.log(TAG3, "Phantom path \u2014 clearing any saved session, will require fresh connect");
1273
- await storage.deleteItem(STORAGE_KEYS.PHANTOM_SESSION).catch(() => {
1274
- });
1275
1241
  try {
1242
+ const savedSession = await storage.getItem(STORAGE_KEYS.PHANTOM_SESSION);
1243
+ if (savedSession && !cancelled) {
1244
+ const session = JSON.parse(savedSession);
1245
+ console.log(TAG3, "Found saved Phantom session, restoring for wallet:", session.walletPublicKey);
1246
+ phantom.restoreSession(session);
1247
+ if (!cancelled) {
1248
+ console.log(TAG3, "Phantom reconnected from saved session");
1249
+ setConnected(true);
1250
+ }
1251
+ } else {
1252
+ console.log(TAG3, "No saved Phantom session");
1253
+ }
1276
1254
  } catch (err) {
1277
- console.log(TAG3, "Unexpected error during Phantom init:", err instanceof Error ? err.message : err);
1255
+ console.log(TAG3, "Phantom session restore failed:", err instanceof Error ? err.message : err);
1256
+ await storage.deleteItem(STORAGE_KEYS.PHANTOM_SESSION).catch(() => {
1257
+ });
1278
1258
  } finally {
1279
1259
  if (!cancelled) {
1280
1260
  console.log(TAG3, "Phantom init complete, marking ready");
@@ -1504,7 +1484,7 @@ import { useState as useState6, useCallback as useCallback6 } from "react";
1504
1484
 
1505
1485
  // src/utils/transaction.ts
1506
1486
  import { Transaction as Transaction3 } from "@solana/web3.js";
1507
- async function signAndSendBase64Transaction(base64Tx, wallet) {
1487
+ async function signAndSendBase64Transaction(base64Tx, wallet, connection) {
1508
1488
  if (!wallet.publicKey) throw new Error("Wallet not connected");
1509
1489
  const binaryStr = atob(base64Tx);
1510
1490
  const bytes = new Uint8Array(binaryStr.length);
@@ -1515,12 +1495,14 @@ async function signAndSendBase64Transaction(base64Tx, wallet) {
1515
1495
  if (wallet.signAndSendTransaction) {
1516
1496
  return wallet.signAndSendTransaction(transaction);
1517
1497
  }
1518
- throw new Error("Wallet does not support signAndSendTransaction");
1498
+ const signed = await wallet.signTransaction(transaction);
1499
+ const signature = await connection.sendRawTransaction(signed.serialize());
1500
+ return signature;
1519
1501
  }
1520
1502
 
1521
1503
  // src/hooks/useCreateGame.ts
1522
1504
  function useCreateGame() {
1523
- const { client, wallet } = useDubs();
1505
+ const { client, wallet, connection } = useDubs();
1524
1506
  const [status, setStatus] = useState6("idle");
1525
1507
  const [error, setError] = useState6(null);
1526
1508
  const [data, setData] = useState6(null);
@@ -1541,7 +1523,8 @@ function useCreateGame() {
1541
1523
  console.log("[useCreateGame] Step 2: Signing and sending...");
1542
1524
  const signature = await signAndSendBase64Transaction(
1543
1525
  createResult.transaction,
1544
- wallet
1526
+ wallet,
1527
+ connection
1545
1528
  );
1546
1529
  console.log("[useCreateGame] Step 2 done. Signature:", signature);
1547
1530
  setStatus("confirming");
@@ -1581,7 +1564,7 @@ function useCreateGame() {
1581
1564
  // src/hooks/useJoinGame.ts
1582
1565
  import { useState as useState7, useCallback as useCallback7 } from "react";
1583
1566
  function useJoinGame() {
1584
- const { client, wallet } = useDubs();
1567
+ const { client, wallet, connection } = useDubs();
1585
1568
  const [status, setStatus] = useState7("idle");
1586
1569
  const [error, setError] = useState7(null);
1587
1570
  const [data, setData] = useState7(null);
@@ -1602,7 +1585,8 @@ function useJoinGame() {
1602
1585
  console.log("[useJoinGame] Step 2: Signing and sending transaction...");
1603
1586
  const signature = await signAndSendBase64Transaction(
1604
1587
  joinResult.transaction,
1605
- wallet
1588
+ wallet,
1589
+ connection
1606
1590
  );
1607
1591
  console.log("[useJoinGame] Step 2 done. Signature:", signature);
1608
1592
  setStatus("confirming");
@@ -1643,7 +1627,7 @@ function useJoinGame() {
1643
1627
  // src/hooks/useClaim.ts
1644
1628
  import { useState as useState8, useCallback as useCallback8 } from "react";
1645
1629
  function useClaim() {
1646
- const { client, wallet } = useDubs();
1630
+ const { client, wallet, connection } = useDubs();
1647
1631
  const [status, setStatus] = useState8("idle");
1648
1632
  const [error, setError] = useState8(null);
1649
1633
  const [data, setData] = useState8(null);
@@ -1664,7 +1648,8 @@ function useClaim() {
1664
1648
  console.log("[useClaim] Step 2: Signing and sending...");
1665
1649
  const signature = await signAndSendBase64Transaction(
1666
1650
  claimResult.transaction,
1667
- wallet
1651
+ wallet,
1652
+ connection
1668
1653
  );
1669
1654
  console.log("[useClaim] Step 2 done. Signature:", signature);
1670
1655
  const explorerUrl = `https://solscan.io/tx/${signature}`;
@@ -1691,7 +1676,7 @@ function useClaim() {
1691
1676
  // src/hooks/useCreateCustomGame.ts
1692
1677
  import { useState as useState9, useCallback as useCallback9 } from "react";
1693
1678
  function useCreateCustomGame() {
1694
- const { client, wallet } = useDubs();
1679
+ const { client, wallet, connection } = useDubs();
1695
1680
  const [status, setStatus] = useState9("idle");
1696
1681
  const [error, setError] = useState9(null);
1697
1682
  const [data, setData] = useState9(null);
@@ -1712,7 +1697,8 @@ function useCreateCustomGame() {
1712
1697
  console.log("[useCreateCustomGame] Step 2: Signing and sending...");
1713
1698
  const signature = await signAndSendBase64Transaction(
1714
1699
  createResult.transaction,
1715
- wallet
1700
+ wallet,
1701
+ connection
1716
1702
  );
1717
1703
  console.log("[useCreateCustomGame] Step 2 done. Signature:", signature);
1718
1704
  setStatus("confirming");
@@ -2401,7 +2387,7 @@ function DubsProvider({
2401
2387
  const rpcUrl = rpcUrlOverride || config.rpcUrl;
2402
2388
  const cluster = config.cluster;
2403
2389
  const client = useMemo(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
2404
- const connection = useMemo(() => new Connection(rpcUrl, { commitment: "confirmed" }), [rpcUrl]);
2390
+ const connection = useMemo(() => new Connection2(rpcUrl, { commitment: "confirmed" }), [rpcUrl]);
2405
2391
  const storage = useMemo(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
2406
2392
  const [uiConfig, setUiConfig] = useState12(null);
2407
2393
  useEffect7(() => {