From 5eeeae32c639520cf6a900ba7b9474c8834263b1 Mon Sep 17 00:00:00 2001
From: Trent Larson <trent@trentlarson.com>
Date: Thu, 29 May 2025 19:36:35 -0600
Subject: [PATCH] fix some incorrect logic & things AI hallucinated

---
 src/components/GiftedDialog.vue     | 14 +-------------
 src/interfaces/common.ts            | 13 +++++--------
 src/libs/endorserServer.ts          | 10 +---------
 src/views/ContactQRScanShowView.vue |  4 ----
 4 files changed, 7 insertions(+), 34 deletions(-)

diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue
index 4a48841f..04856244 100644
--- a/src/components/GiftedDialog.vue
+++ b/src/components/GiftedDialog.vue
@@ -320,10 +320,7 @@ export default class GiftedDialog extends Vue {
         this.fromProjectId,
       );
 
-      if (
-        result.type === "error" ||
-        this.isGiveCreationError(result.response)
-      ) {
+      if (!result.success || result.error) {
         const errorMessage = this.getGiveCreationErrorMessage(result);
         logger.error("Error with give creation result:", result);
         this.$notify(
@@ -370,15 +367,6 @@ export default class GiftedDialog extends Vue {
 
   // Helper functions for readability
 
-  /**
-   * @param result response "data" from the server
-   * @returns true if the result indicates an error
-   */
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  isGiveCreationError(result: any) {
-    return result.status !== 201 || result.data?.error;
-  }
-
   /**
    * @param result direct response eg. ErrorResult or SuccessResult (potentially with embedded "data")
    * @returns best guess at an error message
diff --git a/src/interfaces/common.ts b/src/interfaces/common.ts
index 9ce181e9..6ce02803 100644
--- a/src/interfaces/common.ts
+++ b/src/interfaces/common.ts
@@ -1,6 +1,6 @@
 // similar to VerifiableCredentialSubject... maybe rename this
 export interface GenericVerifiableCredential {
-  "@context": string | string[];
+  "@context"?: string;
   "@type": string;
   [key: string]: unknown;
 }
@@ -50,7 +50,7 @@ export interface KeyMeta {
 
 export interface QuantitativeValue extends GenericVerifiableCredential {
   "@type": "QuantitativeValue";
-  "@context": string | string[];
+  "@context"?: string;
   amountOfThisGood: number;
   unitCode: string;
   [key: string]: unknown;
@@ -102,7 +102,7 @@ export interface Agent {
 
 export interface ClaimObject {
   "@type": string;
-  "@context"?: string | string[];
+  "@context"?: string;
   fulfills?: Array<{
     "@type": string;
     identifier?: string;
@@ -119,7 +119,7 @@ export interface ClaimObject {
 }
 
 export interface VerifiableCredentialClaim {
-  "@context": string | string[];
+  "@context"?: string;
   "@type": string;
   type: string[];
   credentialSubject: ClaimObject;
@@ -128,7 +128,6 @@ export interface VerifiableCredentialClaim {
 
 export interface GiveVerifiableCredential extends GenericVerifiableCredential {
   "@type": "GiveAction";
-  "@context": string | string[];
   object?: GenericVerifiableCredential;
   agent?: Agent;
   participant?: {
@@ -144,8 +143,7 @@ export interface GiveVerifiableCredential extends GenericVerifiableCredential {
 }
 
 export interface OfferVerifiableCredential extends GenericVerifiableCredential {
-  "@type": "OfferAction";
-  "@context": string | string[];
+  "@type": "Offer";
   object?: GenericVerifiableCredential;
   agent?: Agent;
   participant?: {
@@ -167,7 +165,6 @@ export interface OfferVerifiableCredential extends GenericVerifiableCredential {
 export interface RegisterVerifiableCredential
   extends GenericVerifiableCredential {
   "@type": "RegisterAction";
-  "@context": string | string[];
   agent: {
     identifier: string;
   };
diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts
index 41c2a6ac..f44bcf56 100644
--- a/src/libs/endorserServer.ts
+++ b/src/libs/endorserServer.ts
@@ -668,9 +668,6 @@ export function hydrateGive(
     : {
         "@context": SCHEMA_ORG_CONTEXT,
         "@type": "GiveAction",
-        object: undefined,
-        agent: undefined,
-        fulfills: [],
       };
 
   if (lastClaimId) {
@@ -688,8 +685,6 @@ export function hydrateGive(
 
   if (amount && !isNaN(amount)) {
     const quantitativeValue: QuantitativeValue = {
-      "@context": SCHEMA_ORG_CONTEXT,
-      "@type": "QuantitativeValue",
       amountOfThisGood: amount,
       unitCode: unitCode || "HUR",
     };
@@ -857,10 +852,7 @@ export function hydrateOffer(
     ? R.clone(vcClaimOrig)
     : {
         "@context": SCHEMA_ORG_CONTEXT,
-        "@type": "OfferAction",
-        object: undefined,
-        agent: undefined,
-        itemOffered: {},
+        "@type": "Offer",
       };
 
   if (lastClaimId) {
diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue
index d4f6ae9e..34897400 100644
--- a/src/views/ContactQRScanShowView.vue
+++ b/src/views/ContactQRScanShowView.vue
@@ -526,10 +526,6 @@ export default class ContactQRScanShow extends Vue {
       const contact = {
         did: contactInfo.did,
         name: contactInfo.name || "",
-        email: contactInfo.email || "",
-        phone: contactInfo.phone || "",
-        company: contactInfo.company || "",
-        title: contactInfo.title || "",
         notes: contactInfo.notes || "",
       };