Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Store contract addresses in JSON, not TypeScript
Browse files Browse the repository at this point in the history
This allows easier consumption by other languages.  (Specifically, it
eliminates the overhead of keeping the Python addresses package in sync
with the TypeScript one.)
  • Loading branch information
feuGeneA committed Oct 29, 2019
1 parent 4667fc5 commit 503b4f2
Show file tree
Hide file tree
Showing 15 changed files with 293 additions and 244 deletions.
117 changes: 117 additions & 0 deletions packages/contract-addresses/addresses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"1": {
"exchangeV2": "0x080bf510fcbf18b91105470639e9561022937712",
"exchange": "0x0000000000000000000000000000000000000000",
"erc20Proxy": "0x95e6f48254609a6ee006f7d493c8e5fb97094cef",
"erc721Proxy": "0xefc70a1b18c432bdc64b596838b4d138f6bc6cad",
"forwarder": "0x0000000000000000000000000000000000000000",
"orderValidator": "0x0000000000000000000000000000000000000000",
"zrxToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"etherToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"assetProxyOwner": "0xdffe798c7172dd6deb32baee68af322e8f495ce0",
"zeroExGovernor": "0x0000000000000000000000000000000000000000",
"dutchAuction": "0x0000000000000000000000000000000000000000",
"coordinatorRegistry": "0x45797531b873fd5e519477a070a955764c1a5b07",
"coordinator": "0x0000000000000000000000000000000000000000",
"multiAssetProxy": "0xef701d5389ae74503d633396c4d654eabedc9d78",
"staticCallProxy": "0x3517b88c19508c08650616019062b898ab65ed29",
"erc1155Proxy": "0x7eefbd48fd63d441ec7435d024ec7c5131019add",
"zrxVault": "0x0000000000000000000000000000000000000000",
"staking": "0x0000000000000000000000000000000000000000",
"stakingProxy": "0x0000000000000000000000000000000000000000",
"devUtils": "0x0000000000000000000000000000000000000000",
"erc20BridgeProxy": "0x0000000000000000000000000000000000000000"
},
"3": {
"erc20Proxy": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
"erc721Proxy": "0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4",
"zrxToken": "0xff67881f8d12f372d91baae9752eb3631ff0ed00",
"etherToken": "0xc778417e063141139fce010982780140aa0cd5ab",
"exchangeV2": "0xbff9493f92a3df4b0429b6d00743b3cfb4c85831",
"exchange": "0xc56388332ddfc98701fefed94535100c6166956c",
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
"zeroExGovernor": "0xdcf20f7b447d51f2b3e5499b7f6cbbf7295a5d26",
"forwarder": "0xe66ae6162b3e9067d6ce9e5b9799cca1ba0d09f8",
"orderValidator": "0x0000000000000000000000000000000000000000",
"dutchAuction": "0x0000000000000000000000000000000000000000",
"coordinatorRegistry": "0x403cc23e88c17c4652fb904784d1af640a6722d9",
"coordinator": "0xad8464022213a618c96a1178a927a5ed15ad6949",
"multiAssetProxy": "0xab8fbd189c569ccdee3a4d929bb7f557be4028f6",
"staticCallProxy": "0xe1b97e47aa3796276033a5341e884d2ba46b6ac1",
"erc1155Proxy": "0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d",
"devUtils": "0x9a8590eebcfc53f0cc7ab5ebb8c079e9e7d4e0f5",
"zrxVault": "0xffd161026865ad8b4ab28a76840474935eec4dfa",
"staking": "0x3f46b98061a3e1e1f41dff296ec19402c298f8a9",
"stakingProxy": "0xfaabcee42ab6b9c649794ac6c133711071897ee9",
"erc20BridgeProxy": "0x599b340b5045436a99b1f0c718d30f5a0c8519dd"
},
"4": {
"exchangeV2": "0xbff9493f92a3df4b0429b6d00743b3cfb4c85831",
"exchange": "0x3afe8aa355e086d898447732cfa5d931cfb2a792",
"erc20Proxy": "0x2f5ae4f6106e89b4147651688a92256885c5f410",
"erc721Proxy": "0x7656d773e11ff7383a14dcf09a9c50990481cd10",
"zrxToken": "0x8080c7e4b81ecf23aa6f877cfbfd9b0c228c6ffa",
"etherToken": "0xc778417e063141139fce010982780140aa0cd5ab",
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
"zeroExGovernor": "0x5d751aa855a1aee5fe44cf5350ed25b5727b66ae",
"forwarder": "0xf36eabdfe986b35b62c8fd5a98a7f2aebb79b291",
"orderValidator": "0x0000000000000000000000000000000000000000",
"dutchAuction": "0x0000000000000000000000000000000000000000",
"coordinatorRegistry": "0x1084b6a398e47907bae43fec3ff4b677db6e4fee",
"coordinator": "0x9ae7a6e4e4d58c36b7aa573fc06ce46dd3cb0d44",
"multiAssetProxy": "0xb34cde0ad3a83d04abebc0b66e75196f22216621",
"staticCallProxy": "0xe1b97e47aa3796276033a5341e884d2ba46b6ac1",
"erc1155Proxy": "0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d",
"devUtils": "0xfcbb258112485f18dd68f4b1016e48c23542fdc5",
"zrxVault": "0xa5bf6ac73bc40790fc6ffc9dbbbce76c9176e224",
"staking": "0x344d4f661a82afdd84d31456c291822d90d5dc3a",
"stakingProxy": "0xc6ad5277ea225ac05e271eb14a7ebb480cd9dd9f",
"erc20BridgeProxy": "0x31b8653642110f17bdb1f719901d7e7d49b08141"
},
"42": {
"erc20Proxy": "0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e",
"erc721Proxy": "0x2a9127c745688a165106c11cd4d647d2220af821",
"zrxToken": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa",
"etherToken": "0xd0a1e359811322d97991e03f863a0c30c2cf029c",
"exchangeV2": "0x30589010550762d2f0d06f650d8e8b6ade6dbf4b",
"exchange": "0xca8b1626b3b7a0da722ca9f264c4630c7d34d3b8",
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
"zeroExGovernor": "0x3654e5363cd75c8974c76208137df9691e820e97",
"forwarder": "0xd6330f9d2073e1889a295dd1dd2e28d42dec4bff",
"orderValidator": "0x0000000000000000000000000000000000000000",
"dutchAuction": "0x0000000000000000000000000000000000000000",
"coordinatorRegistry": "0x09fb99968c016a3ff537bf58fb3d9fe55a7975d5",
"coordinator": "0x10e0b1c2e6065ec7f290c7e3731264f9a2bf2b2d",
"multiAssetProxy": "0xf6313a772c222f51c28f2304c0703b8cf5428fd8",
"staticCallProxy": "0x48e94bdb9033640d45ea7c721e25f380f8bffa43",
"erc1155Proxy": "0x64517fa2b480ba3678a2a3c0cf08ef7fd4fad36f",
"devUtils": "0x58c4fbdf9222f10ad2bef8f4d374f209135e71a5",
"zrxVault": "0xf36eabdfe986b35b62c8fd5a98a7f2aebb79b291",
"staking": "0x89150f5eed50b3528f79bfb539f29d727f92821c",
"stakingProxy": "0xbab9145f1d57cd4bb0c9aa2d1ece0a5b6e734d34",
"erc20BridgeProxy": "0xfb2dd2a1366de37f7241c83d47da58fd503e2c64"
},
"50": {
"erc20Proxy": "0x1dc4c1cefef38a777b15aa20260a54e584b16c48",
"erc721Proxy": "0x1d7022f5b17d2f8b695918fb48fa1089c9f85401",
"erc1155Proxy": "0x6a4a62e5a7ed13c361b176a5f62c2ee620ac0df8",
"zrxToken": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c",
"etherToken": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082",
"exchangeV2": "0x48bacb9266a570d521063ef5dd96e61686dbe788",
"exchange": "0x48bacb9266a570d521063ef5dd96e61686dbe788",
"zeroExGovernor": "0x0000000000000000000000000000000000000000",
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
"forwarder": "0x0000000000000000000000000000000000000000",
"orderValidator": "0x0000000000000000000000000000000000000000",
"dutchAuction": "0x0000000000000000000000000000000000000000",
"coordinatorRegistry": "0x1941ff73d1154774d87521d2d0aaad5d19c8df60",
"coordinator": "0x0000000000000000000000000000000000000000",
"multiAssetProxy": "0xcfc18cec799fbd1793b5c43e773c98d4d61cc2db",
"staticCallProxy": "0x6dfff22588be9b3ef8cf0ad6dc9b84796f9fb45f",
"devUtils": "0x38ef19fdf8e8415f18c307ed71967e19aac28ba1",
"zrxVault": "0x0000000000000000000000000000000000000000",
"staking": "0x0000000000000000000000000000000000000000",
"stakingProxy": "0x0000000000000000000000000000000000000000",
"erc20BridgeProxy": "0x0000000000000000000000000000000000000000"
}
}
125 changes: 4 additions & 121 deletions packages/contract-addresses/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as _ from 'lodash';

