@tuwaio/satellite-react 1.0.0-fix-gemini-alpha.1.81f88ab → 1.0.0-fix-packages-alpha.2.a842786
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -15
- package/dist/evm/index.cjs +1 -1
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.js +1 -1
- package/dist/evm/index.js.map +1 -1
- package/package.json +16 -21
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ Built on top of `@tuwaio/satellite-core`, this package offers a seamless develop
|
|
|
29
29
|
## 💾 Installation
|
|
30
30
|
|
|
31
31
|
### Requirements
|
|
32
|
+
|
|
32
33
|
- React 19+
|
|
33
34
|
- Node.js 20+
|
|
34
35
|
- TypeScript 5.9+
|
|
@@ -43,43 +44,34 @@ npm install @tuwaio/satellite-react @tuwaio/satellite-core @tuwaio/orbit-core @w
|
|
|
43
44
|
# Using yarn
|
|
44
45
|
yarn add @tuwaio/satellite-react @tuwaio/satellite-core @tuwaio/orbit-core @wagmi/core @wallet-standard/react gill react immer zustand
|
|
45
46
|
```
|
|
47
|
+
|
|
46
48
|
---
|
|
47
49
|
|
|
48
50
|
## 🚀 Quick Start
|
|
49
51
|
|
|
50
52
|
### Basic Setup
|
|
53
|
+
|
|
51
54
|
```tsx
|
|
52
55
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
53
|
-
import { satelliteEVMAdapter, createDefaultTransports
|
|
56
|
+
import { satelliteEVMAdapter, createDefaultTransports } from '@tuwaio/satellite-evm';
|
|
54
57
|
import { SatelliteConnectProvider } from '@tuwaio/satellite-react';
|
|
55
58
|
import { EVMWalletsWatcher } from '@tuwaio/satellite-react/evm';
|
|
56
59
|
import { SolanaWalletsWatcher } from '@tuwaio/satellite-react/solana';
|
|
57
60
|
import { satelliteSolanaAdapter } from '@tuwaio/satellite-solana';
|
|
58
61
|
import { WagmiProvider } from 'wagmi';
|
|
59
62
|
import { ReactNode } from 'react';
|
|
60
|
-
import { createConfig
|
|
63
|
+
import { createConfig } from '@wagmi/core';
|
|
64
|
+
import { injected } from '@wagmi/connectors';
|
|
61
65
|
import { mainnet, sepolia } from 'viem/chains';
|
|
62
66
|
import type { Chain } from 'viem/chains';
|
|
63
67
|
|
|
64
|
-
export const appConfig = {
|
|
65
|
-
appName: 'Satellite EVM Test App',
|
|
66
|
-
// Ensure you have WalletConnect Project ID in your environment variables
|
|
67
|
-
projectId: process.env.NEXT_PUBLIC_WALLET_PROJECT_ID ?? 'YOUR_OWN_PROJECT_ID',
|
|
68
|
-
};
|
|
69
|
-
|
|
70
68
|
export const appEVMChains = [
|
|
71
69
|
mainnet,
|
|
72
70
|
sepolia,
|
|
73
71
|
] as readonly [Chain, ...Chain[]];
|
|
74
72
|
|
|
75
73
|
export const wagmiConfig = createConfig({
|
|
76
|
-
connectors:
|
|
77
|
-
...appConfig,
|
|
78
|
-
// Optional: Add app details for WalletConnect modal
|
|
79
|
-
description: 'My awesome dApp',
|
|
80
|
-
appUrl: '[https://my-dapp.com](https://my-dapp.com)',
|
|
81
|
-
appIcons: ['[https://my-dapp.com/icon.png](https://my-dapp.com/icon.png)'],
|
|
82
|
-
}),
|
|
74
|
+
connectors: [injected()],
|
|
83
75
|
transports: createDefaultTransports(appEVMChains), // Automatically creates http transports
|
|
84
76
|
chains: appEVMChains,
|
|
85
77
|
ssr: true, // Enable SSR support if needed (e.g., in Next.js)
|
|
@@ -111,6 +103,7 @@ export function Providers({ children }: { children: ReactNode }) {
|
|
|
111
103
|
```
|
|
112
104
|
|
|
113
105
|
### Using Hooks
|
|
106
|
+
|
|
114
107
|
```tsx
|
|
115
108
|
import { useSatelliteConnectStore } from '@tuwaio/satellite-react';
|
|
116
109
|
|
|
@@ -119,6 +112,7 @@ function ExampleGettingActiveWalletFromStore() {
|
|
|
119
112
|
return <div>{activeWallet?.address}</div>
|
|
120
113
|
}
|
|
121
114
|
```
|
|
115
|
+
|
|
122
116
|
---
|
|
123
117
|
|
|
124
118
|
### Core Components
|
package/dist/evm/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkYC7F3NGW_cjs=require('../chunk-YC7F3NGW.cjs'),orbitCore=require('@tuwaio/orbit-core'),core=require('@wagmi/core'),react=require('react');function
|
|
1
|
+
'use strict';var chunkYC7F3NGW_cjs=require('../chunk-YC7F3NGW.cjs'),orbitCore=require('@tuwaio/orbit-core'),core=require('@wagmi/core'),react=require('react');function T({wagmiConfig:r,siwe:e}){let o=chunkYC7F3NGW_cjs.b(t=>t.activeWallet),a=chunkYC7F3NGW_cjs.b(t=>t.disconnect),p=chunkYC7F3NGW_cjs.b(t=>t.walletConnectionError),f=chunkYC7F3NGW_cjs.b(t=>t.updateActiveWallet);return react.useEffect(()=>{e?.enabled&&!e?.isSignedIn&&e?.isRejected&&a();},[e,a]),react.useEffect(()=>core.watchConnections(r,{onChange:l=>{if(l.length===0){a();return}let i=r.state.current?l.find(c=>c.connector.uid===r.state.current):l[0];if(!i){a();return}let s=i.accounts[0],d=i.chainId;if(o&&orbitCore.getAdapterFromWalletType(o.walletType)!==orbitCore.OrbitAdapter.EVM||!s||p)return;if(e?.enabled?e.isSignedIn:true){let c=o?.walletType,u=r.chains.find(C=>C.id===d)?.rpcUrls.default.http[0];f(c?{walletType:c,address:s,chainId:d,rpcURL:u,isConnected:true}:{address:s,chainId:d,rpcURL:u,isConnected:true});}}}),[o?.walletType,e,p]),null}exports.EVMWalletsWatcher=T;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/evm/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","activeWallet","useSatelliteConnectStore","store","disconnect","walletConnectionError","updateActiveWallet","useEffect","
|
|
1
|
+
{"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","activeWallet","useSatelliteConnectStore","store","disconnect","walletConnectionError","updateActiveWallet","useEffect","watchConnections","connections","currentConnection","primaryAccount","chainId","getAdapterFromWalletType","OrbitAdapter","walletType","rpcURL","c"],"mappings":"+JAiDO,SAASA,CAAAA,CAAkB,CAAE,YAAAC,CAAAA,CAAa,IAAA,CAAAC,CAAK,CAAA,CAA2B,CAO/E,IAAMC,CAAAA,CAAeC,mBAAAA,CAA0BC,GAAUA,CAAAA,CAAM,YAAY,EAIrEC,CAAAA,CAAaF,mBAAAA,CAA0BC,GAAUA,CAAAA,CAAM,UAAU,EAIjEE,CAAAA,CAAwBH,mBAAAA,CAA0BC,GAAUA,CAAAA,CAAM,qBAAqB,EAIvFG,CAAAA,CAAqBJ,mBAAAA,CAA0BC,GAAUA,CAAAA,CAAM,kBAAkB,EAYvF,OAAAI,eAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,SAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC9CI,IAEJ,CAAA,CAAG,CAACJ,CAAAA,CAAMI,CAAU,CAAC,CAAA,CASrBG,eAAAA,CAAU,IAqFQC,qBAAAA,CAAiBT,CAAAA,CAAa,CAAE,QAAA,CA9EyBU,CAAAA,EAAgB,CAEvF,GAAIA,CAAAA,CAAY,SAAW,CAAA,CAAG,CAC5BL,GAAW,CACX,MACF,CAIA,IAAMM,CAAAA,CAAoBX,EAAY,KAAA,CAAM,OAAA,CACxCU,EAAY,IAAA,CAAM,CAAA,EAAM,CAAA,CAAE,SAAA,CAAU,GAAA,GAAQV,CAAAA,CAAY,MAAM,OAAO,CAAA,CACrEU,EAAY,CAAC,CAAA,CAGjB,GAAI,CAACC,CAAAA,CAAmB,CACtBN,CAAAA,EAAW,CACX,MACF,CAGA,IAAMO,EAAiBD,CAAAA,CAAkB,QAAA,CAAS,CAAC,CAAA,CAC7CE,CAAAA,CAAUF,EAAkB,OAAA,CAQlC,GACGT,GAAgBY,kCAAAA,CAAyBZ,CAAAA,CAAa,UAAU,CAAA,GAAMa,sBAAAA,CAAa,KACpF,CAACH,CAAAA,EACDN,EAEA,OAUF,GAFqBL,GAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAEhB,IAAMe,CAAAA,CAAad,CAAAA,EAAc,UAAA,CAI3Be,CAAAA,CADQjB,CAAAA,CAAY,MAAA,CAAO,KAAMkB,CAAAA,EAAMA,CAAAA,CAAE,KAAOL,CAAO,CAAA,EACvC,QAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAuB5CN,CAAAA,CAlBqBS,EACjB,CAEE,UAAA,CAAAA,EACA,OAAA,CAASJ,CAAAA,CACT,QAAAC,CAAAA,CACA,MAAA,CAAAI,EACA,WAAA,CAAa,IACf,EACA,CAEE,OAAA,CAASL,EACT,OAAA,CAAAC,CAAAA,CACA,OAAAI,CAAAA,CACA,WAAA,CAAa,IACf,CAG2B,EACjC,CACF,CAGkF,CAAC,EAOlF,CAACf,CAAAA,EAAc,WAAYD,CAAAA,CAAMK,CAAqB,CAAC,CAAA,CAGnD,IACT","file":"index.cjs","sourcesContent":["import { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMWalletsWatcher} component.\n */\ninterface EVMWalletsWatcherProps {\n /**\n * The configuration object from `@wagmi/core`.\n * This is required to initialize the account watcher.\n */\n wagmiConfig: Config;\n\n /**\n * Optional object representing the Sign-In With Ethereum (SIWE) state.\n * If provided, the watcher will use this state to manage updates\n * and disconnections based on SIWE status.\n */\n siwe?: {\n /**\n * Flag indicating if the SIWE authentication request was rejected by the user.\n */\n isRejected: boolean;\n /**\n * Flag indicating if the user is successfully signed in via SIWE.\n */\n isSignedIn: boolean;\n /**\n * Flag indicating if the SIWE flow is enabled.\n */\n enabled?: boolean;\n };\n}\n\n/**\n * A headless React component (renders `null`) that synchronizes the EVM wallet\n * state from `@wagmi/core` with the global `useSatelliteConnectStore`.\n *\n * It is responsible for:\n * 1. Automatically disconnecting if a SIWE (Sign-In With Ethereum) request is rejected.\n * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)\n * from `wagmi` and updating the global store accordingly.\n *\n * @param props - The component's props. See {@link EVMWalletsWatcherProps}.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMWalletsWatcher({ wagmiConfig, siwe }: EVMWalletsWatcherProps) {\n // --- Global Store State ---\n // Subscribes to parts of the global Zustand store.\n\n /**\n * The currently active wallet object from the global store.\n */\n const activeWallet = useSatelliteConnectStore((store) => store.activeWallet);\n /**\n * The global function to trigger a wallet disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n /**\n * The global function to update the active wallet's details.\n */\n const updateActiveWallet = useSatelliteConnectStore((store) => store.updateActiveWallet);\n\n // --- Effects ---\n\n /**\n * Effect: Handles SIWE rejection.\n *\n * If the SIWE flow is enabled (`siwe.enabled`), the user is not yet\n * signed in (`!siwe.isSignedIn`), and they have explicitly rejected\n * the SIWE signature request (`siwe.isRejected`), this effect\n * will call the global `disconnect` function.\n */\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n disconnect();\n }\n }, [siwe, disconnect]);\n\n /**\n * Effect: Subscribes to wagmi connection changes.\n *\n * This effect initializes `watchConnections` from `@wagmi/core` to listen for\n * any changes in the connected wallets' state (like switching accounts,\n * changing networks, or disconnecting). Supports multiple simultaneous connections.\n */\n useEffect(() => {\n /**\n * Callback function triggered by `watchConnections` whenever the\n * wagmi connections state changes.\n *\n * @param connections - Array of all active connections from wagmi.\n */\n const handleConnectionsChange: WatchConnectionsParameters['onChange'] = (connections) => {\n // Case 1: No connections means all wallets were disconnected\n if (connections.length === 0) {\n disconnect();\n return;\n }\n\n // Get the current connection from wagmi config state\n // The \"current\" connection is typically the most recently used/active one\n const currentConnection = wagmiConfig.state.current\n ? connections.find((c) => c.connector.uid === wagmiConfig.state.current)\n : connections[0]; // Fallback to first connection if no current is set\n\n // If no valid connection is found, disconnect\n if (!currentConnection) {\n disconnect();\n return;\n }\n\n // Extract the primary account from the current connection\n const primaryAccount = currentConnection.accounts[0];\n const chainId = currentConnection.chainId;\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active wallet in our store is NOT an EVM wallet\n // (we don't want this watcher to override a non-EVM wallet).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeWallet && getAdapterFromWalletType(activeWallet.walletType) !== OrbitAdapter.EVM) ||\n !primaryAccount ||\n walletConnectionError\n ) {\n return;\n }\n\n /**\n * Determines if the global store *should* be updated.\n * - If SIWE is enabled, we only update the store if the user is signed in.\n * - If SIWE is not enabled, we always update the store.\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n // Preserve the `walletType` if it already exists in the active wallet.\n const walletType = activeWallet?.walletType;\n\n // Get the chain information for RPC URL\n const chain = wagmiConfig.chains.find((c) => c.id === chainId);\n const rpcURL = chain?.rpcUrls.default.http[0];\n\n /**\n * The payload to send to the global store update function.\n */\n const walletUpdate = walletType\n ? {\n // Preserve the walletType (e.g., 'metamask', 'walletconnect')\n walletType,\n address: primaryAccount,\n chainId,\n rpcURL,\n isConnected: true,\n }\n : {\n // Fallback if activeWallet was null or had no type\n address: primaryAccount,\n chainId,\n rpcURL,\n isConnected: true,\n };\n\n // Update the global store with the new wallet state.\n updateActiveWallet(walletUpdate);\n }\n };\n\n // Activate the watcher\n const unwatch = watchConnections(wagmiConfig, { onChange: handleConnectionsChange });\n\n // Return the cleanup function.\n // This `unwatch` function will be called when the component unmounts\n // or when the dependencies in the array change, preventing memory leaks.\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeWallet?.walletType, siwe, walletConnectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
|
package/dist/evm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {b}from'../chunk-3WMGCMYX.js';import {getAdapterFromWalletType,OrbitAdapter}from'@tuwaio/orbit-core';import {
|
|
1
|
+
import {b}from'../chunk-3WMGCMYX.js';import {getAdapterFromWalletType,OrbitAdapter}from'@tuwaio/orbit-core';import {watchConnections}from'@wagmi/core';import {useEffect}from'react';function T({wagmiConfig:r,siwe:e}){let o=b(t=>t.activeWallet),a=b(t=>t.disconnect),p=b(t=>t.walletConnectionError),f=b(t=>t.updateActiveWallet);return useEffect(()=>{e?.enabled&&!e?.isSignedIn&&e?.isRejected&&a();},[e,a]),useEffect(()=>watchConnections(r,{onChange:l=>{if(l.length===0){a();return}let i=r.state.current?l.find(c=>c.connector.uid===r.state.current):l[0];if(!i){a();return}let s=i.accounts[0],d=i.chainId;if(o&&getAdapterFromWalletType(o.walletType)!==OrbitAdapter.EVM||!s||p)return;if(e?.enabled?e.isSignedIn:true){let c=o?.walletType,u=r.chains.find(C=>C.id===d)?.rpcUrls.default.http[0];f(c?{walletType:c,address:s,chainId:d,rpcURL:u,isConnected:true}:{address:s,chainId:d,rpcURL:u,isConnected:true});}}}),[o?.walletType,e,p]),null}export{T as EVMWalletsWatcher};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/evm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","activeWallet","useSatelliteConnectStore","store","disconnect","walletConnectionError","updateActiveWallet","useEffect","
|
|
1
|
+
{"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","activeWallet","useSatelliteConnectStore","store","disconnect","walletConnectionError","updateActiveWallet","useEffect","watchConnections","connections","currentConnection","primaryAccount","chainId","getAdapterFromWalletType","OrbitAdapter","walletType","rpcURL","c"],"mappings":"qLAiDO,SAASA,CAAAA,CAAkB,CAAE,YAAAC,CAAAA,CAAa,IAAA,CAAAC,CAAK,CAAA,CAA2B,CAO/E,IAAMC,CAAAA,CAAeC,CAAAA,CAA0BC,GAAUA,CAAAA,CAAM,YAAY,EAIrEC,CAAAA,CAAaF,CAAAA,CAA0BC,GAAUA,CAAAA,CAAM,UAAU,EAIjEE,CAAAA,CAAwBH,CAAAA,CAA0BC,GAAUA,CAAAA,CAAM,qBAAqB,EAIvFG,CAAAA,CAAqBJ,CAAAA,CAA0BC,GAAUA,CAAAA,CAAM,kBAAkB,EAYvF,OAAAI,SAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,SAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC9CI,IAEJ,CAAA,CAAG,CAACJ,CAAAA,CAAMI,CAAU,CAAC,CAAA,CASrBG,SAAAA,CAAU,IAqFQC,gBAAAA,CAAiBT,CAAAA,CAAa,CAAE,QAAA,CA9EyBU,CAAAA,EAAgB,CAEvF,GAAIA,CAAAA,CAAY,SAAW,CAAA,CAAG,CAC5BL,GAAW,CACX,MACF,CAIA,IAAMM,CAAAA,CAAoBX,EAAY,KAAA,CAAM,OAAA,CACxCU,EAAY,IAAA,CAAM,CAAA,EAAM,CAAA,CAAE,SAAA,CAAU,GAAA,GAAQV,CAAAA,CAAY,MAAM,OAAO,CAAA,CACrEU,EAAY,CAAC,CAAA,CAGjB,GAAI,CAACC,CAAAA,CAAmB,CACtBN,CAAAA,EAAW,CACX,MACF,CAGA,IAAMO,EAAiBD,CAAAA,CAAkB,QAAA,CAAS,CAAC,CAAA,CAC7CE,CAAAA,CAAUF,EAAkB,OAAA,CAQlC,GACGT,GAAgBY,wBAAAA,CAAyBZ,CAAAA,CAAa,UAAU,CAAA,GAAMa,YAAAA,CAAa,KACpF,CAACH,CAAAA,EACDN,EAEA,OAUF,GAFqBL,GAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAEhB,IAAMe,CAAAA,CAAad,CAAAA,EAAc,UAAA,CAI3Be,CAAAA,CADQjB,CAAAA,CAAY,MAAA,CAAO,KAAMkB,CAAAA,EAAMA,CAAAA,CAAE,KAAOL,CAAO,CAAA,EACvC,QAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAuB5CN,CAAAA,CAlBqBS,EACjB,CAEE,UAAA,CAAAA,EACA,OAAA,CAASJ,CAAAA,CACT,QAAAC,CAAAA,CACA,MAAA,CAAAI,EACA,WAAA,CAAa,IACf,EACA,CAEE,OAAA,CAASL,EACT,OAAA,CAAAC,CAAAA,CACA,OAAAI,CAAAA,CACA,WAAA,CAAa,IACf,CAG2B,EACjC,CACF,CAGkF,CAAC,EAOlF,CAACf,CAAAA,EAAc,WAAYD,CAAAA,CAAMK,CAAqB,CAAC,CAAA,CAGnD,IACT","file":"index.js","sourcesContent":["import { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMWalletsWatcher} component.\n */\ninterface EVMWalletsWatcherProps {\n /**\n * The configuration object from `@wagmi/core`.\n * This is required to initialize the account watcher.\n */\n wagmiConfig: Config;\n\n /**\n * Optional object representing the Sign-In With Ethereum (SIWE) state.\n * If provided, the watcher will use this state to manage updates\n * and disconnections based on SIWE status.\n */\n siwe?: {\n /**\n * Flag indicating if the SIWE authentication request was rejected by the user.\n */\n isRejected: boolean;\n /**\n * Flag indicating if the user is successfully signed in via SIWE.\n */\n isSignedIn: boolean;\n /**\n * Flag indicating if the SIWE flow is enabled.\n */\n enabled?: boolean;\n };\n}\n\n/**\n * A headless React component (renders `null`) that synchronizes the EVM wallet\n * state from `@wagmi/core` with the global `useSatelliteConnectStore`.\n *\n * It is responsible for:\n * 1. Automatically disconnecting if a SIWE (Sign-In With Ethereum) request is rejected.\n * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)\n * from `wagmi` and updating the global store accordingly.\n *\n * @param props - The component's props. See {@link EVMWalletsWatcherProps}.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMWalletsWatcher({ wagmiConfig, siwe }: EVMWalletsWatcherProps) {\n // --- Global Store State ---\n // Subscribes to parts of the global Zustand store.\n\n /**\n * The currently active wallet object from the global store.\n */\n const activeWallet = useSatelliteConnectStore((store) => store.activeWallet);\n /**\n * The global function to trigger a wallet disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n /**\n * The global function to update the active wallet's details.\n */\n const updateActiveWallet = useSatelliteConnectStore((store) => store.updateActiveWallet);\n\n // --- Effects ---\n\n /**\n * Effect: Handles SIWE rejection.\n *\n * If the SIWE flow is enabled (`siwe.enabled`), the user is not yet\n * signed in (`!siwe.isSignedIn`), and they have explicitly rejected\n * the SIWE signature request (`siwe.isRejected`), this effect\n * will call the global `disconnect` function.\n */\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n disconnect();\n }\n }, [siwe, disconnect]);\n\n /**\n * Effect: Subscribes to wagmi connection changes.\n *\n * This effect initializes `watchConnections` from `@wagmi/core` to listen for\n * any changes in the connected wallets' state (like switching accounts,\n * changing networks, or disconnecting). Supports multiple simultaneous connections.\n */\n useEffect(() => {\n /**\n * Callback function triggered by `watchConnections` whenever the\n * wagmi connections state changes.\n *\n * @param connections - Array of all active connections from wagmi.\n */\n const handleConnectionsChange: WatchConnectionsParameters['onChange'] = (connections) => {\n // Case 1: No connections means all wallets were disconnected\n if (connections.length === 0) {\n disconnect();\n return;\n }\n\n // Get the current connection from wagmi config state\n // The \"current\" connection is typically the most recently used/active one\n const currentConnection = wagmiConfig.state.current\n ? connections.find((c) => c.connector.uid === wagmiConfig.state.current)\n : connections[0]; // Fallback to first connection if no current is set\n\n // If no valid connection is found, disconnect\n if (!currentConnection) {\n disconnect();\n return;\n }\n\n // Extract the primary account from the current connection\n const primaryAccount = currentConnection.accounts[0];\n const chainId = currentConnection.chainId;\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active wallet in our store is NOT an EVM wallet\n // (we don't want this watcher to override a non-EVM wallet).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeWallet && getAdapterFromWalletType(activeWallet.walletType) !== OrbitAdapter.EVM) ||\n !primaryAccount ||\n walletConnectionError\n ) {\n return;\n }\n\n /**\n * Determines if the global store *should* be updated.\n * - If SIWE is enabled, we only update the store if the user is signed in.\n * - If SIWE is not enabled, we always update the store.\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n // Preserve the `walletType` if it already exists in the active wallet.\n const walletType = activeWallet?.walletType;\n\n // Get the chain information for RPC URL\n const chain = wagmiConfig.chains.find((c) => c.id === chainId);\n const rpcURL = chain?.rpcUrls.default.http[0];\n\n /**\n * The payload to send to the global store update function.\n */\n const walletUpdate = walletType\n ? {\n // Preserve the walletType (e.g., 'metamask', 'walletconnect')\n walletType,\n address: primaryAccount,\n chainId,\n rpcURL,\n isConnected: true,\n }\n : {\n // Fallback if activeWallet was null or had no type\n address: primaryAccount,\n chainId,\n rpcURL,\n isConnected: true,\n };\n\n // Update the global store with the new wallet state.\n updateActiveWallet(walletUpdate);\n }\n };\n\n // Activate the watcher\n const unwatch = watchConnections(wagmiConfig, { onChange: handleConnectionsChange });\n\n // Return the cleanup function.\n // This `unwatch` function will be called when the component unmounts\n // or when the dependencies in the array change, preventing memory leaks.\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeWallet?.walletType, siwe, walletConnectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/satellite-react",
|
|
3
|
-
"version": "1.0.0-fix-
|
|
3
|
+
"version": "1.0.0-fix-packages-alpha.2.a842786",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -62,13 +62,12 @@
|
|
|
62
62
|
"@tuwaio/satellite-core": ">=0.1",
|
|
63
63
|
"@tuwaio/satellite-evm": ">=0.1",
|
|
64
64
|
"@tuwaio/satellite-solana": ">=0.1",
|
|
65
|
-
"@wagmi/core": "
|
|
66
|
-
"@wagmi/connectors": "6.x.x",
|
|
65
|
+
"@wagmi/core": "3.x.x",
|
|
67
66
|
"viem": "2.x.x",
|
|
68
67
|
"@wallet-standard/react": "1.x.x",
|
|
69
|
-
"gill": ">=0.
|
|
68
|
+
"gill": ">=0.14",
|
|
70
69
|
"react": "19.x.x",
|
|
71
|
-
"immer": "
|
|
70
|
+
"immer": "11.x.x",
|
|
72
71
|
"zustand": "5.x.x"
|
|
73
72
|
},
|
|
74
73
|
"peerDependenciesMeta": {
|
|
@@ -96,9 +95,6 @@
|
|
|
96
95
|
"@wagmi/core": {
|
|
97
96
|
"optional": true
|
|
98
97
|
},
|
|
99
|
-
"@wagmi/connectors": {
|
|
100
|
-
"optional": true
|
|
101
|
-
},
|
|
102
98
|
"viem": {
|
|
103
99
|
"optional": true
|
|
104
100
|
},
|
|
@@ -116,12 +112,11 @@
|
|
|
116
112
|
}
|
|
117
113
|
},
|
|
118
114
|
"devDependencies": {
|
|
119
|
-
"@types/react": "^19.2.
|
|
120
|
-
"@tuwaio/orbit-core": "
|
|
121
|
-
"@tuwaio/orbit-evm": "
|
|
122
|
-
"@tuwaio/orbit-solana": "
|
|
123
|
-
"@wagmi/core": "^
|
|
124
|
-
"@wagmi/connectors": "^6.1.2",
|
|
115
|
+
"@types/react": "^19.2.7",
|
|
116
|
+
"@tuwaio/orbit-core": "1.0.0-fix-packages-alpha.2.a02ae73",
|
|
117
|
+
"@tuwaio/orbit-evm": "1.0.0-fix-packages-alpha.2.a02ae73",
|
|
118
|
+
"@tuwaio/orbit-solana": "1.0.0-fix-packages-alpha.2.a02ae73",
|
|
119
|
+
"@wagmi/core": "^3.0.0",
|
|
125
120
|
"@wallet-standard/react": "^1.0.1",
|
|
126
121
|
"@wallet-standard/app": "^1.1.0",
|
|
127
122
|
"@wallet-standard/base": "^1.1.0",
|
|
@@ -129,16 +124,16 @@
|
|
|
129
124
|
"@wallet-standard/core": "^1.1.1",
|
|
130
125
|
"@wallet-standard/ui": "^1.0.1",
|
|
131
126
|
"@wallet-standard/ui-registry": "^1.0.1",
|
|
132
|
-
"gill": "^0.
|
|
133
|
-
"immer": "^
|
|
127
|
+
"gill": "^0.14.0",
|
|
128
|
+
"immer": "^11.0.0",
|
|
134
129
|
"react": "^19.2.0",
|
|
135
|
-
"tsup": "^8.5.
|
|
136
|
-
"viem": "^2.
|
|
130
|
+
"tsup": "^8.5.1",
|
|
131
|
+
"viem": "^2.40.3",
|
|
137
132
|
"typescript": "^5.9.3",
|
|
138
133
|
"zustand": "^5.0.8",
|
|
139
|
-
"@tuwaio/satellite-solana": "^1.0.0-fix-
|
|
140
|
-
"@tuwaio/satellite-
|
|
141
|
-
"@tuwaio/satellite-
|
|
134
|
+
"@tuwaio/satellite-solana": "^1.0.0-fix-packages-alpha.2.a842786",
|
|
135
|
+
"@tuwaio/satellite-evm": "^1.0.0-fix-packages-alpha.2.a842786",
|
|
136
|
+
"@tuwaio/satellite-core": "^1.0.0-fix-packages-alpha.2.a842786"
|
|
142
137
|
},
|
|
143
138
|
"scripts": {
|
|
144
139
|
"start": "tsup src/index.ts --watch",
|