Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/update eslint config in package json #188

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@pancakeswap-libs/eslint-config-pancake",
"extends": "@pancakeswap/eslint-config-pancake",
"rules": {
"import/no-extraneous-dependencies": [
"error",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@babel/preset-env": "^7.14.4",
"@commitlint/cli": "^12.1.1",
"@commitlint/config-conventional": "^12.1.1",
"@pancakeswap-libs/eslint-config-pancake": "0.1.0",
"@pancakeswap/eslint-config-pancake": "1.2.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-typescript": "^8.2.1",
"@rollup/plugin-url": "^6.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-pancake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Pancake Eslint config with:
## Usage

```
npx install-peerdeps --dev @pancakeswap-libs/eslint-config-pancake
npx install-peerdeps --dev @pancakeswap/eslint-config-pancake
```

Add `"extends": "@pancakeswap-libs/eslint-config-pancake"` to your eslint config file.
Add `"extends": "@pancakeswap/eslint-config-pancake"` to your eslint config file.
2 changes: 1 addition & 1 deletion packages/token-lists/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"checksum:pcs-top-15": "yarn build && node ./dist checksum pancakeswap-top-15",
"generate:pcs-top-15": "yarn test && yarn build && node ./dist generate pancakeswap-top-15",
"makelist:pcs-top-15": "yarn checksum:pcs-top-15 && yarn generate:pcs-top-15",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
"fetch:pcs-top-100": "yarn build && node ./dist fetch",
"test": "jest",
"ci-check": "yarn build && node ./dist ci-check"
Expand All @@ -33,7 +34,6 @@
"devDependencies": {
"@babel/preset-env": "^7.14.1",
"@babel/preset-typescript": "^7.13.0",
"@pancakeswap-libs/eslint-config-pancake": "^1.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-typescript": "^8.2.1",
"@types/jest": "^26.0.23",
Expand Down
51 changes: 28 additions & 23 deletions packages/token-lists/src/top-100.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getAddress } from "@ethersproject/address";

// Interface for Bitquery GraphQL response.
interface BitqueryEntity {
// eslint-disable-next-line camelcase
Total_USD: number;
baseCurrency: {
address: string;
Expand All @@ -28,7 +29,7 @@ const blacklist: string[] = [

/**
* Return today / 1 month ago ISO-8601 DateTime.
*
*
* @returns string[]
*/
const getDateRange = (): string[] => {
Expand All @@ -43,10 +44,10 @@ const getDateRange = (): string[] => {
/**
* Fetch Top100 Tokens traded on PancakeSwap v2, ordered by trading volume,
* for the past 30 days, filtered to remove default / broken tokens.
*
*
* @returns BitqueryEntity[]]
*/
const getTokens = async () => {
const getTokens = async (): Promise<BitqueryEntity[]> => {
try {
const [today, monthAgo] = getDateRange();

Expand Down Expand Up @@ -75,41 +76,45 @@ const getTokens = async () => {
{
from: monthAgo,
till: today,
blacklist: blacklist,
blacklist,
}
);

return ethereum.dexTrades;
} catch (error) {
console.error(`Error when fetching Top100 Tokens by volume for the past 30 days, error: ${error.message}`);
return error;
}
};

/**
* Main function.
* Fetch tokems, build list, save list.
*/
const main = async () => {
const tokens = await getTokens();
const main = async (): Promise<void> => {
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big diff here is just wrapping it all in try-catch (done to get rid of consistent-return error within getTokens())

const tokens = await getTokens();

const sanitizedTokens = tokens.reduce((list, item: BitqueryEntity) => {
const checksummedAddress = getAddress(item.baseCurrency.address);
const sanitizedTokens = tokens.reduce((list, item: BitqueryEntity) => {
const checksummedAddress = getAddress(item.baseCurrency.address);

const updatedToken = {
name: item.baseCurrency.name,
symbol: item.baseCurrency.symbol.toUpperCase(),
address: checksummedAddress,
chainId: 56,
decimals: item.baseCurrency.decimals,
logoURI: `https://assets.trustwalletapp.com/blockchains/smartchain/assets/${checksummedAddress}/logo.png`,
};
return [...list, updatedToken];
}, []);
const updatedToken = {
name: item.baseCurrency.name,
symbol: item.baseCurrency.symbol.toUpperCase(),
address: checksummedAddress,
chainId: 56,
decimals: item.baseCurrency.decimals,
logoURI: `https://assets.trustwalletapp.com/blockchains/smartchain/assets/${checksummedAddress}/logo.png`,
};
return [...list, updatedToken];
}, []);

const tokenListPath = `${path.resolve()}/src/tokens/pancakeswap-top-100.json`;
console.info("Saving updated list to ", tokenListPath);
const stringifiedList = JSON.stringify(sanitizedTokens, null, 2);
fs.writeFileSync(tokenListPath, stringifiedList);
const tokenListPath = `${path.resolve()}/src/tokens/pancakeswap-top-100.json`;
console.info("Saving updated list to ", tokenListPath);
const stringifiedList = JSON.stringify(sanitizedTokens, null, 2);
fs.writeFileSync(tokenListPath, stringifiedList);
} catch (error) {
console.error(`Error when fetching Top100 Tokens by volume for the past 30 days, error: ${error.message}`);
}
};

export default main;
Loading