-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/improve tokenlist workflow (#179)
* feat: Improve version handling * feat: Validate valid logoURI * feat: Verbose error messages for failed validation * feat: Add CI check * chore: Update README
- Loading branch information
1 parent
feb7c9b
commit 86f3040
Showing
18 changed files
with
286 additions
and
69 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,27 @@ | ||
name: Verify token lists | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "packages/token-lists/src/tokens/**" | ||
- "packages/token-lists/lists/**" | ||
|
||
jobs: | ||
verifyTokenLists: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node | ||
uses: actions/[email protected] | ||
with: | ||
node-version: 14.x | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Check if tokenlists were updated correctly | ||
working-directory: ./packages/token-lists | ||
run: yarn ci-check |
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
File renamed without changes
Binary file added
BIN
+3.58 KB
packages/token-lists/lists/images/0x431e0cd023a32532bf3969cddfc002c00e98429d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30.7 KB
packages/token-lists/lists/images/0x4FA7163E153419E0E1064e418dd7A99314Ed27b6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added
BIN
+36.8 KB
packages/token-lists/lists/images/0x5F84ce30DC3cF7909101C69086c50De191895883.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.9 KB
packages/token-lists/lists/images/0x7e396bfc8a2f84748701167c2d622f041a1d7a17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.9 KB
packages/token-lists/lists/images/0x8595f9da7b868b1822194faed312235e43007b49.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.95 KB
packages/token-lists/lists/images/0x85eac5ac2f758618dfa09bdbe0cf174e7d574d5b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.68 KB
packages/token-lists/lists/images/0xaef0d72a118ce24fee3cd1d43d383897d05b4e99.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.8 KB
packages/token-lists/lists/images/0xc5a49b4cbe004b6fd55b30ba1de6ac360ff9765d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.35 KB
packages/token-lists/lists/images/0xe550a593d09fbc8dcd557b5c88cea6946a8b404a.png
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
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,62 @@ | ||
import srcDefault from "./tokens/pancakeswap-default.json"; | ||
import srcExtended from "./tokens/pancakeswap-extended.json"; | ||
import srcTop100 from "./tokens/pancakeswap-top-100.json"; | ||
import srcTop15 from "./tokens/pancakeswap-top-15.json"; | ||
import defaultList from "../lists/pancakeswap-default.json"; | ||
import extendedtList from "../lists/pancakeswap-extended.json"; | ||
import top15List from "../lists/pancakeswap-top-15.json"; | ||
import top100tList from "../lists/pancakeswap-top-100.json"; | ||
|
||
const lists = [ | ||
{ | ||
name: "pancakeswap-default", | ||
src: srcDefault, | ||
actual: defaultList, | ||
}, | ||
{ | ||
name: "pancakeswap-extended", | ||
src: srcExtended, | ||
actual: extendedtList, | ||
}, | ||
{ | ||
name: "pancakeswap-top-15", | ||
src: srcTop15, | ||
actual: top15List, | ||
}, | ||
{ | ||
name: "pancakeswap-top-100", | ||
src: srcTop100, | ||
actual: top100tList, | ||
}, | ||
]; | ||
|
||
const compareLists = (listPair) => { | ||
const { name, src, actual } = listPair; | ||
if (src.length !== actual.tokens.length) { | ||
throw Error( | ||
`List ${name} seems to be not properly regenerated. Soure file has ${src.length} tokens but actual list has ${actual.tokens.length}. Did you forget to run yarn makelist?` | ||
); | ||
} | ||
src.sort((t1, t2) => (t1.address < t2.address ? -1 : 1)); | ||
actual.tokens.sort((t1, t2) => (t1.address < t2.address ? -1 : 1)); | ||
src.forEach((srcToken, index) => { | ||
if (JSON.stringify(srcToken) !== JSON.stringify(actual.tokens[index])) { | ||
throw Error( | ||
`List ${name} seems to be not properly regenerated. Tokens from src/tokens directory don't match up with the final list. Did you forget to run yarn makelist?` | ||
); | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* Check in CI that author properly updated token list | ||
* i.e. not just changed token list in src/tokens but also regenerated lists with yarn makelist command. | ||
* Github Action runs only on change in src/tokens directory. | ||
*/ | ||
const ciCheck = (): void => { | ||
lists.forEach((listPair) => { | ||
compareLists(listPair); | ||
}); | ||
}; | ||
|
||
export default ciCheck; |
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
Oops, something went wrong.