From 00182443fd0010e0aaadb0545766f7f4e317288c Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 27 Mar 2023 20:37:22 -0600 Subject: [PATCH] adjust to change of confirmed -> amountConfirmed --- src/libs/endorserServer.ts | 7 +++++-- src/views/ContactAmountsView.vue | 14 +++++++------- src/views/ContactsView.vue | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 8d3cc76..2fefe73 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -4,13 +4,15 @@ export const SERVICE_ID = "endorser.ch"; export interface AgreeVerifiableCredential { "@context": string; "@type": string; + // "any" because arbitrary objects can be subject of agreement + // eslint-disable-next-line @typescript-eslint/no-explicit-any object: Record; } export interface GiveServerRecord { agentDid: string; amount: number; - confirmed: number; + amountConfirmed: number; description: string; fullClaim: GiveVerifiableCredential; handleId: string; @@ -20,10 +22,11 @@ export interface GiveServerRecord { } export interface GiveVerifiableCredential { - "@context": string; + "@context"?: string; // optional when embedded, eg. in an Agree "@type": string; agent: { identifier: string }; description?: string; + identifier?: string; object: { amountOfThisGood: number; unitCode: string }; recipient: { identifier: string }; } diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index da8577c..ad2af5b 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -68,7 +68,7 @@
{{ record.amount }} {{ record.unit }} - + Confirmed @@ -94,7 +94,7 @@
{{ record.amount }} {{ record.unit }} - + Confirmed @@ -134,10 +134,8 @@ import { AppString } from "@/constants/app"; import { accessToken, SimpleSigner } from "@/libs/crypto"; import { AgreeVerifiableCredential, - GiveServerRecord, - RegisterVerifiableCredential, + GiveServerRecord, GiveVerifiableCredential, SCHEMA_ORG_CONTEXT, - SERVICE_ID, } from "@/libs/endorserServer"; import * as didJwt from "did-jwt"; import { AxiosError } from "axios"; @@ -243,7 +241,9 @@ export default class ContactsView extends Vue { async confirm(record: GiveServerRecord) { // Make claim // I use clone here because otherwise it gets a Proxy object. - const origClaim: Record = R.clone(record.fullClaim); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const origClaim: GiveVerifiableCredential = + R.clone(record.fullClaim); if (record.fullClaim["@context"] == SCHEMA_ORG_CONTEXT) { delete origClaim["@context"]; } @@ -294,7 +294,7 @@ export default class ContactsView extends Vue { const resp = await this.axios.post(url, payload, { headers }); //console.log("Got resp data:", resp.data); if (resp.data?.success) { - record.confirmed = 1; + record.amountConfirmed = origClaim.object?.amountOfThisGood || 1; } } catch (error) { let userMessage = "There was an error. See logs for more info."; diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 8e69301..55ebd4e 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -326,7 +326,7 @@ export default class ContactsView extends Vue { for (const give of allData) { if (give.unit == "HUR") { const recipDid: string = give.recipientDid; - if (give.confirmed) { + if (give.amountConfirmed) { const prevAmount = contactConfirmed[recipDid] || 0; contactConfirmed[recipDid] = prevAmount + give.amount; } else { @@ -380,7 +380,7 @@ export default class ContactsView extends Vue { const allData: Array = resp.data.data; for (const give of allData) { if (give.unit == "HUR") { - if (give.confirmed) { + if (give.amountConfirmed) { const prevAmount = contactConfirmed[give.agentDid] || 0; contactConfirmed[give.agentDid] = prevAmount + give.amount; } else {