Skip to content

Commit dcb8211

Browse files
authored
Apply common 'prettier' formatting rules across the entire repo (#358)
Update the individual services in the repo to reference the shared `@projectlibertylabs/prettier-config` package that lives in [packages/prettier-config](./packages/prettier-config), and apply formatting.
1 parent 9a9d250 commit dcb8211

File tree

61 files changed

+510
-798
lines changed

Some content is hidden

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

61 files changed

+510
-798
lines changed

.prettierrc.json

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
{
2-
"arrowParens": "always",
3-
"bracketSpacing": true,
4-
"semi": true,
5-
"trailingComma": "all",
6-
"singleQuote": true,
7-
"printWidth": 120,
8-
"tabWidth": 2,
9-
"useTabs": false
10-
}
1+
"@projectlibertylabs/prettier-config"

services/account/apps/api/src/api.module.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ import { BlockchainModule } from '#lib/blockchain/blockchain.module';
1212
import { redisEventsToEventEmitter } from '#lib/utils/redis';
1313
import { EnqueueService } from '#lib/services/enqueue-request.service';
1414
import { QueueModule, QueueConstants } from '#lib/queues';
15-
import {
16-
AccountsControllerV1,
17-
DelegationControllerV1,
18-
HandlesControllerV1,
19-
KeysControllerV1,
20-
HealthController,
21-
} from './controllers';
15+
import { AccountsControllerV1, DelegationControllerV1, HandlesControllerV1, KeysControllerV1, HealthController } from './controllers';
2216
import { ApiService, AccountsService, HandlesService, DelegationService, KeysService } from './services';
2317

2418
@Module({

services/account/apps/api/src/build-openapi.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import { NestFactory } from '@nestjs/core';
1111
process.env.REDIS_URL = 'http://127.0.0.1';
1212
process.env.FREQUENCY_URL = 'http://127.0.0.1';
1313
process.env.FREQUENCY_HTTP_URL = 'http://127.0.0.1';
14-
process.env.PROVIDER_ACCOUNT_SEED_PHRASE =
15-
'offer debate skin describe light badge fish turtle actual inject struggle border';
14+
process.env.PROVIDER_ACCOUNT_SEED_PHRASE = 'offer debate skin describe light badge fish turtle actual inject struggle border';
1615
process.env.PROVIDER_ID = '0';
1716
process.env.WEBHOOK_BASE_URL = 'http://127.0.0.1';
1817
process.env.CAPACITY_LIMIT = '{"type":"amount","value":0}';

services/account/apps/api/src/metadata.ts

+10-31
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
/* eslint-disable */
22
export default async () => {
33
const t = {
4-
['../../../libs/common/src/types/dtos/wallet.login.request.dto']: await import(
5-
'../../../libs/common/src/types/dtos/wallet.login.request.dto'
6-
),
7-
['../../../libs/common/src/types/dtos/accounts.response.dto']: await import(
8-
'../../../libs/common/src/types/dtos/accounts.response.dto'
9-
),
4+
['../../../libs/common/src/types/dtos/wallet.login.request.dto']: await import('../../../libs/common/src/types/dtos/wallet.login.request.dto'),
5+
['../../../libs/common/src/types/dtos/accounts.response.dto']: await import('../../../libs/common/src/types/dtos/accounts.response.dto'),
106
['@polkadot/types-codec/primitive/U32']: await import('@polkadot/types-codec/primitive/U32'),
11-
['../../../libs/common/src/types/dtos/wallet.login.config.response.dto']: await import(
12-
'../../../libs/common/src/types/dtos/wallet.login.config.response.dto'
13-
),
14-
['../../../libs/common/src/types/dtos/wallet.login.response.dto']: await import(
15-
'../../../libs/common/src/types/dtos/wallet.login.response.dto'
16-
),
17-
['../../../libs/common/src/types/dtos/delegation.response.dto']: await import(
18-
'../../../libs/common/src/types/dtos/delegation.response.dto'
19-
),
20-
['../../../libs/common/src/types/dtos/transaction.response.dto']: await import(
21-
'../../../libs/common/src/types/dtos/transaction.response.dto'
22-
),
23-
['../../../libs/common/src/types/dtos/keys.response.dto']: await import(
24-
'../../../libs/common/src/types/dtos/keys.response.dto'
25-
),
7+
['../../../libs/common/src/types/dtos/wallet.login.config.response.dto']: await import('../../../libs/common/src/types/dtos/wallet.login.config.response.dto'),
8+
['../../../libs/common/src/types/dtos/wallet.login.response.dto']: await import('../../../libs/common/src/types/dtos/wallet.login.response.dto'),
9+
['../../../libs/common/src/types/dtos/delegation.response.dto']: await import('../../../libs/common/src/types/dtos/delegation.response.dto'),
10+
['../../../libs/common/src/types/dtos/transaction.response.dto']: await import('../../../libs/common/src/types/dtos/transaction.response.dto'),
11+
['../../../libs/common/src/types/dtos/keys.response.dto']: await import('../../../libs/common/src/types/dtos/keys.response.dto'),
2612
};
2713
return {
2814
'@nestjs/swagger': {
@@ -109,10 +95,7 @@ export default async () => {
10995
MsaIdResponse: { msaId: { required: true, type: () => String } },
11096
},
11197
],
112-
[
113-
import('../../../libs/common/src/types/dtos/transaction.response.dto'),
114-
{ TransactionResponse: { referenceId: { required: true, type: () => String } } },
115-
],
98+
[import('../../../libs/common/src/types/dtos/transaction.response.dto'), { TransactionResponse: { referenceId: { required: true, type: () => String } } }],
11699
[
117100
import('../../../libs/common/src/types/dtos/wallet.login.response.dto'),
118101
{
@@ -143,19 +126,15 @@ export default async () => {
143126
},
144127
},
145128
],
146-
[
147-
import('../../../libs/common/src/types/dtos/keys.response.dto'),
148-
{ KeysResponse: { msaKeys: { required: true } } },
149-
],
129+
[import('../../../libs/common/src/types/dtos/keys.response.dto'), { KeysResponse: { msaKeys: { required: true } } }],
150130
],
151131
controllers: [
152132
[
153133
import('./controllers/v1/accounts-v1.controller'),
154134
{
155135
AccountsControllerV1: {
156136
getSIWFConfig: {
157-
type: t['../../../libs/common/src/types/dtos/wallet.login.config.response.dto']
158-
.WalletLoginConfigResponse,
137+
type: t['../../../libs/common/src/types/dtos/wallet.login.config.response.dto'].WalletLoginConfigResponse,
159138
},
160139
getAccountForMsa: {
161140
type: t['../../../libs/common/src/types/dtos/accounts.response.dto'].AccountResponse,

services/account/apps/api/src/services/delegation.service.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ export class DelegationService {
1919
if (isValidMsaId) {
2020
const { providerId } = this.configService;
2121

22-
const commonPrimitivesMsaDelegation = await this.blockchainService.getCommonPrimitivesMsaDelegation(
23-
msaId,
24-
providerId,
25-
);
22+
const commonPrimitivesMsaDelegation = await this.blockchainService.getCommonPrimitivesMsaDelegation(msaId, providerId);
2623

2724
if (commonPrimitivesMsaDelegation) {
2825
const delegationResponse: DelegationResponse = {

services/account/apps/api/test/accounts.controller.e2e-spec.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ describe('Account Controller', () => {
2929
try {
3030
await Promise.allSettled([
3131
...users.map((u) => ExtrinsicHelper.retireHandle(u.keypair).signAndSend()),
32-
ExtrinsicHelper.claimHandleWithProvider(
33-
users[0].keypair,
34-
provider.keypair,
35-
handlePayload.proof,
36-
handlePayload.payload,
37-
).payWithCapacity(),
32+
ExtrinsicHelper.claimHandleWithProvider(users[0].keypair, provider.keypair, handlePayload.proof, handlePayload.payload).payWithCapacity(),
3833
]);
3934
} catch (e) {
4035
// do nothing
@@ -80,10 +75,7 @@ describe('Account Controller', () => {
8075

8176
it('(GET) /v1/accounts/:msaId with invalid msaId', async () => {
8277
const invalidMsaId = BigInt(maxMsaId) + 1000n;
83-
await request(app.getHttpServer())
84-
.get(`/v1/accounts/${invalidMsaId.toString()}`)
85-
.expect(400)
86-
.expect({ statusCode: 400, message: 'Failed to find the account' });
78+
await request(app.getHttpServer()).get(`/v1/accounts/${invalidMsaId.toString()}`).expect(400).expect({ statusCode: 400, message: 'Failed to find the account' });
8779
});
8880

8981
it('(GET) /v1/accounts/:msaId with valid msaId and handle', async () => {

services/account/apps/api/test/app.e2e-spec.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ describe('Account Service E2E request verification!', () => {
2727
await app.init();
2828
});
2929

30-
it('(GET) /healthz', () =>
31-
request(app.getHttpServer()).get('/healthz').expect(200).expect({ status: 200, message: 'Service is healthy' }));
30+
it('(GET) /healthz', () => request(app.getHttpServer()).get('/healthz').expect(200).expect({ status: 200, message: 'Service is healthy' }));
3231

33-
it('(GET) /livez', () =>
34-
request(app.getHttpServer()).get('/livez').expect(200).expect({ status: 200, message: 'Service is live' }));
32+
it('(GET) /livez', () => request(app.getHttpServer()).get('/livez').expect(200).expect({ status: 200, message: 'Service is live' }));
3533

36-
it('(GET) /readyz', () =>
37-
request(app.getHttpServer()).get('/readyz').expect(200).expect({ status: 200, message: 'Service is ready' }));
34+
it('(GET) /readyz', () => request(app.getHttpServer()).get('/readyz').expect(200).expect({ status: 200, message: 'Service is ready' }));
3835

3936
describe('(POST) /accounts/siwf', () => {
4037
it('Sign Up With Frequency request should work', async () => {
@@ -66,8 +63,7 @@ describe('Account Service E2E request verification!', () => {
6663
siwsPayload: {
6764
message:
6865
'localhost wants you to sign in with your Frequency account:\n5Fghb4Wt3sg9cF6Q2Qucp5jXV5pL2U9uaYXwR9R8W8SYe9np\n\nThe domain localhost wants you to sign in with your Frequency account via localhost\n\nURI: http://localhost:5173/signin/confirm\nNonce: N6rLwqyz34oUxJEXJ\nIssued At: 2024-03-05T23:18:03.041Z\nExpiration Time: 2024-03-05T23:23:03.041Z',
69-
signature:
70-
'0x38faa2fc6f59bef8ffccfc929fb966e1d53ba45e3af7a029ea1d636eaddcbe78a4be0f89eaf7ff7bbaef20a070ad65f9d0f876889686687ef623214fddddb18b',
66+
signature: '0x38faa2fc6f59bef8ffccfc929fb966e1d53ba45e3af7a029ea1d636eaddcbe78a4be0f89eaf7ff7bbaef20a070ad65f9d0f876889686687ef623214fddddb18b',
7167
},
7268
},
7369
signUp: {

services/account/apps/api/test/e2e-setup.mock.spec.ts

+4-19
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,7 @@ export async function setupProviderAndUsers() {
4040
* Generate an array of extrinsics to remove all but the "primary" control key
4141
* from an MSA.
4242
*/
43-
export async function removeExtraKeysFromMsa({
44-
msaId,
45-
keypair,
46-
}: {
47-
msaId?: MessageSourceId | undefined;
48-
keypair: KeyringPair;
49-
}): Promise<void> {
43+
export async function removeExtraKeysFromMsa({ msaId, keypair }: { msaId?: MessageSourceId | undefined; keypair: KeyringPair }): Promise<void> {
5044
if (!msaId) {
5145
return;
5246
}
@@ -64,24 +58,15 @@ export async function removeExtraKeysFromMsa({
6458
}
6559

6660
export async function generateSignedAddKeyPayload(user: ChainUser, newKeys: KeyringPair, currentBlockNumber?: number) {
67-
const payload = await generateAddKeyPayload(
68-
{ msaId: user.msaId!, newPublicKey: newKeys.publicKey },
69-
undefined,
70-
currentBlockNumber,
71-
);
61+
const payload = await generateAddKeyPayload({ msaId: user.msaId!, newPublicKey: newKeys.publicKey }, undefined, currentBlockNumber);
7262
const addKeyData = ExtrinsicHelper.api.registry.createType('PalletMsaAddKeyData', payload);
7363
const ownerProof = signPayloadSr25519(user.keypair, addKeyData);
7464
const newKeyProof = signPayloadSr25519(newKeys, addKeyData);
7565

7666
return { payload, ownerProof, newKeyProof };
7767
}
7868

79-
export async function generateAddPublicKeyExtrinsic(
80-
user: ChainUser,
81-
newKeys: KeyringPair,
82-
currentBlockNumber?: number,
83-
) {
69+
export async function generateAddPublicKeyExtrinsic(user: ChainUser, newKeys: KeyringPair, currentBlockNumber?: number) {
8470
const { payload, ownerProof, newKeyProof } = await generateSignedAddKeyPayload(user, newKeys, currentBlockNumber);
85-
return () =>
86-
ExtrinsicHelper.apiPromise.tx.msa.addPublicKeyToMsa(user.keypair.publicKey, ownerProof, newKeyProof, payload);
71+
return () => ExtrinsicHelper.apiPromise.tx.msa.addPublicKeyToMsa(user.keypair.publicKey, ownerProof, newKeyProof, payload);
8772
}

services/account/apps/api/test/handles.controller.e2e-spec.ts

+5-23
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ describe('Handles Controller', () => {
1717
let users: ChainUser[];
1818
let provider: ChainUser;
1919
let currentBlockNumber: number;
20-
const handles = new Array(2)
21-
.fill(0)
22-
.map(() => uniqueNamesGenerator({ dictionaries: [colors, names], separator: '', length: 2, style: 'capital' }));
20+
const handles = new Array(2).fill(0).map(() => uniqueNamesGenerator({ dictionaries: [colors, names], separator: '', length: 2, style: 'capital' }));
2321
let maxMsaId: string;
2422

2523
beforeAll(async () => {
@@ -33,18 +31,8 @@ describe('Handles Controller', () => {
3331
try {
3432
await Promise.allSettled([
3533
...users.map((u) => ExtrinsicHelper.retireHandle(u.keypair).signAndSend()),
36-
ExtrinsicHelper.claimHandleWithProvider(
37-
users[0].keypair,
38-
provider.keypair,
39-
handlePayloads[0].proof,
40-
handlePayloads[0].payload,
41-
).payWithCapacity(),
42-
ExtrinsicHelper.claimHandleWithProvider(
43-
users[1].keypair,
44-
provider.keypair,
45-
handlePayloads[1].proof,
46-
handlePayloads[1].payload,
47-
).payWithCapacity(),
34+
ExtrinsicHelper.claimHandleWithProvider(users[0].keypair, provider.keypair, handlePayloads[0].proof, handlePayloads[0].payload).payWithCapacity(),
35+
ExtrinsicHelper.claimHandleWithProvider(users[1].keypair, provider.keypair, handlePayloads[1].proof, handlePayloads[1].payload).payWithCapacity(),
4836
]);
4937
} catch (e) {
5038
// do nothing
@@ -125,18 +113,12 @@ describe('Handles Controller', () => {
125113
// User users[3], known to have no handle
126114
const user = users[3];
127115
const msaIdWithNoHandle = user.msaId?.toString();
128-
await request(HTTP_SERVER)
129-
.get(`/v1/handles/${msaIdWithNoHandle}`)
130-
.expect(404)
131-
.expect({ statusCode: 404, message: 'No handle found for MSA' });
116+
await request(HTTP_SERVER).get(`/v1/handles/${msaIdWithNoHandle}`).expect(404).expect({ statusCode: 404, message: 'No handle found for MSA' });
132117
});
133118

134119
it('(GET) /handles/:msaId with invalid msaId', async () => {
135120
const invalidMsaId = BigInt(maxMsaId) + 1000n;
136-
await request(HTTP_SERVER)
137-
.get(`/v1/handles/${invalidMsaId.toString()}`)
138-
.expect(400)
139-
.expect({ statusCode: 400, message: 'Invalid msaId.' });
121+
await request(HTTP_SERVER).get(`/v1/handles/${invalidMsaId.toString()}`).expect(400).expect({ statusCode: 400, message: 'Invalid msaId.' });
140122
});
141123
});
142124
});

services/account/apps/api/test/keys.controller.e2e-spec.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ import { KeysRequest } from '#lib/types/dtos/keys.request.dto';
1010
import { AddKeyData, ChainUser, ExtrinsicHelper, createKeys } from '@projectlibertylabs/frequency-scenario-template';
1111
import { KeyringPair } from '@polkadot/keyring/types';
1212
import { ApiModule } from '../src/api.module';
13-
import {
14-
generateAddPublicKeyExtrinsic,
15-
removeExtraKeysFromMsa,
16-
generateSignedAddKeyPayload,
17-
setupProviderAndUsers,
18-
} from './e2e-setup.mock.spec';
13+
import { generateAddPublicKeyExtrinsic, removeExtraKeysFromMsa, generateSignedAddKeyPayload, setupProviderAndUsers } from './e2e-setup.mock.spec';
1914

2015
let HTTP_SERVER: any = process.env.HTTP_SERVER || 'http://0.0.0.0:3000';
2116

@@ -76,11 +71,7 @@ describe('Keys Controller', () => {
7671
// users[2] should have a single key, this will (eventually) add another
7772
const user = users[2];
7873
const newKeypair = createKeys();
79-
const { payload, ownerProof, newKeyProof } = await generateSignedAddKeyPayload(
80-
user,
81-
newKeypair,
82-
currentBlockNumber,
83-
);
74+
const { payload, ownerProof, newKeyProof } = await generateSignedAddKeyPayload(user, newKeypair, currentBlockNumber);
8475
const keysRequest: KeysRequest = {
8576
msaOwnerAddress: user.keypair.address,
8677
msaOwnerSignature: ownerProof.Sr25519,

services/account/apps/worker/src/transaction_notifier/notifier.service.helper.createWebhookRsp.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,10 @@ import {
1010
} from '#lib/types/dtos/transaction.request.dto';
1111
import { ITxStatus } from '#lib/interfaces/tx-status.interface';
1212

13-
export function createWebhookRsp(
14-
txStatus: ITxStatus,
15-
msaId: string,
16-
options: PublishHandleOpts,
17-
): PublishHandleWebhookRsp;
13+
export function createWebhookRsp(txStatus: ITxStatus, msaId: string, options: PublishHandleOpts): PublishHandleWebhookRsp;
1814
export function createWebhookRsp(txStatus: ITxStatus, msaId: string, options: SIWFOpts): SIWFWebhookRsp;
1915
export function createWebhookRsp(txStatus: ITxStatus, msaId: string, options: PublishKeysOpts): PublishKeysWebhookRsp;
20-
export function createWebhookRsp(
21-
{ type: transactionType, providerId, referenceId }: ITxStatus,
22-
msaId: string,
23-
options: TxWebhookOpts,
24-
): unknown {
16+
export function createWebhookRsp({ type: transactionType, providerId, referenceId }: ITxStatus, msaId: string, options: TxWebhookOpts): unknown {
2517
return {
2618
transactionType,
2719
providerId,

0 commit comments

Comments
 (0)