Skip to content

Commit eb1ea7a

Browse files
committed
feat: 🎸 remove POST /mock-cdd use /create-test-accounts instead
Remove an endpoint that has been marked for 2 years since the `testUtils` pallet is expected to be removed from the chain soon BREAKING CHANGE: 🧨 POST /mock-cdd has been removed
1 parent 4156d0e commit eb1ea7a

6 files changed

+57
-195
lines changed

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@polymeshassociation/fireblocks-signing-manager": "^2.5.0",
5050
"@polymeshassociation/hashicorp-vault-signing-manager": "^3.4.0",
5151
"@polymeshassociation/local-signing-manager": "^3.3.0",
52-
"@polymeshassociation/polymesh-sdk": "^26.2.0-alpha.4",
52+
"@polymeshassociation/polymesh-sdk": "27.0.0-alpha.4",
5353
"@polymeshassociation/signing-manager-types": "^3.2.0",
5454
"class-transformer": "0.5.1",
5555
"class-validator": "^0.14.0",

‎src/developer-testing/developer-testing.service.spec.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,4 @@ describe('DeveloperTestingService', () => {
143143
);
144144
});
145145
});
146-
147-
describe('createMockCdd', () => {
148-
it('should return the created Identity', async () => {
149-
const params = {
150-
address,
151-
initialPolyx: new BigNumber(10),
152-
};
153-
mockPolymeshApi.network.getSs58Format.mockReturnValue(new BigNumber(42));
154-
155-
when(mockAccountsService.findOne)
156-
.calledWith(address)
157-
.mockResolvedValue({
158-
getIdentity: jest.fn().mockResolvedValue('fakeId'),
159-
});
160-
161-
const result = await service.createMockCdd(params);
162-
expect(result).toEqual('fakeId');
163-
});
164-
});
165146
});

‎src/developer-testing/developer-testing.service.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { KeyringPair } from '@polkadot/keyring/types';
55
import { Account, Identity } from '@polymeshassociation/polymesh-sdk/types';
66

77
import { AccountsService } from '~/accounts/accounts.service';
8-
import { AppInternalError, AppValidationError } from '~/common/errors';
8+
import { AppInternalError } from '~/common/errors';
99
import { isNotNull } from '~/common/utils';
1010
import { CreateMockIdentityDto } from '~/developer-testing/dto/create-mock-identity.dto';
1111
import { CreateTestAccountsDto } from '~/developer-testing/dto/create-test-accounts.dto';
@@ -133,40 +133,4 @@ export class DeveloperTestingService {
133133

134134
return identities;
135135
}
136-
137-
/**
138-
* @deprecated Use @link{DeveloperTestingService.createAccount} (the batched version) instead
139-
* @note intended for development chains only (i.e. Alice exists and can call `testUtils.createMockCddClaim`)
140-
*/
141-
public async createMockCdd({ address, initialPolyx }: CreateMockIdentityDto): Promise<Identity> {
142-
const {
143-
_polkadotApi: {
144-
tx: { testUtils, balances, sudo },
145-
},
146-
} = this.polymeshService.polymeshApi;
147-
148-
if (!testUtils) {
149-
throw new AppValidationError(
150-
'The chain does not have the `testUtils` pallet enabled. This endpoint is intended for development use only'
151-
);
152-
}
153-
154-
const targetAccount = await this.accountsService.findOne(address);
155-
156-
await this.polymeshService.execTransaction(
157-
this.sudoPair,
158-
testUtils.mockCddRegisterDid,
159-
address
160-
);
161-
const setBalance = balances.setBalance(address, initialPolyx.shiftedBy(6).toNumber(), 0);
162-
await this.polymeshService.execTransaction(this.sudoPair, sudo.sudo, setBalance);
163-
164-
const id = await targetAccount.getIdentity();
165-
166-
if (!id) {
167-
throw new AppInternalError('The Identity was not created');
168-
}
169-
170-
return id;
171-
}
172136
}

