Skip to content

Commit 41dd53a

Browse files
committed
chore: fixed lint errors in blabsy
1 parent 5e52dfe commit 41dd53a

File tree

21 files changed

+158
-162
lines changed

21 files changed

+158
-162
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
},
1717
"[typescript]": {
18-
"editor.defaultFormatter": "biomejs.biome",
18+
"editor.defaultFormatter": "esbenp.prettier-vscode",
1919
"editor.codeActionsOnSave": {
2020
"source.organizeImports.biome": "explicit",
2121
"source.fixAll.biome": "explicit"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./mapping.db";
1+
export * from "./mapping.db";

infrastructure/web3-adapter/src/db/mapping.db.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class MappingDatabase {
4747
// Validate inputs
4848
if (!params.localId || !params.globalId) {
4949
throw new Error(
50-
"Invalid mapping parameters: all fields are required"
50+
"Invalid mapping parameters: all fields are required",
5151
);
5252
}
5353

@@ -64,7 +64,7 @@ export class MappingDatabase {
6464
await this.runAsync(
6565
`INSERT INTO id_mappings (local_id, global_id)
6666
VALUES (?, ?)`,
67-
[params.localId, params.globalId]
67+
[params.localId, params.globalId],
6868
);
6969

7070
const storedMapping = await this.getGlobalId(params.localId);
@@ -73,7 +73,7 @@ export class MappingDatabase {
7373
console.log(
7474
"storedMappingError",
7575
storedMapping,
76-
params.globalId
76+
params.globalId,
7777
);
7878
console.error("Failed to store mapping");
7979
return;
@@ -96,7 +96,7 @@ export class MappingDatabase {
9696
`SELECT global_id
9797
FROM id_mappings
9898
WHERE local_id = ?`,
99-
[localId]
99+
[localId],
100100
);
101101
return result?.global_id ?? null;
102102
} catch (error) {
@@ -118,7 +118,7 @@ export class MappingDatabase {
118118
`SELECT local_id
119119
FROM id_mappings
120120
WHERE global_id = ?`,
121-
[globalId]
121+
[globalId],
122122
);
123123
return result?.local_id ?? null;
124124
} catch (error) {
@@ -138,7 +138,7 @@ export class MappingDatabase {
138138
await this.runAsync(
139139
`DELETE FROM id_mappings
140140
WHERE local_id = ?`,
141-
[localId]
141+
[localId],
142142
);
143143
} catch (error) {
144144
throw error;
@@ -157,7 +157,7 @@ export class MappingDatabase {
157157
try {
158158
const results = await this.allAsync(
159159
`SELECT local_id, global_id
160-
FROM id_mappings`
160+
FROM id_mappings`,
161161
);
162162

163163
return results.map(({ local_id, global_id }) => ({

infrastructure/web3-adapter/src/evault/evault.ts

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,21 @@ export class EVaultClient {
122122
private httpClient: AxiosInstance;
123123
private isDisposed = false;
124124

125-
constructor(private registryUrl: string, private platform: string) {
125+
constructor(
126+
private registryUrl: string,
127+
private platform: string,
128+
) {
126129
// Configure axios with connection pooling and timeouts
127130
this.httpClient = axios.create({
128131
timeout: CONFIG.REQUEST_TIMEOUT,
129132
maxRedirects: 3,
130133
// Connection pooling configuration
131-
httpAgent: new (require('http').Agent)({
134+
httpAgent: new (require("http").Agent)({
132135
keepAlive: true,
133136
maxSockets: CONFIG.CONNECTION_POOL_SIZE,
134137
timeout: CONFIG.CONNECTION_TIMEOUT,
135138
}),
136-
httpsAgent: new (require('https').Agent)({
139+
httpsAgent: new (require("https").Agent)({
137140
keepAlive: true,
138141
maxSockets: CONFIG.CONNECTION_POOL_SIZE,
139142
timeout: CONFIG.CONNECTION_TIMEOUT,
@@ -146,12 +149,12 @@ export class EVaultClient {
146149
*/
147150
public dispose(): void {
148151
if (this.isDisposed) return;
149-
152+
150153
this.isDisposed = true;
151154
this.client = null;
152155
this.endpoint = null;
153156
this.tokenInfo = null;
154-
157+
155158
// Close HTTP agents to free connections
156159
if (this.httpClient.defaults.httpAgent) {
157160
this.httpClient.defaults.httpAgent.destroy();
@@ -166,36 +169,36 @@ export class EVaultClient {
166169
*/
167170
private async withRetry<T>(
168171
operation: () => Promise<T>,
169-
maxRetries: number = CONFIG.MAX_RETRIES
172+
maxRetries: number = CONFIG.MAX_RETRIES,
170173
): Promise<T> {
171174
let lastError: Error;
172-
175+
173176
for (let attempt = 0; attempt <= maxRetries; attempt++) {
174177
try {
175178
return await operation();
176179
} catch (error) {
177180
lastError = error as Error;
178-
181+
179182
// Don't retry on the last attempt
180183
if (attempt === maxRetries) break;
181-
184+
182185
// Don't retry on certain errors
183186
if (error instanceof Error) {
184187
const isRetryable = !(
185-
error.message.includes('401') ||
186-
error.message.includes('403') ||
187-
error.message.includes('404')
188+
error.message.includes("401") ||
189+
error.message.includes("403") ||
190+
error.message.includes("404")
188191
);
189-
192+
190193
if (!isRetryable) break;
191194
}
192-
195+
193196
// Exponential backoff
194197
const delay = CONFIG.RETRY_DELAY * Math.pow(2, attempt);
195-
await new Promise(resolve => setTimeout(resolve, delay));
198+
await new Promise((resolve) => setTimeout(resolve, delay));
196199
}
197200
}
198-
201+
199202
throw lastError!;
200203
}
201204

@@ -206,19 +209,22 @@ export class EVaultClient {
206209
private async requestPlatformToken(): Promise<TokenInfo> {
207210
try {
208211
const response = await this.httpClient.post<PlatformTokenResponse>(
209-
new URL("/platforms/certification", this.registryUrl).toString(),
212+
new URL(
213+
"/platforms/certification",
214+
this.registryUrl,
215+
).toString(),
210216
{ platform: this.platform },
211217
{
212218
headers: {
213219
"Content-Type": "application/json",
214220
},
215221
timeout: CONFIG.REQUEST_TIMEOUT,
216-
}
222+
},
217223
);
218-
224+
219225
const now = Date.now();
220-
const expiresAt = response.data.expiresAt || (now + 3600000); // Default 1 hour
221-
226+
const expiresAt = response.data.expiresAt || now + 3600000; // Default 1 hour
227+
222228
return {
223229
token: response.data.token,
224230
expiresAt,
@@ -235,10 +241,10 @@ export class EVaultClient {
235241
*/
236242
private isTokenExpired(): boolean {
237243
if (!this.tokenInfo) return true;
238-
244+
239245
const now = Date.now();
240246
const timeUntilExpiry = this.tokenInfo.expiresAt - now;
241-
247+
242248
return timeUntilExpiry <= CONFIG.TOKEN_REFRESH_THRESHOLD;
243249
}
244250

@@ -259,7 +265,7 @@ export class EVaultClient {
259265
new URL(`/resolve?w3id=${w3id}`, this.registryUrl).toString(),
260266
{
261267
timeout: CONFIG.REQUEST_TIMEOUT,
262-
}
268+
},
263269
);
264270
return new URL("/graphql", response.data.uri).toString();
265271
} catch (error) {
@@ -294,7 +300,7 @@ export class EVaultClient {
294300
return null;
295301
});
296302
if (!client) return v4();
297-
303+
298304
console.log("sending payload", envelope);
299305

300306
const response = await client
@@ -306,7 +312,7 @@ export class EVaultClient {
306312
},
307313
})
308314
.catch(() => null);
309-
315+
310316
if (!response) return v4();
311317
return response.storeMetaEnvelope.metaEnvelope.id;
312318
});
@@ -327,7 +333,7 @@ export class EVaultClient {
327333
},
328334
})
329335
.catch(() => null);
330-
336+
331337
if (!response) {
332338
console.error("Failed to store reference");
333339
throw new Error("Failed to store reference");
@@ -345,7 +351,7 @@ export class EVaultClient {
345351
{
346352
id,
347353
w3id,
348-
}
354+
},
349355
);
350356
return response.metaEnvelope;
351357
} catch (error) {
@@ -357,12 +363,15 @@ export class EVaultClient {
357363

358364
async updateMetaEnvelopeById(
359365
id: string,
360-
envelope: MetaEnvelope
366+
envelope: MetaEnvelope,
361367
): Promise<void> {
362368
return this.withRetry(async () => {
363369
console.log("sending to eVault", envelope.w3id);
364-
const client = await this.ensureClient(envelope.w3id).catch(() => null);
365-
if (!client) throw new Error("Failed to establish client connection");
370+
const client = await this.ensureClient(envelope.w3id).catch(
371+
() => null,
372+
);
373+
if (!client)
374+
throw new Error("Failed to establish client connection");
366375

367376
try {
368377
const variables = {
@@ -374,10 +383,11 @@ export class EVaultClient {
374383
},
375384
};
376385

377-
const response = await client.request<StoreMetaEnvelopeResponse>(
378-
UPDATE_META_ENVELOPE,
379-
variables
380-
);
386+
const response =
387+
await client.request<StoreMetaEnvelopeResponse>(
388+
UPDATE_META_ENVELOPE,
389+
variables,
390+
);
381391
} catch (error) {
382392
console.error("Error updating meta envelope:", error);
383393
throw error;

infrastructure/web3-adapter/src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ export class Web3Adapter {
1919
dbPath: string;
2020
registryUrl: string;
2121
platform: string;
22-
}
22+
},
2323
) {
2424
this.readPaths();
2525
this.mappingDb = new MappingDatabase(config.dbPath);
2626
this.evaultClient = new EVaultClient(
2727
config.registryUrl,
28-
config.platform
28+
config.platform,
2929
);
3030
this.platform = config.platform;
3131
}
3232

3333
async readPaths() {
3434
const allRawFiles = await fs.readdir(this.config.schemasPath);
3535
const mappingFiles = allRawFiles.filter((p: string) =>
36-
p.endsWith(".json")
36+
p.endsWith(".json"),
3737
);
3838

3939
for (const mappingFile of mappingFiles) {
4040
const mappingFileContent = await fs.readFile(
41-
path.join(this.config.schemasPath, mappingFile)
41+
path.join(this.config.schemasPath, mappingFile),
4242
);
4343
const mappingParsed = JSON.parse(
44-
mappingFileContent.toString()
44+
mappingFileContent.toString(),
4545
) as IMapping;
4646
this.mapping[mappingParsed.tableName] = mappingParsed;
4747
}
@@ -63,7 +63,7 @@ export class Web3Adapter {
6363
const { data, tableName, participants } = props;
6464

6565
const existingGlobalId = await this.mappingDb.getGlobalId(
66-
data.id as string
66+
data.id as string,
6767
);
6868

6969
console.log(this.mapping, tableName, this.mapping[tableName]);
@@ -122,12 +122,12 @@ export class Web3Adapter {
122122

123123
// Handle references for other participants
124124
const otherEvaults = (participants ?? []).filter(
125-
(i: string) => i !== global.ownerEvault
125+
(i: string) => i !== global.ownerEvault,
126126
);
127127
for (const evault of otherEvaults) {
128128
await this.evaultClient.storeReference(
129129
`${global.ownerEvault}/${globalId}`,
130-
evault
130+
evault,
131131
);
132132
}
133133

0 commit comments

Comments
 (0)