import addresses from '../addresses.json';

export interface ContractAddresses {
erc20Proxy: string;
erc721Proxy: string;
Expand Down Expand Up @@ -32,127 +34,6 @@ export enum NetworkId {
Ganache = 50,
}

const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';

const networkToAddresses: { [networkId: number]: ContractAddresses } = {
1: {
exchangeV2: '0x080bf510fcbf18b91105470639e9561022937712',
exchange: NULL_ADDRESS,
erc20Proxy: '0x95e6f48254609a6ee006f7d493c8e5fb97094cef',
erc721Proxy: '0xefc70a1b18c432bdc64b596838b4d138f6bc6cad',
forwarder: NULL_ADDRESS,
orderValidator: NULL_ADDRESS,
zrxToken: '0xe41d2489571d322189246dafa5ebde1f4699f498',
etherToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
assetProxyOwner: '0xdffe798c7172dd6deb32baee68af322e8f495ce0',
zeroExGovernor: NULL_ADDRESS,
dutchAuction: NULL_ADDRESS,
coordinatorRegistry: '0x45797531b873fd5e519477a070a955764c1a5b07',
coordinator: NULL_ADDRESS,
multiAssetProxy: '0xef701d5389ae74503d633396c4d654eabedc9d78',
staticCallProxy: '0x3517b88c19508c08650616019062b898ab65ed29',
erc1155Proxy: '0x7eefbd48fd63d441ec7435d024ec7c5131019add',
zrxVault: NULL_ADDRESS,
staking: NULL_ADDRESS,
stakingProxy: NULL_ADDRESS,
devUtils: NULL_ADDRESS,
erc20BridgeProxy: NULL_ADDRESS,
},
3: {
erc20Proxy: '0xb1408f4c245a23c31b98d2c626777d4c0d766caa',
erc721Proxy: '0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4',
zrxToken: '0xff67881f8d12f372d91baae9752eb3631ff0ed00',
etherToken: '0xc778417e063141139fce010982780140aa0cd5ab',
exchangeV2: '0xbff9493f92a3df4b0429b6d00743b3cfb4c85831',
exchange: '0xc56388332ddfc98701fefed94535100c6166956c',
assetProxyOwner: NULL_ADDRESS,
zeroExGovernor: '0xdcf20f7b447d51f2b3e5499b7f6cbbf7295a5d26',
forwarder: '0xe66ae6162b3e9067d6ce9e5b9799cca1ba0d09f8',
orderValidator: NULL_ADDRESS,
dutchAuction: NULL_ADDRESS,
coordinatorRegistry: '0x403cc23e88c17c4652fb904784d1af640a6722d9',
coordinator: '0xad8464022213a618c96a1178a927a5ed15ad6949',
multiAssetProxy: '0xab8fbd189c569ccdee3a4d929bb7f557be4028f6',
staticCallProxy: '0xe1b97e47aa3796276033a5341e884d2ba46b6ac1',
erc1155Proxy: '0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d',
devUtils: '0x9a8590eebcfc53f0cc7ab5ebb8c079e9e7d4e0f5',
zrxVault: '0xffd161026865ad8b4ab28a76840474935eec4dfa',
staking: '0x3f46b98061a3e1e1f41dff296ec19402c298f8a9',
stakingProxy: '0xfaabcee42ab6b9c649794ac6c133711071897ee9',
erc20BridgeProxy: '0x599b340b5045436a99b1f0c718d30f5a0c8519dd',
},
4: {
exchangeV2: '0xbff9493f92a3df4b0429b6d00743b3cfb4c85831',
exchange: '0x3afe8aa355e086d898447732cfa5d931cfb2a792',
erc20Proxy: '0x2f5ae4f6106e89b4147651688a92256885c5f410',
erc721Proxy: '0x7656d773e11ff7383a14dcf09a9c50990481cd10',
zrxToken: '0x8080c7e4b81ecf23aa6f877cfbfd9b0c228c6ffa',
etherToken: '0xc778417e063141139fce010982780140aa0cd5ab',
assetProxyOwner: NULL_ADDRESS,
zeroExGovernor: '0x5d751aa855a1aee5fe44cf5350ed25b5727b66ae',
forwarder: '0xf36eabdfe986b35b62c8fd5a98a7f2aebb79b291',
orderValidator: NULL_ADDRESS,
dutchAuction: NULL_ADDRESS,
coordinatorRegistry: '0x1084b6a398e47907bae43fec3ff4b677db6e4fee',
coordinator: '0x9ae7a6e4e4d58c36b7aa573fc06ce46dd3cb0d44',
multiAssetProxy: '0xb34cde0ad3a83d04abebc0b66e75196f22216621',
staticCallProxy: '0xe1b97e47aa3796276033a5341e884d2ba46b6ac1',
erc1155Proxy: '0x19bb6caa3bc34d39e5a23cedfa3e6c7e7f3c931d',
devUtils: '0xfcbb258112485f18dd68f4b1016e48c23542fdc5',
zrxVault: '0xa5bf6ac73bc40790fc6ffc9dbbbce76c9176e224',
staking: '0x344d4f661a82afdd84d31456c291822d90d5dc3a',
stakingProxy: '0xc6ad5277ea225ac05e271eb14a7ebb480cd9dd9f',
erc20BridgeProxy: '0x31b8653642110f17bdb1f719901d7e7d49b08141',
},
42: {
erc20Proxy: '0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e',
erc721Proxy: '0x2a9127c745688a165106c11cd4d647d2220af821',
zrxToken: '0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa',
etherToken: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
exchangeV2: '0x30589010550762d2f0d06f650d8e8b6ade6dbf4b',
exchange: '0xca8b1626b3b7a0da722ca9f264c4630c7d34d3b8',
assetProxyOwner: NULL_ADDRESS,
zeroExGovernor: '0x3654e5363cd75c8974c76208137df9691e820e97',
forwarder: '0xd6330f9d2073e1889a295dd1dd2e28d42dec4bff',
orderValidator: NULL_ADDRESS,
dutchAuction: NULL_ADDRESS,
coordinatorRegistry: '0x09fb99968c016a3ff537bf58fb3d9fe55a7975d5',
coordinator: '0x10e0b1c2e6065ec7f290c7e3731264f9a2bf2b2d',
multiAssetProxy: '0xf6313a772c222f51c28f2304c0703b8cf5428fd8',
staticCallProxy: '0x48e94bdb9033640d45ea7c721e25f380f8bffa43',
erc1155Proxy: '0x64517fa2b480ba3678a2a3c0cf08ef7fd4fad36f',
devUtils: '0x58c4fbdf9222f10ad2bef8f4d374f209135e71a5',
zrxVault: '0xf36eabdfe986b35b62c8fd5a98a7f2aebb79b291',
staking: '0x89150f5eed50b3528f79bfb539f29d727f92821c',
stakingProxy: '0xbab9145f1d57cd4bb0c9aa2d1ece0a5b6e734d34',
erc20BridgeProxy: '0xfb2dd2a1366de37f7241c83d47da58fd503e2c64',
},
// NetworkId 50 represents our Ganache snapshot generated from migrations.
50: {
erc20Proxy: '0x1dc4c1cefef38a777b15aa20260a54e584b16c48',
erc721Proxy: '0x1d7022f5b17d2f8b695918fb48fa1089c9f85401',
erc1155Proxy: '0x6a4a62e5a7ed13c361b176a5f62c2ee620ac0df8',
zrxToken: '0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c',
etherToken: '0x0b1ba0af832d7c05fd64161e0db78e85978e8082',
exchangeV2: '0x48bacb9266a570d521063ef5dd96e61686dbe788',
exchange: '0x48bacb9266a570d521063ef5dd96e61686dbe788',
zeroExGovernor: NULL_ADDRESS,
assetProxyOwner: NULL_ADDRESS,
forwarder: NULL_ADDRESS,
orderValidator: NULL_ADDRESS,
dutchAuction: NULL_ADDRESS,
coordinatorRegistry: '0x1941ff73d1154774d87521d2d0aaad5d19c8df60',
coordinator: NULL_ADDRESS,
multiAssetProxy: '0xcfc18cec799fbd1793b5c43e773c98d4d61cc2db',
staticCallProxy: '0x6dfff22588be9b3ef8cf0ad6dc9b84796f9fb45f',
devUtils: '0x38ef19fdf8e8415f18c307ed71967e19aac28ba1',
zrxVault: NULL_ADDRESS,
staking: NULL_ADDRESS,
stakingProxy: NULL_ADDRESS,
erc20BridgeProxy: NULL_ADDRESS,
},
};

/**
* Used to get addresses of contracts that have been deployed to either the
* Ethereum mainnet or a supported testnet. Throws if there are no known
Expand All @@ -162,6 +43,8 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
* given networkId.
*/
export function getContractAddressesForNetworkOrThrow(networkId: NetworkId): ContractAddresses {
const networkToAddresses: { [networkId: number]: ContractAddresses } = addresses;

if (networkToAddresses[networkId] === undefined) {
throw new Error(`Unknown network id (${networkId}). No known 0x contracts have been deployed on this network.`);
}
Expand Down
9 changes: 7 additions & 2 deletions packages/contract-addresses/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": "."
"rootDir": ".",
"resolveJsonModule": true,
"esModuleInterop": true
},
"include": ["./src/**/*"]
"include": ["./src/**/*"],
"files": [
"./addresses.json"
]
}
41 changes: 38 additions & 3 deletions python-packages/contract_addresses/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# installed when you invoke this script

