Skip to content

Commit

Permalink
chore: run sort script and add to pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewlilley committed Dec 30, 2022
1 parent ae897ec commit e4af9ed
Show file tree
Hide file tree
Showing 2,064 changed files with 52,958 additions and 74,840 deletions.
35 changes: 31 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
dist
# Changeset
.changeset

# GitHub
.github

# Visual Studio Code
.vscode

# Vercel output
.vercel

# Next.js output
.next

# Compiled output
dist

# Generated
.mesh
.graphclient
node_modules
generated
typechain
coverage
exports
deployments
artifacts

# workers
**/public/sw.js
Expand All @@ -15,8 +32,18 @@ exports
**/public/workbox-*.js.map
**/public/worker-*.js.map

# Node modules
node_modules

# Solidity compilers
soljson-v0.6.12+commit.27d51765.js
soljson-v0.8.10+commit.fc410830.js
soljson-v0.8.11+commit.d7f03943.js

# Storybook
storybook-static

# Playwright
playwright-report

.eslintrc.js
1 change: 0 additions & 1 deletion .eslintrc.cjs

This file was deleted.

4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['@sushiswap/eslint-config'],
}
3 changes: 2 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm check
pnpm sort
pnpm run check
# npm test
6 changes: 3 additions & 3 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check
/** @type {import('mocha').MochaOptions} */
const mochaConfig = {
require: ["ts-node/register/files"],
require: ['ts-node/register/files'],
timeout: 20000,
};
}

module.exports = mochaConfig;
module.exports = mochaConfig
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# Visual Studio Code
.vscode

# Vercel output
.vercel

# Next.js output
.next

Expand All @@ -18,6 +21,8 @@ dist
.graphclient
generated
typechain
deployments
artifacts

# Node modules
node_modules
Expand Down
3 changes: 0 additions & 3 deletions .prettierrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@sushiswap/prettier-config').default
2 changes: 1 addition & 1 deletion apis/farm/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require("@sushiswap/eslint-config");
module.exports = require('@sushiswap/eslint-config')
32 changes: 16 additions & 16 deletions apis/farm/api/v0/index.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
import type { VercelRequest, VercelResponse } from "@vercel/node";
import { getUnixTime } from "date-fns";
import type { VercelRequest, VercelResponse } from '@vercel/node'
import { getUnixTime } from 'date-fns'

import redis from "../../lib/redis";
import redis from '../../lib/redis'

export default async (request: VercelRequest, response: VercelResponse) => {
const chainId = request.query.chainId as string;
const chainId = request.query.chainId as string

if (chainId) {
const data = await redis.hget("farms", chainId);
const data = await redis.hget('farms', chainId)

if (!data) {
return response.status(503);
return response.status(503)
}

const json = JSON.parse(data);
const json = JSON.parse(data)

const now = getUnixTime(Date.now());
const now = getUnixTime(Date.now())

return response.status(200).json({
...json,
updatedSecondsAgo: now - json.updatedAtTimestamp,
});
})
}

const data = await redis.hgetall("farms");
const data = await redis.hgetall('farms')

if (!data) {
return response.status(503);
return response.status(503)
}

const now = getUnixTime(Date.now());
const now = getUnixTime(Date.now())

return response.status(200).json(
Object.fromEntries(
Object.entries(data).map(([chainId, data]) => {
const json = JSON.parse(data);
const json = JSON.parse(data)
return [
chainId,
{
...json,
updatedSecondsAgo: now - json.updatedAtTimestamp,
},
];
]
})
)
);
};
)
}
101 changes: 49 additions & 52 deletions apis/farm/api/v1/index.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,70 @@
import type { VercelRequest, VercelResponse } from "@vercel/node";
import type { VercelRequest, VercelResponse } from '@vercel/node'

import redis from "../../lib/redis";
import redis from '../../lib/redis'

interface ChainIdFarmMap {
[key: string]: {
chainId: number;
farms: FarmsMap;
};
chainId: number
farms: FarmsMap
}
}

interface FarmsMap {
[poolAddress: string]: Farm;
[poolAddress: string]: Farm
}

interface Farm {
id: string;
chainId: number;
pool: string;
id: string
chainId: number
pool: string
incentives: {
apr: number;
rewardPerDay: number;
apr: number
rewardPerDay: number
rewardToken: {
address: string;
decimals: number;
symbol: string;
};
address: string
decimals: number
symbol: string
}
rewarder: {
address: string;
type: "Primary" | "Secondary";
};
}[];
chefType: "MasterChefV1" | "MasterChefV2" | "MiniChef";
poolType: "Legacy" | "Trident" | "Kashi" | "Unknown";
address: string
type: 'Primary' | 'Secondary'
}
}[]
chefType: 'MasterChefV1' | 'MasterChefV2' | 'MiniChef'
poolType: 'Legacy' | 'Trident' | 'Kashi' | 'Unknown'
}

