Skip to content

Commit c79b467

Browse files
authored
Merge pull request #85 from PolymathNetwork/chore/sdk-bump
chore: 🤖 NCBD-556 Bump SDK version to `13.0.0-alpha.31`
2 parents b38b3b3 + ddef2e5 commit c79b467

File tree

93 files changed

+1439
-1338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1439
-1338
lines changed

.eslintrc

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,32 @@
1313
"sort-imports": "off",
1414
"import/order": "off",
1515
"no-dupe-class-members": "off",
16-
"no-shadow": "error",
16+
"no-shadow": "off",
17+
"@typescript-eslint/no-shadow": ["error"],
1718
"arrow-parens": "off",
1819
"no-useless-constructor": "off",
1920
"@typescript-eslint/no-useless-constructor": "error",
20-
"no-restricted-imports": ["error", { "patterns": [{
21-
"group": [".*"],
22-
"message": "Please use absolute imports instead"
23-
}],
24-
"paths": [{
25-
"name": "@polymathnetwork/polymesh-sdk/internal",
26-
"message": "polymesh-sdk/internal should not be used"
27-
}, {
28-
"name": "@polymathnetwork/polymesh-sdk/polkadot",
29-
"message": "polymesh-sdk/polkadot should not be used"
30-
}]
31-
}]
21+
"no-restricted-imports": [
22+
"error",
23+
{
24+
"patterns": [
25+
{
26+
"group": [".*"],
27+
"message": "Please use absolute imports instead"
28+
}
29+
],
30+
"paths": [
31+
{
32+
"name": "@polymathnetwork/polymesh-sdk/internal",
33+
"message": "polymesh-sdk/internal should not be used"
34+
},
35+
{
36+
"name": "@polymathnetwork/polymesh-sdk/polkadot",
37+
"message": "polymesh-sdk/polkadot should not be used"
38+
}
39+
]
40+
}
41+
]
3242
},
3343
"plugins": ["@typescript-eslint", "simple-import-sort", "node", "import", "prettier", "promise"],
3444
"parserOptions": {

.vscode/settings.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,19 @@
1010
},
1111
"eslint.nodePath": ".yarn/sdks",
1212
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
13-
"typescript.enablePromptUseWorkspaceTsdk": true
13+
"typescript.enablePromptUseWorkspaceTsdk": true,
14+
"cSpell.ignorePaths": [
15+
"package.json",
16+
"yarn.lock",
17+
"node_modules",
18+
"vscode-extension",
19+
".git/objects",
20+
".vscode"
21+
],
22+
"cSpell.ignoreRegExpList": [
23+
"/from\\s+(['\"]).*\\1/", // ignore imports
24+
"/// TODO @\\w+/", // ignore github handles in TODOs
25+
"/0x.+/" // ignore hex values
26+
],
27+
"cSpell.words": ["Isin", "metatype"]
1428
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@nestjs/core": "7.6.15",
3030
"@nestjs/platform-express": "7.6.15",
3131
"@nestjs/swagger": "4.8.0",
32-
"@polymathnetwork/polymesh-sdk": "12.0.0-alpha.8",
32+
"@polymathnetwork/polymesh-sdk": "13.0.0-alpha.31",
3333
"class-transformer": "0.4.0",
3434
"class-validator": "0.13.1",
3535
"joi": "17.4.0",

src/assets/assets.controller.spec.ts

Lines changed: 57 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,33 @@ import { Test, TestingModule } from '@nestjs/testing';
22
import { BigNumber } from '@polymathnetwork/polymesh-sdk';
33
import {
44
ClaimType,
5-
KnownTokenType,
6-
TokenIdentifierType,
5+
KnownAssetType,
6+
SecurityIdentifierType,
77
} from '@polymathnetwork/polymesh-sdk/types';
88

