diff --git a/docs/api/interfaces/modules_claims.CreateClaimRequestOptions.md b/docs/api/interfaces/modules_claims.CreateClaimRequestOptions.md index c8c9d003..ea7add76 100644 --- a/docs/api/interfaces/modules_claims.CreateClaimRequestOptions.md +++ b/docs/api/interfaces/modules_claims.CreateClaimRequestOptions.md @@ -6,15 +6,15 @@ ### Properties -- [claimData](modules_claims.CreateClaimRequestOptions.md#claimdata) +- [claim](modules_claims.CreateClaimRequestOptions.md#claim) - [registrationTypes](modules_claims.CreateClaimRequestOptions.md#registrationtypes) - [subject](modules_claims.CreateClaimRequestOptions.md#subject) ## Properties -### claimData +### claim -• **claimData**: `ClaimData` +• **claim**: `ClaimData` Claim request params diff --git a/e2e/claims.service.e2e.ts b/e2e/claims.service.e2e.ts index 1cc48e4e..9d78ccf7 100644 --- a/e2e/claims.service.e2e.ts +++ b/e2e/claims.service.e2e.ts @@ -73,6 +73,7 @@ const vcExpired = 'vcExpired'; const electrician = 'electrician'; const projectElectrician = 'projectElectrician'; const projectInstaller = 'projectInstaller'; +const roleForAsset = 'roleForAsset'; const namespace = root; const version = 1; const baseRoleDef = { @@ -160,6 +161,11 @@ const roles: Record = { roleName: projectInstaller, issuer: { issuerType: 'DID', did: [staticIssuerDID] }, }, + [`${roleForAsset}.${root}`]: { + ...baseRoleDef, + roleName: roleForAsset, + issuer: { issuerType: 'DID', did: [rootOwnerDID] }, + }, }; const mockGetRoleDefinition = jest .fn() @@ -337,6 +343,12 @@ describe('Сlaim tests', () => { data: roles[`${projectInstaller}.${root}`], returnSteps: false, }); + await domainsService.createRole({ + roleName: roleForAsset, + namespace, + data: roles[`${roleForAsset}.${root}`], + returnSteps: false, + }); ({ didRegistry, claimsService } = await connectToDidRegistry( await spawnIpfsDaemon() @@ -948,6 +960,40 @@ describe('Сlaim tests', () => { ).toBe(true); }); + test('should be able to issue without request and publish onchain for owned asset', async () => { + await signerService.connect(rootOwner, ProviderType.PrivateKey); + const claimType = `${roleForAsset}.${root}`; + const assetDID = `did:${Methods.Erc1056}:${ + Chain.VOLTA + }:${await assetsService.registerAsset()}`; + + const claim = await issueWithoutRequest(rootOwner, { + subjectDID: assetDID, + claimType, + registrationTypes, + }); + expect(claim.onChainProof).toHaveLength(132); + const mockedClaim = { + claimType, + isApproved: true, + onChainProof: claim.onChainProof, + claimTypeVersion: version, + acceptedBy: claim.acceptedBy, + subject: assetDID, + }; + mockGetClaimsBySubject + .mockReset() + .mockImplementationOnce(() => [mockedClaim]); + + await claimsService.publishPublicClaim({ + claim: { claimType }, + registrationTypes, + }); + expect( + await claimsService.hasOnChainRole(assetDID, claimType, version) + ).toBe(true); + }); + test('should be able to issue without publishing onchain', async () => { mockGetClaimsBySubject.mockImplementationOnce(() => [role1Claim]); @@ -1301,7 +1347,6 @@ describe('Сlaim tests', () => { const assetDID = `did:${Methods.Erc1056}:${ Chain.VOLTA }:${await assetsService.registerAsset()}`; - mockGetCachedOwnedAssets.mockResolvedValueOnce([ { document: { id: assetDID }, id: assetDID }, ]); diff --git a/src/modules/claims/claims.service.ts b/src/modules/claims/claims.service.ts index 5bced296..ff576cba 100644 --- a/src/modules/claims/claims.service.ts +++ b/src/modules/claims/claims.service.ts @@ -545,9 +545,9 @@ export class ClaimsService { return; } - if (!subjectAgreement && subject === this._signerService.did) { + if (!subjectAgreement) { subjectAgreement = await this.approveRolePublishing({ - subject: this._signerService.did, + subject, role: claimType, version: +claimTypeVersion, });