Browse Source

fix some incorrect logic & things AI hallucinated

master
Trent Larson 1 week ago
parent
commit
92e4570672
  1. 14
      src/components/GiftedDialog.vue
  2. 13
      src/interfaces/common.ts
  3. 10
      src/libs/endorserServer.ts
  4. 4
      src/views/ContactQRScanShowView.vue

14
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

13
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;
};

10
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) {

4
src/views/ContactQRScanShowView.vue

@ -504,10 +504,6 @@ export default class ContactQRScanShow extends Vue {
const contact = {
did: did,
name: contactInfo.name || "",
email: contactInfo.email || "",
phone: contactInfo.phone || "",
company: contactInfo.company || "",
title: contactInfo.title || "",
notes: contactInfo.notes || "",
};

Loading…
Cancel
Save