Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Web3Modal paths in readme + Svelte demo link #450

Merged
merged 6 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions dapps/web3modal/svelte/src/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
box-sizing: border-box;
margin: 0;
padding: 0;

scrollbar-width: thin;
scrollbar-color: #fff #141414;
}

body, html{
Expand All @@ -22,11 +19,6 @@ body, html{
font-family: 'montserrat';
}

*::selection{
background-color: rgb(255, 255, 255);
color: #141414;
}

::-webkit-scrollbar {
background: #141414;
width: 9px;
Expand Down
28 changes: 19 additions & 9 deletions dapps/web3modal/svelte/src/lib/web3modal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { defaultWagmiConfig, createWeb3Modal } from '@web3modal/wagmi'

import { getAccount, getChainId, reconnect, watchAccount, watchChainId } from '@wagmi/core'
import {
getAccount,
getChainId,
reconnect,
watchAccount,
watchChainId,
} from '@wagmi/core'
import { readable, writable } from 'svelte/store'

import {
Expand Down Expand Up @@ -64,20 +70,24 @@ createWeb3Modal({
projectId,
themeMode: 'dark',
featuredWalletIds: [],
enableAnalytics: true
enableAnalytics: true,
})

export const chainId = readable(getChainId(wagmiConfig), (set) => watchChainId(wagmiConfig, { onChange: set }))
export const account = readable(getAccount(wagmiConfig), (set) => watchAccount(wagmiConfig, { onChange: set }))
export const chainId = readable(getChainId(wagmiConfig), (set) =>
watchChainId(wagmiConfig, { onChange: set }),
)
export const account = readable(getAccount(wagmiConfig), (set) =>
watchAccount(wagmiConfig, { onChange: set }),
)
export const provider = readable<ExtendedProvider | undefined>(
undefined,
(set) =>
watchAccount(wagmiConfig, {
onChange: async (account) => {
if (!account.connector) return set(undefined)
set(await account.connector?.getProvider())
}
}),
onChange: async (account) => {
if (!account.connector) return set(undefined)
set(await account.connector?.getProvider())
},
}),
)

export const supported_chains = writable<string[]>([])
28 changes: 14 additions & 14 deletions dapps/web3modal/svelte/src/partials/Network.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
<span id="title">Chain ID:</span>
{$chainId}
</span>
{#if $account.chain}
<span>
<span id="title">Network:</span>
{$account.chain?.name}
</span>
<span>
<span id="title">Decimals:</span>
{$account.chain?.nativeCurrency.decimals}
</span>
<span>
<span id="title">Currency:</span>
{$account.chain?.nativeCurrency.name}
</span>
{/if}
{#if $account.chain}
<span>
<span id="title">Network:</span>
{$account.chain?.name}
</span>
<span>
<span id="title">Decimals:</span>
{$account.chain?.nativeCurrency.decimals}
</span>
<span>
<span id="title">Currency:</span>
{$account.chain?.nativeCurrency.name}
</span>
{/if}
</Card>
{/if}

Expand Down
68 changes: 0 additions & 68 deletions dapps/web3modal/svelte/src/partials/SwitchChain.svelte

This file was deleted.

2 changes: 1 addition & 1 deletion dapps/web3modal/svelte/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<span class="btn">
<w3m-button />
<a
href="https://github.com/WalletConnect/evm-e2e-dapp"
href="https://github.com/WalletConnect/web-examples/tree/main/dapps/web3modal/svelte"
target="_blank"
rel="noreferrer nofollow"
>
Expand Down
2 changes: 0 additions & 2 deletions dapps/web3modal/svelte/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import Network from '../partials/Network.svelte'
import SignMessage from '../partials/SignMessage.svelte'
import SignTypeData from '../partials/SignTypeData.svelte'
import SwitchChain from '../partials/SwitchChain.svelte'
import Transaction from '../partials/Transaction.svelte'
import Wallet from '../partials/Wallet.svelte'
</script>
Expand All @@ -15,7 +14,6 @@
{#if $account.isConnected}
<SignMessage />
<SignTypeData />
<SwitchChain />
<Transaction />
{/if}
</div>
Expand Down
Loading