@tuwaio/satellite-react 0.0.4 → 0.1.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.
@@ -0,0 +1,2 @@
1
+ 'use strict';var orbitCore=require('@tuwaio/orbit-core'),core=require('@wagmi/core'),react=require('react');function V({wagmiConfig:i,store:d,siwe:t}){let{activeWallet:n,updateActiveWallet:c,walletConnectionError:a,disconnect:r}=d;return react.useEffect(()=>{t?.enabled&&!t?.isSignedIn&&t?.isRejected&&r();},[t,r]),react.useEffect(()=>core.watchAccount(i,{onChange:e=>{if(e?.status==="disconnected"&&r(),n&&orbitCore.getAdapterFromWalletType(n.walletType)!==orbitCore.OrbitAdapter.EVM||!e.address||a)return;if(t?.enabled?t.isSignedIn:true){let o=n?.walletType,s=o?{walletType:o,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};c(s);}}}),[n?.walletType,t,a]),null}exports.EVMWalletsWatcher=V;//# sourceMappingURL=index.cjs.map
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","store","siwe","activeWallet","updateActiveWallet","walletConnectionError","disconnect","useEffect","watchAccount","account","getAdapterFromWalletType","OrbitAdapter","walletType","walletUpdate"],"mappings":"4GAMO,SAASA,EAAkB,CAChC,WAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CACF,CAAA,CAWG,CACD,GAAM,CAAE,YAAA,CAAAC,CAAAA,CAAc,mBAAAC,CAAAA,CAAoB,qBAAA,CAAAC,CAAAA,CAAuB,UAAA,CAAAC,CAAW,CAAA,CAAIL,CAAAA,CAEhF,OAAAM,eAAAA,CAAU,IAAM,CACVL,CAAAA,EAAM,OAAA,EAAW,CAACA,CAAAA,EAAM,UAAA,EAAcA,CAAAA,EAAM,UAAA,EAC9CI,IAEJ,CAAA,CAAG,CAACJ,CAAAA,CAAMI,CAAU,CAAC,CAAA,CAErBC,eAAAA,CAAU,IAqCQC,iBAAAA,CAAaR,CAAAA,CAAa,CAAE,QAAA,CApCqBS,GAAY,CAK3E,GAJIA,CAAAA,EAAS,MAAA,GAAW,gBACtBH,CAAAA,EAAW,CAIVH,CAAAA,EAAgBO,kCAAAA,CAAyBP,EAAa,UAAU,CAAA,GAAMQ,sBAAAA,CAAa,GAAA,EACpF,CAACF,CAAAA,CAAQ,OAAA,EACTJ,CAAAA,CAEA,OAKF,GAFqBH,CAAAA,EAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAChB,IAAMU,CAAAA,CAAaT,GAAc,UAAA,CAC3BU,CAAAA,CAAeD,CAAAA,CACjB,CACE,UAAA,CAAAA,CAAAA,CACA,OAAA,CAASH,CAAAA,CAAQ,QACjB,OAAA,CAASA,CAAAA,CAAQ,OAAA,CACjB,MAAA,CAAQA,EAAQ,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAC7C,WAAA,CAAaA,CAAAA,CAAQ,WACvB,CAAA,CACA,CACE,OAAA,CAASA,CAAAA,CAAQ,QACjB,OAAA,CAASA,CAAAA,CAAQ,OAAA,CACjB,MAAA,CAAQA,EAAQ,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAC7C,WAAA,CAAaA,CAAAA,CAAQ,WACvB,CAAA,CAEJL,CAAAA,CAAmBS,CAAY,EACjC,CACF,CAE0E,CAAC,CAAA,CAI1E,CAACV,GAAc,UAAA,CAAYD,CAAAA,CAAMG,CAAqB,CAAC,EAEnD,IACT","file":"index.cjs","sourcesContent":["import { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { ConnectorEVM, EVMWallet } from '@tuwaio/satellite-evm';\nimport { Config, watchAccount, WatchAccountParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nexport function EVMWalletsWatcher({\n wagmiConfig,\n store,\n siwe,\n}: {\n wagmiConfig: Config;\n store: Pick<\n ISatelliteConnectStore<ConnectorEVM, EVMWallet>,\n 'activeWallet' | 'updateActiveWallet' | 'walletConnectionError' | 'disconnect'\n >;\n siwe?: {\n isRejected: boolean;\n isSignedIn: boolean;\n enabled?: boolean;\n };\n}) {\n const { activeWallet, updateActiveWallet, walletConnectionError, disconnect } = store;\n\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n disconnect();\n }\n }, [siwe, disconnect]);\n\n useEffect(() => {\n const handleAccountChange: WatchAccountParameters['onChange'] = (account) => {\n if (account?.status === 'disconnected') {\n disconnect();\n }\n\n if (\n (activeWallet && getAdapterFromWalletType(activeWallet.walletType) !== OrbitAdapter.EVM) ||\n !account.address ||\n walletConnectionError\n ) {\n return;\n }\n\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n const walletType = activeWallet?.walletType;\n const walletUpdate = walletType\n ? {\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 address: account.address,\n chainId: account.chainId,\n rpcURL: account.chain?.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n };\n\n updateActiveWallet(walletUpdate);\n }\n };\n\n const unwatch = watchAccount(wagmiConfig, { onChange: handleAccountChange });\n\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeWallet?.walletType, siwe, walletConnectionError]);\n\n return null;\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { OrbitAdapter } from '@tuwaio/orbit-core';
2
+ import { ConnectorEVM, EVMWallet } from '@tuwaio/satellite-evm';
3
+ import { ISatelliteConnectStore } from '@tuwaio/satellite-core';
4
+ import { Config } from '@wagmi/core';
5
+
6
+ declare function EVMWalletsWatcher({ wagmiConfig, store, siwe, }: {
7
+ wagmiConfig: Config;
8
+ store: Pick<ISatelliteConnectStore<ConnectorEVM, EVMWallet>, 'activeWallet' | 'updateActiveWallet' | 'walletConnectionError' | 'disconnect'>;
9
+ siwe?: {
10
+ isRejected: boolean;
11
+ isSignedIn: boolean;
12
+ enabled?: boolean;
13
+ };
14
+ }): null;
15
+
16
+ declare module '@tuwaio/satellite-react' {
17
+ interface AllWallets {
18
+ [OrbitAdapter.EVM]: EVMWallet;
19
+ }
20
+ interface AllConnectors {
21
+ [OrbitAdapter.EVM]: ConnectorEVM;
22
+ }
23
+ }
24
+
25
+ export { EVMWalletsWatcher };
@@ -0,0 +1,25 @@
1
+ import { OrbitAdapter } from '@tuwaio/orbit-core';
2
+ import { ConnectorEVM, EVMWallet } from '@tuwaio/satellite-evm';
3
+ import { ISatelliteConnectStore } from '@tuwaio/satellite-core';
4
+ import { Config } from '@wagmi/core';
5
+
6
+ declare function EVMWalletsWatcher({ wagmiConfig, store, siwe, }: {
7
+ wagmiConfig: Config;
8
+ store: Pick<ISatelliteConnectStore<ConnectorEVM, EVMWallet>, 'activeWallet' | 'updateActiveWallet' | 'walletConnectionError' | 'disconnect'>;
9
+ siwe?: {
10
+ isRejected: boolean;
11
+ isSignedIn: boolean;
12
+ enabled?: boolean;
13
+ };
14
+ }): null;
15
+
16
+ declare module '@tuwaio/satellite-react' {
17
+ interface AllWallets {
18
+ [OrbitAdapter.EVM]: EVMWallet;
19
+ }
20
+ interface AllConnectors {
21
+ [OrbitAdapter.EVM]: ConnectorEVM;
22
+ }
23
+ }
24
+
25
+ export { EVMWalletsWatcher };
@@ -0,0 +1,2 @@
1
+ import {getAdapterFromWalletType,OrbitAdapter}from'@tuwaio/orbit-core';import {watchAccount}from'@wagmi/core';import {useEffect}from'react';function V({wagmiConfig:i,store:d,siwe:t}){let{activeWallet:n,updateActiveWallet:c,walletConnectionError:a,disconnect:r}=d;return useEffect(()=>{t?.enabled&&!t?.isSignedIn&&t?.isRejected&&r();},[t,r]),useEffect(()=>watchAccount(i,{onChange:e=>{if(e?.status==="disconnected"&&r(),n&&getAdapterFromWalletType(n.walletType)!==OrbitAdapter.EVM||!e.address||a)return;if(t?.enabled?t.isSignedIn:true){let o=n?.walletType,s=o?{walletType:o,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};c(s);}}}),[n?.walletType,t,a]),null}export{V as EVMWalletsWatcher};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","store","siwe","activeWallet","updateActiveWallet","walletConnectionError","disconnect","useEffect","watchAccount","account","getAdapterFromWalletType","OrbitAdapter","walletType","walletUpdate"],"mappings":"4IAMO,SAASA,EAAkB,CAChC,WAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,CAAAA,CACA,IAAA,CAAAC,CACF,CAAA,CAWG,CACD,GAAM,CAAE,YAAA,CAAAC,CAAAA,CAAc,mBAAAC,CAAAA,CAAoB,qBAAA,CAAAC,CAAAA,CAAuB,UAAA,CAAAC,CAAW,CAAA,CAAIL,CAAAA,CAEhF,OAAAM,SAAAA,CAAU,IAAM,CACVL,CAAAA,EAAM,OAAA,EAAW,CAACA,CAAAA,EAAM,UAAA,EAAcA,CAAAA,EAAM,UAAA,EAC9CI,IAEJ,CAAA,CAAG,CAACJ,CAAAA,CAAMI,CAAU,CAAC,CAAA,CAErBC,SAAAA,CAAU,IAqCQC,YAAAA,CAAaR,CAAAA,CAAa,CAAE,QAAA,CApCqBS,GAAY,CAK3E,GAJIA,CAAAA,EAAS,MAAA,GAAW,gBACtBH,CAAAA,EAAW,CAIVH,CAAAA,EAAgBO,wBAAAA,CAAyBP,EAAa,UAAU,CAAA,GAAMQ,YAAAA,CAAa,GAAA,EACpF,CAACF,CAAAA,CAAQ,OAAA,EACTJ,CAAAA,CAEA,OAKF,GAFqBH,CAAAA,EAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAChB,IAAMU,CAAAA,CAAaT,GAAc,UAAA,CAC3BU,CAAAA,CAAeD,CAAAA,CACjB,CACE,UAAA,CAAAA,CAAAA,CACA,OAAA,CAASH,CAAAA,CAAQ,QACjB,OAAA,CAASA,CAAAA,CAAQ,OAAA,CACjB,MAAA,CAAQA,EAAQ,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAC7C,WAAA,CAAaA,CAAAA,CAAQ,WACvB,CAAA,CACA,CACE,OAAA,CAASA,CAAAA,CAAQ,QACjB,OAAA,CAASA,CAAAA,CAAQ,OAAA,CACjB,MAAA,CAAQA,EAAQ,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAC7C,WAAA,CAAaA,CAAAA,CAAQ,WACvB,CAAA,CAEJL,CAAAA,CAAmBS,CAAY,EACjC,CACF,CAE0E,CAAC,CAAA,CAI1E,CAACV,GAAc,UAAA,CAAYD,CAAAA,CAAMG,CAAqB,CAAC,EAEnD,IACT","file":"index.js","sourcesContent":["import { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { ConnectorEVM, EVMWallet } from '@tuwaio/satellite-evm';\nimport { Config, watchAccount, WatchAccountParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nexport function EVMWalletsWatcher({\n wagmiConfig,\n store,\n siwe,\n}: {\n wagmiConfig: Config;\n store: Pick<\n ISatelliteConnectStore<ConnectorEVM, EVMWallet>,\n 'activeWallet' | 'updateActiveWallet' | 'walletConnectionError' | 'disconnect'\n >;\n siwe?: {\n isRejected: boolean;\n isSignedIn: boolean;\n enabled?: boolean;\n };\n}) {\n const { activeWallet, updateActiveWallet, walletConnectionError, disconnect } = store;\n\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n disconnect();\n }\n }, [siwe, disconnect]);\n\n useEffect(() => {\n const handleAccountChange: WatchAccountParameters['onChange'] = (account) => {\n if (account?.status === 'disconnected') {\n disconnect();\n }\n\n if (\n (activeWallet && getAdapterFromWalletType(activeWallet.walletType) !== OrbitAdapter.EVM) ||\n !account.address ||\n walletConnectionError\n ) {\n return;\n }\n\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n const walletType = activeWallet?.walletType;\n const walletUpdate = walletType\n ? {\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 address: account.address,\n chainId: account.chainId,\n rpcURL: account.chain?.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n };\n\n updateActiveWallet(walletUpdate);\n }\n };\n\n const unwatch = watchAccount(wagmiConfig, { onChange: handleAccountChange });\n\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeWallet?.walletType, siwe, walletConnectionError]);\n\n return null;\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var orbitCore=require('@tuwaio/orbit-core'),core=require('@wagmi/core'),react=require('react'),zustand=require('zustand'),react$1=require('@wallet-standard/react'),satelliteCore=require('@tuwaio/satellite-core'),jsxRuntime=require('react/jsx-runtime');var i=react.createContext(null),r=t=>{let o=react.useContext(i);if(!o)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return zustand.useStore(o,t)};function b({wagmiConfig:t}){let o=r(e=>e.updateActiveWallet);return core.watchAccount(t,{onChange:async e=>{o({walletType:`${orbitCore.OrbitAdapter.EVM}:${e?.connector?.type}`,address:e.address,chainId:e.chainId,rpcURL:e.chain?.rpcUrls.default.http[0],isConnected:e.isConnected});}}),null}function V(){let t=react$1.useWallets(),o=r(e=>e.updateActiveWallet);return react.useEffect(()=>{let e=t.filter(n=>n.accounts.length>0)[0];e&&o({address:e.accounts[0].address,isConnected:true,connectedAccount:e.accounts[0],connectedWallet:e});},[t]),null}var l=({initializeAppConnectors:t,onError:o})=>{react.useEffect(()=>{(async()=>{try{await t();}catch(n){(o??(c=>console.error("Failed to initialize connectors:",c)))(n);}})();},[]);};function a({autoConnect:t}){let o=r(e=>e.initializeAppConnectors);return l({initializeAppConnectors:()=>o({autoConnect:t})}),null}function K({children:t,autoConnect:o,...e}){let n=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({...e}),[]);return jsxRuntime.jsxs(i.Provider,{value:n,children:[jsxRuntime.jsx(a,{autoConnect:o}),t]})}exports.EVMWalletsWatcher=b;exports.InitializeConnectorsProvider=a;exports.SatelliteConnectProvider=K;exports.SatelliteStoreContext=i;exports.SolanaWalletsWatcher=V;exports.useInitializeAppConnectors=l;exports.useSatelliteConnectStore=r;//# sourceMappingURL=index.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),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.SatelliteConnectProvider=b;exports.SatelliteStoreContext=r;exports.useInitializeAutoConnect=i;exports.useSatelliteConnectStore=A;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/satteliteHook.ts","../src/components/EVMWalletsWatcher.tsx","../src/components/SolanaWalletsWatcher.tsx","../src/hooks/useInitializeConnectors.tsx","../src/providers/InitializeConnectorsProvider.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","EVMWalletsWatcher","wagmiConfig","updateActiveWallet","state","watchAccount","account","OrbitAdapter","SolanaWalletsWatcher","wallets","useWallets","useEffect","activeWallet","wallet","useInitializeAppConnectors","initializeAppConnectors","onError","error","e","InitializeConnectorsProvider","autoConnect","SatelliteConnectProvider","children","parameters","useMemo","createSatelliteConnectStore","jsxs","jsx"],"mappings":"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","file":"index.cjs","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore> | 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) => 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 { OrbitAdapter } from '@tuwaio/orbit-core';\nimport { WalletType } from '@tuwaio/satellite-core';\nimport { Config, watchAccount } from '@wagmi/core';\n\nimport { useSatelliteConnectStore } from '../hooks/satteliteHook';\n\n/**\n * React component that watches for EVM wallet account changes and updates the Satellite store\n *\n * @remarks\n * This component acts as a bridge between Wagmi account state and Satellite store.\n * It doesn't render anything visible but maintains wallet state synchronization.\n *\n * @param props - Component properties\n * @param props.wagmiConfig - Wagmi configuration instance\n *\n * @returns null - This is a headless component\n **/\nexport function EVMWalletsWatcher({ wagmiConfig }: { wagmiConfig: Config }) {\n // Get the updateActiveWallet function from the Satellite store\n const updateActiveWallet = useSatelliteConnectStore((state) => state.updateActiveWallet);\n\n // Set up account change watcher\n watchAccount(wagmiConfig, {\n onChange: async (account) => {\n // Update the Satellite store with the new account information\n updateActiveWallet({\n // Combine EVM adapter key with connector type for wallet identification\n walletType: `${OrbitAdapter.EVM}:${account?.connector?.type}` as WalletType,\n // Update wallet address\n address: account.address,\n // Update chain ID\n chainId: account.chainId,\n // Update RPC URL using the first available HTTP URL\n rpcURL: account.chain?.rpcUrls.default.http[0],\n // Update connection status\n isConnected: account.isConnected,\n });\n },\n });\n\n // This is a headless component, so return null\n return null;\n}\n","import { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../hooks/satteliteHook';\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 // Get all connected Solana wallets\n const wallets = useWallets();\n\n // Get the updateActiveWallet function from the Satellite store\n const updateActiveWallet = useSatelliteConnectStore((state) => state.updateActiveWallet);\n\n // Watch for changes in connected wallets\n useEffect(() => {\n // Currently only handling the first wallet with active accounts\n const activeWallet = wallets.filter((wallet) => wallet.accounts.length > 0)[0];\n\n if (activeWallet) {\n // Update the Satellite store with the active wallet information\n updateActiveWallet({\n // Use the first account's address\n // TODO: Implement support for multiple connected wallets\n address: activeWallet.accounts[0].address,\n // Set connection status\n isConnected: true,\n // Store Wallet Standard specific information\n connectedAccount: activeWallet.accounts[0],\n connectedWallet: activeWallet,\n });\n }\n }, [wallets]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n","import { useEffect } from 'react';\n\n/**\n * Props for useInitializeAppConnectors hook\n */\ninterface InitializeConnectorsProps {\n /** Function to initialize wallet connectors */\n initializeAppConnectors: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing wallet connectors with error handling\n *\n * @remarks\n * This hook handles the initialization of blockchain wallet connectors 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.initializeAppConnectors - Async function that initializes the connectors\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAppConnectors({\n * initializeAppConnectors: store.initializeAppConnectors\n * });\n * // With custom error handling\n * useInitializeAppConnectors({\n * initializeAppConnectors: store.initializeAppConnectors,\n * onError: (error) => {\n * toast.error(`Failed to initialize wallets: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAppConnectors = ({ initializeAppConnectors, onError }: InitializeConnectorsProps): void => {\n useEffect(() => {\n const initializeConnectors = async () => {\n try {\n await initializeAppConnectors();\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 connectors:', e));\n errorHandler(error as Error);\n }\n };\n\n // Initialize connectors when component mounts\n initializeConnectors();\n }, []); // Empty dependency array ensures single execution\n};\n","import { useSatelliteConnectStore } from '../hooks/satteliteHook';\nimport { useInitializeAppConnectors } from '../hooks/useInitializeConnectors';\n\n/**\n * Props for InitializeConnectorsProvider component\n */\ninterface InitializeConnectorsProviderProps {\n /** Whether to automatically connect to the last used wallet */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that handles wallet connectors initialization\n *\n * @remarks\n * This is a headless component that initializes wallet connectors when mounted.\n * It integrates with the Satellite Connect store and supports automatic reconnection\n * to the last used wallet via the autoConnect prop.\n *\n * @param props - Component properties\n * @param props.autoConnect - Optional flag to enable automatic wallet reconnection\n *\n * @returns null - This is a headless component\n *\n **/\nexport function InitializeConnectorsProvider({ autoConnect }: InitializeConnectorsProviderProps) {\n // Get the initialization function from the store\n const initializeAppConnectors = useSatelliteConnectStore((state) => state.initializeAppConnectors);\n\n // Initialize connectors with autoConnect configuration\n useInitializeAppConnectors({\n initializeAppConnectors: () => initializeAppConnectors({ autoConnect }),\n });\n\n // This is a headless component\n return null;\n}\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satteliteHook';\nimport { InitializeConnectorsProvider } from './InitializeConnectorsProvider';\n\n/**\n * Props for SatelliteConnectProvider component\n */\ninterface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters {\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({\n ...parameters,\n });\n }, []); // Empty dependency array as store should be created only once\n\n return (\n <SatelliteStoreContext.Provider value={store}>\n <InitializeConnectorsProvider autoConnect={autoConnect} />\n {children}\n </SatelliteStoreContext.Provider>\n );\n}\n"]}
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":"index.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"]}
package/dist/index.d.cts CHANGED
@@ -1,43 +1,39 @@
1
- import { Config } from '@wagmi/core';
2
1
  import * as react from 'react';