‎src/identities/identities.controller.spec.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { MockDistributionWithDetails } from '~/corporate-actions/mocks/distribut
2626
import { RegisterIdentityDto } from '~/identities/dto/register-identity.dto';
2727
import { IdentitiesController } from '~/identities/identities.controller';
2828
import { IdentitiesService } from '~/identities/identities.service';
29-
import * as identityUtil from '~/identities/identities.util';
3029
import { AccountModel } from '~/identities/models/account.model';
3130
import { IdentityModel } from '~/identities/models/identity.model';
3231
import { IdentitySignerModel } from '~/identities/models/identity-signer.model';
@@ -67,8 +66,6 @@ describe('IdentitiesController', () => {
6766

6867
const mockTickerReservationsService = new MockTickerReservationsService();
6968

70-
const mockDeveloperTestingService = mockDeveloperServiceProvider.useValue;
71-
7269
beforeEach(async () => {
7370
const module = await Test.createTestingModule({
7471
controllers: [IdentitiesController],
@@ -521,23 +518,6 @@ describe('IdentitiesController', () => {
521518
});
522519
});
523520

524-
describe('mockCdd', () => {
525-
it('should call the service and return the Identity', async () => {
526-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
527-
const fakeIdentityModel = 'fakeIdentityModel' as any;
528-
jest.spyOn(identityUtil, 'createIdentityModel').mockResolvedValue(fakeIdentityModel);
529-
530-
const params = {
531-
address: '5abc',
532-
initialPolyx: new BigNumber(10),
533-
};
534-
535-
const result = await controller.createMockCdd(params);
536-
expect(result).toEqual(fakeIdentityModel);
537-
expect(mockDeveloperTestingService.createMockCdd).toHaveBeenCalledWith(params);
538-
});
539-
});
540-
541521
describe('getClaimScopes', () => {
542522
it('should call the service and return the list of claim scopes', async () => {
543523
const params = {

‎src/identities/identities.controller.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import { handleServiceResult, TransactionResponseModel } from '~/common/utils';
5151
import { createDividendDistributionDetailsModel } from '~/corporate-actions/corporate-actions.util';
5252
import { DividendDistributionDetailsModel } from '~/corporate-actions/models/dividend-distribution-details.model';
5353
import { DeveloperTestingService } from '~/developer-testing/developer-testing.service';
54-
import { CreateMockIdentityDto } from '~/developer-testing/dto/create-mock-identity.dto';
5554
import { AddSecondaryAccountParamsDto } from '~/identities/dto/add-secondary-account-params.dto';
5655
import { RegisterIdentityDto } from '~/identities/dto/register-identity.dto';
5756
import { RotatePrimaryKeyParamsDto } from '~/identities/dto/rotate-primary-key-params.dto';
@@ -529,27 +528,6 @@ export class IdentitiesController {
529528
return new ResultsModel({ results });
530529
}
531530

532-
@ApiTags('developer-testing')
533-
@ApiOperation({
534-
summary:
535-
'Creates a fake Identity for an Account and sets its POLYX balance (DEPRECATED: Use `/developer-testing/create-test-account` instead)',
536-
description:
537-
'This endpoint creates a Identity for an Account and sets its POLYX balance. A sudo account must be configured.',
538-
})
539-
@ApiOkResponse({ description: 'The details of the newly created Identity' })
540-
@ApiBadRequestResponse({
541-
description:
542-
'This instance of the REST API is pointing to a chain that lacks development features. A proper CDD provider must be used instead',
543-
})
544-
@ApiInternalServerErrorResponse({
545-
description: 'Failed to execute an extrinsic, or something unexpected',
546-
})
547-
@Post('/mock-cdd')
548-
public async createMockCdd(@Body() params: CreateMockIdentityDto): Promise<IdentityModel> {
549-
const identity = await this.developerTestingService.createMockCdd(params);
550-
return createIdentityModel(identity);
551-
}
552-
553531
@ApiTags('claims')
554532
@ApiOperation({
555533
summary: 'Fetch all CDD claims for an Identity',

0 commit comments

Comments
 (0)