UNPKG

@fleupold/dex-contracts

Version:

Contracts for dFusion multi-token batch auction exchange

34 lines (33 loc) 1.27 kB
import { addTokens, getBatchExchange, getOwl } from "./util"; import fetch from "cross-fetch"; import { factory } from "../src/logging"; const log = factory.getLogger("scripts.add_token_list"); const argv = require("yargs") .option("token_list_url", { describe: "A url which can be fetched with cross-fetch", default: "https://raw.githubusercontent.com/gnosis/dex-js/master/src/tokenList.json", }) .help(false) .version(false).argv; module.exports = async function (callback) { try { const tokenList = await (await fetch(argv.token_list_url)).json(); const networkId = String(await web3.eth.net.getId()); const tokenAddresses = []; for (const token of tokenList) { const address = token.addressByNetwork[networkId]; if (address) { tokenAddresses.push(address); } } const [account] = await web3.eth.getAccounts(); const batchExchange = await getBatchExchange(artifacts); const owl = await getOwl(artifacts); log.info(`Attempting to register ${tokenAddresses.length} tokens`); await addTokens(tokenAddresses, account, batchExchange, owl); callback(); } catch (error) { callback(error); } };