@tuwaio/satellite-react 1.0.0-fix-test-alpha.48.5732da8 → 1.0.0-fix-test-alpha.50.f997a2c

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,e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/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 s=react.createContext(null),i=n=>{let t=react.useContext(s);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return zustand.useStore(t,n)};function B({wagmiConfig:n,siwe:t}){let r=i(l=>l.activeWallet),o=i(l=>l.updateActiveWallet),c=i(l=>l.walletConnectionError),e=i(l=>l.disconnect);return react.useEffect(()=>{t?.enabled&&!t?.isSignedIn&&t?.isRejected&&e();},[t,e]),react.useEffect(()=>core.watchAccount(n,{onChange:a=>{if(a?.status==="disconnected"&&e(),r&&orbitCore.getAdapterFromWalletType(r.walletType)!==orbitCore.OrbitAdapter.EVM||!a.address||c)return;if(t?.enabled?t.isSignedIn:true){let d=r?.walletType,f=d?{walletType:d,address:a.address,chainId:a.chainId,rpcURL:a.chain?.rpcUrls.default.http[0],isConnected:a.isConnected}:{address:a.address,chainId:a.chainId,rpcURL:a.chain?.rpcUrls.default.http[0],isConnected:a.isConnected};o(f);}}}),[r?.walletType,t,c]),null}function X(){let n=react$1.useWallets(),t=i(e=>e.updateActiveWallet),r=i(e=>e.walletConnectionError),o=i(e=>e.activeWallet),c=i(e=>e.disconnect);return react.useEffect(()=>{if(o&&orbitCore.getAdapterFromWalletType(o.walletType)===orbitCore.OrbitAdapter.SOLANA){let e=n.filter(l=>orbitCore.getWalletTypeFromConnectorName(orbitCore.OrbitAdapter.SOLANA,orbitCore.formatWalletName(l.name))===o.walletType)[0];r||t({address:e?.accounts[0]?.address,isConnected:e?.accounts.length>0,connectedAccount:e?.accounts[0],connectedWallet:e}),e?.accounts.length===0&&c();}},[o?.walletType,n,r,t,c]),null}var u=({initializeAutoConnect:n,onError:t})=>{react.useEffect(()=>{(async()=>{try{await n();}catch(o){(t??(e=>console.error("Failed to initialize auto connect:",e)))(o);}})();},[]);};function re({children:n,autoConnect:t,...r}){let o=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({...r}),[]);return react.useEffect(()=>{o.getState().disconnectAll();},[]),u({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsxRuntime.jsx(s.Provider,{value:o,children:n})}exports.EVMWalletsWatcher=B;exports.SatelliteConnectProvider=re;exports.SatelliteStoreContext=s;exports.SolanaWalletsWatcher=X;exports.useInitializeAutoConnect=u;exports.useSatelliteConnectStore=i;//# 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/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","EVMWalletsWatcher","wagmiConfig","siwe","activeWallet","state","updateActiveWallet","walletConnectionError","disconnect","useEffect","watchAccount","account","getAdapterFromWalletType","OrbitAdapter","walletType","walletUpdate","SolanaWalletsWatcher","wallets","useWallets","activeWalletFromStore","w","getWalletTypeFromConnectorName","formatWalletName","useInitializeAutoConnect","initializeAutoConnect","onError","error","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx"],"mappings":"yQAUO,IAAMA,CAAAA,CAAwBC,oBAA0E,IAAI,CAAA,CAqBtGC,EAA+BC,CAAAA,EAAyE,CAEnH,IAAMC,CAAAA,CAAQC,gBAAAA,CAAWL,CAAqB,CA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CAAQ,QAAA,CAAA8B,CAAAA,CAAS,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 { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, watchAccount, WatchAccountParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../hooks/satteliteHook';\n\nexport function EVMWalletsWatcher({\n wagmiConfig,\n siwe,\n}: {\n wagmiConfig: Config;\n siwe?: {\n isRejected: boolean;\n isSignedIn: boolean;\n enabled?: boolean;\n };\n}) {\n const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);\n const updateActiveWallet = useSatelliteConnectStore((state) => state.updateActiveWallet);\n const walletConnectionError = useSatelliteConnectStore((state) => state.walletConnectionError);\n const disconnect = useSatelliteConnectStore((state) => state.disconnect);\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","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 '../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 const wallets = useWallets();\n\n // Get the updateActiveWallet function from the Satellite store\n const updateActiveWallet = useSatelliteConnectStore((state) => state.updateActiveWallet);\n const walletConnectionError = useSatelliteConnectStore((state) => state.walletConnectionError);\n const activeWalletFromStore = useSatelliteConnectStore((state) => state.activeWallet);\n const disconnect = useSatelliteConnectStore((state) => state.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 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","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 */\ninterface 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
+ {"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 */\ninterface 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
- import { ConnectorEVM, EVMWallet } from '@tuwaio/satellite-evm';
6
- import { ConnectorSolana, SolanaWallet } from '@tuwaio/satellite-solana';
7
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
5
 
9
- declare function EVMWalletsWatcher({ wagmiConfig, siwe, }: {
10
- wagmiConfig: Config;
11
- siwe?: {
12
- isRejected: boolean;
13
- isSignedIn: boolean;
14
- enabled?: boolean;
15
- };
16
- }): null;
17
-
18
6
  /**
19
- * React component that monitors Solana wallet connections and updates the Satellite store
20
- *
21
- * @remarks
22
- * This component watches for changes in connected Solana wallets using the Wallet Standard.
23
- * Currently handles the first active wallet only, with multi-wallet support planned for future.
24
- * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.
25
- *
26
- * @returns null - This is a headless component
27
- *
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.
28
11
  */
29
- declare function SolanaWalletsWatcher(): null;
30
-
31
- /** Union type for all supported wallet types */
32
- type Wallet = EVMWallet | SolanaWallet;
33
- /** Union type for all supported connector types */
34
- type Connector = ConnectorEVM | ConnectorSolana;
12
+ interface AllWallets {
13
+ }
14
+ /**
15
+ * @description
16
+ * This interface is intentionally left empty.
17
+ * It will be augmented by satellite packages.
18
+ */
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<Connector, Wallet>> | 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
  *
@@ -143,4 +139,4 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
143
139
  */
144
140
  declare function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps): react_jsx_runtime.JSX.Element;
145
141
 
146
- export { type Connector, EVMWalletsWatcher, SatelliteConnectProvider, SatelliteStoreContext, SolanaWalletsWatcher, type Wallet, useInitializeAutoConnect, useSatelliteConnectStore };
142
+ export { type AllConnectors, type AllWallets, type Connector, SatelliteConnectProvider, 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
- import { ConnectorEVM, EVMWallet } from '@tuwaio/satellite-evm';
6
- import { ConnectorSolana, SolanaWallet } from '@tuwaio/satellite-solana';
7
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
5
 
9
- declare function EVMWalletsWatcher({ wagmiConfig, siwe, }: {
10
- wagmiConfig: Config;
11
- siwe?: {
12
- isRejected: boolean;
13
- isSignedIn: boolean;
14
- enabled?: boolean;
15
- };
16
- }): null;
17
-
18
6
  /**
19
- * React component that monitors Solana wallet connections and updates the Satellite store
20
- *
21
- * @remarks
22
- * This component watches for changes in connected Solana wallets using the Wallet Standard.
23
- * Currently handles the first active wallet only, with multi-wallet support planned for future.
24
- * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.
25
- *
26
- * @returns null - This is a headless component
27
- *
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.
28
11
  */
29
- declare function SolanaWalletsWatcher(): null;
30
-
31
- /** Union type for all supported wallet types */
32
- type Wallet = EVMWallet | SolanaWallet;
33
- /** Union type for all supported connector types */
34
- type Connector = ConnectorEVM | ConnectorSolana;
12
+ interface AllWallets {
13
+ }
14
+ /**
15
+ * @description
16
+ * This interface is intentionally left empty.
17
+ * It will be augmented by satellite packages.
18
+ */
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<Connector, Wallet>> | 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
  *
@@ -143,4 +139,4 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
143
139
  */
144
140
  declare function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps): react_jsx_runtime.JSX.Element;
145
141
 
146
- export { type Connector, EVMWalletsWatcher, SatelliteConnectProvider, SatelliteStoreContext, SolanaWalletsWatcher, type Wallet, useInitializeAutoConnect, useSatelliteConnectStore };
142
+ export { type AllConnectors, type AllWallets, type Connector, SatelliteConnectProvider, SatelliteStoreContext, type Wallet, useInitializeAutoConnect, useSatelliteConnectStore };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import {getAdapterFromWalletType,OrbitAdapter,getWalletTypeFromConnectorName,formatWalletName}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 {jsx}from'react/jsx-runtime';var s=createContext(null),i=n=>{let t=useContext(s);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return useStore(t,n)};function B({wagmiConfig:n,siwe:t}){let r=i(l=>l.activeWallet),o=i(l=>l.updateActiveWallet),c=i(l=>l.walletConnectionError),e=i(l=>l.disconnect);return useEffect(()=>{t?.enabled&&!t?.isSignedIn&&t?.isRejected&&e();},[t,e]),useEffect(()=>watchAccount(n,{onChange:a=>{if(a?.status==="disconnected"&&e(),r&&getAdapterFromWalletType(r.walletType)!==OrbitAdapter.EVM||!a.address||c)return;if(t?.enabled?t.isSignedIn:true){let d=r?.walletType,f=d?{walletType:d,address:a.address,chainId:a.chainId,rpcURL:a.chain?.rpcUrls.default.http[0],isConnected:a.isConnected}:{address:a.address,chainId:a.chainId,rpcURL:a.chain?.rpcUrls.default.http[0],isConnected:a.isConnected};o(f);}}}),[r?.walletType,t,c]),null}function X(){let n=useWallets(),t=i(e=>e.updateActiveWallet),r=i(e=>e.walletConnectionError),o=i(e=>e.activeWallet),c=i(e=>e.disconnect);return useEffect(()=>{if(o&&getAdapterFromWalletType(o.walletType)===OrbitAdapter.SOLANA){let e=n.filter(l=>getWalletTypeFromConnectorName(OrbitAdapter.SOLANA,formatWalletName(l.name))===o.walletType)[0];r||t({address:e?.accounts[0]?.address,isConnected:e?.accounts.length>0,connectedAccount:e?.accounts[0],connectedWallet:e}),e?.accounts.length===0&&c();}},[o?.walletType,n,r,t,c]),null}var u=({initializeAutoConnect:n,onError:t})=>{useEffect(()=>{(async()=>{try{await n();}catch(o){(t??(e=>console.error("Failed to initialize auto connect:",e)))(o);}})();},[]);};function re({children:n,autoConnect:t,...r}){let o=useMemo(()=>createSatelliteConnectStore({...r}),[]);return useEffect(()=>{o.getState().disconnectAll();},[]),u({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsx(s.Provider,{value:o,children:n})}export{B as EVMWalletsWatcher,re as SatelliteConnectProvider,s as SatelliteStoreContext,X as SolanaWalletsWatcher,u as useInitializeAutoConnect,i 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/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","EVMWalletsWatcher","wagmiConfig","siwe","activeWallet","state","updateActiveWallet","walletConnectionError","disconnect","useEffect","watchAccount","account","getAdapterFromWalletType","OrbitAdapter","walletType","walletUpdate","SolanaWalletsWatcher","wallets","useWallets","activeWalletFromStore","w","getWalletTypeFromConnectorName","formatWalletName","useInitializeAutoConnect","initializeAutoConnect","onError","error","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatellite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A,EAAS,CAAE,qBAAA,CAAsB+B,CAAAA,EAAe,EAAK,CAC1F,CAAC,CAAA,CAEMI,GAAAA,CAACvC,CAAAA,CAAsB,QAAA,CAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAA8B,CAAAA,CAAS,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 { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, watchAccount, WatchAccountParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../hooks/satteliteHook';\n\nexport function EVMWalletsWatcher({\n wagmiConfig,\n siwe,\n}: {\n wagmiConfig: Config;\n siwe?: {\n isRejected: boolean;\n isSignedIn: boolean;\n enabled?: boolean;\n };\n}) {\n const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);\n const updateActiveWallet = useSatelliteConnectStore((state) => state.updateActiveWallet);\n const walletConnectionError = useSatelliteConnectStore((state) => state.walletConnectionError);\n const disconnect = useSatelliteConnectStore((state) => state.disconnect);\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","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 '../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 const wallets = useWallets();\n\n // Get the updateActiveWallet function from the Satellite store\n const updateActiveWallet = useSatelliteConnectStore((state) => state.updateActiveWallet);\n const walletConnectionError = useSatelliteConnectStore((state) => state.walletConnectionError);\n const activeWalletFromStore = useSatelliteConnectStore((state) => state.activeWallet);\n const disconnect = useSatelliteConnectStore((state) => state.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 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","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 */\ninterface 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
+ {"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 */\ninterface 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": "1.0.0-fix-test-alpha.48.5732da8",
3
+ "version": "1.0.0-fix-test-alpha.50.f997a2c",
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
  },
@@ -46,6 +63,8 @@
46
63
  "@tuwaio/satellite-evm": ">=0",
47
64
  "@tuwaio/satellite-solana": ">=0",
48
65
  "@wagmi/core": "2.x.x",
66
+ "@wagmi/connectors": "6.x.x",
67
+ "viem": "2.x.x",
49
68
  "@wallet-standard/react": "1.x.x",
50
69
  "gill": ">=0.12",
51
70
  "react": "19.x.x",
@@ -54,7 +73,8 @@
54
73
  },
55
74
  "devDependencies": {
56
75
  "@types/react": "^19.2.2",
57
- "@wagmi/core": "^2.22.0",
76
+ "@wagmi/core": "^2.22.1",
77
+ "@wagmi/connectors": "^6.0.1",
58
78
  "@wallet-standard/react": "^1.0.1",
59
79
  "@wallet-standard/app": "^1.1.0",
60
80
  "@wallet-standard/base": "^1.1.0",
@@ -66,14 +86,15 @@
66
86
  "immer": "^10.1.3",
67
87
  "react": "^19.2.0",
68
88
  "tsup": "^8.5.0",
89
+ "viem": "^2.38.2",
69
90
  "typescript": "^5.9.3",
70
91
  "zustand": "^5.0.8",
71
- "@tuwaio/orbit-core": "^1.0.0-fix-test-alpha.48.5732da8",
72
- "@tuwaio/orbit-evm": "^1.0.0-fix-test-alpha.48.5732da8",
73
- "@tuwaio/orbit-solana": "^1.0.0-fix-test-alpha.48.5732da8",
74
- "@tuwaio/satellite-core": "^1.0.0-fix-test-alpha.48.5732da8",
75
- "@tuwaio/satellite-evm": "^1.0.0-fix-test-alpha.48.5732da8",
76
- "@tuwaio/satellite-solana": "^1.0.0-fix-test-alpha.48.5732da8"
92
+ "@tuwaio/orbit-core": "^1.0.0-fix-test-alpha.50.f997a2c",
93
+ "@tuwaio/orbit-solana": "^1.0.0-fix-test-alpha.50.f997a2c",
94
+ "@tuwaio/orbit-evm": "^1.0.0-fix-test-alpha.50.f997a2c",
95
+ "@tuwaio/satellite-core": "^1.0.0-fix-test-alpha.50.f997a2c",
96
+ "@tuwaio/satellite-evm": "^1.0.0-fix-test-alpha.50.f997a2c",
97
+ "@tuwaio/satellite-solana": "^1.0.0-fix-test-alpha.50.f997a2c"
77
98
  },
78
99
  "scripts": {
79
100
  "start": "tsup src/index.ts --watch",