Skip to content

Commit

Permalink
feat: add script for generating rango custom token list
Browse files Browse the repository at this point in the history
  • Loading branch information
RanGojo committed Aug 23, 2023
1 parent 6455982 commit 6c3aa63
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In order to include your token on Rango Exchange as a custom token, you are requ
git checkout <branch_name>
```

3. Create a directory within `tokens/custom/` using your token's name. Inside this directory, include a 256x256 SVG/PNG icon, along with the token's manifest.
3. Create a directory within `tokens/custom/` using your token's name. Inside this directory, include a 256x256 PNG icon, along with the token's manifest.

4. Submit the Pull Request. Within the _PR description_, kindly provide an explanation regarding **the DEXes/Bridges that your token is supported by**, considering Rango's integration. You could find list of all supported protocols [here](https://docs.rango.exchange/integrations).

Expand Down
80 changes: 80 additions & 0 deletions dest/rango-custom-tokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "Rango Custom Token List",
"logoURI": "",
"keywords": ["rango", "list"],
"timestamp": "2023-08-23T12:15:28.176Z",
"version": {
"major": 1,
"minor": 1,
"patch": 1
},
"tags": {},
"tokens": [
[
{
"name": "BIFI",
"address": "0x4e720dd3ac5cfe1e1fbde4935f386bb1c66f4642",
"symbol": "BIFI",
"decimals": 18,
"chainId": 10,
"logoURI": "https://raw.githubusercontent.com/rango-exchange/rango-token-list/main/tokens/custom/bifi/icon.png"
}
],
[
{
"name": "Flash 3.0",
"symbol": "FLASH",
"address": "0xBb19DA2482308ec02a242ACED4Fe0f09D06b12A7",
"chainId": 1,
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/rango-exchange/rango-token-list/main/tokens/custom/flash/icon.png"
}
],
[
{
"name": "Godzilla Project Token",
"symbol": "GODZ",
"address": "0xae7cf30e14e132e43689ebe4fab49706c59a0bf7",
"chainId": 56,
"decimals": 9,
"logoURI": "https://raw.githubusercontent.com/rango-exchange/rango-token-list/main/tokens/custom/godzilla/icon.png"
}
],
[
{
"name": "KAXAA",
"symbol": "KAX",
"address": "0x42aF7aAc6AE6425Ffa96370cFD0B12522Aa4b458",
"chainId": 137,
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/rango-exchange/rango-token-list/main/tokens/custom/kaxaa/icon.png"
}
],
[
{
"name": "Rocket Vault RocketX",
"symbol": "RVF",
"address": "0xdc8aF07A7861bedD104B8093Ae3e9376fc8596D2",
"chainId": 1,
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/rango-exchange/rango-token-list/main/tokens/custom/rocketx/icon.png"
},
{
"name": "Rocket Vault RocketX",
"symbol": "RVF",
"address": "0x872a34Ebb2d54Af86827810EeBC7b9dC6B2144aA",
"chainId": 56,
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/rango-exchange/rango-token-list/main/tokens/custom/rocketx/icon.png"
},
{
"name": "Rocket Vault RocketX",
"symbol": "RVF",
"address": "0x2CE13E4199443FDfFF531ABb30c9B6594446bbC7",
"chainId": 137,
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/rango-exchange/rango-token-list/main/tokens/custom/rocketx/icon.png"
}
]
]
}
11 changes: 10 additions & 1 deletion eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{
"extends": ["plugin:json/recommended"]
"extends": ["plugin:json/recommended"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"env": {
"browser": true,
"node": true,
"es6": true
}
}
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
"repository": "[email protected]:rango-exchange/rango-token-list.git",
"author": "RanGojo <[email protected]>",
"license": "MIT",
"engines": {
"node": ">=14"
},
"private": true,
"scripts": {
"eslint": "eslint tokens/* --ext .json --fix",
"prepare": "husky install"
"prepare": "husky install",
"generate-token-list": "node ./scripts/generate.mjs"
},
"lint-staged": {
"**.{json}": [
Expand All @@ -19,12 +23,12 @@
"devDependencies": {
"eslint": "^8.9.0",
"eslint-plugin-json": "^3.1.0",
"lint-staged": "^13.2.2",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.0",
"lint-staged": "^13.2.2",
"prettier": "^2.7.1",
"eslint-plugin-prettier": "^4.2.1"
},
"dependencies": {
"glob": "^10.3.3",
"husky-init": "^8.0.0"
}
},
"dependencies": {}
}
27 changes: 27 additions & 0 deletions scripts/generate.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import fs from "fs";

const customTokensDir = "./tokens/custom/";
const logoBaseURI =
"https://raw.githubusercontent.com/rango-exchange/rango-token-list/main/tokens/custom";

const projectsList = fs.readdirSync(customTokensDir);
const template = JSON.parse(fs.readFileSync("./templates/token-list.json"));

const projects = [];
for (let i = 0; i < projectsList.length; i++) {
const projectName = projectsList[i];
const projectTokens = JSON.parse(
fs.readFileSync(`${customTokensDir}${projectName}/manifest.json`)
);
for (const token of projectTokens) {
token["logoURI"] = `${logoBaseURI}/${projectName}/icon.png`;
}
projects.push(projectTokens);
}

template["tokens"] = projects;
template["timestamp"] = new Date();
fs.writeFileSync(
"./dest/rango-custom-tokens.json",
JSON.stringify(template, undefined, 2)
);
13 changes: 13 additions & 0 deletions templates/token-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Rango Custom Token List",
"logoURI": "",
"keywords": ["rango", "list"],
"timestamp": "2023-08-23T00:00:00.000Z",
"version": {
"major": 1,
"minor": 1,
"patch": 1
},
"tags": {},
"tokens": []
}
Loading

0 comments on commit 6c3aa63

Please sign in to comment.