@tuwaio/satellite-react 0.1.2 → 0.2.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.
package/README.md CHANGED
@@ -29,6 +29,7 @@ Built on top of `@tuwaio/satellite-core`, this package offers a seamless develop
29
29
  ## 💾 Installation
30
30
 
31
31
  ### Requirements
32
+
32
33
  - React 19+
33
34
  - Node.js 20+
34
35
  - TypeScript 5.9+
@@ -43,43 +44,34 @@ npm install @tuwaio/satellite-react @tuwaio/satellite-core @tuwaio/orbit-core @w
43
44
  # Using yarn
44
45
  yarn add @tuwaio/satellite-react @tuwaio/satellite-core @tuwaio/orbit-core @wagmi/core @wallet-standard/react gill react immer zustand
45
46
  ```
47
+
46
48
  ---
47
49
 
48
50
  ## 🚀 Quick Start
49
51
 
50
52
  ### Basic Setup
53
+
51
54
  ```tsx
52
55
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
53
- import { satelliteEVMAdapter, createDefaultTransports, initAllConnectors } from '@tuwaio/satellite-evm';
56
+ import { satelliteEVMAdapter, createDefaultTransports } from '@tuwaio/satellite-evm';
54
57
  import { SatelliteConnectProvider } from '@tuwaio/satellite-react';
55
- import { EVMWalletsWatcher } from '@tuwaio/satellite-react/evm';
58
+ import { EVMConnectorsWatcher } from '@tuwaio/satellite-react/evm';
56
59
  import { SolanaWalletsWatcher } from '@tuwaio/satellite-react/solana';
57
60
  import { satelliteSolanaAdapter } from '@tuwaio/satellite-solana';
58
61
  import { WagmiProvider } from 'wagmi';
59
62
  import { ReactNode } from 'react';
60
- import { createConfig, http } from '@wagmi/core';
63
+ import { createConfig } from '@wagmi/core';
64
+ import { injected } from '@wagmi/connectors';
61
65
  import { mainnet, sepolia } from 'viem/chains';
62
66
  import type { Chain } from 'viem/chains';
63
67
 
64
- export const appConfig = {
65
- appName: 'Satellite EVM Test App',
66
- // Ensure you have WalletConnect Project ID in your environment variables
67
- projectId: process.env.NEXT_PUBLIC_WALLET_PROJECT_ID ?? 'YOUR_OWN_PROJECT_ID',
68
- };
69
-
70
68
  export const appEVMChains = [
71
69
  mainnet,
72
70
  sepolia,
73
71
  ] as readonly [Chain, ...Chain[]];
74
72
 
