Skip to content

Commit c601b6c

Browse files
author
Aleksandar Cakalic
committed
Merge branch 'refs/heads/feat/argent-one-button-connector' into beta
2 parents d93a9f5 + e8de757 commit c601b6c

File tree

13 files changed

+170
-129
lines changed

13 files changed

+170
-129
lines changed

src/connectors/argent/argentMobile/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sn from "@starknet-io/get-starknet-core"
12
import { type AccountChangeEventHandler } from "@starknet-io/get-starknet-core"
23
import {
34
Permission,
@@ -222,7 +223,7 @@ export class ArgentMobileBaseConnector extends Connector {
222223
url,
223224
icons,
224225
rpcUrl: providerRpcUrl,
225-
modalWallet: getModalWallet(this),
226+
modalWallet: getModalWallet(this, await sn.getDiscoveryWallets()),
226227
}
227228

228229
if (projectId === DEFAULT_PROJECT_ID) {

src/helpers/mapModalWallets.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ARGENT_X_ICON } from "../connectors/injected/constants"
99
import type { ModalWallet, StoreVersion } from "../types/modal"
1010
import { isInArgentMobileAppBrowser } from "../connectors/argent/helpers"
1111
import { extractConnector, findConnectorById } from "./connector"
12+
import { getStoreVersionFromBrowser } from "./getStoreVersionFromBrowser"
1213

1314
interface SetConnectorsExpandedParams {
1415
availableConnectors: (StarknetkitConnector | StarknetkitCompoundConnector)[]
@@ -23,7 +24,13 @@ export function getModalWallet(
2324
| StarknetkitConnector
2425
| StarknetkitCompoundConnector,
2526
discoveryWallets?: WalletProvider[],
27+
_storeVersion?: StoreVersion | null,
2628
): ModalWallet {
29+
let storeVersion = _storeVersion
30+
if (!storeVersion) {
31+
storeVersion = getStoreVersionFromBrowser()
32+
}
33+
2734
const connector = extractConnector(
2835
connectorOrCompoundConnector,
2936
) as StarknetkitConnector
@@ -32,6 +39,11 @@ export function getModalWallet(
3239
connectorOrCompoundConnector as StarknetkitCompoundConnector
3340
).isCompoundConnector
3441

42+
const downloads = discoveryWallets?.find(
43+
(d) =>
44+
d.id === (connector.id === "argentMobile" ? "argentX" : connector.id),
45+
)?.downloads
46+
3547
return {
3648
name: isCompoundConnector
3749
? connectorOrCompoundConnector.name
@@ -50,7 +62,8 @@ export function getModalWallet(
5062
"subtitle" in connector && isString(connector.subtitle)
5163
? connector.subtitle
5264
: undefined,
53-
downloads: discoveryWallets?.find((d) => d.id === connector.id)?.downloads,
65+
download: downloads?.[storeVersion as keyof typeof downloads],
66+
downloads: downloads,
5467
}
5568
}
5669

@@ -92,6 +105,7 @@ export const mapModalWallets = ({
92105
if (installed) {
93106
let icon
94107
let name
108+
let download
95109

96110
if (isCompoundConnector) {
97111
icon = _c.icon
@@ -107,13 +121,18 @@ export const mapModalWallets = ({
107121
name = installed.name
108122
}
109123

124+
const downloads = discoveryWallets.find(
125+
(d) => d.id === (installed.id === "argentMobile" ? "argentX" : c?.id),
126+
)?.downloads
127+
110128
return {
111129
name,
112130
id: installed.id,
113131
icon,
114132
connector: _c,
115133
installed: true,
116-
downloads: discoveryWallets.find((d) => d.id === c?.id)?.downloads,
134+
download: downloads?.[storeVersion as keyof typeof downloads],
135+
downloads: downloads,
117136
}
118137
}
119138

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export const connect = async ({
170170
modal.$set({ selectedWallet: modalWallet })
171171

172172
if (!modalWallet.installed) {
173-
modal.$set({ layout: Layout.extensionDownloadList })
173+
modal.$set({ layout: Layout.download })
174174
return
175175
}
176176

@@ -223,7 +223,7 @@ export const connect = async ({
223223
theme: modalTheme === "system" ? null : (modalTheme ?? null),
224224
modalWallets,
225225
},
226-
}) as ModalInstance // Prevents vite build errors
226+
}) as unknown as ModalInstance // Prevents vite build errors
227227
})
228228
}
229229

src/modal/Modal.svelte

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
import ArgentMobileQR from "./layouts/argent/ArgentMobileQR.svelte"
1010
import FailedLogin from "./layouts/FailedLogin.svelte"
1111
import SuccessfulLogin from "./layouts/SuccessfulLogin.svelte"
12-
import ArgentDownload from "./layouts/argent/ArgentDownload/ArgentDownload.svelte"
13-
import ExtensionDownloadList from "./layouts/ExtensionDownloadList/ExtensionDownloadList.svelte"
12+
import DownloadWallet from "./layouts/DownloadWallet/DownloadWallet.svelte"
1413
import DynamicIcon from "./components/DynamicIcon.svelte"
1514
1615
import { isInArgentMobileAppBrowser } from "../connectors/argent/helpers"
1716
import { extractConnector } from "../helpers/connector"
1817
import { StarknetkitCompoundConnector } from "../connectors"
1918
import { ArgentX } from "../connectors/injected/argentX"
2019
import { getModalWallet } from "../helpers/mapModalWallets"
20+
import { getStoreVersionFromBrowser } from "../helpers/getStoreVersionFromBrowser"
2121
2222
let nodeRef: HTMLElement | undefined
2323
@@ -117,11 +117,14 @@
117117
handleFallback={() => callback(selectedWallet, true)}
118118
/>
119119
{:else if layout === Layout.qrCode}
120-
<ArgentMobileQR handleInstallClick={() => setLayout(Layout.argentDownload)} />
121-
{:else if layout === Layout.extensionDownloadList}
122-
<ExtensionDownloadList downloadLinks={selectedWallet?.downloads} extensionName={selectedWallet?.name} />
123-
{:else if layout === Layout.argentDownload}
124-
<ArgentDownload showInstallExtension={Boolean(selectedWallet?.downloads)} handleExtensionClick={() => setLayout(Layout.extensionDownloadList)} />
120+
<ArgentMobileQR handleInstallClick={() => setLayout(Layout.download)} />
121+
{:else if layout === Layout.download}
122+
<DownloadWallet
123+
store={getStoreVersionFromBrowser()}
124+
isArgent={Boolean(selectedConnector && (selectedConnector?.id === "argentMobile" || selectedConnector?.id === "argentX"))}
125+
storeLink={selectedWallet?.download}
126+
extensionName={selectedWallet?.name === "Argent" ? "Argent X" : selectedConnector?.name}
127+
/>
125128
{/if}
126129

127130
</main>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<script lang="ts">
2+
import { StoreVersion } from "../../../types/modal"
3+
4+
import AppleIcon from "../../components/icons/brands/AppleIcon.svelte";
5+
import PlayStore from "../../components/icons/brands/PlayStore.svelte";
6+
import ChromeIcon from "../../components/icons/brands/ChromeIcon.svelte";
7+
import EdgeIcon from "../../components/icons/brands/EdgeIcon.svelte"
8+
import FirefoxIcon from "../../components/icons/brands/FirefoxIcon.svelte"
9+
10+
import ArgentMobileGraphic from "./graphics/ArgentMobileGraphic.svelte";
11+
import ArgentXGraphic from "./graphics/ArgentXGraphic.svelte";
12+
import GeneralizedGraphic from "./graphics/GeneralizedGraphic.svelte"
13+
14+
import ArgentDownloadItem from "./DownloadWalletItem.svelte";
15+
import Link from "../../components/buttons/Link.svelte";
16+
import HorizontalLine from "../../components/HorizontalLine.svelte";
17+
18+
export let isArgent: boolean = false;
19+
export let extensionName: string = ""
20+
export let store: StoreVersion | null;
21+
export let storeLink: string | undefined;
22+
23+
const storeData = ({ // @dev - Be mindful of name property length, it might break the UI
24+
chrome: {
25+
name: "Chrome",
26+
icon: ChromeIcon,
27+
},
28+
edge: {
29+
name: "Edge",
30+
icon: EdgeIcon,
31+
},
32+
firefox: {
33+
name: "Firefox",
34+
icon: FirefoxIcon,
35+
}
36+
})
37+
</script>
38+
39+
<section class="flex flex-col flex-grow justify-between">
40+
<div class="flex flex-col gap-2">
41+
{#if isArgent}
42+
<ArgentDownloadItem title="Argent mobile" subtitle="Download Argent wallet on your mobile." link="https://www.argent.xyz/app">
43+
<svelte:fragment slot="icons">
44+
<AppleIcon />
45+
<PlayStore />
46+
</svelte:fragment>
47+
48+
<svelte:fragment slot="button">
49+
Download
50+
</svelte:fragment>
51+
52+
<svelte:fragment slot="graphic">
53+
<ArgentMobileGraphic />
54+
</svelte:fragment>
55+
</ArgentDownloadItem>
56+
{/if}
57+
58+
{#if store && storeLink}
59+
<ArgentDownloadItem title={extensionName} subtitle={`Install ${extensionName} extension.`} link={storeLink}>
60+
<svelte:fragment slot="button">
61+
<div class="flex gap-1 items-center whitespace-nowrap">
62+
<svelte:component this={storeData[store].icon} /> Install for {storeData[store].name}
63+
</div>
64+
</svelte:fragment>
65+
66+
<svelte:fragment slot="graphic">
67+
{#if isArgent}
68+
<ArgentXGraphic />
69+
{:else}
70+
<GeneralizedGraphic />
71+
{/if}
72+
</svelte:fragment>
73+
</ArgentDownloadItem>
74+
{/if}
75+
</div>
76+
77+
<footer class="flex flex-col gap-4">
78+
{#if isArgent}
79+
<HorizontalLine />
80+
<p class="text-[13px] text-secondary">If you want to learn more about argent visit our site:
81+
<Link as="a" className="text-brand" href="https://www.argent.xyz/">www.argent.xyz</Link>
82+
</p>
83+
{/if}
84+
</footer>
85+
</section>

src/modal/layouts/argent/ArgentDownload/ArgentDownloadItem.svelte renamed to src/modal/layouts/DownloadWallet/DownloadWalletItem.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import Button from "../../../components/buttons/Button.svelte";
2+
import Button from "../../components/buttons/Button.svelte";
33
44
export let title: string
55
export let subtitle: string
@@ -8,12 +8,12 @@
88
</script>
99

1010
<div class="flex flex-row gap-3 px-4 py-3 rounded-xl bg-surface-elevated">
11-
<div class="flex flex-col gap-3 flex-grow">
11+
<div class="flex flex-col gap-3">
1212
<div class="flex flex-col gap-1 text-left">
13-
<h4 class="text-heading5 text-primary">{title}</h4>
13+
<h4 class="text-heading5 text-primary capitalize">{title}</h4>
1414
<p class="text-l1 text-secondary-web">{subtitle}</p>
1515
</div>
16-
<div class="flex gap-3">
16+
<div class="flex gap-3 text-primary">
1717
<slot name="icons" />
1818
</div>
1919
<Button
@@ -25,9 +25,9 @@
2525
handleClick()
2626
}
2727
}}
28-
className="bg-button-secondary text-primary hover:bg-button-secondary-hover flex w-[140px] h-[32px] text-b3 rounded-3xl justify-center items-center"
28+
className="bg-button-secondary text-primary hover:bg-button-secondary-hover flex w-full h-[32px] text-b3 rounded-3xl justify-center items-center"
2929
>
30-
Download
30+
<slot name="button" />
3131
</Button>
3232
</div>
3333
<div class="flex items-center">

src/modal/layouts/argent/ArgentDownload/graphics/MobileGraphic.svelte renamed to src/modal/layouts/DownloadWallet/graphics/ArgentMobileGraphic.svelte

File renamed without changes.

src/modal/layouts/argent/ArgentDownload/graphics/ArgentXGraphic.svelte renamed to src/modal/layouts/DownloadWallet/graphics/ArgentXGraphic.svelte

File renamed without changes.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<svg width="109" height="109" viewBox="0 0 109 109" fill="none" xmlns="http://www.w3.org/2000/svg">
2+
<mask id="mask0_697_1274" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="109" height="109">
3+
<ellipse cx="54.201" cy="54.2667" rx="53.9" ry="54.2667" fill="#F2F2F2"/>
4+
</mask>
5+
<g mask="url(#mask0_697_1274)">
6+
<path d="M54.4182 108.477C84.171 108.477 108.29 84.1937 108.29 54.2386C108.29 24.2834 84.171 0 54.4182 0C24.6655 0 0.546143 24.2834 0.546143 54.2386C0.546143 84.1937 24.6655 108.477 54.4182 108.477Z" fill="#BFBFBF" fill-opacity="0.2"/>
7+
<rect x="16.4709" y="21.7067" width="75.46" height="105.573" rx="4.9" fill="black"/>
8+
<ellipse opacity="0.4" cx="54.2011" cy="44.3999" rx="9.31" ry="9.37333" fill="#6D6D6D"/>
9+
<rect x="49.791" y="43.4133" width="5.39" height="1.97333" rx="0.986666" fill="#8C8C8C"/>
10+
<rect x="56.6511" y="43.4133" width="1.96" height="1.97333" rx="0.98" fill="#8C8C8C"/>
11+
<rect x="49.301" y="27.6266" width="10.29" height="1.48" rx="0.74" fill="#595959"/>
12+
<rect x="21.3711" y="69.4933" width="65.66" height="11.76" rx="1.96" fill="#3A3A3A"/>
13+
<rect x="31.1711" y="73.4133" width="18.62" height="1.47" rx="0.735" fill="#CDCDCD"/>
14+
<rect x="31.1711" y="75.8633" width="34.3" height="1.47" rx="0.735" fill="#8C8C8C"/>
15+
<path fill-rule="evenodd" clip-rule="evenodd" d="M83.52 75.373C83.52 74.0199 82.4231 72.923 81.07 72.923H78.2117C76.8586 72.923 75.7617 74.0199 75.7617 75.373C75.7617 76.7261 76.8586 77.823 78.2117 77.823H81.07C82.4231 77.823 83.52 76.7261 83.52 75.373Z" fill="#919191"/>
16+
<g filter="url(#filter0_d_697_1274)">
17+
<path fill-rule="evenodd" clip-rule="evenodd" d="M81.0701 77.4147C79.9426 77.4147 79.0285 76.5006 79.0285 75.373C79.0285 74.2454 79.9426 73.3314 81.0701 73.3314C82.1977 73.3314 83.1118 74.2454 83.1118 75.373C83.1118 76.5006 82.1977 77.4147 81.0701 77.4147Z" fill="#CDCDCD"/>
18+
</g>
19+
<path d="M24.8874 74.0835C24.9425 74.03 25.0173 74 25.0953 74H27.4473C27.5252 74 27.6 74.03 27.6552 74.0835C27.7103 74.137 27.7413 74.2095 27.7413 74.2851V75.1219C27.7413 76.4368 26.5897 76.8719 26.3658 76.9442C26.3046 76.9653 26.2379 76.9653 26.1768 76.9442C25.9528 76.8719 24.8013 76.4368 24.8013 75.1219V74.2851C24.8013 74.2095 24.8322 74.137 24.8874 74.0835Z" fill="#CDCDCD"/>
20+
<rect x="21.3711" y="87.1334" width="65.66" height="6.86" rx="1.96" fill="#262626"/>
21+
<rect x="30.6812" y="90.0734" width="34.79" height="1.47" rx="0.735" fill="#595959"/>
22+
<path d="M81.1511 89.5834L82.1311 90.5634L81.1511 91.5434" stroke="#595959" stroke-width="0.98" stroke-linecap="round" stroke-linejoin="round"/>
23+
<rect x="25.7812" y="89.5834" width="2.45" height="2.45" rx="0.49" fill="#595959"/>
24+
<rect x="21.3711" y="96.9333" width="65.66" height="6.86" rx="1.96" fill="#262626"/>
25+
<rect x="30.6812" y="99.8734" width="34.79" height="1.47" rx="0.735" fill="#595959"/>
26+
<path d="M81.1511 99.3834L82.1311 100.363L81.1511 101.343" stroke="#595959" stroke-width="0.98" stroke-linecap="round" stroke-linejoin="round"/>
27+
<rect x="25.7812" y="99.3834" width="2.45" height="2.45" rx="0.49" fill="#595959"/>
28+
<rect x="21.3711" y="59.6934" width="65.66" height="6.86" rx="1.96" fill="#0F0F0F"/>
29+
<rect x="39.0112" y="62.6334" width="30.87" height="1.47" rx="0.735" fill="#595959"/>
30+
<rect x="80.1711" y="62.1434" width="2.45" height="2.45" rx="0.49" fill="#595959"/>
31+
</g>
32+
<defs>
33+
<filter id="filter0_d_697_1274" x="78.7019" y="73.3314" width="4.73659" height="4.73665" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
34+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
35+
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
36+
<feOffset dy="0.326667"/>
37+
<feGaussianBlur stdDeviation="0.163333"/>
38+
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"/>
39+
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_697_1274"/>
40+
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_697_1274" result="shape"/>
41+
</filter>
42+
</defs>
43+
</svg>

src/modal/layouts/ExtensionDownloadList/ExtensionDownloadItem.svelte

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)