3
2
  import { ISatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';
4
3
  import { StoreApi } from 'zustand';
5
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
5
 
7
6
  /**
8
- * React component that watches for EVM wallet account changes and updates the Satellite store
9
- *
10
- * @remarks
11
- * This component acts as a bridge between Wagmi account state and Satellite store.
12
- * It doesn't render anything visible but maintains wallet state synchronization.
13
- *
14
- * @param props - Component properties
15
- * @param props.wagmiConfig - Wagmi configuration instance
16
- *
17
- * @returns null - This is a headless component
18
- **/
19
- declare function EVMWalletsWatcher({ wagmiConfig }: {
20
- wagmiConfig: Config;
21
- }): null;
22
-
7
+ * @description
8
+ * This interface is intentionally left empty.
9
+ * Other packages (@tuwaio/satellite-*) will use module
10
+ * augmentation to add their specific wallet types here.
11
+ */
12
+ interface AllWallets {
13
+ }
23
14
  /**
24
- * React component that monitors Solana wallet connections and updates the Satellite store
25
- *
26
- * @remarks
27
- * This component watches for changes in connected Solana wallets using the Wallet Standard.
28
- * Currently handles the first active wallet only, with multi-wallet support planned for future.
29
- * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.
30
- *
31
- * @returns null - This is a headless component
32
- *
15
+ * @description
16
+ * This interface is intentionally left empty.
17
+ * It will be augmented by satellite packages.
33
18
  */
34
- declare function SolanaWalletsWatcher(): null;
19
+ interface AllConnectors {
20
+ }
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
25
+ */
26
+ type Wallet = AllWallets[keyof AllWallets];
27
+ /**
28
+ * Union type for all supported connector types.
29
+ */
30
+ type Connector = AllConnectors[keyof AllConnectors];
35
31
 
36
32
  /**
37
33
  * React Context for providing Satellite Connect store throughout the application
38
34
  * @internal
39
35
  */
40
- declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectStore> | null>;
36
+ declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectStore<never, never>> | null>;
41
37
  /**
42
38
  * Custom hook for accessing the Satellite Connect store state
43
39
  *
@@ -57,73 +53,52 @@ declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectSto
57
53
  * const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);
58
54
  * ```
59
55
  */
60
- declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore) => T) => T;
56
+ declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T) => T;
61
57
 
