forked from jsnbuchanan/crowd-funder-for-time-pwa
adjust to change of confirmed -> amountConfirmed
This commit is contained in:
@@ -4,13 +4,15 @@ export const SERVICE_ID = "endorser.ch";
|
|||||||
export interface AgreeVerifiableCredential {
|
export interface AgreeVerifiableCredential {
|
||||||
"@context": string;
|
"@context": string;
|
||||||
"@type": string;
|
"@type": string;
|
||||||
|
// "any" because arbitrary objects can be subject of agreement
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
object: Record<any, any>;
|
object: Record<any, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GiveServerRecord {
|
export interface GiveServerRecord {
|
||||||
agentDid: string;
|
agentDid: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
confirmed: number;
|
amountConfirmed: number;
|
||||||
description: string;
|
description: string;
|
||||||
fullClaim: GiveVerifiableCredential;
|
fullClaim: GiveVerifiableCredential;
|
||||||
handleId: string;
|
handleId: string;
|
||||||
@@ -20,10 +22,11 @@ export interface GiveServerRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GiveVerifiableCredential {
|
export interface GiveVerifiableCredential {
|
||||||
"@context": string;
|
"@context"?: string; // optional when embedded, eg. in an Agree
|
||||||
"@type": string;
|
"@type": string;
|
||||||
agent: { identifier: string };
|
agent: { identifier: string };
|
||||||
description?: string;
|
description?: string;
|
||||||
|
identifier?: string;
|
||||||
object: { amountOfThisGood: number; unitCode: string };
|
object: { amountOfThisGood: number; unitCode: string };
|
||||||
recipient: { identifier: string };
|
recipient: { identifier: string };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<span v-if="record.agentDid == contact.did">
|
<span v-if="record.agentDid == contact.did">
|
||||||
<div class="font-bold">
|
<div class="font-bold">
|
||||||
{{ record.amount }} {{ record.unit }}
|
{{ record.amount }} {{ record.unit }}
|
||||||
<span v-if="record.confirmed" class="tooltip">
|
<span v-if="record.amountConfirmed" class="tooltip">
|
||||||
<fa icon="circle-check" class="text-green-600 fa-fw ml-1" />
|
<fa icon="circle-check" class="text-green-600 fa-fw ml-1" />
|
||||||
<span class="tooltiptext">Confirmed</span>
|
<span class="tooltiptext">Confirmed</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
<span v-if="record.agentDid != contact.did">
|
<span v-if="record.agentDid != contact.did">
|
||||||
<div class="font-bold">
|
<div class="font-bold">
|
||||||
{{ record.amount }} {{ record.unit }}
|
{{ record.amount }} {{ record.unit }}
|
||||||
<span v-if="record.confirmed" class="tooltip">
|
<span v-if="record.amountConfirmed" class="tooltip">
|
||||||
<fa icon="circle-check" class="text-green-600 fa-fw ml-1" />
|
<fa icon="circle-check" class="text-green-600 fa-fw ml-1" />
|
||||||
<span class="tooltiptext">Confirmed</span>
|
<span class="tooltiptext">Confirmed</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -134,10 +134,8 @@ import { AppString } from "@/constants/app";
|
|||||||
import { accessToken, SimpleSigner } from "@/libs/crypto";
|
import { accessToken, SimpleSigner } from "@/libs/crypto";
|
||||||
import {
|
import {
|
||||||
AgreeVerifiableCredential,
|
AgreeVerifiableCredential,
|
||||||
GiveServerRecord,
|
GiveServerRecord, GiveVerifiableCredential,
|
||||||
RegisterVerifiableCredential,
|
|
||||||
SCHEMA_ORG_CONTEXT,
|
SCHEMA_ORG_CONTEXT,
|
||||||
SERVICE_ID,
|
|
||||||
} from "@/libs/endorserServer";
|
} from "@/libs/endorserServer";
|
||||||
import * as didJwt from "did-jwt";
|
import * as didJwt from "did-jwt";
|
||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
@@ -243,7 +241,9 @@ export default class ContactsView extends Vue {
|
|||||||
async confirm(record: GiveServerRecord) {
|
async confirm(record: GiveServerRecord) {
|
||||||
// Make claim
|
// Make claim
|
||||||
// I use clone here because otherwise it gets a Proxy object.
|
// I use clone here because otherwise it gets a Proxy object.
|
||||||
const origClaim: Record<any, any> = 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) {
|
if (record.fullClaim["@context"] == SCHEMA_ORG_CONTEXT) {
|
||||||
delete origClaim["@context"];
|
delete origClaim["@context"];
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ export default class ContactsView extends Vue {
|
|||||||
const resp = await this.axios.post(url, payload, { headers });
|
const resp = await this.axios.post(url, payload, { headers });
|
||||||
//console.log("Got resp data:", resp.data);
|
//console.log("Got resp data:", resp.data);
|
||||||
if (resp.data?.success) {
|
if (resp.data?.success) {
|
||||||
record.confirmed = 1;
|
record.amountConfirmed = origClaim.object?.amountOfThisGood || 1;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let userMessage = "There was an error. See logs for more info.";
|
let userMessage = "There was an error. See logs for more info.";
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ export default class ContactsView extends Vue {
|
|||||||
for (const give of allData) {
|
for (const give of allData) {
|
||||||
if (give.unit == "HUR") {
|
if (give.unit == "HUR") {
|
||||||
const recipDid: string = give.recipientDid;
|
const recipDid: string = give.recipientDid;
|
||||||
if (give.confirmed) {
|
if (give.amountConfirmed) {
|
||||||
const prevAmount = contactConfirmed[recipDid] || 0;
|
const prevAmount = contactConfirmed[recipDid] || 0;
|
||||||
contactConfirmed[recipDid] = prevAmount + give.amount;
|
contactConfirmed[recipDid] = prevAmount + give.amount;
|
||||||
} else {
|
} else {
|
||||||
@@ -380,7 +380,7 @@ export default class ContactsView extends Vue {
|
|||||||
const allData: Array<GiveServerRecord> = resp.data.data;
|
const allData: Array<GiveServerRecord> = resp.data.data;
|
||||||
for (const give of allData) {
|
for (const give of allData) {
|
||||||
if (give.unit == "HUR") {
|
if (give.unit == "HUR") {
|
||||||
if (give.confirmed) {
|
if (give.amountConfirmed) {
|
||||||
const prevAmount = contactConfirmed[give.agentDid] || 0;
|
const prevAmount = contactConfirmed[give.agentDid] || 0;
|
||||||
contactConfirmed[give.agentDid] = prevAmount + give.amount;
|
contactConfirmed[give.agentDid] = prevAmount + give.amount;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user