@tuwaio/satellite-evm 0.2.6 → 0.2.8
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 +42 -35
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -18,7 +18,6 @@ Built on top of `@tuwaio/satellite-core`, this package integrates seamlessly wit
|
|
|
18
18
|
|
|
19
19
|
## ✨ Key Features
|
|
20
20
|
|
|
21
|
-
- **EVM Wallet Support:** Native support for popular EVM wallets
|
|
22
21
|
- **Chain Management:** Built-in utilities for handling multiple EVM chains
|
|
23
22
|
- **Type Safety:** Full TypeScript support with proper type definitions
|
|
24
23
|
- **Wagmi Integration:** Seamless integration with @wagmi/core utilities
|
|
@@ -30,18 +29,12 @@ Built on top of `@tuwaio/satellite-core`, this package integrates seamlessly wit
|
|
|
30
29
|
|
|
31
30
|
### Requirements
|
|
32
31
|
|
|
33
|
-
- Node.js 20
|
|
32
|
+
- Node.js 20-24
|
|
34
33
|
- TypeScript 5.9+
|
|
35
34
|
|
|
36
35
|
```bash
|
|
37
|
-
# Using pnpm (recommended)
|
|
36
|
+
# Using pnpm (recommended), but you can use npm, yarn or bun as well
|
|
38
37
|
pnpm add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @tuwaio/orbit-core @tuwaio/orbit-evm
|
|
39
|
-
|
|
40
|
-
# Using npm
|
|
41
|
-
npm install @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @tuwaio/orbit-core @tuwaio/orbit-evm
|
|
42
|
-
|
|
43
|
-
# Using yarn
|
|
44
|
-
yarn add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @tuwaio/orbit-core @tuwaio/orbit-evm
|
|
45
38
|
````
|
|
46
39
|
|
|
47
40
|
-----
|
|
@@ -84,7 +77,7 @@ You create the adapter by passing your `wagmiConfig` to the `satelliteEVMAdapter
|
|
|
84
77
|
import { satelliteEVMAdapter } from '@tuwaio/satellite-evm';
|
|
85
78
|
import { wagmiConfig } from './your-wagmi-config'; // Import your configured wagmiConfig
|
|
86
79
|
|
|
87
|
-
const evmAdapter = satelliteEVMAdapter(wagmiConfig);
|
|
80
|
+
export const evmAdapter = satelliteEVMAdapter(wagmiConfig);
|
|
88
81
|
```
|
|
89
82
|
|
|
90
83
|
### Integrating with Satellite Connect Provider
|
|
@@ -96,13 +89,12 @@ import { SatelliteConnectProvider, EVMConnectorsWatcher } from '@tuwaio/satellit
|
|
|
96
89
|
import { WagmiProvider } from 'wagmi';
|
|
97
90
|
import { satelliteEVMAdapter } from '@tuwaio/satellite-evm';
|
|
98
91
|
import { wagmiConfig } from './your-wagmi-config';
|
|
92
|
+
import { evmAdapter } from './your-evm-adapter';
|
|
99
93
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; // Wagmi requires react-query
|
|
100
94
|
|
|
101
95
|
const queryClient = new QueryClient();
|
|
102
96
|
|
|
103
97
|
function AppProviders({ children }: { children: React.ReactNode }) {
|
|
104
|
-
const evmAdapter = satelliteEVMAdapter(wagmiConfig);
|
|
105
|
-
|
|
106
98
|
return (
|
|
107
99
|
<WagmiProvider config={wagmiConfig}>
|
|
108
100
|
<QueryClientProvider client={queryClient}>
|
|
@@ -128,7 +120,7 @@ The `satelliteEVMAdapter` seamlessly integrates with SIWE solutions like `@tuwai
|
|
|
128
120
|
This ensures that the SIWE flow is automatically triggered after a successful wallet connection.
|
|
129
121
|
|
|
130
122
|
```tsx
|
|
131
|
-
// Example
|
|
123
|
+
// Example: SIWE integration with @tuwaio/satellite-siwe-next-auth
|
|
132
124
|
|
|
133
125
|
import { useSiweAuth, SiweNextAuthProvider } from '@tuwaio/satellite-siwe-next-auth';
|
|
134
126
|
import { SatelliteConnectProvider } from '@tuwaio/satellite-react';
|
|
@@ -137,50 +129,65 @@ import { satelliteEVMAdapter } from '@tuwaio/satellite-evm';
|
|
|
137
129
|
import { WagmiProvider } from 'wagmi';
|
|
138
130
|
import { wagmiConfig } from './your-wagmi-config'; // Your Wagmi config
|
|
139
131
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
132
|
+
import { ReactNode, useState } from 'react';
|
|
140
133
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// Assuming SiweNextAuthProvider is wrapping this component higher up
|
|
134
|
+
// Step 1: Create SatelliteConnectProvider wrapper that consumes SIWE context
|
|
135
|
+
function SatelliteSiweProvider({ children }: { children: ReactNode }) {
|
|
136
|
+
// Get SIWE auth state and methods from the provider above
|
|
145
137
|
const { signInWithSiwe, enabled: siweEnabled, isRejected, isSignedIn } = useSiweAuth();
|
|
146
138
|
|
|
147
|
-
// Create the adapter, passing signInWithSiwe if SIWE is enabled
|
|
148
|
-
const evmAdapter = satelliteEVMAdapter(wagmiConfig, siweEnabled ? signInWithSiwe : undefined);
|
|
149
|
-
|
|
150
139
|
return (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
140
|
+
<SatelliteConnectProvider
|
|
141
|
+
// Create the adapter, passing signInWithSiwe if SIWE is enabled
|
|
142
|
+
adapter={satelliteEVMAdapter(wagmiConfig, siweEnabled ? signInWithSiwe : undefined)}
|
|
143
|
+
autoConnect={true}
|
|
144
|
+
>
|
|
145
|
+
{/* Pass SIWE state to watcher for handling disconnections on SIWE rejection */}
|
|
146
|
+
<EVMConnectorsWatcher wagmiConfig={wagmiConfig} siwe={{ isSignedIn, isRejected, enabled: siweEnabled }} />
|
|
147
|
+
{children}
|
|
148
|
+
</SatelliteConnectProvider>
|
|
159
149
|
);
|
|
160
150
|
}
|
|
161
151
|
|
|
152
|
+
// Step 2: Compose all providers in the correct order
|
|
153
|
+
// Create QueryClient
|
|
154
|
+
const queryClient = new QueryClient();
|
|
162
155
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return (
|
|
156
|
+
function Providers({ children }: { children: ReactNode }) {
|
|
157
|
+
return (
|
|
166
158
|
<WagmiProvider config={wagmiConfig}>
|
|
167
159
|
<QueryClientProvider client={queryClient}>
|
|
168
|
-
|
|
160
|
+
{/* SIWE Provider must wrap SatelliteSiweProvider to provide context */}
|
|
169
161
|
<SiweNextAuthProvider wagmiConfig={wagmiConfig} enabled={true}>
|
|
170
|
-
|
|
162
|
+
<SatelliteSiweProvider>
|
|
163
|
+
{children}
|
|
164
|
+
</SatelliteSiweProvider>
|
|
171
165
|
</SiweNextAuthProvider>
|
|
172
166
|
</QueryClientProvider>
|
|
173
167
|
</WagmiProvider>
|
|
174
|
-
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Step 3: Use Providers in your application layout
|
|
172
|
+
function RootLayout({ children }: { children: React.ReactNode }) {
|
|
173
|
+
return (
|
|
174
|
+
<Providers>
|
|
175
|
+
{/* Your application components */}
|
|
176
|
+
{children}
|
|
177
|
+
</Providers>
|
|
178
|
+
);
|
|
175
179
|
}
|
|
176
180
|
```
|
|
177
181
|
|
|
178
182
|
-----
|
|
179
183
|
|
|
180
|
-
## 🛠️ Core Utilities
|
|
184
|
+
- ## 🛠️ Core Utilities
|
|
181
185
|
|
|
182
186
|
- **`createDefaultTransports`**: Helper to create default `http` transports for each chain in your `wagmiConfig`.
|
|
183
187
|
- **`checkIsWalletAddressContract`**: Utility to check if a connected address is a smart contract address. The result is cached in memory.
|
|
188
|
+
- **`createEVMConnectionsWatcher`**: Framework-agnostic utility to monitor wagmi connection changes and synchronize them with the global state store. Handles account switches, network changes, disconnections, and optional SIWE rejection scenarios. Returns a cleanup function.
|
|
189
|
+
|
|
190
|
+
-----
|
|
184
191
|
|
|
185
192
|
## 🤝 Contributing & Support
|
|
186
193
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/satellite-evm",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
"@tuwaio/satellite-core": ">=0.2.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@wagmi/core": "^3.
|
|
51
|
+
"@wagmi/core": "^3.3.1",
|
|
52
52
|
"@tuwaio/orbit-core": "^0.2.4",
|
|
53
|
-
"@tuwaio/orbit-evm": "^0.2.
|
|
53
|
+
"@tuwaio/orbit-evm": "^0.2.7",
|
|
54
54
|
"immer": "^11.1.3",
|
|
55
55
|
"jsdom": "^27.4.0",
|
|
56
56
|
"tsup": "^8.5.1",
|
|
57
57
|
"typescript": "^5.9.3",
|
|
58
|
-
"viem": "^2.44.
|
|
59
|
-
"vitest": "^4.0.
|
|
58
|
+
"viem": "^2.44.4",
|
|
59
|
+
"vitest": "^4.0.18",
|
|
60
60
|
"zustand": "^5.0.10",
|
|
61
|
-
"@tuwaio/satellite-core": "^0.2.
|
|
61
|
+
"@tuwaio/satellite-core": "^0.2.4"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"start": "tsup src/index.ts --watch",
|