62
58
  /**
63
- * Props for useInitializeAppConnectors hook
59
+ * Props for the useInitializeAutoConnect hook.
64
60
  */
65
- interface InitializeConnectorsProps {
66
- /** Function to initialize wallet connectors */
67
- initializeAppConnectors: () => Promise<void>;
61
+ interface InitializeAutoConnectProps {
62
+ /** Function to initialize auto connect logic */
63
+ initializeAutoConnect: () => Promise<void>;
68
64
  /** Optional error handler callback */
69
65
  onError?: (error: Error) => void;
70
66
  }
71
67
  /**
72
- * Custom hook for initializing wallet connectors with error handling
68
+ * Custom hook for initializing wallet auto-connection with error handling.
73
69
  *
74
70
  * @remarks
75
- * This hook handles the initialization of blockchain wallet connectors when a component mounts.
71
+ * This hook handles the initial connection logic (e.g., checking for a previously
72
+ * connected wallet) when a component mounts.
76
73
  * It provides default error handling with console.error if no custom handler is provided.
77
74
  * The initialization runs only once when the component mounts.
78
75
  *
79
76
  * @param props - Hook configuration
80
- * @param props.initializeAppConnectors - Async function that initializes the connectors
77
+ * @param props.initializeAutoConnect - Async function that executes the auto-connect logic
81
78
  * @param props.onError - Optional custom error handler
82
79
  *
83
80
  * @example
84
81
  * ```tsx
85
82
  * // Basic usage with default error handling
86
- * useInitializeAppConnectors({
87
- * initializeAppConnectors: store.initializeAppConnectors
83
+ * useInitializeAutoConnect({
84
+ * initializeAutoConnect: store.initializeAutoConnect
88
85
  * });
86
+ *
89
87
  * // With custom error handling
90
- * useInitializeAppConnectors({
91
- * initializeAppConnectors: store.initializeAppConnectors,
92
- * onError: (error) => {
93
- * toast.error(`Failed to initialize wallets: ${error.message}`);
94
- * }
88
+ * useInitializeAutoConnect({
89
+ * initializeAutoConnect: store.initializeAutoConnect,
90
+ * onError: (error) => {
91
+ * toast.error(`Failed to auto-connect: ${error.message}`);
92
+ * }
95
93
  * });
96
94
  * ```
97
95
  */
98
- declare const useInitializeAppConnectors: ({ initializeAppConnectors, onError }: InitializeConnectorsProps) => void;
99
-
100
- /**
101
- * Props for InitializeConnectorsProvider component
102
- */
103
- interface InitializeConnectorsProviderProps {
104
- /** Whether to automatically connect to the last used wallet */
105
- autoConnect?: boolean;
106
- }
107
- /**
108
- * Provider component that handles wallet connectors initialization
109
- *
110
- * @remarks
111
- * This is a headless component that initializes wallet connectors when mounted.
112
- * It integrates with the Satellite Connect store and supports automatic reconnection
113
- * to the last used wallet via the autoConnect prop.
114
- *
115
- * @param props - Component properties
116
- * @param props.autoConnect - Optional flag to enable automatic wallet reconnection
117
- *
118
- * @returns null - This is a headless component
119
- *
120
- **/
121
- declare function InitializeConnectorsProvider({ autoConnect }: InitializeConnectorsProviderProps): null;
96
+ declare const useInitializeAutoConnect: ({ initializeAutoConnect, onError }: InitializeAutoConnectProps) => void;
122
97
 
123
98
  /**
124
99
  * Props for SatelliteConnectProvider component
125
100
  */
126
- interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters {
101
+ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {
127
102
  /** React child components */
128
103
  children: React.ReactNode;
129
104
  /** Whether to automatically connect to last used wallet */
@@ -164,4 +139,4 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
164
139
  */
165
140
  declare function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps): react_jsx_runtime.JSX.Element;
166
141
 
167
- export { EVMWalletsWatcher, InitializeConnectorsProvider, SatelliteConnectProvider, SatelliteStoreContext, SolanaWalletsWatcher, useInitializeAppConnectors, useSatelliteConnectStore };
142
+ export { type AllConnectors, type AllWallets, type Connector, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, type Wallet, useInitializeAutoConnect, useSatelliteConnectStore };
package/dist/index.d.ts CHANGED
@@ -1,43 +1,39 @@
1
- import { Config } from '@wagmi/core';
2
1
  import * as react from 'react';
3
2
  import { ISatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';
4
3
  import { StoreApi } from 'zustand';
5
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
5
 
7
6
  /**
8
- * React component that watches for EVM wallet account changes and updates the Satellite store
9
- *
10
- * @remarks
11
- * This component acts as a bridge between Wagmi account state and Satellite store.
12
- * It doesn't render anything visible but maintains wallet state synchronization.
13
- *
14
- * @param props - Component properties
15
- * @param props.wagmiConfig - Wagmi configuration instance
16
- *
17
- * @returns null - This is a headless component
18
- **/
19
- declare function EVMWalletsWatcher({ wagmiConfig }: {
20
- wagmiConfig: Config;
21
- }): null;
22
-
7
+ * @description
8
+ * This interface is intentionally left empty.
9
+ * Other packages (@tuwaio/satellite-*) will use module
10
+ * augmentation to add their specific wallet types here.
11
+ */
12
+ interface AllWallets {
13
+ }
23
14
  /**
24
- * React component that monitors Solana wallet connections and updates the Satellite store
25
- *
26
- * @remarks
27
- * This component watches for changes in connected Solana wallets using the Wallet Standard.
28
- * Currently handles the first active wallet only, with multi-wallet support planned for future.
29
- * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.
30
- *
31
- * @returns null - This is a headless component
32
- *
15
+ * @description
16
+ * This interface is intentionally left empty.
17
+ * It will be augmented by satellite packages.
33
18
  */
34
- declare function SolanaWalletsWatcher(): null;
19
+ interface AllConnectors {
20
+ }
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
25
+ */
26
+ type Wallet = AllWallets[keyof AllWallets];
27
+ /**
28
+ * Union type for all supported connector types.
29
+ */
30
+ type Connector = AllConnectors[keyof AllConnectors];
35
31
 
36
32
  /**
37
33
  * React Context for providing Satellite Connect store throughout the application
38
34
  * @internal
39
35
  */
40
- declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectStore> | null>;
36
+ declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectStore<never, never>> | null>;
41
37
  /**
42
38
  * Custom hook for accessing the Satellite Connect store state
43
39
  *
@@ -57,73 +53,52 @@ declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectSto
57
53
  * const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);
58
54
  * ```
59
55
  */
60
- declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore) => T) => T;
56
+ declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T) => T;
61
57
 