export default async (request: VercelRequest, response: VercelResponse) => {
const data = await redis.hgetall("farms");
const data = await redis.hgetall('farms')

if (!data) {
return response.status(503);
return response.status(503)
}

return response.status(200).json(
Object.entries(data).reduce(
(previousValue: Farm[], [key, value]: [string, string]) => {
const {
chainId,
farms,
}: {
chainId: number;
farms: FarmsMap;
} = JSON.parse(value);
return [
...previousValue,
...Object.entries(farms).reduce<Farm[]>(
(previousValue, [key, value]) => [
...previousValue,
{
...value,
id: `${chainId}:${key}`,
chainId,
pool: key,
},
],
[]
),
];
},
[]
)
);
};
Object.entries(data).reduce((previousValue: Farm[], [key, value]: [string, string]) => {
const {
chainId,
farms,
}: {
chainId: number
farms: FarmsMap
} = JSON.parse(value)
return [
...previousValue,
...Object.entries(farms).reduce<Farm[]>(
(previousValue, [key, value]) => [
...previousValue,
{
...value,
id: `${chainId}:${key}`,
chainId,
pool: key,
},
],
[]
),
]
}, [])
)
}
8 changes: 4 additions & 4 deletions apis/farm/lib/redis.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Redis from "ioredis";
import Redis from 'ioredis'

if (!process.env.REDIS_URL) throw new Error("REDIS_URL is required");
if (!process.env.REDIS_URL) throw new Error('REDIS_URL is required')

const redis = new Redis(process.env.REDIS_URL);
const redis = new Redis(process.env.REDIS_URL)

export default redis;
export default redis
2 changes: 1 addition & 1 deletion apis/route-processor/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require("@sushiswap/eslint-config");
module.exports = require('@sushiswap/eslint-config')
14 changes: 7 additions & 7 deletions apis/route-processor/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { VercelRequest, VercelResponse } from "@vercel/node";
import { z } from "zod";
import type { VercelRequest, VercelResponse } from '@vercel/node'
import { z } from 'zod'

const schema = z.object({
srcChainId: z.coerce
Expand All @@ -12,10 +12,10 @@ const schema = z.object({
.int()
.gte(0)
.lte(2 ** 256),
});
})

const handler = (request: VercelRequest, response: VercelResponse) => {
const { srcChainId, dstChainId } = schema.parse(request.query);
const { srcChainId, dstChainId } = schema.parse(request.query)

// const amount = request.query.amount

Expand All @@ -27,7 +27,7 @@ const handler = (request: VercelRequest, response: VercelResponse) => {
// const dstChainId = request.query.dstChainId
// const dstToken = request.query.dstToken

return response.status(200).json({ srcChainId, dstChainId });
};
return response.status(200).json({ srcChainId, dstChainId })
}

export default handler;
export default handler
2 changes: 1 addition & 1 deletion apis/tines/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require("@sushiswap/eslint-config");
module.exports = require('@sushiswap/eslint-config')
14 changes: 7 additions & 7 deletions apis/tines/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { VercelRequest, VercelResponse } from "@vercel/node";
import { z } from "zod";
import type { VercelRequest, VercelResponse } from '@vercel/node'
import { z } from 'zod'

const schema = z.object({
srcChainId: z.coerce
Expand All @@ -12,10 +12,10 @@ const schema = z.object({
.int()
.gte(0)
.lte(2 ** 256),
});
})

const handler = (request: VercelRequest, response: VercelResponse) => {
const { srcChainId, dstChainId } = schema.parse(request.query);
const { srcChainId, dstChainId } = schema.parse(request.query)

// const amount = request.query.amount

Expand All @@ -27,7 +27,7 @@ const handler = (request: VercelRequest, response: VercelResponse) => {
// const dstChainId = request.query.dstChainId
// const dstToken = request.query.dstToken

return response.status(200).json({ srcChainId, dstChainId });
};
return response.status(200).json({ srcChainId, dstChainId })
}

export default handler;
export default handler
2 changes: 1 addition & 1 deletion apis/token-list/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require("@sushiswap/eslint-config");
module.exports = require('@sushiswap/eslint-config')
8 changes: 4 additions & 4 deletions apis/token-list/api/chainlink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import CHAINLINK_TOKEN_LIST from "@sushiswap/chainlink-token-list";
import type { VercelRequest, VercelResponse } from "@vercel/node";
import CHAINLINK_TOKEN_LIST from '@sushiswap/chainlink-token-list'
import type { VercelRequest, VercelResponse } from '@vercel/node'

export default (request: VercelRequest, response: VercelResponse) => {
return response.status(200).json(CHAINLINK_TOKEN_LIST);
};
return response.status(200).json(CHAINLINK_TOKEN_LIST)
}
Loading

0 comments on commit e4af9ed

Please sign in to comment.