@phantom/react-native-sdk 0.1.4 → 0.1.6

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/README.md CHANGED
@@ -99,7 +99,6 @@ export default function App() {
99
99
  redirectUrl: "mywalletapp://phantom-auth-callback",
100
100
  },
101
101
  appName: "My Wallet App", // Optional branding
102
- debug: false, // Optional debug logging
103
102
  }}
104
103
  >
105
104
  <YourAppContent />
@@ -193,7 +192,7 @@ interface PhantomSDKConfig {
193
192
  organizationId: string; // Your Phantom organization ID
194
193
  scheme: string; // Custom URL scheme for your app
195
194
  embeddedWalletType: "user-wallet" | "app-wallet";
196
- addressTypes: AddressType[]; // e.g., [AddressType.solana]
195
+ addressTypes: [AddressType, ...AddressType[]]; // e.g., [AddressType.solana]
197
196
  apiBaseUrl: string; // e.g., "https://api.phantom.app/v1/wallets"
198
197
  solanaProvider: "web3js" | "kit"; // Solana provider to use
199
198
  authOptions?: {
@@ -202,7 +201,7 @@ interface PhantomSDKConfig {
202
201
  };
203
202
  appName?: string; // Optional app name for branding
204
203
  appLogo?: string; // Optional app logo URL for branding
205
- debug?: boolean; // Enable debug logging (optional)
204
+ autoConnect?: boolean; // Auto-connect to existing session on SDK instantiation (default: true)
206
205
  }
207
206
  ```
208
207
 
@@ -421,19 +420,40 @@ adb shell am start -W -a android.intent.action.VIEW -d "myapp://phantom-auth-cal
421
420
  - Verify URL scheme configuration
422
421
  - Check intent filters (Android) or URL schemes (iOS)
423
422
 
424
- ### Debug Mode
423
+ ### Debug Configuration
425
424
 
426
- Enable debug logging in development:
425
+ The React Native SDK supports separate debug configuration for better performance and dynamic control:
427
426
 
428
427
  ```typescript
429
- <PhantomProvider
430
- config={{
431
- ...config,
432
- debug: true // Enable debug logging
433
- }}
434
- >
435
- <App />
436
- </PhantomProvider>
428
+ import { PhantomProvider, type PhantomSDKConfig, type PhantomDebugConfig } from "@phantom/react-native-sdk";
429
+
430
+ function App() {
431
+ // SDK configuration - static, won't change when debug settings change
432
+ const config: PhantomSDKConfig = {
433
+ organizationId: "your-org-id",
434
+ scheme: "mywalletapp",
435
+ // ... other config
436
+ };
437
+
438
+ // Debug configuration - separate to avoid SDK reinstantiation
439
+ const debugConfig: PhantomDebugConfig = {
440
+ enabled: true, // Enable debug logging
441
+ };
442
+
443
+ return (
444
+ <PhantomProvider config={config} debugConfig={debugConfig}>
445
+ <App />
446
+ </PhantomProvider>
447
+ );
448
+ }
449
+ ```
450
+
451
+ **PhantomDebugConfig Interface:**
452
+
453
+ ```typescript
454
+ interface PhantomDebugConfig {
455
+ enabled?: boolean; // Enable debug logging (default: false)
456
+ }
437
457
  ```
438
458
 
439
459
  ## Support
package/dist/index.d.ts CHANGED
@@ -6,11 +6,15 @@ export { ConnectResult, SignAndSendTransactionParams, SignMessageParams, SignMes
6
6
  export { AddressType } from '@phantom/client';
7
7
  export { NetworkId } from '@phantom/constants';
8
8
 
9
+ interface PhantomDebugConfig {
10
+ /** Enable debug logging */
11
+ enabled?: boolean;
12
+ }
9
13
  interface PhantomSDKConfig extends EmbeddedProviderConfig {
10
14
  /** Custom URL scheme for your app (e.g., "myapp") */
11
15
  scheme: string;
12
- /** Enable debug logging */
13
- debug?: boolean;
16
+ /** Enable auto-connect to existing sessions (default: true) */
17
+ autoConnect?: boolean;
14
18
  }
15
19
  interface ConnectOptions {
16
20
  /** OAuth provider to use */
@@ -22,19 +26,20 @@ interface ConnectOptions {
22
26
  }
23
27
 
24
28
  interface PhantomContextValue {
25
- sdk: EmbeddedProvider;
29
+ sdk: EmbeddedProvider | null;
26
30
  isConnected: boolean;
31
+ isConnecting: boolean;
32
+ connectError: Error | null;
27
33
  addresses: WalletAddress[];
28
34
  walletId: string | null;
29
- error: Error | null;
30
- updateConnectionState: () => void;
31
35
  setWalletId: (walletId: string | null) => void;
32
36
  }
33
37
  interface PhantomProviderProps {
34
38
  children: ReactNode;
35
39
  config: PhantomSDKConfig;
40
+ debugConfig?: PhantomDebugConfig;
36
41
  }
37
- declare function PhantomProvider({ children, config }: PhantomProviderProps): react_jsx_runtime.JSX.Element;
42
+ declare function PhantomProvider({ children, config, debugConfig }: PhantomProviderProps): react_jsx_runtime.JSX.Element;
38
43
  /**
39
44
  * Hook to access the Phantom context
40
45
  * Must be used within a PhantomProvider
@@ -57,7 +62,6 @@ declare function useAccounts(): {
57
62
  addresses: _phantom_embedded_provider_core.WalletAddress[];
58
63
  isConnected: boolean;
59
64
  walletId: string | null;
60
- error: Error | null;
61
65
  };
62
66
 
63
67
  declare function useSignMessage(): {
@@ -72,4 +76,4 @@ declare function useSignAndSendTransaction(): {
72
76
  error: Error | null;
73
77
  };
74
78
 
75
- export { ConnectOptions, PhantomProvider, PhantomSDKConfig, useAccounts, useConnect, useDisconnect, usePhantom, useSignAndSendTransaction, useSignMessage };
79
+ export { ConnectOptions, PhantomDebugConfig, PhantomProvider, PhantomSDKConfig, useAccounts, useConnect, useDisconnect, usePhantom, useSignAndSendTransaction, useSignMessage };
package/dist/index.js CHANGED
@@ -418,30 +418,31 @@ var ReactNativeStamper = class {
418
418
  var import_react_native2 = require("react-native");
419
419
  var import_jsx_runtime = require("react/jsx-runtime");
420
420
  var PhantomContext = (0, import_react.createContext)(void 0);
421
- function PhantomProvider({ children, config }) {
422
- const sdk = (0, import_react.useMemo)(() => {
421
+ function PhantomProvider({ children, config, debugConfig }) {
422
+ const [isConnected, setIsConnected] = (0, import_react.useState)(false);
423
+ const [isConnecting, setIsConnecting] = (0, import_react.useState)(false);
424
+ const [connectError, setConnectError] = (0, import_react.useState)(null);
425
+ const [addresses, setAddresses] = (0, import_react.useState)([]);
426
+ const [walletId, setWalletId] = (0, import_react.useState)(null);
427
+ const [sdk, setSdk] = (0, import_react.useState)(null);
428
+ const memoizedConfig = (0, import_react.useMemo)(() => {
423
429
  const redirectUrl = config.authOptions?.redirectUrl || `${config.scheme}://phantom-auth-callback`;
424
- const embeddedConfig = {
425
- apiBaseUrl: config.apiBaseUrl,
426
- organizationId: config.organizationId,
430
+ return {
431
+ ...config,
427
432
  authOptions: {
428
- ...config.authOptions,
433
+ ...config.authOptions || {},
429
434
  redirectUrl
430
- },
431
- embeddedWalletType: config.embeddedWalletType,
432
- addressTypes: config.addressTypes,
433
- solanaProvider: config.solanaProvider || "web3js",
434
- appName: config.appName,
435
- appLogo: config.appLogo
436
- // Optional app logo URL
435
+ }
437
436
  };
437
+ }, [config]);
438
+ (0, import_react.useEffect)(() => {
438
439
  const storage = new ExpoSecureStorage();
439
440
  const authProvider = new ExpoAuthProvider();
440
441
  const urlParamsAccessor = new ExpoURLParamsAccessor();
441
- const logger = new ExpoLogger(config.debug);
442
+ const logger = new ExpoLogger(debugConfig?.enabled || false);
442
443
  const stamper = new ReactNativeStamper({
443
- keyPrefix: `phantom-rn-${config.organizationId}`,
444
- organizationId: config.organizationId
444
+ keyPrefix: `phantom-rn-${memoizedConfig.organizationId}`,
445
+ organizationId: memoizedConfig.organizationId
445
446
  });
446
447
  const platform = {
447
448
  storage,
@@ -450,56 +451,74 @@ function PhantomProvider({ children, config }) {
450
451
  stamper,
451
452
  name: `${import_react_native2.Platform.OS}-${import_react_native2.Platform.Version}`
452
453
  };
453
- return new import_embedded_provider_core.EmbeddedProvider(embeddedConfig, platform, logger);
454
- }, [config]);
455
- const [isConnected, setIsConnected] = (0, import_react.useState)(false);
456
- const [addresses, setAddresses] = (0, import_react.useState)([]);
457
- const [walletId, setWalletId] = (0, import_react.useState)(null);
458
- const [error, setError] = (0, import_react.useState)(null);
459
- const updateConnectionState = (0, import_react.useCallback)(() => {
460
- try {
461
- const connected = sdk.isConnected();
462
- setIsConnected(connected);
463
- if (connected) {
464
- const addrs = sdk.getAddresses();
465
- setAddresses(addrs);
466
- } else {
467
- setAddresses([]);
468
- setWalletId(null);
469
- }
470
- } catch (err) {
471
- console.error("[PhantomProvider] Error updating connection state", err);
472
- setError(err);
454
+ const sdkInstance = new import_embedded_provider_core.EmbeddedProvider(memoizedConfig, platform, logger);
455
+ const handleConnectStart = () => {
456
+ setIsConnecting(true);
457
+ setConnectError(null);
458
+ };
459
+ const handleConnect = async () => {
473
460
  try {
474
- sdk.disconnect();
475
- setIsConnected(false);
476
- setAddresses([]);
477
- setWalletId(null);
478
- } catch (disconnectErr) {
479
- console.error("[PhantomProvider] Error disconnecting after error", disconnectErr);
461
+ setIsConnected(true);
462
+ setIsConnecting(false);
463
+ const addrs = await sdkInstance.getAddresses();
464
+ setAddresses(addrs);
465
+ } catch (err) {
466
+ console.error("Error connecting:", err);
467
+ try {
468
+ await sdkInstance.disconnect();
469
+ } catch (err2) {
470
+ console.error("Error disconnecting:", err2);
471
+ }
480
472
  }
481
- }
482
- }, [sdk]);
473
+ };
474
+ const handleConnectError = (errorData) => {
475
+ setIsConnecting(false);
476
+ setConnectError(new Error(errorData.error || "Connection failed"));
477
+ };
478
+ const handleDisconnect = () => {
479
+ setIsConnected(false);
480
+ setIsConnecting(false);
481
+ setConnectError(null);
482
+ setAddresses([]);
483
+ setWalletId(null);
484
+ };
485
+ sdkInstance.on("connect_start", handleConnectStart);
486
+ sdkInstance.on("connect", handleConnect);
487
+ sdkInstance.on("connect_error", handleConnectError);
488
+ sdkInstance.on("disconnect", handleDisconnect);
489
+ setSdk(sdkInstance);
490
+ return () => {
491
+ sdkInstance.off("connect_start", handleConnectStart);
492
+ sdkInstance.off("connect", handleConnect);
493
+ sdkInstance.off("connect_error", handleConnectError);
494
+ sdkInstance.off("disconnect", handleDisconnect);
495
+ };
496
+ }, [memoizedConfig, debugConfig]);
483
497
  (0, import_react.useEffect)(() => {
484
- updateConnectionState();
485
- }, [updateConnectionState]);
498
+ if (!sdk)
499
+ return;
500
+ if (config.autoConnect !== false) {
501
+ sdk.autoConnect().catch(() => {
502
+ });
503
+ }
504
+ }, [sdk, config.autoConnect]);
486
505
  const value = (0, import_react.useMemo)(
487
506
  () => ({
488
507
  sdk,
489
508
  isConnected,
509
+ isConnecting,
510
+ connectError,
490
511
  addresses,
491
512
  walletId,
492
- error,
493
- updateConnectionState,
494
513
  setWalletId
495
514
  }),
496
515
  [
497
516
  sdk,
498
517
  isConnected,
518
+ isConnecting,
519
+ connectError,
499
520
  addresses,
500
521
  walletId,
501
- error,
502
- updateConnectionState,
503
522
  setWalletId
504
523
  ]
505
524
  );
