@steerprotocol/liquidity-meter 1.0.0

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.
@@ -0,0 +1,24 @@
1
+ import { createConfig, http, getClient, getConnectorClient } from '@wagmi/core';
2
+ import { base, mainnet, optimism, arbitrum, polygon, zora } from '@wagmi/core/chains';
3
+ import { defineChain, createPublicClient, http as viemHttp } from 'viem';
4
+ export const defaultConfig = createConfig({
5
+ chains: [mainnet, base, optimism, arbitrum, polygon, zora],
6
+ transports: {
7
+ [mainnet.id]: http(process.env.RPC_URL),
8
+ [base.id]: http(process.env.BASE_RPC_URL || process.env.RPC_URL),
9
+ [optimism.id]: http(process.env.OP_RPC_URL || process.env.RPC_URL),
10
+ [arbitrum.id]: http(process.env.ARB_RPC_URL || process.env.RPC_URL),
11
+ [polygon.id]: http(process.env.POLYGON_RPC_URL || process.env.RPC_URL),
12
+ [zora.id]: http(process.env.ZORA_RPC_URL || process.env.RPC_URL),
13
+ },
14
+ });
15
+ export async function configFromRpc(rpcUrl) {
16
+ // Probe chain id with a temporary viem client
17
+ const pc = createPublicClient({ transport: viemHttp(rpcUrl) });
18
+ const id = await pc.getChainId();
19
+ // Try match against known chains; otherwise define a generic chain
20
+ const known = [mainnet, base, optimism, arbitrum, polygon, zora].find((c) => c.id === id);
21
+ const chain = known ?? defineChain({ id, name: `chain-${id}`, nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, rpcUrls: { default: { http: [rpcUrl] } } });
22
+ return createConfig({ chains: [chain], transports: { [chain.id]: http(rpcUrl) } });
23
+ }
24
+ export { getClient, getConnectorClient };