Skip to content

Commit d851c8a

Browse files
authored
Merge pull request #239 from argentlabs/fix/bug-edge-case
Fix/bug edge case
2 parents 6dcb706 + 18882a2 commit d851c8a

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

src/helpers/mapModalWallets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function getModalWallet(
5454
id: connector.id,
5555
icon: isCompound ? connectorOrCompoundConnector.icon : connector.icon,
5656
connector: connectorOrCompoundConnector,
57-
installed: true,
57+
installed: false,
5858
title:
5959
"title" in connector && isString(connector.title)
6060
? connector.title

src/main.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type {
1414
StarknetkitConnector,
1515
ConnectorData,
1616
} from "./connectors"
17-
import { DEFAULT_WEBWALLET_URL } from "./connectors/webwallet/constants"
1817

1918
import { ArgentMobileBaseConnector } from "./connectors/argent/argentMobile"
2019
import { defaultConnectors } from "./helpers/defaultConnectors"
@@ -73,9 +72,6 @@ export const connect = async ({
7372
skipEmit = false,
7473
...restOptions
7574
}: ConnectOptionsWithConnectors | ConnectOptions): Promise<ModalResult> => {
76-
const { webWalletUrl = DEFAULT_WEBWALLET_URL, argentMobileOptions } =
77-
restOptions as ConnectOptions
78-
7975
const { connectors } = restOptions as ConnectOptionsWithConnectors
8076

8177
// force null in case it was disconnected from mobile app
@@ -248,6 +244,7 @@ export const connect = async ({
248244
},
249245
theme: modalTheme === "system" ? null : (modalTheme ?? null),
250246
modalWallets,
247+
discoveryWallets,
251248
},
252249
}) as unknown as ModalInstance // Prevents vite build errors
253250
})

src/modal/Modal.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { onMount } from "svelte"
3+
import type { WalletProvider } from "@starknet-io/get-starknet-core"
34
45
import {
56
type Callback,
@@ -39,6 +40,7 @@
3940
return layout
4041
}
4142
43+
export let discoveryWallets: WalletProvider[]
4244
export let modalWallets: ModalWallet[] = []
4345
export let selectedWallet: ModalWallet | null = null
4446
$: selectedConnector =
@@ -98,7 +100,9 @@
98100
99101
if (modalWallets.length === 1) {
100102
try {
101-
await callback(modalWallets[0])
103+
setTimeout(() => {
104+
void callback(modalWallets[0])
105+
})
102106
} catch (e) {
103107
console.error(e)
104108
}
@@ -174,6 +178,8 @@
174178
extensionName={selectedWallet?.name.includes("Ready")
175179
? "Ready Wallet (formerly Argent)"
176180
: selectedConnector?.name}
181+
extensionId={selectedWallet?.id}
182+
discoveryWallets={discoveryWallets}
177183
/>
178184
{/if}
179185
</main>

src/modal/layouts/DownloadWallet/DownloadWallet.svelte

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
2-
import { StoreVersion } from "../../../types/modal"
2+
import type { WalletProvider } from "@starknet-io/get-starknet-core"
3+
import type { StoreVersion } from "../../../types/modal"
34
45
import AppleIcon from "../../components/icons/brands/AppleIcon.svelte"
56
import PlayStore from "../../components/icons/brands/PlayStore.svelte"
@@ -16,9 +17,14 @@
1617
import HorizontalLine from "../../components/HorizontalLine.svelte"
1718
1819
export let isArgent: boolean = false
20+
export let extensionId: string = ""
1921
export let extensionName: string = ""
2022
export let store: StoreVersion | null
2123
export let storeLink: string | undefined
24+
export let discoveryWallets: WalletProvider[]
25+
26+
const discoveredWallet = discoveryWallets.find((w: WalletProvider) => w.id.toLowerCase() === extensionId.toLowerCase())
27+
const discoveredWalletDownloads = Object.entries(discoveredWallet?.downloads || {})
2228
2329
const storeData = {
2430
// @dev - Be mindful of name property length, it might break the UI
@@ -39,6 +45,7 @@
3945

4046
<section class="flex flex-col flex-grow justify-between">
4147
<div class="flex flex-col gap-2">
48+
<!-- Upon removal of Argent mobile, remove and code else `!isArgent` if case from line 84 -->
4249
{#if isArgent}
4350
<ArgentDownloadItem
4451
title="Ready mobile"
@@ -80,6 +87,16 @@
8087
{/if}
8188
</svelte:fragment>
8289
</ArgentDownloadItem>
90+
{:else if !isArgent}
91+
<p class="text-[16px] text-primary">
92+
<span class="capitalize">{extensionName}</span> is not available on your browser.<br/><br/>
93+
{#if discoveredWalletDownloads.length > 0}
94+
Try on other browsers:{" "}
95+
{#each discoveredWalletDownloads as discovery, i}
96+
<Link as="a" className="capitalize" href={discovery[1]}>{discovery[0]}</Link>{i + 1 === discoveredWalletDownloads.length ? "." : ", "}
97+
{/each}
98+
{/if}
99+
</p>
83100
{/if}
84101
</div>
85102

src/modal/layouts/WalletList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { Callback, ModalWallet, Theme } from "../../types/modal"
2+
import type { Callback, ModalWallet, Theme } from "../../types/modal"
33
import WalletButton from "../components/buttons/WalletButton.svelte"
44
55
export let theme: Theme

0 commit comments

Comments
 (0)