@@ -516,46 +535,36 @@ function usePhantom() {
516
535
  // src/hooks/useConnect.ts
517
536
  var import_react2 = require("react");
518
537
  function useConnect() {
519
- const { sdk, updateConnectionState, setWalletId } = usePhantom();
520
- const [isConnecting, setIsConnecting] = (0, import_react2.useState)(false);
521
- const [error, setError] = (0, import_react2.useState)(null);
538
+ const { sdk, isConnecting, connectError, setWalletId } = usePhantom();
522
539
  const connect = (0, import_react2.useCallback)(
523
540
  async (options) => {
524
541
  if (!sdk) {
525
542
  throw new Error("SDK not initialized");
526
543
  }
527
- setIsConnecting(true);
528
- setError(null);
529
544
  try {
530
545
  const result = await sdk.connect(options);
531
- if (result.status === "completed") {
532
- if (result.walletId) {
533
- setWalletId(result.walletId);
534
- }
535
- updateConnectionState();
546
+ if (result.status === "completed" && result.walletId) {
547
+ setWalletId(result.walletId);
536
548
  }
537
549
  return result;
538
550
  } catch (err) {
539
- const error2 = err;
540
- setError(error2);
541
- throw error2;
542
- } finally {
543
- setIsConnecting(false);
551
+ const error = err;
552
+ throw error;
544
553
  }
545
554
  },
546
- [sdk, updateConnectionState, setWalletId]
555
+ [sdk, setWalletId]
547
556
  );
548
557
  return {
549
558
  connect,
550
559
  isConnecting,
551
- error
560
+ error: connectError
552
561
  };
553
562
  }
554
563
 
555
564
  // src/hooks/useDisconnect.ts
556
565
  var import_react3 = require("react");
557
566
  function useDisconnect() {
558
- const { sdk, updateConnectionState } = usePhantom();
567
+ const { sdk } = usePhantom();
559
568
  const [isDisconnecting, setIsDisconnecting] = (0, import_react3.useState)(false);
560
569
  const [error, setError] = (0, import_react3.useState)(null);
561
570
  const disconnect = (0, import_react3.useCallback)(async () => {
@@ -566,7 +575,6 @@ function useDisconnect() {
566
575
  setError(null);
567
576
  try {
568
577
  await sdk.disconnect();
569
- updateConnectionState();
570
578
  } catch (err) {
571
579
  const error2 = err;
572
580
  setError(error2);
@@ -574,7 +582,7 @@ function useDisconnect() {
574
582
  } finally {
575
583
  setIsDisconnecting(false);
576
584
  }
577
- }, [sdk, updateConnectionState]);
585
+ }, [sdk]);
578
586
  return {
579
587
  disconnect,
580
588
  isDisconnecting,
@@ -584,12 +592,11 @@ function useDisconnect() {
584
592
 
585
593
  // src/hooks/useAccounts.ts
586
594
  function useAccounts() {
587
- const { addresses, isConnected, walletId, error } = usePhantom();
595
+ const { addresses, isConnected, walletId } = usePhantom();
588
596
  return {
589
597
  addresses,
590
598
  isConnected,
591
- walletId,
592
- error
599
+ walletId
593
600
  };
594
601
  }
595
602
 
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/PhantomProvider.tsx
2
- import { createContext, useContext, useState, useEffect, useCallback, useMemo } from "react";
2
+ import { createContext, useContext, useState, useEffect, useMemo } from "react";
3
3
  import { EmbeddedProvider } from "@phantom/embedded-provider-core";
4
4
 
5
5
  // src/providers/embedded/storage.ts
@@ -374,30 +374,31 @@ var ReactNativeStamper = class {
374
374
  import { Platform } from "react-native";
375
375
  import { jsx } from "react/jsx-runtime";
376
376
  var PhantomContext = createContext(void 0);
377
- function PhantomProvider({ children, config }) {
378
- const sdk = useMemo(() => {
377
+ function PhantomProvider({ children, config, debugConfig }) {
378
+ const [isConnected, setIsConnected] = useState(false);
379
+ const [isConnecting, setIsConnecting] = useState(false);
380
+ const [connectError, setConnectError] = useState(null);
381
+ const [addresses, setAddresses] = useState([]);
382
+ const [walletId, setWalletId] = useState(null);
383
+ const [sdk, setSdk] = useState(null);
384
+ const memoizedConfig = useMemo(() => {
379
385
  const redirectUrl = config.authOptions?.redirectUrl || `${config.scheme}://phantom-auth-callback`;
380
- const embeddedConfig = {
381
- apiBaseUrl: config.apiBaseUrl,
382
- organizationId: config.organizationId,
386
+ return {
387
+ ...config,
383
388
  authOptions: {
384
- ...config.authOptions,
389
+ ...config.authOptions || {},
385
390
  redirectUrl
386
- },
387
- embeddedWalletType: config.embeddedWalletType,
388
- addressTypes: config.addressTypes,
389
- solanaProvider: config.solanaProvider || "web3js",
390
- appName: config.appName,
391
- appLogo: config.appLogo
392
- // Optional app logo URL
391
+ }
393
392
  };
393
+ }, [config]);
394
+ useEffect(() => {
394
395
  const storage = new ExpoSecureStorage();
395
396
  const authProvider = new ExpoAuthProvider();
396
397
  const urlParamsAccessor = new ExpoURLParamsAccessor();
397
- const logger = new ExpoLogger(config.debug);
398
+ const logger = new ExpoLogger(debugConfig?.enabled || false);
398
399
  const stamper = new ReactNativeStamper({
399
- keyPrefix: `phantom-rn-${config.organizationId}`,
400
- organizationId: config.organizationId
400
+ keyPrefix: `phantom-rn-${memoizedConfig.organizationId}`,
401
+ organizationId: memoizedConfig.organizationId
401
402
  });
402
403
  const platform = {
403
404
  storage,
@@ -406,56 +407,74 @@ function PhantomProvider({ children, config }) {
406
407
  stamper,
407
408
  name: `${Platform.OS}-${Platform.Version}`
408
409
  };
409
- return new EmbeddedProvider(embeddedConfig, platform, logger);
410
- }, [config]);
411
- const [isConnected, setIsConnected] = useState(false);
412
- const [addresses, setAddresses] = useState([]);
413
- const [walletId, setWalletId] = useState(null);
414
- const [error, setError] = useState(null);
415
- const updateConnectionState = useCallback(() => {
416
- try {
417
- const connected = sdk.isConnected();
418
- setIsConnected(connected);
419
- if (connected) {
420
- const addrs = sdk.getAddresses();
421
- setAddresses(addrs);
422
- } else {
423
- setAddresses([]);
424
- setWalletId(null);
425
- }
426
- } catch (err) {
427
- console.error("[PhantomProvider] Error updating connection state", err);
428
- setError(err);
410
+ const sdkInstance = new EmbeddedProvider(memoizedConfig, platform, logger);
411
+ const handleConnectStart = () => {
412
+ setIsConnecting(true);
413
+ setConnectError(null);
414
+ };
415
+ const handleConnect = async () => {
429
416
  try {
430
- sdk.disconnect();
431
- setIsConnected(false);
432
- setAddresses([]);
433
- setWalletId(null);
434
- } catch (disconnectErr) {
435
- console.error("[PhantomProvider] Error disconnecting after error", disconnectErr);
417
+ setIsConnected(true);
418
+ setIsConnecting(false);
419
+ const addrs = await sdkInstance.getAddresses();
420
+ setAddresses(addrs);
421
+ } catch (err) {
422
+ console.error("Error connecting:", err);
423
+ try {
424
+ await sdkInstance.disconnect();
425
+ } catch (err2) {
426
+ console.error("Error disconnecting:", err2);
427
+ }
436
428
  }
437
- }
438
- }, [sdk]);
429
+ };
430
+ const handleConnectError = (errorData) => {
431
+ setIsConnecting(false);
432
+ setConnectError(new Error(errorData.error || "Connection failed"));
433
+ };
434
+ const handleDisconnect = () => {
435
+ setIsConnected(false);
436
+ setIsConnecting(false);
437
+ setConnectError(null);
438
+ setAddresses([]);
439
+ setWalletId(null);
440
+ };
441
+ sdkInstance.on("connect_start", handleConnectStart);
442
+ sdkInstance.on("connect", handleConnect);
443
+ sdkInstance.on("connect_error", handleConnectError);
444
+ sdkInstance.on("disconnect", handleDisconnect);
445
+ setSdk(sdkInstance);
446
+ return () => {
447
+ sdkInstance.off("connect_start", handleConnectStart);
448
+ sdkInstance.off("connect", handleConnect);
449
+ sdkInstance.off("connect_error", handleConnectError);
450
+ sdkInstance.off("disconnect", handleDisconnect);
451
+ };
452
+ }, [memoizedConfig, debugConfig]);
439
453
  useEffect(() => {
440
- updateConnectionState();
441
- }, [updateConnectionState]);
454
+ if (!sdk)
455
+ return;
456
+ if (config.autoConnect !== false) {
457
+ sdk.autoConnect().catch(() => {
458
+ });
459
+ }
460
+ }, [sdk, config.autoConnect]);
442
461
  const value = useMemo(
443
462
  () => ({
444
463
  sdk,
445
464
  isConnected,
465
+ isConnecting,
466
+ connectError,
446
467
  addresses,
447
468
  walletId,
448
- error,
449
- updateConnectionState,
450
469
  setWalletId
451
470
  }),
452
471
  [
453
472
  sdk,
454
473
  isConnected,
474
+ isConnecting,
475
+ connectError,
455
476
  addresses,
456
477
  walletId,
457
- error,
458
- updateConnectionState,
459
478
  setWalletId
460
479
  ]
461
480
  );
@@ -470,51 +489,41 @@ function usePhantom() {
470
489
  }
471
490
 
472
491
  // src/hooks/useConnect.ts
473
- import { useState as useState2, useCallback as useCallback2 } from "react";
492
+ import { useCallback } from "react";
474
493
  function useConnect() {
475
- const { sdk, updateConnectionState, setWalletId } = usePhantom();
476
- const [isConnecting, setIsConnecting] = useState2(false);
477
- const [error, setError] = useState2(null);
478
- const connect = useCallback2(
494
+ const { sdk, isConnecting, connectError, setWalletId } = usePhantom();
495
+ const connect = useCallback(
479
496
  async (options) => {
480
497
  if (!sdk) {
481
498
  throw new Error("SDK not initialized");
482
499
  }
483
- setIsConnecting(true);
484
- setError(null);
485
500
  try {
486
501
  const result = await sdk.connect(options);
487
- if (result.status === "completed") {
488
- if (result.walletId) {
489
- setWalletId(result.walletId);
490
- }
491
- updateConnectionState();
502
+ if (result.status === "completed" && result.walletId) {
503
+ setWalletId(result.walletId);
492
504
  }
493
505
  return result;
494
506
  } catch (err) {
495
- const error2 = err;
496
- setError(error2);
497
- throw error2;
498
- } finally {
499
- setIsConnecting(false);
507
+ const error = err;
508
+ throw error;
500
509
  }
501
510
  },
502
- [sdk, updateConnectionState, setWalletId]
511
+ [sdk, setWalletId]
503
512
  );
504
513
  return {
505
514
  connect,
506
515
  isConnecting,
507
- error
516
+ error: connectError
508
517
  };
509
518
  }
510
519
 
511
520
  // src/hooks/useDisconnect.ts
512
- import { useState as useState3, useCallback as useCallback3 } from "react";
521
+ import { useState as useState2, useCallback as useCallback2 } from "react";
513
522
  function useDisconnect() {
514
- const { sdk, updateConnectionState } = usePhantom();
515
- const [isDisconnecting, setIsDisconnecting] = useState3(false);
516
- const [error, setError] = useState3(null);
517
- const disconnect = useCallback3(async () => {
523
+ const { sdk } = usePhantom();
524
+ const [isDisconnecting, setIsDisconnecting] = useState2(false);
525
+ const [error, setError] = useState2(null);
526
+ const disconnect = useCallback2(async () => {
518
527
  if (!sdk) {
519
528
  throw new Error("SDK not initialized");
520
529
  }
@@ -522,7 +531,6 @@ function useDisconnect() {
522
531
  setError(null);
523
532
  try {
524
533
  await sdk.disconnect();
525
- updateConnectionState();
526
534
  } catch (err) {
527
535
  const error2 = err;
528
536
  setError(error2);
@@ -530,7 +538,7 @@ function useDisconnect() {
530
538
  } finally {
531
539
  setIsDisconnecting(false);
532
540
  }
533
- }, [sdk, updateConnectionState]);
541
+ }, [sdk]);
534
542
  return {
535
543
  disconnect,
536
544
  isDisconnecting,
@@ -540,22 +548,21 @@ function useDisconnect() {
540
548
 
541
549
  // src/hooks/useAccounts.ts
542
550
  function useAccounts() {
543
- const { addresses, isConnected, walletId, error } = usePhantom();
551
+ const { addresses, isConnected, walletId } = usePhantom();
544
552
  return {
545
553
  addresses,
546
554
  isConnected,
547
- walletId,
548
- error
555
+ walletId
549
556
  };
550
557
  }
551
558
 
552
559
  // src/hooks/useSignMessage.ts
553
- import { useState as useState4, useCallback as useCallback4 } from "react";
560
+ import { useState as useState3, useCallback as useCallback3 } from "react";
554
561
  function useSignMessage() {
555
562
  const { sdk } = usePhantom();
556
- const [isSigning, setIsSigning] = useState4(false);
557
- const [error, setError] = useState4(null);
558
- const signMessage = useCallback4(
563
+ const [isSigning, setIsSigning] = useState3(false);
564
+ const [error, setError] = useState3(null);
565
+ const signMessage = useCallback3(
559
566
  async (params) => {
560
567
  if (!sdk) {
561
568
  throw new Error("SDK not initialized");
@@ -583,12 +590,12 @@ function useSignMessage() {
583
590
  }
584
591
 
585
592
  // src/hooks/useSignAndSendTransaction.ts
586
- import { useState as useState5, useCallback as useCallback5 } from "react";
593
+ import { useState as useState4, useCallback as useCallback4 } from "react";
587
594
  function useSignAndSendTransaction() {
588
595
  const { sdk } = usePhantom();
589
- const [isSigning, setIsSigning] = useState5(false);
590
- const [error, setError] = useState5(null);
591
- const signAndSendTransaction = useCallback5(
596
+ const [isSigning, setIsSigning] = useState4(false);
597
+ const [error, setError] = useState4(null);
598
+ const signAndSendTransaction = useCallback4(
592
599
  async (params) => {
593
600
  if (!sdk) {
594
601
  throw new Error("SDK not initialized");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phantom/react-native-sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Phantom Wallet SDK for React Native and Expo applications",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -50,7 +50,7 @@
50
50
  "@phantom/client": "^0.1.8",
51
51
  "@phantom/constants": "^0.0.3",
52
52
  "@phantom/crypto": "^0.1.2",
53
- "@phantom/embedded-provider-core": "^0.1.5",
53
+ "@phantom/embedded-provider-core": "^0.1.7",
54
54
  "@phantom/sdk-types": "^0.1.4",
55
55
  "@types/bs58": "^5.0.0",
56
56
  "bs58": "^6.0.0",