start linking gives to projects

This commit is contained in:
2023-07-01 07:07:46 -06:00
parent c40b690878
commit 643f777d10
3 changed files with 130 additions and 14 deletions

View File

@@ -46,6 +46,7 @@ export interface GiveVerifiableCredential {
"@type": string;
agent?: { identifier: string };
description?: string;
fulfills?: { "@type": string; identifier: string };
identifier?: string;
object?: { amountOfThisGood: number; unitCode: string };
recipient: { identifier: string };
@@ -95,7 +96,7 @@ export function didInfo(did, identifiers, contacts) {
/**
* For result, see https://endorser.ch:3000/api-docs/#/claims/post_api_v2_claim
*
* @param identity
* @param fromDid may be null
* @param toDid
@@ -109,7 +110,8 @@ export async function createAndSubmitGive(
fromDid: string,
toDid: string,
description: string,
hours: number
hours: number,
fulfillsProjectHandleId: string
): Promise<AxiosResponse<ClaimResult> | InternalError> {
// Make a claim
const vcClaim: GiveVerifiableCredential = {
@@ -126,6 +128,12 @@ export async function createAndSubmitGive(
if (hours) {
vcClaim.object = { amountOfThisGood: hours, unitCode: "HUR" };
}
if (fulfillsProjectHandleId) {
vcClaim.fulfills = {
"@type": "PlanAction",
identifier: fulfillsProjectHandleId,
};
}
// Make a payload for the claim
const vcPayload = {
vc: {