forked from jsnbuchanan/crowd-funder-for-time-pwa
add flag for logging a contribution as a trade
This commit is contained in:
@@ -88,7 +88,7 @@ export interface GiveVerifiableCredential {
|
||||
"@type": "GiveAction";
|
||||
agent?: { identifier: string };
|
||||
description?: string;
|
||||
fulfills?: { "@type": string; identifier?: string; lastClaimId?: string };
|
||||
fulfills?: { "@type": string; identifier?: string; lastClaimId?: string }[];
|
||||
identifier?: string;
|
||||
object?: { amountOfThisGood: number; unitCode: string };
|
||||
recipient?: { identifier: string };
|
||||
@@ -312,6 +312,7 @@ export async function createAndSubmitGive(
|
||||
hours?: number,
|
||||
unitCode?: string,
|
||||
fulfillsProjectHandleId?: string,
|
||||
isTrade: boolean = false,
|
||||
): Promise<CreateAndSubmitClaimResult> {
|
||||
const vcClaim: GiveVerifiableCredential = {
|
||||
"@context": "https://schema.org",
|
||||
@@ -322,10 +323,16 @@ export async function createAndSubmitGive(
|
||||
object: hours
|
||||
? { amountOfThisGood: hours, unitCode: unitCode || "HUR" }
|
||||
: undefined,
|
||||
fulfills: fulfillsProjectHandleId
|
||||
? { "@type": "PlanAction", identifier: fulfillsProjectHandleId }
|
||||
: undefined,
|
||||
fulfills: [{ "@type": isTrade ? "TradeAction" : "DonateAction" }],
|
||||
};
|
||||
if (fulfillsProjectHandleId) {
|
||||
vcClaim.fulfills = vcClaim.fulfills || []; // weird that it won't typecheck without this
|
||||
vcClaim.fulfills.push({
|
||||
"@type": "PlanAction",
|
||||
identifier: fulfillsProjectHandleId,
|
||||
});
|
||||
}
|
||||
console.log("createAndSubmitGive vcClaim", vcClaim);
|
||||
return createAndSubmitClaim(
|
||||
vcClaim as GenericServerRecord,
|
||||
identity,
|
||||
|
||||
Reference in New Issue
Block a user