Skip to content

Commit

Permalink
feat: read erc20 token contract (#79)
Browse files Browse the repository at this point in the history
* chore: sync

* chore: wip

* refactor: yarn to npm

* chore: wip

* chore: read symbol

* chore: read symbol

* chore: read symbol

* chore: read symbol

* chore: rpc mapping

* chore: wip

* chore: try matic

* chore: try matic

* chore: try matic

* chore: sync matic

* Update readSymbolAndNameFromContract.ts

* chore: sync other chain

* chore: done

* chore: read decimal also

* chore: sync each time

* chore: sync

* chore: update package version

* chore: done
  • Loading branch information
zhouhanseng authored Apr 12, 2023
1 parent 3dd1c41 commit c07d190
Show file tree
Hide file tree
Showing 14 changed files with 14,062 additions and 3,063 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,68 @@ jobs:
- uses: actions/checkout@v3
- name: Use node_modules cache
uses: actions/cache@v2
id: yarn-cache
id: npm-cache
with:
path: |
node_modules
key: yarn-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}
key: npm-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}

- name: Yarn install
run: yarn install
if: steps.yarn-cache.outputs.cache-hit != 'true'
- name: NPM install
run: npm run install
if: steps.npm-cache.outputs.cache-hit != 'true'

- name: Sync Solana Token List
id: sync-token-list-solana
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i solana && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=solana && npm run lint-fix
- name: Sync OP Token List
id: sync-token-list-op
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i 10 && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=10 && npm run lint-fix
- name: Sync Aurora Token List
id: sync-token-list-aurora
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i 1313161554 && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=1313161554 && npm run lint-fix
- name: Sync Gnosis Token List
id: sync-token-list-gnosis
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i 100 && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=100 && npm run lint-fix
- name: Sync Fantom Token List
id: sync-token-list-fantom
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i 250 && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=250 && npm run lint-fix
- name: Sync Avalanche Token List
id: sync-token-list-avalanche
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i 43114 && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=43114 && npm run lint-fix
- name: Sync Arbitrum Token List
id: sync-token-list-arbitrum
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i 42161 && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=42161 && npm run lint-fix
- name: Sync Polygon Token List
id: sync-token-list-polygon
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i 137 && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=137 && npm run lint-fix
- name: Sync BSC Token List
id: sync-token-list-bsc
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i 56 && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=56 && npm run lint-fix
- name: Sync ETH Token List
id: sync-token-list-eth
run: |
node node_modules/puppeteer/install.js && yarn cli generate -i 1 && yarn lint-fix
node node_modules/puppeteer/install.js && npm run cli generate -- --include=1 && npm run lint-fix
- name: Prettier Check
run: yarn prettier
run: npm run prettier

- name: Get Package Version
id: package-version
Expand Down
109 changes: 109 additions & 0 deletions .github/workflows/read_contract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Read contract

on:
push:
branches:
- 'sync-token-list-from-contract'
workflow_dispatch:

jobs:
read-contract:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use node_modules cache
uses: actions/cache@v2
id: npm-cache
with:
path: |
node_modules
key: npm-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}

- name: npm install
run: npm install
if: steps.npm-cache.outputs.cache-hit != 'true'

- name: Sync ETH Token List
id: sync-token-list-eth
run: |
node node_modules/puppeteer/install.js && npm run cli read-contract -- --include=1 && npm run lint-fix
- name: Sync BSC Token List
id: sync-token-list-bsc
run: |
node node_modules/puppeteer/install.js && npm run cli read-contract -- --include=56 && npm run lint-fix
- name: Sync Polygon Token List
id: sync-token-list-polygon
run: |
node node_modules/puppeteer/install.js && npm run cli read-contract -- --include=137 && npm run lint-fix
- name: Sync OP Token List
id: sync-token-list-op
run: |
node node_modules/puppeteer/install.js && npm run cli read-contract -- --include=10 && npm run lint-fix
- name: Sync Aurora Token List
id: sync-token-list-aurora
run: |
node node_modules/puppeteer/install.js && npm run cli read-contract -- --include=1313161554 && npm run lint-fix
- name: Sync Gnosis Token List
id: sync-token-list-gnosis
run: |
node node_modules/puppeteer/install.js && npm run cli read-contract -- --include=100 && npm run lint-fix
- name: Sync Fantom Token List
id: sync-token-list-fantom
run: |
node node_modules/puppeteer/install.js && npm run cli read-contract -- --include=250 && npm run lint-fix
- name: Sync Avalanche Token List
id: sync-token-list-avalanche
run: |
node node_modules/puppeteer/install.js && npm run cli read-contract -- --include=43114 && npm run lint-fix
- name: Sync Arbitrum Token List
id: sync-token-list-arbitrum
run: |
node node_modules/puppeteer/install.js && npm run cli read-contract -- --include=42161 && npm run lint-fix
- name: Prettier Check
run: npm run prettier

- name: Get Package Version
id: package-version
uses: martinbeentjes/npm-get-version-action@master

- name: Tag Package Version
run: git tag v${{ steps.package-version.outputs.current-version }}

- name: Create Release Package
uses: montudor/action-zip@v1
with:
args:
zip -qq -r v${{ steps.package-version.outputs.current-version }}.zip dist/v${{
steps.package-version.outputs.current-version }}

- name: Upload Latest Release
uses: actions/upload-artifact@v2
with:
name: v${{ steps.package-version.outputs.current-version }}.zip
path: v${{ steps.package-version.outputs.current-version }}.zip

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: v${{ steps.package-version.outputs.current-version }}.zip
asset_name: v${{ steps.package-version.outputs.current-version }}.zip
tag: v${{ steps.package-version.outputs.current-version }}
overwrite: true

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
keep_files: true
cname: tokens.r2d2.to
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ The token lists for Mask Network.
## Setup

```bash
yarn install # install dependencies
yarn build # build token lists
npm run install # install dependencies
npm run build # build token lists
```

## Steps for new chain

- Add the chain id in [types.ts](src/types.ts).
- Add your token lists into [src/fungible-tokens/](src/fungible-tokens/) or [src/non-fungible-tokens/](src/non-fungible-tokens/).
- Run `yarn build` to ensure everything is working great.
- Run `npm run build` to ensure everything is working great.
- Don't forget to bump version in `package.json`.
- Update below two tables in README file here.

Expand All @@ -42,13 +42,13 @@ It requires two separate commits to trigger Cloudflare to update its resource.
Generate target chain's token list:

```bash
yarn cli generate -i <chainId>
npm run cli generate -- --include=<chainId>
```

Generate all support chains list:

```bash
yarn cli generate
npm run cli generate
```

## Versions based on chain id
Expand Down
Loading

0 comments on commit c07d190

Please sign in to comment.