mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Revert "CMC mapping: merge exceptions on every commit, retrieve from CMC and merge on Update runs."
This reverts commit 4f035dae0f
.
This commit is contained in:
parent
e388c3238d
commit
d310074554
|
@ -1,5 +1,5 @@
|
||||||
import { ActionInterface, CheckStepInterface } from "../../script/action/interface";
|
import { ActionInterface, CheckStepInterface } from "../../script/action/interface";
|
||||||
import { update, mergeCmcData } from "./script";
|
import { run } from "./script";
|
||||||
import { getSanityChecks } from "./check";
|
import { getSanityChecks } from "./check";
|
||||||
|
|
||||||
export class Coinmarketcap implements ActionInterface {
|
export class Coinmarketcap implements ActionInterface {
|
||||||
|
@ -11,12 +11,9 @@ export class Coinmarketcap implements ActionInterface {
|
||||||
|
|
||||||
sanityFix = null;
|
sanityFix = null;
|
||||||
|
|
||||||
async consistencyFix(): Promise<void> {
|
consistencyFix = null;
|
||||||
// do merge, for the case exceptions or script has been changed
|
|
||||||
await mergeCmcData();
|
|
||||||
}
|
|
||||||
|
|
||||||
async update(): Promise<void> {
|
async update(): Promise<void> {
|
||||||
await update();
|
await run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -59,39 +59,22 @@ const custom: mapTiker[] = [
|
||||||
// {"coin": 60, "type": typeToken, "token_id": "XXX", "id": XXX}, // XXX (XXX)
|
// {"coin": 60, "type": typeToken, "token_id": "XXX", "id": XXX}, // XXX (XXX)
|
||||||
]
|
]
|
||||||
|
|
||||||
var allContracts: mapTiker[] = [] // Temp storage for mapped assets
|
const allContracts: mapTiker[] = [] // Temp storage for mapped assets
|
||||||
let bnbOwnerToSymbol = {} // e.g: bnb1tawge8u97slduhhtumm03l4xl4c46dwv5m9yzk: WISH-2D5
|
let bnbOwnerToSymbol = {} // e.g: bnb1tawge8u97slduhhtumm03l4xl4c46dwv5m9yzk: WISH-2D5
|
||||||
let bnbOriginalSymbolToSymbol = {} // e.g: WISH: WISH-2D5
|
let bnbOriginalSymbolToSymbol = {} // e.g: WISH: WISH-2D5
|
||||||
|
|
||||||
async function retrieveCmcData() {
|
export async function run() {
|
||||||
allContracts = []
|
try {
|
||||||
await Promise.all([initState(), setBinanceTokens()])
|
await Promise.all([initState(), setBinanceTokens()])
|
||||||
const [totalCrypto, coins] = await Promise.all([getTotalActiveCryptocurrencies(), getTickers()])
|
const [totalCrypto, coins] = await Promise.all([getTotalActiveCryptocurrencies(), getTickers()])
|
||||||
// setBIP44Constants()
|
// setBIP44Constants()
|
||||||
log(`Found ${totalCrypto} on CMC`, chalk.yellowBright)
|
log(`Found ${totalCrypto} on CMC`, chalk.yellowBright)
|
||||||
await BluebirdPromise.mapSeries(coins, processCoin)
|
await BluebirdPromise.mapSeries(coins, processCoin)
|
||||||
|
|
||||||
sortContracts()
|
|
||||||
fs.writeFileSync(path.join(__dirname, 'cmc-data.json'), JSON.stringify(allContracts, null, 4))
|
|
||||||
allContracts = []
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function mergeCmcData() {
|
|
||||||
try {
|
|
||||||
allContracts = JSON.parse(readFileSync(path.join(__dirname, 'cmc-data.json')))
|
|
||||||
addCustom()
|
addCustom()
|
||||||
printContracts()
|
printContracts()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log(`Exception: ${error.message}`)
|
log(`Error at the end ${error.message}`)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function update() {
|
|
||||||
try {
|
|
||||||
await retrieveCmcData()
|
|
||||||
await mergeCmcData()
|
|
||||||
} catch (error) {
|
|
||||||
log(`Exception: ${error.message}`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +220,7 @@ function addToContractsList(ticker: mapTiker) {
|
||||||
allContracts.push(ticker)
|
allContracts.push(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortContracts() {
|
function printContracts() {
|
||||||
const sortedById = allContracts.sort((a,b) => {
|
const sortedById = allContracts.sort((a,b) => {
|
||||||
if (a.id < b.id) return -1
|
if (a.id < b.id) return -1
|
||||||
if (a.id > b.id) return 1
|
if (a.id > b.id) return 1
|
||||||
|
@ -250,14 +233,9 @@ function sortContracts() {
|
||||||
if (a.token_id < b.token_id) return -1
|
if (a.token_id < b.token_id) return -1
|
||||||
if (a.token_id > b.token_id) return 1
|
if (a.token_id > b.token_id) return 1
|
||||||
})
|
})
|
||||||
allContracts = sortedById
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function printContracts() {
|
|
||||||
sortContracts()
|
|
||||||
const wstream = fs.createWriteStream(path.join(__dirname, 'mapping.json'))
|
const wstream = fs.createWriteStream(path.join(__dirname, 'mapping.json'))
|
||||||
wstream.write(JSON.stringify(allContracts, null, 4))
|
wstream.write(JSON.stringify(sortedById, null, 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSlip44Index(symbol: string, name: string): number {
|
function getSlip44Index(symbol: string, name: string): number {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user