Skip to content

Commit d81c793

Browse files
committed
feat: 🎸 update code to accomodate sdk v27.0.2
Remove multiSig.joinCreator (by default MultiSigs are joined now). No longer accept Ticker in claim scopes. Asset ID should be used instead BREAKING CHANGE: 🧨 /multisigs/:multiSigAddress/join-creator is removed. Ticker is no longer allowed for claim scope (use asset ID instead)
1 parent 311924f commit d81c793

10 files changed

+24
-99
lines changed

‎src/claims/decorators/validation.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ export function IsValidScopeValue(property: string, validationOptions?: Validati
5454
switch (scopeType) {
5555
case ScopeType.Asset:
5656
return isString(value) && (isAssetId(value) || isTicker(value));
57-
case ScopeType.Ticker:
58-
return isString(value) && isTicker(value);
5957
case ScopeType.Identity:
6058
return (
6159
isHexadecimal(value) &&
@@ -76,8 +74,6 @@ export function IsValidScopeValue(property: string, validationOptions?: Validati
7674
switch (scopeType) {
7775
case ScopeType.Asset:
7876
return 'value must be a valid Asset ID (either in hex or UUID format) or a valid ticker (all uppercase and no longer than 12 characters)';
79-
case ScopeType.Ticker:
80-
return `value must be all uppercase and no longer than 12 characters for type: ${scopeType}`;
8177
case ScopeType.Identity:
8278
return `value must be a hex string ${DID_LENGTH} characters long and prefixed with 0x`;
8379
case ScopeType.Custom:

‎src/claims/dto/claim.dto.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ describe('claimsDto', () => {
153153
type: ClaimType.Affiliate,
154154
scope: { type: 'Wrong', value: 123 },
155155
},
156-
['scope.type must be one of the following values: Identity, Ticker, Asset, Custom'],
156+
['scope.type must be one of the following values: Identity, Asset, Custom'],
157157
],
158158
[
159159
'CustomerDueDiligence without `cddId`',
@@ -189,7 +189,7 @@ describe('claimsDto', () => {
189189
scope: {},
190190
customClaimTypeId: new BigNumber('1'),
191191
},
192-
['scope.type must be one of the following values: Identity, Ticker, Asset, Custom'],
192+
['scope.type must be one of the following values: Identity, Asset, Custom'],
193193
],
194194
];
195195
test.each(cases)('%s', async (_, input, expected) => {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,6 @@ describe('IdentitiesController', () => {
763763
it('should return the Assets for which the Identity has permissions', async () => {
764764
const asset = createMock<Asset>({
765765
id: '3616b82e-8e10-80ae-dc95-2ea28b9db8b3',
766-
ticker: 'SOME_TICKER',
767766
});
768767
const assetGroups = [
769768
{ asset, group: createMock<CustomPermissionGroup>({ id: new BigNumber(1), asset }) },

‎src/identities/identities.service.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ describe('IdentitiesService', () => {
319319
it('should return the list of AssetsGroups for which the Identity has permissions', async () => {
320320
const asset = createMock<Asset>({
321321
id: '3616b82e-8e10-80ae-dc95-2ea28b9db8b3',
322-
ticker: 'SOME_TICKER',
323322
});
324323
const assetGroups = [
325324
{ asset, group: createMock<CustomPermissionGroup>({ id: new BigNumber(1), asset }) },

‎src/multi-sigs/dto/join-creator.dto.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎src/multi-sigs/multi-sigs.controller.spec.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NotFoundException } from '@nestjs/common';
33
import { Test, TestingModule } from '@nestjs/testing';
44
import { BigNumber } from '@polymeshassociation/polymesh-sdk';
55
import {
6+
HistoricalMultiSigProposal,
67
Identity,
78
MultiSig,
89
MultiSigProposal,
@@ -56,18 +57,6 @@ describe('MultiSigsController', () => {
5657
});
5758
});
5859

59-
describe('joinCreator', () => {
60-
it('should call the service and return the result', async () => {
61-
const params = { asPrimary: true };
62-
63-
when(service.joinCreator).calledWith(multiSigAddress, params).mockResolvedValue(txResult);
64-
65-
const result = await controller.joinCreator({ multiSigAddress }, params);
66-
67-
expect(result).toEqual(processedTxResult);
68-
});
69-
});
70-
7160
describe('modify', () => {
7261
it('should call the service and return the result', async () => {
7362
const params = {
@@ -190,11 +179,20 @@ describe('MultiSigsController', () => {
190179
details: jest.fn().mockResolvedValue(mockDetails),
191180
id: new BigNumber(2),
192181
});
193-
const mockPaginatedResult = createMock<ResultSet<MultiSigProposal>>({
194-
data: [mockProposal1, mockProposal2],
182+
183+
const historic1 = createMock<HistoricalMultiSigProposal>({
184+
proposal: mockProposal1,
185+
});
186+
const historic2 = createMock<HistoricalMultiSigProposal>({
187+
proposal: mockProposal2,
188+
});
189+
190+
// Passing `HistoricalMultiSigProposal` would give an infinite type error
191+
const mockPaginatedResult = createMock<ResultSet<unknown>>({
192+
data: [historic1, historic2],
195193
next: new BigNumber(2),
196194
count: new BigNumber(2),
197-
});
195+
}) as ResultSet<HistoricalMultiSigProposal>;
198196

199197
when(service.getHistoricalProposals)
200198
.calledWith(multiSigAddress)

‎src/multi-sigs/multi-sigs.controller.ts

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { handleServiceResult, TransactionResolver, TransactionResponseModel } fr
2121
import { IdentityModel } from '~/identities/models/identity.model';
2222
import { IdentitySignerModel } from '~/identities/models/identity-signer.model';
2323
import { CreateMultiSigDto } from '~/multi-sigs/dto/create-multi-sig.dto';
24-
import { JoinCreatorDto } from '~/multi-sigs/dto/join-creator.dto';
2524
import { ModifyMultiSigDto } from '~/multi-sigs/dto/modify-multi-sig.dto';
2625
import { MultiSigParamsDto } from '~/multi-sigs/dto/multi-sig-params.dto';
2726
import { MultiSigProposalParamsDto } from '~/multi-sigs/dto/multisig-proposal-params.dto';
@@ -68,29 +67,6 @@ export class MultiSigsController {
6867
return handleServiceResult(serviceResult, resolver);
6968
}
7069

71-
@ApiOperation({
72-
summary: "Join the creator's identity as a signing key",
73-
description: `This endpoint joins a MultiSig to its creator's identity. For the multiSig to join a DID not belonging to the creator then a join identity auth needs to be made and accepted by the MultiSig.
74-
NOTE: This endpoint is only applicable for 6.x.x chains as from 7.x.x chain, the MultiSig is automatically attached to the creator's identity`,
75-
deprecated: true,
76-
})
77-
@ApiTransactionResponse({
78-
description: 'Details about the transaction',
79-
type: TransactionQueueModel,
80-
})
81-
@ApiBadRequestResponse({
82-
description: '<ul>' + '<li>The multiSig is already attached to an identity</li>' + '</ul>',
83-
})
84-
@Post(':multiSigAddress/join-creator')
85-
async joinCreator(
86-
@Param() { multiSigAddress }: MultiSigParamsDto,
87-
@Body() params: JoinCreatorDto
88-
): Promise<TransactionResponseModel> {
89-
const serviceResult = await this.multiSigService.joinCreator(multiSigAddress, params);
90-
91-
return handleServiceResult(serviceResult);
92-
}
93-
9470
@ApiOperation({
9571
summary: 'Modify a MultiSig',
9672
description: 'This endpoint allows for a multiSig to be modified by its creator',
@@ -361,12 +337,12 @@ export class MultiSigsController {
361337
multiSigAddress
362338
);
363339

364-
const detailsPromises = data.map(proposal => proposal.details());
340+
const detailsPromises = data.map(({ proposal }) => proposal.details());
365341
const details = await Promise.all(detailsPromises);
366342

367343
return new PaginatedResultsModel({
368344
results: data.map(
369-
(proposal, i) =>
345+
({ proposal }, i) =>
370346
new MultiSigProposalModel({
371347
multiSigAddress,
372348
proposalId: proposal.id,

‎src/multi-sigs/multi-sigs.service.spec.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Test, TestingModule } from '@nestjs/testing';
66
import { BigNumber } from '@polymeshassociation/polymesh-sdk';
77
import {
88
Account,
9+
HistoricalMultiSigProposal,
910
Identity,
1011
MultiSig,
1112
MultiSigProposal,
@@ -41,13 +42,15 @@ describe('MultiSigsService', () => {
4142

4243
let multiSig: DeepMocked<MultiSig>;
4344
let proposal: DeepMocked<MultiSigProposal>;
45+
let historicalProposal: DeepMocked<HistoricalMultiSigProposal>;
4446

4547
beforeEach(async () => {
4648
mockAccountService = createMock<AccountsService>();
4749
mockTransactionsService = new MockTransactionsService();
4850

4951
multiSig = createMock<MultiSig>({ address: multiSigAddress });
5052
proposal = createMock<MultiSigProposal>({ id: proposalId });
53+
historicalProposal = createMock<HistoricalMultiSigProposal>({ proposal });
5154
mockPolymeshApi = new MockPolymesh();
5255

5356
const module: TestingModule = await Test.createTestingModule({
@@ -150,14 +153,6 @@ describe('MultiSigsService', () => {
150153
});
151154
});
152155

153-
describe('joinCreator', () => {
154-
it('should join the multiSig to the creator', async () => {
155-
const result = await service.joinCreator(multiSigAddress, { options });
156-
157-
expect(result).toEqual(txResult);
158-
});
159-
});
160-
161156
describe('approve', () => {
162157
it('should approve the proposal', async () => {
163158
const result = await service.approve(proposalParams, { options });
@@ -177,7 +172,7 @@ describe('MultiSigsService', () => {
177172
describe('getHistoricalProposals', () => {
178173
it('should return historical proposals', async () => {
179174
const mockResultSet = {
180-
data: [proposal],
175+
data: [historicalProposal],
181176
next: new BigNumber(2),
182177
count: new BigNumber(1),
183178
};

‎src/multi-sigs/multi-sigs.service.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Injectable } from '@nestjs/common';
22
import { BigNumber } from '@polymeshassociation/polymesh-sdk';
33
import {
4+
HistoricalMultiSigProposal,
45
Identity,
5-
JoinCreatorParams,
66
MultiSig,
77
MultiSigProposal,
88
ResultSet,
@@ -14,7 +14,6 @@ import { TransactionBaseDto } from '~/common/dto/transaction-base-dto';
1414
import { AppValidationError } from '~/common/errors';
1515
import { extractTxOptions, ServiceReturn } from '~/common/utils';
1616
import { CreateMultiSigDto } from '~/multi-sigs/dto/create-multi-sig.dto';
17-
import { JoinCreatorDto } from '~/multi-sigs/dto/join-creator.dto';
1817
import { ModifyMultiSigDto } from '~/multi-sigs/dto/modify-multi-sig.dto';
1918
import { MultiSigProposalParamsDto } from '~/multi-sigs/dto/multisig-proposal-params.dto';
2019
import { SetMultiSigAdminDto } from '~/multi-sigs/dto/set-multi-sig-admin.dto';
@@ -88,14 +87,6 @@ export class MultiSigsService {
8887
return this.transactionsService.submit(multiSig.modify, { signers: signerAccounts }, options);
8988
}
9089

91-
public async joinCreator(multiSigAddress: string, params: JoinCreatorDto): ServiceReturn<void> {
92-
const { options, args } = extractTxOptions(params);
93-
94-
const multi = await this.findOne(multiSigAddress);
95-
96-
return this.transactionsService.submit(multi.joinCreator, args as JoinCreatorParams, options);
97-
}
98-
9990
public async approve(
10091
proposalParams: MultiSigProposalParamsDto,
10192
txParams: TransactionBaseDto
@@ -179,7 +170,7 @@ export class MultiSigsService {
179170
multiSigAddress: string,
180171
size?: BigNumber,
181172
start?: BigNumber
182-
): Promise<ResultSet<MultiSigProposal>> {
173+
): Promise<ResultSet<HistoricalMultiSigProposal>> {
183174
const multiSig = await this.findOne(multiSigAddress);
184175

185176
return multiSig.getHistoricalProposals({ size, start });

‎src/test-utils/mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ export function createMockMetadataEntry(
502502
partial: PartialFuncReturn<MetadataEntry> = {
503503
id: new BigNumber(1),
504504
type: MetadataType.Local,
505-
asset: { id: testValues.assetId, ticker: 'TICKER' },
505+
asset: { id: testValues.assetId },
506506
}
507507
): DeepMocked<MetadataEntry> {
508508
return createMock<MetadataEntry>(partial);

0 commit comments

Comments
 (0)