Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
9yoi authored Feb 19, 2024
2 parents cd412c7 + 0499733 commit dc55a4d
Show file tree
Hide file tree
Showing 18 changed files with 4,702 additions and 656 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/clear-stale-PRs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: clear-stale-PRs

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *" # UTC Midnight everyday

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Close Stale Issues
uses: actions/[email protected]
with:
repo-token: ${{ secrets.PAT }}
# ====== for pr
exempt-pr-labels: pinned,security,good-first-issue,in-progress

ascending: true # gets in ascending order
stale-issue-label: "stale"
days-before-pr-stale: 21
stale-pr-message: |
This pull request has been automatically marked as stale because it
has not had recent activity. It will be closed if no further activity
occurs - please feel free to re-open when your project has more traction.
days-before-pr-close: 7
close-pr-message: |
This pull request has not seen any activity since it was marked stale.
Closing.
operations-per-run: 250
debug-only: false # true for dry run, false to actually perform the operations
6 changes: 2 additions & 4 deletions .github/workflows/validate-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ jobs:

## for local act testing
# - run: npm install -g yarn

- run: yarn install

- name: Validate PR
run: yarn validate-PR


run: yarn validate-PR >> $GITHUB_STEP_SUMMARY
16 changes: 16 additions & 0 deletions PR-KPOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Validate [{KPOP}](https://solscan.io/token/{DcUoGUeNTLhhzyrcz49LE7z3MEFwca2N9uSw1xbVi1gm})

## Attestations (Please provide links):
- Tweet from Twitter Account attesting the Mint address, tagging [@JupiterExchange](https://twitter.com/JupiterExchange) and showing community support: (https://x.com/kpopsolana/status/1738601649499693512?s=20)
- Coingecko/ CMC URL (If available): [https://www.coingecko.com/en/coins/{id}](https://www.coingecko.com/en/coins/k-pop-on-solana)

## Validation (Please check off boxes):
- [X] The metadata provided in the PR matches what is on-chain (Mandatory)
- [X] Does not duplicate the symbol of another token on Jupiter's strict list (If not, review will be delayed)
- [X] Is Listed on Coingecko / CMC (Optional, but helpful for reviewers)

## Acknowledgement (Please check off boxes)
- [X] My change matches the format in the file (no spaces between fields).
- [X] My token is already live and trading on Jupiter.
- [X] !!! I read the README section on Community-Driven Validation and understand this PR will be only be reviewed when there is community support on Twitter.
- [X] Please make sure your pull request title has your token name. If it just says "Main", or "Validate", it will automatically be closed. PRs containing broken attestation or solscan links will also be closed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This could include:
- Attestation from known developers on your validation PR: [Example1](https://github.com/jup-ag/token-list/pull/165), [Example2](https://github.com/jup-ag/token-list/pull/76)
- Support from your community in Jupiter's [#community-validation discord channel](https://discord.gg/jup)

Reminder: Tokens that meet minimum liquidity criteria will always be available for trading on the 'All' list even without immediate validation.
Reminder: Tokens that meet [minimum liquidity criteria](https://station.jup.ag/docs/get-your-token-onto-jup) will always be available for trading on the 'All' list even without immediate validation.

## Projects -- Open a PR to Request Validation:
- Open a PR like this [sample PR](https://github.com/jup-ag/token-list/pull/76) with your addition in the validated-tokens file.
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"@solana/web3.js": "^1.73.2",
"@types/minimist": "^1.2.5",
"csv-writer": "^1.6.0",
"minimist": "^1.2.8",
"node-downloader-helper": "^2.1.6",
"node-fetch": "^2.6.6"
},
Expand Down
16 changes: 0 additions & 16 deletions pull_request_template.md

This file was deleted.

13 changes: 13 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { validateValidatedTokensCsv } from "./logic";
import minimist from "minimist";
// CLI entrypoint which accepts an argument
(async () => {
try {
const argv = minimist(process.argv.slice(2));
const returnCode = await validateValidatedTokensCsv(argv._[0]);
process.exit(returnCode);
}
catch (error: any) {
console.log(error.message)
}
})();
95 changes: 95 additions & 0 deletions src/logic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import * as core from "@actions/core";
import { exec } from "@actions/exec";
import { detectDuplicateSymbol, detectDuplicateMints, canOnlyAddOneToken, validMintAddress, noEditsToPreviousLinesAllowed, isCommunityValidated, isSymbolConfusing } from "./utils/validate";
import { ValidatedTokensData } from "./types/types";
import { indexToLineNumber } from "./utils/validate";
import { parse } from "csv-parse/sync";
import fs from "fs";
import { allowedDuplicateSymbols, allowedNotCommunityValidated } from "./utils/duplicate-symbols";

export async function validateValidatedTokensCsv(filename: string): Promise<number> {
const [records, recordsRaw] = parseCsv(filename);

const recordsPreviousRaw = await gitPreviousVersion("validated-tokens.csv");
fs.writeFileSync(".validated-tokens-0.csv", recordsPreviousRaw);
const [recordsPrevious, _] = parseCsv(".validated-tokens-0.csv")

let duplicateSymbols;
let duplicateMints;
let attemptsToAddMultipleTokens;
let invalidMintAddresses;
let notCommunityValidated;
let noEditsAllowed;
let potentiallyConfusingSymbols;

duplicateSymbols = detectDuplicateSymbol(recordsPrevious, records);
duplicateMints = detectDuplicateMints(records);
attemptsToAddMultipleTokens = canOnlyAddOneToken(recordsPrevious, records)
invalidMintAddresses = validMintAddress(records);
noEditsAllowed = noEditsToPreviousLinesAllowed(recordsPrevious, records);
notCommunityValidated = isCommunityValidated(records);
potentiallyConfusingSymbols = isSymbolConfusing(recordsPrevious, records);

console.log("No More Duplicate Symbols:", duplicateSymbols, `(${allowedDuplicateSymbols.length} exceptions)`);
console.log("Duplicate Mints:", duplicateMints);
console.log("Attempts to Add Multiple Tokens:", attemptsToAddMultipleTokens);
console.log("Invalid Mint Addresses:", invalidMintAddresses);
console.log("Not Community Validated:", notCommunityValidated, `(${allowedNotCommunityValidated.length} exceptions)`);
console.log("Edits to Existing Tokens:", noEditsAllowed);
console.log("Issues with Symbols in Added Tokens:", potentiallyConfusingSymbols);
return (duplicateSymbols + duplicateMints + attemptsToAddMultipleTokens + invalidMintAddresses + noEditsAllowed)
}

// Get previous version of validated-tokens.csv from last commit
async function gitPreviousVersion(path: string): Promise<any> {
let prevVersion = "";
let gitCmdError = "";

try {
await exec("git", ["show", `origin/main:${path}`], {
listeners: {
stdout: (data: Buffer) => {
prevVersion += data.toString();
},
stderr: (data: Buffer) => {
gitCmdError += data.toString();
},
},
silent: true
});
} catch (error: any) {
core.setFailed(error.message);
}

if (gitCmdError) {
core.setFailed(gitCmdError);
}
return prevVersion;
}

function parseCsv(filename: string): [ValidatedTokensData[], string] {
const recordsRaw = fs.readFileSync(filename, "utf8")
const r = parse(recordsRaw, {
columns: true,
skip_empty_lines: true,
});
const records = csvToRecords(r);
return [records, recordsRaw];
}

function csvToRecords(r: any): ValidatedTokensData[] {
const records: ValidatedTokensData[] = [];
r.forEach((record: any, i: number) => {
const rec: ValidatedTokensData = {
Name: record.Name,
Symbol: record.Symbol,
Mint: record.Mint,
Decimals: record.Decimals,
LogoURI: record.LogoURI,
"Community Validated": JSON.parse(record["Community Validated"]),
Line: indexToLineNumber(i)
};
records.push(rec);
});
return records;
}
78 changes: 8 additions & 70 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,13 @@
import * as core from "@actions/core";
import { exec } from "@actions/exec";
import { parseGitPatch } from "./utils/parse";
import { validateGitPatch } from "./utils/validate";
import { getValidated } from "./utils/get-jup-strict";
import { ValidatedSet, ValidationError } from "./types/types";
import { parse } from "csv-parse/sync";
import fs from "fs";
import assert from "assert";

function validateValidatedTokensCsv() {
const records = parse(fs.readFileSync("validated-tokens.csv", "utf8"), {
columns: true,
skip_empty_lines: true,
});
assert.deepStrictEqual(Object.keys(records[0]), [
"Name",
"Symbol",
"Mint",
"Decimals",
"LogoURI",
"Community Validated",
]);
}

// Validates diff between validated-tokens.csv in the branch vs origin/main
async function getDiffAndValidate(): Promise<void> {
let gitDiff = "";
let gitDiffError = "";

import { validateValidatedTokensCsv } from "./logic";
// Github Actions entrypoint
(async () => {
try {
await exec("git", ["diff", "origin/main", "validated-tokens.csv"], {
listeners: {
stdout: (data: Buffer) => {
gitDiff += data.toString();
},
stderr: (data: Buffer) => {
gitDiffError += data.toString();
},
},
});
} catch (error: any) {
core.setFailed(error.message);
}

if (gitDiffError) {
core.setFailed(gitDiffError);
const returnCode = await validateValidatedTokensCsv("validated-tokens.csv");
process.exit(returnCode);
}

// core.debug(`Git diff: ${gitDiff}`)

// Get Jup tokens that are in the strict list to check for duplicates.
let validatedSet: ValidatedSet;
try {
validatedSet = await getValidated();

const errors: ValidationError[][] = [];

parseGitPatch(gitDiff).forEach((patch) => {
const patchErrors = validateGitPatch(patch, validatedSet);
if (patchErrors && patchErrors.length > 0) {
errors.push(patchErrors);
}
});

if (errors.length > 0) {
core.setFailed(errors.join(","));
}
} catch (error: any) {
catch (error: any) {
core.setFailed(error.message);
console.log(error.message)
}
}

validateValidatedTokensCsv();
// getDiffAndValidate();
})();
Loading

0 comments on commit dc55a4d

Please sign in to comment.