From 911c701ae738a9f2e12c14455c23951845d0c4c2 Mon Sep 17 00:00:00 2001 From: Francisco Ramos Date: Sat, 24 Jun 2023 02:54:34 +0200 Subject: [PATCH] feat(bridge-ui-v2): use web3modal (#14043) --- lefthook.yml | 3 + packages/bridge-ui-v2/.env.example | 8 ++- packages/bridge-ui-v2/.vscode/extensions.json | 3 + packages/bridge-ui-v2/.vscode/settings.json | 7 ++ packages/bridge-ui-v2/package.json | 2 + packages/bridge-ui-v2/src/app.html | 2 +- .../src/components/Button/Button.svelte | 4 +- .../src/components/Header/Header.svelte | 19 ++++-- .../src/components/Icon/Icon.svelte | 10 ++- .../components/LinkButton/LinkButton.svelte | 13 ++-- .../src/components/Logo/LogoWithText.svelte | 2 +- .../SideNavigation/SideNavigation.svelte | 20 +++--- .../bridge-ui-v2/src/libs/classNames/index.ts | 1 - .../bridge-ui-v2/src/libs/connect/index.ts | 1 + .../src/libs/connect/web3modal.ts | 28 ++++++++ packages/bridge-ui-v2/src/libs/i18n/en.json | 18 +++++ packages/bridge-ui-v2/src/libs/i18n/i18n.ts | 14 ++++ packages/bridge-ui-v2/src/libs/i18n/index.ts | 1 + .../{classNames => util}/classNames.test.ts | 0 .../libs/{classNames => util}/classNames.ts | 0 packages/bridge-ui-v2/src/libs/util/logger.ts | 5 ++ .../bridge-ui-v2/src/libs/wagmi/client.ts | 68 +++++++++++++++++++ packages/bridge-ui-v2/src/libs/wagmi/index.ts | 2 + .../bridge-ui-v2/src/libs/wagmi/watcher.ts | 33 +++++++++ .../bridge-ui-v2/src/routes/+layout.svelte | 6 +- packages/bridge-ui-v2/src/routes/+layout.ts | 5 ++ packages/bridge-ui-v2/tailwind.config.js | 4 ++ packages/bridge-ui-v2/tsconfig.json | 4 +- pnpm-lock.yaml | 29 ++++++-- 29 files changed, 273 insertions(+), 39 deletions(-) create mode 100644 packages/bridge-ui-v2/.vscode/extensions.json create mode 100644 packages/bridge-ui-v2/.vscode/settings.json delete mode 100644 packages/bridge-ui-v2/src/libs/classNames/index.ts create mode 100644 packages/bridge-ui-v2/src/libs/connect/index.ts create mode 100644 packages/bridge-ui-v2/src/libs/connect/web3modal.ts create mode 100644 packages/bridge-ui-v2/src/libs/i18n/en.json create mode 100644 packages/bridge-ui-v2/src/libs/i18n/i18n.ts create mode 100644 packages/bridge-ui-v2/src/libs/i18n/index.ts rename packages/bridge-ui-v2/src/libs/{classNames => util}/classNames.test.ts (100%) rename packages/bridge-ui-v2/src/libs/{classNames => util}/classNames.ts (100%) create mode 100644 packages/bridge-ui-v2/src/libs/util/logger.ts create mode 100644 packages/bridge-ui-v2/src/libs/wagmi/client.ts create mode 100644 packages/bridge-ui-v2/src/libs/wagmi/index.ts create mode 100644 packages/bridge-ui-v2/src/libs/wagmi/watcher.ts diff --git a/lefthook.yml b/lefthook.yml index d63dedfe182..f8ec27262a7 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -5,6 +5,9 @@ pre-commit: bridge-ui: glob: "packages/bridge-ui/**.{js,svelte,ts}" run: pnpm -F bridge-ui lint:fix && git add {staged_files} + bridge-ui-v2: + glob: "packages/bridge-ui-v2/**.{js,ts,css,svelte}" + run: pnpm -F bridge-ui-v2 lint:fix && git add {staged_files} protocol_sol: glob: "packages/protocol/**.{sol}" run: pnpm -F protocol lint:sol && git add {staged_files} diff --git a/packages/bridge-ui-v2/.env.example b/packages/bridge-ui-v2/.env.example index 282ca9d172c..8eb1d37b6cb 100644 --- a/packages/bridge-ui-v2/.env.example +++ b/packages/bridge-ui-v2/.env.example @@ -1,6 +1,6 @@ # Chain Names -export export PUBLIC_L1_CHAIN_NAME="" -export export PUBLIC_L2_CHAIN_NAME="" +export PUBLIC_L1_CHAIN_NAME="" +export PUBLIC_L2_CHAIN_NAME="" export PUBLIC_L3_CHAIN_NAME="" @@ -58,6 +58,10 @@ export PUBLIC_L3_SIGNAL_SERVICE_ADDRESS=0x export PUBLIC_TEST_ERC20=[] +# Web3Modal Project ID +export PUBLIC_WEB3_MODAL_PROJECT_ID="" + + # Sentry export PUBLIC_SENTRY_DSN=https:// diff --git a/packages/bridge-ui-v2/.vscode/extensions.json b/packages/bridge-ui-v2/.vscode/extensions.json new file mode 100644 index 00000000000..0fbc6ecd261 --- /dev/null +++ b/packages/bridge-ui-v2/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["esbenp.prettier-vscode", "eslint.vscode-eslint"] +} diff --git a/packages/bridge-ui-v2/.vscode/settings.json b/packages/bridge-ui-v2/.vscode/settings.json new file mode 100644 index 00000000000..f8f6dcce47e --- /dev/null +++ b/packages/bridge-ui-v2/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + } +} diff --git a/packages/bridge-ui-v2/package.json b/packages/bridge-ui-v2/package.json index d03290e2c23..6efdc52d928 100644 --- a/packages/bridge-ui-v2/package.json +++ b/packages/bridge-ui-v2/package.json @@ -21,6 +21,7 @@ "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-static": "^2.0.2", "@sveltejs/kit": "^1.5.0", + "@types/debug": "^4.1.7", "@typescript-eslint/eslint-plugin": "^5.45.0", "@typescript-eslint/parser": "^5.45.0", "autoprefixer": "^10.4.14", @@ -47,6 +48,7 @@ "@web3modal/ethereum": "^2.4.7", "@web3modal/html": "^2.4.7", "debug": "^4.3.4", + "svelte-i18n": "^3.5.1", "viem": "^1.0.7" } } diff --git a/packages/bridge-ui-v2/src/app.html b/packages/bridge-ui-v2/src/app.html index ff9d5e137ce..be167ec1d9b 100644 --- a/packages/bridge-ui-v2/src/app.html +++ b/packages/bridge-ui-v2/src/app.html @@ -25,6 +25,6 @@ - %sveltekit.body% +
%sveltekit.body%
diff --git a/packages/bridge-ui-v2/src/components/Button/Button.svelte b/packages/bridge-ui-v2/src/components/Button/Button.svelte index 4b04c59208a..a81c6abde31 100644 --- a/packages/bridge-ui-v2/src/components/Button/Button.svelte +++ b/packages/bridge-ui-v2/src/components/Button/Button.svelte @@ -1,5 +1,5 @@ -
+
-
- + + + +
diff --git a/packages/bridge-ui-v2/src/components/Icon/Icon.svelte b/packages/bridge-ui-v2/src/components/Icon/Icon.svelte index 7e58622bb19..670ab80dee8 100644 --- a/packages/bridge-ui-v2/src/components/Icon/Icon.svelte +++ b/packages/bridge-ui-v2/src/components/Icon/Icon.svelte @@ -1,5 +1,5 @@ - + {#if type === 'bridge'} + {:else if type === 'user-circle'} + {/if} diff --git a/packages/bridge-ui-v2/src/components/LinkButton/LinkButton.svelte b/packages/bridge-ui-v2/src/components/LinkButton/LinkButton.svelte index 6883ea183a8..5bd86f6b774 100644 --- a/packages/bridge-ui-v2/src/components/LinkButton/LinkButton.svelte +++ b/packages/bridge-ui-v2/src/components/LinkButton/LinkButton.svelte @@ -1,18 +1,19 @@ + target={external ? '_blank' : null} + class={classNames( + 'btn btn-sm md:btn-md btn-ghost p-3 rounded-full body-bold flex justify-start content-center', + activeClass, + )}> diff --git a/packages/bridge-ui-v2/src/components/Logo/LogoWithText.svelte b/packages/bridge-ui-v2/src/components/Logo/LogoWithText.svelte index 7e2c5c320a4..0b871cf7f53 100644 --- a/packages/bridge-ui-v2/src/components/Logo/LogoWithText.svelte +++ b/packages/bridge-ui-v2/src/components/Logo/LogoWithText.svelte @@ -7,7 +7,7 @@ export let height = 34; - + diff --git a/packages/bridge-ui-v2/src/components/SideNavigation/SideNavigation.svelte b/packages/bridge-ui-v2/src/components/SideNavigation/SideNavigation.svelte index ef59e7520a4..0c49fc9c065 100644 --- a/packages/bridge-ui-v2/src/components/SideNavigation/SideNavigation.svelte +++ b/packages/bridge-ui-v2/src/components/SideNavigation/SideNavigation.svelte @@ -4,6 +4,7 @@