From 239b555f9cd67210af4d9466f786a1daf36c6047 Mon Sep 17 00:00:00 2001 From: bluecco Date: Thu, 12 Oct 2023 09:37:46 +0200 Subject: [PATCH 1/7] fix: argent mobile project id and refactor constants --- src/connectors/argentMobile/constants.ts | 1 + src/connectors/argentMobile/index.ts | 2 +- src/{constants/index.ts => connectors/injected/constants.ts} | 4 ---- src/connectors/webwallet/constants.ts | 1 + src/connectors/webwallet/index.ts | 3 +-- src/helpers/getWallets.ts | 2 +- src/helpers/mapModalWallets.ts | 2 +- src/main.ts | 2 +- 8 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 src/connectors/argentMobile/constants.ts rename src/{constants/index.ts => connectors/injected/constants.ts} (92%) create mode 100644 src/connectors/webwallet/constants.ts diff --git a/src/connectors/argentMobile/constants.ts b/src/connectors/argentMobile/constants.ts new file mode 100644 index 0000000..cfda51d --- /dev/null +++ b/src/connectors/argentMobile/constants.ts @@ -0,0 +1 @@ +export const DEFAULT_PROJECT_ID = "f2e613881f7a0e811295cdd57999e31b" diff --git a/src/connectors/argentMobile/index.ts b/src/connectors/argentMobile/index.ts index 6759a8d..d21edfc 100644 --- a/src/connectors/argentMobile/index.ts +++ b/src/connectors/argentMobile/index.ts @@ -4,7 +4,7 @@ import type { } from "get-starknet-core" import type { AccountInterface } from "starknet" import { constants } from "starknet" -import { DEFAULT_PROJECT_ID } from "../../constants" +import { DEFAULT_PROJECT_ID } from "./constants" import { ConnectorNotConnectedError, ConnectorNotFoundError, diff --git a/src/constants/index.ts b/src/connectors/injected/constants.ts similarity index 92% rename from src/constants/index.ts rename to src/connectors/injected/constants.ts index b12d846..c621231 100644 --- a/src/constants/index.ts +++ b/src/connectors/injected/constants.ts @@ -1,5 +1 @@ -export const DEFAULT_WEBWALLET_URL = "https://web.argent.xyz" - -export const DEFAULT_PROJECT_ID = "d7615e8fcbb3757ec0771a14ca715d09" - export const ARGENT_X_ICON = `data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0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UMyMS43ODk1IDcuNzA5MDYgMjEuNzg3MyA3LjQwMTc3IDIyLjAwMTEgNy4zMzIwMUwyMy41NDY5IDYuODI0NjZDMjMuODYwOSA2LjcyMTQ2IDI0LjEwNiA2LjQ2OTUyIDI0LjIwMjcgNi4xNTAxMUwyNC42Nzk4IDQuNTc1MDJDMjQuNzQ1OCA0LjM1NzA5IDI1LjA0ODkgNC4zNTQ3NyAyNS4xMTgzIDQuNTcxNTZMMjUuNjE4OCA2LjEzOTE1QzI1LjcyMDYgNi40NTc0IDI1Ljk2ODYgNi43MDUzMSAyNi4yODQyIDYuODAzOUwyNy44MzggNy4yODc2MUMyOC4wNTI0IDcuMzU0NSAyOC4wNTQ3IDcuNjYxNzkgMjcuODQwOCA3LjczMjEzTDI2LjI5NSA4LjIzOTQ4QzI1Ljk4MTEgOC4zNDIxIDI1LjczNiA4LjU5NDA0IDI1LjYzOTMgOC45MTQwMkwyNS4xNjIxIDEwLjQ4ODVDMjUuMDk2MSAxMC43MDY1IDI0Ljc5MyAxMC43MDg4IDI0LjcyMzYgMTAuNDkyWiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==` diff --git a/src/connectors/webwallet/constants.ts b/src/connectors/webwallet/constants.ts new file mode 100644 index 0000000..99b24ab --- /dev/null +++ b/src/connectors/webwallet/constants.ts @@ -0,0 +1 @@ +export const DEFAULT_WEBWALLET_URL = "https://web.argent.xyz" diff --git a/src/connectors/webwallet/index.ts b/src/connectors/webwallet/index.ts index 17d5b63..3aa293e 100644 --- a/src/connectors/webwallet/index.ts +++ b/src/connectors/webwallet/index.ts @@ -13,8 +13,7 @@ import { UserRejectedRequestError, } from "../../errors" import { getWebWalletStarknetObject } from "./starknetWindowObject/getWebWalletStarknetObject" - -const DEFAULT_WEBWALLET_URL = "https://web.argent.xyz" +import { DEFAULT_WEBWALLET_URL } from "./constants" let _wallet: StarknetWindowObject | null = null diff --git a/src/helpers/getWallets.ts b/src/helpers/getWallets.ts index 497ef2e..cb417ef 100644 --- a/src/helpers/getWallets.ts +++ b/src/helpers/getWallets.ts @@ -1,5 +1,5 @@ import type { StarknetWindowObject, WalletProvider } from "get-starknet-core" -import { ARGENT_X_ICON } from "../constants" +import { ARGENT_X_ICON } from "../connectors/injected/constants" export const replaceArgentXIcon = async ( wallets: StarknetWindowObject[] | WalletProvider[], diff --git a/src/helpers/mapModalWallets.ts b/src/helpers/mapModalWallets.ts index b8a9973..9aeb4c0 100644 --- a/src/helpers/mapModalWallets.ts +++ b/src/helpers/mapModalWallets.ts @@ -1,6 +1,6 @@ import type { StarknetWindowObject, WalletProvider } from "get-starknet-core" import { Connector } from "../connectors/connector" -import { ARGENT_X_ICON } from "../constants" +import { ARGENT_X_ICON } from "../connectors/injected/constants" import type { ModalWallet, StoreVersion } from "../types/modal" interface SetConnectorsExpandedParams { diff --git a/src/main.ts b/src/main.ts index bb936a1..b83eb98 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,7 @@ import sn from "get-starknet-core" import { getStoreVersionFromBrowser } from "./helpers/getStoreVersionFromBrowser" -import { DEFAULT_WEBWALLET_URL } from "./constants" +import { DEFAULT_WEBWALLET_URL } from "./connectors/webwallet/constants" import { defaultConnectors } from "./helpers/defaultConnectors" import { mapModalWallets } from "./helpers/mapModalWallets" import { resetWalletConnect } from "./helpers/resetWalletConnect" From c8b9646aa5ce1db4486ac90ddeb7988a643941fa Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 12 Oct 2023 07:43:19 +0000 Subject: [PATCH 2/7] chore(release): 1.0.7 [skip ci] ## [1.0.7](https://github.com/argentlabs/starknetkit/compare/v1.0.6...v1.0.7) (2023-10-12) ### Bug Fixes * argent mobile project id and refactor constants ([239b555](https://github.com/argentlabs/starknetkit/commit/239b555f9cd67210af4d9466f786a1daf36c6047)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 994a917..31c176e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "starknetkit", - "version": "1.0.6", + "version": "1.0.7", "repository": "github:argentlabs/starknetkit", "private": false, "browser": { From 0bbeb06a605cd94ae4a598cd21991b891cbfaa0d Mon Sep 17 00:00:00 2001 From: bluecco Date: Thu, 12 Oct 2023 16:38:18 +0200 Subject: [PATCH 3/7] fix: universal link schema --- src/connectors/argentMobile/modal/argentModal.ts | 2 +- src/connectors/argentMobile/modal/login.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/connectors/argentMobile/modal/argentModal.ts b/src/connectors/argentMobile/modal/argentModal.ts index 9aea30b..cb7a309 100644 --- a/src/connectors/argentMobile/modal/argentModal.ts +++ b/src/connectors/argentMobile/modal/argentModal.ts @@ -60,7 +60,7 @@ interface Urls { class ArgentModal { public bridgeUrl = "https://login.argent.xyz" - public mobileUrl = "https://www.argent.xyz/" + public mobileUrl = "argent://" public type: "overlay" | "window" = "overlay" public wcUri?: string diff --git a/src/connectors/argentMobile/modal/login.ts b/src/connectors/argentMobile/modal/login.ts index 77be181..46e1a1d 100644 --- a/src/connectors/argentMobile/modal/login.ts +++ b/src/connectors/argentMobile/modal/login.ts @@ -144,6 +144,6 @@ const getMobileUrl = (chainId: unknown) => { String(chainId).startsWith(Network.SN_MAIN) || chainIdNumber === 1 // mainnet numeric value ) { - return "https://www.argent.xyz/" + return "argent://" } } From 5cc68da51f2839d9433c68e4f362cfd09cae87a5 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 12 Oct 2023 14:42:17 +0000 Subject: [PATCH 4/7] chore(release): 1.0.8 [skip ci] ## [1.0.8](https://github.com/argentlabs/starknetkit/compare/v1.0.7...v1.0.8) (2023-10-12) ### Bug Fixes * universal link schema ([0bbeb06](https://github.com/argentlabs/starknetkit/commit/0bbeb06a605cd94ae4a598cd21991b891cbfaa0d)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31c176e..ebd7182 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "starknetkit", - "version": "1.0.7", + "version": "1.0.8", "repository": "github:argentlabs/starknetkit", "private": false, "browser": { From 3773de6e58faf0098fbf7fcdb8dffec22cea1494 Mon Sep 17 00:00:00 2001 From: bluecco Date: Tue, 17 Oct 2023 16:32:21 +0200 Subject: [PATCH 5/7] fix: use shadow dom to prevent css leak --- src/main.ts | 10 ++++- src/modal/ConnectorButton.svelte | 74 +++++++++++++++++++------------- src/modal/Modal.svelte | 66 +++++++++++----------------- src/theme.css | 38 ++++++++++++++++ tailwind.config.cjs | 1 - 5 files changed, 114 insertions(+), 75 deletions(-) create mode 100644 src/theme.css diff --git a/src/main.ts b/src/main.ts index b83eb98..e966625 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,6 +14,8 @@ import { setStarknetLastConnectedWallet, } from "./helpers/lastConnected" +import css from "./theme.css?inline" + export const connect = async ({ modalMode = "canAsk", storeVersion = getStoreVersionFromBrowser(), @@ -67,9 +69,15 @@ export const connect = async ({ storeVersion, }) + const element = document.createElement("div") + document.body.appendChild(element) + const target = element.attachShadow({ mode: "open" }) + + target.innerHTML = `` + return new Promise((resolve) => { const modal = new Modal({ - target: document.body, + target, props: { dappName, callback: async (value: StarknetWindowObject | null) => { diff --git a/src/modal/ConnectorButton.svelte b/src/modal/ConnectorButton.svelte index 518cafc..cbd1505 100644 --- a/src/modal/ConnectorButton.svelte +++ b/src/modal/ConnectorButton.svelte @@ -14,15 +14,15 @@ href={wallet.download} target="_blank" rel="noopener noreferrer" - class={`starknetkit-rounded-md focus:starknetkit-outline-none focus:starknetkit-ring-2 - focus:starknetkit-ring-neutral-200 dark:focus:starknetkit-ring-neutral-700 starknetkit-transition-colors`} + class={`rounded-md focus:outline-none focus:ring-2 + focus:ring-neutral-200 dark:focus:ring-neutral-700 transition-colors`} >
  • { cb(null) }} @@ -33,26 +33,22 @@ }} > -

    +

    Install {wallet.name}

    - {wallet.name} + {wallet.name}
  • {:else}
  • { @@ -65,13 +61,11 @@ }} > -
    -

    +

    +

    {wallet.title ?? wallet.name}

    -

    +

    {wallet.subtitle ?? ""}

    @@ -80,7 +74,7 @@
    - Loading... + Loading...
    {:else if isSvg}
    {@html wallet.icon}
    {:else} - {wallet?.name} + {wallet?.name} {/if}
  • {/if} + + diff --git a/src/modal/Modal.svelte b/src/modal/Modal.svelte index 6358e24..2403c44 100644 --- a/src/modal/Modal.svelte +++ b/src/modal/Modal.svelte @@ -46,7 +46,7 @@ (theme === null && window.matchMedia("(prefers-color-scheme: dark)").matches) ) { - darkModeControlClass = "starknetkit-dark" + darkModeControlClass = "dark" } else { darkModeControlClass = "" } @@ -74,8 +74,8 @@ {#if !isInAppBrowser && !emailOnly}
    cb(null)} on:keyup={(e) => { if (e.key === "Escape") { @@ -86,39 +86,33 @@
    e.stopPropagation()} on:keyup={(e) => { e.stopPropagation() }} > -
    -

    - Connect to -

    +
    +

    Connect to

    {dappName}

    -
      +
        {#each modalWallets as wallet} {/each} @@ -153,14 +147,14 @@
    {/if} - + --> diff --git a/src/theme.css b/src/theme.css new file mode 100644 index 0000000..6bb141a --- /dev/null +++ b/src/theme.css @@ -0,0 +1,38 @@ +@import url("https://fonts.googleapis.com/css2?family=Barlow:wght@500;600&display=swap"); + +@tailwind utilities; +@tailwind components; +@tailwind base; + +.modal-font { + font-family: + "Barlow", + -apple-system, + BlinkMacSystemFont, + Segoe UI, + Roboto, + Oxygen, + Ubuntu, + Cantarell, + Fira Sans, + Droid Sans, + Helvetica Neue, + sans-serif; + -webkit-font-smoothing: antialiased; + text-rendering: optimizeLegibility; + text-size-adjust: 100%; + font-feature-settings: "kern"; +} + +.l2 { + color: #8c8c8c; + font-size: 12px; + font-weight: 500; + line-height: 14px; + letter-spacing: 0em; + text-align: left; +} + +.p { + margin: 0; +} diff --git a/tailwind.config.cjs b/tailwind.config.cjs index 92b05b9..b3a73ef 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -2,7 +2,6 @@ module.exports = { content: ["./src/**/*.{svelte,ts}"], darkMode: "class", - prefix: "starknetkit-", theme: { extend: { boxShadow: { From e1954ed96744fbf3b63e07d3de3f4e9f9fd70541 Mon Sep 17 00:00:00 2001 From: bluecco Date: Tue, 17 Oct 2023 16:53:24 +0200 Subject: [PATCH 6/7] chore: remove comment --- src/modal/ConnectorButton.svelte | 22 ---------------------- src/modal/Modal.svelte | 19 ------------------- 2 files changed, 41 deletions(-) diff --git a/src/modal/ConnectorButton.svelte b/src/modal/ConnectorButton.svelte index cbd1505..121c9f2 100644 --- a/src/modal/ConnectorButton.svelte +++ b/src/modal/ConnectorButton.svelte @@ -97,25 +97,3 @@ {/if} {/if} - - diff --git a/src/modal/Modal.svelte b/src/modal/Modal.svelte index 2403c44..5cc346c 100644 --- a/src/modal/Modal.svelte +++ b/src/modal/Modal.svelte @@ -146,22 +146,3 @@ {/if} - - From c5fcbea1ef27917454bfb6962bbb75576d98b121 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 17 Oct 2023 20:47:50 +0000 Subject: [PATCH 7/7] chore(release): 1.0.9 [skip ci] ## [1.0.9](https://github.com/argentlabs/starknetkit/compare/v1.0.8...v1.0.9) (2023-10-17) ### Bug Fixes * use shadow dom to prevent css leak ([3773de6](https://github.com/argentlabs/starknetkit/commit/3773de6e58faf0098fbf7fcdb8dffec22cea1494)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ebd7182..90024b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "starknetkit", - "version": "1.0.8", + "version": "1.0.9", "repository": "github:argentlabs/starknetkit", "private": false, "browser": {