Skip to content

Commit

Permalink
Merge pull request #88 from argentlabs/fix/webwallet-argent-mobile
Browse files Browse the repository at this point in the history
Fix/webwallet argent mobile
  • Loading branch information
bluecco authored Mar 21, 2024
2 parents 646de38 + ce4548b commit bbee9e8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/connectors/argentMobile/modal/argentModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ class ArgentModal {
const wcParam = encodeURIComponent(wcUri)
const href = encodeURIComponent(window.location.href)

const desktopWcParam = `${this.mobileUrl}app/wc?uri=${wcParam}`
const desktopWcParam = encodeURIComponent(
`${this.mobileUrl}app/wc?uri=${wcParam}`,
)

this.showModal({
desktop: `${this.bridgeUrl}?wc=${desktopWcParam}&device=desktop`,
Expand Down
33 changes: 23 additions & 10 deletions src/connectors/webwallet/helpers/openWebwallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,30 @@ export const openWebwallet = async (
const { allowedDapps } = await fetchAllowedDapps(network)

if (allowedDapps.includes(window.location.hostname)) {
const { iframe, modal } = await createModal(origin, false)
const windowProxyClient = trpcProxyClient({})
const isConnected = await windowProxyClient.authorize.mutate()
if (isConnected) {
const starknetWindowObject = await getWebWalletStarknetObject(
origin,
trpcProxyClient({ iframe: iframe.contentWindow ?? undefined }),
{ modal, iframe },
)
return starknetWindowObject
const modalId = "argent-webwallet-modal"
const iframeId = "argent-webwallet-iframe"

const existingIframe = document.getElementById(modalId)
const existingModal = document.getElementById(iframeId)

// avoid duplicate iframes
if (existingIframe && existingIframe && existingModal) {
existingIframe.remove()
existingModal.remove()
}
const { iframe, modal } = await createModal(origin, false)

const iframeTrpcProxyClient = trpcProxyClient({
iframe: iframe.contentWindow ?? undefined,
})
await iframeTrpcProxyClient.authorize.mutate()
const starknetWindowObject = await getWebWalletStarknetObject(
origin,
iframeTrpcProxyClient,
{ modal, iframe },
)
return starknetWindowObject
/* } */
} else {
const windowProxyClient = trpcProxyClient({})
return await getWebWalletStarknetObject(
Expand Down
2 changes: 2 additions & 0 deletions src/connectors/webwallet/starknetWindowObject/wormhole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ export const createModal = async (targetUrl: string, shouldShow: boolean) => {
"allow-popups",
)
iframe.allow = "clipboard-write"
iframe.id = "argent-webwallet-iframe"

const modal = applyModalStyle(iframe)
modal.style.display = shouldShow ? "block" : "none"
modal.id = "argent-webwallet-modal"

// append the modal to the body
window.document.body.appendChild(modal)
Expand Down

0 comments on commit bbee9e8

Please sign in to comment.