99
import { MAX_CONTENT_HASH_LENGTH } from '~/assets/assets.consts';
1010
import { AssetsController } from '~/assets/assets.controller';
1111
import { AssetsService } from '~/assets/assets.service';
12-
import { MockComplianceRequirements } from '~/assets/mocks/compliance-requirements.mock';
13-
import { ComplianceRequirementsModel } from '~/assets/models/compliance-requirements.model';
1412
import { PaginatedResultsModel } from '~/common/models/paginated-results.model';
15-
import { MockSecurityToken } from '~/test-utils/mocks';
16-
import { MockAssetService } from '~/test-utils/service-mocks';
13+
import { ComplianceService } from '~/compliance/compliance.service';
14+
import { MockAsset } from '~/test-utils/mocks';
15+
import { MockAssetService, MockComplianceService } from '~/test-utils/service-mocks';
1716

1817
describe('AssetsController', () => {
1918
let controller: AssetsController;
2019

2120
const mockAssetsService = new MockAssetService();
21+
const mockComplianceService = new MockComplianceService();
2222

2323
beforeEach(async () => {
2424
const module: TestingModule = await Test.createTestingModule({
2525
controllers: [AssetsController],
26-
providers: [AssetsService],
26+
providers: [AssetsService, ComplianceService],
2727
})
2828
.overrideProvider(AssetsService)
2929
.useValue(mockAssetsService)
30+
.overrideProvider(ComplianceService)
31+
.useValue(mockComplianceService)
3032
.compile();
3133

3234
controller = module.get<AssetsController>(AssetsController);
@@ -38,8 +40,8 @@ describe('AssetsController', () => {
3840

3941
describe('getDetails', () => {
4042
it('should return the details', async () => {
41-
const mockTokenDetails = {
42-
assetType: KnownTokenType.EquityCommon,
43+
const mockAssetDetails = {
44+
assetType: KnownAssetType.EquityCommon,
4345
isDivisible: false,
4446
name: 'NAME',
4547
owner: {
@@ -49,24 +51,24 @@ describe('AssetsController', () => {
4951
};
5052
const mockIdentifiers = [
5153
{
52-
type: TokenIdentifierType.Isin,
54+
type: SecurityIdentifierType.Isin,
5355
value: 'US000000000',
5456
},
5557
];
56-
const mockSecurityToken = new MockSecurityToken();
57-
mockSecurityToken.details.mockResolvedValue(mockTokenDetails);
58-
mockSecurityToken.getIdentifiers.mockResolvedValue(mockIdentifiers);
58+
const mockAsset = new MockAsset();
59+
mockAsset.details.mockResolvedValue(mockAssetDetails);
60+
mockAsset.getIdentifiers.mockResolvedValue(mockIdentifiers);
5961

6062
const mockFundingRound = 'Series A';
61-
mockSecurityToken.currentFundingRound.mockResolvedValue(mockFundingRound);
63+
mockAsset.currentFundingRound.mockResolvedValue(mockFundingRound);
6264

63-
mockAssetsService.findOne.mockResolvedValue(mockSecurityToken);
65+
mockAssetsService.findOne.mockResolvedValue(mockAsset);
6466

6567
const result = await controller.getDetails({ ticker: 'SOME_TICKER' });
6668

6769
const mockResult = {
68-
...mockTokenDetails,
69-
identifiers: mockIdentifiers,
70+
...mockAssetDetails,
71+
securityIdentifiers: mockIdentifiers,
7072
fundingRound: mockFundingRound,
7173
};
7274

@@ -83,21 +85,24 @@ describe('AssetsController', () => {
8385
},
8486
],
8587
next: '0xddddd',
86-
count: 2,
88+
count: new BigNumber(2),
8789
};
8890

8991
it('should return the list of Asset holders', async () => {
9092
mockAssetsService.findHolders.mockResolvedValue(mockHolders);
9193

92-
const result = await controller.getHolders({ ticker: 'SOME_TICKER' }, { size: 1 });
94+
const result = await controller.getHolders(
95+
{ ticker: 'SOME_TICKER' },
96+
{ size: new BigNumber(1) }
97+
);
9398
const expectedResults = mockHolders.data.map(holder => {
9499
return { identity: holder.identity.did, balance: holder.balance };
95100
});
96101

97102
expect(result).toEqual(
98103
new PaginatedResultsModel({
99104
results: expectedResults,
100-
total: mockHolders.count,
105+
total: new BigNumber(mockHolders.count),
101106
next: mockHolders.next,
102107
})
103108
);
@@ -108,7 +113,7 @@ describe('AssetsController', () => {
108113

109114
const result = await controller.getHolders(
110115
{ ticker: 'SOME_TICKER' },
111-
{ size: 1, start: 'SOME_START_KEY' }
116+
{ size: new BigNumber(1), start: 'SOME_START_KEY' }
112117
);
113118

114119
const expectedResults = mockHolders.data.map(holder => {
@@ -118,7 +123,7 @@ describe('AssetsController', () => {
118123
expect(result).toEqual(
119124
new PaginatedResultsModel({
120125
results: expectedResults,
121-
total: mockHolders.count,
126+
total: new BigNumber(mockHolders.count),
122127
next: mockHolders.next,
123128
})
124129
);
@@ -135,18 +140,21 @@ describe('AssetsController', () => {
135140
},
136141
],
137142
next: '0xddddd',
138-
count: 2,
143+
count: new BigNumber(2),
139144
};
140145

141146
it('should return the list of Asset documents', async () => {
142147
mockAssetsService.findDocuments.mockResolvedValue(mockDocuments);
143148

144-
const result = await controller.getDocuments({ ticker: 'SOME_TICKER' }, { size: 1 });
149+
const result = await controller.getDocuments(
150+
{ ticker: 'SOME_TICKER' },
151+
{ size: new BigNumber(1) }
152+
);
145153

146154
expect(result).toEqual(
147155
new PaginatedResultsModel({
148156
results: mockDocuments.data,
149-
total: mockDocuments.count,
157+
total: new BigNumber(mockDocuments.count),
150158
next: mockDocuments.next,
151159
})
152160
);
@@ -157,63 +165,53 @@ describe('AssetsController', () => {
157165

158166
const result = await controller.getDocuments(
159167
{ ticker: 'SOME_TICKER' },
160-
{ size: 1, start: 'SOME_START_KEY' }
168+
{ size: new BigNumber(1), start: 'SOME_START_KEY' }
161169
);
162170

163171
expect(result).toEqual(
164172
new PaginatedResultsModel({
165173
results: mockDocuments.data,
166-
total: mockDocuments.count,
174+
total: new BigNumber(mockDocuments.count),
167175
next: mockDocuments.next,
168176
})
169177
);
170178
});
171179
});
172180

173-
describe('getComplianceRequirements', () => {
174-
it('should return the list of all compliance requirements of an Asset', async () => {
175-
const mockComplianceRequirements = new MockComplianceRequirements();
176-
mockAssetsService.findComplianceRequirements.mockResolvedValue(mockComplianceRequirements);
177-
178-
const result = await controller.getComplianceRequirements({ ticker: 'SOME_TICKER' });
179-
180-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
181-
expect(result).toEqual(new ComplianceRequirementsModel(mockComplianceRequirements as any));
182-
});
183-
});
184-
185181
describe('getTrustedClaimIssuers', () => {
186182
it('should return the list of all trusted Claim Issuers of an Asset', async () => {
187183
const mockClaimIssuers = [
188184
{
189-
did: 'Ox6'.padEnd(66, '0'),
185+
identity: {
186+
did: 'Ox6'.padEnd(66, '0'),
187+
},
190188
trustedFor: [ClaimType.Accredited, ClaimType.InvestorUniqueness],
191189
},
192190
];
193-
mockAssetsService.findTrustedClaimIssuers.mockResolvedValue(mockClaimIssuers);
191+
mockComplianceService.findTrustedClaimIssuers.mockResolvedValue(mockClaimIssuers);
194192

195193
const result = await controller.getTrustedClaimIssuers({ ticker: 'SOME_TICKER' });
196194

197-
expect(result).toEqual({ results: mockClaimIssuers });
195+
expect(result).toEqual({
196+
results: [
197+
{
198+
did: 'Ox6'.padEnd(66, '0'),
199+
trustedFor: [ClaimType.Accredited, ClaimType.InvestorUniqueness],
200+
},
201+
],
202+
});
198203
});
199204
});
200205

201206
describe('reserveTicker', () => {
202207
it('should call the service and return the results', async () => {
203208
const input = { ticker: 'SOME_TICKER', signer: '0x6000' };
204-
const response = {
205-
transactions: [
206-
{
207-
blockHash: '0xfb3f745444ae63e66240d57eb9d769b0152af23214600425fe7c01f02512d960',
208-
transactionHash: '0xe16c51097d10e712b9f6ff572ca0c8c77ffcab0af8a8cb0598f8b891ab3ce46a',
209-
transactionTag: 'asset.reserveTicker',
210-
},
211-
],
212-
};
213-
mockAssetsService.registerTicker.mockResolvedValue(response);
209+
mockAssetsService.registerTicker.mockResolvedValue({ transactions: ['transaction'] });
214210

215211
const result = await controller.registerTicker(input);
216-
expect(result).toEqual(response);
212+
expect(result).toEqual({
213+
transactions: ['transaction'],
214+
});
217215
expect(mockAssetsService.registerTicker).toHaveBeenCalledWith(input);
218216
});
219217

@@ -224,22 +222,13 @@ describe('AssetsController', () => {
224222
name: 'Berkshire Class A',
225223
ticker: 'BRK.A',
226224
isDivisible: false,
227-
assetType: KnownTokenType.EquityCommon,
225+
assetType: KnownAssetType.EquityCommon,
228226
requireInvestorUniqueness: false,
229227
};
230-
const response = {
231-
transactions: [
232-
{
233-
blockHash: '0xfb3f745444ae63e66240d57eb9d769b0152af23214600425fe7c01f02512d960',
234-
transactionHash: '0xe16c51097d10e712b9f6ff572ca0c8c77ffcab0af8a8cb0598f8b891ab3ce46a',
235-
transactionTag: 'asset.createAsset',
236-
},
237-
],
238-
};
239-
mockAssetsService.createAsset.mockResolvedValue(response);
228+
mockAssetsService.createAsset.mockResolvedValue({ transactions: ['transaction'] });
240229

241230
const result = await controller.createAsset(input);
242-
expect(result).toEqual(response);
231+
expect(result).toEqual({ transactions: ['transaction'] });
243232
expect(mockAssetsService.createAsset).toHaveBeenCalledWith(input);
244233
});
245234
});
@@ -248,20 +237,11 @@ describe('AssetsController', () => {
248237
it('should call the service and return the results', async () => {
249238
const signer = '0x6000';
250239
const ticker = 'TICKER';
251-
const amount = new BigNumber('1000');
252-
const response = {
253-
transactions: [
254-
{
255-
blockHash: '0xfb3f745444ae63e66240d57eb9d769b0152af23214600425fe7c01f02512d960',
256-
transactionHash: '0xe16c51097d10e712b9f6ff572ca0c8c77ffcab0af8a8cb0598f8b891ab3ce46a',
257-
transactionTag: 'asset.issue',
258-
},
259-
],
260-
};
261-
mockAssetsService.issue.mockResolvedValue(response);
240+
const amount = new BigNumber(1000);
241+
mockAssetsService.issue.mockResolvedValue({ transactions: ['transaction'] });
262242

263243
const result = await controller.issue({ ticker }, { signer, amount });
264-
expect(result).toEqual(response);
244+
expect(result).toEqual({ transactions: ['transaction'] });
265245
expect(mockAssetsService.issue).toHaveBeenCalledWith(ticker, { signer, amount });
266246
});
267247
});

0 commit comments

Comments
 (0)