From 3038f2a243fa579e6bb9c549b43c62940980f5cc Mon Sep 17 00:00:00 2001
From: mtyszczak <mateusz.tyszczak@gmail.com>
Date: Fri, 14 Mar 2025 17:29:27 +0100
Subject: [PATCH] Improve error message handling

---
 package.json                                   |  2 +-
 pnpm-lock.yaml                                 | 18 +++++++++---------
 src/components/utilcards/MemoEncryptCard.vue   |  2 +-
 .../utilcards/SignTransactionCard.vue          |  2 +-
 src/lib/parse-error.ts                         | 10 ++++++++--
 src/utils/wallet/metamask/snap.ts              |  2 +-
 6 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/package.json b/package.json
index 9cc4a81..2a837a7 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,7 @@
     "vue-sonner": "^1.3.0"
   },
   "devDependencies": {
-    "@hiveio/wax": "1.27.6-rc7-250304235913",
+    "@hiveio/wax": "1.27.6-rc7-250314161617",
     "@mdi/js": "^7.4.47",
     "@metamask/providers": "^16.0.0",
     "@tanstack/vue-table": "^8.21.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4bdf1ab..40f511c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -13,8 +13,8 @@ importers:
         version: 1.3.0
     devDependencies:
       '@hiveio/wax':
-        specifier: 1.27.6-rc7-250304235913
-        version: 1.27.6-rc7-250304235913
+        specifier: 1.27.6-rc7-250314161617
+        version: 1.27.6-rc7-250314161617
       '@mdi/js':
         specifier: ^7.4.47
         version: 7.4.47
@@ -284,12 +284,12 @@ packages:
   '@floating-ui/vue@1.1.6':
     resolution: {integrity: sha512-XFlUzGHGv12zbgHNk5FN2mUB7ROul3oG2ENdTpWdE+qMFxyNxWSRmsoyhiEnpmabNm6WnUvR1OvJfUfN4ojC1A==}
 
-  '@hiveio/beekeeper@1.27.9-stable.250219154236':
-    resolution: {integrity: sha1-6fL+OgTwp6MSp0Xm3fwj+kFLzD8=, tarball: https://gitlab.syncad.com/api/v4/projects/198/packages/npm/@hiveio/beekeeper/-/@hiveio/beekeeper-1.27.9-stable.250219154236.tgz}
+  '@hiveio/beekeeper@1.27.10-stable.250305202831':
+    resolution: {integrity: sha1-mPx0QrDh3NSPSOYGyR1SUyi3lyA=, tarball: https://gitlab.syncad.com/api/v4/projects/198/packages/npm/@hiveio/beekeeper/-/@hiveio/beekeeper-1.27.10-stable.250305202831.tgz}
     engines: {node: ^20.11 || >= 21.2}
 
-  '@hiveio/wax@1.27.6-rc7-250304235913':
-    resolution: {integrity: sha1-Dk27ws/cbPd8P+aomJlGCzL98rI=, tarball: https://gitlab.syncad.com/api/v4/projects/419/packages/npm/@hiveio/wax/-/@hiveio/wax-1.27.6-rc7-250304235913.tgz}
+  '@hiveio/wax@1.27.6-rc7-250314161617':
+    resolution: {integrity: sha1-cFrsq3vl6M18v4dhbfYScUj00p0=, tarball: https://gitlab.syncad.com/api/v4/projects/419/packages/npm/@hiveio/wax/-/@hiveio/wax-1.27.6-rc7-250314161617.tgz}
     engines: {node: ^20.11 || >= 21.2}
 
   '@internationalized/date@3.7.0':
@@ -1637,11 +1637,11 @@ snapshots:
       - '@vue/composition-api'
       - vue
 
-  '@hiveio/beekeeper@1.27.9-stable.250219154236': {}
+  '@hiveio/beekeeper@1.27.10-stable.250305202831': {}
 
-  '@hiveio/wax@1.27.6-rc7-250304235913':
+  '@hiveio/wax@1.27.6-rc7-250314161617':
     dependencies:
-      '@hiveio/beekeeper': 1.27.9-stable.250219154236
+      '@hiveio/beekeeper': 1.27.10-stable.250305202831
       events: 3.3.0
       long: 5.3.1
 
diff --git a/src/components/utilcards/MemoEncryptCard.vue b/src/components/utilcards/MemoEncryptCard.vue
index f0bdaf9..3bf1f90 100644
--- a/src/components/utilcards/MemoEncryptCard.vue
+++ b/src/components/utilcards/MemoEncryptCard.vue
@@ -84,7 +84,7 @@ const encryptOrDecrypt = async () => {
       <div class="flex mb-4 underline text-sm" v-if="isEncrypt">
         <a @click="useMyMemoKey" class="ml-auto mr-1 cursor-pointer" style="color: hsla(var(--foreground) / 70%)">Use my memo key</a>
       </div>
-      <Button :disabled="!hasWallet" @click="encryptOrDecrypt">{{ isEncrypt ? "Encrypt" : "Decrypt" }}</Button>
+      <Button :disabled="!hasWallet || (!encryptForKey && isEncrypt)" @click="encryptOrDecrypt">{{ isEncrypt ? "Encrypt" : "Decrypt" }}</Button>
       <Textarea v-model="outputData" placeholder="Output" copy-enabled class="my-4" disabled/>
     </CardContent>
   </Card>
diff --git a/src/components/utilcards/SignTransactionCard.vue b/src/components/utilcards/SignTransactionCard.vue
index f1c500f..5e80639 100644
--- a/src/components/utilcards/SignTransactionCard.vue
+++ b/src/components/utilcards/SignTransactionCard.vue
@@ -70,7 +70,7 @@ const broadcast = async () => {
     const tx = wax.createTransactionFromJson(inputData.value);
     tx.sign(outputData.value);
 
-    wax.broadcast(tx);
+    await wax.broadcast(tx);
   } catch (error) {
     toastError('Error broadcasting transaction', error);
   } finally {
diff --git a/src/lib/parse-error.ts b/src/lib/parse-error.ts
index bd51fc4..dd277c7 100644
--- a/src/lib/parse-error.ts
+++ b/src/lib/parse-error.ts
@@ -7,8 +7,14 @@ export const toastError = (title: string, error: unknown) => {
   if (typeof error === "object" && error) {
     if (error instanceof WaxError) {
       if (error instanceof WaxChainApiError) {
-        if (error.apiError && typeof error.apiError === "object" && "message" in error.apiError && typeof error.apiError.message === "string")
-          description = error.apiError.message;
+        if (error.apiError
+            && typeof error.apiError === "object"
+            && "error" in error.apiError
+            && typeof error.apiError.error === "object"
+            && error.apiError.error
+            && "message" in error.apiError.error
+            && typeof error.apiError.error.message === "string")
+          description = error.apiError.error.message;
         else
           description = error.message;
       } else {
diff --git a/src/utils/wallet/metamask/snap.ts b/src/utils/wallet/metamask/snap.ts
index a7ac039..100d54a 100644
--- a/src/utils/wallet/metamask/snap.ts
+++ b/src/utils/wallet/metamask/snap.ts
@@ -8,7 +8,7 @@
  */
 export const defaultSnapOrigin = import.meta.env.VITE_SNAP_ORIGIN || `npm:@hiveio/metamask-snap`; // local:http://localhost:8080
 
-export const defaultSnapVersion: string | undefined = import.meta.env.VITE_SNAP_VERSION ?? '1.3.2';
+export const defaultSnapVersion: string | undefined = import.meta.env.VITE_SNAP_VERSION ?? '1.3.3';
 
 /**
  * Check if a snap ID is a local snap ID.
-- 
GitLab