-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit fdcd6a7
Showing
16 changed files
with
3,769 additions
and
0 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,26 @@ | ||
name: "Test Collection Lists" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "**" | ||
pull_request: | ||
paths: | ||
- "**" | ||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "npm" | ||
- run: npm install && npx lint-staged && npm test | ||
working-directory: "." |
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,3 @@ | ||
node_modules | ||
yarn-error.log | ||
.eslintcache |
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 @@ | ||
_ |
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,2 @@ | ||
npx lint-staged | ||
npm run test |
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,29 @@ | ||
# P2P Collections List | ||
|
||
This repo contains the list of p2p collections supported by the jpegd frontend. | ||
|
||
## Installation | ||
|
||
Run the following command : | ||
|
||
- `yarn` | ||
|
||
## PR Guidelines | ||
|
||
Instructions to Follow when adding a collection: | ||
|
||
- Collection key must be in all caps, eg: CRYPTOPUNKS | ||
- The collection logo must be added to the `logos` folder, in png format and 240x240 pixels. Its name must be the same as the collection key. eg: CRYPTOPUNKS.png | ||
- The collection should then be added to `collections.json` with the following format : | ||
|
||
{ | ||
address: string | ||
label: string | ||
key: string | ||
imageBaseUrl: string | ||
logoUrl: https://github.com/jpegd/p2p-collection-list/blob/main/logos/<key>.png?raw=true | ||
isERC721: true | ||
osSlug?: string | ||
blurSlug?: string | ||
ext?: string | ||
} |
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,89 @@ | ||
[ | ||
{ | ||
"address": "0x9dbd6Bb8cD5F9aB9d7B66Dd41805BEE41d61A7F6", | ||
"label": "CryptoPunks", | ||
"key": "CRYPTOPUNKS", | ||
"imageBaseUrl": "https://cdn.jpegd.io/collections/punks", | ||
"logoUrl": "https://github.com/jpegd/p2p-collection-list/blob/main/logos/CRYPTOPUNKS.png?raw=true", | ||
"enabled": true, | ||
"isERC721": false, | ||
"osSlug": "cryptopunks" | ||
}, | ||
{ | ||
"address": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D", | ||
"label": "BAYC", | ||
"key": "BAYC", | ||
"imageBaseUrl": "https://cdn.jpegd.io/collections/bayc", | ||
"logoUrl": "https://github.com/jpegd/p2p-collection-list/blob/main/logos/BAYC.png?raw=true", | ||
"enabled": true, | ||
"isERC721": true, | ||
"osSlug": "boredapeyachtclub", | ||
"blurSlug": "boredapeyachtclub" | ||
}, | ||
{ | ||
"address": "0xBd3531dA5CF5857e7CfAA92426877b022e612cf8", | ||
"label": "Pudgy Penguin", | ||
"key": "PUDGYPENGUINS", | ||
"imageBaseUrl": "https://cdn.jpegd.io/collections/pudgypenguins", | ||
"logoUrl": "https://cdn.jpegd.io/static/logos/PENGUINS.png", | ||
"enabled": true, | ||
"isERC721": true, | ||
"osSlug": "pudgypenguins", | ||
"blurSlug": "pudgypenguins" | ||
}, | ||
{ | ||
"label": "Milady", | ||
"key": "MILADY", | ||
"address": "0x5Af0D9827E0c53E4799BB226655A1de152A425a5", | ||
"imageBaseUrl": "https://cdn.jpegd.io/collections/milady", | ||
"logoUrl": "https://cdn.jpegd.io/static/logos/MILADY.png", | ||
"enabled": true, | ||
"isERC721": true, | ||
"osSlug": "milady", | ||
"blurSlug": "milady" | ||
}, | ||
{ | ||
"label": "MAYC", | ||
"key": "MAYC", | ||
"address": "0x60E4d786628Fea6478F785A6d7e704777c86a7c6", | ||
"imageBaseUrl": "https://cdn.jpegd.io/collections/mayc", | ||
"logoUrl": "https://cdn.jpegd.io/static/logos/MAYC.png", | ||
"enabled": true, | ||
"isERC721": true, | ||
"osSlug": "mutant-ape-yacht-club", | ||
"blurSlug": "mutant-ape-yacht-club" | ||
}, | ||
{ | ||
"label": "BAKC", | ||
"key": "BAKC", | ||
"address": "0xba30E5F9Bb24caa003E9f2f0497Ad287FDF95623", | ||
"imageBaseUrl": "https://cdn.jpegd.io/collections/bakc", | ||
"logoUrl": "https://cdn.jpegd.io/static/logos/BAKC.png", | ||
"enabled": true, | ||
"isERC721": true, | ||
"osSlug": "bored-ape-kennel-club", | ||
"blurSlug": "bored-ape-kennel-club" | ||
}, | ||
{ | ||
"label": "Azuki", | ||
"key": "AZUKI", | ||
"address": "0xED5AF388653567Af2F388E6224dC7C4b3241C544", | ||
"imageBaseUrl": "https://cdn.jpegd.io/collections/azuki", | ||
"logoUrl": "https://cdn.jpegd.io/static/logos/AZUKI.png", | ||
"enabled": true, | ||
"isERC721": true, | ||
"osSlug": "azuki", | ||
"blurSlug": "azuki" | ||
}, | ||
{ | ||
"label": "Doodles", | ||
"key": "DOODLES", | ||
"address": "0x8a90CAb2b38dba80c64b7734e58Ee1dB38B8992e", | ||
"imageBaseUrl": "https://cdn.jpegd.io/collections/doodles", | ||
"logoUrl": "https://cdn.jpegd.io/static/logos/DOODLES.png", | ||
"enabled": true, | ||
"isERC721": true, | ||
"osSlug": "doodles-official", | ||
"blurSlug": "doodles-official" | ||
} | ||
] |
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,19 @@ | ||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
import json from "eslint-plugin-json"; | ||
|
||
export default [ | ||
{ | ||
files: ["**/*.{js,mjs,cjs,ts}", "**/*.json"], | ||
plugins: { json }, | ||
processor: "json/json", | ||
rules: { | ||
"json/*": ["error", "allowComments"], | ||
"json/*": ["error", { allowComments: true }], | ||
}, | ||
}, | ||
{ languageOptions: { globals: globals.browser } }, | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
]; |
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,8 @@ | ||
import type { Config } from "@jest/types"; | ||
const config: Config.InitialOptions = { | ||
verbose: true, | ||
transform: { | ||
"^.+\\.tsx?$": "ts-jest", | ||
}, | ||
}; | ||
export default config; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 @@ | ||
{ | ||
"name": "p2p-collection-list", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "jest", | ||
"lint-staged": "lint-staged", | ||
"prepare": "husky && husky install" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"lint-staged": { | ||
"*.{js,jsx,json}": [ | ||
"pretty-quick --staged", | ||
"eslint --fix", | ||
"git add" | ||
], | ||
"*.{js,json}": "eslint --cache --fix", | ||
"*.{js,css,md,json}": "prettier --write" | ||
}, | ||
"dependencies": { | ||
"@ethersproject/address": "^5.7.0", | ||
"@types/node": "^20.14.10", | ||
"ajv": "^8.16.0", | ||
"ajv-formats": "^3.0.1", | ||
"chai": "^5.1.1", | ||
"image-size": "^1.1.1", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.2.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.5.3" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.3.16", | ||
"@types/jest": "^29.5.12", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-json": "^4.0.0", | ||
"husky": "^9.0.11", | ||
"lint-staged": "^15.2.7", | ||
"prettier": "^3.3.2", | ||
"pretty-quick": "^4.0.0", | ||
"typescript-eslint": "^7.16.1" | ||
} | ||
} |
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,15 @@ | ||
export const schema = { | ||
type: "object", | ||
properties: { | ||
address: { type: "string" }, | ||
label: { type: "string" }, | ||
key: { type: "string" }, | ||
imageBaseUrl: { type: "string", format: "uri" }, | ||
logoUrl: { type: "string", format: "uri" }, | ||
isERC721: { type: "boolean" }, | ||
osSlug: { type: "string" }, | ||
blurSlug: { type: "string" }, | ||
ext: { type: "string" }, | ||
}, | ||
required: ["address", "label", "key", "imageBaseUrl", "logoUrl", "isERC721"], | ||
}; |
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,74 @@ | ||
import { schema } from "../schema"; | ||
import { expect } from "@jest/globals"; | ||
import { getAddress } from "@ethersproject/address"; | ||
import addFormats from "ajv-formats"; | ||
import Ajv from "ajv"; | ||
|
||
const ajv = new Ajv(); | ||
addFormats(ajv); | ||
const validator = ajv.compile(schema); | ||
|
||
describe("Test collection data", () => { | ||
const collectionList = require(`../collections.json`); | ||
|
||
it("validates", () => { | ||
for (let collection of collectionList) { | ||
const result = validator(collection); | ||
expect(result === true); | ||
} | ||
}); | ||
|
||
it("all addresses are valid and checksummed", () => { | ||
for (let collection of collectionList) { | ||
expect(getAddress(collection.address) === collection.address); | ||
} | ||
}); | ||
|
||
it("contains no duplicate collection keys", () => { | ||
const map: any = {}; | ||
for (let collection of collectionList) { | ||
const key = collection.key; | ||
if (map[key]) { | ||
console.log("duplicate address found"); | ||
} | ||
expect(typeof map[key] === "undefined"); | ||
map[key] = true; | ||
} | ||
}); | ||
|
||
it("contains no duplicate addresses", () => { | ||
const map: any = {}; | ||
for (let collection of collectionList) { | ||
const key = collection.address; | ||
if (map[getAddress(key)]) { | ||
console.log("duplicate key found"); | ||
} | ||
expect(typeof map[key] === "undefined"); | ||
map[getAddress(key)] = true; | ||
} | ||
}); | ||
|
||
it("contains no duplicate os slug", () => { | ||
const map: any = {}; | ||
for (let collection of collectionList) { | ||
const key = collection.osSlug; | ||
if (map[key]) { | ||
console.log("duplicate key found"); | ||
} | ||
expect(typeof map[key] === "undefined"); | ||
map[key] = true; | ||
} | ||
}); | ||
|
||
it("contains no duplicate blur slug", () => { | ||
const map: any = {}; | ||
for (let collection of collectionList) { | ||
const key = collection.blurSlug; | ||
if (map[key]) { | ||
console.log("duplicate key found"); | ||
} | ||
expect(typeof map[key] === "undefined"); | ||
map[key] = true; | ||
} | ||
}); | ||
}); |
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,49 @@ | ||
import fs from "fs"; | ||
import { expect } from "@jest/globals"; | ||
import sizeOf from "image-size"; | ||
|
||
const LOGO_PATH = "logos"; | ||
|
||
test("Image size is valid and extension should be in png", () => { | ||
let keyMapping: Record<string, string> = {}; | ||
const collectionList = require(`../collections.json`); | ||
|
||
keyMapping = collectionList.reduce( | ||
(prev: any, curr: any) => ({ ...prev, [curr.key]: true }), | ||
{}, | ||
); | ||
|
||
fs.readdir(LOGO_PATH, (error: any, logos: string[]) => { | ||
if (error) { | ||
throw error; | ||
} | ||
for (const file of logos) { | ||
const [filename, extention] = file.split("."); | ||
const { width, height } = sizeOf(LOGO_PATH + "/" + file); | ||
|
||
try { | ||
expect(extention).toBe("png"); | ||
} catch { | ||
throw Error(`${filename} should have a png extension`); | ||
} | ||
|
||
try { | ||
expect(keyMapping[filename]).toBe(true); | ||
} catch { | ||
throw Error(`${filename} doesnt exist as a key`); | ||
} | ||
|
||
try { | ||
expect(width).toBe(240); | ||
} catch { | ||
throw Error(`${filename} should have a width of 240`); | ||
} | ||
|
||
try { | ||
expect(height).toBe(240); | ||
} catch { | ||
throw Error(`${filename} should have a height of 240`); | ||
} | ||
} | ||
}); | ||
}); |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2016", | ||
"module": "commonjs", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true | ||
} | ||
} |
Oops, something went wrong.