Skip to content

Commit

Permalink
fix: lint and add linter to CI
Browse files Browse the repository at this point in the history
Somehow linter never got added to CI here so we've gone off the rails
  • Loading branch information
marktoda committed Feb 9, 2024
1 parent 7b420e0 commit 6e98723
Show file tree
Hide file tree
Showing 19 changed files with 422 additions and 301 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint

on:
push:
branches:
- main
pull_request:

jobs:
run-linters:
name: lint
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: https://registry.npmjs.org

- name: Install dependencies
run: |
npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_AUTH_TOKEN }}" \
&& yarn install --frozen-lockfile
- name: Run linters
run: yarn lint
4 changes: 2 additions & 2 deletions lib/entities/QuoteRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ export class QuoteRequest {
...(this.quoteId && { quoteId: this.quoteId }),
};
}

public toOpposingRequest(): QuoteRequest {
const opposingJSON = this.toOpposingCleanJSON();
return new QuoteRequest({
...opposingJSON,
amount: BigNumber.from(opposingJSON.amount),
type: TradeType[opposingJSON.type as keyof typeof TradeType],
});
}
}

public get requestId(): string {
return this.data.requestId;
Expand Down
7 changes: 4 additions & 3 deletions lib/entities/analytics-events.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { v4 as uuidv4 } from 'uuid';

import { timestampInMstoISOString } from '../util/time';

export enum AnalyticsEventType {
WEBHOOK_RESPONSE = 'WebhookQuoterResponse',
};
}

export enum WebhookResponseType {
OK = 'OK',
Expand All @@ -13,7 +14,7 @@ export enum WebhookResponseType {
TIMEOUT = 'TIMEOUT',
HTTP_ERROR = 'HTTP_ERROR',
OTHER_ERROR = 'OTHER_ERROR',
};
}

export class AnalyticsEvent {
eventId: string; // gets set in constructor
Expand All @@ -27,4 +28,4 @@ export class AnalyticsEvent {
this.eventTime = timestampInMstoISOString(Date.now());
this.eventProperties = eventProperties;
}
};
}
2 changes: 1 addition & 1 deletion lib/entities/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './analytics-events';
export * from './aws-metrics-logger';
export * from './QuoteRequest';
export * from './QuoteResponse';
export * from './analytics-events';
2 changes: 1 addition & 1 deletion lib/handlers/quote/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
FADE_RATE_BUCKET,
FADE_RATE_S3_KEY,
INTEGRATION_S3_KEY,
PRODUCTION_S3_KEY,
PROD_COMPLIANCE_S3_KEY,
PRODUCTION_S3_KEY,
WEBHOOK_CONFIG_BUCKET,
} from '../../constants';
import {
Expand Down
2 changes: 1 addition & 1 deletion lib/providers/analytics/firehose.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FirehoseClient, PutRecordCommand } from '@aws-sdk/client-firehose';
import { default as Logger } from 'bunyan';

import { IAnalyticsLogger } from '.';
import { AnalyticsEvent } from '../../entities/analytics-events';
import { IAnalyticsLogger } from '.';

export class FirehoseLogger implements IAnalyticsLogger {
private log: Logger;
Expand Down
2 changes: 1 addition & 1 deletion lib/providers/compliance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface FillerComplianceConfiguration {

export interface FillerComplianceConfigurationProvider {
getConfigs(): Promise<FillerComplianceConfiguration[]>;
// getExcludedAddrToEndpointsMap(): Promise<Map<string, Set<string>>>;
// getExcludedAddrToEndpointsMap(): Promise<Map<string, Set<string>>>;
getEndpointToExcludedAddrsMap(): Promise<Map<string, Set<string>>>;
}

Expand Down
7 changes: 3 additions & 4 deletions lib/providers/compliance/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class MockFillerComplianceConfigurationProvider implements FillerComplian
async getConfigs(): Promise<FillerComplianceConfiguration[]> {
return this.configs;
}

async getEndpointToExcludedAddrsMap(): Promise<Map<string, Set<string>>> {
const map = new Map<string, Set<string>>();
this.configs.forEach((config) => {
Expand All @@ -18,8 +18,7 @@ export class MockFillerComplianceConfigurationProvider implements FillerComplian
map.get(endpoint)?.add(address);
});
});
})
});
return map;
}

}
}
10 changes: 3 additions & 7 deletions lib/providers/compliance/s3.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
import { default as Logger } from 'bunyan';

import { checkDefined } from '../../preconditions/preconditions';
import { FillerComplianceConfiguration, FillerComplianceConfigurationProvider } from '.';


export class S3FillerComplianceConfigurationProvider implements FillerComplianceConfigurationProvider {
private log: Logger;
private configs: FillerComplianceConfiguration[];
Expand All @@ -32,14 +30,12 @@ export class S3FillerComplianceConfigurationProvider implements FillerCompliance
this.endpointToExcludedAddrsMap.get(endpoint)?.add(address);
});
});
})
});
return this.endpointToExcludedAddrsMap;
}

async getConfigs(): Promise<FillerComplianceConfiguration[]> {
if (
this.configs.length === 0
) {
if (this.configs.length === 0) {
await this.fetchConfigs();
}
return this.configs;
Expand All @@ -57,4 +53,4 @@ export class S3FillerComplianceConfigurationProvider implements FillerCompliance
this.configs = JSON.parse(await s3Body.transformToString()) as FillerComplianceConfiguration[];
this.log.info({ configsLength: this.configs.map((c) => c.addresses.length) }, `Fetched configs`);
}
}
}
2 changes: 1 addition & 1 deletion lib/quoters/MockQuoter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Logger from 'bunyan';
import { BigNumber } from 'ethers';

import { Quoter, QuoterType } from '.';
import { QuoteRequest, QuoteResponse } from '../entities';
import { Quoter, QuoterType } from '.';

export const MOCK_FILLER_ADDRESS = '0x0000000000000000000000000000000000000001';

Expand Down
2 changes: 1 addition & 1 deletion test/entities/QuoteRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('QuoteRequest', () => {
numOutputs: 1,
});
});

it('toOpposingRequest', async () => {
const opposingRequest = request.toOpposingRequest();
expect(opposingRequest.toCleanJSON()).toEqual({
Expand Down
Loading

0 comments on commit 6e98723

Please sign in to comment.