2019-08-09 22:46:58 +00:00
|
|
|
const axios = require("axios")
|
|
|
|
const fs = require('fs')
|
|
|
|
|
|
|
|
const TRUST_API_URL = process.env.TRUST_API_URL
|
|
|
|
const TOKEN_VERIFICATION_KEY = process.env.TOKEN_VERIFICATION_KEY
|
2019-11-08 18:55:41 +00:00
|
|
|
const ethereumSidechains = ["ethereum", "classic", "poa", "tomochain", "gochain", "wanchain", "thundertoken"]
|
2019-08-09 22:46:58 +00:00
|
|
|
|
|
|
|
const addresses = []
|
|
|
|
ethereumSidechains.forEach(chain => {
|
|
|
|
addresses.push(fs.readdirSync(`./blockchains/${chain}/assets`))
|
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
const tokens = [].concat.apply([], addresses).map(a => a.toLowerCase())
|
2019-08-09 22:46:58 +00:00
|
|
|
|
2019-11-12 21:26:53 +00:00
|
|
|
axios.post(TRUST_API_URL, {tokens}, {
|
2019-08-09 22:46:58 +00:00
|
|
|
headers: {
|
|
|
|
TOKEN_VERIFICATION_KEY
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
if (res.status !== 200) {
|
|
|
|
exitWithMsg(`Error verifying tokens`)
|
|
|
|
}
|
|
|
|
console.log(`Tokens were successfully verified`, res.data)
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
exitWithMsg(`Failed to verify tokens ${e.message}`)
|
|
|
|
})
|
|
|
|
|
|
|
|
const exitWithMsg = (msg) => {
|
|
|
|
console.log(msg)
|
|
|
|
process.exit(1)
|
|
|
|
}
|