From 60ff7cb89c8f8e9d7dc936f42065b745d13708f8 Mon Sep 17 00:00:00 2001 From: Joe Schnetzler Date: Tue, 12 Sep 2023 07:25:26 +0000 Subject: [PATCH 01/33] Fix --- packages/ui/src/routes/+page.svelte | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/ui/src/routes/+page.svelte b/packages/ui/src/routes/+page.svelte index 03581fd..7673355 100644 --- a/packages/ui/src/routes/+page.svelte +++ b/packages/ui/src/routes/+page.svelte @@ -31,14 +31,12 @@ const initializeSnap = async () => { const chainsFromInit = await initSnap(); - if (chainsFromInit) { - localStorage.setItem(LOCAL_STORAGE_CHAINS, JSON.stringify(chainsFromInit)); - chains.set(chainsFromInit); - localStorage.setItem(LOCAL_STORAGE_INIT, "true"); - isSnapInitValue = true; - $state.connected = true; - goto("/balances"); - } + localStorage.setItem(LOCAL_STORAGE_CHAINS, JSON.stringify(chainsFromInit)); + chains.set(chainsFromInit); + localStorage.setItem(LOCAL_STORAGE_INIT, "true"); + isSnapInitValue = true; + $state.connected = true; + console.log("All Setup"); }; afterUpdate(initializeData); From b00515ed302bd2bd01db5d19b154a17bdf1d8ce4 Mon Sep 17 00:00:00 2001 From: Joe Schnetzler Date: Tue, 12 Sep 2023 07:27:58 +0000 Subject: [PATCH 02/33] Init optimizes --- packages/ui/src/routes/+page.svelte | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/ui/src/routes/+page.svelte b/packages/ui/src/routes/+page.svelte index 7673355..94fca0d 100644 --- a/packages/ui/src/routes/+page.svelte +++ b/packages/ui/src/routes/+page.svelte @@ -30,13 +30,25 @@ }; const initializeSnap = async () => { - const chainsFromInit = await initSnap(); - localStorage.setItem(LOCAL_STORAGE_CHAINS, JSON.stringify(chainsFromInit)); - chains.set(chainsFromInit); - localStorage.setItem(LOCAL_STORAGE_INIT, "true"); - isSnapInitValue = true; - $state.connected = true; - console.log("All Setup"); + try { + const chainsFromInit = await initSnap(); + localStorage.setItem(LOCAL_STORAGE_CHAINS, JSON.stringify(chainsFromInit)); + chains.set(chainsFromInit); + localStorage.setItem(LOCAL_STORAGE_INIT, "true"); + isSnapInitValue = true; + $state.connected = true; + } catch (err: any) { + if (err.message == "The Cosmos Snap has already been initialized.") { + localStorage.setItem(LOCAL_STORAGE_INIT, "true"); + isSnapInitValue = true; + $state.connected = true; + goto("/balances") + } else { + $state.alertText = `${err.message}` + $state.alertType = "danger" + $state.showAlert = true + } + } }; afterUpdate(initializeData); From b59bf25ea72b6a6fc55f5a6c51ab780d6e9fe7b7 Mon Sep 17 00:00:00 2001 From: Joe Schnetzler Date: Tue, 12 Sep 2023 14:39:29 +0000 Subject: [PATCH 03/33] Change install params --- packages/ui/src/utils/snap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/utils/snap.ts b/packages/ui/src/utils/snap.ts index 978e45a..aa14fe1 100644 --- a/packages/ui/src/utils/snap.ts +++ b/packages/ui/src/utils/snap.ts @@ -13,7 +13,7 @@ export const snapId = import.meta.env.VITE_SNAP_ID ?? `npm:@cosmsnap/snap`; const snapVersion = import.meta.env.VITE_SNAP_VERSION; const initialJsonString = "{}"; const installParams = JSON.parse(initialJsonString); -installParams[snapId] = { version: snapVersion }; +console.log(installParams); export const isMetaMaskInstalled = (): boolean | undefined => !!window.ethereum && window.ethereum.isMetaMask; From a1e02c30393e0a89183df73415f682727ab49c19 Mon Sep 17 00:00:00 2001 From: Joe Schnetzler Date: Tue, 12 Sep 2023 15:13:01 +0000 Subject: [PATCH 04/33] Button update --- packages/ui/src/components/Button.svelte | 3 +- packages/ui/src/components/Step.svelte | 85 ++---------------------- packages/ui/src/routes/+page.svelte | 11 +++ packages/ui/src/utils/snap.ts | 2 +- 4 files changed, 19 insertions(+), 82 deletions(-) diff --git a/packages/ui/src/components/Button.svelte b/packages/ui/src/components/Button.svelte index 18a21e1..8f0276a 100644 --- a/packages/ui/src/components/Button.svelte +++ b/packages/ui/src/components/Button.svelte @@ -2,9 +2,10 @@ export let onClick: Function = () => {} export let loading = false; export let text = "Transfer"; + export let disabled: boolean = false; - + diff --git a/packages/ui/src/components/Menu.svelte b/packages/ui/src/components/Menu.svelte index c3abf36..982eafc 100644 --- a/packages/ui/src/components/Menu.svelte +++ b/packages/ui/src/components/Menu.svelte @@ -6,6 +6,7 @@ { route: "/balances", title: "Balances", icon: "https://anima-uploads.s3.amazonaws.com/projects/64863aebc1255e7dd4fb600b/releases/64a70dda287bc6479f0ac9fd/img/dashboard.svg", path: "/balances" }, { route: "/transactions", title: "History", icon: "https://anima-uploads.s3.amazonaws.com/projects/64863aebc1255e7dd4fb600b/releases/64a70dda287bc6479f0ac9fd/img/dns.svg", path: "/transactions" }, { route: "/address", title: "Address Book", icon: "https://anima-uploads.s3.amazonaws.com/projects/64863aebc1255e7dd4fb600b/releases/64a70dda287bc6479f0ac9fd/img/account-box.svg", path: "/address" }, + { route: "/funds", title: "Funds", icon: "https://anima-uploads.s3.amazonaws.com/projects/64863aebc1255e7dd4fb600b/releases/64a70dda287bc6479f0ac9fd/img/account-box.svg", path: "/funds" }, { route: "/settings", title: "Settings", icon: "https://anima-uploads.s3.amazonaws.com/projects/64863aebc1255e7dd4fb600b/releases/64a70dda287bc6479f0ac9fd/img/settings.svg", path: "/settings" } ] let active = $page.route.id; diff --git a/packages/ui/src/routes/+page.svelte b/packages/ui/src/routes/+page.svelte index 46f4d4b..9b9fa10 100644 --- a/packages/ui/src/routes/+page.svelte +++ b/packages/ui/src/routes/+page.svelte @@ -15,23 +15,36 @@ $: if (isMetaMaskInstalledValue && isSnapInitValue && isSnapInstalledValue) { $state.connected = true; + loading = false; goto("/balances"); } const initializeData = async () => { - loading = true; - isMetaMaskInstalledValue = isMetaMaskInstalled() ?? false; - isSnapInstalledValue = await isSnapInstalled() ?? false; - isSnapInitValue = (localStorage.getItem(LOCAL_STORAGE_INIT) === "true"); - loading = false; + try { + loading = true; + isMetaMaskInstalledValue = isMetaMaskInstalled() ?? false; + isSnapInstalledValue = await isSnapInstalled() ?? false; + isSnapInitValue = (localStorage.getItem(LOCAL_STORAGE_INIT) === "true"); + loading = false; + } catch (err: any) { + $state.alertText = err.message + $state.alertType = "danger" + $state.showAlert = true + } }; const runInstallSnap = async () => { - loading = true; - await installSnap(); - isSnapInstalledValue = true; - isSnapInitValue = false; - loading = false; + try { + loading = true; + await installSnap(); + isSnapInstalledValue = true; + isSnapInitValue = false; + loading = false; + } catch (err: any) { + $state.alertText = err.message + $state.alertType = "danger" + $state.showAlert = true + } }; const initializeSnap = async () => { @@ -70,7 +83,7 @@
{ window.open('https://metamask.io/download', '_blank') }} complete={isMetaMaskInstalledValue} @@ -84,7 +97,7 @@ /> { await initializeSnap(); }} complete={isSnapInitValue} diff --git a/packages/ui/src/routes/funds/+page.svelte b/packages/ui/src/routes/funds/+page.svelte new file mode 100644 index 0000000..45b5030 --- /dev/null +++ b/packages/ui/src/routes/funds/+page.svelte @@ -0,0 +1,37 @@ + + +
+
+
+ Manage Funds +
+
+ {#if mode == 'Fiat'} + +
+ +
+ {:else if mode == 'Swap'} +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/packages/ui/src/routes/funds/+page.svelte b/packages/ui/src/routes/funds/+page.svelte deleted file mode 100644 index 45b5030..0000000 --- a/packages/ui/src/routes/funds/+page.svelte +++ /dev/null @@ -1,37 +0,0 @@ - - -
-
-
- Manage Funds -
-
- {#if mode == 'Fiat'} - -
- -
- {:else if mode == 'Swap'} -
- +
+
diff --git a/packages/ui/src/routes/swap/+page.svelte b/packages/ui/src/routes/swap/+page.svelte index 3f72d8e..a696dfe 100644 --- a/packages/ui/src/routes/swap/+page.svelte +++ b/packages/ui/src/routes/swap/+page.svelte @@ -1,15 +1,16 @@ -
-
-
-
+
+
+
+
+
diff --git a/packages/ui/src/routes/swap/+page.svelte b/packages/ui/src/routes/swap/+page.svelte index a696dfe..f49b334 100644 --- a/packages/ui/src/routes/swap/+page.svelte +++ b/packages/ui/src/routes/swap/+page.svelte @@ -4,12 +4,11 @@
-
+
-
-
-
-
- - \ No newline at end of file diff --git a/packages/ui/src/routes/swap/+page.svelte b/packages/ui/src/routes/swap/+page.svelte deleted file mode 100644 index f49b334..0000000 --- a/packages/ui/src/routes/swap/+page.svelte +++ /dev/null @@ -1,20 +0,0 @@ - - -
-
-
-
-