import subprocess # nosec
from shutil import rmtree
from os import environ, path
from shutil import copyfile, rmtree
from os import environ, path, remove
from sys import argv, exit # pylint: disable=redefined-builtin

from distutils.command.clean import clean
Expand All @@ -17,6 +17,38 @@
from setuptools.command.test import test as TestCommand


class PreInstallCommand(distutils.command.build_py.build_py):
"""Custom setuptools command class for pulling in addresses.json."""

description = (
"Pull in addresses.json from ../../packages/contract-addresses"
)

def run(self):
"""Copy over addresses.json."""
pkgdir = path.dirname(path.realpath(argv[0]))

destination_path = path.join(
pkgdir, "src", "zero_ex", "contract_addresses"
)

try:
remove(path.join(destination_path, "addresses.json"))
except FileNotFoundError:
pass
copyfile(
path.join(
pkgdir,
"..",
"..",
"packages",
"contract-addresses",
"addresses.json",
),
path.join(destination_path, "addresses.json"),
)


class LintCommand(distutils.command.build_py.build_py):
"""Custom setuptools command class for running linters."""

Expand Down Expand Up @@ -135,6 +167,7 @@ def run_tests(self):
author_email="[email protected]",
cmdclass={
"clean": CleanCommandExtension,
"pre_install": PreInstallCommand,
"lint": LintCommand,
"test": TestCommandExtension,
"test_publish": TestPublishCommand,
Expand All @@ -160,7 +193,9 @@ def run_tests(self):
]
},
python_requires=">=3.6, <4",
package_data={"zero_ex.contract_addresses": ["py.typed"]},
package_data={
"zero_ex.contract_addresses": ["py.typed", "addresses.json"]
},
package_dir={"": "src"},
license="Apache 2.0",
keywords=(
Expand Down
2 changes: 1 addition & 1 deletion python-packages/contract_addresses/src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Python zero_ex.contract_addresses
:members:
:show-inheritance:

.. autodata:: zero_ex.contract_addresses.NETWORK_TO_ADDRESSES
.. autodata:: zero_ex.contract_addresses.network_to_addresses
:annotation: : Dict[NetworkId, ContractAddresses]

Indices and tables
Expand Down
Loading

0 comments on commit 503b4f2

Please sign in to comment.