feat(provider): Enhance provider setup with meaningful logging
- Introduced detailed system-level logging for provider initialization and configuration stages. - Adjusted path references for accurate message sourcing. - Abstracted walletConnectId for improved modularity.
This commit is contained in:
parent
a572099312
commit
3f024283ef
@ -1,69 +0,0 @@
|
|||||||
<script>
|
|
||||||
import { configureChains, createConfig } from '@wagmi/core';
|
|
||||||
import { gnosis } from '@wagmi/core/chains';
|
|
||||||
import { publicProvider } from '@wagmi/core/providers/public';
|
|
||||||
import { InjectedConnector } from '@wagmi/core/connectors/injected';
|
|
||||||
import { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect';
|
|
||||||
import { jsonRpcProvider } from '@wagmi/core/providers/jsonRpc';
|
|
||||||
|
|
||||||
import { onMount } from 'svelte';
|
|
||||||
|
|
||||||
const chronicleChain = {
|
|
||||||
id: 175177,
|
|
||||||
name: 'Chronicle',
|
|
||||||
network: 'chronicle',
|
|
||||||
|
|
||||||
nativeCurrency: {
|
|
||||||
decimals: 18,
|
|
||||||
name: 'Chronicle - Lit Protocol Testnet',
|
|
||||||
symbol: 'LIT'
|
|
||||||
},
|
|
||||||
rpcUrls: {
|
|
||||||
default: {
|
|
||||||
http: ['https://chain-rpc.litprotocol.com/http']
|
|
||||||
},
|
|
||||||
public: {
|
|
||||||
http: ['https://chain-rpc.litprotocol.com/http']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
blockExplorers: {
|
|
||||||
default: {
|
|
||||||
name: 'Chronicle - Lit Protocol Testnet',
|
|
||||||
url: 'https://chain.litprotocol.com'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
testnet: true
|
|
||||||
};
|
|
||||||
|
|
||||||
const { chains, publicClient } = configureChains(
|
|
||||||
[chronicleChain, gnosis],
|
|
||||||
[
|
|
||||||
jsonRpcProvider({
|
|
||||||
rpc: (chain) => ({ http: chain.rpcUrls.default.http[0] })
|
|
||||||
}),
|
|
||||||
jsonRpcProvider({
|
|
||||||
rpc: () => ({
|
|
||||||
http: `https://rpc.gnosischain.com/`,
|
|
||||||
wss: `wss://rpc.gnosischain.com/wss`
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
publicProvider()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
createConfig({
|
|
||||||
autoConnect: true,
|
|
||||||
connectors: [
|
|
||||||
new InjectedConnector({ chains }),
|
|
||||||
new WalletConnectConnector({
|
|
||||||
chains,
|
|
||||||
options: {
|
|
||||||
projectId: '7db8ca514b865088d90cebec1bf28318'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
],
|
|
||||||
publicClient
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { messages, createMessage } from '$lib/services/messages';
|
import { messages } from '$lib/services/messages';
|
||||||
import { onMount, afterUpdate } from 'svelte';
|
import { onMount, afterUpdate } from 'svelte';
|
||||||
import Composite from './Composite.svelte';
|
import Composite from './Composite.svelte';
|
||||||
|
|
||||||
|
91
src/lib/services/provider.ts
Normal file
91
src/lib/services/provider.ts
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import { configureChains, createConfig } from '@wagmi/core';
|
||||||
|
import { gnosis } from '@wagmi/core/chains';
|
||||||
|
import { publicProvider } from '@wagmi/core/providers/public';
|
||||||
|
import { InjectedConnector } from '@wagmi/core/connectors/injected';
|
||||||
|
import { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect';
|
||||||
|
import { jsonRpcProvider } from '@wagmi/core/providers/jsonRpc';
|
||||||
|
import { createMessage } from '$lib/services/messages';
|
||||||
|
|
||||||
|
export interface ProviderData {
|
||||||
|
walletConnectId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const chronicleChain = {
|
||||||
|
id: 175177,
|
||||||
|
name: 'Chronicle',
|
||||||
|
network: 'chronicle',
|
||||||
|
|
||||||
|
nativeCurrency: {
|
||||||
|
decimals: 18,
|
||||||
|
name: 'Chronicle - Lit Protocol Testnet',
|
||||||
|
symbol: 'LIT'
|
||||||
|
},
|
||||||
|
rpcUrls: {
|
||||||
|
default: {
|
||||||
|
http: ['https://chain-rpc.litprotocol.com/http']
|
||||||
|
},
|
||||||
|
public: {
|
||||||
|
http: ['https://chain-rpc.litprotocol.com/http']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
blockExplorers: {
|
||||||
|
default: {
|
||||||
|
name: 'Chronicle - Lit Protocol Testnet',
|
||||||
|
url: 'https://chain.litprotocol.com'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
testnet: true
|
||||||
|
};
|
||||||
|
|
||||||
|
export function initProvider(data: ProviderData) {
|
||||||
|
createMessage({
|
||||||
|
text: 'Provider setup initialization started...',
|
||||||
|
sender: '$lib/services/provider.ts',
|
||||||
|
type: 'SYSTEM'
|
||||||
|
});
|
||||||
|
|
||||||
|
const { chains, publicClient } = configureChains(
|
||||||
|
[chronicleChain, gnosis],
|
||||||
|
[
|
||||||
|
jsonRpcProvider({
|
||||||
|
rpc: (chain) => ({ http: chain.rpcUrls.default.http[0] })
|
||||||
|
}),
|
||||||
|
jsonRpcProvider({
|
||||||
|
rpc: () => ({
|
||||||
|
http: `https://rpc.gnosischain.com/`,
|
||||||
|
wss: `wss://rpc.gnosischain.com/wss`
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
publicProvider()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
createMessage({
|
||||||
|
text: 'Chains configured successfully...',
|
||||||
|
sender: '$lib/services/provider.ts',
|
||||||
|
type: 'SYSTEM'
|
||||||
|
});
|
||||||
|
|
||||||
|
createConfig({
|
||||||
|
autoConnect: true,
|
||||||
|
connectors: [
|
||||||
|
new InjectedConnector({ chains }),
|
||||||
|
new WalletConnectConnector({
|
||||||
|
chains,
|
||||||
|
options: {
|
||||||
|
projectId: data.walletConnectId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
],
|
||||||
|
publicClient
|
||||||
|
});
|
||||||
|
|
||||||
|
createMessage({
|
||||||
|
text: 'Provider configuration created and autoConnect enabled...',
|
||||||
|
sender: '$lib/services/provider.ts',
|
||||||
|
type: 'SYSTEM'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,18 @@
|
|||||||
<script>
|
<script>
|
||||||
import '../app.css';
|
import '../app.css';
|
||||||
import Provider from '$lib/Provider.svelte';
|
import { initProvider } from '$lib/services/provider.ts';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
/** @type {import('$lib/services/provider.ts').ProviderData} */
|
||||||
|
const providerData = {
|
||||||
|
walletConnectId: import.meta.env.VITE_WALLETCONNECT_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
initProvider(providerData);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Provider />
|
<div class="relative w-screen h-screen overflow-hidden">
|
||||||
|
|
||||||
<div class="w-screen h-screen overflow-hidden relative">
|
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user