Skip to content

Commit 0fbb647

Browse files
author
Aleksandar Cakalic
committed
Merge remote-tracking branch 'origin/feat/argent-one-button-connector' into beta
2 parents c601b6c + 3b2b33d commit 0fbb647

File tree

19 files changed

+321
-161
lines changed

19 files changed

+321
-161
lines changed

.releaserc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
{
99
"name": "beta",
1010
"prerelease": true
11+
},
12+
{
13+
"name": "beta-braavos-mobile",
14+
"prerelease": true
1115
}
1216
],
1317
"plugins": [

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
"import": "./dist/braavos.js",
5858
"require": "./dist/braavos.cjs"
5959
},
60+
"./braavosMobile": {
61+
"types": "./dist/braavosMobile.d.ts",
62+
"import": "./dist/braavosMobile.js",
63+
"require": "./dist/braavosMobile.cjs"
64+
},
6065
"./window": {
6166
"types": "./dist/window.d.ts",
6267
"import": "./dist/window.js",
@@ -76,8 +81,8 @@
7681
],
7782
"dependencies": {
7883
"@argent/x-ui": "^1.70.1",
79-
"@starknet-io/get-starknet": "^4.0.0",
80-
"@starknet-io/get-starknet-core": "^4.0.0",
84+
"@starknet-io/get-starknet": "^4.0.2",
85+
"@starknet-io/get-starknet-core": "^4.0.2",
8186
"@starknet-io/types-js": "^0.7.7",
8287
"@trpc/client": "^10.38.1",
8388
"@trpc/server": "^10.38.1",

pnpm-lock.yaml

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/connectors/argent/argentMobile/modal/argentModal.ts

Lines changed: 21 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,6 @@ export interface RequestArguments {
1111
params?: unknown[] | object
1212
}
1313

14-
// TODO - SK-47 - remove this
15-
const overlayStyle = {
16-
position: "fixed",
17-
top: "0",
18-
left: "0",
19-
right: "0",
20-
bottom: "0",
21-
backgroundColor: "rgba(0,0,0,0.8)",
22-
backdropFilter: "blur(10px)",
23-
zIndex: "9999",
24-
display: "flex",
25-
alignItems: "center",
26-
justifyContent: "center",
27-
flexDirection: "column",
28-
color: "white",
29-
fontWeight: "500",
30-
fontFamily: "'Barlow', sans-serif",
31-
}
32-
33-
// TODO - SK-47 - remove this
34-
const iframeStyle = {
35-
width: "840px",
36-
height: "540px",
37-
zIndex: "99999",
38-
backgroundColor: "white",
39-
border: "none",
40-
outline: "none",
41-
borderRadius: "40px",
42-
boxShadow: "0px 4px 40px 0px rgb(0 0 0), 0px 4px 8px 0px rgb(0 0 0 / 25%)",
43-
position: "fixed",
44-
top: "50%",
45-
left: "50%",
46-
transform: "translate(-50%,-50%)",
47-
}
48-
4914
const iframeStyleOnlyQR = {
5015
width: "245px",
5116
height: "245px",
@@ -56,19 +21,6 @@ const iframeStyleOnlyQR = {
5621
outline: "none",
5722
}
5823

59-
// TODO - SK-47 - remove this
60-
const overlayHtml = `
61-
<div id="argent-mobile-modal-container" style="position: relative">
62-
<iframe class="argent-iframe" allow="clipboard-write"></iframe>
63-
<div class="argent-close-button" style="position: absolute; top: 24px; right: 24px; cursor: pointer;">
64-
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
65-
<circle cx="16" cy="16" r="16" fill="#F5F3F0"/>
66-
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.2462 9.75382C22.7018 10.2094 22.7018 10.9481 22.2462 11.4037L17.6499 16L22.2462 20.5963C22.7018 21.0519 22.7018 21.7906 22.2462 22.2462C21.7905 22.7018 21.0519 22.7018 20.5962 22.2462L16 17.6499L11.4039 22.246C10.9482 22.7017 10.2096 22.7017 9.75394 22.246C9.29833 21.7904 9.29833 21.0517 9.75394 20.5961L14.3501 16L9.75394 11.4039C9.29833 10.9483 9.29833 10.2096 9.75394 9.75396C10.2096 9.29835 10.9482 9.29835 11.4039 9.75396L16 14.3501L20.5962 9.75382C21.0519 9.29821 21.7905 9.29821 22.2462 9.75382Z" fill="#333332"/>
67-
</svg>
68-
</div>
69-
</div>
70-
`
71-
7224
const overlayHtmlOnlyQR = `
7325
<div id="argent-mobile-modal-container" style="position: relative; display: flex; justify-content: center; align-items: center">
7426
<iframe class="argent-iframe" allow="clipboard-write"></iframe>
@@ -148,59 +100,46 @@ class ArgentModal {
148100
}
149101
}
150102

151-
// TODO - SK-47 - handle this
152103
public showApprovalModal(_: RequestArguments): void {
153104
if (device === "desktop") {
154-
this.showModalOld({
155-
desktop: `${this.bridgeUrl}?action=sign`,
156-
ios: "",
157-
android: "",
158-
})
105+
this.getModal(undefined, Layout.approval)
159106
return
160107
}
161108
const href = encodeURIComponent(window.location.href)
162-
163-
/*
109+
/*
164110
//https://docs.walletconnect.com/2.0/web3wallet/mobileLinking?platform=ios#ios-wallet-support
165-
Additionally when there is a signing request triggered by the dapp it will hit the deep link with an incomplete URI,
111+
Additionally when there is a signing request triggered by the dapp it will hit the deep link with an incomplete URI,
166112
this should be ignored and not considered valid as it's only used for automatically redirecting the users to approve or reject a signing request.
167113
*/
168-
this.showModalOld({
169-
desktop: `${this.bridgeUrl}?action=sign&device=desktop&href=${href}`,
170-
ios: `${this.mobileUrl}app/wc/request?href=${href}&device=mobile`,
171-
android: `${this.mobileUrl}app/wc/request?href=${href}&device=mobile`,
172-
})
114+
this.showModal(
115+
{
116+
desktop: `${this.bridgeUrl}?action=sign&device=desktop&href=${href}`,
117+
ios: `${this.mobileUrl}app/wc/request?href=${href}&device=mobile`,
118+
android: `${this.mobileUrl}app/wc/request?href=${href}&device=mobile`,
119+
},
120+
undefined,
121+
)
173122
}
174123

175124
public closeModal(success?: boolean) {
176125
const modal = this.standaloneConnectorModal
177126
if (success) {
178127
modal?.$set({ layout: Layout.success })
179-
setTimeout(() => modal?.$destroy(), 3000)
128+
setTimeout(() => modal?.$destroy(), 500)
180129
} else {
181130
modal?.$set({ layout: Layout.failure })
182131
}
183132
}
184133

185-
// TODO - SK-47 - remove this
186-
public closeModalOld(success?: boolean) {
187-
if (success) {
188-
this.overlay
189-
?.querySelector("iframe")
190-
?.contentWindow?.postMessage("argent-login.success", "*")
191-
this.popupWindow?.postMessage("argent-login.success", "*")
192-
this.closingTimeout = setTimeout(this.close, 3400)
193-
} else {
194-
this.close()
195-
}
196-
}
197-
198-
private showModal(urls: Urls, modalWallet: ModalWalletExtended) {
134+
private getModal(
135+
modalWallet?: ModalWalletExtended,
136+
modalLayout: Layout = Layout.qrCode,
137+
) {
199138
this.standaloneConnectorModal = new Modal({
200139
target: getModalTarget(),
201140
props: {
202-
layout: Layout.qrCode,
203-
dappName: modalWallet.dappName,
141+
layout: modalLayout,
142+
dappName: modalWallet?.dappName,
204143
showBackButton: false,
205144
selectedWallet: modalWallet,
206145
callback: async (wallet: ModalWallet | null) => {
@@ -215,64 +154,12 @@ class ArgentModal {
215154
},
216155
},
217156
})
218-
219-
this.getQR(urls)
220157
}
221158

222-
// TODO - SK-47 - remove this
223-
private showModalOld(urls: Urls) {
224-
clearTimeout(this.closingTimeout)
225-
if (this.overlay || this.popupWindow) {
226-
this.close()
227-
}
228-
229-
if (device === "android" || device === "ios") {
230-
const toMobileApp = document.createElement("button")
231-
toMobileApp.style.display = "none"
232-
toMobileApp.addEventListener("click", () => {
233-
window.location.href = urls[device]
234-
})
235-
toMobileApp.click()
159+
private showModal(urls: Urls, modalWallet?: ModalWalletExtended) {
160+
this.getModal(modalWallet, Layout.qrCode)
236161

237-
return
238-
}
239-
if (this.type === "window") {
240-
const features =
241-
"menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=840,height=540"
242-
this.popupWindow =
243-
window.open(urls.desktop, "_blank", features) || undefined
244-
return
245-
}
246-
247-
// type=overlay, device=desktop
248-
const overlay = document.createElement("div")
249-
overlay.innerHTML = overlayHtml
250-
overlay.id = "argent-mobile-modal-overlay"
251-
for (const [key, value] of Object.entries(overlayStyle)) {
252-
overlay.style[key as any] = value
253-
}
254-
document.body.appendChild(overlay)
255-
overlay.addEventListener("click", () => this.closeModal())
256-
this.overlay = overlay
257-
258-
const iframe = overlay.querySelector("iframe") as HTMLIFrameElement
259-
iframe.setAttribute("src", urls.desktop)
260-
for (const [key, value] of Object.entries(iframeStyle)) {
261-
iframe.style[key as any] = value
262-
}
263-
264-
const closeButton = overlay.querySelector(
265-
".argent-close-button",
266-
) as HTMLDivElement
267-
closeButton.addEventListener("click", () => this.closeModal())
268-
}
269-
270-
// TODO - SK-47 - remove this
271-
private close = () => {
272-
this.overlay?.remove()
273-
this.popupWindow?.close()
274-
this.overlay = undefined
275-
this.popupWindow = undefined
162+
this.getQR(urls)
276163
}
277164
}
278165

src/connectors/argent/argentMobile/modal/starknet/adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ export class StarknetAdapter
186186
const chainId = this.formatChainId(this.chainId)
187187
argentModal.showApprovalModal(request)
188188
const response = await this.client.request({ topic, chainId, request })
189-
argentModal.closeModalOld(true)
189+
argentModal.closeModal(true)
190190
return response
191191
} catch (error) {
192-
argentModal.closeModalOld()
192+
argentModal.closeModal()
193193
if (error instanceof Error) {
194194
throw new Error(error.message)
195195
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
export const BRAAVOS_MOBILE_APP_ICON = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32px" height="32px" viewBox="0 0 32 32" version="1.1">
2+
<defs>
3+
<clipPath id="clip1">
4+
<path d="M 5.332031 0 L 26.667969 0 C 29.613281 0 32 2.386719 32 5.332031 L 32 26.667969 C 32 29.613281 29.613281 32 26.667969 32 L 5.332031 32 C 2.386719 32 0 29.613281 0 26.667969 L 0 5.332031 C 0 2.386719 2.386719 0 5.332031 0 Z M 5.332031 0 "/>
5+
</clipPath>
6+
<linearGradient id="linear0" gradientUnits="userSpaceOnUse" x1="-9.552" y1="-6.444" x2="50.240002" y2="41.303001" gradientTransform="matrix(0.666667,0,0,0.666667,0,0)">
7+
<stop offset="0" style="stop-color:rgb(3.529412%,45.09804%,75.294119%);stop-opacity:1;"/>
8+
<stop offset="1" style="stop-color:rgb(10.980392%,28.627452%,87.058824%);stop-opacity:1;"/>
9+
</linearGradient>
10+
<clipPath id="clip2">
11+
<path d="M 7 4 L 25 4 L 25 15 L 7 15 Z M 7 4 "/>
12+
</clipPath>
13+
<clipPath id="clip3">
14+
<path d="M 5.332031 0 L 26.667969 0 C 29.613281 0 32 2.386719 32 5.332031 L 32 26.667969 C 32 29.613281 29.613281 32 26.667969 32 L 5.332031 32 C 2.386719 32 0 29.613281 0 26.667969 L 0 5.332031 C 0 2.386719 2.386719 0 5.332031 0 Z M 5.332031 0 "/>
15+
</clipPath>
16+
<clipPath id="clip4">
17+
<path d="M 6 13 L 26 13 L 26 28 L 6 28 Z M 6 13 "/>
18+
</clipPath>
19+
<clipPath id="clip5">
20+
<path d="M 5.332031 0 L 26.667969 0 C 29.613281 0 32 2.386719 32 5.332031 L 32 26.667969 C 32 29.613281 29.613281 32 26.667969 32 L 5.332031 32 C 2.386719 32 0 29.613281 0 26.667969 L 0 5.332031 C 0 2.386719 2.386719 0 5.332031 0 Z M 5.332031 0 "/>
21+
</clipPath>
22+
</defs>
23+
<g id="surface1">
24+
<g clip-path="url(#clip1)" clip-rule="nonzero">
25+
<rect x="0" y="0" width="32" height="32" style="fill:url(#linear0);stroke:none;"/>
26+
</g>
27+
<g clip-path="url(#clip2)" clip-rule="nonzero">
28+
<g clip-path="url(#clip3)" clip-rule="nonzero">
29+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 19.507812 6.320312 C 19.542969 6.378906 19.496094 6.453125 19.425781 6.453125 C 18.027344 6.453125 16.886719 7.5625 16.859375 8.941406 C 16.375 8.851562 15.878906 8.847656 15.390625 8.929688 C 15.359375 7.554688 14.222656 6.453125 12.824219 6.453125 C 12.757812 6.453125 12.710938 6.378906 12.746094 6.320312 C 13.453125 5.128906 14.738281 4.398438 16.125 4.398438 C 17.515625 4.394531 18.800781 5.125 19.507812 6.320312 M 23.65625 14.847656 C 24.132812 14.992188 24.585938 14.574219 24.402344 14.109375 C 23.066406 10.65625 19.109375 9.242188 16.105469 9.242188 C 13.097656 9.242188 9.054688 10.703125 7.804688 14.128906 C 7.632812 14.589844 8.082031 14.996094 8.550781 14.851562 L 15.75 12.648438 C 15.957031 12.582031 16.179688 12.582031 16.386719 12.644531 Z M 23.65625 14.847656 "/>
30+
</g>
31+
</g>
32+
<g clip-path="url(#clip4)" clip-rule="nonzero">
33+
<g clip-path="url(#clip5)" clip-rule="nonzero">
34+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 7.734375 15.511719 L 15.757812 13.078125 C 15.964844 13.015625 16.183594 13.015625 16.390625 13.078125 L 24.464844 15.511719 C 25.136719 15.714844 25.597656 16.335938 25.597656 17.042969 L 25.597656 24.378906 C 25.566406 26.167969 23.960938 27.605469 22.167969 27.605469 L 19.195312 27.605469 C 19.054688 27.605469 18.917969 27.550781 18.820312 27.449219 C 18.71875 27.347656 18.664062 27.214844 18.664062 27.074219 L 18.664062 24.5 C 18.664062 23.488281 19.261719 22.570312 20.191406 22.164062 C 21.433594 21.621094 22.90625 20.886719 23.183594 19.410156 C 23.269531 18.933594 22.960938 18.472656 22.484375 18.378906 C 21.285156 18.140625 19.953125 18.230469 18.824219 18.734375 C 17.546875 19.308594 17.210938 20.257812 17.085938 21.539062 L 16.9375 22.914062 C 16.890625 23.335938 16.496094 23.65625 16.074219 23.65625 C 15.636719 23.65625 15.308594 23.324219 15.261719 22.886719 L 15.113281 21.539062 C 15.007812 20.441406 14.8125 19.378906 13.683594 18.875 C 12.390625 18.296875 11.09375 18.105469 9.714844 18.378906 C 9.238281 18.472656 8.929688 18.933594 9.015625 19.410156 C 9.296875 20.898438 10.757812 21.617188 12.007812 22.164062 C 12.9375 22.570312 13.535156 23.488281 13.535156 24.5 L 13.535156 27.074219 C 13.535156 27.367188 13.296875 27.605469 13.003906 27.605469 L 10.03125 27.605469 C 8.238281 27.605469 6.628906 26.167969 6.597656 24.378906 L 6.597656 17.039062 C 6.597656 16.335938 7.058594 15.714844 7.734375 15.511719 "/>
35+
</g>
36+
</g>
37+
</g>
38+
</svg>
39+
`
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const isInBraavosMobileAppBrowser = (): boolean => {
2+
if (typeof window === "undefined") {
3+
return false
4+
}
5+
6+
const userAgent = navigator.userAgent.toLowerCase()
7+
const isBraavosMobileApp = userAgent.includes("braavos")
8+
9+
if (!isBraavosMobileApp) {
10+
return false
11+
}
12+
13+
return isBraavosMobileApp
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./inAppBrowser"

0 commit comments

Comments
 (0)