This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
4,702 additions
and
656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
})(); |
Oops, something went wrong.