Skip to content

Commit

Permalink
fix(app): wallet fix (#2071)
Browse files Browse the repository at this point in the history
Update `$cosmosStore` so we don't have old wallet values.
  • Loading branch information
cor authored Jun 8, 2024
2 parents aac38a1 + 8f16798 commit f7122b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
20 changes: 13 additions & 7 deletions app/src/lib/wallet/cosmos/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,19 @@ function createCosmosStore(
disconnect: async () => {
const cosmosWalletId = get({ subscribe }).connectedWallet as CosmosWalletId
console.log("[cosmos] cosmosDisconnectClick", get(cosmosStore))
if (cosmosWalletId && cosmosWalletId === "keplr" && window[cosmosWalletId]) {
await window[cosmosWalletId]?.disable("union-testnet-8")
update(v => ({ ...v, connectedWallet: "none", connectionStatus: "disconnected" }))
}
if (cosmosWalletId && cosmosWalletId === "leap" && window[cosmosWalletId]) {
await window[cosmosWalletId]?.disconnect("union-testnet-8")
update(v => ({ ...v, connectedWallet: "none", connectionStatus: "disconnected" }))
if (cosmosWalletId && window[cosmosWalletId]) {
if (cosmosWalletId === "keplr") {
await window[cosmosWalletId]?.disable("union-testnet-8")
} else if (cosmosWalletId === "leap") {
await window[cosmosWalletId]?.disconnect("union-testnet-8")
}
update(v => ({
...v,
connectedWallet: "none",
connectionStatus: "disconnected",
address: undefined,
rawAddress: undefined
}))
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion app/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ $: if (
address: $cosmosStore.rawAddress
})
}
$: if ($cosmosStore.connectionStatus === "disconnected") cosmosBalances = null
</script>

<main class="flex flex-col items-center w-full p-4 mt-16 gap-6">
Expand Down Expand Up @@ -98,7 +100,11 @@ $: if (
{#each $cosmosBalances as balance, index}
<div>
<h3 class="font-bold">{$cosmosChains[index].display_name}</h3>
<div class="text-xs font-mono text-muted-foreground">{rawToBech32($cosmosChains[index].addr_prefix, $cosmosStore.rawAddress)}</div>
{#if $cosmosChains[index]?.addr_prefix && $cosmosStore.rawAddress && $cosmosStore.rawAddress.length > 0}
<div class="text-xs font-mono text-muted-foreground">
{rawToBech32($cosmosChains[index].addr_prefix, $cosmosStore.rawAddress)}
</div>
{/if}
{#if balance.isLoading}
<p class="text-muted-foreground">Loading...</p>
{:else if balance.isError}
Expand Down

0 comments on commit f7122b3

Please sign in to comment.