@dubsdotapp/expo 0.2.12 → 0.2.14

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.d.mts CHANGED
@@ -304,6 +304,7 @@ interface UiConfig {
304
304
  accentColor?: string;
305
305
  appIcon?: string;
306
306
  appName?: string;
307
+ appUrl?: string;
307
308
  tagline?: string;
308
309
  }
309
310
 
package/dist/index.d.ts CHANGED
@@ -304,6 +304,7 @@ interface UiConfig {
304
304
  accentColor?: string;
305
305
  appIcon?: string;
306
306
  appName?: string;
307
+ appUrl?: string;
307
308
  tagline?: string;
308
309
  }
309
310
 
package/dist/index.js CHANGED
@@ -1212,6 +1212,31 @@ var styles = import_react_native3.StyleSheet.create({
1212
1212
  // src/managed-wallet.tsx
1213
1213
  var import_jsx_runtime2 = require("react/jsx-runtime");
1214
1214
  var TAG3 = "[Dubs:ManagedWallet]";
1215
+ var phantomSingleton = null;
1216
+ function getOrCreatePhantomAdapter(config) {
1217
+ if (!phantomSingleton) {
1218
+ console.log(TAG3, "Creating PhantomDeeplinkAdapter (singleton)");
1219
+ phantomSingleton = new PhantomDeeplinkAdapter({
1220
+ redirectUri: config.redirectUri,
1221
+ appUrl: config.appUrl,
1222
+ cluster: config.cluster,
1223
+ onSessionChange: (session) => {
1224
+ if (session) {
1225
+ console.log(TAG3, "Phantom session changed \u2014 saving to storage, wallet:", session.walletPublicKey);
1226
+ config.storage.setItem(STORAGE_KEYS.PHANTOM_SESSION, JSON.stringify(session)).catch((err) => {
1227
+ console.log(TAG3, "Failed to save Phantom session:", err);
1228
+ });
1229
+ } else {
1230
+ console.log(TAG3, "Phantom session cleared \u2014 removing from storage");
1231
+ config.storage.deleteItem(STORAGE_KEYS.PHANTOM_SESSION).catch((err) => {
1232
+ console.log(TAG3, "Failed to delete Phantom session:", err);
1233
+ });
1234
+ }
1235
+ }
1236
+ });
1237
+ }
1238
+ return phantomSingleton;
1239
+ }
1215
1240
  var DisconnectContext = (0, import_react.createContext)(null);
1216
1241
  function useDisconnect() {
1217
1242
  return (0, import_react.useContext)(DisconnectContext);
@@ -1238,24 +1263,11 @@ function ManagedWalletProvider({
1238
1263
  const transactRef = (0, import_react.useRef)(null);
1239
1264
  if (!adapterRef.current) {
1240
1265
  if (usePhantom) {
1241
- console.log(TAG3, "Creating PhantomDeeplinkAdapter");
1242
- adapterRef.current = new PhantomDeeplinkAdapter({
1266
+ adapterRef.current = getOrCreatePhantomAdapter({
1243
1267
  redirectUri,
1244
1268
  appUrl,
1245
1269
  cluster,
1246
- onSessionChange: (session) => {
1247
- if (session) {
1248
- console.log(TAG3, "Phantom session changed \u2014 saving to storage, wallet:", session.walletPublicKey);
1249
- storage.setItem(STORAGE_KEYS.PHANTOM_SESSION, JSON.stringify(session)).catch((err) => {
1250
- console.log(TAG3, "Failed to save Phantom session:", err);
1251
- });
1252
- } else {
1253
- console.log(TAG3, "Phantom session cleared \u2014 removing from storage");
1254
- storage.deleteItem(STORAGE_KEYS.PHANTOM_SESSION).catch((err) => {
1255
- console.log(TAG3, "Failed to delete Phantom session:", err);
1256
- });
1257
- }
1258
- }
1270
+ storage
1259
1271
  });
1260
1272
  } else {
1261
1273
  console.log(TAG3, "Creating MwaWalletAdapter");
@@ -1287,13 +1299,22 @@ function ManagedWalletProvider({
1287
1299
  let cancelled = false;
1288
1300
  (async () => {
1289
1301
  if (usePhantom) {
1302
+ const phantom = adapter;
1303
+ if (phantom.connected) {
1304
+ console.log(TAG3, "Phantom adapter already connected, skipping restore");
1305
+ if (!cancelled) {
1306
+ setConnected(true);
1307
+ setIsReady(true);
1308
+ }
1309
+ return;
1310
+ }
1290
1311
  console.log(TAG3, "Phantom path \u2014 checking for saved session...");
1291
1312
  try {
1292
1313
  const savedJson = await storage.getItem(STORAGE_KEYS.PHANTOM_SESSION);
1293
1314
  if (savedJson && !cancelled) {
1294
1315
  console.log(TAG3, "Found saved Phantom session, restoring...");
1295
1316
  const saved = JSON.parse(savedJson);
1296
- adapter.restoreSession(saved);
1317
+ phantom.restoreSession(saved);
1297
1318
  if (!cancelled) {
1298
1319
  console.log(TAG3, "Session restored, marking connected");
1299
1320
  setConnected(true);
@@ -1365,6 +1386,12 @@ function ManagedWalletProvider({
1365
1386
  const disconnect = (0, import_react.useCallback)(async () => {
1366
1387
  console.log(TAG3, "disconnect() \u2014 clearing all state");
1367
1388
  adapter.disconnect?.();
1389
+ if (usePhantom && phantomSingleton) {
1390
+ console.log(TAG3, "Destroying Phantom singleton");
1391
+ phantomSingleton.destroy();
1392
+ phantomSingleton = null;
1393
+ adapterRef.current = null;
1394
+ }
1368
1395
  await storage.deleteItem(STORAGE_KEYS.MWA_AUTH_TOKEN).catch(() => {
1369
1396
  });
1370
1397
  await storage.deleteItem(STORAGE_KEYS.PHANTOM_SESSION).catch(() => {
@@ -1373,15 +1400,7 @@ function ManagedWalletProvider({
1373
1400
  });
1374
1401
  setConnected(false);
1375
1402
  console.log(TAG3, "disconnect() \u2014 done");
1376
- }, [adapter, storage]);
1377
- (0, import_react.useEffect)(() => {
1378
- return () => {
1379
- if (usePhantom && adapter && "destroy" in adapter) {
1380
- console.log(TAG3, "Unmounting \u2014 destroying Phantom adapter");
1381
- adapter.destroy();
1382
- }
1383
- };
1384
- }, [adapter, usePhantom]);
1403
+ }, [adapter, storage, usePhantom]);
1385
1404
  if (!isReady) {
1386
1405
  console.log(TAG3, "Not ready yet \u2014 rendering null");
1387
1406
  return null;
@@ -2462,7 +2481,7 @@ function DubsProvider({
2462
2481
  appIcon: uiConfig.appIcon,
2463
2482
  tagline: uiConfig.tagline,
2464
2483
  redirectUri,
2465
- appUrl,
2484
+ appUrl: appUrl || uiConfig.appUrl,
2466
2485
  children: (adapter) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2467
2486
  ManagedInner,
2468
2487
  {