@tuwaio/satellite-evm 0.1.5 → 0.2.1
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 +12 -48
- package/dist/index.d.mts +31 -45
- package/dist/index.d.ts +31 -45
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -21
package/README.md
CHANGED
|
@@ -29,18 +29,19 @@ Built on top of `@tuwaio/satellite-core`, this package integrates seamlessly wit
|
|
|
29
29
|
## 💾 Installation
|
|
30
30
|
|
|
31
31
|
### Requirements
|
|
32
|
+
|
|
32
33
|
- Node.js 20+
|
|
33
34
|
- TypeScript 5.9+
|
|
34
35
|
|
|
35
36
|
```bash
|
|
36
37
|
# Using pnpm (recommended)
|
|
37
|
-
pnpm add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @
|
|
38
|
+
pnpm add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @tuwaio/orbit-core @tuwaio/orbit-evm
|
|
38
39
|
|
|
39
40
|
# Using npm
|
|
40
|
-
npm install @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @
|
|
41
|
+
npm install @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @tuwaio/orbit-core @tuwaio/orbit-evm
|
|
41
42
|
|
|
42
43
|
# Using yarn
|
|
43
|
-
yarn add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @
|
|
44
|
+
yarn add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zustand @tuwaio/orbit-core @tuwaio/orbit-evm
|
|
44
45
|
````
|
|
45
46
|
|
|
46
47
|
-----
|
|
@@ -50,30 +51,19 @@ yarn add @tuwaio/satellite-evm @tuwaio/satellite-core viem @wagmi/core immer zus
|
|
|
50
51
|
### Basic Configuration
|
|
51
52
|
|
|
52
53
|
```typescript
|
|
53
|
-
import { createDefaultTransports
|
|
54
|
-
import { createConfig
|
|
54
|
+
import { createDefaultTransports } from '@tuwaio/satellite-evm';
|
|
55
|
+
import { createConfig } from '@wagmi/core';
|
|
56
|
+
import { injected } from '@wagmi/connectors';
|
|
55
57
|
import { mainnet, sepolia } from 'viem/chains';
|
|
56
58
|
import type { Chain } from 'viem/chains';
|
|
57
59
|
|
|
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
60
|
export const appEVMChains = [
|
|
65
61
|
mainnet,
|
|
66
62
|
sepolia,
|
|
67
63
|
] as readonly [Chain, ...Chain[]];
|
|
68
64
|
|
|
69
65
|
export const wagmiConfig = createConfig({
|
|
70
|
-
connectors:
|
|
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
|
-
}),
|
|
66
|
+
connectors: [injected()],
|
|
77
67
|
transports: createDefaultTransports(appEVMChains), // Automatically creates http transports
|
|
78
68
|
chains: appEVMChains,
|
|
79
69
|
ssr: true, // Enable SSR support if needed (e.g., in Next.js)
|
|
@@ -102,7 +92,7 @@ const evmAdapter = satelliteEVMAdapter(wagmiConfig);
|
|
|
102
92
|
Use the created adapter within the `SatelliteConnectProvider` from `@tuwaio/satellite-react`.
|
|
103
93
|
|
|
104
94
|
```tsx
|
|
105
|
-
import { SatelliteConnectProvider,
|
|
95
|
+
import { SatelliteConnectProvider, EVMConnectorsWatcher } from '@tuwaio/satellite-react';
|
|
106
96
|
import { WagmiProvider } from 'wagmi';
|
|
107
97
|
import { satelliteEVMAdapter } from '@tuwaio/satellite-evm';
|
|
108
98
|
import { wagmiConfig } from './your-wagmi-config';
|
|
@@ -120,7 +110,7 @@ function AppProviders({ children }: { children: React.ReactNode }) {
|
|
|
120
110
|
adapter={evmAdapter} // Pass the EVM adapter
|
|
121
111
|
autoConnect={true} // Optional: enable auto-connect
|
|
122
112
|
>
|
|
123
|
-
<
|
|
113
|
+
<EVMConnectorsWatcher wagmiConfig={wagmiConfig} /> {/* Manages EVM wallet state */}
|
|
124
114
|
{children}
|
|
125
115
|
</SatelliteConnectProvider>
|
|
126
116
|
</QueryClientProvider>
|
|
@@ -142,7 +132,7 @@ This ensures that the SIWE flow is automatically triggered after a successful wa
|
|
|
142
132
|
|
|
143
133
|
import { useSiweAuth, SiweNextAuthProvider } from '@tuwaio/satellite-siwe-next-auth';
|
|
144
134
|
import { SatelliteConnectProvider } from '@tuwaio/satellite-react';
|
|
145
|
-
import {
|
|
135
|
+
import { EVMConnectorsWatcher } from '@tuwaio/satellite-react/evm';
|
|
146
136
|
import { satelliteEVMAdapter } from '@tuwaio/satellite-evm';
|
|
147
137
|
import { WagmiProvider } from 'wagmi';
|
|
148
138
|
import { wagmiConfig } from './your-wagmi-config'; // Your Wagmi config
|
|
@@ -163,7 +153,7 @@ function App() {
|
|
|
163
153
|
autoConnect={true}
|
|
164
154
|
>
|
|
165
155
|
{/* Pass siwe state to watcher for handling disconnections on SIWE rejection */}
|
|
166
|
-
<
|
|
156
|
+
<EVMConnectorsWatcher wagmiConfig={wagmiConfig} siwe={{ isSignedIn, isRejected, enabled: siweEnabled }} />
|
|
167
157
|
{/* Your application components */}
|
|
168
158
|
</SatelliteConnectProvider>
|
|
169
159
|
);
|
|
@@ -189,35 +179,9 @@ function RootLayout({ children }: { children: React.ReactNode }) {
|
|
|
189
179
|
|
|
190
180
|
## 🛠️ Core Utilities
|
|
191
181
|
|
|
192
|
-
- **`initAllConnectors`**: Initializes default EVM connectors (`injected`, `coinbaseWallet`, `safe`, `walletConnect` if `projectId` is provided, and a development `impersonated` connector).
|
|
193
182
|
- **`createDefaultTransports`**: Helper to create default `http` transports for each chain in your `wagmiConfig`.
|
|
194
183
|
- **`checkIsWalletAddressContract`**: Utility to check if a connected address is a smart contract address. The result is cached in memory.
|
|
195
184
|
|
|
196
|
-
-----
|
|
197
|
-
|
|
198
|
-
## 🌐 Supported Wallets
|
|
199
|
-
|
|
200
|
-
- MetaMask
|
|
201
|
-
- WalletConnect v2
|
|
202
|
-
- Coinbase Wallet
|
|
203
|
-
- Safe (Gnosis Safe)
|
|
204
|
-
- And other EVM-compatible wallets injected into the browser
|
|
205
|
-
|
|
206
|
-
-----
|
|
207
|
-
|
|
208
|
-
## 🔗 Chain Support
|
|
209
|
-
|
|
210
|
-
Supports any EVM chain configured in your `wagmiConfig`. Examples:
|
|
211
|
-
|
|
212
|
-
- Ethereum Mainnet
|
|
213
|
-
- Sepolia Testnet
|
|
214
|
-
- Polygon
|
|
215
|
-
- Arbitrum
|
|
216
|
-
- Optimism
|
|
217
|
-
- And other EVM-compatible networks
|
|
218
|
-
|
|
219
|
-
---
|
|
220
|
-
|
|
221
185
|
## 🤝 Contributing & Support
|
|
222
186
|
|
|
223
187
|
Contributions are welcome! Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)**.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseConnector, SatelliteAdapter } from '@tuwaio/satellite-core';
|
|
2
|
+
import * as _wagmi_core from '@wagmi/core';
|
|
2
3
|
import { Connector, CreateConnectorFn, Config, CreateConfigParameters } from '@wagmi/core';
|
|
3
|
-
import { GeminiParameters, PortoParameters } from '@wagmi/connectors';
|
|
4
4
|
import { Chain } from 'viem/chains';
|
|
5
5
|
import { Transport } from 'viem';
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ type ConnectorEVM = Connector<CreateConnectorFn>;
|
|
|
9
9
|
/**
|
|
10
10
|
* Extended wallet interface for EVM-specific properties
|
|
11
11
|
*/
|
|
12
|
-
interface
|
|
12
|
+
interface EVMConnection extends BaseConnector {
|
|
13
13
|
/** Connected Wallet Standard account */
|
|
14
14
|
connector?: ConnectorEVM;
|
|
15
15
|
}
|
|
@@ -19,7 +19,7 @@ interface EVMWallet extends BaseWallet {
|
|
|
19
19
|
*
|
|
20
20
|
* @remarks
|
|
21
21
|
* This adapter implements the SatelliteAdapter interface for Ethereum Virtual Machine (EVM) compatible chains.
|
|
22
|
-
* It uses wagmi as the underlying library for
|
|
22
|
+
* It uses wagmi as the underlying library for connector connections and chain interactions.
|
|
23
23
|
*
|
|
24
24
|
* @param config - Wagmi configuration object containing chain and connector settings
|
|
25
25
|
* @param signInWithSiwe - Optional function for signing in with SIWE
|
|
@@ -30,19 +30,39 @@ interface EVMWallet extends BaseWallet {
|
|
|
30
30
|
* ```typescript
|
|
31
31
|
* const config = createConfig({
|
|
32
32
|
* chains: [mainnet, polygon],
|
|
33
|
-
* connectors: [
|
|
34
|
-
* new InjectedConnector(),
|
|
35
|
-
* new WalletConnectConnector({ projectId: 'your_project_id' })
|
|
36
|
-
* ]
|
|
33
|
+
* connectors: [injected()]
|
|
37
34
|
* });
|
|
38
35
|
*
|
|
39
36
|
* const evmAdapter = satelliteEVMAdapter(config);
|
|
40
37
|
* ```
|
|
41
38
|
*/
|
|
42
|
-
declare function satelliteEVMAdapter(config: Config, signInWithSiwe?: () => Promise<void>): SatelliteAdapter<ConnectorEVM>;
|
|
39
|
+
declare function satelliteEVMAdapter(config: Config, signInWithSiwe?: () => Promise<void>): SatelliteAdapter<ConnectorEVM, EVMConnection>;
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
|
-
* Configuration
|
|
42
|
+
* Configuration parameters for impersonated wallet connector
|
|
43
|
+
*/
|
|
44
|
+
type ImpersonatedParameters = {
|
|
45
|
+
/** Optional feature flags for testing error scenarios */
|
|
46
|
+
features?: {
|
|
47
|
+
/** Simulate connection error */
|
|
48
|
+
connectError?: boolean | Error;
|
|
49
|
+
/** Simulate chain switching error */
|
|
50
|
+
switchChainError?: boolean | Error;
|
|
51
|
+
/** Simulate message signing error */
|
|
52
|
+
signMessageError?: boolean | Error;
|
|
53
|
+
/** Simulate typed data signing error */
|
|
54
|
+
signTypedDataError?: boolean | Error;
|
|
55
|
+
/** Enable reconnection behavior */
|
|
56
|
+
reconnect?: boolean;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
declare function impersonated(parameters: ImpersonatedParameters): _wagmi_core.CreateConnectorFn<provider, properties, storageItem>;
|
|
60
|
+
declare namespace impersonated {
|
|
61
|
+
var type: "impersonated";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Configuration options for Safe SDK
|
|
46
66
|
* @remarks
|
|
47
67
|
* Defines allowed domains and debug mode for Safe integration
|
|
48
68
|
*/
|
|
@@ -52,40 +72,6 @@ declare const safeSdkOptions: {
|
|
|
52
72
|
/** Enable debug mode */
|
|
53
73
|
debug: boolean;
|
|
54
74
|
};
|
|
55
|
-
/**
|
|
56
|
-
* Initializes all supported wallet connectors based on provided configuration
|
|
57
|
-
*
|
|
58
|
-
* @remarks
|
|
59
|
-
* Creates instances of various wallet connectors including:
|
|
60
|
-
* - Injected wallets (e.g., MetaMask, Phantom, Trust Wallet, etc.)
|
|
61
|
-
* - Coinbase Wallet
|
|
62
|
-
* - Gnosis Safe
|
|
63
|
-
* - WalletConnect (if projectId provided)
|
|
64
|
-
* - Impersonated wallet (for development/testing)
|
|
65
|
-
*
|
|
66
|
-
* The order of connectors in the returned array determines their priority
|
|
67
|
-
* in the wallet connection UI.
|
|
68
|
-
*
|
|
69
|
-
* @param props - Configuration options for initializing connectors
|
|
70
|
-
* @param geminiParameters - Optional parameters for Gemini wallet connector
|
|
71
|
-
* @param portoParameters - Optional parameters for Porto wallet connector
|
|
72
|
-
* @returns Array of wallet connector instances
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* const connectors = initAllConnectors({
|
|
77
|
-
* appName: "My dApp",
|
|
78
|
-
* projectId: "wallet_connect_project_id",
|
|
79
|
-
* appUrl: "https://mydapp.com",
|
|
80
|
-
* appLogoUrl: "https://mydapp.com/logo.png"
|
|
81
|
-
* });
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
declare const initAllConnectors: ({ initialParameters, geminiParameters, portoParameters, }: {
|
|
85
|
-
initialParameters: ConnectorsInitProps;
|
|
86
|
-
geminiParameters?: GeminiParameters;
|
|
87
|
-
portoParameters?: PortoParameters;
|
|
88
|
-
}) => readonly CreateConnectorFn[];
|
|
89
75
|
|
|
90
76
|
/**
|
|
91
77
|
* Checks if a given wallet address is a smart contract by examining its bytecode
|
|
@@ -136,4 +122,4 @@ declare function checkIsWalletAddressContract({ config, address, chainId, chains
|
|
|
136
122
|
*/
|
|
137
123
|
declare const createDefaultTransports: (chains: CreateConfigParameters["chains"]) => Record<number, Transport>;
|
|
138
124
|
|
|
139
|
-
export { type ConnectorEVM, type
|
|
125
|
+
export { type ConnectorEVM, type EVMConnection, type ImpersonatedParameters, checkIsWalletAddressContract, createDefaultTransports, impersonated, safeSdkOptions, satelliteEVMAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseConnector, SatelliteAdapter } from '@tuwaio/satellite-core';
|
|
2
|
+
import * as _wagmi_core from '@wagmi/core';
|
|
2
3
|
import { Connector, CreateConnectorFn, Config, CreateConfigParameters } from '@wagmi/core';
|
|
3
|
-
import { GeminiParameters, PortoParameters } from '@wagmi/connectors';
|
|
4
4
|
import { Chain } from 'viem/chains';
|
|
5
5
|
import { Transport } from 'viem';
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ type ConnectorEVM = Connector<CreateConnectorFn>;
|
|
|
9
9
|
/**
|
|
10
10
|
* Extended wallet interface for EVM-specific properties
|
|
11
11
|
*/
|
|
12
|
-
interface
|
|
12
|
+
interface EVMConnection extends BaseConnector {
|
|
13
13
|
/** Connected Wallet Standard account */
|
|
14
14
|
connector?: ConnectorEVM;
|
|
15
15
|
}
|
|
@@ -19,7 +19,7 @@ interface EVMWallet extends BaseWallet {
|
|
|
19
19
|
*
|
|
20
20
|
* @remarks
|
|
21
21
|
* This adapter implements the SatelliteAdapter interface for Ethereum Virtual Machine (EVM) compatible chains.
|
|
22
|
-
* It uses wagmi as the underlying library for
|
|
22
|
+
* It uses wagmi as the underlying library for connector connections and chain interactions.
|
|
23
23
|
*
|
|
24
24
|
* @param config - Wagmi configuration object containing chain and connector settings
|
|
25
25
|
* @param signInWithSiwe - Optional function for signing in with SIWE
|
|
@@ -30,19 +30,39 @@ interface EVMWallet extends BaseWallet {
|
|
|
30
30
|
* ```typescript
|
|
31
31
|
* const config = createConfig({
|
|
32
32
|
* chains: [mainnet, polygon],
|
|
33
|
-
* connectors: [
|
|
34
|
-
* new InjectedConnector(),
|
|
35
|
-
* new WalletConnectConnector({ projectId: 'your_project_id' })
|
|
36
|
-
* ]
|
|
33
|
+
* connectors: [injected()]
|
|
37
34
|
* });
|
|
38
35
|
*
|
|
39
36
|
* const evmAdapter = satelliteEVMAdapter(config);
|
|
40
37
|
* ```
|
|
41
38
|
*/
|
|
42
|
-
declare function satelliteEVMAdapter(config: Config, signInWithSiwe?: () => Promise<void>): SatelliteAdapter<ConnectorEVM>;
|
|
39
|
+
declare function satelliteEVMAdapter(config: Config, signInWithSiwe?: () => Promise<void>): SatelliteAdapter<ConnectorEVM, EVMConnection>;
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
|
-
* Configuration
|
|
42
|
+
* Configuration parameters for impersonated wallet connector
|
|
43
|
+
*/
|
|
44
|
+
type ImpersonatedParameters = {
|
|
45
|
+
/** Optional feature flags for testing error scenarios */
|
|
46
|
+
features?: {
|
|
47
|
+
/** Simulate connection error */
|
|
48
|
+
connectError?: boolean | Error;
|
|
49
|
+
/** Simulate chain switching error */
|
|
50
|
+
switchChainError?: boolean | Error;
|
|
51
|
+
/** Simulate message signing error */
|
|
52
|
+
signMessageError?: boolean | Error;
|
|
53
|
+
/** Simulate typed data signing error */
|
|
54
|
+
signTypedDataError?: boolean | Error;
|
|
55
|
+
/** Enable reconnection behavior */
|
|
56
|
+
reconnect?: boolean;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
declare function impersonated(parameters: ImpersonatedParameters): _wagmi_core.CreateConnectorFn<provider, properties, storageItem>;
|
|
60
|
+
declare namespace impersonated {
|
|
61
|
+
var type: "impersonated";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Configuration options for Safe SDK
|
|
46
66
|
* @remarks
|
|
47
67
|
* Defines allowed domains and debug mode for Safe integration
|
|
48
68
|
*/
|
|
@@ -52,40 +72,6 @@ declare const safeSdkOptions: {
|
|
|
52
72
|
/** Enable debug mode */
|
|
53
73
|
debug: boolean;
|
|
54
74
|
};
|
|
55
|
-
/**
|
|
56
|
-
* Initializes all supported wallet connectors based on provided configuration
|
|
57
|
-
*
|
|
58
|
-
* @remarks
|
|
59
|
-
* Creates instances of various wallet connectors including:
|
|
60
|
-
* - Injected wallets (e.g., MetaMask, Phantom, Trust Wallet, etc.)
|
|
61
|
-
* - Coinbase Wallet
|
|
62
|
-
* - Gnosis Safe
|
|
63
|
-
* - WalletConnect (if projectId provided)
|
|
64
|
-
* - Impersonated wallet (for development/testing)
|
|
65
|
-
*
|
|
66
|
-
* The order of connectors in the returned array determines their priority
|
|
67
|
-
* in the wallet connection UI.
|
|
68
|
-
*
|
|
69
|
-
* @param props - Configuration options for initializing connectors
|
|
70
|
-
* @param geminiParameters - Optional parameters for Gemini wallet connector
|
|
71
|
-
* @param portoParameters - Optional parameters for Porto wallet connector
|
|
72
|
-
* @returns Array of wallet connector instances
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* const connectors = initAllConnectors({
|
|
77
|
-
* appName: "My dApp",
|
|
78
|
-
* projectId: "wallet_connect_project_id",
|
|
79
|
-
* appUrl: "https://mydapp.com",
|
|
80
|
-
* appLogoUrl: "https://mydapp.com/logo.png"
|
|
81
|
-
* });
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
declare const initAllConnectors: ({ initialParameters, geminiParameters, portoParameters, }: {
|
|
85
|
-
initialParameters: ConnectorsInitProps;
|
|
86
|
-
geminiParameters?: GeminiParameters;
|
|
87
|
-
portoParameters?: PortoParameters;
|
|
88
|
-
}) => readonly CreateConnectorFn[];
|
|
89
75
|
|
|
90
76
|
/**
|
|
91
77
|
* Checks if a given wallet address is a smart contract by examining its bytecode
|
|
@@ -136,4 +122,4 @@ declare function checkIsWalletAddressContract({ config, address, chainId, chains
|
|
|
136
122
|
*/
|
|
137
123
|
declare const createDefaultTransports: (chains: CreateConfigParameters["chains"]) => Record<number, Transport>;
|
|
138
124
|
|
|
139
|
-
export { type ConnectorEVM, type
|
|
125
|
+
export { type ConnectorEVM, type EVMConnection, type ImpersonatedParameters, checkIsWalletAddressContract, createDefaultTransports, impersonated, safeSdkOptions, satelliteEVMAdapter };
|
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'),
|
|
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'),utils=require('viem/utils');var w=new Map;async function E({config:o,address:n,chainId:e,chains:r}){if(w.has(n))return w.get(n);if(orbitEvm.createViemClient(e,r)){let t=!!await core.getBytecode(o,{address:n});return w.set(n,t),t}else return false}function de(o,n){if(!o)throw new Error("Satellite EVM adapter requires a wagmi config object.");return {key:orbitCore.OrbitAdapter.EVM,connect:async({connectorType:e,chainId:r})=>{let s=core.getConnectors(o).find(t=>orbitCore.getConnectorTypeFromName(orbitCore.OrbitAdapter.EVM,orbitCore.formatConnectorName(t.name))===e);if(!s)throw new Error("Cannot find connector with this wallet type");try{await core.connect(o,{connector:s,chainId:r}),n&&!orbitCore.isSafeApp&&orbitCore.formatConnectorName(s.name)!=="porto"&&orbitCore.formatConnectorName(s.name)!=="geminiwallet"&&orbitCore.formatConnectorName(s.name)!=="Impersonatedconnector"&&await n();let t=core.getConnection(o);return {connectorType:e,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,icon:s?.icon?.trim(),connector:s}}catch(t){throw new Error(t instanceof Error?t.message:String(t))}},disconnect:async e=>{if(e&&e.isConnected)await core.disconnect(o,{connector:e?.connector});else {let r=core.getConnectors(o);await Promise.allSettled(r.map(async a=>{await core.disconnect(o,{connector:a});}));}},getConnectors:()=>{let e=core.getConnectors(o);return {adapter:orbitCore.OrbitAdapter.EVM,connectors:e.map(r=>r)}},checkAndSwitchNetwork:async e=>await orbitEvm.checkAndSwitchChain(Number(e),o),getBalance:async(e,r)=>{let a=await core.getBalance(o,{address:e,chainId:Number(r)});return {value:viem.formatUnits(a.value,a.decimals),symbol:a.symbol}},getExplorerUrl:e=>{let{chain:r}=core.getConnection(o),a=r?.blockExplorers?.default.url;return e?`${a}/${e}`:a},getName:e=>orbitEvm.getName(e),getAvatar:e=>orbitEvm.getAvatar(e),getAddress:e=>orbitEvm.getAddress(e),checkIsContractAddress:async({address:e,chainId:r})=>{let a=core.getChains(o);return await E({config:o,address:e,chainId:r,chains:a})},getSafeConnectorChainId:async()=>{let r=core.getConnectors(o).find(a=>a.name==="Safe");if(r)return await r.getChainId()},switchConnection:async e=>{let a=core.getConnectors(o).find(s=>orbitCore.getConnectorTypeFromName(orbitCore.OrbitAdapter.EVM,orbitCore.formatConnectorName(s.name))===e);if(!a)throw new Error(`Cannot find connector with type: ${e}`);try{await core.switchConnection(o,{connector:a});}catch(s){throw new Error(`Failed to switch to connector ${e}: ${s instanceof Error?s.message:String(s)}`)}}}}q.type="impersonated";function q(o){let n=o.features??{},e=false,r,a;return core.createConnector(s=>({id:"impersonated",name:"Impersonated Connector",type:q.type,async setup(){r=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"}),h=await this.getChainId();return t&&h!==t&&(h=(await this.switchChain({chainId:t})).id),e=true,{accounts:d,chainId:h}},async disconnect(){e=false,a=void 0;},async getAccounts(){if(!e)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 e?!!(await this.getAccounts()).length:false},async switchChain({chainId:t}){let c=s.chains.find(h=>h.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"),e=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:m})=>{if(i==="eth_chainId")return viem.numberToHex(r);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;r=viem.fromHex(m[0].chainId,"number"),this.onChainChanged(r.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",m=[m[1],m[0]];}let C={method:i,params:m},{error:g,result:R}=await utils.rpc.http(d,{body:C});if(g)throw new viem.RpcRequestError({body:C,error:g,url:d});return R}})({retryCount:1})}}))}var we={allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/,/metissafe.tech$/],debug:false};var be=o=>o.reduce((n,e)=>{let r=e.id;return n[r]=viem.http(),n},{});exports.checkIsWalletAddressContract=E;exports.createDefaultTransports=be;exports.impersonated=q;exports.safeSdkOptions=we;exports.satelliteEVMAdapter=de;//# 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","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","initialParameters","geminiParameters","portoParameters","injectedConnector","injected","baseConnector","baseAccount","gnosisSafeConnector","safe","geminiConnector","gemini","portoConnector","porto","wcMetadata","walletConnectConnector","walletConnect","createDefaultTransports","acc","key","http"],"mappings":"kPAUA,IAAMA,CAAAA,CAAe,IAAI,GAAA,CA8BzB,eAAsBC,CAAAA,CAA6B,CACjD,MAAA,CAAAC,EACA,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,CAAA,CAE7C,CAOV,IAAME,EAAa,CAAC,CALQ,MAAMC,gBAAAA,CAAYN,CAAAA,CAAQ,CACpD,OAAA,CAASC,CACX,CAAC,CAAA,CAID,OAAAH,CAAAA,CAAa,GAAA,CAAIG,CAAAA,CAASI,CAAU,CAAA,CAE7BA,CACT,MAEE,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,OAAA,CAAS,MAAO,CAAE,UAAA,CAAAC,CAAAA,CAAY,QAAAR,CAAQ,CAAA,GAAM,CAE1C,IAAMS,CAAAA,CADaC,kBAAAA,CAAcZ,CAAM,CAAA,CACV,KAC1BW,CAAAA,EACCE,wCAAAA,CAA+BJ,sBAAAA,CAAa,GAAA,CAAKK,0BAAAA,CAAiBH,CAAAA,CAAU,IAAI,CAAC,CAAA,GAAMD,CAC3F,CAAA,CACA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AiBC,gBAAAA,CAAMV,CAAe,CAAA,CAEtC7C,CAAAA,CAAa,CACjB8C,CAAAA,CACAE,EACAE,CAAAA,CACAE,CAAAA,CACAE,CAAAA,CACAxC,CAAAA,CAAa,EAAE,CACjB,CAAA,CAGM0C,EACJb,CAAAA,CAAkB,MAAA,EAAUA,CAAAA,CAAkB,QAAA,EAAYA,CAAAA,CAAkB,OAAA,EAAWA,CAAAA,CAAkB,WAAA,CACrG,CACE,IAAA,CAAMA,CAAAA,CAAkB,OAAA,CACxB,WAAA,CAAaA,CAAAA,CAAkB,WAAA,CAC/B,GAAA,CAAKA,CAAAA,CAAkB,OACvB,KAAA,CAAOA,CAAAA,CAAkB,QAC3B,CAAA,CACA,MAAA,CAEN,GAAIA,CAAAA,CAAkB,SAAA,CAAW,CAC/B,IAAMc,CAAAA,CAAyBC,wBAAAA,CAAc,CAC3C,SAAA,CAAWf,CAAAA,CAAkB,SAAA,CAC7B,QAAA,CAAUa,CACZ,CAAC,CAAA,CAEDxD,CAAAA,CAAW,IAAA,CAAKyD,CAAsB,EACxC,CAEA,OAAOzD,CACT,ECpGO,IAAM2D,EAAAA,CAA2BhF,CAAAA,EAC/BA,EAAO,MAAA,CACZ,CAACiF,CAAAA,CAAKtD,CAAAA,GAAU,CACd,IAAMuD,CAAAA,CAAMvD,CAAAA,CAAM,GAClB,OAAAsD,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 (\n signInWithSiwe &&\n !isSafeApp &&\n formatWalletName(connector.name) !== 'porto' &&\n formatWalletName(connector.name) !== 'geminiwallet'\n ) {\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 {\n baseAccount,\n gemini,\n GeminiParameters,\n injected,\n porto,\n PortoParameters,\n safe,\n walletConnect,\n} 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 * @param geminiParameters - Optional parameters for Gemini wallet connector\n * @param portoParameters - Optional parameters for Porto wallet connector\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 = ({\n initialParameters,\n geminiParameters,\n portoParameters,\n}: {\n initialParameters: ConnectorsInitProps;\n geminiParameters?: GeminiParameters;\n portoParameters?: PortoParameters;\n}): readonly CreateConnectorFn[] => {\n const injectedConnector = injected();\n const baseConnector = baseAccount({\n appName: initialParameters.appName,\n appLogoUrl: initialParameters.appLogoUrl,\n });\n const gnosisSafeConnector = safe({\n ...safeSdkOptions,\n });\n const geminiConnector = gemini({\n appMetadata: {\n appName: initialParameters?.appName,\n ...geminiParameters?.appMetadata,\n },\n });\n const portoConnector = porto(portoParameters);\n\n const connectors = [\n injectedConnector,\n baseConnector,\n gnosisSafeConnector,\n geminiConnector,\n portoConnector,\n impersonated({}),\n ];\n\n // WalletConnect metadata configuration\n const wcMetadata =\n initialParameters.appUrl && initialParameters.appIcons && initialParameters.appName && initialParameters.description\n ? {\n name: initialParameters.appName,\n description: initialParameters.description,\n url: initialParameters.appUrl,\n icons: initialParameters.appIcons,\n }\n : undefined;\n\n if (initialParameters.projectId) {\n const walletConnectConnector = walletConnect({\n projectId: initialParameters.projectId,\n metadata: wcMetadata,\n });\n // @ts-expect-error - WalletConnect has unique types for connectors and connectorsOptions\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","connectorType","connector","getConnectors","getConnectorTypeFromName","formatConnectorName","connect","isSafeApp","account","getConnection","zeroAddress","mainnet","e","activeWallet","disconnect","connectors","checkAndSwitchChain","balance","getBalance","formatUnits","url","chain","baseExplorerLink","getName","name","getAvatar","getAddress","getChains","safeConnector","c","switchConnection","impersonated","parameters","features","connected","connectedChainId","accountAddress","createConnector","UserRejectedRequestError","request","accounts","currentChainId","hexChainId","fromHex","x","SwitchChainError","ChainNotConfiguredError","numberToHex","impersonatedHelpers","custom","method","params","body","error","result","rpc","RpcRequestError","safeSdkOptions","createDefaultTransports","acc","key","http"],"mappings":"0MAUA,IAAM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AY,CAAE,CAAC,CAC9C,CACF,CAAA,CAAE,CACJ,CC/OO,IAAMG,EAAAA,CAAiB,CAE5B,cAAA,CAAgB,CAAC,iBAAA,CAAmB,kBAAA,CAAoB,iBAAiB,CAAA,CAEzE,KAAA,CAAO,KACT,ECCO,IAAMC,EAAAA,CAA2BhE,CAAAA,EAC/BA,EAAO,MAAA,CACZ,CAACiE,CAAAA,CAAKtC,CAAAA,GAAU,CACd,IAAMuC,CAAAA,CAAMvC,CAAAA,CAAM,GAClB,OAAAsC,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 { formatConnectorName, getConnectorTypeFromName, isSafeApp, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { checkAndSwitchChain, getAddress, getAvatar, getName } from '@tuwaio/orbit-evm';\nimport { SatelliteAdapter } from '@tuwaio/satellite-core';\nimport {\n Config,\n connect,\n disconnect,\n getBalance,\n getChains,\n getConnection,\n getConnectors,\n switchConnection,\n} from '@wagmi/core';\nimport { Address, formatUnits, zeroAddress } from 'viem';\nimport { mainnet } from 'viem/chains';\n\nimport { ConnectorEVM, EVMConnection } 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 connector 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: [injected()]\n * });\n *\n * const evmAdapter = satelliteEVMAdapter(config);\n * ```\n */\nexport function satelliteEVMAdapter(\n config: Config,\n signInWithSiwe?: () => Promise<void>,\n): SatelliteAdapter<ConnectorEVM, EVMConnection> {\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 connector\n * @returns Connected connector information\n * @throws Error if connector not found or connection fails\n */\n connect: async ({ connectorType, chainId }) => {\n const connectors = getConnectors(config);\n const connector = connectors.find(\n (connector) =>\n getConnectorTypeFromName(OrbitAdapter.EVM, formatConnectorName(connector.name)) === connectorType,\n );\n if (!connector) throw new Error('Cannot find connector with this wallet type');\n\n try {\n await connect(config, { connector, chainId: chainId as number });\n if (\n signInWithSiwe &&\n !isSafeApp &&\n formatConnectorName(connector.name) !== 'porto' &&\n formatConnectorName(connector.name) !== 'geminiwallet' &&\n formatConnectorName(connector.name) !== 'Impersonatedconnector'\n ) {\n await signInWithSiwe();\n }\n const account = getConnection(config);\n\n return {\n connectorType,\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 icon: 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 connector\n */\n disconnect: async (activeWallet) => {\n if (activeWallet && activeWallet.isConnected) {\n await disconnect(config, { connector: (activeWallet as EVMConnection)?.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 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 connector 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 } = getConnection(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 * Resolves ENS name to address\n * @param name - ENS name to resolve\n * @returns Address if available, null otherwise\n */\n getAddress: (name: string) => getAddress(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 checkIsContractAddress: 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 switchConnection: async (connectorType) => {\n const connectors = getConnectors(config);\n const connector = connectors.find(\n (c) => getConnectorTypeFromName(OrbitAdapter.EVM, formatConnectorName(c.name)) === connectorType,\n );\n\n if (!connector) {\n throw new Error(`Cannot find connector with type: ${connectorType}`);\n }\n\n try {\n await switchConnection(config, { connector });\n } catch (e) {\n throw new Error(\n `Failed to switch to connector ${connectorType}: ${e instanceof Error ? e.message : String(e)}`,\n );\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","/**\n * Configuration options for 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\nexport * from './ImpersonatedConnector';\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,
|
|
1
|
+
import {OrbitAdapter,getConnectorTypeFromName,formatConnectorName,isSafeApp,impersonatedHelpers}from'@tuwaio/orbit-core';import {createViemClient,getAddress,getAvatar,getName,checkAndSwitchChain}from'@tuwaio/orbit-evm';import {getBytecode,getConnectors,switchConnection,getChains,getConnection,getBalance,disconnect,connect,createConnector,ChainNotConfiguredError}from'@wagmi/core';import {formatUnits,zeroAddress,custom,numberToHex,UserRejectedRequestError,fromHex,RpcRequestError,getAddress as getAddress$1,SwitchChainError,http}from'viem';import {mainnet}from'viem/chains';import {rpc}from'viem/utils';var w=new Map;async function E({config:o,address:n,chainId:e,chains:r}){if(w.has(n))return w.get(n);if(createViemClient(e,r)){let t=!!await getBytecode(o,{address:n});return w.set(n,t),t}else return false}function de(o,n){if(!o)throw new Error("Satellite EVM adapter requires a wagmi config object.");return {key:OrbitAdapter.EVM,connect:async({connectorType:e,chainId:r})=>{let s=getConnectors(o).find(t=>getConnectorTypeFromName(OrbitAdapter.EVM,formatConnectorName(t.name))===e);if(!s)throw new Error("Cannot find connector with this wallet type");try{await connect(o,{connector:s,chainId:r}),n&&!isSafeApp&&formatConnectorName(s.name)!=="porto"&&formatConnectorName(s.name)!=="geminiwallet"&&formatConnectorName(s.name)!=="Impersonatedconnector"&&await n();let t=getConnection(o);return {connectorType:e,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,icon:s?.icon?.trim(),connector:s}}catch(t){throw new Error(t instanceof Error?t.message:String(t))}},disconnect:async e=>{if(e&&e.isConnected)await disconnect(o,{connector:e?.connector});else {let r=getConnectors(o);await Promise.allSettled(r.map(async a=>{await disconnect(o,{connector:a});}));}},getConnectors:()=>{let e=getConnectors(o);return {adapter:OrbitAdapter.EVM,connectors:e.map(r=>r)}},checkAndSwitchNetwork:async e=>await checkAndSwitchChain(Number(e),o),getBalance:async(e,r)=>{let a=await getBalance(o,{address:e,chainId:Number(r)});return {value:formatUnits(a.value,a.decimals),symbol:a.symbol}},getExplorerUrl:e=>{let{chain:r}=getConnection(o),a=r?.blockExplorers?.default.url;return e?`${a}/${e}`:a},getName:e=>getName(e),getAvatar:e=>getAvatar(e),getAddress:e=>getAddress(e),checkIsContractAddress:async({address:e,chainId:r})=>{let a=getChains(o);return await E({config:o,address:e,chainId:r,chains:a})},getSafeConnectorChainId:async()=>{let r=getConnectors(o).find(a=>a.name==="Safe");if(r)return await r.getChainId()},switchConnection:async e=>{let a=getConnectors(o).find(s=>getConnectorTypeFromName(OrbitAdapter.EVM,formatConnectorName(s.name))===e);if(!a)throw new Error(`Cannot find connector with type: ${e}`);try{await switchConnection(o,{connector:a});}catch(s){throw new Error(`Failed to switch to connector ${e}: ${s instanceof Error?s.message:String(s)}`)}}}}q.type="impersonated";function q(o){let n=o.features??{},e=false,r,a;return createConnector(s=>({id:"impersonated",name:"Impersonated Connector",type:q.type,async setup(){r=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"}),h=await this.getChainId();return t&&h!==t&&(h=(await this.switchChain({chainId:t})).id),e=true,{accounts:d,chainId:h}},async disconnect(){e=false,a=void 0;},async getAccounts(){if(!e)throw new Error("Not connected connector");let{request:t}=await this.getProvider();return (await t({method:"eth_accounts"})).map(getAddress$1)},async getChainId(){let{request:t}=await this.getProvider(),c=await t({method:"eth_chainId"});return fromHex(c,"number")},async isAuthorized(){return e?!!(await this.getAccounts()).length:false},async switchChain({chainId:t}){let c=s.chains.find(h=>h.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$1)});},onChainChanged(t){let c=Number(t);s.emitter.emit("change",{chainId:c});},async onDisconnect(){s.emitter.emit("disconnect"),e=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:m})=>{if(i==="eth_chainId")return numberToHex(r);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;r=fromHex(m[0].chainId,"number"),this.onChainChanged(r.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",m=[m[1],m[0]];}let C={method:i,params:m},{error:g,result:R}=await rpc.http(d,{body:C});if(g)throw new RpcRequestError({body:C,error:g,url:d});return R}})({retryCount:1})}}))}var we={allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/,/metissafe.tech$/],debug:false};var be=o=>o.reduce((n,e)=>{let r=e.id;return n[r]=http(),n},{});export{E as checkIsWalletAddressContract,be as createDefaultTransports,q as impersonated,we as safeSdkOptions,de as satelliteEVMAdapter};//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.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","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","initialParameters","geminiParameters","portoParameters","injectedConnector","injected","baseConnector","baseAccount","gnosisSafeConnector","safe","geminiConnector","gemini","portoConnector","porto","wcMetadata","walletConnectConnector","walletConnect","createDefaultTransports","acc","key","http"],"mappings":"soBAUA,IAAMA,CAAAA,CAAe,IAAI,GAAA,CA8BzB,eAAsBC,CAAAA,CAA6B,CACjD,MAAA,CAAAC,EACA,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,gBAAAA,CAAiBF,CAAAA,CAAmBC,CAAM,CAAA,CAE7C,CAOV,IAAME,EAAa,CAAC,CALQ,MAAMC,WAAAA,CAAYN,CAAAA,CAAQ,CACpD,OA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zD,CACT,ECpGO,IAAM2D,EAAAA,CAA2BhF,CAAAA,EAC/BA,EAAO,MAAA,CACZ,CAACiF,CAAAA,CAAKtD,CAAAA,GAAU,CACd,IAAMuD,CAAAA,CAAMvD,CAAAA,CAAM,GAClB,OAAAsD,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 (\n signInWithSiwe &&\n !isSafeApp &&\n formatWalletName(connector.name) !== 'porto' &&\n formatWalletName(connector.name) !== 'geminiwallet'\n ) {\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 {\n baseAccount,\n gemini,\n GeminiParameters,\n injected,\n porto,\n PortoParameters,\n safe,\n walletConnect,\n} 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 * @param geminiParameters - Optional parameters for Gemini wallet connector\n * @param portoParameters - Optional parameters for Porto wallet connector\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 = ({\n initialParameters,\n geminiParameters,\n portoParameters,\n}: {\n initialParameters: ConnectorsInitProps;\n geminiParameters?: GeminiParameters;\n portoParameters?: PortoParameters;\n}): readonly CreateConnectorFn[] => {\n const injectedConnector = injected();\n const baseConnector = baseAccount({\n appName: initialParameters.appName,\n appLogoUrl: initialParameters.appLogoUrl,\n });\n const gnosisSafeConnector = safe({\n ...safeSdkOptions,\n });\n const geminiConnector = gemini({\n appMetadata: {\n appName: initialParameters?.appName,\n ...geminiParameters?.appMetadata,\n },\n });\n const portoConnector = porto(portoParameters);\n\n const connectors = [\n injectedConnector,\n baseConnector,\n gnosisSafeConnector,\n geminiConnector,\n portoConnector,\n impersonated({}),\n ];\n\n // WalletConnect metadata configuration\n const wcMetadata =\n initialParameters.appUrl && initialParameters.appIcons && initialParameters.appName && initialParameters.description\n ? {\n name: initialParameters.appName,\n description: initialParameters.description,\n url: initialParameters.appUrl,\n icons: initialParameters.appIcons,\n }\n : undefined;\n\n if (initialParameters.projectId) {\n const walletConnectConnector = walletConnect({\n projectId: initialParameters.projectId,\n metadata: wcMetadata,\n });\n // @ts-expect-error - WalletConnect has unique types for connectors and connectorsOptions\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","connectorType","connector","getConnectors","getConnectorTypeFromName","formatConnectorName","connect","isSafeApp","account","getConnection","zeroAddress","mainnet","e","activeWallet","disconnect","connectors","checkAndSwitchChain","balance","getBalance","formatUnits","url","chain","baseExplorerLink","getName","name","getAvatar","getAddress","getChains","safeConnector","c","switchConnection","impersonated","parameters","features","connected","connectedChainId","accountAddress","createConnector","UserRejectedRequestError","request","accounts","currentChainId","hexChainId","fromHex","x","SwitchChainError","ChainNotConfiguredError","numberToHex","impersonatedHelpers","custom","method","params","body","error","result","rpc","RpcRequestError","safeSdkOptions","createDefaultTransports","acc","key","http"],"mappings":"6lBAUA,IAAMA,CAAAA,CAAe,IAAI,GAAA,CA8BzB,eAAsBC,CAAAA,CAA6B,CACjD,MAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,EACA,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,gBAAAA,CAAiBF,CAAAA,CAAmBC,CAAM,CAAA,CAE7C,CAOV,IAAME,CAAAA,CAAa,CAAC,CALQ,MAAMC,WAAAA,CAAYN,CAAAA,CAAQ,CACpD,OAAA,CAASC,CACX,CAAC,EAID,OAAAH,CAAAA,CAAa,GAAA,CAAIG,CAAAA,CAASI,CAAU,CAAA,CAE7BA,CACT,CAAA,KAEE,OAAO,MAEX,CCrCO,SAASE,EAAAA,CACdP,CAAAA,CACAQ,CAAAA,CAC+C,CAC/C,GAAI,CAACR,CAAAA,CAAQ,MAAM,IAAI,KAAA,CAAM,uDAAuD,CAAA,CAEp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AAA,CAETC,CAAAA,CAAS,CAAEA,CAAAA,CAAkB,CAAC,CAAA,CAAIA,CAAAA,CAAkB,CAAC,CAAC,EACxD,CAEA,IAAMC,CAAAA,CAAO,CAAE,MAAA,CAAAF,CAAAA,CAAQ,MAAA,CAAAC,CAAO,CAAA,CACxB,CAAE,KAAA,CAAAE,CAAAA,CAAO,MAAA,CAAAC,CAAO,CAAA,CAAI,MAAMC,GAAAA,CAAI,IAAA,CAAKnC,CAAAA,CAAK,CAAE,KAAAgC,CAAK,CAAC,CAAA,CACtD,GAAIC,CAAAA,CAAO,MAAM,IAAIG,eAAAA,CAAgB,CAAE,IAAA,CAAAJ,CAAAA,CAAM,KAAA,CAAAC,CAAAA,CAAO,GAAA,CAAAjC,CAAI,CAAC,EAEzD,OAAOkC,CACT,CACwB,CAAC,CAAA,CAAE,CAAE,UAAA,CAAY,CAAE,CAAC,CAC9C,CACF,CAAA,CAAE,CACJ,CC/OO,IAAMG,EAAAA,CAAiB,CAE5B,cAAA,CAAgB,CAAC,iBAAA,CAAmB,kBAAA,CAAoB,iBAAiB,CAAA,CAEzE,KAAA,CAAO,KACT,ECCO,IAAMC,EAAAA,CAA2BhE,CAAAA,EAC/BA,EAAO,MAAA,CACZ,CAACiE,CAAAA,CAAKtC,CAAAA,GAAU,CACd,IAAMuC,CAAAA,CAAMvC,CAAAA,CAAM,GAClB,OAAAsC,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 { formatConnectorName, getConnectorTypeFromName, isSafeApp, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { checkAndSwitchChain, getAddress, getAvatar, getName } from '@tuwaio/orbit-evm';\nimport { SatelliteAdapter } from '@tuwaio/satellite-core';\nimport {\n Config,\n connect,\n disconnect,\n getBalance,\n getChains,\n getConnection,\n getConnectors,\n switchConnection,\n} from '@wagmi/core';\nimport { Address, formatUnits, zeroAddress } from 'viem';\nimport { mainnet } from 'viem/chains';\n\nimport { ConnectorEVM, EVMConnection } 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 connector 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: [injected()]\n * });\n *\n * const evmAdapter = satelliteEVMAdapter(config);\n * ```\n */\nexport function satelliteEVMAdapter(\n config: Config,\n signInWithSiwe?: () => Promise<void>,\n): SatelliteAdapter<ConnectorEVM, EVMConnection> {\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 connector\n * @returns Connected connector information\n * @throws Error if connector not found or connection fails\n */\n connect: async ({ connectorType, chainId }) => {\n const connectors = getConnectors(config);\n const connector = connectors.find(\n (connector) =>\n getConnectorTypeFromName(OrbitAdapter.EVM, formatConnectorName(connector.name)) === connectorType,\n );\n if (!connector) throw new Error('Cannot find connector with this wallet type');\n\n try {\n await connect(config, { connector, chainId: chainId as number });\n if (\n signInWithSiwe &&\n !isSafeApp &&\n formatConnectorName(connector.name) !== 'porto' &&\n formatConnectorName(connector.name) !== 'geminiwallet' &&\n formatConnectorName(connector.name) !== 'Impersonatedconnector'\n ) {\n await signInWithSiwe();\n }\n const account = getConnection(config);\n\n return {\n connectorType,\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 icon: 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 connector\n */\n disconnect: async (activeWallet) => {\n if (activeWallet && activeWallet.isConnected) {\n await disconnect(config, { connector: (activeWallet as EVMConnection)?.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 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 connector 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 } = getConnection(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 * Resolves ENS name to address\n * @param name - ENS name to resolve\n * @returns Address if available, null otherwise\n */\n getAddress: (name: string) => getAddress(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 checkIsContractAddress: 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 switchConnection: async (connectorType) => {\n const connectors = getConnectors(config);\n const connector = connectors.find(\n (c) => getConnectorTypeFromName(OrbitAdapter.EVM, formatConnectorName(c.name)) === connectorType,\n );\n\n if (!connector) {\n throw new Error(`Cannot find connector with type: ${connectorType}`);\n }\n\n try {\n await switchConnection(config, { connector });\n } catch (e) {\n throw new Error(\n `Failed to switch to connector ${connectorType}: ${e instanceof Error ? e.message : String(e)}`,\n );\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","/**\n * Configuration options for 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\nexport * from './ImpersonatedConnector';\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
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,32 +38,27 @@
|
|
|
38
38
|
"url": "https://github.com/Argeare5"
|
|
39
39
|
}
|
|
40
40
|
],
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"@react-native-async-storage/async-storage": "^2.2.0"
|
|
43
|
-
},
|
|
44
41
|
"peerDependencies": {
|
|
45
|
-
"@wagmi/core": "
|
|
46
|
-
"immer": "
|
|
42
|
+
"@wagmi/core": "3.x.x",
|
|
43
|
+
"immer": "11.x.x",
|
|
47
44
|
"zustand": "5.x.x",
|
|
48
45
|
"viem": "2.x.x",
|
|
49
|
-
"@
|
|
50
|
-
"@tuwaio/orbit-
|
|
51
|
-
"@tuwaio/
|
|
52
|
-
"@tuwaio/satellite-core": ">=0.1"
|
|
46
|
+
"@tuwaio/orbit-core": ">=0.2",
|
|
47
|
+
"@tuwaio/orbit-evm": ">=0.2",
|
|
48
|
+
"@tuwaio/satellite-core": ">=0.2"
|
|
53
49
|
},
|
|
54
50
|
"devDependencies": {
|
|
55
|
-
"@wagmi/core": "^
|
|
56
|
-
"@
|
|
57
|
-
"@tuwaio/orbit-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"tsup": "^8.5.0",
|
|
51
|
+
"@wagmi/core": "^3.0.0",
|
|
52
|
+
"@tuwaio/orbit-core": "^0.2.0",
|
|
53
|
+
"@tuwaio/orbit-evm": "^0.2.1",
|
|
54
|
+
"immer": "^11.0.1",
|
|
55
|
+
"jsdom": "^27.2.0",
|
|
56
|
+
"tsup": "^8.5.1",
|
|
62
57
|
"typescript": "^5.9.3",
|
|
63
|
-
"viem": "^2.
|
|
64
|
-
"vitest": "^4.0.
|
|
65
|
-
"zustand": "^5.0.
|
|
66
|
-
"@tuwaio/satellite-core": "^0.
|
|
58
|
+
"viem": "^2.41.2",
|
|
59
|
+
"vitest": "^4.0.15",
|
|
60
|
+
"zustand": "^5.0.9",
|
|
61
|
+
"@tuwaio/satellite-core": "^0.2.0"
|
|
67
62
|
},
|
|
68
63
|
"scripts": {
|
|
69
64
|
"start": "tsup src/index.ts --watch",
|