trustwallet-assets/script/erc20_to_checksum.ts
Mykola 3ac372ecf8
Checksum script (#1263)
* Add @types/node

* Add checksum script

* Update azl pipeline

* Update map

* Optimised images with calibre/image-actions

* Omit checkout

* remove

* Recreate with exectute permission

* Add lovercase for tsting script

* Change to chmod 700

* run with sudo

* run with sudo

* Use SYSTEM_PULLREQUEST_SOURCEBRANCH var to get branch name

* Use Bash task

* Checksum ERC20 addresses [skip ci]

* Add in lowercase for testing

* Checksum ERC20 addresses [skip ci]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2020-02-18 18:00:11 -08:00

22 lines
930 B
TypeScript

const { execSync } = require('child_process');
const path = require('path')
const Web3 = require('web3')
const web3 = new Web3('ws://localhost:8546');
import { ethSidechains, readDirSync } from "../src/test/helpers"
ethSidechains.forEach(chain => {
const assetsPath = path.resolve(`${__dirname}/../blockchains/${chain}/assets`)
const chainAddresses = readDirSync(assetsPath)
chainAddresses.forEach(addr => {
const isChecksum = web3.utils.checkAddressChecksum(addr)
if (!isChecksum) {
console.log(`Address ${addr} not in checksum`)
const checksum = web3.utils.toChecksumAddress(addr)
const moveToChecksum = `git mv ${addr} ${checksum}-temp && git mv ${checksum}-temp ${checksum}`
const renamed = execSync(`cd ${assetsPath} && ${moveToChecksum}`, {encoding: "utf-8"})
console.log(`Result renaming ${addr} : ${renamed}`)
}
})
});