@tuwaio/satellite-evm 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,7 @@ EVM-specific implementation for the Satellite ecosystem, providing comprehensive
10
10
 
11
11
  ## 🏛️ What is `@tuwaio/satellite-evm`?
12
12
 
13
- `@tuwaio/satellite-evm` is the EVM implementation of the Satellite ecosystem's wallet connection system. It provides specialized adapters and utilities for interacting with EVM-compatible wallets and chains like MetaMask, WalletConnect, and others.
13
+ `@tuwaio/satellite-evm` is the EVM implementation of the Satellite ecosystem's wallet connection system. It provides specialized adapters and utilities for interacting with EVM-compatible wallets like MetaMask, WalletConnect, and others.
14
14
 
15
15
  Built on top of `@tuwaio/satellite-core`, this package integrates seamlessly with modern Web3 libraries like `viem` and `@wagmi/core`.
16
16
 
@@ -34,60 +34,181 @@ Built on top of `@tuwaio/satellite-core`, this package integrates seamlessly wit
34
34
 
35
35
  ```bash
36
36
  # Using pnpm (recommended)
37
- pnpm add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core @wallet-standard/ui immer zustand @wagmi/connectors @tuwaio/orbit-core @tuwaio/orbit-evm
37
+ pnpm add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @wagmi/connectors @tuwaio/orbit-core @tuwaio/orbit-evm
38
38
 
39
39
  # Using npm
40
- npm install @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core @wallet-standard/ui immer zustand @wagmi/connectors @tuwaio/orbit-core @tuwaio/orbit-evm
40
+ npm install @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @wagmi/connectors @tuwaio/orbit-core @tuwaio/orbit-evm
41
41
 
42
42
  # Using yarn
43
- yarn add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core @wallet-standard/ui immer zustand @wagmi/connectors @tuwaio/orbit-core @tuwaio/orbit-evm
44
- ```
45
- ---
43
+ yarn add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @wagmi/connectors @tuwaio/orbit-core @tuwaio/orbit-evm
44
+ ````
45
+
46
+ -----
46
47
 
47
48
  ## 🚀 Quick Start
48
49
 
49
50
  ### Basic Configuration
51
+
50
52
  ```typescript
51
- import { createWagmiConfig } from '@tuwaio/satellite-evm';
53
+ import { createDefaultTransports, initAllConnectors } from '@tuwaio/satellite-evm';
54
+ import { createConfig, http } from '@wagmi/core';
52
55
  import { mainnet, sepolia } from 'viem/chains';
53
-
54
- const config = createWagmiConfig({
55
- appName: 'Your App Name',
56
- projectId: 'your-wallet-project-id',
57
- chains: [mainnet, sepolia],
56
+ import type { Chain } from 'viem/chains';
57
+
58
+ export const appConfig = {
59
+ appName: 'Satellite EVM Test App',
60
+ // Ensure you have WalletConnect Project ID in your environment variables
61
+ projectId: process.env.NEXT_PUBLIC_WALLET_PROJECT_ID ?? 'YOUR_OWN_PROJECT_ID',
62
+ };
63
+
64
+ export const appEVMChains = [
65
+ mainnet,
66
+ sepolia,
67
+ ] as readonly [Chain, ...Chain[]];
68
+
69
+ export const wagmiConfig = createConfig({
70
+ connectors: initAllConnectors({
71
+ ...appConfig,
72
+ // Optional: Add app details for WalletConnect modal
73
+ description: 'My awesome dApp',
74
+ appUrl: '[https://my-dapp.com](https://my-dapp.com)',
75
+ appIcons: ['[https://my-dapp.com/icon.png](https://my-dapp.com/icon.png)'],
76
+ }),
77
+ transports: createDefaultTransports(appEVMChains), // Automatically creates http transports
78
+ chains: appEVMChains,
79
+ ssr: true, // Enable SSR support if needed (e.g., in Next.js)
58
80
  });
59
81
  ```
60
- ---
61
82
 
62
- ### Core Components
83
+ -----
63
84
 
64
- 1. **Adapters**
65
- - Wallet-specific implementations
66
- - Chain management utilities
67
- - Connection state handlers
85
+ ## 🔌 Using the EVM Adapter
68
86
 
69
- 2. **Connectors**
70
- - Chain configuration
71
- - Network management
72
- - Provider utilities
87
+ The core of this package is the `satelliteEVMAdapter`. It bridges the Satellite Connect system with the underlying `wagmi` configuration and functionalities.
73
88
 
74
- 3. **Utils**
75
- - Create wagmi config helper with connectors
89
+ ### Creating the Adapter
76
90
 
77
- ---
91
+ You create the adapter by passing your `wagmiConfig` to the `satelliteEVMAdapter` function.
92
+
93
+ ```typescript
94
+ import { satelliteEVMAdapter } from '@tuwaio/satellite-evm';
95
+ import { wagmiConfig } from './your-wagmi-config'; // Import your configured wagmiConfig
96
+
97
+ const evmAdapter = satelliteEVMAdapter(wagmiConfig);
98
+ ```
99
+
100
+ ### Integrating with Satellite Connect Provider
101
+
102
+ Use the created adapter within the `SatelliteConnectProvider` from `@tuwaio/satellite-react`.
103
+
104
+ ```tsx
105
+ import { SatelliteConnectProvider, EVMWalletsWatcher } from '@tuwaio/satellite-react';
106
+ import { WagmiProvider } from 'wagmi';
107
+ import { satelliteEVMAdapter } from '@tuwaio/satellite-evm';
108
+ import { wagmiConfig } from './your-wagmi-config';
109
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; // Wagmi requires react-query
110
+
111
+ const queryClient = new QueryClient();
112
+
113
+ function AppProviders({ children }: { children: React.ReactNode }) {
114
+ const evmAdapter = satelliteEVMAdapter(wagmiConfig);
115
+
116
+ return (
117
+ <WagmiProvider config={wagmiConfig}>
118
+ <QueryClientProvider client={queryClient}>
119
+ <SatelliteConnectProvider
120
+ adapter={evmAdapter} // Pass the EVM adapter
121
+ autoConnect={true} // Optional: enable auto-connect
122
+ >
123
+ <EVMWalletsWatcher wagmiConfig={wagmiConfig} /> {/* Manages EVM wallet state */}
124
+ {children}
125
+ </SatelliteConnectProvider>
126
+ </QueryClientProvider>
127
+ </WagmiProvider>
128
+ );
129
+ }
130
+ ```
131
+
132
+ -----
133
+
134
+ ## 🔐 Sign-In with Ethereum (SIWE) Integration
135
+
136
+ The `satelliteEVMAdapter` seamlessly integrates with SIWE solutions like `@tuwaio/satellite-siwe-next-auth`. You can pass the `signInWithSiwe` function (obtained from the SIWE provider/hook) as the second argument to the adapter.
137
+
138
+ This ensures that the SIWE flow is automatically triggered after a successful wallet connection.
139
+
140
+ ```tsx
141
+ // Example within a React component using @tuwaio/satellite-siwe-next-auth
142
+
143
+ import { useSiweAuth, SiweNextAuthProvider } from '@tuwaio/satellite-siwe-next-auth';
144
+ import { SatelliteConnectProvider } from '@tuwaio/satellite-react';
145
+ import { EVMWalletsWatcher } from '@tuwaio/satellite-react/evm';
146
+ import { satelliteEVMAdapter } from '@tuwaio/satellite-evm';
147
+ import { WagmiProvider } from 'wagmi';
148
+ import { wagmiConfig } from './your-wagmi-config'; // Your Wagmi config
149
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
150
+
151
+ const queryClient = new QueryClient();
152
+
153
+ function App() {
154
+ // Assuming SiweNextAuthProvider is wrapping this component higher up
155
+ const { signInWithSiwe, enabled: siweEnabled, isRejected, isSignedIn } = useSiweAuth();
156
+
157
+ // Create the adapter, passing signInWithSiwe if SIWE is enabled
158
+ const evmAdapter = satelliteEVMAdapter(wagmiConfig, siweEnabled ? signInWithSiwe : undefined);
159
+
160
+ return (
161
+ <SatelliteConnectProvider
162
+ adapter={evmAdapter}
163
+ autoConnect={true}
164
+ >
165
+ {/* Pass siwe state to watcher for handling disconnections on SIWE rejection */}
166
+ <EVMWalletsWatcher wagmiConfig={wagmiConfig} siwe={{ isSignedIn, isRejected, enabled: siweEnabled }} />
167
+ {/* Your application components */}
168
+ </SatelliteConnectProvider>
169
+ );
170
+ }
171
+
172
+
173
+ // Wrap your main application layout with necessary providers
174
+ function RootLayout({ children }: { children: React.ReactNode }) {
175
+ return (
176
+ <WagmiProvider config={wagmiConfig}>
177
+ <QueryClientProvider client={queryClient}>
178
+ {/* SIWE Provider wraps SatelliteConnectProvider */}
179
+ <SiweNextAuthProvider wagmiConfig={wagmiConfig} enabled={true}>
180
+ {children} {/* App component will be rendered here */}
181
+ </SiweNextAuthProvider>
182
+ </QueryClientProvider>
183
+ </WagmiProvider>
184
+ );
185
+ }
186
+ ```
187
+
188
+ -----
189
+
190
+ ## 🛠️ Core Utilities
191
+
192
+ - **`initAllConnectors`**: Initializes default EVM connectors (`injected`, `coinbaseWallet`, `safe`, `walletConnect` if `projectId` is provided, and a development `impersonated` connector).
193
+ - **`createDefaultTransports`**: Helper to create default `http` transports for each chain in your `wagmiConfig`.
194
+ - **`checkIsWalletAddressContract`**: Utility to check if a connected address is a smart contract address. The result is cached in memory.
195
+
196
+ -----
78
197
 
79
198
  ## 🌐 Supported Wallets
80
199
 
81
200
  - MetaMask
82
201
  - WalletConnect v2
83
202
  - Coinbase Wallet
84
- - And other EVM-compatible wallets
203
+ - Safe (Gnosis Safe)
204
+ - And other EVM-compatible wallets injected into the browser
85
205
 
86
- ---
206
+ -----
87
207
 
88
208
  ## 🔗 Chain Support
89
209
 
90
- Built-in support for major EVM networks:
210
+ Supports any EVM chain configured in your `wagmiConfig`. Examples:
211
+
91
212
  - Ethereum Mainnet
92
213
  - Sepolia Testnet
93
214
  - Polygon
@@ -108,7 +229,3 @@ If you find this library useful, please consider supporting its development. Eve
108
229
  ## 📄 License
109
230
 
110
231
  This project is licensed under the **Apache-2.0 License** - see the [LICENSE](./LICENSE) file for details.
