@tuwaio/satellite-evm 1.0.0-fix-adapters-independ-alpha.7.0de606d → 1.0.0-fix-adapters-independ-alpha.9.583293c
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/dist/index.d.mts +56 -1
- package/dist/index.d.ts +56 -1
- 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 +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import * as _wagmi_core from '@wagmi/core';
|
|
|
3
3
|
import { Connector, CreateConnectorFn, Config, CreateConfigParameters } from '@wagmi/core';
|
|
4
4
|
import { Chain } from 'viem/chains';
|
|
5
5
|
import { Transport } from 'viem';
|
|
6
|
+
import { ConnectorType } from '@tuwaio/orbit-core';
|
|
6
7
|
|
|
7
8
|
/** EVM-specific connector type */
|
|
8
9
|
type ConnectorEVM = Connector<CreateConnectorFn>;
|
|
@@ -122,4 +123,58 @@ declare function checkIsWalletAddressContract({ config, address, chainId, chains
|
|
|
122
123
|
*/
|
|
123
124
|
declare const createDefaultTransports: (chains: CreateConfigParameters["chains"]) => Record<number, Transport>;
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Callback functions interface for the EVM connections watcher.
|
|
128
|
+
* These callbacks are used to interact with the global state store.
|
|
129
|
+
*/
|
|
130
|
+
interface EVMWatcherCallbacks {
|
|
131
|
+
/** The currently active EVM connection from the global store */
|
|
132
|
+
activeConnection: EVMConnection | undefined;
|
|
133
|
+
/** Function to disconnect a specific connector type */
|
|
134
|
+
disconnect: (connectorType: ConnectorType) => void;
|
|
135
|
+
/** Current connection error state, if any */
|
|
136
|
+
connectionError: string | undefined;
|
|
137
|
+
/** Function to update the active connection's properties */
|
|
138
|
+
updateActiveConnection: (connection: Partial<EVMConnection>) => void;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Configuration interface for the EVM connections watcher.
|
|
142
|
+
*/
|
|
143
|
+
interface EVMWatcherConfig {
|
|
144
|
+
/** Wagmi configuration object required for connection monitoring */
|
|
145
|
+
wagmiConfig: Config;
|
|
146
|
+
/** Optional Sign-In With Ethereum (SIWE) configuration */
|
|
147
|
+
siwe?: {
|
|
148
|
+
/** Whether SIWE authentication is enabled */
|
|
149
|
+
enabled: boolean;
|
|
150
|
+
/** Whether the user is currently signed in via SIWE */
|
|
151
|
+
isSignedIn: boolean;
|
|
152
|
+
/** Whether the user has rejected the SIWE signature request */
|
|
153
|
+
isRejected: boolean;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Creates and initializes an EVM connections watcher that monitors wagmi connection changes
|
|
158
|
+
* and synchronizes them with the global state store.
|
|
159
|
+
*
|
|
160
|
+
* This function provides a pure, framework-agnostic way to watch EVM connections
|
|
161
|
+
* without being tied to React hooks or components.
|
|
162
|
+
*
|
|
163
|
+
* @param config - Configuration object containing wagmi config and optional SIWE settings
|
|
164
|
+
* @param callbacks - Callback functions for interacting with the global state
|
|
165
|
+
* @returns A cleanup function to stop watching connections
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const unwatch = createEVMConnectionsWatcher(
|
|
170
|
+
* { wagmiConfig, siwe: { enabled: true, isSignedIn: true, isRejected: false } },
|
|
171
|
+
* { activeConnection, disconnect, connectionError, updateActiveConnection }
|
|
172
|
+
* );
|
|
173
|
+
*
|
|
174
|
+
* // Later, when you need to stop watching:
|
|
175
|
+
* unwatch();
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
declare function createEVMConnectionsWatcher(config: EVMWatcherConfig, callbacks: EVMWatcherCallbacks): () => void;
|
|
179
|
+
|
|
180
|
+
export { type ConnectorEVM, type EVMConnection, type EVMWatcherCallbacks, type EVMWatcherConfig, type ImpersonatedParameters, checkIsWalletAddressContract, createDefaultTransports, createEVMConnectionsWatcher, impersonated, safeSdkOptions, satelliteEVMAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as _wagmi_core from '@wagmi/core';
|
|
|
3
3
|
import { Connector, CreateConnectorFn, Config, CreateConfigParameters } from '@wagmi/core';
|
|
4
4
|
import { Chain } from 'viem/chains';
|
|
5
5
|
import { Transport } from 'viem';
|
|
6
|
+
import { ConnectorType } from '@tuwaio/orbit-core';
|
|
6
7
|
|
|
7
8
|
/** EVM-specific connector type */
|
|
8
9
|
type ConnectorEVM = Connector<CreateConnectorFn>;
|
|
@@ -122,4 +123,58 @@ declare function checkIsWalletAddressContract({ config, address, chainId, chains
|
|
|
122
123
|
*/
|
|
123
124
|
declare const createDefaultTransports: (chains: CreateConfigParameters["chains"]) => Record<number, Transport>;
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Callback functions interface for the EVM connections watcher.
|
|
128
|
+
* These callbacks are used to interact with the global state store.
|
|
129
|
+
*/
|
|
130
|
+
interface EVMWatcherCallbacks {
|
|
131
|
+
/** The currently active EVM connection from the global store */
|
|
132
|
+
activeConnection: EVMConnection | undefined;
|
|
133
|
+
/** Function to disconnect a specific connector type */
|
|
134
|
+
disconnect: (connectorType: ConnectorType) => void;
|
|
135
|
+
/** Current connection error state, if any */
|
|
136
|
+
connectionError: string | undefined;
|
|
137
|
+
/** Function to update the active connection's properties */
|
|
138
|
+
updateActiveConnection: (connection: Partial<EVMConnection>) => void;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Configuration interface for the EVM connections watcher.
|
|
142
|
+
*/
|
|
143
|
+
interface EVMWatcherConfig {
|
|
144
|
+
/** Wagmi configuration object required for connection monitoring */
|
|
145
|
+
wagmiConfig: Config;
|
|
146
|
+
/** Optional Sign-In With Ethereum (SIWE) configuration */
|
|
147
|
+
siwe?: {
|
|
148
|
+
/** Whether SIWE authentication is enabled */
|
|
149
|
+
enabled: boolean;
|
|
150
|
+
/** Whether the user is currently signed in via SIWE */
|
|
151
|
+
isSignedIn: boolean;
|
|
152
|
+
/** Whether the user has rejected the SIWE signature request */
|
|
153
|
+
isRejected: boolean;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Creates and initializes an EVM connections watcher that monitors wagmi connection changes
|
|
158
|
+
* and synchronizes them with the global state store.
|
|
159
|
+
*
|
|
160
|
+
* This function provides a pure, framework-agnostic way to watch EVM connections
|
|
161
|
+
* without being tied to React hooks or components.
|
|
162
|
+
*
|
|
163
|
+
* @param config - Configuration object containing wagmi config and optional SIWE settings
|
|
164
|
+
* @param callbacks - Callback functions for interacting with the global state
|
|
165
|
+
* @returns A cleanup function to stop watching connections
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const unwatch = createEVMConnectionsWatcher(
|
|
170
|
+
* { wagmiConfig, siwe: { enabled: true, isSignedIn: true, isRejected: false } },
|
|
171
|
+
* { activeConnection, disconnect, connectionError, updateActiveConnection }
|
|
172
|
+
* );
|
|
173
|
+
*
|
|
174
|
+
* // Later, when you need to stop watching:
|
|
175
|
+
* unwatch();
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
declare function createEVMConnectionsWatcher(config: EVMWatcherConfig, callbacks: EVMWatcherCallbacks): () => void;
|
|
179
|
+
|
|
180
|
+
export { type ConnectorEVM, type EVMConnection, type EVMWatcherCallbacks, type EVMWatcherConfig, type ImpersonatedParameters, checkIsWalletAddressContract, createDefaultTransports, createEVMConnectionsWatcher, 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'),utils=require('viem/utils');var
|
|
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 E=new Map;async function b({config:s,address:o,chainId:e,chains:r}){if(E.has(o))return E.get(o);if(orbitEvm.createViemClient(e,r)){let n=!!await core.getBytecode(s,{address:o});return E.set(o,n),n}else return false}function Ce(s,o){if(!s)throw new Error("Satellite EVM adapter requires a wagmi config object.");return {key:orbitCore.OrbitAdapter.EVM,connect:async({connectorType:e,chainId:r})=>{let a=core.getConnectors(s).find(n=>orbitCore.getConnectorTypeFromName(orbitCore.OrbitAdapter.EVM,orbitCore.formatConnectorName(n.name))===e);if(!a)throw new Error("Cannot find connector with this wallet type");try{await core.connect(s,{connector:a,chainId:r}),o&&!orbitCore.isSafeApp&&orbitCore.formatConnectorName(a.name)!=="porto"&&orbitCore.formatConnectorName(a.name)!=="geminiwallet"&&orbitCore.formatConnectorName(a.name)!=="Impersonatedconnector"&&await o();let n=core.getConnection(s);return {connectorType:e,address:n.address??viem.zeroAddress,chainId:n.chainId??chains.mainnet.id,rpcURL:n.chain?.rpcUrls.default.http[0]??chains.mainnet.rpcUrls.default.http[0],isConnected:n.isConnected,isContractAddress:!1,icon:a?.icon?.trim(),connector:a}}catch(n){throw new Error(n instanceof Error?n.message:String(n))}},disconnect:async e=>{if(e&&e.isConnected)await core.disconnect(s,{connector:e?.connector});else {let r=core.getConnectors(s);await Promise.allSettled(r.map(async t=>{await core.disconnect(s,{connector:t});}));}},getConnectors:()=>{let e=core.getConnectors(s);return {adapter:orbitCore.OrbitAdapter.EVM,connectors:e.map(r=>r)}},checkAndSwitchNetwork:async e=>await orbitEvm.checkAndSwitchChain(Number(e),s),getBalance:async(e,r)=>{let t=await core.getBalance(s,{address:e,chainId:Number(r)});return {value:viem.formatUnits(t.value,t.decimals),symbol:t.symbol}},getExplorerUrl:e=>{let{chain:r}=core.getConnection(s),t=r?.blockExplorers?.default.url;return e?`${t}/${e}`:t},getName:e=>orbitEvm.getName(e),getAvatar:e=>orbitEvm.getAvatar(e),getAddress:e=>orbitEvm.getAddress(e),checkIsContractAddress:async({address:e,chainId:r})=>{let t=core.getChains(s);return await b({config:s,address:e,chainId:r,chains:t})},getSafeConnectorChainId:async()=>{let r=core.getConnectors(s).find(t=>t.name==="Safe");if(r)return await r.getChainId()},switchConnection:async e=>{let t=core.getConnectors(s).find(a=>orbitCore.getConnectorTypeFromName(orbitCore.OrbitAdapter.EVM,orbitCore.formatConnectorName(a.name))===e);if(!t)throw new Error(`Cannot find connector with type: ${e}`);try{await core.switchConnection(s,{connector:t});}catch(a){throw new Error(`Failed to switch to connector ${e}: ${a instanceof Error?a.message:String(a)}`)}}}}S.type="impersonated";function S(s){let o=s.features??{},e=false,r,t;return core.createConnector(a=>({id:"impersonated",name:"Impersonated Connector",type:S.type,async setup(){r=a.chains[0].id;},async connect({chainId:n}={}){if(o.connectError)throw typeof o.connectError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to connect.")):o.connectError;let{request:c}=await this.getProvider(),d=await c({method:"eth_requestAccounts"}),h=await this.getChainId();return n&&h!==n&&(h=(await this.switchChain({chainId:n})).id),e=true,{accounts:d,chainId:h}},async disconnect(){e=false,t=void 0;},async getAccounts(){if(!e)throw new Error("Not connected connector");let{request:n}=await this.getProvider();return (await n({method:"eth_accounts"})).map(viem.getAddress)},async getChainId(){let{request:n}=await this.getProvider(),c=await n({method:"eth_chainId"});return viem.fromHex(c,"number")},async isAuthorized(){return e?!!(await this.getAccounts()).length:false},async switchChain({chainId:n}){let c=a.chains.find(h=>h.id===n);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(n)}]}),c},onAccountsChanged(n){n.length===0?this.onDisconnect():a.emitter.emit("change",{accounts:n.map(viem.getAddress)});},onChainChanged(n){let c=Number(n);a.emitter.emit("change",{chainId:c});},async onDisconnect(){a.emitter.emit("disconnect"),e=false,t=void 0;},async getProvider({chainId:n}={}){t=orbitCore.impersonatedHelpers?.getImpersonated()?[orbitCore.impersonatedHelpers.getImpersonated()||viem.zeroAddress]:void 0;let d=(a.chains.find(i=>i.id===n)??a.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 t;if(i==="eth_signTypedData_v4"&&o.signTypedDataError)throw typeof o.signTypedDataError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to sign typed data.")):o.signTypedDataError;if(i==="wallet_switchEthereumChain"){if(o.switchChainError)throw typeof o.switchChainError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to switch chain.")):o.switchChainError;r=viem.fromHex(m[0].chainId,"number"),this.onChainChanged(r.toString());return}if(i==="personal_sign"){if(o.signMessageError)throw typeof o.signMessageError=="boolean"?new viem.UserRejectedRequestError(new Error("Failed to sign message.")):o.signMessageError;i="eth_sign",m=[m[1],m[0]];}let p={method:i,params:m},{error:g,result:f}=await utils.rpc.http(d,{body:p});if(g)throw new viem.RpcRequestError({body:p,error:g,url:d});return f}})({retryCount:1})}}))}var Ie={allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/,/metissafe.tech$/],debug:false};var Ve=s=>s.reduce((o,e)=>{let r=e.id;return o[r]=viem.http(),o},{});function Ue(s,o){let{wagmiConfig:e,siwe:r}=s,{activeConnection:t,disconnect:a,connectionError:n,updateActiveConnection:c}=o,d=()=>{r?.enabled&&!r?.isSignedIn&&r?.isRejected&&t&&a(t.connectorType);},h=m=>{if(t&&orbitCore.getAdapterFromConnectorType(t.connectorType)!==orbitCore.OrbitAdapter.EVM)return;if(m.length===0){t&&a(t.connectorType);return}let p=core.getConnection(e);if(t&&orbitCore.getAdapterFromConnectorType(t.connectorType)!==orbitCore.OrbitAdapter.EVM||!p||n)return;if(r?.enabled?r.isSignedIn:true){let f=p.connector,k={connectorType:f?`${orbitCore.OrbitAdapter.EVM}:${orbitCore.formatConnectorName(f.name)}`:t?.connectorType,address:p.address,chainId:p.chainId,rpcURL:p?.chain?.rpcUrls.default.http[0],isConnected:true};c(k);}};return d(),core.watchConnections(e,{onChange:h})}exports.checkIsWalletAddressContract=b;exports.createDefaultTransports=Ve;exports.createEVMConnectionsWatcher=Ue;exports.impersonated=S;exports.safeSdkOptions=Ie;exports.satelliteEVMAdapter=Ce;//# 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","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,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,yBAAAA,CAAiBF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AAA,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"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/checkIsWalletAddressContract.ts","../src/adapters/evmAdapter.ts","../src/connectors/ImpersonatedConnector.ts","../src/connectors/index.ts","../src/utils/createDefaultTransports.ts","../src/utils/createEVMConnectionsWatcher.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","createEVMConnectionsWatcher","callbacks","wagmiConfig","siwe","activeConnection","connectionError","updateActiveConnection","handleSIWERejection","handleConnectionsChange","connections","getAdapterFromConnectorType","currentConnection","currentConnector","updatedConnector","watchConnections"],"mappings":"0MAUA,IAAMA,CAAAA,CAAe,IAAI,GAAA,CA8BzB,eAAsBC,CAAAA,CAA6B,CACjD,MAAA,CAAAC,CAAAA,CACA,QAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,CACF,CAAA,CASqB,CAEnB,GAAIL,CAAAA,CAAa,IAAIG,CAAO,CAAA,CAC1B,OAAOH,CAAAA,CAAa,GAAA,CAAIG,CAAO,CAAA,CAMjC,GAFeG,0BAAiBF,CAAAA,CAAmBC,CAAM,CAAA,CAE7C,CAOV,IAAME,CAAAA,CAAa,CAAC,CALQ,MAAMC,iBAAYN,CAAAA,CAAQ,CACpD,OAAA,CAASC,CACX,CAAC,CAAA,CAID,OAAAH,CAAAA,CAAa,GAAA,CAAIG,EAASI,CAAU,CAAA,CAE7BA,CACT,CAAA,YAES,MAEX,CCrCO,SA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lE,uBAAa,GAAA,CACnG,OAIF,GAAIuE,CAAAA,CAAY,SAAW,CAAA,CAAG,CACxBL,CAAAA,EACFpD,CAAAA,CAAWoD,EAAiB,aAAa,CAAA,CAE3C,MACF,CAGA,IAAMO,CAAAA,CAAoBhE,kBAAAA,CAAcuD,CAAW,EAGnD,GAEGE,CAAAA,EAAoBM,qCAAAA,CAA4BN,CAAAA,CAAiB,aAAa,CAAA,GAAMlE,sBAAAA,CAAa,GAAA,EAElG,CAACyE,GAEDN,CAAAA,CAEA,OAUF,GAFqBF,CAAAA,EAAM,QAAUA,CAAAA,CAAK,UAAA,CAAa,IAAA,CAErC,CAChB,IAAMS,CAAAA,CAAmBD,CAAAA,CAAkB,SAAA,CAQrCE,CAAAA,CAA2C,CAC/C,aAAA,CAN2BD,CAAAA,CACxB,CAAA,EAAG1E,sBAAAA,CAAa,GAAG,CAAA,CAAA,EAAIK,6BAAAA,CAAoBqE,CAAAA,CAAiB,IAAI,CAAC,CAAA,CAAA,CAClER,CAAAA,EAAkB,aAAA,CAKpB,QAASO,CAAAA,CAAkB,OAAA,CAC3B,OAAA,CAASA,CAAAA,CAAkB,QAC3B,MAAA,CAAQA,CAAAA,EAAmB,KAAA,EAAO,OAAA,CAAQ,QAAQ,IAAA,CAAK,CAAC,CAAA,CACxD,WAAA,CAAa,IACf,CAAA,CAGAL,CAAAA,CAAuBO,CAAgB,EACzC,CACF,CAAA,CAGA,OAAAN,CAAAA,EAAoB,CAGJO,sBAAiBZ,CAAAA,CAAa,CAC5C,QAAA,CAAUM,CACZ,CAAC,CAIH","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","import { ConnectorType, formatConnectorName, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, getConnection, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\n\nimport { EVMConnection } from '../types';\n\n/**\n * Callback functions interface for the EVM connections watcher.\n * These callbacks are used to interact with the global state store.\n */\nexport interface EVMWatcherCallbacks {\n /** The currently active EVM connection from the global store */\n activeConnection: EVMConnection | undefined;\n /** Function to disconnect a specific connector type */\n disconnect: (connectorType: ConnectorType) => void;\n /** Current connection error state, if any */\n connectionError: string | undefined;\n /** Function to update the active connection's properties */\n updateActiveConnection: (connection: Partial<EVMConnection>) => void;\n}\n\n/**\n * Configuration interface for the EVM connections watcher.\n */\nexport interface EVMWatcherConfig {\n /** Wagmi configuration object required for connection monitoring */\n wagmiConfig: Config;\n /** Optional Sign-In With Ethereum (SIWE) configuration */\n siwe?: {\n /** Whether SIWE authentication is enabled */\n enabled: boolean;\n /** Whether the user is currently signed in via SIWE */\n isSignedIn: boolean;\n /** Whether the user has rejected the SIWE signature request */\n isRejected: boolean;\n };\n}\n\n/**\n * Creates and initializes an EVM connections watcher that monitors wagmi connection changes\n * and synchronizes them with the global state store.\n *\n * This function provides a pure, framework-agnostic way to watch EVM connections\n * without being tied to React hooks or components.\n *\n * @param config - Configuration object containing wagmi config and optional SIWE settings\n * @param callbacks - Callback functions for interacting with the global state\n * @returns A cleanup function to stop watching connections\n *\n * @example\n * ```typescript\n * const unwatch = createEVMConnectionsWatcher(\n * { wagmiConfig, siwe: { enabled: true, isSignedIn: true, isRejected: false } },\n * { activeConnection, disconnect, connectionError, updateActiveConnection }\n * );\n *\n * // Later, when you need to stop watching:\n * unwatch();\n * ```\n */\nexport function createEVMConnectionsWatcher(config: EVMWatcherConfig, callbacks: EVMWatcherCallbacks): () => void {\n const { wagmiConfig, siwe } = config;\n const { activeConnection, disconnect, connectionError, updateActiveConnection } = callbacks;\n\n /**\n * Handles SIWE (Sign-In With Ethereum) rejection scenarios.\n * If SIWE is enabled and the user has rejected signing, this will trigger a disconnect.\n *\n * @internal\n */\n const handleSIWERejection = (): void => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n }\n };\n\n /**\n * Handles changes in wagmi connection state.\n * This function is called whenever wagmi detects connection changes\n * such as account switches, network changes, or disconnections.\n *\n * @param connections - Array of all active connections from wagmi\n * @internal\n */\n const handleConnectionsChange: WatchConnectionsParameters['onChange'] = (connections): void => {\n // Early return: Skip processing if the active connection is not an EVM connector\n if (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Handle disconnection: If no connections exist, disconnect the active connector\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n return;\n }\n\n // Get current wagmi connection state\n const currentConnection = getConnection(wagmiConfig);\n\n // Guard clauses: Skip processing under certain conditions\n if (\n // Active connection exists but is not an EVM connector\n (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) ||\n // No current connection from wagmi\n !currentConnection ||\n // There's already a connection error in the store\n connectionError\n ) {\n return;\n }\n\n /**\n * Determine whether to update the store based on SIWE state.\n * - If SIWE is enabled: only update when user is signed in\n * - If SIWE is disabled: always update\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n const currentConnector = currentConnection.connector;\n\n // Determine the connector type, fallback to existing if connector is unavailable\n const currentConnectorType = currentConnector\n ? (`${OrbitAdapter.EVM}:${formatConnectorName(currentConnector.name)}` as ConnectorType)\n : activeConnection?.connectorType;\n\n // Build the updated connector object with current connection data\n const updatedConnector: Partial<EVMConnection> = {\n connectorType: currentConnectorType,\n address: currentConnection.address,\n chainId: currentConnection.chainId,\n rpcURL: currentConnection?.chain?.rpcUrls.default.http[0],\n isConnected: true,\n };\n\n // Update the global store with the new connector state\n updateActiveConnection(updatedConnector);\n }\n };\n\n // Process initial SIWE rejection state\n handleSIWERejection();\n\n // Start watching wagmi connections for changes\n const unwatch = watchConnections(wagmiConfig, {\n onChange: handleConnectionsChange,\n });\n\n // Return cleanup function\n return unwatch;\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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
|
|
1
|
+
import {OrbitAdapter,getConnectorTypeFromName,formatConnectorName,isSafeApp,impersonatedHelpers,getAdapterFromConnectorType}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,watchConnections}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 E=new Map;async function b({config:s,address:o,chainId:e,chains:r}){if(E.has(o))return E.get(o);if(createViemClient(e,r)){let n=!!await getBytecode(s,{address:o});return E.set(o,n),n}else return false}function Ce(s,o){if(!s)throw new Error("Satellite EVM adapter requires a wagmi config object.");return {key:OrbitAdapter.EVM,connect:async({connectorType:e,chainId:r})=>{let a=getConnectors(s).find(n=>getConnectorTypeFromName(OrbitAdapter.EVM,formatConnectorName(n.name))===e);if(!a)throw new Error("Cannot find connector with this wallet type");try{await connect(s,{connector:a,chainId:r}),o&&!isSafeApp&&formatConnectorName(a.name)!=="porto"&&formatConnectorName(a.name)!=="geminiwallet"&&formatConnectorName(a.name)!=="Impersonatedconnector"&&await o();let n=getConnection(s);return {connectorType:e,address:n.address??zeroAddress,chainId:n.chainId??mainnet.id,rpcURL:n.chain?.rpcUrls.default.http[0]??mainnet.rpcUrls.default.http[0],isConnected:n.isConnected,isContractAddress:!1,icon:a?.icon?.trim(),connector:a}}catch(n){throw new Error(n instanceof Error?n.message:String(n))}},disconnect:async e=>{if(e&&e.isConnected)await disconnect(s,{connector:e?.connector});else {let r=getConnectors(s);await Promise.allSettled(r.map(async t=>{await disconnect(s,{connector:t});}));}},getConnectors:()=>{let e=getConnectors(s);return {adapter:OrbitAdapter.EVM,connectors:e.map(r=>r)}},checkAndSwitchNetwork:async e=>await checkAndSwitchChain(Number(e),s),getBalance:async(e,r)=>{let t=await getBalance(s,{address:e,chainId:Number(r)});return {value:formatUnits(t.value,t.decimals),symbol:t.symbol}},getExplorerUrl:e=>{let{chain:r}=getConnection(s),t=r?.blockExplorers?.default.url;return e?`${t}/${e}`:t},getName:e=>getName(e),getAvatar:e=>getAvatar(e),getAddress:e=>getAddress(e),checkIsContractAddress:async({address:e,chainId:r})=>{let t=getChains(s);return await b({config:s,address:e,chainId:r,chains:t})},getSafeConnectorChainId:async()=>{let r=getConnectors(s).find(t=>t.name==="Safe");if(r)return await r.getChainId()},switchConnection:async e=>{let t=getConnectors(s).find(a=>getConnectorTypeFromName(OrbitAdapter.EVM,formatConnectorName(a.name))===e);if(!t)throw new Error(`Cannot find connector with type: ${e}`);try{await switchConnection(s,{connector:t});}catch(a){throw new Error(`Failed to switch to connector ${e}: ${a instanceof Error?a.message:String(a)}`)}}}}S.type="impersonated";function S(s){let o=s.features??{},e=false,r,t;return createConnector(a=>({id:"impersonated",name:"Impersonated Connector",type:S.type,async setup(){r=a.chains[0].id;},async connect({chainId:n}={}){if(o.connectError)throw typeof o.connectError=="boolean"?new UserRejectedRequestError(new Error("Failed to connect.")):o.connectError;let{request:c}=await this.getProvider(),d=await c({method:"eth_requestAccounts"}),h=await this.getChainId();return n&&h!==n&&(h=(await this.switchChain({chainId:n})).id),e=true,{accounts:d,chainId:h}},async disconnect(){e=false,t=void 0;},async getAccounts(){if(!e)throw new Error("Not connected connector");let{request:n}=await this.getProvider();return (await n({method:"eth_accounts"})).map(getAddress$1)},async getChainId(){let{request:n}=await this.getProvider(),c=await n({method:"eth_chainId"});return fromHex(c,"number")},async isAuthorized(){return e?!!(await this.getAccounts()).length:false},async switchChain({chainId:n}){let c=a.chains.find(h=>h.id===n);if(!c)throw new SwitchChainError(new ChainNotConfiguredError);let{request:d}=await this.getProvider();return await d({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(n)}]}),c},onAccountsChanged(n){n.length===0?this.onDisconnect():a.emitter.emit("change",{accounts:n.map(getAddress$1)});},onChainChanged(n){let c=Number(n);a.emitter.emit("change",{chainId:c});},async onDisconnect(){a.emitter.emit("disconnect"),e=false,t=void 0;},async getProvider({chainId:n}={}){t=impersonatedHelpers?.getImpersonated()?[impersonatedHelpers.getImpersonated()||zeroAddress]:void 0;let d=(a.chains.find(i=>i.id===n)??a.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 t;if(i==="eth_signTypedData_v4"&&o.signTypedDataError)throw typeof o.signTypedDataError=="boolean"?new UserRejectedRequestError(new Error("Failed to sign typed data.")):o.signTypedDataError;if(i==="wallet_switchEthereumChain"){if(o.switchChainError)throw typeof o.switchChainError=="boolean"?new UserRejectedRequestError(new Error("Failed to switch chain.")):o.switchChainError;r=fromHex(m[0].chainId,"number"),this.onChainChanged(r.toString());return}if(i==="personal_sign"){if(o.signMessageError)throw typeof o.signMessageError=="boolean"?new UserRejectedRequestError(new Error("Failed to sign message.")):o.signMessageError;i="eth_sign",m=[m[1],m[0]];}let p={method:i,params:m},{error:g,result:f}=await rpc.http(d,{body:p});if(g)throw new RpcRequestError({body:p,error:g,url:d});return f}})({retryCount:1})}}))}var Ie={allowedDomains:[/gnosis-safe.io$/,/app.safe.global$/,/metissafe.tech$/],debug:false};var Ve=s=>s.reduce((o,e)=>{let r=e.id;return o[r]=http(),o},{});function Ue(s,o){let{wagmiConfig:e,siwe:r}=s,{activeConnection:t,disconnect:a,connectionError:n,updateActiveConnection:c}=o,d=()=>{r?.enabled&&!r?.isSignedIn&&r?.isRejected&&t&&a(t.connectorType);},h=m=>{if(t&&getAdapterFromConnectorType(t.connectorType)!==OrbitAdapter.EVM)return;if(m.length===0){t&&a(t.connectorType);return}let p=getConnection(e);if(t&&getAdapterFromConnectorType(t.connectorType)!==OrbitAdapter.EVM||!p||n)return;if(r?.enabled?r.isSignedIn:true){let f=p.connector,k={connectorType:f?`${OrbitAdapter.EVM}:${formatConnectorName(f.name)}`:t?.connectorType,address:p.address,chainId:p.chainId,rpcURL:p?.chain?.rpcUrls.default.http[0],isConnected:true};c(k);}};return d(),watchConnections(e,{onChange:h})}export{b as checkIsWalletAddressContract,Ve as createDefaultTransports,Ue as createEVMConnectionsWatcher,S as impersonated,Ie as safeSdkOptions,Ce 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","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,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,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"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/checkIsWalletAddressContract.ts","../src/adapters/evmAdapter.ts","../src/connectors/ImpersonatedConnector.ts","../src/connectors/index.ts","../src/utils/createDefaultTransports.ts","../src/utils/createEVMConnectionsWatcher.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","createEVMConnectionsWatcher","callbacks","wagmiConfig","siwe","activeConnection","connectionError","updateActiveConnection","handleSIWERejection","handleConnectionsChange","connections","getAdapterFromConnectorType","currentConnection","currentConnector","updatedConnector","watchConnections"],"mappings":"0oBAUA,IAAMA,CAAAA,CAAe,IAAI,GAAA,CA8BzB,eAAsBC,CAAAA,CAA6B,CACjD,MAAA,CAAAC,CAAAA,CACA,QAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,CACF,CAAA,CASqB,CAEnB,GAAIL,CAAAA,CAAa,IAAIG,CAAO,CAAA,CAC1B,OAAOH,CAAAA,CAAa,GAAA,CAAIG,CAAO,CAAA,CAMjC,GAFeG,iBAAiBF,CAAAA,CAAmBC,CAAM,CAAA,CAE7C,CAOV,IAAME,CAAAA,CAAa,CAAC,CALQ,MAAMC,YAAYN,CAAAA,CAAQ,CACpD,OAAA,CAASC,CACX,CAAC,CAAA,CAID,OAAAH,C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,GAAoBM,2BAAAA,CAA4BN,CAAAA,CAAiB,aAAa,CAAA,GAAMlE,aAAa,GAAA,CACnG,OAIF,GAAIuE,CAAAA,CAAY,SAAW,CAAA,CAAG,CACxBL,CAAAA,EACFpD,CAAAA,CAAWoD,EAAiB,aAAa,CAAA,CAE3C,MACF,CAGA,IAAMO,CAAAA,CAAoBhE,aAAAA,CAAcuD,CAAW,EAGnD,GAEGE,CAAAA,EAAoBM,2BAAAA,CAA4BN,CAAAA,CAAiB,aAAa,CAAA,GAAMlE,YAAAA,CAAa,GAAA,EAElG,CAACyE,GAEDN,CAAAA,CAEA,OAUF,GAFqBF,CAAAA,EAAM,QAAUA,CAAAA,CAAK,UAAA,CAAa,IAAA,CAErC,CAChB,IAAMS,CAAAA,CAAmBD,CAAAA,CAAkB,SAAA,CAQrCE,CAAAA,CAA2C,CAC/C,aAAA,CAN2BD,CAAAA,CACxB,CAAA,EAAG1E,YAAAA,CAAa,GAAG,CAAA,CAAA,EAAIK,mBAAAA,CAAoBqE,CAAAA,CAAiB,IAAI,CAAC,CAAA,CAAA,CAClER,CAAAA,EAAkB,aAAA,CAKpB,QAASO,CAAAA,CAAkB,OAAA,CAC3B,OAAA,CAASA,CAAAA,CAAkB,QAC3B,MAAA,CAAQA,CAAAA,EAAmB,KAAA,EAAO,OAAA,CAAQ,QAAQ,IAAA,CAAK,CAAC,CAAA,CACxD,WAAA,CAAa,IACf,CAAA,CAGAL,CAAAA,CAAuBO,CAAgB,EACzC,CACF,CAAA,CAGA,OAAAN,CAAAA,EAAoB,CAGJO,iBAAiBZ,CAAAA,CAAa,CAC5C,QAAA,CAAUM,CACZ,CAAC,CAIH","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","import { ConnectorType, formatConnectorName, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, getConnection, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\n\nimport { EVMConnection } from '../types';\n\n/**\n * Callback functions interface for the EVM connections watcher.\n * These callbacks are used to interact with the global state store.\n */\nexport interface EVMWatcherCallbacks {\n /** The currently active EVM connection from the global store */\n activeConnection: EVMConnection | undefined;\n /** Function to disconnect a specific connector type */\n disconnect: (connectorType: ConnectorType) => void;\n /** Current connection error state, if any */\n connectionError: string | undefined;\n /** Function to update the active connection's properties */\n updateActiveConnection: (connection: Partial<EVMConnection>) => void;\n}\n\n/**\n * Configuration interface for the EVM connections watcher.\n */\nexport interface EVMWatcherConfig {\n /** Wagmi configuration object required for connection monitoring */\n wagmiConfig: Config;\n /** Optional Sign-In With Ethereum (SIWE) configuration */\n siwe?: {\n /** Whether SIWE authentication is enabled */\n enabled: boolean;\n /** Whether the user is currently signed in via SIWE */\n isSignedIn: boolean;\n /** Whether the user has rejected the SIWE signature request */\n isRejected: boolean;\n };\n}\n\n/**\n * Creates and initializes an EVM connections watcher that monitors wagmi connection changes\n * and synchronizes them with the global state store.\n *\n * This function provides a pure, framework-agnostic way to watch EVM connections\n * without being tied to React hooks or components.\n *\n * @param config - Configuration object containing wagmi config and optional SIWE settings\n * @param callbacks - Callback functions for interacting with the global state\n * @returns A cleanup function to stop watching connections\n *\n * @example\n * ```typescript\n * const unwatch = createEVMConnectionsWatcher(\n * { wagmiConfig, siwe: { enabled: true, isSignedIn: true, isRejected: false } },\n * { activeConnection, disconnect, connectionError, updateActiveConnection }\n * );\n *\n * // Later, when you need to stop watching:\n * unwatch();\n * ```\n */\nexport function createEVMConnectionsWatcher(config: EVMWatcherConfig, callbacks: EVMWatcherCallbacks): () => void {\n const { wagmiConfig, siwe } = config;\n const { activeConnection, disconnect, connectionError, updateActiveConnection } = callbacks;\n\n /**\n * Handles SIWE (Sign-In With Ethereum) rejection scenarios.\n * If SIWE is enabled and the user has rejected signing, this will trigger a disconnect.\n *\n * @internal\n */\n const handleSIWERejection = (): void => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n }\n };\n\n /**\n * Handles changes in wagmi connection state.\n * This function is called whenever wagmi detects connection changes\n * such as account switches, network changes, or disconnections.\n *\n * @param connections - Array of all active connections from wagmi\n * @internal\n */\n const handleConnectionsChange: WatchConnectionsParameters['onChange'] = (connections): void => {\n // Early return: Skip processing if the active connection is not an EVM connector\n if (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Handle disconnection: If no connections exist, disconnect the active connector\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n return;\n }\n\n // Get current wagmi connection state\n const currentConnection = getConnection(wagmiConfig);\n\n // Guard clauses: Skip processing under certain conditions\n if (\n // Active connection exists but is not an EVM connector\n (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) ||\n // No current connection from wagmi\n !currentConnection ||\n // There's already a connection error in the store\n connectionError\n ) {\n return;\n }\n\n /**\n * Determine whether to update the store based on SIWE state.\n * - If SIWE is enabled: only update when user is signed in\n * - If SIWE is disabled: always update\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n const currentConnector = currentConnection.connector;\n\n // Determine the connector type, fallback to existing if connector is unavailable\n const currentConnectorType = currentConnector\n ? (`${OrbitAdapter.EVM}:${formatConnectorName(currentConnector.name)}` as ConnectorType)\n : activeConnection?.connectorType;\n\n // Build the updated connector object with current connection data\n const updatedConnector: Partial<EVMConnection> = {\n connectorType: currentConnectorType,\n address: currentConnection.address,\n chainId: currentConnection.chainId,\n rpcURL: currentConnection?.chain?.rpcUrls.default.http[0],\n isConnected: true,\n };\n\n // Update the global store with the new connector state\n updateActiveConnection(updatedConnector);\n }\n };\n\n // Process initial SIWE rejection state\n handleSIWERejection();\n\n // Start watching wagmi connections for changes\n const unwatch = watchConnections(wagmiConfig, {\n onChange: handleConnectionsChange,\n });\n\n // Return cleanup function\n return unwatch;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/satellite-evm",
|
|
3
|
-
"version": "1.0.0-fix-adapters-independ-alpha.
|
|
3
|
+
"version": "1.0.0-fix-adapters-independ-alpha.9.583293c",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"viem": "^2.42.1",
|
|
59
59
|
"vitest": "^4.0.15",
|
|
60
60
|
"zustand": "^5.0.9",
|
|
61
|
-
"@tuwaio/satellite-core": "^1.0.0-fix-adapters-independ-alpha.
|
|
61
|
+
"@tuwaio/satellite-core": "^1.0.0-fix-adapters-independ-alpha.9.583293c"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"start": "tsup src/index.ts --watch",
|