From 4b3e0383235ca4ca0127f24c2e05543bb45a56bb Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Wed, 29 Nov 2017 22:02:43 -0800 Subject: Add contracts to packages, fix most linting errors --- packages/contracts/migrations/3_register_tokens.ts | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 packages/contracts/migrations/3_register_tokens.ts (limited to 'packages/contracts/migrations/3_register_tokens.ts') diff --git a/packages/contracts/migrations/3_register_tokens.ts b/packages/contracts/migrations/3_register_tokens.ts new file mode 100644 index 000000000..ef0e03123 --- /dev/null +++ b/packages/contracts/migrations/3_register_tokens.ts @@ -0,0 +1,86 @@ +import * as Bluebird from 'bluebird'; +import * as _ from 'lodash'; + +import {Artifacts} from '../util/artifacts'; +import {constants} from '../util/constants'; +import {ContractInstance, Token, TokenInfoByNetwork} from '../util/types'; + +import {tokenInfo} from './config/token_info'; +const { + DummyToken, + EtherToken, + ZRXToken, + TokenRegistry, +} = new Artifacts(artifacts); + +module.exports = (deployer: any, network: string) => { + const tokens = network === 'live' ? tokenInfo.live : tokenInfo.development; + deployer.then(() => { + return TokenRegistry.deployed(); + }).then((tokenRegistry: ContractInstance) => { + if (network !== 'live') { + const totalSupply = Math.pow(10, 18) * 1000000000; + return Bluebird.each(tokens.map((token: Token) => DummyToken.new( + token.name, + token.symbol, + token.decimals, + totalSupply, + )), _.noop).then((dummyTokens: ContractInstance[]) => { + const weth = { + address: EtherToken.address, + name: 'Ether Token', + symbol: 'WETH', + url: '', + decimals: 18, + ipfsHash: constants.NULL_BYTES, + swarmHash: constants.NULL_BYTES, + }; + return Bluebird.each(dummyTokens.map((tokenContract: ContractInstance, i: number) => { + const token = tokens[i]; + return tokenRegistry.addToken( + tokenContract.address, + token.name, + token.symbol, + token.decimals, + token.ipfsHash, + token.swarmHash, + ); + }).concat(tokenRegistry.addToken( + weth.address, + weth.name, + weth.symbol, + weth.decimals, + weth.ipfsHash, + weth.swarmHash, + )), _.noop); + }); + } else { + const zrx = { + address: ZRXToken.address, + name: '0x Protocol Token', + symbol: 'ZRX', + url: 'https://www.0xproject.com/', + decimals: 18, + ipfsHash: constants.NULL_BYTES, + swarmHash: constants.NULL_BYTES, + }; + return Bluebird.each(tokens.map((token: Token) => { + return tokenRegistry.addToken( + token.address, + token.name, + token.symbol, + token.decimals, + token.ipfsHash, + token.swarmHash, + ); + }).concat(tokenRegistry.addToken( + zrx.address, + zrx.name, + zrx.symbol, + zrx.decimals, + zrx.ipfsHash, + zrx.swarmHash, + )), _.noop); + } + }); +}; -- cgit v1.2.3 From e85a69655c29a04b7f1a3506c5ecb55433425f7f Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Wed, 29 Nov 2017 22:26:51 -0800 Subject: Fix indentations --- packages/contracts/migrations/3_register_tokens.ts | 146 ++++++++++----------- 1 file changed, 73 insertions(+), 73 deletions(-) (limited to 'packages/contracts/migrations/3_register_tokens.ts') diff --git a/packages/contracts/migrations/3_register_tokens.ts b/packages/contracts/migrations/3_register_tokens.ts index ef0e03123..c72ac1510 100644 --- a/packages/contracts/migrations/3_register_tokens.ts +++ b/packages/contracts/migrations/3_register_tokens.ts @@ -7,80 +7,80 @@ import {ContractInstance, Token, TokenInfoByNetwork} from '../util/types'; import {tokenInfo} from './config/token_info'; const { - DummyToken, - EtherToken, - ZRXToken, - TokenRegistry, + DummyToken, + EtherToken, + ZRXToken, + TokenRegistry, } = new Artifacts(artifacts); module.exports = (deployer: any, network: string) => { - const tokens = network === 'live' ? tokenInfo.live : tokenInfo.development; - deployer.then(() => { - return TokenRegistry.deployed(); - }).then((tokenRegistry: ContractInstance) => { - if (network !== 'live') { - const totalSupply = Math.pow(10, 18) * 1000000000; - return Bluebird.each(tokens.map((token: Token) => DummyToken.new( - token.name, - token.symbol, - token.decimals, - totalSupply, - )), _.noop).then((dummyTokens: ContractInstance[]) => { - const weth = { - address: EtherToken.address, - name: 'Ether Token', - symbol: 'WETH', - url: '', - decimals: 18, - ipfsHash: constants.NULL_BYTES, - swarmHash: constants.NULL_BYTES, - }; - return Bluebird.each(dummyTokens.map((tokenContract: ContractInstance, i: number) => { - const token = tokens[i]; - return tokenRegistry.addToken( - tokenContract.address, - token.name, - token.symbol, - token.decimals, - token.ipfsHash, - token.swarmHash, - ); - }).concat(tokenRegistry.addToken( - weth.address, - weth.name, - weth.symbol, - weth.decimals, - weth.ipfsHash, - weth.swarmHash, - )), _.noop); - }); - } else { - const zrx = { - address: ZRXToken.address, - name: '0x Protocol Token', - symbol: 'ZRX', - url: 'https://www.0xproject.com/', - decimals: 18, - ipfsHash: constants.NULL_BYTES, - swarmHash: constants.NULL_BYTES, - }; - return Bluebird.each(tokens.map((token: Token) => { - return tokenRegistry.addToken( - token.address, - token.name, - token.symbol, - token.decimals, - token.ipfsHash, - token.swarmHash, - ); - }).concat(tokenRegistry.addToken( - zrx.address, - zrx.name, - zrx.symbol, - zrx.decimals, - zrx.ipfsHash, - zrx.swarmHash, - )), _.noop); - } - }); + const tokens = network === 'live' ? tokenInfo.live : tokenInfo.development; + deployer.then(() => { + return TokenRegistry.deployed(); + }).then((tokenRegistry: ContractInstance) => { + if (network !== 'live') { + const totalSupply = Math.pow(10, 18) * 1000000000; + return Bluebird.each(tokens.map((token: Token) => DummyToken.new( + token.name, + token.symbol, + token.decimals, + totalSupply, + )), _.noop).then((dummyTokens: ContractInstance[]) => { + const weth = { + address: EtherToken.address, + name: 'Ether Token', + symbol: 'WETH', + url: '', + decimals: 18, + ipfsHash: constants.NULL_BYTES, + swarmHash: constants.NULL_BYTES, + }; + return Bluebird.each(dummyTokens.map((tokenContract: ContractInstance, i: number) => { + const token = tokens[i]; + return tokenRegistry.addToken( + tokenContract.address, + token.name, + token.symbol, + token.decimals, + token.ipfsHash, + token.swarmHash, + ); + }).concat(tokenRegistry.addToken( + weth.address, + weth.name, + weth.symbol, + weth.decimals, + weth.ipfsHash, + weth.swarmHash, + )), _.noop); + }); + } else { + const zrx = { + address: ZRXToken.address, + name: '0x Protocol Token', + symbol: 'ZRX', + url: 'https://www.0xproject.com/', + decimals: 18, + ipfsHash: constants.NULL_BYTES, + swarmHash: constants.NULL_BYTES, + }; + return Bluebird.each(tokens.map((token: Token) => { + return tokenRegistry.addToken( + token.address, + token.name, + token.symbol, + token.decimals, + token.ipfsHash, + token.swarmHash, + ); + }).concat(tokenRegistry.addToken( + zrx.address, + zrx.name, + zrx.symbol, + zrx.decimals, + zrx.ipfsHash, + zrx.swarmHash, + )), _.noop); + } + }); }; -- cgit v1.2.3