75
73
  export const wagmiConfig = createConfig({
76
- connectors: initAllConnectors({
77
- ...appConfig,
78
- // Optional: Add app details for WalletConnect modal
79
- description: 'My awesome dApp',
80
- appUrl: '[https://my-dapp.com](https://my-dapp.com)',
81
- appIcons: ['[https://my-dapp.com/icon.png](https://my-dapp.com/icon.png)'],
82
- }),
74
+ connectors: [injected()],
83
75
  transports: createDefaultTransports(appEVMChains), // Automatically creates http transports
84
76
  chains: appEVMChains,
85
77
  ssr: true, // Enable SSR support if needed (e.g., in Next.js)
@@ -100,7 +92,7 @@ export function Providers({ children }: { children: ReactNode }) {
100
92
  adapter={[satelliteEVMAdapter(wagmiConfig), satelliteSolanaAdapter({ rpcUrls: solanaRPCUrls })]}
101
93
  autoConnect={true}
102
94
  >
103
- <EVMWalletsWatcher wagmiConfig={wagmiConfig} />
95
+ <EVMConnectorsWatcher wagmiConfig={wagmiConfig} />
104
96
  <SolanaWalletsWatcher />
105
97
  {children}
106
98
  </SatelliteConnectProvider>
@@ -111,6 +103,7 @@ export function Providers({ children }: { children: ReactNode }) {
111
103
  ```
112
104
 
113
105
  ### Using Hooks
106
+
114
107
  ```tsx
115
108
  import { useSatelliteConnectStore } from '@tuwaio/satellite-react';
116
109
 
@@ -119,6 +112,7 @@ function ExampleGettingActiveWalletFromStore() {
119
112
  return <div>{activeWallet?.address}</div>
120
113
  }
121
114
  ```
115
+
122
116
  ---
123
117
 
124
118
  ### Core Components
@@ -129,7 +123,7 @@ function ExampleGettingActiveWalletFromStore() {
129
123
 
130
124
  2. **Provider Components**
131
125
  - `SatelliteConnectProvider`: Global context provider with all necessary configurations
132
- - `EVMWalletsWatcher`: EVM wallet connection state management
126
+ - `EVMConnectorsWatcher`: EVM wallet connection state management
133
127
  - `SolanaWalletsWatcher`: Solana wallet connection state management
134
128
 
135
129
  ---
@@ -1,2 +1,2 @@
1
- 'use strict';var react=require('react'),zustand=require('zustand'),satelliteCore=require('@tuwaio/satellite-core'),jsxRuntime=require('react/jsx-runtime');var r=react.createContext(null),A=e=>{let t=react.useContext(r);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return zustand.useStore(t,e)};var i=({initializeAutoConnect:e,onError:t})=>{react.useEffect(()=>{(async()=>{try{await e();}catch(o){(t??(l=>console.error("Failed to initialize auto connect:",l)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({...n}),[]);return react.useEffect(()=>{o.getState().disconnectAll();},[]),i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsxRuntime.jsx(r.Provider,{value:o,children:e})}exports.a=r;exports.b=A;exports.c=i;exports.d=b;//# sourceMappingURL=chunk-YC7F3NGW.cjs.map
2
- //# sourceMappingURL=chunk-YC7F3NGW.cjs.map
1
+ 'use strict';var react=require('react'),zustand=require('zustand'),satelliteCore=require('@tuwaio/satellite-core'),jsxRuntime=require('react/jsx-runtime');var r=react.createContext(null),P=e=>{let t=react.useContext(r);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return zustand.useStore(t,e)};var i=({initializeAutoConnect:e,onError:t})=>{react.useEffect(()=>{(async()=>{try{await e();}catch(o){(t??(c=>console.error("Failed to initialize auto connect:",c)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({...n}),[]);return i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsxRuntime.jsx(r.Provider,{value:o,children:e})}exports.a=r;exports.b=P;exports.c=i;exports.d=b;//# sourceMappingURL=chunk-23IZMVDP.cjs.map
2
+ //# sourceMappingURL=chunk-23IZMVDP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/satelliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx"],"mappings":"2JAUO,IAAMA,CAAAA,CAAwBC,mBAAAA,CACnC,IACF,CAAA,CAqBaC,CAAAA,CACXC,CAAAA,EACM,CAEN,IAAMC,CAAAA,CAAQC,gBAAAA,CAAWL,CAAqB,EAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,gBAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECLO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,eAAAA,CAAU,IAAM,CAAA,CACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,CAAA,CAEOF,CAAAA,GAAaG,CAAAA,EAAa,QAAQ,KAAA,CAAM,oCAAA,CAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,QAAA,CAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,EAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,aAAAA,CAAQ,IACbC,yCAAAA,CAAmD,CACxD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAEL,OAAAT,CAAAA,CAAyB,CACvB,sBAAuB,IAAMH,CAAAA,CAAM,QAAA,EAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,cAAAA,CAACnB,CAAAA,CAAsB,QAAA,CAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-23IZMVDP.cjs","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connection, Connector } from '../types';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore<Connector, Connection>> | null>(\n null,\n);\n\n/**\n * Custom hook for accessing the Satellite Connect store state\n *\n * @remarks\n * This hook provides type-safe access to the Satellite store state and must be used\n * within a component that is wrapped by SatelliteConnectProvider.\n *\n * @typeParam T - The type of the selected state slice\n * @param selector - Function that selects a slice of the store state\n * @returns Selected state slice\n *\n * @throws Error if used outside of SatelliteConnectProvider\n *\n * @example\n * ```tsx\n * // Get the active connection\n * const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);\n * ```\n */\nexport const useSatelliteConnectStore = <T>(\n selector: (state: ISatelliteConnectStore<Connector, Connection>) => T,\n): T => {\n // Get store instance from context\n const store = useContext(SatelliteStoreContext);\n\n // Ensure hook is used within provider\n if (!store) {\n throw new Error('useSatelliteConnectStore must be used within a SatelliteConnectProvider');\n }\n\n // Return selected state using Zustand's useStore\n return useStore(store, selector);\n};\n","import { useEffect } from 'react';\n\n/**\n * Props for the useInitializeAutoConnect hook.\n */\ninterface InitializeAutoConnectProps {\n /** Function to initialize auto connect logic */\n initializeAutoConnect: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing connector auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected connector) when a component mounts.\n * It provides default error handling with console.error if no custom handler is provided.\n * The initialization runs only once when the component mounts.\n *\n * @param props - Hook configuration\n * @param props.initializeAutoConnect - Async function that executes the auto-connect logic\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect\n * });\n *\n * // With custom error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect,\n * onError: (error) => {\n * toast.error(`Failed to auto-connect: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAutoConnect = ({ initializeAutoConnect, onError }: InitializeAutoConnectProps): void => {\n useEffect(() => {\n const initializeAutoConnectLocal = async () => {\n try {\n await initializeAutoConnect();\n } catch (error) {\n // Use provided error handler or fallback to default console.error\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize auto connect:', e));\n errorHandler(error as Error);\n }\n };\n // Initialize auto connect when component mounts\n initializeAutoConnectLocal();\n }, []); // Empty dependency array ensures single execution\n};\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satelliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connection, Connector } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used connector */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages connector connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles connector connections, state management, and automatic reconnection functionality.\n * The store is memoized to ensure stable reference across renders.\n *\n * @param props - Component properties including store parameters and children\n * @param props.children - Child components that will have access to the store\n * @param props.autoConnect - Optional flag to enable automatic connector reconnection\n * @param props.adapter - Blockchain adapter(s) for connector interactions\n * @param props.callbackAfterConnected - Optional callback for successful connections\n *\n * @example\n * ```tsx\n * // Basic usage with single adapter\n * <SatelliteConnectProvider adapter={solanaAdapter}>\n * <App />\n * </SatelliteConnectProvider>\n *\n * // With auto-connect and multiple adapters\n * <SatelliteConnectProvider\n * adapter={[solanaAdapter, evmAdapter]}\n * autoConnect={true}\n * callbackAfterConnected={(wallet) => {\n * console.log('Wallet connected:', wallet.address);\n * }}\n * >\n * <App />\n * </SatelliteConnectProvider>\n * ```\n */\nexport function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps) {\n // Create and memoize the store instance\n const store = useMemo(() => {\n return createSatelliteConnectStore<Connector, Connection>({\n ...parameters,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Empty dependency array as store should be created only once\n\n useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import {createContext,useContext,useEffect,useMemo}from'react';import {useStore}from'zustand';import {createSatelliteConnectStore}from'@tuwaio/satellite-core';import {jsx}from'react/jsx-runtime';var r=createContext(null),P=e=>{let t=useContext(r);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return useStore(t,e)};var i=({initializeAutoConnect:e,onError:t})=>{useEffect(()=>{(async()=>{try{await e();}catch(o){(t??(c=>console.error("Failed to initialize auto connect:",c)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=useMemo(()=>createSatelliteConnectStore({...n}),[]);return i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsx(r.Provider,{value:o,children:e})}export{r as a,P as b,i as c,b as d};//# sourceMappingURL=chunk-4RWO4WUN.js.map
2
+ //# sourceMappingURL=chunk-4RWO4WUN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/satelliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx"],"mappings":"mMAUO,IAAMA,CAAAA,CAAwBC,aAAAA,CACnC,IACF,CAAA,CAqBaC,CAAAA,CACXC,CAAAA,EACM,CAEN,IAAMC,CAAAA,CAAQC,UAAAA,CAAWL,CAAqB,EAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,QAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECLO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,SAAAA,CAAU,IAAM,CAAA,CACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,CAAA,CAEOF,CAAAA,GAAaG,CAAAA,EAAa,QAAQ,KAAA,CAAM,oCAAA,CAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,QAAA,CAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,EAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,OAAAA,CAAQ,IACbC,2BAAAA,CAAmD,CACxD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAEL,OAAAT,CAAAA,CAAyB,CACvB,sBAAuB,IAAMH,CAAAA,CAAM,QAAA,EAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,GAAAA,CAACnB,CAAAA,CAAsB,QAAA,CAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-4RWO4WUN.js","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connection, Connector } from '../types';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore<Connector, Connection>> | null>(\n null,\n);\n\n/**\n * Custom hook for accessing the Satellite Connect store state\n *\n * @remarks\n * This hook provides type-safe access to the Satellite store state and must be used\n * within a component that is wrapped by SatelliteConnectProvider.\n *\n * @typeParam T - The type of the selected state slice\n * @param selector - Function that selects a slice of the store state\n * @returns Selected state slice\n *\n * @throws Error if used outside of SatelliteConnectProvider\n *\n * @example\n * ```tsx\n * // Get the active connection\n * const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);\n * ```\n */\nexport const useSatelliteConnectStore = <T>(\n selector: (state: ISatelliteConnectStore<Connector, Connection>) => T,\n): T => {\n // Get store instance from context\n const store = useContext(SatelliteStoreContext);\n\n // Ensure hook is used within provider\n if (!store) {\n throw new Error('useSatelliteConnectStore must be used within a SatelliteConnectProvider');\n }\n\n // Return selected state using Zustand's useStore\n return useStore(store, selector);\n};\n","import { useEffect } from 'react';\n\n/**\n * Props for the useInitializeAutoConnect hook.\n */\ninterface InitializeAutoConnectProps {\n /** Function to initialize auto connect logic */\n initializeAutoConnect: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing connector auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected connector) when a component mounts.\n * It provides default error handling with console.error if no custom handler is provided.\n * The initialization runs only once when the component mounts.\n *\n * @param props - Hook configuration\n * @param props.initializeAutoConnect - Async function that executes the auto-connect logic\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect\n * });\n *\n * // With custom error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect,\n * onError: (error) => {\n * toast.error(`Failed to auto-connect: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAutoConnect = ({ initializeAutoConnect, onError }: InitializeAutoConnectProps): void => {\n useEffect(() => {\n const initializeAutoConnectLocal = async () => {\n try {\n await initializeAutoConnect();\n } catch (error) {\n // Use provided error handler or fallback to default console.error\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize auto connect:', e));\n errorHandler(error as Error);\n }\n };\n // Initialize auto connect when component mounts\n initializeAutoConnectLocal();\n }, []); // Empty dependency array ensures single execution\n};\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satelliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connection, Connector } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used connector */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages connector connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles connector connections, state management, and automatic reconnection functionality.\n * The store is memoized to ensure stable reference across renders.\n *\n * @param props - Component properties including store parameters and children\n * @param props.children - Child components that will have access to the store\n * @param props.autoConnect - Optional flag to enable automatic connector reconnection\n * @param props.adapter - Blockchain adapter(s) for connector interactions\n * @param props.callbackAfterConnected - Optional callback for successful connections\n *\n * @example\n * ```tsx\n * // Basic usage with single adapter\n * <SatelliteConnectProvider adapter={solanaAdapter}>\n * <App />\n * </SatelliteConnectProvider>\n *\n * // With auto-connect and multiple adapters\n * <SatelliteConnectProvider\n * adapter={[solanaAdapter, evmAdapter]}\n * autoConnect={true}\n * callbackAfterConnected={(wallet) => {\n * console.log('Wallet connected:', wallet.address);\n * }}\n * >\n * <App />\n * </SatelliteConnectProvider>\n * ```\n */\nexport function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps) {\n // Create and memoize the store instance\n const store = useMemo(() => {\n return createSatelliteConnectStore<Connector, Connection>({\n ...parameters,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Empty dependency array as store should be created only once\n\n useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkYC7F3NGW_cjs=require('../chunk-YC7F3NGW.cjs'),orbitCore=require('@tuwaio/orbit-core'),core=require('@wagmi/core'),react=require('react');function V({wagmiConfig:i,siwe:n}){let a=chunkYC7F3NGW_cjs.b(t=>t.activeWallet),l=chunkYC7F3NGW_cjs.b(t=>t.disconnect),o=chunkYC7F3NGW_cjs.b(t=>t.walletConnectionError),s=chunkYC7F3NGW_cjs.b(t=>t.updateActiveWallet);return react.useEffect(()=>{n?.enabled&&!n?.isSignedIn&&n?.isRejected&&l();},[n,l]),react.useEffect(()=>core.watchAccount(i,{onChange:e=>{if(e?.status==="disconnected"&&l(),a&&orbitCore.getAdapterFromWalletType(a.walletType)!==orbitCore.OrbitAdapter.EVM||!e.address||o)return;if(n?.enabled?n.isSignedIn:true){let c=a?.walletType,p=c?{walletType:c,address:e.address,chainId:e.chainId,rpcURL:e.chain?.rpcUrls.default.http[0],isConnected:e.isConnected}:{address:e.address,chainId:e.chainId,rpcURL:e.chain?.rpcUrls.default.http[0],isConnected:e.isConnected};s(p);}}}),[a?.walletType,n,o]),null}exports.EVMWalletsWatcher=V;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunk23IZMVDP_cjs=require('../chunk-23IZMVDP.cjs'),orbitCore=require('@tuwaio/orbit-core'),core=require('@wagmi/core'),react=require('react');function v({wagmiConfig:a,siwe:o}){let n=chunk23IZMVDP_cjs.b(e=>e.activeConnection),c=chunk23IZMVDP_cjs.b(e=>e.disconnect),s=chunk23IZMVDP_cjs.b(e=>e.connectionError),l=chunk23IZMVDP_cjs.b(e=>e.updateActiveConnection);return react.useEffect(()=>{o?.enabled&&!o?.isSignedIn&&o?.isRejected&&n&&c(n.connectorType);},[o,c,n]),react.useEffect(()=>core.watchConnections(a,{onChange:u=>{if(n&&orbitCore.getAdapterFromConnectorType(n.connectorType)!==orbitCore.OrbitAdapter.EVM)return;if(u.length===0){n&&c(n.connectorType);return}let t=core.getConnection(a);if(n&&orbitCore.getAdapterFromConnectorType(n.connectorType)!==orbitCore.OrbitAdapter.EVM||!t||s)return;if(o?.enabled?o.isSignedIn:true){let p=t.connector,f={connectorType:p?`${orbitCore.OrbitAdapter.EVM}:${orbitCore.formatConnectorName(p.name)}`:n?.connectorType,address:t.address,chainId:t.chainId,rpcURL:t?.chain?.rpcUrls.default.http[0],isConnected:true};l(f);}}}),[n?.connectorType,o,s]),null}exports.EVMConnectorsWatcher=v;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","activeWallet","useSatelliteConnectStore","store","disconnect","walletConnectionError","updateActiveWallet","useEffect","watchAccount","account","getAdapterFromWalletType","OrbitAdapter","walletType","walletUpdate"],"mappings":"+JAiDO,SAASA,CAAAA,CAAkB,CAAE,WAAA,CAAAC,CAAAA,CAAa,IAAA,CAAAC,CAAK,EAA2B,CAO/E,IAAMC,CAAAA,CAAeC,mBAAAA,CAA0BC,GAAUA,CAAAA,CAAM,YAAY,CAAA,CAIrEC,CAAAA,CAAaF,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,EAAwBH,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,qBAAqB,EAIvFG,CAAAA,CAAqBJ,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,kBAAkB,CAAA,CAYvF,OAAAI,eAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,OAAA,EAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC9CI,CAAAA,GAEJ,EAAG,CAACJ,CAAAA,CAAMI,CAAU,CAAC,EASrBG,eAAAA,CAAU,IAgEQC,iBAAAA,CAAaT,CAAAA,CAAa,CAAE,QAAA,CAzDqBU,CAAAA,EAAY,CAY3E,GAVIA,CAAAA,EAAS,SAAW,cAAA,EACtBL,CAAAA,EAAW,CAUVH,CAAAA,EAAgBS,mCAAyBT,CAAAA,CAAa,UAAU,CAAA,GAAMU,sBAAAA,CAAa,KACpF,CAACF,CAAAA,CAAQ,OAAA,EACTJ,CAAAA,CAEA,OAUF,GAFqBL,CAAAA,EAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAEhB,IAAMY,CAAAA,CAAaX,GAAc,UAAA,CAK3BY,CAAAA,CAAeD,CAAAA,CACjB,CAEE,WAAAA,CAAAA,CACA,OAAA,CAASH,CAAAA,CAAQ,OAAA,CACjB,QAASA,CAAAA,CAAQ,OAAA,CACjB,OAAQA,CAAAA,CAAQ,KAAA,EAAO,QAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAC7C,YAAaA,CAAAA,CAAQ,WACvB,CAAA,CACA,CAEE,QAASA,CAAAA,CAAQ,OAAA,CACjB,OAAA,CAASA,CAAAA,CAAQ,QACjB,MAAA,CAAQA,CAAAA,CAAQ,KAAA,EAAO,OAAA,CAAQ,QAAQ,IAAA,CAAK,CAAC,CAAA,CAC7C,WAAA,CAAaA,EAAQ,WACvB,CAAA,CAGJH,CAAAA,CAAmBO,CAAY,EACjC,CACF,CAG0E,CAAC,CAAA,CAO1E,CAACZ,CAAAA,EAAc,UAAA,CAAYD,EAAMK,CAAqB,CAAC,EAGnD,IACT","file":"index.cjs","sourcesContent":["import { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, watchAccount, WatchAccountParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMWalletsWatcher} component.\n */\ninterface EVMWalletsWatcherProps {\n /**\n * The configuration object from `@wagmi/core`.\n * This is required to initialize the account watcher.\n */\n wagmiConfig: Config;\n\n /**\n * Optional object representing the Sign-In With Ethereum (SIWE) state.\n * If provided, the watcher will use this state to manage updates\n * and disconnections based on SIWE status.\n */\n siwe?: {\n /**\n * Flag indicating if the SIWE authentication request was rejected by the user.\n */\n isRejected: boolean;\n /**\n * Flag indicating if the user is successfully signed in via SIWE.\n */\n isSignedIn: boolean;\n /**\n * Flag indicating if the SIWE flow is enabled.\n */\n enabled?: boolean;\n };\n}\n\n/**\n * A headless React component (renders `null`) that synchronizes the EVM wallet\n * state from `@wagmi/core` with the global `useSatelliteConnectStore`.\n *\n * It is responsible for:\n * 1. Automatically disconnecting if a SIWE (Sign-In With Ethereum) request is rejected.\n * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)\n * from `wagmi` and updating the global store accordingly.\n *\n * @param props - The component's props. See {@link EVMWalletsWatcherProps}.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMWalletsWatcher({ wagmiConfig, siwe }: EVMWalletsWatcherProps) {\n // --- Global Store State ---\n // Subscribes to parts of the global Zustand store.\n\n /**\n * The currently active wallet object from the global store.\n */\n const activeWallet = useSatelliteConnectStore((store) => store.activeWallet);\n /**\n * The global function to trigger a wallet disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n /**\n * The global function to update the active wallet's details.\n */\n const updateActiveWallet = useSatelliteConnectStore((store) => store.updateActiveWallet);\n\n // --- Effects ---\n\n /**\n * Effect: Handles SIWE rejection.\n *\n * If the SIWE flow is enabled (`siwe.enabled`), the user is not yet\n * signed in (`!siwe.isSignedIn`), and they have explicitly rejected\n * the SIWE signature request (`siwe.isRejected`), this effect\n * will call the global `disconnect` function.\n */\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n disconnect();\n }\n }, [siwe, disconnect]);\n\n /**\n * Effect: Subscribes to wagmi account changes.\n *\n * This effect initializes `watchAccount` from `@wagmi/core` to listen for\n * any changes in the connected wallet's state (like switching accounts,\n * changing networks, or disconnecting).\n */\n useEffect(() => {\n /**\n * Callback function triggered by `watchAccount` whenever the\n * wagmi account state changes.\n *\n * @param account - The new account state provided by wagmi.\n */\n const handleAccountChange: WatchAccountParameters['onChange'] = (account) => {\n // Case 1: The wallet was disconnected from the provider (e.g., MetaMask).\n if (account?.status === 'disconnected') {\n disconnect();\n }\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active wallet in our store is NOT an EVM wallet\n // (we don't want this watcher to override a non-EVM wallet).\n // 2. The new account state from wagmi has no address.\n // 3. There is already a connection error in our global store.\n if (\n (activeWallet && getAdapterFromWalletType(activeWallet.walletType) !== OrbitAdapter.EVM) ||\n !account.address ||\n walletConnectionError\n ) {\n return;\n }\n\n /**\n * Determines if the global store *should* be updated.\n * - If SIWE is enabled, we only update the store if the user is signed in.\n * - If SIWE is not enabled, we always update the store.\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n // Preserve the `walletType` if it already exists in the active wallet.\n const walletType = activeWallet?.walletType;\n\n /**\n * The payload to send to the global store update function.\n */\n const walletUpdate = walletType\n ? {\n // Preserve the walletType (e.g., 'metamask', 'walletconnect')\n walletType,\n address: account.address,\n chainId: account.chainId,\n rpcURL: account.chain?.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n }\n : {\n // Fallback if activeWallet was null or had no type\n address: account.address,\n chainId: account.chainId,\n rpcURL: account.chain?.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n };\n\n // Update the global store with the new wallet state.\n updateActiveWallet(walletUpdate);\n }\n };\n\n // Activate the watcher\n const unwatch = watchAccount(wagmiConfig, { onChange: handleAccountChange });\n\n // Return the cleanup function.\n // This `unwatch` function will be called when the component unmounts\n // or when the dependencies in the array change, preventing memory leaks.\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeWallet?.walletType, siwe, walletConnectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/evm/EVMConnectorsWatcher.tsx"],"names":["EVMConnectorsWatcher","wagmiConfig","siwe","activeConnection","useSatelliteConnectStore","store","disconnect","connectionError","updateActiveConnection","useEffect","watchConnections","connections","getAdapterFromConnectorType","OrbitAdapter","currentConnection","getConnection","currentConnector","updatedConnector","formatConnectorName"],"mappings":"+JAiDO,SAASA,CAAAA,CAAqB,CAAE,WAAA,CAAAC,CAAAA,CAAa,KAAAC,CAAK,CAAA,CAA8B,CAUrF,IAAMC,CAAAA,CAAmBC,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CAI7EC,CAAAA,CAAaF,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,CAAAA,CAAkBH,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,eAAe,CAAA,CAI3EG,EAAyBJ,mBAAAA,CAA0BC,CAAAA,EAAUA,EAAM,sBAAsB,CAAA,CAY/F,OAAAI,eAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,SAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC1CC,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,EAG/C,EAAG,CAACD,CAAAA,CAAMI,EAAYH,CAAgB,CAAC,EASvCM,eAAAA,CAAU,IAgEQC,sBAAiBT,CAAAA,CAAa,CAAE,SAzDyBU,CAAAA,EAAgB,CAEvF,GAAIR,CAAAA,EAAoBS,qCAAAA,CAA4BT,EAAiB,aAAa,CAAA,GAAMU,sBAAAA,CAAa,GAAA,CACnG,OAIF,GAAIF,CAAAA,CAAY,SAAW,CAAA,CAAG,CACxBR,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,CAAA,CAE3C,MACF,CAEA,IAAMW,EAAoBC,kBAAAA,CAAcd,CAAW,EAQnD,GACGE,CAAAA,EAAoBS,qCAAAA,CAA4BT,CAAAA,CAAiB,aAAa,CAAA,GAAMU,sBAAAA,CAAa,KAClG,CAACC,CAAAA,EACDP,EAEA,OAUF,GAFqBL,GAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAChB,IAAMc,CAAAA,CAAmBF,CAAAA,CAAkB,UAKrCG,CAAAA,CAAmB,CACvB,aAAA,CAL2BD,CAAAA,CACxB,GAAGH,sBAAAA,CAAa,GAAG,IAAIK,6BAAAA,CAAoBF,CAAAA,CAAiB,IAAI,CAAC,CAAA,CAAA,CAClEb,GAAkB,aAAA,CAIpB,OAAA,CAASW,EAAkB,OAAA,CAC3B,OAAA,CAASA,EAAkB,OAAA,CAC3B,MAAA,CAAQA,GAAmB,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACxD,WAAA,CAAa,IACf,CAAA,CAGAN,CAAAA,CAAuBS,CAAgB,EACzC,CACF,CAGkF,CAAC,CAAA,CAOlF,CAACd,CAAAA,EAAkB,aAAA,CAAeD,EAAMK,CAAe,CAAC,EAGpD,IACT","file":"index.cjs","sourcesContent":["import { ConnectorType, formatConnectorName, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, getConnection, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMConnectorsWatcher} component.\n */\ninterface EVMConnectorsWatcherProps {\n /**\n * The configuration object from `@wagmi/core`.\n * This is required to initialize the account watcher.\n */\n wagmiConfig: Config;\n\n /**\n * Optional object representing the Sign-In With Ethereum (SIWE) state.\n * If provided, the watcher will use this state to manage updates\n * and disconnections based on SIWE status.\n */\n siwe?: {\n /**\n * Flag indicating if the SIWE authentication request was rejected by the user.\n */\n isRejected: boolean;\n /**\n * Flag indicating if the user is successfully signed in via SIWE.\n */\n isSignedIn: boolean;\n /**\n * Flag indicating if the SIWE flow is enabled.\n */\n enabled?: boolean;\n };\n}\n\n/**\n * A headless React component (renders `null`) that synchronizes the EVM connector\n * state from `@wagmi/core` with the global `useSatelliteConnectStore`.\n *\n * It is responsible for:\n * 1. Automatically disconnecting if a SIWE (Sign-In With Ethereum) request is rejected.\n * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)\n * from `wagmi` and updating the global store accordingly.\n *\n * @param props - The component's props. See {@link EVMConnectorsWatcherProps} for details.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMConnectorsWatcher({ wagmiConfig, siwe }: EVMConnectorsWatcherProps) {\n // --- Global Store State ---\n // Subscribes to parts of the global Zustand store.\n\n /**\n * The currently active wallet object from the global store.\n */\n /**\n * The currently active wallet object from the global store.\n */\n const activeConnection = useSatelliteConnectStore((store) => store.activeConnection);\n /**\n * The global function to trigger a connector disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n /**\n * The global function to update the active connector's details.\n */\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n\n // --- Effects ---\n\n /**\n * Effect: Handles SIWE rejection.\n *\n * If the SIWE flow is enabled (`siwe.enabled`), the user is not yet\n * signed in (`!siwe.isSignedIn`), and they have explicitly rejected\n * the SIWE signature request (`siwe.isRejected`), this effect\n * will call the global `disconnect` function.\n */\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n }\n }, [siwe, disconnect, activeConnection]);\n\n /**\n * Effect: Subscribes to wagmi connection changes.\n *\n * This effect initializes `watchConnections` from `@wagmi/core` to listen for\n * any changes in the connected connectors' state (like switching accounts,\n * changing networks, or disconnecting). Supports multiple simultaneous connections.\n */\n useEffect(() => {\n /**\n * Callback function triggered by `watchConnections` whenever the\n * wagmi connections state changes.\n *\n * @param connections - Array of all active connections from wagmi.\n */\n const handleConnectionsChange: WatchConnectionsParameters['onChange'] = (connections) => {\n // Guard: If active connection is not EVM, ignore changes\n if (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Case 1: No connections means all connectors were disconnected\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n return;\n }\n\n const currentConnection = getConnection(wagmiConfig);\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active connector in our store is NOT an EVM connector\n // (we don't want this watcher to override a non-EVM connector).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) ||\n !currentConnection ||\n connectionError\n ) {\n return;\n }\n\n /**\n * Determines if the global store *should* be updated.\n * - If SIWE is enabled, we only update the store if the user is signed in.\n * - If SIWE is not enabled, we always update the store.\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n const currentConnector = currentConnection.connector;\n const currentConnectorType = currentConnector\n ? (`${OrbitAdapter.EVM}:${formatConnectorName(currentConnector.name)}` as ConnectorType)\n : activeConnection?.connectorType;\n\n const updatedConnector = {\n connectorType: currentConnectorType,\n address: currentConnection.address,\n chainId: currentConnection.chainId,\n rpcURL: currentConnection?.chain?.rpcUrls.default.http[0],\n isConnected: true,\n };\n\n // Update the global store with the new connector state.\n updateActiveConnection(updatedConnector);\n }\n };\n\n // Activate the watcher\n const unwatch = watchConnections(wagmiConfig, { onChange: handleConnectionsChange });\n\n // Return the cleanup function.\n // This `unwatch` function will be called when the component unmounts\n // or when the dependencies in the array change, preventing memory leaks.\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnection?.connectorType, siwe, connectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { OrbitAdapter } from '@tuwaio/orbit-core';
2
- import { EVMWallet, ConnectorEVM } from '@tuwaio/satellite-evm';
2
+ import { EVMConnection, ConnectorEVM } from '@tuwaio/satellite-evm';
3
3
  import { Config } from '@wagmi/core';
4
4
 
5
5
  /**
6
- * Props for the {@link EVMWalletsWatcher} component.
6
+ * Props for the {@link EVMConnectorsWatcher} component.
7
7
  */
8
- interface EVMWalletsWatcherProps {
8
+ interface EVMConnectorsWatcherProps {
9
9
  /**
10
10
  * The configuration object from `@wagmi/core`.
11
11
  * This is required to initialize the account watcher.
@@ -32,7 +32,7 @@ interface EVMWalletsWatcherProps {
32
32
  };
33
33
  }
34
34
  /**
35
- * A headless React component (renders `null`) that synchronizes the EVM wallet
35
+ * A headless React component (renders `null`) that synchronizes the EVM connector
36
36
  * state from `@wagmi/core` with the global `useSatelliteConnectStore`.
37
37
  *
38
38
  * It is responsible for:
@@ -40,18 +40,18 @@ interface EVMWalletsWatcherProps {
40
40
  * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)
41
41
  * from `wagmi` and updating the global store accordingly.
42
42
  *
43
- * @param props - The component's props. See {@link EVMWalletsWatcherProps}.
43
+ * @param props - The component's props. See {@link EVMConnectorsWatcherProps} for details.
44
44
  * @returns {null} This component does not render any UI.
45
45
  */
46
- declare function EVMWalletsWatcher({ wagmiConfig, siwe }: EVMWalletsWatcherProps): null;
46
+ declare function EVMConnectorsWatcher({ wagmiConfig, siwe }: EVMConnectorsWatcherProps): null;
47
47
 
48
48
  declare module '@tuwaio/satellite-react' {
49
- interface AllWallets {
50
- [OrbitAdapter.EVM]: EVMWallet;
49
+ interface AllConnections {
50
+ [OrbitAdapter.EVM]: EVMConnection;
51
51
  }
52
52
  interface AllConnectors {
53
53
  [OrbitAdapter.EVM]: ConnectorEVM;
54
54
  }
55
55
  }
56
56
 
57
- export { EVMWalletsWatcher };
57
+ export { EVMConnectorsWatcher };
@@ -1,11 +1,11 @@
1
1
  import { OrbitAdapter } from '@tuwaio/orbit-core';
2
- import { EVMWallet, ConnectorEVM } from '@tuwaio/satellite-evm';
2
+ import { EVMConnection, ConnectorEVM } from '@tuwaio/satellite-evm';
3
3
  import { Config } from '@wagmi/core';
4
4
 
5
5
  /**
6
- * Props for the {@link EVMWalletsWatcher} component.
6
+ * Props for the {@link EVMConnectorsWatcher} component.
7
7
  */
8
- interface EVMWalletsWatcherProps {
8
+ interface EVMConnectorsWatcherProps {
9
9
  /**
10
10
  * The configuration object from `@wagmi/core`.
11
11
  * This is required to initialize the account watcher.
@@ -32,7 +32,7 @@ interface EVMWalletsWatcherProps {
32
32
  };
33
33
  }
34
34
  /**
35
- * A headless React component (renders `null`) that synchronizes the EVM wallet
35
+ * A headless React component (renders `null`) that synchronizes the EVM connector
36
36
  * state from `@wagmi/core` with the global `useSatelliteConnectStore`.
37
37
  *
38
38
  * It is responsible for:
@@ -40,18 +40,18 @@ interface EVMWalletsWatcherProps {
40
40
  * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)
41
41
  * from `wagmi` and updating the global store accordingly.
42
42
  *
43
- * @param props - The component's props. See {@link EVMWalletsWatcherProps}.
43
+ * @param props - The component's props. See {@link EVMConnectorsWatcherProps} for details.
44
44
  * @returns {null} This component does not render any UI.
45
45
  */
46
- declare function EVMWalletsWatcher({ wagmiConfig, siwe }: EVMWalletsWatcherProps): null;
46
+ declare function EVMConnectorsWatcher({ wagmiConfig, siwe }: EVMConnectorsWatcherProps): null;
47
47
 
48
48
  declare module '@tuwaio/satellite-react' {
49
- interface AllWallets {
50
- [OrbitAdapter.EVM]: EVMWallet;
49
+ interface AllConnections {
50
+ [OrbitAdapter.EVM]: EVMConnection;
51
51
  }
52
52
  interface AllConnectors {
53
53
  [OrbitAdapter.EVM]: ConnectorEVM;
54
54
  }
55
55
  }
56
56
 
57
- export { EVMWalletsWatcher };
57
+ export { EVMConnectorsWatcher };
package/dist/evm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import {b}from'../chunk-3WMGCMYX.js';import {getAdapterFromWalletType,OrbitAdapter}from'@tuwaio/orbit-core';import {watchAccount}from'@wagmi/core';import {useEffect}from'react';function V({wagmiConfig:i,siwe:n}){let a=b(t=>t.activeWallet),l=b(t=>t.disconnect),o=b(t=>t.walletConnectionError),s=b(t=>t.updateActiveWallet);return useEffect(()=>{n?.enabled&&!n?.isSignedIn&&n?.isRejected&&l();},[n,l]),useEffect(()=>watchAccount(i,{onChange:e=>{if(e?.status==="disconnected"&&l(),a&&getAdapterFromWalletType(a.walletType)!==OrbitAdapter.EVM||!e.address||o)return;if(n?.enabled?n.isSignedIn:true){let c=a?.walletType,p=c?{walletType:c,address:e.address,chainId:e.chainId,rpcURL:e.chain?.rpcUrls.default.http[0],isConnected:e.isConnected}:{address:e.address,chainId:e.chainId,rpcURL:e.chain?.rpcUrls.default.http[0],isConnected:e.isConnected};s(p);}}}),[a?.walletType,n,o]),null}export{V as EVMWalletsWatcher};//# sourceMappingURL=index.js.map
1
+ import {b}from'../chunk-4RWO4WUN.js';import {getAdapterFromConnectorType,OrbitAdapter,formatConnectorName}from'@tuwaio/orbit-core';import {watchConnections,getConnection}from'@wagmi/core';import {useEffect}from'react';function v({wagmiConfig:a,siwe:o}){let n=b(e=>e.activeConnection),c=b(e=>e.disconnect),s=b(e=>e.connectionError),l=b(e=>e.updateActiveConnection);return useEffect(()=>{o?.enabled&&!o?.isSignedIn&&o?.isRejected&&n&&c(n.connectorType);},[o,c,n]),useEffect(()=>watchConnections(a,{onChange:u=>{if(n&&getAdapterFromConnectorType(n.connectorType)!==OrbitAdapter.EVM)return;if(u.length===0){n&&c(n.connectorType);return}let t=getConnection(a);if(n&&getAdapterFromConnectorType(n.connectorType)!==OrbitAdapter.EVM||!t||s)return;if(o?.enabled?o.isSignedIn:true){let p=t.connector,f={connectorType:p?`${OrbitAdapter.EVM}:${formatConnectorName(p.name)}`:n?.connectorType,address:t.address,chainId:t.chainId,rpcURL:t?.chain?.rpcUrls.default.http[0],isConnected:true};l(f);}}}),[n?.connectorType,o,s]),null}export{v as EVMConnectorsWatcher};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","activeWallet","useSatelliteConnectStore","store","disconnect","walletConnectionError","updateActiveWallet","useEffect","watchAccount","account","getAdapterFromWalletType","OrbitAdapter","walletType","walletUpdate"],"mappings":"iLAiDO,SAASA,CAAAA,CAAkB,CAAE,WAAA,CAAAC,CAAAA,CAAa,IAAA,CAAAC,CAAK,EAA2B,CAO/E,IAAMC,CAAAA,CAAeC,CAAAA,CAA0BC,GAAUA,CAAAA,CAAM,YAAY,CAAA,CAIrEC,CAAAA,CAAaF,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,EAAwBH,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,qBAAqB,EAIvFG,CAAAA,CAAqBJ,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,kBAAkB,CAAA,CAYvF,OAAAI,SAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,OAAA,EAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC9CI,CAAAA,GAEJ,EAAG,CAACJ,CAAAA,CAAMI,CAAU,CAAC,EASrBG,SAAAA,CAAU,IAgEQC,YAAAA,CAAaT,CAAAA,CAAa,CAAE,QAAA,CAzDqBU,CAAAA,EAAY,CAY3E,GAVIA,CAAAA,EAAS,SAAW,cAAA,EACtBL,CAAAA,EAAW,CAUVH,CAAAA,EAAgBS,yBAAyBT,CAAAA,CAAa,UAAU,CAAA,GAAMU,YAAAA,CAAa,KACpF,CAACF,CAAAA,CAAQ,OAAA,EACTJ,CAAAA,CAEA,OAUF,GAFqBL,CAAAA,EAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAEhB,IAAMY,CAAAA,CAAaX,GAAc,UAAA,CAK3BY,CAAAA,CAAeD,CAAAA,CACjB,CAEE,WAAAA,CAAAA,CACA,OAAA,CAASH,CAAAA,CAAQ,OAAA,CACjB,QAASA,CAAAA,CAAQ,OAAA,CACjB,OAAQA,CAAAA,CAAQ,KAAA,EAAO,QAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAC7C,YAAaA,CAAAA,CAAQ,WACvB,CAAA,CACA,CAEE,QAASA,CAAAA,CAAQ,OAAA,CACjB,OAAA,CAASA,CAAAA,CAAQ,QACjB,MAAA,CAAQA,CAAAA,CAAQ,KAAA,EAAO,OAAA,CAAQ,QAAQ,IAAA,CAAK,CAAC,CAAA,CAC7C,WAAA,CAAaA,EAAQ,WACvB,CAAA,CAGJH,CAAAA,CAAmBO,CAAY,EACjC,CACF,CAG0E,CAAC,CAAA,CAO1E,CAACZ,CAAAA,EAAc,UAAA,CAAYD,EAAMK,CAAqB,CAAC,EAGnD,IACT","file":"index.js","sourcesContent":["import { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, watchAccount, WatchAccountParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMWalletsWatcher} component.\n */\ninterface EVMWalletsWatcherProps {\n /**\n * The configuration object from `@wagmi/core`.\n * This is required to initialize the account watcher.\n */\n wagmiConfig: Config;\n\n /**\n * Optional object representing the Sign-In With Ethereum (SIWE) state.\n * If provided, the watcher will use this state to manage updates\n * and disconnections based on SIWE status.\n */\n siwe?: {\n /**\n * Flag indicating if the SIWE authentication request was rejected by the user.\n */\n isRejected: boolean;\n /**\n * Flag indicating if the user is successfully signed in via SIWE.\n */\n isSignedIn: boolean;\n /**\n * Flag indicating if the SIWE flow is enabled.\n */\n enabled?: boolean;\n };\n}\n\n/**\n * A headless React component (renders `null`) that synchronizes the EVM wallet\n * state from `@wagmi/core` with the global `useSatelliteConnectStore`.\n *\n * It is responsible for:\n * 1. Automatically disconnecting if a SIWE (Sign-In With Ethereum) request is rejected.\n * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)\n * from `wagmi` and updating the global store accordingly.\n *\n * @param props - The component's props. See {@link EVMWalletsWatcherProps}.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMWalletsWatcher({ wagmiConfig, siwe }: EVMWalletsWatcherProps) {\n // --- Global Store State ---\n // Subscribes to parts of the global Zustand store.\n\n /**\n * The currently active wallet object from the global store.\n */\n const activeWallet = useSatelliteConnectStore((store) => store.activeWallet);\n /**\n * The global function to trigger a wallet disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n /**\n * The global function to update the active wallet's details.\n */\n const updateActiveWallet = useSatelliteConnectStore((store) => store.updateActiveWallet);\n\n // --- Effects ---\n\n /**\n * Effect: Handles SIWE rejection.\n *\n * If the SIWE flow is enabled (`siwe.enabled`), the user is not yet\n * signed in (`!siwe.isSignedIn`), and they have explicitly rejected\n * the SIWE signature request (`siwe.isRejected`), this effect\n * will call the global `disconnect` function.\n */\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n disconnect();\n }\n }, [siwe, disconnect]);\n\n /**\n * Effect: Subscribes to wagmi account changes.\n *\n * This effect initializes `watchAccount` from `@wagmi/core` to listen for\n * any changes in the connected wallet's state (like switching accounts,\n * changing networks, or disconnecting).\n */\n useEffect(() => {\n /**\n * Callback function triggered by `watchAccount` whenever the\n * wagmi account state changes.\n *\n * @param account - The new account state provided by wagmi.\n */\n const handleAccountChange: WatchAccountParameters['onChange'] = (account) => {\n // Case 1: The wallet was disconnected from the provider (e.g., MetaMask).\n if (account?.status === 'disconnected') {\n disconnect();\n }\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active wallet in our store is NOT an EVM wallet\n // (we don't want this watcher to override a non-EVM wallet).\n // 2. The new account state from wagmi has no address.\n // 3. There is already a connection error in our global store.\n if (\n (activeWallet && getAdapterFromWalletType(activeWallet.walletType) !== OrbitAdapter.EVM) ||\n !account.address ||\n walletConnectionError\n ) {\n return;\n }\n\n /**\n * Determines if the global store *should* be updated.\n * - If SIWE is enabled, we only update the store if the user is signed in.\n * - If SIWE is not enabled, we always update the store.\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n // Preserve the `walletType` if it already exists in the active wallet.\n const walletType = activeWallet?.walletType;\n\n /**\n * The payload to send to the global store update function.\n */\n const walletUpdate = walletType\n ? {\n // Preserve the walletType (e.g., 'metamask', 'walletconnect')\n walletType,\n address: account.address,\n chainId: account.chainId,\n rpcURL: account.chain?.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n }\n : {\n // Fallback if activeWallet was null or had no type\n address: account.address,\n chainId: account.chainId,\n rpcURL: account.chain?.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n };\n\n // Update the global store with the new wallet state.\n updateActiveWallet(walletUpdate);\n }\n };\n\n // Activate the watcher\n const unwatch = watchAccount(wagmiConfig, { onChange: handleAccountChange });\n\n // Return the cleanup function.\n // This `unwatch` function will be called when the component unmounts\n // or when the dependencies in the array change, preventing memory leaks.\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeWallet?.walletType, siwe, walletConnectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/evm/EVMConnectorsWatcher.tsx"],"names":["EVMConnectorsWatcher","wagmiConfig","siwe","activeConnection","useSatelliteConnectStore","store","disconnect","connectionError","updateActiveConnection","useEffect","watchConnections","connections","getAdapterFromConnectorType","OrbitAdapter","currentConnection","getConnection","currentConnector","updatedConnector","formatConnectorName"],"mappings":"0NAiDO,SAASA,CAAAA,CAAqB,CAAE,WAAA,CAAAC,CAAAA,CAAa,KAAAC,CAAK,CAAA,CAA8B,CAUrF,IAAMC,CAAAA,CAAmBC,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CAI7EC,CAAAA,CAAaF,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,CAAAA,CAAkBH,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,eAAe,CAAA,CAI3EG,EAAyBJ,CAAAA,CAA0BC,CAAAA,EAAUA,EAAM,sBAAsB,CAAA,CAY/F,OAAAI,SAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,SAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC1CC,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,EAG/C,EAAG,CAACD,CAAAA,CAAMI,EAAYH,CAAgB,CAAC,EASvCM,SAAAA,CAAU,IAgEQC,iBAAiBT,CAAAA,CAAa,CAAE,SAzDyBU,CAAAA,EAAgB,CAEvF,GAAIR,CAAAA,EAAoBS,2BAAAA,CAA4BT,EAAiB,aAAa,CAAA,GAAMU,YAAAA,CAAa,GAAA,CACnG,OAIF,GAAIF,CAAAA,CAAY,SAAW,CAAA,CAAG,CACxBR,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,CAAA,CAE3C,MACF,CAEA,IAAMW,EAAoBC,aAAAA,CAAcd,CAAW,EAQnD,GACGE,CAAAA,EAAoBS,2BAAAA,CAA4BT,CAAAA,CAAiB,aAAa,CAAA,GAAMU,YAAAA,CAAa,KAClG,CAACC,CAAAA,EACDP,EAEA,OAUF,GAFqBL,GAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAChB,IAAMc,CAAAA,CAAmBF,CAAAA,CAAkB,UAKrCG,CAAAA,CAAmB,CACvB,aAAA,CAL2BD,CAAAA,CACxB,GAAGH,YAAAA,CAAa,GAAG,IAAIK,mBAAAA,CAAoBF,CAAAA,CAAiB,IAAI,CAAC,CAAA,CAAA,CAClEb,GAAkB,aAAA,CAIpB,OAAA,CAASW,EAAkB,OAAA,CAC3B,OAAA,CAASA,EAAkB,OAAA,CAC3B,MAAA,CAAQA,GAAmB,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACxD,WAAA,CAAa,IACf,CAAA,CAGAN,CAAAA,CAAuBS,CAAgB,EACzC,CACF,CAGkF,CAAC,CAAA,CAOlF,CAACd,CAAAA,EAAkB,aAAA,CAAeD,EAAMK,CAAe,CAAC,EAGpD,IACT","file":"index.js","sourcesContent":["import { ConnectorType, formatConnectorName, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, getConnection, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMConnectorsWatcher} component.\n */\ninterface EVMConnectorsWatcherProps {\n /**\n * The configuration object from `@wagmi/core`.\n * This is required to initialize the account watcher.\n */\n wagmiConfig: Config;\n\n /**\n * Optional object representing the Sign-In With Ethereum (SIWE) state.\n * If provided, the watcher will use this state to manage updates\n * and disconnections based on SIWE status.\n */\n siwe?: {\n /**\n * Flag indicating if the SIWE authentication request was rejected by the user.\n */\n isRejected: boolean;\n /**\n * Flag indicating if the user is successfully signed in via SIWE.\n */\n isSignedIn: boolean;\n /**\n * Flag indicating if the SIWE flow is enabled.\n */\n enabled?: boolean;\n };\n}\n\n/**\n * A headless React component (renders `null`) that synchronizes the EVM connector\n * state from `@wagmi/core` with the global `useSatelliteConnectStore`.\n *\n * It is responsible for:\n * 1. Automatically disconnecting if a SIWE (Sign-In With Ethereum) request is rejected.\n * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)\n * from `wagmi` and updating the global store accordingly.\n *\n * @param props - The component's props. See {@link EVMConnectorsWatcherProps} for details.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMConnectorsWatcher({ wagmiConfig, siwe }: EVMConnectorsWatcherProps) {\n // --- Global Store State ---\n // Subscribes to parts of the global Zustand store.\n\n /**\n * The currently active wallet object from the global store.\n */\n /**\n * The currently active wallet object from the global store.\n */\n const activeConnection = useSatelliteConnectStore((store) => store.activeConnection);\n /**\n * The global function to trigger a connector disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n /**\n * The global function to update the active connector's details.\n */\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n\n // --- Effects ---\n\n /**\n * Effect: Handles SIWE rejection.\n *\n * If the SIWE flow is enabled (`siwe.enabled`), the user is not yet\n * signed in (`!siwe.isSignedIn`), and they have explicitly rejected\n * the SIWE signature request (`siwe.isRejected`), this effect\n * will call the global `disconnect` function.\n */\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n }\n }, [siwe, disconnect, activeConnection]);\n\n /**\n * Effect: Subscribes to wagmi connection changes.\n *\n * This effect initializes `watchConnections` from `@wagmi/core` to listen for\n * any changes in the connected connectors' state (like switching accounts,\n * changing networks, or disconnecting). Supports multiple simultaneous connections.\n */\n useEffect(() => {\n /**\n * Callback function triggered by `watchConnections` whenever the\n * wagmi connections state changes.\n *\n * @param connections - Array of all active connections from wagmi.\n */\n const handleConnectionsChange: WatchConnectionsParameters['onChange'] = (connections) => {\n // Guard: If active connection is not EVM, ignore changes\n if (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Case 1: No connections means all connectors were disconnected\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n return;\n }\n\n const currentConnection = getConnection(wagmiConfig);\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active connector in our store is NOT an EVM connector\n // (we don't want this watcher to override a non-EVM connector).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) ||\n !currentConnection ||\n connectionError\n ) {\n return;\n }\n\n /**\n * Determines if the global store *should* be updated.\n * - If SIWE is enabled, we only update the store if the user is signed in.\n * - If SIWE is not enabled, we always update the store.\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n const currentConnector = currentConnection.connector;\n const currentConnectorType = currentConnector\n ? (`${OrbitAdapter.EVM}:${formatConnectorName(currentConnector.name)}` as ConnectorType)\n : activeConnection?.connectorType;\n\n const updatedConnector = {\n connectorType: currentConnectorType,\n address: currentConnection.address,\n chainId: currentConnection.chainId,\n rpcURL: currentConnection?.chain?.rpcUrls.default.http[0],\n isConnected: true,\n };\n\n // Update the global store with the new connector state.\n updateActiveConnection(updatedConnector);\n }\n };\n\n // Activate the watcher\n const unwatch = watchConnections(wagmiConfig, { onChange: handleConnectionsChange });\n\n // Return the cleanup function.\n // This `unwatch` function will be called when the component unmounts\n // or when the dependencies in the array change, preventing memory leaks.\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnection?.connectorType, siwe, connectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkYC7F3NGW_cjs=require('./chunk-YC7F3NGW.cjs');Object.defineProperty(exports,"SatelliteConnectProvider",{enumerable:true,get:function(){return chunkYC7F3NGW_cjs.d}});Object.defineProperty(exports,"SatelliteStoreContext",{enumerable:true,get:function(){return chunkYC7F3NGW_cjs.a}});Object.defineProperty(exports,"useInitializeAutoConnect",{enumerable:true,get:function(){return chunkYC7F3NGW_cjs.c}});Object.defineProperty(exports,"useSatelliteConnectStore",{enumerable:true,get:function(){return chunkYC7F3NGW_cjs.b}});//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunk23IZMVDP_cjs=require('./chunk-23IZMVDP.cjs');Object.defineProperty(exports,"SatelliteConnectProvider",{enumerable:true,get:function(){return chunk23IZMVDP_cjs.d}});Object.defineProperty(exports,"SatelliteStoreContext",{enumerable:true,get:function(){return chunk23IZMVDP_cjs.a}});Object.defineProperty(exports,"useInitializeAutoConnect",{enumerable:true,get:function(){return chunk23IZMVDP_cjs.c}});Object.defineProperty(exports,"useSatelliteConnectStore",{enumerable:true,get:function(){return chunk23IZMVDP_cjs.b}});//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -7,9 +7,9 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
  * @description
8
8
  * This interface is intentionally left empty.
9
9
  * Other packages (@tuwaio/satellite-*) will use module
10
- * augmentation to add their specific wallet types here.
10
+ * augmentation to add their specific connection types here.
11
11
  */
12
- interface AllWallets {
12
+ interface AllConnections {
13
13
  }
14
14
  /**
15
15
  * @description
@@ -19,11 +19,11 @@ interface AllWallets {
19
19
  interface AllConnectors {
20
20
  }
21
21
  /**
22
- * Union type for all supported wallet types.
23
- * It's created from the values of the AllWallets interface.
24
- * e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
22
+ * Union type for all supported connection types.
23
+ * It's created from the values of the AllConnections interface.
24
+ * e.g., { evm: EVMConnection, solana: SolanaConnection } -> EVMConnection | SolanaConnection
25
25
  */
26
- type Wallet = AllWallets[keyof AllWallets];
26
+ type Connection = AllConnections[keyof AllConnections];
27
27
  /**
28
28
  * Union type for all supported connector types.
29
29
  */
@@ -49,11 +49,11 @@ declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectSto
49
49
  *
50
50
  * @example
51
51
  * ```tsx
52
- * // Get the active wallet
53
- * const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);
52
+ * // Get the active connection
53
+ * const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);
54
54
  * ```
55
55
  */
56
- declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T) => T;
56
+ declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore<Connector, Connection>) => T) => T;
57
57
 
58
58
  /**
59
59
  * Props for the useInitializeAutoConnect hook.
@@ -65,11 +65,11 @@ interface InitializeAutoConnectProps {
65
65
  onError?: (error: Error) => void;
66
66
  }
67
67
  /**
68
- * Custom hook for initializing wallet auto-connection with error handling.
68
+ * Custom hook for initializing connector auto-connection with error handling.
69
69
  *
70
70
  * @remarks
71
71
  * This hook handles the initial connection logic (e.g., checking for a previously
72
- * connected wallet) when a component mounts.
72
+ * connected connector) when a component mounts.
73
73
  * It provides default error handling with console.error if no custom handler is provided.
74
74
  * The initialization runs only once when the component mounts.
75
75
  *
@@ -98,24 +98,24 @@ declare const useInitializeAutoConnect: ({ initializeAutoConnect, onError }: Ini
98
98
  /**
99
99
  * Props for SatelliteConnectProvider component
100
100
  */
101
- interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {
101
+ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {
102
102
  /** React child components */
103
103
  children: React.ReactNode;
104
- /** Whether to automatically connect to last used wallet */
104
+ /** Whether to automatically connect to last used connector */
105
105
  autoConnect?: boolean;
106
106
  }
107
107
  /**
108
- * Provider component that manages wallet connections and state
108
+ * Provider component that manages connector connections and state
109
109
  *
110
110
  * @remarks
111
111
  * This component creates and provides the Satellite Connect store context to its children.
112
- * It handles wallet connections, state management, and automatic reconnection functionality.
112
+ * It handles connector connections, state management, and automatic reconnection functionality.
113
113
  * The store is memoized to ensure stable reference across renders.
114
114
  *
115
115
  * @param props - Component properties including store parameters and children
116
116
  * @param props.children - Child components that will have access to the store
117
- * @param props.autoConnect - Optional flag to enable automatic wallet reconnection
118
- * @param props.adapter - Blockchain adapter(s) for wallet interactions
117
+ * @param props.autoConnect - Optional flag to enable automatic connector reconnection
118
+ * @param props.adapter - Blockchain adapter(s) for connector interactions
119
119
  * @param props.callbackAfterConnected - Optional callback for successful connections
120
120
  *
121
121
  * @example
@@ -139,4 +139,4 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
139
139
  */
140
140
  declare function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps): react_jsx_runtime.JSX.Element;
141
141
 
142
- export { type AllConnectors, type AllWallets, type Connector, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, type Wallet, useInitializeAutoConnect, useSatelliteConnectStore };
142
+ export { type AllConnections, type AllConnectors, type Connection, type Connector, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, useInitializeAutoConnect, useSatelliteConnectStore };
package/dist/index.d.ts CHANGED
@@ -7,9 +7,9 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
  * @description
8
8
  * This interface is intentionally left empty.
9
9
  * Other packages (@tuwaio/satellite-*) will use module
10
- * augmentation to add their specific wallet types here.
10
+ * augmentation to add their specific connection types here.
11
11
  */
12
- interface AllWallets {
12
+ interface AllConnections {
13
13
  }
14
14
  /**
15
15
  * @description
@@ -19,11 +19,11 @@ interface AllWallets {
19
19
  interface AllConnectors {
20
20
  }
21
21
  /**
22
- * Union type for all supported wallet types.
23
- * It's created from the values of the AllWallets interface.
24
- * e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
22
+ * Union type for all supported connection types.
23
+ * It's created from the values of the AllConnections interface.
24
+ * e.g., { evm: EVMConnection, solana: SolanaConnection } -> EVMConnection | SolanaConnection
25
25
  */
26
- type Wallet = AllWallets[keyof AllWallets];
26
+ type Connection = AllConnections[keyof AllConnections];
27
27
  /**
28
28
  * Union type for all supported connector types.
29
29
  */
@@ -49,11 +49,11 @@ declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectSto
49
49
  *
50
50
  * @example
51
51
  * ```tsx
52
- * // Get the active wallet
53
- * const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);
52
+ * // Get the active connection
53
+ * const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);
54
54
  * ```
55
55
  */
56
- declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T) => T;
56
+ declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore<Connector, Connection>) => T) => T;
57
57
 
58
58
  /**
59
59
  * Props for the useInitializeAutoConnect hook.
@@ -65,11 +65,11 @@ interface InitializeAutoConnectProps {
65
65
  onError?: (error: Error) => void;
66
66
  }
67
67
  /**
68
- * Custom hook for initializing wallet auto-connection with error handling.
68
+ * Custom hook for initializing connector auto-connection with error handling.
69
69
  *
70
70
  * @remarks
71
71
  * This hook handles the initial connection logic (e.g., checking for a previously
72
- * connected wallet) when a component mounts.
72
+ * connected connector) when a component mounts.
73
73
  * It provides default error handling with console.error if no custom handler is provided.
74
74
  * The initialization runs only once when the component mounts.
75
75
  *
@@ -98,24 +98,24 @@ declare const useInitializeAutoConnect: ({ initializeAutoConnect, onError }: Ini
98
98
  /**
99
99
  * Props for SatelliteConnectProvider component
100
100
  */
101
- interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {
101
+ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {
102
102
  /** React child components */
103
103
  children: React.ReactNode;
104
- /** Whether to automatically connect to last used wallet */
104
+ /** Whether to automatically connect to last used connector */
105
105
  autoConnect?: boolean;
106
106
  }
107
107
  /**
108
- * Provider component that manages wallet connections and state
108
+ * Provider component that manages connector connections and state
109
109
  *
110
110
  * @remarks
111
111
  * This component creates and provides the Satellite Connect store context to its children.
112
- * It handles wallet connections, state management, and automatic reconnection functionality.
112
+ * It handles connector connections, state management, and automatic reconnection functionality.
113
113
  * The store is memoized to ensure stable reference across renders.
114
114
  *
115
115
  * @param props - Component properties including store parameters and children
116
116
  * @param props.children - Child components that will have access to the store
117
- * @param props.autoConnect - Optional flag to enable automatic wallet reconnection
118
- * @param props.adapter - Blockchain adapter(s) for wallet interactions
117
+ * @param props.autoConnect - Optional flag to enable automatic connector reconnection
118
+ * @param props.adapter - Blockchain adapter(s) for connector interactions
119
119
  * @param props.callbackAfterConnected - Optional callback for successful connections
120
120
  *
121
121
  * @example
@@ -139,4 +139,4 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
139
139
  */
140
140
  declare function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps): react_jsx_runtime.JSX.Element;
141
141
 
142
- export { type AllConnectors, type AllWallets, type Connector, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, type Wallet, useInitializeAutoConnect, useSatelliteConnectStore };
142
+ export { type AllConnections, type AllConnectors, type Connection, type Connector, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, useInitializeAutoConnect, useSatelliteConnectStore };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{d as SatelliteConnectProvider,a as SatelliteStoreContext,c as useInitializeAutoConnect,b as useSatelliteConnectStore}from'./chunk-3WMGCMYX.js';//# sourceMappingURL=index.js.map
1
+ export{d as SatelliteConnectProvider,a as SatelliteStoreContext,c as useInitializeAutoConnect,b as useSatelliteConnectStore}from'./chunk-4RWO4WUN.js';//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkYC7F3NGW_cjs=require('../chunk-YC7F3NGW.cjs'),orbitCore=require('@tuwaio/orbit-core'),react=require('@wallet-standard/react'),react$1=require('react');function C(){let l=react.useWallets(),o=chunkYC7F3NGW_cjs.b(t=>t.activeWallet),a=chunkYC7F3NGW_cjs.b(t=>t.updateActiveWallet),r=chunkYC7F3NGW_cjs.b(t=>t.walletConnectionError),n=chunkYC7F3NGW_cjs.b(t=>t.disconnect);return react$1.useEffect(()=>{if(o&&orbitCore.getAdapterFromWalletType(o.walletType)===orbitCore.OrbitAdapter.SOLANA){let t=l.filter(i=>orbitCore.getWalletTypeFromConnectorName(orbitCore.OrbitAdapter.SOLANA,orbitCore.formatWalletName(i.name))===o.walletType)[0];r||a({address:t?.accounts[0]?.address,isConnected:t?.accounts.length>0,connectedAccount:t?.accounts[0],connectedWallet:t}),t?.accounts.length===0&&n();}},[o?.walletType,l,r,a,n]),null}exports.SolanaWalletsWatcher=C;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunk23IZMVDP_cjs=require('../chunk-23IZMVDP.cjs'),orbitCore=require('@tuwaio/orbit-core'),react=require('@wallet-standard/react'),react$1=require('react');function h(){let c=react.useWallets(),o=chunk23IZMVDP_cjs.b(n=>n.activeConnection),r=chunk23IZMVDP_cjs.b(n=>n.updateActiveConnection),a=chunk23IZMVDP_cjs.b(n=>n.connectionError),i=chunk23IZMVDP_cjs.b(n=>n.disconnect);return react$1.useEffect(()=>{if(o&&orbitCore.getAdapterFromConnectorType(o.connectorType)===orbitCore.OrbitAdapter.SOLANA){let n=c.filter(e=>orbitCore.getConnectorTypeFromName(orbitCore.OrbitAdapter.SOLANA,orbitCore.formatConnectorName(e.name))===o.connectorType)[0];if(!a){let e={address:n?.accounts[0]?.address,isConnected:n?.accounts.length>0,connectedAccount:n?.accounts[0],connectedWallet:n};(e.address!==o.address||e.isConnected!==o.isConnected)&&r(e);}n?.accounts.length===0&&o.connectorType&&i(o.connectorType);}},[o?.connectorType,c,a,r,i]),null}exports.SolanaConnectorsWatcher=h;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/solana/SolanaWalletsWatcher.tsx"],"names":["SolanaWalletsWatcher","wallets","useWallets","activeWalletFromStore","useSatelliteConnectStore","store","updateActiveWallet","walletConnectionError","disconnect","useEffect","getAdapterFromWalletType","OrbitAdapter","activeWallet","w","getWalletTypeFromConnectorName","formatWalletName"],"mappings":"6KAsBO,SAASA,CAAAA,EAAuB,CACrC,IAAMC,CAAAA,CAAUC,gBAAAA,EAAW,CAErBC,CAAAA,CAAwBC,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,YAAY,CAAA,CAC9EC,CAAAA,CAAqBF,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,kBAAkB,CAAA,CACjFE,CAAAA,CAAwBH,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,qBAAqB,CAAA,CACvFG,CAAAA,CAAaJ,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,iBAAAA,CAAU,IAAM,CACd,GAAIN,CAAAA,EAAyBO,kCAAAA,CAAyBP,CAAAA,CAAsB,UAAU,CAAA,GAAMQ,sBAAAA,CAAa,OAAQ,CAC/G,IAAMC,CAAAA,CAAeX,CAAAA,CAAQ,MAAA,CAC1BY,CAAAA,EACCC,wCAAAA,CAA+BH,sBAAAA,CAAa,MAAA,CAAQI,0BAAAA,CAAiBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GAC5EV,CAAAA,CAAsB,UAC1B,CAAA,CAAE,CAAC,CAAA,CAEEI,CAAAA,EAGHD,CAAAA,CAAmB,CAEjB,OAAA,CAASM,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAEpC,WAAA,CAAaA,CAAAA,EAAc,SAAS,MAAA,CAAS,CAAA,CAG7C,gBAAA,CAAkBA,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,CAC1C,eAAA,CAAiBA,CACnB,CAAC,CAAA,CAECA,CAAAA,EAAc,QAAA,CAAS,MAAA,GAAW,CAAA,EAEpCJ,CAAAA,GAEJ,CAEF,CAAA,CAAG,CAACL,CAAAA,EAAuB,UAAA,CAAYF,CAAAA,CAASM,CAAAA,CAAuBD,CAAAA,CAAoBE,CAAU,CAAC,CAAA,CAG/F,IACT","file":"index.cjs","sourcesContent":["import {\n formatWalletName,\n getAdapterFromWalletType,\n getWalletTypeFromConnectorName,\n OrbitAdapter,\n} from '@tuwaio/orbit-core';\nimport { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * React component that monitors Solana wallet connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana wallets using the Wallet Standard.\n * Currently handles the first active wallet only, with multi-wallet support planned for future.\n * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.\n *\n * @returns null - This is a headless component\n *\n */\nexport function SolanaWalletsWatcher() {\n const wallets = useWallets();\n\n const activeWalletFromStore = useSatelliteConnectStore((store) => store.activeWallet);\n const updateActiveWallet = useSatelliteConnectStore((store) => store.updateActiveWallet);\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected wallets\n useEffect(() => {\n if (activeWalletFromStore && getAdapterFromWalletType(activeWalletFromStore.walletType) === OrbitAdapter.SOLANA) {\n const activeWallet = wallets.filter(\n (w) =>\n getWalletTypeFromConnectorName(OrbitAdapter.SOLANA, formatWalletName(w.name)) ===\n activeWalletFromStore.walletType,\n )[0];\n\n if (!walletConnectionError) {\n // Update the Satellite store with the active wallet information\n\n updateActiveWallet({\n // Use the first account's address\n address: activeWallet?.accounts[0]?.address,\n // Set connection status\n isConnected: activeWallet?.accounts.length > 0,\n // Store Wallet Standard specific information\n // @ts-expect-error - wallet type is not set fully on the package level\n connectedAccount: activeWallet?.accounts[0],\n connectedWallet: activeWallet,\n });\n }\n if (activeWallet?.accounts.length === 0) {\n // If the wallet is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect();\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeWalletFromStore?.walletType, wallets, walletConnectionError, updateActiveWallet, disconnect]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/solana/SolanaConnectorsWatcher.tsx"],"names":["SolanaConnectorsWatcher","wallets","useWallets","activeConnectionFromStore","useSatelliteConnectStore","store","updateActiveConnection","connectionError","disconnect","useEffect","getAdapterFromConnectorType","OrbitAdapter","activeConnection","w","getConnectorTypeFromName","formatConnectorName","newState"],"mappings":"6KAsBO,SAASA,CAAAA,EAA0B,CACxC,IAAMC,EAAUC,gBAAAA,EAAW,CAErBC,CAAAA,CAA4BC,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CACtFC,EAAyBF,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,sBAAsB,CAAA,CACzFE,CAAAA,CAAkBH,mBAAAA,CAA0BC,CAAAA,EAAUA,EAAM,eAAe,CAAA,CAC3EG,CAAAA,CAAaJ,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,iBAAAA,CAAU,IAAM,CACd,GACEN,CAAAA,EACAO,qCAAAA,CAA4BP,CAAAA,CAA0B,aAAa,IAAMQ,sBAAAA,CAAa,MAAA,CACtF,CACA,IAAMC,CAAAA,CAAmBX,CAAAA,CAAQ,MAAA,CAC9BY,CAAAA,EACCC,mCAAyBH,sBAAAA,CAAa,MAAA,CAAQI,6BAAAA,CAAoBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GACzEV,CAAAA,CAA0B,aAC9B,CAAA,CAAE,CAAC,CAAA,CAEH,GAAI,CAACI,CAAAA,CAAiB,CACpB,IAAMS,CAAAA,CAAW,CAEf,OAAA,CAASJ,CAAAA,EAAkB,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAExC,YAAaA,CAAAA,EAAkB,QAAA,CAAS,MAAA,CAAS,CAAA,CAEjD,gBAAA,CAAkBA,CAAAA,EAAkB,QAAA,CAAS,CAAC,EAC9C,eAAA,CAAiBA,CACnB,CAAA,CAAA,CAMEI,CAAAA,CAAS,OAAA,GAAYb,CAAAA,CAA0B,OAAA,EAC/Ca,CAAAA,CAAS,cAAgBb,CAAAA,CAA0B,WAAA,GAInDG,CAAAA,CAAuBU,CAAQ,EAEnC,CACIJ,CAAAA,EAAkB,QAAA,CAAS,SAAW,CAAA,EAAKT,CAAAA,CAA0B,aAAA,EAEvEK,CAAAA,CAAWL,CAAAA,CAA0B,aAAa,EAEtD,CAEF,EAAG,CAACA,CAAAA,EAA2B,aAAA,CAAeF,CAAAA,CAASM,CAAAA,CAAiBD,CAAAA,CAAwBE,CAAU,CAAC,EAGpG,IACT","file":"index.cjs","sourcesContent":["import {\n formatConnectorName,\n getAdapterFromConnectorType,\n getConnectorTypeFromName,\n OrbitAdapter,\n} from '@tuwaio/orbit-core';\nimport { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * React component that monitors Solana connector connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana connectors using the Wallet Standard.\n * Currently handles the first active connector only, with multi-connector support planned for future.\n * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.\n *\n * @returns null - This is a headless component\n *\n */\nexport function SolanaConnectorsWatcher() {\n const wallets = useWallets();\n\n const activeConnectionFromStore = useSatelliteConnectStore((store) => store.activeConnection);\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected connectors\n useEffect(() => {\n if (\n activeConnectionFromStore &&\n getAdapterFromConnectorType(activeConnectionFromStore.connectorType) === OrbitAdapter.SOLANA\n ) {\n const activeConnection = wallets.filter(\n (w) =>\n getConnectorTypeFromName(OrbitAdapter.SOLANA, formatConnectorName(w.name)) ===\n activeConnectionFromStore.connectorType,\n )[0];\n\n if (!connectionError) {\n const newState = {\n // Use the first account's address\n address: activeConnection?.accounts[0]?.address,\n // Set connection status\n isConnected: activeConnection?.accounts.length > 0,\n // Store Wallet Standard specific information\n connectedAccount: activeConnection?.accounts[0],\n connectedWallet: activeConnection,\n };\n\n // Check if anything actually changed to prevent infinite loops\n // We only check address and isConnected because connectedAccount/connectedWallet\n // might be new references on every render, causing infinite loops if checked.\n const hasChanged =\n newState.address !== activeConnectionFromStore.address ||\n newState.isConnected !== activeConnectionFromStore.isConnected;\n\n if (hasChanged) {\n // Update the Satellite store with the active connector information\n updateActiveConnection(newState);\n }\n }\n if (activeConnection?.accounts.length === 0 && activeConnectionFromStore.connectorType) {\n // If the connector is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect(activeConnectionFromStore.connectorType);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnectionFromStore?.connectorType, wallets, connectionError, updateActiveConnection, disconnect]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n"]}
@@ -1,26 +1,26 @@
1
1
  import { OrbitAdapter } from '@tuwaio/orbit-core';
2
- import { SolanaWallet, ConnectorSolana } from '@tuwaio/satellite-solana';
2
+ import { SolanaConnection, ConnectorSolana } from '@tuwaio/satellite-solana';
3
3
 
4
4
  /**
5
- * React component that monitors Solana wallet connections and updates the Satellite store
5
+ * React component that monitors Solana connector connections and updates the Satellite store
6
6
  *
7
7
  * @remarks
8
- * This component watches for changes in connected Solana wallets using the Wallet Standard.
9
- * Currently handles the first active wallet only, with multi-wallet support planned for future.
8
+ * This component watches for changes in connected Solana connectors using the Wallet Standard.
9
+ * Currently handles the first active connector only, with multi-connector support planned for future.
10
10
  * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.
11
11
  *
12
12
  * @returns null - This is a headless component
13
13
  *
14
14
  */
15
- declare function SolanaWalletsWatcher(): null;
15
+ declare function SolanaConnectorsWatcher(): null;
16
16
 
17
17
  declare module '@tuwaio/satellite-react' {
18
- interface AllWallets {
19
- [OrbitAdapter.SOLANA]: SolanaWallet;
18
+ interface AllConnections {
19
+ [OrbitAdapter.SOLANA]: SolanaConnection;
20
20
  }
21
21
  interface AllConnectors {
22
22
  [OrbitAdapter.SOLANA]: ConnectorSolana;
23
23
  }
24
24
  }
25
25
 
26
- export { SolanaWalletsWatcher };
26
+ export { SolanaConnectorsWatcher };
@@ -1,26 +1,26 @@
1
1
  import { OrbitAdapter } from '@tuwaio/orbit-core';
2
- import { SolanaWallet, ConnectorSolana } from '@tuwaio/satellite-solana';
2
+ import { SolanaConnection, ConnectorSolana } from '@tuwaio/satellite-solana';
3
3
 
4
4
  /**
5
- * React component that monitors Solana wallet connections and updates the Satellite store
5
+ * React component that monitors Solana connector connections and updates the Satellite store
6
6
  *
7
7
  * @remarks
8
- * This component watches for changes in connected Solana wallets using the Wallet Standard.
9
- * Currently handles the first active wallet only, with multi-wallet support planned for future.
8
+ * This component watches for changes in connected Solana connectors using the Wallet Standard.
9
+ * Currently handles the first active connector only, with multi-connector support planned for future.
10
10
  * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.
11
11
  *
12
12
  * @returns null - This is a headless component
13
13
  *
14
14
  */
15
- declare function SolanaWalletsWatcher(): null;
15
+ declare function SolanaConnectorsWatcher(): null;
16
16
 
17
17
  declare module '@tuwaio/satellite-react' {
18
- interface AllWallets {
19
- [OrbitAdapter.SOLANA]: SolanaWallet;
18
+ interface AllConnections {
19
+ [OrbitAdapter.SOLANA]: SolanaConnection;
20
20
  }
21
21
  interface AllConnectors {
22
22
  [OrbitAdapter.SOLANA]: ConnectorSolana;
23
23
  }
24
24
  }
25
25
 
26
- export { SolanaWalletsWatcher };
26
+ export { SolanaConnectorsWatcher };
@@ -1,2 +1,2 @@
1
- import {b}from'../chunk-3WMGCMYX.js';import {getAdapterFromWalletType,OrbitAdapter,getWalletTypeFromConnectorName,formatWalletName}from'@tuwaio/orbit-core';import {useWallets}from'@wallet-standard/react';import {useEffect}from'react';function C(){let l=useWallets(),o=b(t=>t.activeWallet),a=b(t=>t.updateActiveWallet),r=b(t=>t.walletConnectionError),n=b(t=>t.disconnect);return useEffect(()=>{if(o&&getAdapterFromWalletType(o.walletType)===OrbitAdapter.SOLANA){let t=l.filter(i=>getWalletTypeFromConnectorName(OrbitAdapter.SOLANA,formatWalletName(i.name))===o.walletType)[0];r||a({address:t?.accounts[0]?.address,isConnected:t?.accounts.length>0,connectedAccount:t?.accounts[0],connectedWallet:t}),t?.accounts.length===0&&n();}},[o?.walletType,l,r,a,n]),null}export{C as SolanaWalletsWatcher};//# sourceMappingURL=index.js.map
1
+ import {b}from'../chunk-4RWO4WUN.js';import {getAdapterFromConnectorType,OrbitAdapter,getConnectorTypeFromName,formatConnectorName}from'@tuwaio/orbit-core';import {useWallets}from'@wallet-standard/react';import {useEffect}from'react';function h(){let c=useWallets(),o=b(n=>n.activeConnection),r=b(n=>n.updateActiveConnection),a=b(n=>n.connectionError),i=b(n=>n.disconnect);return useEffect(()=>{if(o&&getAdapterFromConnectorType(o.connectorType)===OrbitAdapter.SOLANA){let n=c.filter(e=>getConnectorTypeFromName(OrbitAdapter.SOLANA,formatConnectorName(e.name))===o.connectorType)[0];if(!a){let e={address:n?.accounts[0]?.address,isConnected:n?.accounts.length>0,connectedAccount:n?.accounts[0],connectedWallet:n};(e.address!==o.address||e.isConnected!==o.isConnected)&&r(e);}n?.accounts.length===0&&o.connectorType&&i(o.connectorType);}},[o?.connectorType,c,a,r,i]),null}export{h as SolanaConnectorsWatcher};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/solana/SolanaWalletsWatcher.tsx"],"names":["SolanaWalletsWatcher","wallets","useWallets","activeWalletFromStore","useSatelliteConnectStore","store","updateActiveWallet","walletConnectionError","disconnect","useEffect","getAdapterFromWalletType","OrbitAdapter","activeWallet","w","getWalletTypeFromConnectorName","formatWalletName"],"mappings":"0OAsBO,SAASA,CAAAA,EAAuB,CACrC,IAAMC,CAAAA,CAAUC,UAAAA,EAAW,CAErBC,CAAAA,CAAwBC,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,YAAY,CAAA,CAC9EC,CAAAA,CAAqBF,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,kBAAkB,CAAA,CACjFE,CAAAA,CAAwBH,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,qBAAqB,CAAA,CACvFG,CAAAA,CAAaJ,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,SAAAA,CAAU,IAAM,CACd,GAAIN,CAAAA,EAAyBO,wBAAAA,CAAyBP,CAAAA,CAAsB,UAAU,CAAA,GAAMQ,YAAAA,CAAa,OAAQ,CAC/G,IAAMC,CAAAA,CAAeX,CAAAA,CAAQ,MAAA,CAC1BY,CAAAA,EACCC,8BAAAA,CAA+BH,YAAAA,CAAa,MAAA,CAAQI,gBAAAA,CAAiBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GAC5EV,CAAAA,CAAsB,UAC1B,CAAA,CAAE,CAAC,CAAA,CAEEI,CAAAA,EAGHD,CAAAA,CAAmB,CAEjB,OAAA,CAASM,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAEpC,WAAA,CAAaA,CAAAA,EAAc,SAAS,MAAA,CAAS,CAAA,CAG7C,gBAAA,CAAkBA,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,CAC1C,eAAA,CAAiBA,CACnB,CAAC,CAAA,CAECA,CAAAA,EAAc,QAAA,CAAS,MAAA,GAAW,CAAA,EAEpCJ,CAAAA,GAEJ,CAEF,CAAA,CAAG,CAACL,CAAAA,EAAuB,UAAA,CAAYF,CAAAA,CAASM,CAAAA,CAAuBD,CAAAA,CAAoBE,CAAU,CAAC,CAAA,CAG/F,IACT","file":"index.js","sourcesContent":["import {\n formatWalletName,\n getAdapterFromWalletType,\n getWalletTypeFromConnectorName,\n OrbitAdapter,\n} from '@tuwaio/orbit-core';\nimport { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * React component that monitors Solana wallet connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana wallets using the Wallet Standard.\n * Currently handles the first active wallet only, with multi-wallet support planned for future.\n * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.\n *\n * @returns null - This is a headless component\n *\n */\nexport function SolanaWalletsWatcher() {\n const wallets = useWallets();\n\n const activeWalletFromStore = useSatelliteConnectStore((store) => store.activeWallet);\n const updateActiveWallet = useSatelliteConnectStore((store) => store.updateActiveWallet);\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected wallets\n useEffect(() => {\n if (activeWalletFromStore && getAdapterFromWalletType(activeWalletFromStore.walletType) === OrbitAdapter.SOLANA) {\n const activeWallet = wallets.filter(\n (w) =>\n getWalletTypeFromConnectorName(OrbitAdapter.SOLANA, formatWalletName(w.name)) ===\n activeWalletFromStore.walletType,\n )[0];\n\n if (!walletConnectionError) {\n // Update the Satellite store with the active wallet information\n\n updateActiveWallet({\n // Use the first account's address\n address: activeWallet?.accounts[0]?.address,\n // Set connection status\n isConnected: activeWallet?.accounts.length > 0,\n // Store Wallet Standard specific information\n // @ts-expect-error - wallet type is not set fully on the package level\n connectedAccount: activeWallet?.accounts[0],\n connectedWallet: activeWallet,\n });\n }\n if (activeWallet?.accounts.length === 0) {\n // If the wallet is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect();\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeWalletFromStore?.walletType, wallets, walletConnectionError, updateActiveWallet, disconnect]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/solana/SolanaConnectorsWatcher.tsx"],"names":["SolanaConnectorsWatcher","wallets","useWallets","activeConnectionFromStore","useSatelliteConnectStore","store","updateActiveConnection","connectionError","disconnect","useEffect","getAdapterFromConnectorType","OrbitAdapter","activeConnection","w","getConnectorTypeFromName","formatConnectorName","newState"],"mappings":"0OAsBO,SAASA,CAAAA,EAA0B,CACxC,IAAMC,EAAUC,UAAAA,EAAW,CAErBC,CAAAA,CAA4BC,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CACtFC,EAAyBF,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,sBAAsB,CAAA,CACzFE,CAAAA,CAAkBH,CAAAA,CAA0BC,CAAAA,EAAUA,EAAM,eAAe,CAAA,CAC3EG,CAAAA,CAAaJ,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,SAAAA,CAAU,IAAM,CACd,GACEN,CAAAA,EACAO,2BAAAA,CAA4BP,CAAAA,CAA0B,aAAa,IAAMQ,YAAAA,CAAa,MAAA,CACtF,CACA,IAAMC,CAAAA,CAAmBX,CAAAA,CAAQ,MAAA,CAC9BY,CAAAA,EACCC,yBAAyBH,YAAAA,CAAa,MAAA,CAAQI,mBAAAA,CAAoBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GACzEV,CAAAA,CAA0B,aAC9B,CAAA,CAAE,CAAC,CAAA,CAEH,GAAI,CAACI,CAAAA,CAAiB,CACpB,IAAMS,CAAAA,CAAW,CAEf,OAAA,CAASJ,CAAAA,EAAkB,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAExC,YAAaA,CAAAA,EAAkB,QAAA,CAAS,MAAA,CAAS,CAAA,CAEjD,gBAAA,CAAkBA,CAAAA,EAAkB,QAAA,CAAS,CAAC,EAC9C,eAAA,CAAiBA,CACnB,CAAA,CAAA,CAMEI,CAAAA,CAAS,OAAA,GAAYb,CAAAA,CAA0B,OAAA,EAC/Ca,CAAAA,CAAS,cAAgBb,CAAAA,CAA0B,WAAA,GAInDG,CAAAA,CAAuBU,CAAQ,EAEnC,CACIJ,CAAAA,EAAkB,QAAA,CAAS,SAAW,CAAA,EAAKT,CAAAA,CAA0B,aAAA,EAEvEK,CAAAA,CAAWL,CAAAA,CAA0B,aAAa,EAEtD,CAEF,EAAG,CAACA,CAAAA,EAA2B,aAAA,CAAeF,CAAAA,CAASM,CAAAA,CAAiBD,CAAAA,CAAwBE,CAAU,CAAC,EAGpG,IACT","file":"index.js","sourcesContent":["import {\n formatConnectorName,\n getAdapterFromConnectorType,\n getConnectorTypeFromName,\n OrbitAdapter,\n} from '@tuwaio/orbit-core';\nimport { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * React component that monitors Solana connector connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana connectors using the Wallet Standard.\n * Currently handles the first active connector only, with multi-connector support planned for future.\n * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.\n *\n * @returns null - This is a headless component\n *\n */\nexport function SolanaConnectorsWatcher() {\n const wallets = useWallets();\n\n const activeConnectionFromStore = useSatelliteConnectStore((store) => store.activeConnection);\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected connectors\n useEffect(() => {\n if (\n activeConnectionFromStore &&\n getAdapterFromConnectorType(activeConnectionFromStore.connectorType) === OrbitAdapter.SOLANA\n ) {\n const activeConnection = wallets.filter(\n (w) =>\n getConnectorTypeFromName(OrbitAdapter.SOLANA, formatConnectorName(w.name)) ===\n activeConnectionFromStore.connectorType,\n )[0];\n\n if (!connectionError) {\n const newState = {\n // Use the first account's address\n address: activeConnection?.accounts[0]?.address,\n // Set connection status\n isConnected: activeConnection?.accounts.length > 0,\n // Store Wallet Standard specific information\n connectedAccount: activeConnection?.accounts[0],\n connectedWallet: activeConnection,\n };\n\n // Check if anything actually changed to prevent infinite loops\n // We only check address and isConnected because connectedAccount/connectedWallet\n // might be new references on every render, causing infinite loops if checked.\n const hasChanged =\n newState.address !== activeConnectionFromStore.address ||\n newState.isConnected !== activeConnectionFromStore.isConnected;\n\n if (hasChanged) {\n // Update the Satellite store with the active connector information\n updateActiveConnection(newState);\n }\n }\n if (activeConnection?.accounts.length === 0 && activeConnectionFromStore.connectorType) {\n // If the connector is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect(activeConnectionFromStore.connectorType);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnectionFromStore?.connectorType, wallets, connectionError, updateActiveConnection, disconnect]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n"]}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@tuwaio/satellite-react",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",
7
- "description": "An provider and hook with for React for satellite based wallets.",
7
+ "description": "An provider and hook with for React for satellite based connectors.",
8
8
  "type": "module",
9
9
  "main": "./dist/index.js",
10
10
  "module": "./dist/index.cjs",
@@ -56,19 +56,18 @@
56
56
  }
57
57
  ],
58
58
  "peerDependencies": {
59
- "@tuwaio/orbit-core": ">=0.1",
60
- "@tuwaio/orbit-evm": ">=0.1",
61
- "@tuwaio/orbit-solana": ">=0.1",
62
- "@tuwaio/satellite-core": ">=0.1",
63
- "@tuwaio/satellite-evm": ">=0.1",
64
- "@tuwaio/satellite-solana": ">=0.1",
65
- "@wagmi/core": "2.x.x",
66
- "@wagmi/connectors": "6.x.x",
59
+ "@tuwaio/orbit-core": ">=0.2",
60
+ "@tuwaio/orbit-evm": ">=0.2",
61
+ "@tuwaio/orbit-solana": ">=0.2",
62
+ "@tuwaio/satellite-core": ">=0.2",
63
+ "@tuwaio/satellite-evm": ">=0.2",
64
+ "@tuwaio/satellite-solana": ">=0.2",
65
+ "@wagmi/core": "3.x.x",
67
66
  "viem": "2.x.x",
68
67
  "@wallet-standard/react": "1.x.x",
69
- "gill": ">=0.12",
68
+ "gill": ">=0.14",
70
69
  "react": "19.x.x",
71
- "immer": "10.x.x",
70
+ "immer": "11.x.x",
72
71
  "zustand": "5.x.x"
73
72
  },
74
73
  "peerDependenciesMeta": {
@@ -96,9 +95,6 @@
96
95
  "@wagmi/core": {
97
96
  "optional": true
98
97
  },
99
- "@wagmi/connectors": {
100
- "optional": true
101
- },
102
98
  "viem": {
103
99
  "optional": true
104
100
  },
@@ -116,12 +112,11 @@
116
112
  }
117
113
  },
118
114
  "devDependencies": {
119
- "@types/react": "^19.2.2",
120
- "@tuwaio/orbit-core": "^0.1.0",
121
- "@tuwaio/orbit-evm": "^0.1.0",
122
- "@tuwaio/orbit-solana": "^0.1.0",
123
- "@wagmi/core": "^2.22.1",
124
- "@wagmi/connectors": "^6.0.1",
115
+ "@types/react": "^19.2.7",
116
+ "@tuwaio/orbit-core": "^0.2.0",
117
+ "@tuwaio/orbit-evm": "^0.2.0",
118
+ "@tuwaio/orbit-solana": "^0.2.0",
119
+ "@wagmi/core": "^3.0.0",
125
120
  "@wallet-standard/react": "^1.0.1",
126
121
  "@wallet-standard/app": "^1.1.0",
127
122
  "@wallet-standard/base": "^1.1.0",
@@ -129,16 +124,16 @@
129
124
  "@wallet-standard/core": "^1.1.1",
130
125
  "@wallet-standard/ui": "^1.0.1",
131
126
  "@wallet-standard/ui-registry": "^1.0.1",
132
- "gill": "^0.12.0",
133
- "immer": "^10.1.3",
127
+ "gill": "^0.14.0",
128
+ "immer": "^11.0.1",
134
129
  "react": "^19.2.0",
135
- "tsup": "^8.5.0",
136
- "viem": "^2.38.3",
130
+ "tsup": "^8.5.1",
131
+ "viem": "^2.40.3",
137
132
  "typescript": "^5.9.3",
138
- "zustand": "^5.0.8",
139
- "@tuwaio/satellite-evm": "^0.1.2",
140
- "@tuwaio/satellite-core": "^0.1.1",
141
- "@tuwaio/satellite-solana": "^0.1.1"
133
+ "zustand": "^5.0.9",
134
+ "@tuwaio/satellite-core": "^0.2.0",
135
+ "@tuwaio/satellite-solana": "^0.2.0",
136
+ "@tuwaio/satellite-evm": "^0.2.0"
142
137
  },
143
138
  "scripts": {
144
139
  "start": "tsup src/index.ts --watch",
@@ -1,2 +0,0 @@
1
- import {createContext,useContext,useEffect,useMemo}from'react';import {useStore}from'zustand';import {createSatelliteConnectStore}from'@tuwaio/satellite-core';import {jsx}from'react/jsx-runtime';var r=createContext(null),A=e=>{let t=useContext(r);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return useStore(t,e)};var i=({initializeAutoConnect:e,onError:t})=>{useEffect(()=>{(async()=>{try{await e();}catch(o){(t??(l=>console.error("Failed to initialize auto connect:",l)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=useMemo(()=>createSatelliteConnectStore({...n}),[]);return useEffect(()=>{o.getState().disconnectAll();},[]),i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsx(r.Provider,{value:o,children:e})}export{r as a,A as b,i as c,b as d};//# sourceMappingURL=chunk-3WMGCMYX.js.map
2
- //# sourceMappingURL=chunk-3WMGCMYX.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/satteliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx"],"mappings":"uMAUaA,CAAAA,CAAwBC,aAAAA,CAA0E,IAAI,CAAA,CAqBtGC,EAA+BC,CAAAA,EAAyE,CAEnH,IAAMC,CAAAA,CAAQC,UAAAA,CAAWL,CAAqB,CAAA,CAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,QAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECDO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,SAAAA,CAAU,IAAM,EACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,EAEOF,CAAAA,GAAaG,CAAAA,EAAa,OAAA,CAAQ,KAAA,CAAM,qCAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,SAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,CAAA,CAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,QAAQ,IACbC,2BAAAA,CAA+C,CACpD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAGL,OAAAN,SAAAA,CAAU,IAAM,CACdN,CAAAA,CAAM,QAAA,EAAS,CAAE,aAAA,GAEnB,CAAA,CAAG,EAAE,CAAA,CAELG,EAAyB,CACvB,qBAAA,CAAuB,IAAMH,CAAAA,CAAM,UAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,GAAAA,CAACnB,CAAAA,CAAsB,SAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-3WMGCMYX.js","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connector, Wallet } from '../types';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore<Connector, Wallet>> | null>(null);\n\n/**\n * Custom hook for accessing the Satellite Connect store state\n *\n * @remarks\n * This hook provides type-safe access to the Satellite store state and must be used\n * within a component that is wrapped by SatelliteConnectProvider.\n *\n * @typeParam T - The type of the selected state slice\n * @param selector - Function that selects a slice of the store state\n * @returns Selected state slice\n *\n * @throws Error if used outside of SatelliteConnectProvider\n *\n * @example\n * ```tsx\n * // Get the active wallet\n * const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);\n * ```\n */\nexport const useSatelliteConnectStore = <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T): T => {\n // Get store instance from context\n const store = useContext(SatelliteStoreContext);\n\n // Ensure hook is used within provider\n if (!store) {\n throw new Error('useSatelliteConnectStore must be used within a SatelliteConnectProvider');\n }\n\n // Return selected state using Zustand's useStore\n return useStore(store, selector);\n};\n","import { useEffect } from 'react';\n\n/**\n * Props for the useInitializeAutoConnect hook.\n */\ninterface InitializeAutoConnectProps {\n /** Function to initialize auto connect logic */\n initializeAutoConnect: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing wallet auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected wallet) when a component mounts.\n * It provides default error handling with console.error if no custom handler is provided.\n * The initialization runs only once when the component mounts.\n *\n * @param props - Hook configuration\n * @param props.initializeAutoConnect - Async function that executes the auto-connect logic\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect\n * });\n *\n * // With custom error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect,\n * onError: (error) => {\n * toast.error(`Failed to auto-connect: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAutoConnect = ({ initializeAutoConnect, onError }: InitializeAutoConnectProps): void => {\n useEffect(() => {\n const initializeAutoConnectLocal = async () => {\n try {\n await initializeAutoConnect();\n } catch (error) {\n // Use provided error handler or fallback to default console.error\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize auto connect:', e));\n errorHandler(error as Error);\n }\n };\n // Initialize auto connect when component mounts\n initializeAutoConnectLocal();\n }, []); // Empty dependency array ensures single execution\n};\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useEffect, useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satteliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connector, Wallet } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used wallet */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages wallet connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles wallet connections, state management, and automatic reconnection functionality.\n * The store is memoized to ensure stable reference across renders.\n *\n * @param props - Component properties including store parameters and children\n * @param props.children - Child components that will have access to the store\n * @param props.autoConnect - Optional flag to enable automatic wallet reconnection\n * @param props.adapter - Blockchain adapter(s) for wallet interactions\n * @param props.callbackAfterConnected - Optional callback for successful connections\n *\n * @example\n * ```tsx\n * // Basic usage with single adapter\n * <SatelliteConnectProvider adapter={solanaAdapter}>\n * <App />\n * </SatelliteConnectProvider>\n *\n * // With auto-connect and multiple adapters\n * <SatelliteConnectProvider\n * adapter={[solanaAdapter, evmAdapter]}\n * autoConnect={true}\n * callbackAfterConnected={(wallet) => {\n * console.log('Wallet connected:', wallet.address);\n * }}\n * >\n * <App />\n * </SatelliteConnectProvider>\n * ```\n */\nexport function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps) {\n // Create and memoize the store instance\n const store = useMemo(() => {\n return createSatelliteConnectStore<Connector, Wallet>({\n ...parameters,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Empty dependency array as store should be created only once\n\n // Disconnect from any existing wallets on mount\n useEffect(() => {\n store.getState().disconnectAll();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/satteliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx"],"mappings":"+JAUaA,CAAAA,CAAwBC,mBAAAA,CAA0E,IAAI,CAAA,CAqBtGC,EAA+BC,CAAAA,EAAyE,CAEnH,IAAMC,CAAAA,CAAQC,gBAAAA,CAAWL,CAAqB,CAAA,CAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,gBAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECDO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,eAAAA,CAAU,IAAM,EACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,EAEOF,CAAAA,GAAaG,CAAAA,EAAa,OAAA,CAAQ,KAAA,CAAM,qCAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,SAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,CAAA,CAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,cAAQ,IACbC,yCAAAA,CAA+C,CACpD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAGL,OAAAN,eAAAA,CAAU,IAAM,CACdN,CAAAA,CAAM,QAAA,EAAS,CAAE,aAAA,GAEnB,CAAA,CAAG,EAAE,CAAA,CAELG,EAAyB,CACvB,qBAAA,CAAuB,IAAMH,CAAAA,CAAM,UAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,cAAAA,CAACnB,CAAAA,CAAsB,SAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-YC7F3NGW.cjs","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connector, Wallet } from '../types';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore<Connector, Wallet>> | null>(null);\n\n/**\n * Custom hook for accessing the Satellite Connect store state\n *\n * @remarks\n * This hook provides type-safe access to the Satellite store state and must be used\n * within a component that is wrapped by SatelliteConnectProvider.\n *\n * @typeParam T - The type of the selected state slice\n * @param selector - Function that selects a slice of the store state\n * @returns Selected state slice\n *\n * @throws Error if used outside of SatelliteConnectProvider\n *\n * @example\n * ```tsx\n * // Get the active wallet\n * const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);\n * ```\n */\nexport const useSatelliteConnectStore = <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T): T => {\n // Get store instance from context\n const store = useContext(SatelliteStoreContext);\n\n // Ensure hook is used within provider\n if (!store) {\n throw new Error('useSatelliteConnectStore must be used within a SatelliteConnectProvider');\n }\n\n // Return selected state using Zustand's useStore\n return useStore(store, selector);\n};\n","import { useEffect } from 'react';\n\n/**\n * Props for the useInitializeAutoConnect hook.\n */\ninterface InitializeAutoConnectProps {\n /** Function to initialize auto connect logic */\n initializeAutoConnect: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing wallet auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected wallet) when a component mounts.\n * It provides default error handling with console.error if no custom handler is provided.\n * The initialization runs only once when the component mounts.\n *\n * @param props - Hook configuration\n * @param props.initializeAutoConnect - Async function that executes the auto-connect logic\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect\n * });\n *\n * // With custom error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect,\n * onError: (error) => {\n * toast.error(`Failed to auto-connect: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAutoConnect = ({ initializeAutoConnect, onError }: InitializeAutoConnectProps): void => {\n useEffect(() => {\n const initializeAutoConnectLocal = async () => {\n try {\n await initializeAutoConnect();\n } catch (error) {\n // Use provided error handler or fallback to default console.error\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize auto connect:', e));\n errorHandler(error as Error);\n }\n };\n // Initialize auto connect when component mounts\n initializeAutoConnectLocal();\n }, []); // Empty dependency array ensures single execution\n};\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useEffect, useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satteliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connector, Wallet } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used wallet */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages wallet connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles wallet connections, state management, and automatic reconnection functionality.\n * The store is memoized to ensure stable reference across renders.\n *\n * @param props - Component properties including store parameters and children\n * @param props.children - Child components that will have access to the store\n * @param props.autoConnect - Optional flag to enable automatic wallet reconnection\n * @param props.adapter - Blockchain adapter(s) for wallet interactions\n * @param props.callbackAfterConnected - Optional callback for successful connections\n *\n * @example\n * ```tsx\n * // Basic usage with single adapter\n * <SatelliteConnectProvider adapter={solanaAdapter}>\n * <App />\n * </SatelliteConnectProvider>\n *\n * // With auto-connect and multiple adapters\n * <SatelliteConnectProvider\n * adapter={[solanaAdapter, evmAdapter]}\n * autoConnect={true}\n * callbackAfterConnected={(wallet) => {\n * console.log('Wallet connected:', wallet.address);\n * }}\n * >\n * <App />\n * </SatelliteConnectProvider>\n * ```\n */\nexport function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps) {\n // Create and memoize the store instance\n const store = useMemo(() => {\n return createSatelliteConnectStore<Connector, Wallet>({\n ...parameters,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Empty dependency array as store should be created only once\n\n // Disconnect from any existing wallets on mount\n useEffect(() => {\n store.getState().disconnectAll();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}