111
-
112
- ## 👥 Contributors
113
-
114
- - **Oleksandr Tkach** - [GitHub](https://github.com/Argeare5)
package/dist/index.d.mts CHANGED
@@ -56,6 +56,7 @@ declare const safeSdkOptions: {
56
56
  *
57
57
  * @remarks
58
58
  * Creates instances of various wallet connectors including:
59
+ * - Injected wallets (e.g., MetaMask, Phantom, Trust Wallet, etc.)
59
60
  * - Coinbase Wallet
60
61
  * - Gnosis Safe
61
62
  * - WalletConnect (if projectId provided)
package/dist/index.d.ts CHANGED
@@ -56,6 +56,7 @@ declare const safeSdkOptions: {
56
56
  *
57
57
  * @remarks
58
58
  * Creates instances of various wallet connectors including:
59
+ * - Injected wallets (e.g., MetaMask, Phantom, Trust Wallet, etc.)
59
60
  * - Coinbase Wallet
60
61
  * - Gnosis Safe
61
62
  * - WalletConnect (if projectId provided)
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var orbitCore=require('@tuwaio/orbit-core'),orbitEvm=require('@tuwaio/orbit-evm'),core=require('@wagmi/core'),viem=require('viem'),chains=require('viem/chains'),connectors=require('@wagmi/connectors'),utils=require('viem/utils');var f=new Map;async function y({config:t,address:n,chainId:r,chains:o}){if(f.has(n))return f.get(n);if(orbitEvm.createViemClient(r,o)){let e=!!await core.getBytecode(t,{address:n});return f.set(n,e),e}else return false}function le(t,n){if(!t)throw new Error("Satellite EVM adapter requires a wagmi config object.");return {key:orbitCore.OrbitAdapter.EVM,connect:async({walletType:r,chainId:o})=>{let s=core.getConnectors(t).find(e=>orbitCore.getWalletTypeFromConnectorName(orbitCore.OrbitAdapter.EVM,orbitCore.formatWalletName(e.name))===r);if(!s)throw new Error("Cannot find connector with this wallet type");try{await core.connect(t,{connector:s,chainId:o}),n&&!orbitCore.isSafeApp&&await n();let e=core.getAccount(t);return {walletType:r,address:e.address??viem.zeroAddress,chainId:e.chainId??chains.mainnet.id,rpcURL:e.chain?.rpcUrls.default.http[0]??chains.mainnet.rpcUrls.default.http[0],isConnected:e.isConnected,isContractAddress:!1,walletIcon:s?.icon?.trim(),connector:s}}catch(e){throw new Error(e instanceof Error?e.message:String(e))}},disconnect:async()=>{let r=core.getConnectors(t);await Promise.allSettled(r.map(async o=>{await core.disconnect(t,{connector:o});}));},getConnectors:()=>{let r=core.getConnectors(t);return {adapter:orbitCore.OrbitAdapter.EVM,connectors:r.map(o=>o)}},checkAndSwitchNetwork:async r=>await orbitEvm.checkAndSwitchChain(Number(r),t),getBalance:async(r,o)=>{let a=await core.getBalance(t,{address:r,chainId:Number(o)});return {value:viem.formatUnits(a.value,a.decimals),symbol:a.symbol}},getExplorerUrl:r=>{let{chain:o}=core.getAccount(t),a=o?.blockExplorers?.default.url;return r?`${a}/${r}`:a},getName:r=>orbitEvm.getName(r),getAvatar:r=>orbitEvm.getAvatar(r),checkIsContractWallet:async({address:r,chainId:o})=>{let a=core.getChains(t);return await y({config:t,address:r,chainId:o,chains:a})},getSafeConnectorChainId:async()=>{let o=core.getConnectors(t).find(a=>a.name==="Safe");if(o)return await o.getChainId()}}}u.type="impersonated";function u(t){let n=t.features??{},r=false,o,a;return core.createConnector(s=>({id:"impersonated",name:"Impersonated Connector",type:u.type,async setup(){o=s.chains[0].id;},async connect({chainId:e}={}){if(n.connectError)throw typeof n.connectError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to connect.")):n.connectError;let{request:c}=await this.getProvider(),d=await c({method:"eth_requestAccounts"}),m=await this.getChainId();return e&&m!==e&&(m=(await this.switchChain({chainId:e})).id),r=true,{accounts:d,chainId:m}},async disconnect(){r=false,a=void 0;},async getAccounts(){if(!r)throw new Error("Not connected connector");let{request:e}=await this.getProvider();return (await e({method:"eth_accounts"})).map(viem.getAddress)},async getChainId(){let{request:e}=await this.getProvider(),c=await e({method:"eth_chainId"});return viem.fromHex(c,"number")},async isAuthorized(){return r?!!(await this.getAccounts()).length:false},async switchChain({chainId:e}){let c=s.chains.find(m=>m.id===e);if(!c)throw new viem.SwitchChainError(new core.ChainNotConfiguredError);let{request:d}=await this.getProvider();return await d({method:"wallet_switchEthereumChain",params:[{chainId:viem.numberToHex(e)}]}),c},onAccountsChanged(e){e.length===0?this.onDisconnect():s.emitter.emit("change",{accounts:e.map(viem.getAddress)});},onChainChanged(e){let c=Number(e);s.emitter.emit("change",{chainId:c});},async onDisconnect(){s.emitter.emit("disconnect"),r=false,a=void 0;},async getProvider({chainId:e}={}){a=orbitCore.impersonatedHelpers?.getImpersonated()?[orbitCore.impersonatedHelpers.getImpersonated()||viem.zeroAddress]:void 0;let d=(s.chains.find(i=>i.id===e)??s.chains[0]).rpcUrls.default.http[0];return viem.custom({request:async({method:i,params:h})=>{if(i==="eth_chainId")return viem.numberToHex(o);if(i==="eth_requestAccounts")return a;if(i==="eth_signTypedData_v4"&&n.signTypedDataError)throw typeof n.signTypedDataError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to sign typed data.")):n.signTypedDataError;if(i==="wallet_switchEthereumChain"){if(n.switchChainError)throw typeof n.switchChainError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to switch chain.")):n.switchChainError;o=viem.fromHex(h[0].chainId,"number"),this.onChainChanged(o.toString());return}if(i==="personal_sign"){if(n.signMessageError)throw typeof n.signMessageError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to sign message.")):n.signMessageError;i="eth_sign",h=[h[1],h[0]];}let C={method:i,params:h},{error:g,result:N}=await utils.rpc.http(d,{body:C});if(g)throw new viem.RpcRequestError({body:C,error:g,url:d});return N}})({retryCount:1})}}))}var Y={allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/,/metissafe.tech$/],debug:false},be=t=>{let n=connectors.injected(),r=connectors.coinbaseWallet({appName:t.appName,appLogoUrl:t.appLogoUrl}),o=connectors.safe({...Y}),a=[n,r,o,u({})],s=t.appUrl&&t.appIcons&&t.appName&&t.description?{name:t.appName,description:t.description,url:t.appUrl,icons:t.appIcons}:void 0;if(t.projectId){let e=connectors.walletConnect({projectId:t.projectId,metadata:s});a.push(e);}return a};var xe=t=>t.reduce((n,r)=>{let o=r.id;return n[o]=viem.http(),n},{});exports.checkIsWalletAddressContract=y;exports.createDefaultTransports=xe;exports.initAllConnectors=be;exports.safeSdkOptions=Y;exports.satelliteEVMAdapter=le;//# sourceMappingURL=index.js.map
1
+ 'use strict';var orbitCore=require('@tuwaio/orbit-core'),orbitEvm=require('@tuwaio/orbit-evm'),core=require('@wagmi/core'),viem=require('viem'),chains=require('viem/chains'),connectors=require('@wagmi/connectors'),utils=require('viem/utils');var f=new Map;async function E({config:e,address:n,chainId:r,chains:o}){if(f.has(n))return f.get(n);if(orbitEvm.createViemClient(r,o)){let t=!!await core.getBytecode(e,{address:n});return f.set(n,t),t}else return false}function he(e,n){if(!e)throw new Error("Satellite EVM adapter requires a wagmi config object.");return {key:orbitCore.OrbitAdapter.EVM,connect:async({walletType:r,chainId:o})=>{let s=core.getConnectors(e).find(t=>orbitCore.getWalletTypeFromConnectorName(orbitCore.OrbitAdapter.EVM,orbitCore.formatWalletName(t.name))===r);if(!s)throw new Error("Cannot find connector with this wallet type");try{await core.connect(e,{connector:s,chainId:o}),n&&!orbitCore.isSafeApp&&await n();let t=core.getAccount(e);return {walletType:r,address:t.address??viem.zeroAddress,chainId:t.chainId??chains.mainnet.id,rpcURL:t.chain?.rpcUrls.default.http[0]??chains.mainnet.rpcUrls.default.http[0],isConnected:t.isConnected,isContractAddress:!1,walletIcon:s?.icon?.trim(),connector:s}}catch(t){throw new Error(t instanceof Error?t.message:String(t))}},disconnect:async()=>{let r=core.getAccount(e);if(r.isConnected)await core.disconnect(e,{connector:r.connector});else {let o=core.getConnectors(e);await Promise.allSettled(o.map(async a=>{await core.disconnect(e,{connector:a});}));}},getConnectors:()=>{let r=core.getConnectors(e);return {adapter:orbitCore.OrbitAdapter.EVM,connectors:r.map(o=>o)}},checkAndSwitchNetwork:async r=>await orbitEvm.checkAndSwitchChain(Number(r),e),getBalance:async(r,o)=>{let a=await core.getBalance(e,{address:r,chainId:Number(o)});return {value:viem.formatUnits(a.value,a.decimals),symbol:a.symbol}},getExplorerUrl:r=>{let{chain:o}=core.getAccount(e),a=o?.blockExplorers?.default.url;return r?`${a}/${r}`:a},getName:r=>orbitEvm.getName(r),getAvatar:r=>orbitEvm.getAvatar(r),checkIsContractWallet:async({address:r,chainId:o})=>{let a=core.getChains(e);return await E({config:e,address:r,chainId:o,chains:a})},getSafeConnectorChainId:async()=>{let o=core.getConnectors(e).find(a=>a.name==="Safe");if(o)return await o.getChainId()}}}u.type="impersonated";function u(e){let n=e.features??{},r=false,o,a;return core.createConnector(s=>({id:"impersonated",name:"Impersonated Connector",type:u.type,async setup(){o=s.chains[0].id;},async connect({chainId:t}={}){if(n.connectError)throw typeof n.connectError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to connect.")):n.connectError;let{request:c}=await this.getProvider(),d=await c({method:"eth_requestAccounts"}),m=await this.getChainId();return t&&m!==t&&(m=(await this.switchChain({chainId:t})).id),r=true,{accounts:d,chainId:m}},async disconnect(){r=false,a=void 0;},async getAccounts(){if(!r)throw new Error("Not connected connector");let{request:t}=await this.getProvider();return (await t({method:"eth_accounts"})).map(viem.getAddress)},async getChainId(){let{request:t}=await this.getProvider(),c=await t({method:"eth_chainId"});return viem.fromHex(c,"number")},async isAuthorized(){return r?!!(await this.getAccounts()).length:false},async switchChain({chainId:t}){let c=s.chains.find(m=>m.id===t);if(!c)throw new viem.SwitchChainError(new core.ChainNotConfiguredError);let{request:d}=await this.getProvider();return await d({method:"wallet_switchEthereumChain",params:[{chainId:viem.numberToHex(t)}]}),c},onAccountsChanged(t){t.length===0?this.onDisconnect():s.emitter.emit("change",{accounts:t.map(viem.getAddress)});},onChainChanged(t){let c=Number(t);s.emitter.emit("change",{chainId:c});},async onDisconnect(){s.emitter.emit("disconnect"),r=false,a=void 0;},async getProvider({chainId:t}={}){a=orbitCore.impersonatedHelpers?.getImpersonated()?[orbitCore.impersonatedHelpers.getImpersonated()||viem.zeroAddress]:void 0;let d=(s.chains.find(i=>i.id===t)??s.chains[0]).rpcUrls.default.http[0];return viem.custom({request:async({method:i,params:l})=>{if(i==="eth_chainId")return viem.numberToHex(o);if(i==="eth_requestAccounts")return a;if(i==="eth_signTypedData_v4"&&n.signTypedDataError)throw typeof n.signTypedDataError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to sign typed data.")):n.signTypedDataError;if(i==="wallet_switchEthereumChain"){if(n.switchChainError)throw typeof n.switchChainError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to switch chain.")):n.switchChainError;o=viem.fromHex(l[0].chainId,"number"),this.onChainChanged(o.toString());return}if(i==="personal_sign"){if(n.signMessageError)throw typeof n.signMessageError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to sign message.")):n.signMessageError;i="eth_sign",l=[l[1],l[0]];}let g={method:i,params:l},{error:y,result:S}=await utils.rpc.http(d,{body:g});if(y)throw new viem.RpcRequestError({body:g,error:y,url:d});return S}})({retryCount:1})}}))}var Y={allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/,/metissafe.tech$/],debug:false},be=e=>{let n=connectors.injected(),r=connectors.coinbaseWallet({appName:e.appName,appLogoUrl:e.appLogoUrl}),o=connectors.safe({...Y}),a=[n,r,o,u({})],s=e.appUrl&&e.appIcons&&e.appName&&e.description?{name:e.appName,description:e.description,url:e.appUrl,icons:e.appIcons}:void 0;if(e.projectId){let t=connectors.walletConnect({projectId:e.projectId,metadata:s});a.push(t);}return a};var xe=e=>e.reduce((n,r)=>{let o=r.id;return n[o]=viem.http(),n},{});exports.checkIsWalletAddressContract=E;exports.createDefaultTransports=xe;exports.initAllConnectors=be;exports.safeSdkOptions=Y;exports.satelliteEVMAdapter=he;//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/checkIsWalletAddressContract.ts","../src/adapters/evmAdapter.ts","../src/connectors/ImpersonatedConnector.ts","../src/connectors/index.ts","../src/utils/createDefaultTransports.ts"],"names":["walletsCache","checkIsWalletAddressContract","config","address","chainId","chains","createViemClient","isContract","getBytecode","satelliteEVMAdapter","signInWithSiwe","OrbitAdapter","walletType","connector","getConnectors","getWalletTypeFromConnectorName","formatWalletName","connect","isSafeApp","account","getAccount","zeroAddress","mainnet","connectors","disconnect","checkAndSwitchChain","balance","getBalance","formatUnits","url","chain","baseExplorerLink","getName","name","getAvatar","getChains","safeConnector","c","impersonated","parameters","features","connected","connectedChainId","accountAddress","createConnector","UserRejectedRequestError","request","accounts","currentChainId","getAddress","hexChainId","fromHex","x","SwitchChainError","ChainNotConfiguredError","numberToHex","impersonatedHelpers","custom","method","params","body","error","result","rpc","RpcRequestError","safeSdkOptions","initAllConnectors","props","injectedConnector","injected","coinbaseConnector","coinbaseWallet","gnosisSafeConnector","safe","wcMetadata","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QAAA,CAAUO,CACZ,CAAC,EAEDnD,CAAAA,CAAW,IAAA,CAAKoD,CAAsB,EACxC,CAEA,OAAOpD,CACT,EClEO,IAAMsD,EAAAA,CAA2BxE,CAAAA,EAC/BA,CAAAA,CAAO,OACZ,CAACyE,CAAAA,CAAKhD,CAAAA,GAAU,CACd,IAAMiD,CAAAA,CAAMjD,CAAAA,CAAM,EAAA,CAClB,OAAAgD,CAAAA,CAAIC,CAAG,CAAA,CAAIC,SAAAA,EAAK,CACTF,CACT,CAAA,CACA,EACF","file":"index.js","sourcesContent":["import { createViemClient } from '@tuwaio/orbit-evm';\nimport { Config, getBytecode } from '@wagmi/core';\nimport { Address } from 'viem';\nimport { Chain } from 'viem/chains';\n\n/**\n * An in-memory cache for wallets bytecode to avoid redundant requests to the blockchain.\n * Key is the wallet address, value is boolean indicating if it's a contract address.\n * @internal\n */\nconst walletsCache = new Map<string, boolean>();\n\n/**\n * Checks if a given wallet address is a smart contract by examining its bytecode\n *\n * @remarks\n * This function uses an in-memory cache to store results and avoid redundant blockchain requests.\n * The cache persists for the lifetime of the application session.\n *\n * @param config - Wagmi configuration object\n * @param address - Ethereum address to check\n * @param chainId - ID of the blockchain network\n * @param chains - Array of supported chain configurations\n *\n * @returns Promise resolving to boolean indicating if the address is a contract\n * - true: Address is a smart contract\n * - false: Address is an EOA (Externally Owned Account) or client creation failed\n *\n * @example\n * ```typescript\n * const isContract = await checkIsWalletAddressContract({\n * config: wagmiConfig,\n * address: \"0x1234...\",\n * chainId: 1,\n * chains: [mainnet, polygon]\n * });\n * ```\n *\n * @throws Will throw an error if getBytecode request fails\n */\nexport async function checkIsWalletAddressContract({\n config,\n address,\n chainId,\n chains,\n}: {\n /** Wagmi configuration for blockchain interaction */\n config: Config;\n /** Ethereum address to check */\n address: string;\n /** Chain ID where the check should be performed */\n chainId: number | string;\n /** Array of supported chain configurations */\n chains: readonly [Chain, ...Chain[]];\n}): Promise<boolean> {\n // Check cache first to avoid redundant blockchain requests\n if (walletsCache.has(address)) {\n return walletsCache.get(address)!;\n }\n\n // Create Viem client for blockchain interaction\n const client = createViemClient(chainId as number, chains);\n\n if (client) {\n // Get bytecode from the blockchain\n const codeOfWalletAddress = await getBytecode(config, {\n address: address as Address,\n });\n\n // Cache the result\n const isContract = !!codeOfWalletAddress;\n walletsCache.set(address, isContract);\n\n return isContract;\n } else {\n // Return false if client creation failed\n return false;\n }\n}\n","import { formatWalletName, getWalletTypeFromConnectorName, isSafeApp, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { checkAndSwitchChain, getAvatar, getName } from '@tuwaio/orbit-evm';\nimport { SatelliteAdapter } from '@tuwaio/satellite-core';\nimport { Config, connect, disconnect, getAccount, getBalance, getChains, getConnectors } from '@wagmi/core';\nimport { Address, formatUnits, zeroAddress } from 'viem';\nimport { mainnet } from 'viem/chains';\n\nimport { ConnectorEVM } from '../types';\nimport { checkIsWalletAddressContract } from '../utils/checkIsWalletAddressContract';\n\n/**\n * Creates an EVM-compatible adapter for Satellite\n *\n * @remarks\n * This adapter implements the SatelliteAdapter interface for Ethereum Virtual Machine (EVM) compatible chains.\n * It uses wagmi as the underlying library for wallet connections and chain interactions.\n *\n * @param config - Wagmi configuration object containing chain and connector settings\n * @param signInWithSiwe - Optional function for signing in with SIWE\n * @returns A configured SatelliteAdapter instance for EVM chains\n * @throws Error if config is not provided\n *\n * @example\n * ```typescript\n * const config = createConfig({\n * chains: [mainnet, polygon],\n * connectors: [\n * new InjectedConnector(),\n * new WalletConnectConnector({ projectId: 'your_project_id' })\n * ]\n * });\n *\n * const evmAdapter = satelliteEVMAdapter(config);\n * ```\n */\nexport function satelliteEVMAdapter(\n config: Config,\n signInWithSiwe?: () => Promise<void>,\n): SatelliteAdapter<ConnectorEVM> {\n if (!config) throw new Error('Satellite EVM adapter requires a wagmi config object.');\n\n return {\n /** Identifies this adapter as EVM-compatible */\n key: OrbitAdapter.EVM,\n\n /**\n * Connects to an EVM wallet\n * @returns Connected wallet information\n * @throws Error if connector not found or connection fails\n */\n connect: async ({ walletType, chainId }) => {\n const connectors = getConnectors(config);\n const connector = connectors.find(\n (connector) =>\n getWalletTypeFromConnectorName(OrbitAdapter.EVM, formatWalletName(connector.name)) === walletType,\n );\n if (!connector) throw new Error('Cannot find connector with this wallet type');\n\n try {\n // const isConnected = await connector.isAuthorized();\n // if (isConnected) {\n // await disconnect(config, { connector });\n // }\n await connect(config, { connector, chainId: chainId as number });\n if (signInWithSiwe && !isSafeApp) {\n await signInWithSiwe();\n }\n const account = getAccount(config);\n\n return {\n walletType,\n address: account.address ?? zeroAddress,\n chainId: account.chainId ?? mainnet.id,\n rpcURL: account.chain?.rpcUrls.default.http[0] ?? mainnet.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n isContractAddress: false,\n walletIcon: connector?.icon?.trim(),\n connector,\n };\n } catch (e) {\n throw new Error(e instanceof Error ? e.message : String(e));\n }\n },\n\n /**\n * Disconnects the currently connected wallet\n */\n disconnect: async () => {\n const connectors = getConnectors(config);\n await Promise.allSettled(\n connectors.map(async (connector) => {\n await disconnect(config, { connector });\n }),\n );\n },\n\n /**\n * Retrieves available EVM wallet connectors\n * @returns Object containing adapter type and list of available connectors\n */\n getConnectors: () => {\n const connectors = getConnectors(config);\n return {\n adapter: OrbitAdapter.EVM,\n connectors: connectors.map((connector) => {\n return connector;\n }) as ConnectorEVM[],\n };\n },\n\n /**\n * Switches the connected wallet to specified network\n * @param chainId - Target chain ID to switch to\n */\n checkAndSwitchNetwork: async (chainId) => await checkAndSwitchChain(Number(chainId), config),\n\n getBalance: async (address, chainId) => {\n const balance = await getBalance(config, { address: address as Address, chainId: Number(chainId) });\n return {\n value: formatUnits(balance.value, balance.decimals),\n symbol: balance.symbol,\n };\n },\n\n /**\n * Generates blockchain explorer URLs for the current network\n * @param url - Optional path to append to base explorer URL\n * @returns Complete explorer URL or base explorer URL if no path provided\n */\n getExplorerUrl: (url) => {\n const { chain } = getAccount(config);\n const baseExplorerLink = chain?.blockExplorers?.default.url;\n return url ? `${baseExplorerLink}/${url}` : baseExplorerLink;\n },\n\n /**\n * Resolves ENS name for given address\n * @param address - Ethereum address to resolve\n * @returns ENS name if available, null otherwise\n */\n getName: (address: string) => getName(address as `0x${string}`),\n\n /**\n * Retrieves avatar for ENS name\n * @param name - ENS name to get avatar for\n * @returns Avatar URL if available, null otherwise\n */\n getAvatar: (name: string) => getAvatar(name),\n\n /**\n * Checks if given address is a smart contract\n * @param address - Address to check\n * @param chainId - Chain ID on which to perform the check\n * @returns Promise resolving to boolean indicating if address is a contract\n */\n checkIsContractWallet: async ({ address, chainId }) => {\n const chains = getChains(config);\n return await checkIsWalletAddressContract({ config, address, chainId, chains });\n },\n\n getSafeConnectorChainId: async () => {\n const connectors = getConnectors(config);\n const safeConnector = connectors.find((c) => c.name === 'Safe');\n if (safeConnector) {\n return await safeConnector.getChainId();\n } else {\n return undefined;\n }\n },\n };\n}\n","import { impersonatedHelpers } from '@tuwaio/orbit-core';\nimport { ChainNotConfiguredError, createConnector } from '@wagmi/core';\nimport {\n type Address,\n custom,\n type EIP1193RequestFn,\n fromHex,\n getAddress,\n type Hex,\n numberToHex,\n RpcRequestError,\n SwitchChainError,\n type Transport,\n UserRejectedRequestError,\n type WalletRpcSchema,\n zeroAddress,\n} from 'viem';\nimport { rpc } from 'viem/utils';\n\n/**\n * Configuration parameters for impersonated wallet connector\n */\nexport type ImpersonatedParameters = {\n /** Optional feature flags for testing error scenarios */\n features?: {\n /** Simulate connection error */\n connectError?: boolean | Error;\n /** Simulate chain switching error */\n switchChainError?: boolean | Error;\n /** Simulate message signing error */\n signMessageError?: boolean | Error;\n /** Simulate typed data signing error */\n signTypedDataError?: boolean | Error;\n /** Enable reconnection behavior */\n reconnect?: boolean;\n };\n};\n\n/**\n * Creates a wagmi connector for impersonating Ethereum accounts\n *\n * @remarks\n * This connector allows testing wallet interactions without an actual wallet by impersonating\n * an Ethereum address. It implements the EIP-1193 provider interface and can simulate\n * various error scenarios for testing purposes.\n *\n * @param parameters - Configuration options for the impersonated connector\n * @returns A wagmi connector instance\n *\n * @example\n * ```typescript\n * const connector = impersonated({\n * getAccountAddress: () => \"0x1234...\",\n * features: {\n * // Simulate errors for testing\n * connectError: false,\n * signMessageError: false\n * }\n * });\n * ```\n */\nimpersonated.type = 'impersonated' as const;\nexport function impersonated(parameters: ImpersonatedParameters) {\n const features = parameters.features ?? {};\n\n type Provider = ReturnType<Transport<'custom', NonNullable<unknown>, EIP1193RequestFn<WalletRpcSchema>>>;\n let connected = false;\n let connectedChainId: number;\n let accountAddress: Hex[] | undefined = undefined;\n\n return createConnector<Provider>((config) => ({\n id: 'impersonated',\n name: 'Impersonated Connector',\n type: impersonated.type,\n\n /**\n * Initial setup - sets default chain ID\n */\n async setup() {\n connectedChainId = config.chains[0].id;\n },\n /**\n * Simulates wallet connection\n * @throws {UserRejectedRequestError} When connection is rejected\n */\n // @ts-expect-error - not typed correctly\n async connect({ chainId } = {}) {\n if (features.connectError) {\n if (typeof features.connectError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to connect.'));\n throw features.connectError;\n }\n\n const { request } = await this.getProvider();\n const accounts = await request({\n method: 'eth_requestAccounts',\n });\n\n let currentChainId = await this.getChainId();\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId });\n currentChainId = chain.id;\n }\n\n connected = true;\n return { accounts, chainId: currentChainId };\n },\n\n /**\n * Simulates wallet disconnection\n */\n async disconnect() {\n connected = false;\n accountAddress = undefined;\n },\n\n /**\n * Returns impersonated accounts\n * @throws {Error} When not connected\n */\n async getAccounts() {\n if (!connected) throw new Error('Not connected connector');\n const { request } = await this.getProvider();\n const accounts = await request({ method: 'eth_accounts' });\n return accounts.map(getAddress);\n },\n\n /**\n * Returns current chain ID\n */\n async getChainId() {\n const { request } = await this.getProvider();\n const hexChainId = await request({ method: 'eth_chainId' });\n return fromHex(hexChainId, 'number');\n },\n\n /**\n * Checks if wallet is connected and authorized\n */\n async isAuthorized() {\n if (!connected) return false;\n const accounts = await this.getAccounts();\n return !!accounts.length;\n },\n\n /**\n * Simulates switching to a different chain\n * @throws {SwitchChainError} When chain is not configured\n * @throws {UserRejectedRequestError} When switch is rejected\n */\n async switchChain({ chainId }) {\n const chain = config.chains.find((x) => x.id === chainId);\n if (!chain) throw new SwitchChainError(new ChainNotConfiguredError());\n // @ts-expect-error - request is not typed correctly\n const { request } = await this.getProvider();\n await request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: numberToHex(chainId) }],\n });\n return chain;\n },\n\n /**\n * Handles account changes\n */\n onAccountsChanged(accounts) {\n if (accounts.length === 0) this.onDisconnect();\n else config.emitter.emit('change', { accounts: accounts.map(getAddress) });\n },\n\n /**\n * Handles chain changes\n */\n onChainChanged(chain) {\n const chainId = Number(chain);\n config.emitter.emit('change', { chainId });\n },\n\n /**\n * Handles disconnection\n */\n async onDisconnect() {\n config.emitter.emit('disconnect');\n connected = false;\n accountAddress = undefined;\n },\n\n /**\n * Creates an EIP-1193 compatible provider\n * @returns Custom provider instance\n */\n async getProvider({ chainId }: { chainId?: number } = {}) {\n accountAddress = impersonatedHelpers?.getImpersonated()\n ? [(impersonatedHelpers.getImpersonated() as Address) || zeroAddress]\n : undefined;\n const chain = config.chains.find((x) => x.id === chainId) ?? config.chains[0];\n const url = chain.rpcUrls.default.http[0]!;\n\n const request: EIP1193RequestFn = async ({ method, params }) => {\n // eth methods\n if (method === 'eth_chainId') return numberToHex(connectedChainId);\n if (method === 'eth_requestAccounts') return accountAddress;\n if (method === 'eth_signTypedData_v4')\n if (features.signTypedDataError) {\n if (typeof features.signTypedDataError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to sign typed data.'));\n throw features.signTypedDataError;\n }\n\n // wallet methods\n if (method === 'wallet_switchEthereumChain') {\n if (features.switchChainError) {\n if (typeof features.switchChainError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to switch chain.'));\n throw features.switchChainError;\n }\n type Params = [{ chainId: Hex }];\n connectedChainId = fromHex((params as Params)[0].chainId, 'number');\n this.onChainChanged(connectedChainId.toString());\n return;\n }\n\n // other methods\n if (method === 'personal_sign') {\n if (features.signMessageError) {\n if (typeof features.signMessageError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to sign message.'));\n throw features.signMessageError;\n }\n // Change `personal_sign` to `eth_sign` and swap params\n method = 'eth_sign';\n type Params = [data: Hex, address: Address];\n params = [(params as Params)[1], (params as Params)[0]];\n }\n\n const body = { method, params };\n const { error, result } = await rpc.http(url, { body });\n if (error) throw new RpcRequestError({ body, error, url });\n\n return result;\n };\n return custom({ request })({ retryCount: 1 });\n },\n }));\n}\n","import { ConnectorsInitProps } from '@tuwaio/satellite-core';\nimport { coinbaseWallet, injected, safe, walletConnect } from '@wagmi/connectors';\nimport { CreateConnectorFn } from '@wagmi/core';\n\nimport { impersonated } from './ImpersonatedConnector';\n\n/**\n * Configuration options for Gnosis Safe SDK\n * @remarks\n * Defines allowed domains and debug mode for Safe integration\n */\nexport const safeSdkOptions = {\n /** Regular expressions for allowed Safe wallet domains */\n allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/, /metissafe.tech$/],\n /** Enable debug mode */\n debug: false,\n};\n\n/**\n * Initializes all supported wallet connectors based on provided configuration\n *\n * @remarks\n * Creates instances of various wallet connectors including:\n * - Coinbase Wallet\n * - Gnosis Safe\n * - WalletConnect (if projectId provided)\n * - Impersonated wallet (for development/testing)\n *\n * The order of connectors in the returned array determines their priority\n * in the wallet connection UI.\n *\n * @param props - Configuration options for initializing connectors\n * @returns Array of wallet connector instances\n *\n * @example\n * ```typescript\n * const connectors = initAllConnectors({\n * appName: \"My dApp\",\n * projectId: \"wallet_connect_project_id\",\n * appUrl: \"https://mydapp.com\",\n * appLogoUrl: \"https://mydapp.com/logo.png\"\n * });\n * ```\n */\nexport const initAllConnectors = (props: ConnectorsInitProps): readonly CreateConnectorFn[] => {\n const injectedConnector = injected();\n const coinbaseConnector = coinbaseWallet({\n appName: props.appName,\n appLogoUrl: props.appLogoUrl,\n });\n const gnosisSafeConnector = safe({\n ...safeSdkOptions,\n });\n\n const connectors = [injectedConnector, coinbaseConnector, gnosisSafeConnector, impersonated({})];\n\n // WalletConnect metadata configuration\n const wcMetadata =\n props.appUrl && props.appIcons && props.appName && props.description\n ? {\n name: props.appName,\n description: props.description,\n url: props.appUrl,\n icons: props.appIcons,\n }\n : undefined;\n\n if (props.projectId) {\n const walletConnectConnector = walletConnect({\n projectId: props.projectId,\n metadata: wcMetadata,\n });\n // @ts-expect-error - connector has some different types\n connectors.push(walletConnectConnector);\n }\n\n return connectors;\n};\n","import { CreateConfigParameters } from '@wagmi/core';\nimport { http, Transport } from 'viem';\n\n/**\n * Creates default HTTP transports for each chain in the configuration\n *\n * @param chains - Array of chain configurations from wagmi\n * @returns Object mapping chain IDs to their corresponding HTTP transport instances\n *\n * @public\n */\nexport const createDefaultTransports = (chains: CreateConfigParameters['chains']): Record<number, Transport> => {\n return chains.reduce(\n (acc, chain) => {\n const key = chain.id;\n acc[key] = http() as Transport;\n return acc;\n },\n {} as Record<number, Transport>,\n );\n};\n"]}
1
+ {"version":3,"sources":["../src/utils/checkIsWalletAddressContract.ts","../src/adapters/evmAdapter.ts","../src/connectors/ImpersonatedConnector.ts","../src/connectors/index.ts","../src/utils/createDefaultTransports.ts"],"names":["walletsCache","checkIsWalletAddressContract","config","address","chainId","chains","createViemClient","isContract","getBytecode","satelliteEVMAdapter","signInWithSiwe","OrbitAdapter","walletType","connector","getConnectors","getWalletTypeFromConnectorName","formatWalletName","connect","isSafeApp","account","getAccount","zeroAddress","mainnet","e","activeWallet","disconnect","connectors","checkAndSwitchChain","balance","getBalance","formatUnits","url","chain","baseExplorerLink","getName","name","getAvatar","getChains","safeConnector","c","impersonated","parameters","features","connected","connectedChainId","accountAddress","createConnector","UserRejectedRequestError","request","accounts","currentChainId","getAddress","hexChainId","fromHex","x","SwitchChainError","ChainNotConfiguredError","numberToHex","impersonatedHelpers","custom","method","params","body","error","result","rpc","RpcRequestError","safeSdkOptions","initAllConnectors","props","injectedConnector","injected","coinbaseConnector","coinbaseWallet","gnosisSafeConnector","safe","wcMetadata","walletConnectConnector","walletConnect","createDefaultTransports","acc","key","http"],"mappings":"kPAUA,IAAMA,CAAAA,CAAe,IAAI,GAAA,CA8BzB,eAAsBC,CAAAA,CAA6B,CACjD,MAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,CACF,CAAA,CASqB,CAEnB,GAAIL,CAAAA,CAAa,GAAA,CAAIG,CAAO,CAAA,CAC1B,OAAOH,CAAAA,CAAa,GAAA,CAAIG,CAAO,CAAA,CAMjC,GAFeG,yBAAAA,CAAiBF,CAAAA,CAAmBC,CAAM,EAE7C,CAOV,IAAME,CAAAA,CAAa,CAAC,CALQ,MAAMC,gBAAAA,CAAYN,CAAAA,CAAQ,CACpD,OAAA,CAASC,CACX,CAAC,CAAA,CAID,OAAAH,CAAAA,CAAa,GAAA,CAAIG,EAASI,CAAU,CAAA,CAE7BA,CACT,CAAA,KAEE,OAAO,MAEX,CC3CO,SAASE,EAAAA,CACdP,CAAAA,CACAQ,CAAAA,CACgC,CAChC,GAAI,CAACR,CAAAA,CAAQ,MAAM,IAAI,KAAA,CAAM,uDAAuD,CAAA,CAEpF,OAAO,CAEL,GAAA,CAAKS,sBAAAA,CAAa,GAAA,CAOlB,QAAS,MAAO,CAAE,UAAA,CAAAC,CAAAA,CAAY,OAAA,CAAAR,CAAQ,CAAA,GAAM,CAE1C,IAAMS,CAAAA,CADaC,kBAAAA,CAAcZ,CAAM,CAAA,CACV,IAAA,CAC1BW,CAAAA,EACCE,wCAAAA,CAA+BJ,sBAAAA,CAAa,GAAA,CAAKK,0BAAAA,CAAiBH,CAAAA,CAAU,IAAI,CAAC,CAAA,GAAMD,CAC3F,CAAA,CACA,GAAI,CAACC,CAAAA,CAAW,MAAM,IAAI,KAAA,CAAM,6CAA6C,CAAA,CAE7E,GAAI,CAKF,MAA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AM,WAAA,CACnB,GAAA,CAAKA,CAAAA,CAAM,MAAA,CACX,KAAA,CAAOA,EAAM,QACf,CAAA,CACA,MAAA,CAEN,GAAIA,CAAAA,CAAM,SAAA,CAAW,CACnB,IAAMQ,CAAAA,CAAyBC,wBAAAA,CAAc,CAC3C,SAAA,CAAWT,CAAAA,CAAM,SAAA,CACjB,QAAA,CAAUO,CACZ,CAAC,CAAA,CAEDlD,CAAAA,CAAW,IAAA,CAAKmD,CAAsB,EACxC,CAEA,OAAOnD,CACT,ECnEO,IAAMqD,EAAAA,CAA2B1E,CAAAA,EAC/BA,EAAO,MAAA,CACZ,CAAC2E,CAAAA,CAAKhD,CAAAA,GAAU,CACd,IAAMiD,CAAAA,CAAMjD,CAAAA,CAAM,GAClB,OAAAgD,CAAAA,CAAIC,CAAG,CAAA,CAAIC,SAAAA,EAAK,CACTF,CACT,CAAA,CACA,EACF","file":"index.js","sourcesContent":["import { createViemClient } from '@tuwaio/orbit-evm';\nimport { Config, getBytecode } from '@wagmi/core';\nimport { Address } from 'viem';\nimport { Chain } from 'viem/chains';\n\n/**\n * An in-memory cache for wallets bytecode to avoid redundant requests to the blockchain.\n * Key is the wallet address, value is boolean indicating if it's a contract address.\n * @internal\n */\nconst walletsCache = new Map<string, boolean>();\n\n/**\n * Checks if a given wallet address is a smart contract by examining its bytecode\n *\n * @remarks\n * This function uses an in-memory cache to store results and avoid redundant blockchain requests.\n * The cache persists for the lifetime of the application session.\n *\n * @param config - Wagmi configuration object\n * @param address - Ethereum address to check\n * @param chainId - ID of the blockchain network\n * @param chains - Array of supported chain configurations\n *\n * @returns Promise resolving to boolean indicating if the address is a contract\n * - true: Address is a smart contract\n * - false: Address is an EOA (Externally Owned Account) or client creation failed\n *\n * @example\n * ```typescript\n * const isContract = await checkIsWalletAddressContract({\n * config: wagmiConfig,\n * address: \"0x1234...\",\n * chainId: 1,\n * chains: [mainnet, polygon]\n * });\n * ```\n *\n * @throws Will throw an error if getBytecode request fails\n */\nexport async function checkIsWalletAddressContract({\n config,\n address,\n chainId,\n chains,\n}: {\n /** Wagmi configuration for blockchain interaction */\n config: Config;\n /** Ethereum address to check */\n address: string;\n /** Chain ID where the check should be performed */\n chainId: number | string;\n /** Array of supported chain configurations */\n chains: readonly [Chain, ...Chain[]];\n}): Promise<boolean> {\n // Check cache first to avoid redundant blockchain requests\n if (walletsCache.has(address)) {\n return walletsCache.get(address)!;\n }\n\n // Create Viem client for blockchain interaction\n const client = createViemClient(chainId as number, chains);\n\n if (client) {\n // Get bytecode from the blockchain\n const codeOfWalletAddress = await getBytecode(config, {\n address: address as Address,\n });\n\n // Cache the result\n const isContract = !!codeOfWalletAddress;\n walletsCache.set(address, isContract);\n\n return isContract;\n } else {\n // Return false if client creation failed\n return false;\n }\n}\n","import { formatWalletName, getWalletTypeFromConnectorName, isSafeApp, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { checkAndSwitchChain, getAvatar, getName } from '@tuwaio/orbit-evm';\nimport { SatelliteAdapter } from '@tuwaio/satellite-core';\nimport { Config, connect, disconnect, getAccount, getBalance, getChains, getConnectors } from '@wagmi/core';\nimport { Address, formatUnits, zeroAddress } from 'viem';\nimport { mainnet } from 'viem/chains';\n\nimport { ConnectorEVM } from '../types';\nimport { checkIsWalletAddressContract } from '../utils/checkIsWalletAddressContract';\n\n/**\n * Creates an EVM-compatible adapter for Satellite\n *\n * @remarks\n * This adapter implements the SatelliteAdapter interface for Ethereum Virtual Machine (EVM) compatible chains.\n * It uses wagmi as the underlying library for wallet connections and chain interactions.\n *\n * @param config - Wagmi configuration object containing chain and connector settings\n * @param signInWithSiwe - Optional function for signing in with SIWE\n * @returns A configured SatelliteAdapter instance for EVM chains\n * @throws Error if config is not provided\n *\n * @example\n * ```typescript\n * const config = createConfig({\n * chains: [mainnet, polygon],\n * connectors: [\n * new InjectedConnector(),\n * new WalletConnectConnector({ projectId: 'your_project_id' })\n * ]\n * });\n *\n * const evmAdapter = satelliteEVMAdapter(config);\n * ```\n */\nexport function satelliteEVMAdapter(\n config: Config,\n signInWithSiwe?: () => Promise<void>,\n): SatelliteAdapter<ConnectorEVM> {\n if (!config) throw new Error('Satellite EVM adapter requires a wagmi config object.');\n\n return {\n /** Identifies this adapter as EVM-compatible */\n key: OrbitAdapter.EVM,\n\n /**\n * Connects to an EVM wallet\n * @returns Connected wallet information\n * @throws Error if connector not found or connection fails\n */\n connect: async ({ walletType, chainId }) => {\n const connectors = getConnectors(config);\n const connector = connectors.find(\n (connector) =>\n getWalletTypeFromConnectorName(OrbitAdapter.EVM, formatWalletName(connector.name)) === walletType,\n );\n if (!connector) throw new Error('Cannot find connector with this wallet type');\n\n try {\n // const isConnected = await connector.isAuthorized();\n // if (isConnected) {\n // await disconnect(config, { connector });\n // }\n await connect(config, { connector, chainId: chainId as number });\n if (signInWithSiwe && !isSafeApp) {\n await signInWithSiwe();\n }\n const account = getAccount(config);\n\n return {\n walletType,\n address: account.address ?? zeroAddress,\n chainId: account.chainId ?? mainnet.id,\n rpcURL: account.chain?.rpcUrls.default.http[0] ?? mainnet.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n isContractAddress: false,\n walletIcon: connector?.icon?.trim(),\n connector,\n };\n } catch (e) {\n throw new Error(e instanceof Error ? e.message : String(e));\n }\n },\n\n /**\n * Disconnects the currently connected wallet\n */\n disconnect: async () => {\n const activeWallet = getAccount(config);\n if (activeWallet.isConnected) {\n await disconnect(config, { connector: activeWallet.connector });\n } else {\n const connectors = getConnectors(config);\n await Promise.allSettled(\n connectors.map(async (connector) => {\n await disconnect(config, { connector });\n }),\n );\n }\n },\n\n /**\n * Retrieves available EVM wallet connectors\n * @returns Object containing adapter type and list of available connectors\n */\n getConnectors: () => {\n const connectors = getConnectors(config);\n return {\n adapter: OrbitAdapter.EVM,\n connectors: connectors.map((connector) => {\n return connector;\n }) as ConnectorEVM[],\n };\n },\n\n /**\n * Switches the connected wallet to specified network\n * @param chainId - Target chain ID to switch to\n */\n checkAndSwitchNetwork: async (chainId) => await checkAndSwitchChain(Number(chainId), config),\n\n getBalance: async (address, chainId) => {\n const balance = await getBalance(config, { address: address as Address, chainId: Number(chainId) });\n return {\n value: formatUnits(balance.value, balance.decimals),\n symbol: balance.symbol,\n };\n },\n\n /**\n * Generates blockchain explorer URLs for the current network\n * @param url - Optional path to append to base explorer URL\n * @returns Complete explorer URL or base explorer URL if no path provided\n */\n getExplorerUrl: (url) => {\n const { chain } = getAccount(config);\n const baseExplorerLink = chain?.blockExplorers?.default.url;\n return url ? `${baseExplorerLink}/${url}` : baseExplorerLink;\n },\n\n /**\n * Resolves ENS name for given address\n * @param address - Ethereum address to resolve\n * @returns ENS name if available, null otherwise\n */\n getName: (address: string) => getName(address as `0x${string}`),\n\n /**\n * Retrieves avatar for ENS name\n * @param name - ENS name to get avatar for\n * @returns Avatar URL if available, null otherwise\n */\n getAvatar: (name: string) => getAvatar(name),\n\n /**\n * Checks if given address is a smart contract\n * @param address - Address to check\n * @param chainId - Chain ID on which to perform the check\n * @returns Promise resolving to boolean indicating if address is a contract\n */\n checkIsContractWallet: async ({ address, chainId }) => {\n const chains = getChains(config);\n return await checkIsWalletAddressContract({ config, address, chainId, chains });\n },\n\n getSafeConnectorChainId: async () => {\n const connectors = getConnectors(config);\n const safeConnector = connectors.find((c) => c.name === 'Safe');\n if (safeConnector) {\n return await safeConnector.getChainId();\n } else {\n return undefined;\n }\n },\n };\n}\n","import { impersonatedHelpers } from '@tuwaio/orbit-core';\nimport { ChainNotConfiguredError, createConnector } from '@wagmi/core';\nimport {\n type Address,\n custom,\n type EIP1193RequestFn,\n fromHex,\n getAddress,\n type Hex,\n numberToHex,\n RpcRequestError,\n SwitchChainError,\n type Transport,\n UserRejectedRequestError,\n type WalletRpcSchema,\n zeroAddress,\n} from 'viem';\nimport { rpc } from 'viem/utils';\n\n/**\n * Configuration parameters for impersonated wallet connector\n */\nexport type ImpersonatedParameters = {\n /** Optional feature flags for testing error scenarios */\n features?: {\n /** Simulate connection error */\n connectError?: boolean | Error;\n /** Simulate chain switching error */\n switchChainError?: boolean | Error;\n /** Simulate message signing error */\n signMessageError?: boolean | Error;\n /** Simulate typed data signing error */\n signTypedDataError?: boolean | Error;\n /** Enable reconnection behavior */\n reconnect?: boolean;\n };\n};\n\n/**\n * Creates a wagmi connector for impersonating Ethereum accounts\n *\n * @remarks\n * This connector allows testing wallet interactions without an actual wallet by impersonating\n * an Ethereum address. It implements the EIP-1193 provider interface and can simulate\n * various error scenarios for testing purposes.\n *\n * @param parameters - Configuration options for the impersonated connector\n * @returns A wagmi connector instance\n *\n * @example\n * ```typescript\n * const connector = impersonated({\n * getAccountAddress: () => \"0x1234...\",\n * features: {\n * // Simulate errors for testing\n * connectError: false,\n * signMessageError: false\n * }\n * });\n * ```\n */\nimpersonated.type = 'impersonated' as const;\nexport function impersonated(parameters: ImpersonatedParameters) {\n const features = parameters.features ?? {};\n\n type Provider = ReturnType<Transport<'custom', NonNullable<unknown>, EIP1193RequestFn<WalletRpcSchema>>>;\n let connected = false;\n let connectedChainId: number;\n let accountAddress: Hex[] | undefined = undefined;\n\n return createConnector<Provider>((config) => ({\n id: 'impersonated',\n name: 'Impersonated Connector',\n type: impersonated.type,\n\n /**\n * Initial setup - sets default chain ID\n */\n async setup() {\n connectedChainId = config.chains[0].id;\n },\n /**\n * Simulates wallet connection\n * @throws {UserRejectedRequestError} When connection is rejected\n */\n // @ts-expect-error - not typed correctly\n async connect({ chainId } = {}) {\n if (features.connectError) {\n if (typeof features.connectError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to connect.'));\n throw features.connectError;\n }\n\n const { request } = await this.getProvider();\n const accounts = await request({\n method: 'eth_requestAccounts',\n });\n\n let currentChainId = await this.getChainId();\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId });\n currentChainId = chain.id;\n }\n\n connected = true;\n return { accounts, chainId: currentChainId };\n },\n\n /**\n * Simulates wallet disconnection\n */\n async disconnect() {\n connected = false;\n accountAddress = undefined;\n },\n\n /**\n * Returns impersonated accounts\n * @throws {Error} When not connected\n */\n async getAccounts() {\n if (!connected) throw new Error('Not connected connector');\n const { request } = await this.getProvider();\n const accounts = await request({ method: 'eth_accounts' });\n return accounts.map(getAddress);\n },\n\n /**\n * Returns current chain ID\n */\n async getChainId() {\n const { request } = await this.getProvider();\n const hexChainId = await request({ method: 'eth_chainId' });\n return fromHex(hexChainId, 'number');\n },\n\n /**\n * Checks if wallet is connected and authorized\n */\n async isAuthorized() {\n if (!connected) return false;\n const accounts = await this.getAccounts();\n return !!accounts.length;\n },\n\n /**\n * Simulates switching to a different chain\n * @throws {SwitchChainError} When chain is not configured\n * @throws {UserRejectedRequestError} When switch is rejected\n */\n async switchChain({ chainId }) {\n const chain = config.chains.find((x) => x.id === chainId);\n if (!chain) throw new SwitchChainError(new ChainNotConfiguredError());\n // @ts-expect-error - request is not typed correctly\n const { request } = await this.getProvider();\n await request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: numberToHex(chainId) }],\n });\n return chain;\n },\n\n /**\n * Handles account changes\n */\n onAccountsChanged(accounts) {\n if (accounts.length === 0) this.onDisconnect();\n else config.emitter.emit('change', { accounts: accounts.map(getAddress) });\n },\n\n /**\n * Handles chain changes\n */\n onChainChanged(chain) {\n const chainId = Number(chain);\n config.emitter.emit('change', { chainId });\n },\n\n /**\n * Handles disconnection\n */\n async onDisconnect() {\n config.emitter.emit('disconnect');\n connected = false;\n accountAddress = undefined;\n },\n\n /**\n * Creates an EIP-1193 compatible provider\n * @returns Custom provider instance\n */\n async getProvider({ chainId }: { chainId?: number } = {}) {\n accountAddress = impersonatedHelpers?.getImpersonated()\n ? [(impersonatedHelpers.getImpersonated() as Address) || zeroAddress]\n : undefined;\n const chain = config.chains.find((x) => x.id === chainId) ?? config.chains[0];\n const url = chain.rpcUrls.default.http[0]!;\n\n const request: EIP1193RequestFn = async ({ method, params }) => {\n // eth methods\n if (method === 'eth_chainId') return numberToHex(connectedChainId);\n if (method === 'eth_requestAccounts') return accountAddress;\n if (method === 'eth_signTypedData_v4')\n if (features.signTypedDataError) {\n if (typeof features.signTypedDataError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to sign typed data.'));\n throw features.signTypedDataError;\n }\n\n // wallet methods\n if (method === 'wallet_switchEthereumChain') {\n if (features.switchChainError) {\n if (typeof features.switchChainError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to switch chain.'));\n throw features.switchChainError;\n }\n type Params = [{ chainId: Hex }];\n connectedChainId = fromHex((params as Params)[0].chainId, 'number');\n this.onChainChanged(connectedChainId.toString());\n return;\n }\n\n // other methods\n if (method === 'personal_sign') {\n if (features.signMessageError) {\n if (typeof features.signMessageError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to sign message.'));\n throw features.signMessageError;\n }\n // Change `personal_sign` to `eth_sign` and swap params\n method = 'eth_sign';\n type Params = [data: Hex, address: Address];\n params = [(params as Params)[1], (params as Params)[0]];\n }\n\n const body = { method, params };\n const { error, result } = await rpc.http(url, { body });\n if (error) throw new RpcRequestError({ body, error, url });\n\n return result;\n };\n return custom({ request })({ retryCount: 1 });\n },\n }));\n}\n","import { ConnectorsInitProps } from '@tuwaio/satellite-core';\nimport { coinbaseWallet, injected, safe, walletConnect } from '@wagmi/connectors';\nimport { CreateConnectorFn } from '@wagmi/core';\n\nimport { impersonated } from './ImpersonatedConnector';\n\n/**\n * Configuration options for Gnosis Safe SDK\n * @remarks\n * Defines allowed domains and debug mode for Safe integration\n */\nexport const safeSdkOptions = {\n /** Regular expressions for allowed Safe wallet domains */\n allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/, /metissafe.tech$/],\n /** Enable debug mode */\n debug: false,\n};\n\n/**\n * Initializes all supported wallet connectors based on provided configuration\n *\n * @remarks\n * Creates instances of various wallet connectors including:\n * - Injected wallets (e.g., MetaMask, Phantom, Trust Wallet, etc.)\n * - Coinbase Wallet\n * - Gnosis Safe\n * - WalletConnect (if projectId provided)\n * - Impersonated wallet (for development/testing)\n *\n * The order of connectors in the returned array determines their priority\n * in the wallet connection UI.\n *\n * @param props - Configuration options for initializing connectors\n * @returns Array of wallet connector instances\n *\n * @example\n * ```typescript\n * const connectors = initAllConnectors({\n * appName: \"My dApp\",\n * projectId: \"wallet_connect_project_id\",\n * appUrl: \"https://mydapp.com\",\n * appLogoUrl: \"https://mydapp.com/logo.png\"\n * });\n * ```\n */\nexport const initAllConnectors = (props: ConnectorsInitProps): readonly CreateConnectorFn[] => {\n const injectedConnector = injected();\n const coinbaseConnector = coinbaseWallet({\n appName: props.appName,\n appLogoUrl: props.appLogoUrl,\n });\n const gnosisSafeConnector = safe({\n ...safeSdkOptions,\n });\n\n const connectors = [injectedConnector, coinbaseConnector, gnosisSafeConnector, impersonated({})];\n\n // WalletConnect metadata configuration\n const wcMetadata =\n props.appUrl && props.appIcons && props.appName && props.description\n ? {\n name: props.appName,\n description: props.description,\n url: props.appUrl,\n icons: props.appIcons,\n }\n : undefined;\n\n if (props.projectId) {\n const walletConnectConnector = walletConnect({\n projectId: props.projectId,\n metadata: wcMetadata,\n });\n // @ts-expect-error - connector has some different types\n connectors.push(walletConnectConnector);\n }\n\n return connectors;\n};\n","import { CreateConfigParameters } from '@wagmi/core';\nimport { http, Transport } from 'viem';\n\n/**\n * Creates default HTTP transports for each chain in the configuration\n *\n * @param chains - Array of chain configurations from wagmi\n * @returns Object mapping chain IDs to their corresponding HTTP transport instances\n *\n * @public\n */\nexport const createDefaultTransports = (chains: CreateConfigParameters['chains']): Record<number, Transport> => {\n return chains.reduce(\n (acc, chain) => {\n const key = chain.id;\n acc[key] = http() as Transport;\n return acc;\n },\n {} as Record<number, Transport>,\n );\n};\n"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {OrbitAdapter,getWalletTypeFromConnectorName,formatWalletName,isSafeApp,impersonatedHelpers}from'@tuwaio/orbit-core';import {createViemClient,getAvatar,getName,checkAndSwitchChain}from'@tuwaio/orbit-evm';import {getBytecode,getConnectors,getChains,getAccount,getBalance,disconnect,connect,createConnector,ChainNotConfiguredError}from'@wagmi/core';import {formatUnits,zeroAddress,http,custom,numberToHex,UserRejectedRequestError,fromHex,RpcRequestError,getAddress,SwitchChainError}from'viem';import {mainnet}from'viem/chains';import {injected,coinbaseWallet,safe,walletConnect}from'@wagmi/connectors';import {rpc}from'viem/utils';var f=new Map;async function y({config:t,address:n,chainId:r,chains:o}){if(f.has(n))return f.get(n);if(createViemClient(r,o)){let e=!!await getBytecode(t,{address:n});return f.set(n,e),e}else return false}function le(t,n){if(!t)throw new Error("Satellite EVM adapter requires a wagmi config object.");return {key:OrbitAdapter.EVM,connect:async({walletType:r,chainId:o})=>{let s=getConnectors(t).find(e=>getWalletTypeFromConnectorName(OrbitAdapter.EVM,formatWalletName(e.name))===r);if(!s)throw new Error("Cannot find connector with this wallet type");try{await connect(t,{connector:s,chainId:o}),n&&!isSafeApp&&await n();let e=getAccount(t);return {walletType:r,address:e.address??zeroAddress,chainId:e.chainId??mainnet.id,rpcURL:e.chain?.rpcUrls.default.http[0]??mainnet.rpcUrls.default.http[0],isConnected:e.isConnected,isContractAddress:!1,walletIcon:s?.icon?.trim(),connector:s}}catch(e){throw new Error(e instanceof Error?e.message:String(e))}},disconnect:async()=>{let r=getConnectors(t);await Promise.allSettled(r.map(async o=>{await disconnect(t,{connector:o});}));},getConnectors:()=>{let r=getConnectors(t);return {adapter:OrbitAdapter.EVM,connectors:r.map(o=>o)}},checkAndSwitchNetwork:async r=>await checkAndSwitchChain(Number(r),t),getBalance:async(r,o)=>{let a=await getBalance(t,{address:r,chainId:Number(o)});return {value:formatUnits(a.value,a.decimals),symbol:a.symbol}},getExplorerUrl:r=>{let{chain:o}=getAccount(t),a=o?.blockExplorers?.default.url;return r?`${a}/${r}`:a},getName:r=>getName(r),getAvatar:r=>getAvatar(r),checkIsContractWallet:async({address:r,chainId:o})=>{let a=getChains(t);return await y({config:t,address:r,chainId:o,chains:a})},getSafeConnectorChainId:async()=>{let o=getConnectors(t).find(a=>a.name==="Safe");if(o)return await o.getChainId()}}}u.type="impersonated";function u(t){let n=t.features??{},r=false,o,a;return createConnector(s=>({id:"impersonated",name:"Impersonated Connector",type:u.type,async setup(){o=s.chains[0].id;},async connect({chainId:e}={}){if(n.connectError)throw typeof n.connectError=="boolean"?new UserRejectedRequestError(new Error("Failed to connect.")):n.connectError;let{request:c}=await this.getProvider(),d=await c({method:"eth_requestAccounts"}),m=await this.getChainId();return e&&m!==e&&(m=(await this.switchChain({chainId:e})).id),r=true,{accounts:d,chainId:m}},async disconnect(){r=false,a=void 0;},async getAccounts(){if(!r)throw new Error("Not connected connector");let{request:e}=await this.getProvider();return (await e({method:"eth_accounts"})).map(getAddress)},async getChainId(){let{request:e}=await this.getProvider(),c=await e({method:"eth_chainId"});return fromHex(c,"number")},async isAuthorized(){return r?!!(await this.getAccounts()).length:false},async switchChain({chainId:e}){let c=s.chains.find(m=>m.id===e);if(!c)throw new SwitchChainError(new ChainNotConfiguredError);let{request:d}=await this.getProvider();return await d({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(e)}]}),c},onAccountsChanged(e){e.length===0?this.onDisconnect():s.emitter.emit("change",{accounts:e.map(getAddress)});},onChainChanged(e){let c=Number(e);s.emitter.emit("change",{chainId:c});},async onDisconnect(){s.emitter.emit("disconnect"),r=false,a=void 0;},async getProvider({chainId:e}={}){a=impersonatedHelpers?.getImpersonated()?[impersonatedHelpers.getImpersonated()||zeroAddress]:void 0;let d=(s.chains.find(i=>i.id===e)??s.chains[0]).rpcUrls.default.http[0];return custom({request:async({method:i,params:h})=>{if(i==="eth_chainId")return numberToHex(o);if(i==="eth_requestAccounts")return a;if(i==="eth_signTypedData_v4"&&n.signTypedDataError)throw typeof n.signTypedDataError=="boolean"?new UserRejectedRequestError(new Error("Failed to sign typed data.")):n.signTypedDataError;if(i==="wallet_switchEthereumChain"){if(n.switchChainError)throw typeof n.switchChainError=="boolean"?new UserRejectedRequestError(new Error("Failed to switch chain.")):n.switchChainError;o=fromHex(h[0].chainId,"number"),this.onChainChanged(o.toString());return}if(i==="personal_sign"){if(n.signMessageError)throw typeof n.signMessageError=="boolean"?new UserRejectedRequestError(new Error("Failed to sign message.")):n.signMessageError;i="eth_sign",h=[h[1],h[0]];}let C={method:i,params:h},{error:g,result:N}=await rpc.http(d,{body:C});if(g)throw new RpcRequestError({body:C,error:g,url:d});return N}})({retryCount:1})}}))}var Y={allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/,/metissafe.tech$/],debug:false},be=t=>{let n=injected(),r=coinbaseWallet({appName:t.appName,appLogoUrl:t.appLogoUrl}),o=safe({...Y}),a=[n,r,o,u({})],s=t.appUrl&&t.appIcons&&t.appName&&t.description?{name:t.appName,description:t.description,url:t.appUrl,icons:t.appIcons}:void 0;if(t.projectId){let e=walletConnect({projectId:t.projectId,metadata:s});a.push(e);}return a};var xe=t=>t.reduce((n,r)=>{let o=r.id;return n[o]=http(),n},{});export{y as checkIsWalletAddressContract,xe as createDefaultTransports,be as initAllConnectors,Y as safeSdkOptions,le as satelliteEVMAdapter};//# sourceMappingURL=index.mjs.map
1
+ import {OrbitAdapter,getWalletTypeFromConnectorName,formatWalletName,isSafeApp,impersonatedHelpers}from'@tuwaio/orbit-core';import {createViemClient,getAvatar,getName,checkAndSwitchChain}from'@tuwaio/orbit-evm';import {getBytecode,getConnectors,getChains,getAccount,getBalance,disconnect,connect,createConnector,ChainNotConfiguredError}from'@wagmi/core';import {formatUnits,zeroAddress,http,custom,numberToHex,UserRejectedRequestError,fromHex,RpcRequestError,getAddress,SwitchChainError}from'viem';import {mainnet}from'viem/chains';import {injected,coinbaseWallet,safe,walletConnect}from'@wagmi/connectors';import {rpc}from'viem/utils';var f=new Map;async function E({config:e,address:n,chainId:r,chains:o}){if(f.has(n))return f.get(n);if(createViemClient(r,o)){let t=!!await getBytecode(e,{address:n});return f.set(n,t),t}else return false}function he(e,n){if(!e)throw new Error("Satellite EVM adapter requires a wagmi config object.");return {key:OrbitAdapter.EVM,connect:async({walletType:r,chainId:o})=>{let s=getConnectors(e).find(t=>getWalletTypeFromConnectorName(OrbitAdapter.EVM,formatWalletName(t.name))===r);if(!s)throw new Error("Cannot find connector with this wallet type");try{await connect(e,{connector:s,chainId:o}),n&&!isSafeApp&&await n();let t=getAccount(e);return {walletType:r,address:t.address??zeroAddress,chainId:t.chainId??mainnet.id,rpcURL:t.chain?.rpcUrls.default.http[0]??mainnet.rpcUrls.default.http[0],isConnected:t.isConnected,isContractAddress:!1,walletIcon:s?.icon?.trim(),connector:s}}catch(t){throw new Error(t instanceof Error?t.message:String(t))}},disconnect:async()=>{let r=getAccount(e);if(r.isConnected)await disconnect(e,{connector:r.connector});else {let o=getConnectors(e);await Promise.allSettled(o.map(async a=>{await disconnect(e,{connector:a});}));}},getConnectors:()=>{let r=getConnectors(e);return {adapter:OrbitAdapter.EVM,connectors:r.map(o=>o)}},checkAndSwitchNetwork:async r=>await checkAndSwitchChain(Number(r),e),getBalance:async(r,o)=>{let a=await getBalance(e,{address:r,chainId:Number(o)});return {value:formatUnits(a.value,a.decimals),symbol:a.symbol}},getExplorerUrl:r=>{let{chain:o}=getAccount(e),a=o?.blockExplorers?.default.url;return r?`${a}/${r}`:a},getName:r=>getName(r),getAvatar:r=>getAvatar(r),checkIsContractWallet:async({address:r,chainId:o})=>{let a=getChains(e);return await E({config:e,address:r,chainId:o,chains:a})},getSafeConnectorChainId:async()=>{let o=getConnectors(e).find(a=>a.name==="Safe");if(o)return await o.getChainId()}}}u.type="impersonated";function u(e){let n=e.features??{},r=false,o,a;return createConnector(s=>({id:"impersonated",name:"Impersonated Connector",type:u.type,async setup(){o=s.chains[0].id;},async connect({chainId:t}={}){if(n.connectError)throw typeof n.connectError=="boolean"?new UserRejectedRequestError(new Error("Failed to connect.")):n.connectError;let{request:c}=await this.getProvider(),d=await c({method:"eth_requestAccounts"}),m=await this.getChainId();return t&&m!==t&&(m=(await this.switchChain({chainId:t})).id),r=true,{accounts:d,chainId:m}},async disconnect(){r=false,a=void 0;},async getAccounts(){if(!r)throw new Error("Not connected connector");let{request:t}=await this.getProvider();return (await t({method:"eth_accounts"})).map(getAddress)},async getChainId(){let{request:t}=await this.getProvider(),c=await t({method:"eth_chainId"});return fromHex(c,"number")},async isAuthorized(){return r?!!(await this.getAccounts()).length:false},async switchChain({chainId:t}){let c=s.chains.find(m=>m.id===t);if(!c)throw new SwitchChainError(new ChainNotConfiguredError);let{request:d}=await this.getProvider();return await d({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(t)}]}),c},onAccountsChanged(t){t.length===0?this.onDisconnect():s.emitter.emit("change",{accounts:t.map(getAddress)});},onChainChanged(t){let c=Number(t);s.emitter.emit("change",{chainId:c});},async onDisconnect(){s.emitter.emit("disconnect"),r=false,a=void 0;},async getProvider({chainId:t}={}){a=impersonatedHelpers?.getImpersonated()?[impersonatedHelpers.getImpersonated()||zeroAddress]:void 0;let d=(s.chains.find(i=>i.id===t)??s.chains[0]).rpcUrls.default.http[0];return custom({request:async({method:i,params:l})=>{if(i==="eth_chainId")return numberToHex(o);if(i==="eth_requestAccounts")return a;if(i==="eth_signTypedData_v4"&&n.signTypedDataError)throw typeof n.signTypedDataError=="boolean"?new UserRejectedRequestError(new Error("Failed to sign typed data.")):n.signTypedDataError;if(i==="wallet_switchEthereumChain"){if(n.switchChainError)throw typeof n.switchChainError=="boolean"?new UserRejectedRequestError(new Error("Failed to switch chain.")):n.switchChainError;o=fromHex(l[0].chainId,"number"),this.onChainChanged(o.toString());return}if(i==="personal_sign"){if(n.signMessageError)throw typeof n.signMessageError=="boolean"?new UserRejectedRequestError(new Error("Failed to sign message.")):n.signMessageError;i="eth_sign",l=[l[1],l[0]];}let g={method:i,params:l},{error:y,result:S}=await rpc.http(d,{body:g});if(y)throw new RpcRequestError({body:g,error:y,url:d});return S}})({retryCount:1})}}))}var Y={allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/,/metissafe.tech$/],debug:false},be=e=>{let n=injected(),r=coinbaseWallet({appName:e.appName,appLogoUrl:e.appLogoUrl}),o=safe({...Y}),a=[n,r,o,u({})],s=e.appUrl&&e.appIcons&&e.appName&&e.description?{name:e.appName,description:e.description,url:e.appUrl,icons:e.appIcons}:void 0;if(e.projectId){let t=walletConnect({projectId:e.projectId,metadata:s});a.push(t);}return a};var xe=e=>e.reduce((n,r)=>{let o=r.id;return n[o]=http(),n},{});export{E as checkIsWalletAddressContract,xe as createDefaultTransports,be as initAllConnectors,Y as safeSdkOptions,he as satelliteEVMAdapter};//# sourceMappingURL=index.mjs.map
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/checkIsWalletAddressContract.ts","../src/adapters/evmAdapter.ts","../src/connectors/ImpersonatedConnector.ts","../src/connectors/index.ts","../src/utils/createDefaultTransports.ts"],"names":["walletsCache","checkIsWalletAddressContract","config","address","chainId","chains","createViemClient","isContract","getBytecode","satelliteEVMAdapter","signInWithSiwe","OrbitAdapter","walletType","connector","getConnectors","getWalletTypeFromConnectorName","formatWalletName","connect","isSafeApp","account","getAccount","zeroAddress","mainnet","connectors","disconnect","checkAndSwitchChain","balance","getBalance","formatUnits","url","chain","baseExplorerLink","getName","name","getAvatar","getChains","safeConnector","c","impersonated","parameters","features","connected","connectedChainId","accountAddress","createConnector","UserRejectedRequestError","request","accounts","currentChainId","getAddress","hexChainId","fromHex","x","SwitchChainError","ChainNotConfiguredError","numberToHex","impersonatedHelpers","custom","method","params","body","error","result","rpc","RpcRequestError","safeSdkOptions","initAllConnectors","props","injectedConnector","injected","coinbaseConnector","coinbaseWallet","gnosisSafeConnector","safe","wcMetadata","walletConnectConnector","walletConnect","createDefaultTransports","acc","key","http"],"mappings":"4nBAUA,IAAMA,CAAAA,CAAe,IAAI,GAAA,CA8BzB,eAAsBC,CAAAA,CAA6B,CACjD,MAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,OAAAC,CACF,CAAA,CASqB,CAEnB,GAAIL,CAAAA,CAAa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AAG,CAAA,CAAIC,IAAAA,EAAK,CACTF,CACT,CAAA,CACA,EACF","file":"index.mjs","sourcesContent":["import { createViemClient } from '@tuwaio/orbit-evm';\nimport { Config, getBytecode } from '@wagmi/core';\nimport { Address } from 'viem';\nimport { Chain } from 'viem/chains';\n\n/**\n * An in-memory cache for wallets bytecode to avoid redundant requests to the blockchain.\n * Key is the wallet address, value is boolean indicating if it's a contract address.\n * @internal\n */\nconst walletsCache = new Map<string, boolean>();\n\n/**\n * Checks if a given wallet address is a smart contract by examining its bytecode\n *\n * @remarks\n * This function uses an in-memory cache to store results and avoid redundant blockchain requests.\n * The cache persists for the lifetime of the application session.\n *\n * @param config - Wagmi configuration object\n * @param address - Ethereum address to check\n * @param chainId - ID of the blockchain network\n * @param chains - Array of supported chain configurations\n *\n * @returns Promise resolving to boolean indicating if the address is a contract\n * - true: Address is a smart contract\n * - false: Address is an EOA (Externally Owned Account) or client creation failed\n *\n * @example\n * ```typescript\n * const isContract = await checkIsWalletAddressContract({\n * config: wagmiConfig,\n * address: \"0x1234...\",\n * chainId: 1,\n * chains: [mainnet, polygon]\n * });\n * ```\n *\n * @throws Will throw an error if getBytecode request fails\n */\nexport async function checkIsWalletAddressContract({\n config,\n address,\n chainId,\n chains,\n}: {\n /** Wagmi configuration for blockchain interaction */\n config: Config;\n /** Ethereum address to check */\n address: string;\n /** Chain ID where the check should be performed */\n chainId: number | string;\n /** Array of supported chain configurations */\n chains: readonly [Chain, ...Chain[]];\n}): Promise<boolean> {\n // Check cache first to avoid redundant blockchain requests\n if (walletsCache.has(address)) {\n return walletsCache.get(address)!;\n }\n\n // Create Viem client for blockchain interaction\n const client = createViemClient(chainId as number, chains);\n\n if (client) {\n // Get bytecode from the blockchain\n const codeOfWalletAddress = await getBytecode(config, {\n address: address as Address,\n });\n\n // Cache the result\n const isContract = !!codeOfWalletAddress;\n walletsCache.set(address, isContract);\n\n return isContract;\n } else {\n // Return false if client creation failed\n return false;\n }\n}\n","import { formatWalletName, getWalletTypeFromConnectorName, isSafeApp, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { checkAndSwitchChain, getAvatar, getName } from '@tuwaio/orbit-evm';\nimport { SatelliteAdapter } from '@tuwaio/satellite-core';\nimport { Config, connect, disconnect, getAccount, getBalance, getChains, getConnectors } from '@wagmi/core';\nimport { Address, formatUnits, zeroAddress } from 'viem';\nimport { mainnet } from 'viem/chains';\n\nimport { ConnectorEVM } from '../types';\nimport { checkIsWalletAddressContract } from '../utils/checkIsWalletAddressContract';\n\n/**\n * Creates an EVM-compatible adapter for Satellite\n *\n * @remarks\n * This adapter implements the SatelliteAdapter interface for Ethereum Virtual Machine (EVM) compatible chains.\n * It uses wagmi as the underlying library for wallet connections and chain interactions.\n *\n * @param config - Wagmi configuration object containing chain and connector settings\n * @param signInWithSiwe - Optional function for signing in with SIWE\n * @returns A configured SatelliteAdapter instance for EVM chains\n * @throws Error if config is not provided\n *\n * @example\n * ```typescript\n * const config = createConfig({\n * chains: [mainnet, polygon],\n * connectors: [\n * new InjectedConnector(),\n * new WalletConnectConnector({ projectId: 'your_project_id' })\n * ]\n * });\n *\n * const evmAdapter = satelliteEVMAdapter(config);\n * ```\n */\nexport function satelliteEVMAdapter(\n config: Config,\n signInWithSiwe?: () => Promise<void>,\n): SatelliteAdapter<ConnectorEVM> {\n if (!config) throw new Error('Satellite EVM adapter requires a wagmi config object.');\n\n return {\n /** Identifies this adapter as EVM-compatible */\n key: OrbitAdapter.EVM,\n\n /**\n * Connects to an EVM wallet\n * @returns Connected wallet information\n * @throws Error if connector not found or connection fails\n */\n connect: async ({ walletType, chainId }) => {\n const connectors = getConnectors(config);\n const connector = connectors.find(\n (connector) =>\n getWalletTypeFromConnectorName(OrbitAdapter.EVM, formatWalletName(connector.name)) === walletType,\n );\n if (!connector) throw new Error('Cannot find connector with this wallet type');\n\n try {\n // const isConnected = await connector.isAuthorized();\n // if (isConnected) {\n // await disconnect(config, { connector });\n // }\n await connect(config, { connector, chainId: chainId as number });\n if (signInWithSiwe && !isSafeApp) {\n await signInWithSiwe();\n }\n const account = getAccount(config);\n\n return {\n walletType,\n address: account.address ?? zeroAddress,\n chainId: account.chainId ?? mainnet.id,\n rpcURL: account.chain?.rpcUrls.default.http[0] ?? mainnet.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n isContractAddress: false,\n walletIcon: connector?.icon?.trim(),\n connector,\n };\n } catch (e) {\n throw new Error(e instanceof Error ? e.message : String(e));\n }\n },\n\n /**\n * Disconnects the currently connected wallet\n */\n disconnect: async () => {\n const connectors = getConnectors(config);\n await Promise.allSettled(\n connectors.map(async (connector) => {\n await disconnect(config, { connector });\n }),\n );\n },\n\n /**\n * Retrieves available EVM wallet connectors\n * @returns Object containing adapter type and list of available connectors\n */\n getConnectors: () => {\n const connectors = getConnectors(config);\n return {\n adapter: OrbitAdapter.EVM,\n connectors: connectors.map((connector) => {\n return connector;\n }) as ConnectorEVM[],\n };\n },\n\n /**\n * Switches the connected wallet to specified network\n * @param chainId - Target chain ID to switch to\n */\n checkAndSwitchNetwork: async (chainId) => await checkAndSwitchChain(Number(chainId), config),\n\n getBalance: async (address, chainId) => {\n const balance = await getBalance(config, { address: address as Address, chainId: Number(chainId) });\n return {\n value: formatUnits(balance.value, balance.decimals),\n symbol: balance.symbol,\n };\n },\n\n /**\n * Generates blockchain explorer URLs for the current network\n * @param url - Optional path to append to base explorer URL\n * @returns Complete explorer URL or base explorer URL if no path provided\n */\n getExplorerUrl: (url) => {\n const { chain } = getAccount(config);\n const baseExplorerLink = chain?.blockExplorers?.default.url;\n return url ? `${baseExplorerLink}/${url}` : baseExplorerLink;\n },\n\n /**\n * Resolves ENS name for given address\n * @param address - Ethereum address to resolve\n * @returns ENS name if available, null otherwise\n */\n getName: (address: string) => getName(address as `0x${string}`),\n\n /**\n * Retrieves avatar for ENS name\n * @param name - ENS name to get avatar for\n * @returns Avatar URL if available, null otherwise\n */\n getAvatar: (name: string) => getAvatar(name),\n\n /**\n * Checks if given address is a smart contract\n * @param address - Address to check\n * @param chainId - Chain ID on which to perform the check\n * @returns Promise resolving to boolean indicating if address is a contract\n */\n checkIsContractWallet: async ({ address, chainId }) => {\n const chains = getChains(config);\n return await checkIsWalletAddressContract({ config, address, chainId, chains });\n },\n\n getSafeConnectorChainId: async () => {\n const connectors = getConnectors(config);\n const safeConnector = connectors.find((c) => c.name === 'Safe');\n if (safeConnector) {\n return await safeConnector.getChainId();\n } else {\n return undefined;\n }\n },\n };\n}\n","import { impersonatedHelpers } from '@tuwaio/orbit-core';\nimport { ChainNotConfiguredError, createConnector } from '@wagmi/core';\nimport {\n type Address,\n custom,\n type EIP1193RequestFn,\n fromHex,\n getAddress,\n type Hex,\n numberToHex,\n RpcRequestError,\n SwitchChainError,\n type Transport,\n UserRejectedRequestError,\n type WalletRpcSchema,\n zeroAddress,\n} from 'viem';\nimport { rpc } from 'viem/utils';\n\n/**\n * Configuration parameters for impersonated wallet connector\n */\nexport type ImpersonatedParameters = {\n /** Optional feature flags for testing error scenarios */\n features?: {\n /** Simulate connection error */\n connectError?: boolean | Error;\n /** Simulate chain switching error */\n switchChainError?: boolean | Error;\n /** Simulate message signing error */\n signMessageError?: boolean | Error;\n /** Simulate typed data signing error */\n signTypedDataError?: boolean | Error;\n /** Enable reconnection behavior */\n reconnect?: boolean;\n };\n};\n\n/**\n * Creates a wagmi connector for impersonating Ethereum accounts\n *\n * @remarks\n * This connector allows testing wallet interactions without an actual wallet by impersonating\n * an Ethereum address. It implements the EIP-1193 provider interface and can simulate\n * various error scenarios for testing purposes.\n *\n * @param parameters - Configuration options for the impersonated connector\n * @returns A wagmi connector instance\n *\n * @example\n * ```typescript\n * const connector = impersonated({\n * getAccountAddress: () => \"0x1234...\",\n * features: {\n * // Simulate errors for testing\n * connectError: false,\n * signMessageError: false\n * }\n * });\n * ```\n */\nimpersonated.type = 'impersonated' as const;\nexport function impersonated(parameters: ImpersonatedParameters) {\n const features = parameters.features ?? {};\n\n type Provider = ReturnType<Transport<'custom', NonNullable<unknown>, EIP1193RequestFn<WalletRpcSchema>>>;\n let connected = false;\n let connectedChainId: number;\n let accountAddress: Hex[] | undefined = undefined;\n\n return createConnector<Provider>((config) => ({\n id: 'impersonated',\n name: 'Impersonated Connector',\n type: impersonated.type,\n\n /**\n * Initial setup - sets default chain ID\n */\n async setup() {\n connectedChainId = config.chains[0].id;\n },\n /**\n * Simulates wallet connection\n * @throws {UserRejectedRequestError} When connection is rejected\n */\n // @ts-expect-error - not typed correctly\n async connect({ chainId } = {}) {\n if (features.connectError) {\n if (typeof features.connectError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to connect.'));\n throw features.connectError;\n }\n\n const { request } = await this.getProvider();\n const accounts = await request({\n method: 'eth_requestAccounts',\n });\n\n let currentChainId = await this.getChainId();\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId });\n currentChainId = chain.id;\n }\n\n connected = true;\n return { accounts, chainId: currentChainId };\n },\n\n /**\n * Simulates wallet disconnection\n */\n async disconnect() {\n connected = false;\n accountAddress = undefined;\n },\n\n /**\n * Returns impersonated accounts\n * @throws {Error} When not connected\n */\n async getAccounts() {\n if (!connected) throw new Error('Not connected connector');\n const { request } = await this.getProvider();\n const accounts = await request({ method: 'eth_accounts' });\n return accounts.map(getAddress);\n },\n\n /**\n * Returns current chain ID\n */\n async getChainId() {\n const { request } = await this.getProvider();\n const hexChainId = await request({ method: 'eth_chainId' });\n return fromHex(hexChainId, 'number');\n },\n\n /**\n * Checks if wallet is connected and authorized\n */\n async isAuthorized() {\n if (!connected) return false;\n const accounts = await this.getAccounts();\n return !!accounts.length;\n },\n\n /**\n * Simulates switching to a different chain\n * @throws {SwitchChainError} When chain is not configured\n * @throws {UserRejectedRequestError} When switch is rejected\n */\n async switchChain({ chainId }) {\n const chain = config.chains.find((x) => x.id === chainId);\n if (!chain) throw new SwitchChainError(new ChainNotConfiguredError());\n // @ts-expect-error - request is not typed correctly\n const { request } = await this.getProvider();\n await request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: numberToHex(chainId) }],\n });\n return chain;\n },\n\n /**\n * Handles account changes\n */\n onAccountsChanged(accounts) {\n if (accounts.length === 0) this.onDisconnect();\n else config.emitter.emit('change', { accounts: accounts.map(getAddress) });\n },\n\n /**\n * Handles chain changes\n */\n onChainChanged(chain) {\n const chainId = Number(chain);\n config.emitter.emit('change', { chainId });\n },\n\n /**\n * Handles disconnection\n */\n async onDisconnect() {\n config.emitter.emit('disconnect');\n connected = false;\n accountAddress = undefined;\n },\n\n /**\n * Creates an EIP-1193 compatible provider\n * @returns Custom provider instance\n */\n async getProvider({ chainId }: { chainId?: number } = {}) {\n accountAddress = impersonatedHelpers?.getImpersonated()\n ? [(impersonatedHelpers.getImpersonated() as Address) || zeroAddress]\n : undefined;\n const chain = config.chains.find((x) => x.id === chainId) ?? config.chains[0];\n const url = chain.rpcUrls.default.http[0]!;\n\n const request: EIP1193RequestFn = async ({ method, params }) => {\n // eth methods\n if (method === 'eth_chainId') return numberToHex(connectedChainId);\n if (method === 'eth_requestAccounts') return accountAddress;\n if (method === 'eth_signTypedData_v4')\n if (features.signTypedDataError) {\n if (typeof features.signTypedDataError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to sign typed data.'));\n throw features.signTypedDataError;\n }\n\n // wallet methods\n if (method === 'wallet_switchEthereumChain') {\n if (features.switchChainError) {\n if (typeof features.switchChainError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to switch chain.'));\n throw features.switchChainError;\n }\n type Params = [{ chainId: Hex }];\n connectedChainId = fromHex((params as Params)[0].chainId, 'number');\n this.onChainChanged(connectedChainId.toString());\n return;\n }\n\n // other methods\n if (method === 'personal_sign') {\n if (features.signMessageError) {\n if (typeof features.signMessageError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to sign message.'));\n throw features.signMessageError;\n }\n // Change `personal_sign` to `eth_sign` and swap params\n method = 'eth_sign';\n type Params = [data: Hex, address: Address];\n params = [(params as Params)[1], (params as Params)[0]];\n }\n\n const body = { method, params };\n const { error, result } = await rpc.http(url, { body });\n if (error) throw new RpcRequestError({ body, error, url });\n\n return result;\n };\n return custom({ request })({ retryCount: 1 });\n },\n }));\n}\n","import { ConnectorsInitProps } from '@tuwaio/satellite-core';\nimport { coinbaseWallet, injected, safe, walletConnect } from '@wagmi/connectors';\nimport { CreateConnectorFn } from '@wagmi/core';\n\nimport { impersonated } from './ImpersonatedConnector';\n\n/**\n * Configuration options for Gnosis Safe SDK\n * @remarks\n * Defines allowed domains and debug mode for Safe integration\n */\nexport const safeSdkOptions = {\n /** Regular expressions for allowed Safe wallet domains */\n allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/, /metissafe.tech$/],\n /** Enable debug mode */\n debug: false,\n};\n\n/**\n * Initializes all supported wallet connectors based on provided configuration\n *\n * @remarks\n * Creates instances of various wallet connectors including:\n * - Coinbase Wallet\n * - Gnosis Safe\n * - WalletConnect (if projectId provided)\n * - Impersonated wallet (for development/testing)\n *\n * The order of connectors in the returned array determines their priority\n * in the wallet connection UI.\n *\n * @param props - Configuration options for initializing connectors\n * @returns Array of wallet connector instances\n *\n * @example\n * ```typescript\n * const connectors = initAllConnectors({\n * appName: \"My dApp\",\n * projectId: \"wallet_connect_project_id\",\n * appUrl: \"https://mydapp.com\",\n * appLogoUrl: \"https://mydapp.com/logo.png\"\n * });\n * ```\n */\nexport const initAllConnectors = (props: ConnectorsInitProps): readonly CreateConnectorFn[] => {\n const injectedConnector = injected();\n const coinbaseConnector = coinbaseWallet({\n appName: props.appName,\n appLogoUrl: props.appLogoUrl,\n });\n const gnosisSafeConnector = safe({\n ...safeSdkOptions,\n });\n\n const connectors = [injectedConnector, coinbaseConnector, gnosisSafeConnector, impersonated({})];\n\n // WalletConnect metadata configuration\n const wcMetadata =\n props.appUrl && props.appIcons && props.appName && props.description\n ? {\n name: props.appName,\n description: props.description,\n url: props.appUrl,\n icons: props.appIcons,\n }\n : undefined;\n\n if (props.projectId) {\n const walletConnectConnector = walletConnect({\n projectId: props.projectId,\n metadata: wcMetadata,\n });\n // @ts-expect-error - connector has some different types\n connectors.push(walletConnectConnector);\n }\n\n return connectors;\n};\n","import { CreateConfigParameters } from '@wagmi/core';\nimport { http, Transport } from 'viem';\n\n/**\n * Creates default HTTP transports for each chain in the configuration\n *\n * @param chains - Array of chain configurations from wagmi\n * @returns Object mapping chain IDs to their corresponding HTTP transport instances\n *\n * @public\n */\nexport const createDefaultTransports = (chains: CreateConfigParameters['chains']): Record<number, Transport> => {\n return chains.reduce(\n (acc, chain) => {\n const key = chain.id;\n acc[key] = http() as Transport;\n return acc;\n },\n {} as Record<number, Transport>,\n );\n};\n"]}
1
+ {"version":3,"sources":["../src/utils/checkIsWalletAddressContract.ts","../src/adapters/evmAdapter.ts","../src/connectors/ImpersonatedConnector.ts","../src/connectors/index.ts","../src/utils/createDefaultTransports.ts"],"names":["walletsCache","checkIsWalletAddressContract","config","address","chainId","chains","createViemClient","isContract","getBytecode","satelliteEVMAdapter","signInWithSiwe","OrbitAdapter","walletType","connector","getConnectors","getWalletTypeFromConnectorName","formatWalletName","connect","isSafeApp","account","getAccount","zeroAddress","mainnet","e","activeWallet","disconnect","connectors","checkAndSwitchChain","balance","getBalance","formatUnits","url","chain","baseExplorerLink","getName","name","getAvatar","getChains","safeConnector","c","impersonated","parameters","features","connected","connectedChainId","accountAddress","createConnector","UserRejectedRequestError","request","accounts","currentChainId","getAddress","hexChainId","fromHex","x","SwitchChainError","ChainNotConfiguredError","numberToHex","impersonatedHelpers","custom","method","params","body","error","result","rpc","RpcRequestError","safeSdkOptions","initAllConnectors","props","injectedConnector","injected","coinbaseConnector","coinbaseWallet","gnosisSafeConnector","safe","wcMetadata","walletConnectConnector","walletConnect","createDefaultTransports","acc","key","http"],"mappings":"4nBAUA,IAAMA,CAAAA,CAAe,IAAI,GAAA,CA8BzB,eAAsBC,CAAAA,CAA6B,CACjD,MAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,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,EACxC,CAEA,OAAOnD,CACT,ECnEO,IAAMqD,EAAAA,CAA2B1E,CAAAA,EAC/BA,EAAO,MAAA,CACZ,CAAC2E,CAAAA,CAAKhD,CAAAA,GAAU,CACd,IAAMiD,CAAAA,CAAMjD,CAAAA,CAAM,GAClB,OAAAgD,CAAAA,CAAIC,CAAG,CAAA,CAAIC,IAAAA,EAAK,CACTF,CACT,CAAA,CACA,EACF","file":"index.mjs","sourcesContent":["import { createViemClient } from '@tuwaio/orbit-evm';\nimport { Config, getBytecode } from '@wagmi/core';\nimport { Address } from 'viem';\nimport { Chain } from 'viem/chains';\n\n/**\n * An in-memory cache for wallets bytecode to avoid redundant requests to the blockchain.\n * Key is the wallet address, value is boolean indicating if it's a contract address.\n * @internal\n */\nconst walletsCache = new Map<string, boolean>();\n\n/**\n * Checks if a given wallet address is a smart contract by examining its bytecode\n *\n * @remarks\n * This function uses an in-memory cache to store results and avoid redundant blockchain requests.\n * The cache persists for the lifetime of the application session.\n *\n * @param config - Wagmi configuration object\n * @param address - Ethereum address to check\n * @param chainId - ID of the blockchain network\n * @param chains - Array of supported chain configurations\n *\n * @returns Promise resolving to boolean indicating if the address is a contract\n * - true: Address is a smart contract\n * - false: Address is an EOA (Externally Owned Account) or client creation failed\n *\n * @example\n * ```typescript\n * const isContract = await checkIsWalletAddressContract({\n * config: wagmiConfig,\n * address: \"0x1234...\",\n * chainId: 1,\n * chains: [mainnet, polygon]\n * });\n * ```\n *\n * @throws Will throw an error if getBytecode request fails\n */\nexport async function checkIsWalletAddressContract({\n config,\n address,\n chainId,\n chains,\n}: {\n /** Wagmi configuration for blockchain interaction */\n config: Config;\n /** Ethereum address to check */\n address: string;\n /** Chain ID where the check should be performed */\n chainId: number | string;\n /** Array of supported chain configurations */\n chains: readonly [Chain, ...Chain[]];\n}): Promise<boolean> {\n // Check cache first to avoid redundant blockchain requests\n if (walletsCache.has(address)) {\n return walletsCache.get(address)!;\n }\n\n // Create Viem client for blockchain interaction\n const client = createViemClient(chainId as number, chains);\n\n if (client) {\n // Get bytecode from the blockchain\n const codeOfWalletAddress = await getBytecode(config, {\n address: address as Address,\n });\n\n // Cache the result\n const isContract = !!codeOfWalletAddress;\n walletsCache.set(address, isContract);\n\n return isContract;\n } else {\n // Return false if client creation failed\n return false;\n }\n}\n","import { formatWalletName, getWalletTypeFromConnectorName, isSafeApp, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { checkAndSwitchChain, getAvatar, getName } from '@tuwaio/orbit-evm';\nimport { SatelliteAdapter } from '@tuwaio/satellite-core';\nimport { Config, connect, disconnect, getAccount, getBalance, getChains, getConnectors } from '@wagmi/core';\nimport { Address, formatUnits, zeroAddress } from 'viem';\nimport { mainnet } from 'viem/chains';\n\nimport { ConnectorEVM } from '../types';\nimport { checkIsWalletAddressContract } from '../utils/checkIsWalletAddressContract';\n\n/**\n * Creates an EVM-compatible adapter for Satellite\n *\n * @remarks\n * This adapter implements the SatelliteAdapter interface for Ethereum Virtual Machine (EVM) compatible chains.\n * It uses wagmi as the underlying library for wallet connections and chain interactions.\n *\n * @param config - Wagmi configuration object containing chain and connector settings\n * @param signInWithSiwe - Optional function for signing in with SIWE\n * @returns A configured SatelliteAdapter instance for EVM chains\n * @throws Error if config is not provided\n *\n * @example\n * ```typescript\n * const config = createConfig({\n * chains: [mainnet, polygon],\n * connectors: [\n * new InjectedConnector(),\n * new WalletConnectConnector({ projectId: 'your_project_id' })\n * ]\n * });\n *\n * const evmAdapter = satelliteEVMAdapter(config);\n * ```\n */\nexport function satelliteEVMAdapter(\n config: Config,\n signInWithSiwe?: () => Promise<void>,\n): SatelliteAdapter<ConnectorEVM> {\n if (!config) throw new Error('Satellite EVM adapter requires a wagmi config object.');\n\n return {\n /** Identifies this adapter as EVM-compatible */\n key: OrbitAdapter.EVM,\n\n /**\n * Connects to an EVM wallet\n * @returns Connected wallet information\n * @throws Error if connector not found or connection fails\n */\n connect: async ({ walletType, chainId }) => {\n const connectors = getConnectors(config);\n const connector = connectors.find(\n (connector) =>\n getWalletTypeFromConnectorName(OrbitAdapter.EVM, formatWalletName(connector.name)) === walletType,\n );\n if (!connector) throw new Error('Cannot find connector with this wallet type');\n\n try {\n // const isConnected = await connector.isAuthorized();\n // if (isConnected) {\n // await disconnect(config, { connector });\n // }\n await connect(config, { connector, chainId: chainId as number });\n if (signInWithSiwe && !isSafeApp) {\n await signInWithSiwe();\n }\n const account = getAccount(config);\n\n return {\n walletType,\n address: account.address ?? zeroAddress,\n chainId: account.chainId ?? mainnet.id,\n rpcURL: account.chain?.rpcUrls.default.http[0] ?? mainnet.rpcUrls.default.http[0],\n isConnected: account.isConnected,\n isContractAddress: false,\n walletIcon: connector?.icon?.trim(),\n connector,\n };\n } catch (e) {\n throw new Error(e instanceof Error ? e.message : String(e));\n }\n },\n\n /**\n * Disconnects the currently connected wallet\n */\n disconnect: async () => {\n const activeWallet = getAccount(config);\n if (activeWallet.isConnected) {\n await disconnect(config, { connector: activeWallet.connector });\n } else {\n const connectors = getConnectors(config);\n await Promise.allSettled(\n connectors.map(async (connector) => {\n await disconnect(config, { connector });\n }),\n );\n }\n },\n\n /**\n * Retrieves available EVM wallet connectors\n * @returns Object containing adapter type and list of available connectors\n */\n getConnectors: () => {\n const connectors = getConnectors(config);\n return {\n adapter: OrbitAdapter.EVM,\n connectors: connectors.map((connector) => {\n return connector;\n }) as ConnectorEVM[],\n };\n },\n\n /**\n * Switches the connected wallet to specified network\n * @param chainId - Target chain ID to switch to\n */\n checkAndSwitchNetwork: async (chainId) => await checkAndSwitchChain(Number(chainId), config),\n\n getBalance: async (address, chainId) => {\n const balance = await getBalance(config, { address: address as Address, chainId: Number(chainId) });\n return {\n value: formatUnits(balance.value, balance.decimals),\n symbol: balance.symbol,\n };\n },\n\n /**\n * Generates blockchain explorer URLs for the current network\n * @param url - Optional path to append to base explorer URL\n * @returns Complete explorer URL or base explorer URL if no path provided\n */\n getExplorerUrl: (url) => {\n const { chain } = getAccount(config);\n const baseExplorerLink = chain?.blockExplorers?.default.url;\n return url ? `${baseExplorerLink}/${url}` : baseExplorerLink;\n },\n\n /**\n * Resolves ENS name for given address\n * @param address - Ethereum address to resolve\n * @returns ENS name if available, null otherwise\n */\n getName: (address: string) => getName(address as `0x${string}`),\n\n /**\n * Retrieves avatar for ENS name\n * @param name - ENS name to get avatar for\n * @returns Avatar URL if available, null otherwise\n */\n getAvatar: (name: string) => getAvatar(name),\n\n /**\n * Checks if given address is a smart contract\n * @param address - Address to check\n * @param chainId - Chain ID on which to perform the check\n * @returns Promise resolving to boolean indicating if address is a contract\n */\n checkIsContractWallet: async ({ address, chainId }) => {\n const chains = getChains(config);\n return await checkIsWalletAddressContract({ config, address, chainId, chains });\n },\n\n getSafeConnectorChainId: async () => {\n const connectors = getConnectors(config);\n const safeConnector = connectors.find((c) => c.name === 'Safe');\n if (safeConnector) {\n return await safeConnector.getChainId();\n } else {\n return undefined;\n }\n },\n };\n}\n","import { impersonatedHelpers } from '@tuwaio/orbit-core';\nimport { ChainNotConfiguredError, createConnector } from '@wagmi/core';\nimport {\n type Address,\n custom,\n type EIP1193RequestFn,\n fromHex,\n getAddress,\n type Hex,\n numberToHex,\n RpcRequestError,\n SwitchChainError,\n type Transport,\n UserRejectedRequestError,\n type WalletRpcSchema,\n zeroAddress,\n} from 'viem';\nimport { rpc } from 'viem/utils';\n\n/**\n * Configuration parameters for impersonated wallet connector\n */\nexport type ImpersonatedParameters = {\n /** Optional feature flags for testing error scenarios */\n features?: {\n /** Simulate connection error */\n connectError?: boolean | Error;\n /** Simulate chain switching error */\n switchChainError?: boolean | Error;\n /** Simulate message signing error */\n signMessageError?: boolean | Error;\n /** Simulate typed data signing error */\n signTypedDataError?: boolean | Error;\n /** Enable reconnection behavior */\n reconnect?: boolean;\n };\n};\n\n/**\n * Creates a wagmi connector for impersonating Ethereum accounts\n *\n * @remarks\n * This connector allows testing wallet interactions without an actual wallet by impersonating\n * an Ethereum address. It implements the EIP-1193 provider interface and can simulate\n * various error scenarios for testing purposes.\n *\n * @param parameters - Configuration options for the impersonated connector\n * @returns A wagmi connector instance\n *\n * @example\n * ```typescript\n * const connector = impersonated({\n * getAccountAddress: () => \"0x1234...\",\n * features: {\n * // Simulate errors for testing\n * connectError: false,\n * signMessageError: false\n * }\n * });\n * ```\n */\nimpersonated.type = 'impersonated' as const;\nexport function impersonated(parameters: ImpersonatedParameters) {\n const features = parameters.features ?? {};\n\n type Provider = ReturnType<Transport<'custom', NonNullable<unknown>, EIP1193RequestFn<WalletRpcSchema>>>;\n let connected = false;\n let connectedChainId: number;\n let accountAddress: Hex[] | undefined = undefined;\n\n return createConnector<Provider>((config) => ({\n id: 'impersonated',\n name: 'Impersonated Connector',\n type: impersonated.type,\n\n /**\n * Initial setup - sets default chain ID\n */\n async setup() {\n connectedChainId = config.chains[0].id;\n },\n /**\n * Simulates wallet connection\n * @throws {UserRejectedRequestError} When connection is rejected\n */\n // @ts-expect-error - not typed correctly\n async connect({ chainId } = {}) {\n if (features.connectError) {\n if (typeof features.connectError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to connect.'));\n throw features.connectError;\n }\n\n const { request } = await this.getProvider();\n const accounts = await request({\n method: 'eth_requestAccounts',\n });\n\n let currentChainId = await this.getChainId();\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId });\n currentChainId = chain.id;\n }\n\n connected = true;\n return { accounts, chainId: currentChainId };\n },\n\n /**\n * Simulates wallet disconnection\n */\n async disconnect() {\n connected = false;\n accountAddress = undefined;\n },\n\n /**\n * Returns impersonated accounts\n * @throws {Error} When not connected\n */\n async getAccounts() {\n if (!connected) throw new Error('Not connected connector');\n const { request } = await this.getProvider();\n const accounts = await request({ method: 'eth_accounts' });\n return accounts.map(getAddress);\n },\n\n /**\n * Returns current chain ID\n */\n async getChainId() {\n const { request } = await this.getProvider();\n const hexChainId = await request({ method: 'eth_chainId' });\n return fromHex(hexChainId, 'number');\n },\n\n /**\n * Checks if wallet is connected and authorized\n */\n async isAuthorized() {\n if (!connected) return false;\n const accounts = await this.getAccounts();\n return !!accounts.length;\n },\n\n /**\n * Simulates switching to a different chain\n * @throws {SwitchChainError} When chain is not configured\n * @throws {UserRejectedRequestError} When switch is rejected\n */\n async switchChain({ chainId }) {\n const chain = config.chains.find((x) => x.id === chainId);\n if (!chain) throw new SwitchChainError(new ChainNotConfiguredError());\n // @ts-expect-error - request is not typed correctly\n const { request } = await this.getProvider();\n await request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: numberToHex(chainId) }],\n });\n return chain;\n },\n\n /**\n * Handles account changes\n */\n onAccountsChanged(accounts) {\n if (accounts.length === 0) this.onDisconnect();\n else config.emitter.emit('change', { accounts: accounts.map(getAddress) });\n },\n\n /**\n * Handles chain changes\n */\n onChainChanged(chain) {\n const chainId = Number(chain);\n config.emitter.emit('change', { chainId });\n },\n\n /**\n * Handles disconnection\n */\n async onDisconnect() {\n config.emitter.emit('disconnect');\n connected = false;\n accountAddress = undefined;\n },\n\n /**\n * Creates an EIP-1193 compatible provider\n * @returns Custom provider instance\n */\n async getProvider({ chainId }: { chainId?: number } = {}) {\n accountAddress = impersonatedHelpers?.getImpersonated()\n ? [(impersonatedHelpers.getImpersonated() as Address) || zeroAddress]\n : undefined;\n const chain = config.chains.find((x) => x.id === chainId) ?? config.chains[0];\n const url = chain.rpcUrls.default.http[0]!;\n\n const request: EIP1193RequestFn = async ({ method, params }) => {\n // eth methods\n if (method === 'eth_chainId') return numberToHex(connectedChainId);\n if (method === 'eth_requestAccounts') return accountAddress;\n if (method === 'eth_signTypedData_v4')\n if (features.signTypedDataError) {\n if (typeof features.signTypedDataError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to sign typed data.'));\n throw features.signTypedDataError;\n }\n\n // wallet methods\n if (method === 'wallet_switchEthereumChain') {\n if (features.switchChainError) {\n if (typeof features.switchChainError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to switch chain.'));\n throw features.switchChainError;\n }\n type Params = [{ chainId: Hex }];\n connectedChainId = fromHex((params as Params)[0].chainId, 'number');\n this.onChainChanged(connectedChainId.toString());\n return;\n }\n\n // other methods\n if (method === 'personal_sign') {\n if (features.signMessageError) {\n if (typeof features.signMessageError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to sign message.'));\n throw features.signMessageError;\n }\n // Change `personal_sign` to `eth_sign` and swap params\n method = 'eth_sign';\n type Params = [data: Hex, address: Address];\n params = [(params as Params)[1], (params as Params)[0]];\n }\n\n const body = { method, params };\n const { error, result } = await rpc.http(url, { body });\n if (error) throw new RpcRequestError({ body, error, url });\n\n return result;\n };\n return custom({ request })({ retryCount: 1 });\n },\n }));\n}\n","import { ConnectorsInitProps } from '@tuwaio/satellite-core';\nimport { coinbaseWallet, injected, safe, walletConnect } from '@wagmi/connectors';\nimport { CreateConnectorFn } from '@wagmi/core';\n\nimport { impersonated } from './ImpersonatedConnector';\n\n/**\n * Configuration options for Gnosis Safe SDK\n * @remarks\n * Defines allowed domains and debug mode for Safe integration\n */\nexport const safeSdkOptions = {\n /** Regular expressions for allowed Safe wallet domains */\n allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/, /metissafe.tech$/],\n /** Enable debug mode */\n debug: false,\n};\n\n/**\n * Initializes all supported wallet connectors based on provided configuration\n *\n * @remarks\n * Creates instances of various wallet connectors including:\n * - Injected wallets (e.g., MetaMask, Phantom, Trust Wallet, etc.)\n * - Coinbase Wallet\n * - Gnosis Safe\n * - WalletConnect (if projectId provided)\n * - Impersonated wallet (for development/testing)\n *\n * The order of connectors in the returned array determines their priority\n * in the wallet connection UI.\n *\n * @param props - Configuration options for initializing connectors\n * @returns Array of wallet connector instances\n *\n * @example\n * ```typescript\n * const connectors = initAllConnectors({\n * appName: \"My dApp\",\n * projectId: \"wallet_connect_project_id\",\n * appUrl: \"https://mydapp.com\",\n * appLogoUrl: \"https://mydapp.com/logo.png\"\n * });\n * ```\n */\nexport const initAllConnectors = (props: ConnectorsInitProps): readonly CreateConnectorFn[] => {\n const injectedConnector = injected();\n const coinbaseConnector = coinbaseWallet({\n appName: props.appName,\n appLogoUrl: props.appLogoUrl,\n });\n const gnosisSafeConnector = safe({\n ...safeSdkOptions,\n });\n\n const connectors = [injectedConnector, coinbaseConnector, gnosisSafeConnector, impersonated({})];\n\n // WalletConnect metadata configuration\n const wcMetadata =\n props.appUrl && props.appIcons && props.appName && props.description\n ? {\n name: props.appName,\n description: props.description,\n url: props.appUrl,\n icons: props.appIcons,\n }\n : undefined;\n\n if (props.projectId) {\n const walletConnectConnector = walletConnect({\n projectId: props.projectId,\n metadata: wcMetadata,\n });\n // @ts-expect-error - connector has some different types\n connectors.push(walletConnectConnector);\n }\n\n return connectors;\n};\n","import { CreateConfigParameters } from '@wagmi/core';\nimport { http, Transport } from 'viem';\n\n/**\n * Creates default HTTP transports for each chain in the configuration\n *\n * @param chains - Array of chain configurations from wagmi\n * @returns Object mapping chain IDs to their corresponding HTTP transport instances\n *\n * @public\n */\nexport const createDefaultTransports = (chains: CreateConfigParameters['chains']): Record<number, Transport> => {\n return chains.reduce(\n (acc, chain) => {\n const key = chain.id;\n acc[key] = http() as Transport;\n return acc;\n },\n {} as Record<number, Transport>,\n );\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuwaio/satellite-evm",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",
@@ -53,17 +53,17 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@wagmi/core": "^2.22.1",
56
- "@wagmi/connectors": "^6.0.1",
57
- "@tuwaio/orbit-core": "^0.1.0",
58
- "@tuwaio/orbit-evm": "^0.1.0",
56
+ "@wagmi/connectors": "^6.1.0",
57
+ "@tuwaio/orbit-core": "^0.1.1",
58
+ "@tuwaio/orbit-evm": "^0.1.1",
59
59
  "immer": "^10.1.3",
60
60
  "jsdom": "^27.0.1",
61
61
  "tsup": "^8.5.0",
62
62
  "typescript": "^5.9.3",
63
63
  "viem": "^2.38.3",
64
- "vitest": "^3.2.4",
64
+ "vitest": "^4.0.1",
65
65
  "zustand": "^5.0.8",
66
- "@tuwaio/satellite-core": "^0.1.0"
66
+ "@tuwaio/satellite-core": "^0.1.1"
67
67
  },
68
68
  "scripts": {
69
69
  "start": "tsup src/index.ts --watch",