Skip to content

Commit

Permalink
feat(claims): remove deprecated 'fields' property
Browse files Browse the repository at this point in the history
BREAKING CHANGE: backward compatible 'fields' props have been removed. Use 'requestorFields' instead
  • Loading branch information
Passerino committed Mar 9, 2022
1 parent 6242e8b commit c2e4018
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 45 deletions.
3 changes: 0 additions & 3 deletions docs/api/classes/ClaimsService.md
Expand Up @@ -52,8 +52,6 @@

**`description`** allows subject to request for credential

**`field`** { claim: fields } - @deprecated - use requestorFields instead

#### Parameters

| Name | Type |
Expand All @@ -62,7 +60,6 @@
| `__namedParameters.claim` | `Object` |
| `__namedParameters.claim.claimType` | `string` |
| `__namedParameters.claim.claimTypeVersion` | `number` |
| `__namedParameters.claim.fields?` | { `key`: `string` ; `value`: `string` \| `number` }[] |
| `__namedParameters.claim.issuerFields?` | { `key`: `string` ; `value`: `string` \| `number` }[] |
| `__namedParameters.claim.requestorFields?` | { `key`: `string` ; `value`: `string` \| `number` }[] |
| `__namedParameters.registrationTypes?` | [`RegistrationTypes`](../enums/RegistrationTypes.md)[] |
Expand Down
62 changes: 31 additions & 31 deletions e2e/domains.service/domain.migration.ts
@@ -1,35 +1,35 @@
import { VOLTA_CHAIN_ID } from '@energyweb/iam-contracts';
import { providers } from 'ethers';
import { Wallet } from 'ethers';
import { updateLegacyIssuers } from '../../src/utils/updateLegacyIssuers';
import util from 'util';
// import { VOLTA_CHAIN_ID } from '@energyweb/iam-contracts';
// import { providers } from 'ethers';
// import { Wallet } from 'ethers';
// import { updateLegacyIssuers } from '../../src/utils/updateLegacyIssuers';
// import util from 'util';

const { JsonRpcProvider } = providers;
// const { JsonRpcProvider } = providers;

describe.skip('Domains migration', () => {
let rootOwner: Wallet;
const root = 'spotify.apps.dmitryfesenko.iam.ewc';
const ganacheUrl = 'http://localhost:8544';
// describe.skip('Domains migration', () => {
// let rootOwner: Wallet;
// const root = 'spotify.apps.dmitryfesenko.iam.ewc';
// const ganacheUrl = 'http://localhost:8544';

beforeAll(async () => {
rootOwner = Wallet.createRandom().connect(new JsonRpcProvider(ganacheUrl));
});
// beforeAll(async () => {
// rootOwner = Wallet.createRandom().connect(new JsonRpcProvider(ganacheUrl));
// });

test(
'Role definitions should be migrated',
async () => {
const updatedDomains = await updateLegacyIssuers(
root,
rootOwner,
VOLTA_CHAIN_ID
);
updatedDomains.forEach((d) => {
console.group(d.domain);
console.log('def:', util.inspect(d.legacyDef, { depth: 5 }));
console.log('updated def:', util.inspect(d.updatedDef, { depth: 5 }));
console.groupEnd();
});
},
10 * 60 * 1000
);
});
// test(
// 'Role definitions should be migrated',
// async () => {
// const updatedDomains = await updateLegacyIssuers(
// root,
// rootOwner,
// VOLTA_CHAIN_ID
// );
// updatedDomains.forEach((d) => {
// console.group(d.domain);
// console.log('def:', util.inspect(d.legacyDef, { depth: 5 }));
// console.log('updated def:', util.inspect(d.updatedDef, { depth: 5 }));
// console.groupEnd();
// });
// },
// 10 * 60 * 1000
// );
// });
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions src/modules/claims/claims.service.ts
Expand Up @@ -167,7 +167,6 @@ export class ClaimsService {

/**
* @description allows subject to request for credential
* @field { claim: fields } - @deprecated - use requestorFields instead
*/
async createClaimRequest({
claim,
Expand All @@ -177,21 +176,14 @@ export class ClaimsService {
claim: {
claimType: string;
claimTypeVersion: number;
fields?: { key: string; value: string | number }[];
requestorFields?: { key: string; value: string | number }[];
issuerFields?: { key: string; value: string | number }[];
};
subject?: string;
registrationTypes?: RegistrationTypes[];
}) {
const { claimType: role, claimTypeVersion: version } = claim;
const { fields, ...strippedClaim } = claim;
const data = {
...strippedClaim,
requestorFields: claim.requestorFields || fields || [],
};

const token = await this._didRegistry.createPublicClaim({ data, subject });
const token = await this._didRegistry.createPublicClaim({ data: claim, subject });

await this.verifyEnrolmentPrerequisites({ subject, role });

Expand Down

0 comments on commit c2e4018

Please sign in to comment.