62
58
  /**
63
- * Props for useInitializeAppConnectors hook
59
+ * Props for the useInitializeAutoConnect hook.
64
60
  */
65
- interface InitializeConnectorsProps {
66
- /** Function to initialize wallet connectors */
67
- initializeAppConnectors: () => Promise<void>;
61
+ interface InitializeAutoConnectProps {
62
+ /** Function to initialize auto connect logic */
63
+ initializeAutoConnect: () => Promise<void>;
68
64
  /** Optional error handler callback */
69
65
  onError?: (error: Error) => void;
70
66
  }
71
67
  /**
72
- * Custom hook for initializing wallet connectors with error handling
68
+ * Custom hook for initializing wallet auto-connection with error handling.
73
69
  *
74
70
  * @remarks
75
- * This hook handles the initialization of blockchain wallet connectors when a component mounts.
71
+ * This hook handles the initial connection logic (e.g., checking for a previously
72
+ * connected wallet) when a component mounts.
76
73
  * It provides default error handling with console.error if no custom handler is provided.
77
74
  * The initialization runs only once when the component mounts.
78
75
  *
79
76
  * @param props - Hook configuration
80
- * @param props.initializeAppConnectors - Async function that initializes the connectors
77
+ * @param props.initializeAutoConnect - Async function that executes the auto-connect logic
81
78
  * @param props.onError - Optional custom error handler
82
79
  *
83
80
  * @example
84
81
  * ```tsx
85
82
  * // Basic usage with default error handling
86
- * useInitializeAppConnectors({
87
- * initializeAppConnectors: store.initializeAppConnectors
83
+ * useInitializeAutoConnect({
84
+ * initializeAutoConnect: store.initializeAutoConnect
88
85
  * });
86
+ *
89
87
  * // With custom error handling
90
- * useInitializeAppConnectors({
91
- * initializeAppConnectors: store.initializeAppConnectors,
92
- * onError: (error) => {
93
- * toast.error(`Failed to initialize wallets: ${error.message}`);
94
- * }
88
+ * useInitializeAutoConnect({
89
+ * initializeAutoConnect: store.initializeAutoConnect,
90
+ * onError: (error) => {
91
+ * toast.error(`Failed to auto-connect: ${error.message}`);
92
+ * }
95
93
  * });
96
94
  * ```
97
95
  */
98
- declare const useInitializeAppConnectors: ({ initializeAppConnectors, onError }: InitializeConnectorsProps) => void;
99
-
100
- /**
101
- * Props for InitializeConnectorsProvider component
102
- */
103
- interface InitializeConnectorsProviderProps {
104
- /** Whether to automatically connect to the last used wallet */
105
- autoConnect?: boolean;
106
- }
107
- /**
108
- * Provider component that handles wallet connectors initialization
109
- *
110
- * @remarks
111
- * This is a headless component that initializes wallet connectors when mounted.
112
- * It integrates with the Satellite Connect store and supports automatic reconnection
113
- * to the last used wallet via the autoConnect prop.
114
- *
115
- * @param props - Component properties
116
- * @param props.autoConnect - Optional flag to enable automatic wallet reconnection
117
- *
118
- * @returns null - This is a headless component
119
- *
120
- **/
121
- declare function InitializeConnectorsProvider({ autoConnect }: InitializeConnectorsProviderProps): null;
96
+ declare const useInitializeAutoConnect: ({ initializeAutoConnect, onError }: InitializeAutoConnectProps) => void;
122
97
 
123
98
  /**
124
99
  * Props for SatelliteConnectProvider component
125
100
  */
126
- interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters {
101
+ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {
127
102
  /** React child components */
128
103
  children: React.ReactNode;
129
104
  /** Whether to automatically connect to last used wallet */
@@ -164,4 +139,4 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
164
139
  */
165
140
  declare function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps): react_jsx_runtime.JSX.Element;
166
141
 
167
- export { EVMWalletsWatcher, InitializeConnectorsProvider, SatelliteConnectProvider, SatelliteStoreContext, SolanaWalletsWatcher, useInitializeAppConnectors, useSatelliteConnectStore };
142
+ export { type AllConnectors, type AllWallets, type Connector, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, type Wallet, useInitializeAutoConnect, useSatelliteConnectStore };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import {OrbitAdapter}from'@tuwaio/orbit-core';import {watchAccount}from'@wagmi/core';import {createContext,useContext,useEffect,useMemo}from'react';import {useStore}from'zustand';import {useWallets}from'@wallet-standard/react';import {createSatelliteConnectStore}from'@tuwaio/satellite-core';import {jsxs,jsx}from'react/jsx-runtime';var i=createContext(null),r=t=>{let o=useContext(i);if(!o)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return useStore(o,t)};function b({wagmiConfig:t}){let o=r(e=>e.updateActiveWallet);return watchAccount(t,{onChange:async e=>{o({walletType:`${OrbitAdapter.EVM}:${e?.connector?.type}`,address:e.address,chainId:e.chainId,rpcURL:e.chain?.rpcUrls.default.http[0],isConnected:e.isConnected});}}),null}function V(){let t=useWallets(),o=r(e=>e.updateActiveWallet);return useEffect(()=>{let e=t.filter(n=>n.accounts.length>0)[0];e&&o({address:e.accounts[0].address,isConnected:true,connectedAccount:e.accounts[0],connectedWallet:e});},[t]),null}var l=({initializeAppConnectors:t,onError:o})=>{useEffect(()=>{(async()=>{try{await t();}catch(n){(o??(c=>console.error("Failed to initialize connectors:",c)))(n);}})();},[]);};function a({autoConnect:t}){let o=r(e=>e.initializeAppConnectors);return l({initializeAppConnectors:()=>o({autoConnect:t})}),null}function K({children:t,autoConnect:o,...e}){let n=useMemo(()=>createSatelliteConnectStore({...e}),[]);return jsxs(i.Provider,{value:n,children:[jsx(a,{autoConnect:o}),t]})}export{b as EVMWalletsWatcher,a as InitializeConnectorsProvider,K as SatelliteConnectProvider,i as SatelliteStoreContext,V as SolanaWalletsWatcher,l as useInitializeAppConnectors,r as useSatelliteConnectStore};//# sourceMappingURL=index.js.map
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{b as SatelliteConnectProvider,r as SatelliteStoreContext,i as useInitializeAutoConnect,A as useSatelliteConnectStore};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/satteliteHook.ts","../src/components/EVMWalletsWatcher.tsx","../src/components/SolanaWalletsWatcher.tsx","../src/hooks/useInitializeConnectors.tsx","../src/providers/InitializeConnectorsProvider.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","EVMWalletsWatcher","wagmiConfig","updateActiveWallet","state","watchAccount","account","OrbitAdapter","SolanaWalletsWatcher","wallets","useWallets","useEffect","activeWallet","wallet","useInitializeAppConnectors","initializeAppConnectors","onError","error","e","InitializeConnectorsProvider","autoConnect","SatelliteConnectProvider","children","parameters","useMemo","createSatelliteConnectStore","jsxs","jsx"],"mappings":"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","file":"index.js","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore> | 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) => 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 { OrbitAdapter } from '@tuwaio/orbit-core';\nimport { WalletType } from '@tuwaio/satellite-core';\nimport { Config, watchAccount } from '@wagmi/core';\n\nimport { useSatelliteConnectStore } from '../hooks/satteliteHook';\n\n/**\n * React component that watches for EVM wallet account changes and updates the Satellite store\n *\n * @remarks\n * This component acts as a bridge between Wagmi account state and Satellite store.\n * It doesn't render anything visible but maintains wallet state synchronization.\n *\n * @param props - Component properties\n * @param props.wagmiConfig - Wagmi configuration instance\n *\n * @returns null - This is a headless component\n **/\nexport function EVMWalletsWatcher({ wagmiConfig }: { wagmiConfig: Config }) {\n // Get the updateActiveWallet function from the Satellite store\n const updateActiveWallet = useSatelliteConnectStore((state) => state.updateActiveWallet);\n\n // Set up account change watcher\n watchAccount(wagmiConfig, {\n onChange: async (account) => {\n // Update the Satellite store with the new account information\n updateActiveWallet({\n // Combine EVM adapter key with connector type for wallet identification\n walletType: `${OrbitAdapter.EVM}:${account?.connector?.type}` as WalletType,\n // Update wallet address\n address: account.address,\n // Update chain ID\n chainId: account.chainId,\n // Update RPC URL using the first available HTTP URL\n rpcURL: account.chain?.rpcUrls.default.http[0],\n // Update connection status\n isConnected: account.isConnected,\n });\n },\n });\n\n // This is a headless component, so return null\n return null;\n}\n","import { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../hooks/satteliteHook';\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 // Get all connected Solana wallets\n const wallets = useWallets();\n\n // Get the updateActiveWallet function from the Satellite store\n const updateActiveWallet = useSatelliteConnectStore((state) => state.updateActiveWallet);\n\n // Watch for changes in connected wallets\n useEffect(() => {\n // Currently only handling the first wallet with active accounts\n const activeWallet = wallets.filter((wallet) => wallet.accounts.length > 0)[0];\n\n if (activeWallet) {\n // Update the Satellite store with the active wallet information\n updateActiveWallet({\n // Use the first account's address\n // TODO: Implement support for multiple connected wallets\n address: activeWallet.accounts[0].address,\n // Set connection status\n isConnected: true,\n // Store Wallet Standard specific information\n connectedAccount: activeWallet.accounts[0],\n connectedWallet: activeWallet,\n });\n }\n }, [wallets]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n","import { useEffect } from 'react';\n\n/**\n * Props for useInitializeAppConnectors hook\n */\ninterface InitializeConnectorsProps {\n /** Function to initialize wallet connectors */\n initializeAppConnectors: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing wallet connectors with error handling\n *\n * @remarks\n * This hook handles the initialization of blockchain wallet connectors 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.initializeAppConnectors - Async function that initializes the connectors\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAppConnectors({\n * initializeAppConnectors: store.initializeAppConnectors\n * });\n * // With custom error handling\n * useInitializeAppConnectors({\n * initializeAppConnectors: store.initializeAppConnectors,\n * onError: (error) => {\n * toast.error(`Failed to initialize wallets: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAppConnectors = ({ initializeAppConnectors, onError }: InitializeConnectorsProps): void => {\n useEffect(() => {\n const initializeConnectors = async () => {\n try {\n await initializeAppConnectors();\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 connectors:', e));\n errorHandler(error as Error);\n }\n };\n\n // Initialize connectors when component mounts\n initializeConnectors();\n }, []); // Empty dependency array ensures single execution\n};\n","import { useSatelliteConnectStore } from '../hooks/satteliteHook';\nimport { useInitializeAppConnectors } from '../hooks/useInitializeConnectors';\n\n/**\n * Props for InitializeConnectorsProvider component\n */\ninterface InitializeConnectorsProviderProps {\n /** Whether to automatically connect to the last used wallet */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that handles wallet connectors initialization\n *\n * @remarks\n * This is a headless component that initializes wallet connectors when mounted.\n * It integrates with the Satellite Connect store and supports automatic reconnection\n * to the last used wallet via the autoConnect prop.\n *\n * @param props - Component properties\n * @param props.autoConnect - Optional flag to enable automatic wallet reconnection\n *\n * @returns null - This is a headless component\n *\n **/\nexport function InitializeConnectorsProvider({ autoConnect }: InitializeConnectorsProviderProps) {\n // Get the initialization function from the store\n const initializeAppConnectors = useSatelliteConnectStore((state) => state.initializeAppConnectors);\n\n // Initialize connectors with autoConnect configuration\n useInitializeAppConnectors({\n initializeAppConnectors: () => initializeAppConnectors({ autoConnect }),\n });\n\n // This is a headless component\n return null;\n}\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satteliteHook';\nimport { InitializeConnectorsProvider } from './InitializeConnectorsProvider';\n\n/**\n * Props for SatelliteConnectProvider component\n */\ninterface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters {\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({\n ...parameters,\n });\n }, []); // Empty dependency array as store should be created only once\n\n return (\n <SatelliteStoreContext.Provider value={store}>\n <InitializeConnectorsProvider autoConnect={autoConnect} />\n {children}\n </SatelliteStoreContext.Provider>\n );\n}\n"]}
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":"index.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"]}
@@ -0,0 +1,2 @@
1
+ 'use strict';var orbitCore=require('@tuwaio/orbit-core'),react=require('@wallet-standard/react'),react$1=require('react');function u({store:c}){let l=react.useWallets(),{activeWallet:e,updateActiveWallet:o,walletConnectionError:a,disconnect:n}=c;return react$1.useEffect(()=>{if(e&&orbitCore.getAdapterFromWalletType(e.walletType)===orbitCore.OrbitAdapter.SOLANA){let t=l.filter(i=>orbitCore.getWalletTypeFromConnectorName(orbitCore.OrbitAdapter.SOLANA,orbitCore.formatWalletName(i.name))===e.walletType)[0];a||o({address:t?.accounts[0]?.address,isConnected:t?.accounts.length>0,connectedAccount:t?.accounts[0],connectedWallet:t}),t?.accounts.length===0&&n();}},[e?.walletType,l,a,o,n]),null}exports.SolanaWalletsWatcher=u;//# sourceMappingURL=index.cjs.map
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/solana/SolanaWalletsWatcher.tsx"],"names":["SolanaWalletsWatcher","store","wallets","useWallets","activeWalletFromStore","updateActiveWallet","walletConnectionError","disconnect","useEffect","getAdapterFromWalletType","OrbitAdapter","activeWallet","w","getWalletTypeFromConnectorName","formatWalletName"],"mappings":"0HAsBO,SAASA,CAAAA,CAAqB,CACnC,KAAA,CAAAC,CACF,CAAA,CAKG,CACD,IAAMC,CAAAA,CAAUC,kBAAW,CAErB,CAAE,YAAA,CAAcC,CAAAA,CAAuB,kBAAA,CAAAC,CAAAA,CAAoB,sBAAAC,CAAAA,CAAuB,UAAA,CAAAC,CAAW,CAAA,CAAIN,CAAAA,CAGvG,OAAAO,kBAAU,IAAM,CACd,GAAIJ,CAAAA,EAAyBK,kCAAAA,CAAyBL,CAAAA,CAAsB,UAAU,CAAA,GAAMM,sBAAAA,CAAa,MAAA,CAAQ,CAC/G,IAAMC,CAAAA,CAAeT,CAAAA,CAAQ,OAC1BU,CAAAA,EACCC,wCAAAA,CAA+BH,sBAAAA,CAAa,MAAA,CAAQI,0BAAAA,CAAiBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GAC5ER,CAAAA,CAAsB,UAC1B,CAAA,CAAE,CAAC,EAEEE,CAAAA,EAGHD,CAAAA,CAAmB,CAEjB,OAAA,CAASM,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAEpC,WAAA,CAAaA,CAAAA,EAAc,QAAA,CAAS,MAAA,CAAS,EAE7C,gBAAA,CAAkBA,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,CAC1C,eAAA,CAAiBA,CACnB,CAAC,CAAA,CAECA,CAAAA,EAAc,QAAA,CAAS,MAAA,GAAW,CAAA,EAEpCJ,IAEJ,CAEF,CAAA,CAAG,CAACH,CAAAA,EAAuB,UAAA,CAAYF,CAAAA,CAASI,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 { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { ConnectorSolana, SolanaWallet } from '@tuwaio/satellite-solana';\nimport { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\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 store,\n}: {\n store: Pick<\n ISatelliteConnectStore<ConnectorSolana, SolanaWallet>,\n 'activeWallet' | 'updateActiveWallet' | 'walletConnectionError' | 'disconnect'\n >;\n}) {\n const wallets = useWallets();\n\n const { activeWallet: activeWalletFromStore, updateActiveWallet, walletConnectionError, disconnect } = store;\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 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"]}
@@ -0,0 +1,29 @@
1
+ import { OrbitAdapter } from '@tuwaio/orbit-core';
2
+ import { ConnectorSolana, SolanaWallet } from '@tuwaio/satellite-solana';
3
+ import { ISatelliteConnectStore } from '@tuwaio/satellite-core';
4
+
5
+ /**
6
+ * React component that monitors Solana wallet connections and updates the Satellite store
7
+ *
8
+ * @remarks
9
+ * This component watches for changes in connected Solana wallets using the Wallet Standard.
10
+ * Currently handles the first active wallet only, with multi-wallet support planned for future.
11
+ * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.
12
+ *
13
+ * @returns null - This is a headless component
14
+ *
15
+ */
16
+ declare function SolanaWalletsWatcher({ store, }: {
17
+ store: Pick<ISatelliteConnectStore<ConnectorSolana, SolanaWallet>, 'activeWallet' | 'updateActiveWallet' | 'walletConnectionError' | 'disconnect'>;
18
+ }): null;
19
+
20
+ declare module '@tuwaio/satellite-react' {
21
+ interface AllWallets {
22
+ [OrbitAdapter.SOLANA]: SolanaWallet;
23
+ }
24
+ interface AllConnectors {
25
+ [OrbitAdapter.SOLANA]: ConnectorSolana;
26
+ }
27
+ }
28
+
29
+ export { SolanaWalletsWatcher };
@@ -0,0 +1,29 @@
1
+ import { OrbitAdapter } from '@tuwaio/orbit-core';
2
+ import { ConnectorSolana, SolanaWallet } from '@tuwaio/satellite-solana';
3
+ import { ISatelliteConnectStore } from '@tuwaio/satellite-core';
4
+
5
+ /**
6
+ * React component that monitors Solana wallet connections and updates the Satellite store
7
+ *
8
+ * @remarks
9
+ * This component watches for changes in connected Solana wallets using the Wallet Standard.
10
+ * Currently handles the first active wallet only, with multi-wallet support planned for future.
11
+ * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.
12
+ *
13
+ * @returns null - This is a headless component
14
+ *
15
+ */
16
+ declare function SolanaWalletsWatcher({ store, }: {
17
+ store: Pick<ISatelliteConnectStore<ConnectorSolana, SolanaWallet>, 'activeWallet' | 'updateActiveWallet' | 'walletConnectionError' | 'disconnect'>;
18
+ }): null;
19
+
20
+ declare module '@tuwaio/satellite-react' {
21
+ interface AllWallets {
22
+ [OrbitAdapter.SOLANA]: SolanaWallet;
23
+ }
24
+ interface AllConnectors {
25
+ [OrbitAdapter.SOLANA]: ConnectorSolana;
26
+ }
27
+ }
28
+
29
+ export { SolanaWalletsWatcher };
@@ -0,0 +1,2 @@
1
+ import {getAdapterFromWalletType,OrbitAdapter,getWalletTypeFromConnectorName,formatWalletName}from'@tuwaio/orbit-core';import {useWallets}from'@wallet-standard/react';import {useEffect}from'react';function u({store:c}){let l=useWallets(),{activeWallet:e,updateActiveWallet:o,walletConnectionError:a,disconnect:n}=c;return useEffect(()=>{if(e&&getAdapterFromWalletType(e.walletType)===OrbitAdapter.SOLANA){let t=l.filter(i=>getWalletTypeFromConnectorName(OrbitAdapter.SOLANA,formatWalletName(i.name))===e.walletType)[0];a||o({address:t?.accounts[0]?.address,isConnected:t?.accounts.length>0,connectedAccount:t?.accounts[0],connectedWallet:t}),t?.accounts.length===0&&n();}},[e?.walletType,l,a,o,n]),null}export{u as SolanaWalletsWatcher};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/solana/SolanaWalletsWatcher.tsx"],"names":["SolanaWalletsWatcher","store","wallets","useWallets","activeWalletFromStore","updateActiveWallet","walletConnectionError","disconnect","useEffect","getAdapterFromWalletType","OrbitAdapter","activeWallet","w","getWalletTypeFromConnectorName","formatWalletName"],"mappings":"qMAsBO,SAASA,CAAAA,CAAqB,CACnC,KAAA,CAAAC,CACF,CAAA,CAKG,CACD,IAAMC,CAAAA,CAAUC,YAAW,CAErB,CAAE,YAAA,CAAcC,CAAAA,CAAuB,kBAAA,CAAAC,CAAAA,CAAoB,sBAAAC,CAAAA,CAAuB,UAAA,CAAAC,CAAW,CAAA,CAAIN,CAAAA,CAGvG,OAAAO,UAAU,IAAM,CACd,GAAIJ,CAAAA,EAAyBK,wBAAAA,CAAyBL,CAAAA,CAAsB,UAAU,CAAA,GAAMM,YAAAA,CAAa,MAAA,CAAQ,CAC/G,IAAMC,CAAAA,CAAeT,CAAAA,CAAQ,OAC1BU,CAAAA,EACCC,8BAAAA,CAA+BH,YAAAA,CAAa,MAAA,CAAQI,gBAAAA,CAAiBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GAC5ER,CAAAA,CAAsB,UAC1B,CAAA,CAAE,CAAC,EAEEE,CAAAA,EAGHD,CAAAA,CAAmB,CAEjB,OAAA,CAASM,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAEpC,WAAA,CAAaA,CAAAA,EAAc,QAAA,CAAS,MAAA,CAAS,EAE7C,gBAAA,CAAkBA,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,CAC1C,eAAA,CAAiBA,CACnB,CAAC,CAAA,CAECA,CAAAA,EAAc,QAAA,CAAS,MAAA,GAAW,CAAA,EAEpCJ,IAEJ,CAEF,CAAA,CAAG,CAACH,CAAAA,EAAuB,UAAA,CAAYF,CAAAA,CAASI,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 { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { ConnectorSolana, SolanaWallet } from '@tuwaio/satellite-solana';\nimport { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\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 store,\n}: {\n store: Pick<\n ISatelliteConnectStore<ConnectorSolana, SolanaWallet>,\n 'activeWallet' | 'updateActiveWallet' | 'walletConnectionError' | 'disconnect'\n >;\n}) {\n const wallets = useWallets();\n\n const { activeWallet: activeWalletFromStore, updateActiveWallet, walletConnectionError, disconnect } = store;\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 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"]}
package/package.json CHANGED
@@ -1,14 +1,31 @@
1
1
  {
2
2
  "name": "@tuwaio/satellite-react",
3
- "version": "0.0.4",
3
+ "version": "0.1.0",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",
7
7
  "description": "An provider and hook with for React for satellite based wallets.",
8
8
  "type": "module",
9
9
  "main": "./dist/index.js",
10
- "module": "./dist/index.mjs",
10
+ "module": "./dist/index.cjs",
11
11
  "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.cjs",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./evm": {
19
+ "types": "./dist/evm/index.d.ts",
20
+ "import": "./dist/evm/index.cjs",
21
+ "default": "./dist/evm/index.js"
22
+ },
23
+ "./solana": {
24
+ "types": "./dist/solana/index.d.ts",
25
+ "import": "./dist/solana/index.cjs",
26
+ "default": "./dist/solana/index.js"
27
+ }
28
+ },
12
29
  "publishConfig": {
13
30
  "access": "public"
14
31
  },
@@ -39,28 +56,89 @@
39
56
  }
40
57
  ],
41
58
  "peerDependencies": {
42
- "@tuwaio/orbit-core": ">=0",
43
- "@tuwaio/satellite-core": ">=0",
44
- "@wagmi/core": ">=2",
45
- "@wallet-standard/react": ">=1",
46
- "gill": ">=0.11",
47
- "react": ">=19",
48
- "immer": ">=10",
49
- "zustand": ">=5"
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",
67
+ "viem": "2.x.x",
68
+ "@wallet-standard/react": "1.x.x",
69
+ "gill": ">=0.12",
70
+ "react": "19.x.x",
71
+ "immer": "10.x.x",
72
+ "zustand": "5.x.x"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "@tuwaio/orbit-core": {
76
+ "optional": false
77
+ },
78
+ "@tuwaio/satellite-core": {
79
+ "optional": false
80
+ },
81
+ "react": {
82
+ "optional": false
83
+ },
84
+ "immer": {
85
+ "optional": false
86
+ },
87
+ "zustand": {
88
+ "optional": false
89
+ },
90
+ "@tuwaio/orbit-evm": {
91
+ "optional": true
92
+ },
93
+ "@tuwaio/satellite-evm": {
94
+ "optional": true
95
+ },
96
+ "@wagmi/core": {
97
+ "optional": true
98
+ },
99
+ "@wagmi/connectors": {
100
+ "optional": true
101
+ },
102
+ "viem": {
103
+ "optional": true
104
+ },
105
+ "@tuwaio/orbit-solana": {
106
+ "optional": true
107
+ },
108
+ "@tuwaio/satellite-solana": {
109
+ "optional": true
110
+ },
111
+ "@wallet-standard/react": {
112
+ "optional": true
113
+ },
114
+ "gill": {
115
+ "optional": true
116
+ }
50
117
  },
51
118
  "devDependencies": {
52
- "@types/react": "^19.1.12",
53
- "@wagmi/core": "^2.21.1",
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",
54
125
  "@wallet-standard/react": "^1.0.1",
55
- "gill": "^0.11.0",
126
+ "@wallet-standard/app": "^1.1.0",
127
+ "@wallet-standard/base": "^1.1.0",
128
+ "@wallet-standard/features": "^1.1.0",
129
+ "@wallet-standard/core": "^1.1.1",
130
+ "@wallet-standard/ui": "^1.0.1",
131
+ "@wallet-standard/ui-registry": "^1.0.1",
132
+ "gill": "^0.12.0",
56
133
  "immer": "^10.1.3",
57
- "react": "^19.1.1",
134
+ "react": "^19.2.0",
58
135
  "tsup": "^8.5.0",
59
- "typescript": "^5.9.2",
136
+ "viem": "^2.38.3",
137
+ "typescript": "^5.9.3",
60
138
  "zustand": "^5.0.8",
61
- "@tuwaio/orbit-core": "^0.0.4",
62
- "@tuwaio/orbit-solana": "^0.0.4",
63
- "@tuwaio/satellite-core": "^0.0.4"
139
+ "@tuwaio/satellite-evm": "^0.1.0",
140
+ "@tuwaio/satellite-solana": "^0.1.0",
141
+ "@tuwaio/satellite-core": "^0.1.0"
64
142
  },
65
143
  "scripts": {
66
144
  "start": "tsup src/index.ts --watch",