diff --git a/src/core/agent/records/notificationRecord.ts b/src/core/agent/records/notificationRecord.ts index a855674ea..08690e4a6 100644 --- a/src/core/agent/records/notificationRecord.ts +++ b/src/core/agent/records/notificationRecord.ts @@ -1,6 +1,6 @@ import { BaseRecord, Tags } from "../../storage/storage.types"; import { NotificationRoute } from "../agent.types"; -import { LinkedGroupRequest } from "./notificationRecord.types"; +import { LinkedRequest } from "./notificationRecord.types"; import { randomSalt } from "../services/utils"; interface NotificationRecordStorageProps { @@ -13,7 +13,7 @@ interface NotificationRecordStorageProps { multisigId?: string; connectionId: string; credentialId?: string; - linkedGroupRequest?: LinkedGroupRequest; + linkedRequest?: LinkedRequest; groupReplied?: boolean, initiatorAid?: string, groupInitiator?: boolean, @@ -25,7 +25,7 @@ class NotificationRecord extends BaseRecord { read!: boolean; multisigId?: string; connectionId!: string; - linkedGroupRequest!: LinkedGroupRequest; + linkedRequest!: LinkedRequest; credentialId?: string; groupReplied?: boolean; initiatorAid?: string; @@ -45,7 +45,7 @@ class NotificationRecord extends BaseRecord { this.multisigId = props.multisigId; this.connectionId = props.connectionId; this._tags = props.tags ?? {}; - this.linkedGroupRequest = props.linkedGroupRequest ?? { accepted: false }; + this.linkedRequest = props.linkedRequest ?? { accepted: false }; this.credentialId = props.credentialId; this.groupReplied = props.groupReplied; this.initiatorAid = props.initiatorAid; diff --git a/src/core/agent/records/notificationRecord.types.ts b/src/core/agent/records/notificationRecord.types.ts index 5b3f11d10..169a6eed9 100644 --- a/src/core/agent/records/notificationRecord.types.ts +++ b/src/core/agent/records/notificationRecord.types.ts @@ -1,6 +1,6 @@ import { Notification } from "../services/credentialService.types"; -interface LinkedGroupRequest { +interface LinkedRequest { accepted: boolean; current?: string; previous?: string; @@ -12,4 +12,4 @@ interface NotificationAttempts { notification: Notification; } -export type { LinkedGroupRequest, NotificationAttempts }; +export type { LinkedRequest, NotificationAttempts }; diff --git a/src/core/agent/records/operationPendingRecord.type.ts b/src/core/agent/records/operationPendingRecord.type.ts index 09f278cac..58a195c56 100644 --- a/src/core/agent/records/operationPendingRecord.type.ts +++ b/src/core/agent/records/operationPendingRecord.type.ts @@ -1,6 +1,7 @@ export enum OperationPendingRecordType { Witness = "witness", Group = "group", + Done = "done", Oobi = "oobi", ExchangeReceiveCredential = "exchange.receivecredential", ExchangeOfferCredential = "exchange.offercredential", diff --git a/src/core/agent/services/identifierService.ts b/src/core/agent/services/identifierService.ts index 2b7724cf0..4c134390d 100644 --- a/src/core/agent/services/identifierService.ts +++ b/src/core/agent/services/identifierService.ts @@ -498,24 +498,30 @@ class IdentifierService extends AgentService { continue; } + let recordType = OperationPendingRecordType.Witness; + const op: Operation = await this.props.signifyClient .operations() .get(`witness.${identifier.prefix}`) .catch(async (error) => { const status = error.message.split(" - ")[1]; + if (/404/gi.test(status)) { + recordType = OperationPendingRecordType.Done return await this.props.signifyClient .operations() .get(`done.${identifier.prefix}`); } + throw error; }); + const isPending = !op.done; if (isPending) { const pendingOperation = await this.operationPendingStorage.save({ id: op.name, - recordType: OperationPendingRecordType.Witness, + recordType, }); this.props.eventEmitter.emit({ type: EventTypes.OperationAdded, diff --git a/src/core/agent/services/ipexCommunicationService.test.ts b/src/core/agent/services/ipexCommunicationService.test.ts index 98decdde6..cbe32cc05 100644 --- a/src/core/agent/services/ipexCommunicationService.test.ts +++ b/src/core/agent/services/ipexCommunicationService.test.ts @@ -1,4 +1,5 @@ import { Saider, Serder } from "signify-ts"; +import { current } from "@reduxjs/toolkit"; import { CoreEventEmitter } from "../event"; import { IpexCommunicationService } from "./ipexCommunicationService"; import { Agent } from "../agent"; @@ -314,7 +315,7 @@ describe("Receive individual ACDC actions", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }); @@ -432,7 +433,9 @@ describe("Receive individual ACDC actions", () => { a: { d: "saidForUuid", }, - linkedGroupRequest: { accepted: false }, + linkedRequest: { + current: "EL3A2jk9gvmVe4ROISB2iWmM8yPSNwQlmar6-SFVWSPW", + accepted: false }, }); identifierStorage.getIdentifierMetadata = jest .fn() @@ -469,7 +472,7 @@ describe("Receive group ACDC actions", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: false, }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", @@ -533,7 +536,7 @@ describe("Receive group ACDC actions", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { + linkedRequest: { "EDm8iNyZ9I3P93jb0lFtL6DJD-4Mtd2zw1ADFOoEQAqw": false, }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", @@ -587,7 +590,7 @@ describe("Receive group ACDC actions", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { + linkedRequest: { "accepted": true, "current": "EL3A2jk9gvmVe4ROISB2iWmM8yPSNwQlmar6-SFVWSPW", }, @@ -633,7 +636,7 @@ describe("Receive group ACDC actions", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "EC1cyV3zLnGs4B9AYgoGNjXESyQZrBWygz3jLlRD30bR" }, @@ -662,7 +665,7 @@ describe("Receive group ACDC actions", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: false, current: "EL3A2jk9gvmVe4ROISB2iWmM8yPSNwQlmar6-SFVWSPW", }, @@ -765,7 +768,7 @@ describe("Receive group ACDC actions", () => { expect(notificationStorage.update).toBeCalledWith(expect.objectContaining({ id: "id", route: NotificationRoute.ExnIpexGrant, - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "EL3A2jk9gvmVe4ROISB2iWmM8yPSNwQlmar6-SFVWSPW", }, @@ -825,7 +828,7 @@ describe("Receive group ACDC actions", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "current-admit-said" }, @@ -857,7 +860,7 @@ describe("Receive group ACDC actions", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: false, }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", @@ -888,7 +891,7 @@ describe("Receive group ACDC actions", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: false, current: "EL3A2jk9gvmVe4ROISB2iWmM8yPSNwQlmar6-SFVWSPW", }, @@ -916,7 +919,7 @@ describe("Receive group ACDC progress", () => { await new ConfigurationService().start(); }); - test("Cannot get linkedGroupRequest from ipex/grant if the notification is missing in the DB", async () => { + test("Cannot get linkedRequest from ipex/grant if the notification is missing in the DB", async () => { const id = "uuid"; const date = DATETIME.toISOString(); const notification = { @@ -939,7 +942,7 @@ describe("Receive group ACDC progress", () => { test("Should return the current progress of an admit linked to a grant", async () => { const grantNoteRecord = { - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "currentsaid" }, @@ -984,7 +987,7 @@ describe("Receive group ACDC progress", () => { members: ["memberA", "memberB", "memberC"], threshold: "2", othersJoined: ["memberB", "memberC"], - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "currentsaid" } @@ -993,7 +996,7 @@ describe("Receive group ACDC progress", () => { test("Should return the defaults when there is no admit linked to a grant", async () => { const grantNoteRecord = { - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, a: { d: "d" }, }; @@ -1030,7 +1033,7 @@ describe("Receive group ACDC progress", () => { members: ["memberA", "memberB", "memberC"], threshold: "2", othersJoined: [], - linkedGroupRequest: { + linkedRequest: { accepted: false, } }); @@ -1056,7 +1059,7 @@ describe("Offer ACDC individual actions", () => { }, route: NotificationRoute.ExnIpexApply, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { current: "EC1cyV3zLnGs4B9AYgoGNjXESyQZrBWygz3jLlRD30bR", accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }); @@ -1081,6 +1084,11 @@ describe("Offer ACDC individual actions", () => { await ipexCommunicationService.offerAcdcFromApply(id, grantForIssuanceExnMessage.exn.e.acdc); + expect(operationPendingStorage.save).toBeCalledWith({ + id: "opName", + recordType: OperationPendingRecordType.ExchangeOfferCredential, + }); + expect(ipexOfferMock).toBeCalledWith({ senderName: "abc123", recipient: "i", @@ -1107,8 +1115,7 @@ describe("Offer ACDC individual actions", () => { recordType: OperationPendingRecordType.ExchangeOfferCredential, }, }, - }); - expect(notificationStorage.deleteById).toBeCalledWith(id); + }); expect(notificationStorage.deleteById).toBeCalledWith(id); }); test("Cannot offer ACDC if the apply notification is missing in the DB", async () => { @@ -1151,7 +1158,7 @@ describe("Offer ACDC group actions", () => { }, route: NotificationRoute.ExnIpexApply, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }); @@ -1197,7 +1204,7 @@ describe("Offer ACDC group actions", () => { expect(notificationStorage.update).toBeCalledWith(expect.objectContaining({ id, route: NotificationRoute.ExnIpexApply, - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "EARi8kQ1PkSSRyFEIPOFPdnsnv7P2QZYEQqnmr1Eo2N8", }, @@ -1214,8 +1221,7 @@ describe("Offer ACDC group actions", () => { recordType: OperationPendingRecordType.ExchangeOfferCredential, }, }, - }); - expect(markNotificationMock).not.toBeCalled(); + }); expect(markNotificationMock).not.toBeCalled(); expect(notificationStorage.deleteById).not.toBeCalled(); }); @@ -1223,7 +1229,7 @@ describe("Offer ACDC group actions", () => { Agent.agent.getKeriaOnlineStatus = jest.fn().mockReturnValueOnce(true); eventEmitter.emit = jest.fn(); const applyNoteRecord = { - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "currentsaid" }, @@ -1250,7 +1256,7 @@ describe("Offer ACDC group actions", () => { }, route: NotificationRoute.ExnIpexApply, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: false, current: "current-offer-said" }, @@ -1320,7 +1326,7 @@ describe("Offer ACDC group actions", () => { expect(notificationStorage.update).toBeCalledWith(expect.objectContaining({ id: "id", route: NotificationRoute.ExnIpexApply, - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "current-offer-said", }, @@ -1350,7 +1356,7 @@ describe("Offer ACDC group actions", () => { }, route: NotificationRoute.ExnIpexApply, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "current-offer-said" }, @@ -1378,7 +1384,7 @@ describe("Offer ACDC group actions", () => { }, route: NotificationRoute.ExnIpexApply, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: false, }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", @@ -1422,7 +1428,7 @@ describe("Offer ACDC group progress", () => { test("Should return the current progress of a group offer", async () => { const applyNoteRecord = { - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "current-offer-said" }, @@ -1462,7 +1468,7 @@ describe("Offer ACDC group progress", () => { expect(result).toEqual({ members: ["memberA", "memberB", "memberC"], threshold: "2", - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "current-offer-said", }, @@ -1472,7 +1478,7 @@ describe("Offer ACDC group progress", () => { test("Should return the defaults when there is no offer linked to the apply", async () => { const applyNoteRecord = { - linkedGroupRequest: { + linkedRequest: { accepted: false, }, a: { d: "d" }, @@ -1504,7 +1510,7 @@ describe("Offer ACDC group progress", () => { expect(result).toEqual({ members: ["memberA", "memberB"], threshold: "2", - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, othersJoined: [], }); }); @@ -1528,7 +1534,7 @@ describe("Grant ACDC individual actions", () => { }, route: NotificationRoute.ExnIpexAgree, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false, current: "current-grant-said" }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }); @@ -1570,6 +1576,7 @@ describe("Grant ACDC individual actions", () => { }, }, }); + expect(eventEmitter.emit).toBeCalledTimes(1); expect(notificationStorage.deleteById).toBeCalledWith("agree-note-id"); }); @@ -1592,7 +1599,7 @@ describe("Grant ACDC individual actions", () => { test("Cannot present non existing ACDC", async () => { Agent.agent.getKeriaOnlineStatus = jest.fn().mockReturnValue(true); eventEmitter.emit = jest.fn(); - notificationStorage.findById = jest.fn().mockResolvedValue({ + notificationStorage.findById = jest.fn().mockResolvedValueOnce({ type: "NotificationRecord", id: "note-id", createdAt: DATETIME, @@ -1602,7 +1609,7 @@ describe("Grant ACDC individual actions", () => { }, route: NotificationRoute.ExnIpexAgree, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false, current: "current-grant-said" }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }); @@ -1617,7 +1624,7 @@ describe("Grant ACDC individual actions", () => { await expect(ipexCommunicationService.grantAcdcFromAgree("id")).rejects.toThrowError( IpexCommunicationService.CREDENTIAL_NOT_FOUND ); - + expect(ipexGrantMock).not.toBeCalled(); expect(ipexSubmitGrantMock).not.toBeCalled(); expect(notificationStorage.save).not.toBeCalled(); @@ -1638,7 +1645,7 @@ describe("Grant ACDC individual actions", () => { }, route: NotificationRoute.ExnIpexAgree, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }); @@ -1669,7 +1676,7 @@ describe("Grant ACDC group actions", () => { }, route: NotificationRoute.ExnIpexAgree, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }); @@ -1727,7 +1734,7 @@ describe("Grant ACDC group actions", () => { expect(notificationStorage.update).toBeCalledWith(expect.objectContaining({ id: "note-id", route: NotificationRoute.ExnIpexAgree, - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "EEpfEHR6EedLnEzleK7mM3AKJSoPWuSQeREC8xjyq3pa", }, @@ -1760,7 +1767,7 @@ describe("Grant ACDC group actions", () => { }, route: NotificationRoute.ExnIpexAgree, read: true, - linkedGroupRequest: { accepted: true, current: "current-grant-said" }, + linkedRequest: { accepted: true, current: "current-grant-said" }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }); @@ -1813,7 +1820,7 @@ describe("Grant ACDC group actions", () => { }, route: NotificationRoute.ExnIpexAgree, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: false, current: "current-grant-said" }, @@ -1850,7 +1857,7 @@ describe("Grant ACDC group actions", () => { expect(notificationStorage.update).toBeCalledWith(expect.objectContaining({ id: "note-id", route: NotificationRoute.ExnIpexAgree, - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "current-grant-said", }, @@ -1868,7 +1875,7 @@ describe("Grant ACDC group actions", () => { }, route: NotificationRoute.ExnIpexAgree, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "current-grant-said" }, @@ -1892,7 +1899,7 @@ describe("Grant ACDC group actions", () => { }, route: NotificationRoute.ExnIpexApply, read: true, - linkedGroupRequest: { + linkedRequest: { accepted: false, }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", diff --git a/src/core/agent/services/ipexCommunicationService.ts b/src/core/agent/services/ipexCommunicationService.ts index 13620230b..dbbbd9111 100644 --- a/src/core/agent/services/ipexCommunicationService.ts +++ b/src/core/agent/services/ipexCommunicationService.ts @@ -94,7 +94,7 @@ class IpexCommunicationService extends AgentService { } // For groups only - if (grantNoteRecord.linkedGroupRequest.accepted) { + if (grantNoteRecord.linkedRequest.accepted) { throw new Error(`${IpexCommunicationService.IPEX_ALREADY_REPLIED} ${notificationId}`); } @@ -149,8 +149,8 @@ class IpexCommunicationService extends AgentService { allSchemaSaids ); op = opMultisigAdmit; - grantNoteRecord.linkedGroupRequest = { - ...grantNoteRecord.linkedGroupRequest, + grantNoteRecord.linkedRequest = { + ...grantNoteRecord.linkedRequest, accepted: true, current: exnSaid, }; @@ -197,9 +197,9 @@ class IpexCommunicationService extends AgentService { `${IpexCommunicationService.NOTIFICATION_NOT_FOUND} ${notificationId}` ); } - + // For groups only - if (applyNoteRecord.linkedGroupRequest.accepted) { + if (applyNoteRecord.linkedRequest.accepted) { throw new Error(`${IpexCommunicationService.IPEX_ALREADY_REPLIED} ${notificationId}`); } @@ -221,8 +221,8 @@ class IpexCommunicationService extends AgentService { applyExn.exn.i ); op = opMultisigOffer; - applyNoteRecord.linkedGroupRequest = { - ...applyNoteRecord.linkedGroupRequest, + applyNoteRecord.linkedRequest = { + ...applyNoteRecord.linkedRequest, accepted: true, current: exnSaid, }; @@ -269,7 +269,7 @@ class IpexCommunicationService extends AgentService { } // For groups only - if (agreeNoteRecord.linkedGroupRequest.accepted) { + if (agreeNoteRecord.linkedRequest.accepted) { throw new Error(`${IpexCommunicationService.IPEX_ALREADY_REPLIED} ${notificationId}`); } @@ -313,8 +313,8 @@ class IpexCommunicationService extends AgentService { ); op = opMultisigGrant; - agreeNoteRecord.linkedGroupRequest = { - ...agreeNoteRecord.linkedGroupRequest, + agreeNoteRecord.linkedRequest = { + ...agreeNoteRecord.linkedRequest, accepted: true, current: exnSaid, }; @@ -543,11 +543,11 @@ class IpexCommunicationService extends AgentService { ); } - if (grantNoteRecord.linkedGroupRequest.accepted) { + if (grantNoteRecord.linkedRequest.accepted) { throw new Error(IpexCommunicationService.IPEX_ALREADY_REPLIED); } - const multiSigExnSaid = grantNoteRecord.linkedGroupRequest.current; + const multiSigExnSaid = grantNoteRecord.linkedRequest.current; if (!multiSigExnSaid) { throw new Error(IpexCommunicationService.NO_CURRENT_IPEX_MSG_TO_JOIN); } @@ -613,8 +613,8 @@ class IpexCommunicationService extends AgentService { payload: { operation: pendingOperation }, }); - grantNoteRecord.linkedGroupRequest = { - ...grantNoteRecord.linkedGroupRequest, + grantNoteRecord.linkedRequest = { + ...grantNoteRecord.linkedRequest, accepted: true, }; await this.notificationStorage.update(grantNoteRecord); @@ -628,11 +628,11 @@ class IpexCommunicationService extends AgentService { ); } - if (applyNoteRecord.linkedGroupRequest.accepted) { + if (applyNoteRecord.linkedRequest.accepted) { throw new Error(IpexCommunicationService.IPEX_ALREADY_REPLIED); } - const multiSigExnSaid = applyNoteRecord.linkedGroupRequest.current; + const multiSigExnSaid = applyNoteRecord.linkedRequest.current; if (!multiSigExnSaid) { throw new Error(IpexCommunicationService.NO_CURRENT_IPEX_MSG_TO_JOIN); } @@ -658,19 +658,19 @@ class IpexCommunicationService extends AgentService { payload: { operation: pendingOperation }, }); - applyNoteRecord.linkedGroupRequest = { - ...applyNoteRecord.linkedGroupRequest, + applyNoteRecord.linkedRequest = { + ...applyNoteRecord.linkedRequest, accepted: true, }; await this.notificationStorage.update(applyNoteRecord); } async joinMultisigGrant(multiSigExn: ExnMessage, agreeNoteRecord: NotificationRecord): Promise { - if (agreeNoteRecord.linkedGroupRequest.accepted) { + if (agreeNoteRecord.linkedRequest.accepted) { throw new Error(IpexCommunicationService.IPEX_ALREADY_REPLIED); } - if (!agreeNoteRecord.linkedGroupRequest.current) { + if (!agreeNoteRecord.linkedRequest.current) { throw new Error(IpexCommunicationService.NO_CURRENT_IPEX_MSG_TO_JOIN); } @@ -696,8 +696,8 @@ class IpexCommunicationService extends AgentService { payload: { operation: pendingOperation }, }); - agreeNoteRecord.linkedGroupRequest = { - ...agreeNoteRecord.linkedGroupRequest, + agreeNoteRecord.linkedRequest = { + ...agreeNoteRecord.linkedRequest, accepted: true, }; await this.notificationStorage.update(agreeNoteRecord); @@ -1078,8 +1078,8 @@ class IpexCommunicationService extends AgentService { const memberAids = members.signing.map((member: any) => member.aid); const othersJoined: string[] = []; - if (grantNoteRecord.linkedGroupRequest.current) { - for (const signal of (await this.props.signifyClient.groups().getRequest(grantNoteRecord.linkedGroupRequest.current))) { + if (grantNoteRecord.linkedRequest.current) { + for (const signal of (await this.props.signifyClient.groups().getRequest(grantNoteRecord.linkedRequest.current))) { othersJoined.push(signal.exn.i); } } @@ -1088,7 +1088,7 @@ class IpexCommunicationService extends AgentService { threshold: multisigAid.state.kt, members: memberAids, othersJoined: othersJoined, - linkedGroupRequest: grantNoteRecord.linkedGroupRequest, + linkedRequest: grantNoteRecord.linkedRequest, } } @@ -1113,8 +1113,8 @@ class IpexCommunicationService extends AgentService { const memberAids = members.signing.map((member: any) => member.aid); const othersJoined: string[] = []; - if (applyNoteRecord.linkedGroupRequest.current) { - for (const signal of (await this.props.signifyClient.groups().getRequest(applyNoteRecord.linkedGroupRequest.current))) { + if (applyNoteRecord.linkedRequest.current) { + for (const signal of (await this.props.signifyClient.groups().getRequest(applyNoteRecord.linkedRequest.current))) { othersJoined.push(signal.exn.i); } } @@ -1123,7 +1123,7 @@ class IpexCommunicationService extends AgentService { threshold: multisigAid.state.kt, members: memberAids, othersJoined: othersJoined, - linkedGroupRequest: applyNoteRecord.linkedGroupRequest, + linkedRequest: applyNoteRecord.linkedRequest, } } diff --git a/src/core/agent/services/ipexCommunicationService.types.ts b/src/core/agent/services/ipexCommunicationService.types.ts index fa1088c29..1cc131081 100644 --- a/src/core/agent/services/ipexCommunicationService.types.ts +++ b/src/core/agent/services/ipexCommunicationService.types.ts @@ -1,4 +1,4 @@ -import { LinkedGroupRequest } from "../records/notificationRecord.types"; +import { LinkedRequest } from "../records/notificationRecord.types"; interface CredentialsMatchingApply { schema: { @@ -17,7 +17,7 @@ interface LinkedGroupInfo { threshold: string | string[]; members: string[]; othersJoined: string[]; - linkedGroupRequest: LinkedGroupRequest; + linkedRequest: LinkedRequest; } export type { CredentialsMatchingApply, LinkedGroupInfo }; diff --git a/src/core/agent/services/keriaNotificationService.test.ts b/src/core/agent/services/keriaNotificationService.test.ts index 667e8d285..3783da2c5 100644 --- a/src/core/agent/services/keriaNotificationService.test.ts +++ b/src/core/agent/services/keriaNotificationService.test.ts @@ -1,4 +1,5 @@ import { create } from "domain"; +import { current } from "@reduxjs/toolkit"; import { Agent } from "../agent"; import { ConnectionStatus, @@ -301,7 +302,7 @@ describe("Signify notification service of agent", () => { }, connectionId: "ED_3K5-VPI8N3iRrV7o75fIMOnJfoSmEJy679HTkWsFQ", read: false, - linkedGroupRequest: { accepted: false } + linkedRequest: { accepted: false } }); groupGetRequestMock.mockResolvedValue([{ exn: { a: { gid: "id" } } }]); @@ -339,6 +340,8 @@ describe("Signify notification service of agent", () => { et: "rev", }); notificationStorage.findAllByQuery = jest.fn().mockResolvedValue([]); + notificationStorage.findById = jest.fn().mockResolvedValueOnce({linkedRequest: {current: "current_id"}}); + const notes = [notificationIpexGrantProp]; credentialStorage.getCredentialMetadata.mockResolvedValue( credentialMetadataMock @@ -629,7 +632,8 @@ describe("Signify notification service of agent", () => { ); notificationStorage.save = jest .fn() - .mockReturnValue({ id: "id", createdAt: new Date(), linkedGroupRequest: { accepted: false } }); + .mockReturnValue({ id: "id", createdAt: new Date(), linkedRequest: { accepted: false } }); + notificationStorage.findById = jest.fn().mockResolvedValueOnce({linkedRequest: {current: "current_id"}}); await keriaNotificationService.processNotification( notificationIpexApplyProp @@ -669,6 +673,7 @@ describe("Signify notification service of agent", () => { done: true, }); notificationStorage.findAllByQuery = jest.fn().mockResolvedValue([]); + notificationStorage.findById = jest.fn().mockResolvedValueOnce({linkedRequest: {current: "current_id"}}); await keriaNotificationService.processNotification( notificationIpexGrantProp @@ -687,7 +692,7 @@ describe("Signify notification service of agent", () => { }); notificationStorage.save = jest .fn() - .mockReturnValue({ id: "id", createdAt: new Date(), linkedGroupRequest: { accepted: false } }); + .mockReturnValue({ id: "id", createdAt: new Date(), linkedRequest: { accepted: false } }); credentialStorage.getCredentialMetadata.mockResolvedValue( credentialMetadataMock ); @@ -716,11 +721,12 @@ describe("Signify notification service of agent", () => { }, route: NotificationRoute.ExnIpexGrant, read: false, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: new Date(), }; notificationStorage.findAllByQuery = jest.fn().mockResolvedValue([notification]); + notificationStorage.findById = jest.fn().mockResolvedValueOnce({linkedRequest: {current: "current_id"}}); await keriaNotificationService.processNotification( notificationIpexGrantProp @@ -765,7 +771,7 @@ describe("Signify notification service of agent", () => { }); notificationStorage.save = jest .fn() - .mockReturnValue({ id: "id", createdAt: new Date(), linkedGroupRequest: { accepted: false } }); + .mockReturnValue({ id: "id", createdAt: new Date(), linkedRequest: { accepted: false } }); credentialStorage.getCredentialMetadata.mockResolvedValue(undefined); const notification = { type: "NotificationRecord", @@ -777,7 +783,7 @@ describe("Signify notification service of agent", () => { }, route: NotificationRoute.ExnIpexGrant, read: false, - linkedGroupRequest: { accepted: false }, + linkedGlinkedRequestroupRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: new Date(), }; @@ -793,6 +799,7 @@ describe("Signify notification service of agent", () => { .mockResolvedValue({ id: "id", }); + notificationStorage.findById = jest.fn().mockResolvedValueOnce({linkedRequest: {current: "current_id"}}); await keriaNotificationService.processNotification( notificationIpexGrantProp @@ -831,7 +838,8 @@ describe("Signify notification service of agent", () => { .mockResolvedValue({ id: "id", }); - + notificationStorage.findById = jest.fn().mockResolvedValueOnce({linkedRequest: {current: "current_id"}}); + await expect(keriaNotificationService.processNotification( notificationIpexGrantProp )).rejects.toThrowError(KeriaNotificationService.DUPLICATE_ISSUANCE); @@ -922,7 +930,7 @@ describe("Signify notification service of agent", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }, @@ -937,7 +945,7 @@ describe("Signify notification service of agent", () => { id: "id", read: false, route: NotificationRoute.ExnIpexGrant, - linkedGroupRequest: { + linkedRequest: { accepted: false, current: "ELW97_QXT2MWtsmWLCSR8RBzH-dcyF2gTJvt72I0wEFO", }, @@ -1030,7 +1038,7 @@ describe("Signify notification service of agent", () => { multisigId: "multisig1", read: false, connectionId: "ED_3K5-VPI8N3iRrV7o75fIMOnJfoSmEJy679HTkWsFQ", - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, }, { id: "0AC0W34tnnd2WyUCOy-790AY", @@ -1039,7 +1047,7 @@ describe("Signify notification service of agent", () => { multisigId: "multisig2", read: false, connectionId: "ED_5C2-UOA8N3iRrV7o75fIMOnJfoSmYAe829YCiSaVB", - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, }, ]; @@ -1085,7 +1093,7 @@ describe("Signify notification service of agent", () => { multisigId: "multisig1", read: false, connectionId: "ED_3K5-VPI8N3iRrV7o75fIMOnJfoSmEJy679HTkWsFQ", - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, }, { id: "0AC0W34tnnd2WyUCOy-790AY", @@ -1094,7 +1102,7 @@ describe("Signify notification service of agent", () => { multisigId: "multisig2", read: false, connectionId: "ED_5C2-UOA8N3iRrV7o75fIMOnJfoSmYAe829YCiSaVB", - linkedGroupRequest: { accepted: false, current: "current-admit-said" }, + linkedRequest: { accepted: false, current: "current-admit-said" }, }, ]; @@ -1277,7 +1285,8 @@ describe("Signify notification service of agent", () => { .mockRejectedValueOnce( new Error(IdentifierStorage.IDENTIFIER_METADATA_RECORD_MISSING) ); - + notificationStorage.findById = jest.fn().mockResolvedValueOnce({linkedRequest: {current: "current_id"}}); + jest.useRealTimers(); await keriaNotificationService.processNotification( notificationIpexGrantProp @@ -1329,7 +1338,7 @@ describe("Signify notification service of agent", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: new Date(), }, @@ -1360,7 +1369,7 @@ describe("Signify notification service of agent", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: new Date(), }, @@ -1434,7 +1443,7 @@ describe("Signify notification service of agent", () => { }); notificationStorage.save = jest .fn() - .mockReturnValue({ id: "id", createdAt: new Date(), linkedGroupRequest: { accepted: false } }); + .mockReturnValue({ id: "id", createdAt: new Date(), linkedRequest: { accepted: false } }); const notes = [notificationIpexAgreeProp]; for (const notif of notes) { @@ -1533,7 +1542,7 @@ describe("Group IPEX presentation", () => { }, route: NotificationRoute.ExnIpexApply, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: DATETIME, }, @@ -1548,7 +1557,7 @@ describe("Group IPEX presentation", () => { expect(notificationStorage.update).toBeCalledWith(expect.objectContaining({ id: "id", route: NotificationRoute.ExnIpexApply, - linkedGroupRequest: { + linkedRequest: { accepted: false, current: "ELW97_QXT2MWtsmWLCSR8RBzH-dcyF2gTJvt72I0wEFO", }, @@ -1625,7 +1634,7 @@ describe("Group IPEX presentation", () => { }, route: NotificationRoute.ExnIpexAgree, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: new Date("2024-04-29T11:01:04.903Z"), }, @@ -1638,7 +1647,7 @@ describe("Group IPEX presentation", () => { const updatedAgree = { id: "id", route: NotificationRoute.ExnIpexAgree, - linkedGroupRequest: { + linkedRequest: { accepted: false, current: "ELW97_QXT2MWtsmWLCSR8RBzH-dcyF2gTJvt72I0wEFO", }, @@ -1678,7 +1687,7 @@ describe("Group IPEX presentation", () => { .mockResolvedValue(groupIdentifierMetadataRecord); notificationStorage.save = jest .fn() - .mockReturnValue({ id: "id", createdAt: new Date(), linkedGroupRequest: { accepted: false } }); + .mockReturnValue({ id: "id", createdAt: new Date(), linkedRequest: { accepted: false } }); identifiersMemberMock.mockResolvedValue({ signing: [ { @@ -1722,7 +1731,7 @@ describe("Group IPEX presentation", () => { .mockResolvedValue(groupIdentifierMetadataRecord); notificationStorage.save = jest .fn() - .mockReturnValue({ id: "id", createdAt: new Date(), linkedGroupRequest: { accepted: false } }); + .mockReturnValue({ id: "id", createdAt: new Date(), linkedRequest: { accepted: false } }); identifiersMemberMock.mockResolvedValue({ signing: [ { @@ -2501,7 +2510,7 @@ describe("Long running operation tracker", () => { }, route: NotificationRoute.ExnIpexGrant, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: new Date(), }, @@ -2572,7 +2581,7 @@ describe("Long running operation tracker", () => { }, route: NotificationRoute.ExnIpexApply, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: new Date(), groupReplied: true, @@ -2688,7 +2697,7 @@ describe("Long running operation tracker", () => { }, route: NotificationRoute.ExnIpexAgree, read: true, - linkedGroupRequest: { accepted: false }, + linkedRequest: { accepted: false }, connectionId: "EEFjBBDcUM2IWpNF7OclCme_bE76yKE3hzULLzTOFE8E", updatedAt: new Date(), }, diff --git a/src/core/agent/services/keriaNotificationService.ts b/src/core/agent/services/keriaNotificationService.ts index ad52f4b07..d0ffca265 100644 --- a/src/core/agent/services/keriaNotificationService.ts +++ b/src/core/agent/services/keriaNotificationService.ts @@ -286,8 +286,24 @@ class KeriaNotificationService extends AgentService { let shouldCreateRecord = true; if (notif.a.r === NotificationRoute.ExnIpexApply) { + const applyNoteRecord = await this.notificationStorage.findById(notif.a.d); + + if (applyNoteRecord?.linkedRequest) { + await this.operationPendingStorage.save({ + id: applyNoteRecord?.linkedRequest.current, + recordType: OperationPendingRecordType.ExchangeOfferCredential, + }); + } shouldCreateRecord = await this.processExnIpexApplyNotification(exn); } else if (notif.a.r === NotificationRoute.ExnIpexGrant) { + const grantNoteRecord = await this.notificationStorage.findById(notif.a.d); + + if (grantNoteRecord?.linkedRequest) { + await this.operationPendingStorage.save({ + id: grantNoteRecord?.linkedRequest.current, + recordType: OperationPendingRecordType.ExchangePresentCredential, + }); + } shouldCreateRecord = await this.processExnIpexGrantNotification( notif, exn @@ -651,8 +667,8 @@ class KeriaNotificationService extends AgentService { // Refresh the date and read status for UI, and link const notificationRecord = grantNotificationRecords[0]; - notificationRecord.linkedGroupRequest = { - ...notificationRecord.linkedGroupRequest, + notificationRecord.linkedRequest = { + ...notificationRecord.linkedRequest, current: exchange.exn.d, }; notificationRecord.createdAt = new Date(); @@ -701,8 +717,8 @@ class KeriaNotificationService extends AgentService { // Refresh the date and read status for UI, and link const notificationRecord = applyNotificationRecords[0]; - notificationRecord.linkedGroupRequest = { - ...notificationRecord.linkedGroupRequest, + notificationRecord.linkedRequest = { + ...notificationRecord.linkedRequest, current: exchange.exn.d, }; notificationRecord.createdAt = new Date(); @@ -766,8 +782,8 @@ class KeriaNotificationService extends AgentService { // @TODO - foconnor: Could be optimised to only update record once but deviates from the other IPEX messages - OK for now. const notificationRecord = agreeNotificationRecords[0]; - notificationRecord.linkedGroupRequest = { - ...notificationRecord.linkedGroupRequest, + notificationRecord.linkedRequest = { + ...notificationRecord.linkedRequest, current: exchange.exn.d, }; @@ -828,7 +844,7 @@ class KeriaNotificationService extends AgentService { multisigId: result.multisigId, connectionId: result.connectionId, read: result.read, - groupReplied: result.linkedGroupRequest.current !== undefined, + groupReplied: result.linkedRequest.current !== undefined, }; } @@ -868,7 +884,7 @@ class KeriaNotificationService extends AgentService { multisigId: notification.multisigId, connectionId: notification.connectionId, read: notification.read, - groupReplied: notification.linkedGroupRequest.current !== undefined, + groupReplied: notification.linkedRequest.current !== undefined, groupInitiator: notification.groupInitiator, initiatorAid: notification.initiatorAid, }; diff --git a/src/ui/components/AppWrapper/AppWrapper.tsx b/src/ui/components/AppWrapper/AppWrapper.tsx index 4323cc87d..1282052f3 100644 --- a/src/ui/components/AppWrapper/AppWrapper.tsx +++ b/src/ui/components/AppWrapper/AppWrapper.tsx @@ -34,6 +34,7 @@ import { setFavouritesIdentifiersCache, setIdentifiersCache, setIdentifiersFilters, + updateOrAddIdentifiersCache, } from "../../../store/reducers/identifiersCache"; import { FavouriteIdentifier } from "../../../store/reducers/identifiersCache/identifiersCache.types"; import { diff --git a/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequest.test.tsx b/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequest.test.tsx index e5de4f2c0..c8213ca19 100644 --- a/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequest.test.tsx +++ b/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequest.test.tsx @@ -219,7 +219,7 @@ describe("Credential request: Multisig", () => { beforeEach(() => { getLinkedGroupFromIpexApplyMock.mockImplementation(() => Promise.resolve({ - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "", previous: undefined, diff --git a/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequest.tsx b/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequest.tsx index 2187e815a..098525f4f 100644 --- a/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequest.tsx +++ b/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequest.tsx @@ -36,7 +36,7 @@ const CredentialRequest = ({ const reachThreshold = linkedGroup && - linkedGroup.othersJoined.length + (linkedGroup.linkedGroupRequest.accepted ? 1 : 0) >= Number(linkedGroup.threshold); + linkedGroup.othersJoined.length + (linkedGroup.linkedRequest.accepted ? 1 : 0) >= Number(linkedGroup.threshold); const userAID = useMemo(() => { if(!credentialRequest) return null; @@ -58,7 +58,7 @@ const CredentialRequest = ({ return { aid: member, name: userName, - joined: linkedGroup.linkedGroupRequest.accepted, + joined: linkedGroup.linkedRequest.accepted, } } diff --git a/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequestInformation/CredentialRequestInformation.test.tsx b/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequestInformation/CredentialRequestInformation.test.tsx index ba1249f3d..adde6db47 100644 --- a/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequestInformation/CredentialRequestInformation.test.tsx +++ b/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequestInformation/CredentialRequestInformation.test.tsx @@ -111,7 +111,7 @@ describe("Credential request information", () => { describe("Credential request information: multisig", () => { const linkedGroup = { - linkedGroupRequest:{ + linkedRequest:{ accepted: false, current: "", previous: undefined, @@ -184,7 +184,7 @@ describe("Credential request information: multisig", () => { test("Initiator chosen cred", async () => { const linkedGroup = { - linkedGroupRequest:{ + linkedRequest:{ accepted: true, current: "cred-id", previous: undefined, @@ -257,7 +257,7 @@ describe("Credential request information: multisig", () => { test("Member open cred", async () => { const linkedGroup = { - linkedGroupRequest:{ + linkedRequest:{ accepted: false, current: "cred-id", previous: undefined, @@ -344,7 +344,7 @@ describe("Credential request information: multisig", () => { test("Member open cred after initiator chosen cred", async () => { const linkedGroup = { - linkedGroupRequest:{ + linkedRequest:{ accepted: true, current: "cred-id", previous: undefined, diff --git a/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequestInformation/CredentialRequestInformation.tsx b/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequestInformation/CredentialRequestInformation.tsx index 09627c6f8..14d014c61 100644 --- a/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequestInformation/CredentialRequestInformation.tsx +++ b/src/ui/pages/NotificationDetails/components/CredentialRequest/CredentialRequestInformation/CredentialRequestInformation.tsx @@ -60,15 +60,15 @@ const CredentialRequestInformation = ({ const isGroupInitiatorJoined = !!linkedGroup?.memberInfos.at(0)?.joined; const getCred = useCallback(async () => { - if(!isGroupInitiatorJoined || !linkedGroup?.linkedGroupRequest.current) return; + if(!isGroupInitiatorJoined || !linkedGroup?.linkedRequest.current) return; try { - const id = await Agent.agent.ipexCommunications.getOfferedCredentialSaid(linkedGroup.linkedGroupRequest.current); + const id = await Agent.agent.ipexCommunications.getOfferedCredentialSaid(linkedGroup.linkedRequest.current); setChooseCredId(id); } catch (error) { showError("Unable to get choosen cred", error, dispatch); } - }, [dispatch, isGroupInitiatorJoined, linkedGroup?.linkedGroupRequest]); + }, [dispatch, isGroupInitiatorJoined, linkedGroup?.linkedRequest]); useOnlineStatusEffect(getCred); @@ -114,7 +114,7 @@ const CredentialRequestInformation = ({ const reachThreshold = linkedGroup && - linkedGroup.othersJoined.length + (linkedGroup.linkedGroupRequest.accepted ? 1 : 0) >= Number(linkedGroup.threshold); + linkedGroup.othersJoined.length + (linkedGroup.linkedRequest.accepted ? 1 : 0) >= Number(linkedGroup.threshold); const showProvidedCred = () => { setViewCredId(chooseCredId); @@ -251,7 +251,7 @@ const CredentialRequestInformation = ({ } { - linkedGroup?.linkedGroupRequest.current && { threshold: "2", members: ["member-1", "member-2"], othersJoined: [], - linkedGroupRequest: { + linkedRequest: { accepted: false, } }); @@ -514,7 +514,7 @@ describe("Credential request: Multisig", () => { threshold: "2", members: ["member-1", "member-2"], othersJoined: ["member-1"], - linkedGroupRequest: { + linkedRequest: { accepted: false, } }); @@ -562,7 +562,7 @@ describe("Credential request: Multisig", () => { threshold: "2", members: ["member-1", "member-2", "member-3"], othersJoined: ["member-1", "member-2"], - linkedGroupRequest: { + linkedRequest: { accepted: false, } }); @@ -604,7 +604,7 @@ describe("Credential request: Multisig", () => { threshold: "2", members: ["member-1", "member-2"], othersJoined: ["member-1"], - linkedGroupRequest: { + linkedRequest: { accepted: true, current: "currentadmitsaid" } diff --git a/src/ui/pages/NotificationDetails/components/ReceiveCredential/ReceiveCredential.tsx b/src/ui/pages/NotificationDetails/components/ReceiveCredential/ReceiveCredential.tsx index 200fcc9d7..d14bddfaa 100644 --- a/src/ui/pages/NotificationDetails/components/ReceiveCredential/ReceiveCredential.tsx +++ b/src/ui/pages/NotificationDetails/components/ReceiveCredential/ReceiveCredential.tsx @@ -79,7 +79,7 @@ const ReceiveCredential = ({ threshold: "0", members: [], othersJoined: [], - linkedGroupRequest: { + linkedRequest: { accepted: false, } }); @@ -93,10 +93,10 @@ const ReceiveCredential = ({ const connection = connectionsCache?.[notificationDetails.connectionId]?.label; - const userAccepted = multisigMemberStatus.linkedGroupRequest.accepted; + const userAccepted = multisigMemberStatus.linkedRequest.accepted; const maxThreshold = isMultisig && - (multisigMemberStatus.othersJoined.length + (multisigMemberStatus.linkedGroupRequest.accepted ? 1 : 0)) >= + (multisigMemberStatus.othersJoined.length + (multisigMemberStatus.linkedRequest.accepted ? 1 : 0)) >= Number(multisigMemberStatus.threshold); const identifier = useMemo(() => { @@ -193,7 +193,7 @@ const ReceiveCredential = ({ if(!isMultisig || (isMultisig && isGroupInitiator)) { await Agent.agent.ipexCommunications.admitAcdcFromGrant(notificationDetails.id); - } else if(multisigMemberStatus.linkedGroupRequest.current) { + } else if(multisigMemberStatus.linkedRequest.current) { await Agent.agent.ipexCommunications.joinMultisigAdmit(notificationDetails.id); } @@ -240,13 +240,13 @@ const ReceiveCredential = ({ return MemberAcceptStatus.Accepted; } - if (multisigMemberStatus.linkedGroupRequest.accepted && identifier?.multisigManageAid === member) { + if (multisigMemberStatus.linkedRequest.accepted && identifier?.multisigManageAid === member) { return MemberAcceptStatus.Accepted; } return MemberAcceptStatus.Waiting; }, - [multisigMemberStatus.othersJoined, multisigMemberStatus.linkedGroupRequest, identifier] + [multisigMemberStatus.othersJoined, multisigMemberStatus.linkedRequest, identifier] ); const members = useMemo(() => {