/audio/sox/files/

kages?h=dev' type='application/atom+xml'/>
aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-01-25 23:42:58 +0800
committerFabio Berger <me@fabioberger.com>2018-01-25 23:42:58 +0800
commit71d68f975cd7bc089f0cbef4e5888a73eab4ee42 (patch)
tree9482602fc23d2baec3fff1fb97750ad45adc6eca /packages
parentec3d8a034fe763d8255935985b1fb97aff6c177b (diff)
parentf58f0ddb67555c3f0c7252ea3e003824984c48ad (diff)
downloaddexon-0x-contracts-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar.gz
dexon-0x-contracts-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar.zst
dexon-0x-contracts-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.zip
Merge branch 'development' into feature/portal-ledger-support
* development: (437 commits) Publish Update yarn.lock Update the CHANGELOG Fix the bug making it impossible to specify the custom ZRX address Fix fill/cancel order by looking for NoError instead of empty blockchainErr given the BlockchainErrs type refactor Add a comment about a yarn bug Add our mainnet and kovan nodes as backups for Portal requests Fix bug hiding the user info from topBar Add dev-utils package to top level README Prettier newline Prettier Allow Token symbols to be alphanumeric Update CHANGELOG, rebase on development Should not -> cannot Reject negative amounts in isValidBaseUnitAmount Re-add changelog for 0x.js Fix prettier Update yarn.lock Move tests to a separate folder Change file layout ... # Conflicts: # packages/website/README.md
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/CHANGELOG.md200
-rw-r--r--packages/0x.js/README.md7
-rw-r--r--packages/0x.js/contract_templates/contract.mustache (renamed from packages/abi-gen-templates/contract.mustache)8
-rw-r--r--packages/0x.js/contract_templates/partials/call.mustache (renamed from packages/abi-gen-templates/partials/call.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/params.mustache (renamed from packages/abi-gen-templates/partials/params.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/return_type.mustache (renamed from packages/abi-gen-templates/partials/return_type.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/tx.mustache (renamed from packages/abi-gen-templates/partials/tx.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/typed_params.mustache (renamed from packages/abi-gen-templates/partials/typed_params.mustache)0
-rw-r--r--packages/0x.js/package.json199
-rw-r--r--packages/0x.js/scripts/postpublish.js24
-rwxr-xr-xpackages/0x.js/scripts/test_umd.sh6
-rw-r--r--packages/0x.js/src/0x.ts133
-rw-r--r--packages/0x.js/src/artifacts.ts16
-rw-r--r--packages/0x.js/src/artifacts/DummyToken.json22
-rw-r--r--packages/0x.js/src/artifacts/EtherToken.json484
-rw-r--r--packages/0x.js/src/artifacts/Exchange.json1206
-rw-r--r--packages/0x.js/src/artifacts/Token.json310
-rw-r--r--packages/0x.js/src/artifacts/TokenRegistry.json1072
-rw-r--r--packages/0x.js/src/artifacts/TokenTransferProxy.json330
-rw-r--r--packages/0x.js/src/artifacts/ZRX.json28
-rw-r--r--packages/0x.js/src/bignumber_config.ts11
-rw-r--r--packages/0x.js/src/contract_wrappers/contract_wrapper.ts121
-rw-r--r--packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts152
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts378
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/.gitignore6
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/base_contract.ts3
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/ether_token.ts363
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/exchange.ts730
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/token.ts232
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/token_registry.ts550
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts285
-rw-r--r--packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts42
-rw-r--r--packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts18
-rw-r--r--packages/0x.js/src/contract_wrappers/token_wrapper.ts169
-rw-r--r--packages/0x.js/src/globals.d.ts17
-rw-r--r--packages/0x.js/src/globalsAugment.d.ts6
-rw-r--r--packages/0x.js/src/index.ts12
-rw-r--r--packages/0x.js/src/order_watcher/event_watcher.ts40
-rw-r--r--packages/0x.js/src/order_watcher/expiration_watcher.ts74
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts155
-rw-r--r--packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts113
-rw-r--r--packages/0x.js/src/schemas/zero_ex_config_schema.ts7
-rw-r--r--packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts75
-rw-r--r--packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts43
-rw-r--r--packages/0x.js/src/types.ts88
-rw-r--r--packages/0x.js/src/utils/abi_decoder.ts33
-rw-r--r--packages/0x.js/src/utils/assert.ts28
-rw-r--r--packages/0x.js/src/utils/constants.ts3
-rw-r--r--packages/0x.js/src/utils/decorators.ts94
-rw-r--r--packages/0x.js/src/utils/exchange_transfer_simulator.ts83
-rw-r--r--packages/0x.js/src/utils/filter_utils.ts26
-rw-r--r--packages/0x.js/src/utils/interval_utils.ts20
-rw-r--r--packages/0x.js/src/utils/order_state_utils.ts89
-rw-r--r--packages/0x.js/src/utils/order_validation_utils.ts172
-rw-r--r--packages/0x.js/src/utils/signature_utils.ts7
-rw-r--r--packages/0x.js/src/utils/utils.ts45
-rw-r--r--packages/0x.js/test/0x.js_test.ts93
-rw-r--r--packages/0x.js/test/artifacts_test.ts8
-rw-r--r--packages/0x.js/test/assert_test.ts29
-rw-r--r--packages/0x.js/test/ether_token_wrapper_test.ts286
-rw-r--r--packages/0x.js/test/event_watcher_test.ts34
-rw-r--r--packages/0x.js/test/exchange_transfer_simulator_test.ts68
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts755
-rw-r--r--packages/0x.js/test/expiration_watcher_test.ts66
-rw-r--r--packages/0x.js/test/order_state_watcher_test.ts290
-rw-r--r--packages/0x.js/test/order_validation_test.ts381
-rw-r--r--packages/0x.js/test/remaining_fillable_calculator_test.ts154
-rw-r--r--packages/0x.js/test/subscription_test.ts74
-rw-r--r--packages/0x.js/test/token_registry_wrapper_test.ts22
-rw-r--r--packages/0x.js/test/token_transfer_proxy_wrapper_test.ts9
-rw-r--r--packages/0x.js/test/token_wrapper_test.ts230
-rw-r--r--packages/0x.js/test/utils/blockchain_lifecycle.ts26
-rw-r--r--packages/0x.js/test/utils/constants.ts7
-rw-r--r--packages/0x.js/test/utils/fill_scenarios.ts234
-rw-r--r--packages/0x.js/test/utils/order_factory.ts15
-rw-r--r--packages/0x.js/test/utils/report_callback_errors.ts60
-rw-r--r--packages/0x.js/test/utils/subproviders/empty_wallet_subprovider.ts4
-rw-r--r--packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts10
-rw-r--r--packages/0x.js/test/utils/token_utils.ts24
-rw-r--r--packages/0x.js/test/utils/web3_factory.ts23
-rw-r--r--packages/0x.js/tsconfig.json34
-rw-r--r--packages/0x.js/tslint.json4
-rw-r--r--packages/0x.js/webpack.config.js4
-rw-r--r--packages/abi-gen-templates/package.json15
-rw-r--r--packages/abi-gen/CHANGELOG.md7
-rw-r--r--packages/abi-gen/README.md21
-rw-r--r--packages/abi-gen/package.json92
-rw-r--r--packages/abi-gen/scripts/postpublish.js15
-rw-r--r--packages/abi-gen/src/index.ts28
-rw-r--r--packages/abi-gen/src/types.ts8
-rw-r--r--packages/abi-gen/src/utils.ts37
-rw-r--r--packages/abi-gen/tsconfig.json20
-rw-r--r--packages/abi-gen/tslint.json4
-rw-r--r--packages/assert/CHANGELOG.md4
-rw-r--r--packages/assert/README.md53
-rw-r--r--packages/assert/package.json87
-rw-r--r--packages/assert/scripts/postpublish.js5
-rw-r--r--packages/assert/src/globals.d.ts4
-rw-r--r--packages/assert/src/index.ts39
-rw-r--r--packages/assert/test/assert_test.ts162
-rw-r--r--packages/assert/tsconfig.json21
-rw-r--r--packages/assert/tslint.json4
-rw-r--r--packages/chai-as-promised-typescript-typings/CHANGELOG.md3
-rw-r--r--packages/chai-as-promised-typescript-typings/README.md43
-rw-r--r--packages/chai-as-promised-typescript-typings/index.d.ts268
-rw-r--r--packages/chai-as-promised-typescript-typings/package.json23
-rw-r--r--packages/chai-as-promised-typescript-typings/scripts/postpublish.js15
-rw-r--r--packages/chai-as-promised-typescript-typings/tslint.json3
-rw-r--r--packages/chai-typescript-typings/CHANGELOG.md3
-rw-r--r--packages/chai-typescript-typings/README.md43
-rw-r--r--packages/chai-typescript-typings/index.d.ts1254
-rw-r--r--packages/chai-typescript-typings/package.json16
-rw-r--r--packages/chai-typescript-typings/scripts/postpublish.js15
-rw-r--r--packages/chai-typescript-typings/tslint.json3
-rw-r--r--packages/connect/CHANGELOG.md22
-rw-r--r--packages/connect/README.md51
-rw-r--r--packages/connect/package.json134
-rw-r--r--packages/connect/scripts/postpublish.js19
-rw-r--r--packages/connect/src/http_client.ts77
-rw-r--r--packages/connect/src/index.ts4
-rw-r--r--packages/connect/src/schemas/relayer_fees_request_schema.ts4
-rw-r--r--packages/connect/src/schemas/relayer_orderbook_request_schema.ts4
-rw-r--r--packages/connect/src/schemas/relayer_orders_request_schema.ts20
-rw-r--r--packages/connect/src/schemas/relayer_token_pairs_request_schema.ts4
-rw-r--r--packages/connect/src/schemas/schemas.ts12
-rw-r--r--packages/connect/src/types.ts25
-rw-r--r--packages/connect/src/utils/orderbook_channel_message_parser.ts37
-rw-r--r--packages/connect/src/utils/orderbook_channel_message_parsers.ts41
-rw-r--r--packages/connect/src/utils/relayer_response_json_parsers.ts37
-rw-r--r--packages/connect/src/utils/type_converters.ts29
-rw-r--r--packages/connect/src/ws_orderbook_channel.ts66
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/fees.ts4
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts2
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/orderbook.json2
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/orderbook.ts2
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/orders.ts2
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts4
-rw-r--r--packages/connect/test/http_client_test.ts63
-rw-r--r--packages/connect/test/orderbook_channel_message_parsers_test.ts32
-rw-r--r--packages/connect/test/ws_orderbook_channel_test.ts40
-rw-r--r--packages/connect/tsconfig.json21
-rw-r--r--packages/connect/tslint.json4
-rw-r--r--packages/contracts/README.md73
-rw-r--r--packages/contracts/build/contracts/DummyToken.json6
-rw-r--r--packages/contracts/build/contracts/EtherToken.json18
-rw-r--r--packages/contracts/build/contracts/Exchange.json18
-rw-r--r--packages/contracts/build/contracts/MaliciousToken.json6
-rw-r--r--packages/contracts/build/contracts/Migrations.json4
-rw-r--r--packages/contracts/build/contracts/Mintable.json4
-rw-r--r--packages/contracts/build/contracts/MultiSigWallet.json4
-rw-r--r--packages/contracts/build/contracts/MultiSigWalletWithTimeLock.json8
-rw-r--r--packages/contracts/build/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json6
-rw-r--r--packages/contracts/build/contracts/Ownable.json4
-rw-r--r--packages/contracts/build/contracts/SafeMath.json4
-rw-r--r--packages/contracts/build/contracts/StandardToken.json4
-rw-r--r--packages/contracts/build/contracts/Token.json4
-rw-r--r--packages/contracts/build/contracts/TokenRegistry.json18
-rw-r--r--packages/contracts/build/contracts/TokenTransferProxy.json18
-rw-r--r--packages/contracts/build/contracts/ZRXToken.json18
-rw-r--r--packages/contracts/contracts/Exchange.sol7
-rw-r--r--packages/contracts/contracts/TokenRegistry.sol5
-rw-r--r--packages/contracts/contracts/TokenTransferProxy.sol7
-rw-r--r--packages/contracts/contracts/base/SafeMath.sol41
-rw-r--r--packages/contracts/contracts/multisig/MultiSigWallet.sol (renamed from packages/contracts/contracts/base/MultiSigWallet.sol)3
-rw-r--r--packages/contracts/contracts/multisig/MultiSigWalletWithTimeLock.sol (renamed from packages/contracts/contracts/MultiSigWalletWithTimeLock.sol)5
-rw-r--r--packages/contracts/contracts/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol (renamed from packages/contracts/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol)3
-rw-r--r--packages/contracts/contracts/test/DummyToken.sol9
-rw-r--r--packages/contracts/contracts/test/DummyToken_v2.sol38
-rw-r--r--packages/contracts/contracts/test/MaliciousToken.sol9
-rw-r--r--packages/contracts/contracts/test/Mintable.sol9
-rw-r--r--packages/contracts/contracts/test/Mintable_v2.sol19
-rw-r--r--packages/contracts/contracts/tokens/ERC20Token.sol59
-rw-r--r--packages/contracts/contracts/tokens/EtherToken.sol56
-rw-r--r--packages/contracts/contracts/tokens/StandardToken.sol (renamed from packages/contracts/contracts/base/StandardToken.sol)3
-rw-r--r--packages/contracts/contracts/tokens/Token.sol (renamed from packages/contracts/contracts/base/Token.sol)3
-rw-r--r--packages/contracts/contracts/tokens/Token_v2.sol36
-rw-r--r--packages/contracts/contracts/tokens/UnlimitedAllowanceToken.sol5
-rw-r--r--packages/contracts/contracts/tokens/UnlimitedAllowanceToken_v2.sol47
-rw-r--r--packages/contracts/contracts/tokens/WETH9.sol756
-rw-r--r--packages/contracts/contracts/tokens/ZRXToken.sol3
-rw-r--r--packages/contracts/contracts/utils/Ownable.sol (renamed from packages/contracts/contracts/base/Ownable.sol)3
-rw-r--r--packages/contracts/contracts/utils/Ownable_v2.sol33
-rw-r--r--packages/contracts/contracts/utils/SafeMath.sol74
-rw-r--r--packages/contracts/contracts/utils/SafeMath_v2.sol74
-rw-r--r--packages/contracts/deploy/migrations/migrate.ts106
-rw-r--r--packages/contracts/deploy/test/fixtures/exchange_bin.ts4
-rw-r--r--packages/contracts/globals.d.ts8
-rw-r--r--packages/contracts/globalsAugment.d.ts4
-rw-r--r--packages/contracts/migrations/1_initial_migration.ts4
-rw-r--r--packages/contracts/migrations/2_deploy_independent_contracts.ts27
-rw-r--r--packages/contracts/migrations/3_register_tokens.ts155
-rw-r--r--packages/contracts/migrations/4_configure_proxy.ts41
-rw-r--r--packages/contracts/migrations/5_transfer_ownership.ts29
-rw-r--r--packages/contracts/migrations/config/multisig_sample.ts2
-rw-r--r--packages/contracts/migrations/config/token_info.ts4
-rw-r--r--packages/contracts/package.json139
-rw-r--r--packages/contracts/test/ts/ether_token.ts38
-rw-r--r--packages/contracts/test/ts/exchange/core.ts586
-rw-r--r--packages/contracts/test/ts/exchange/helpers.ts24
-rw-r--r--packages/contracts/test/ts/exchange/wrapper.ts255
-rw-r--r--packages/contracts/test/ts/multi_sig_with_time_lock.ts36
-rw-r--r--packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts61
-rw-r--r--packages/contracts/test/ts/token_registry.ts102
-rw-r--r--packages/contracts/test/ts/token_transfer_proxy/auth.ts46
-rw-r--r--packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts52
-rw-r--r--packages/contracts/test/ts/unlimited_allowance_token.ts (renamed from packages/contracts/test/ts/unlimitedAllowanceToken.ts)44
-rw-r--r--packages/contracts/test/ts/unlimited_allowance_token_v2.ts141
-rw-r--r--packages/contracts/test/ts/zrx_token.ts (renamed from packages/contracts/test/ts/zrxToken.ts)59
-rw-r--r--packages/contracts/tsconfig.json16
-rw-r--r--packages/contracts/tslint.json4
-rw-r--r--packages/contracts/util/artifacts.ts7
-rw-r--r--packages/contracts/util/balances.ts19
-rw-r--r--packages/contracts/util/bignumber_config.ts11
-rw-r--r--packages/contracts/util/constants.ts5
-rw-r--r--packages/contracts/util/crypto.ts5
-rw-r--r--packages/contracts/util/exchange_wrapper.ts134
-rw-r--r--packages/contracts/util/formatters.ts82
-rw-r--r--packages/contracts/util/multi_sig_wrapper.ts23
-rw-r--r--packages/contracts/util/order.ts17
-rw-r--r--packages/contracts/util/order_factory.ts29
-rw-r--r--packages/contracts/util/rpc.ts43
-rw-r--r--packages/contracts/util/token_registry_wrapper.ts16
-rw-r--r--packages/contracts/util/types.ts20
-rw-r--r--packages/deployer/README.md73
-rw-r--r--packages/deployer/package.json43
-rw-r--r--packages/deployer/scripts/postpublish.js39
-rw-r--r--packages/deployer/src/cli.ts (renamed from packages/contracts/deploy/cli.ts)51
-rw-r--r--packages/deployer/src/commands.ts (renamed from packages/contracts/deploy/src/commands.ts)8
-rw-r--r--packages/deployer/src/compiler.ts (renamed from packages/contracts/deploy/src/compiler.ts)100
-rw-r--r--packages/deployer/src/deployer.ts (renamed from packages/contracts/deploy/src/deployer.ts)88
-rw-r--r--packages/deployer/src/globals.d.ts8
-rw-r--r--packages/deployer/src/migrations/config/multisig_sample.ts10
-rw-r--r--packages/deployer/src/migrations/config/token_info.ts (renamed from packages/contracts/deploy/migrations/config/token_info.ts)4
-rw-r--r--packages/deployer/src/migrations/migrate.ts90
-rw-r--r--packages/deployer/src/solc/bin_paths.ts (renamed from packages/contracts/deploy/solc/bin_paths.ts)2
-rw-r--r--packages/deployer/src/solc/solc_bin/soljson-v0.4.10+commit.f0d539ae.js (renamed from packages/contracts/deploy/solc/solc_bin/soljson-v0.4.10+commit.f0d539ae.js)0
-rw-r--r--packages/deployer/src/solc/solc_bin/soljson-v0.4.11+commit.68ef5810.js (renamed from packages/contracts/deploy/solc/solc_bin/soljson-v0.4.11+commit.68ef5810.js)0
-rw-r--r--packages/deployer/src/solc/solc_bin/soljson-v0.4.12+commit.194ff033.js (renamed from packages/contracts/deploy/solc/solc_bin/soljson-v0.4.12+commit.194ff033.js)0
-rw-r--r--packages/deployer/src/solc/solc_bin/soljson-v0.4.13+commit.fb4cb1a.js (renamed from packages/contracts/deploy/solc/solc_bin/soljson-v0.4.13+commit.fb4cb1a.js)0
-rw-r--r--packages/deployer/src/solc/solc_bin/soljson-v0.4.14+commit.c2215d46.js (renamed from packages/contracts/deploy/solc/solc_bin/soljson-v0.4.14+commit.c2215d46.js)0
-rw-r--r--packages/deployer/src/solc/solc_bin/soljson-v0.4.15+commit.bbb8e64f.js (renamed from packages/contracts/deploy/solc/solc_bin/soljson-v0.4.15+commit.bbb8e64f.js)0
-rw-r--r--packages/deployer/src/solc/solc_bin/soljson-v0.4.16+commit.d7661dd9.js (renamed from packages/contracts/deploy/solc/solc_bin/soljson-v0.4.16+commit.d7661dd9.js)0
-rw-r--r--packages/deployer/src/solc/solc_bin/soljson-v0.4.17+commit.bdeb9e52.js (renamed from packages/contracts/deploy/solc/solc_bin/soljson-v0.4.17+commit.bdeb9e52.js)0
-rw-r--r--packages/deployer/src/solc/solc_bin/soljson-v0.4.18+commit.9cf6e910.js (renamed from packages/contracts/deploy/solc/solc_bin/soljson-v0.4.18+commit.9cf6e910.js)0
-rw-r--r--packages/deployer/src/types.ts23
-rw-r--r--packages/deployer/src/utils/constants.ts (renamed from packages/contracts/deploy/src/utils/constants.ts)0
-rw-r--r--packages/deployer/src/utils/contract.ts (renamed from packages/contracts/deploy/src/utils/contract.ts)56
-rw-r--r--packages/deployer/src/utils/encoder.ts (renamed from packages/contracts/deploy/src/utils/encoder.ts)2
-rw-r--r--packages/deployer/src/utils/fs_wrapper.ts (renamed from packages/contracts/deploy/src/utils/fs_wrapper.ts)2
-rw-r--r--packages/deployer/src/utils/types.ts (renamed from packages/contracts/deploy/src/utils/types.ts)5
-rw-r--r--packages/deployer/src/utils/utils.ts (renamed from packages/contracts/deploy/src/utils/utils.ts)0
-rw-r--r--packages/deployer/test/deploy_test.ts (renamed from packages/contracts/deploy/test/deploy_test.ts)12
-rw-r--r--packages/deployer/test/fixtures/contracts/Exchange.sol (renamed from packages/contracts/deploy/test/fixtures/contracts/Exchange.sol)0
-rw-r--r--packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol (renamed from packages/contracts/deploy/test/fixtures/contracts/TokenTransferProxy.sol)0
-rw-r--r--packages/deployer/test/fixtures/contracts/base/Ownable.sol (renamed from packages/contracts/deploy/test/fixtures/contracts/base/Ownable.sol)0
-rw-r--r--packages/deployer/test/fixtures/contracts/base/SafeMath.sol (renamed from packages/contracts/deploy/test/fixtures/contracts/base/SafeMath.sol)0
-rw-r--r--packages/deployer/test/fixtures/contracts/base/Token.sol (renamed from packages/contracts/deploy/test/fixtures/contracts/base/Token.sol)0
-rw-r--r--packages/deployer/test/fixtures/exchange_bin.ts4
-rw-r--r--packages/deployer/test/util/constants.ts (renamed from packages/contracts/deploy/test/util/constants.ts)4
-rw-r--r--packages/deployer/tsconfig.json16
-rw-r--r--packages/dev-utils/README.md9
-rw-r--r--packages/dev-utils/package.json37
-rw-r--r--packages/dev-utils/scripts/postpublish.js15
-rw-r--r--packages/dev-utils/src/blockchain_lifecycle.ts23
-rw-r--r--packages/dev-utils/src/index.ts2
-rw-r--r--packages/dev-utils/src/rpc.ts (renamed from packages/0x.js/test/utils/rpc.ts)42
-rw-r--r--packages/dev-utils/tsconfig.json11
-rw-r--r--packages/dev-utils/tslint.json3
-rw-r--r--packages/json-schemas/CHANGELOG.md8
-rw-r--r--packages/json-schemas/README.md50
-rw-r--r--packages/json-schemas/package.json87
-rw-r--r--packages/json-schemas/schemas/block_range_schema.ts (renamed from packages/json-schemas/schemas/subscription_opts_schema.ts)8
-rw-r--r--packages/json-schemas/schemas/ec_signature_schema.ts4
-rw-r--r--packages/json-schemas/schemas/index_filter_values_schema.ts6
-rw-r--r--packages/json-schemas/schemas/order_cancel_schema.ts4
-rw-r--r--packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts4
-rw-r--r--packages/json-schemas/schemas/order_fill_requests_schema.ts4
-rw-r--r--packages/json-schemas/schemas/order_schemas.ts38
-rw-r--r--packages/json-schemas/schemas/relayer_api_error_response_schema.ts10
-rw-r--r--packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts27
-rw-r--r--packages/json-schemas/schemas/relayer_api_fees_response_schema.ts6
-rw-r--r--packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts16
-rw-r--r--packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts12
-rw-r--r--packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts8
-rw-r--r--packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts4
-rw-r--r--packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts12
-rw-r--r--packages/json-schemas/schemas/signed_orders_schema.ts2
-rw-r--r--packages/json-schemas/schemas/token_schema.ts8
-rw-r--r--packages/json-schemas/schemas/tx_data_schema.ts19
-rw-r--r--packages/json-schemas/scripts/postpublish.js5
-rw-r--r--packages/json-schemas/src/index.ts6
-rw-r--r--packages/json-schemas/src/schema_validator.ts14
-rw-r--r--packages/json-schemas/src/schemas.ts75
-rw-r--r--packages/json-schemas/test/schema_test.ts158
-rw-r--r--packages/json-schemas/tsconfig.json20
-rw-r--r--packages/json-schemas/tslint.json4
-rw-r--r--packages/kovan-faucets/Dockerfile13
-rw-r--r--packages/kovan-faucets/README.md78
-rw-r--r--packages/kovan-faucets/gulpfile.js92
-rw-r--r--packages/kovan-faucets/package.json43
-rw-r--r--packages/kovan-faucets/scripts/postpublish.js15
-rw-r--r--packages/kovan-faucets/src/ts/configs.ts12
-rw-r--r--packages/kovan-faucets/src/ts/error_reporter.ts40
-rw-r--r--packages/kovan-faucets/src/ts/ether_request_queue.ts27
-rw-r--r--packages/kovan-faucets/src/ts/global.d.ts26
-rw-r--r--packages/kovan-faucets/src/ts/handler.ts93
-rw-r--r--packages/kovan-faucets/src/ts/id_management.ts23
-rw-r--r--packages/kovan-faucets/src/ts/request_queue.ts56
-rw-r--r--packages/kovan-faucets/src/ts/server.ts28
-rw-r--r--packages/kovan-faucets/src/ts/utils.ts7
-rw-r--r--packages/kovan-faucets/src/ts/zrx_request_queue.ts45
-rw-r--r--packages/kovan-faucets/tsconfig.json7
-rw-r--r--packages/kovan-faucets/tslint.json3
-rw-r--r--packages/monorepo-scripts/README.md53
-rw-r--r--packages/monorepo-scripts/package.json64
-rw-r--r--packages/monorepo-scripts/scripts/postpublish.js15
-rw-r--r--packages/monorepo-scripts/src/deps_versions.ts2
-rw-r--r--packages/monorepo-scripts/tsconfig.json16
-rw-r--r--packages/monorepo-scripts/tslint.json4
-rw-r--r--packages/subproviders/CHANGELOG.md13
-rw-r--r--packages/subproviders/README.md87
-rw-r--r--packages/subproviders/package.json104
-rw-r--r--packages/subproviders/scripts/postpublish.js14
-rw-r--r--packages/subproviders/src/globals.d.ts55
-rw-r--r--packages/subproviders/src/index.ts16
-rw-r--r--packages/subproviders/src/subproviders/injected_web3.ts16
-rw-r--r--packages/subproviders/src/subproviders/ledger.ts129
-rw-r--r--packages/subproviders/src/subproviders/redundant_rpc.ts31
-rw-r--r--packages/subproviders/src/subproviders/subprovider.ts22
-rw-r--r--packages/subproviders/src/types.ts12
-rw-r--r--packages/subproviders/test/integration/ledger_subprovider_test.ts44
-rw-r--r--packages/subproviders/test/unit/ledger_subprovider_test.ts84
-rw-r--r--packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts20
-rw-r--r--packages/subproviders/tsconfig.json33
-rw-r--r--packages/subproviders/tslint.json4
-rw-r--r--packages/tslint-config/CHANGELOG.md13
-rw-r--r--packages/tslint-config/README.md57
-rw-r--r--packages/tslint-config/package.json81
-rw-r--r--packages/tslint-config/rules/asyncSuffixRule.ts10
-rw-r--r--packages/tslint-config/rules/underscorePrivatesRule.ts61
-rw-r--r--packages/tslint-config/rules/walkers/async_suffix.ts26
-rw-r--r--packages/tslint-config/tsconfig.json7
-rw-r--r--packages/tslint-config/tslint.json202
-rw-r--r--packages/types/CHANGELOG.md3
-rw-r--r--packages/types/README.md45
-rw-r--r--packages/types/package.json59
-rw-r--r--packages/types/scripts/postpublish.js14
-rw-r--r--packages/types/src/index.ts10
-rw-r--r--packages/types/tsconfig.json19
-rw-r--r--packages/types/tslint.json4
-rw-r--r--packages/utils/CHANGELOG.md6
-rw-r--r--packages/utils/README.md43
-rw-r--r--packages/utils/package.json63
-rw-r--r--packages/utils/scripts/postpublish.js14
-rw-r--r--packages/utils/src/address_utils.ts36
-rw-r--r--packages/utils/src/class_utils.ts (renamed from packages/0x.js/src/utils/class_utils.ts)0
-rw-r--r--packages/utils/src/configured_bignumber.ts9
-rw-r--r--packages/utils/src/index.ts6
-rw-r--r--packages/utils/src/interval_utils.ts37
-rw-r--r--packages/utils/src/promisify.ts11
-rw-r--r--packages/utils/tsconfig.json18
-rw-r--r--packages/utils/tslint.json4
-rw-r--r--packages/web3-typescript-typings/.gitignore2
-rw-r--r--packages/web3-typescript-typings/CHANGELOG.md6
-rw-r--r--packages/web3-typescript-typings/README.md49
-rw-r--r--packages/web3-typescript-typings/index.d.ts422
-rw-r--r--packages/web3-typescript-typings/package.json32
-rw-r--r--packages/web3-typescript-typings/scripts/postpublish.js15
-rw-r--r--packages/web3-typescript-typings/tslint.json3
-rw-r--r--packages/web3-typescript-typings/yarn.lock197
-rw-r--r--packages/web3-wrapper/CHANGELOG.md3
-rw-r--r--packages/web3-wrapper/README.md55
-rw-r--r--packages/web3-wrapper/package.json69
-rw-r--r--packages/web3-wrapper/scripts/postpublish.js14
-rw-r--r--packages/web3-wrapper/src/index.ts99
-rw-r--r--packages/web3-wrapper/tsconfig.json19
-rw-r--r--packages/web3-wrapper/tslint.json4
-rw-r--r--packages/website/CHANGELOG.md5
-rw-r--r--packages/website/README.md62
-rw-r--r--packages/website/contracts/Mintable.json343
-rw-r--r--packages/website/md/docs/0xjs/async.md9
-rw-r--r--packages/website/md/docs/0xjs/installation.md4
-rw-r--r--packages/website/md/docs/connect/installation.md2
-rw-r--r--packages/website/md/docs/smart_contracts/introduction.md8
-rw-r--r--packages/website/package.json209
-rw-r--r--packages/website/public/images/ether.pngbin2312 -> 4235 bytes
-rw-r--r--packages/website/public/images/social/discourse.pngbin0 -> 1454 bytes
-rw-r--r--packages/website/public/images/team/jacob.jpgbin0 -> 1177087 bytes
-rw-r--r--packages/website/public/images/team/tom.jpgbin0 -> 41810 bytes
-rw-r--r--packages/website/public/images/token_icons/augur.pngbin146258 -> 23161 bytes
-rw-r--r--packages/website/public/images/token_icons/default.pngbin17037 -> 20225 bytes
-rw-r--r--packages/website/public/images/token_icons/district0x.pngbin67267 -> 25007 bytes
-rw-r--r--packages/website/public/images/token_icons/ether_erc20.pngbin69772 -> 7584 bytes
-rw-r--r--packages/website/public/images/token_icons/firstblood.jpgbin72909 -> 7872 bytes
-rw-r--r--packages/website/public/images/token_icons/qtum.pngbin169182 -> 32496 bytes
-rw-r--r--packages/website/public/images/token_icons/zero_ex.pngbin162879 -> 17905 bytes
-rw-r--r--packages/website/public/images/wrapped_eth_gray.pngbin0 -> 7649 bytes
-rw-r--r--packages/website/ts/blockchain.ts656
-rw-r--r--packages/website/ts/components/dialogs/blockchain_err_dialog.tsx133
-rw-r--r--packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx172
-rw-r--r--packages/website/ts/components/dialogs/ledger_config_dialog.tsx142
-rw-r--r--packages/website/ts/components/dialogs/portal_disclaimer_dialog.tsx35
-rw-r--r--packages/website/ts/components/dialogs/send_dialog.tsx51
-rw-r--r--packages/website/ts/components/dialogs/track_token_confirmation_dialog.tsx37
-rw-r--r--packages/website/ts/components/dialogs/u2f_not_supported_dialog.tsx26
-rw-r--r--packages/website/ts/components/dialogs/wrapped_eth_section_notice_dialog.tsx33
-rw-r--r--packages/website/ts/components/eth_weth_conversion_button.tsx90
-rw-r--r--packages/website/ts/components/eth_wrappers.tsx374
-rw-r--r--packages/website/ts/components/fill_order.tsx330
-rw-r--r--packages/website/ts/components/fill_order_json.tsx43
-rw-r--r--packages/website/ts/components/fill_warning_dialog.tsx18
-rw-r--r--packages/website/ts/components/flash_messages/token_send_completed.tsx24
-rw-r--r--packages/website/ts/components/flash_messages/transaction_submitted.tsx7
-rw-r--r--packages/website/ts/components/footer.tsx169
-rw-r--r--packages/website/ts/components/generate_order/asset_picker.tsx147
-rw-r--r--packages/website/ts/components/generate_order/generate_order_form.tsx159
-rw-r--r--packages/website/ts/components/generate_order/new_token_form.tsx92
-rw-r--r--packages/website/ts/components/inputs/address_input.tsx27
-rw-r--r--packages/website/ts/components/inputs/allowance_toggle.tsx35
-rw-r--r--packages/website/ts/components/inputs/balance_bounded_input.tsx85
-rw-r--r--packages/website/ts/components/inputs/eth_amount_input.tsx32
-rw-r--r--packages/website/ts/components/inputs/expiration_input.tsx46
-rw-r--r--packages/website/ts/components/inputs/hash_input.tsx20
-rw-r--r--packages/website/ts/components/inputs/identicon_address_input.tsx23
-rw-r--r--packages/website/ts/components/inputs/token_amount_input.tsx43
-rw-r--r--packages/website/ts/components/inputs/token_input.tsx39
-rw-r--r--packages/website/ts/components/order_json.tsx143
-rw-r--r--packages/website/ts/components/portal.tsx281
-rw-r--r--packages/website/ts/components/portal_menu.tsx31
-rw-r--r--packages/website/ts/components/send_button.tsx36
-rw-r--r--packages/website/ts/components/token_balances.tsx436
-rw-r--r--packages/website/ts/components/top_bar.tsx242
-rw-r--r--packages/website/ts/components/top_bar_menu_item.tsx33
-rw-r--r--packages/website/ts/components/track_token_confirmation.tsx34
-rw-r--r--packages/website/ts/components/trade_history/trade_history.tsx44
-rw-r--r--packages/website/ts/components/trade_history/trade_history_item.tsx81
-rw-r--r--packages/website/ts/components/ui/alert.tsx12
-rw-r--r--packages/website/ts/components/ui/badge.tsx9
-rw-r--r--packages/website/ts/components/ui/copy_icon.tsx68
-rw-r--r--packages/website/ts/components/ui/drop_down_menu_item.tsx71
-rw-r--r--packages/website/ts/components/ui/ethereum_address.tsx15
-rw-r--r--packages/website/ts/components/ui/etherscan_icon.tsx35
-rw-r--r--packages/website/ts/components/ui/fake_text_field.tsx7
-rw-r--r--packages/website/ts/components/ui/flash_message.tsx8
-rw-r--r--packages/website/ts/components/ui/help_tooltip.tsx4
-rw-r--r--packages/website/ts/components/ui/identicon.tsx18
-rw-r--r--packages/website/ts/components/ui/input_label.tsx8
-rw-r--r--packages/website/ts/components/ui/labeled_switcher.tsx73
-rw-r--r--packages/website/ts/components/ui/lifecycle_raised_button.tsx38
-rw-r--r--packages/website/ts/components/ui/loading.tsx21
-rw-r--r--packages/website/ts/components/ui/menu_item.tsx13
-rw-r--r--packages/website/ts/components/ui/party.tsx131
-rw-r--r--packages/website/ts/components/ui/required_label.tsx6
-rw-r--r--packages/website/ts/components/ui/simple_loading.tsx12
-rw-r--r--packages/website/ts/components/ui/swap_icon.tsx16
-rw-r--r--packages/website/ts/components/ui/token_icon.tsx14
-rw-r--r--packages/website/ts/components/visual_order.tsx19
-rw-r--r--packages/website/ts/containers/connect_documentation.tsx54
-rw-r--r--packages/website/ts/containers/generate_order_form.tsx18
-rw-r--r--packages/website/ts/containers/portal.tsx65
-rw-r--r--packages/website/ts/containers/smart_contracts_documentation.tsx57
-rw-r--r--packages/website/ts/containers/zero_ex_js_documentation.tsx61
-rw-r--r--packages/website/ts/globals.d.ts31
-rw-r--r--packages/website/ts/index.tsx106
-rw-r--r--packages/website/ts/lazy_component.tsx19
-rw-r--r--packages/website/ts/local_storage/tracked_token_storage.ts27
-rw-r--r--packages/website/ts/local_storage/trade_history_storage.tsx24
-rw-r--r--packages/website/ts/pages/about/about.tsx163
-rw-r--r--packages/website/ts/pages/about/profile.tsx56
-rw-r--r--packages/website/ts/pages/documentation/comment.tsx9
-rw-r--r--packages/website/ts/pages/documentation/custom_enum.tsx9
-rw-r--r--packages/website/ts/pages/documentation/docs_info.ts31
-rw-r--r--packages/website/ts/pages/documentation/documentation.tsx288
-rw-r--r--packages/website/ts/pages/documentation/enum.tsx10
-rw-r--r--packages/website/ts/pages/documentation/event_definition.tsx50
-rw-r--r--packages/website/ts/pages/documentation/interface.tsx32
-rw-r--r--packages/website/ts/pages/documentation/method_block.tsx128
-rw-r--r--packages/website/ts/pages/documentation/method_signature.tsx58
-rw-r--r--packages/website/ts/pages/documentation/source_link.tsx18
-rw-r--r--packages/website/ts/pages/documentation/type.tsx134
-rw-r--r--packages/website/ts/pages/documentation/type_definition.tsx82
-rw-r--r--packages/website/ts/pages/faq/faq.tsx384
-rw-r--r--packages/website/ts/pages/faq/question.tsx21
-rw-r--r--packages/website/ts/pages/landing/landing.tsx574
-rw-r--r--packages/website/ts/pages/not_found.tsx16
-rw-r--r--packages/website/ts/pages/shared/anchor_title.tsx27
-rw-r--r--packages/website/ts/pages/shared/markdown_code_block.tsx25
-rw-r--r--packages/website/ts/pages/shared/markdown_section.tsx29
-rw-r--r--packages/website/ts/pages/shared/nested_sidebar_menu.tsx127
-rw-r--r--packages/website/ts/pages/shared/section_header.tsx16
-rw-r--r--packages/website/ts/pages/shared/version_drop_down.tsx20
-rw-r--r--packages/website/ts/pages/wiki/wiki.tsx126
-rw-r--r--packages/website/ts/redux/dispatcher.ts194
-rw-r--r--packages/website/ts/redux/reducer.ts302
-rw-r--r--packages/website/ts/schemas/order_schema.ts27
-rw-r--r--packages/website/ts/schemas/order_taker_schema.ts8
-rw-r--r--packages/website/ts/schemas/signature_data_schema.ts8
-rw-r--r--packages/website/ts/schemas/token_schema.ts8
-rw-r--r--packages/website/ts/schemas/validator.ts24
-rw-r--r--packages/website/ts/types.ts255
-rw-r--r--packages/website/ts/utils/colors.ts43
-rw-r--r--packages/website/ts/utils/configs.ts128
-rw-r--r--packages/website/ts/utils/constants.ts240
-rw-r--r--packages/website/ts/utils/doc_utils.ts20
-rw-r--r--packages/website/ts/utils/doxity_utils.ts74
-rw-r--r--packages/website/ts/utils/error_reporter.ts12
-rw-r--r--packages/website/ts/utils/mui_theme.ts35
-rw-r--r--packages/website/ts/utils/typedoc_utils.ts212
-rw-r--r--packages/website/ts/utils/utils.ts110
-rw-r--r--packages/website/ts/web3_wrapper.ts163
-rw-r--r--packages/website/tsconfig.json16
-rw-r--r--packages/website/tslint.json16
512 files changed, 19034 insertions, 14417 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index 963b3d56c..7fc1d9bba 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -1,11 +1,43 @@
# CHANGELOG
-v0.27.1 - _November 28, 2017_
-------------------------
+## v0.30.1 - _January 18, 2018_
+
+ * Fix a bug allowing negative fill values (#212)
+ * Fix a bug that made it impossible to pass a custom ZRX address (#341)
+
+## v0.30.0 - _January 17, 2018_
+
+ * Add an error parameter to the order watcher callback (#312)
+ * Fix a bug making it impossible to catch some errors from awaitTransactionMinedAsync (#312)
+ * Fix a bug in fillOrdersUpTo validation making it impossible to fill up to if user doesn't have enough balance to fully fill all the orders (#321)
+
+## v0.29.1 - _January 11, 2018_
+
+ * Fixed bignumber config issue #301 (#305)
+
+## v0.29.0 - _December 28, 2017_
+
+ * Assert baseUnit amount supplied to `toUnitAmount` is integer amount. (#287)
+ * `toBaseUnitAmount` throws if amount supplied has too many decimals (#287)
+
+## v0.28.0 - _December 20, 2017_
+
+ * Add `etherTokenAddress` arg to `depositAsync` and `withdrawAsync` methods on `zeroEx.etherToken` (#267)
+ * Removed accidentally included `unsubscribeAll` method from `zeroEx.proxy`, `zeroEx.etherToken` and `zeroEx.tokenRegistry` (#267)
+ * Removed `etherTokenContractAddress` from `ZeroEx` constructor arg `ZeroExConfig` (#267)
+ * Rename `SubscriptionOpts` to `BlockRange` (#272)
+ * Add `zeroEx.etherToken.subscribe`, `zeroEx.etherToken.unsubscribe`, `zeroEx.etherToken.unsubscribeAll` (#277)
+ * Add `zeroEx.etherToken.getLogsAsync` (#277)
+ * Add new public types `BlockParamLiteral`, `EtherTokenEvents`, `EtherTokenContractEventArgs`, `DepositContractEventArgs`, `WithdrawalContractEventArgs` (#277)
+ * Support `Deposit` and `Withdraw` events on etherToken (#277)
+ * Improve the error message when taker is not a string (#278)
+
+## v0.27.1 - _November 28, 2017_
+
* Export `TransactionOpts` type
-v0.27.0 - _November 28, 2017_
-------------------------
+## v0.27.0 - _November 28, 2017_
+
* Make `ZeroExConfig` required parameter of `ZeroEx` constructor (#233)
* Add a required property `networkId` to `ZeroExConfig` (#233)
* Make all `getContractAddress` functions, `zeroEx.exchange.subscribe`, `zeroEx.exchange.getZRXTokenAddress` sync (#233)
@@ -16,66 +48,66 @@ v0.27.0 - _November 28, 2017_
* All transaction sending methods now call `estimateGas` if no gas amount was supplied (#235)
* Modify order validation methods to validate against the `latest` block, not against the `pending` block (#236)
-v0.26.0 - _November 21, 2017_
-------------------------
+## v0.26.0 - _November 21, 2017_
+
* Add post-formatter for logs converting `blockNumber`, `logIndex`, `transactionIndex` from hexes to numbers (#231)
* Remove support for Async callback types when used in Subscribe functions (#222)
* In OrderWatcher subscribe to ZRX Token Transfer and Approval events when maker token is different (#225)
-v0.25.1 - _November 13, 2017_
-------------------------
+## v0.25.1 - _November 13, 2017_
+
* Standardise on Cancelled over Canceled (#217)
* Add missing `DecodedLogEvent` type to exported types (#205)
* Normalized the transactionReceipt status to be `null|0|1`, 1 meaning transaction execution successful, 0 unsuccessful and `null` if it is a pre-byzantinium transaction. (#200)
-v0.23.0 - _November 12, 2017_
-------------------------
+## v0.23.0 - _November 12, 2017_
+
* Fixed unhandled promise rejection error in subscribe methods (#209)
* Subscribe callbacks now receive an error object as their first argument
-v0.22.6 - _November 10, 2017_
-------------------------
+## v0.22.6 - _November 10, 2017_
+
* Add a timeout parameter to transaction awaiting (#206)
-v0.22.5 - _November 7, 2017_
-------------------------
+## v0.22.5 - _November 7, 2017_
+
* Re-publish v0.22.4 to fix publishing issue
-v0.22.4 - _October 25, 2017_
-------------------------
+## v0.22.4 - _October 25, 2017_
+
* Upgraded bignumber.js to a new version that ships with native typings
-v0.22.3 - _October 25, 2017_
-------------------------
+## v0.22.3 - _October 25, 2017_
+
* Fixed an issue with new version of testrpc and unlimited proxy allowance (#199)
-v0.22.2 - _October 24, 2017_
-------------------------
+## v0.22.2 - _October 24, 2017_
+
* Fixed rounding of maker fill amount and incorrect validation of partial fees (#197)
-v0.22.0 - _October 16, 2017_
-------------------------
+## v0.22.0 - _October 16, 2017_
+
* Started using `OrderFillRequest` interface instead of `OrderFillOrKillRequest` interface for `zeroEx.exchange.batchFillOrKill` (#187)
* Removed `OrderFillOrKillRequest` (#187)
-v0.21.4 - _October 13, 2017_
-------------------------
+## v0.21.4 - _October 13, 2017_
+
* Made 0x.js more type-safe by making `getLogsAsync` and `subscribe/subscribeAsync` generics parametrized with arg type (#194)
-v0.21.3 - _October 12, 2017_
-------------------------
+## v0.21.3 - _October 12, 2017_
+
* Fixed a bug causing order fills to throw `INSUFFICIENT_TAKER_ALLOWANCE` (#193)
-v0.21.2 - _October 11, 2017_
-------------------------
+## v0.21.2 - _October 11, 2017_
+
* Exported `ContractEventArg` as a public type (#190)
-v0.21.1 - _October 11, 2017_
-------------------------
+## v0.21.1 - _October 11, 2017_
+
* Fixed a bug in subscriptions (#189)
-v0.21.0 - _October 10, 2017_
-------------------------
+## v0.21.0 - _October 10, 2017_
+
* Complete rewrite of subscription logic (#182)
* Subscriptions no longer return historical logs. If you want them - use `getLogsAsync`
* Subscriptions now use [ethereumjs-blockstream](https://github.com/ethereumjs/ethereumjs-blockstream) under the hood
@@ -89,77 +121,77 @@ v0.21.0 - _October 10, 2017_
* Renamed `zeroEx.token.stopWatchingAllEventsAsync` to `zeroEx.token.unsubscribeAll`
* Fixed the batch fills validation by emulating all balance & proxy allowance changes (#185)
-v0.20.0 - _October 5, 2017_
-------------------------
+## v0.20.0 - _October 5, 2017_
+
* Add `zeroEx.token.getLogsAsync` (#178)
* Add `zeroEx.exchange.getLogsAsync` (#178)
* Fixed fees validation when one of the tokens transferred is ZRX (#181)
-v0.19.0 - _September 29, 2017_
-------------------------
+## v0.19.0 - _September 29, 2017_
+
* Made order validation optional (#172)
* Added Ropsten testnet support (#173)
* Fixed a bug causing awaitTransactionMinedAsync to DDos backend nodes (#175)
-v0.18.0 - _September 26, 2017_
-------------------------
+## v0.18.0 - _September 26, 2017_
+
* Added `zeroEx.exchange.validateOrderFillableOrThrowAsync` to simplify orderbook pruning (#170)
-v0.17.0 - _September 26, 2017_
-------------------------
+## v0.17.0 - _September 26, 2017_
+
* Made `zeroEx.exchange.getZRXTokenAddressAsync` public (#171)
-v0.16.0 - _September 20, 2017_
-------------------------
+## v0.16.0 - _September 20, 2017_
+
* Added the ability to specify custom contract addresses to be used with 0x.js (#165)
* ZeroExConfig.exchangeContractAddress
* ZeroExConfig.tokenRegistryContractAddress
* ZeroExConfig.etherTokenContractAddress
* Added `zeroEx.tokenRegistry.getContractAddressAsync` (#165)
-v0.15.0 - _September 8, 2017_
-------------------------
+## v0.15.0 - _September 8, 2017_
+
* Added the ability to specify a historical `blockNumber` at which to query the blockchain's state when calling a token or exchange method (#161)
-v0.14.2 - _September 7, 2017_
-------------------------
+## v0.14.2 - _September 7, 2017_
+
* Fixed an issue with bignumber.js types not found (#160)
-v0.14.1 - _September 7, 2017_
-------------------------
+## v0.14.1 - _September 7, 2017_
+
* Fixed an issue with Artifact type not found (#159)
-v0.14.0 - _September 6, 2017_
-------------------------
+## v0.14.0 - _September 6, 2017_
+
* Added `zeroEx.exchange.throwLogErrorsAsErrors` method to public interface (#157)
* Fixed an issue with overlapping async intervals in `zeroEx.awaitTransactionMinedAsync` (#157)
* Fixed an issue with log decoder returning `BigNumber`s as `strings` (#157)
-v0.13.0 - _September 6, 2017_
-------------------------
+## v0.13.0 - _September 6, 2017_
+
* Made all the functions submitting transactions to the network to immediately return transaction hash (#151)
* Added `zeroEx.awaitTransactionMinedAsync` (#151)
* Added `TransactionReceiptWithDecodedLogs`, `LogWithDecodedArgs`, `DecodedLogArgs` to public types (#151)
* Added signature validation to `validateFillOrderThrowIfInvalidAsync` (#152)
-v0.12.1 - _September 2, 2017_
-------------------------
+## v0.12.1 - _September 2, 2017_
+
* Added the support for web3@1.x.x provider (#142)
* Added the optional `zeroExConfig` parameter to the constructor of `ZeroEx` (#139)
* Added the ability to specify `gasPrice` when instantiating `ZeroEx` (#139)
-v0.11.0 - _August 24, 2017_
-------------------------
+## v0.11.0 - _August 24, 2017_
+
* Added `zeroEx.token.setUnlimitedProxyAllowanceAsync` (#137)
* Added `zeroEx.token.setUnlimitedAllowanceAsync` (#137)
* Added `zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS` (#137)
-v0.10.4 - _Aug 24, 2017_
-------------------------
+## v0.10.4 - _Aug 24, 2017_
+
* Fixed a bug where checksummed addresses were being pulled from artifacts and not lower-cased. (#135)
-v0.10.1 - _Aug 24, 2017_
-------------------------
+## v0.10.1 - _Aug 24, 2017_
+
* Added `zeroEx.exchange.validateFillOrderThrowIfInvalidAsync` (#128)
* Added `zeroEx.exchange.validateFillOrKillOrderThrowIfInvalidAsync` (#128)
* Added `zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync` (#128)
@@ -173,21 +205,21 @@ v0.10.1 - _Aug 24, 2017_
* Added clear error message when checksummed address is passed to a public method (#124)
* Fixes the description of `shouldThrowOnInsufficientBalanceOrAllowance` in docs (#127)
-v0.9.3 - _Aug 22, 2017_
-------------------------
+## v0.9.3 - _Aug 22, 2017_
+
* Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
-v0.9.2 - _Aug 21, 2017_
-------------------------
+## v0.9.2 - _Aug 21, 2017_
+
* *This version was unpublished because of a publishing issue.*
* Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
-v0.9.1 - _Aug. 16, 2017_
-------------------------
+## v0.9.1 - _Aug. 16, 2017_
+
* Fixed the bug causing `zeroEx.token.getBalanceAsync()` to fail if no addresses available (#120)
-v0.9.0 - _Jul. 26, 2017_
-------------------------
+## v0.9.0 - _Jul. 26, 2017_
+
* Migrated to the new version of smart contracts (#101)
* Removed the ability to call methods on multiple authorized Exchange smart contracts (#106)
* Made `zeroEx.getOrderHashHex` a static method (#107)
@@ -197,8 +229,8 @@ v0.9.0 - _Jul. 26, 2017_
* Updated to typescript v2.4 (#104)
* Fixed an issue with incorrect balance/allowance validation when ZRX is one of the tokens traded (#109)
-v0.8.0 - _Jul. 4, 2017_
-------------------------
+## v0.8.0 - _Jul. 4, 2017_
+
* Added the ability to call methods on different authorized versions of the Exchange smart contract (#82)
* Updated contract artifacts to reflect latest changes to the smart contracts (0xproject/contracts#59)
* Added `zeroEx.proxy.isAuthorizedAsync` and `zeroEx.proxy.getAuthorizedAddressesAsync` (#89)
@@ -210,35 +242,35 @@ v0.8.0 - _Jul. 4, 2017_
* `zeroEx.tokenRegistry.invalidateContractInstance`
* Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance
-v0.7.1 - _Jun. 26, 2017_
-------------------------
+## v0.7.1 - _Jun. 26, 2017_
+
* Added the ability to convert Ether to wrapped Ether tokens and back via `zeroEx.etherToken.depostAsync` and `zeroEx.etherToken.withdrawAsync` (#81)
-v0.7.0 - _Jun. 22, 2017_
-------------------------
+## v0.7.0 - _Jun. 22, 2017_
+
* Added Kovan smart contract artifacts (#78)
* Started returning fillAmount from `fillOrderAsync` and `fillUpToAsync` (#72)
* Started returning cancelledAmount from `cancelOrderAsync` (#72)
* Renamed type `LogCancelArgs` to `LogCancelContractEventArgs` and `LogFillArgs` to `LogFillContractEventArgs`
-v0.6.2 - _Jun. 21, 2017_
-------------------------
+## v0.6.2 - _Jun. 21, 2017_
+
* Reduced bundle size
* Improved documentation
-v0.6.1 - _Jun. 19, 2017_
-------------------------
+## v0.6.1 - _Jun. 19, 2017_
+
* Improved documentation
-v0.6.0 - _Jun. 19, 2017_
-------------------------
+## v0.6.0 - _Jun. 19, 2017_
+
* Made `ZeroEx` class accept `Web3Provider` instance instead of `Web3` instance
* Added types for contract event arguments
-v0.5.2 - _Jun. 15, 2017_
-------------------------
+## v0.5.2 - _Jun. 15, 2017_
+
* Fixed the bug in `postpublish` script that caused that only unminified UMD bundle was uploaded to release page
-v0.5.1 - _Jun. 15, 2017_
-------------------------
+## v0.5.1 - _Jun. 15, 2017_
+
* Added `postpublish` script to publish to Github Releases with assets.
diff --git a/packages/0x.js/README.md b/packages/0x.js/README.md
index 6cdcbde70..bac4fa5d8 100644
--- a/packages/0x.js/README.md
+++ b/packages/0x.js/README.md
@@ -1,11 +1,10 @@
-0x.js
------
+## 0x.js
## Installation
0x.js ships as both a [UMD](https://github.com/umdjs/umd) module and a [CommonJS](https://en.wikipedia.org/wiki/CommonJS) package.
-#### CommonJS *(recommended)*:
+#### CommonJS _(recommended)_:
**Install**
@@ -16,7 +15,7 @@ npm install 0x.js --save
**Import**
```javascript
-import {ZeroEx} from '0x.js';
+import { ZeroEx } from '0x.js';
```
#### UMD:
diff --git a/packages/abi-gen-templates/contract.mustache b/packages/0x.js/contract_templates/contract.mustache
index ec06df507..3e501cce6 100644
--- a/packages/abi-gen-templates/contract.mustache
+++ b/packages/0x.js/contract_templates/contract.mustache
@@ -2,13 +2,11 @@
* This file is auto-generated using abi-gen. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
*/
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
+// tslint:disable-next-line:no-unused-variable
+import { TxData, TxDataPayable } from '@0xproject/types';
+import { BigNumber, classUtils, promisify } from '@0xproject/utils';
import * as Web3 from 'web3';
-import {TxData, TxDataPayable} from '../../types';
-import {classUtils} from '../../utils/class_utils';
-
import {BaseContract} from './base_contract';
export class {{contractName}}Contract extends BaseContract {
diff --git a/packages/abi-gen-templates/partials/call.mustache b/packages/0x.js/contract_templates/partials/call.mustache
index ef4bda724..ef4bda724 100644
--- a/packages/abi-gen-templates/partials/call.mustache
+++ b/packages/0x.js/contract_templates/partials/call.mustache
diff --git a/packages/abi-gen-templates/partials/params.mustache b/packages/0x.js/contract_templates/partials/params.mustache
index ac5d4ae85..ac5d4ae85 100644
--- a/packages/abi-gen-templates/partials/params.mustache
+++ b/packages/0x.js/contract_templates/partials/params.mustache
diff --git a/packages/abi-gen-templates/partials/return_type.mustache b/packages/0x.js/contract_templates/partials/return_type.mustache
index 383961a40..383961a40 100644
--- a/packages/abi-gen-templates/partials/return_type.mustache
+++ b/packages/0x.js/contract_templates/partials/return_type.mustache
diff --git a/packages/abi-gen-templates/partials/tx.mustache b/packages/0x.js/contract_templates/partials/tx.mustache
index 8a43e5319..8a43e5319 100644
--- a/packages/abi-gen-templates/partials/tx.mustache
+++ b/packages/0x.js/contract_templates/partials/tx.mustache
diff --git a/packages/abi-gen-templates/partials/typed_params.mustache b/packages/0x.js/contract_templates/partials/typed_params.mustache
index 3ea4b2e95..3ea4b2e95 100644
--- a/packages/abi-gen-templates/partials/typed_params.mustache
+++ b/packages/0x.js/contract_templates/partials/typed_params.mustache
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 7b267fa8e..fb27f48de 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -1,106 +1,97 @@
{
- "name": "0x.js",
- "version": "0.27.1",
- "description": "A javascript library for interacting with the 0x protocol",
- "keywords": [
- "0x.js",
- "0xproject",
- "ethereum",
- "tokens",
- "exchange"
- ],
- "main": "lib/src/index.js",
- "types": "lib/src/index.d.ts",
- "scripts": {
- "prebuild": "npm run clean",
- "build": "run-p build:umd:prod build:commonjs; exit 0;",
- "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_DIR",
- "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
- "generate_contract_wrappers": "abi-gen --abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry).json' --templates ../abi-gen-templates/ --output src/contract_wrappers/generated --fileExtension ts",
- "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
- "test:circleci": "run-s test:coverage report_test_coverage && if [ $CIRCLE_BRANCH = \"development\" ]; then yarn test:umd; fi",
- "test": "run-s clean test:commonjs",
- "test:umd": "./scripts/test_umd.sh",
- "test:coverage": "nyc npm run test --all",
- "report_test_coverage": "nyc report --reporter=text-lcov | coveralls",
- "update_contracts": "for i in ${npm_package_config_artifacts}; do copyfiles -u 4 ../contracts/build/contracts/$i.json ../0x.js/src/artifacts; done;",
- "clean": "shx rm -rf _bundles lib test_temp",
- "build:umd:dev": "webpack",
- "build:umd:prod": "NODE_ENV=production webpack",
- "build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts;",
- "test:commonjs": "run-s build:commonjs run_mocha",
- "pretest:umd": "run-s clean build:umd:dev build:commonjs",
- "substitute_umd_bundle": "shx mv _bundles/* lib/src",
- "run_mocha": "mocha lib/test/**/*_test.js --timeout 5000 --bail --exit"
- },
- "config": {
- "artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/0xProject/0x.js"
- },
- "license": "Apache-2.0",
- "engines": {
- "node": ">=6.0.0"
- },
- "devDependencies": {
- "@0xproject/tslint-config": "^0.2.0",
- "@0xproject/types": "^0.0.1",
- "@types/bintrees": "^1.0.2",
- "@types/jsonschema": "^1.1.1",
- "@types/lodash": "^4.14.86",
- "@types/mocha": "^2.2.42",
- "@types/node": "^8.0.53",
- "@types/sinon": "^2.2.2",
- "@types/uuid": "^3.4.2",
- "abi-gen": "^0.0.1",
- "abi-gen-templates": "^0.0.1",
- "awesome-typescript-loader": "^3.1.3",
- "chai": "^4.0.1",
- "chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.3",
- "chai-bignumber": "^2.0.1",
- "chai-typescript-typings": "^0.0.1",
- "copyfiles": "^1.2.0",
- "coveralls": "^3.0.0",
- "dirty-chai": "^2.0.1",
- "json-loader": "^0.5.4",
- "mocha": "^4.0.1",
- "npm-run-all": "^4.1.2",
- "nyc": "^11.0.1",
- "opn-cli": "^3.1.0",
- "request": "^2.81.0",
- "request-promise-native": "^1.0.4",
- "shx": "^0.2.2",
- "sinon": "^4.0.0",
- "source-map-support": "^0.5.0",
- "truffle-hdwallet-provider": "^0.0.3",
- "tslint": "5.8.0",
- "typedoc": "~0.8.0",
- "types-bn": "^0.0.1",
- "types-ethereumjs-util": "0xProject/types-ethereumjs-util",
- "typescript": "~2.6.1",
- "web3-provider-engine": "^13.0.1",
- "web3-typescript-typings": "^0.7.2",
- "webpack": "^3.1.0"
- },
- "dependencies": {
- "@0xproject/assert": "^0.0.6",
- "@0xproject/json-schemas": "^0.6.9",
- "@0xproject/utils": "^0.0.1",
- "@0xproject/web3-wrapper": "^0.0.1",
- "bignumber.js": "~4.1.0",
- "bintrees": "^1.0.2",
- "bn.js": "^4.11.8",
- "compare-versions": "^3.0.1",
- "ethereumjs-abi": "^0.6.4",
- "ethereumjs-blockstream": "^2.0.6",
- "ethereumjs-util": "^5.1.1",
- "find-versions": "^2.0.0",
- "js-sha3": "^0.6.1",
- "lodash": "^4.17.4",
- "uuid": "^3.1.0",
- "web3": "^0.20.0"
- }
+ "name": "0x.js",
+ "version": "0.30.1",
+ "description": "A javascript library for interacting with the 0x protocol",
+ "keywords": [
+ "0x.js",
+ "0xproject",
+ "ethereum",
+ "tokens",
+ "exchange"
+ ],
+ "main": "lib/src/index.js",
+ "types": "lib/src/index.d.ts",
+ "scripts": {
+ "prebuild": "run-s clean generate_contract_wrappers",
+ "build": "run-p build:umd:prod build:commonjs; exit 0;",
+ "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_DIR",
+ "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
+ "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --templates contract_templates --output src/contract_wrappers/generated",
+ "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
+ "test:circleci": "run-s test:coverage report_test_coverage",
+ "test": "run-s clean test:commonjs",
+ "test:coverage": "nyc npm run test --all",
+ "report_test_coverage": "nyc report --reporter=text-lcov | coveralls",
+ "update_contracts": "for i in ${npm_package_config_artifacts}; do copyfiles -u 4 ../contracts/build/contracts/$i.json ../0x.js/src/artifacts; done;",
+ "clean": "shx rm -rf _bundles lib test_temp",
+ "build:umd:prod": "NODE_ENV=production webpack",
+ "build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts;",
+ "test:commonjs": "run-s build:commonjs run_mocha",
+ "run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit"
+ },
+ "config": {
+ "artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/0xProject/0x.js"
+ },
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=6.0.0"
+ },
+ "devDependencies": {
+ "@0xproject/abi-gen": "^0.1.3",
+ "@0xproject/dev-utils": "^0.0.6",
+ "@0xproject/tslint-config": "^0.4.3",
+ "@0xproject/types": "^0.1.5",
+ "@types/bintrees": "^1.0.2",
+ "@types/jsonschema": "^1.1.1",
+ "@types/lodash": "^4.14.86",
+ "@types/mocha": "^2.2.42",
+ "@types/node": "^8.0.53",
+ "@types/sinon": "^2.2.2",
+ "@types/uuid": "^3.4.2",
+ "awesome-typescript-loader": "^3.1.3",
+ "chai": "^4.0.1",
+ "chai-as-promised": "^7.1.0",
+ "chai-as-promised-typescript-typings": "^0.0.5",
+ "chai-bignumber": "^2.0.1",
+ "chai-typescript-typings": "^0.0.2",
+ "copyfiles": "^1.2.0",
+ "coveralls": "^3.0.0",
+ "dirty-chai": "^2.0.1",
+ "json-loader": "^0.5.4",
+ "mocha": "^4.0.1",
+ "npm-run-all": "^4.1.2",
+ "nyc": "^11.0.1",
+ "opn-cli": "^3.1.0",
+ "request": "^2.81.0",
+ "request-promise-native": "^1.0.4",
+ "shx": "^0.2.2",
+ "sinon": "^4.0.0",
+ "source-map-support": "^0.5.0",
+ "truffle-hdwallet-provider": "^0.0.3",
+ "tslint": "5.8.0",
+ "typedoc": "~0.8.0",
+ "typescript": "~2.6.1",
+ "web3-provider-engine": "^13.0.1",
+ "web3-typescript-typings": "^0.9.5",
+ "webpack": "^3.1.0"
+ },
+ "dependencies": {
+ "@0xproject/assert": "^0.0.12",
+ "@0xproject/json-schemas": "^0.7.4",
+ "@0xproject/utils": "^0.2.1",
+ "@0xproject/web3-wrapper": "^0.1.6",
+ "bintrees": "^1.0.2",
+ "bn.js": "^4.11.8",
+ "ethereumjs-abi": "^0.6.4",
+ "ethereumjs-blockstream": "^2.0.6",
+ "ethereumjs-util": "^5.1.1",
+ "js-sha3": "^0.6.1",
+ "lodash": "^4.17.4",
+ "uuid": "^3.1.0",
+ "web3": "^0.20.0"
+ }
}
diff --git a/packages/0x.js/scripts/postpublish.js b/packages/0x.js/scripts/postpublish.js
index 28484a8bd..1be964478 100644
--- a/packages/0x.js/scripts/postpublish.js
+++ b/packages/0x.js/scripts/postpublish.js
@@ -8,26 +8,21 @@ const S3BucketPath = 's3://0xjs-docs-jsons/';
let tag;
let version;
-postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
+postpublish_utils
+ .getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
tag = result.tag;
version = result.version;
- const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
- const assets = [
- __dirname + '/../_bundles/index.js',
- __dirname + '/../_bundles/index.min.js',
- ];
- return postpublish_utils.publishReleaseNotes(tag, releaseName, assets);
+ const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
+ const assets = [__dirname + '/../_bundles/index.js', __dirname + '/../_bundles/index.min.js'];
+ return postpublish_utils.publishReleaseNotes(tag, releaseName, assets);
})
.then(function(release) {
console.log('POSTPUBLISH: Release successful, generating docs...');
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
- return execAsync(
- 'JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json',
- {
- cwd,
- }
- );
+ return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json', {
+ cwd,
+ });
})
.then(function(result) {
if (result.stderr !== '') {
@@ -39,6 +34,7 @@ postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
cwd,
});
- }).catch (function(err) {
+ })
+ .catch(function(err) {
throw err;
});
diff --git a/packages/0x.js/scripts/test_umd.sh b/packages/0x.js/scripts/test_umd.sh
deleted file mode 100755
index e3eba088a..000000000
--- a/packages/0x.js/scripts/test_umd.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env bash
-# This script runs umd tests and cleans up after them while preserving the `return_code` for CI
-# UMD tests should only be run after building the commonjs because they reuse some of the commonjs build artifacts
-run-s substitute_umd_bundle run_mocha
-return_code=$?
-exit $return_code
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts
index 935e4ac1a..503a937c4 100644
--- a/packages/0x.js/src/0x.ts
+++ b/packages/0x.js/src/0x.ts
@@ -1,38 +1,32 @@
-import {schemas, SchemaValidator} from '@0xproject/json-schemas';
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+import { schemas, SchemaValidator } from '@0xproject/json-schemas';
+import { BigNumber, intervalUtils } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
-import {artifacts} from './artifacts';
-import {bigNumberConfigs} from './bignumber_config';
-import {EtherTokenWrapper} from './contract_wrappers/ether_token_wrapper';
-import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper';
-import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper';
-import {TokenTransferProxyWrapper} from './contract_wrappers/token_transfer_proxy_wrapper';
-import {TokenWrapper} from './contract_wrappers/token_wrapper';
-import {OrderStateWatcher} from './order_watcher/order_state_watcher';
-import {zeroExConfigSchema} from './schemas/zero_ex_config_schema';
+import { artifacts } from './artifacts';
+import { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper';
+import { ExchangeWrapper } from './contract_wrappers/exchange_wrapper';
+import { TokenRegistryWrapper } from './contract_wrappers/token_registry_wrapper';
+import { TokenTransferProxyWrapper } from './contract_wrappers/token_transfer_proxy_wrapper';
+import { TokenWrapper } from './contract_wrappers/token_wrapper';
+import { OrderStateWatcher } from './order_watcher/order_state_watcher';
+import { zeroExConfigSchema } from './schemas/zero_ex_config_schema';
import {
ECSignature,
Order,
- OrderStateWatcherConfig,
SignedOrder,
TransactionReceiptWithDecodedLogs,
Web3Provider,
ZeroExConfig,
ZeroExError,
} from './types';
-import {AbiDecoder} from './utils/abi_decoder';
-import {assert} from './utils/assert';
-import {constants} from './utils/constants';
-import {intervalUtils} from './utils/interval_utils';
-import {OrderStateUtils} from './utils/order_state_utils';
-import {signatureUtils} from './utils/signature_utils';
-import {utils} from './utils/utils';
-
-// Customize our BigNumber instances
-bigNumberConfigs.configure();
+import { AbiDecoder } from './utils/abi_decoder';
+import { assert } from './utils/assert';
+import { constants } from './utils/constants';
+import { decorators } from './utils/decorators';
+import { signatureUtils } from './utils/signature_utils';
+import { utils } from './utils/utils';
/**
* The ZeroEx class is the single entry-point into the 0x.js library. It contains all of the library's functionality
@@ -130,7 +124,7 @@ export class ZeroEx {
* @return The amount in units.
*/
public static toUnitAmount(amount: BigNumber, decimals: number): BigNumber {
- assert.isBigNumber('amount', amount);
+ assert.isValidBaseUnitAmount('amount', amount);
assert.isNumber('decimals', decimals);
const aUnit = new BigNumber(10).pow(decimals);
@@ -151,6 +145,10 @@ export class ZeroEx {
const unit = new BigNumber(10).pow(decimals);
const baseUnitAmount = amount.times(unit);
+ const hasDecimals = baseUnitAmount.decimalPlaces() !== 0;
+ if (hasDecimals) {
+ throw new Error(`Invalid unit amount: ${amount.toString()} - Too many decimal places`);
+ }
return baseUnitAmount;
}
/**
@@ -158,7 +156,8 @@ export class ZeroEx {
* @param order An object that conforms to the Order or SignedOrder interface definitions.
* @return The resulting orderHash from hashing the supplied order.
*/
- public static getOrderHashHex(order: Order|SignedOrder): string {
+ @decorators.syncZeroExErrorHandler
+ public static getOrderHashHex(order: Order | SignedOrder): string {
assert.doesConformToSchema('order', order, schemas.orderSchema);
const orderHashHex = utils.getOrderHashHex(order);
return orderHashHex;
@@ -185,27 +184,27 @@ export class ZeroEx {
config.networkId,
config.tokenTransferProxyContractAddress,
);
- this.token = new TokenWrapper(
- this._web3Wrapper,
- config.networkId,
- this._abiDecoder,
- this.proxy,
- );
+ this.token = new TokenWrapper(this._web3Wrapper, config.networkId, this._abiDecoder, this.proxy);
this.exchange = new ExchangeWrapper(
this._web3Wrapper,
config.networkId,
this._abiDecoder,
this.token,
config.exchangeContractAddress,
+ config.zrxContractAddress,
);
this.tokenRegistry = new TokenRegistryWrapper(
- this._web3Wrapper, config.networkId, config.tokenRegistryContractAddress,
- );
- this.etherToken = new EtherTokenWrapper(
- this._web3Wrapper, config.networkId, this.token, config.etherTokenContractAddress,
+ this._web3Wrapper,
+ config.networkId,
+ config.tokenRegistryContractAddress,
);
+ this.etherToken = new EtherTokenWrapper(this._web3Wrapper, config.networkId, this._abiDecoder, this.token);
this.orderStateWatcher = new OrderStateWatcher(
- this._web3Wrapper, this._abiDecoder, this.token, this.exchange, config.orderWatcherConfig,
+ this._web3Wrapper,
+ this._abiDecoder,
+ this.token,
+ this.exchange,
+ config.orderWatcherConfig,
);
}
/**
@@ -215,12 +214,17 @@ export class ZeroEx {
* @param networkId The id of the network your provider is connected to
*/
public setProvider(provider: Web3Provider, networkId: number): void {
- this._web3Wrapper.setProvider(provider, networkId);
+ this._web3Wrapper.setProvider(provider);
(this.exchange as any)._invalidateContractInstances();
+ (this.exchange as any)._setNetworkId(networkId);
(this.tokenRegistry as any)._invalidateContractInstance();
+ (this.tokenRegistry as any)._setNetworkId(networkId);
(this.token as any)._invalidateContractInstances();
+ (this.token as any)._setNetworkId(networkId);
(this.proxy as any)._invalidateContractInstance();
+ (this.proxy as any)._setNetworkId(networkId);
(this.etherToken as any)._invalidateContractInstance();
+ (this.etherToken as any)._setNetworkId(networkId);
}
/**
* Get user Ethereum addresses available through the supplied web3 provider available for sending transactions.
@@ -288,35 +292,46 @@ export class ZeroEx {
* @return Transaction receipt with decoded log args.
*/
public async awaitTransactionMinedAsync(
- txHash: string, pollingIntervalMs = 1000, timeoutMs?: number): Promise<TransactionReceiptWithDecodedLogs> {
+ txHash: string,
+ pollingIntervalMs = 1000,
+ timeoutMs?: number,
+ ): Promise<TransactionReceiptWithDecodedLogs> {
let timeoutExceeded = false;
if (timeoutMs) {
- setTimeout(() => timeoutExceeded = true, timeoutMs);
+ setTimeout(() => (timeoutExceeded = true), timeoutMs);
}
const txReceiptPromise = new Promise(
(resolve: (receipt: TransactionReceiptWithDecodedLogs) => void, reject) => {
- const intervalId = intervalUtils.setAsyncExcludingInterval(async () => {
- if (timeoutExceeded) {
- intervalUtils.clearAsyncExcludingInterval(intervalId);
- return reject(ZeroExError.TransactionMiningTimeout);
- }
+ const intervalId = intervalUtils.setAsyncExcludingInterval(
+ async () => {
+ if (timeoutExceeded) {
+ intervalUtils.clearAsyncExcludingInterval(intervalId);
+ return reject(ZeroExError.TransactionMiningTimeout);
+ }
- const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash);
- if (!_.isNull(transactionReceipt)) {
- intervalUtils.clearAsyncExcludingInterval(intervalId);
- const logsWithDecodedArgs = _.map(
- transactionReceipt.logs,
- this._abiDecoder.tryToDecodeLogOrNoop.bind(this._abiDecoder),
- );
- const transactionReceiptWithDecodedLogArgs: TransactionReceiptWithDecodedLogs = {
- ...transactionReceipt,
- logs: logsWithDecodedArgs,
- };
- resolve(transactionReceiptWithDecodedLogArgs);
- }
- }, pollingIntervalMs);
- });
+ const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash);
+ if (!_.isNull(transactionReceipt)) {
+ intervalUtils.clearAsyncExcludingInterval(intervalId);
+ const logsWithDecodedArgs = _.map(
+ transactionReceipt.logs,
+ this._abiDecoder.tryToDecodeLogOrNoop.bind(this._abiDecoder),
+ );
+ const transactionReceiptWithDecodedLogArgs: TransactionReceiptWithDecodedLogs = {
+ ...transactionReceipt,
+ logs: logsWithDecodedArgs,
+ };
+ resolve(transactionReceiptWithDecodedLogArgs);
+ }
+ },
+ pollingIntervalMs,
+ (err: Error) => {
+ intervalUtils.clearAsyncExcludingInterval(intervalId);
+ reject(err);
+ },
+ );
+ },
+ );
return txReceiptPromise;
}
diff --git a/packages/0x.js/src/artifacts.ts b/packages/0x.js/src/artifacts.ts
index de2030812..cbacd7d56 100644
--- a/packages/0x.js/src/artifacts.ts
+++ b/packages/0x.js/src/artifacts.ts
@@ -1,16 +1,18 @@
+import * as DummyTokenArtifact from './artifacts/DummyToken.json';
import * as EtherTokenArtifact from './artifacts/EtherToken.json';
import * as ExchangeArtifact from './artifacts/Exchange.json';
import * as TokenArtifact from './artifacts/Token.json';
import * as TokenRegistryArtifact from './artifacts/TokenRegistry.json';
import * as TokenTransferProxyArtifact from './artifacts/TokenTransferProxy.json';
import * as ZRXArtifact from './artifacts/ZRX.json';
-import {Artifact} from './types';
+import { Artifact } from './types';
export const artifacts = {
- ZRXArtifact: ZRXArtifact as any as Artifact,
- TokenArtifact: TokenArtifact as any as Artifact,
- ExchangeArtifact: ExchangeArtifact as any as Artifact,
- EtherTokenArtifact: EtherTokenArtifact as any as Artifact,
- TokenRegistryArtifact: TokenRegistryArtifact as any as Artifact,
- TokenTransferProxyArtifact: TokenTransferProxyArtifact as any as Artifact,
+ ZRXArtifact: (ZRXArtifact as any) as Artifact,
+ DummyTokenArtifact: (DummyTokenArtifact as any) as Artifact,
+ TokenArtifact: (TokenArtifact as any) as Artifact,
+ ExchangeArtifact: (ExchangeArtifact as any) as Artifact,
+ EtherTokenArtifact: (EtherTokenArtifact as any) as Artifact,
+ TokenRegistryArtifact: (TokenRegistryArtifact as any) as Artifact,
+ TokenTransferProxyArtifact: (TokenTransferProxyArtifact as any) as Artifact,
};
diff --git a/packages/0x.js/src/artifacts/DummyToken.json b/packages/0x.js/src/artifacts/DummyToken.json
new file mode 100644
index 000000000..f64a8cd3d
--- /dev/null
+++ b/packages/0x.js/src/artifacts/DummyToken.json
@@ -0,0 +1,22 @@
+{
+ "contract_name": "DummyToken",
+ "abi": [
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_target",
+ "type": "address"
+ },
+ {
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "setBalance",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ }
+ ]
+}
diff --git a/packages/0x.js/src/artifacts/EtherToken.json b/packages/0x.js/src/artifacts/EtherToken.json
index 8c1d0f499..91fba7f0a 100644
--- a/packages/0x.js/src/artifacts/EtherToken.json
+++ b/packages/0x.js/src/artifacts/EtherToken.json
@@ -1,250 +1,284 @@
{
- "contract_name": "EtherToken",
- "abi": [
- {
- "constant": true,
- "inputs": [],
- "name": "name",
- "outputs": [
- {
- "name": "",
- "type": "string"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
+ "contract_name": "EtherToken",
+ "abi": [
{
- "name": "_spender",
- "type": "address"
+ "constant": true,
+ "inputs": [],
+ "name": "name",
+ "outputs": [
+ {
+ "name": "",
+ "type": "string"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "name": "_value",
- "type": "uint256"
- }
- ],
- "name": "approve",
- "outputs": [
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_spender",
+ "type": "address"
+ },
+ {
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "approve",
+ "outputs": [
+ {
+ "name": "",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "totalSupply",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
+ "constant": true,
+ "inputs": [],
+ "name": "totalSupply",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "_from",
- "type": "address"
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_from",
+ "type": "address"
+ },
+ {
+ "name": "_to",
+ "type": "address"
+ },
+ {
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "transferFrom",
+ "outputs": [
+ {
+ "name": "",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "name": "_to",
- "type": "address"
+ "constant": false,
+ "inputs": [
+ {
+ "name": "amount",
+ "type": "uint256"
+ }
+ ],
+ "name": "withdraw",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
},
{
- "name": "_value",
- "type": "uint256"
- }
- ],
- "name": "transferFrom",
- "outputs": [
+ "constant": true,
+ "inputs": [],
+ "name": "decimals",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint8"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "amount",
- "type": "uint256"
- }
- ],
- "name": "withdraw",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "decimals",
- "outputs": [
- {
- "name": "",
- "type": "uint8"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_owner",
- "type": "address"
- }
- ],
- "name": "balanceOf",
- "outputs": [
+ "constant": true,
+ "inputs": [
+ {
+ "name": "_owner",
+ "type": "address"
+ }
+ ],
+ "name": "balanceOf",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "symbol",
- "outputs": [
- {
- "name": "",
- "type": "string"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
+ "constant": true,
+ "inputs": [],
+ "name": "symbol",
+ "outputs": [
+ {
+ "name": "",
+ "type": "string"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "_to",
- "type": "address"
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_to",
+ "type": "address"
+ },
+ {
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "transfer",
+ "outputs": [
+ {
+ "name": "",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "name": "_value",
- "type": "uint256"
- }
- ],
- "name": "transfer",
- "outputs": [
+ "constant": false,
+ "inputs": [],
+ "name": "deposit",
+ "outputs": [],
+ "payable": true,
+ "type": "function"
+ },
{
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [],
- "name": "deposit",
- "outputs": [],
- "payable": true,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_owner",
- "type": "address"
- },
- {
- "name": "_spender",
- "type": "address"
- }
- ],
- "name": "allowance",
- "outputs": [
+ "constant": true,
+ "inputs": [
+ {
+ "name": "_owner",
+ "type": "address"
+ },
+ {
+ "name": "_spender",
+ "type": "address"
+ }
+ ],
+ "name": "allowance",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "payable": true,
- "type": "fallback"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "_from",
- "type": "address"
- },
- {
- "indexed": true,
- "name": "_to",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "_value",
- "type": "uint256"
- }
- ],
- "name": "Transfer",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
+ "payable": true,
+ "type": "fallback"
+ },
{
- "indexed": true,
- "name": "_owner",
- "type": "address"
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "_from",
+ "type": "address"
+ },
+ {
+ "indexed": true,
+ "name": "_to",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "Transfer",
+ "type": "event"
},
{
- "indexed": true,
- "name": "_spender",
- "type": "address"
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "_owner",
+ "type": "address"
+ },
+ {
+ "indexed": true,
+ "name": "_spender",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "Approval",
+ "type": "event"
},
{
- "indexed": false,
- "name": "_value",
- "type": "uint256"
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "_owner",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "Deposit",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "_owner",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "Withdrawal",
+ "type": "event"
+ }
+ ],
+ "networks": {
+ "1": {
+ "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
+ },
+ "3": {
+ "address": "0xc00fd9820cd2898cc4c054b7bf142de637ad129a"
+ },
+ "42": {
+ "address": "0x653e49e301e508a13237c0ddc98ae7d4cd2667a1"
+ },
+ "50": {
+ "address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
}
- ],
- "name": "Approval",
- "type": "event"
- }
- ],
- "networks": {
- "1": {
- "address": "0x2956356cd2a2bf3202f771f50d3d14a367b48070"
- },
- "3": {
- "address": "0xc00fd9820cd2898cc4c054b7bf142de637ad129a"
- },
- "42": {
- "address": "0x05d090b51c40b020eab3bfcb6a2dff130df22e9c"
- },
- "50": {
- "address": "0x48bacb9266a570d521063ef5dd96e61686dbe788"
}
- }
}
diff --git a/packages/0x.js/src/artifacts/Exchange.json b/packages/0x.js/src/artifacts/Exchange.json
index 25495a041..45e277c45 100644
--- a/packages/0x.js/src/artifacts/Exchange.json
+++ b/packages/0x.js/src/artifacts/Exchange.json
@@ -1,607 +1,607 @@
{
- "contract_name": "Exchange",
- "abi": [
- {
- "constant": true,
- "inputs": [
- {
- "name": "numerator",
- "type": "uint256"
- },
- {
- "name": "denominator",
- "type": "uint256"
- },
- {
- "name": "target",
- "type": "uint256"
- }
- ],
- "name": "isRoundingError",
- "outputs": [
- {
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "bytes32"
- }
- ],
- "name": "filled",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "bytes32"
- }
- ],
- "name": "cancelled",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "orderAddresses",
- "type": "address[5][]"
- },
- {
- "name": "orderValues",
- "type": "uint256[6][]"
- },
- {
- "name": "fillTakerTokenAmount",
- "type": "uint256"
- },
- {
- "name": "shouldThrowOnInsufficientBalanceOrAllowance",
- "type": "bool"
- },
- {
- "name": "v",
- "type": "uint8[]"
- },
- {
- "name": "r",
- "type": "bytes32[]"
- },
- {
- "name": "s",
- "type": "bytes32[]"
- }
- ],
- "name": "fillOrdersUpTo",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "orderAddresses",
- "type": "address[5]"
- },
- {
- "name": "orderValues",
- "type": "uint256[6]"
- },
- {
- "name": "cancelTakerTokenAmount",
- "type": "uint256"
- }
- ],
- "name": "cancelOrder",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "ZRX_TOKEN_CONTRACT",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "orderAddresses",
- "type": "address[5][]"
- },
- {
- "name": "orderValues",
- "type": "uint256[6][]"
- },
- {
- "name": "fillTakerTokenAmounts",
- "type": "uint256[]"
- },
- {
- "name": "v",
- "type": "uint8[]"
- },
- {
- "name": "r",
- "type": "bytes32[]"
- },
- {
- "name": "s",
- "type": "bytes32[]"
- }
- ],
- "name": "batchFillOrKillOrders",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "orderAddresses",
- "type": "address[5]"
- },
- {
- "name": "orderValues",
- "type": "uint256[6]"
- },
- {
- "name": "fillTakerTokenAmount",
- "type": "uint256"
- },
- {
- "name": "v",
- "type": "uint8"
- },
- {
- "name": "r",
- "type": "bytes32"
- },
- {
- "name": "s",
- "type": "bytes32"
- }
- ],
- "name": "fillOrKillOrder",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "orderHash",
- "type": "bytes32"
- }
- ],
- "name": "getUnavailableTakerTokenAmount",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "signer",
- "type": "address"
- },
- {
- "name": "hash",
- "type": "bytes32"
- },
- {
- "name": "v",
- "type": "uint8"
- },
- {
- "name": "r",
- "type": "bytes32"
- },
- {
- "name": "s",
- "type": "bytes32"
- }
- ],
- "name": "isValidSignature",
- "outputs": [
- {
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "numerator",
- "type": "uint256"
- },
- {
- "name": "denominator",
- "type": "uint256"
- },
- {
- "name": "target",
- "type": "uint256"
- }
- ],
- "name": "getPartialAmount",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "TOKEN_TRANSFER_PROXY_CONTRACT",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "orderAddresses",
- "type": "address[5][]"
- },
- {
- "name": "orderValues",
- "type": "uint256[6][]"
- },
- {
- "name": "fillTakerTokenAmounts",
- "type": "uint256[]"
- },
- {
- "name": "shouldThrowOnInsufficientBalanceOrAllowance",
- "type": "bool"
- },
- {
- "name": "v",
- "type": "uint8[]"
- },
- {
- "name": "r",
- "type": "bytes32[]"
- },
- {
- "name": "s",
- "type": "bytes32[]"
- }
- ],
- "name": "batchFillOrders",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "orderAddresses",
- "type": "address[5][]"
- },
- {
- "name": "orderValues",
- "type": "uint256[6][]"
- },
- {
- "name": "cancelTakerTokenAmounts",
- "type": "uint256[]"
- }
- ],
- "name": "batchCancelOrders",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "orderAddresses",
- "type": "address[5]"
- },
- {
- "name": "orderValues",
- "type": "uint256[6]"
- },
- {
- "name": "fillTakerTokenAmount",
- "type": "uint256"
- },
- {
- "name": "shouldThrowOnInsufficientBalanceOrAllowance",
- "type": "bool"
- },
- {
- "name": "v",
- "type": "uint8"
- },
- {
- "name": "r",
- "type": "bytes32"
- },
- {
- "name": "s",
- "type": "bytes32"
- }
- ],
- "name": "fillOrder",
- "outputs": [
- {
- "name": "filledTakerTokenAmount",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "orderAddresses",
- "type": "address[5]"
- },
- {
- "name": "orderValues",
- "type": "uint256[6]"
- }
- ],
- "name": "getOrderHash",
- "outputs": [
- {
- "name": "",
- "type": "bytes32"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "EXTERNAL_QUERY_GAS_LIMIT",
- "outputs": [
- {
- "name": "",
- "type": "uint16"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "VERSION",
- "outputs": [
- {
- "name": "",
- "type": "string"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "inputs": [
- {
- "name": "_zrxToken",
- "type": "address"
- },
- {
- "name": "_tokenTransferProxy",
- "type": "address"
- }
- ],
- "payable": false,
- "type": "constructor"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "maker",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "taker",
- "type": "address"
- },
- {
- "indexed": true,
- "name": "feeRecipient",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "makerToken",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "takerToken",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "filledMakerTokenAmount",
- "type": "uint256"
- },
- {
- "indexed": false,
- "name": "filledTakerTokenAmount",
- "type": "uint256"
- },
- {
- "indexed": false,
- "name": "paidMakerFee",
- "type": "uint256"
- },
- {
- "indexed": false,
- "name": "paidTakerFee",
- "type": "uint256"
- },
- {
- "indexed": true,
- "name": "tokens",
- "type": "bytes32"
- },
- {
- "indexed": false,
- "name": "orderHash",
- "type": "bytes32"
+ "contract_name": "Exchange",
+ "abi": [
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "numerator",
+ "type": "uint256"
+ },
+ {
+ "name": "denominator",
+ "type": "uint256"
+ },
+ {
+ "name": "target",
+ "type": "uint256"
+ }
+ ],
+ "name": "isRoundingError",
+ "outputs": [
+ {
+ "name": "",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "",
+ "type": "bytes32"
+ }
+ ],
+ "name": "filled",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "",
+ "type": "bytes32"
+ }
+ ],
+ "name": "cancelled",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "orderAddresses",
+ "type": "address[5][]"
+ },
+ {
+ "name": "orderValues",
+ "type": "uint256[6][]"
+ },
+ {
+ "name": "fillTakerTokenAmount",
+ "type": "uint256"
+ },
+ {
+ "name": "shouldThrowOnInsufficientBalanceOrAllowance",
+ "type": "bool"
+ },
+ {
+ "name": "v",
+ "type": "uint8[]"
+ },
+ {
+ "name": "r",
+ "type": "bytes32[]"
+ },
+ {
+ "name": "s",
+ "type": "bytes32[]"
+ }
+ ],
+ "name": "fillOrdersUpTo",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "orderAddresses",
+ "type": "address[5]"
+ },
+ {
+ "name": "orderValues",
+ "type": "uint256[6]"
+ },
+ {
+ "name": "cancelTakerTokenAmount",
+ "type": "uint256"
+ }
+ ],
+ "name": "cancelOrder",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [],
+ "name": "ZRX_TOKEN_CONTRACT",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "orderAddresses",
+ "type": "address[5][]"
+ },
+ {
+ "name": "orderValues",
+ "type": "uint256[6][]"
+ },
+ {
+ "name": "fillTakerTokenAmounts",
+ "type": "uint256[]"
+ },
+ {
+ "name": "v",
+ "type": "uint8[]"
+ },
+ {
+ "name": "r",
+ "type": "bytes32[]"
+ },
+ {
+ "name": "s",
+ "type": "bytes32[]"
+ }
+ ],
+ "name": "batchFillOrKillOrders",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "orderAddresses",
+ "type": "address[5]"
+ },
+ {
+ "name": "orderValues",
+ "type": "uint256[6]"
+ },
+ {
+ "name": "fillTakerTokenAmount",
+ "type": "uint256"
+ },
+ {
+ "name": "v",
+ "type": "uint8"
+ },
+ {
+ "name": "r",
+ "type": "bytes32"
+ },
+ {
+ "name": "s",
+ "type": "bytes32"
+ }
+ ],
+ "name": "fillOrKillOrder",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "orderHash",
+ "type": "bytes32"
+ }
+ ],
+ "name": "getUnavailableTakerTokenAmount",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "signer",
+ "type": "address"
+ },
+ {
+ "name": "hash",
+ "type": "bytes32"
+ },
+ {
+ "name": "v",
+ "type": "uint8"
+ },
+ {
+ "name": "r",
+ "type": "bytes32"
+ },
+ {
+ "name": "s",
+ "type": "bytes32"
+ }
+ ],
+ "name": "isValidSignature",
+ "outputs": [
+ {
+ "name": "",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "numerator",
+ "type": "uint256"
+ },
+ {
+ "name": "denominator",
+ "type": "uint256"
+ },
+ {
+ "name": "target",
+ "type": "uint256"
+ }
+ ],
+ "name": "getPartialAmount",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [],
+ "name": "TOKEN_TRANSFER_PROXY_CONTRACT",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "orderAddresses",
+ "type": "address[5][]"
+ },
+ {
+ "name": "orderValues",
+ "type": "uint256[6][]"
+ },
+ {
+ "name": "fillTakerTokenAmounts",
+ "type": "uint256[]"
+ },
+ {
+ "name": "shouldThrowOnInsufficientBalanceOrAllowance",
+ "type": "bool"
+ },
+ {
+ "name": "v",
+ "type": "uint8[]"
+ },
+ {
+ "name": "r",
+ "type": "bytes32[]"
+ },
+ {
+ "name": "s",
+ "type": "bytes32[]"
+ }
+ ],
+ "name": "batchFillOrders",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "orderAddresses",
+ "type": "address[5][]"
+ },
+ {
+ "name": "orderValues",
+ "type": "uint256[6][]"
+ },
+ {
+ "name": "cancelTakerTokenAmounts",
+ "type": "uint256[]"
+ }
+ ],
+ "name": "batchCancelOrders",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "orderAddresses",
+ "type": "address[5]"
+ },
+ {
+ "name": "orderValues",
+ "type": "uint256[6]"
+ },
+ {
+ "name": "fillTakerTokenAmount",
+ "type": "uint256"
+ },
+ {
+ "name": "shouldThrowOnInsufficientBalanceOrAllowance",
+ "type": "bool"
+ },
+ {
+ "name": "v",
+ "type": "uint8"
+ },
+ {
+ "name": "r",
+ "type": "bytes32"
+ },
+ {
+ "name": "s",
+ "type": "bytes32"
+ }
+ ],
+ "name": "fillOrder",
+ "outputs": [
+ {
+ "name": "filledTakerTokenAmount",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "orderAddresses",
+ "type": "address[5]"
+ },
+ {
+ "name": "orderValues",
+ "type": "uint256[6]"
+ }
+ ],
+ "name": "getOrderHash",
+ "outputs": [
+ {
+ "name": "",
+ "type": "bytes32"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [],
+ "name": "EXTERNAL_QUERY_GAS_LIMIT",
+ "outputs": [
+ {
+ "name": "",
+ "type": "uint16"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [],
+ "name": "VERSION",
+ "outputs": [
+ {
+ "name": "",
+ "type": "string"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "inputs": [
+ {
+ "name": "_zrxToken",
+ "type": "address"
+ },
+ {
+ "name": "_tokenTransferProxy",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "constructor"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "maker",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "taker",
+ "type": "address"
+ },
+ {
+ "indexed": true,
+ "name": "feeRecipient",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "makerToken",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "takerToken",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "filledMakerTokenAmount",
+ "type": "uint256"
+ },
+ {
+ "indexed": false,
+ "name": "filledTakerTokenAmount",
+ "type": "uint256"
+ },
+ {
+ "indexed": false,
+ "name": "paidMakerFee",
+ "type": "uint256"
+ },
+ {
+ "indexed": false,
+ "name": "paidTakerFee",
+ "type": "uint256"
+ },
+ {
+ "indexed": true,
+ "name": "tokens",
+ "type": "bytes32"
+ },
+ {
+ "indexed": false,
+ "name": "orderHash",
+ "type": "bytes32"
+ }
+ ],
+ "name": "LogFill",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "maker",
+ "type": "address"
+ },
+ {
+ "indexed": true,
+ "name": "feeRecipient",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "makerToken",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "takerToken",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "cancelledMakerTokenAmount",
+ "type": "uint256"
+ },
+ {
+ "indexed": false,
+ "name": "cancelledTakerTokenAmount",
+ "type": "uint256"
+ },
+ {
+ "indexed": true,
+ "name": "tokens",
+ "type": "bytes32"
+ },
+ {
+ "indexed": false,
+ "name": "orderHash",
+ "type": "bytes32"
+ }
+ ],
+ "name": "LogCancel",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "errorId",
+ "type": "uint8"
+ },
+ {
+ "indexed": true,
+ "name": "orderHash",
+ "type": "bytes32"
+ }
+ ],
+ "name": "LogError",
+ "type": "event"
+ }
+ ],
+ "networks": {
+ "1": {
+ "address": "0x12459c951127e0c374ff9105dda097662a027093"
+ },
+ "3": {
+ "address": "0x479cc461fecd078f766ecc58533d6f69580cf3ac"
+ },
+ "42": {
+ "address": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364"
+ },
+ "50": {
+ "address": "0x48bacb9266a570d521063ef5dd96e61686dbe788"
}
- ],
- "name": "LogFill",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "maker",
- "type": "address"
- },
- {
- "indexed": true,
- "name": "feeRecipient",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "makerToken",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "takerToken",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "cancelledMakerTokenAmount",
- "type": "uint256"
- },
- {
- "indexed": false,
- "name": "cancelledTakerTokenAmount",
- "type": "uint256"
- },
- {
- "indexed": true,
- "name": "tokens",
- "type": "bytes32"
- },
- {
- "indexed": false,
- "name": "orderHash",
- "type": "bytes32"
- }
- ],
- "name": "LogCancel",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "errorId",
- "type": "uint8"
- },
- {
- "indexed": true,
- "name": "orderHash",
- "type": "bytes32"
- }
- ],
- "name": "LogError",
- "type": "event"
- }
- ],
- "networks": {
- "1": {
- "address": "0x12459c951127e0c374ff9105dda097662a027093"
- },
- "3": {
- "address": "0x479cc461fecd078f766ecc58533d6f69580cf3ac"
- },
- "42": {
- "address": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364"
- },
- "50": {
- "address": "0xb69e673309512a9d726f87304c6984054f87a93b"
}
- }
}
diff --git a/packages/0x.js/src/artifacts/Token.json b/packages/0x.js/src/artifacts/Token.json
index a86f8228d..3b5a86ae0 100644
--- a/packages/0x.js/src/artifacts/Token.json
+++ b/packages/0x.js/src/artifacts/Token.json
@@ -1,172 +1,172 @@
{
- "contract_name": "Token",
- "abi": [
- {
- "constant": false,
- "inputs": [
- {
- "name": "_spender",
- "type": "address"
+ "contract_name": "Token",
+ "abi": [
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_spender",
+ "type": "address"
+ },
+ {
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "approve",
+ "outputs": [
+ {
+ "name": "success",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "name": "_value",
- "type": "uint256"
- }
- ],
- "name": "approve",
- "outputs": [
- {
- "name": "success",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "totalSupply",
- "outputs": [
- {
- "name": "supply",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_from",
- "type": "address"
+ "constant": true,
+ "inputs": [],
+ "name": "totalSupply",
+ "outputs": [
+ {
+ "name": "supply",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "name": "_to",
- "type": "address"
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_from",
+ "type": "address"
+ },
+ {
+ "name": "_to",
+ "type": "address"
+ },
+ {
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "transferFrom",
+ "outputs": [
+ {
+ "name": "success",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "name": "_value",
- "type": "uint256"
- }
- ],
- "name": "transferFrom",
- "outputs": [
- {
- "name": "success",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_owner",
- "type": "address"
- }
- ],
- "name": "balanceOf",
- "outputs": [
- {
- "name": "balance",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_to",
- "type": "address"
+ "constant": true,
+ "inputs": [
+ {
+ "name": "_owner",
+ "type": "address"
+ }
+ ],
+ "name": "balanceOf",
+ "outputs": [
+ {
+ "name": "balance",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "name": "_value",
- "type": "uint256"
- }
- ],
- "name": "transfer",
- "outputs": [
- {
- "name": "success",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_owner",
- "type": "address"
- },
- {
- "name": "_spender",
- "type": "address"
- }
- ],
- "name": "allowance",
- "outputs": [
- {
- "name": "remaining",
- "type": "uint256"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "_from",
- "type": "address"
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_to",
+ "type": "address"
+ },
+ {
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "transfer",
+ "outputs": [
+ {
+ "name": "success",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "indexed": true,
- "name": "_to",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "_value",
- "type": "uint256"
- }
- ],
- "name": "Transfer",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "_owner",
- "type": "address"
+ "constant": true,
+ "inputs": [
+ {
+ "name": "_owner",
+ "type": "address"
+ },
+ {
+ "name": "_spender",
+ "type": "address"
+ }
+ ],
+ "name": "allowance",
+ "outputs": [
+ {
+ "name": "remaining",
+ "type": "uint256"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "indexed": true,
- "name": "_spender",
- "type": "address"
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "_from",
+ "type": "address"
+ },
+ {
+ "indexed": true,
+ "name": "_to",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "Transfer",
+ "type": "event"
},
{
- "indexed": false,
- "name": "_value",
- "type": "uint256"
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "_owner",
+ "type": "address"
+ },
+ {
+ "indexed": true,
+ "name": "_spender",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "_value",
+ "type": "uint256"
+ }
+ ],
+ "name": "Approval",
+ "type": "event"
}
- ],
- "name": "Approval",
- "type": "event"
- }
- ]
+ ]
}
diff --git a/packages/0x.js/src/artifacts/TokenRegistry.json b/packages/0x.js/src/artifacts/TokenRegistry.json
index 973a101e8..81780074c 100644
--- a/packages/0x.js/src/artifacts/TokenRegistry.json
+++ b/packages/0x.js/src/artifacts/TokenRegistry.json
@@ -1,544 +1,544 @@
{
- "contract_name": "TokenRegistry",
- "abi": [
- {
- "constant": false,
- "inputs": [
- {
- "name": "_token",
- "type": "address"
- },
- {
- "name": "_index",
- "type": "uint256"
- }
- ],
- "name": "removeToken",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_name",
- "type": "string"
- }
- ],
- "name": "getTokenAddressByName",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_symbol",
- "type": "string"
- }
- ],
- "name": "getTokenAddressBySymbol",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_token",
- "type": "address"
- },
- {
- "name": "_swarmHash",
- "type": "bytes"
- }
- ],
- "name": "setTokenSwarmHash",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_token",
- "type": "address"
- }
- ],
- "name": "getTokenMetaData",
- "outputs": [
- {
- "name": "",
- "type": "address"
- },
- {
- "name": "",
- "type": "string"
- },
- {
- "name": "",
- "type": "string"
- },
- {
- "name": "",
- "type": "uint8"
- },
- {
- "name": "",
- "type": "bytes"
- },
- {
- "name": "",
- "type": "bytes"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "owner",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_token",
- "type": "address"
- },
- {
- "name": "_name",
- "type": "string"
- },
- {
- "name": "_symbol",
- "type": "string"
- },
- {
- "name": "_decimals",
- "type": "uint8"
- },
- {
- "name": "_ipfsHash",
- "type": "bytes"
- },
- {
- "name": "_swarmHash",
- "type": "bytes"
- }
- ],
- "name": "addToken",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_token",
- "type": "address"
- },
- {
- "name": "_name",
- "type": "string"
- }
- ],
- "name": "setTokenName",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "name": "tokens",
- "outputs": [
- {
- "name": "token",
- "type": "address"
- },
- {
- "name": "name",
- "type": "string"
- },
- {
- "name": "symbol",
- "type": "string"
- },
- {
- "name": "decimals",
- "type": "uint8"
- },
- {
- "name": "ipfsHash",
- "type": "bytes"
- },
- {
- "name": "swarmHash",
- "type": "bytes"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "name": "tokenAddresses",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_name",
- "type": "string"
- }
- ],
- "name": "getTokenByName",
- "outputs": [
- {
- "name": "",
- "type": "address"
- },
- {
- "name": "",
- "type": "string"
- },
- {
- "name": "",
- "type": "string"
- },
- {
- "name": "",
- "type": "uint8"
- },
- {
- "name": "",
- "type": "bytes"
- },
- {
- "name": "",
- "type": "bytes"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "getTokenAddresses",
- "outputs": [
- {
- "name": "",
- "type": "address[]"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_token",
- "type": "address"
- },
- {
- "name": "_ipfsHash",
- "type": "bytes"
- }
- ],
- "name": "setTokenIpfsHash",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_symbol",
- "type": "string"
- }
- ],
- "name": "getTokenBySymbol",
- "outputs": [
- {
- "name": "",
- "type": "address"
- },
- {
- "name": "",
- "type": "string"
- },
- {
- "name": "",
- "type": "string"
- },
- {
- "name": "",
- "type": "uint8"
- },
- {
- "name": "",
- "type": "bytes"
- },
- {
- "name": "",
- "type": "bytes"
+ "contract_name": "TokenRegistry",
+ "abi": [
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_token",
+ "type": "address"
+ },
+ {
+ "name": "_index",
+ "type": "uint256"
+ }
+ ],
+ "name": "removeToken",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "_name",
+ "type": "string"
+ }
+ ],
+ "name": "getTokenAddressByName",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "_symbol",
+ "type": "string"
+ }
+ ],
+ "name": "getTokenAddressBySymbol",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_token",
+ "type": "address"
+ },
+ {
+ "name": "_swarmHash",
+ "type": "bytes"
+ }
+ ],
+ "name": "setTokenSwarmHash",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "_token",
+ "type": "address"
+ }
+ ],
+ "name": "getTokenMetaData",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ },
+ {
+ "name": "",
+ "type": "string"
+ },
+ {
+ "name": "",
+ "type": "string"
+ },
+ {
+ "name": "",
+ "type": "uint8"
+ },
+ {
+ "name": "",
+ "type": "bytes"
+ },
+ {
+ "name": "",
+ "type": "bytes"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [],
+ "name": "owner",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_token",
+ "type": "address"
+ },
+ {
+ "name": "_name",
+ "type": "string"
+ },
+ {
+ "name": "_symbol",
+ "type": "string"
+ },
+ {
+ "name": "_decimals",
+ "type": "uint8"
+ },
+ {
+ "name": "_ipfsHash",
+ "type": "bytes"
+ },
+ {
+ "name": "_swarmHash",
+ "type": "bytes"
+ }
+ ],
+ "name": "addToken",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_token",
+ "type": "address"
+ },
+ {
+ "name": "_name",
+ "type": "string"
+ }
+ ],
+ "name": "setTokenName",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "name": "tokens",
+ "outputs": [
+ {
+ "name": "token",
+ "type": "address"
+ },
+ {
+ "name": "name",
+ "type": "string"
+ },
+ {
+ "name": "symbol",
+ "type": "string"
+ },
+ {
+ "name": "decimals",
+ "type": "uint8"
+ },
+ {
+ "name": "ipfsHash",
+ "type": "bytes"
+ },
+ {
+ "name": "swarmHash",
+ "type": "bytes"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "name": "tokenAddresses",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "_name",
+ "type": "string"
+ }
+ ],
+ "name": "getTokenByName",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ },
+ {
+ "name": "",
+ "type": "string"
+ },
+ {
+ "name": "",
+ "type": "string"
+ },
+ {
+ "name": "",
+ "type": "uint8"
+ },
+ {
+ "name": "",
+ "type": "bytes"
+ },
+ {
+ "name": "",
+ "type": "bytes"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [],
+ "name": "getTokenAddresses",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address[]"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_token",
+ "type": "address"
+ },
+ {
+ "name": "_ipfsHash",
+ "type": "bytes"
+ }
+ ],
+ "name": "setTokenIpfsHash",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": true,
+ "inputs": [
+ {
+ "name": "_symbol",
+ "type": "string"
+ }
+ ],
+ "name": "getTokenBySymbol",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ },
+ {
+ "name": "",
+ "type": "string"
+ },
+ {
+ "name": "",
+ "type": "string"
+ },
+ {
+ "name": "",
+ "type": "uint8"
+ },
+ {
+ "name": "",
+ "type": "bytes"
+ },
+ {
+ "name": "",
+ "type": "bytes"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "_token",
+ "type": "address"
+ },
+ {
+ "name": "_symbol",
+ "type": "string"
+ }
+ ],
+ "name": "setTokenSymbol",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "newOwner",
+ "type": "address"
+ }
+ ],
+ "name": "transferOwnership",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "token",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "name",
+ "type": "string"
+ },
+ {
+ "indexed": false,
+ "name": "symbol",
+ "type": "string"
+ },
+ {
+ "indexed": false,
+ "name": "decimals",
+ "type": "uint8"
+ },
+ {
+ "indexed": false,
+ "name": "ipfsHash",
+ "type": "bytes"
+ },
+ {
+ "indexed": false,
+ "name": "swarmHash",
+ "type": "bytes"
+ }
+ ],
+ "name": "LogAddToken",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "token",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "name",
+ "type": "string"
+ },
+ {
+ "indexed": false,
+ "name": "symbol",
+ "type": "string"
+ },
+ {
+ "indexed": false,
+ "name": "decimals",
+ "type": "uint8"
+ },
+ {
+ "indexed": false,
+ "name": "ipfsHash",
+ "type": "bytes"
+ },
+ {
+ "indexed": false,
+ "name": "swarmHash",
+ "type": "bytes"
+ }
+ ],
+ "name": "LogRemoveToken",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "token",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "oldName",
+ "type": "string"
+ },
+ {
+ "indexed": false,
+ "name": "newName",
+ "type": "string"
+ }
+ ],
+ "name": "LogTokenNameChange",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "token",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "oldSymbol",
+ "type": "string"
+ },
+ {
+ "indexed": false,
+ "name": "newSymbol",
+ "type": "string"
+ }
+ ],
+ "name": "LogTokenSymbolChange",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "token",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "oldIpfsHash",
+ "type": "bytes"
+ },
+ {
+ "indexed": false,
+ "name": "newIpfsHash",
+ "type": "bytes"
+ }
+ ],
+ "name": "LogTokenIpfsHashChange",
+ "type": "event"
+ },
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "token",
+ "type": "address"
+ },
+ {
+ "indexed": false,
+ "name": "oldSwarmHash",
+ "type": "bytes"
+ },
+ {
+ "indexed": false,
+ "name": "newSwarmHash",
+ "type": "bytes"
+ }
+ ],
+ "name": "LogTokenSwarmHashChange",
+ "type": "event"
}
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_token",
- "type": "address"
+ ],
+ "networks": {
+ "1": {
+ "address": "0x926a74c5c36adf004c87399e65f75628b0f98d2c"
},
- {
- "name": "_symbol",
- "type": "string"
- }
- ],
- "name": "setTokenSymbol",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "newOwner",
- "type": "address"
- }
- ],
- "name": "transferOwnership",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "token",
- "type": "address"
+ "3": {
+ "address": "0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed"
},
- {
- "indexed": false,
- "name": "name",
- "type": "string"
+ "42": {
+ "address": "0xf18e504561f4347bea557f3d4558f559dddbae7f"
},
- {
- "indexed": false,
- "name": "symbol",
- "type": "string"
- },
- {
- "indexed": false,
- "name": "decimals",
- "type": "uint8"
- },
- {
- "indexed": false,
- "name": "ipfsHash",
- "type": "bytes"
- },
- {
- "indexed": false,
- "name": "swarmHash",
- "type": "bytes"
+ "50": {
+ "address": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082"
}
- ],
- "name": "LogAddToken",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "token",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "name",
- "type": "string"
- },
- {
- "indexed": false,
- "name": "symbol",
- "type": "string"
- },
- {
- "indexed": false,
- "name": "decimals",
- "type": "uint8"
- },
- {
- "indexed": false,
- "name": "ipfsHash",
- "type": "bytes"
- },
- {
- "indexed": false,
- "name": "swarmHash",
- "type": "bytes"
- }
- ],
- "name": "LogRemoveToken",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "token",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "oldName",
- "type": "string"
- },
- {
- "indexed": false,
- "name": "newName",
- "type": "string"
- }
- ],
- "name": "LogTokenNameChange",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "token",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "oldSymbol",
- "type": "string"
- },
- {
- "indexed": false,
- "name": "newSymbol",
- "type": "string"
- }
- ],
- "name": "LogTokenSymbolChange",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "token",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "oldIpfsHash",
- "type": "bytes"
- },
- {
- "indexed": false,
- "name": "newIpfsHash",
- "type": "bytes"
- }
- ],
- "name": "LogTokenIpfsHashChange",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "token",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "oldSwarmHash",
- "type": "bytes"
- },
- {
- "indexed": false,
- "name": "newSwarmHash",
- "type": "bytes"
- }
- ],
- "name": "LogTokenSwarmHashChange",
- "type": "event"
- }
- ],
- "networks": {
- "1": {
- "address": "0x926a74c5c36adf004c87399e65f75628b0f98d2c"
- },
- "3": {
- "address": "0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed"
- },
- "42": {
- "address": "0xf18e504561f4347bea557f3d4558f559dddbae7f"
- },
- "50": {
- "address": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082"
}
- }
}
diff --git a/packages/0x.js/src/artifacts/TokenTransferProxy.json b/packages/0x.js/src/artifacts/TokenTransferProxy.json
index 065343919..9b6a6cdf9 100644
--- a/packages/0x.js/src/artifacts/TokenTransferProxy.json
+++ b/packages/0x.js/src/artifacts/TokenTransferProxy.json
@@ -1,184 +1,184 @@
{
- "contract_name": "TokenTransferProxy",
- "abi": [
- {
- "constant": false,
- "inputs": [
- {
- "name": "token",
- "type": "address"
+ "contract_name": "TokenTransferProxy",
+ "abi": [
+ {
+ "constant": false,
+ "inputs": [
+ {
+ "name": "token",
+ "type": "address"
+ },
+ {
+ "name": "from",
+ "type": "address"
+ },
+ {
+ "name": "to",
+ "type": "address"
+ },
+ {
+ "name": "value",
+ "type": "uint256"
+ }
+ ],
+ "name": "transferFrom",
+ "outputs": [
+ {
+ "name": "",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "name": "from",
- "type": "address"
+ "constant": false,
+ "inputs": [
+ {
+ "name": "target",
+ "type": "address"
+ }
+ ],
+ "name": "addAuthorizedAddress",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
},
{
- "name": "to",
- "type": "address"
+ "constant": true,
+ "inputs": [
+ {
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "name": "authorities",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "function"
},
{
- "name": "value",
- "type": "uint256"
- }
- ],
- "name": "transferFrom",
- "outputs": [
- {
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "target",
- "type": "address"
- }
- ],
- "name": "addAuthorizedAddress",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "name": "authorities",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "target",
- "type": "address"
- }
- ],
- "name": "removeAuthorizedAddress",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "owner",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
+ "constant": false,
+ "inputs": [
+ {
+ "name": "target",
+ "type": "address"
+ }
+ ],
+ "name": "removeAuthorizedAddress",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "",
- "type": "address"
- }
- ],
- "name": "authorized",
- "outputs": [
+ "constant": true,
+ "inputs": [],
+ "name": "owner",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "getAuthorizedAddresses",
- "outputs": [
+ "constant": true,
+ "inputs": [
+ {
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "name": "authorized",
+ "outputs": [
+ {
+ "name": "",
+ "type": "bool"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "",
- "type": "address[]"
- }
- ],
- "payable": false,
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
+ "constant": true,
+ "inputs": [],
+ "name": "getAuthorizedAddresses",
+ "outputs": [
+ {
+ "name": "",
+ "type": "address[]"
+ }
+ ],
+ "payable": false,
+ "type": "function"
+ },
{
- "name": "newOwner",
- "type": "address"
- }
- ],
- "name": "transferOwnership",
- "outputs": [],
- "payable": false,
- "type": "function"
- },
- {
- "anonymous": false,
- "inputs": [
+ "constant": false,
+ "inputs": [
+ {
+ "name": "newOwner",
+ "type": "address"
+ }
+ ],
+ "name": "transferOwnership",
+ "outputs": [],
+ "payable": false,
+ "type": "function"
+ },
{
- "indexed": true,
- "name": "target",
- "type": "address"
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "target",
+ "type": "address"
+ },
+ {
+ "indexed": true,
+ "name": "caller",
+ "type": "address"
+ }
+ ],
+ "name": "LogAuthorizedAddressAdded",
+ "type": "event"
},
{
- "indexed": true,
- "name": "caller",
- "type": "address"
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "name": "target",
+ "type": "address"
+ },
+ {
+ "indexed": true,
+ "name": "caller",
+ "type": "address"
+ }
+ ],
+ "name": "LogAuthorizedAddressRemoved",
+ "type": "event"
}
- ],
- "name": "LogAuthorizedAddressAdded",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "target",
- "type": "address"
+ ],
+ "networks": {
+ "1": {
+ "address": "0x8da0d80f5007ef1e431dd2127178d224e32c2ef4"
},
- {
- "indexed": true,
- "name": "caller",
- "type": "address"
+ "3": {
+ "address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
+ },
+ "42": {
+ "address": "0x087eed4bc1ee3de49befbd66c662b434b15d49d4"
+ },
+ "50": {
+ "address": "0x1dc4c1cefef38a777b15aa20260a54e584b16c48"
}
- ],
- "name": "LogAuthorizedAddressRemoved",
- "type": "event"
}
- ],
- "networks": {
- "1": {
- "address": "0x8da0d80f5007ef1e431dd2127178d224e32c2ef4"
- },
- "3": {
- "address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
- },
- "42": {
- "address": "0x087eed4bc1ee3de49befbd66c662b434b15d49d4"
- },
- "50": {
- "address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
- }
- }
}
diff --git a/packages/0x.js/src/artifacts/ZRX.json b/packages/0x.js/src/artifacts/ZRX.json
index 7da67fde0..1bd973178 100644
--- a/packages/0x.js/src/artifacts/ZRX.json
+++ b/packages/0x.js/src/artifacts/ZRX.json
@@ -1,17 +1,17 @@
{
- "contract_name": "ZRX",
- "networks": {
- "1": {
- "address": "0xe41d2489571d322189246dafa5ebde1f4699f498"
- },
- "3": {
- "address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
- },
- "42": {
- "address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
- },
- "50": {
- "address": "0x25b8fe1de9daf8ba351890744ff28cf7dfa8f5e3"
+ "contract_name": "ZRX",
+ "networks": {
+ "1": {
+ "address": "0xe41d2489571d322189246dafa5ebde1f4699f498"
+ },
+ "3": {
+ "address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
+ },
+ "42": {
+ "address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
+ },
+ "50": {
+ "address": "0x1d7022f5b17d2f8b695918fb48fa1089c9f85401"
+ }
}
- }
}
diff --git a/packages/0x.js/src/bignumber_config.ts b/packages/0x.js/src/bignumber_config.ts
deleted file mode 100644
index 2d5214e6f..000000000
--- a/packages/0x.js/src/bignumber_config.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import BigNumber from 'bignumber.js';
-
-export const bigNumberConfigs = {
- configure() {
- // By default BigNumber's `toString` method converts to exponential notation if the value has
- // more then 20 digits. We want to avoid this behavior, so we set EXPONENTIAL_AT to a high number
- BigNumber.config({
- EXPONENTIAL_AT: 1000,
- });
- },
-};
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
index d56b8632d..27551c01d 100644
--- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
@@ -1,11 +1,13 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import {Block, BlockAndLogStreamer} from 'ethereumjs-blockstream';
+import { intervalUtils } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { Block, BlockAndLogStreamer } from 'ethereumjs-blockstream';
import * as _ from 'lodash';
import * as Web3 from 'web3';
import {
Artifact,
BlockParamLiteral,
+ BlockRange,
ContractEventArgs,
ContractEvents,
EventCallback,
@@ -13,15 +15,15 @@ import {
InternalZeroExError,
LogWithDecodedArgs,
RawLog,
- SubscriptionOpts,
ZeroExError,
} from '../types';
-import {AbiDecoder} from '../utils/abi_decoder';
-import {constants} from '../utils/constants';
-import {filterUtils} from '../utils/filter_utils';
-import {intervalUtils} from '../utils/interval_utils';
+import { AbiDecoder } from '../utils/abi_decoder';
+import { constants } from '../utils/constants';
+import { filterUtils } from '../utils/filter_utils';
-const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {[contractName: string]: ZeroExError} = {
+const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {
+ [contractName: string]: ZeroExError;
+} = {
ZRX: ZeroExError.ZRXContractDoesNotExist,
EtherToken: ZeroExError.EtherTokenContractDoesNotExist,
Token: ZeroExError.TokenContractDoesNotExist,
@@ -34,26 +36,25 @@ export class ContractWrapper {
protected _web3Wrapper: Web3Wrapper;
private _networkId: number;
private _abiDecoder?: AbiDecoder;
- private _blockAndLogStreamer: BlockAndLogStreamer|undefined;
+ private _blockAndLogStreamerIfExists: BlockAndLogStreamer | undefined;
private _blockAndLogStreamInterval: NodeJS.Timer;
- private _filters: {[filterToken: string]: Web3.FilterObject};
- private _filterCallbacks: {[filterToken: string]: EventCallback<ContractEventArgs>};
- private _onLogAddedSubscriptionToken: string|undefined;
- private _onLogRemovedSubscriptionToken: string|undefined;
+ private _filters: { [filterToken: string]: Web3.FilterObject };
+ private _filterCallbacks: {
+ [filterToken: string]: EventCallback<ContractEventArgs>;
+ };
+ private _onLogAddedSubscriptionToken: string | undefined;
+ private _onLogRemovedSubscriptionToken: string | undefined;
constructor(web3Wrapper: Web3Wrapper, networkId: number, abiDecoder?: AbiDecoder) {
this._web3Wrapper = web3Wrapper;
this._networkId = networkId;
this._abiDecoder = abiDecoder;
this._filters = {};
this._filterCallbacks = {};
- this._blockAndLogStreamer = undefined;
+ this._blockAndLogStreamerIfExists = undefined;
this._onLogAddedSubscriptionToken = undefined;
this._onLogRemovedSubscriptionToken = undefined;
}
- /**
- * Cancels all existing subscriptions
- */
- public unsubscribeAll(): void {
+ protected unsubscribeAll(): void {
const filterTokens = _.keys(this._filterCallbacks);
_.each(filterTokens, filterToken => {
this._unsubscribe(filterToken);
@@ -74,27 +75,36 @@ export class ContractWrapper {
}
}
protected _subscribe<ArgsType extends ContractEventArgs>(
- address: string, eventName: ContractEvents, indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi,
- callback: EventCallback<ArgsType>): string {
+ address: string,
+ eventName: ContractEvents,
+ indexFilterValues: IndexedFilterValues,
+ abi: Web3.ContractAbi,
+ callback: EventCallback<ArgsType>,
+ ): string {
const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi);
- if (_.isUndefined(this._blockAndLogStreamer)) {
+ if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
this._startBlockAndLogStream();
}
const filterToken = filterUtils.generateUUID();
this._filters[filterToken] = filter;
- this._filterCallbacks[filterToken] = callback;
+ this._filterCallbacks[filterToken] = callback as EventCallback<ContractEventArgs>;
return filterToken;
}
protected async _getLogsAsync<ArgsType extends ContractEventArgs>(
- address: string, eventName: ContractEvents, subscriptionOpts: SubscriptionOpts,
- indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
- const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, subscriptionOpts);
+ address: string,
+ eventName: ContractEvents,
+ blockRange: BlockRange,
+ indexFilterValues: IndexedFilterValues,
+ abi: Web3.ContractAbi,
+ ): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
+ const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, blockRange);
const logs = await this._web3Wrapper.getLogsAsync(filter);
const logsWithDecodedArguments = _.map(logs, this._tryToDecodeLogOrNoop.bind(this));
return logsWithDecodedArguments;
}
protected _tryToDecodeLogOrNoop<ArgsType extends ContractEventArgs>(
- log: Web3.LogEntry): LogWithDecodedArgs<ArgsType>|RawLog {
+ log: Web3.LogEntry,
+ ): LogWithDecodedArgs<ArgsType> | RawLog {
if (_.isUndefined(this._abiDecoder)) {
throw new Error(InternalZeroExError.NoAbiDecoder);
}
@@ -102,7 +112,8 @@ export class ContractWrapper {
return logWithDecodedArgs;
}
protected async _instantiateContractIfExistsAsync(
- artifact: Artifact, addressIfExists?: string,
+ artifact: Artifact,
+ addressIfExists?: string,
): Promise<Web3.ContractInstance> {
let contractAddress: string;
if (_.isUndefined(addressIfExists)) {
@@ -117,9 +128,7 @@ export class ContractWrapper {
if (!doesContractExist) {
throw new Error(CONTRACT_NAME_TO_NOT_FOUND_ERROR[artifact.contract_name]);
}
- const contractInstance = this._web3Wrapper.getContractInstance(
- artifact.abi, contractAddress,
- );
+ const contractInstance = this._web3Wrapper.getContractInstance(artifact.abi, contractAddress);
return contractInstance;
}
protected _getContractAddress(artifact: Artifact, addressIfExists?: string): string {
@@ -146,45 +155,53 @@ export class ContractWrapper {
});
}
private _startBlockAndLogStream(): void {
- this._blockAndLogStreamer = new BlockAndLogStreamer(
+ if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
+ throw new Error(ZeroExError.SubscriptionAlreadyPresent);
+ }
+ this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper),
this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper),
);
const catchAllLogFilter = {};
- this._blockAndLogStreamer.addLogFilter(catchAllLogFilter);
+ this._blockAndLogStreamerIfExists.addLogFilter(catchAllLogFilter);
this._blockAndLogStreamInterval = intervalUtils.setAsyncExcludingInterval(
- this._reconcileBlockAsync.bind(this), constants.DEFAULT_BLOCK_POLLING_INTERVAL,
+ this._reconcileBlockAsync.bind(this),
+ constants.DEFAULT_BLOCK_POLLING_INTERVAL,
+ this._onReconcileBlockError.bind(this),
);
let isRemoved = false;
- this._onLogAddedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogAdded(
+ this._onLogAddedSubscriptionToken = this._blockAndLogStreamerIfExists.subscribeToOnLogAdded(
this._onLogStateChanged.bind(this, isRemoved),
);
isRemoved = true;
- this._onLogRemovedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogRemoved(
+ this._onLogRemovedSubscriptionToken = this._blockAndLogStreamerIfExists.subscribeToOnLogRemoved(
this._onLogStateChanged.bind(this, isRemoved),
);
}
+ private _onReconcileBlockError(err: Error): void {
+ const filterTokens = _.keys(this._filterCallbacks);
+ _.each(filterTokens, filterToken => {
+ this._unsubscribe(filterToken, err);
+ });
+ }
+ private _setNetworkId(networkId: number): void {
+ this._networkId = networkId;
+ }
private _stopBlockAndLogStream(): void {
- (this._blockAndLogStreamer as BlockAndLogStreamer).unsubscribeFromOnLogAdded(
- this._onLogAddedSubscriptionToken as string);
- (this._blockAndLogStreamer as BlockAndLogStreamer).unsubscribeFromOnLogRemoved(
- this._onLogRemovedSubscriptionToken as string);
+ if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
+ throw new Error(ZeroExError.SubscriptionNotFound);
+ }
+ this._blockAndLogStreamerIfExists.unsubscribeFromOnLogAdded(this._onLogAddedSubscriptionToken as string);
+ this._blockAndLogStreamerIfExists.unsubscribeFromOnLogRemoved(this._onLogRemovedSubscriptionToken as string);
intervalUtils.clearAsyncExcludingInterval(this._blockAndLogStreamInterval);
- delete this._blockAndLogStreamer;
+ delete this._blockAndLogStreamerIfExists;
}
private async _reconcileBlockAsync(): Promise<void> {
- try {
- const latestBlock = await this._web3Wrapper.getBlockAsync(BlockParamLiteral.Latest);
- // We need to coerce to Block type cause Web3.Block includes types for mempool blocks
- if (!_.isUndefined(this._blockAndLogStreamer)) {
- // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined
- await this._blockAndLogStreamer.reconcileNewBlock(latestBlock as any as Block);
- }
- } catch (err) {
- const filterTokens = _.keys(this._filterCallbacks);
- _.each(filterTokens, filterToken => {
- this._unsubscribe(filterToken, err);
- });
+ const latestBlock = await this._web3Wrapper.getBlockAsync(BlockParamLiteral.Latest);
+ // We need to coerce to Block type cause Web3.Block includes types for mempool blocks
+ if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
+ // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined
+ await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlock as any) as Block);
}
}
}
diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
index 896cfde3d..b03571636 100644
--- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
@@ -1,40 +1,54 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+import { schemas } from '@0xproject/json-schemas';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import {artifacts} from '../artifacts';
-import {TransactionOpts, ZeroExError} from '../types';
-import {assert} from '../utils/assert';
+import { artifacts } from '../artifacts';
+import {
+ BlockRange,
+ EtherTokenContractEventArgs,
+ EtherTokenEvents,
+ EventCallback,
+ IndexedFilterValues,
+ LogWithDecodedArgs,
+ TransactionOpts,
+ ZeroExError,
+} from '../types';
+import { AbiDecoder } from '../utils/abi_decoder';
+import { assert } from '../utils/assert';
-import {ContractWrapper} from './contract_wrapper';
-import {EtherTokenContract} from './generated/ether_token';
-import {TokenWrapper} from './token_wrapper';
+import { ContractWrapper } from './contract_wrapper';
+import { EtherTokenContract } from './generated/ether_token';
+import { TokenWrapper } from './token_wrapper';
/**
* This class includes all the functionality related to interacting with a wrapped Ether ERC20 token contract.
* The caller can convert ETH into the equivalent number of wrapped ETH ERC20 tokens and back.
*/
export class EtherTokenWrapper extends ContractWrapper {
- private _etherTokenContractIfExists?: EtherTokenContract;
+ private _etherTokenContractsByAddress: {
+ [address: string]: EtherTokenContract;
+ } = {};
private _tokenWrapper: TokenWrapper;
- private _contractAddressIfExists?: string;
- constructor(web3Wrapper: Web3Wrapper, networkId: number, tokenWrapper: TokenWrapper,
- contractAddressIfExists?: string) {
- super(web3Wrapper, networkId);
+ constructor(web3Wrapper: Web3Wrapper, networkId: number, abiDecoder: AbiDecoder, tokenWrapper: TokenWrapper) {
+ super(web3Wrapper, networkId, abiDecoder);
this._tokenWrapper = tokenWrapper;
- this._contractAddressIfExists = contractAddressIfExists;
}
/**
* Deposit ETH into the Wrapped ETH smart contract and issues the equivalent number of wrapped ETH tokens
* to the depositor address. These wrapped ETH tokens can be used in 0x trades and are redeemable for 1-to-1
* for ETH.
- * @param amountInWei Amount of ETH in Wei the caller wishes to deposit.
- * @param depositor The hex encoded user Ethereum address that would like to make the deposit.
- * @param txOpts Transaction parameters.
+ * @param etherTokenAddress EtherToken address you wish to deposit into.
+ * @param amountInWei Amount of ETH in Wei the caller wishes to deposit.
+ * @param depositor The hex encoded user Ethereum address that would like to make the deposit.
+ * @param txOpts Transaction parameters.
* @return Transaction hash.
*/
public async depositAsync(
- amountInWei: BigNumber, depositor: string, txOpts: TransactionOpts = {},
+ etherTokenAddress: string,
+ amountInWei: BigNumber,
+ depositor: string,
+ txOpts: TransactionOpts = {},
): Promise<string> {
assert.isValidBaseUnitAmount('amountInWei', amountInWei);
await assert.isSenderAddressAsync('depositor', depositor, this._web3Wrapper);
@@ -42,7 +56,7 @@ export class EtherTokenWrapper extends ContractWrapper {
const ethBalanceInWei = await this._web3Wrapper.getBalanceInWeiAsync(depositor);
assert.assert(ethBalanceInWei.gte(amountInWei), ZeroExError.InsufficientEthBalanceForDeposit);
- const wethContract = await this._getEtherTokenContractAsync();
+ const wethContract = await this._getEtherTokenContractAsync(etherTokenAddress);
const txHash = await wethContract.deposit.sendTransactionAsync({
from: depositor,
value: amountInWei,
@@ -54,22 +68,25 @@ export class EtherTokenWrapper extends ContractWrapper {
/**
* Withdraw ETH to the withdrawer's address from the wrapped ETH smart contract in exchange for the
* equivalent number of wrapped ETH tokens.
+ * @param etherTokenAddress EtherToken address you wish to withdraw from.
* @param amountInWei Amount of ETH in Wei the caller wishes to withdraw.
* @param withdrawer The hex encoded user Ethereum address that would like to make the withdrawl.
* @param txOpts Transaction parameters.
* @return Transaction hash.
*/
public async withdrawAsync(
- amountInWei: BigNumber, withdrawer: string, txOpts: TransactionOpts = {},
+ etherTokenAddress: string,
+ amountInWei: BigNumber,
+ withdrawer: string,
+ txOpts: TransactionOpts = {},
): Promise<string> {
assert.isValidBaseUnitAmount('amountInWei', amountInWei);
await assert.isSenderAddressAsync('withdrawer', withdrawer, this._web3Wrapper);
- const wethContractAddress = this.getContractAddress();
- const WETHBalanceInBaseUnits = await this._tokenWrapper.getBalanceAsync(wethContractAddress, withdrawer);
+ const WETHBalanceInBaseUnits = await this._tokenWrapper.getBalanceAsync(etherTokenAddress, withdrawer);
assert.assert(WETHBalanceInBaseUnits.gte(amountInWei), ZeroExError.InsufficientWEthBalanceForWithdrawal);
- const wethContract = await this._getEtherTokenContractAsync();
+ const wethContract = await this._getEtherTokenContractAsync(etherTokenAddress);
const txHash = await wethContract.withdraw.sendTransactionAsync(amountInWei, {
from: withdrawer,
gas: txOpts.gasLimit,
@@ -78,27 +95,90 @@ export class EtherTokenWrapper extends ContractWrapper {
return txHash;
}
/**
- * Retrieves the Wrapped Ether token contract address
- * @return The Wrapped Ether token contract address
+ * Gets historical logs without creating a subscription
+ * @param etherTokenAddress An address of the ether token that emmited the logs.
+ * @param eventName The ether token contract event you would like to subscribe to.
+ * @param blockRange Block range to get logs from.
+ * @param indexFilterValues An object where the keys are indexed args returned by the event and
+ * the value is the value you are interested in. E.g `{_owner: aUserAddressHex}`
+ * @return Array of logs that match the parameters
*/
- public getContractAddress(): string {
- const contractAddress = this._getContractAddress(
- artifacts.EtherTokenArtifact, this._contractAddressIfExists,
+ public async getLogsAsync<ArgsType extends EtherTokenContractEventArgs>(
+ etherTokenAddress: string,
+ eventName: EtherTokenEvents,
+ blockRange: BlockRange,
+ indexFilterValues: IndexedFilterValues,
+ ): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
+ assert.isETHAddressHex('etherTokenAddress', etherTokenAddress);
+ assert.doesBelongToStringEnum('eventName', eventName, EtherTokenEvents);
+ assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
+ assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
+ const logs = await this._getLogsAsync<ArgsType>(
+ etherTokenAddress,
+ eventName,
+ blockRange,
+ indexFilterValues,
+ artifacts.EtherTokenArtifact.abi,
);
- return contractAddress;
+ return logs;
+ }
+ /**
+ * Subscribe to an event type emitted by the Token contract.
+ * @param etherTokenAddress The hex encoded address where the ether token is deployed.
+ * @param eventName The ether token contract event you would like to subscribe to.
+ * @param indexFilterValues An object where the keys are indexed args returned by the event and
+ * the value is the value you are interested in. E.g `{_owner: aUserAddressHex}`
+ * @param callback Callback that gets called when a log is added/removed
+ * @return Subscription token used later to unsubscribe
+ */
+ public subscribe<ArgsType extends EtherTokenContractEventArgs>(
+ etherTokenAddress: string,
+ eventName: EtherTokenEvents,
+ indexFilterValues: IndexedFilterValues,
+ callback: EventCallback<ArgsType>,
+ ): string {
+ assert.isETHAddressHex('etherTokenAddress', etherTokenAddress);
+ assert.doesBelongToStringEnum('eventName', eventName, EtherTokenEvents);
+ assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
+ assert.isFunction('callback', callback);
+ const subscriptionToken = this._subscribe<ArgsType>(
+ etherTokenAddress,
+ eventName,
+ indexFilterValues,
+ artifacts.EtherTokenArtifact.abi,
+ callback,
+ );
+ return subscriptionToken;
+ }
+ /**
+ * Cancel a subscription
+ * @param subscriptionToken Subscription token returned by `subscribe()`
+ */
+ public unsubscribe(subscriptionToken: string): void {
+ this._unsubscribe(subscriptionToken);
+ }
+ /**
+ * Cancels all existing subscriptions
+ */
+ public unsubscribeAll(): void {
+ super.unsubscribeAll();
}
private _invalidateContractInstance(): void {
- delete this._etherTokenContractIfExists;
+ this.unsubscribeAll();
+ this._etherTokenContractsByAddress = {};
}
- private async _getEtherTokenContractAsync(): Promise<EtherTokenContract> {
- if (!_.isUndefined(this._etherTokenContractIfExists)) {
- return this._etherTokenContractIfExists;
+ private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<EtherTokenContract> {
+ let etherTokenContract = this._etherTokenContractsByAddress[etherTokenAddress];
+ if (!_.isUndefined(etherTokenContract)) {
+ return etherTokenContract;
}
const web3ContractInstance = await this._instantiateContractIfExistsAsync(
- artifacts.EtherTokenArtifact, this._contractAddressIfExists,
+ artifacts.EtherTokenArtifact,
+ etherTokenAddress,
);
const contractInstance = new EtherTokenContract(web3ContractInstance, this._web3Wrapper.getContractDefaults());
- this._etherTokenContractIfExists = contractInstance;
- return this._etherTokenContractIfExists;
+ etherTokenContract = contractInstance;
+ this._etherTokenContractsByAddress[etherTokenAddress] = etherTokenContract;
+ return etherTokenContract;
}
}
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index 1e9865395..2b6117729 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -1,12 +1,13 @@
-import {schemas} from '@0xproject/json-schemas';
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+import { schemas } from '@0xproject/json-schemas';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import * as Web3 from 'web3';
-import {artifacts} from '../artifacts';
+import { artifacts } from '../artifacts';
import {
BlockParamLiteral,
+ BlockRange,
DecodedLogArgs,
ECSignature,
EventCallback,
@@ -15,9 +16,7 @@ import {
ExchangeContractEventArgs,
ExchangeEvents,
IndexedFilterValues,
- LogCancelContractEventArgs,
LogErrorContractEventArgs,
- LogFillContractEventArgs,
LogWithDecodedArgs,
MethodOpts,
Order,
@@ -26,21 +25,19 @@ import {
OrderFillRequest,
OrderTransactionOpts,
OrderValues,
- RawLog,
SignedOrder,
- SubscriptionOpts,
ValidateOrderFillableOpts,
} from '../types';
-import {AbiDecoder} from '../utils/abi_decoder';
-import {assert} from '../utils/assert';
-import {decorators} from '../utils/decorators';
-import {ExchangeTransferSimulator} from '../utils/exchange_transfer_simulator';
-import {OrderValidationUtils} from '../utils/order_validation_utils';
-import {utils} from '../utils/utils';
+import { AbiDecoder } from '../utils/abi_decoder';
+import { assert } from '../utils/assert';
+import { decorators } from '../utils/decorators';
+import { ExchangeTransferSimulator } from '../utils/exchange_transfer_simulator';
+import { OrderValidationUtils } from '../utils/order_validation_utils';
+import { utils } from '../utils/utils';
-import {ContractWrapper} from './contract_wrapper';
-import {ExchangeContract} from './generated/exchange';
-import {TokenWrapper} from './token_wrapper';
+import { ContractWrapper } from './contract_wrapper';
+import { ExchangeContract } from './generated/exchange';
+import { TokenWrapper } from './token_wrapper';
const SHOULD_VALIDATE_BY_DEFAULT = true;
@@ -84,12 +81,19 @@ export class ExchangeWrapper extends ContractWrapper {
];
return [orderAddresses, orderValues];
}
- constructor(web3Wrapper: Web3Wrapper, networkId: number, abiDecoder: AbiDecoder,
- tokenWrapper: TokenWrapper, contractAddressIfExists?: string) {
+ constructor(
+ web3Wrapper: Web3Wrapper,
+ networkId: number,
+ abiDecoder: AbiDecoder,
+ tokenWrapper: TokenWrapper,
+ contractAddressIfExists?: string,
+ zrxContractAddressIfExists?: string,
+ ) {
super(web3Wrapper, networkId, abiDecoder);
this._tokenWrapper = tokenWrapper;
- this._orderValidationUtils = new OrderValidationUtils(tokenWrapper, this);
+ this._orderValidationUtils = new OrderValidationUtils(this);
this._contractAddressIfExists = contractAddressIfExists;
+ this._zrxContractAddressIfExists = zrxContractAddressIfExists;
}
/**
* Returns the unavailable takerAmount of an order. Unavailable amount is defined as the total
@@ -100,14 +104,14 @@ export class ExchangeWrapper extends ContractWrapper {
* @param methodOpts Optional arguments this method accepts.
* @return The amount of the order (in taker tokens) that has either been filled or cancelled.
*/
- public async getUnavailableTakerAmountAsync(orderHash: string,
- methodOpts?: MethodOpts): Promise<BigNumber> {
+ public async getUnavailableTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber> {
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const exchangeContract = await this._getExchangeContractAsync();
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.callAsync(
- orderHash, defaultBlock,
+ orderHash,
+ defaultBlock,
);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
unavailableTakerTokenAmount = new BigNumber(unavailableTakerTokenAmount);
@@ -165,25 +169,33 @@ export class ExchangeWrapper extends ContractWrapper {
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
- @decorators.contractCallErrorHandler
- public async fillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber,
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {}): Promise<string> {
+ @decorators.asyncZeroExErrorHandler
+ public async fillOrderAsync(
+ signedOrder: SignedOrder,
+ fillTakerTokenAmount: BigNumber,
+ shouldThrowOnInsufficientBalanceOrAllowance: boolean,
+ takerAddress: string,
+ orderTransactionOpts: OrderTransactionOpts = {},
+ ): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const exchangeInstance = await this._getExchangeContractAsync();
- const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate) ?
- SHOULD_VALIDATE_BY_DEFAULT :
- orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
+ ? SHOULD_VALIDATE_BY_DEFAULT
+ : orderTransactionOpts.shouldValidate;
if (shouldValidate) {
const zrxTokenAddress = this.getZRXTokenAddress();
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress);
+ exchangeTradeEmulator,
+ signedOrder,
+ fillTakerTokenAmount,
+ takerAddress,
+ zrxTokenAddress,
+ );
}
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder);
@@ -221,31 +233,45 @@ export class ExchangeWrapper extends ContractWrapper {
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
- @decorators.contractCallErrorHandler
- public async fillOrdersUpToAsync(signedOrders: SignedOrder[], fillTakerTokenAmount: BigNumber,
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {}): Promise<string> {
+ @decorators.asyncZeroExErrorHandler
+ public async fillOrdersUpToAsync(
+ signedOrders: SignedOrder[],
+ fillTakerTokenAmount: BigNumber,
+ shouldThrowOnInsufficientBalanceOrAllowance: boolean,
+ takerAddress: string,
+ orderTransactionOpts: OrderTransactionOpts = {},
+ ): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
const takerTokenAddresses = _.map(signedOrders, signedOrder => signedOrder.takerTokenAddress);
- assert.hasAtMostOneUniqueValue(takerTokenAddresses,
- ExchangeContractErrs.MultipleTakerTokensInFillUpToDisallowed);
+ assert.hasAtMostOneUniqueValue(
+ takerTokenAddresses,
+ ExchangeContractErrs.MultipleTakerTokensInFillUpToDisallowed,
+ );
const exchangeContractAddresses = _.map(signedOrders, signedOrder => signedOrder.exchangeContractAddress);
- assert.hasAtMostOneUniqueValue(exchangeContractAddresses,
- ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress);
+ assert.hasAtMostOneUniqueValue(
+ exchangeContractAddresses,
+ ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
+ );
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
- const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate) ?
- SHOULD_VALIDATE_BY_DEFAULT :
- orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
+ ? SHOULD_VALIDATE_BY_DEFAULT
+ : orderTransactionOpts.shouldValidate;
if (shouldValidate) {
+ let filledTakerTokenAmount = new BigNumber(0);
const zrxTokenAddress = this.getZRXTokenAddress();
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
for (const signedOrder of signedOrders) {
- await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress);
+ const singleFilledTakerTokenAmount = await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
+ exchangeTradeEmulator,
+ signedOrder,
+ fillTakerTokenAmount.minus(filledTakerTokenAmount),
+ takerAddress,
+ zrxTokenAddress,
+ );
+ filledTakerTokenAmount = filledTakerTokenAmount.plus(singleFilledTakerTokenAmount);
}
}
@@ -302,30 +328,37 @@ export class ExchangeWrapper extends ContractWrapper {
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
- @decorators.contractCallErrorHandler
- public async batchFillOrdersAsync(orderFillRequests: OrderFillRequest[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {}): Promise<string> {
+ @decorators.asyncZeroExErrorHandler
+ public async batchFillOrdersAsync(
+ orderFillRequests: OrderFillRequest[],
+ shouldThrowOnInsufficientBalanceOrAllowance: boolean,
+ takerAddress: string,
+ orderTransactionOpts: OrderTransactionOpts = {},
+ ): Promise<string> {
assert.doesConformToSchema('orderFillRequests', orderFillRequests, schemas.orderFillRequestsSchema);
const exchangeContractAddresses = _.map(
orderFillRequests,
orderFillRequest => orderFillRequest.signedOrder.exchangeContractAddress,
);
- assert.hasAtMostOneUniqueValue(exchangeContractAddresses,
- ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress);
+ assert.hasAtMostOneUniqueValue(
+ exchangeContractAddresses,
+ ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
+ );
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
- const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate) ?
- SHOULD_VALIDATE_BY_DEFAULT :
- orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
+ ? SHOULD_VALIDATE_BY_DEFAULT
+ : orderTransactionOpts.shouldValidate;
if (shouldValidate) {
const zrxTokenAddress = this.getZRXTokenAddress();
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
for (const orderFillRequest of orderFillRequests) {
await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator, orderFillRequest.signedOrder, orderFillRequest.takerTokenFillAmount,
- takerAddress, zrxTokenAddress,
+ exchangeTradeEmulator,
+ orderFillRequest.signedOrder,
+ orderFillRequest.takerTokenFillAmount,
+ takerAddress,
+ zrxTokenAddress,
);
}
}
@@ -375,24 +408,32 @@ export class ExchangeWrapper extends ContractWrapper {
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
- @decorators.contractCallErrorHandler
- public async fillOrKillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber,
- takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {}): Promise<string> {
+ @decorators.asyncZeroExErrorHandler
+ public async fillOrKillOrderAsync(
+ signedOrder: SignedOrder,
+ fillTakerTokenAmount: BigNumber,
+ takerAddress: string,
+ orderTransactionOpts: OrderTransactionOpts = {},
+ ): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const exchangeInstance = await this._getExchangeContractAsync();
- const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate) ?
- SHOULD_VALIDATE_BY_DEFAULT :
- orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
+ ? SHOULD_VALIDATE_BY_DEFAULT
+ : orderTransactionOpts.shouldValidate;
if (shouldValidate) {
const zrxTokenAddress = this.getZRXTokenAddress();
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress);
+ exchangeTradeEmulator,
+ signedOrder,
+ fillTakerTokenAmount,
+ takerAddress,
+ zrxTokenAddress,
+ );
}
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder);
@@ -420,34 +461,40 @@ export class ExchangeWrapper extends ContractWrapper {
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
- @decorators.contractCallErrorHandler
- public async batchFillOrKillAsync(orderFillRequests: OrderFillRequest[],
- takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {}): Promise<string> {
- assert.doesConformToSchema('orderFillRequests', orderFillRequests,
- schemas.orderFillRequestsSchema);
+ @decorators.asyncZeroExErrorHandler
+ public async batchFillOrKillAsync(
+ orderFillRequests: OrderFillRequest[],
+ takerAddress: string,
+ orderTransactionOpts: OrderTransactionOpts = {},
+ ): Promise<string> {
+ assert.doesConformToSchema('orderFillRequests', orderFillRequests, schemas.orderFillRequestsSchema);
const exchangeContractAddresses = _.map(
orderFillRequests,
orderFillRequest => orderFillRequest.signedOrder.exchangeContractAddress,
);
- assert.hasAtMostOneUniqueValue(exchangeContractAddresses,
- ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress);
+ assert.hasAtMostOneUniqueValue(
+ exchangeContractAddresses,
+ ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
+ );
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
if (_.isEmpty(orderFillRequests)) {
throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
}
const exchangeInstance = await this._getExchangeContractAsync();
- const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate) ?
- SHOULD_VALIDATE_BY_DEFAULT :
- orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
+ ? SHOULD_VALIDATE_BY_DEFAULT
+ : orderTransactionOpts.shouldValidate;
if (shouldValidate) {
const zrxTokenAddress = this.getZRXTokenAddress();
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
for (const orderFillRequest of orderFillRequests) {
await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator, orderFillRequest.signedOrder, orderFillRequest.takerTokenFillAmount,
- takerAddress, zrxTokenAddress,
+ exchangeTradeEmulator,
+ orderFillRequest.signedOrder,
+ orderFillRequest.takerTokenFillAmount,
+ takerAddress,
+ zrxTokenAddress,
);
}
}
@@ -463,8 +510,9 @@ export class ExchangeWrapper extends ContractWrapper {
});
// We use _.unzip<any> because _.unzip doesn't type check if values have different types :'(
- const [orderAddresses, orderValues, fillTakerTokenAmounts, vParams, rParams, sParams] =
- _.unzip<any>(orderAddressesValuesAndTakerTokenFillAmounts);
+ const [orderAddresses, orderValues, fillTakerTokenAmounts, vParams, rParams, sParams] = _.unzip<any>(
+ orderAddressesValuesAndTakerTokenFillAmounts,
+ );
const txHash = await exchangeInstance.batchFillOrKillOrders.sendTransactionAsync(
orderAddresses,
orderValues,
@@ -488,24 +536,29 @@ export class ExchangeWrapper extends ContractWrapper {
* @param transactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
- @decorators.contractCallErrorHandler
- public async cancelOrderAsync(order: Order|SignedOrder,
- cancelTakerTokenAmount: BigNumber,
- orderTransactionOpts: OrderTransactionOpts = {}): Promise<string> {
+ @decorators.asyncZeroExErrorHandler
+ public async cancelOrderAsync(
+ order: Order | SignedOrder,
+ cancelTakerTokenAmount: BigNumber,
+ orderTransactionOpts: OrderTransactionOpts = {},
+ ): Promise<string> {
assert.doesConformToSchema('order', order, schemas.orderSchema);
assert.isValidBaseUnitAmount('takerTokenCancelAmount', cancelTakerTokenAmount);
await assert.isSenderAddressAsync('order.maker', order.maker, this._web3Wrapper);
const exchangeInstance = await this._getExchangeContractAsync();
- const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate) ?
- SHOULD_VALIDATE_BY_DEFAULT :
- orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
+ ? SHOULD_VALIDATE_BY_DEFAULT
+ : orderTransactionOpts.shouldValidate;
if (shouldValidate) {
const orderHash = utils.getOrderHashHex(order);
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
- order, cancelTakerTokenAmount, unavailableTakerTokenAmount);
+ order,
+ cancelTakerTokenAmount,
+ unavailableTakerTokenAmount,
+ );
}
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order);
@@ -529,34 +582,41 @@ export class ExchangeWrapper extends ContractWrapper {
* @param transactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
- @decorators.contractCallErrorHandler
- public async batchCancelOrdersAsync(orderCancellationRequests: OrderCancellationRequest[],
- orderTransactionOpts: OrderTransactionOpts = {}): Promise<string> {
- assert.doesConformToSchema('orderCancellationRequests', orderCancellationRequests,
- schemas.orderCancellationRequestsSchema);
+ @decorators.asyncZeroExErrorHandler
+ public async batchCancelOrdersAsync(
+ orderCancellationRequests: OrderCancellationRequest[],
+ orderTransactionOpts: OrderTransactionOpts = {},
+ ): Promise<string> {
+ assert.doesConformToSchema(
+ 'orderCancellationRequests',
+ orderCancellationRequests,
+ schemas.orderCancellationRequestsSchema,
+ );
const exchangeContractAddresses = _.map(
orderCancellationRequests,
orderCancellationRequest => orderCancellationRequest.order.exchangeContractAddress,
);
- assert.hasAtMostOneUniqueValue(exchangeContractAddresses,
- ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress);
+ assert.hasAtMostOneUniqueValue(
+ exchangeContractAddresses,
+ ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
+ );
const makers = _.map(orderCancellationRequests, cancellationRequest => cancellationRequest.order.maker);
assert.hasAtMostOneUniqueValue(makers, ExchangeContractErrs.MultipleMakersInSingleCancelBatchDisallowed);
const maker = makers[0];
await assert.isSenderAddressAsync('maker', maker, this._web3Wrapper);
- const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate) ?
- SHOULD_VALIDATE_BY_DEFAULT :
- orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
+ ? SHOULD_VALIDATE_BY_DEFAULT
+ : orderTransactionOpts.shouldValidate;
if (shouldValidate) {
for (const orderCancellationRequest of orderCancellationRequests) {
const orderHash = utils.getOrderHashHex(orderCancellationRequest.order);
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
- orderCancellationRequest.order, orderCancellationRequest.takerTokenCancelAmount,
+ orderCancellationRequest.order,
+ orderCancellationRequest.takerTokenCancelAmount,
unavailableTakerTokenAmount,
);
}
-
}
if (_.isEmpty(orderCancellationRequests)) {
throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
@@ -569,8 +629,9 @@ export class ExchangeWrapper extends ContractWrapper {
];
});
// We use _.unzip<any> because _.unzip doesn't type check if values have different types :'(
- const [orderAddresses, orderValues, cancelTakerTokenAmounts] =
- _.unzip<any>(orderAddressesValuesAndTakerTokenCancelAmounts);
+ const [orderAddresses, orderValues, cancelTakerTokenAmounts] = _.unzip<any>(
+ orderAddressesValuesAndTakerTokenCancelAmounts,
+ );
const txHash = await exchangeInstance.batchCancelOrders.sendTransactionAsync(
orderAddresses,
orderValues,
@@ -592,14 +653,20 @@ export class ExchangeWrapper extends ContractWrapper {
* @return Subscription token used later to unsubscribe
*/
public subscribe<ArgsType extends ExchangeContractEventArgs>(
- eventName: ExchangeEvents, indexFilterValues: IndexedFilterValues,
- callback: EventCallback<ArgsType>): string {
+ eventName: ExchangeEvents,
+ indexFilterValues: IndexedFilterValues,
+ callback: EventCallback<ArgsType>,
+ ): string {
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const exchangeContractAddress = this.getContractAddress();
const subscriptionToken = this._subscribe<ArgsType>(
- exchangeContractAddress, eventName, indexFilterValues, artifacts.ExchangeArtifact.abi, callback,
+ exchangeContractAddress,
+ eventName,
+ indexFilterValues,
+ artifacts.ExchangeArtifact.abi,
+ callback,
);
return subscriptionToken;
}
@@ -611,22 +678,34 @@ export class ExchangeWrapper extends ContractWrapper {
this._unsubscribe(subscriptionToken);
}
/**
+ * Cancels all existing subscriptions
+ */
+ public unsubscribeAll(): void {
+ super.unsubscribeAll();
+ }
+ /**
* Gets historical logs without creating a subscription
* @param eventName The exchange contract event you would like to subscribe to.
- * @param subscriptionOpts Subscriptions options that let you configure the subscription.
+ * @param blockRange Block range to get logs from.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
* @return Array of logs that match the parameters
*/
public async getLogsAsync<ArgsType extends ExchangeContractEventArgs>(
- eventName: ExchangeEvents, subscriptionOpts: SubscriptionOpts, indexFilterValues: IndexedFilterValues,
+ eventName: ExchangeEvents,
+ blockRange: BlockRange,
+ indexFilterValues: IndexedFilterValues,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
- assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema);
+ assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const exchangeContractAddress = this.getContractAddress();
const logs = await this._getLogsAsync<ArgsType>(
- exchangeContractAddress, eventName, subscriptionOpts, indexFilterValues, artifacts.ExchangeArtifact.abi,
+ exchangeContractAddress,
+ eventName,
+ blockRange,
+ indexFilterValues,
+ artifacts.ExchangeArtifact.abi,
);
return logs;
}
@@ -649,14 +728,18 @@ export class ExchangeWrapper extends ContractWrapper {
* to validate for.
*/
public async validateOrderFillableOrThrowAsync(
- signedOrder: SignedOrder, opts?: ValidateOrderFillableOpts,
+ signedOrder: SignedOrder,
+ opts?: ValidateOrderFillableOpts,
): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
const zrxTokenAddress = this.getZRXTokenAddress();
const expectedFillTakerTokenAmount = !_.isUndefined(opts) ? opts.expectedFillTakerTokenAmount : undefined;
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
await this._orderValidationUtils.validateOrderFillableOrThrowAsync(
- exchangeTradeEmulator, signedOrder, zrxTokenAddress, expectedFillTakerTokenAmount,
+ exchangeTradeEmulator,
+ signedOrder,
+ zrxTokenAddress,
+ expectedFillTakerTokenAmount,
);
}
/**
@@ -667,16 +750,23 @@ export class ExchangeWrapper extends ContractWrapper {
* @param takerAddress The user Ethereum address who would like to fill this order.
* Must be available via the supplied Web3.Provider passed to 0x.js.
*/
- public async validateFillOrderThrowIfInvalidAsync(signedOrder: SignedOrder,
- fillTakerTokenAmount: BigNumber,
- takerAddress: string): Promise<void> {
+ public async validateFillOrderThrowIfInvalidAsync(
+ signedOrder: SignedOrder,
+ fillTakerTokenAmount: BigNumber,
+ takerAddress: string,
+ ): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const zrxTokenAddress = this.getZRXTokenAddress();
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress);
+ exchangeTradeEmulator,
+ signedOrder,
+ fillTakerTokenAmount,
+ takerAddress,
+ zrxTokenAddress,
+ );
}
/**
* Checks if cancelling a given order will succeed and throws an informative error if it won't.
@@ -685,13 +775,18 @@ export class ExchangeWrapper extends ContractWrapper {
* @param cancelTakerTokenAmount The amount (specified in taker tokens) that you would like to cancel.
*/
public async validateCancelOrderThrowIfInvalidAsync(
- order: Order, cancelTakerTokenAmount: BigNumber): Promise<void> {
+ order: Order,
+ cancelTakerTokenAmount: BigNumber,
+ ): Promise<void> {
assert.doesConformToSchema('order', order, schemas.orderSchema);
assert.isValidBaseUnitAmount('cancelTakerTokenAmount', cancelTakerTokenAmount);
const orderHash = utils.getOrderHashHex(order);
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
- order, cancelTakerTokenAmount, unavailableTakerTokenAmount);
+ order,
+ cancelTakerTokenAmount,
+ unavailableTakerTokenAmount,
+ );
}
/**
* Checks if calling fillOrKill on a given order will succeed and throws an informative error if it won't.
@@ -701,16 +796,23 @@ export class ExchangeWrapper extends ContractWrapper {
* @param takerAddress The user Ethereum address who would like to fill this order.
* Must be available via the supplied Web3.Provider passed to 0x.js.
*/
- public async validateFillOrKillOrderThrowIfInvalidAsync(signedOrder: SignedOrder,
- fillTakerTokenAmount: BigNumber,
- takerAddress: string): Promise<void> {
+ public async validateFillOrKillOrderThrowIfInvalidAsync(
+ signedOrder: SignedOrder,
+ fillTakerTokenAmount: BigNumber,
+ takerAddress: string,
+ ): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const zrxTokenAddress = this.getZRXTokenAddress();
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress);
+ exchangeTradeEmulator,
+ signedOrder,
+ fillTakerTokenAmount,
+ takerAddress,
+ zrxTokenAddress,
+ );
}
/**
* Checks if rounding error will be > 0.1% when computing makerTokenAmount by doing:
@@ -721,15 +823,19 @@ export class ExchangeWrapper extends ContractWrapper {
* @param takerTokenAmount The order size on the taker side
* @param makerTokenAmount The order size on the maker side
*/
- public async isRoundingErrorAsync(fillTakerTokenAmount: BigNumber,
- takerTokenAmount: BigNumber,
- makerTokenAmount: BigNumber): Promise<boolean> {
+ public async isRoundingErrorAsync(
+ fillTakerTokenAmount: BigNumber,
+ takerTokenAmount: BigNumber,
+ makerTokenAmount: BigNumber,
+ ): Promise<boolean> {
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isValidBaseUnitAmount('takerTokenAmount', takerTokenAmount);
assert.isValidBaseUnitAmount('makerTokenAmount', makerTokenAmount);
const exchangeInstance = await this._getExchangeContractAsync();
const isRoundingError = await exchangeInstance.isRoundingError.callAsync(
- fillTakerTokenAmount, takerTokenAmount, makerTokenAmount,
+ fillTakerTokenAmount,
+ takerTokenAmount,
+ makerTokenAmount,
);
return isRoundingError;
}
@@ -737,10 +843,10 @@ export class ExchangeWrapper extends ContractWrapper {
* Checks if logs contain LogError, which is emmited by Exchange contract on transaction failure.
* @param logs Transaction logs as returned by `zeroEx.awaitTransactionMinedAsync`
*/
- public throwLogErrorsAsErrors(logs: Array<LogWithDecodedArgs<DecodedLogArgs>|Web3.LogEntry>): void {
+ public throwLogErrorsAsErrors(logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>): void {
const errLog = _.find(logs, {
event: ExchangeEvents.LogError,
- }) as LogWithDecodedArgs<LogErrorContractEventArgs>|undefined;
+ }) as LogWithDecodedArgs<LogErrorContractEventArgs> | undefined;
if (!_.isUndefined(errLog)) {
const logArgs = errLog.args;
const errCode = logArgs.errorId.toNumber();
@@ -753,17 +859,18 @@ export class ExchangeWrapper extends ContractWrapper {
* @return Address of ZRX token
*/
public getZRXTokenAddress(): string {
- const contractAddress = this._getContractAddress(
- artifacts.ZRXArtifact, this._zrxContractAddressIfExists,
- );
+ const contractAddress = this._getContractAddress(artifacts.ZRXArtifact, this._zrxContractAddressIfExists);
return contractAddress;
}
private _invalidateContractInstances(): void {
this.unsubscribeAll();
delete this._exchangeContractIfExists;
}
- private async _isValidSignatureUsingContractCallAsync(dataHex: string, ecSignature: ECSignature,
- signerAddressHex: string): Promise<boolean> {
+ private async _isValidSignatureUsingContractCallAsync(
+ dataHex: string,
+ ecSignature: ECSignature,
+ signerAddressHex: string,
+ ): Promise<boolean> {
assert.isHexString('dataHex', dataHex);
assert.doesConformToSchema('ecSignature', ecSignature, schemas.ecSignatureSchema);
assert.isETHAddressHex('signerAddressHex', signerAddressHex);
@@ -779,7 +886,7 @@ export class ExchangeWrapper extends ContractWrapper {
);
return isValidSignature;
}
- private async _getOrderHashHexUsingContractCallAsync(order: Order|SignedOrder): Promise<string> {
+ private async _getOrderHashHexUsingContractCallAsync(order: Order | SignedOrder): Promise<string> {
const exchangeInstance = await this._getExchangeContractAsync();
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order);
const orderHashHex = await exchangeInstance.getOrderHash.callAsync(orderAddresses, orderValues);
@@ -790,7 +897,8 @@ export class ExchangeWrapper extends ContractWrapper {
return this._exchangeContractIfExists;
}
const web3ContractInstance = await this._instantiateContractIfExistsAsync(
- artifacts.ExchangeArtifact, this._contractAddressIfExists,
+ artifacts.ExchangeArtifact,
+ this._contractAddressIfExists,
);
const contractInstance = new ExchangeContract(web3ContractInstance, this._web3Wrapper.getContractDefaults());
this._exchangeContractIfExists = contractInstance;
diff --git a/packages/0x.js/src/contract_wrappers/generated/.gitignore b/packages/0x.js/src/contract_wrappers/generated/.gitignore
new file mode 100644
index 000000000..834808b48
--- /dev/null
+++ b/packages/0x.js/src/contract_wrappers/generated/.gitignore
@@ -0,0 +1,6 @@
+dummy_token.ts
+ether_token.ts
+exchange.ts
+token_registry.ts
+token_transfer_proxy.ts
+token.ts
diff --git a/packages/0x.js/src/contract_wrappers/generated/base_contract.ts b/packages/0x.js/src/contract_wrappers/generated/base_contract.ts
index 396a4d593..28a7e2f52 100644
--- a/packages/0x.js/src/contract_wrappers/generated/base_contract.ts
+++ b/packages/0x.js/src/contract_wrappers/generated/base_contract.ts
@@ -1,8 +1,7 @@
+import {TxData, TxDataPayable} from '@0xproject/types';
import * as _ from 'lodash';
import * as Web3 from 'web3';
-import {TxData, TxDataPayable} from '../../types';
-
export class BaseContract {
protected web3ContractInstance: Web3.ContractInstance;
protected defaults: Partial<TxData>;
diff --git a/packages/0x.js/src/contract_wrappers/generated/ether_token.ts b/packages/0x.js/src/contract_wrappers/generated/ether_token.ts
deleted file mode 100644
index ce3f9f527..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/ether_token.ts
+++ /dev/null
@@ -1,363 +0,0 @@
-/**
- * This file is auto-generated using abi-gen. Don't edit directly.
- * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
- */
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
-import * as Web3 from 'web3';
-
-import {TxData, TxDataPayable} from '../../types';
-import {classUtils} from '../../utils/class_utils';
-
-import {BaseContract} from './base_contract';
-
-export class EtherTokenContract extends BaseContract {
- public name = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as EtherTokenContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.name.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public approve = {
- async sendTransactionAsync(
- _spender: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.approve.estimateGasAsync.bind(
- self,
- _spender,
- _value,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.approve, self.web3ContractInstance,
- )(
- _spender,
- _value,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _spender: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.approve.estimateGas, self.web3ContractInstance,
- )(
- _spender,
- _value,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _spender: string,
- _value: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as EtherTokenContract;
- const abiEncodedTransactionData = self.web3ContractInstance.approve.getData();
- return abiEncodedTransactionData;
- },
- };
- public totalSupply = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as EtherTokenContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.totalSupply.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public transferFrom = {
- async sendTransactionAsync(
- _from: string,
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.transferFrom.estimateGasAsync.bind(
- self,
- _from,
- _to,
- _value,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.transferFrom, self.web3ContractInstance,
- )(
- _from,
- _to,
- _value,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _from: string,
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.transferFrom.estimateGas, self.web3ContractInstance,
- )(
- _from,
- _to,
- _value,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _from: string,
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as EtherTokenContract;
- const abiEncodedTransactionData = self.web3ContractInstance.transferFrom.getData();
- return abiEncodedTransactionData;
- },
- };
- public withdraw = {
- async sendTransactionAsync(
- amount: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.withdraw.estimateGasAsync.bind(
- self,
- amount,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.withdraw, self.web3ContractInstance,
- )(
- amount,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- amount: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.withdraw.estimateGas, self.web3ContractInstance,
- )(
- amount,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- amount: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as EtherTokenContract;
- const abiEncodedTransactionData = self.web3ContractInstance.withdraw.getData();
- return abiEncodedTransactionData;
- },
- };
- public decimals = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as EtherTokenContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.decimals.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public balanceOf = {
- async callAsync(
- _owner: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as EtherTokenContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.balanceOf.call,
- self.web3ContractInstance,
- )(
- _owner,
- );
- return result;
- },
- };
- public symbol = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as EtherTokenContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.symbol.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public transfer = {
- async sendTransactionAsync(
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.transfer.estimateGasAsync.bind(
- self,
- _to,
- _value,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.transfer, self.web3ContractInstance,
- )(
- _to,
- _value,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.transfer.estimateGas, self.web3ContractInstance,
- )(
- _to,
- _value,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as EtherTokenContract;
- const abiEncodedTransactionData = self.web3ContractInstance.transfer.getData();
- return abiEncodedTransactionData;
- },
- };
- public deposit = {
- async sendTransactionAsync(
- txData: TxDataPayable = {},
- ): Promise<string> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.deposit.estimateGasAsync.bind(
- self,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.deposit, self.web3ContractInstance,
- )(
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- txData: TxData = {},
- ): Promise<number> {
- const self = this as EtherTokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.deposit.estimateGas, self.web3ContractInstance,
- )(
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- txData: TxData = {},
- ): string {
- const self = this as EtherTokenContract;
- const abiEncodedTransactionData = self.web3ContractInstance.deposit.getData();
- return abiEncodedTransactionData;
- },
- };
- public allowance = {
- async callAsync(
- _owner: string,
- _spender: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as EtherTokenContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.allowance.call,
- self.web3ContractInstance,
- )(
- _owner,
- _spender,
- );
- return result;
- },
- };
- constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
- super(web3ContractInstance, defaults);
- classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
- }
-} // tslint:disable:max-file-line-count
diff --git a/packages/0x.js/src/contract_wrappers/generated/exchange.ts b/packages/0x.js/src/contract_wrappers/generated/exchange.ts
deleted file mode 100644
index e06ed960c..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/exchange.ts
+++ /dev/null
@@ -1,730 +0,0 @@
-/**
- * This file is auto-generated using abi-gen. Don't edit directly.
- * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
- */
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
-import * as Web3 from 'web3';
-
-import {TxData, TxDataPayable} from '../../types';
-import {classUtils} from '../../utils/class_utils';
-
-import {BaseContract} from './base_contract';
-
-export class ExchangeContract extends BaseContract {
- public isRoundingError = {
- async callAsync(
- numerator: BigNumber,
- denominator: BigNumber,
- target: BigNumber,
- defaultBlock?: Web3.BlockParam,
- ): Promise<boolean
- > {
- const self = this as ExchangeContract;
- const result = await promisify<boolean
- >(
- self.web3ContractInstance.isRoundingError.call,
- self.web3ContractInstance,
- )(
- numerator,
- denominator,
- target,
- );
- return result;
- },
- };
- public filled = {
- async callAsync(
- index: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as ExchangeContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.filled.call,
- self.web3ContractInstance,
- )(
- index,
- );
- return result;
- },
- };
- public cancelled = {
- async callAsync(
- index: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as ExchangeContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.cancelled.call,
- self.web3ContractInstance,
- )(
- index,
- );
- return result;
- },
- };
- public fillOrdersUpTo = {
- async sendTransactionAsync(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- fillTakerTokenAmount: BigNumber,
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- v: number|BigNumber[],
- r: string[],
- s: string[],
- txData: TxData = {},
- ): Promise<string> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.fillOrdersUpTo.estimateGasAsync.bind(
- self,
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v,
- r,
- s,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.fillOrdersUpTo, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- fillTakerTokenAmount: BigNumber,
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- v: number|BigNumber[],
- r: string[],
- s: string[],
- txData: TxData = {},
- ): Promise<number> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.fillOrdersUpTo.estimateGas, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- fillTakerTokenAmount: BigNumber,
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- v: number|BigNumber[],
- r: string[],
- s: string[],
- txData: TxData = {},
- ): string {
- const self = this as ExchangeContract;
- const abiEncodedTransactionData = self.web3ContractInstance.fillOrdersUpTo.getData();
- return abiEncodedTransactionData;
- },
- };
- public cancelOrder = {
- async sendTransactionAsync(
- orderAddresses: string[],
- orderValues: BigNumber[],
- cancelTakerTokenAmount: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.cancelOrder.estimateGasAsync.bind(
- self,
- orderAddresses,
- orderValues,
- cancelTakerTokenAmount,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.cancelOrder, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- cancelTakerTokenAmount,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- orderAddresses: string[],
- orderValues: BigNumber[],
- cancelTakerTokenAmount: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.cancelOrder.estimateGas, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- cancelTakerTokenAmount,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- orderAddresses: string[],
- orderValues: BigNumber[],
- cancelTakerTokenAmount: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as ExchangeContract;
- const abiEncodedTransactionData = self.web3ContractInstance.cancelOrder.getData();
- return abiEncodedTransactionData;
- },
- };
- public ZRX_TOKEN_CONTRACT = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as ExchangeContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.ZRX_TOKEN_CONTRACT.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public batchFillOrKillOrders = {
- async sendTransactionAsync(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- fillTakerTokenAmounts: BigNumber[],
- v: number|BigNumber[],
- r: string[],
- s: string[],
- txData: TxData = {},
- ): Promise<string> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.batchFillOrKillOrders.estimateGasAsync.bind(
- self,
- orderAddresses,
- orderValues,
- fillTakerTokenAmounts,
- v,
- r,
- s,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.batchFillOrKillOrders, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmounts,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- fillTakerTokenAmounts: BigNumber[],
- v: number|BigNumber[],
- r: string[],
- s: string[],
- txData: TxData = {},
- ): Promise<number> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.batchFillOrKillOrders.estimateGas, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmounts,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- fillTakerTokenAmounts: BigNumber[],
- v: number|BigNumber[],
- r: string[],
- s: string[],
- txData: TxData = {},
- ): string {
- const self = this as ExchangeContract;
- const abiEncodedTransactionData = self.web3ContractInstance.batchFillOrKillOrders.getData();
- return abiEncodedTransactionData;
- },
- };
- public fillOrKillOrder = {
- async sendTransactionAsync(
- orderAddresses: string[],
- orderValues: BigNumber[],
- fillTakerTokenAmount: BigNumber,
- v: number|BigNumber,
- r: string,
- s: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.fillOrKillOrder.estimateGasAsync.bind(
- self,
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- v,
- r,
- s,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.fillOrKillOrder, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- orderAddresses: string[],
- orderValues: BigNumber[],
- fillTakerTokenAmount: BigNumber,
- v: number|BigNumber,
- r: string,
- s: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.fillOrKillOrder.estimateGas, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- orderAddresses: string[],
- orderValues: BigNumber[],
- fillTakerTokenAmount: BigNumber,
- v: number|BigNumber,
- r: string,
- s: string,
- txData: TxData = {},
- ): string {
- const self = this as ExchangeContract;
- const abiEncodedTransactionData = self.web3ContractInstance.fillOrKillOrder.getData();
- return abiEncodedTransactionData;
- },
- };
- public getUnavailableTakerTokenAmount = {
- async callAsync(
- orderHash: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as ExchangeContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.getUnavailableTakerTokenAmount.call,
- self.web3ContractInstance,
- )(
- orderHash,
- );
- return result;
- },
- };
- public isValidSignature = {
- async callAsync(
- signer: string,
- hash: string,
- v: number|BigNumber,
- r: string,
- s: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<boolean
- > {
- const self = this as ExchangeContract;
- const result = await promisify<boolean
- >(
- self.web3ContractInstance.isValidSignature.call,
- self.web3ContractInstance,
- )(
- signer,
- hash,
- v,
- r,
- s,
- );
- return result;
- },
- };
- public getPartialAmount = {
- async callAsync(
- numerator: BigNumber,
- denominator: BigNumber,
- target: BigNumber,
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as ExchangeContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.getPartialAmount.call,
- self.web3ContractInstance,
- )(
- numerator,
- denominator,
- target,
- );
- return result;
- },
- };
- public TOKEN_TRANSFER_PROXY_CONTRACT = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as ExchangeContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.TOKEN_TRANSFER_PROXY_CONTRACT.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public batchFillOrders = {
- async sendTransactionAsync(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- fillTakerTokenAmounts: BigNumber[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- v: number|BigNumber[],
- r: string[],
- s: string[],
- txData: TxData = {},
- ): Promise<string> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.batchFillOrders.estimateGasAsync.bind(
- self,
- orderAddresses,
- orderValues,
- fillTakerTokenAmounts,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v,
- r,
- s,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.batchFillOrders, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmounts,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- fillTakerTokenAmounts: BigNumber[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- v: number|BigNumber[],
- r: string[],
- s: string[],
- txData: TxData = {},
- ): Promise<number> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.batchFillOrders.estimateGas, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmounts,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- fillTakerTokenAmounts: BigNumber[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- v: number|BigNumber[],
- r: string[],
- s: string[],
- txData: TxData = {},
- ): string {
- const self = this as ExchangeContract;
- const abiEncodedTransactionData = self.web3ContractInstance.batchFillOrders.getData();
- return abiEncodedTransactionData;
- },
- };
- public batchCancelOrders = {
- async sendTransactionAsync(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- cancelTakerTokenAmounts: BigNumber[],
- txData: TxData = {},
- ): Promise<string> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.batchCancelOrders.estimateGasAsync.bind(
- self,
- orderAddresses,
- orderValues,
- cancelTakerTokenAmounts,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.batchCancelOrders, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- cancelTakerTokenAmounts,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- cancelTakerTokenAmounts: BigNumber[],
- txData: TxData = {},
- ): Promise<number> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.batchCancelOrders.estimateGas, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- cancelTakerTokenAmounts,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- orderAddresses: string[][],
- orderValues: BigNumber[][],
- cancelTakerTokenAmounts: BigNumber[],
- txData: TxData = {},
- ): string {
- const self = this as ExchangeContract;
- const abiEncodedTransactionData = self.web3ContractInstance.batchCancelOrders.getData();
- return abiEncodedTransactionData;
- },
- };
- public fillOrder = {
- async sendTransactionAsync(
- orderAddresses: string[],
- orderValues: BigNumber[],
- fillTakerTokenAmount: BigNumber,
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- v: number|BigNumber,
- r: string,
- s: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.fillOrder.estimateGasAsync.bind(
- self,
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v,
- r,
- s,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.fillOrder, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- orderAddresses: string[],
- orderValues: BigNumber[],
- fillTakerTokenAmount: BigNumber,
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- v: number|BigNumber,
- r: string,
- s: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as ExchangeContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.fillOrder.estimateGas, self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- shouldThrowOnInsufficientBalanceOrAllowance,
- v,
- r,
- s,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- orderAddresses: string[],
- orderValues: BigNumber[],
- fillTakerTokenAmount: BigNumber,
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- v: number|BigNumber,
- r: string,
- s: string,
- txData: TxData = {},
- ): string {
- const self = this as ExchangeContract;
- const abiEncodedTransactionData = self.web3ContractInstance.fillOrder.getData();
- return abiEncodedTransactionData;
- },
- };
- public getOrderHash = {
- async callAsync(
- orderAddresses: string[],
- orderValues: BigNumber[],
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as ExchangeContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.getOrderHash.call,
- self.web3ContractInstance,
- )(
- orderAddresses,
- orderValues,
- );
- return result;
- },
- };
- public EXTERNAL_QUERY_GAS_LIMIT = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as ExchangeContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.EXTERNAL_QUERY_GAS_LIMIT.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public VERSION = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as ExchangeContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.VERSION.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
- super(web3ContractInstance, defaults);
- classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
- }
-} // tslint:disable:max-file-line-count
diff --git a/packages/0x.js/src/contract_wrappers/generated/token.ts b/packages/0x.js/src/contract_wrappers/generated/token.ts
deleted file mode 100644
index 83a4ead34..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/token.ts
+++ /dev/null
@@ -1,232 +0,0 @@
-/**
- * This file is auto-generated using abi-gen. Don't edit directly.
- * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
- */
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
-import * as Web3 from 'web3';
-
-import {TxData, TxDataPayable} from '../../types';
-import {classUtils} from '../../utils/class_utils';
-
-import {BaseContract} from './base_contract';
-
-export class TokenContract extends BaseContract {
- public approve = {
- async sendTransactionAsync(
- _spender: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.approve.estimateGasAsync.bind(
- self,
- _spender,
- _value,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.approve, self.web3ContractInstance,
- )(
- _spender,
- _value,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _spender: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.approve.estimateGas, self.web3ContractInstance,
- )(
- _spender,
- _value,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _spender: string,
- _value: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as TokenContract;
- const abiEncodedTransactionData = self.web3ContractInstance.approve.getData();
- return abiEncodedTransactionData;
- },
- };
- public totalSupply = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as TokenContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.totalSupply.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public transferFrom = {
- async sendTransactionAsync(
- _from: string,
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.transferFrom.estimateGasAsync.bind(
- self,
- _from,
- _to,
- _value,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.transferFrom, self.web3ContractInstance,
- )(
- _from,
- _to,
- _value,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _from: string,
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.transferFrom.estimateGas, self.web3ContractInstance,
- )(
- _from,
- _to,
- _value,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _from: string,
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as TokenContract;
- const abiEncodedTransactionData = self.web3ContractInstance.transferFrom.getData();
- return abiEncodedTransactionData;
- },
- };
- public balanceOf = {
- async callAsync(
- _owner: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as TokenContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.balanceOf.call,
- self.web3ContractInstance,
- )(
- _owner,
- );
- return result;
- },
- };
- public transfer = {
- async sendTransactionAsync(
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.transfer.estimateGasAsync.bind(
- self,
- _to,
- _value,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.transfer, self.web3ContractInstance,
- )(
- _to,
- _value,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.transfer.estimateGas, self.web3ContractInstance,
- )(
- _to,
- _value,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _to: string,
- _value: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as TokenContract;
- const abiEncodedTransactionData = self.web3ContractInstance.transfer.getData();
- return abiEncodedTransactionData;
- },
- };
- public allowance = {
- async callAsync(
- _owner: string,
- _spender: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<BigNumber
- > {
- const self = this as TokenContract;
- const result = await promisify<BigNumber
- >(
- self.web3ContractInstance.allowance.call,
- self.web3ContractInstance,
- )(
- _owner,
- _spender,
- );
- return result;
- },
- };
- constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
- super(web3ContractInstance, defaults);
- classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
- }
-} // tslint:disable:max-file-line-count
diff --git a/packages/0x.js/src/contract_wrappers/generated/token_registry.ts b/packages/0x.js/src/contract_wrappers/generated/token_registry.ts
deleted file mode 100644
index 5d9ad9016..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/token_registry.ts
+++ /dev/null
@@ -1,550 +0,0 @@
-/**
- * This file is auto-generated using abi-gen. Don't edit directly.
- * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
- */
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
-import * as Web3 from 'web3';
-
-import {TxData, TxDataPayable} from '../../types';
-import {classUtils} from '../../utils/class_utils';
-
-import {BaseContract} from './base_contract';
-
-export class TokenRegistryContract extends BaseContract {
- public removeToken = {
- async sendTransactionAsync(
- _token: string,
- _index: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.removeToken.estimateGasAsync.bind(
- self,
- _token,
- _index,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.removeToken, self.web3ContractInstance,
- )(
- _token,
- _index,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _token: string,
- _index: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.removeToken.estimateGas, self.web3ContractInstance,
- )(
- _token,
- _index,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _token: string,
- _index: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as TokenRegistryContract;
- const abiEncodedTransactionData = self.web3ContractInstance.removeToken.getData();
- return abiEncodedTransactionData;
- },
- };
- public getTokenAddressByName = {
- async callAsync(
- _name: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as TokenRegistryContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.getTokenAddressByName.call,
- self.web3ContractInstance,
- )(
- _name,
- );
- return result;
- },
- };
- public getTokenAddressBySymbol = {
- async callAsync(
- _symbol: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as TokenRegistryContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.getTokenAddressBySymbol.call,
- self.web3ContractInstance,
- )(
- _symbol,
- );
- return result;
- },
- };
- public setTokenSwarmHash = {
- async sendTransactionAsync(
- _token: string,
- _swarmHash: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.setTokenSwarmHash.estimateGasAsync.bind(
- self,
- _token,
- _swarmHash,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.setTokenSwarmHash, self.web3ContractInstance,
- )(
- _token,
- _swarmHash,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _token: string,
- _swarmHash: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.setTokenSwarmHash.estimateGas, self.web3ContractInstance,
- )(
- _token,
- _swarmHash,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _token: string,
- _swarmHash: string,
- txData: TxData = {},
- ): string {
- const self = this as TokenRegistryContract;
- const abiEncodedTransactionData = self.web3ContractInstance.setTokenSwarmHash.getData();
- return abiEncodedTransactionData;
- },
- };
- public getTokenMetaData = {
- async callAsync(
- _token: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<[string, string, string, BigNumber, string, string]
- > {
- const self = this as TokenRegistryContract;
- const result = await promisify<[string, string, string, BigNumber, string, string]
- >(
- self.web3ContractInstance.getTokenMetaData.call,
- self.web3ContractInstance,
- )(
- _token,
- );
- return result;
- },
- };
- public owner = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as TokenRegistryContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.owner.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public addToken = {
- async sendTransactionAsync(
- _token: string,
- _name: string,
- _symbol: string,
- _decimals: number|BigNumber,
- _ipfsHash: string,
- _swarmHash: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.addToken.estimateGasAsync.bind(
- self,
- _token,
- _name,
- _symbol,
- _decimals,
- _ipfsHash,
- _swarmHash,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.addToken, self.web3ContractInstance,
- )(
- _token,
- _name,
- _symbol,
- _decimals,
- _ipfsHash,
- _swarmHash,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _token: string,
- _name: string,
- _symbol: string,
- _decimals: number|BigNumber,
- _ipfsHash: string,
- _swarmHash: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.addToken.estimateGas, self.web3ContractInstance,
- )(
- _token,
- _name,
- _symbol,
- _decimals,
- _ipfsHash,
- _swarmHash,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _token: string,
- _name: string,
- _symbol: string,
- _decimals: number|BigNumber,
- _ipfsHash: string,
- _swarmHash: string,
- txData: TxData = {},
- ): string {
- const self = this as TokenRegistryContract;
- const abiEncodedTransactionData = self.web3ContractInstance.addToken.getData();
- return abiEncodedTransactionData;
- },
- };
- public setTokenName = {
- async sendTransactionAsync(
- _token: string,
- _name: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.setTokenName.estimateGasAsync.bind(
- self,
- _token,
- _name,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.setTokenName, self.web3ContractInstance,
- )(
- _token,
- _name,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _token: string,
- _name: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.setTokenName.estimateGas, self.web3ContractInstance,
- )(
- _token,
- _name,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _token: string,
- _name: string,
- txData: TxData = {},
- ): string {
- const self = this as TokenRegistryContract;
- const abiEncodedTransactionData = self.web3ContractInstance.setTokenName.getData();
- return abiEncodedTransactionData;
- },
- };
- public tokens = {
- async callAsync(
- index: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<[string, string, string, BigNumber, string, string]
- > {
- const self = this as TokenRegistryContract;
- const result = await promisify<[string, string, string, BigNumber, string, string]
- >(
- self.web3ContractInstance.tokens.call,
- self.web3ContractInstance,
- )(
- index,
- );
- return result;
- },
- };
- public tokenAddresses = {
- async callAsync(
- index: BigNumber,
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as TokenRegistryContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.tokenAddresses.call,
- self.web3ContractInstance,
- )(
- index,
- );
- return result;
- },
- };
- public getTokenByName = {
- async callAsync(
- _name: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<[string, string, string, BigNumber, string, string]
- > {
- const self = this as TokenRegistryContract;
- const result = await promisify<[string, string, string, BigNumber, string, string]
- >(
- self.web3ContractInstance.getTokenByName.call,
- self.web3ContractInstance,
- )(
- _name,
- );
- return result;
- },
- };
- public getTokenAddresses = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<string[]
- > {
- const self = this as TokenRegistryContract;
- const result = await promisify<string[]
- >(
- self.web3ContractInstance.getTokenAddresses.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public setTokenIpfsHash = {
- async sendTransactionAsync(
- _token: string,
- _ipfsHash: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.setTokenIpfsHash.estimateGasAsync.bind(
- self,
- _token,
- _ipfsHash,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.setTokenIpfsHash, self.web3ContractInstance,
- )(
- _token,
- _ipfsHash,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _token: string,
- _ipfsHash: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.setTokenIpfsHash.estimateGas, self.web3ContractInstance,
- )(
- _token,
- _ipfsHash,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _token: string,
- _ipfsHash: string,
- txData: TxData = {},
- ): string {
- const self = this as TokenRegistryContract;
- const abiEncodedTransactionData = self.web3ContractInstance.setTokenIpfsHash.getData();
- return abiEncodedTransactionData;
- },
- };
- public getTokenBySymbol = {
- async callAsync(
- _symbol: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<[string, string, string, BigNumber, string, string]
- > {
- const self = this as TokenRegistryContract;
- const result = await promisify<[string, string, string, BigNumber, string, string]
- >(
- self.web3ContractInstance.getTokenBySymbol.call,
- self.web3ContractInstance,
- )(
- _symbol,
- );
- return result;
- },
- };
- public setTokenSymbol = {
- async sendTransactionAsync(
- _token: string,
- _symbol: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.setTokenSymbol.estimateGasAsync.bind(
- self,
- _token,
- _symbol,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.setTokenSymbol, self.web3ContractInstance,
- )(
- _token,
- _symbol,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- _token: string,
- _symbol: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.setTokenSymbol.estimateGas, self.web3ContractInstance,
- )(
- _token,
- _symbol,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- _token: string,
- _symbol: string,
- txData: TxData = {},
- ): string {
- const self = this as TokenRegistryContract;
- const abiEncodedTransactionData = self.web3ContractInstance.setTokenSymbol.getData();
- return abiEncodedTransactionData;
- },
- };
- public transferOwnership = {
- async sendTransactionAsync(
- newOwner: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.transferOwnership.estimateGasAsync.bind(
- self,
- newOwner,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.transferOwnership, self.web3ContractInstance,
- )(
- newOwner,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- newOwner: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenRegistryContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.transferOwnership.estimateGas, self.web3ContractInstance,
- )(
- newOwner,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- newOwner: string,
- txData: TxData = {},
- ): string {
- const self = this as TokenRegistryContract;
- const abiEncodedTransactionData = self.web3ContractInstance.transferOwnership.getData();
- return abiEncodedTransactionData;
- },
- };
- constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
- super(web3ContractInstance, defaults);
- classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
- }
-} // tslint:disable:max-file-line-count
diff --git a/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts b/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts
deleted file mode 100644
index fd50a5894..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts
+++ /dev/null
@@ -1,285 +0,0 @@
-/**
- * This file is auto-generated using abi-gen. Don't edit directly.
- * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
- */
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
-import * as Web3 from 'web3';
-
-import {TxData, TxDataPayable} from '../../types';
-import {classUtils} from '../../utils/class_utils';
-
-import {BaseContract} from './base_contract';
-
-export class TokenTransferProxyContract extends BaseContract {
- public transferFrom = {
- async sendTransactionAsync(
- token: string,
- from: string,
- to: string,
- value: BigNumber,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenTransferProxyContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.transferFrom.estimateGasAsync.bind(
- self,
- token,
- from,
- to,
- value,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.transferFrom, self.web3ContractInstance,
- )(
- token,
- from,
- to,
- value,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- token: string,
- from: string,
- to: string,
- value: BigNumber,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenTransferProxyContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.transferFrom.estimateGas, self.web3ContractInstance,
- )(
- token,
- from,
- to,
- value,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- token: string,
- from: string,
- to: string,
- value: BigNumber,
- txData: TxData = {},
- ): string {
- const self = this as TokenTransferProxyContract;
- const abiEncodedTransactionData = self.web3ContractInstance.transferFrom.getData();
- return abiEncodedTransactionData;
- },
- };
- public addAuthorizedAddress = {
- async sendTransactionAsync(
- target: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenTransferProxyContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.addAuthorizedAddress.estimateGasAsync.bind(
- self,
- target,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.addAuthorizedAddress, self.web3ContractInstance,
- )(
- target,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- target: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenTransferProxyContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.addAuthorizedAddress.estimateGas, self.web3ContractInstance,
- )(
- target,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- target: string,
- txData: TxData = {},
- ): string {
- const self = this as TokenTransferProxyContract;
- const abiEncodedTransactionData = self.web3ContractInstance.addAuthorizedAddress.getData();
- return abiEncodedTransactionData;
- },
- };
- public authorities = {
- async callAsync(
- index: BigNumber,
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as TokenTransferProxyContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.authorities.call,
- self.web3ContractInstance,
- )(
- index,
- );
- return result;
- },
- };
- public removeAuthorizedAddress = {
- async sendTransactionAsync(
- target: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenTransferProxyContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.removeAuthorizedAddress.estimateGasAsync.bind(
- self,
- target,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.removeAuthorizedAddress, self.web3ContractInstance,
- )(
- target,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- target: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenTransferProxyContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.removeAuthorizedAddress.estimateGas, self.web3ContractInstance,
- )(
- target,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- target: string,
- txData: TxData = {},
- ): string {
- const self = this as TokenTransferProxyContract;
- const abiEncodedTransactionData = self.web3ContractInstance.removeAuthorizedAddress.getData();
- return abiEncodedTransactionData;
- },
- };
- public owner = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<string
- > {
- const self = this as TokenTransferProxyContract;
- const result = await promisify<string
- >(
- self.web3ContractInstance.owner.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public authorized = {
- async callAsync(
- index: string,
- defaultBlock?: Web3.BlockParam,
- ): Promise<boolean
- > {
- const self = this as TokenTransferProxyContract;
- const result = await promisify<boolean
- >(
- self.web3ContractInstance.authorized.call,
- self.web3ContractInstance,
- )(
- index,
- );
- return result;
- },
- };
- public getAuthorizedAddresses = {
- async callAsync(
- defaultBlock?: Web3.BlockParam,
- ): Promise<string[]
- > {
- const self = this as TokenTransferProxyContract;
- const result = await promisify<string[]
- >(
- self.web3ContractInstance.getAuthorizedAddresses.call,
- self.web3ContractInstance,
- )(
- );
- return result;
- },
- };
- public transferOwnership = {
- async sendTransactionAsync(
- newOwner: string,
- txData: TxData = {},
- ): Promise<string> {
- const self = this as TokenTransferProxyContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- self.transferOwnership.estimateGasAsync.bind(
- self,
- newOwner,
- ),
- );
- const txHash = await promisify<string>(
- self.web3ContractInstance.transferOwnership, self.web3ContractInstance,
- )(
- newOwner,
- txDataWithDefaults,
- );
- return txHash;
- },
- async estimateGasAsync(
- newOwner: string,
- txData: TxData = {},
- ): Promise<number> {
- const self = this as TokenTransferProxyContract;
- const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
- txData,
- );
- const gas = await promisify<number>(
- self.web3ContractInstance.transferOwnership.estimateGas, self.web3ContractInstance,
- )(
- newOwner,
- txDataWithDefaults,
- );
- return gas;
- },
- getABIEncodedTransactionData(
- newOwner: string,
- txData: TxData = {},
- ): string {
- const self = this as TokenTransferProxyContract;
- const abiEncodedTransactionData = self.web3ContractInstance.transferOwnership.getData();
- return abiEncodedTransactionData;
- },
- };
- constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
- super(web3ContractInstance, defaults);
- classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
- }
-} // tslint:disable:max-file-line-count
diff --git a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts
index 064b826d8..f54aaf0f8 100644
--- a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts
@@ -1,13 +1,13 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import {artifacts} from '../artifacts';
-import {Token, TokenMetadata, ZeroExError} from '../types';
-import {assert} from '../utils/assert';
-import {constants} from '../utils/constants';
+import { artifacts } from '../artifacts';
+import { Token, TokenMetadata } from '../types';
+import { assert } from '../utils/assert';
+import { constants } from '../utils/constants';
-import {ContractWrapper} from './contract_wrapper';
-import {TokenRegistryContract} from './generated/token_registry';
+import { ContractWrapper } from './contract_wrapper';
+import { TokenRegistryContract } from './generated/token_registry';
/**
* This class includes all the functionality related to interacting with the 0x Token Registry smart contract.
@@ -15,7 +15,7 @@ import {TokenRegistryContract} from './generated/token_registry';
export class TokenRegistryWrapper extends ContractWrapper {
private _tokenRegistryContractIfExists?: TokenRegistryContract;
private _contractAddressIfExists?: string;
- private static _createTokenFromMetadata(metadata: TokenMetadata): Token|undefined {
+ private static _createTokenFromMetadata(metadata: TokenMetadata): Token | undefined {
if (metadata[0] === constants.NULL_ADDRESS) {
return undefined;
}
@@ -36,12 +36,9 @@ export class TokenRegistryWrapper extends ContractWrapper {
* @return An array of objects that conform to the Token interface.
*/
public async getTokensAsync(): Promise<Token[]> {
- const tokenRegistryContract = await this._getTokenRegistryContractAsync();
-
const addresses = await this.getTokenAddressesAsync();
- const tokenPromises: Array<Promise<Token|undefined>> = _.map(
- addresses,
- async (address: string) => this.getTokenIfExistsAsync(address),
+ const tokenPromises: Array<Promise<Token | undefined>> = _.map(addresses, async (address: string) =>
+ this.getTokenIfExistsAsync(address),
);
const tokens = await Promise.all(tokenPromises);
return tokens as Token[];
@@ -59,7 +56,7 @@ export class TokenRegistryWrapper extends ContractWrapper {
* Retrieves a token by address currently listed in the Token Registry smart contract
* @return An object that conforms to the Token interface or undefined if token not found.
*/
- public async getTokenIfExistsAsync(address: string): Promise<Token|undefined> {
+ public async getTokenIfExistsAsync(address: string): Promise<Token | undefined> {
assert.isETHAddressHex('address', address);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
@@ -67,7 +64,7 @@ export class TokenRegistryWrapper extends ContractWrapper {
const token = TokenRegistryWrapper._createTokenFromMetadata(metadata);
return token;
}
- public async getTokenAddressBySymbolIfExistsAsync(symbol: string): Promise<string|undefined> {
+ public async getTokenAddressBySymbolIfExistsAsync(symbol: string): Promise<string | undefined> {
assert.isString('symbol', symbol);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
const addressIfExists = await tokenRegistryContract.getTokenAddressBySymbol.callAsync(symbol);
@@ -76,7 +73,7 @@ export class TokenRegistryWrapper extends ContractWrapper {
}
return addressIfExists;
}
- public async getTokenAddressByNameIfExistsAsync(name: string): Promise<string|undefined> {
+ public async getTokenAddressByNameIfExistsAsync(name: string): Promise<string | undefined> {
assert.isString('name', name);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
const addressIfExists = await tokenRegistryContract.getTokenAddressByName.callAsync(name);
@@ -85,14 +82,14 @@ export class TokenRegistryWrapper extends ContractWrapper {
}
return addressIfExists;
}
- public async getTokenBySymbolIfExistsAsync(symbol: string): Promise<Token|undefined> {
+ public async getTokenBySymbolIfExistsAsync(symbol: string): Promise<Token | undefined> {
assert.isString('symbol', symbol);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
const metadata = await tokenRegistryContract.getTokenBySymbol.callAsync(symbol);
const token = TokenRegistryWrapper._createTokenFromMetadata(metadata);
return token;
}
- public async getTokenByNameIfExistsAsync(name: string): Promise<Token|undefined> {
+ public async getTokenByNameIfExistsAsync(name: string): Promise<Token | undefined> {
assert.isString('name', name);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
const metadata = await tokenRegistryContract.getTokenByName.callAsync(name);
@@ -106,7 +103,8 @@ export class TokenRegistryWrapper extends ContractWrapper {
*/
public getContractAddress(): string {
const contractAddress = this._getContractAddress(
- artifacts.TokenRegistryArtifact, this._contractAddressIfExists,
+ artifacts.TokenRegistryArtifact,
+ this._contractAddressIfExists,
);
return contractAddress;
}
@@ -118,10 +116,12 @@ export class TokenRegistryWrapper extends ContractWrapper {
return this._tokenRegistryContractIfExists;
}
const web3ContractInstance = await this._instantiateContractIfExistsAsync(
- artifacts.TokenRegistryArtifact, this._contractAddressIfExists,
+ artifacts.TokenRegistryArtifact,
+ this._contractAddressIfExists,
);
const contractInstance = new TokenRegistryContract(
- web3ContractInstance, this._web3Wrapper.getContractDefaults(),
+ web3ContractInstance,
+ this._web3Wrapper.getContractDefaults(),
);
this._tokenRegistryContractIfExists = contractInstance;
return this._tokenRegistryContractIfExists;
diff --git a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
index 1a16e3540..f5d9d108a 100644
--- a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
@@ -1,11 +1,10 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import {artifacts} from '../artifacts';
-import {ZeroExError} from '../types';
+import { artifacts } from '../artifacts';
-import {ContractWrapper} from './contract_wrapper';
-import {TokenTransferProxyContract} from './generated/token_transfer_proxy';
+import { ContractWrapper } from './contract_wrapper';
+import { TokenTransferProxyContract } from './generated/token_transfer_proxy';
/**
* This class includes the functionality related to interacting with the TokenTransferProxy contract.
@@ -43,7 +42,8 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
*/
public getContractAddress(): string {
const contractAddress = this._getContractAddress(
- artifacts.TokenTransferProxyArtifact, this._contractAddressIfExists,
+ artifacts.TokenTransferProxyArtifact,
+ this._contractAddressIfExists,
);
return contractAddress;
}
@@ -55,10 +55,12 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
return this._tokenTransferProxyContractIfExists;
}
const web3ContractInstance = await this._instantiateContractIfExistsAsync(
- artifacts.TokenTransferProxyArtifact, this._contractAddressIfExists,
+ artifacts.TokenTransferProxyArtifact,
+ this._contractAddressIfExists,
);
const contractInstance = new TokenTransferProxyContract(
- web3ContractInstance, this._web3Wrapper.getContractDefaults(),
+ web3ContractInstance,
+ this._web3Wrapper.getContractDefaults(),
);
this._tokenTransferProxyContractIfExists = contractInstance;
return this._tokenTransferProxyContractIfExists;
diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
index 684f291a5..7943f4a60 100644
--- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
@@ -1,29 +1,27 @@
-import {schemas} from '@0xproject/json-schemas';
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+import { schemas } from '@0xproject/json-schemas';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import {artifacts} from '../artifacts';
+import { artifacts } from '../artifacts';
import {
+ BlockRange,
EventCallback,
IndexedFilterValues,
LogWithDecodedArgs,
MethodOpts,
- SubscriptionOpts,
TokenContractEventArgs,
TokenEvents,
TransactionOpts,
ZeroExError,
} from '../types';
-import {AbiDecoder} from '../utils/abi_decoder';
-import {assert} from '../utils/assert';
-import {constants} from '../utils/constants';
+import { AbiDecoder } from '../utils/abi_decoder';
+import { assert } from '../utils/assert';
+import { constants } from '../utils/constants';
-import {ContractWrapper} from './contract_wrapper';
-import {TokenContract} from './generated/token';
-import {TokenTransferProxyWrapper} from './token_transfer_proxy_wrapper';
-
-const ALLOWANCE_TO_ZERO_GAS_AMOUNT = 47275;
+import { ContractWrapper } from './contract_wrapper';
+import { TokenContract } from './generated/token';
+import { TokenTransferProxyWrapper } from './token_transfer_proxy_wrapper';
/**
* This class includes all the functionality related to interacting with ERC20 token contracts.
@@ -32,10 +30,14 @@ const ALLOWANCE_TO_ZERO_GAS_AMOUNT = 47275;
*/
export class TokenWrapper extends ContractWrapper {
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- private _tokenContractsByAddress: {[address: string]: TokenContract};
+ private _tokenContractsByAddress: { [address: string]: TokenContract };
private _tokenTransferProxyWrapper: TokenTransferProxyWrapper;
- constructor(web3Wrapper: Web3Wrapper, networkId: number, abiDecoder: AbiDecoder,
- tokenTransferProxyWrapper: TokenTransferProxyWrapper) {
+ constructor(
+ web3Wrapper: Web3Wrapper,
+ networkId: number,
+ abiDecoder: AbiDecoder,
+ tokenTransferProxyWrapper: TokenTransferProxyWrapper,
+ ) {
super(web3Wrapper, networkId, abiDecoder);
this._tokenContractsByAddress = {};
this._tokenTransferProxyWrapper = tokenTransferProxyWrapper;
@@ -47,8 +49,11 @@ export class TokenWrapper extends ContractWrapper {
* @param methodOpts Optional arguments this method accepts.
* @return The owner's ERC20 token balance in base units.
*/
- public async getBalanceAsync(tokenAddress: string, ownerAddress: string,
- methodOpts?: MethodOpts): Promise<BigNumber> {
+ public async getBalanceAsync(
+ tokenAddress: string,
+ ownerAddress: string,
+ methodOpts?: MethodOpts,
+ ): Promise<BigNumber> {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
@@ -70,8 +75,13 @@ export class TokenWrapper extends ContractWrapper {
* @param txOpts Transaction parameters.
* @return Transaction hash.
*/
- public async setAllowanceAsync(tokenAddress: string, ownerAddress: string, spenderAddress: string,
- amountInBaseUnits: BigNumber, txOpts: TransactionOpts = {}): Promise<string> {
+ public async setAllowanceAsync(
+ tokenAddress: string,
+ ownerAddress: string,
+ spenderAddress: string,
+ amountInBaseUnits: BigNumber,
+ txOpts: TransactionOpts = {},
+ ): Promise<string> {
await assert.isSenderAddressAsync('ownerAddress', ownerAddress, this._web3Wrapper);
assert.isETHAddressHex('spenderAddress', spenderAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
@@ -97,10 +107,18 @@ export class TokenWrapper extends ContractWrapper {
* @param txOpts Transaction parameters.
* @return Transaction hash.
*/
- public async setUnlimitedAllowanceAsync(tokenAddress: string, ownerAddress: string,
- spenderAddress: string, txOpts: TransactionOpts = {}): Promise<string> {
+ public async setUnlimitedAllowanceAsync(
+ tokenAddress: string,
+ ownerAddress: string,
+ spenderAddress: string,
+ txOpts: TransactionOpts = {},
+ ): Promise<string> {
const txHash = await this.setAllowanceAsync(
- tokenAddress, ownerAddress, spenderAddress, this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS, txOpts,
+ tokenAddress,
+ ownerAddress,
+ spenderAddress,
+ this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS,
+ txOpts,
);
return txHash;
}
@@ -112,8 +130,12 @@ export class TokenWrapper extends ContractWrapper {
* @param spenderAddress The hex encoded user Ethereum address who can spend the allowance you are fetching.
* @param methodOpts Optional arguments this method accepts.
*/
- public async getAllowanceAsync(tokenAddress: string, ownerAddress: string,
- spenderAddress: string, methodOpts?: MethodOpts): Promise<BigNumber> {
+ public async getAllowanceAsync(
+ tokenAddress: string,
+ ownerAddress: string,
+ spenderAddress: string,
+ methodOpts?: MethodOpts,
+ ): Promise<BigNumber> {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
@@ -130,8 +152,11 @@ export class TokenWrapper extends ContractWrapper {
* @param ownerAddress The hex encoded user Ethereum address whose proxy contract allowance we are retrieving.
* @param methodOpts Optional arguments this method accepts.
*/
- public async getProxyAllowanceAsync(tokenAddress: string, ownerAddress: string,
- methodOpts?: MethodOpts): Promise<BigNumber> {
+ public async getProxyAllowanceAsync(
+ tokenAddress: string,
+ ownerAddress: string,
+ methodOpts?: MethodOpts,
+ ): Promise<BigNumber> {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
@@ -149,15 +174,23 @@ export class TokenWrapper extends ContractWrapper {
* @param txOpts Transaction parameters.
* @return Transaction hash.
*/
- public async setProxyAllowanceAsync(tokenAddress: string, ownerAddress: string,
- amountInBaseUnits: BigNumber, txOpts: TransactionOpts = {}): Promise<string> {
+ public async setProxyAllowanceAsync(
+ tokenAddress: string,
+ ownerAddress: string,
+ amountInBaseUnits: BigNumber,
+ txOpts: TransactionOpts = {},
+ ): Promise<string> {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
const proxyAddress = this._tokenTransferProxyWrapper.getContractAddress();
const txHash = await this.setAllowanceAsync(
- tokenAddress, ownerAddress, proxyAddress, amountInBaseUnits, txOpts,
+ tokenAddress,
+ ownerAddress,
+ proxyAddress,
+ amountInBaseUnits,
+ txOpts,
);
return txHash;
}
@@ -173,10 +206,15 @@ export class TokenWrapper extends ContractWrapper {
* @return Transaction hash.
*/
public async setUnlimitedProxyAllowanceAsync(
- tokenAddress: string, ownerAddress: string, txOpts: TransactionOpts = {},
+ tokenAddress: string,
+ ownerAddress: string,
+ txOpts: TransactionOpts = {},
): Promise<string> {
const txHash = await this.setProxyAllowanceAsync(
- tokenAddress, ownerAddress, this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS, txOpts,
+ tokenAddress,
+ ownerAddress,
+ this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS,
+ txOpts,
);
return txHash;
}
@@ -189,8 +227,13 @@ export class TokenWrapper extends ContractWrapper {
* @param txOpts Transaction parameters.
* @return Transaction hash.
*/
- public async transferAsync(tokenAddress: string, fromAddress: string, toAddress: string,
- amountInBaseUnits: BigNumber, txOpts: TransactionOpts = {}): Promise<string> {
+ public async transferAsync(
+ tokenAddress: string,
+ fromAddress: string,
+ toAddress: string,
+ amountInBaseUnits: BigNumber,
+ txOpts: TransactionOpts = {},
+ ): Promise<string> {
assert.isETHAddressHex('tokenAddress', tokenAddress);
await assert.isSenderAddressAsync('fromAddress', fromAddress, this._web3Wrapper);
assert.isETHAddressHex('toAddress', toAddress);
@@ -224,9 +267,14 @@ export class TokenWrapper extends ContractWrapper {
* @param txOpts Transaction parameters.
* @return Transaction hash.
*/
- public async transferFromAsync(tokenAddress: string, fromAddress: string, toAddress: string,
- senderAddress: string, amountInBaseUnits: BigNumber, txOpts: TransactionOpts = {}):
- Promise<string> {
+ public async transferFromAsync(
+ tokenAddress: string,
+ fromAddress: string,
+ toAddress: string,
+ senderAddress: string,
+ amountInBaseUnits: BigNumber,
+ txOpts: TransactionOpts = {},
+ ): Promise<string> {
assert.isETHAddressHex('tokenAddress', tokenAddress);
assert.isETHAddressHex('fromAddress', fromAddress);
assert.isETHAddressHex('toAddress', toAddress);
@@ -246,7 +294,9 @@ export class TokenWrapper extends ContractWrapper {
}
const txHash = await tokenContract.transferFrom.sendTransactionAsync(
- fromAddress, toAddress, amountInBaseUnits,
+ fromAddress,
+ toAddress,
+ amountInBaseUnits,
{
from: senderAddress,
gas: txOpts.gasLimit,
@@ -265,14 +315,21 @@ export class TokenWrapper extends ContractWrapper {
* @return Subscription token used later to unsubscribe
*/
public subscribe<ArgsType extends TokenContractEventArgs>(
- tokenAddress: string, eventName: TokenEvents, indexFilterValues: IndexedFilterValues,
- callback: EventCallback<ArgsType>): string {
+ tokenAddress: string,
+ eventName: TokenEvents,
+ indexFilterValues: IndexedFilterValues,
+ callback: EventCallback<ArgsType>,
+ ): string {
assert.isETHAddressHex('tokenAddress', tokenAddress);
assert.doesBelongToStringEnum('eventName', eventName, TokenEvents);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
assert.isFunction('callback', callback);
const subscriptionToken = this._subscribe<ArgsType>(
- tokenAddress, eventName, indexFilterValues, artifacts.TokenArtifact.abi, callback,
+ tokenAddress,
+ eventName,
+ indexFilterValues,
+ artifacts.TokenArtifact.abi,
+ callback,
);
return subscriptionToken;
}
@@ -284,23 +341,36 @@ export class TokenWrapper extends ContractWrapper {
this._unsubscribe(subscriptionToken);
}
/**
+ * Cancels all existing subscriptions
+ */
+ public unsubscribeAll(): void {
+ super.unsubscribeAll();
+ }
+ /**
* Gets historical logs without creating a subscription
* @param tokenAddress An address of the token that emmited the logs.
* @param eventName The token contract event you would like to subscribe to.
- * @param subscriptionOpts Subscriptions options that let you configure the subscription.
+ * @param blockRange Block range to get logs from.
* @param indexFilterValues An object where the keys are indexed args returned by the event and
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
* @return Array of logs that match the parameters
*/
public async getLogsAsync<ArgsType extends TokenContractEventArgs>(
- tokenAddress: string, eventName: TokenEvents, subscriptionOpts: SubscriptionOpts,
- indexFilterValues: IndexedFilterValues): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
+ tokenAddress: string,
+ eventName: TokenEvents,
+ blockRange: BlockRange,
+ indexFilterValues: IndexedFilterValues,
+ ): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
assert.isETHAddressHex('tokenAddress', tokenAddress);
assert.doesBelongToStringEnum('eventName', eventName, TokenEvents);
- assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema);
+ assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const logs = await this._getLogsAsync<ArgsType>(
- tokenAddress, eventName, subscriptionOpts, indexFilterValues, artifacts.TokenArtifact.abi,
+ tokenAddress,
+ eventName,
+ blockRange,
+ indexFilterValues,
+ artifacts.TokenArtifact.abi,
);
return logs;
}
@@ -314,11 +384,10 @@ export class TokenWrapper extends ContractWrapper {
return tokenContract;
}
const web3ContractInstance = await this._instantiateContractIfExistsAsync(
- artifacts.TokenArtifact, tokenAddress,
- );
- const contractInstance = new TokenContract(
- web3ContractInstance, this._web3Wrapper.getContractDefaults(),
+ artifacts.TokenArtifact,
+ tokenAddress,
);
+ const contractInstance = new TokenContract(web3ContractInstance, this._web3Wrapper.getContractDefaults());
tokenContract = contractInstance;
this._tokenContractsByAddress[tokenAddress] = tokenContract;
return tokenContract;
diff --git a/packages/0x.js/src/globals.d.ts b/packages/0x.js/src/globals.d.ts
index 4fa1cfd9c..4f4932b6e 100644
--- a/packages/0x.js/src/globals.d.ts
+++ b/packages/0x.js/src/globals.d.ts
@@ -1,5 +1,3 @@
-/// <reference types='chai-typescript-typings' />
-/// <reference types='chai-as-promised-typescript-typings' />
declare module 'web3_beta';
declare module 'chai-bignumber';
declare module 'dirty-chai';
@@ -27,18 +25,6 @@ declare module '*.json' {
/* tslint:enable */
}
-// find-version declarations
-declare function findVersions(version: string): string[];
-declare module 'find-versions' {
- export = findVersions;
-}
-
-// compare-version declarations
-declare function compareVersions(firstVersion: string, secondVersion: string): number;
-declare module 'compare-versions' {
- export = compareVersions;
-}
-
declare module 'ethereumjs-abi' {
const soliditySHA3: (argTypes: string[], args: any[]) => Buffer;
}
@@ -57,8 +43,7 @@ declare module 'truffle-hdwallet-provider' {
}
// abi-decoder declarations
-interface DecodedLogArg {
-}
+interface DecodedLogArg {}
interface DecodedLog {
name: string;
events: DecodedLogArg[];
diff --git a/packages/0x.js/src/globalsAugment.d.ts b/packages/0x.js/src/globalsAugment.d.ts
index 60e2312a3..3e2f2216b 100644
--- a/packages/0x.js/src/globalsAugment.d.ts
+++ b/packages/0x.js/src/globalsAugment.d.ts
@@ -1,4 +1,4 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
// HACK: This module overrides the Chai namespace so that we can use BigNumber types inside.
// Source: https://github.com/Microsoft/TypeScript/issues/7352#issuecomment-191547232
@@ -9,7 +9,7 @@ declare global {
/* tslint:disable */
namespace Chai {
interface NumberComparer {
- (value: number|BigNumber, message?: string): Assertion;
+ (value: number | BigNumber, message?: string): Assertion;
}
interface NumericComparison {
greaterThan: NumberComparer;
@@ -18,6 +18,6 @@ declare global {
/* tslint:enable */
interface DecodedLogArg {
name: string;
- value: string|BigNumber;
+ value: string | BigNumber;
}
}
diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts
index d4193a3e9..599c3a2b0 100644
--- a/packages/0x.js/src/index.ts
+++ b/packages/0x.js/src/index.ts
@@ -1,7 +1,8 @@
-export {ZeroEx} from './0x';
+export { ZeroEx } from './0x';
export {
Order,
+ BlockParamLiteral,
SignedOrder,
ECSignature,
ZeroExError,
@@ -12,7 +13,7 @@ export {
ExchangeEvents,
TokenEvents,
IndexedFilterValues,
- SubscriptionOpts,
+ BlockRange,
BlockParam,
OrderCancellationRequest,
OrderFillRequest,
@@ -23,11 +24,14 @@ export {
TransferContractEventArgs,
ApprovalContractEventArgs,
TokenContractEventArgs,
+ EtherTokenContractEventArgs,
+ WithdrawalContractEventArgs,
+ DepositContractEventArgs,
ContractEventArgs,
ContractEventArg,
Web3Provider,
ZeroExConfig,
- TransactionReceipt,
+ EtherTokenEvents,
TransactionReceiptWithDecodedLogs,
LogWithDecodedArgs,
MethodOpts,
@@ -42,3 +46,5 @@ export {
OrderStateInvalid,
OrderState,
} from './types';
+
+export { TransactionReceipt } from '@0xproject/types';
diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts
index d5b30d567..5d05bfb60 100644
--- a/packages/0x.js/src/order_watcher/event_watcher.ts
+++ b/packages/0x.js/src/order_watcher/event_watcher.ts
@@ -1,17 +1,10 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
+import { intervalUtils } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import * as Web3 from 'web3';
-import {
- BlockParamLiteral,
- EventCallback,
- EventWatcherCallback,
- ZeroExError,
-} from '../types';
-import {AbiDecoder} from '../utils/abi_decoder';
-import {assert} from '../utils/assert';
-import {intervalUtils} from '../utils/interval_utils';
-import {utils} from '../utils/utils';
+import { BlockParamLiteral, EventWatcherCallback, ZeroExError } from '../types';
+import { assert } from '../utils/assert';
const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200;
@@ -29,11 +22,11 @@ export class EventWatcher {
private _pollingIntervalMs: number;
private _intervalIdIfExists?: NodeJS.Timer;
private _lastEvents: Web3.LogEntry[] = [];
- constructor(web3Wrapper: Web3Wrapper, pollingIntervalIfExistsMs: undefined|number) {
+ constructor(web3Wrapper: Web3Wrapper, pollingIntervalIfExistsMs: undefined | number) {
this._web3Wrapper = web3Wrapper;
- this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs) ?
- DEFAULT_EVENT_POLLING_INTERVAL_MS :
- pollingIntervalIfExistsMs;
+ this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs)
+ ? DEFAULT_EVENT_POLLING_INTERVAL_MS
+ : pollingIntervalIfExistsMs;
}
public subscribe(callback: EventWatcherCallback): void {
assert.isFunction('callback', callback);
@@ -41,7 +34,12 @@ export class EventWatcher {
throw new Error(ZeroExError.SubscriptionAlreadyPresent);
}
this._intervalIdIfExists = intervalUtils.setAsyncExcludingInterval(
- this._pollForBlockchainEventsAsync.bind(this, callback), this._pollingIntervalMs,
+ this._pollForBlockchainEventsAsync.bind(this, callback),
+ this._pollingIntervalMs,
+ (err: Error) => {
+ this.unsubscribe();
+ callback(err);
+ },
);
}
public unsubscribe(): void {
@@ -53,6 +51,10 @@ export class EventWatcher {
}
private async _pollForBlockchainEventsAsync(callback: EventWatcherCallback): Promise<void> {
const pendingEvents = await this._getEventsAsync();
+ if (_.isUndefined(pendingEvents)) {
+ // HACK: This should never happen, but happens frequently on CI due to a ganache bug
+ return;
+ }
if (pendingEvents.length === 0) {
// HACK: Sometimes when node rebuilds the pending block we get back the empty result.
// We don't want to emit a lot of removal events and bring them back after a couple of miliseconds,
@@ -74,7 +76,9 @@ export class EventWatcher {
return events;
}
private async _emitDifferencesAsync(
- logs: Web3.LogEntry[], logEventState: LogEventState, callback: EventWatcherCallback,
+ logs: Web3.LogEntry[],
+ logEventState: LogEventState,
+ callback: EventWatcherCallback,
): Promise<void> {
for (const log of logs) {
const logEvent = {
@@ -82,7 +86,7 @@ export class EventWatcher {
...log,
};
if (!_.isUndefined(this._intervalIdIfExists)) {
- callback(logEvent);
+ callback(null, logEvent);
}
}
}
diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts
index 9a1bb1ca4..00b62162d 100644
--- a/packages/0x.js/src/order_watcher/expiration_watcher.ts
+++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts
@@ -1,11 +1,9 @@
-import {BigNumber} from 'bignumber.js';
-import {RBTree} from 'bintrees';
+import { BigNumber, intervalUtils } from '@0xproject/utils';
+import { RBTree } from 'bintrees';
import * as _ from 'lodash';
-import {ZeroEx} from '../0x';
-import {SignedOrder, ZeroExError} from '../types';
-import {intervalUtils} from '../utils/interval_utils';
-import {utils} from '../utils/utils';
+import { ZeroExError } from '../types';
+import { utils } from '../utils/utils';
const DEFAULT_EXPIRATION_MARGIN_MS = 0;
const DEFAULT_ORDER_EXPIRATION_CHECKING_INTERVAL_MS = 50;
@@ -15,62 +13,62 @@ const DEFAULT_ORDER_EXPIRATION_CHECKING_INTERVAL_MS = 50;
* It stores them in a min heap by expiration time and checks for expired ones every `orderExpirationCheckingIntervalMs`
*/
export class ExpirationWatcher {
- private orderHashByExpirationRBTree: RBTree<string>;
- private expiration: {[orderHash: string]: BigNumber} = {};
- private orderExpirationCheckingIntervalMs: number;
- private expirationMarginMs: number;
- private orderExpirationCheckingIntervalIdIfExists?: NodeJS.Timer;
- constructor(expirationMarginIfExistsMs?: number,
- orderExpirationCheckingIntervalIfExistsMs?: number) {
- this.expirationMarginMs = expirationMarginIfExistsMs ||
- DEFAULT_EXPIRATION_MARGIN_MS;
- this.orderExpirationCheckingIntervalMs = expirationMarginIfExistsMs ||
- DEFAULT_ORDER_EXPIRATION_CHECKING_INTERVAL_MS;
- const scoreFunction = (orderHash: string) => this.expiration[orderHash].toNumber();
+ private _orderHashByExpirationRBTree: RBTree<string>;
+ private _expiration: { [orderHash: string]: BigNumber } = {};
+ private _orderExpirationCheckingIntervalMs: number;
+ private _expirationMarginMs: number;
+ private _orderExpirationCheckingIntervalIdIfExists?: NodeJS.Timer;
+ constructor(expirationMarginIfExistsMs?: number, orderExpirationCheckingIntervalIfExistsMs?: number) {
+ this._expirationMarginMs = expirationMarginIfExistsMs || DEFAULT_EXPIRATION_MARGIN_MS;
+ this._orderExpirationCheckingIntervalMs =
+ expirationMarginIfExistsMs || DEFAULT_ORDER_EXPIRATION_CHECKING_INTERVAL_MS;
+ const scoreFunction = (orderHash: string) => this._expiration[orderHash].toNumber();
const comparator = (lhs: string, rhs: string) => scoreFunction(lhs) - scoreFunction(rhs);
- this.orderHashByExpirationRBTree = new RBTree(comparator);
+ this._orderHashByExpirationRBTree = new RBTree(comparator);
}
public subscribe(callback: (orderHash: string) => void): void {
- if (!_.isUndefined(this.orderExpirationCheckingIntervalIdIfExists)) {
+ if (!_.isUndefined(this._orderExpirationCheckingIntervalIdIfExists)) {
throw new Error(ZeroExError.SubscriptionAlreadyPresent);
}
- this.orderExpirationCheckingIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval(
- this.pruneExpiredOrders.bind(this, callback), this.orderExpirationCheckingIntervalMs,
+ this._orderExpirationCheckingIntervalIdIfExists = intervalUtils.setInterval(
+ this._pruneExpiredOrders.bind(this, callback),
+ this._orderExpirationCheckingIntervalMs,
+ _.noop, // _pruneExpiredOrders never throws
);
}
public unsubscribe(): void {
- if (_.isUndefined(this.orderExpirationCheckingIntervalIdIfExists)) {
+ if (_.isUndefined(this._orderExpirationCheckingIntervalIdIfExists)) {
throw new Error(ZeroExError.SubscriptionNotFound);
}
- intervalUtils.clearAsyncExcludingInterval(this.orderExpirationCheckingIntervalIdIfExists);
- delete this.orderExpirationCheckingIntervalIdIfExists;
+ intervalUtils.clearInterval(this._orderExpirationCheckingIntervalIdIfExists);
+ delete this._orderExpirationCheckingIntervalIdIfExists;
}
public addOrder(orderHash: string, expirationUnixTimestampMs: BigNumber): void {
- this.expiration[orderHash] = expirationUnixTimestampMs;
- this.orderHashByExpirationRBTree.insert(orderHash);
+ this._expiration[orderHash] = expirationUnixTimestampMs;
+ this._orderHashByExpirationRBTree.insert(orderHash);
}
public removeOrder(orderHash: string): void {
- this.orderHashByExpirationRBTree.remove(orderHash);
- delete this.expiration[orderHash];
+ this._orderHashByExpirationRBTree.remove(orderHash);
+ delete this._expiration[orderHash];
}
- private pruneExpiredOrders(callback: (orderHash: string) => void): void {
+ private _pruneExpiredOrders(callback: (orderHash: string) => void): void {
const currentUnixTimestampMs = utils.getCurrentUnixTimestampMs();
while (true) {
- const hasTrakedOrders = this.orderHashByExpirationRBTree.size === 0;
+ const hasTrakedOrders = this._orderHashByExpirationRBTree.size === 0;
if (hasTrakedOrders) {
break;
}
- const nextOrderHashToExpire = this.orderHashByExpirationRBTree.min();
- const hasNoExpiredOrders = this.expiration[nextOrderHashToExpire].greaterThan(
- currentUnixTimestampMs.plus(this.expirationMarginMs),
+ const nextOrderHashToExpire = this._orderHashByExpirationRBTree.min();
+ const hasNoExpiredOrders = this._expiration[nextOrderHashToExpire].greaterThan(
+ currentUnixTimestampMs.plus(this._expirationMarginMs),
);
- const isSubscriptionActive = _.isUndefined(this.orderExpirationCheckingIntervalIdIfExists);
+ const isSubscriptionActive = _.isUndefined(this._orderExpirationCheckingIntervalIdIfExists);
if (hasNoExpiredOrders || isSubscriptionActive) {
break;
}
- const orderHash = this.orderHashByExpirationRBTree.min();
- this.orderHashByExpirationRBTree.remove(orderHash);
- delete this.expiration[orderHash];
+ const orderHash = this._orderHashByExpirationRBTree.min();
+ this._orderHashByExpirationRBTree.remove(orderHash);
+ delete this._expiration[orderHash];
callback(orderHash);
}
}
diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts
index 08f52d6e1..12ac60960 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -1,17 +1,19 @@
-import {schemas} from '@0xproject/json-schemas';
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
+import { schemas } from '@0xproject/json-schemas';
+import { intervalUtils } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import {ZeroEx} from '../0x';
-import {artifacts} from '../artifacts';
-import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
-import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
-import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store';
+import { ZeroEx } from '../0x';
+import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
+import { TokenWrapper } from '../contract_wrappers/token_wrapper';
+import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store';
+import { OrderFilledCancelledLazyStore } from '../stores/order_filled_cancelled_lazy_store';
import {
ApprovalContractEventArgs,
BlockParamLiteral,
ContractEventArgs,
+ DepositContractEventArgs,
+ EtherTokenEvents,
ExchangeContractErrs,
ExchangeEvents,
LogCancelContractEventArgs,
@@ -24,17 +26,16 @@ import {
SignedOrder,
TokenEvents,
TransferContractEventArgs,
- Web3Provider,
+ WithdrawalContractEventArgs,
ZeroExError,
} from '../types';
-import {AbiDecoder} from '../utils/abi_decoder';
-import {assert} from '../utils/assert';
-import {intervalUtils} from '../utils/interval_utils';
-import {OrderStateUtils} from '../utils/order_state_utils';
-import {utils} from '../utils/utils';
+import { AbiDecoder } from '../utils/abi_decoder';
+import { assert } from '../utils/assert';
+import { OrderStateUtils } from '../utils/order_state_utils';
+import { utils } from '../utils/utils';
-import {EventWatcher} from './event_watcher';
-import {ExpirationWatcher} from './expiration_watcher';
+import { EventWatcher } from './event_watcher';
+import { ExpirationWatcher } from './expiration_watcher';
interface DependentOrderHashes {
[makerAddress: string]: {
@@ -73,7 +74,10 @@ export class OrderStateWatcher {
private _cleanupJobInterval: number;
private _cleanupJobIntervalIdIfExists?: NodeJS.Timer;
constructor(
- web3Wrapper: Web3Wrapper, abiDecoder: AbiDecoder, token: TokenWrapper, exchange: ExchangeWrapper,
+ web3Wrapper: Web3Wrapper,
+ abiDecoder: AbiDecoder,
+ token: TokenWrapper,
+ exchange: ExchangeWrapper,
config?: OrderStateWatcherConfig,
) {
this._abiDecoder = abiDecoder;
@@ -81,24 +85,26 @@ export class OrderStateWatcher {
const pollingIntervalIfExistsMs = _.isUndefined(config) ? undefined : config.eventPollingIntervalMs;
this._eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalIfExistsMs);
this._balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore(
- token, BlockParamLiteral.Pending,
+ token,
+ BlockParamLiteral.Pending,
);
this._orderFilledCancelledLazyStore = new OrderFilledCancelledLazyStore(exchange);
this._orderStateUtils = new OrderStateUtils(
- this._balanceAndProxyAllowanceLazyStore, this._orderFilledCancelledLazyStore,
+ this._balanceAndProxyAllowanceLazyStore,
+ this._orderFilledCancelledLazyStore,
);
- const orderExpirationCheckingIntervalMsIfExists = _.isUndefined(config) ?
- undefined :
- config.orderExpirationCheckingIntervalMs;
- const expirationMarginIfExistsMs = _.isUndefined(config) ?
- undefined :
- config.expirationMarginMs;
+ const orderExpirationCheckingIntervalMsIfExists = _.isUndefined(config)
+ ? undefined
+ : config.orderExpirationCheckingIntervalMs;
+ const expirationMarginIfExistsMs = _.isUndefined(config) ? undefined : config.expirationMarginMs;
this._expirationWatcher = new ExpirationWatcher(
- expirationMarginIfExistsMs, orderExpirationCheckingIntervalMsIfExists,
+ expirationMarginIfExistsMs,
+ orderExpirationCheckingIntervalMsIfExists,
);
- this._cleanupJobInterval = _.isUndefined(config) || _.isUndefined(config.cleanupJobIntervalMs) ?
- DEFAULT_CLEANUP_JOB_INTERVAL_MS :
- config.cleanupJobIntervalMs;
+ this._cleanupJobInterval =
+ _.isUndefined(config) || _.isUndefined(config.cleanupJobIntervalMs)
+ ? DEFAULT_CLEANUP_JOB_INTERVAL_MS
+ : config.cleanupJobIntervalMs;
}
/**
* Add an order to the orderStateWatcher. Before the order is added, it's
@@ -110,7 +116,7 @@ export class OrderStateWatcher {
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
assert.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker);
this._orderByOrderHash[orderHash] = signedOrder;
- this.addToDependentOrderHashes(signedOrder, orderHash);
+ this._addToDependentOrderHashes(signedOrder, orderHash);
const expirationUnixTimestampMs = signedOrder.expirationUnixTimestampSec.times(1000);
this._expirationWatcher.addOrder(orderHash, expirationUnixTimestampMs);
}
@@ -126,10 +132,10 @@ export class OrderStateWatcher {
}
delete this._orderByOrderHash[orderHash];
delete this._orderStateByOrderHashCache[orderHash];
- const exchange = (this._orderFilledCancelledLazyStore as any).exchange as ExchangeWrapper;
+ const exchange = (this._orderFilledCancelledLazyStore as any)._exchange as ExchangeWrapper;
const zrxTokenAddress = exchange.getZRXTokenAddress();
- this.removeFromDependentOrderHashes(signedOrder.maker, zrxTokenAddress, orderHash);
- this.removeFromDependentOrderHashes(signedOrder.maker, signedOrder.makerTokenAddress, orderHash);
+ this._removeFromDependentOrderHashes(signedOrder.maker, zrxTokenAddress, orderHash);
+ this._removeFromDependentOrderHashes(signedOrder.maker, signedOrder.makerTokenAddress, orderHash);
this._expirationWatcher.removeOrder(orderHash);
}
/**
@@ -147,7 +153,12 @@ export class OrderStateWatcher {
this._eventWatcher.subscribe(this._onEventWatcherCallbackAsync.bind(this));
this._expirationWatcher.subscribe(this._onOrderExpired.bind(this));
this._cleanupJobIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval(
- this._cleanupAsync.bind(this), this._cleanupJobInterval,
+ this._cleanupAsync.bind(this),
+ this._cleanupJobInterval,
+ (err: Error) => {
+ this.unsubscribe();
+ callback(err);
+ },
);
}
/**
@@ -200,11 +211,19 @@ export class OrderStateWatcher {
if (!_.isUndefined(this._orderByOrderHash[orderHash])) {
this.removeOrder(orderHash);
if (!_.isUndefined(this._callbackIfExists)) {
- this._callbackIfExists(orderState);
+ this._callbackIfExists(null, orderState);
}
}
}
- private async _onEventWatcherCallbackAsync(log: LogEvent): Promise<void> {
+ private async _onEventWatcherCallbackAsync(err: Error | null, logIfExists?: LogEvent): Promise<void> {
+ if (!_.isNull(err)) {
+ if (!_.isUndefined(this._callbackIfExists)) {
+ this._callbackIfExists(err);
+ this.unsubscribe();
+ }
+ return;
+ }
+ const log = logIfExists as LogEvent; // At this moment we are sure that no error occured and log is defined.
const maybeDecodedLog = this._abiDecoder.tryToDecodeLogOrNoop(log);
const isLogDecoded = !_.isUndefined((maybeDecodedLog as LogWithDecodedArgs<any>).event);
if (!isLogDecoded) {
@@ -214,23 +233,23 @@ export class OrderStateWatcher {
let makerToken: string;
let makerAddress: string;
switch (decodedLog.event) {
- case TokenEvents.Approval:
- {
+ case TokenEvents.Approval: {
// Invalidate cache
const args = decodedLog.args as ApprovalContractEventArgs;
this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(decodedLog.address, args._owner);
// Revalidate orders
makerToken = decodedLog.address;
makerAddress = args._owner;
- if (!_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
- !_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])) {
+ if (
+ !_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
+ !_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])
+ ) {
const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
await this._emitRevalidateOrdersAsync(orderHashes);
}
break;
}
- case TokenEvents.Transfer:
- {
+ case TokenEvents.Transfer: {
// Invalidate cache
const args = decodedLog.args as TransferContractEventArgs;
this._balanceAndProxyAllowanceLazyStore.deleteBalance(decodedLog.address, args._from);
@@ -238,15 +257,48 @@ export class OrderStateWatcher {
// Revalidate orders
makerToken = decodedLog.address;
makerAddress = args._from;
- if (!_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
- !_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])) {
+ if (
+ !_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
+ !_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])
+ ) {
+ const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
+ await this._emitRevalidateOrdersAsync(orderHashes);
+ }
+ break;
+ }
+ case EtherTokenEvents.Deposit: {
+ // Invalidate cache
+ const args = decodedLog.args as DepositContractEventArgs;
+ this._balanceAndProxyAllowanceLazyStore.deleteBalance(decodedLog.address, args._owner);
+ // Revalidate orders
+ makerToken = decodedLog.address;
+ makerAddress = args._owner;
+ if (
+ !_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
+ !_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])
+ ) {
+ const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
+ await this._emitRevalidateOrdersAsync(orderHashes);
+ }
+ break;
+ }
+ case EtherTokenEvents.Withdrawal: {
+ // Invalidate cache
+ const args = decodedLog.args as WithdrawalContractEventArgs;
+ this._balanceAndProxyAllowanceLazyStore.deleteBalance(decodedLog.address, args._owner);
+ // Revalidate orders
+ makerToken = decodedLog.address;
+ makerAddress = args._owner;
+ if (
+ !_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
+ !_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])
+ ) {
const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
await this._emitRevalidateOrdersAsync(orderHashes);
}
break;
}
- case ExchangeEvents.LogFill:
- {
+ case ExchangeEvents.LogFill: {
// Invalidate cache
const args = decodedLog.args as LogFillContractEventArgs;
this._orderFilledCancelledLazyStore.deleteFilledTakerAmount(args.orderHash);
@@ -258,8 +310,7 @@ export class OrderStateWatcher {
}
break;
}
- case ExchangeEvents.LogCancel:
- {
+ case ExchangeEvents.LogCancel: {
// Invalidate cache
const args = decodedLog.args as LogCancelContractEventArgs;
this._orderFilledCancelledLazyStore.deleteCancelledTakerAmount(args.orderHash);
@@ -293,10 +344,10 @@ export class OrderStateWatcher {
} else {
this._orderStateByOrderHashCache[orderHash] = orderState;
}
- this._callbackIfExists(orderState);
+ this._callbackIfExists(null, orderState);
}
}
- private addToDependentOrderHashes(signedOrder: SignedOrder, orderHash: string): void {
+ private _addToDependentOrderHashes(signedOrder: SignedOrder, orderHash: string): void {
if (_.isUndefined(this._dependentOrderHashes[signedOrder.maker])) {
this._dependentOrderHashes[signedOrder.maker] = {};
}
@@ -310,7 +361,7 @@ export class OrderStateWatcher {
}
this._dependentOrderHashes[signedOrder.maker][zrxTokenAddress].add(orderHash);
}
- private removeFromDependentOrderHashes(makerAddress: string, tokenAddress: string, orderHash: string) {
+ private _removeFromDependentOrderHashes(makerAddress: string, tokenAddress: string, orderHash: string) {
this._dependentOrderHashes[makerAddress][tokenAddress].delete(orderHash);
if (this._dependentOrderHashes[makerAddress][tokenAddress].size === 0) {
delete this._dependentOrderHashes[makerAddress][tokenAddress];
@@ -320,7 +371,7 @@ export class OrderStateWatcher {
}
}
private _getZRXTokenAddress(): string {
- const exchange = (this._orderFilledCancelledLazyStore as any).exchange as ExchangeWrapper;
+ const exchange = (this._orderFilledCancelledLazyStore as any)._exchange as ExchangeWrapper;
const zrxTokenAddress = exchange.getZRXTokenAddress();
return zrxTokenAddress;
}
diff --git a/packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts b/packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts
index e8601e678..20b09d606 100644
--- a/packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts
+++ b/packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts
@@ -1,87 +1,96 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
-import {SignedOrder} from '../types';
+import { SignedOrder } from '../types';
export class RemainingFillableCalculator {
- private signedOrder: SignedOrder;
- private isMakerTokenZRX: boolean;
+ private _signedOrder: SignedOrder;
+ private _isMakerTokenZRX: boolean;
// Transferrable Amount is the minimum of Approval and Balance
- private transferrableMakerTokenAmount: BigNumber;
- private transferrableMakerFeeTokenAmount: BigNumber;
- private remainingMakerTokenAmount: BigNumber;
- private remainingMakerFeeAmount: BigNumber;
- constructor(signedOrder: SignedOrder,
- isMakerTokenZRX: boolean,
- transferrableMakerTokenAmount: BigNumber,
- transferrableMakerFeeTokenAmount: BigNumber,
- remainingMakerTokenAmount: BigNumber) {
- this.signedOrder = signedOrder;
- this.isMakerTokenZRX = isMakerTokenZRX;
- this.transferrableMakerTokenAmount = transferrableMakerTokenAmount;
- this.transferrableMakerFeeTokenAmount = transferrableMakerFeeTokenAmount;
- this.remainingMakerTokenAmount = remainingMakerTokenAmount;
- this.remainingMakerFeeAmount = remainingMakerTokenAmount.times(signedOrder.makerFee)
- .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ private _transferrableMakerTokenAmount: BigNumber;
+ private _transferrableMakerFeeTokenAmount: BigNumber;
+ private _remainingMakerTokenAmount: BigNumber;
+ private _remainingMakerFeeAmount: BigNumber;
+ constructor(
+ signedOrder: SignedOrder,
+ isMakerTokenZRX: boolean,
+ transferrableMakerTokenAmount: BigNumber,
+ transferrableMakerFeeTokenAmount: BigNumber,
+ remainingMakerTokenAmount: BigNumber,
+ ) {
+ this._signedOrder = signedOrder;
+ this._isMakerTokenZRX = isMakerTokenZRX;
+ this._transferrableMakerTokenAmount = transferrableMakerTokenAmount;
+ this._transferrableMakerFeeTokenAmount = transferrableMakerFeeTokenAmount;
+ this._remainingMakerTokenAmount = remainingMakerTokenAmount;
+ this._remainingMakerFeeAmount = remainingMakerTokenAmount
+ .times(signedOrder.makerFee)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
}
public computeRemainingMakerFillable(): BigNumber {
- if (this.hasSufficientFundsForFeeAndTransferAmount()) {
- return this.remainingMakerTokenAmount;
+ if (this._hasSufficientFundsForFeeAndTransferAmount()) {
+ return this._remainingMakerTokenAmount;
}
- if (this.signedOrder.makerFee.isZero()) {
- return BigNumber.min(this.remainingMakerTokenAmount, this.transferrableMakerTokenAmount);
+ if (this._signedOrder.makerFee.isZero()) {
+ return BigNumber.min(this._remainingMakerTokenAmount, this._transferrableMakerTokenAmount);
}
- return this.calculatePartiallyFillableMakerTokenAmount();
+ return this._calculatePartiallyFillableMakerTokenAmount();
}
public computeRemainingTakerFillable(): BigNumber {
- return this.computeRemainingMakerFillable().times(this.signedOrder.takerTokenAmount)
- .dividedToIntegerBy(this.signedOrder.makerTokenAmount);
+ return this.computeRemainingMakerFillable()
+ .times(this._signedOrder.takerTokenAmount)
+ .dividedToIntegerBy(this._signedOrder.makerTokenAmount);
}
- private hasSufficientFundsForFeeAndTransferAmount(): boolean {
- if (this.isMakerTokenZRX) {
- const totalZRXTransferAmountRequired = this.remainingMakerTokenAmount.plus(this.remainingMakerFeeAmount);
- const hasSufficientFunds = this.transferrableMakerTokenAmount.greaterThanOrEqualTo(
- totalZRXTransferAmountRequired);
+ private _hasSufficientFundsForFeeAndTransferAmount(): boolean {
+ if (this._isMakerTokenZRX) {
+ const totalZRXTransferAmountRequired = this._remainingMakerTokenAmount.plus(this._remainingMakerFeeAmount);
+ const hasSufficientFunds = this._transferrableMakerTokenAmount.greaterThanOrEqualTo(
+ totalZRXTransferAmountRequired,
+ );
return hasSufficientFunds;
} else {
- const hasSufficientFundsForTransferAmount = this.transferrableMakerTokenAmount.greaterThanOrEqualTo(
- this.remainingMakerTokenAmount);
- const hasSufficientFundsForFeeAmount = this.transferrableMakerFeeTokenAmount.greaterThanOrEqualTo(
- this.remainingMakerFeeAmount);
+ const hasSufficientFundsForTransferAmount = this._transferrableMakerTokenAmount.greaterThanOrEqualTo(
+ this._remainingMakerTokenAmount,
+ );
+ const hasSufficientFundsForFeeAmount = this._transferrableMakerFeeTokenAmount.greaterThanOrEqualTo(
+ this._remainingMakerFeeAmount,
+ );
const hasSufficientFunds = hasSufficientFundsForTransferAmount && hasSufficientFundsForFeeAmount;
return hasSufficientFunds;
}
}
- private calculatePartiallyFillableMakerTokenAmount(): BigNumber {
+ private _calculatePartiallyFillableMakerTokenAmount(): BigNumber {
// Given an order for 200 wei for 2 ZRXwei fee, find 100 wei for 1 ZRXwei. Order ratio is then 100:1
- const orderToFeeRatio = this.signedOrder.makerTokenAmount.dividedBy(this.signedOrder.makerFee);
+ const orderToFeeRatio = this._signedOrder.makerTokenAmount.dividedBy(this._signedOrder.makerFee);
// The number of times the maker can fill the order, if each fill only required the transfer of a single
// baseUnit of fee tokens.
// Given 2 ZRXwei, the maximum amount of times Maker can fill this order, in terms of fees, is 2
- const fillableTimesInFeeTokenBaseUnits = BigNumber.min(this.transferrableMakerFeeTokenAmount,
- this.remainingMakerFeeAmount);
+ const fillableTimesInFeeTokenBaseUnits = BigNumber.min(
+ this._transferrableMakerFeeTokenAmount,
+ this._remainingMakerFeeAmount,
+ );
// The number of times the Maker can fill the order, given the Maker Token Balance
// Assuming a balance of 150 wei, and an orderToFeeRatio of 100:1, maker can fill this order 1 time.
- let fillableTimesInMakerTokenUnits = this.transferrableMakerTokenAmount.dividedBy(orderToFeeRatio);
- if (this.isMakerTokenZRX) {
+ let fillableTimesInMakerTokenUnits = this._transferrableMakerTokenAmount.dividedBy(orderToFeeRatio);
+ if (this._isMakerTokenZRX) {
// If ZRX is the maker token, the Fee and the Maker amount need to be removed from the same pool;
// 200 ZRXwei for 2ZRXwei fee can only be filled once (need 202 ZRXwei)
- const totalZRXTokenPooled = this.transferrableMakerTokenAmount;
+ const totalZRXTokenPooled = this._transferrableMakerTokenAmount;
// The purchasing power here is less as the tokens are taken from the same Pool
// For every one number of fills, we have to take an extra ZRX out of the pool
- fillableTimesInMakerTokenUnits = totalZRXTokenPooled.dividedBy(
- orderToFeeRatio.plus(new BigNumber(1)));
-
+ fillableTimesInMakerTokenUnits = totalZRXTokenPooled.dividedBy(orderToFeeRatio.plus(new BigNumber(1)));
}
// When Ratio is not fully divisible there can be remainders which cannot be represented, so they are floored.
// This can result in a RoundingError being thrown by the Exchange Contract.
const partiallyFillableMakerTokenAmount = fillableTimesInMakerTokenUnits
- .times(this.signedOrder.makerTokenAmount)
- .dividedToIntegerBy(this.signedOrder.makerFee);
+ .times(this._signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(this._signedOrder.makerFee);
const partiallyFillableFeeTokenAmount = fillableTimesInFeeTokenBaseUnits
- .times(this.signedOrder.makerTokenAmount)
- .dividedToIntegerBy(this.signedOrder.makerFee);
- const partiallyFillableAmount = BigNumber.min(partiallyFillableMakerTokenAmount,
- partiallyFillableFeeTokenAmount);
+ .times(this._signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(this._signedOrder.makerFee);
+ const partiallyFillableAmount = BigNumber.min(
+ partiallyFillableMakerTokenAmount,
+ partiallyFillableFeeTokenAmount,
+ );
return partiallyFillableAmount;
}
}
diff --git a/packages/0x.js/src/schemas/zero_ex_config_schema.ts b/packages/0x.js/src/schemas/zero_ex_config_schema.ts
index 121d81257..546b1c2d0 100644
--- a/packages/0x.js/src/schemas/zero_ex_config_schema.ts
+++ b/packages/0x.js/src/schemas/zero_ex_config_schema.ts
@@ -5,10 +5,9 @@ export const zeroExConfigSchema = {
type: 'number',
minimum: 0,
},
- gasPrice: {$ref: '/Number'},
- exchangeContractAddress: {$ref: '/Address'},
- tokenRegistryContractAddress: {$ref: '/Address'},
- etherTokenContractAddress: {$ref: '/Address'},
+ gasPrice: { $ref: '/Number' },
+ exchangeContractAddress: { $ref: '/Address' },
+ tokenRegistryContractAddress: { $ref: '/Address' },
orderWatcherConfig: {
type: 'object',
properties: {
diff --git a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
index 6225e9e72..33feea105 100644
--- a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
+++ b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
@@ -1,85 +1,86 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
-import {BlockParamLiteral} from '../types';
+import { TokenWrapper } from '../contract_wrappers/token_wrapper';
+import { BlockParamLiteral } from '../types';
/**
* Copy on read store for balances/proxyAllowances of tokens/accounts
*/
export class BalanceAndProxyAllowanceLazyStore {
- private token: TokenWrapper;
- private defaultBlock: BlockParamLiteral;
- private balance: {
+ private _token: TokenWrapper;
+ private _defaultBlock: BlockParamLiteral;
+ private _balance: {
[tokenAddress: string]: {
[userAddress: string]: BigNumber;
};
};
- private proxyAllowance: {
+ private _proxyAllowance: {
[tokenAddress: string]: {
[userAddress: string]: BigNumber;
};
};
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
- this.token = token;
- this.defaultBlock = defaultBlock;
- this.balance = {};
- this.proxyAllowance = {};
+ this._token = token;
+ this._defaultBlock = defaultBlock;
+ this._balance = {};
+ this._proxyAllowance = {};
}
public async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
- if (_.isUndefined(this.balance[tokenAddress]) || _.isUndefined(this.balance[tokenAddress][userAddress])) {
+ if (_.isUndefined(this._balance[tokenAddress]) || _.isUndefined(this._balance[tokenAddress][userAddress])) {
const methodOpts = {
- defaultBlock: this.defaultBlock,
+ defaultBlock: this._defaultBlock,
};
- const balance = await this.token.getBalanceAsync(tokenAddress, userAddress, methodOpts);
+ const balance = await this._token.getBalanceAsync(tokenAddress, userAddress, methodOpts);
this.setBalance(tokenAddress, userAddress, balance);
}
- const cachedBalance = this.balance[tokenAddress][userAddress];
+ const cachedBalance = this._balance[tokenAddress][userAddress];
return cachedBalance;
}
public setBalance(tokenAddress: string, userAddress: string, balance: BigNumber): void {
- if (_.isUndefined(this.balance[tokenAddress])) {
- this.balance[tokenAddress] = {};
+ if (_.isUndefined(this._balance[tokenAddress])) {
+ this._balance[tokenAddress] = {};
}
- this.balance[tokenAddress][userAddress] = balance;
+ this._balance[tokenAddress][userAddress] = balance;
}
public deleteBalance(tokenAddress: string, userAddress: string): void {
- if (!_.isUndefined(this.balance[tokenAddress])) {
- delete this.balance[tokenAddress][userAddress];
- if (_.isEmpty(this.balance[tokenAddress])) {
- delete this.balance[tokenAddress];
+ if (!_.isUndefined(this._balance[tokenAddress])) {
+ delete this._balance[tokenAddress][userAddress];
+ if (_.isEmpty(this._balance[tokenAddress])) {
+ delete this._balance[tokenAddress];
}
}
}
public async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
- if (_.isUndefined(this.proxyAllowance[tokenAddress]) ||
- _.isUndefined(this.proxyAllowance[tokenAddress][userAddress])) {
+ if (
+ _.isUndefined(this._proxyAllowance[tokenAddress]) ||
+ _.isUndefined(this._proxyAllowance[tokenAddress][userAddress])
+ ) {
const methodOpts = {
- defaultBlock: this.defaultBlock,
+ defaultBlock: this._defaultBlock,
};
- const proxyAllowance = await this.token.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
+ const proxyAllowance = await this._token.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance);
}
- const cachedProxyAllowance = this.proxyAllowance[tokenAddress][userAddress];
+ const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress];
return cachedProxyAllowance;
}
public setProxyAllowance(tokenAddress: string, userAddress: string, proxyAllowance: BigNumber): void {
- if (_.isUndefined(this.proxyAllowance[tokenAddress])) {
- this.proxyAllowance[tokenAddress] = {};
+ if (_.isUndefined(this._proxyAllowance[tokenAddress])) {
+ this._proxyAllowance[tokenAddress] = {};
}
- this.proxyAllowance[tokenAddress][userAddress] = proxyAllowance;
+ this._proxyAllowance[tokenAddress][userAddress] = proxyAllowance;
}
public deleteProxyAllowance(tokenAddress: string, userAddress: string): void {
- if (!_.isUndefined(this.proxyAllowance[tokenAddress])) {
- delete this.proxyAllowance[tokenAddress][userAddress];
- if (_.isEmpty(this.proxyAllowance[tokenAddress])) {
- delete this.proxyAllowance[tokenAddress];
+ if (!_.isUndefined(this._proxyAllowance[tokenAddress])) {
+ delete this._proxyAllowance[tokenAddress][userAddress];
+ if (_.isEmpty(this._proxyAllowance[tokenAddress])) {
+ delete this._proxyAllowance[tokenAddress];
}
}
}
public deleteAll(): void {
- this.balance = {};
- this.proxyAllowance = {};
+ this._balance = {};
+ this._proxyAllowance = {};
}
}
diff --git a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
index 28b32f9e2..e22364c09 100644
--- a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
+++ b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
@@ -1,62 +1,61 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
-import {BlockParamLiteral} from '../types';
+import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
+import { BlockParamLiteral } from '../types';
/**
* Copy on read store for filled/cancelled taker amounts
*/
export class OrderFilledCancelledLazyStore {
- private exchange: ExchangeWrapper;
- private filledTakerAmount: {
+ private _exchange: ExchangeWrapper;
+ private _filledTakerAmount: {
[orderHash: string]: BigNumber;
};
- private cancelledTakerAmount: {
+ private _cancelledTakerAmount: {
[orderHash: string]: BigNumber;
};
constructor(exchange: ExchangeWrapper) {
- this.exchange = exchange;
- this.filledTakerAmount = {};
- this.cancelledTakerAmount = {};
+ this._exchange = exchange;
+ this._filledTakerAmount = {};
+ this._cancelledTakerAmount = {};
}
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
- if (_.isUndefined(this.filledTakerAmount[orderHash])) {
+ if (_.isUndefined(this._filledTakerAmount[orderHash])) {
const methodOpts = {
defaultBlock: BlockParamLiteral.Pending,
};
- const filledTakerAmount = await this.exchange.getFilledTakerAmountAsync(orderHash, methodOpts);
+ const filledTakerAmount = await this._exchange.getFilledTakerAmountAsync(orderHash, methodOpts);
this.setFilledTakerAmount(orderHash, filledTakerAmount);
}
- const cachedFilled = this.filledTakerAmount[orderHash];
+ const cachedFilled = this._filledTakerAmount[orderHash];
return cachedFilled;
}
public setFilledTakerAmount(orderHash: string, filledTakerAmount: BigNumber): void {
- this.filledTakerAmount[orderHash] = filledTakerAmount;
+ this._filledTakerAmount[orderHash] = filledTakerAmount;
}
public deleteFilledTakerAmount(orderHash: string): void {
- delete this.filledTakerAmount[orderHash];
+ delete this._filledTakerAmount[orderHash];
}
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
- if (_.isUndefined(this.cancelledTakerAmount[orderHash])) {
+ if (_.isUndefined(this._cancelledTakerAmount[orderHash])) {
const methodOpts = {
defaultBlock: BlockParamLiteral.Pending,
};
- const cancelledTakerAmount = await this.exchange.getCancelledTakerAmountAsync(orderHash, methodOpts);
+ const cancelledTakerAmount = await this._exchange.getCancelledTakerAmountAsync(orderHash, methodOpts);
this.setCancelledTakerAmount(orderHash, cancelledTakerAmount);
}
- const cachedCancelled = this.cancelledTakerAmount[orderHash];
+ const cachedCancelled = this._cancelledTakerAmount[orderHash];
return cachedCancelled;
}
public setCancelledTakerAmount(orderHash: string, cancelledTakerAmount: BigNumber): void {
- this.cancelledTakerAmount[orderHash] = cancelledTakerAmount;
+ this._cancelledTakerAmount[orderHash] = cancelledTakerAmount;
}
public deleteCancelledTakerAmount(orderHash: string): void {
- delete this.cancelledTakerAmount[orderHash];
+ delete this._cancelledTakerAmount[orderHash];
}
public deleteAll(): void {
- this.filledTakerAmount = {};
- this.cancelledTakerAmount = {};
+ this._filledTakerAmount = {};
+ this._cancelledTakerAmount = {};
}
}
diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts
index 3586919cb..3c93910e9 100644
--- a/packages/0x.js/src/types.ts
+++ b/packages/0x.js/src/types.ts
@@ -1,4 +1,5 @@
-import BigNumber from 'bignumber.js';
+import { TransactionReceipt } from '@0xproject/types';
+import { BigNumber } from '@0xproject/utils';
import * as Web3 from 'web3';
export enum ZeroExError {
@@ -27,6 +28,7 @@ export enum ZeroExError {
export enum InternalZeroExError {
NoAbiDecoder = 'NO_ABI_DECODER',
ZrxNotInTokenRegistry = 'ZRX_NOT_IN_TOKEN_REGISTRY',
+ WethNotInTokenRegistry = 'WETH_NOT_IN_TOKEN_REGISTRY',
}
/**
@@ -40,8 +42,7 @@ export interface ECSignature {
export type OrderAddresses = [string, string, string, string, string];
-export type OrderValues = [BigNumber, BigNumber, BigNumber,
- BigNumber, BigNumber, BigNumber];
+export type OrderValues = [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber];
export type LogEvent = Web3.LogEntryEvent;
export interface DecodedLogEvent<ArgsType> {
@@ -49,8 +50,8 @@ export interface DecodedLogEvent<ArgsType> {
log: LogWithDecodedArgs<ArgsType>;
}
-export type EventCallback<ArgsType> = (err: null|Error, log?: DecodedLogEvent<ArgsType>) => void;
-export type EventWatcherCallback = (log: LogEvent) => void;
+export type EventCallback<ArgsType> = (err: null | Error, log?: DecodedLogEvent<ArgsType>) => void;
+export type EventWatcherCallback = (err: null | Error, log?: LogEvent) => void;
export enum SolidityTypes {
Address = 'address',
@@ -134,7 +135,10 @@ export interface LogErrorContractEventArgs {
errorId: BigNumber;
orderHash: string;
}
-export type ExchangeContractEventArgs = LogFillContractEventArgs|LogCancelContractEventArgs|LogErrorContractEventArgs;
+export type ExchangeContractEventArgs =
+ | LogFillContractEventArgs
+ | LogCancelContractEventArgs
+ | LogErrorContractEventArgs;
export interface TransferContractEventArgs {
_from: string;
_to: string;
@@ -145,9 +149,21 @@ export interface ApprovalContractEventArgs {
_spender: string;
_value: BigNumber;
}
-export type TokenContractEventArgs = TransferContractEventArgs|ApprovalContractEventArgs;
-export type ContractEventArgs = ExchangeContractEventArgs|TokenContractEventArgs;
-export type ContractEventArg = string|BigNumber;
+export interface DepositContractEventArgs {
+ _owner: string;
+ _value: BigNumber;
+}
+export interface WithdrawalContractEventArgs {
+ _owner: string;
+ _value: BigNumber;
+}
+export type TokenContractEventArgs = TransferContractEventArgs | ApprovalContractEventArgs;
+export type EtherTokenContractEventArgs =
+ | TokenContractEventArgs
+ | DepositContractEventArgs
+ | WithdrawalContractEventArgs;
+export type ContractEventArgs = ExchangeContractEventArgs | TokenContractEventArgs | EtherTokenContractEventArgs;
+export type ContractEventArg = string | BigNumber;
export interface Order {
maker: string;
@@ -200,7 +216,14 @@ export enum TokenEvents {
Approval = 'Approval',
}
-export type ContractEvents = TokenEvents|ExchangeEvents;
+export enum EtherTokenEvents {
+ Transfer = 'Transfer',
+ Approval = 'Approval',
+ Deposit = 'Deposit',
+ Withdrawal = 'Withdrawal',
+}
+
+export type ContractEvents = TokenEvents | ExchangeEvents | EtherTokenEvents;
export interface IndexedFilterValues {
[index: string]: ContractEventArg;
@@ -214,9 +237,9 @@ export enum BlockParamLiteral {
Pending = 'pending',
}
-export type BlockParam = BlockParamLiteral|number;
+export type BlockParam = BlockParamLiteral | number;
-export interface SubscriptionOpts {
+export interface BlockRange {
fromBlock: BlockParam;
toBlock: BlockParam;
}
@@ -224,7 +247,7 @@ export interface SubscriptionOpts {
export type DoneCallback = (err?: Error) => void;
export interface OrderCancellationRequest {
- order: Order|SignedOrder;
+ order: Order | SignedOrder;
takerTokenCancelAmount: BigNumber;
}
@@ -234,6 +257,7 @@ export interface OrderFillRequest {
}
export type AsyncMethod = (...args: any[]) => Promise<any>;
+export type SyncMethod = (...args: any[]) => any;
/**
* We re-export the `Web3.Provider` type specified in the Web3 Typescript typings
@@ -266,8 +290,8 @@ export interface OrderStateWatcherConfig {
* networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 42-kovan, 50-testrpc)
* gasPrice: Gas price to use with every transaction
* exchangeContractAddress: The address of an exchange contract to use
+ * zrxContractAddress: The address of the ZRX contract to use
* tokenRegistryContractAddress: The address of a token registry contract to use
- * etherTokenContractAddress: The address of an ether token contract to use
* tokenTransferProxyContractAddress: The address of the token transfer proxy contract to use
* orderWatcherConfig: All the configs related to the orderWatcher
*/
@@ -275,8 +299,8 @@ export interface ZeroExConfig {
networkId: number;
gasPrice?: BigNumber;
exchangeContractAddress?: string;
+ zrxContractAddress?: string;
tokenRegistryContractAddress?: string;
- etherTokenContractAddress?: string;
tokenTransferProxyContractAddress?: string;
orderWatcherConfig?: OrderStateWatcherConfig;
}
@@ -295,10 +319,10 @@ export interface DecodedLogArgs {
export interface LogWithDecodedArgs<ArgsType> extends Web3.DecodedLogEntry<ArgsType> {}
export interface TransactionReceiptWithDecodedLogs extends TransactionReceipt {
- logs: Array<LogWithDecodedArgs<DecodedLogArgs>|Web3.LogEntry>;
+ logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>;
}
-export type ArtifactContractName = 'ZRX'|'TokenTransferProxy'|'TokenRegistry'|'Token'|'Exchange'|'EtherToken';
+export type ArtifactContractName = 'ZRX' | 'TokenTransferProxy' | 'TokenRegistry' | 'Token' | 'Exchange' | 'EtherToken';
export interface Artifact {
contract_name: ArtifactContractName;
@@ -382,31 +406,7 @@ export interface OrderStateInvalid {
error: ExchangeContractErrs;
}
-export type OrderState = OrderStateValid|OrderStateInvalid;
-
-export type OnOrderStateChangeCallback = (orderState: OrderState) => void;
+export type OrderState = OrderStateValid | OrderStateInvalid;
-export interface TxData {
- from?: string;
- gas?: number;
- gasPrice?: BigNumber;
- nonce?: number;
-}
-
-export interface TxDataPayable extends TxData {
- value?: BigNumber;
-}
-
-export interface TransactionReceipt {
- blockHash: string;
- blockNumber: number;
- transactionHash: string;
- transactionIndex: number;
- from: string;
- to: string;
- status: null|0|1;
- cumulativeGasUsed: number;
- gasUsed: number;
- contractAddress: string|null;
- logs: Web3.LogEntry[];
-} // tslint:disable:max-file-line-count
+export type OnOrderStateChangeCallback = (err: Error | null, orderState?: OrderState) => void;
+// tslint:disable:max-file-line-count
diff --git a/packages/0x.js/src/utils/abi_decoder.ts b/packages/0x.js/src/utils/abi_decoder.ts
index f26b057f0..bbd2a0b1d 100644
--- a/packages/0x.js/src/utils/abi_decoder.ts
+++ b/packages/0x.js/src/utils/abi_decoder.ts
@@ -1,14 +1,14 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
import * as SolidityCoder from 'web3/lib/solidity/coder';
-import {AbiType, ContractEventArgs, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes} from '../types';
+import { AbiType, ContractEventArgs, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes } from '../types';
export class AbiDecoder {
- private savedABIs: Web3.AbiDefinition[] = [];
- private methodIds: {[signatureHash: string]: Web3.EventAbi} = {};
- private static padZeros(address: string) {
+ private _savedABIs: Web3.AbiDefinition[] = [];
+ private _methodIds: { [signatureHash: string]: Web3.EventAbi } = {};
+ private static _padZeros(address: string) {
let formatted = address;
if (_.startsWith(formatted, '0x')) {
formatted = formatted.slice(2);
@@ -18,13 +18,14 @@ export class AbiDecoder {
return `0x${formatted}`;
}
constructor(abiArrays: Web3.AbiDefinition[][]) {
- _.map(abiArrays, this.addABI.bind(this));
+ _.map(abiArrays, this._addABI.bind(this));
}
// This method can only decode logs from the 0x & ERC20 smart contracts
public tryToDecodeLogOrNoop<ArgsType extends ContractEventArgs>(
- log: Web3.LogEntry): LogWithDecodedArgs<ArgsType>|RawLog {
+ log: Web3.LogEntry,
+ ): LogWithDecodedArgs<ArgsType> | RawLog {
const methodId = log.topics[0];
- const event = this.methodIds[methodId];
+ const event = this._methodIds[methodId];
if (_.isUndefined(event)) {
return log;
}
@@ -41,10 +42,12 @@ export class AbiDecoder {
// Indexed parameters are stored in topics. Non-indexed ones in decodedData
let value = param.indexed ? log.topics[topicsIndex++] : decodedData[dataIndex++];
if (param.type === SolidityTypes.Address) {
- value = AbiDecoder.padZeros(new BigNumber(value).toString(16));
- } else if (param.type === SolidityTypes.Uint256 ||
- param.type === SolidityTypes.Uint8 ||
- param.type === SolidityTypes.Uint) {
+ value = AbiDecoder._padZeros(new BigNumber(value).toString(16));
+ } else if (
+ param.type === SolidityTypes.Uint256 ||
+ param.type === SolidityTypes.Uint8 ||
+ param.type === SolidityTypes.Uint
+ ) {
value = new BigNumber(value);
}
decodedParams[param.name] = value;
@@ -56,14 +59,14 @@ export class AbiDecoder {
args: decodedParams,
};
}
- private addABI(abiArray: Web3.AbiDefinition[]): void {
+ private _addABI(abiArray: Web3.AbiDefinition[]): void {
_.map(abiArray, (abi: Web3.AbiDefinition) => {
if (abi.type === AbiType.Event) {
const signature = `${abi.name}(${_.map(abi.inputs, input => input.type).join(',')})`;
const signatureHash = new Web3().sha3(signature);
- this.methodIds[signatureHash] = abi;
+ this._methodIds[signatureHash] = abi;
}
});
- this.savedABIs = this.savedABIs.concat(abiArray);
+ this._savedABIs = this._savedABIs.concat(abiArray);
}
}
diff --git a/packages/0x.js/src/utils/assert.ts b/packages/0x.js/src/utils/assert.ts
index 4cf6caf77..c21f2dbca 100644
--- a/packages/0x.js/src/utils/assert.ts
+++ b/packages/0x.js/src/utils/assert.ts
@@ -1,14 +1,14 @@
-import {assert as sharedAssert} from '@0xproject/assert';
-import {Schema, SchemaValidator} from '@0xproject/json-schemas';
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+import { assert as sharedAssert } from '@0xproject/assert';
+// We need those two unused imports because they're actually used by sharedAssert which gets injected here
+// tslint:disable-next-line:no-unused-variable
+import { Schema } from '@0xproject/json-schemas';
+// tslint:disable-next-line:no-unused-variable
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-import {ECSignature} from '../types';
-import {signatureUtils} from '../utils/signature_utils';
-
-const HEX_REGEX = /^0x[0-9A-F]*$/i;
+import { ECSignature } from '../types';
+import { signatureUtils } from '../utils/signature_utils';
export const assert = {
...sharedAssert,
@@ -16,11 +16,15 @@ export const assert = {
const isValidSignature = signatureUtils.isValidSignature(orderHash, ecSignature, signerAddress);
this.assert(isValidSignature, `Expected order with hash '${orderHash}' to have a valid signature`);
},
- async isSenderAddressAsync(variableName: string, senderAddressHex: string,
- web3Wrapper: Web3Wrapper): Promise<void> {
+ async isSenderAddressAsync(
+ variableName: string,
+ senderAddressHex: string,
+ web3Wrapper: Web3Wrapper,
+ ): Promise<void> {
sharedAssert.isETHAddressHex(variableName, senderAddressHex);
const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex);
- sharedAssert.assert(isSenderAddressAvailable,
+ sharedAssert.assert(
+ isSenderAddressAvailable,
`Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`,
);
},
diff --git a/packages/0x.js/src/utils/constants.ts b/packages/0x.js/src/utils/constants.ts
index 3de3f5bc1..06beec8e2 100644
--- a/packages/0x.js/src/utils/constants.ts
+++ b/packages/0x.js/src/utils/constants.ts
@@ -1,4 +1,4 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
export const constants = {
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
@@ -6,6 +6,7 @@ export const constants = {
MAX_DIGITS_IN_UNSIGNED_256_INT: 78,
INVALID_JUMP_PATTERN: 'invalid JUMP at',
OUT_OF_GAS_PATTERN: 'out of gas',
+ INVALID_TAKER_FORMAT: 'instance.taker is not of a type(s) string',
UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1),
DEFAULT_BLOCK_POLLING_INTERVAL: 1000,
};
diff --git a/packages/0x.js/src/utils/decorators.ts b/packages/0x.js/src/utils/decorators.ts
index 1760d8872..f774d734e 100644
--- a/packages/0x.js/src/utils/decorators.ts
+++ b/packages/0x.js/src/utils/decorators.ts
@@ -1,37 +1,91 @@
import * as _ from 'lodash';
-import {AsyncMethod, ZeroExError} from '../types';
+import { AsyncMethod, SyncMethod, ZeroExError } from '../types';
-import {constants} from './constants';
+import { constants } from './constants';
-export const decorators = {
- /**
- * Source: https://stackoverflow.com/a/29837695/3546986
- */
- contractCallErrorHandler(target: object,
- key: string|symbol,
- descriptor: TypedPropertyDescriptor<AsyncMethod>,
- ): TypedPropertyDescriptor<AsyncMethod> {
- const originalMethod = (descriptor.value as AsyncMethod);
+type ErrorTransformer = (err: Error) => Error;
+
+const contractCallErrorTransformer = (error: Error) => {
+ if (_.includes(error.message, constants.INVALID_JUMP_PATTERN)) {
+ return new Error(ZeroExError.InvalidJump);
+ }
+ if (_.includes(error.message, constants.OUT_OF_GAS_PATTERN)) {
+ return new Error(ZeroExError.OutOfGas);
+ }
+ return error;
+};
+
+const schemaErrorTransformer = (error: Error) => {
+ if (_.includes(error.message, constants.INVALID_TAKER_FORMAT)) {
+ const errMsg =
+ 'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS';
+ return new Error(errMsg);
+ }
+ return error;
+};
+
+/**
+ * Source: https://stackoverflow.com/a/29837695/3546986
+ */
+const asyncErrorHandlerFactory = (errorTransformer: ErrorTransformer) => {
+ const asyncErrorHandlingDecorator = (
+ target: object,
+ key: string | symbol,
+ descriptor: TypedPropertyDescriptor<AsyncMethod>,
+ ) => {
+ const originalMethod = descriptor.value as AsyncMethod;
// Do not use arrow syntax here. Use a function expression in
// order to use the correct value of `this` in this method
// tslint:disable-next-line:only-arrow-functions
- descriptor.value = async function(...args: any[]) {
+ descriptor.value = async function(...args: any[]) {
try {
const result = await originalMethod.apply(this, args);
return result;
} catch (error) {
- if (_.includes(error.message, constants.INVALID_JUMP_PATTERN)) {
- throw new Error(ZeroExError.InvalidJump);
- }
- if (_.includes(error.message, constants.OUT_OF_GAS_PATTERN)) {
- throw new Error(ZeroExError.OutOfGas);
- }
- throw error;
+ const transformedError = errorTransformer(error);
+ throw transformedError;
}
};
return descriptor;
- },
+ };
+
+ return asyncErrorHandlingDecorator;
+};
+
+const syncErrorHandlerFactory = (errorTransformer: ErrorTransformer) => {
+ const syncErrorHandlingDecorator = (
+ target: object,
+ key: string | symbol,
+ descriptor: TypedPropertyDescriptor<SyncMethod>,
+ ) => {
+ const originalMethod = descriptor.value as SyncMethod;
+
+ // Do not use arrow syntax here. Use a function expression in
+ // order to use the correct value of `this` in this method
+ // tslint:disable-next-line:only-arrow-functions
+ descriptor.value = function(...args: any[]) {
+ try {
+ const result = originalMethod.apply(this, args);
+ return result;
+ } catch (error) {
+ const transformedError = errorTransformer(error);
+ throw transformedError;
+ }
+ };
+
+ return descriptor;
+ };
+
+ return syncErrorHandlingDecorator;
+};
+
+// _.flow(f, g) = f ∘ g
+const zeroExErrorTransformer = _.flow(schemaErrorTransformer, contractCallErrorTransformer);
+
+export const decorators = {
+ asyncZeroExErrorHandler: asyncErrorHandlerFactory(zeroExErrorTransformer),
+ syncZeroExErrorHandler: syncErrorHandlerFactory(zeroExErrorTransformer),
};
diff --git a/packages/0x.js/src/utils/exchange_transfer_simulator.ts b/packages/0x.js/src/utils/exchange_transfer_simulator.ts
index 2574bd9ac..662cd210c 100644
--- a/packages/0x.js/src/utils/exchange_transfer_simulator.ts
+++ b/packages/0x.js/src/utils/exchange_transfer_simulator.ts
@@ -1,9 +1,9 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
-import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
-import {BlockParamLiteral, ExchangeContractErrs, TradeSide, TransferType} from '../types';
+import { TokenWrapper } from '../contract_wrappers/token_wrapper';
+import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store';
+import { BlockParamLiteral, ExchangeContractErrs, TradeSide, TransferType } from '../types';
enum FailureReason {
Balance = 'balance',
@@ -34,16 +34,19 @@ const ERR_MSG_MAPPING = {
};
export class ExchangeTransferSimulator {
- private store: BalanceAndProxyAllowanceLazyStore;
- private UNLIMITED_ALLOWANCE_IN_BASE_UNITS: BigNumber;
- private static throwValidationError(failureReason: FailureReason, tradeSide: TradeSide,
- transferType: TransferType): never {
+ private _store: BalanceAndProxyAllowanceLazyStore;
+ private _UNLIMITED_ALLOWANCE_IN_BASE_UNITS: BigNumber;
+ private static _throwValidationError(
+ failureReason: FailureReason,
+ tradeSide: TradeSide,
+ transferType: TransferType,
+ ): never {
const errMsg = ERR_MSG_MAPPING[failureReason][tradeSide][transferType];
throw new Error(errMsg);
}
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
- this.store = new BalanceAndProxyAllowanceLazyStore(token, defaultBlock);
- this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS = token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
+ this._store = new BalanceAndProxyAllowanceLazyStore(token, defaultBlock);
+ this._UNLIMITED_ALLOWANCE_IN_BASE_UNITS = token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
}
/**
* Simulates transferFrom call performed by a proxy
@@ -54,36 +57,50 @@ export class ExchangeTransferSimulator {
* @param tradeSide Is Maker/Taker transferring
* @param transferType Is it a fee payment or a value transfer
*/
- public async transferFromAsync(tokenAddress: string, from: string, to: string,
- amountInBaseUnits: BigNumber, tradeSide: TradeSide,
- transferType: TransferType): Promise<void> {
- const balance = await this.store.getBalanceAsync(tokenAddress, from);
- const proxyAllowance = await this.store.getProxyAllowanceAsync(tokenAddress, from);
+ public async transferFromAsync(
+ tokenAddress: string,
+ from: string,
+ to: string,
+ amountInBaseUnits: BigNumber,
+ tradeSide: TradeSide,
+ transferType: TransferType,
+ ): Promise<void> {
+ const balance = await this._store.getBalanceAsync(tokenAddress, from);
+ const proxyAllowance = await this._store.getProxyAllowanceAsync(tokenAddress, from);
if (proxyAllowance.lessThan(amountInBaseUnits)) {
- ExchangeTransferSimulator.throwValidationError(FailureReason.ProxyAllowance, tradeSide, transferType);
+ ExchangeTransferSimulator._throwValidationError(FailureReason.ProxyAllowance, tradeSide, transferType);
}
if (balance.lessThan(amountInBaseUnits)) {
- ExchangeTransferSimulator.throwValidationError(FailureReason.Balance, tradeSide, transferType);
+ ExchangeTransferSimulator._throwValidationError(FailureReason.Balance, tradeSide, transferType);
}
- await this.decreaseProxyAllowanceAsync(tokenAddress, from, amountInBaseUnits);
- await this.decreaseBalanceAsync(tokenAddress, from, amountInBaseUnits);
- await this.increaseBalanceAsync(tokenAddress, to, amountInBaseUnits);
+ await this._decreaseProxyAllowanceAsync(tokenAddress, from, amountInBaseUnits);
+ await this._decreaseBalanceAsync(tokenAddress, from, amountInBaseUnits);
+ await this._increaseBalanceAsync(tokenAddress, to, amountInBaseUnits);
}
- private async decreaseProxyAllowanceAsync(tokenAddress: string, userAddress: string,
- amountInBaseUnits: BigNumber): Promise<void> {
- const proxyAllowance = await this.store.getProxyAllowanceAsync(tokenAddress, userAddress);
- if (!proxyAllowance.eq(this.UNLIMITED_ALLOWANCE_IN_BASE_UNITS)) {
- this.store.setProxyAllowance(tokenAddress, userAddress, proxyAllowance.minus(amountInBaseUnits));
+ private async _decreaseProxyAllowanceAsync(
+ tokenAddress: string,
+ userAddress: string,
+ amountInBaseUnits: BigNumber,
+ ): Promise<void> {
+ const proxyAllowance = await this._store.getProxyAllowanceAsync(tokenAddress, userAddress);
+ if (!proxyAllowance.eq(this._UNLIMITED_ALLOWANCE_IN_BASE_UNITS)) {
+ this._store.setProxyAllowance(tokenAddress, userAddress, proxyAllowance.minus(amountInBaseUnits));
}
}
- private async increaseBalanceAsync(tokenAddress: string, userAddress: string,
- amountInBaseUnits: BigNumber): Promise<void> {
- const balance = await this.store.getBalanceAsync(tokenAddress, userAddress);
- this.store.setBalance(tokenAddress, userAddress, balance.plus(amountInBaseUnits));
+ private async _increaseBalanceAsync(
+ tokenAddress: string,
+ userAddress: string,
+ amountInBaseUnits: BigNumber,
+ ): Promise<void> {
+ const balance = await this._store.getBalanceAsync(tokenAddress, userAddress);
+ this._store.setBalance(tokenAddress, userAddress, balance.plus(amountInBaseUnits));
}
- private async decreaseBalanceAsync(tokenAddress: string, userAddress: string,
- amountInBaseUnits: BigNumber): Promise<void> {
- const balance = await this.store.getBalanceAsync(tokenAddress, userAddress);
- this.store.setBalance(tokenAddress, userAddress, balance.minus(amountInBaseUnits));
+ private async _decreaseBalanceAsync(
+ tokenAddress: string,
+ userAddress: string,
+ amountInBaseUnits: BigNumber,
+ ): Promise<void> {
+ const balance = await this._store.getBalanceAsync(tokenAddress, userAddress);
+ this._store.setBalance(tokenAddress, userAddress, balance.minus(amountInBaseUnits));
}
}
diff --git a/packages/0x.js/src/utils/filter_utils.ts b/packages/0x.js/src/utils/filter_utils.ts
index 57c3ee71c..97205ace3 100644
--- a/packages/0x.js/src/utils/filter_utils.ts
+++ b/packages/0x.js/src/utils/filter_utils.ts
@@ -4,7 +4,7 @@ import * as _ from 'lodash';
import * as uuid from 'uuid/v4';
import * as Web3 from 'web3';
-import {ContractEvents, IndexedFilterValues, SubscriptionOpts} from '../types';
+import { BlockRange, ContractEvents, IndexedFilterValues } from '../types';
const TOPIC_LENGTH = 32;
@@ -12,10 +12,14 @@ export const filterUtils = {
generateUUID(): string {
return uuid();
},
- getFilter(address: string, eventName: ContractEvents,
- indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi,
- subscriptionOpts?: SubscriptionOpts): Web3.FilterObject {
- const eventAbi = _.find(abi, {name: eventName}) as Web3.EventAbi;
+ getFilter(
+ address: string,
+ eventName: ContractEvents,
+ indexFilterValues: IndexedFilterValues,
+ abi: Web3.ContractAbi,
+ blockRange?: BlockRange,
+ ): Web3.FilterObject {
+ const eventAbi = _.find(abi, { name: eventName }) as Web3.EventAbi;
const eventSignature = filterUtils.getEventSignatureFromAbiByName(eventAbi, eventName);
const topicForEventSignature = ethUtil.addHexPrefix(jsSHA3.keccak256(eventSignature));
const topicsForIndexedArgs = filterUtils.getTopicsForIndexedArgs(eventAbi, indexFilterValues);
@@ -24,9 +28,9 @@ export const filterUtils = {
address,
topics,
};
- if (!_.isUndefined(subscriptionOpts)) {
+ if (!_.isUndefined(blockRange)) {
filter = {
- ...subscriptionOpts,
+ ...blockRange,
...filter,
};
}
@@ -37,8 +41,8 @@ export const filterUtils = {
const signature = `${eventAbi.name}(${types.join(',')})`;
return signature;
},
- getTopicsForIndexedArgs(abi: Web3.EventAbi, indexFilterValues: IndexedFilterValues): Array<string|null> {
- const topics: Array<string|null> = [];
+ getTopicsForIndexedArgs(abi: Web3.EventAbi, indexFilterValues: IndexedFilterValues): Array<string | null> {
+ const topics: Array<string | null> = [];
for (const eventInput of abi.inputs) {
if (!eventInput.indexed) {
continue;
@@ -65,12 +69,12 @@ export const filterUtils = {
}
return true;
},
- matchesTopics(logTopics: string[], filterTopics: Array<string[]|string|null>): boolean {
+ matchesTopics(logTopics: string[], filterTopics: Array<string[] | string | null>): boolean {
const matchesTopic = _.zipWith(logTopics, filterTopics, filterUtils.matchesTopic.bind(filterUtils));
const matchesTopics = _.every(matchesTopic);
return matchesTopics;
},
- matchesTopic(logTopic: string, filterTopic: string[]|string|null): boolean {
+ matchesTopic(logTopic: string, filterTopic: string[] | string | null): boolean {
if (_.isArray(filterTopic)) {
return _.includes(filterTopic, logTopic);
}
diff --git a/packages/0x.js/src/utils/interval_utils.ts b/packages/0x.js/src/utils/interval_utils.ts
deleted file mode 100644
index 62b79f2f5..000000000
--- a/packages/0x.js/src/utils/interval_utils.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import * as _ from 'lodash';
-
-export const intervalUtils = {
- setAsyncExcludingInterval(fn: () => Promise<void>, intervalMs: number) {
- let locked = false;
- const intervalId = setInterval(async () => {
- if (locked) {
- return;
- } else {
- locked = true;
- await fn();
- locked = false;
- }
- }, intervalMs);
- return intervalId;
- },
- clearAsyncExcludingInterval(intervalId: NodeJS.Timer): void {
- clearInterval(intervalId);
- },
-};
diff --git a/packages/0x.js/src/utils/order_state_utils.ts b/packages/0x.js/src/utils/order_state_utils.ts
index 6b7f811ae..b7a55ff42 100644
--- a/packages/0x.js/src/utils/order_state_utils.ts
+++ b/packages/0x.js/src/utils/order_state_utils.ts
@@ -1,31 +1,26 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-import {ZeroEx} from '../0x';
-import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
-import {RemainingFillableCalculator} from '../order_watcher/remaining_fillable_calculator';
-import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
-import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store';
+import { ZeroEx } from '../0x';
+import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
+import { RemainingFillableCalculator } from '../order_watcher/remaining_fillable_calculator';
+import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store';
+import { OrderFilledCancelledLazyStore } from '../stores/order_filled_cancelled_lazy_store';
import {
ExchangeContractErrs,
- MethodOpts,
OrderRelevantState,
OrderState,
OrderStateInvalid,
OrderStateValid,
SignedOrder,
} from '../types';
-import {constants} from '../utils/constants';
-import {utils} from '../utils/utils';
const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001;
export class OrderStateUtils {
- private balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore;
- private orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore;
- private static validateIfOrderIsValid(signedOrder: SignedOrder, orderRelevantState: OrderRelevantState): void {
+ private _balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore;
+ private _orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore;
+ private static _validateIfOrderIsValid(signedOrder: SignedOrder, orderRelevantState: OrderRelevantState): void {
const unavailableTakerTokenAmount = orderRelevantState.cancelledTakerTokenAmount.add(
orderRelevantState.filledTakerTokenAmount,
);
@@ -49,23 +44,28 @@ export class OrderStateUtils {
}
}
const minFillableTakerTokenAmountWithinNoRoundingErrorRange = signedOrder.takerTokenAmount
- .dividedBy(ACCEPTABLE_RELATIVE_ROUNDING_ERROR)
- .dividedBy(signedOrder.makerTokenAmount);
- if (orderRelevantState.remainingFillableTakerTokenAmount
- .lessThan(minFillableTakerTokenAmountWithinNoRoundingErrorRange)) {
+ .dividedBy(ACCEPTABLE_RELATIVE_ROUNDING_ERROR)
+ .dividedBy(signedOrder.makerTokenAmount);
+ if (
+ orderRelevantState.remainingFillableTakerTokenAmount.lessThan(
+ minFillableTakerTokenAmountWithinNoRoundingErrorRange,
+ )
+ ) {
throw new Error(ExchangeContractErrs.OrderFillRoundingError);
}
}
- constructor(balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore,
- orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore) {
- this.balanceAndProxyAllowanceLazyStore = balanceAndProxyAllowanceLazyStore;
- this.orderFilledCancelledLazyStore = orderFilledCancelledLazyStore;
+ constructor(
+ balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore,
+ orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore,
+ ) {
+ this._balanceAndProxyAllowanceLazyStore = balanceAndProxyAllowanceLazyStore;
+ this._orderFilledCancelledLazyStore = orderFilledCancelledLazyStore;
}
public async getOrderStateAsync(signedOrder: SignedOrder): Promise<OrderState> {
const orderRelevantState = await this.getOrderRelevantStateAsync(signedOrder);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
try {
- OrderStateUtils.validateIfOrderIsValid(signedOrder, orderRelevantState);
+ OrderStateUtils._validateIfOrderIsValid(signedOrder, orderRelevantState);
const orderState: OrderStateValid = {
isValid: true,
orderHash,
@@ -86,40 +86,47 @@ export class OrderStateUtils {
// If we pass it from the instantiator - there is no opportunity to get it there
// because JS doesn't support async constructors.
// Moreover - it's cached under the hood so it's equivalent to an async constructor.
- const exchange = (this.orderFilledCancelledLazyStore as any).exchange as ExchangeWrapper;
+ const exchange = (this._orderFilledCancelledLazyStore as any)._exchange as ExchangeWrapper;
const zrxTokenAddress = exchange.getZRXTokenAddress();
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- const makerBalance = await this.balanceAndProxyAllowanceLazyStore.getBalanceAsync(
- signedOrder.makerTokenAddress, signedOrder.maker,
+ const makerBalance = await this._balanceAndProxyAllowanceLazyStore.getBalanceAsync(
+ signedOrder.makerTokenAddress,
+ signedOrder.maker,
);
- const makerProxyAllowance = await this.balanceAndProxyAllowanceLazyStore.getProxyAllowanceAsync(
- signedOrder.makerTokenAddress, signedOrder.maker,
+ const makerProxyAllowance = await this._balanceAndProxyAllowanceLazyStore.getProxyAllowanceAsync(
+ signedOrder.makerTokenAddress,
+ signedOrder.maker,
);
- const makerFeeBalance = await this.balanceAndProxyAllowanceLazyStore.getBalanceAsync(
- zrxTokenAddress, signedOrder.maker,
+ const makerFeeBalance = await this._balanceAndProxyAllowanceLazyStore.getBalanceAsync(
+ zrxTokenAddress,
+ signedOrder.maker,
);
- const makerFeeProxyAllowance = await this.balanceAndProxyAllowanceLazyStore.getProxyAllowanceAsync(
- zrxTokenAddress, signedOrder.maker,
+ const makerFeeProxyAllowance = await this._balanceAndProxyAllowanceLazyStore.getProxyAllowanceAsync(
+ zrxTokenAddress,
+ signedOrder.maker,
);
- const filledTakerTokenAmount = await this.orderFilledCancelledLazyStore.getFilledTakerAmountAsync(orderHash);
- const cancelledTakerTokenAmount = await this.orderFilledCancelledLazyStore.getCancelledTakerAmountAsync(
+ const filledTakerTokenAmount = await this._orderFilledCancelledLazyStore.getFilledTakerAmountAsync(orderHash);
+ const cancelledTakerTokenAmount = await this._orderFilledCancelledLazyStore.getCancelledTakerAmountAsync(
orderHash,
);
const unavailableTakerTokenAmount = await exchange.getUnavailableTakerAmountAsync(orderHash);
const totalMakerTokenAmount = signedOrder.makerTokenAmount;
const totalTakerTokenAmount = signedOrder.takerTokenAmount;
const remainingTakerTokenAmount = totalTakerTokenAmount.minus(unavailableTakerTokenAmount);
- const remainingMakerTokenAmount = remainingTakerTokenAmount.times(totalMakerTokenAmount)
- .dividedToIntegerBy(totalTakerTokenAmount);
+ const remainingMakerTokenAmount = remainingTakerTokenAmount
+ .times(totalMakerTokenAmount)
+ .dividedToIntegerBy(totalTakerTokenAmount);
const transferrableMakerTokenAmount = BigNumber.min([makerProxyAllowance, makerBalance]);
const transferrableFeeTokenAmount = BigNumber.min([makerFeeProxyAllowance, makerFeeBalance]);
const isMakerTokenZRX = signedOrder.makerTokenAddress === zrxTokenAddress;
- const remainingFillableCalculator = new RemainingFillableCalculator(signedOrder,
- isMakerTokenZRX,
- transferrableMakerTokenAmount,
- transferrableFeeTokenAmount,
- remainingMakerTokenAmount);
+ const remainingFillableCalculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
const remainingFillableMakerTokenAmount = remainingFillableCalculator.computeRemainingMakerFillable();
const remainingFillableTakerTokenAmount = remainingFillableCalculator.computeRemainingTakerFillable();
const orderRelevantState = {
diff --git a/packages/0x.js/src/utils/order_validation_utils.ts b/packages/0x.js/src/utils/order_validation_utils.ts
index d514483e0..917d414c8 100644
--- a/packages/0x.js/src/utils/order_validation_utils.ts
+++ b/packages/0x.js/src/utils/order_validation_utils.ts
@@ -1,20 +1,20 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import {ZeroEx} from '../0x';
-import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
-import {ExchangeContractErrs, Order, SignedOrder, TradeSide, TransferType, ZeroExError} from '../types';
-import {constants} from '../utils/constants';
-import {utils} from '../utils/utils';
+import { ZeroEx } from '../0x';
+import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
+import { ExchangeContractErrs, Order, SignedOrder, TradeSide, TransferType, ZeroExError } from '../types';
+import { constants } from '../utils/constants';
+import { utils } from '../utils/utils';
-import {ExchangeTransferSimulator} from './exchange_transfer_simulator';
+import { ExchangeTransferSimulator } from './exchange_transfer_simulator';
export class OrderValidationUtils {
- private tokenWrapper: TokenWrapper;
- private exchangeWrapper: ExchangeWrapper;
+ private _exchangeWrapper: ExchangeWrapper;
public static validateCancelOrderThrowIfInvalid(
- order: Order, cancelTakerTokenAmount: BigNumber, unavailableTakerTokenAmount: BigNumber,
+ order: Order,
+ cancelTakerTokenAmount: BigNumber,
+ unavailableTakerTokenAmount: BigNumber,
): void {
if (cancelTakerTokenAmount.eq(0)) {
throw new Error(ExchangeContractErrs.OrderCancelAmountZero);
@@ -28,102 +28,135 @@ export class OrderValidationUtils {
}
}
public static async validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
- exchangeTradeEmulator: ExchangeTransferSimulator, signedOrder: SignedOrder,
- fillTakerTokenAmount: BigNumber, senderAddress: string, zrxTokenAddress: string,
+ exchangeTradeEmulator: ExchangeTransferSimulator,
+ signedOrder: SignedOrder,
+ fillTakerTokenAmount: BigNumber,
+ senderAddress: string,
+ zrxTokenAddress: string,
): Promise<void> {
- const fillMakerTokenAmount = OrderValidationUtils.getPartialAmount(
+ const fillMakerTokenAmount = OrderValidationUtils._getPartialAmount(
fillTakerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.makerTokenAmount,
);
await exchangeTradeEmulator.transferFromAsync(
- signedOrder.makerTokenAddress, signedOrder.maker, senderAddress, fillMakerTokenAmount,
- TradeSide.Maker, TransferType.Trade,
+ signedOrder.makerTokenAddress,
+ signedOrder.maker,
+ senderAddress,
+ fillMakerTokenAmount,
+ TradeSide.Maker,
+ TransferType.Trade,
);
await exchangeTradeEmulator.transferFromAsync(
- signedOrder.takerTokenAddress, senderAddress, signedOrder.maker, fillTakerTokenAmount,
- TradeSide.Taker, TransferType.Trade,
+ signedOrder.takerTokenAddress,
+ senderAddress,
+ signedOrder.maker,
+ fillTakerTokenAmount,
+ TradeSide.Taker,
+ TransferType.Trade,
);
- const makerFeeAmount = OrderValidationUtils.getPartialAmount(
+ const makerFeeAmount = OrderValidationUtils._getPartialAmount(
fillTakerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.makerFee,
);
await exchangeTradeEmulator.transferFromAsync(
- zrxTokenAddress, signedOrder.maker, signedOrder.feeRecipient, makerFeeAmount, TradeSide.Maker,
+ zrxTokenAddress,
+ signedOrder.maker,
+ signedOrder.feeRecipient,
+ makerFeeAmount,
+ TradeSide.Maker,
TransferType.Fee,
);
- const takerFeeAmount = OrderValidationUtils.getPartialAmount(
+ const takerFeeAmount = OrderValidationUtils._getPartialAmount(
fillTakerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.takerFee,
);
await exchangeTradeEmulator.transferFromAsync(
- zrxTokenAddress, senderAddress, signedOrder.feeRecipient, takerFeeAmount, TradeSide.Taker,
+ zrxTokenAddress,
+ senderAddress,
+ signedOrder.feeRecipient,
+ takerFeeAmount,
+ TradeSide.Taker,
TransferType.Fee,
);
}
- private static validateRemainingFillAmountNotZeroOrThrow(
- takerTokenAmount: BigNumber, unavailableTakerTokenAmount: BigNumber,
+ private static _validateRemainingFillAmountNotZeroOrThrow(
+ takerTokenAmount: BigNumber,
+ unavailableTakerTokenAmount: BigNumber,
) {
if (takerTokenAmount.eq(unavailableTakerTokenAmount)) {
throw new Error(ExchangeContractErrs.OrderRemainingFillAmountZero);
}
}
- private static validateOrderNotExpiredOrThrow(expirationUnixTimestampSec: BigNumber) {
+ private static _validateOrderNotExpiredOrThrow(expirationUnixTimestampSec: BigNumber) {
const currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
if (expirationUnixTimestampSec.lessThan(currentUnixTimestampSec)) {
throw new Error(ExchangeContractErrs.OrderFillExpired);
}
}
- private static getPartialAmount(numerator: BigNumber, denominator: BigNumber,
- target: BigNumber): BigNumber {
+ private static _getPartialAmount(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber {
const fillMakerTokenAmount = numerator
- .mul(target)
- .div(denominator)
- .round(0);
+ .mul(target)
+ .div(denominator)
+ .round(0);
return fillMakerTokenAmount;
}
- constructor(tokenWrapper: TokenWrapper, exchangeWrapper: ExchangeWrapper) {
- this.tokenWrapper = tokenWrapper;
- this.exchangeWrapper = exchangeWrapper;
+ constructor(exchangeWrapper: ExchangeWrapper) {
+ this._exchangeWrapper = exchangeWrapper;
}
public async validateOrderFillableOrThrowAsync(
- exchangeTradeEmulator: ExchangeTransferSimulator, signedOrder: SignedOrder, zrxTokenAddress: string,
- expectedFillTakerTokenAmount?: BigNumber): Promise<void> {
+ exchangeTradeEmulator: ExchangeTransferSimulator,
+ signedOrder: SignedOrder,
+ zrxTokenAddress: string,
+ expectedFillTakerTokenAmount?: BigNumber,
+ ): Promise<void> {
const orderHash = utils.getOrderHashHex(signedOrder);
- const unavailableTakerTokenAmount = await this.exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
- OrderValidationUtils.validateRemainingFillAmountNotZeroOrThrow(
- signedOrder.takerTokenAmount, unavailableTakerTokenAmount,
+ const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
+ OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow(
+ signedOrder.takerTokenAmount,
+ unavailableTakerTokenAmount,
);
- OrderValidationUtils.validateOrderNotExpiredOrThrow(signedOrder.expirationUnixTimestampSec);
+ OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationUnixTimestampSec);
let fillTakerTokenAmount = signedOrder.takerTokenAmount.minus(unavailableTakerTokenAmount);
if (!_.isUndefined(expectedFillTakerTokenAmount)) {
fillTakerTokenAmount = expectedFillTakerTokenAmount;
}
- const fillMakerTokenAmount = OrderValidationUtils.getPartialAmount(
+ const fillMakerTokenAmount = OrderValidationUtils._getPartialAmount(
fillTakerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.makerTokenAmount,
);
await exchangeTradeEmulator.transferFromAsync(
- signedOrder.makerTokenAddress, signedOrder.maker, signedOrder.taker, fillMakerTokenAmount,
- TradeSide.Maker, TransferType.Trade,
- );
- const makerFeeAmount = OrderValidationUtils.getPartialAmount(
+ signedOrder.makerTokenAddress,
+ signedOrder.maker,
+ signedOrder.taker,
+ fillMakerTokenAmount,
+ TradeSide.Maker,
+ TransferType.Trade,
+ );
+ const makerFeeAmount = OrderValidationUtils._getPartialAmount(
fillTakerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.makerFee,
);
await exchangeTradeEmulator.transferFromAsync(
- zrxTokenAddress, signedOrder.maker, signedOrder.feeRecipient, makerFeeAmount,
- TradeSide.Maker, TransferType.Fee,
+ zrxTokenAddress,
+ signedOrder.maker,
+ signedOrder.feeRecipient,
+ makerFeeAmount,
+ TradeSide.Maker,
+ TransferType.Fee,
);
}
public async validateFillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator: ExchangeTransferSimulator, signedOrder: SignedOrder,
- fillTakerTokenAmount: BigNumber, takerAddress: string,
- zrxTokenAddress: string): Promise<BigNumber> {
+ exchangeTradeEmulator: ExchangeTransferSimulator,
+ signedOrder: SignedOrder,
+ fillTakerTokenAmount: BigNumber,
+ takerAddress: string,
+ zrxTokenAddress: string,
+ ): Promise<BigNumber> {
if (fillTakerTokenAmount.eq(0)) {
throw new Error(ExchangeContractErrs.OrderFillAmountZero);
}
@@ -131,24 +164,31 @@ export class OrderValidationUtils {
if (!ZeroEx.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker)) {
throw new Error(ZeroExError.InvalidSignature);
}
- const unavailableTakerTokenAmount = await this.exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
- OrderValidationUtils.validateRemainingFillAmountNotZeroOrThrow(
- signedOrder.takerTokenAmount, unavailableTakerTokenAmount,
+ const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
+ OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow(
+ signedOrder.takerTokenAmount,
+ unavailableTakerTokenAmount,
);
if (signedOrder.taker !== constants.NULL_ADDRESS && signedOrder.taker !== takerAddress) {
throw new Error(ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker);
}
- OrderValidationUtils.validateOrderNotExpiredOrThrow(signedOrder.expirationUnixTimestampSec);
+ OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationUnixTimestampSec);
const remainingTakerTokenAmount = signedOrder.takerTokenAmount.minus(unavailableTakerTokenAmount);
- const filledTakerTokenAmount = remainingTakerTokenAmount.lessThan(fillTakerTokenAmount) ?
- remainingTakerTokenAmount :
- fillTakerTokenAmount;
+ const filledTakerTokenAmount = remainingTakerTokenAmount.lessThan(fillTakerTokenAmount)
+ ? remainingTakerTokenAmount
+ : fillTakerTokenAmount;
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
- exchangeTradeEmulator, signedOrder, filledTakerTokenAmount, takerAddress, zrxTokenAddress,
+ exchangeTradeEmulator,
+ signedOrder,
+ filledTakerTokenAmount,
+ takerAddress,
+ zrxTokenAddress,
);
- const wouldRoundingErrorOccur = await this.exchangeWrapper.isRoundingErrorAsync(
- filledTakerTokenAmount, signedOrder.takerTokenAmount, signedOrder.makerTokenAmount,
+ const wouldRoundingErrorOccur = await this._exchangeWrapper.isRoundingErrorAsync(
+ filledTakerTokenAmount,
+ signedOrder.takerTokenAmount,
+ signedOrder.makerTokenAmount,
);
if (wouldRoundingErrorOccur) {
throw new Error(ExchangeContractErrs.OrderFillRoundingError);
@@ -156,10 +196,18 @@ export class OrderValidationUtils {
return filledTakerTokenAmount;
}
public async validateFillOrKillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator: ExchangeTransferSimulator, signedOrder: SignedOrder,
- fillTakerTokenAmount: BigNumber, takerAddress: string, zrxTokenAddress: string): Promise<void> {
+ exchangeTradeEmulator: ExchangeTransferSimulator,
+ signedOrder: SignedOrder,
+ fillTakerTokenAmount: BigNumber,
+ takerAddress: string,
+ zrxTokenAddress: string,
+ ): Promise<void> {
const filledTakerTokenAmount = await this.validateFillOrderThrowIfInvalidAsync(
- exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress,
+ exchangeTradeEmulator,
+ signedOrder,
+ fillTakerTokenAmount,
+ takerAddress,
+ zrxTokenAddress,
);
if (filledTakerTokenAmount !== fillTakerTokenAmount) {
throw new Error(ExchangeContractErrs.InsufficientRemainingFillAmount);
diff --git a/packages/0x.js/src/utils/signature_utils.ts b/packages/0x.js/src/utils/signature_utils.ts
index aaf04e7b0..b0f1d61ef 100644
--- a/packages/0x.js/src/utils/signature_utils.ts
+++ b/packages/0x.js/src/utils/signature_utils.ts
@@ -1,6 +1,6 @@
import * as ethUtil from 'ethereumjs-util';
-import {ECSignature} from '../types';
+import { ECSignature } from '../types';
export const signatureUtils = {
isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
@@ -11,7 +11,8 @@ export const signatureUtils = {
msgHashBuff,
signature.v,
ethUtil.toBuffer(signature.r),
- ethUtil.toBuffer(signature.s));
+ ethUtil.toBuffer(signature.s),
+ );
const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
return retrievedAddress === signerAddress;
} catch (err) {
@@ -34,7 +35,7 @@ export const signatureUtils = {
return ecSignature;
},
parseSignatureHexAsRSV(signatureHex: string): ECSignature {
- const {v, r, s} = ethUtil.fromRpcSig(signatureHex);
+ const { v, r, s } = ethUtil.fromRpcSig(signatureHex);
const ecSignature: ECSignature = {
v,
r: ethUtil.bufferToHex(r),
diff --git a/packages/0x.js/src/utils/utils.ts b/packages/0x.js/src/utils/utils.ts
index 04ae34aac..e42a1a853 100644
--- a/packages/0x.js/src/utils/utils.ts
+++ b/packages/0x.js/src/utils/utils.ts
@@ -1,10 +1,10 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import BN = require('bn.js');
import * as ethABI from 'ethereumjs-abi';
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
-import {Order, SignedOrder, SolidityTypes} from '../types';
+import { Order, SignedOrder, SolidityTypes } from '../types';
export const utils = {
/**
@@ -29,20 +29,35 @@ export const utils = {
spawnSwitchErr(name: string, value: any): Error {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},
- getOrderHashHex(order: Order|SignedOrder): string {
+ getOrderHashHex(order: Order | SignedOrder): string {
const orderParts = [
- {value: order.exchangeContractAddress, type: SolidityTypes.Address},
- {value: order.maker, type: SolidityTypes.Address},
- {value: order.taker, type: SolidityTypes.Address},
- {value: order.makerTokenAddress, type: SolidityTypes.Address},
- {value: order.takerTokenAddress, type: SolidityTypes.Address},
- {value: order.feeRecipient, type: SolidityTypes.Address},
- {value: utils.bigNumberToBN(order.makerTokenAmount), type: SolidityTypes.Uint256},
- {value: utils.bigNumberToBN(order.takerTokenAmount), type: SolidityTypes.Uint256},
- {value: utils.bigNumberToBN(order.makerFee), type: SolidityTypes.Uint256},
- {value: utils.bigNumberToBN(order.takerFee), type: SolidityTypes.Uint256},
- {value: utils.bigNumberToBN(order.expirationUnixTimestampSec), type: SolidityTypes.Uint256},
- {value: utils.bigNumberToBN(order.salt), type: SolidityTypes.Uint256},
+ { value: order.exchangeContractAddress, type: SolidityTypes.Address },
+ { value: order.maker, type: SolidityTypes.Address },
+ { value: order.taker, type: SolidityTypes.Address },
+ { value: order.makerTokenAddress, type: SolidityTypes.Address },
+ { value: order.takerTokenAddress, type: SolidityTypes.Address },
+ { value: order.feeRecipient, type: SolidityTypes.Address },
+ {
+ value: utils.bigNumberToBN(order.makerTokenAmount),
+ type: SolidityTypes.Uint256,
+ },
+ {
+ value: utils.bigNumberToBN(order.takerTokenAmount),
+ type: SolidityTypes.Uint256,
+ },
+ {
+ value: utils.bigNumberToBN(order.makerFee),
+ type: SolidityTypes.Uint256,
+ },
+ {
+ value: utils.bigNumberToBN(order.takerFee),
+ type: SolidityTypes.Uint256,
+ },
+ {
+ value: utils.bigNumberToBN(order.expirationUnixTimestampSec),
+ type: SolidityTypes.Uint256,
+ },
+ { value: utils.bigNumberToBN(order.salt), type: SolidityTypes.Uint256 },
];
const types = _.map(orderParts, o => o.type);
const values = _.map(orderParts, o => o.value);
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index 6b7a70699..5bc2c149c 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -1,18 +1,18 @@
-import BigNumber from 'bignumber.js';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as Sinon from 'sinon';
-import {ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx, ZeroExError} from '../src';
+import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx } from '../src';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {TokenUtils} from './utils/token_utils';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { TokenUtils } from './utils/token_utils';
+import { web3Factory } from './utils/web3_factory';
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
chaiSetup.configure();
const expect = chai.expect;
@@ -41,11 +41,11 @@ describe('ZeroEx library', () => {
// Check that all nested web3 wrapper instances return the updated provider
const nestedWeb3WrapperProvider = (zeroEx as any)._web3Wrapper.getCurrentProvider();
- expect((nestedWeb3WrapperProvider).zeroExTestId).to.be.a('number');
+ expect(nestedWeb3WrapperProvider.zeroExTestId).to.be.a('number');
const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getCurrentProvider();
- expect((exchangeWeb3WrapperProvider).zeroExTestId).to.be.a('number');
+ expect(exchangeWeb3WrapperProvider.zeroExTestId).to.be.a('number');
const tokenRegistryWeb3WrapperProvider = (zeroEx.tokenRegistry as any)._web3Wrapper.getCurrentProvider();
- expect((tokenRegistryWeb3WrapperProvider).zeroExTestId).to.be.a('number');
+ expect(tokenRegistryWeb3WrapperProvider.zeroExTestId).to.be.a('number');
});
});
describe('#isValidSignature', () => {
@@ -58,22 +58,25 @@ describe('ZeroEx library', () => {
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
};
const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
- it('should return false if the data doesn\'t pertain to the signature & address', async () => {
+ it("should return false if the data doesn't pertain to the signature & address", async () => {
expect(ZeroEx.isValidSignature('0x0', signature, address)).to.be.false();
return expect(
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync('0x0', signature, address),
).to.become(false);
});
- it('should return false if the address doesn\'t pertain to the signature & data', async () => {
+ it("should return false if the address doesn't pertain to the signature & data", async () => {
const validUnrelatedAddress = '0x8b0292b11a196601ed2ce54b665cafeca0347d42';
expect(ZeroEx.isValidSignature(dataHex, signature, validUnrelatedAddress)).to.be.false();
return expect(
- (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, signature,
- validUnrelatedAddress),
+ (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(
+ dataHex,
+ signature,
+ validUnrelatedAddress,
+ ),
).to.become(false);
});
- it('should return false if the signature doesn\'t pertain to the dataHex & address', async () => {
- const wrongSignature = _.assign({}, signature, {v: 28});
+ it("should return false if the signature doesn't pertain to the dataHex & address", async () => {
+ const wrongSignature = _.assign({}, signature, { v: 28 });
expect(ZeroEx.isValidSignature(dataHex, wrongSignature, address)).to.be.false();
return expect(
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, wrongSignature, address),
@@ -82,9 +85,9 @@ describe('ZeroEx library', () => {
it('should return true if the signature does pertain to the dataHex & address', async () => {
const isValidSignatureLocal = ZeroEx.isValidSignature(dataHex, signature, address);
expect(isValidSignatureLocal).to.be.true();
- const isValidSignatureOnContract = await (zeroEx.exchange as any)
- ._isValidSignatureUsingContractCallAsync(dataHex, signature, address);
- return expect(isValidSignatureOnContract).to.be.true();
+ return expect(
+ (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, signature, address),
+ ).to.become(true);
});
});
describe('#generateSalt', () => {
@@ -114,6 +117,13 @@ describe('ZeroEx library', () => {
});
});
describe('#toUnitAmount', () => {
+ it('should throw if invalid baseUnit amount supplied as argument', () => {
+ const invalidBaseUnitAmount = new BigNumber(1000000000.4);
+ const decimals = 6;
+ expect(() => ZeroEx.toUnitAmount(invalidBaseUnitAmount, decimals)).to.throw(
+ 'amount should be in baseUnits (no decimals), found value: 1000000000.4',
+ );
+ });
it('Should return the expected unit amount for the decimals passed in', () => {
const baseUnitAmount = new BigNumber(1000000000);
const decimals = 6;
@@ -130,6 +140,13 @@ describe('ZeroEx library', () => {
const expectedUnitAmount = new BigNumber(1000000000);
expect(baseUnitAmount).to.be.bignumber.equal(expectedUnitAmount);
});
+ it('should throw if unitAmount has more decimals then specified as the max decimal precision', () => {
+ const unitAmount = new BigNumber(0.823091);
+ const decimals = 5;
+ expect(() => ZeroEx.toBaseUnitAmount(unitAmount, decimals)).to.throw(
+ 'Invalid unit amount: 0.823091 - Too many decimal places',
+ );
+ });
});
describe('#getOrderHashHex', () => {
const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83';
@@ -152,6 +169,15 @@ describe('ZeroEx library', () => {
const orderHash = ZeroEx.getOrderHashHex(order);
expect(orderHash).to.be.equal(expectedOrderHash);
});
+ it('throws a readable error message if taker format is invalid', async () => {
+ const orderWithInvalidtakerFormat = {
+ ...order,
+ taker: (null as any) as string,
+ };
+ const expectedErrorMessage =
+ 'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS';
+ expect(() => ZeroEx.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage);
+ });
});
describe('#signOrderHashAsync', () => {
let stubs: Sinon.SinonStub[] = [];
@@ -177,16 +203,15 @@ describe('ZeroEx library', () => {
});
it('should return the correct ECSignature for signatureHex concatenated as R + S + V', async () => {
const orderHash = '0x34decbedc118904df65f379a175bb39ca18209d6ce41d5ed549d54e6e0a95004';
- // tslint:disable-next-line: max-line-length
- const signature = '0x22109d11d79cb8bf96ed88625e1cd9558800c4073332a9a02857499883ee5ce3050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb021b';
+ const signature =
+ '0x22109d11d79cb8bf96ed88625e1cd9558800c4073332a9a02857499883ee5ce3050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb021b';
const expectedECSignature = {
v: 27,
r: '0x22109d11d79cb8bf96ed88625e1cd9558800c4073332a9a02857499883ee5ce3',
s: '0x050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb02',
};
stubs = [
- Sinon.stub((zeroEx as any)._web3Wrapper, 'signTransactionAsync')
- .returns(Promise.resolve(signature)),
+ Sinon.stub((zeroEx as any)._web3Wrapper, 'signTransactionAsync').returns(Promise.resolve(signature)),
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
];
@@ -195,16 +220,15 @@ describe('ZeroEx library', () => {
});
it('should return the correct ECSignature for signatureHex concatenated as V + R + S', async () => {
const orderHash = '0xc793e33ffded933b76f2f48d9aa3339fc090399d5e7f5dec8d3660f5480793f7';
- // tslint:disable-next-line: max-line-length
- const signature = '0x1bc80bedc6756722672753413efdd749b5adbd4fd552595f59c13427407ee9aee02dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960';
+ const signature =
+ '0x1bc80bedc6756722672753413efdd749b5adbd4fd552595f59c13427407ee9aee02dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960';
const expectedECSignature = {
v: 27,
r: '0xc80bedc6756722672753413efdd749b5adbd4fd552595f59c13427407ee9aee0',
s: '0x2dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960',
};
stubs = [
- Sinon.stub((zeroEx as any)._web3Wrapper, 'signTransactionAsync')
- .returns(Promise.resolve(signature)),
+ Sinon.stub((zeroEx as any)._web3Wrapper, 'signTransactionAsync').returns(Promise.resolve(signature)),
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
];
@@ -244,22 +268,15 @@ describe('ZeroEx library', () => {
const zeroExWithWrongExchangeAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
expect(zeroExWithWrongExchangeAddress.exchange.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
});
- it('allows to specify ether token contract address', async () => {
- const zeroExConfig = {
- etherTokenContractAddress: ZeroEx.NULL_ADDRESS,
- networkId: constants.TESTRPC_NETWORK_ID,
- };
- const zeroExWithWrongEtherTokenAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
- expect(zeroExWithWrongEtherTokenAddress.etherToken.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
- });
it('allows to specify token registry token contract address', async () => {
const zeroExConfig = {
tokenRegistryContractAddress: ZeroEx.NULL_ADDRESS,
networkId: constants.TESTRPC_NETWORK_ID,
};
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
- expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddress())
- .to.be.equal(ZeroEx.NULL_ADDRESS);
+ expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddress()).to.be.equal(
+ ZeroEx.NULL_ADDRESS,
+ );
});
});
});
diff --git a/packages/0x.js/test/artifacts_test.ts b/packages/0x.js/test/artifacts_test.ts
index f4599a24d..e8ab9aa97 100644
--- a/packages/0x.js/test/artifacts_test.ts
+++ b/packages/0x.js/test/artifacts_test.ts
@@ -1,14 +1,12 @@
-import * as chai from 'chai';
import * as fs from 'fs';
import HDWalletProvider = require('truffle-hdwallet-provider');
-import {ZeroEx} from '../src';
+import { ZeroEx } from '../src';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
chaiSetup.configure();
-const expect = chai.expect;
// Those tests are slower cause they're talking to a remote node
const TIMEOUT = 10000;
diff --git a/packages/0x.js/test/assert_test.ts b/packages/0x.js/test/assert_test.ts
index 9fa7f780f..1f2820070 100644
--- a/packages/0x.js/test/assert_test.ts
+++ b/packages/0x.js/test/assert_test.ts
@@ -1,11 +1,11 @@
import * as chai from 'chai';
import 'mocha';
-import {ZeroEx} from '../src';
-import {assert} from '../src/utils/assert';
+import { ZeroEx } from '../src';
+import { assert } from '../src/utils/assert';
-import {constants} from './utils/constants';
-import {web3Factory} from './utils/web3_factory';
+import { constants } from './utils/constants';
+import { web3Factory } from './utils/web3_factory';
const expect = chai.expect;
@@ -19,22 +19,25 @@ describe('Assertion library', () => {
it('throws when address is invalid', async () => {
const address = '0xdeadbeef';
const varName = 'address';
- return expect(assert.isSenderAddressAsync(varName, address, (zeroEx as any)._web3Wrapper))
- .to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`);
+ return expect(
+ assert.isSenderAddressAsync(varName, address, (zeroEx as any)._web3Wrapper),
+ ).to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`);
});
it('throws when address is unavailable', async () => {
const validUnrelatedAddress = '0x8b0292b11a196601eddce54b665cafeca0347d42';
const varName = 'address';
- return expect(assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any)._web3Wrapper))
- .to.be.rejectedWith(
- `Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 provider`,
- );
+ return expect(
+ assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any)._web3Wrapper),
+ ).to.be.rejectedWith(
+ `Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 provider`,
+ );
});
- it('doesn\'t throw if address is available', async () => {
+ it("doesn't throw if address is available", async () => {
const availableAddress = (await zeroEx.getAvailableAddressesAsync())[0];
const varName = 'address';
- return expect(assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any)._web3Wrapper))
- .to.become(undefined);
+ return expect(
+ assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any)._web3Wrapper),
+ ).to.become(undefined);
});
});
});
diff --git a/packages/0x.js/test/ether_token_wrapper_test.ts b/packages/0x.js/test/ether_token_wrapper_test.ts
index d3e4439ee..b810fc9f1 100644
--- a/packages/0x.js/test/ether_token_wrapper_test.ts
+++ b/packages/0x.js/test/ether_token_wrapper_test.ts
@@ -1,18 +1,34 @@
-import BigNumber from 'bignumber.js';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import 'mocha';
import * as Web3 from 'web3';
-import {ZeroEx, ZeroExError} from '../src';
+import {
+ ApprovalContractEventArgs,
+ BlockParamLiteral,
+ BlockRange,
+ DecodedLogEvent,
+ DepositContractEventArgs,
+ EtherTokenEvents,
+ Token,
+ TransferContractEventArgs,
+ WithdrawalContractEventArgs,
+ ZeroEx,
+ ZeroExError,
+} from '../src';
+import { artifacts } from '../src/artifacts';
+import { DoneCallback } from '../src/types';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { reportNodeCallbackErrors } from './utils/report_callback_errors';
+import { TokenUtils } from './utils/token_utils';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
// Since the address depositing/withdrawing ETH/WETH also needs to pay gas costs for the transaction,
// a small amount of ETH will be used to pay this gas cost. We therefore check that the difference between
@@ -23,24 +39,32 @@ const MAX_REASONABLE_GAS_COST_IN_WEI = 62517;
describe('EtherTokenWrapper', () => {
let web3: Web3;
let zeroEx: ZeroEx;
+ let tokens: Token[];
let userAddresses: string[];
let addressWithETH: string;
let wethContractAddress: string;
let depositWeiAmount: BigNumber;
let decimalPlaces: number;
+ let addressWithoutFunds: string;
const gasPrice = new BigNumber(1);
const zeroExConfig = {
gasPrice,
networkId: constants.TESTRPC_NETWORK_ID,
};
+ const transferAmount = new BigNumber(42);
+ const allowanceAmount = new BigNumber(42);
+ const depositAmount = new BigNumber(42);
+ const withdrawalAmount = new BigNumber(42);
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
+ tokens = await zeroEx.tokenRegistry.getTokensAsync();
userAddresses = await zeroEx.getAvailableAddressesAsync();
addressWithETH = userAddresses[0];
- wethContractAddress = zeroEx.etherToken.getContractAddress();
+ wethContractAddress = (zeroEx.etherToken as any)._getContractAddress(artifacts.EtherTokenArtifact);
depositWeiAmount = (zeroEx as any)._web3Wrapper.toWei(new BigNumber(5));
decimalPlaces = 7;
+ addressWithoutFunds = userAddresses[1];
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -55,7 +79,7 @@ describe('EtherTokenWrapper', () => {
expect(preETHBalance).to.be.bignumber.gt(0);
expect(preWETHBalance).to.be.bignumber.equal(0);
- const txHash = await zeroEx.etherToken.depositAsync(depositWeiAmount, addressWithETH);
+ const txHash = await zeroEx.etherToken.depositAsync(wethContractAddress, depositWeiAmount, addressWithETH);
await zeroEx.awaitTransactionMinedAsync(txHash);
const postETHBalanceInWei = await (zeroEx as any)._web3Wrapper.getBalanceInWeiAsync(addressWithETH);
@@ -73,7 +97,7 @@ describe('EtherTokenWrapper', () => {
const overETHBalanceinWei = preETHBalance.add(extraETHBalance);
return expect(
- zeroEx.etherToken.depositAsync(overETHBalanceinWei, addressWithETH),
+ zeroEx.etherToken.depositAsync(wethContractAddress, overETHBalanceinWei, addressWithETH),
).to.be.rejectedWith(ZeroExError.InsufficientEthBalanceForDeposit);
});
});
@@ -81,7 +105,7 @@ describe('EtherTokenWrapper', () => {
it('should successfully withdraw ETH in return for Wrapped ETH tokens', async () => {
const ETHBalanceInWei = await (zeroEx as any)._web3Wrapper.getBalanceInWeiAsync(addressWithETH);
- await zeroEx.etherToken.depositAsync(depositWeiAmount, addressWithETH);
+ await zeroEx.etherToken.depositAsync(wethContractAddress, depositWeiAmount, addressWithETH);
const expectedPreETHBalance = ETHBalanceInWei.minus(depositWeiAmount);
const preETHBalance = await (zeroEx as any)._web3Wrapper.getBalanceInWeiAsync(addressWithETH);
@@ -90,7 +114,7 @@ describe('EtherTokenWrapper', () => {
expect(gasCost).to.be.bignumber.lte(MAX_REASONABLE_GAS_COST_IN_WEI);
expect(preWETHBalance).to.be.bignumber.equal(depositWeiAmount);
- const txHash = await zeroEx.etherToken.withdrawAsync(depositWeiAmount, addressWithETH);
+ const txHash = await zeroEx.etherToken.withdrawAsync(wethContractAddress, depositWeiAmount, addressWithETH);
await zeroEx.awaitTransactionMinedAsync(txHash);
const postETHBalance = await (zeroEx as any)._web3Wrapper.getBalanceInWeiAsync(addressWithETH);
@@ -108,8 +132,244 @@ describe('EtherTokenWrapper', () => {
const overWETHBalance = preWETHBalance.add(999999999);
return expect(
- zeroEx.etherToken.withdrawAsync(overWETHBalance, addressWithETH),
+ zeroEx.etherToken.withdrawAsync(wethContractAddress, overWETHBalance, addressWithETH),
).to.be.rejectedWith(ZeroExError.InsufficientWEthBalanceForWithdrawal);
});
});
+ describe('#subscribe', () => {
+ const indexFilterValues = {};
+ let etherTokenAddress: string;
+ before(() => {
+ const tokenUtils = new TokenUtils(tokens);
+ const etherToken = tokenUtils.getWethTokenOrThrow();
+ etherTokenAddress = etherToken.address;
+ });
+ afterEach(() => {
+ zeroEx.etherToken.unsubscribeAll();
+ });
+ // Hack: Mocha does not allow a test to be both async and have a `done` callback
+ // Since we need to await the receipt of the event in the `subscribe` callback,
+ // we do need both. A hack is to make the top-level async fn w/ a done callback and then
+ // wrap the rest of the test in an async block
+ // Source: https://github.com/mochajs/mocha/issues/2407
+ it('Should receive the Transfer event when tokens are transfered', (done: DoneCallback) => {
+ (async () => {
+ const callback = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<TransferContractEventArgs>) => {
+ expect(logEvent).to.not.be.undefined();
+ expect(logEvent.isRemoved).to.be.false();
+ expect(logEvent.log.logIndex).to.be.equal(0);
+ expect(logEvent.log.transactionIndex).to.be.equal(0);
+ expect(logEvent.log.blockNumber).to.be.a('number');
+ const args = logEvent.log.args;
+ expect(args._from).to.be.equal(addressWithETH);
+ expect(args._to).to.be.equal(addressWithoutFunds);
+ expect(args._value).to.be.bignumber.equal(transferAmount);
+ },
+ );
+ await zeroEx.etherToken.depositAsync(etherTokenAddress, transferAmount, addressWithETH);
+ zeroEx.etherToken.subscribe(etherTokenAddress, EtherTokenEvents.Transfer, indexFilterValues, callback);
+ await zeroEx.token.transferAsync(
+ etherTokenAddress,
+ addressWithETH,
+ addressWithoutFunds,
+ transferAmount,
+ );
+ })().catch(done);
+ });
+ it('Should receive the Approval event when allowance is being set', (done: DoneCallback) => {
+ (async () => {
+ const callback = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
+ expect(logEvent).to.not.be.undefined();
+ expect(logEvent.isRemoved).to.be.false();
+ const args = logEvent.log.args;
+ expect(args._owner).to.be.equal(addressWithETH);
+ expect(args._spender).to.be.equal(addressWithoutFunds);
+ expect(args._value).to.be.bignumber.equal(allowanceAmount);
+ },
+ );
+ zeroEx.etherToken.subscribe(etherTokenAddress, EtherTokenEvents.Approval, indexFilterValues, callback);
+ await zeroEx.token.setAllowanceAsync(
+ etherTokenAddress,
+ addressWithETH,
+ addressWithoutFunds,
+ allowanceAmount,
+ );
+ })().catch(done);
+ });
+ it('Should receive the Deposit event when ether is being deposited', (done: DoneCallback) => {
+ (async () => {
+ const callback = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<DepositContractEventArgs>) => {
+ expect(logEvent).to.not.be.undefined();
+ expect(logEvent.isRemoved).to.be.false();
+ const args = logEvent.log.args;
+ expect(args._owner).to.be.equal(addressWithETH);
+ expect(args._value).to.be.bignumber.equal(depositAmount);
+ },
+ );
+ zeroEx.etherToken.subscribe(etherTokenAddress, EtherTokenEvents.Deposit, indexFilterValues, callback);
+ await zeroEx.etherToken.depositAsync(etherTokenAddress, depositAmount, addressWithETH);
+ })().catch(done);
+ });
+ it('Should receive the Withdrawal event when ether is being withdrawn', (done: DoneCallback) => {
+ (async () => {
+ const callback = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<WithdrawalContractEventArgs>) => {
+ expect(logEvent).to.not.be.undefined();
+ expect(logEvent.isRemoved).to.be.false();
+ const args = logEvent.log.args;
+ expect(args._owner).to.be.equal(addressWithETH);
+ expect(args._value).to.be.bignumber.equal(depositAmount);
+ },
+ );
+ await zeroEx.etherToken.depositAsync(etherTokenAddress, depositAmount, addressWithETH);
+ zeroEx.etherToken.subscribe(
+ etherTokenAddress,
+ EtherTokenEvents.Withdrawal,
+ indexFilterValues,
+ callback,
+ );
+ await zeroEx.etherToken.withdrawAsync(etherTokenAddress, withdrawalAmount, addressWithETH);
+ })().catch(done);
+ });
+ it('should cancel outstanding subscriptions when ZeroEx.setProvider is called', (done: DoneCallback) => {
+ (async () => {
+ const callbackNeverToBeCalled = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
+ done(new Error('Expected this subscription to have been cancelled'));
+ },
+ );
+ zeroEx.etherToken.subscribe(
+ etherTokenAddress,
+ EtherTokenEvents.Transfer,
+ indexFilterValues,
+ callbackNeverToBeCalled,
+ );
+ const callbackToBeCalled = reportNodeCallbackErrors(done)();
+ const newProvider = web3Factory.getRpcProvider();
+ zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
+ await zeroEx.etherToken.depositAsync(etherTokenAddress, transferAmount, addressWithETH);
+ zeroEx.etherToken.subscribe(
+ etherTokenAddress,
+ EtherTokenEvents.Transfer,
+ indexFilterValues,
+ callbackToBeCalled,
+ );
+ await zeroEx.token.transferAsync(
+ etherTokenAddress,
+ addressWithETH,
+ addressWithoutFunds,
+ transferAmount,
+ );
+ })().catch(done);
+ });
+ it('Should cancel subscription when unsubscribe called', (done: DoneCallback) => {
+ (async () => {
+ const callbackNeverToBeCalled = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
+ done(new Error('Expected this subscription to have been cancelled'));
+ },
+ );
+ await zeroEx.etherToken.depositAsync(etherTokenAddress, transferAmount, addressWithETH);
+ const subscriptionToken = zeroEx.etherToken.subscribe(
+ etherTokenAddress,
+ EtherTokenEvents.Transfer,
+ indexFilterValues,
+ callbackNeverToBeCalled,
+ );
+ zeroEx.etherToken.unsubscribe(subscriptionToken);
+ await zeroEx.token.transferAsync(
+ etherTokenAddress,
+ addressWithETH,
+ addressWithoutFunds,
+ transferAmount,
+ );
+ done();
+ })().catch(done);
+ });
+ });
+ describe('#getLogsAsync', () => {
+ let etherTokenAddress: string;
+ let tokenTransferProxyAddress: string;
+ const blockRange: BlockRange = {
+ fromBlock: 0,
+ toBlock: BlockParamLiteral.Latest,
+ };
+ let txHash: string;
+ before(() => {
+ addressWithETH = userAddresses[0];
+ const tokenUtils = new TokenUtils(tokens);
+ const etherToken = tokenUtils.getWethTokenOrThrow();
+ etherTokenAddress = etherToken.address;
+ tokenTransferProxyAddress = zeroEx.proxy.getContractAddress();
+ });
+ it('should get logs with decoded args emitted by Approval', async () => {
+ txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(etherTokenAddress, addressWithETH);
+ await zeroEx.awaitTransactionMinedAsync(txHash);
+ const eventName = EtherTokenEvents.Approval;
+ const indexFilterValues = {};
+ const logs = await zeroEx.etherToken.getLogsAsync<ApprovalContractEventArgs>(
+ etherTokenAddress,
+ eventName,
+ blockRange,
+ indexFilterValues,
+ );
+ expect(logs).to.have.length(1);
+ const args = logs[0].args;
+ expect(logs[0].event).to.be.equal(eventName);
+ expect(args._owner).to.be.equal(addressWithETH);
+ expect(args._spender).to.be.equal(tokenTransferProxyAddress);
+ expect(args._value).to.be.bignumber.equal(zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS);
+ });
+ it('should get logs with decoded args emitted by Deposit', async () => {
+ await zeroEx.etherToken.depositAsync(etherTokenAddress, depositAmount, addressWithETH);
+ const eventName = EtherTokenEvents.Deposit;
+ const indexFilterValues = {};
+ const logs = await zeroEx.etherToken.getLogsAsync<DepositContractEventArgs>(
+ etherTokenAddress,
+ eventName,
+ blockRange,
+ indexFilterValues,
+ );
+ expect(logs).to.have.length(1);
+ const args = logs[0].args;
+ expect(logs[0].event).to.be.equal(eventName);
+ expect(args._owner).to.be.equal(addressWithETH);
+ expect(args._value).to.be.bignumber.equal(depositAmount);
+ });
+ it('should only get the logs with the correct event name', async () => {
+ txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(etherTokenAddress, addressWithETH);
+ await zeroEx.awaitTransactionMinedAsync(txHash);
+ const differentEventName = EtherTokenEvents.Transfer;
+ const indexFilterValues = {};
+ const logs = await zeroEx.etherToken.getLogsAsync(
+ etherTokenAddress,
+ differentEventName,
+ blockRange,
+ indexFilterValues,
+ );
+ expect(logs).to.have.length(0);
+ });
+ it('should only get the logs with the correct indexed fields', async () => {
+ txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(etherTokenAddress, addressWithETH);
+ await zeroEx.awaitTransactionMinedAsync(txHash);
+ txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(etherTokenAddress, addressWithoutFunds);
+ await zeroEx.awaitTransactionMinedAsync(txHash);
+ const eventName = EtherTokenEvents.Approval;
+ const indexFilterValues = {
+ _owner: addressWithETH,
+ };
+ const logs = await zeroEx.etherToken.getLogsAsync<ApprovalContractEventArgs>(
+ etherTokenAddress,
+ eventName,
+ blockRange,
+ indexFilterValues,
+ );
+ expect(logs).to.have.length(1);
+ const args = logs[0].args;
+ expect(args._owner).to.be.equal(addressWithETH);
+ });
+ });
});
diff --git a/packages/0x.js/test/event_watcher_test.ts b/packages/0x.js/test/event_watcher_test.ts
index 3d92c62a3..f92fb2b02 100644
--- a/packages/0x.js/test/event_watcher_test.ts
+++ b/packages/0x.js/test/event_watcher_test.ts
@@ -1,22 +1,17 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as Sinon from 'sinon';
import * as Web3 from 'web3';
-import {
- DecodedLogEvent,
- LogEvent,
- ZeroEx,
-} from '../src';
-import {EventWatcher} from '../src/order_watcher/event_watcher';
-import {DoneCallback} from '../src/types';
+import { LogEvent } from '../src';
+import { EventWatcher } from '../src/order_watcher/event_watcher';
+import { DoneCallback } from '../src/types';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { reportNodeCallbackErrors } from './utils/report_callback_errors';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
@@ -26,7 +21,6 @@ describe('EventWatcher', () => {
let stubs: Sinon.SinonStub[] = [];
let eventWatcher: EventWatcher;
let web3Wrapper: Web3Wrapper;
- const numConfirmations = 0;
const logA: Web3.LogEntry = {
address: '0x71d271f8b14adef568f8f28f1587ce7271ac4ca5',
blockHash: null,
@@ -43,7 +37,7 @@ describe('EventWatcher', () => {
blockNumber: null,
data: '',
logIndex: null,
- topics: [ '0xf341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567' ],
+ topics: ['0xf341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567'],
transactionHash: '0x01ef3c048b18d9b09ea195b4ed94cf8dd5f3d857a1905ff886b152cfb1166f25',
transactionIndex: 0,
};
@@ -53,7 +47,7 @@ describe('EventWatcher', () => {
blockNumber: null,
data: '',
logIndex: null,
- topics: [ '0xf341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567' ],
+ topics: ['0xf341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567'],
transactionHash: '0x01ef3c048b18d9b09ea195b4ed94cf8dd5f3d857a1905ff886b152cfb1166f25',
transactionIndex: 0,
};
@@ -84,13 +78,14 @@ describe('EventWatcher', () => {
const getLogsStub = Sinon.stub(web3Wrapper, 'getLogsAsync');
getLogsStub.onCall(0).returns(logs);
stubs.push(getLogsStub);
- const callback = (event: LogEvent) => {
+ const expectedToBeCalledOnce = false;
+ const callback = reportNodeCallbackErrors(done, expectedToBeCalledOnce)((event: LogEvent) => {
const expectedLogEvent = expectedLogEvents.shift();
expect(event).to.be.deep.equal(expectedLogEvent);
if (_.isEmpty(expectedLogEvents)) {
done();
}
- };
+ });
eventWatcher.subscribe(callback);
});
it('correctly computes the difference and emits only changes', (done: DoneCallback) => {
@@ -118,13 +113,14 @@ describe('EventWatcher', () => {
getLogsStub.onCall(0).returns(initialLogs);
getLogsStub.onCall(1).returns(changedLogs);
stubs.push(getLogsStub);
- const callback = (event: LogEvent) => {
+ const expectedToBeCalledOnce = false;
+ const callback = reportNodeCallbackErrors(done, expectedToBeCalledOnce)((event: LogEvent) => {
const expectedLogEvent = expectedLogEvents.shift();
expect(event).to.be.deep.equal(expectedLogEvent);
if (_.isEmpty(expectedLogEvents)) {
done();
}
- };
+ });
eventWatcher.subscribe(callback);
});
});
diff --git a/packages/0x.js/test/exchange_transfer_simulator_test.ts b/packages/0x.js/test/exchange_transfer_simulator_test.ts
index a1d9bdade..20b4a05ca 100644
--- a/packages/0x.js/test/exchange_transfer_simulator_test.ts
+++ b/packages/0x.js/test/exchange_transfer_simulator_test.ts
@@ -1,18 +1,18 @@
-import BigNumber from 'bignumber.js';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
-import {ExchangeContractErrs, Token, ZeroEx} from '../src';
-import {BlockParamLiteral, TradeSide, TransferType} from '../src/types';
-import {ExchangeTransferSimulator} from '../src/utils/exchange_transfer_simulator';
+import { ExchangeContractErrs, Token, ZeroEx } from '../src';
+import { BlockParamLiteral, TradeSide, TransferType } from '../src/types';
+import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simulator';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('ExchangeTransferSimulator', () => {
const web3 = web3Factory.create();
@@ -45,17 +45,31 @@ describe('ExchangeTransferSimulator', () => {
beforeEach(() => {
exchangeTransferSimulator = new ExchangeTransferSimulator(zeroEx.token, BlockParamLiteral.Latest);
});
- it('throws if the user doesn\'t have enough allowance', async () => {
- return expect(exchangeTransferSimulator.transferFromAsync(
- exampleTokenAddress, sender, recipient, transferAmount, TradeSide.Taker, TransferType.Trade,
- )).to.be.rejectedWith(ExchangeContractErrs.InsufficientTakerAllowance);
+ it("throws if the user doesn't have enough allowance", async () => {
+ return expect(
+ exchangeTransferSimulator.transferFromAsync(
+ exampleTokenAddress,
+ sender,
+ recipient,
+ transferAmount,
+ TradeSide.Taker,
+ TransferType.Trade,
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.InsufficientTakerAllowance);
});
- it('throws if the user doesn\'t have enough balance', async () => {
+ it("throws if the user doesn't have enough balance", async () => {
txHash = await zeroEx.token.setProxyAllowanceAsync(exampleTokenAddress, sender, transferAmount);
await zeroEx.awaitTransactionMinedAsync(txHash);
- return expect(exchangeTransferSimulator.transferFromAsync(
- exampleTokenAddress, sender, recipient, transferAmount, TradeSide.Maker, TransferType.Trade,
- )).to.be.rejectedWith(ExchangeContractErrs.InsufficientMakerBalance);
+ return expect(
+ exchangeTransferSimulator.transferFromAsync(
+ exampleTokenAddress,
+ sender,
+ recipient,
+ transferAmount,
+ TradeSide.Maker,
+ TransferType.Trade,
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.InsufficientMakerBalance);
});
it('updates balances and proxyAllowance after transfer', async () => {
txHash = await zeroEx.token.transferAsync(exampleTokenAddress, coinbase, sender, transferAmount);
@@ -63,9 +77,14 @@ describe('ExchangeTransferSimulator', () => {
txHash = await zeroEx.token.setProxyAllowanceAsync(exampleTokenAddress, sender, transferAmount);
await zeroEx.awaitTransactionMinedAsync(txHash);
await exchangeTransferSimulator.transferFromAsync(
- exampleTokenAddress, sender, recipient, transferAmount, TradeSide.Taker, TransferType.Trade,
+ exampleTokenAddress,
+ sender,
+ recipient,
+ transferAmount,
+ TradeSide.Taker,
+ TransferType.Trade,
);
- const store = (exchangeTransferSimulator as any).store;
+ const store = (exchangeTransferSimulator as any)._store;
const senderBalance = await store.getBalanceAsync(exampleTokenAddress, sender);
const recipientBalance = await store.getBalanceAsync(exampleTokenAddress, recipient);
const senderProxyAllowance = await store.getProxyAllowanceAsync(exampleTokenAddress, sender);
@@ -73,15 +92,20 @@ describe('ExchangeTransferSimulator', () => {
expect(recipientBalance).to.be.bignumber.equal(transferAmount);
expect(senderProxyAllowance).to.be.bignumber.equal(0);
});
- it('doesn\'t update proxyAllowance after transfer if unlimited', async () => {
+ it("doesn't update proxyAllowance after transfer if unlimited", async () => {
txHash = await zeroEx.token.transferAsync(exampleTokenAddress, coinbase, sender, transferAmount);
await zeroEx.awaitTransactionMinedAsync(txHash);
txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(exampleTokenAddress, sender);
await zeroEx.awaitTransactionMinedAsync(txHash);
await exchangeTransferSimulator.transferFromAsync(
- exampleTokenAddress, sender, recipient, transferAmount, TradeSide.Taker, TransferType.Trade,
+ exampleTokenAddress,
+ sender,
+ recipient,
+ transferAmount,
+ TradeSide.Taker,
+ TransferType.Trade,
);
- const store = (exchangeTransferSimulator as any).store;
+ const store = (exchangeTransferSimulator as any)._store;
const senderBalance = await store.getBalanceAsync(exampleTokenAddress, sender);
const recipientBalance = await store.getBalanceAsync(exampleTokenAddress, recipient);
const senderProxyAllowance = await store.getProxyAllowanceAsync(exampleTokenAddress, sender);
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts
index 14559c706..7e0ffd818 100644
--- a/packages/0x.js/test/exchange_wrapper_test.ts
+++ b/packages/0x.js/test/exchange_wrapper_test.ts
@@ -1,34 +1,35 @@
-import BigNumber from 'bignumber.js';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
+import * as _ from 'lodash';
import 'mocha';
import * as Web3 from 'web3';
import {
+ BlockRange,
DecodedLogEvent,
ExchangeContractErrs,
ExchangeEvents,
LogCancelContractEventArgs,
- LogEvent,
LogFillContractEventArgs,
OrderCancellationRequest,
OrderFillRequest,
SignedOrder,
- SubscriptionOpts,
Token,
ZeroEx,
} from '../src';
-import {BlockParamLiteral, DoneCallback} from '../src/types';
+import { BlockParamLiteral, DoneCallback } from '../src/types';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {FillScenarios} from './utils/fill_scenarios';
-import {TokenUtils} from './utils/token_utils';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { FillScenarios } from './utils/fill_scenarios';
+import { reportNodeCallbackErrors } from './utils/report_callback_errors';
+import { TokenUtils } from './utils/token_utils';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
const NON_EXISTENT_ORDER_HASH = '0x79370342234e7acd6bbeac335bd3bb1d368383294b64b8160a00f4060e4d3777';
@@ -53,6 +54,7 @@ describe('ExchangeWrapper', () => {
tokenUtils = new TokenUtils(tokens);
zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
+ await fillScenarios.initTokenBalancesAsync();
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -71,7 +73,7 @@ describe('ExchangeWrapper', () => {
before(async () => {
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
tokens = await zeroEx.tokenRegistry.getTokensAsync();
- const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
});
@@ -80,10 +82,18 @@ describe('ExchangeWrapper', () => {
const fillableAmount = new BigNumber(5);
const partialFillTakerAmount = new BigNumber(2);
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
const anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
const orderFillRequests = [
{
@@ -103,7 +113,11 @@ describe('ExchangeWrapper', () => {
const fillableAmount = new BigNumber(5);
beforeEach(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
orderFillRequests = [
{
@@ -113,18 +127,23 @@ describe('ExchangeWrapper', () => {
];
});
it('should validate when orderTransactionOptions are not present', async () => {
- return expect(zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress))
- .to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should validate when orderTransactionOptions specify to validate', async () => {
- return expect(zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress, {
- shouldValidate: true,
- })).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress, {
+ shouldValidate: true,
+ }),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should not validate when orderTransactionOptions specify not to validate', async () => {
- return expect(zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress, {
- shouldValidate: false,
- })).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress, {
+ shouldValidate: false,
+ }),
+ ).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
});
});
@@ -133,57 +152,78 @@ describe('ExchangeWrapper', () => {
const fillableAmount = new BigNumber(5);
beforeEach(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
});
describe('successful fills', () => {
it('should fill a valid order', async () => {
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillableAmount);
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
- .to.be.bignumber.equal(0);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress))
- .to.be.bignumber.equal(0);
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillableAmount);
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ fillableAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ 0,
+ );
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ 0,
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ fillableAmount,
+ );
await zeroEx.exchange.fillOrKillOrderAsync(signedOrder, takerTokenFillAmount, takerAddress);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(takerTokenFillAmount));
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
- .to.be.bignumber.equal(takerTokenFillAmount);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress))
- .to.be.bignumber.equal(takerTokenFillAmount);
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(takerTokenFillAmount));
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ fillableAmount.minus(takerTokenFillAmount),
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ takerTokenFillAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ takerTokenFillAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ fillableAmount.minus(takerTokenFillAmount),
+ );
});
it('should partially fill a valid order', async () => {
const partialFillAmount = new BigNumber(3);
await zeroEx.exchange.fillOrKillOrderAsync(signedOrder, partialFillAmount, takerAddress);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(partialFillAmount));
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
- .to.be.bignumber.equal(partialFillAmount);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress))
- .to.be.bignumber.equal(partialFillAmount);
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(partialFillAmount));
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ fillableAmount.minus(partialFillAmount),
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ partialFillAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ partialFillAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ fillableAmount.minus(partialFillAmount),
+ );
});
});
describe('order transaction options', () => {
const emptyFillableAmount = new BigNumber(0);
it('should validate when orderTransactionOptions are not present', async () => {
- return expect(zeroEx.exchange.fillOrKillOrderAsync(signedOrder, emptyFillableAmount, takerAddress))
- .to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.fillOrKillOrderAsync(signedOrder, emptyFillableAmount, takerAddress),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should validate when orderTransactionOptions specify to validate', async () => {
- return expect(zeroEx.exchange.fillOrKillOrderAsync(signedOrder, emptyFillableAmount, takerAddress, {
- shouldValidate: true,
- })).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.fillOrKillOrderAsync(signedOrder, emptyFillableAmount, takerAddress, {
+ shouldValidate: true,
+ }),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should not validate when orderTransactionOptions specify not to validate', async () => {
- return expect(zeroEx.exchange.fillOrKillOrderAsync(signedOrder, emptyFillableAmount, takerAddress, {
- shouldValidate: false,
- })).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.fillOrKillOrderAsync(signedOrder, emptyFillableAmount, takerAddress, {
+ shouldValidate: false,
+ }),
+ ).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
});
});
@@ -201,7 +241,7 @@ describe('ExchangeWrapper', () => {
before(async () => {
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
tokens = await zeroEx.tokenRegistry.getTokensAsync();
- const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
});
@@ -209,57 +249,96 @@ describe('ExchangeWrapper', () => {
describe('successful fills', () => {
it('should fill a valid order', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
- );
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillableAmount);
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
- .to.be.bignumber.equal(0);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress))
- .to.be.bignumber.equal(0);
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillableAmount);
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ fillableAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ 0,
+ );
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ 0,
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ fillableAmount,
+ );
const txHash = await zeroEx.exchange.fillOrderAsync(
- signedOrder, takerTokenFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress);
+ signedOrder,
+ takerTokenFillAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ );
await zeroEx.awaitTransactionMinedAsync(txHash);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(takerTokenFillAmount));
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
- .to.be.bignumber.equal(takerTokenFillAmount);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress))
- .to.be.bignumber.equal(takerTokenFillAmount);
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(takerTokenFillAmount));
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ fillableAmount.minus(takerTokenFillAmount),
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ takerTokenFillAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ takerTokenFillAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ fillableAmount.minus(takerTokenFillAmount),
+ );
});
it('should partially fill the valid order', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
const partialFillAmount = new BigNumber(3);
const txHash = await zeroEx.exchange.fillOrderAsync(
- signedOrder, partialFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress);
+ signedOrder,
+ partialFillAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ );
await zeroEx.awaitTransactionMinedAsync(txHash);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(partialFillAmount));
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
- .to.be.bignumber.equal(partialFillAmount);
- expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress))
- .to.be.bignumber.equal(partialFillAmount);
- expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(partialFillAmount));
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ fillableAmount.minus(partialFillAmount),
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress)).to.be.bignumber.equal(
+ partialFillAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ partialFillAmount,
+ );
+ expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)).to.be.bignumber.equal(
+ fillableAmount.minus(partialFillAmount),
+ );
});
it('should fill the valid orders with fees', async () => {
const makerFee = new BigNumber(1);
const takerFee = new BigNumber(2);
const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
- makerTokenAddress, takerTokenAddress, makerFee, takerFee,
- makerAddress, takerAddress, fillableAmount, feeRecipient,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerFee,
+ takerFee,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ feeRecipient,
);
const txHash = await zeroEx.exchange.fillOrderAsync(
- signedOrder, takerTokenFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress);
+ signedOrder,
+ takerTokenFillAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ );
await zeroEx.awaitTransactionMinedAsync(txHash);
- expect(await zeroEx.token.getBalanceAsync(zrxTokenAddress, feeRecipient))
- .to.be.bignumber.equal(makerFee.plus(takerFee));
+ expect(await zeroEx.token.getBalanceAsync(zrxTokenAddress, feeRecipient)).to.be.bignumber.equal(
+ makerFee.plus(takerFee),
+ );
});
});
describe('order transaction options', () => {
@@ -267,25 +346,71 @@ describe('ExchangeWrapper', () => {
const emptyFillTakerAmount = new BigNumber(0);
beforeEach(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
});
it('should validate when orderTransactionOptions are not present', async () => {
- return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, emptyFillTakerAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
- )).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.fillOrderAsync(
+ signedOrder,
+ emptyFillTakerAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should validate when orderTransactionOptions specify to validate', async () => {
- return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, emptyFillTakerAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, {
- shouldValidate: true,
- })).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.fillOrderAsync(
+ signedOrder,
+ emptyFillTakerAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ {
+ shouldValidate: true,
+ },
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should not validate when orderTransactionOptions specify not to validate', async () => {
- return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, emptyFillTakerAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, {
- shouldValidate: false,
- })).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.fillOrderAsync(
+ signedOrder,
+ emptyFillTakerAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ {
+ shouldValidate: false,
+ },
+ ),
+ ).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ });
+ });
+ describe('negative fill amount', async () => {
+ let signedOrder: SignedOrder;
+ const negativeFillTakerAmount = new BigNumber(-100);
+ beforeEach(async () => {
+ signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ );
+ });
+ it('should not allow the exchange wrapper to fill if amount is negative', async () => {
+ return expect(
+ zeroEx.exchange.fillOrderAsync(
+ signedOrder,
+ negativeFillTakerAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ ),
+ ).to.be.rejected();
});
});
});
@@ -297,11 +422,19 @@ describe('ExchangeWrapper', () => {
let orderFillBatch: OrderFillRequest[];
beforeEach(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
signedOrderHashHex = ZeroEx.getOrderHashHex(signedOrder);
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
anotherOrderHashHex = ZeroEx.getOrderHashHex(anotherSignedOrder);
});
@@ -319,13 +452,20 @@ describe('ExchangeWrapper', () => {
];
});
it('should throw if a batch is empty', async () => {
- return expect(zeroEx.exchange.batchFillOrdersAsync(
- [], shouldThrowOnInsufficientBalanceOrAllowance, takerAddress),
+ return expect(
+ zeroEx.exchange.batchFillOrdersAsync(
+ [],
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ ),
).to.be.rejectedWith(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
});
it('should successfully fill multiple orders', async () => {
const txHash = await zeroEx.exchange.batchFillOrdersAsync(
- orderFillBatch, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress);
+ orderFillBatch,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ );
await zeroEx.awaitTransactionMinedAsync(txHash);
const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex);
const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex);
@@ -348,21 +488,61 @@ describe('ExchangeWrapper', () => {
];
});
it('should validate when orderTransactionOptions are not present', async () => {
- return expect(zeroEx.exchange.batchFillOrdersAsync(
- orderFillBatch, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress),
+ return expect(
+ zeroEx.exchange.batchFillOrdersAsync(
+ orderFillBatch,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ ),
).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should validate when orderTransactionOptions specify to validate', async () => {
- return expect(zeroEx.exchange.batchFillOrdersAsync(
- orderFillBatch, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, {
- shouldValidate: true,
- })).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.batchFillOrdersAsync(
+ orderFillBatch,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ {
+ shouldValidate: true,
+ },
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should not validate when orderTransactionOptions specify not to validate', async () => {
- return expect(zeroEx.exchange.batchFillOrdersAsync(
- orderFillBatch, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, {
- shouldValidate: false,
- })).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.batchFillOrdersAsync(
+ orderFillBatch,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ {
+ shouldValidate: false,
+ },
+ ),
+ ).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ });
+ });
+ describe('negative batch fill amount', async () => {
+ beforeEach(async () => {
+ const negativeFillTakerAmount = new BigNumber(-100);
+ orderFillBatch = [
+ {
+ signedOrder,
+ takerTokenFillAmount,
+ },
+ {
+ signedOrder: anotherSignedOrder,
+ takerTokenFillAmount: negativeFillTakerAmount,
+ },
+ ];
+ });
+ it('should not allow the exchange wrapper to batch fill if any amount is negative', async () => {
+ return expect(
+ zeroEx.exchange.batchFillOrdersAsync(
+ orderFillBatch,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ ),
+ ).to.be.rejected();
});
});
});
@@ -375,24 +555,57 @@ describe('ExchangeWrapper', () => {
const fillUpToAmount = fillableAmount.plus(fillableAmount).minus(1);
beforeEach(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
signedOrderHashHex = ZeroEx.getOrderHashHex(signedOrder);
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
anotherOrderHashHex = ZeroEx.getOrderHashHex(anotherSignedOrder);
signedOrders = [signedOrder, anotherSignedOrder];
});
describe('successful batch fills', () => {
it('should throw if a batch is empty', async () => {
- return expect(zeroEx.exchange.fillOrdersUpToAsync(
- [], fillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress),
+ return expect(
+ zeroEx.exchange.fillOrdersUpToAsync(
+ [],
+ fillUpToAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ ),
).to.be.rejectedWith(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
});
- it('should successfully fill up to specified amount', async () => {
+ it('should successfully fill up to specified amount when all orders are fully funded', async () => {
+ const txHash = await zeroEx.exchange.fillOrdersUpToAsync(
+ signedOrders,
+ fillUpToAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ );
+ await zeroEx.awaitTransactionMinedAsync(txHash);
+ const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex);
+ const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex);
+ expect(filledAmount).to.be.bignumber.equal(fillableAmount);
+ const remainingFillAmount = fillableAmount.minus(1);
+ expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount);
+ });
+ it('should successfully fill up to specified amount even if filling all orders would fail', async () => {
+ const missingBalance = new BigNumber(1); // User will still have enough balance to fill up to 9,
+ // but won't have 10 to fully fill all orders in a batch.
+ await zeroEx.token.transferAsync(makerTokenAddress, makerAddress, coinbase, missingBalance);
const txHash = await zeroEx.exchange.fillOrdersUpToAsync(
- signedOrders, fillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
+ signedOrders,
+ fillUpToAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
);
await zeroEx.awaitTransactionMinedAsync(txHash);
const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex);
@@ -402,24 +615,57 @@ describe('ExchangeWrapper', () => {
expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount);
});
});
+ describe('failed batch fills', () => {
+ it("should fail validation if user doesn't have enough balance without fill up to", async () => {
+ const missingBalance = new BigNumber(2); // User will only have enough balance to fill up to 8
+ await zeroEx.token.transferAsync(makerTokenAddress, makerAddress, coinbase, missingBalance);
+ return expect(
+ zeroEx.exchange.fillOrdersUpToAsync(
+ signedOrders,
+ fillUpToAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.InsufficientMakerBalance);
+ });
+ });
describe('order transaction options', () => {
const emptyFillUpToAmount = new BigNumber(0);
it('should validate when orderTransactionOptions are not present', async () => {
- return expect(zeroEx.exchange.fillOrdersUpToAsync(
- signedOrders, emptyFillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
- )).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.fillOrdersUpToAsync(
+ signedOrders,
+ emptyFillUpToAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should validate when orderTransactionOptions specify to validate', async () => {
- return expect(zeroEx.exchange.fillOrdersUpToAsync(
- signedOrders, emptyFillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, {
- shouldValidate: true,
- })).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.fillOrdersUpToAsync(
+ signedOrders,
+ emptyFillUpToAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ {
+ shouldValidate: true,
+ },
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should not validate when orderTransactionOptions specify not to validate', async () => {
- return expect(zeroEx.exchange.fillOrdersUpToAsync(
- signedOrders, emptyFillUpToAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, {
- shouldValidate: false,
- })).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.fillOrdersUpToAsync(
+ signedOrders,
+ emptyFillUpToAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
+ {
+ shouldValidate: false,
+ },
+ ),
+ ).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
});
});
@@ -436,11 +682,15 @@ describe('ExchangeWrapper', () => {
const cancelAmount = new BigNumber(3);
beforeEach(async () => {
[coinbase, makerAddress, takerAddress] = userAddresses;
- const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
});
@@ -456,18 +706,23 @@ describe('ExchangeWrapper', () => {
describe('order transaction options', () => {
const emptyCancelTakerTokenAmount = new BigNumber(0);
it('should validate when orderTransactionOptions are not present', async () => {
- return expect(zeroEx.exchange.cancelOrderAsync(signedOrder, emptyCancelTakerTokenAmount))
- .to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
+ return expect(
+ zeroEx.exchange.cancelOrderAsync(signedOrder, emptyCancelTakerTokenAmount),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
});
it('should validate when orderTransactionOptions specify to validate', async () => {
- return expect(zeroEx.exchange.cancelOrderAsync(signedOrder, emptyCancelTakerTokenAmount, {
- shouldValidate: true,
- })).to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
+ return expect(
+ zeroEx.exchange.cancelOrderAsync(signedOrder, emptyCancelTakerTokenAmount, {
+ shouldValidate: true,
+ }),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
});
it('should not validate when orderTransactionOptions specify not to validate', async () => {
- return expect(zeroEx.exchange.cancelOrderAsync(signedOrder, emptyCancelTakerTokenAmount, {
- shouldValidate: false,
- })).to.not.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
+ return expect(
+ zeroEx.exchange.cancelOrderAsync(signedOrder, emptyCancelTakerTokenAmount, {
+ shouldValidate: false,
+ }),
+ ).to.not.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
});
});
});
@@ -477,7 +732,11 @@ describe('ExchangeWrapper', () => {
let cancelBatch: OrderCancellationRequest[];
beforeEach(async () => {
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
anotherOrderHashHex = ZeroEx.getOrderHashHex(anotherSignedOrder);
cancelBatch = [
@@ -494,15 +753,21 @@ describe('ExchangeWrapper', () => {
describe('failed batch cancels', () => {
it('should throw when orders have different makers', async () => {
const signedOrderWithDifferentMaker = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, takerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ takerAddress,
+ takerAddress,
+ fillableAmount,
);
- return expect(zeroEx.exchange.batchCancelOrdersAsync([
- cancelBatch[0],
- {
- order: signedOrderWithDifferentMaker,
- takerTokenCancelAmount: cancelAmount,
- },
- ])).to.be.rejectedWith(ExchangeContractErrs.MultipleMakersInSingleCancelBatchDisallowed);
+ return expect(
+ zeroEx.exchange.batchCancelOrdersAsync([
+ cancelBatch[0],
+ {
+ order: signedOrderWithDifferentMaker,
+ takerTokenCancelAmount: cancelAmount,
+ },
+ ]),
+ ).to.be.rejectedWith(ExchangeContractErrs.MultipleMakersInSingleCancelBatchDisallowed);
});
});
describe('successful batch cancels', () => {
@@ -531,18 +796,23 @@ describe('ExchangeWrapper', () => {
];
});
it('should validate when orderTransactionOptions are not present', async () => {
- return expect(zeroEx.exchange.batchCancelOrdersAsync(cancelBatch))
- .to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
+ return expect(zeroEx.exchange.batchCancelOrdersAsync(cancelBatch)).to.be.rejectedWith(
+ ExchangeContractErrs.OrderCancelAmountZero,
+ );
});
it('should validate when orderTransactionOptions specify to validate', async () => {
- return expect(zeroEx.exchange.batchCancelOrdersAsync(cancelBatch, {
- shouldValidate: true,
- })).to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
+ return expect(
+ zeroEx.exchange.batchCancelOrdersAsync(cancelBatch, {
+ shouldValidate: true,
+ }),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
});
it('should not validate when orderTransactionOptions specify not to validate', async () => {
- return expect(zeroEx.exchange.batchCancelOrdersAsync(cancelBatch, {
- shouldValidate: false,
- })).to.not.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
+ return expect(
+ zeroEx.exchange.batchCancelOrdersAsync(cancelBatch, {
+ shouldValidate: false,
+ }),
+ ).to.not.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
});
});
});
@@ -557,7 +827,8 @@ describe('ExchangeWrapper', () => {
let orderHash: string;
before(() => {
takerAddress = userAddresses[1];
- const [makerToken, takerToken] = tokens;
+ tokenUtils = new TokenUtils(tokens);
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
});
@@ -565,7 +836,11 @@ describe('ExchangeWrapper', () => {
fillableAmount = new BigNumber(5);
partialFillAmount = new BigNumber(2);
signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ takerAddress,
+ fillableAmount,
+ partialFillAmount,
);
orderHash = ZeroEx.getOrderHashHex(signedOrder);
});
@@ -589,8 +864,7 @@ describe('ExchangeWrapper', () => {
return expect(zeroEx.exchange.getFilledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected();
});
it('should return zero if passed a valid but non-existent orderHash', async () => {
- const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(NON_EXISTENT_ORDER_HASH,
- );
+ const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(NON_EXISTENT_ORDER_HASH);
expect(filledValueT).to.be.bignumber.equal(0);
});
it('should return the filledValueT for a valid and partially filled orderHash', async () => {
@@ -633,14 +907,18 @@ describe('ExchangeWrapper', () => {
const cancelTakerAmountInBaseUnits = new BigNumber(1);
before(() => {
[coinbase, makerAddress, takerAddress] = userAddresses;
- const [makerToken, takerToken] = tokens;
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
});
beforeEach(async () => {
fillableAmount = new BigNumber(5);
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
});
afterEach(async () => {
@@ -653,70 +931,74 @@ describe('ExchangeWrapper', () => {
// Source: https://github.com/mochajs/mocha/issues/2407
it('Should receive the LogFill event when an order is filled', (done: DoneCallback) => {
(async () => {
-
- const callback = (err: Error, logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
- expect(logEvent.log.event).to.be.equal(ExchangeEvents.LogFill);
- done();
- };
- zeroEx.exchange.subscribe(
- ExchangeEvents.LogFill, indexFilterValues, callback,
+ const callback = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
+ expect(logEvent.log.event).to.be.equal(ExchangeEvents.LogFill);
+ },
);
+ zeroEx.exchange.subscribe(ExchangeEvents.LogFill, indexFilterValues, callback);
await zeroEx.exchange.fillOrderAsync(
- signedOrder, takerTokenFillAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance,
+ signedOrder,
+ takerTokenFillAmountInBaseUnits,
+ shouldThrowOnInsufficientBalanceOrAllowance,
takerAddress,
);
})().catch(done);
});
it('Should receive the LogCancel event when an order is cancelled', (done: DoneCallback) => {
(async () => {
-
- const callback = (err: Error, logEvent: DecodedLogEvent<LogCancelContractEventArgs>) => {
- expect(logEvent.log.event).to.be.equal(ExchangeEvents.LogCancel);
- done();
- };
- zeroEx.exchange.subscribe(
- ExchangeEvents.LogCancel, indexFilterValues, callback,
+ const callback = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<LogCancelContractEventArgs>) => {
+ expect(logEvent.log.event).to.be.equal(ExchangeEvents.LogCancel);
+ },
);
+ zeroEx.exchange.subscribe(ExchangeEvents.LogCancel, indexFilterValues, callback);
await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelTakerAmountInBaseUnits);
})().catch(done);
});
it('Outstanding subscriptions are cancelled when zeroEx.setProvider called', (done: DoneCallback) => {
(async () => {
-
- const callbackNeverToBeCalled = (err: Error, logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
- done(new Error('Expected this subscription to have been cancelled'));
- };
- zeroEx.exchange.subscribe(
- ExchangeEvents.LogFill, indexFilterValues, callbackNeverToBeCalled,
+ const callbackNeverToBeCalled = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
+ done(new Error('Expected this subscription to have been cancelled'));
+ },
);
+ zeroEx.exchange.subscribe(ExchangeEvents.LogFill, indexFilterValues, callbackNeverToBeCalled);
const newProvider = web3Factory.getRpcProvider();
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
- const callback = (err: Error, logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
- expect(logEvent.log.event).to.be.equal(ExchangeEvents.LogFill);
- done();
- };
- zeroEx.exchange.subscribe(
- ExchangeEvents.LogFill, indexFilterValues, callback,
+ const callback = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
+ expect(logEvent.log.event).to.be.equal(ExchangeEvents.LogFill);
+ },
);
+ zeroEx.exchange.subscribe(ExchangeEvents.LogFill, indexFilterValues, callback);
await zeroEx.exchange.fillOrderAsync(
- signedOrder, takerTokenFillAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance,
+ signedOrder,
+ takerTokenFillAmountInBaseUnits,
+ shouldThrowOnInsufficientBalanceOrAllowance,
takerAddress,
);
})().catch(done);
});
it('Should cancel subscription when unsubscribe called', (done: DoneCallback) => {
(async () => {
- const callbackNeverToBeCalled = (err: Error, logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
- done(new Error('Expected this subscription to have been cancelled'));
- };
+ const callbackNeverToBeCalled = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
+ done(new Error('Expected this subscription to have been cancelled'));
+ },
+ );
const subscriptionToken = zeroEx.exchange.subscribe(
- ExchangeEvents.LogFill, indexFilterValues, callbackNeverToBeCalled,
+ ExchangeEvents.LogFill,
+ indexFilterValues,
+ callbackNeverToBeCalled,
);
zeroEx.exchange.unsubscribe(subscriptionToken);
await zeroEx.exchange.fillOrderAsync(
- signedOrder, takerTokenFillAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance,
+ signedOrder,
+ takerTokenFillAmountInBaseUnits,
+ shouldThrowOnInsufficientBalanceOrAllowance,
takerAddress,
);
done();
@@ -731,17 +1013,22 @@ describe('ExchangeWrapper', () => {
const fillableAmount = new BigNumber(5);
before(async () => {
[, makerAddress, takerAddress] = userAddresses;
- const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
});
- it('get\'s the same hash as the local function', async () => {
+ it("get's the same hash as the local function", async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- const orderHashFromContract = await (zeroEx.exchange as any)
- ._getOrderHashHexUsingContractCallAsync(signedOrder);
+ const orderHashFromContract = await (zeroEx.exchange as any)._getOrderHashHexUsingContractCallAsync(
+ signedOrder,
+ );
expect(orderHash).to.equal(orderHashFromContract);
});
});
@@ -759,59 +1046,87 @@ describe('ExchangeWrapper', () => {
let takerAddress: string;
const fillableAmount = new BigNumber(5);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
- const subscriptionOpts: SubscriptionOpts = {
+ const blockRange: BlockRange = {
fromBlock: 0,
toBlock: BlockParamLiteral.Latest,
};
let txHash: string;
before(async () => {
[, makerAddress, takerAddress] = userAddresses;
- const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
});
it('should get logs with decoded args emitted by LogFill', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
txHash = await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillableAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
+ signedOrder,
+ fillableAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
);
await zeroEx.awaitTransactionMinedAsync(txHash);
const eventName = ExchangeEvents.LogFill;
const indexFilterValues = {};
- const logs = await zeroEx.exchange.getLogsAsync(eventName, subscriptionOpts, indexFilterValues);
+ const logs = await zeroEx.exchange.getLogsAsync(eventName, blockRange, indexFilterValues);
expect(logs).to.have.length(1);
expect(logs[0].event).to.be.equal(eventName);
});
it('should only get the logs with the correct event name', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
txHash = await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillableAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
+ signedOrder,
+ fillableAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
);
await zeroEx.awaitTransactionMinedAsync(txHash);
const differentEventName = ExchangeEvents.LogCancel;
const indexFilterValues = {};
- const logs = await zeroEx.exchange.getLogsAsync(differentEventName, subscriptionOpts, indexFilterValues);
+ const logs = await zeroEx.exchange.getLogsAsync(differentEventName, blockRange, indexFilterValues);
expect(logs).to.have.length(0);
});
it('should only get the logs with the correct indexed fields', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
txHash = await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillableAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
+ signedOrder,
+ fillableAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
);
await zeroEx.awaitTransactionMinedAsync(txHash);
const differentMakerAddress = userAddresses[2];
const anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, differentMakerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ differentMakerAddress,
+ takerAddress,
+ fillableAmount,
);
txHash = await zeroEx.exchange.fillOrderAsync(
- anotherSignedOrder, fillableAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
+ anotherSignedOrder,
+ fillableAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
);
await zeroEx.awaitTransactionMinedAsync(txHash);
@@ -820,7 +1135,9 @@ describe('ExchangeWrapper', () => {
maker: differentMakerAddress,
};
const logs = await zeroEx.exchange.getLogsAsync<LogFillContractEventArgs>(
- eventName, subscriptionOpts, indexFilterValues,
+ eventName,
+ blockRange,
+ indexFilterValues,
);
expect(logs).to.have.length(1);
const args = logs[0].args;
diff --git a/packages/0x.js/test/expiration_watcher_test.ts b/packages/0x.js/test/expiration_watcher_test.ts
index d4581259d..770615f88 100644
--- a/packages/0x.js/test/expiration_watcher_test.ts
+++ b/packages/0x.js/test/expiration_watcher_test.ts
@@ -1,27 +1,27 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as Sinon from 'sinon';
import * as Web3 from 'web3';
-import {ZeroEx} from '../src/0x';
-import {ExpirationWatcher} from '../src/order_watcher/expiration_watcher';
-import {DoneCallback, Token} from '../src/types';
-import {constants} from '../src/utils/constants';
-import {utils} from '../src/utils/utils';
+import { ZeroEx } from '../src/0x';
+import { ExpirationWatcher } from '../src/order_watcher/expiration_watcher';
+import { DoneCallback, Token } from '../src/types';
+import { constants } from '../src/utils/constants';
+import { utils } from '../src/utils/utils';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {FillScenarios} from './utils/fill_scenarios';
-import {reportCallbackErrors} from './utils/report_callback_errors';
-import {TokenUtils} from './utils/token_utils';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants as testConstants } from './utils/constants';
+import { FillScenarios } from './utils/fill_scenarios';
+import { reportNoErrorCallbackErrors } from './utils/report_callback_errors';
+import { TokenUtils } from './utils/token_utils';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(testConstants.RPC_URL);
describe('ExpirationWatcher', () => {
let web3: Web3;
@@ -56,13 +56,13 @@ describe('ExpirationWatcher', () => {
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
tokens = await zeroEx.tokenRegistry.getTokensAsync();
- const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
- const sinonTimerConfig = {shouldAdvanceTime: true} as any;
+ const sinonTimerConfig = { shouldAdvanceTime: true } as any;
// This constructor has incorrect types
timer = Sinon.useFakeTimers(sinonTimerConfig);
currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
@@ -78,31 +78,38 @@ describe('ExpirationWatcher', () => {
const orderLifetimeSec = 60;
const expirationUnixTimestampSec = currentUnixTimestampSec.plus(orderLifetimeSec);
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
expirationUnixTimestampSec,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(1000));
- const callbackAsync = reportCallbackErrors(done)(async (hash: string) => {
+ const callbackAsync = reportNoErrorCallbackErrors(done)((hash: string) => {
expect(hash).to.be.equal(orderHash);
expect(utils.getCurrentUnixTimestampSec()).to.be.bignumber.gte(expirationUnixTimestampSec);
- done();
});
expirationWatcher.subscribe(callbackAsync);
timer.tick(orderLifetimeSec * 1000);
})().catch(done);
});
- it('doesn\'t emit events before order expires', (done: DoneCallback) => {
+ it("doesn't emit events before order expires", (done: DoneCallback) => {
(async () => {
const orderLifetimeSec = 60;
const expirationUnixTimestampSec = currentUnixTimestampSec.plus(orderLifetimeSec);
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
expirationUnixTimestampSec,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(1000));
- const callbackAsync = reportCallbackErrors(done)(async (hash: string) => {
+ const callbackAsync = reportNoErrorCallbackErrors(done)(async (hash: string) => {
done(new Error('Emitted expiration went before the order actually expired'));
});
expirationWatcher.subscribe(callbackAsync);
@@ -118,11 +125,19 @@ describe('ExpirationWatcher', () => {
const order1ExpirationUnixTimestampSec = currentUnixTimestampSec.plus(order1Lifetime);
const order2ExpirationUnixTimestampSec = currentUnixTimestampSec.plus(order2Lifetime);
const signedOrder1 = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
order1ExpirationUnixTimestampSec,
);
const signedOrder2 = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
order2ExpirationUnixTimestampSec,
);
const orderHash1 = ZeroEx.getOrderHashHex(signedOrder1);
@@ -130,7 +145,8 @@ describe('ExpirationWatcher', () => {
expirationWatcher.addOrder(orderHash2, signedOrder2.expirationUnixTimestampSec.times(1000));
expirationWatcher.addOrder(orderHash1, signedOrder1.expirationUnixTimestampSec.times(1000));
const expirationOrder = [orderHash1, orderHash2];
- const callbackAsync = reportCallbackErrors(done)(async (hash: string) => {
+ const expectToBeCalledOnce = false;
+ const callbackAsync = reportNoErrorCallbackErrors(done, expectToBeCalledOnce)((hash: string) => {
const orderHash = expirationOrder.shift();
expect(hash).to.be.equal(orderHash);
if (_.isEmpty(expirationOrder)) {
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts
index b5968dc24..2e9202fe2 100644
--- a/packages/0x.js/test/order_state_watcher_test.ts
+++ b/packages/0x.js/test/order_state_watcher_test.ts
@@ -1,39 +1,34 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as Web3 from 'web3';
import {
- DecodedLogEvent,
ExchangeContractErrs,
- LogEvent,
OrderState,
OrderStateInvalid,
OrderStateValid,
SignedOrder,
Token,
ZeroEx,
- ZeroExConfig,
ZeroExError,
} from '../src';
-import {OrderStateWatcher} from '../src/order_watcher/order_state_watcher';
-import {DoneCallback} from '../src/types';
+import { DoneCallback } from '../src/types';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {FillScenarios} from './utils/fill_scenarios';
-import {reportCallbackErrors} from './utils/report_callback_errors';
-import {TokenUtils} from './utils/token_utils';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { FillScenarios } from './utils/fill_scenarios';
+import { reportNodeCallbackErrors } from './utils/report_callback_errors';
+import { TokenUtils } from './utils/token_utils';
+import { web3Factory } from './utils/web3_factory';
const TIMEOUT_MS = 150;
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('OrderStateWatcher', () => {
let web3: Web3;
@@ -48,7 +43,6 @@ describe('OrderStateWatcher', () => {
let takerToken: Token;
let maker: string;
let taker: string;
- let web3Wrapper: Web3Wrapper;
let signedOrder: SignedOrder;
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
@@ -65,8 +59,8 @@ describe('OrderStateWatcher', () => {
tokenUtils = new TokenUtils(tokens);
zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
- [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
- web3Wrapper = (zeroEx as any)._web3Wrapper;
+ await fillScenarios.initTokenBalancesAsync();
+ [makerToken, takerToken] = tokenUtils.getDummyTokens();
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -77,7 +71,11 @@ describe('OrderStateWatcher', () => {
describe('#removeOrder', async () => {
it('should successfully remove existing order', async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
@@ -95,10 +93,18 @@ describe('OrderStateWatcher', () => {
});
it('should no-op when removing a non-existing order', async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- const nonExistentOrderHash = `0x${orderHash.substr(2).split('').reverse().join('')}`;
+ const nonExistentOrderHash = `0x${orderHash
+ .substr(2)
+ .split('')
+ .reverse()
+ .join('')}`;
zeroEx.orderStateWatcher.removeOrder(nonExistentOrderHash);
});
});
@@ -108,8 +114,7 @@ describe('OrderStateWatcher', () => {
});
it('should fail when trying to subscribe twice', async () => {
zeroEx.orderStateWatcher.subscribe(_.noop);
- expect(() => zeroEx.orderStateWatcher.subscribe(_.noop))
- .to.throw(ZeroExError.SubscriptionAlreadyPresent);
+ expect(() => zeroEx.orderStateWatcher.subscribe(_.noop)).to.throw(ZeroExError.SubscriptionAlreadyPresent);
});
});
describe('tests with cleanup', async () => {
@@ -121,16 +126,19 @@ describe('OrderStateWatcher', () => {
it('should emit orderStateInvalid when maker allowance set to 0 for watched order', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.InsufficientMakerAllowance);
- done();
});
zeroEx.orderStateWatcher.subscribe(callback);
await zeroEx.token.setProxyAllowanceAsync(makerToken.address, maker, new BigNumber(0));
@@ -139,18 +147,20 @@ describe('OrderStateWatcher', () => {
it('should not emit an orderState event when irrelevant Transfer event received', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
- const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
throw new Error('OrderState callback fired for irrelevant order');
});
zeroEx.orderStateWatcher.subscribe(callback);
const notTheMaker = userAddresses[0];
const anyRecipient = taker;
const transferAmount = new BigNumber(2);
- const notTheMakerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, notTheMaker);
await zeroEx.token.transferAsync(makerToken.address, notTheMaker, anyRecipient, transferAmount);
setTimeout(() => {
done();
@@ -160,16 +170,19 @@ describe('OrderStateWatcher', () => {
it('should emit orderStateInvalid when maker moves balance backing watched order', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.InsufficientMakerBalance);
- done();
});
zeroEx.orderStateWatcher.subscribe(callback);
const anyRecipient = taker;
@@ -180,40 +193,48 @@ describe('OrderStateWatcher', () => {
it('should emit orderStateInvalid when watched order fully filled', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderRemainingFillAmountZero);
- done();
});
zeroEx.orderStateWatcher.subscribe(callback);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillableAmount, shouldThrowOnInsufficientBalanceOrAllowance, taker,
+ signedOrder,
+ fillableAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ taker,
);
})().catch(done);
});
it('should emit orderStateValid when watched order partially filled', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
- const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
-
const fillAmountInBaseUnits = new BigNumber(2);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.true();
const validOrderState = orderState as OrderStateValid;
expect(validOrderState.orderHash).to.be.equal(orderHash);
@@ -221,16 +242,20 @@ describe('OrderStateWatcher', () => {
const remainingMakerBalance = makerBalance.sub(fillAmountInBaseUnits);
const remainingFillable = fillableAmount.minus(fillAmountInBaseUnits);
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
- remainingFillable);
+ remainingFillable,
+ );
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
- remainingFillable);
+ remainingFillable,
+ );
expect(orderRelevantState.makerBalance).to.be.bignumber.equal(remainingMakerBalance);
- done();
});
zeroEx.orderStateWatcher.subscribe(callback);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance, taker,
+ signedOrder,
+ fillAmountInBaseUnits,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ taker,
);
})().catch(done);
});
@@ -239,13 +264,17 @@ describe('OrderStateWatcher', () => {
const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(2), 18);
const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), 18);
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
- makerToken.address, takerToken.address, makerFee, takerFee, maker, taker, fillableAmount,
- taker);
- const orderHash = ZeroEx.getOrderHashHex(signedOrder);
+ makerToken.address,
+ takerToken.address,
+ makerFee,
+ takerFee,
+ maker,
+ taker,
+ fillableAmount,
+ taker,
+ );
+ const callback = reportNodeCallbackErrors(done)();
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
- done();
- });
zeroEx.orderStateWatcher.subscribe(callback);
await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, maker, new BigNumber(0));
})().catch(done);
@@ -256,51 +285,60 @@ describe('OrderStateWatcher', () => {
const takerFillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(10), decimals);
const makerFillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(20), decimals);
signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, makerFillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ makerFillableAmount,
takerFillableAmount,
);
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
- const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
const fillAmountInBaseUnits = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.true();
const validOrderState = orderState as OrderStateValid;
expect(validOrderState.orderHash).to.be.equal(orderHash);
const orderRelevantState = validOrderState.orderRelevantState;
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
- ZeroEx.toBaseUnitAmount(new BigNumber(16), decimals));
+ ZeroEx.toBaseUnitAmount(new BigNumber(16), decimals),
+ );
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
- ZeroEx.toBaseUnitAmount(new BigNumber(8), decimals));
- done();
+ ZeroEx.toBaseUnitAmount(new BigNumber(8), decimals),
+ );
});
zeroEx.orderStateWatcher.subscribe(callback);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance, taker,
+ signedOrder,
+ fillAmountInBaseUnits,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ taker,
);
})().catch(done);
});
it('should equal approved amount when approved amount is lowest', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
-
const changedMakerApprovalAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
const validOrderState = orderState as OrderStateValid;
const orderRelevantState = validOrderState.orderRelevantState;
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
- changedMakerApprovalAmount);
+ changedMakerApprovalAmount,
+ );
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
- changedMakerApprovalAmount);
- done();
+ changedMakerApprovalAmount,
+ );
});
zeroEx.orderStateWatcher.subscribe(callback);
await zeroEx.token.setProxyAllowanceAsync(makerToken.address, maker, changedMakerApprovalAmount);
@@ -309,7 +347,11 @@ describe('OrderStateWatcher', () => {
it('should equal balance amount when balance amount is lowest', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
@@ -318,19 +360,19 @@ describe('OrderStateWatcher', () => {
const transferAmount = makerBalance.sub(remainingAmount);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.true();
const validOrderState = orderState as OrderStateValid;
const orderRelevantState = validOrderState.orderRelevantState;
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
- remainingAmount);
+ remainingAmount,
+ );
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
- remainingAmount);
- done();
+ remainingAmount,
+ );
});
zeroEx.orderStateWatcher.subscribe(callback);
- await zeroEx.token.transferAsync(
- makerToken.address, maker, ZeroEx.NULL_ADDRESS, transferAmount);
+ await zeroEx.token.transferAsync(makerToken.address, maker, ZeroEx.NULL_ADDRESS, transferAmount);
})().catch(done);
});
it('should equal remaining amount when partially cancelled and order has fees', (done: DoneCallback) => {
@@ -339,22 +381,27 @@ describe('OrderStateWatcher', () => {
const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
const feeRecipient = taker;
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
- makerToken.address, takerToken.address, makerFee, takerFee, maker,
- taker, fillableAmount, feeRecipient);
-
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
+ makerToken.address,
+ takerToken.address,
+ makerFee,
+ takerFee,
+ maker,
+ taker,
+ fillableAmount,
+ feeRecipient,
+ );
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.true();
const validOrderState = orderState as OrderStateValid;
const orderRelevantState = validOrderState.orderRelevantState;
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
- remainingTokenAmount);
- done();
+ remainingTokenAmount,
+ );
});
zeroEx.orderStateWatcher.subscribe(callback);
await zeroEx.exchange.cancelOrderAsync(signedOrder, transferTokenAmount);
@@ -366,29 +413,37 @@ describe('OrderStateWatcher', () => {
const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
const feeRecipient = taker;
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
- makerToken.address, takerToken.address, makerFee, takerFee, maker,
- taker, fillableAmount, feeRecipient);
-
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
+ makerToken.address,
+ takerToken.address,
+ makerFee,
+ takerFee,
+ maker,
+ taker,
+ fillableAmount,
+ feeRecipient,
+ );
const remainingFeeAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
- const transferFeeAmount = makerFee.sub(remainingFeeAmount);
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
const validOrderState = orderState as OrderStateValid;
const orderRelevantState = validOrderState.orderRelevantState;
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
- remainingFeeAmount);
- done();
+ remainingFeeAmount,
+ );
});
zeroEx.orderStateWatcher.subscribe(callback);
await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, maker, remainingFeeAmount);
await zeroEx.token.transferAsync(
- makerToken.address, maker, ZeroEx.NULL_ADDRESS, transferTokenAmount);
+ makerToken.address,
+ maker,
+ ZeroEx.NULL_ADDRESS,
+ transferTokenAmount,
+ );
})().catch(done);
});
it('should calculate full amount when all available and non-divisible', (done: DoneCallback) => {
@@ -397,43 +452,54 @@ describe('OrderStateWatcher', () => {
const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
const feeRecipient = taker;
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
- makerToken.address, takerToken.address, makerFee, takerFee, maker,
- taker, fillableAmount, feeRecipient);
+ makerToken.address,
+ takerToken.address,
+ makerFee,
+ takerFee,
+ maker,
+ taker,
+ fillableAmount,
+ feeRecipient,
+ );
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
const validOrderState = orderState as OrderStateValid;
const orderRelevantState = validOrderState.orderRelevantState;
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
- fillableAmount);
- done();
+ fillableAmount,
+ );
});
zeroEx.orderStateWatcher.subscribe(callback);
await zeroEx.token.setProxyAllowanceAsync(
- makerToken.address, maker, ZeroEx.toBaseUnitAmount(new BigNumber(100), decimals));
+ makerToken.address,
+ maker,
+ ZeroEx.toBaseUnitAmount(new BigNumber(100), decimals),
+ );
})().catch(done);
});
});
it('should emit orderStateInvalid when watched order cancelled', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderRemainingFillAmountZero);
- done();
});
zeroEx.orderStateWatcher.subscribe(callback);
- const shouldThrowOnInsufficientBalanceOrAllowance = true;
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
})().catch(done);
});
@@ -441,44 +507,48 @@ describe('OrderStateWatcher', () => {
(async () => {
const remainingFillableAmountInBaseUnits = new BigNumber(100);
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderFillRoundingError);
- done();
});
zeroEx.orderStateWatcher.subscribe(callback);
await zeroEx.exchange.cancelOrderAsync(
- signedOrder, fillableAmount.minus(remainingFillableAmountInBaseUnits),
+ signedOrder,
+ fillableAmount.minus(remainingFillableAmountInBaseUnits),
);
})().catch(done);
});
it('should emit orderStateValid when watched order partially cancelled', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ makerToken.address,
+ takerToken.address,
+ maker,
+ taker,
+ fillableAmount,
);
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
- const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
-
const cancelAmountInBaseUnits = new BigNumber(2);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.true();
const validOrderState = orderState as OrderStateValid;
expect(validOrderState.orderHash).to.be.equal(orderHash);
const orderRelevantState = validOrderState.orderRelevantState;
expect(orderRelevantState.cancelledTakerTokenAmount).to.be.bignumber.equal(cancelAmountInBaseUnits);
- done();
});
zeroEx.orderStateWatcher.subscribe(callback);
await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmountInBaseUnits);
diff --git a/packages/0x.js/test/order_validation_test.ts b/packages/0x.js/test/order_validation_test.ts
index d585c1f3c..be3e0590c 100644
--- a/packages/0x.js/test/order_validation_test.ts
+++ b/packages/0x.js/test/order_validation_test.ts
@@ -1,23 +1,23 @@
-import BigNumber from 'bignumber.js';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as Sinon from 'sinon';
import * as Web3 from 'web3';
-import {ExchangeContractErrs, SignedOrder, Token, ZeroEx, ZeroExError} from '../src';
-import {BlockParamLiteral, TradeSide, TransferType} from '../src/types';
-import {ExchangeTransferSimulator} from '../src/utils/exchange_transfer_simulator';
-import {OrderValidationUtils} from '../src/utils/order_validation_utils';
+import { ExchangeContractErrs, SignedOrder, Token, ZeroEx, ZeroExError } from '../src';
+import { BlockParamLiteral, TradeSide, TransferType } from '../src/types';
+import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simulator';
+import { OrderValidationUtils } from '../src/utils/order_validation_utils';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {FillScenarios} from './utils/fill_scenarios';
-import {TokenUtils} from './utils/token_utils';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { FillScenarios } from './utils/fill_scenarios';
+import { TokenUtils } from './utils/token_utils';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('OrderValidation', () => {
let web3: Web3;
@@ -34,7 +34,6 @@ describe('OrderValidation', () => {
let makerAddress: string;
let takerAddress: string;
let feeRecipient: string;
- let orderValidationUtils: OrderValidationUtils;
const fillableAmount = new BigNumber(5);
const fillTakerAmount = new BigNumber(5);
const config = {
@@ -50,10 +49,9 @@ describe('OrderValidation', () => {
tokenUtils = new TokenUtils(tokens);
zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
- const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
- orderValidationUtils = new OrderValidationUtils(zeroEx.token, zeroEx.exchange);
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -64,108 +62,152 @@ describe('OrderValidation', () => {
describe('validateOrderFillableOrThrowAsync', () => {
it('should succeed if the order is fillable', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
- );
- await zeroEx.exchange.validateOrderFillableOrThrowAsync(
- signedOrder,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
+ await zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder);
});
it('should succeed if the order is asymmetric and fillable', async () => {
const makerFillableAmount = fillableAmount;
const takerFillableAmount = fillableAmount.minus(4);
const signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
- makerFillableAmount, takerFillableAmount,
- );
- await zeroEx.exchange.validateOrderFillableOrThrowAsync(
- signedOrder,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ makerFillableAmount,
+ takerFillableAmount,
);
+ await zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder);
});
it('should throw when the order is fully filled or cancelled', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
- return expect(zeroEx.exchange.validateOrderFillableOrThrowAsync(
- signedOrder,
- )).to.be.rejectedWith(ExchangeContractErrs.OrderRemainingFillAmountZero);
+ return expect(zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder)).to.be.rejectedWith(
+ ExchangeContractErrs.OrderRemainingFillAmountZero,
+ );
});
it('should throw when order is expired', async () => {
const expirationInPast = new BigNumber(1496826058); // 7th Jun 2017
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
- fillableAmount, expirationInPast,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ expirationInPast,
+ );
+ return expect(zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder)).to.be.rejectedWith(
+ ExchangeContractErrs.OrderFillExpired,
);
- return expect(zeroEx.exchange.validateOrderFillableOrThrowAsync(
- signedOrder,
- )).to.be.rejectedWith(ExchangeContractErrs.OrderFillExpired);
});
});
describe('validateFillOrderAndThrowIfInvalidAsync', () => {
it('should throw when the fill amount is zero', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
const zeroFillAmount = new BigNumber(0);
- return expect(zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(
- signedOrder, zeroFillAmount, takerAddress,
- )).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
+ return expect(
+ zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, zeroFillAmount, takerAddress),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should throw when the signature is invalid', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
// 27 <--> 28
- signedOrder.ecSignature.v = (28 - signedOrder.ecSignature.v) + 27;
- return expect(zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(
- signedOrder, fillableAmount, takerAddress,
- )).to.be.rejectedWith(ZeroExError.InvalidSignature);
+ signedOrder.ecSignature.v = 28 - signedOrder.ecSignature.v + 27;
+ return expect(
+ zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, fillableAmount, takerAddress),
+ ).to.be.rejectedWith(ZeroExError.InvalidSignature);
});
it('should throw when the order is fully filled or cancelled', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
- return expect(zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(
- signedOrder, fillableAmount, takerAddress,
- )).to.be.rejectedWith(ExchangeContractErrs.OrderRemainingFillAmountZero);
+ return expect(
+ zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, fillableAmount, takerAddress),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderRemainingFillAmountZero);
});
it('should throw when sender is not a taker', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
const nonTakerAddress = userAddresses[6];
- return expect(zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(
- signedOrder, fillTakerAmount, nonTakerAddress,
- )).to.be.rejectedWith(ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker);
+ return expect(
+ zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, fillTakerAmount, nonTakerAddress),
+ ).to.be.rejectedWith(ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker);
});
it('should throw when order is expired', async () => {
const expirationInPast = new BigNumber(1496826058); // 7th Jun 2017
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
- fillableAmount, expirationInPast,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ expirationInPast,
);
- return expect(zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(
- signedOrder, fillTakerAmount, takerAddress,
- )).to.be.rejectedWith(ExchangeContractErrs.OrderFillExpired);
+ return expect(
+ zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, fillTakerAmount, takerAddress),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillExpired);
});
it('should throw when there a rounding error would have occurred', async () => {
const makerAmount = new BigNumber(3);
const takerAmount = new BigNumber(5);
const signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
- makerAmount, takerAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ makerAmount,
+ takerAmount,
);
const fillTakerAmountThatCausesRoundingError = new BigNumber(3);
- return expect(zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(
- signedOrder, fillTakerAmountThatCausesRoundingError, takerAddress,
- )).to.be.rejectedWith(ExchangeContractErrs.OrderFillRoundingError);
+ return expect(
+ zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(
+ signedOrder,
+ fillTakerAmountThatCausesRoundingError,
+ takerAddress,
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderFillRoundingError);
});
});
describe('#validateFillOrKillOrderAndThrowIfInvalidAsync', () => {
it('should throw if remaining fillAmount is less then the desired fillAmount', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
const tooLargeFillAmount = new BigNumber(7);
const fillAmountDifference = tooLargeFillAmount.minus(fillableAmount);
@@ -174,44 +216,56 @@ describe('OrderValidation', () => {
await zeroEx.token.transferAsync(makerTokenAddress, coinbase, makerAddress, fillAmountDifference);
await zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, tooLargeFillAmount);
- return expect(zeroEx.exchange.validateFillOrKillOrderThrowIfInvalidAsync(
- signedOrder, tooLargeFillAmount, takerAddress,
- )).to.be.rejectedWith(ExchangeContractErrs.InsufficientRemainingFillAmount);
+ return expect(
+ zeroEx.exchange.validateFillOrKillOrderThrowIfInvalidAsync(
+ signedOrder,
+ tooLargeFillAmount,
+ takerAddress,
+ ),
+ ).to.be.rejectedWith(ExchangeContractErrs.InsufficientRemainingFillAmount);
});
});
describe('validateCancelOrderAndThrowIfInvalidAsync', () => {
let signedOrder: SignedOrder;
- let orderHashHex: string;
const cancelAmount = new BigNumber(3);
beforeEach(async () => {
[coinbase, makerAddress, takerAddress] = userAddresses;
- const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ const [makerToken, takerToken] = tokenUtils.getDummyTokens();
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
);
- orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
});
it('should throw when cancel amount is zero', async () => {
const zeroCancelAmount = new BigNumber(0);
- return expect(zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(signedOrder, zeroCancelAmount))
- .to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
+ return expect(
+ zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(signedOrder, zeroCancelAmount),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
});
it('should throw when order is expired', async () => {
const expirationInPast = new BigNumber(1496826058); // 7th Jun 2017
const expiredSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
- fillableAmount, expirationInPast,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ expirationInPast,
);
- orderHashHex = ZeroEx.getOrderHashHex(expiredSignedOrder);
- return expect(zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(expiredSignedOrder, cancelAmount))
- .to.be.rejectedWith(ExchangeContractErrs.OrderCancelExpired);
+ return expect(
+ zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(expiredSignedOrder, cancelAmount),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderCancelExpired);
});
it('should throw when order is already cancelled or filled', async () => {
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
- return expect(zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(signedOrder, fillableAmount))
- .to.be.rejectedWith(ExchangeContractErrs.OrderAlreadyCancelledOrFilled);
+ return expect(
+ zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(signedOrder, fillableAmount),
+ ).to.be.rejectedWith(ExchangeContractErrs.OrderAlreadyCancelledOrFilled);
});
});
describe('#validateFillOrderBalancesAllowancesThrowIfInvalidAsync', () => {
@@ -229,82 +283,159 @@ describe('OrderValidation', () => {
const makerFee = new BigNumber(2);
const takerFee = new BigNumber(2);
const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
- makerTokenAddress, takerTokenAddress, makerFee, takerFee,
- makerAddress, takerAddress, fillableAmount, feeRecipient,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerFee,
+ takerFee,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ feeRecipient,
);
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
- exchangeTransferSimulator, signedOrder, fillableAmount, takerAddress, zrxTokenAddress,
+ exchangeTransferSimulator,
+ signedOrder,
+ fillableAmount,
+ takerAddress,
+ zrxTokenAddress,
);
expect(transferFromAsync.callCount).to.be.equal(4);
expect(
- transferFromAsync.getCall(0).calledWith(
- makerTokenAddress, makerAddress, takerAddress, bigNumberMatch(fillableAmount),
- TradeSide.Maker, TransferType.Trade,
- ),
+ transferFromAsync
+ .getCall(0)
+ .calledWith(
+ makerTokenAddress,
+ makerAddress,
+ takerAddress,
+ bigNumberMatch(fillableAmount),
+ TradeSide.Maker,
+ TransferType.Trade,
+ ),
).to.be.true();
expect(
- transferFromAsync.getCall(1).calledWith(
- takerTokenAddress, takerAddress, makerAddress, bigNumberMatch(fillableAmount),
- TradeSide.Taker, TransferType.Trade,
- ),
+ transferFromAsync
+ .getCall(1)
+ .calledWith(
+ takerTokenAddress,
+ takerAddress,
+ makerAddress,
+ bigNumberMatch(fillableAmount),
+ TradeSide.Taker,
+ TransferType.Trade,
+ ),
).to.be.true();
expect(
- transferFromAsync.getCall(2).calledWith(
- zrxTokenAddress, makerAddress, feeRecipient, bigNumberMatch(makerFee),
- TradeSide.Maker, TransferType.Fee,
- ),
+ transferFromAsync
+ .getCall(2)
+ .calledWith(
+ zrxTokenAddress,
+ makerAddress,
+ feeRecipient,
+ bigNumberMatch(makerFee),
+ TradeSide.Maker,
+ TransferType.Fee,
+ ),
).to.be.true();
expect(
- transferFromAsync.getCall(3).calledWith(
- zrxTokenAddress, takerAddress, feeRecipient, bigNumberMatch(takerFee),
- TradeSide.Taker, TransferType.Fee,
- ),
+ transferFromAsync
+ .getCall(3)
+ .calledWith(
+ zrxTokenAddress,
+ takerAddress,
+ feeRecipient,
+ bigNumberMatch(takerFee),
+ TradeSide.Taker,
+ TransferType.Fee,
+ ),
).to.be.true();
});
it('should call exchangeTransferSimulator.transferFrom with correct values for an open order', async () => {
const makerFee = new BigNumber(2);
const takerFee = new BigNumber(2);
const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
- makerTokenAddress, takerTokenAddress, makerFee, takerFee,
- makerAddress, ZeroEx.NULL_ADDRESS, fillableAmount, feeRecipient,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerFee,
+ takerFee,
+ makerAddress,
+ ZeroEx.NULL_ADDRESS,
+ fillableAmount,
+ feeRecipient,
);
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
- exchangeTransferSimulator, signedOrder, fillableAmount, takerAddress, zrxTokenAddress,
+ exchangeTransferSimulator,
+ signedOrder,
+ fillableAmount,
+ takerAddress,
+ zrxTokenAddress,
);
expect(transferFromAsync.callCount).to.be.equal(4);
expect(
- transferFromAsync.getCall(0).calledWith(
- makerTokenAddress, makerAddress, takerAddress, bigNumberMatch(fillableAmount),
- TradeSide.Maker, TransferType.Trade,
- ),
+ transferFromAsync
+ .getCall(0)
+ .calledWith(
+ makerTokenAddress,
+ makerAddress,
+ takerAddress,
+ bigNumberMatch(fillableAmount),
+ TradeSide.Maker,
+ TransferType.Trade,
+ ),
).to.be.true();
expect(
- transferFromAsync.getCall(1).calledWith(
- takerTokenAddress, takerAddress, makerAddress, bigNumberMatch(fillableAmount),
- TradeSide.Taker, TransferType.Trade,
- ),
+ transferFromAsync
+ .getCall(1)
+ .calledWith(
+ takerTokenAddress,
+ takerAddress,
+ makerAddress,
+ bigNumberMatch(fillableAmount),
+ TradeSide.Taker,
+ TransferType.Trade,
+ ),
).to.be.true();
expect(
- transferFromAsync.getCall(2).calledWith(
- zrxTokenAddress, makerAddress, feeRecipient, bigNumberMatch(makerFee),
- TradeSide.Maker, TransferType.Fee,
- ),
+ transferFromAsync
+ .getCall(2)
+ .calledWith(
+ zrxTokenAddress,
+ makerAddress,
+ feeRecipient,
+ bigNumberMatch(makerFee),
+ TradeSide.Maker,
+ TransferType.Fee,
+ ),
).to.be.true();
expect(
- transferFromAsync.getCall(3).calledWith(
- zrxTokenAddress, takerAddress, feeRecipient, bigNumberMatch(takerFee),
- TradeSide.Taker, TransferType.Fee,
- ),
+ transferFromAsync
+ .getCall(3)
+ .calledWith(
+ zrxTokenAddress,
+ takerAddress,
+ feeRecipient,
+ bigNumberMatch(takerFee),
+ TradeSide.Taker,
+ TransferType.Fee,
+ ),
).to.be.true();
});
it('should correctly round the fillMakerTokenAmount', async () => {
const makerTokenAmount = new BigNumber(3);
const takerTokenAmount = new BigNumber(1);
const signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, makerTokenAmount, takerTokenAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ makerTokenAmount,
+ takerTokenAmount,
);
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
- exchangeTransferSimulator, signedOrder, takerTokenAmount, takerAddress, zrxTokenAddress,
+ exchangeTransferSimulator,
+ signedOrder,
+ takerTokenAmount,
+ takerAddress,
+ zrxTokenAddress,
);
expect(transferFromAsync.callCount).to.be.equal(4);
const makerFillAmount = transferFromAsync.getCall(0).args[3];
@@ -314,12 +445,22 @@ describe('OrderValidation', () => {
const makerFee = new BigNumber(2);
const takerFee = new BigNumber(4);
const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
- makerTokenAddress, takerTokenAddress, makerFee, takerFee, makerAddress, takerAddress,
- fillableAmount, ZeroEx.NULL_ADDRESS,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerFee,
+ takerFee,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ ZeroEx.NULL_ADDRESS,
);
const fillTakerTokenAmount = fillableAmount.div(2).round(0);
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
- exchangeTransferSimulator, signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress,
+ exchangeTransferSimulator,
+ signedOrder,
+ fillTakerTokenAmount,
+ takerAddress,
+ zrxTokenAddress,
);
const makerPartialFee = makerFee.div(2);
const takerPartialFee = takerFee.div(2);
diff --git a/packages/0x.js/test/remaining_fillable_calculator_test.ts b/packages/0x.js/test/remaining_fillable_calculator_test.ts
index 610bf9b1a..4c6b8f3ac 100644
--- a/packages/0x.js/test/remaining_fillable_calculator_test.ts
+++ b/packages/0x.js/test/remaining_fillable_calculator_test.ts
@@ -1,4 +1,4 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import 'mocha';
@@ -7,7 +7,6 @@ import { RemainingFillableCalculator } from '../src/order_watcher/remaining_fill
import { ECSignature, SignedOrder } from '../src/types';
import { chaiSetup } from './utils/chai_setup';
-import { TokenUtils } from './utils/token_utils';
chaiSetup.configure();
const expect = chai.expect;
@@ -27,29 +26,34 @@ describe('RemainingFillableCalculator', () => {
const decimals: number = 4;
const zero: BigNumber = new BigNumber(0);
const zeroAddress = '0x0';
- const signature: ECSignature = { v: 27, r: '', s: ''};
+ const signature: ECSignature = { v: 27, r: '', s: '' };
beforeEach(async () => {
- [makerAmount, takerAmount, makerFeeAmount] = [ZeroEx.toBaseUnitAmount(new BigNumber(50), decimals),
- ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals),
- ZeroEx.toBaseUnitAmount(new BigNumber(1), decimals)];
+ [makerAmount, takerAmount, makerFeeAmount] = [
+ ZeroEx.toBaseUnitAmount(new BigNumber(50), decimals),
+ ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals),
+ ZeroEx.toBaseUnitAmount(new BigNumber(1), decimals),
+ ];
[transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount] = [
- ZeroEx.toBaseUnitAmount(new BigNumber(50), decimals),
- ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals)];
+ ZeroEx.toBaseUnitAmount(new BigNumber(50), decimals),
+ ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals),
+ ];
});
function buildSignedOrder(): SignedOrder {
- return { ecSignature: signature,
- exchangeContractAddress: zeroAddress,
- feeRecipient: zeroAddress,
- maker: zeroAddress,
- taker: zeroAddress,
- makerFee: makerFeeAmount,
- takerFee: zero,
- makerTokenAmount: makerAmount,
- takerTokenAmount: takerAmount,
- makerTokenAddress: makerToken,
- takerTokenAddress: takerToken,
- salt: zero,
- expirationUnixTimestampSec: zero };
+ return {
+ ecSignature: signature,
+ exchangeContractAddress: zeroAddress,
+ feeRecipient: zeroAddress,
+ maker: zeroAddress,
+ taker: zeroAddress,
+ makerFee: makerFeeAmount,
+ takerFee: zero,
+ makerTokenAmount: makerAmount,
+ takerTokenAmount: takerAmount,
+ makerTokenAddress: makerToken,
+ takerTokenAddress: takerToken,
+ salt: zero,
+ expirationUnixTimestampSec: zero,
+ };
}
describe('Maker token is NOT ZRX', () => {
before(async () => {
@@ -58,23 +62,38 @@ describe('RemainingFillableCalculator', () => {
it('calculates the correct amount when unfilled and funds available', () => {
signedOrder = buildSignedOrder();
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
});
it('calculates the correct amount when partially filled and funds available', () => {
signedOrder = buildSignedOrder();
remainingMakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), decimals);
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
});
it('calculates the amount to be 0 when all fee funds are transferred', () => {
signedOrder = buildSignedOrder();
transferrableMakerFeeTokenAmount = zero;
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(zero);
});
it('calculates the correct amount when balance is less than remaining fillable', () => {
@@ -82,41 +101,58 @@ describe('RemainingFillableCalculator', () => {
const partiallyFilledAmount = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
remainingMakerTokenAmount = signedOrder.makerTokenAmount.minus(partiallyFilledAmount);
transferrableMakerTokenAmount = remainingMakerTokenAmount.minus(partiallyFilledAmount);
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(transferrableMakerTokenAmount);
});
describe('Order to Fee Ratio is < 1', () => {
beforeEach(async () => {
- [makerAmount, takerAmount, makerFeeAmount] = [ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals),
- ZeroEx.toBaseUnitAmount(new BigNumber(6), decimals),
- ZeroEx.toBaseUnitAmount(new BigNumber(6), decimals)];
+ [makerAmount, takerAmount, makerFeeAmount] = [
+ ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals),
+ ZeroEx.toBaseUnitAmount(new BigNumber(6), decimals),
+ ZeroEx.toBaseUnitAmount(new BigNumber(6), decimals),
+ ];
});
it('calculates the correct amount when funds unavailable', () => {
signedOrder = buildSignedOrder();
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
const transferredAmount = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
transferrableMakerTokenAmount = remainingMakerTokenAmount.minus(transferredAmount);
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount,
- remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(transferrableMakerTokenAmount);
});
});
describe('Ratio is not evenly divisble', () => {
beforeEach(async () => {
- [makerAmount, takerAmount, makerFeeAmount] = [ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals),
- ZeroEx.toBaseUnitAmount(new BigNumber(7), decimals),
- ZeroEx.toBaseUnitAmount(new BigNumber(7), decimals)];
+ [makerAmount, takerAmount, makerFeeAmount] = [
+ ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals),
+ ZeroEx.toBaseUnitAmount(new BigNumber(7), decimals),
+ ZeroEx.toBaseUnitAmount(new BigNumber(7), decimals),
+ ];
});
it('calculates the correct amount when funds unavailable', () => {
signedOrder = buildSignedOrder();
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
const transferredAmount = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
transferrableMakerTokenAmount = remainingMakerTokenAmount.minus(transferredAmount);
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount,
- remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
const calculatedFillableAmount = calculator.computeRemainingMakerFillable();
expect(calculatedFillableAmount.lessThanOrEqualTo(transferrableMakerTokenAmount)).to.be.true();
expect(calculatedFillableAmount).to.be.bignumber.greaterThan(new BigNumber(0));
@@ -135,15 +171,25 @@ describe('RemainingFillableCalculator', () => {
transferrableMakerTokenAmount = makerAmount.plus(makerFeeAmount);
transferrableMakerFeeTokenAmount = transferrableMakerTokenAmount;
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
});
it('calculates the correct amount when partially filled and funds available', () => {
signedOrder = buildSignedOrder();
remainingMakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), decimals);
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
});
it('calculates the amount to be 0 when all fee funds are transferred', () => {
@@ -151,8 +197,13 @@ describe('RemainingFillableCalculator', () => {
transferrableMakerTokenAmount = zero;
transferrableMakerFeeTokenAmount = zero;
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(zero);
});
it('calculates the correct amount when balance is less than remaining fillable', () => {
@@ -164,8 +215,13 @@ describe('RemainingFillableCalculator', () => {
const orderToFeeRatio = signedOrder.makerTokenAmount.dividedToIntegerBy(signedOrder.makerFee);
const expectedFillableAmount = new BigNumber(450980);
- calculator = new RemainingFillableCalculator(signedOrder, isMakerTokenZRX,
- transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount);
+ calculator = new RemainingFillableCalculator(
+ signedOrder,
+ isMakerTokenZRX,
+ transferrableMakerTokenAmount,
+ transferrableMakerFeeTokenAmount,
+ remainingMakerTokenAmount,
+ );
const calculatedFillableAmount = calculator.computeRemainingMakerFillable();
const numberOfFillsInRatio = calculatedFillableAmount.dividedToIntegerBy(orderToFeeRatio);
const calculatedFillableAmountPlusFees = calculatedFillableAmount.plus(numberOfFillsInRatio);
diff --git a/packages/0x.js/test/subscription_test.ts b/packages/0x.js/test/subscription_test.ts
index 3aeeaa109..f4c6f748f 100644
--- a/packages/0x.js/test/subscription_test.ts
+++ b/packages/0x.js/test/subscription_test.ts
@@ -1,37 +1,26 @@
-import BigNumber from 'bignumber.js';
-import * as chai from 'chai';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import 'mocha';
import * as Sinon from 'sinon';
import * as Web3 from 'web3';
-import {
- ApprovalContractEventArgs,
- DecodedLogEvent,
- Token,
- TokenEvents,
- ZeroEx,
- ZeroExError,
-} from '../src';
-import {BlockParamLiteral, DoneCallback} from '../src/types';
+import { ApprovalContractEventArgs, DecodedLogEvent, Token, TokenEvents, ZeroEx } from '../src';
+import { DoneCallback } from '../src/types';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {reportCallbackErrors} from './utils/report_callback_errors';
-import {TokenUtils} from './utils/token_utils';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { assertNodeCallbackError } from './utils/report_callback_errors';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
-const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('SubscriptionTest', () => {
let web3: Web3;
let zeroEx: ZeroEx;
let userAddresses: string[];
let tokens: Token[];
- let tokenUtils: TokenUtils;
let coinbase: string;
let addressWithoutFunds: string;
const config = {
@@ -42,7 +31,6 @@ describe('SubscriptionTest', () => {
zeroEx = new ZeroEx(web3.currentProvider, config);
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();
- tokenUtils = new TokenUtils(tokens);
coinbase = userAddresses[0];
addressWithoutFunds = userAddresses[1];
});
@@ -54,9 +42,7 @@ describe('SubscriptionTest', () => {
});
describe('#subscribe', () => {
const indexFilterValues = {};
- const shouldThrowOnInsufficientBalanceOrAllowance = true;
let tokenAddress: string;
- const transferAmount = new BigNumber(42);
const allowanceAmount = new BigNumber(42);
let stubs: Sinon.SinonStub[] = [];
before(() => {
@@ -71,50 +57,26 @@ describe('SubscriptionTest', () => {
it('Should receive the Error when an error occurs while fetching the block', (done: DoneCallback) => {
(async () => {
const errMsg = 'Error fetching block';
- const callback = reportCallbackErrors(done)(
- (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
- expect(err.message).to.be.equal(errMsg);
- expect(logEvent).to.be.undefined();
- done();
- },
- );
- stubs = [
- Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync')
- .throws(new Error(errMsg)),
- ];
- zeroEx.token.subscribe(
- tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
+ const callback = assertNodeCallbackError(done, errMsg);
+ stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error(errMsg))];
+ zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount);
})().catch(done);
});
it('Should receive the Error when an error occurs while reconciling the new block', (done: DoneCallback) => {
(async () => {
const errMsg = 'Error fetching logs';
- const callback = reportCallbackErrors(done)(
- (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
- expect(err.message).to.be.equal(errMsg);
- expect(logEvent).to.be.undefined();
- done();
- },
- );
- stubs = [
- Sinon.stub((zeroEx as any)._web3Wrapper, 'getLogsAsync')
- .throws(new Error(errMsg)),
- ];
- zeroEx.token.subscribe(
- tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
+ const callback = assertNodeCallbackError(done, errMsg);
+ stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getLogsAsync').throws(new Error(errMsg))];
+ zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount);
})().catch(done);
});
it('Should allow unsubscribeAll to be called successfully after an error', (done: DoneCallback) => {
(async () => {
- const callback = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => _.noop;
- zeroEx.token.subscribe(
- tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
- stubs = [
- Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync')
- .throws(new Error('JSON RPC error')),
- ];
+ const callback = (err: Error | null, logEvent?: DecodedLogEvent<ApprovalContractEventArgs>) => _.noop;
+ zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
+ stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error('JSON RPC error'))];
zeroEx.token.unsubscribeAll();
done();
})().catch(done);
diff --git a/packages/0x.js/test/token_registry_wrapper_test.ts b/packages/0x.js/test/token_registry_wrapper_test.ts
index f1f307f3a..0a170db8f 100644
--- a/packages/0x.js/test/token_registry_wrapper_test.ts
+++ b/packages/0x.js/test/token_registry_wrapper_test.ts
@@ -1,28 +1,28 @@
-import {schemas, SchemaValidator} from '@0xproject/json-schemas';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { schemas, SchemaValidator } from '@0xproject/json-schemas';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
-import {Token, ZeroEx} from '../src';
+import { Token, ZeroEx } from '../src';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
const TOKEN_REGISTRY_SIZE_AFTER_MIGRATION = 7;
describe('TokenRegistryWrapper', () => {
let zeroEx: ZeroEx;
let tokens: Token[];
- const tokenAddressBySymbol: {[symbol: string]: string} = {};
- const tokenAddressByName: {[symbol: string]: string} = {};
- const tokenBySymbol: {[symbol: string]: Token} = {};
- const tokenByName: {[symbol: string]: Token} = {};
+ const tokenAddressBySymbol: { [symbol: string]: string } = {};
+ const tokenAddressByName: { [symbol: string]: string } = {};
+ const tokenBySymbol: { [symbol: string]: Token } = {};
+ const tokenByName: { [symbol: string]: Token } = {};
const registeredSymbol = 'ZRX';
const registeredName = '0x Protocol Token';
const unregisteredSymbol = 'MAL';
diff --git a/packages/0x.js/test/token_transfer_proxy_wrapper_test.ts b/packages/0x.js/test/token_transfer_proxy_wrapper_test.ts
index 05861d112..15bd7a8ba 100644
--- a/packages/0x.js/test/token_transfer_proxy_wrapper_test.ts
+++ b/packages/0x.js/test/token_transfer_proxy_wrapper_test.ts
@@ -1,11 +1,10 @@
import * as chai from 'chai';
-import {ZeroEx} from '../src';
-import {TokenTransferProxyWrapper} from '../src/contract_wrappers/token_transfer_proxy_wrapper';
+import { ZeroEx } from '../src';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts
index ae6016869..4ba1f07c5 100644
--- a/packages/0x.js/test/token_wrapper_test.ts
+++ b/packages/0x.js/test/token_wrapper_test.ts
@@ -1,35 +1,32 @@
-import {promisify} from '@0xproject/utils';
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import 'mocha';
import * as Web3 from 'web3';
import {
ApprovalContractEventArgs,
- ContractEvent,
+ BlockParamLiteral,
+ BlockRange,
DecodedLogEvent,
- LogEvent,
- LogWithDecodedArgs,
- SubscriptionOpts,
Token,
- TokenContractEventArgs,
TokenEvents,
TransferContractEventArgs,
ZeroEx,
ZeroExError,
} from '../src';
-import {BlockParamLiteral, DoneCallback} from '../src/types';
+import { DoneCallback } from '../src/types';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
-import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
-import {TokenUtils} from './utils/token_utils';
-import {web3Factory} from './utils/web3_factory';
+import { chaiSetup } from './utils/chai_setup';
+import { constants } from './utils/constants';
+import { reportNodeCallbackErrors } from './utils/report_callback_errors';
+import { TokenUtils } from './utils/token_utils';
+import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('TokenWrapper', () => {
let web3: Web3;
@@ -71,25 +68,24 @@ describe('TokenWrapper', () => {
const toAddress = addressWithoutFunds;
const preBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
expect(preBalance).to.be.bignumber.equal(0);
- const txHash = await zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount);
- const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ await zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount);
const postBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
return expect(postBalance).to.be.bignumber.equal(transferAmount);
});
it('should fail to transfer tokens if fromAddress has an insufficient balance', async () => {
const fromAddress = addressWithoutFunds;
const toAddress = coinbase;
- return expect(zeroEx.token.transferAsync(
- token.address, fromAddress, toAddress, transferAmount,
- )).to.be.rejectedWith(ZeroExError.InsufficientBalanceForTransfer);
+ return expect(
+ zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount),
+ ).to.be.rejectedWith(ZeroExError.InsufficientBalanceForTransfer);
});
it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
const fromAddress = coinbase;
const toAddress = coinbase;
- return expect(zeroEx.token.transferAsync(
- nonExistentTokenAddress, fromAddress, toAddress, transferAmount,
- )).to.be.rejectedWith(ZeroExError.TokenContractDoesNotExist);
+ return expect(
+ zeroEx.token.transferAsync(nonExistentTokenAddress, fromAddress, toAddress, transferAmount),
+ ).to.be.rejectedWith(ZeroExError.TokenContractDoesNotExist);
});
});
describe('#transferFromAsync', () => {
@@ -108,24 +104,22 @@ describe('TokenWrapper', () => {
const fromAddressBalance = await zeroEx.token.getBalanceAsync(token.address, fromAddress);
expect(fromAddressBalance).to.be.bignumber.greaterThan(transferAmount);
- const fromAddressAllowance = await zeroEx.token.getAllowanceAsync(token.address, fromAddress,
- toAddress);
+ const fromAddressAllowance = await zeroEx.token.getAllowanceAsync(token.address, fromAddress, toAddress);
expect(fromAddressAllowance).to.be.bignumber.equal(0);
- return expect(zeroEx.token.transferFromAsync(
- token.address, fromAddress, toAddress, senderAddress, transferAmount,
- )).to.be.rejectedWith(ZeroExError.InsufficientAllowanceForTransfer);
+ return expect(
+ zeroEx.token.transferFromAsync(token.address, fromAddress, toAddress, senderAddress, transferAmount),
+ ).to.be.rejectedWith(ZeroExError.InsufficientAllowanceForTransfer);
});
- it('[regression] should fail to transfer tokens if set allowance for toAddress instead of senderAddress',
- async () => {
+ it('[regression] should fail to transfer tokens if set allowance for toAddress instead of senderAddress', async () => {
const fromAddress = coinbase;
const transferAmount = new BigNumber(42);
await zeroEx.token.setAllowanceAsync(token.address, fromAddress, toAddress, transferAmount);
- return expect(zeroEx.token.transferFromAsync(
- token.address, fromAddress, toAddress, senderAddress, transferAmount,
- )).to.be.rejectedWith(ZeroExError.InsufficientAllowanceForTransfer);
+ return expect(
+ zeroEx.token.transferFromAsync(token.address, fromAddress, toAddress, senderAddress, transferAmount),
+ ).to.be.rejectedWith(ZeroExError.InsufficientAllowanceForTransfer);
});
it('should fail to transfer tokens if fromAddress has insufficient balance', async () => {
const fromAddress = addressWithoutFunds;
@@ -135,13 +129,16 @@ describe('TokenWrapper', () => {
expect(fromAddressBalance).to.be.bignumber.equal(0);
await zeroEx.token.setAllowanceAsync(token.address, fromAddress, senderAddress, transferAmount);
- const fromAddressAllowance = await zeroEx.token.getAllowanceAsync(token.address, fromAddress,
- senderAddress);
+ const fromAddressAllowance = await zeroEx.token.getAllowanceAsync(
+ token.address,
+ fromAddress,
+ senderAddress,
+ );
expect(fromAddressAllowance).to.be.bignumber.equal(transferAmount);
- return expect(zeroEx.token.transferFromAsync(
- token.address, fromAddress, toAddress, senderAddress, transferAmount,
- )).to.be.rejectedWith(ZeroExError.InsufficientBalanceForTransfer);
+ return expect(
+ zeroEx.token.transferFromAsync(token.address, fromAddress, toAddress, senderAddress, transferAmount),
+ ).to.be.rejectedWith(ZeroExError.InsufficientBalanceForTransfer);
});
it('should successfully transfer tokens', async () => {
const fromAddress = coinbase;
@@ -152,17 +149,22 @@ describe('TokenWrapper', () => {
const transferAmount = new BigNumber(42);
await zeroEx.token.setAllowanceAsync(token.address, fromAddress, senderAddress, transferAmount);
- await zeroEx.token.transferFromAsync(token.address, fromAddress, toAddress, senderAddress,
- transferAmount);
+ await zeroEx.token.transferFromAsync(token.address, fromAddress, toAddress, senderAddress, transferAmount);
const postBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
return expect(postBalance).to.be.bignumber.equal(transferAmount);
});
it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
const fromAddress = coinbase;
const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
- return expect(zeroEx.token.transferFromAsync(
- nonExistentTokenAddress, fromAddress, toAddress, senderAddress, new BigNumber(42),
- )).to.be.rejectedWith(ZeroExError.TokenContractDoesNotExist);
+ return expect(
+ zeroEx.token.transferFromAsync(
+ nonExistentTokenAddress,
+ fromAddress,
+ toAddress,
+ senderAddress,
+ new BigNumber(42),
+ ),
+ ).to.be.rejectedWith(ZeroExError.TokenContractDoesNotExist);
});
});
describe('#getBalanceAsync', () => {
@@ -177,8 +179,9 @@ describe('TokenWrapper', () => {
it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
const ownerAddress = coinbase;
- return expect(zeroEx.token.getBalanceAsync(nonExistentTokenAddress, ownerAddress))
- .to.be.rejectedWith(ZeroExError.TokenContractDoesNotExist);
+ return expect(zeroEx.token.getBalanceAsync(nonExistentTokenAddress, ownerAddress)).to.be.rejectedWith(
+ ZeroExError.TokenContractDoesNotExist,
+ );
});
it('should return a balance of 0 for a non-existent owner address', async () => {
const token = tokens[0];
@@ -196,22 +199,25 @@ describe('TokenWrapper', () => {
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
});
it('should return balance even when called with Web3 provider instance without addresses', async () => {
- const token = tokens[0];
- const ownerAddress = coinbase;
- const balance = await zeroExWithoutAccounts.token.getBalanceAsync(token.address, ownerAddress);
- const expectedBalance = new BigNumber('1000000000000000000000000000');
- return expect(balance).to.be.bignumber.equal(expectedBalance);
+ const token = tokens[0];
+ const ownerAddress = coinbase;
+ const balance = await zeroExWithoutAccounts.token.getBalanceAsync(token.address, ownerAddress);
+ const expectedBalance = new BigNumber('1000000000000000000000000000');
+ return expect(balance).to.be.bignumber.equal(expectedBalance);
});
});
});
describe('#setAllowanceAsync', () => {
- it('should set the spender\'s allowance', async () => {
+ it("should set the spender's allowance", async () => {
const token = tokens[0];
const ownerAddress = coinbase;
const spenderAddress = addressWithoutFunds;
- const allowanceBeforeSet = await zeroEx.token.getAllowanceAsync(token.address, ownerAddress,
- spenderAddress);
+ const allowanceBeforeSet = await zeroEx.token.getAllowanceAsync(
+ token.address,
+ ownerAddress,
+ spenderAddress,
+ );
const expectedAllowanceBeforeAllowanceSet = new BigNumber(0);
expect(allowanceBeforeSet).to.be.bignumber.equal(expectedAllowanceBeforeAllowanceSet);
@@ -224,7 +230,7 @@ describe('TokenWrapper', () => {
});
});
describe('#setUnlimitedAllowanceAsync', () => {
- it('should set the unlimited spender\'s allowance', async () => {
+ it("should set the unlimited spender's allowance", async () => {
const token = tokens[0];
const ownerAddress = coinbase;
const spenderAddress = addressWithoutFunds;
@@ -246,10 +252,18 @@ describe('TokenWrapper', () => {
);
await zeroEx.token.transferFromAsync(
- zrx.address, coinbase, userWithNormalAllowance, userWithNormalAllowance, transferAmount,
+ zrx.address,
+ coinbase,
+ userWithNormalAllowance,
+ userWithNormalAllowance,
+ transferAmount,
);
await zeroEx.token.transferFromAsync(
- zrx.address, coinbase, userWithUnlimitedAllowance, userWithUnlimitedAllowance, transferAmount,
+ zrx.address,
+ coinbase,
+ userWithUnlimitedAllowance,
+ userWithUnlimitedAllowance,
+ transferAmount,
);
const finalBalanceWithNormalAllowance = await web3Wrapper.getBalanceInWeiAsync(userWithNormalAllowance);
@@ -305,7 +319,9 @@ describe('TokenWrapper', () => {
await zeroEx.token.setAllowanceAsync(token.address, ownerAddress, spenderAddress, amountInBaseUnits);
const allowance = await zeroExWithoutAccounts.token.getAllowanceAsync(
- token.address, ownerAddress, spenderAddress,
+ token.address,
+ ownerAddress,
+ spenderAddress,
);
const expectedAllowance = amountInBaseUnits;
return expect(allowance).to.be.bignumber.equal(expectedAllowance);
@@ -354,7 +370,6 @@ describe('TokenWrapper', () => {
});
describe('#subscribe', () => {
const indexFilterValues = {};
- const shouldThrowOnInsufficientBalanceOrAllowance = true;
let tokenAddress: string;
const transferAmount = new BigNumber(42);
const allowanceAmount = new BigNumber(42);
@@ -372,65 +387,66 @@ describe('TokenWrapper', () => {
// Source: https://github.com/mochajs/mocha/issues/2407
it('Should receive the Transfer event when tokens are transfered', (done: DoneCallback) => {
(async () => {
- const callback = (err: Error, logEvent: DecodedLogEvent<TransferContractEventArgs>) => {
- expect(logEvent).to.not.be.undefined();
- expect(logEvent.isRemoved).to.be.false();
- expect(logEvent.log.logIndex).to.be.equal(0);
- expect(logEvent.log.transactionIndex).to.be.equal(0);
- expect(logEvent.log.blockNumber).to.be.a('number');
- const args = logEvent.log.args;
- expect(args._from).to.be.equal(coinbase);
- expect(args._to).to.be.equal(addressWithoutFunds);
- expect(args._value).to.be.bignumber.equal(transferAmount);
- done();
- };
- zeroEx.token.subscribe(
- tokenAddress, TokenEvents.Transfer, indexFilterValues, callback);
+ const callback = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<TransferContractEventArgs>) => {
+ expect(logEvent.isRemoved).to.be.false();
+ expect(logEvent.log.logIndex).to.be.equal(0);
+ expect(logEvent.log.transactionIndex).to.be.equal(0);
+ expect(logEvent.log.blockNumber).to.be.a('number');
+ const args = logEvent.log.args;
+ expect(args._from).to.be.equal(coinbase);
+ expect(args._to).to.be.equal(addressWithoutFunds);
+ expect(args._value).to.be.bignumber.equal(transferAmount);
+ },
+ );
+ zeroEx.token.subscribe(tokenAddress, TokenEvents.Transfer, indexFilterValues, callback);
await zeroEx.token.transferAsync(tokenAddress, coinbase, addressWithoutFunds, transferAmount);
})().catch(done);
});
it('Should receive the Approval event when allowance is being set', (done: DoneCallback) => {
(async () => {
- const callback = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
- expect(logEvent).to.not.be.undefined();
- expect(logEvent.isRemoved).to.be.false();
- const args = logEvent.log.args;
- expect(args._owner).to.be.equal(coinbase);
- expect(args._spender).to.be.equal(addressWithoutFunds);
- expect(args._value).to.be.bignumber.equal(allowanceAmount);
- done();
- };
- zeroEx.token.subscribe(
- tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
+ const callback = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
+ expect(logEvent).to.not.be.undefined();
+ expect(logEvent.isRemoved).to.be.false();
+ const args = logEvent.log.args;
+ expect(args._owner).to.be.equal(coinbase);
+ expect(args._spender).to.be.equal(addressWithoutFunds);
+ expect(args._value).to.be.bignumber.equal(allowanceAmount);
+ },
+ );
+ zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount);
})().catch(done);
});
it('Outstanding subscriptions are cancelled when zeroEx.setProvider called', (done: DoneCallback) => {
(async () => {
- const callbackNeverToBeCalled = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
- done(new Error('Expected this subscription to have been cancelled'));
- };
- zeroEx.token.subscribe(
- tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackNeverToBeCalled,
+ const callbackNeverToBeCalled = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
+ done(new Error('Expected this subscription to have been cancelled'));
+ },
);
- const callbackToBeCalled = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
- done();
- };
+ zeroEx.token.subscribe(tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackNeverToBeCalled);
+ const callbackToBeCalled = reportNodeCallbackErrors(done)();
const newProvider = web3Factory.getRpcProvider();
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
- zeroEx.token.subscribe(
- tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackToBeCalled,
- );
+ zeroEx.token.subscribe(tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackToBeCalled);
await zeroEx.token.transferAsync(tokenAddress, coinbase, addressWithoutFunds, transferAmount);
})().catch(done);
});
it('Should cancel subscription when unsubscribe called', (done: DoneCallback) => {
(async () => {
- const callbackNeverToBeCalled = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
- done(new Error('Expected this subscription to have been cancelled'));
- };
+ const callbackNeverToBeCalled = reportNodeCallbackErrors(done)(
+ (logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
+ done(new Error('Expected this subscription to have been cancelled'));
+ },
+ );
const subscriptionToken = zeroEx.token.subscribe(
- tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackNeverToBeCalled);
+ tokenAddress,
+ TokenEvents.Transfer,
+ indexFilterValues,
+ callbackNeverToBeCalled,
+ );
zeroEx.token.unsubscribe(subscriptionToken);
await zeroEx.token.transferAsync(tokenAddress, coinbase, addressWithoutFunds, transferAmount);
done();
@@ -440,7 +456,7 @@ describe('TokenWrapper', () => {
describe('#getLogsAsync', () => {
let tokenAddress: string;
let tokenTransferProxyAddress: string;
- const subscriptionOpts: SubscriptionOpts = {
+ const blockRange: BlockRange = {
fromBlock: 0,
toBlock: BlockParamLiteral.Latest,
};
@@ -456,7 +472,10 @@ describe('TokenWrapper', () => {
const eventName = TokenEvents.Approval;
const indexFilterValues = {};
const logs = await zeroEx.token.getLogsAsync<ApprovalContractEventArgs>(
- tokenAddress, eventName, subscriptionOpts, indexFilterValues,
+ tokenAddress,
+ eventName,
+ blockRange,
+ indexFilterValues,
);
expect(logs).to.have.length(1);
const args = logs[0].args;
@@ -471,7 +490,10 @@ describe('TokenWrapper', () => {
const differentEventName = TokenEvents.Transfer;
const indexFilterValues = {};
const logs = await zeroEx.token.getLogsAsync(
- tokenAddress, differentEventName, subscriptionOpts, indexFilterValues,
+ tokenAddress,
+ differentEventName,
+ blockRange,
+ indexFilterValues,
);
expect(logs).to.have.length(0);
});
@@ -485,7 +507,10 @@ describe('TokenWrapper', () => {
_owner: coinbase,
};
const logs = await zeroEx.token.getLogsAsync<ApprovalContractEventArgs>(
- tokenAddress, eventName, subscriptionOpts, indexFilterValues,
+ tokenAddress,
+ eventName,
+ blockRange,
+ indexFilterValues,
);
expect(logs).to.have.length(1);
const args = logs[0].args;
@@ -493,3 +518,4 @@ describe('TokenWrapper', () => {
});
});
});
+// tslint:disable:max-file-line-count
diff --git a/packages/0x.js/test/utils/blockchain_lifecycle.ts b/packages/0x.js/test/utils/blockchain_lifecycle.ts
deleted file mode 100644
index 9a44ccd6f..000000000
--- a/packages/0x.js/test/utils/blockchain_lifecycle.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import {RPC} from './rpc';
-
-export class BlockchainLifecycle {
- private rpc: RPC;
- private snapshotIdsStack: number[];
- constructor() {
- this.rpc = new RPC();
- this.snapshotIdsStack = [];
- }
- // TODO: In order to run these tests on an actual node, we should check if we are running against
- // TestRPC, if so, use snapshots, otherwise re-deploy contracts before every test
- public async startAsync(): Promise<void> {
- const snapshotId = await this.rpc.takeSnapshotAsync();
- this.snapshotIdsStack.push(snapshotId);
- }
- public async revertAsync(): Promise<void> {
- const snapshotId = this.snapshotIdsStack.pop() as number;
- const didRevert = await this.rpc.revertSnapshotAsync(snapshotId);
- if (!didRevert) {
- throw new Error(`Snapshot with id #${snapshotId} failed to revert`);
- }
- }
- public async mineABlock(): Promise<void> {
- await this.rpc.mineBlockAsync();
- }
-}
diff --git a/packages/0x.js/test/utils/constants.ts b/packages/0x.js/test/utils/constants.ts
index 75fdf49c9..a9e665c25 100644
--- a/packages/0x.js/test/utils/constants.ts
+++ b/packages/0x.js/test/utils/constants.ts
@@ -1,12 +1,11 @@
export const constants = {
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
- RPC_HOST: 'localhost',
- RPC_PORT: 8545,
+ RPC_URL: 'http://localhost:8545',
ROPSTEN_NETWORK_ID: 3,
KOVAN_NETWORK_ID: 42,
TESTRPC_NETWORK_ID: 50,
- KOVAN_RPC_URL: 'https://kovan.infura.io',
- ROPSTEN_RPC_URL: 'https://ropsten.infura.io',
+ KOVAN_RPC_URL: 'https://kovan.infura.io/',
+ ROPSTEN_RPC_URL: 'https://ropsten.infura.io/',
ZRX_DECIMALS: 18,
GAS_ESTIMATE: 500000,
};
diff --git a/packages/0x.js/test/utils/fill_scenarios.ts b/packages/0x.js/test/utils/fill_scenarios.ts
index 090493935..1a61487f4 100644
--- a/packages/0x.js/test/utils/fill_scenarios.ts
+++ b/packages/0x.js/test/utils/fill_scenarios.ts
@@ -1,116 +1,202 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import {SignedOrder, Token, ZeroEx} from '../../src';
-import {orderFactory} from '../utils/order_factory';
+import { SignedOrder, Token, ZeroEx } from '../../src';
+import { artifacts } from '../../src/artifacts';
+import { DummyTokenContract } from '../../src/contract_wrappers/generated/dummy_token';
+import { orderFactory } from '../utils/order_factory';
-import {constants} from './constants';
+import { constants } from './constants';
+
+const INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS = new BigNumber(100);
export class FillScenarios {
- private zeroEx: ZeroEx;
- private userAddresses: string[];
- private tokens: Token[];
- private coinbase: string;
- private zrxTokenAddress: string;
- private exchangeContractAddress: string;
- constructor(zeroEx: ZeroEx, userAddresses: string[],
- tokens: Token[], zrxTokenAddress: string, exchangeContractAddress: string) {
- this.zeroEx = zeroEx;
- this.userAddresses = userAddresses;
- this.tokens = tokens;
- this.coinbase = userAddresses[0];
- this.zrxTokenAddress = zrxTokenAddress;
- this.exchangeContractAddress = exchangeContractAddress;
+ private _zeroEx: ZeroEx;
+ private _userAddresses: string[];
+ private _tokens: Token[];
+ private _coinbase: string;
+ private _zrxTokenAddress: string;
+ private _exchangeContractAddress: string;
+ constructor(
+ zeroEx: ZeroEx,
+ userAddresses: string[],
+ tokens: Token[],
+ zrxTokenAddress: string,
+ exchangeContractAddress: string,
+ ) {
+ this._zeroEx = zeroEx;
+ this._userAddresses = userAddresses;
+ this._tokens = tokens;
+ this._coinbase = userAddresses[0];
+ this._zrxTokenAddress = zrxTokenAddress;
+ this._exchangeContractAddress = exchangeContractAddress;
+ }
+ public async initTokenBalancesAsync() {
+ const web3Wrapper = (this._zeroEx as any)._web3Wrapper as Web3Wrapper;
+ for (const token of this._tokens) {
+ if (token.symbol !== 'ZRX' && token.symbol !== 'WETH') {
+ const contractInstance = web3Wrapper.getContractInstance(
+ artifacts.DummyTokenArtifact.abi,
+ token.address,
+ );
+ const defaults = {};
+ const dummyToken = new DummyTokenContract(contractInstance, defaults);
+ const tokenSupply = ZeroEx.toBaseUnitAmount(INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS, token.decimals);
+ const txHash = await dummyToken.setBalance.sendTransactionAsync(this._coinbase, tokenSupply, {
+ from: this._coinbase,
+ });
+ await this._zeroEx.awaitTransactionMinedAsync(txHash);
+ }
+ }
}
- public async createFillableSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string,
- makerAddress: string, takerAddress: string,
- fillableAmount: BigNumber,
- expirationUnixTimestampSec?: BigNumber):
- Promise<SignedOrder> {
+ public async createFillableSignedOrderAsync(
+ makerTokenAddress: string,
+ takerTokenAddress: string,
+ makerAddress: string,
+ takerAddress: string,
+ fillableAmount: BigNumber,
+ expirationUnixTimestampSec?: BigNumber,
+ ): Promise<SignedOrder> {
return this.createAsymmetricFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
- fillableAmount, fillableAmount, expirationUnixTimestampSec,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ fillableAmount,
+ expirationUnixTimestampSec,
);
}
public async createFillableSignedOrderWithFeesAsync(
- makerTokenAddress: string, takerTokenAddress: string,
- makerFee: BigNumber, takerFee: BigNumber,
- makerAddress: string, takerAddress: string,
+ makerTokenAddress: string,
+ takerTokenAddress: string,
+ makerFee: BigNumber,
+ takerFee: BigNumber,
+ makerAddress: string,
+ takerAddress: string,
fillableAmount: BigNumber,
- feeRecepient: string, expirationUnixTimestampSec?: BigNumber,
+ feeRecepient: string,
+ expirationUnixTimestampSec?: BigNumber,
): Promise<SignedOrder> {
- return this.createAsymmetricFillableSignedOrderWithFeesAsync(
- makerTokenAddress, takerTokenAddress, makerFee, takerFee, makerAddress, takerAddress,
- fillableAmount, fillableAmount, feeRecepient, expirationUnixTimestampSec,
+ return this._createAsymmetricFillableSignedOrderWithFeesAsync(
+ makerTokenAddress,
+ takerTokenAddress,
+ makerFee,
+ takerFee,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ fillableAmount,
+ feeRecepient,
+ expirationUnixTimestampSec,
);
}
public async createAsymmetricFillableSignedOrderAsync(
- makerTokenAddress: string, takerTokenAddress: string, makerAddress: string, takerAddress: string,
- makerFillableAmount: BigNumber, takerFillableAmount: BigNumber,
- expirationUnixTimestampSec?: BigNumber): Promise<SignedOrder> {
+ makerTokenAddress: string,
+ takerTokenAddress: string,
+ makerAddress: string,
+ takerAddress: string,
+ makerFillableAmount: BigNumber,
+ takerFillableAmount: BigNumber,
+ expirationUnixTimestampSec?: BigNumber,
+ ): Promise<SignedOrder> {
const makerFee = new BigNumber(0);
const takerFee = new BigNumber(0);
const feeRecepient = constants.NULL_ADDRESS;
- return this.createAsymmetricFillableSignedOrderWithFeesAsync(
- makerTokenAddress, takerTokenAddress, makerFee, takerFee, makerAddress, takerAddress,
- makerFillableAmount, takerFillableAmount, feeRecepient, expirationUnixTimestampSec,
+ return this._createAsymmetricFillableSignedOrderWithFeesAsync(
+ makerTokenAddress,
+ takerTokenAddress,
+ makerFee,
+ takerFee,
+ makerAddress,
+ takerAddress,
+ makerFillableAmount,
+ takerFillableAmount,
+ feeRecepient,
+ expirationUnixTimestampSec,
);
}
- public async createPartiallyFilledSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string,
- takerAddress: string, fillableAmount: BigNumber,
- partialFillAmount: BigNumber) {
- const [makerAddress] = this.userAddresses;
+ public async createPartiallyFilledSignedOrderAsync(
+ makerTokenAddress: string,
+ takerTokenAddress: string,
+ takerAddress: string,
+ fillableAmount: BigNumber,
+ partialFillAmount: BigNumber,
+ ) {
+ const [makerAddress] = this._userAddresses;
const signedOrder = await this.createAsymmetricFillableSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
- fillableAmount, fillableAmount,
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ fillableAmount,
);
const shouldThrowOnInsufficientBalanceOrAllowance = false;
- await this.zeroEx.exchange.fillOrderAsync(
- signedOrder, partialFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
+ await this._zeroEx.exchange.fillOrderAsync(
+ signedOrder,
+ partialFillAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ takerAddress,
);
return signedOrder;
}
- private async createAsymmetricFillableSignedOrderWithFeesAsync(
- makerTokenAddress: string, takerTokenAddress: string,
- makerFee: BigNumber, takerFee: BigNumber,
- makerAddress: string, takerAddress: string,
- makerFillableAmount: BigNumber, takerFillableAmount: BigNumber,
- feeRecepient: string, expirationUnixTimestampSec?: BigNumber): Promise<SignedOrder> {
-
+ private async _createAsymmetricFillableSignedOrderWithFeesAsync(
+ makerTokenAddress: string,
+ takerTokenAddress: string,
+ makerFee: BigNumber,
+ takerFee: BigNumber,
+ makerAddress: string,
+ takerAddress: string,
+ makerFillableAmount: BigNumber,
+ takerFillableAmount: BigNumber,
+ feeRecepient: string,
+ expirationUnixTimestampSec?: BigNumber,
+ ): Promise<SignedOrder> {
await Promise.all([
- this.increaseBalanceAndAllowanceAsync(makerTokenAddress, makerAddress, makerFillableAmount),
- this.increaseBalanceAndAllowanceAsync(takerTokenAddress, takerAddress, takerFillableAmount),
+ this._increaseBalanceAndAllowanceAsync(makerTokenAddress, makerAddress, makerFillableAmount),
+ this._increaseBalanceAndAllowanceAsync(takerTokenAddress, takerAddress, takerFillableAmount),
]);
await Promise.all([
- this.increaseBalanceAndAllowanceAsync(this.zrxTokenAddress, makerAddress, makerFee),
- this.increaseBalanceAndAllowanceAsync(this.zrxTokenAddress, takerAddress, takerFee),
+ this._increaseBalanceAndAllowanceAsync(this._zrxTokenAddress, makerAddress, makerFee),
+ this._increaseBalanceAndAllowanceAsync(this._zrxTokenAddress, takerAddress, takerFee),
]);
- const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx,
- makerAddress, takerAddress, makerFee, takerFee,
- makerFillableAmount, makerTokenAddress, takerFillableAmount, takerTokenAddress,
- this.exchangeContractAddress, feeRecepient, expirationUnixTimestampSec);
+ const signedOrder = await orderFactory.createSignedOrderAsync(
+ this._zeroEx,
+ makerAddress,
+ takerAddress,
+ makerFee,
+ takerFee,
+ makerFillableAmount,
+ makerTokenAddress,
+ takerFillableAmount,
+ takerTokenAddress,
+ this._exchangeContractAddress,
+ feeRecepient,
+ expirationUnixTimestampSec,
+ );
return signedOrder;
}
- private async increaseBalanceAndAllowanceAsync(
- tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
+ private async _increaseBalanceAndAllowanceAsync(
+ tokenAddress: string,
+ address: string,
+ amount: BigNumber,
+ ): Promise<void> {
if (amount.isZero() || address === ZeroEx.NULL_ADDRESS) {
return; // noop
}
await Promise.all([
- this.increaseBalanceAsync(tokenAddress, address, amount),
- this.increaseAllowanceAsync(tokenAddress, address, amount),
+ this._increaseBalanceAsync(tokenAddress, address, amount),
+ this._increaseAllowanceAsync(tokenAddress, address, amount),
]);
}
- private async increaseBalanceAsync(
- tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
- await this.zeroEx.token.transferAsync(tokenAddress, this.coinbase, address, amount);
+ private async _increaseBalanceAsync(tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
+ await this._zeroEx.token.transferAsync(tokenAddress, this._coinbase, address, amount);
}
- private async increaseAllowanceAsync(
- tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
- const oldMakerAllowance = await this.zeroEx.token.getProxyAllowanceAsync(tokenAddress, address);
+ private async _increaseAllowanceAsync(tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
+ const oldMakerAllowance = await this._zeroEx.token.getProxyAllowanceAsync(tokenAddress, address);
const newMakerAllowance = oldMakerAllowance.plus(amount);
- await this.zeroEx.token.setProxyAllowanceAsync(
- tokenAddress, address, newMakerAllowance,
- );
+ await this._zeroEx.token.setProxyAllowanceAsync(tokenAddress, address, newMakerAllowance);
}
}
diff --git a/packages/0x.js/test/utils/order_factory.ts b/packages/0x.js/test/utils/order_factory.ts
index 41d93e340..60a7c5fb2 100644
--- a/packages/0x.js/test/utils/order_factory.ts
+++ b/packages/0x.js/test/utils/order_factory.ts
@@ -1,7 +1,7 @@
-import BigNumber from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import {SignedOrder, ZeroEx} from '../../src';
+import { SignedOrder, ZeroEx } from '../../src';
export const orderFactory = {
async createSignedOrderAsync(
@@ -16,11 +16,12 @@ export const orderFactory = {
takerTokenAddress: string,
exchangeContractAddress: string,
feeRecipient: string,
- expirationUnixTimestampSecIfExists?: BigNumber): Promise<SignedOrder> {
+ expirationUnixTimestampSecIfExists?: BigNumber,
+ ): Promise<SignedOrder> {
const defaultExpirationUnixTimestampSec = new BigNumber(2524604400); // Close to infinite
- const expirationUnixTimestampSec = _.isUndefined(expirationUnixTimestampSecIfExists) ?
- defaultExpirationUnixTimestampSec :
- expirationUnixTimestampSecIfExists;
+ const expirationUnixTimestampSec = _.isUndefined(expirationUnixTimestampSecIfExists)
+ ? defaultExpirationUnixTimestampSec
+ : expirationUnixTimestampSecIfExists;
const order = {
maker,
taker,
@@ -37,7 +38,7 @@ export const orderFactory = {
};
const orderHash = ZeroEx.getOrderHashHex(order);
const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker);
- const signedOrder: SignedOrder = _.assign(order, {ecSignature});
+ const signedOrder: SignedOrder = _.assign(order, { ecSignature });
return signedOrder;
},
};
diff --git a/packages/0x.js/test/utils/report_callback_errors.ts b/packages/0x.js/test/utils/report_callback_errors.ts
index 8a8f4d966..27c9745c9 100644
--- a/packages/0x.js/test/utils/report_callback_errors.ts
+++ b/packages/0x.js/test/utils/report_callback_errors.ts
@@ -1,10 +1,22 @@
+import * as chai from 'chai';
+import * as _ from 'lodash';
+
import { DoneCallback } from '../../src/types';
-export const reportCallbackErrors = (done: DoneCallback) => {
- return (f: (...args: any[]) => void) => {
- const wrapped = async (...args: any[]) => {
+const expect = chai.expect;
+
+export const reportNoErrorCallbackErrors = (done: DoneCallback, expectToBeCalledOnce = true) => {
+ return <T>(f?: (value: T) => void) => {
+ const wrapped = (value: T) => {
+ if (_.isUndefined(f)) {
+ done();
+ return;
+ }
try {
- f(...args);
+ f(value);
+ if (expectToBeCalledOnce) {
+ done();
+ }
} catch (err) {
done(err);
}
@@ -12,3 +24,43 @@ export const reportCallbackErrors = (done: DoneCallback) => {
return wrapped;
};
};
+
+export const reportNodeCallbackErrors = (done: DoneCallback, expectToBeCalledOnce = true) => {
+ return <T>(f?: (value: T) => void) => {
+ const wrapped = (error: Error | null, value: T | undefined) => {
+ if (!_.isNull(error)) {
+ done(error);
+ } else {
+ if (_.isUndefined(f)) {
+ done();
+ return;
+ }
+ try {
+ f(value as T);
+ if (expectToBeCalledOnce) {
+ done();
+ }
+ } catch (err) {
+ done(err);
+ }
+ }
+ };
+ return wrapped;
+ };
+};
+
+export const assertNodeCallbackError = (done: DoneCallback, errMsg: string) => {
+ const wrapped = <T>(error: Error | null, value: T | undefined) => {
+ if (_.isNull(error)) {
+ done(new Error('Expected callback to receive an error'));
+ } else {
+ try {
+ expect(error.message).to.be.equal(errMsg);
+ done();
+ } catch (err) {
+ done(err);
+ }
+ }
+ };
+ return wrapped;
+};
diff --git a/packages/0x.js/test/utils/subproviders/empty_wallet_subprovider.ts b/packages/0x.js/test/utils/subproviders/empty_wallet_subprovider.ts
index e5e279873..53f2be83d 100644
--- a/packages/0x.js/test/utils/subproviders/empty_wallet_subprovider.ts
+++ b/packages/0x.js/test/utils/subproviders/empty_wallet_subprovider.ts
@@ -1,4 +1,4 @@
-import {JSONRPCPayload} from '../../../src/types';
+import { JSONRPCPayload } from '../../../src/types';
/*
* This class implements the web3-provider-engine subprovider interface and returns
@@ -8,7 +8,7 @@ import {JSONRPCPayload} from '../../../src/types';
export class EmptyWalletSubprovider {
// This method needs to be here to satisfy the interface but linter wants it to be static.
// tslint:disable-next-line:prefer-function-over-method
- public handleRequest(payload: JSONRPCPayload, next: () => void, end: (err: Error|null, result: any) => void) {
+ public handleRequest(payload: JSONRPCPayload, next: () => void, end: (err: Error | null, result: any) => void) {
switch (payload.method) {
case 'eth_accounts':
end(null, []);
diff --git a/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts b/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts
index 059163f2e..e1113a851 100644
--- a/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts
+++ b/packages/0x.js/test/utils/subproviders/fake_gas_estimate_subprovider.ts
@@ -1,4 +1,4 @@
-import {JSONRPCPayload} from '../../../src/types';
+import { JSONRPCPayload } from '../../../src/types';
/*
* This class implements the web3-provider-engine subprovider interface and returns
@@ -9,16 +9,16 @@ import {JSONRPCPayload} from '../../../src/types';
* Source: https://github.com/MetaMask/provider-engine/blob/master/subproviders/subprovider.js
*/
export class FakeGasEstimateSubprovider {
- private constantGasAmount: number;
+ private _constantGasAmount: number;
constructor(constantGasAmount: number) {
- this.constantGasAmount = constantGasAmount;
+ this._constantGasAmount = constantGasAmount;
}
// This method needs to be here to satisfy the interface but linter wants it to be static.
// tslint:disable-next-line:prefer-function-over-method
- public handleRequest(payload: JSONRPCPayload, next: () => void, end: (err: Error|null, result: any) => void) {
+ public handleRequest(payload: JSONRPCPayload, next: () => void, end: (err: Error | null, result: any) => void) {
switch (payload.method) {
case 'eth_estimateGas':
- end(null, this.constantGasAmount);
+ end(null, this._constantGasAmount);
return;
default:
diff --git a/packages/0x.js/test/utils/token_utils.ts b/packages/0x.js/test/utils/token_utils.ts
index 9c20f52a1..d3fc22ff4 100644
--- a/packages/0x.js/test/utils/token_utils.ts
+++ b/packages/0x.js/test/utils/token_utils.ts
@@ -1,25 +1,33 @@
import * as _ from 'lodash';
-import {InternalZeroExError, Token} from '../../src/types';
+import { InternalZeroExError, Token } from '../../src/types';
const PROTOCOL_TOKEN_SYMBOL = 'ZRX';
+const WETH_TOKEN_SYMBOL = 'WETH';
export class TokenUtils {
- private tokens: Token[];
+ private _tokens: Token[];
constructor(tokens: Token[]) {
- this.tokens = tokens;
+ this._tokens = tokens;
}
public getProtocolTokenOrThrow(): Token {
- const zrxToken = _.find(this.tokens, {symbol: PROTOCOL_TOKEN_SYMBOL});
+ const zrxToken = _.find(this._tokens, { symbol: PROTOCOL_TOKEN_SYMBOL });
if (_.isUndefined(zrxToken)) {
throw new Error(InternalZeroExError.ZrxNotInTokenRegistry);
}
return zrxToken;
}
- public getNonProtocolTokens(): Token[] {
- const nonProtocolTokens = _.filter(this.tokens, token => {
- return token.symbol !== PROTOCOL_TOKEN_SYMBOL;
+ public getWethTokenOrThrow(): Token {
+ const wethToken = _.find(this._tokens, { symbol: WETH_TOKEN_SYMBOL });
+ if (_.isUndefined(wethToken)) {
+ throw new Error(InternalZeroExError.WethNotInTokenRegistry);
+ }
+ return wethToken;
+ }
+ public getDummyTokens(): Token[] {
+ const dummyTokens = _.filter(this._tokens, token => {
+ return !_.includes([PROTOCOL_TOKEN_SYMBOL, WETH_TOKEN_SYMBOL], token.symbol);
});
- return nonProtocolTokens;
+ return dummyTokens;
}
}
diff --git a/packages/0x.js/test/utils/web3_factory.ts b/packages/0x.js/test/utils/web3_factory.ts
index da4828943..26c26e03d 100644
--- a/packages/0x.js/test/utils/web3_factory.ts
+++ b/packages/0x.js/test/utils/web3_factory.ts
@@ -3,14 +3,20 @@
// we are not running in a browser env.
// Filed issue: https://github.com/ethereum/web3.js/issues/844
(global as any).XMLHttpRequest = undefined;
-import * as Web3 from 'web3';
import ProviderEngine = require('web3-provider-engine');
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
-import {EmptyWalletSubprovider} from './subproviders/empty_wallet_subprovider';
-import {FakeGasEstimateSubprovider} from './subproviders/fake_gas_estimate_subprovider';
+import { EmptyWalletSubprovider } from './subproviders/empty_wallet_subprovider';
+import { FakeGasEstimateSubprovider } from './subproviders/fake_gas_estimate_subprovider';
+
+import { constants } from './constants';
-import {constants} from './constants';
+// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang
+// because they are using the wrong XHR package.
+// importing web3 after subproviders fixes this issue
+// Filed issue: https://github.com/ethereum/web3.js/issues/844
+// tslint:disable-next-line:ordered-imports
+import * as Web3 from 'web3';
export const web3Factory = {
create(hasAddresses: boolean = true): Web3 {
@@ -21,14 +27,15 @@ export const web3Factory = {
},
getRpcProvider(hasAddresses: boolean = true): Web3.Provider {
const provider = new ProviderEngine();
- const rpcUrl = `http://${constants.RPC_HOST}:${constants.RPC_PORT}`;
if (!hasAddresses) {
provider.addProvider(new EmptyWalletSubprovider());
}
provider.addProvider(new FakeGasEstimateSubprovider(constants.GAS_ESTIMATE));
- provider.addProvider(new RpcSubprovider({
- rpcUrl,
- }));
+ provider.addProvider(
+ new RpcSubprovider({
+ rpcUrl: constants.RPC_URL,
+ }),
+ );
provider.start();
return provider;
},
diff --git a/packages/0x.js/tsconfig.json b/packages/0x.js/tsconfig.json
index a5da86b88..117f51e83 100644
--- a/packages/0x.js/tsconfig.json
+++ b/packages/0x.js/tsconfig.json
@@ -1,22 +1,16 @@
{
- "compilerOptions": {
- "module": "commonjs",
- "target": "es5",
- "lib": [ "es2015", "dom" ],
- "outDir": "lib",
- "sourceMap": true,
- "declaration": true,
- "noImplicitAny": true,
- "experimentalDecorators": true,
- "strictNullChecks": true
- },
- "include": [
- "./src/**/*",
- "./test/**/*",
- "../../node_modules/types-bn/index.d.ts",
- "../../node_modules/types-ethereumjs-util/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts",
- "../../node_modules/chai-as-promised-typescript-typings/index.d.ts"
- ]
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "lib",
+ "noImplicitThis": false
+ },
+ "include": [
+ "./src/**/*",
+ "./test/**/*",
+ "../../node_modules/types-bn/index.d.ts",
+ "../../node_modules/types-ethereumjs-util/index.d.ts",
+ "../../node_modules/web3-typescript-typings/index.d.ts",
+ "../../node_modules/chai-typescript-typings/index.d.ts",
+ "../../node_modules/chai-as-promised-typescript-typings/index.d.ts"
+ ]
}
diff --git a/packages/0x.js/tslint.json b/packages/0x.js/tslint.json
index a07795151..ffaefe83a 100644
--- a/packages/0x.js/tslint.json
+++ b/packages/0x.js/tslint.json
@@ -1,5 +1,3 @@
{
- "extends": [
- "@0xproject/tslint-config"
- ]
+ "extends": ["@0xproject/tslint-config"]
}
diff --git a/packages/0x.js/webpack.config.js b/packages/0x.js/webpack.config.js
index 61a7e4196..2c1fe81a7 100644
--- a/packages/0x.js/webpack.config.js
+++ b/packages/0x.js/webpack.config.js
@@ -7,10 +7,10 @@ const path = require('path');
const production = process.env.NODE_ENV === 'production';
let entry = {
- 'index': './src/index.ts',
+ index: './src/index.ts',
};
if (production) {
- entry = _.assign({}, entry, {'index.min': './src/index.ts'});
+ entry = _.assign({}, entry, { 'index.min': './src/index.ts' });
}
module.exports = {
diff --git a/packages/abi-gen-templates/package.json b/packages/abi-gen-templates/package.json
deleted file mode 100644
index e45da3bf1..000000000
--- a/packages/abi-gen-templates/package.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "name": "abi-gen-templates",
- "private": true,
- "version": "0.0.1",
- "description": "Handlebars templates to generate TS contract wrappers",
- "repository": {
- "type": "git",
- "url": "https://github.com/0xProject/0x.js.git"
- },
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/0x.js/issues"
- },
- "homepage": "https://github.com/0xProject/0x.js/packages/abi-gen-templates/README.md"
-}
diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md
new file mode 100644
index 000000000..fb2c6eb24
--- /dev/null
+++ b/packages/abi-gen/CHANGELOG.md
@@ -0,0 +1,7 @@
+# CHANGELOG
+
+## v0.1.0 - _January 11, 2018_
+
+* Fixed array typings with union types (#295)
+* Add event ABIs to context data passed to templates (#302)
+* Add constructor ABIs to context data passed to templates (#304)
diff --git a/packages/abi-gen/README.md b/packages/abi-gen/README.md
index 16dd9b969..1188bd437 100644
--- a/packages/abi-gen/README.md
+++ b/packages/abi-gen/README.md
@@ -5,11 +5,14 @@ It's heavily inspired by [Geth abigen](https://github.com/ethereum/go-ethereum/w
You can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions.
For an example of the generated [wrapper files](https://github.com/0xProject/0x.js/tree/development/packages/0x.js/src/contract_wrappers/generated) check out 0x.js.
-[Here](https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates) are the templates used to generate those files.
+[Here](https://github.com/0xProject/0x.js/tree/development/packages/0x.js/contract_templates) are the templates used to generate those files.
+
+## Installation
-## Instalation
`yarn add -g @0xproject/abi-gen`
+
## Usage
+
```
abi-gen
Options:
@@ -19,8 +22,10 @@ Options:
--templates Folder where to search for templates [string] [required]
--output Folder where to put the output files [string] [required]
```
+
## ABI files
-You're required to pass a [glob](https://en.wikipedia.org/wiki/Glob_(programming)) template where your abi files are located.
+
+You're required to pass a [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) template where your abi files are located.
TL;DR - here is the example from 0x.js.
`--abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry).json`
@@ -28,12 +33,18 @@ TL;DR - here is the example from 0x.js.
We could've just used `--abiGlob 'src/artifacts/*.json` but we wanted to exclude some of the abi files.
The abi file should be either a [Truffle](http://truffleframework.com/) contract artifact (a JSON object with an abi key) or a JSON abi array.
+
## How to write custom templates?
-The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates) and start adjusting them for your needs.
-We use [handlebars](handlebarsjs.com) template engine under the hood.
+
+The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x.js/tree/development/packages/0x.js/contract_templates) and start adjusting them for your needs.
+We use [handlebars](http://handlebarsjs.com/) template engine under the hood.
You need to have a master template called `contract.mustache`. it will be used to generate each contract wrapper. Although - you don't need and probably shouldn't write all your logic in a single template file. You can write [partial templates](http://handlebarsjs.com/partials.html) and as long as they are within a partials folder - they will be registered and available.
+
## Which data/context do I get in my templates?
+
For now you don't get much on top of methods abi, some useful helpers and a contract name because it was enough for our use-case, but if you need something else - create a PR.
See the [type definition](https://github.com/0xProject/0x.js/tree/development/packages/abi-gen/src/types.ts) of what we pass to the render method.
+
## Output files
+
Output files will be generated within an output folder with names converted to camel case and taken from abi file names. If you already have some files in that folder they will be overwritten.
diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json
index 9ce64f818..8d2dee18a 100644
--- a/packages/abi-gen/package.json
+++ b/packages/abi-gen/package.json
@@ -1,48 +1,48 @@
{
- "name": "abi-gen",
- "version": "0.0.1",
- "description": "Generate contract wrappers from ABI and handlebars templates",
- "main": "lib/index.js",
- "types": "lib/index.d.ts",
- "scripts": {
- "lint": "tslint --project . 'src/**/*.ts'",
- "clean": "shx rm -rf lib",
- "build": "tsc"
- },
- "bin": {
- "abi-gen": "lib/index.js"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/0xProject/0x.js.git"
- },
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/0x.js/issues"
- },
- "homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
- "dependencies": {
- "bignumber.js": "~4.1.0",
- "chalk": "^2.3.0",
- "glob": "^7.1.2",
- "handlebars": "^4.0.11",
- "lodash": "^4.17.4",
- "mkdirp": "^0.5.1",
- "to-snake-case": "^1.0.0",
- "web3": "^0.20.0",
- "yargs": "^10.0.3"
- },
- "devDependencies": {
- "@0xproject/tslint-config": "^0.2.0",
- "@types/glob": "^5.0.33",
- "@types/handlebars": "^4.0.36",
- "@types/mkdirp": "^0.5.1",
- "@types/node": "^8.0.53",
- "@types/yargs": "^8.0.2",
- "npm-run-all": "^4.1.2",
- "shx": "^0.2.2",
- "tslint": "5.8.0",
- "typescript": "~2.6.1",
- "web3-typescript-typings": "^0.7.2"
- }
+ "name": "@0xproject/abi-gen",
+ "version": "0.1.3",
+ "description": "Generate contract wrappers from ABI and handlebars templates",
+ "main": "lib/index.js",
+ "types": "lib/index.d.ts",
+ "scripts": {
+ "lint": "tslint --project . 'src/**/*.ts'",
+ "clean": "shx rm -rf lib",
+ "build": "tsc"
+ },
+ "bin": {
+ "abi-gen": "lib/index.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/0xProject/0x.js.git"
+ },
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/0x.js/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
+ "dependencies": {
+ "@0xproject/utils": "^0.2.1",
+ "chalk": "^2.3.0",
+ "glob": "^7.1.2",
+ "handlebars": "^4.0.11",
+ "lodash": "^4.17.4",
+ "mkdirp": "^0.5.1",
+ "to-snake-case": "^1.0.0",
+ "web3": "^0.20.0",
+ "yargs": "^10.0.3"
+ },
+ "devDependencies": {
+ "@0xproject/tslint-config": "^0.4.3",
+ "@types/glob": "^5.0.33",
+ "@types/handlebars": "^4.0.36",
+ "@types/mkdirp": "^0.5.1",
+ "@types/node": "^8.0.53",
+ "@types/yargs": "^10.0.0",
+ "npm-run-all": "^4.1.2",
+ "shx": "^0.2.2",
+ "tslint": "5.8.0",
+ "typescript": "~2.6.1",
+ "web3-typescript-typings": "^0.9.5"
+ }
}
diff --git a/packages/abi-gen/scripts/postpublish.js b/packages/abi-gen/scripts/postpublish.js
new file mode 100644
index 000000000..16d67e03f
--- /dev/null
+++ b/packages/abi-gen/scripts/postpublish.js
@@ -0,0 +1,15 @@
+const postpublish_utils = require('../../../scripts/postpublish_utils');
+const packageJSON = require('../package.json');
+
+const subPackageName = packageJSON.name;
+
+postpublish_utils
+ .getLatestTagAndVersionAsync(subPackageName)
+ .then(function(result) {
+ const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
+ const assets = [];
+ return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
+ })
+ .catch(function(err) {
+ throw err;
+ });
diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts
index 19d289e49..527af32b1 100644
--- a/packages/abi-gen/src/index.ts
+++ b/packages/abi-gen/src/index.ts
@@ -2,7 +2,7 @@
import chalk from 'chalk';
import * as fs from 'fs';
-import {sync as globSync} from 'glob';
+import { sync as globSync } from 'glob';
import * as Handlebars from 'handlebars';
import * as _ from 'lodash';
import * as mkdirp from 'mkdirp';
@@ -11,10 +11,12 @@ import * as yargs from 'yargs';
import toSnakeCase = require('to-snake-case');
import * as Web3 from 'web3';
-import {ContextData, ParamKind} from './types';
-import {utils} from './utils';
+import { ContextData, ParamKind } from './types';
+import { utils } from './utils';
+const ABI_TYPE_CONSTRUCTOR = 'constructor';
const ABI_TYPE_METHOD = 'function';
+const ABI_TYPE_EVENT = 'event';
const MAIN_TEMPLATE_NAME = 'contract.mustache';
const args = yargs
@@ -32,8 +34,7 @@ const args = yargs
describe: 'Folder where to put the output files',
type: 'string',
demand: true,
- })
- .argv;
+ }).argv;
function writeOutputFile(name: string, renderedTsCode: string): void {
const fileName = toSnakeCase(name);
@@ -66,14 +67,20 @@ for (const abiFileName of abiFileNames) {
const namedContent = utils.getNamedContent(abiFileName);
utils.log(`Processing: ${chalk.bold(namedContent.name)}...`);
const parsedContent = JSON.parse(namedContent.content);
- const ABI = _.isArray(parsedContent) ?
- parsedContent : // ABI file
- parsedContent.abi; // Truffle contracts file
+ const ABI = _.isArray(parsedContent)
+ ? parsedContent // ABI file
+ : parsedContent.abi; // Truffle contracts file
if (_.isUndefined(ABI)) {
utils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`);
utils.log(`Please make sure your ABI file is either an array with ABI entries or an object with the abi key`);
process.exit(1);
}
+
+ let ctor = ABI.find((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_CONSTRUCTOR) as Web3.ConstructorAbi;
+ if (_.isUndefined(ctor)) {
+ ctor = utils.getEmptyConstructor(); // The constructor exists, but it's implicit in JSON's ABI definition
+ }
+
const methodAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_METHOD) as Web3.MethodAbi[];
const methodsData = _.map(methodAbis, methodAbi => {
_.map(methodAbi.inputs, input => {
@@ -89,9 +96,14 @@ for (const abiFileName of abiFileNames) {
};
return methodData;
});
+
+ const eventAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_EVENT) as Web3.EventAbi[];
+
const contextData = {
contractName: namedContent.name,
+ ctor,
methods: methodsData,
+ events: eventAbis,
};
const renderedTsCode = template(contextData);
writeOutputFile(namedContent.name, renderedTsCode);
diff --git a/packages/abi-gen/src/types.ts b/packages/abi-gen/src/types.ts
index 1dc039c83..e82ab824b 100644
--- a/packages/abi-gen/src/types.ts
+++ b/packages/abi-gen/src/types.ts
@@ -5,6 +5,13 @@ export enum ParamKind {
Output = 'output',
}
+export enum AbiType {
+ Function = 'function',
+ Constructor = 'constructor',
+ Event = 'event',
+ Fallback = 'fallback',
+}
+
export interface Method extends Web3.MethodAbi {
singleReturnValue: boolean;
}
@@ -12,4 +19,5 @@ export interface Method extends Web3.MethodAbi {
export interface ContextData {
contractName: string;
methods: Method[];
+ events: Web3.EventAbi[];
}
diff --git a/packages/abi-gen/src/utils.ts b/packages/abi-gen/src/utils.ts
index eaf5a30cc..14255643a 100644
--- a/packages/abi-gen/src/utils.ts
+++ b/packages/abi-gen/src/utils.ts
@@ -1,8 +1,9 @@
import * as fs from 'fs';
import * as _ from 'lodash';
import * as path from 'path';
+import * as Web3 from 'web3';
-import {ParamKind} from './types';
+import { AbiType, ParamKind } from './types';
export const utils = {
solTypeToTsType(paramKind: ParamKind, solType: string): string {
@@ -10,23 +11,28 @@ export const utils = {
if (solType.match(trailingArrayRegex)) {
const arrayItemSolType = solType.replace(trailingArrayRegex, '');
const arrayItemTsType = utils.solTypeToTsType(paramKind, arrayItemSolType);
- const arrayTsType = `${arrayItemTsType}[]`;
+ const arrayTsType = utils.isUnionType(arrayItemTsType)
+ ? `Array<${arrayItemTsType}>`
+ : `${arrayItemTsType}[]`;
return arrayTsType;
} else {
const solTypeRegexToTsType = [
- {regex: '^string$', tsType: 'string'},
- {regex: '^address$', tsType: 'string'},
- {regex: '^bool$', tsType: 'boolean'},
- {regex: '^u?int\\d*$', tsType: 'BigNumber'},
- {regex: '^bytes\\d*$', tsType: 'string'},
+ { regex: '^string$', tsType: 'string' },
+ { regex: '^address$', tsType: 'string' },
+ { regex: '^bool$', tsType: 'boolean' },
+ { regex: '^u?int\\d*$', tsType: 'BigNumber' },
+ { regex: '^bytes\\d*$', tsType: 'string' },
];
if (paramKind === ParamKind.Input) {
// web3 allows to pass those an non-bignumbers and that's nice
// but it always returns stuff as BigNumbers
- solTypeRegexToTsType.unshift({regex: '^u?int(8|16|32)?$', tsType: 'number|BigNumber'});
+ solTypeRegexToTsType.unshift({
+ regex: '^u?int(8|16|32)?$',
+ tsType: 'number|BigNumber',
+ });
}
for (const regexAndTxType of solTypeRegexToTsType) {
- const {regex, tsType} = regexAndTxType;
+ const { regex, tsType } = regexAndTxType;
if (solType.match(regex)) {
return tsType;
}
@@ -34,6 +40,9 @@ export const utils = {
throw new Error(`Unknown Solidity type found: ${solType}`);
}
},
+ isUnionType(tsType: string): boolean {
+ return tsType === 'number|BigNumber';
+ },
log(...args: any[]): void {
console.log(...args); // tslint:disable-line:no-console
},
@@ -41,7 +50,7 @@ export const utils = {
const name = path.parse(filename).name;
return name;
},
- getNamedContent(filename: string): {name: string; content: string} {
+ getNamedContent(filename: string): { name: string; content: string } {
const name = utils.getPartialNameFromFileName(filename);
try {
const content = fs.readFileSync(filename).toString();
@@ -53,4 +62,12 @@ export const utils = {
throw new Error(`Failed to read ${filename}: ${err}`);
}
},
+ getEmptyConstructor(): Web3.ConstructorAbi {
+ return {
+ type: AbiType.Constructor,
+ stateMutability: 'nonpayable',
+ payable: false,
+ inputs: [],
+ };
+ },
};
diff --git a/packages/abi-gen/tsconfig.json b/packages/abi-gen/tsconfig.json
index 695f2a47e..5e0c7c6d3 100644
--- a/packages/abi-gen/tsconfig.json
+++ b/packages/abi-gen/tsconfig.json
@@ -1,17 +1,7 @@
{
- "compilerOptions": {
- "module": "commonjs",
- "target": "es5",
- "lib": ["es2015", "dom"],
- "outDir": "lib",
- "sourceMap": true,
- "declaration": true,
- "noImplicitAny": true,
- "strictNullChecks": true
- },
- "include": [
- "./src/**/*",
- "./test/**/*",
- "../../node_modules/web3-typescript-typings/index.d.ts"
- ]
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "lib"
+ },
+ "include": ["./src/**/*", "./test/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"]
}
diff --git a/packages/abi-gen/tslint.json b/packages/abi-gen/tslint.json
index a07795151..ffaefe83a 100644
--- a/packages/abi-gen/tslint.json
+++ b/packages/abi-gen/tslint.json
@@ -1,5 +1,3 @@
{
- "extends": [
- "@0xproject/tslint-config"
- ]
+ "extends": ["@0xproject/tslint-config"]
}
diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md
index fd6bec3f4..cd04130de 100644
--- a/packages/assert/CHANGELOG.md
+++ b/packages/assert/CHANGELOG.md
@@ -1,6 +1,6 @@
# CHANGELOG
-v0.0.4 - _Nov. 14, 2017_
-------------------------
+## v0.0.4 - _Nov. 14, 2017_
+
* Re-publish Assert previously published under NPM package @0xproject/0x-assert
* Added assertion isValidBaseUnitAmount which checks both that the value is a valid bigNumber and that it does not contain decimals.
diff --git a/packages/assert/README.md b/packages/assert/README.md
index b0dc9a451..59ab63e91 100644
--- a/packages/assert/README.md
+++ b/packages/assert/README.md
@@ -1,10 +1,55 @@
-assert
-------
+## @0xproject/assert
Standard type and schema assertions to be used across all 0x projects and packages
-## Install
+## Installation
```bash
-npm install @0xproject/assert --save
+yarn add @0xproject/assert
+```
+
+## Usage
+
+```typescript
+import { assert } from '@0xproject/assert';
+
+assert.isValidBaseUnitAmount('baseUnitAmount', baseUnitAmount);
+```
+
+## Contributing
+
+We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install Dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Build
+
+```bash
+yarn build
+```
+
+### Lint
+
+```bash
+yarn lint
+```
+
+### Run Tests
+
+```bash
+yarn test
```
diff --git a/packages/assert/package.json b/packages/assert/package.json
index 68d1ebb05..1c25b4e40 100644
--- a/packages/assert/package.json
+++ b/packages/assert/package.json
@@ -1,46 +1,45 @@
{
- "name": "@0xproject/assert",
- "version": "0.0.6",
- "description": "Provides a standard way of performing type and schema validation across 0x projects",
- "main": "lib/src/index.js",
- "types": "lib/src/index.d.ts",
- "scripts": {
- "build": "tsc",
- "clean": "shx rm -rf _bundles lib test_temp",
- "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
- "run_mocha": "mocha lib/test/**/*_test.js",
- "prepublishOnly": "run-p build",
- "test": "run-s clean build run_mocha",
- "test:circleci": "yarn test"
- },
- "license": "Apache-2.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/0xProject/0x.js.git"
- },
- "bugs": {
- "url": "https://github.com/0xProject/0x.js/issues"
- },
- "homepage": "https://github.com/0xProject/0x.js/packages/assert/README.md",
- "devDependencies": {
- "@0xproject/tslint-config": "^0.2.0",
- "@types/lodash": "^4.14.86",
- "@types/mocha": "^2.2.42",
- "@types/valid-url": "^1.0.2",
- "chai": "^4.0.1",
- "chai-typescript-typings": "^0.0.1",
- "dirty-chai": "^2.0.1",
- "mocha": "^4.0.1",
- "npm-run-all": "^4.1.2",
- "shx": "^0.2.2",
- "tslint": "5.8.0",
- "typescript": "~2.6.1"
- },
- "dependencies": {
- "@0xproject/json-schemas": "^0.6.9",
- "bignumber.js": "~4.1.0",
- "ethereum-address": "^0.0.4",
- "lodash": "^4.17.4",
- "valid-url": "^1.0.9"
- }
+ "name": "@0xproject/assert",
+ "version": "0.0.12",
+ "description": "Provides a standard way of performing type and schema validation across 0x projects",
+ "main": "lib/src/index.js",
+ "types": "lib/src/index.d.ts",
+ "scripts": {
+ "build": "tsc",
+ "clean": "shx rm -rf _bundles lib test_temp",
+ "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
+ "run_mocha": "mocha lib/test/**/*_test.js",
+ "prepublishOnly": "run-p build",
+ "test": "run-s clean build run_mocha",
+ "test:circleci": "yarn test"
+ },
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/0xProject/0x.js.git"
+ },
+ "bugs": {
+ "url": "https://github.com/0xProject/0x.js/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x.js/packages/assert/README.md",
+ "devDependencies": {
+ "@0xproject/tslint-config": "^0.4.3",
+ "@types/lodash": "^4.14.86",
+ "@types/mocha": "^2.2.42",
+ "@types/valid-url": "^1.0.2",
+ "chai": "^4.0.1",
+ "chai-typescript-typings": "^0.0.2",
+ "dirty-chai": "^2.0.1",
+ "mocha": "^4.0.1",
+ "npm-run-all": "^4.1.2",
+ "shx": "^0.2.2",
+ "tslint": "5.8.0",
+ "typescript": "~2.6.1"
+ },
+ "dependencies": {
+ "@0xproject/json-schemas": "^0.7.4",
+ "@0xproject/utils": "^0.2.1",
+ "lodash": "^4.17.4",
+ "valid-url": "^1.0.9"
+ }
}
diff --git a/packages/assert/scripts/postpublish.js b/packages/assert/scripts/postpublish.js
index 7fa452b08..16d67e03f 100644
--- a/packages/assert/scripts/postpublish.js
+++ b/packages/assert/scripts/postpublish.js
@@ -3,12 +3,13 @@ const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
-postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
+postpublish_utils
+ .getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
- .catch (function(err) {
+ .catch(function(err) {
throw err;
});
diff --git a/packages/assert/src/globals.d.ts b/packages/assert/src/globals.d.ts
index cc47f3113..91ed2021e 100644
--- a/packages/assert/src/globals.d.ts
+++ b/packages/assert/src/globals.d.ts
@@ -1,5 +1 @@
declare module 'dirty-chai';
-
-declare module 'ethereum-address' {
- const isAddress: (arg: any) => boolean;
-}
diff --git a/packages/assert/src/index.ts b/packages/assert/src/index.ts
index 92bcf6f03..7ad574ec7 100644
--- a/packages/assert/src/index.ts
+++ b/packages/assert/src/index.ts
@@ -1,9 +1,5 @@
-import {
- Schema,
- SchemaValidator,
-} from '@0xproject/json-schemas';
-import BigNumber from 'bignumber.js';
-import * as ethereum_address from 'ethereum-address';
+import { Schema, SchemaValidator } from '@0xproject/json-schemas';
+import { addressUtils, BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as validUrl from 'valid-url';
@@ -16,14 +12,14 @@ export const assert = {
},
isValidBaseUnitAmount(variableName: string, value: BigNumber) {
assert.isBigNumber(variableName, value);
+ const isNegative = value.lessThan(0);
+ this.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
const hasDecimals = value.decimalPlaces() !== 0;
this.assert(
- !hasDecimals, `${variableName} should be in baseUnits (no decimals), found value: ${value.toNumber()}`,
+ !hasDecimals,
+ `${variableName} should be in baseUnits (no decimals), found value: ${value.toNumber()}`,
);
},
- isUndefined(value: any, variableName?: string): void {
- this.assert(_.isUndefined(value), this.typeAssertionMessage(variableName, 'undefined', value));
- },
isString(variableName: string, value: string): void {
this.assert(_.isString(value), this.typeAssertionMessage(variableName, 'string', value));
},
@@ -31,18 +27,23 @@ export const assert = {
this.assert(_.isFunction(value), this.typeAssertionMessage(variableName, 'function', value));
},
isHexString(variableName: string, value: string): void {
- this.assert(_.isString(value) && HEX_REGEX.test(value),
- this.typeAssertionMessage(variableName, 'HexString', value));
+ this.assert(
+ _.isString(value) && HEX_REGEX.test(value),
+ this.typeAssertionMessage(variableName, 'HexString', value),
+ );
},
isETHAddressHex(variableName: string, value: string): void {
- this.assert(ethereum_address.isAddress(value), this.typeAssertionMessage(variableName, 'ETHAddressHex', value));
+ this.assert(addressUtils.isAddress(value), this.typeAssertionMessage(variableName, 'ETHAddressHex', value));
this.assert(
- ethereum_address.isAddress(value) && value.toLowerCase() === value,
+ addressUtils.isAddress(value) && value.toLowerCase() === value,
`Checksummed addresses are not supported. Convert ${variableName} to lower case before passing`,
);
},
- doesBelongToStringEnum(variableName: string, value: string,
- stringEnum: any /* There is no base type for every string enum */): void {
+ doesBelongToStringEnum(
+ variableName: string,
+ value: string,
+ stringEnum: any /* There is no base type for every string enum */,
+ ): void {
const doesBelongToStringEnum = !_.isUndefined(stringEnum[value]);
const enumValues = _.keys(stringEnum);
const enumValuesAsStrings = _.map(enumValues, enumValue => `'${enumValue}'`);
@@ -62,7 +63,7 @@ export const assert = {
this.assert(_.isBoolean(value), this.typeAssertionMessage(variableName, 'boolean', value));
},
isWeb3Provider(variableName: string, value: any): void {
- const isWeb3Provider = _.isFunction((value).send) || _.isFunction((value).sendAsync);
+ const isWeb3Provider = _.isFunction(value.send) || _.isFunction(value.sendAsync);
this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Web3.Provider', value));
},
doesConformToSchema(variableName: string, value: any, schema: Schema): void {
@@ -75,11 +76,11 @@ Validation errors: ${validationResult.errors.join(', ')}`;
this.assert(!hasValidationErrors, msg);
},
isHttpUrl(variableName: string, value: any): void {
- const isValidUrl = validUrl.isWebUri(value);
+ const isValidUrl = !_.isUndefined(validUrl.isWebUri(value));
this.assert(isValidUrl, this.typeAssertionMessage(variableName, 'http url', value));
},
isUri(variableName: string, value: any): void {
- const isValidUri = validUrl.isUri(value);
+ const isValidUri = !_.isUndefined(validUrl.isUri(value));
this.assert(isValidUri, this.typeAssertionMessage(variableName, 'uri', value));
},
assert(condition: boolean, message: string): void {
diff --git a/packages/assert/test/assert_test.ts b/packages/assert/test/assert_test.ts
index 5fa96e49a..b0fa398d6 100644
--- a/packages/assert/test/assert_test.ts
+++ b/packages/assert/test/assert_test.ts
@@ -1,10 +1,10 @@
-import {schemas} from '@0xproject/json-schemas';
-import {BigNumber} from 'bignumber.js';
+import { schemas } from '@0xproject/json-schemas';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as dirtyChai from 'dirty-chai';
import 'mocha';
-import {assert} from '../src/index';
+import { assert } from '../src/index';
chai.config.includeStack = true;
chai.use(dirtyChai);
@@ -14,75 +14,45 @@ describe('Assertions', () => {
const variableName = 'variable';
describe('#isBigNumber', () => {
it('should not throw for valid input', () => {
- const validInputs = [
- new BigNumber(23),
- new BigNumber('45'),
- ];
+ const validInputs = [new BigNumber(23), new BigNumber('45')];
validInputs.forEach(input => expect(assert.isBigNumber.bind(assert, variableName, input)).to.not.throw());
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- 'test',
- 42,
- false,
- { random: 'test' },
- undefined,
- ];
+ const invalidInputs = ['test', 42, false, { random: 'test' }, undefined];
invalidInputs.forEach(input => expect(assert.isBigNumber.bind(assert, variableName, input)).to.throw());
});
});
- describe('#isUndefined', () => {
+ describe('#isValidBaseUnitAmount', () => {
it('should not throw for valid input', () => {
- const validInputs = [
- undefined,
- ];
- validInputs.forEach(input => expect(assert.isUndefined.bind(assert, input, variableName)).to.not.throw());
+ const validInputs = [new BigNumber(23), new BigNumber('45000000')];
+ validInputs.forEach(input =>
+ expect(assert.isValidBaseUnitAmount.bind(assert, variableName, input)).to.not.throw(),
+ );
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- 'test',
- 42,
- false,
- { random: 'test' },
- ];
- invalidInputs.forEach(input => expect(assert.isUndefined.bind(assert, input, variableName)).to.throw());
+ const invalidInputs = [0, undefined, new BigNumber(3.145), 3.145, new BigNumber(-400)];
+ invalidInputs.forEach(input =>
+ expect(assert.isValidBaseUnitAmount.bind(assert, variableName, input)).to.throw(),
+ );
});
});
describe('#isString', () => {
it('should not throw for valid input', () => {
- const validInputs = [
- 'hello',
- 'goodbye',
- ];
+ const validInputs = ['hello', 'goodbye'];
validInputs.forEach(input => expect(assert.isString.bind(assert, variableName, input)).to.not.throw());
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- 42,
- false,
- { random: 'test' },
- undefined,
- new BigNumber(45),
- ];
+ const invalidInputs = [42, false, { random: 'test' }, undefined, new BigNumber(45)];
invalidInputs.forEach(input => expect(assert.isString.bind(assert, variableName, input)).to.throw());
});
});
describe('#isFunction', () => {
it('should not throw for valid input', () => {
- const validInputs = [
- BigNumber,
- assert.isString.bind(this),
- ];
+ const validInputs = [BigNumber, assert.isString];
validInputs.forEach(input => expect(assert.isFunction.bind(assert, variableName, input)).to.not.throw());
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- 42,
- false,
- { random: 'test' },
- undefined,
- new BigNumber(45),
- ];
+ const invalidInputs = [42, false, { random: 'test' }, undefined, new BigNumber(45)];
invalidInputs.forEach(input => expect(assert.isFunction.bind(assert, variableName, input)).to.throw());
});
});
@@ -127,9 +97,7 @@ describe('Assertions', () => {
'0x6FFFd0ae3f7d88c9b4925323f54c6e4b2918c5fd',
'0x6FFFd0ae3f7d88c9b4925323f54c6e4',
];
- invalidInputs.forEach(input =>
- expect(assert.isETHAddressHex.bind(assert, variableName, input)).to.throw(),
- );
+ invalidInputs.forEach(input => expect(assert.isETHAddressHex.bind(assert, variableName, input)).to.throw());
});
});
describe('#doesBelongToStringEnum', () => {
@@ -138,22 +106,13 @@ describe('Assertions', () => {
Test2 = 'Test2',
}
it('should not throw for valid input', () => {
- const validInputs = [
- TestEnums.Test1,
- TestEnums.Test2,
- ];
+ const validInputs = [TestEnums.Test1, TestEnums.Test2];
validInputs.forEach(input =>
expect(assert.doesBelongToStringEnum.bind(assert, variableName, input, TestEnums)).to.not.throw(),
);
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- 42,
- false,
- { random: 'test' },
- undefined,
- new BigNumber(45),
- ];
+ const invalidInputs = [42, false, { random: 'test' }, undefined, new BigNumber(45)];
invalidInputs.forEach(input =>
expect(assert.doesBelongToStringEnum.bind(assert, variableName, input, TestEnums)).to.throw(),
);
@@ -162,19 +121,13 @@ describe('Assertions', () => {
describe('#hasAtMostOneUniqueValue', () => {
const errorMsg = 'more than one unique value';
it('should not throw for valid input', () => {
- const validInputs = [
- ['hello'],
- ['goodbye', 'goodbye', 'goodbye'],
- ];
+ const validInputs = [['hello'], ['goodbye', 'goodbye', 'goodbye']];
validInputs.forEach(input =>
expect(assert.hasAtMostOneUniqueValue.bind(assert, input, errorMsg)).to.not.throw(),
);
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- ['hello', 'goodbye'],
- ['goodbye', 42, false, false],
- ];
+ const invalidInputs = [['hello', 'goodbye'], ['goodbye', 42, false, false]];
invalidInputs.forEach(input =>
expect(assert.hasAtMostOneUniqueValue.bind(assert, input, errorMsg)).to.throw(),
);
@@ -182,61 +135,34 @@ describe('Assertions', () => {
});
describe('#isNumber', () => {
it('should not throw for valid input', () => {
- const validInputs = [
- 42,
- 0,
- 21e+42,
- ];
+ const validInputs = [42, 0, 21e42];
validInputs.forEach(input => expect(assert.isNumber.bind(assert, variableName, input)).to.not.throw());
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- false,
- { random: 'test' },
- undefined,
- new BigNumber(45),
- ];
+ const invalidInputs = [false, { random: 'test' }, undefined, new BigNumber(45)];
invalidInputs.forEach(input => expect(assert.isNumber.bind(assert, variableName, input)).to.throw());
});
});
describe('#isBoolean', () => {
it('should not throw for valid input', () => {
- const validInputs = [
- true,
- false,
- ];
+ const validInputs = [true, false];
validInputs.forEach(input => expect(assert.isBoolean.bind(assert, variableName, input)).to.not.throw());
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- 42,
- { random: 'test' },
- undefined,
- new BigNumber(45),
- ];
+ const invalidInputs = [42, { random: 'test' }, undefined, new BigNumber(45)];
invalidInputs.forEach(input => expect(assert.isBoolean.bind(assert, variableName, input)).to.throw());
});
});
describe('#isWeb3Provider', () => {
it('should not throw for valid input', () => {
- const validInputs = [
- { send: () => 45 },
- { sendAsync: () => 45 },
- ];
+ const validInputs = [{ send: () => 45 }, { sendAsync: () => 45 }];
validInputs.forEach(input =>
expect(assert.isWeb3Provider.bind(assert, variableName, input)).to.not.throw(),
);
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- 42,
- { random: 'test' },
- undefined,
- new BigNumber(45),
- ];
- invalidInputs.forEach(input =>
- expect(assert.isWeb3Provider.bind(assert, variableName, input)).to.throw(),
- );
+ const invalidInputs = [42, { random: 'test' }, undefined, new BigNumber(45)];
+ invalidInputs.forEach(input => expect(assert.isWeb3Provider.bind(assert, variableName, input)).to.throw());
});
});
describe('#doesConformToSchema', () => {
@@ -251,12 +177,7 @@ describe('Assertions', () => {
);
});
it('should throw for invalid input', () => {
- const invalidInputs = [
- 42,
- { random: 'test' },
- undefined,
- new BigNumber(45),
- ];
+ const invalidInputs = [42, { random: 'test' }, undefined, new BigNumber(45)];
invalidInputs.forEach(input =>
expect(assert.doesConformToSchema.bind(assert, variableName, input, schema)).to.throw(),
);
@@ -270,9 +191,7 @@ describe('Assertions', () => {
'https://api.radarrelay.com/0x/v0/',
'https://zeroex.beta.radarrelay.com:8000/0x/v0/',
];
- validInputs.forEach(input =>
- expect(assert.isHttpUrl.bind(assert, variableName, input)).to.not.throw(),
- );
+ validInputs.forEach(input => expect(assert.isHttpUrl.bind(assert, variableName, input)).to.not.throw());
});
it('should throw for invalid input', () => {
const invalidInputs = [
@@ -286,9 +205,7 @@ describe('Assertions', () => {
'user:password@api.example-relayer.net',
'//api.example-relayer.net',
];
- invalidInputs.forEach(input =>
- expect(assert.isHttpUrl.bind(assert, variableName, input)).to.throw(),
- );
+ invalidInputs.forEach(input => expect(assert.isHttpUrl.bind(assert, variableName, input)).to.throw());
});
});
describe('#isUri', () => {
@@ -302,9 +219,7 @@ describe('Assertions', () => {
'wss://www.api.example-relayer.net',
'user:password@api.example-relayer.net',
];
- validInputs.forEach(input =>
- expect(assert.isUri.bind(assert, variableName, input)).to.not.throw(),
- );
+ validInputs.forEach(input => expect(assert.isUri.bind(assert, variableName, input)).to.not.throw());
});
it('should throw for invalid input', () => {
const invalidInputs = [
@@ -316,9 +231,7 @@ describe('Assertions', () => {
'api.example-relayer.net',
'//api.example-relayer.net',
];
- invalidInputs.forEach(input =>
- expect(assert.isUri.bind(assert, variableName, input)).to.throw(),
- );
+ invalidInputs.forEach(input => expect(assert.isUri.bind(assert, variableName, input)).to.throw());
});
});
describe('#assert', () => {
@@ -332,8 +245,9 @@ describe('Assertions', () => {
});
describe('#typeAssertionMessage', () => {
it('should render correct message', () => {
- expect(assert.typeAssertionMessage('variable', 'string', 'number'))
- .to.equal(`Expected variable to be of type string, encountered: number`);
+ expect(assert.typeAssertionMessage('variable', 'string', 'number')).to.equal(
+ `Expected variable to be of type string, encountered: number`,
+ );
});
});
});
diff --git a/packages/assert/tsconfig.json b/packages/assert/tsconfig.json
index 709e20154..88a467ccb 100644
--- a/packages/assert/tsconfig.json
+++ b/packages/assert/tsconfig.json
@@ -1,18 +1,7 @@
{
- "compilerOptions": {
- "module": "commonjs",
- "target": "es5",
- "lib": [ "es2017", "dom"],
- "outDir": "lib",
- "sourceMap": true,
- "declaration": true,
- "noImplicitAny": true,
- "strictNullChecks": true
- },
- "include": [
- "./src/**/*",
- "./test/**/*",
- "../../node_modules/chai-typescript-typings/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts"
- ]
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "lib"
+ },
+ "include": ["./src/**/*", "./test/**/*", "../../node_modules/chai-typescript-typings/index.d.ts"]
}
diff --git a/packages/assert/tslint.json b/packages/assert/tslint.json
index a07795151..ffaefe83a 100644
--- a/packages/assert/tslint.json
+++ b/packages/assert/tslint.json
@@ -1,5 +1,3 @@
{
- "extends": [
- "@0xproject/tslint-config"
- ]
+ "extends": ["@0xproject/tslint-config"]
}
diff --git a/packages/chai-as-promised-typescript-typings/CHANGELOG.md b/packages/chai-as-promised-typescript-typings/CHANGELOG.md
new file mode 100644
index 000000000..8c52570da
--- /dev/null
+++ b/packages/chai-as-promised-typescript-typings/CHANGELOG.md
@@ -0,0 +1,3 @@
+# CHANGELOG
+
+## v0.x.x - _TBD, 2018_
diff --git a/packages/chai-as-promised-typescript-typings/README.md b/packages/chai-as-promised-typescript-typings/README.md
new file mode 100644
index 000000000..72784ef53
--- /dev/null
+++ b/packages/chai-as-promised-typescript-typings/README.md
@@ -0,0 +1,43 @@
+## chai-as-promised-typescript-typings
+
+Fork of type definitions for chai-as-promised that includes changes made by dirty-chai
+
+## Installation
+
+```bash
+yarn add -D chai-as-promised-typescript-typings
+```
+
+## Usage
+
+Add the following line within an `include` section of your `tsconfig.json`
+
+```json
+"./node_modules/chai-as-promised-typescript-typings/index.d.ts"
+```
+
+## Contributing
+
+We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install Dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Lint
+
+```bash
+yarn lint
+```
diff --git a/packages/chai-as-promised-typescript-typings/index.d.ts b/packages/chai-as-promised-typescript-typings/index.d.ts
new file mode 100644
index 000000000..ba6dabdcc
--- /dev/null
+++ b/packages/chai-as-promised-typescript-typings/index.d.ts
@@ -0,0 +1,268 @@
+// Type definitions for chai-as-promised
+// Project: https://github.com/domenic/chai-as-promised/
+// Definitions by: jt000 <https://github.com/jt000>, Yuki Kokubun <https://github.com/Kuniwak>
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare module 'chai-as-promised' {
+ function chaiAsPromised(chai: any, utils: any): void;
+ namespace chaiAsPromised {
+
+ }
+ export = chaiAsPromised;
+}
+
+// tslint:disable:no-namespace ban-types member-ordering
+declare namespace Chai {
+ // For BDD API
+ interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
+ eventually: PromisedAssertion;
+ fulfilled: PromisedAssertion;
+ become(expected: any): PromisedAssertion;
+ rejected(): PromisedAssertion;
+ rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion;
+ notify(fn: Function): PromisedAssertion;
+ }
+
+ // Eventually does not have .then(), but PromisedAssertion have.
+ interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison {
+ // From chai-as-promised
+ become(expected: PromiseLike<any>): PromisedAssertion;
+ fulfilled: PromisedAssertion;
+ rejected: () => PromisedAssertion;
+ rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion;
+ notify(fn: Function): PromisedAssertion;
+
+ // From chai
+ not: PromisedAssertion;
+ deep: PromisedDeep;
+ all: PromisedKeyFilter;
+ a: PromisedTypeComparison;
+ an: PromisedTypeComparison;
+ include: PromisedInclude;
+ contain: PromisedInclude;
+ ok: PromisedAssertion;
+ true: () => PromisedAssertion;
+ false: () => PromisedAssertion;
+ null: PromisedAssertion;
+ undefined: PromisedAssertion;
+ exist: PromisedAssertion;
+ empty: PromisedAssertion;
+ arguments: PromisedAssertion;
+ Arguments: PromisedAssertion;
+ equal: PromisedEqual;
+ equals: PromisedEqual;
+ eq: PromisedEqual;
+ eql: PromisedEqual;
+ eqls: PromisedEqual;
+ property: PromisedProperty;
+ ownProperty: PromisedOwnProperty;
+ haveOwnProperty: PromisedOwnProperty;
+ length: PromisedLength;
+ lengthOf: PromisedLength;
+ match(regexp: RegExp | string, message?: string): PromisedAssertion;
+ string(string: string, message?: string): PromisedAssertion;
+ keys: PromisedKeys;
+ key(string: string): PromisedAssertion;
+ throw: PromisedThrow;
+ throws: PromisedThrow;
+ Throw: PromisedThrow;
+ respondTo(method: string, message?: string): PromisedAssertion;
+ itself: PromisedAssertion;
+ satisfy(matcher: Function, message?: string): PromisedAssertion;
+ closeTo(expected: number, delta: number, message?: string): PromisedAssertion;
+ members: PromisedMembers;
+ }
+
+ interface PromisedAssertion extends Eventually, PromiseLike<any> {}
+
+ interface PromisedLanguageChains {
+ eventually: Eventually;
+
+ // From chai
+ to: PromisedAssertion;
+ be: PromisedAssertion;
+ been: PromisedAssertion;
+ is: PromisedAssertion;
+ that: PromisedAssertion;
+ which: PromisedAssertion;
+ and: PromisedAssertion;
+ has: PromisedAssertion;
+ have: PromisedAssertion;
+ with: PromisedAssertion;
+ at: PromisedAssertion;
+ of: PromisedAssertion;
+ same: PromisedAssertion;
+ }
+
+ interface PromisedNumericComparison {
+ above: PromisedNumberComparer;
+ gt: PromisedNumberComparer;
+ greaterThan: PromisedNumberComparer;
+ least: PromisedNumberComparer;
+ gte: PromisedNumberComparer;
+ below: PromisedNumberComparer;
+ lt: PromisedNumberComparer;
+ lessThan: PromisedNumberComparer;
+ most: PromisedNumberComparer;
+ lte: PromisedNumberComparer;
+ within(start: number, finish: number, message?: string): PromisedAssertion;
+ }
+
+ type PromisedNumberComparer = (value: number, message?: string) => PromisedAssertion;
+
+ interface PromisedTypeComparison {
+ (type: string, message?: string): PromisedAssertion;
+ instanceof: PromisedInstanceOf;
+ instanceOf: PromisedInstanceOf;
+ }
+
+ type PromisedInstanceOf = (constructor: Object, message?: string) => PromisedAssertion;
+
+ interface PromisedDeep {
+ equal: PromisedEqual;
+ include: PromisedInclude;
+ property: PromisedProperty;
+ }
+
+ interface PromisedKeyFilter {
+ keys: PromisedKeys;
+ }
+
+ type PromisedEqual = (value: any, message?: string) => PromisedAssertion;
+
+ type PromisedProperty = (name: string, value?: any, message?: string) => PromisedAssertion;
+
+ type PromisedOwnProperty = (name: string, message?: string) => PromisedAssertion;
+
+ interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison {
+ (length: number, message?: string): PromisedAssertion;
+ }
+
+ interface PromisedInclude {
+ (value: Object | string | number, message?: string): PromisedAssertion;
+ keys: PromisedKeys;
+ members: PromisedMembers;
+ all: PromisedKeyFilter;
+ }
+
+ interface PromisedKeys {
+ (...keys: string[]): PromisedAssertion;
+ (keys: any[]): PromisedAssertion;
+ }
+
+ interface PromisedThrow {
+ (): PromisedAssertion;
+ (expected: string | RegExp, message?: string): PromisedAssertion;
+ (constructor: Error | Function, expected?: string | RegExp, message?: string): PromisedAssertion;
+ }
+
+ type PromisedMembers = (set: any[], message?: string) => PromisedAssertion;
+
+ // For Assert API
+ interface Assert {
+ eventually: PromisedAssert;
+ isFulfilled(promise: PromiseLike<any>, message?: string): PromiseLike<void>;
+ becomes(promise: PromiseLike<any>, expected: any, message?: string): PromiseLike<void>;
+ doesNotBecome(promise: PromiseLike<any>, expected: any, message?: string): PromiseLike<void>;
+ isRejected(promise: PromiseLike<any>, message?: string): PromiseLike<void>;
+ isRejected(promise: PromiseLike<any>, expected: any | RegExp, message?: string): PromiseLike<void>;
+ notify(fn: Function): PromiseLike<void>;
+ }
+
+ export interface PromisedAssert {
+ fail(actual?: any, expected?: any, msg?: string, operator?: string): PromiseLike<void>;
+
+ ok(val: any, msg?: string): PromiseLike<void>;
+ notOk(val: any, msg?: string): PromiseLike<void>;
+
+ equal(act: any, exp: any, msg?: string): PromiseLike<void>;
+ notEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
+
+ strictEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
+ notStrictEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
+
+ deepEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
+ notDeepEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
+
+ isTrue(val: any, msg?: string): PromiseLike<void>;
+ isFalse(val: any, msg?: string): PromiseLike<void>;
+
+ isNull(val: any, msg?: string): PromiseLike<void>;
+ isNotNull(val: any, msg?: string): PromiseLike<void>;
+
+ isUndefined(val: any, msg?: string): PromiseLike<void>;
+ isDefined(val: any, msg?: string): PromiseLike<void>;
+
+ isFunction(val: any, msg?: string): PromiseLike<void>;
+ isNotFunction(val: any, msg?: string): PromiseLike<void>;
+
+ isObject(val: any, msg?: string): PromiseLike<void>;
+ isNotObject(val: any, msg?: string): PromiseLike<void>;
+
+ isArray(val: any, msg?: string): PromiseLike<void>;
+ isNotArray(val: any, msg?: string): PromiseLike<void>;
+
+ isString(val: any, msg?: string): PromiseLike<void>;
+ isNotString(val: any, msg?: string): PromiseLike<void>;
+
+ isNumber(val: any, msg?: string): PromiseLike<void>;
+ isNotNumber(val: any, msg?: string): PromiseLike<void>;
+
+ isBoolean(val: any, msg?: string): PromiseLike<void>;
+ isNotBoolean(val: any, msg?: string): PromiseLike<void>;
+
+ typeOf(val: any, type: string, msg?: string): PromiseLike<void>;
+ notTypeOf(val: any, type: string, msg?: string): PromiseLike<void>;
+
+ instanceOf(val: any, type: Function, msg?: string): PromiseLike<void>;
+ notInstanceOf(val: any, type: Function, msg?: string): PromiseLike<void>;
+
+ include(exp: string | any[], inc: any, msg?: string): PromiseLike<void>;
+
+ notInclude(exp: string | any[], inc: any, msg?: string): PromiseLike<void>;
+
+ match(exp: any, re: RegExp, msg?: string): PromiseLike<void>;
+ notMatch(exp: any, re: RegExp, msg?: string): PromiseLike<void>;
+
+ property(obj: Object, prop: string, msg?: string): PromiseLike<void>;
+ notProperty(obj: Object, prop: string, msg?: string): PromiseLike<void>;
+ deepProperty(obj: Object, prop: string, msg?: string): PromiseLike<void>;
+ notDeepProperty(obj: Object, prop: string, msg?: string): PromiseLike<void>;
+
+ propertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike<void>;
+ propertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike<void>;
+
+ deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike<void>;
+ deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike<void>;
+
+ lengthOf(exp: any, len: number, msg?: string): PromiseLike<void>;
+ // alias frenzy
+ throw(fn: Function, msg?: string): PromiseLike<void>;
+ throw(fn: Function, regExp: RegExp): PromiseLike<void>;
+ throw(fn: Function, errType: Function, msg?: string): PromiseLike<void>;
+ throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike<void>;
+
+ throws(fn: Function, msg?: string): PromiseLike<void>;
+ throws(fn: Function, regExp: RegExp): PromiseLike<void>;
+ throws(fn: Function, errType: Function, msg?: string): PromiseLike<void>;
+ throws(fn: Function, errType: Function, regExp: RegExp): PromiseLike<void>;
+
+ Throw(fn: Function, msg?: string): PromiseLike<void>;
+ Throw(fn: Function, regExp: RegExp): PromiseLike<void>;
+ Throw(fn: Function, errType: Function, msg?: string): PromiseLike<void>;
+ Throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike<void>;
+
+ doesNotThrow(fn: Function, msg?: string): PromiseLike<void>;
+ doesNotThrow(fn: Function, regExp: RegExp): PromiseLike<void>;
+ doesNotThrow(fn: Function, errType: Function, msg?: string): PromiseLike<void>;
+ doesNotThrow(fn: Function, errType: Function, regExp: RegExp): PromiseLike<void>;
+
+ operator(val: any, operator: string, val2: any, msg?: string): PromiseLike<void>;
+ closeTo(act: number, exp: number, delta: number, msg?: string): PromiseLike<void>;
+
+ sameMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
+ includeMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
+
+ ifError(val: any, msg?: string): PromiseLike<void>;
+ }
+}
diff --git a/packages/chai-as-promised-typescript-typings/package.json b/packages/chai-as-promised-typescript-typings/package.json
new file mode 100644
index 000000000..34f4ed1f3
--- /dev/null
+++ b/packages/chai-as-promised-typescript-typings/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "chai-as-promised-typescript-typings",
+ "version": "0.0.5",
+ "description": "Typescript type definitions for chai-as-promised",
+ "main": "index.d.ts",
+ "types": "index.d.ts",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/0xProject/0x.js.git"
+ },
+ "author": "Fabio Berger",
+ "contributors": [
+ "Leonid Logvinov <logvinov.leon@gmail.com>"
+ ],
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/0x.js/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x.js/packages/chai-as-promised-typescript-typings#readme",
+ "dependencies": {
+ "chai-typescript-typings": "^0.0.0"
+ }
+}
diff --git a/packages/chai-as-promised-typescript-typings/scripts/postpublish.js b/packages/chai-as-promised-typescript-typings/scripts/postpublish.js
new file mode 100644
index 000000000..16d67e03f
--- /dev/null
+++ b/packages/chai-as-promised-typescript-typings/scripts/postpublish.js
@@ -0,0 +1,15 @@
+const postpublish_utils = require('../../../scripts/postpublish_utils');
+const packageJSON = require('../package.json');
+
+const subPackageName = packageJSON.name;
+
+postpublish_utils
+ .getLatestTagAndVersionAsync(subPackageName)
+ .then(function(result) {
+ const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
+ const assets = [];
+ return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
+ })
+ .catch(function(err) {
+ throw err;
+ });
diff --git a/packages/chai-as-promised-typescript-typings/tslint.json b/packages/chai-as-promised-typescript-typings/tslint.json
new file mode 100644
index 000000000..9a93a1f74
--- /dev/null
+++ b/packages/chai-as-promised-typescript-typings/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": ["tslint-config-0xproject"]
+}
diff --git a/packages/chai-typescript-typings/CHANGELOG.md b/packages/chai-typescript-typings/CHANGELOG.md
new file mode 100644
index 000000000..8c52570da
--- /dev/null
+++ b/packages/chai-typescript-typings/CHANGELOG.md
@@ -0,0 +1,3 @@
+# CHANGELOG
+
+## v0.x.x - _TBD, 2018_
diff --git a/packages/chai-typescript-typings/README.md b/packages/chai-typescript-typings/README.md
new file mode 100644
index 000000000..9bd0574d1
--- /dev/null
+++ b/packages/chai-typescript-typings/README.md
@@ -0,0 +1,43 @@
+## chai-typescript-typings
+
+Fork of type definitions for chai that includes changes made by dirty-chai
+
+## Installation
+
+```bash
+yarn add -D chai-typescript-typings
+```
+
+## Usage
+
+Add the following line within an `include` section of your `tsconfig.json`
+
+```json
+"./node_modules/chai-typescript-typings/index.d.ts"
+```
+
+## Contributing
+
+We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install Dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Lint
+
+```bash
+yarn lint
+```
diff --git a/packages/chai-typescript-typings/index.d.ts b/packages/chai-typescript-typings/index.d.ts
new file mode 100644
index 000000000..8b3e4c079
--- /dev/null
+++ b/packages/chai-typescript-typings/index.d.ts
@@ -0,0 +1,1254 @@
+// Type definitions for chai 4.0.0
+// Project: http://chaijs.com/
+// Definitions by: Jed Mao <https://github.com/jedmao/>,
+// Bart van der Schoor <https://github.com/Bartvds>,
+// Andrew Brown <https://github.com/AGBrown>,
+// Olivier Chevet <https://github.com/olivr70>,
+// Matt Wistrand <https://github.com/mwistrand>,
+// Josh Goldberg <https://github.com/joshuakgoldberg>
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+// <reference types="assertion-error"/>
+
+// tslint:disable:no-namespace member-ordering ban-types unified-signatures variable-name callable-types
+declare namespace Chai {
+ interface ChaiStatic {
+ expect: ExpectStatic;
+ should(): Should;
+ /**
+ * Provides a way to extend the internals of Chai
+ */
+ use(fn: (chai: any, utils: any) => void): ChaiStatic;
+ assert: AssertStatic;
+ config: Config;
+ AssertionError: typeof AssertionError;
+ version: string;
+ }
+
+ export interface ExpectStatic extends AssertionStatic {
+ fail(actual?: any, expected?: any, message?: string, operator?: Operator): void;
+ }
+
+ export interface AssertStatic extends Assert {}
+
+ type AssertionStatic = (target: any, message?: string) => Assertion;
+
+ export type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!==";
+
+ export type OperatorComparable = boolean | null | number | string | undefined | Date;
+
+ interface ShouldAssertion {
+ equal(value1: any, value2: any, message?: string): void;
+ Throw: ShouldThrow;
+ throw: ShouldThrow;
+ exist(value: any, message?: string): void;
+ }
+
+ interface Should extends ShouldAssertion {
+ not: ShouldAssertion;
+ fail(actual: any, expected: any, message?: string, operator?: Operator): void;
+ }
+
+ interface ShouldThrow {
+ (actual: Function): void;
+ (actual: Function, expected: string | RegExp, message?: string): void;
+ (actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void;
+ }
+
+ interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
+ not: Assertion;
+ deep: Deep;
+ nested: Nested;
+ any: KeyFilter;
+ all: KeyFilter;
+ a: TypeComparison;
+ an: TypeComparison;
+ include: Include;
+ includes: Include;
+ contain: Include;
+ contains: Include;
+ ok: Assertion;
+ true: () => Assertion;
+ false: () => Assertion;
+ null: () => Assertion;
+ undefined: () => Assertion;
+ NaN: Assertion;
+ exist: Assertion;
+ empty: Assertion;
+ arguments: Assertion;
+ Arguments: Assertion;
+ equal: Equal;
+ equals: Equal;
+ eq: Equal;
+ eql: Equal;
+ eqls: Equal;
+ property: Property;
+ ownProperty: OwnProperty;
+ haveOwnProperty: OwnProperty;
+ ownPropertyDescriptor: OwnPropertyDescriptor;
+ haveOwnPropertyDescriptor: OwnPropertyDescriptor;
+ length: Length;
+ lengthOf: Length;
+ match: Match;
+ matches: Match;
+ string(string: string, message?: string): Assertion;
+ keys: Keys;
+ key(string: string): Assertion;
+ throw: (message?: string) => Assertion;
+ throws: Throw;
+ Throw: Throw;
+ respondTo: RespondTo;
+ respondsTo: RespondTo;
+ itself: Assertion;
+ satisfy: Satisfy;
+ satisfies: Satisfy;
+ closeTo: CloseTo;
+ approximately: CloseTo;
+ members: Members;
+ increase: PropertyChange;
+ increases: PropertyChange;
+ decrease: PropertyChange;
+ decreases: PropertyChange;
+ change: PropertyChange;
+ changes: PropertyChange;
+ extensible: Assertion;
+ sealed: Assertion;
+ frozen: Assertion;
+ oneOf(list: any[], message?: string): Assertion;
+ }
+
+ interface LanguageChains {
+ to: Assertion;
+ be: Assertion;
+ been: Assertion;
+ is: Assertion;
+ that: Assertion;
+ which: Assertion;
+ and: Assertion;
+ has: Assertion;
+ have: Assertion;
+ with: Assertion;
+ at: Assertion;
+ of: Assertion;
+ same: Assertion;
+ }
+
+ interface NumericComparison {
+ above: NumberComparer;
+ gt: NumberComparer;
+ greaterThan: NumberComparer;
+ least: NumberComparer;
+ gte: NumberComparer;
+ below: NumberComparer;
+ lt: NumberComparer;
+ lessThan: NumberComparer;
+ most: NumberComparer;
+ lte: NumberComparer;
+ within(start: number, finish: number, message?: string): Assertion;
+ }
+
+ interface NumberComparer {
+ (value: number, message?: string): Assertion;
+ }
+
+ interface TypeComparison {
+ (type: string, message?: string): Assertion;
+ instanceof: InstanceOf;
+ instanceOf: InstanceOf;
+ }
+
+ interface InstanceOf {
+ (constructor: Object, message?: string): Assertion;
+ }
+
+ interface CloseTo {
+ (expected: number, delta: number, message?: string): Assertion;
+ }
+
+ interface Nested {
+ include: Include;
+ property: Property;
+ members: Members;
+ }
+
+ interface Deep {
+ equal: Equal;
+ equals: Equal;
+ eq: Equal;
+ include: Include;
+ property: Property;
+ members: Members;
+ }
+
+ interface KeyFilter {
+ keys: Keys;
+ }
+
+ interface Equal {
+ (value: any, message?: string): Assertion;
+ }
+
+ interface Property {
+ (name: string, value?: any, message?: string): Assertion;
+ }
+
+ interface OwnProperty {
+ (name: string, message?: string): Assertion;
+ }
+
+ interface OwnPropertyDescriptor {
+ (name: string, descriptor: PropertyDescriptor, message?: string): Assertion;
+ (name: string, message?: string): Assertion;
+ }
+
+ interface Length extends LanguageChains, NumericComparison {
+ (length: number, message?: string): Assertion;
+ }
+
+ interface Include {
+ (value: Object | string | number, message?: string): Assertion;
+ keys: Keys;
+ members: Members;
+ any: KeyFilter;
+ all: KeyFilter;
+ }
+
+ interface Match {
+ (regexp: RegExp | string, message?: string): Assertion;
+ }
+
+ interface Keys {
+ (...keys: string[]): Assertion;
+ (keys: any[]): Assertion;
+ (keys: Object): Assertion;
+ }
+
+ interface Throw {
+ (): Assertion;
+ (expected: string, message?: string): Assertion;
+ (expected: RegExp, message?: string): Assertion;
+ (constructor: Error, expected?: string, message?: string): Assertion;
+ (constructor: Error, expected?: RegExp, message?: string): Assertion;
+ (constructor: Function, expected?: string, message?: string): Assertion;
+ (constructor: Function, expected?: RegExp, message?: string): Assertion;
+ }
+
+ interface RespondTo {
+ (method: string, message?: string): Assertion;
+ }
+
+ interface Satisfy {
+ (matcher: Function, message?: string): Assertion;
+ }
+
+ interface Members {
+ (set: any[], message?: string): Assertion;
+ }
+
+ interface PropertyChange {
+ (object: Object, property: string, message?: string): Assertion;
+ }
+
+ export interface Assert {
+ /**
+ * @param expression Expression to test for truthiness.
+ * @param message Message to display on error.
+ */
+ (expression: any, message?: string): void;
+
+ /**
+ * Throws a failure.
+ *
+ * @type T Type of the objects.
+ * @param actual Actual value.
+ * @param expected Potential expected value.
+ * @param message Message to display on error.
+ * @param operator Comparison operator, if not strict equality.
+ * @remarks Node.js assert module-compatible.
+ */
+ fail<T>(actual?: T, expected?: T, message?: string, operator?: Operator): void;
+
+ /**
+ * Asserts that object is truthy.
+ *
+ * @type T Type of object.
+ * @param object Object to test.
+ * @param message Message to display on error.
+ */
+ isOk<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that object is truthy.
+ *
+ * @type T Type of object.
+ * @param object Object to test.
+ * @param message Message to display on error.
+ */
+ ok<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that object is falsy.
+ *
+ * @type T Type of object.
+ * @param object Object to test.
+ * @param message Message to display on error.
+ */
+ isNotOk<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that object is falsy.
+ *
+ * @type T Type of object.
+ * @param object Object to test.
+ * @param message Message to display on error.
+ */
+ notOk<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts non-strict equality (==) of actual and expected.
+ *
+ * @type T Type of the objects.
+ * @param actual Actual value.
+ * @param expected Potential expected value.
+ * @param message Message to display on error.
+ */
+ equal<T>(actual: T, expected: T, message?: string): void;
+
+ /**
+ * Asserts non-strict inequality (==) of actual and expected.
+ *
+ * @type T Type of the objects.
+ * @param actual Actual value.
+ * @param expected Potential expected value.
+ * @param message Message to display on error.
+ */
+ notEqual<T>(actual: T, expected: T, message?: string): void;
+
+ /**
+ * Asserts strict equality (===) of actual and expected.
+ *
+ * @type T Type of the objects.
+ * @param actual Actual value.
+ * @param expected Potential expected value.
+ * @param message Message to display on error.
+ */
+ strictEqual<T>(actual: T, expected: T, message?: string): void;
+
+ /**
+ * Asserts strict inequality (==) of actual and expected.
+ *
+ * @type T Type of the objects.
+ * @param actual Actual value.
+ * @param expected Potential expected value.
+ * @param message Message to display on error.
+ */
+ notStrictEqual<T>(actual: T, expected: T, message?: string): void;
+
+ /**
+ * Asserts that actual is deeply equal to expected.
+ *
+ * @type T Type of the objects.
+ * @param actual Actual value.
+ * @param expected Potential expected value.
+ * @param message Message to display on error.
+ */
+ deepEqual<T>(actual: T, expected: T, message?: string): void;
+
+ /**
+ * Asserts that actual is not deeply equal to expected.
+ *
+ * @type T Type of the objects.
+ * @param actual Actual value.
+ * @param expected Potential expected value.
+ * @param message Message to display on error.
+ */
+ notDeepEqual<T>(actual: T, expected: T, message?: string): void;
+
+ /**
+ * Asserts valueToCheck is strictly greater than (>) valueToBeAbove.
+ *
+ * @param valueToCheck Actual value.
+ * @param valueToBeAbove Minimum Potential expected value.
+ * @param message Message to display on error.
+ */
+ isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void;
+
+ /**
+ * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtLeast.
+ *
+ * @param valueToCheck Actual value.
+ * @param valueToBeAtLeast Minimum Potential expected value.
+ * @param message Message to display on error.
+ */
+ isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void;
+
+ /**
+ * Asserts valueToCheck is strictly less than (<) valueToBeBelow.
+ *
+ * @param valueToCheck Actual value.
+ * @param valueToBeBelow Minimum Potential expected value.
+ * @param message Message to display on error.
+ */
+ isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void;
+
+ /**
+ * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtMost.
+ *
+ * @param valueToCheck Actual value.
+ * @param valueToBeAtMost Minimum Potential expected value.
+ * @param message Message to display on error.
+ */
+ isAtMost(valueToCheck: number, valueToBeAtMost: number, message?: string): void;
+
+ /**
+ * Asserts that value is true.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isTrue<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is false.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isFalse<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not true.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotTrue<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not false.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotFalse<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is null.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNull<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not null.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotNull<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not null.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNaN<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not null.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotNaN<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is undefined.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isUndefined<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not undefined.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isDefined<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is a function.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isFunction<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not a function.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotFunction<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is an object of type 'Object'
+ * (as revealed by Object.prototype.toString).
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ * @remarks The assertion does not match subclassed objects.
+ */
+ isObject<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not an object of type 'Object'
+ * (as revealed by Object.prototype.toString).
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotObject<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is an array.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isArray<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not an array.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotArray<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is a string.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isString<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not a string.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotString<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is a number.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNumber<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not a number.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotNumber<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is a boolean.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isBoolean<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value is not a boolean.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param message Message to display on error.
+ */
+ isNotBoolean<T>(value: T, message?: string): void;
+
+ /**
+ * Asserts that value's type is name, as determined by Object.prototype.toString.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param name Potential expected type name of value.
+ * @param message Message to display on error.
+ */
+ typeOf<T>(value: T, name: string, message?: string): void;
+
+ /**
+ * Asserts that value's type is not name, as determined by Object.prototype.toString.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param name Potential expected type name of value.
+ * @param message Message to display on error.
+ */
+ notTypeOf<T>(value: T, name: string, message?: string): void;
+
+ /**
+ * Asserts that value is an instance of constructor.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param constructor Potential expected contructor of value.
+ * @param message Message to display on error.
+ */
+ instanceOf<T>(value: T, constructor: Function, message?: string): void;
+
+ /**
+ * Asserts that value is not an instance of constructor.
+ *
+ * @type T Type of value.
+ * @param value Actual value.
+ * @param constructor Potential expected contructor of value.
+ * @param message Message to display on error.
+ */
+ notInstanceOf<T>(value: T, type: Function, message?: string): void;
+
+ /**
+ * Asserts that haystack includes needle.
+ *
+ * @param haystack Container string.
+ * @param needle Potential expected substring of haystack.
+ * @param message Message to display on error.
+ */
+ include(haystack: string, needle: string, message?: string): void;
+
+ /**
+ * Asserts that haystack includes needle.
+ *
+ * @type T Type of values in haystack.
+ * @param haystack Container array.
+ * @param needle Potential value contained in haystack.
+ * @param message Message to display on error.
+ */
+ include<T>(haystack: T[], needle: T, message?: string): void;
+
+ /**
+ * Asserts that haystack does not include needle.
+ *
+ * @param haystack Container string.
+ * @param needle Potential expected substring of haystack.
+ * @param message Message to display on error.
+ */
+ notInclude(haystack: string, needle: any, message?: string): void;
+
+ /**
+ * Asserts that haystack does not include needle.
+ *
+ * @type T Type of values in haystack.
+ * @param haystack Container array.
+ * @param needle Potential value contained in haystack.
+ * @param message Message to display on error.
+ */
+ notInclude(haystack: any[], needle: any, message?: string): void;
+
+ /**
+ * Asserts that value matches the regular expression regexp.
+ *
+ * @param value Actual value.
+ * @param regexp Potential match of value.
+ * @param message Message to display on error.
+ */
+ match(value: string, regexp: RegExp, message?: string): void;
+
+ /**
+ * Asserts that value does not match the regular expression regexp.
+ *
+ * @param value Actual value.
+ * @param regexp Potential match of value.
+ * @param message Message to display on error.
+ */
+ notMatch(expected: any, regexp: RegExp, message?: string): void;
+
+ /**
+ * Asserts that object has a property named by property.
+ *
+ * @type T Type of object.
+ * @param object Container object.
+ * @param property Potential contained property of object.
+ * @param message Message to display on error.
+ */
+ property<T>(object: T, property: string /* keyof T */, message?: string): void;
+
+ /**
+ * Asserts that object has a property named by property.
+ *
+ * @type T Type of object.
+ * @param object Container object.
+ * @param property Potential contained property of object.
+ * @param message Message to display on error.
+ */
+ notProperty<T>(object: T, property: string /* keyof T */, message?: string): void;
+
+ /**
+ * Asserts that object has a property named by property, which can be a string
+ * using dot- and bracket-notation for deep reference.
+ *
+ * @type T Type of object.
+ * @param object Container object.
+ * @param property Potential contained property of object.
+ * @param message Message to display on error.
+ */
+ deepProperty<T>(object: T, property: string, message?: string): void;
+
+ /**
+ * Asserts that object does not have a property named by property, which can be a
+ * string using dot- and bracket-notation for deep reference.
+ *
+ * @type T Type of object.
+ * @param object Container object.
+ * @param property Potential contained property of object.
+ * @param message Message to display on error.
+ */
+ notDeepProperty<T>(object: T, property: string, message?: string): void;
+
+ /**
+ * Asserts that object has a property named by property with value given by value.
+ *
+ * @type T Type of object.
+ * @type V Type of value.
+ * @param object Container object.
+ * @param property Potential contained property of object.
+ * @param value Potential expected property value.
+ * @param message Message to display on error.
+ */
+ propertyVal<T, V>(object: T, property: string /* keyof T */, value: V, message?: string): void;
+
+ /**
+ * Asserts that object has a property named by property with value given by value.
+ *
+ * @type T Type of object.
+ * @type V Type of value.
+ * @param object Container object.
+ * @param property Potential contained property of object.
+ * @param value Potential expected property value.
+ * @param message Message to display on error.
+ */
+ propertyNotVal<T, V>(object: T, property: string /* keyof T */, value: V, message?: string): void;
+
+ /**
+ * Asserts that object has a property named by property, which can be a string
+ * using dot- and bracket-notation for deep reference.
+ *
+ * @type T Type of object.
+ * @type V Type of value.
+ * @param object Container object.
+ * @param property Potential contained property of object.
+ * @param value Potential expected property value.
+ * @param message Message to display on error.
+ */
+ deepPropertyVal<T, V>(object: T, property: string, value: V, message?: string): void;
+
+ /**
+ * Asserts that object does not have a property named by property, which can be a
+ * string using dot- and bracket-notation for deep reference.
+ *
+ * @type T Type of object.
+ * @type V Type of value.
+ * @param object Container object.
+ * @param property Potential contained property of object.
+ * @param value Potential expected property value.
+ * @param message Message to display on error.
+ */
+ deepPropertyNotVal<T, V>(object: T, property: string, value: V, message?: string): void;
+
+ /**
+ * Asserts that object has a length property with the expected value.
+ *
+ * @type T Type of object.
+ * @param object Container object.
+ * @param length Potential expected length of object.
+ * @param message Message to display on error.
+ */
+ lengthOf<T extends { readonly length?: number }>(object: T, length: number, message?: string): void;
+
+ /**
+ * Asserts that fn will throw an error.
+ *
+ * @param fn Function that may throw.
+ * @param message Message to display on error.
+ */
+ throw(fn: Function, message?: string): void;
+
+ /**
+ * Asserts that function will throw an error with message matching regexp.
+ *
+ * @param fn Function that may throw.
+ * @param regExp Potential expected message match.
+ * @param message Message to display on error.
+ */
+ throw(fn: Function, regExp: RegExp): void;
+
+ /**
+ * Asserts that function will throw an error that is an instance of constructor.
+ *
+ * @param fn Function that may throw.
+ * @param constructor Potential expected error constructor.
+ * @param message Message to display on error.
+ */
+ throw(fn: Function, constructor: Function, message?: string): void;
+
+ /**
+ * Asserts that function will throw an error that is an instance of constructor
+ * and an error with message matching regexp.
+ *
+ * @param fn Function that may throw.
+ * @param constructor Potential expected error constructor.
+ * @param message Message to display on error.
+ */
+ throw(fn: Function, constructor: Function, regExp: RegExp): void;
+
+ /**
+ * Asserts that fn will throw an error.
+ *
+ * @param fn Function that may throw.
+ * @param message Message to display on error.
+ */
+ throws(fn: Function, message?: string): void;
+
+ /**
+ * Asserts that function will throw an error with message matching regexp.
+ *
+ * @param fn Function that may throw.
+ * @param regExp Potential expected message match.
+ * @param message Message to display on error.
+ */
+ throws(fn: Function, regExp: RegExp, message?: string): void;
+
+ /**
+ * Asserts that function will throw an error that is an instance of constructor.
+ *
+ * @param fn Function that may throw.
+ * @param constructor Potential expected error constructor.
+ * @param message Message to display on error.
+ */
+ throws(fn: Function, errType: Function, message?: string): void;
+
+ /**
+ * Asserts that function will throw an error that is an instance of constructor
+ * and an error with message matching regexp.
+ *
+ * @param fn Function that may throw.
+ * @param constructor Potential expected error constructor.
+ * @param message Message to display on error.
+ */
+ throws(fn: Function, errType: Function, regExp: RegExp): void;
+
+ /**
+ * Asserts that fn will throw an error.
+ *
+ * @param fn Function that may throw.
+ * @param message Message to display on error.
+ */
+ Throw(fn: Function, message?: string): void;
+
+ /**
+ * Asserts that function will throw an error with message matching regexp.
+ *
+ * @param fn Function that may throw.
+ * @param regExp Potential expected message match.
+ * @param message Message to display on error.
+ */
+ Throw(fn: Function, regExp: RegExp): void;
+
+ /**
+ * Asserts that function will throw an error that is an instance of constructor.
+ *
+ * @param fn Function that may throw.
+ * @param constructor Potential expected error constructor.
+ * @param message Message to display on error.
+ */
+ Throw(fn: Function, errType: Function, message?: string): void;
+
+ /**
+ * Asserts that function will throw an error that is an instance of constructor
+ * and an error with message matching regexp.
+ *
+ * @param fn Function that may throw.
+ * @param constructor Potential expected error constructor.
+ * @param message Message to display on error.
+ */
+ Throw(fn: Function, errType: Function, regExp: RegExp): void;
+
+ /**
+ * Asserts that fn will not throw an error.
+ *
+ * @param fn Function that may throw.
+ * @param message Message to display on error.
+ */
+ doesNotThrow(fn: Function, message?: string): void;
+
+ /**
+ * Asserts that function will throw an error with message matching regexp.
+ *
+ * @param fn Function that may throw.
+ * @param regExp Potential expected message match.
+ * @param message Message to display on error.
+ */
+ doesNotThrow(fn: Function, regExp: RegExp): void;
+
+ /**
+ * Asserts that function will throw an error that is an instance of constructor.
+ *
+ * @param fn Function that may throw.
+ * @param constructor Potential expected error constructor.
+ * @param message Message to display on error.
+ */
+ doesNotThrow(fn: Function, errType: Function, message?: string): void;
+
+ /**
+ * Asserts that function will throw an error that is an instance of constructor
+ * and an error with message matching regexp.
+ *
+ * @param fn Function that may throw.
+ * @param constructor Potential expected error constructor.
+ * @param message Message to display on error.
+ */
+ doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
+
+ /**
+ * Compares two values using operator.
+ *
+ * @param val1 Left value during comparison.
+ * @param operator Comparison operator.
+ * @param val2 Right value during comparison.
+ * @param message Message to display on error.
+ */
+ operator(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string): void;
+
+ /**
+ * Asserts that the target is equal to expected, to within a +/- delta range.
+ *
+ * @param actual Actual value
+ * @param expected Potential expected value.
+ * @param delta Maximum differenced between values.
+ * @param message Message to display on error.
+ */
+ closeTo(actual: number, expected: number, delta: number, message?: string): void;
+
+ /**
+ * Asserts that the target is equal to expected, to within a +/- delta range.
+ *
+ * @param actual Actual value
+ * @param expected Potential expected value.
+ * @param delta Maximum differenced between values.
+ * @param message Message to display on error.
+ */
+ approximately(act: number, exp: number, delta: number, message?: string): void;
+
+ /**
+ * Asserts that set1 and set2 have the same members. Order is not take into account.
+ *
+ * @type T Type of set values.
+ * @param set1 Actual set of values.
+ * @param set2 Potential expected set of values.
+ * @param message Message to display on error.
+ */
+ sameMembers<T>(set1: T[], set2: T[], message?: string): void;
+
+ /**
+ * Asserts that set1 and set2 have the same members using deep equality checking.
+ * Order is not take into account.
+ *
+ * @type T Type of set values.
+ * @param set1 Actual set of values.
+ * @param set2 Potential expected set of values.
+ * @param message Message to display on error.
+ */
+ sameDeepMembers<T>(set1: T[], set2: T[], message?: string): void;
+
+ /**
+ * Asserts that subset is included in superset. Order is not take into account.
+ *
+ * @type T Type of set values.
+ * @param superset Actual set of values.
+ * @param subset Potential contained set of values.
+ * @param message Message to display on error.
+ */
+ includeMembers<T>(superset: T[], subset: T[], message?: string): void;
+
+ /**
+ * Asserts that subset is included in superset using deep equality checking.
+ * Order is not take into account.
+ *
+ * @type T Type of set values.
+ * @param superset Actual set of values.
+ * @param subset Potential contained set of values.
+ * @param message Message to display on error.
+ */
+ includeDeepMembers<T>(superset: T[], subset: T[], message?: string): void;
+
+ /**
+ * Asserts that non-object, non-array value inList appears in the flat array list.
+ *
+ * @type T Type of list values.
+ * @param inList Value expected to be in the list.
+ * @param list List of values.
+ * @param message Message to display on error.
+ */
+ oneOf<T>(inList: T, list: T[], message?: string): void;
+
+ /**
+ * Asserts that a function changes the value of a property.
+ *
+ * @type T Type of object.
+ * @param modifier Function to run.
+ * @param object Container object.
+ * @param property Property of object expected to be modified.
+ * @param message Message to display on error.
+ */
+ changes<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
+
+ /**
+ * Asserts that a function does not change the value of a property.
+ *
+ * @type T Type of object.
+ * @param modifier Function to run.
+ * @param object Container object.
+ * @param property Property of object expected not to be modified.
+ * @param message Message to display on error.
+ */
+ doesNotChange<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
+
+ /**
+ * Asserts that a function increases an object property.
+ *
+ * @type T Type of object.
+ * @param modifier Function to run.
+ * @param object Container object.
+ * @param property Property of object expected to be increased.
+ * @param message Message to display on error.
+ */
+ increases<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
+
+ /**
+ * Asserts that a function does not increase an object property.
+ *
+ * @type T Type of object.
+ * @param modifier Function to run.
+ * @param object Container object.
+ * @param property Property of object expected not to be increased.
+ * @param message Message to display on error.
+ */
+ doesNotIncrease<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
+
+ /**
+ * Asserts that a function decreases an object property.
+ *
+ * @type T Type of object.
+ * @param modifier Function to run.
+ * @param object Container object.
+ * @param property Property of object expected to be decreased.
+ * @param message Message to display on error.
+ */
+ decreases<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
+
+ /**
+ * Asserts that a function does not decrease an object property.
+ *
+ * @type T Type of object.
+ * @param modifier Function to run.
+ * @param object Container object.
+ * @param property Property of object expected not to be decreased.
+ * @param message Message to display on error.
+ */
+ doesNotDecrease<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
+
+ /**
+ * Asserts if value is not a false value, and throws if it is a true value.
+ *
+ * @type T Type of object.
+ * @param object Actual value.
+ * @param message Message to display on error.
+ * @remarks This is added to allow for chai to be a drop-in replacement for
+ * Node’s assert class.
+ */
+ ifError<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is extensible (can have new properties added to it).
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ isExtensible<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is extensible (can have new properties added to it).
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ extensible<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is not extensible.
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ isNotExtensible<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is not extensible.
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ notExtensible<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is sealed (can have new properties added to it
+ * and its existing properties cannot be removed).
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ isSealed<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is sealed (can have new properties added to it
+ * and its existing properties cannot be removed).
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ sealed<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is not sealed.
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ isNotSealed<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is not sealed.
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ notSealed<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is frozen (cannot have new properties added to it
+ * and its existing properties cannot be removed).
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ isFrozen<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is frozen (cannot have new properties added to it
+ * and its existing properties cannot be removed).
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ frozen<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is not frozen (cannot have new properties added to it
+ * and its existing properties cannot be removed).
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ isNotFrozen<T>(object: T, message?: string): void;
+
+ /**
+ * Asserts that object is not frozen (cannot have new properties added to it
+ * and its existing properties cannot be removed).
+ *
+ * @type T Type of object
+ * @param object Actual value.
+ * @param message Message to display on error.
+ */
+ notFrozen<T>(object: T, message?: string): void;
+ }
+
+ export interface Config {
+ /**
+ * Default: false
+ */
+ includeStack: boolean;
+
+ /**
+ * Default: true
+ */
+ showDiff: boolean;
+
+ /**
+ * Default: 40
+ */
+ truncateThreshold: number;
+ }
+
+ export class AssertionError {
+ constructor(message: string, _props?: any, ssf?: Function);
+ public name: string;
+ public message: string;
+ public showDiff: boolean;
+ public stack: string;
+ }
+}
+
+declare const chai: Chai.ChaiStatic;
+
+declare module 'chai' {
+ export = chai;
+}
+
+interface Object {
+ should: Chai.Assertion;
+}
diff --git a/packages/chai-typescript-typings/package.json b/packages/chai-typescript-typings/package.json
new file mode 100644
index 000000000..db7cba863
--- /dev/null
+++ b/packages/chai-typescript-typings/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "chai-typescript-typings",
+ "version": "0.0.2",
+ "description": "Typescript type definitions for chai",
+ "main": "index.d.ts",
+ "types": "index.d.ts",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/0xProject/0x.js.git"
+ },
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/0x.js/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x.js/packages/chai-typescript-typings#readme"
+}
diff --git a/packages/chai-typescript-typings/scripts/postpublish.js b/packages/chai-typescript-typings/scripts/postpublish.js
new file mode 100644
index 000000000..16d67e03f
--- /dev/null
+++ b/packages/chai-typescript-typings/scripts/postpublish.js
@@ -0,0 +1,15 @@
+const postpublish_utils = require('../../../scripts/postpublish_utils');
+const packageJSON = require('../package.json');
+
+const subPackageName = packageJSON.name;
+
+postpublish_utils
+ .getLatestTagAndVersionAsync(subPackageName)
+ .then(function(result) {
+ const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
+ const assets = [];
+ return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
+ })
+ .catch(function(err) {
+ throw err;
+ });
diff --git a/packages/chai-typescript-typings/tslint.json b/packages/chai-typescript-typings/tslint.json
new file mode 100644
index 000000000..9a93a1f74
--- /dev/null
+++ b/packages/chai-typescript-typings/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": ["tslint-config-0xproject"]
+}
diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md
index cf507dbe6..e02020204 100644
--- a/packages/connect/CHANGELOG.md
+++ b/packages/connect/CHANGELOG.md
@@ -1,16 +1,26 @@
# CHANGELOG
-vx.x.x
-------------------------
+## v0.5.0 - _January 17, 2018_
+
+ * Sanitize api endpoint url and remove trailing slashes (#318)
+ * Improve error message text in HttpClient (#318)
+ * Stop appending '/v0' to api endpoint url in HttpClient (#318)
+
+## v0.4.0 - _January 11, 2018_
+
+ * Prevent getFeesAsync method on HttpClient from mutating input (#296)
+
+## v0.3.0 - _December 8, 2017_
+
* Expose WebSocketOrderbookChannel and associated types to public interface (#251)
* Remove tokenA and tokenB fields from OrdersRequest (#256)
-v0.2.0 - _November 29, 2017_
-------------------------
+## v0.2.0 - _November 29, 2017_
+
* Add SignedOrder and TokenTradeInfo to the public interface
* Add ECSignature and Order to the public interface
* Remove dependency on 0x.js
-v0.1.0 - _November 22, 2017_
-------------------------
+## v0.1.0 - _November 22, 2017_
+
* Provide a HttpClient class for interacting with standard relayer api compliant HTTP urls
diff --git a/packages/connect/README.md b/packages/connect/README.md
index 900045526..63faf5271 100644
--- a/packages/connect/README.md
+++ b/packages/connect/README.md
@@ -1 +1,52 @@
+## @0xproject/connect
+
This repository contains a Javascript library that makes it easy to interact with Relayers that conform to the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api)
+
+## Installation
+
+```bash
+yarn add @0xproject/connect
+```
+
+## Usage
+
+* [Docs](https://0xproject.com/docs/connect)
+* [Tutorials](https://0xproject.com/wiki#connect)
+
+## Contributing
+
+We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install Dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Build
+
+```bash
+yarn build
+```
+
+### Lint
+
+```bash
+yarn lint
+```
+
+### Run Tests
+
+```bash
+yarn test
+```
diff --git a/packages/connect/package.json b/packages/connect/package.json
index 2392d9907..a28916903 100644
--- a/packages/connect/package.json
+++ b/packages/connect/package.json
@@ -1,69 +1,69 @@
{
- "name": "@0xproject/connect",
- "version": "0.2.0",
- "description": "A javascript library for interacting with the standard relayer api",
- "keywords": [
- "connect",
- "0xproject",
- "ethereum",
- "tokens",
- "exchange"
- ],
- "main": "lib/src/index.js",
- "types": "lib/src/index.d.ts",
- "scripts": {
- "build": "tsc",
- "clean": "shx rm -rf _bundles lib test_temp",
- "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_DIR",
- "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
- "copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
- "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
- "run_mocha": "mocha lib/test/**/*_test.js",
- "test": "run-s clean build copy_test_fixtures run_mocha",
- "test:circleci": "yarn test"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/0xProject/0x.js.git"
- },
- "author": "Brandon Millman",
- "license": "Apache-2.0",
- "engines": {
- "node": ">=6.0.0"
- },
- "bugs": {
- "url": "https://github.com/0xProject/0x.js/issues"
- },
- "homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md",
- "dependencies": {
- "@0xproject/assert": "^0.0.6",
- "@0xproject/json-schemas": "^0.6.9",
- "bignumber.js": "~4.1.0",
- "isomorphic-fetch": "^2.2.1",
- "lodash": "^4.17.4",
- "query-string": "^5.0.1",
- "websocket": "^1.0.25"
- },
- "devDependencies": {
- "@0xproject/tslint-config": "^0.2.0",
- "@types/fetch-mock": "^5.12.1",
- "@types/lodash": "^4.14.86",
- "@types/mocha": "^2.2.42",
- "@types/query-string": "^5.0.1",
- "@types/websocket": "^0.0.34",
- "chai": "^4.0.1",
- "chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.3",
- "chai-typescript-typings": "^0.0.1",
- "copyfiles": "^1.2.0",
- "dirty-chai": "^2.0.1",
- "fetch-mock": "^5.13.1",
- "mocha": "^4.0.1",
- "npm-run-all": "^4.1.2",
- "shx": "^0.2.2",
- "tslint": "5.8.0",
- "typedoc": "~0.8.0",
- "typescript": "~2.6.1",
- "web3-typescript-typings": "^0.7.2"
- }
+ "name": "@0xproject/connect",
+ "version": "0.5.1",
+ "description": "A javascript library for interacting with the standard relayer api",
+ "keywords": [
+ "connect",
+ "0xproject",
+ "ethereum",
+ "tokens",
+ "exchange"
+ ],
+ "main": "lib/src/index.js",
+ "types": "lib/src/index.d.ts",
+ "scripts": {
+ "build": "tsc",
+ "clean": "shx rm -rf _bundles lib test_temp",
+ "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_DIR",
+ "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
+ "copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
+ "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
+ "run_mocha": "mocha lib/test/**/*_test.js",
+ "test": "run-s clean build copy_test_fixtures run_mocha",
+ "test:circleci": "yarn test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/0xProject/0x.js.git"
+ },
+ "author": "Brandon Millman",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=6.0.0"
+ },
+ "bugs": {
+ "url": "https://github.com/0xProject/0x.js/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md",
+ "dependencies": {
+ "@0xproject/assert": "^0.0.12",
+ "@0xproject/json-schemas": "^0.7.4",
+ "@0xproject/utils": "^0.2.1",
+ "isomorphic-fetch": "^2.2.1",
+ "lodash": "^4.17.4",
+ "query-string": "^5.0.1",
+ "websocket": "^1.0.25"
+ },
+ "devDependencies": {
+ "@0xproject/tslint-config": "^0.4.3",
+ "@types/fetch-mock": "^5.12.1",
+ "@types/lodash": "^4.14.86",
+ "@types/mocha": "^2.2.42",
+ "@types/query-string": "^5.0.1",
+ "@types/websocket": "^0.0.34",
+ "chai": "^4.0.1",
+ "chai-as-promised": "^7.1.0",
+ "chai-as-promised-typescript-typings": "^0.0.5",
+ "chai-typescript-typings": "^0.0.2",
+ "copyfiles": "^1.2.0",
+ "dirty-chai": "^2.0.1",
+ "fetch-mock": "^5.13.1",
+ "mocha": "^4.0.1",
+ "npm-run-all": "^4.1.2",
+ "shx": "^0.2.2",
+ "tslint": "5.8.0",
+ "typedoc": "~0.8.0",
+ "typescript": "~2.6.1",
+ "web3-typescript-typings": "^0.9.5"
+ }
}
diff --git a/packages/connect/scripts/postpublish.js b/packages/connect/scripts/postpublish.js
index e6a2cc065..24384b228 100644
--- a/packages/connect/scripts/postpublish.js
+++ b/packages/connect/scripts/postpublish.js
@@ -8,22 +8,20 @@ const S3BucketPath = 's3://connect-docs-jsons/';
let tag;
let version;
-postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
+postpublish_utils
+ .getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
tag = result.tag;
version = result.version;
- const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
- return postpublish_utils.publishReleaseNotes(tag, releaseName);
+ const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
+ return postpublish_utils.publishReleaseNotes(tag, releaseName);
})
.then(function(release) {
console.log('POSTPUBLISH: Release successful, generating docs...');
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
- return execAsync(
- 'JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json',
- {
- cwd,
- }
- );
+ return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json', {
+ cwd,
+ });
})
.then(function(result) {
if (result.stderr !== '') {
@@ -35,6 +33,7 @@ postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
cwd,
});
- }).catch (function(err) {
+ })
+ .catch(function(err) {
throw err;
});
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts
index 252c9e9dd..3df77b0f0 100644
--- a/packages/connect/src/http_client.ts
+++ b/packages/connect/src/http_client.ts
@@ -1,11 +1,10 @@
-import {assert} from '@0xproject/assert';
-import {schemas} from '@0xproject/json-schemas';
-import {BigNumber} from 'bignumber.js';
+import { assert } from '@0xproject/assert';
+import { schemas } from '@0xproject/json-schemas';
import 'isomorphic-fetch';
import * as _ from 'lodash';
import * as queryString from 'query-string';
-import {schemas as clientSchemas} from './schemas/schemas';
+import { schemas as clientSchemas } from './schemas/schemas';
import {
Client,
FeesRequest,
@@ -19,19 +18,15 @@ import {
TokenPairsItem,
TokenPairsRequest,
} from './types';
-import {typeConverters} from './utils/type_converters';
-
-// TODO: move this and bigNumberConfigs in the 0x.js package into one place
-BigNumber.config({
- EXPONENTIAL_AT: 1000,
-});
+import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
+const TRAILING_SLASHES_REGEX = /\/+$/;
/**
* This class includes all the functionality related to interacting with a set of HTTP endpoints
* that implement the standard relayer API v0
*/
export class HttpClient implements Client {
- private apiEndpointUrl: string;
+ private _apiEndpointUrl: string;
/**
* Instantiates a new HttpClient instance
* @param url The relayer API base HTTP url you would like to interact with
@@ -39,7 +34,7 @@ export class HttpClient implements Client {
*/
constructor(url: string) {
assert.isHttpUrl('url', url);
- this.apiEndpointUrl = url;
+ this._apiEndpointUrl = url.replace(TRAILING_SLASHES_REGEX, ''); // remove trailing slashes
}
/**
* Retrieve token pair info from the API
@@ -54,17 +49,8 @@ export class HttpClient implements Client {
const requestOpts = {
params: request,
};
- const tokenPairs = await this._requestAsync('/token_pairs', HttpRequestType.Get, requestOpts);
- assert.doesConformToSchema(
- 'tokenPairs', tokenPairs, schemas.relayerApiTokenPairsResponseSchema);
- _.each(tokenPairs, (tokenPair: object) => {
- typeConverters.convertStringsFieldsToBigNumbers(tokenPair, [
- 'tokenA.minAmount',
- 'tokenA.maxAmount',
- 'tokenB.minAmount',
- 'tokenB.maxAmount',
- ]);
- });
+ const responseJson = await this._requestAsync('/token_pairs', HttpRequestType.Get, requestOpts);
+ const tokenPairs = relayerResponseJsonParsers.parseTokenPairsJson(responseJson);
return tokenPairs;
}
/**
@@ -79,9 +65,8 @@ export class HttpClient implements Client {
const requestOpts = {
params: request,
};
- const orders = await this._requestAsync(`/orders`, HttpRequestType.Get, requestOpts);
- assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema);
- _.each(orders, (order: object) => typeConverters.convertOrderStringFieldsToBigNumber(order));
+ const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, requestOpts);
+ const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson);
return orders;
}
/**
@@ -91,9 +76,8 @@ export class HttpClient implements Client {
*/
public async getOrderAsync(orderHash: string): Promise<SignedOrder> {
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
- const order = await this._requestAsync(`/order/${orderHash}`, HttpRequestType.Get);
- assert.doesConformToSchema('order', order, schemas.signedOrderSchema);
- typeConverters.convertOrderStringFieldsToBigNumber(order);
+ const responseJson = await this._requestAsync(`/order/${orderHash}`, HttpRequestType.Get);
+ const order = relayerResponseJsonParsers.parseOrderJson(responseJson);
return order;
}
/**
@@ -106,10 +90,9 @@ export class HttpClient implements Client {
const requestOpts = {
params: request,
};
- const orderBook = await this._requestAsync('/orderbook', HttpRequestType.Get, requestOpts);
- assert.doesConformToSchema('orderBook', orderBook, schemas.relayerApiOrderBookResponseSchema);
- typeConverters.convertOrderbookStringFieldsToBigNumber(orderBook);
- return orderBook;
+ const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, requestOpts);
+ const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson);
+ return orderbook;
}
/**
* Retrieve fee information from the API
@@ -118,18 +101,11 @@ export class HttpClient implements Client {
*/
public async getFeesAsync(request: FeesRequest): Promise<FeesResponse> {
assert.doesConformToSchema('request', request, schemas.relayerApiFeesPayloadSchema);
- typeConverters.convertBigNumberFieldsToStrings(request, [
- 'makerTokenAmount',
- 'takerTokenAmount',
- 'expirationUnixTimestampSec',
- 'salt',
- ]);
const requestOpts = {
payload: request,
};
- const fees = await this._requestAsync('/fees', HttpRequestType.Post, requestOpts);
- assert.doesConformToSchema('fees', fees, schemas.relayerApiFeesResponseSchema);
- typeConverters.convertStringsFieldsToBigNumbers(fees, ['makerFee', 'takerFee']);
+ const responseJson = await this._requestAsync('/fees', HttpRequestType.Post, requestOpts);
+ const fees = relayerResponseJsonParsers.parseFeesResponseJson(responseJson);
return fees;
}
/**
@@ -143,8 +119,11 @@ export class HttpClient implements Client {
};
await this._requestAsync('/order', HttpRequestType.Post, requestOpts);
}
- private async _requestAsync(path: string, requestType: HttpRequestType,
- requestOptions?: HttpRequestOptions): Promise<any> {
+ private async _requestAsync(
+ path: string,
+ requestType: HttpRequestType,
+ requestOptions?: HttpRequestOptions,
+ ): Promise<any> {
const params = _.get(requestOptions, 'params');
const payload = _.get(requestOptions, 'payload');
let query = '';
@@ -152,20 +131,22 @@ export class HttpClient implements Client {
const stringifiedParams = queryString.stringify(params);
query = `?${stringifiedParams}`;
}
- const url = `${this.apiEndpointUrl}/v0${path}${query}`;
+ const url = `${this._apiEndpointUrl}${path}${query}`;
const headers = new Headers({
'content-type': 'application/json',
});
-
const response = await fetch(url, {
method: requestType,
body: JSON.stringify(payload),
headers,
});
+ const json = await response.json();
if (!response.ok) {
- throw Error(response.statusText);
+ const errorString = `${response.status} - ${response.statusText}\n${requestType} ${url}\n${JSON.stringify(
+ json,
+ )}`;
+ throw Error(errorString);
}
- const json = await response.json();
return json;
}
}
diff --git a/packages/connect/src/index.ts b/packages/connect/src/index.ts
index ec369a606..a492f5ae9 100644
--- a/packages/connect/src/index.ts
+++ b/packages/connect/src/index.ts
@@ -1,5 +1,5 @@
-export {HttpClient} from './http_client';
-export {WebSocketOrderbookChannel} from './ws_orderbook_channel';
+export { HttpClient } from './http_client';
+export { WebSocketOrderbookChannel } from './ws_orderbook_channel';
export {
Client,
ECSignature,
diff --git a/packages/connect/src/schemas/relayer_fees_request_schema.ts b/packages/connect/src/schemas/relayer_fees_request_schema.ts
index 9408c94a0..f20e077ba 100644
--- a/packages/connect/src/schemas/relayer_fees_request_schema.ts
+++ b/packages/connect/src/schemas/relayer_fees_request_schema.ts
@@ -2,7 +2,7 @@ export const relayerOrderBookRequestSchema = {
id: '/RelayerOrderBookRequest',
type: 'object',
properties: {
- baseTokenAddress: {$ref: '/Address'},
- quoteTokenAddress: {$ref: '/Address'},
+ baseTokenAddress: { $ref: '/Address' },
+ quoteTokenAddress: { $ref: '/Address' },
},
};
diff --git a/packages/connect/src/schemas/relayer_orderbook_request_schema.ts b/packages/connect/src/schemas/relayer_orderbook_request_schema.ts
index 9408c94a0..f20e077ba 100644
--- a/packages/connect/src/schemas/relayer_orderbook_request_schema.ts
+++ b/packages/connect/src/schemas/relayer_orderbook_request_schema.ts
@@ -2,7 +2,7 @@ export const relayerOrderBookRequestSchema = {
id: '/RelayerOrderBookRequest',
type: 'object',
properties: {
- baseTokenAddress: {$ref: '/Address'},
- quoteTokenAddress: {$ref: '/Address'},
+ baseTokenAddress: { $ref: '/Address' },
+ quoteTokenAddress: { $ref: '/Address' },
},
};
diff --git a/packages/connect/src/schemas/relayer_orders_request_schema.ts b/packages/connect/src/schemas/relayer_orders_request_schema.ts
index c11bc77be..570238dae 100644
--- a/packages/connect/src/schemas/relayer_orders_request_schema.ts
+++ b/packages/connect/src/schemas/relayer_orders_request_schema.ts
@@ -2,15 +2,15 @@ export const relayerOrdersRequestSchema = {
id: '/RelayerOrdersRequest',
type: 'object',
properties: {
- exchangeContractAddress: {$ref: '/Address'},
- tokenAddress: {$ref: '/Address'},
- makerTokenAddress: {$ref: '/Address'},
- takerTokenAddress: {$ref: '/Address'},
- tokenA: {$ref: '/Address'},
- tokenB: {$ref: '/Address'},
- maker: {$ref: '/Address'},
- taker: {$ref: '/Address'},
- trader: {$ref: '/Address'},
- feeRecipient: {$ref: '/Address'},
+ exchangeContractAddress: { $ref: '/Address' },
+ tokenAddress: { $ref: '/Address' },
+ makerTokenAddress: { $ref: '/Address' },
+ takerTokenAddress: { $ref: '/Address' },
+ tokenA: { $ref: '/Address' },
+ tokenB: { $ref: '/Address' },
+ maker: { $ref: '/Address' },
+ taker: { $ref: '/Address' },
+ trader: { $ref: '/Address' },
+ feeRecipient: { $ref: '/Address' },
},
};
diff --git a/packages/connect/src/schemas/relayer_token_pairs_request_schema.ts b/packages/connect/src/schemas/relayer_token_pairs_request_schema.ts
index 8013e1454..379232204 100644
--- a/packages/connect/src/schemas/relayer_token_pairs_request_schema.ts
+++ b/packages/connect/src/schemas/relayer_token_pairs_request_schema.ts
@@ -2,7 +2,7 @@ export const relayerTokenPairsRequestSchema = {
id: '/RelayerTokenPairsRequest',
type: 'object',
properties: {
- tokenA: {$ref: '/Address'},
- tokenB: {$ref: '/Address'},
+ tokenA: { $ref: '/Address' },
+ tokenB: { $ref: '/Address' },
},
};
diff --git a/packages/connect/src/schemas/schemas.ts b/packages/connect/src/schemas/schemas.ts
index 97ac672bf..288d6969d 100644
--- a/packages/connect/src/schemas/schemas.ts
+++ b/packages/connect/src/schemas/schemas.ts
@@ -1,12 +1,6 @@
-import {
- relayerOrderBookRequestSchema,
-} from './relayer_orderbook_request_schema';
-import {
- relayerOrdersRequestSchema,
-} from './relayer_orders_request_schema';
-import {
- relayerTokenPairsRequestSchema,
-} from './relayer_token_pairs_request_schema';
+import { relayerOrderBookRequestSchema } from './relayer_orderbook_request_schema';
+import { relayerOrdersRequestSchema } from './relayer_orders_request_schema';
+import { relayerTokenPairsRequestSchema } from './relayer_token_pairs_request_schema';
export const schemas = {
relayerOrderBookRequestSchema,
diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts
index d02444a3e..edb6c77a6 100644
--- a/packages/connect/src/types.ts
+++ b/packages/connect/src/types.ts
@@ -1,4 +1,4 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
// TODO: Consolidate Order, SignedOrder and ECSignature into a shared package instead of duplicating them from 0x.js
export interface Order {
@@ -57,19 +57,24 @@ export interface OrderbookChannelSubscriptionOpts {
}
export interface OrderbookChannelHandler {
- onSnapshot: (channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts,
- snapshot: OrderbookResponse) => void;
- onUpdate: (channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts,
- order: SignedOrder) => void;
- onError: (channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts,
- err: Error) => void;
+ onSnapshot: (
+ channel: OrderbookChannel,
+ subscriptionOpts: OrderbookChannelSubscriptionOpts,
+ snapshot: OrderbookResponse,
+ ) => void;
+ onUpdate: (
+ channel: OrderbookChannel,
+ subscriptionOpts: OrderbookChannelSubscriptionOpts,
+ order: SignedOrder,
+ ) => void;
+ onError: (channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts, err: Error) => void;
onClose: (channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts) => void;
}
export type OrderbookChannelMessage =
- SnapshotOrderbookChannelMessage |
- UpdateOrderbookChannelMessage |
- UnknownOrderbookChannelMessage;
+ | SnapshotOrderbookChannelMessage
+ | UpdateOrderbookChannelMessage
+ | UnknownOrderbookChannelMessage;
export enum OrderbookChannelMessageTypes {
Snapshot = 'snapshot',
diff --git a/packages/connect/src/utils/orderbook_channel_message_parser.ts b/packages/connect/src/utils/orderbook_channel_message_parser.ts
new file mode 100644
index 000000000..9a9ca8901
--- /dev/null
+++ b/packages/connect/src/utils/orderbook_channel_message_parser.ts
@@ -0,0 +1,37 @@
+import { assert } from '@0xproject/assert';
+import { schemas } from '@0xproject/json-schemas';
+import * as _ from 'lodash';
+
+import { OrderbookChannelMessage, OrderbookChannelMessageTypes } from '../types';
+
+import { relayerResponseJsonParsers } from './relayer_response_json_parsers';
+
+export const orderbookChannelMessageParser = {
+ parse(utf8Data: string): OrderbookChannelMessage {
+ const messageObj = JSON.parse(utf8Data);
+ const type: string = _.get(messageObj, 'type');
+ assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`);
+ assert.isString('type', type);
+ switch (type) {
+ case OrderbookChannelMessageTypes.Snapshot: {
+ assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelSnapshotSchema);
+ const orderbookJson = messageObj.payload;
+ const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(orderbookJson);
+ return _.assign(messageObj, { payload: orderbook });
+ }
+ case OrderbookChannelMessageTypes.Update: {
+ assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelUpdateSchema);
+ const orderJson = messageObj.payload;
+ const order = relayerResponseJsonParsers.parseOrderJson(orderJson);
+ return _.assign(messageObj, { payload: order });
+ }
+ default: {
+ return {
+ type: OrderbookChannelMessageTypes.Unknown,
+ requestId: 0,
+ payload: undefined,
+ };
+ }
+ }
+ },
+};
diff --git a/packages/connect/src/utils/orderbook_channel_message_parsers.ts b/packages/connect/src/utils/orderbook_channel_message_parsers.ts
deleted file mode 100644
index 486a416ef..000000000
--- a/packages/connect/src/utils/orderbook_channel_message_parsers.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import {assert} from '@0xproject/assert';
-import {schemas} from '@0xproject/json-schemas';
-import * as _ from 'lodash';
-
-import {
- OrderbookChannelMessage,
- OrderbookChannelMessageTypes,
- SignedOrder,
-} from '../types';
-
-import {typeConverters} from './type_converters';
-
-export const orderbookChannelMessageParsers = {
- parser(utf8Data: string): OrderbookChannelMessage {
- const messageObj = JSON.parse(utf8Data);
- const type: string = _.get(messageObj, 'type');
- assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`);
- assert.isString('type', type);
- switch (type) {
- case (OrderbookChannelMessageTypes.Snapshot): {
- assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelSnapshotSchema);
- const orderbook = messageObj.payload;
- typeConverters.convertOrderbookStringFieldsToBigNumber(orderbook);
- return messageObj;
- }
- case (OrderbookChannelMessageTypes.Update): {
- assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelUpdateSchema);
- const order = messageObj.payload;
- typeConverters.convertOrderStringFieldsToBigNumber(order);
- return messageObj;
- }
- default: {
- return {
- type: OrderbookChannelMessageTypes.Unknown,
- requestId: 0,
- payload: undefined,
- };
- }
- }
- },
-};
diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts
new file mode 100644
index 000000000..668461bf4
--- /dev/null
+++ b/packages/connect/src/utils/relayer_response_json_parsers.ts
@@ -0,0 +1,37 @@
+import { assert } from '@0xproject/assert';
+import { schemas } from '@0xproject/json-schemas';
+import * as _ from 'lodash';
+
+import { FeesResponse, OrderbookResponse, SignedOrder, TokenPairsItem } from '../types';
+
+import { typeConverters } from './type_converters';
+
+export const relayerResponseJsonParsers = {
+ parseTokenPairsJson(json: any): TokenPairsItem[] {
+ assert.doesConformToSchema('tokenPairs', json, schemas.relayerApiTokenPairsResponseSchema);
+ return json.map((tokenPair: any) => {
+ return typeConverters.convertStringsFieldsToBigNumbers(tokenPair, [
+ 'tokenA.minAmount',
+ 'tokenA.maxAmount',
+ 'tokenB.minAmount',
+ 'tokenB.maxAmount',
+ ]);
+ });
+ },
+ parseOrdersJson(json: any): SignedOrder[] {
+ assert.doesConformToSchema('orders', json, schemas.signedOrdersSchema);
+ return json.map((order: object) => typeConverters.convertOrderStringFieldsToBigNumber(order));
+ },
+ parseOrderJson(json: any): SignedOrder {
+ assert.doesConformToSchema('order', json, schemas.signedOrderSchema);
+ return typeConverters.convertOrderStringFieldsToBigNumber(json);
+ },
+ parseOrderbookResponseJson(json: any): OrderbookResponse {
+ assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrderBookResponseSchema);
+ return typeConverters.convertOrderbookStringFieldsToBigNumber(json);
+ },
+ parseFeesResponseJson(json: any): FeesResponse {
+ assert.doesConformToSchema('fees', json, schemas.relayerApiFeesResponseSchema);
+ return typeConverters.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']);
+ },
+};
diff --git a/packages/connect/src/utils/type_converters.ts b/packages/connect/src/utils/type_converters.ts
index c136382fd..c1808ce8a 100644
--- a/packages/connect/src/utils/type_converters.ts
+++ b/packages/connect/src/utils/type_converters.ts
@@ -1,15 +1,17 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-// TODO: convert all of these to non-mutating, pure functions
export const typeConverters = {
- convertOrderbookStringFieldsToBigNumber(orderbook: object): void {
- _.each(orderbook, (orders: object[]) => {
- _.each(orders, (order: object) => this.convertOrderStringFieldsToBigNumber(order));
- });
+ convertOrderbookStringFieldsToBigNumber(orderbook: any): any {
+ const bids = _.get(orderbook, 'bids', []);
+ const asks = _.get(orderbook, 'asks', []);
+ return {
+ bids: bids.map((order: any) => this.convertOrderStringFieldsToBigNumber(order)),
+ asks: asks.map((order: any) => this.convertOrderStringFieldsToBigNumber(order)),
+ };
},
- convertOrderStringFieldsToBigNumber(order: object): void {
- this.convertStringsFieldsToBigNumbers(order, [
+ convertOrderStringFieldsToBigNumber(order: any): any {
+ return this.convertStringsFieldsToBigNumbers(order, [
'makerTokenAmount',
'takerTokenAmount',
'makerFee',
@@ -18,14 +20,11 @@ export const typeConverters = {
'salt',
]);
},
- convertBigNumberFieldsToStrings(obj: object, fields: string[]): void {
- _.each(fields, field => {
- _.update(obj, field, (value: BigNumber) => value.toString());
- });
- },
- convertStringsFieldsToBigNumbers(obj: object, fields: string[]): void {
+ convertStringsFieldsToBigNumbers(obj: any, fields: string[]): any {
+ const result = _.assign({}, obj);
_.each(fields, field => {
- _.update(obj, field, (value: string) => new BigNumber(value));
+ _.update(result, field, (value: string) => new BigNumber(value));
});
+ return result;
},
};
diff --git a/packages/connect/src/ws_orderbook_channel.ts b/packages/connect/src/ws_orderbook_channel.ts
index 6687025c0..822a022f4 100644
--- a/packages/connect/src/ws_orderbook_channel.ts
+++ b/packages/connect/src/ws_orderbook_channel.ts
@@ -1,5 +1,5 @@
-import {assert} from '@0xproject/assert';
-import {schemas} from '@0xproject/json-schemas';
+import { assert } from '@0xproject/assert';
+import { schemas } from '@0xproject/json-schemas';
import * as _ from 'lodash';
import * as WebSocket from 'websocket';
@@ -8,21 +8,20 @@ import {
OrderbookChannelHandler,
OrderbookChannelMessageTypes,
OrderbookChannelSubscriptionOpts,
- SignedOrder,
WebsocketClientEventType,
WebsocketConnectionEventType,
} from './types';
-import {orderbookChannelMessageParsers} from './utils/orderbook_channel_message_parsers';
+import { orderbookChannelMessageParser } from './utils/orderbook_channel_message_parser';
/**
* This class includes all the functionality related to interacting with a websocket endpoint
* that implements the standard relayer API v0
*/
export class WebSocketOrderbookChannel implements OrderbookChannel {
- private apiEndpointUrl: string;
- private client: WebSocket.client;
- private connectionIfExists?: WebSocket.connection;
- private subscriptionCounter = 0;
+ private _apiEndpointUrl: string;
+ private _client: WebSocket.client;
+ private _connectionIfExists?: WebSocket.connection;
+ private _subscriptionCounter = 0;
/**
* Instantiates a new WebSocketOrderbookChannel instance
* @param url The relayer API base WS url you would like to interact with
@@ -30,8 +29,8 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
*/
constructor(url: string) {
assert.isUri('url', url);
- this.apiEndpointUrl = url;
- this.client = new WebSocket.client();
+ this._apiEndpointUrl = url;
+ this._client = new WebSocket.client();
}
/**
* Subscribe to orderbook snapshots and updates from the websocket
@@ -42,16 +41,19 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
*/
public subscribe(subscriptionOpts: OrderbookChannelSubscriptionOpts, handler: OrderbookChannelHandler): void {
assert.doesConformToSchema(
- 'subscriptionOpts', subscriptionOpts, schemas.relayerApiOrderbookChannelSubscribePayload);
+ 'subscriptionOpts',
+ subscriptionOpts,
+ schemas.relayerApiOrderbookChannelSubscribePayload,
+ );
assert.isFunction('handler.onSnapshot', _.get(handler, 'onSnapshot'));
assert.isFunction('handler.onUpdate', _.get(handler, 'onUpdate'));
assert.isFunction('handler.onError', _.get(handler, 'onError'));
assert.isFunction('handler.onClose', _.get(handler, 'onClose'));
- this.subscriptionCounter += 1;
+ this._subscriptionCounter += 1;
const subscribeMessage = {
type: 'subscribe',
channel: 'orderbook',
- requestId: this.subscriptionCounter,
+ requestId: this._subscriptionCounter,
payload: subscriptionOpts,
};
this._getConnection((error, connection) => {
@@ -75,44 +77,50 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
* Close the websocket and stop receiving updates
*/
public close() {
- if (!_.isUndefined(this.connectionIfExists)) {
- this.connectionIfExists.close();
+ if (!_.isUndefined(this._connectionIfExists)) {
+ this._connectionIfExists.close();
}
}
private _getConnection(callback: (error?: Error, connection?: WebSocket.connection) => void) {
- if (!_.isUndefined(this.connectionIfExists) && this.connectionIfExists.connected) {
- callback(undefined, this.connectionIfExists);
+ if (!_.isUndefined(this._connectionIfExists) && this._connectionIfExists.connected) {
+ callback(undefined, this._connectionIfExists);
} else {
- this.client.on(WebsocketClientEventType.Connect, connection => {
- this.connectionIfExists = connection;
- callback(undefined, this.connectionIfExists);
+ this._client.on(WebsocketClientEventType.Connect, connection => {
+ this._connectionIfExists = connection;
+ callback(undefined, this._connectionIfExists);
});
- this.client.on(WebsocketClientEventType.ConnectFailed, error => {
+ this._client.on(WebsocketClientEventType.ConnectFailed, error => {
callback(error, undefined);
});
- this.client.connect(this.apiEndpointUrl);
+ this._client.connect(this._apiEndpointUrl);
}
}
- private _handleWebSocketMessage(requestId: number, subscriptionOpts: OrderbookChannelSubscriptionOpts,
- message: WebSocket.IMessage, handler: OrderbookChannelHandler): void {
+ private _handleWebSocketMessage(
+ requestId: number,
+ subscriptionOpts: OrderbookChannelSubscriptionOpts,
+ message: WebSocket.IMessage,
+ handler: OrderbookChannelHandler,
+ ): void {
if (!_.isUndefined(message.utf8Data)) {
try {
const utf8Data = message.utf8Data;
- const parserResult = orderbookChannelMessageParsers.parser(utf8Data);
- const type = parserResult.type;
+ const parserResult = orderbookChannelMessageParser.parse(utf8Data);
if (parserResult.requestId === requestId) {
switch (parserResult.type) {
- case (OrderbookChannelMessageTypes.Snapshot): {
+ case OrderbookChannelMessageTypes.Snapshot: {
handler.onSnapshot(this, subscriptionOpts, parserResult.payload);
break;
}
- case (OrderbookChannelMessageTypes.Update): {
+ case OrderbookChannelMessageTypes.Update: {
handler.onUpdate(this, subscriptionOpts, parserResult.payload);
break;
}
default: {
handler.onError(
- this, subscriptionOpts, new Error(`Message has missing a type parameter: ${utf8Data}`));
+ this,
+ subscriptionOpts,
+ new Error(`Message has missing a type parameter: ${utf8Data}`),
+ );
}
}
}
diff --git a/packages/connect/test/fixtures/standard_relayer_api/fees.ts b/packages/connect/test/fixtures/standard_relayer_api/fees.ts
index 68421880e..fecbaacff 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/fees.ts
+++ b/packages/connect/test/fixtures/standard_relayer_api/fees.ts
@@ -1,6 +1,6 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
-import {FeesResponse} from '../../../src/types';
+import { FeesResponse } from '../../../src/types';
export const feesResponse: FeesResponse = {
feeRecipient: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
diff --git a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts
index 9df45065c..5a03a2ff6 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts
+++ b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts
@@ -1,4 +1,4 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
export const orderResponse = {
maker: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
diff --git a/packages/connect/test/fixtures/standard_relayer_api/orderbook.json b/packages/connect/test/fixtures/standard_relayer_api/orderbook.json
index bd6e10e4c..825be34c2 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/orderbook.json
+++ b/packages/connect/test/fixtures/standard_relayer_api/orderbook.json
@@ -41,4 +41,4 @@
}
}
]
-} \ No newline at end of file
+}
diff --git a/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts b/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts
index 529d2b450..6684ac2e5 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts
+++ b/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts
@@ -1,4 +1,4 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
export const orderbookResponse = {
bids: [
diff --git a/packages/connect/test/fixtures/standard_relayer_api/orders.ts b/packages/connect/test/fixtures/standard_relayer_api/orders.ts
index 54c8a150d..5044777bd 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/orders.ts
+++ b/packages/connect/test/fixtures/standard_relayer_api/orders.ts
@@ -1,4 +1,4 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
export const ordersResponse = [
{
diff --git a/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts b/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts
index b3ae7a1b1..f48b1e877 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts
+++ b/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts
@@ -1,6 +1,6 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
-import {TokenPairsItem} from '../../../src/types';
+import { TokenPairsItem } from '../../../src/types';
export const tokenPairsResponse: TokenPairsItem[] = [
{
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
index 21e7abb69..15759d911 100644
--- a/packages/connect/test/http_client_test.ts
+++ b/packages/connect/test/http_client_test.ts
@@ -1,24 +1,21 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import * as dirtyChai from 'dirty-chai';
import * as fetchMock from 'fetch-mock';
import 'mocha';
-import {HttpClient} from '../src/index';
+import { HttpClient } from '../src/index';
-import {feesResponse} from './fixtures/standard_relayer_api/fees';
+import { feesResponse } from './fixtures/standard_relayer_api/fees';
import * as feesResponseJSON from './fixtures/standard_relayer_api/fees.json';
-import {
- orderResponse,
-} from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
-// tslint:disable-next-line:max-line-length
+import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
import * as orderResponseJSON from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json';
-import {orderbookResponse} from './fixtures/standard_relayer_api/orderbook';
+import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook';
import * as orderbookJSON from './fixtures/standard_relayer_api/orderbook.json';
-import {ordersResponse} from './fixtures/standard_relayer_api/orders';
+import { ordersResponse } from './fixtures/standard_relayer_api/orders';
import * as ordersResponseJSON from './fixtures/standard_relayer_api/orders.json';
-import {tokenPairsResponse} from './fixtures/standard_relayer_api/token_pairs';
+import { tokenPairsResponse } from './fixtures/standard_relayer_api/token_pairs';
import * as tokenPairsResponseJSON from './fixtures/standard_relayer_api/token_pairs.json';
chai.config.includeStack = true;
@@ -32,14 +29,23 @@ describe('HttpClient', () => {
afterEach(() => {
fetchMock.restore();
});
+ describe('#constructor', () => {
+ it('should remove trailing slashes from api url', async () => {
+ const urlWithTrailingSlash = 'https://slash.com/';
+ const urlWithoutTrailingSlash = 'https://slash.com';
+ const client = new HttpClient(urlWithTrailingSlash);
+ const sanitizedUrl = (client as any)._apiEndpointUrl;
+ expect(sanitizedUrl).to.be.deep.equal(urlWithoutTrailingSlash);
+ });
+ });
describe('#getTokenPairsAsync', () => {
- const url = `${relayUrl}/v0/token_pairs`;
+ const url = `${relayUrl}/token_pairs`;
it('gets token pairs', async () => {
fetchMock.get(url, tokenPairsResponseJSON);
const tokenPairs = await relayerClient.getTokenPairsAsync();
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
});
- it('gets specfic token pairs for request', async () => {
+ it('gets specific token pairs for request', async () => {
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
const tokenPairsRequest = {
tokenA: tokenAddress,
@@ -50,12 +56,12 @@ describe('HttpClient', () => {
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
});
it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, {test: 'dummy'});
+ fetchMock.get(url, { test: 'dummy' });
expect(relayerClient.getTokenPairsAsync()).to.be.rejected();
});
});
describe('#getOrdersAsync', () => {
- const url = `${relayUrl}/v0/orders`;
+ const url = `${relayUrl}/orders`;
it('gets orders', async () => {
fetchMock.get(url, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync();
@@ -72,20 +78,20 @@ describe('HttpClient', () => {
expect(orders).to.be.deep.equal(ordersResponse);
});
it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, {test: 'dummy'});
+ fetchMock.get(url, { test: 'dummy' });
expect(relayerClient.getOrdersAsync()).to.be.rejected();
});
});
describe('#getOrderAsync', () => {
const orderHash = '0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
- const url = `${relayUrl}/v0/order/${orderHash}`;
+ const url = `${relayUrl}/order/${orderHash}`;
it('gets order', async () => {
fetchMock.get(url, orderResponseJSON);
const order = await relayerClient.getOrderAsync(orderHash);
expect(order).to.be.deep.equal(orderResponse);
});
it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, {test: 'dummy'});
+ fetchMock.get(url, { test: 'dummy' });
expect(relayerClient.getOrderAsync(orderHash)).to.be.rejected();
});
});
@@ -94,15 +100,16 @@ describe('HttpClient', () => {
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
quoteTokenAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
};
- // tslint:disable-next-line:max-line-length
- const url = `${relayUrl}/v0/orderbook?baseTokenAddress=${request.baseTokenAddress}&quoteTokenAddress=${request.quoteTokenAddress}`;
+ const url = `${relayUrl}/orderbook?baseTokenAddress=${request.baseTokenAddress}&quoteTokenAddress=${
+ request.quoteTokenAddress
+ }`;
it('gets order book', async () => {
fetchMock.get(url, orderbookJSON);
const orderbook = await relayerClient.getOrderbookAsync(request);
expect(orderbook).to.be.deep.equal(orderbookResponse);
});
it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, {test: 'dummy'});
+ fetchMock.get(url, { test: 'dummy' });
expect(relayerClient.getOrderbookAsync(request)).to.be.rejected();
});
});
@@ -118,14 +125,26 @@ describe('HttpClient', () => {
salt: new BigNumber('256'),
expirationUnixTimestampSec: new BigNumber('42'),
};
- const url = `${relayUrl}/v0/fees`;
+ const url = `${relayUrl}/fees`;
it('gets fees', async () => {
fetchMock.post(url, feesResponseJSON);
const fees = await relayerClient.getFeesAsync(request);
expect(fees).to.be.deep.equal(feesResponse);
});
+ it('does not mutate input', async () => {
+ fetchMock.post(url, feesResponseJSON);
+ const makerTokenAmountBefore = new BigNumber(request.makerTokenAmount);
+ const takerTokenAmountBefore = new BigNumber(request.takerTokenAmount);
+ const saltBefore = new BigNumber(request.salt);
+ const expirationUnixTimestampSecBefore = new BigNumber(request.expirationUnixTimestampSec);
+ await relayerClient.getFeesAsync(request);
+ expect(makerTokenAmountBefore).to.be.deep.equal(request.makerTokenAmount);
+ expect(takerTokenAmountBefore).to.be.deep.equal(request.takerTokenAmount);
+ expect(saltBefore).to.be.deep.equal(request.salt);
+ expect(expirationUnixTimestampSecBefore).to.be.deep.equal(request.expirationUnixTimestampSec);
+ });
it('throws an error for invalid JSON response', async () => {
- fetchMock.post(url, {test: 'dummy'});
+ fetchMock.post(url, { test: 'dummy' });
expect(relayerClient.getFeesAsync(request)).to.be.rejected();
});
});
diff --git a/packages/connect/test/orderbook_channel_message_parsers_test.ts b/packages/connect/test/orderbook_channel_message_parsers_test.ts
index 2c776b095..3e1f44384 100644
--- a/packages/connect/test/orderbook_channel_message_parsers_test.ts
+++ b/packages/connect/test/orderbook_channel_message_parsers_test.ts
@@ -2,16 +2,15 @@ import * as chai from 'chai';
import * as dirtyChai from 'dirty-chai';
import 'mocha';
-import {orderbookChannelMessageParsers} from '../src/utils/orderbook_channel_message_parsers';
+import { orderbookChannelMessageParser } from '../src/utils/orderbook_channel_message_parser';
-// tslint:disable-next-line:max-line-length
-import {orderResponse} from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
-import {orderbookResponse} from './fixtures/standard_relayer_api/orderbook';
+import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
+import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook';
import {
malformedSnapshotOrderbookChannelMessage,
snapshotOrderbookChannelMessage,
} from './fixtures/standard_relayer_api/snapshot_orderbook_channel_message';
-import {unknownOrderbookChannelMessage} from './fixtures/standard_relayer_api/unknown_orderbook_channel_message';
+import { unknownOrderbookChannelMessage } from './fixtures/standard_relayer_api/unknown_orderbook_channel_message';
import {
malformedUpdateOrderbookChannelMessage,
updateOrderbookChannelMessage,
@@ -21,20 +20,20 @@ chai.config.includeStack = true;
chai.use(dirtyChai);
const expect = chai.expect;
-describe('orderbookChannelMessageParsers', () => {
+describe('orderbookChannelMessageParser', () => {
describe('#parser', () => {
it('parses snapshot messages', () => {
- const snapshotMessage = orderbookChannelMessageParsers.parser(snapshotOrderbookChannelMessage);
+ const snapshotMessage = orderbookChannelMessageParser.parse(snapshotOrderbookChannelMessage);
expect(snapshotMessage.type).to.be.equal('snapshot');
expect(snapshotMessage.payload).to.be.deep.equal(orderbookResponse);
});
it('parses update messages', () => {
- const updateMessage = orderbookChannelMessageParsers.parser(updateOrderbookChannelMessage);
+ const updateMessage = orderbookChannelMessageParser.parse(updateOrderbookChannelMessage);
expect(updateMessage.type).to.be.equal('update');
expect(updateMessage.payload).to.be.deep.equal(orderResponse);
});
it('returns unknown message for messages with unsupported types', () => {
- const unknownMessage = orderbookChannelMessageParsers.parser(unknownOrderbookChannelMessage);
+ const unknownMessage = orderbookChannelMessageParser.parse(unknownOrderbookChannelMessage);
expect(unknownMessage.type).to.be.equal('unknown');
expect(unknownMessage.payload).to.be.undefined();
});
@@ -44,7 +43,7 @@ describe('orderbookChannelMessageParsers', () => {
"requestId": 1,
"payload": {}
}`;
- const badCall = () => orderbookChannelMessageParsers.parser(typelessMessage);
+ const badCall = () => orderbookChannelMessageParser.parse(typelessMessage);
expect(badCall).throws(`Message is missing a type parameter: ${typelessMessage}`);
});
it('throws when type is not a string', () => {
@@ -54,24 +53,23 @@ describe('orderbookChannelMessageParsers', () => {
"requestId": 1,
"payload": {}
}`;
- const badCall = () => orderbookChannelMessageParsers.parser(messageWithBadType);
+ const badCall = () => orderbookChannelMessageParser.parse(messageWithBadType);
expect(badCall).throws('Expected type to be of type string, encountered: 1');
});
it('throws when snapshot message has malformed payload', () => {
- const badCall = () =>
- orderbookChannelMessageParsers.parser(malformedSnapshotOrderbookChannelMessage);
+ const badCall = () => orderbookChannelMessageParser.parse(malformedSnapshotOrderbookChannelMessage);
// tslint:disable-next-line:max-line-length
- const errMsg = 'Validation errors: instance.payload requires property "bids", instance.payload requires property "asks"';
+ const errMsg =
+ 'Validation errors: instance.payload requires property "bids", instance.payload requires property "asks"';
expect(badCall).throws(errMsg);
});
it('throws when update message has malformed payload', () => {
- const badCall = () =>
- orderbookChannelMessageParsers.parser(malformedUpdateOrderbookChannelMessage);
+ const badCall = () => orderbookChannelMessageParser.parse(malformedUpdateOrderbookChannelMessage);
expect(badCall).throws(/^Expected message to conform to schema/);
});
it('throws when input message is not valid JSON', () => {
const nonJsonString = 'h93b{sdfs9fsd f';
- const badCall = () => orderbookChannelMessageParsers.parser(nonJsonString);
+ const badCall = () => orderbookChannelMessageParser.parse(nonJsonString);
expect(badCall).throws('Unexpected token h in JSON at position 0');
});
});
diff --git a/packages/connect/test/ws_orderbook_channel_test.ts b/packages/connect/test/ws_orderbook_channel_test.ts
index 6190a5ac3..ce404d934 100644
--- a/packages/connect/test/ws_orderbook_channel_test.ts
+++ b/packages/connect/test/ws_orderbook_channel_test.ts
@@ -3,9 +3,7 @@ import * as dirtyChai from 'dirty-chai';
import * as _ from 'lodash';
import 'mocha';
-import {
- WebSocketOrderbookChannel,
-} from '../src/ws_orderbook_channel';
+import { WebSocketOrderbookChannel } from '../src/ws_orderbook_channel';
chai.config.includeStack = true;
chai.use(dirtyChai);
@@ -21,26 +19,42 @@ describe('WebSocketOrderbookChannel', () => {
limit: 100,
};
const emptyOrderbookChannelHandler = {
- onSnapshot: () => { _.noop(); },
- onUpdate: () => { _.noop(); },
- onError: () => { _.noop(); },
- onClose: () => { _.noop(); },
+ onSnapshot: () => {
+ _.noop();
+ },
+ onUpdate: () => {
+ _.noop();
+ },
+ onError: () => {
+ _.noop();
+ },
+ onClose: () => {
+ _.noop();
+ },
};
describe('#subscribe', () => {
it('throws when subscriptionOpts does not conform to schema', () => {
const badSubscribeCall = orderbookChannel.subscribe.bind(
- orderbookChannel, {}, emptyOrderbookChannelHandler);
- // tslint:disable-next-line:max-line-length
- expect(badSubscribeCall).throws('Expected subscriptionOpts to conform to schema /RelayerApiOrderbookChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseTokenAddress", instance requires property "quoteTokenAddress"');
+ orderbookChannel,
+ {},
+ emptyOrderbookChannelHandler,
+ );
+ expect(badSubscribeCall).throws(
+ 'Expected subscriptionOpts to conform to schema /RelayerApiOrderbookChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseTokenAddress", instance requires property "quoteTokenAddress"',
+ );
});
it('throws when handler has the incorrect members', () => {
const badSubscribeCall = orderbookChannel.subscribe.bind(orderbookChannel, subscriptionOpts, {});
- expect(badSubscribeCall)
- .throws('Expected handler.onSnapshot to be of type function, encountered: undefined');
+ expect(badSubscribeCall).throws(
+ 'Expected handler.onSnapshot to be of type function, encountered: undefined',
+ );
});
it('does not throw when inputs are of correct types', () => {
const goodSubscribeCall = orderbookChannel.subscribe.bind(
- orderbookChannel, subscriptionOpts, emptyOrderbookChannelHandler);
+ orderbookChannel,
+ subscriptionOpts,
+ emptyOrderbookChannelHandler,
+ );
expect(goodSubscribeCall).to.not.throw();
});
});
diff --git a/packages/connect/tsconfig.json b/packages/connect/tsconfig.json
index a6c8277f8..3c150236e 100644
--- a/packages/connect/tsconfig.json
+++ b/packages/connect/tsconfig.json
@@ -1,19 +1,12 @@
{
+ "extends": "../../tsconfig",
"compilerOptions": {
- "module": "commonjs",
- "target": "es5",
- "lib": [ "es2015", "dom" ],
- "outDir": "lib",
- "sourceMap": true,
- "declaration": true,
- "noImplicitAny": true,
- "strictNullChecks": true
+ "outDir": "lib"
},
"include": [
- "./src/**/*",
- "./test/**/*",
- "../../node_modules/chai-as-promised-typescript-typings/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts"
+ "./src/**/*",
+ "./test/**/*",
+ "../../node_modules/chai-as-promised-typescript-typings/index.d.ts",
+ "../../node_modules/chai-typescript-typings/index.d.ts"
]
- }
+}
diff --git a/packages/connect/tslint.json b/packages/connect/tslint.json
index a07795151..ffaefe83a 100644
--- a/packages/connect/tslint.json
+++ b/packages/connect/tslint.json
@@ -1,5 +1,3 @@
{
- "extends": [
- "@0xproject/tslint-config"
- ]
+ "extends": ["@0xproject/tslint-config"]
}
diff --git a/packages/contracts/README.md b/packages/contracts/README.md
index 57c75cb85..0a1c272ab 100644
--- a/packages/contracts/README.md
+++ b/packages/contracts/README.md
@@ -1,51 +1,68 @@
-Contracts
------
+## Contracts
-## Useful 0x Wiki Articles
+Smart contracts that implement the 0x protocol.
-* [Architecture](https://0xproject.com/wiki#Architecture)
-* [Contract Interactions](https://0xproject.com/wiki#Contract-Interactions)
-* [Contract deployed addresses](https://0xproject.com/wiki#Deployed-Addresses)
-* [0x Protocol Message Format](https://0xproject.com/wiki#Message-Format)
-* [Bug Bounty Program](https://0xproject.com/wiki#Bug-Bounty)
+## Usage
-## Setup
+* [Docs](https://0xproject.com/docs/contracts)
+* [Overview of 0x protocol architecture](https://0xproject.com/wiki#Architecture)
+* [0x smart contract interactions](https://0xproject.com/wiki#Contract-Interactions)
+* [Deployed smart contract addresses](https://0xproject.com/wiki#Deployed-Addresses)
+* [0x protocol message format](https://0xproject.com/wiki#Message-Format)
-### Installing Dependencies
+## Contributing
-Install [Node](https://nodejs.org/en/download/releases/)
+We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
-Install [yarn](https://yarnpkg.com/lang/en/docs/install/) in order to install the project dependencies more deterministically.
+For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
-Install project dependencies:
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
-```
-yarn
-```
+### Install Dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
-### Running Tests
+```bash
+yarn config set workspaces-experimental true
+```
-Start Testrpc
+Then install dependencies
+```bash
+yarn install
```
-yarn testrpc
+
+### Build
+
+```bash
+yarn build
```
-Run tests
+### Clean
+```bash
+yarn clean
```
-yarn test
+
+### Lint
+
+```bash
+yarn lint
```
-## Contributing
+### Run Tests
-0x protocol is intended to serve as an open technical standard for EVM blockchains and we strongly encourage our community members to help us make improvements and to determine the future direction of the protocol. To report bugs within the 0x smart contracts or unit tests, please create an issue in this repository.
+Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance.
-### ZEIPs
-Significant changes to 0x protocol's smart contracts, architecture, message format or functionality should be proposed in the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository. Follow the contribution guidelines provided therein.
+In a separate terminal, start TestRPC (a convenience command is provided as part of the [0x.js monorepo](https://github.com/0xProject/0x.js))
-### Coding conventions
+```bash
+cd ../..
+yarn testrpc
+```
-We use a custom set of [TSLint](https://palantir.github.io/tslint/) rules to enforce our coding conventions.
+Then in your main terminal run
-In order to see style violation errors, install a tslinter for your text editor. e.g Atom's [atom-typescript](https://atom.io/packages/atom-typescript).
+```bash
+yarn test
+```
diff --git a/packages/contracts/build/contracts/DummyToken.json b/packages/contracts/build/contracts/DummyToken.json
index 2698a1e17..6ed9daeed 100644
--- a/packages/contracts/build/contracts/DummyToken.json
+++ b/packages/contracts/build/contracts/DummyToken.json
@@ -286,7 +286,7 @@
"type": "event"
}
],
- "unlinked_binary": "0x6060604052341561000c57fe5b604051610a46380380610a4683398101604090815281516020830151918301516060840151918401939290920191905b5b60038054600160a060020a03191633600160a060020a03161790555b835161006c9060049060208701906100b0565b5082516100809060059060208601906100b0565b5060068290556002819055600160a060020a03331660009081526020819052604090208190555b50505050610150565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100f157805160ff191683800117855561011e565b8280016001018555821561011e579182015b8281111561011e578251825591602001919060010190610103565b5b5061012b92915061012f565b5090565b61014d91905b8082111561012b5760008155600101610135565b5090565b90565b6108e78061015f6000396000f300606060405236156100a95763ffffffff60e060020a60003504166306fdde0381146100ab578063095ea7b31461013b57806318160ddd1461016e57806323b872dd14610190578063313ce567146101c957806370a08231146101eb5780638da5cb5b1461021957806395d89b4114610245578063a0712d68146102d5578063a9059cbb146102ea578063dd62ed3e1461031d578063e30443bc14610351578063f2fde38b14610372575bfe5b34156100b357fe5b6100bb610390565b604080516020808252835181830152835191928392908301918501908083838215610101575b80518252602083111561010157601f1990920191602091820191016100e1565b505050905090810190601f16801561012d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014357fe5b61015a600160a060020a036004351660243561041e565b604080519115158252519081900360200190f35b341561017657fe5b61017e610489565b60408051918252519081900360200190f35b341561019857fe5b61015a600160a060020a036004358116906024351660443561048f565b604080519115158252519081900360200190f35b34156101d157fe5b61017e61058b565b60408051918252519081900360200190f35b34156101f357fe5b61017e600160a060020a0360043516610591565b60408051918252519081900360200190f35b341561022157fe5b6102296105b0565b60408051600160a060020a039092168252519081900360200190f35b341561024d57fe5b6100bb6105bf565b604080516020808252835181830152835191928392908301918501908083838215610101575b80518252602083111561010157601f1990920191602091820191016100e1565b505050905090810190601f16801561012d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102dd57fe5b6102e860043561064d565b005b34156102f257fe5b61015a600160a060020a03600435166024356106b5565b604080519115158252519081900360200190f35b341561032557fe5b61017e600160a060020a0360043581169060243516610767565b60408051918252519081900360200190f35b341561035957fe5b6102e8600160a060020a0360043516602435610794565b005b341561037a57fe5b6102e8600160a060020a036004351661081e565b005b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104165780601f106103eb57610100808354040283529160200191610416565b820191906000526020600020905b8154815290600101906020018083116103f957829003601f168201915b505050505081565b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a0383166000908152602081905260408120548290108015906104df5750600160a060020a0380851660009081526001602090815260408083203390941683529290522054829010155b80156105055750600160a060020a03831660009081526020819052604090205482810110155b1561057f57600160a060020a03808416600081815260208181526040808320805488019055888516808452818420805489900390556001835281842033909616845294825291829020805487900390558151868152915192939260008051602061089c8339815191529281900390910190a3506001610583565b5060005b5b9392505050565b60065481565b600160a060020a0381166000908152602081905260409020545b919050565b600354600160a060020a031681565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104165780601f106103eb57610100808354040283529160200191610416565b820191906000526020600020905b8154815290600101906020018083116103f957829003601f168201915b505050505081565b68056bc75e2d631000008111156106645760006000fd5b600160a060020a03331660009081526020819052604090205461068890829061086a565b600160a060020a0333166000908152602081905260409020556002546106ae908261086a565b6002555b50565b600160a060020a0333166000908152602081905260408120548290108015906106f85750600160a060020a03831660009081526020819052604090205482810110155b1561075857600160a060020a03338116600081815260208181526040808320805488900390559387168083529184902080548701905583518681529351919360008051602061089c833981519152929081900390910190a3506001610483565b506000610483565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b60035460009033600160a060020a039081169116146107b35760006000fd5b6107bc83610591565b9050808210156107e3576107db6002546107d68385610884565b610884565b6002556107fc565b6107f86002546107f38484610884565b61086a565b6002555b600160a060020a03831660009081526020819052604090208290555b5b505050565b60035433600160a060020a0390811691161461083a5760006000fd5b600160a060020a038116156106b25760038054600160a060020a031916600160a060020a0383161790555b5b5b50565b60008282018381101561087957fe5b8091505b5092915050565b60008282111561089057fe5b508082035b929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a723058204a428de115c741873c68da562de00a2839a910073c061da3394aa07287d9ef5f0029",
+ "unlinked_binary": "0x6060604052341561000c57fe5b604051610a6d380380610a6d83398101604090815281516020830151918301516060840151918401939290920191905b5b60038054600160a060020a03191633600160a060020a03161790555b835161006c9060049060208701906100b0565b5082516100809060059060208601906100b0565b5060068290556002819055600160a060020a03331660009081526020819052604090208190555b50505050610150565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100f157805160ff191683800117855561011e565b8280016001018555821561011e579182015b8281111561011e578251825591602001919060010190610103565b5b5061012b92915061012f565b5090565b61014d91905b8082111561012b5760008155600101610135565b5090565b90565b61090e8061015f6000396000f300606060405236156100a95763ffffffff60e060020a60003504166306fdde0381146100ab578063095ea7b31461013b57806318160ddd1461016e57806323b872dd14610190578063313ce567146101c957806370a08231146101eb5780638da5cb5b1461021957806395d89b4114610245578063a0712d68146102d5578063a9059cbb146102ea578063dd62ed3e1461031d578063e30443bc14610351578063f2fde38b14610372575bfe5b34156100b357fe5b6100bb610390565b604080516020808252835181830152835191928392908301918501908083838215610101575b80518252602083111561010157601f1990920191602091820191016100e1565b505050905090810190601f16801561012d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014357fe5b61015a600160a060020a036004351660243561041e565b604080519115158252519081900360200190f35b341561017657fe5b61017e610489565b60408051918252519081900360200190f35b341561019857fe5b61015a600160a060020a036004358116906024351660443561048f565b604080519115158252519081900360200190f35b34156101d157fe5b61017e6105b2565b60408051918252519081900360200190f35b34156101f357fe5b61017e600160a060020a03600435166105b8565b60408051918252519081900360200190f35b341561022157fe5b6102296105d7565b60408051600160a060020a039092168252519081900360200190f35b341561024d57fe5b6100bb6105e6565b604080516020808252835181830152835191928392908301918501908083838215610101575b80518252602083111561010157601f1990920191602091820191016100e1565b505050905090810190601f16801561012d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102dd57fe5b6102e8600435610674565b005b34156102f257fe5b61015a600160a060020a03600435166024356106dc565b604080519115158252519081900360200190f35b341561032557fe5b61017e600160a060020a036004358116906024351661078e565b60408051918252519081900360200190f35b341561035957fe5b6102e8600160a060020a03600435166024356107bb565b005b341561037a57fe5b6102e8600160a060020a0360043516610845565b005b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104165780601f106103eb57610100808354040283529160200191610416565b820191906000526020600020905b8154815290600101906020018083116103f957829003601f168201915b505050505081565b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a03808416600081815260016020908152604080832033909516835293815283822054928252819052918220548390108015906104d25750828110155b80156104f85750600160a060020a03841660009081526020819052604090205483810110155b156105a457600160a060020a038085166000908152602081905260408082208054870190559187168152208054849003905560001981101561056257600160a060020a03808616600090815260016020908152604080832033909416835292905220805484900390555b83600160a060020a031685600160a060020a03166000805160206108c3833981519152856040518082815260200191505060405180910390a3600191506105a9565b600091505b5b509392505050565b60065481565b600160a060020a0381166000908152602081905260409020545b919050565b600354600160a060020a031681565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104165780601f106103eb57610100808354040283529160200191610416565b820191906000526020600020905b8154815290600101906020018083116103f957829003601f168201915b505050505081565b68056bc75e2d6310000081111561068b5760006000fd5b600160a060020a0333166000908152602081905260409020546106af908290610891565b600160a060020a0333166000908152602081905260409020556002546106d59082610891565b6002555b50565b600160a060020a03331660009081526020819052604081205482901080159061071f5750600160a060020a03831660009081526020819052604090205482810110155b1561077f57600160a060020a0333811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191936000805160206108c3833981519152929081900390910190a3506001610483565b506000610483565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b60035460009033600160a060020a039081169116146107da5760006000fd5b6107e3836105b8565b90508082101561080a576108026002546107fd83856108ab565b6108ab565b600255610823565b61081f60025461081a84846108ab565b610891565b6002555b600160a060020a03831660009081526020819052604090208290555b5b505050565b60035433600160a060020a039081169116146108615760006000fd5b600160a060020a038116156106d95760038054600160a060020a031916600160a060020a0383161790555b5b5b50565b6000828201838110156108a057fe5b8091505b5092915050565b6000828211156108b757fe5b508082035b929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820d93905a702dd25447548c9b62604a718169270050b73347c63e4161fb4317c7e0029",
"networks": {
"50": {
"links": {},
@@ -336,9 +336,9 @@
"type": "event"
}
},
- "updated_at": 1502391794392
+ "updated_at": 1513088404208
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794392
+ "updated_at": 1513088404208
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/EtherToken.json b/packages/contracts/build/contracts/EtherToken.json
index f46e256ca..64e144e20 100644
--- a/packages/contracts/build/contracts/EtherToken.json
+++ b/packages/contracts/build/contracts/EtherToken.json
@@ -233,9 +233,9 @@
"type": "event"
}
],
- "unlinked_binary": "0x6060604052341561000c57fe5b5b61070f8061001c6000396000f300606060405236156100935763ffffffff60e060020a60003504166306fdde0381146100a4578063095ea7b31461013457806318160ddd1461016757806323b872dd146101895780632e1a7d4d146101c2578063313ce567146101d757806370a08231146101fd57806395d89b411461022b578063a9059cbb146102bb578063d0e30db0146102ee578063dd62ed3e146102f8575b6100a25b61009f61032c565b5b565b005b34156100ac57fe5b6100b461037b565b6040805160208082528351818301528351919283929083019185019080838382156100fa575b8051825260208311156100fa57601f1990920191602091820191016100da565b505050905090810190601f1680156101265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561013c57fe5b610153600160a060020a03600435166024356103a3565b604080519115158252519081900360200190f35b341561016f57fe5b61017761040e565b60408051918252519081900360200190f35b341561019157fe5b610153600160a060020a0360043581169060243516604435610414565b604080519115158252519081900360200190f35b34156101ca57fe5b6100a26004356104ff565b005b34156101df57fe5b6101e7610580565b6040805160ff9092168252519081900360200190f35b341561020557fe5b610177600160a060020a0360043516610585565b60408051918252519081900360200190f35b341561023357fe5b6100b46105a4565b6040805160208082528351818301528351919283929083019185019080838382156100fa575b8051825260208311156100fa57601f1990920191602091820191016100da565b505050905090810190601f1680156101265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102c357fe5b610153600160a060020a03600435166024356105c5565b604080519115158252519081900360200190f35b6100a261032c565b005b341561030057fe5b610177600160a060020a0360043581169060243516610665565b60408051918252519081900360200190f35b600160a060020a03331660009081526020819052604090205461034f9034610692565b600160a060020a0333166000908152602081905260409020556002546103759034610692565b6002555b565b60408051808201909152600b815260a960020a6a22ba3432b9102a37b5b2b702602082015281565b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a03831660009081526020819052604081205461043790836106ac565b600160a060020a03808616600090815260208181526040808320949094556001815283822033909316825291909152205461047290836106ac565b600160a060020a038086166000908152600160209081526040808320338516845282528083209490945591861681529081905220546104b19083610692565b600160a060020a038085166000818152602081815260409182902094909455805186815290519193928816926000805160206106c483398151915292918290030190a35060015b9392505050565b600160a060020a03331660009081526020819052604090205461052290826106ac565b600160a060020a03331660009081526020819052604090205560025461054890826106ac565b600255604051600160a060020a0333169082156108fc029083906000818181858888f19350505050151561057c5760006000fd5b5b50565b601281565b600160a060020a0381166000908152602081905260409020545b919050565b604080518082019091526004815260e360020a630ae8aa8902602082015281565b600160a060020a0333166000908152602081905260408120546105e890836106ac565b600160a060020a0333811660009081526020819052604080822093909355908516815220546106179083610692565b600160a060020a03808516600081815260208181526040918290209490945580518681529051919333909316926000805160206106c483398151915292918290030190a35060015b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b6000828201838110156106a157fe5b8091505b5092915050565b6000828211156106b857fe5b508082035b929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820b0be668913b36ff13a97f9ad56d8eb2e9c169cc9b32bfde9e3b92cec1036f1080029",
+ "unlinked_binary": "0x6060604052341561000c57fe5b5b6107598061001c6000396000f300606060405236156100935763ffffffff60e060020a60003504166306fdde0381146100a4578063095ea7b31461013457806318160ddd1461016757806323b872dd146101895780632e1a7d4d146101c2578063313ce567146101d757806370a08231146101fd57806395d89b411461022b578063a9059cbb146102bb578063d0e30db0146102ee578063dd62ed3e146102f8575b6100a25b61009f61032c565b5b565b005b34156100ac57fe5b6100b461037b565b6040805160208082528351818301528351919283929083019185019080838382156100fa575b8051825260208311156100fa57601f1990920191602091820191016100da565b505050905090810190601f1680156101265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561013c57fe5b610153600160a060020a03600435166024356103a3565b604080519115158252519081900360200190f35b341561016f57fe5b61017761040e565b60408051918252519081900360200190f35b341561019157fe5b610153600160a060020a0360043581169060243516604435610414565b604080519115158252519081900360200190f35b34156101ca57fe5b6100a2600435610537565b005b34156101df57fe5b6101e76105b8565b6040805160ff9092168252519081900360200190f35b341561020557fe5b610177600160a060020a03600435166105bd565b60408051918252519081900360200190f35b341561023357fe5b6100b46105dc565b6040805160208082528351818301528351919283929083019185019080838382156100fa575b8051825260208311156100fa57601f1990920191602091820191016100da565b505050905090810190601f1680156101265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102c357fe5b610153600160a060020a03600435166024356105fd565b604080519115158252519081900360200190f35b6100a261032c565b005b341561030057fe5b610177600160a060020a03600435811690602435166106af565b60408051918252519081900360200190f35b600160a060020a03331660009081526020819052604090205461034f90346106dc565b600160a060020a03331660009081526020819052604090205560025461037590346106dc565b6002555b565b60408051808201909152600b815260a960020a6a22ba3432b9102a37b5b2b702602082015281565b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a03808416600081815260016020908152604080832033909516835293815283822054928252819052918220548390108015906104575750828110155b801561047d5750600160a060020a03841660009081526020819052604090205483810110155b1561052957600160a060020a03808516600090815260208190526040808220805487019055918716815220805484900390556000198110156104e757600160a060020a03808616600090815260016020908152604080832033909416835292905220805484900390555b83600160a060020a031685600160a060020a031660008051602061070e833981519152856040518082815260200191505060405180910390a36001915061052e565b600091505b5b509392505050565b600160a060020a03331660009081526020819052604090205461055a90826106f6565b600160a060020a03331660009081526020819052604090205560025461058090826106f6565b600255604051600160a060020a0333169082156108fc029083906000818181858888f1935050505015156105b45760006000fd5b5b50565b601281565b600160a060020a0381166000908152602081905260409020545b919050565b604080518082019091526004815260e360020a630ae8aa8902602082015281565b600160a060020a0333166000908152602081905260408120548290108015906106405750600160a060020a03831660009081526020819052604090205482810110155b156106a057600160a060020a03338116600081815260208181526040808320805488900390559387168083529184902080548701905583518681529351919360008051602061070e833981519152929081900390910190a3506001610408565b506000610408565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b6000828201838110156106eb57fe5b8091505b5092915050565b60008282111561070257fe5b508082035b929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a7230582036b62e75991ca24307fbb7333dc79a1493b9acb6b3e146e3c707708262cfbe430029",
"networks": {
- "50": {
+ "1": {
"links": {},
"events": {
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": {
@@ -283,8 +283,8 @@
"type": "event"
}
},
- "updated_at": 1502391794392,
- "address": "0x6eead871b92e216b0368f596e751a25841f65bec"
+ "updated_at": 1502488087000,
+ "address": "0x2956356cd2a2bf3202f771f50d3d14a367b48070"
},
"42": {
"links": {},
@@ -337,7 +337,7 @@
"updated_at": 1502391794392,
"address": "0x05d090b51c40b020eab3bfcb6a2dff130df22e9c"
},
- "1": {
+ "50": {
"links": {},
"events": {
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": {
@@ -385,10 +385,10 @@
"type": "event"
}
},
- "updated_at": 1502488087000,
- "address": "0x2956356cd2a2bf3202f771f50d3d14a367b48070"
+ "updated_at": 1513088404209,
+ "address": "0x48bacb9266a570d521063ef5dd96e61686dbe788"
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794392
-}
+ "updated_at": 1513088404209
+} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/Exchange.json b/packages/contracts/build/contracts/Exchange.json
index 245b8e86c..3e2308f8f 100644
--- a/packages/contracts/build/contracts/Exchange.json
+++ b/packages/contracts/build/contracts/Exchange.json
@@ -590,9 +590,9 @@
"type": "event"
}
],
- "unlinked_binary": "0x6060604052341561000f57600080fd5b604051604080612c4d833981016040528080519060200190919080519060200190919050505b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50505b612b84806100c96000396000f300606060405236156100fa576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806314df96ee146100ff578063288cdc911461014c5780632ac1262214610187578063363349be146101c2578063394c21e7146103bc5780633b30ba591461044b5780634f150787146104a0578063741bcc93146106b25780637e9abb50146107535780638163681e1461078e57806398024a8b14610812578063add1cbc51461085b578063b7b2c7d6146108b0578063baa0181d14610acd578063bc61394a14610c1f578063cfc4d0ec14610cdf578063f06bbf7514610d6d578063ffa1ad7414610d9e575b600080fd5b341561010a57600080fd5b6101326004808035906020019091908035906020019091908035906020019091905050610e2d565b604051808215151515815260200191505060405180910390f35b341561015757600080fd5b610171600480803560001916906020019091905050610e7c565b6040518082815260200191505060405180910390f35b341561019257600080fd5b6101ac600480803560001916906020019091905050610e94565b6040518082815260200191505060405180910390f35b34156101cd57600080fd5b6103a660048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561024857848483905060a002016005806020026040519081016040528092919082600560200280828437820191505050505081526020019060010190610203565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156102c457848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061027f565b5050505050919080359060200190919080351515906020019091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050610eac565b6040518082815260200191505060405180910390f35b34156103c757600080fd5b6104356004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091908035906020019091905050611013565b6040518082815260200191505060405180910390f35b341561045657600080fd5b61045e6114fb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104ab57600080fd5b6106b060048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561052657848483905060a0020160058060200260405190810160405280929190826005602002808284378201915050505050815260200190600101906104e1565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156105a257848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061055d565b50505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050611520565b005b34156106bd57600080fd5b6107516004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c00190600680602002604051908101604052809291908260066020028082843782019150505050509190803590602001909190803560ff1690602001909190803560001916906020019091908035600019169060200190919050506115df565b005b341561075e57600080fd5b610778600480803560001916906020019091905050611605565b6040518082815260200191505060405180910390f35b341561079957600080fd5b6107f8600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080356000191690602001909190803560ff16906020019091908035600019169060200190919080356000191690602001909190505061164f565b604051808215151515815260200191505060405180910390f35b341561081d57600080fd5b6108456004808035906020019091908035906020019091908035906020019091905050611757565b6040518082815260200191505060405180910390f35b341561086657600080fd5b61086e611776565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156108bb57600080fd5b610acb60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561093657848483905060a0020160058060200260405190810160405280929190826005602002808284378201915050505050815260200190600101906108f1565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156109b257848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061096d565b50505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035151590602001909190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061179c565b005b3415610ad857600080fd5b610c1d60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610b5357848483905060a002016005806020026040519081016040528092919082600560200280828437820191505050505081526020019060010190610b0e565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610bcf57848483905060c002016006806020026040519081016040528092919082600660200280828437820191505050505081526020019060010190610b8a565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061185e565b005b3415610c2a57600080fd5b610cc96004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091908035906020019091908035151590602001909190803560ff1690602001909190803560001916906020019091908035600019169060200190919050506118d3565b6040518082815260200191505060405180910390f35b3415610cea57600080fd5b610d4f6004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091905050612073565b60405180826000191660001916815260200191505060405180910390f35b3415610d7857600080fd5b610d8061231f565b604051808261ffff1661ffff16815260200191505060405180910390f35b3415610da957600080fd5b610db1612325565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610df25780820151818401525b602081019050610dd6565b50505050905090810190601f168015610e1f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60008060008486850991506000821415610e4a5760009250610e73565b610e69610e5a83620f424061235e565b610e64888761235e565b612392565b90506103e8811192505b50509392505050565b60026020528060005260406000206000915090505481565b60036020528060005260406000206000915090505481565b6000806000809150600090505b895181101561100257896000815181101515610ed157fe5b906020019060200201516003600581101515610ee957fe5b602002015173ffffffffffffffffffffffffffffffffffffffff168a82815181101515610f1257fe5b906020019060200201516003600581101515610f2a57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16141515610f5157600080fd5b610fe582610fe08c84815181101515610f6657fe5b906020019060200201518c85815181101515610f7e57fe5b90602001906020020151610f928d886123ae565b8c8c88815181101515610fa157fe5b906020019060200201518c89815181101515610fb957fe5b906020019060200201518c8a815181101515610fd157fe5b906020019060200201516118d3565b6123c8565b915087821415610ff457611002565b5b8080600101915050610eb9565b8192505b5050979650505050505050565b600061101d612a8c565b6000806101606040519081016040528088600060058110151561103c57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200188600160058110151561106b57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200188600260058110151561109a57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018860036005811015156110c957fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018860046005811015156110f857fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200187600060068110151561112757fe5b6020020151815260200187600160068110151561114057fe5b6020020151815260200187600260068110151561115957fe5b6020020151815260200187600360068110151561117257fe5b6020020151815260200187600460068110151561118b57fe5b6020020151815260200161119f8989612073565b6000191681525092503373ffffffffffffffffffffffffffffffffffffffff16836000015173ffffffffffffffffffffffffffffffffffffffff161415156111e657600080fd5b60008360a001511180156111fe575060008360c00151115b801561120a5750600085115b151561121557600080fd5b8261012001514210151561127257826101400151600019166000600381111561123a57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a3600093506114f1565b61128d8360c00151611288856101400151611605565b6123ae565b915061129985836123e7565b905060008114156112f35782610140015160001916600160038111156112bb57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a3600093506114f1565b61131d600360008561014001516000191660001916815260200190815260200160002054826123c8565b60036000856101400151600019166000191681526020019081526020016000208190555082604001518360600151604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140192505050604051809103902060001916836080015173ffffffffffffffffffffffffffffffffffffffff16846000015173ffffffffffffffffffffffffffffffffffffffff167f67d66f160bc93d925d05dae1794c90d2d6d6688b29b84ff069398a9b0458713186604001518760600151611455878a60c001518b60a00151611757565b878a6101400151604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182600019166000191681526020019550505050505060405180910390a48093505b5050509392505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008090505b86518110156115d5576115c7878281518110151561154057fe5b90602001906020020151878381518110151561155857fe5b90602001906020020151878481518110151561157057fe5b90602001906020020151878581518110151561158857fe5b9060200190602002015187868151811015156115a057fe5b9060200190602002015187878151811015156115b857fe5b906020019060200201516115df565b5b8080600101915050611526565b5b50505050505050565b836115f087878760008888886118d3565b1415156115fc57600080fd5b5b505050505050565b600061164760026000846000191660001916815260200190815260200160002054600360008560001916600019168152602001908152602001600020546123c8565b90505b919050565b600060018560405180807f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250601c0182600019166000191681526020019150506040518091039020858585604051600081526020016040526000604051602001526040518085600019166000191681526020018460ff1660ff16815260200183600019166000191681526020018260001916600019168152602001945050505050602060405160208103908084039060008661646e5a03f1151561171457600080fd5b50506020604051035173ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161490505b95945050505050565b600061176c611766858461235e565b84612392565b90505b9392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008090505b87518110156118535761184488828151811015156117bc57fe5b9060200190602002015188838151811015156117d457fe5b9060200190602002015188848151811015156117ec57fe5b9060200190602002015188888681518110151561180557fe5b90602001906020020151888781518110151561181d57fe5b90602001906020020151888881518110151561183557fe5b906020019060200201516118d3565b505b80806001019150506117a2565b5b5050505050505050565b60008090505b83518110156118cc576118bd848281518110151561187e57fe5b90602001906020020151848381518110151561189657fe5b9060200190602002015184848151811015156118ae57fe5b90602001906020020151611013565b505b8080600101915050611864565b5b50505050565b60006118dd612a8c565b600080600080610160604051908101604052808e60006005811015156118ff57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600160058110151561192e57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600260058110151561195d57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600360058110151561198c57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e60046005811015156119bb57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018d60006006811015156119ea57fe5b602002015181526020018d6001600681101515611a0357fe5b602002015181526020018d6002600681101515611a1c57fe5b602002015181526020018d6003600681101515611a3557fe5b602002015181526020018d6004600681101515611a4e57fe5b60200201518152602001611a628f8f612073565b600019168152509450600073ffffffffffffffffffffffffffffffffffffffff16856020015173ffffffffffffffffffffffffffffffffffffffff161480611ad957503373ffffffffffffffffffffffffffffffffffffffff16856020015173ffffffffffffffffffffffffffffffffffffffff16145b1515611ae457600080fd5b60008560a00151118015611afc575060008560c00151115b8015611b08575060008b115b1515611b1357600080fd5b611b2985600001518661014001518b8b8b61164f565b1515611b3457600080fd5b84610120015142101515611b91578461014001516000191660006003811115611b5957fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611bac8560c00151611ba7876101400151611605565b6123ae565b9350611bb88b856123e7565b95506000861415611c12578461014001516000191660016003811115611bda57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611c25868660c001518760a00151610e2d565b15611c79578461014001516000191660026003811115611c4157fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b89158015611c8e5750611c8c8587612401565b155b15611ce15784610140015160001916600380811115611ca957fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611cf4868660c001518760a00151611757565b9250611d20600260008761014001516000191660001916815260200190815260200160002054876123c8565b600260008761014001516000191660001916815260200190815260200160002081905550611d58856040015186600001513386612751565b1515611d6357600080fd5b611d77856060015133876000015189612751565b1515611d8257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16856080015173ffffffffffffffffffffffffffffffffffffffff16141515611e815760008560e001511115611e1f57611ddc868660c001518760e00151611757565b9150611e136000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168660000151876080015185612751565b1515611e1e57600080fd5b5b60008561010001511115611e8057611e41868660c00151876101000151611757565b9050611e746000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633876080015184612751565b1515611e7f57600080fd5b5b5b84604001518560600151604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140192505050604051809103902060001916856080015173ffffffffffffffffffffffffffffffffffffffff16866000015173ffffffffffffffffffffffffffffffffffffffff167f0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb33389604001518a60600151898d8a8a8f6101400151604051808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200186815260200185815260200184815260200183815260200182600019166000191681526020019850505050505050505060405180910390a48595505b5050505050979650505050505050565b60003083600060058110151561208557fe5b602002015184600160058110151561209957fe5b60200201518560026005811015156120ad57fe5b60200201518660036005811015156120c157fe5b60200201518760046005811015156120d557fe5b60200201518760006006811015156120e957fe5b60200201518860016006811015156120fd57fe5b602002015189600260068110151561211157fe5b60200201518a600360068110151561212557fe5b60200201518b600460068110151561213957fe5b60200201518c600560068110151561214d57fe5b6020020151604051808d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018781526020018681526020018581526020018481526020018381526020018281526020019c50505050505050505050505050604051809103902090505b92915050565b61138781565b6040805190810160405280600581526020017f312e302e3000000000000000000000000000000000000000000000000000000081525081565b6000808284029050600084148061237f575082848281151561237c57fe5b04145b151561238757fe5b8091505b5092915050565b60008082848115156123a057fe5b0490508091505b5092915050565b60008282111515156123bc57fe5b81830390505b92915050565b60008082840190508381101515156123dc57fe5b8091505b5092915050565b60008183106123f657816123f8565b825b90505b92915050565b60008060008060008060008060003397506124258a8c60c001518d60a00151611757565b9650600073ffffffffffffffffffffffffffffffffffffffff168b6080015173ffffffffffffffffffffffffffffffffffffffff161415156126d2576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168b6040015173ffffffffffffffffffffffffffffffffffffffff161495506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168b6060015173ffffffffffffffffffffffffffffffffffffffff161494506125208a8c60c001518d60e00151611757565b93506125368a8c60c001518d6101000151611757565b925085612543578361254e565b61254d87856123c8565b5b91508461255b5782612566565b6125658a846123c8565b5b9050816125986000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168d600001516128ae565b10806125d15750816125cf6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168d60000151612972565b105b806126055750806126036000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a6128ae565b105b806126395750806126376000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a612972565b105b156126475760009850612743565b851580156126805750866126638c604001518d600001516128ae565b108061267f57508661267d8c604001518d60000151612972565b105b5b1561268e5760009850612743565b841580156126bf5750896126a68c606001518a6128ae565b10806126be5750896126bc8c606001518a612972565b105b5b156126cd5760009850612743565b61273e565b866126e58c604001518d600001516128ae565b10806127015750866126ff8c604001518d60000151612972565b105b806127185750896127168c606001518a6128ae565b105b8061272f57508961272d8c606001518a612972565b105b1561273d5760009850612743565b5b600198505b505050505050505092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166315dacbea868686866000604051602001526040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050602060405180830381600087803b151561288857600080fd5b6102c65a03f1151561289957600080fd5b5050506040518051905090505b949350505050565b60008273ffffffffffffffffffffffffffffffffffffffff166370a0823161138761ffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600088803b151561295157600080fd5b87f1151561295e57600080fd5b505050506040518051905090505b92915050565b60008273ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e61138761ffff1684600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600088803b1515612a6b57600080fd5b87f11515612a7857600080fd5b505050506040518051905090505b92915050565b61016060405190810160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016000801916815250905600a165627a7a7230582051fd36c20467561cfff517e73443e85bfad01c2fe07b8431ba9903676db7bb140029",
+ "unlinked_binary": "0x6060604052341561000c57fe5b604051604080611ed68339810160405280516020909101515b60008054600160a060020a03808516600160a060020a03199283161790925560018054928416929091169190911790555b50505b611e6e806100686000396000f300606060405236156100e05763ffffffff60e060020a60003504166314df96ee81146100e2578063288cdc911461010f5780632ac1262214610134578063363349be14610159578063394c21e71461031b5780633b30ba591461038e5780634f150787146103ba578063741bcc931461059d5780637e9abb50146106135780638163681e1461063857806398024a8b14610677578063add1cbc5146106a2578063b7b2c7d6146106ce578063baa0181d146108b9578063bc61394a146109f4578063cfc4d0ec14610a81578063f06bbf7514610af2578063ffa1ad7414610b19575bfe5b34156100ea57fe5b6100fb600435602435604435610ba9565b604080519115158252519081900360200190f35b341561011757fe5b610122600435610bf7565b60408051918252519081900360200190f35b341561013c57fe5b610122600435610c09565b60408051918252519081900360200190f35b341561016157fe5b61012260048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156101d3576040805160a08181019092529080840287019060059083908390808284375050509183525050600190910190602001610197565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610246576040805160c0818101909252908084028701906006908390839080828437505050918352505060019091019060200161020a565b5050604080516020878301358901803582810280850184019095528084529799893599838101351515999198506060019650929450810192829185019084908082843750506040805187358901803560208181028481018201909552818452989a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989a998901989297509082019550935083925085019084908082843750949650610c1b95505050505050565b60408051918252519081900360200190f35b341561032357fe5b6040805160a08181019092526101229160049160a4918390600590839083908082843750506040805160c08181019092529496958181019594509250600691508390839080828437509395505092359250610d44915050565b60408051918252519081900360200190f35b341561039657fe5b61039e611036565b60408051600160a060020a039092168252519081900360200190f35b34156103c257fe5b61059b60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610434576040805160a081810190925290808402870190600590839083908082843750505091835250506001909101906020016103f8565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156104a7576040805160c0818101909252908084028701906006908390839080828437505050918352505060019091019060200161046b565b50505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843750506040805187358901803560208181028481018201909552818452989a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989a99890198929750908201955093508392508501908490808284375094965061104595505050505050565b005b34156105a557fe5b6040805160a081810190925261059b9160049160a4918390600590839083908082843750506040805160c08181019092529496958181019594509250600691508390839080828437509395505083359360ff6020820135169350604081013592506060013590506110fc565b005b341561061b57fe5b610122600435611121565b60408051918252519081900360200190f35b341561064057fe5b6100fb600160a060020a036004351660243560ff6044351660643560843561114d565b604080519115158252519081900360200190f35b341561067f57fe5b610122600435602435604435611205565b60408051918252519081900360200190f35b34156106aa57fe5b61039e611224565b60408051600160a060020a039092168252519081900360200190f35b34156106d657fe5b61059b60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610748576040805160a0818101909252908084028701906005908390839080828437505050918352505060019091019060200161070c565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156107bb576040805160c0818101909252908084028701906006908390839080828437505050918352505060019091019060200161077f565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284375050604080516020808901358a01803580830284810184018652818552999b8b3515159b909a950198509296508101945090925082919085019084908082843750506040805187358901803560208181028481018201909552818452989a998901989297509082019550935083925085019084908082843750506040805187358901803560208181028481018201909552818452989a99890198929750908201955093508392508501908490808284375094965061123395505050505050565b005b34156108c157fe5b61059b60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610933576040805160a081810190925290808402870190600590839083908082843750505091835250506001909101906020016108f7565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156109a6576040805160c0818101909252908084028701906006908390839080828437505050918352505060019091019060200161096a565b505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437509496506112ed95505050505050565b005b34156109fc57fe5b6040805160a08181019092526101229160049160a4918390600590839083908082843750506040805160c08181019092529496958181019594509250600691508390839080828437509395505083359360208101351515935060ff6040820135169250606081013591506080013561135a565b60408051918252519081900360200190f35b3415610a8957fe5b6040805160a08181019092526101229160049160a4918390600590839083908082843750506040805160c0818101909252949695818101959450925060069150839083908082843750939550611838945050505050565b60408051918252519081900360200190f35b3415610afa57fe5b610b0261192b565b6040805161ffff9092168252519081900360200190f35b3415610b2157fe5b610b29611931565b604080516020808252835181830152835191928392908301918501908083838215610b6f575b805182526020831115610b6f57601f199092019160209182019101610b4f565b505050905090810190601f168015610b9b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600060006000848685099150811515610bc55760009250610bee565b610be4610bd583620f4240611953565b610bdf8887611953565b611982565b90506103e8811192505b50509392505050565b60026020526000908152604090205481565b60036020526000908152604090205481565b600080805b8951811015610d3357896000815181101515610c3857fe5b6020908102909101015160035b6020020151600160a060020a03168a82815181101515610c6157fe5b6020908102909101015160035b6020020151600160a060020a031614610c875760006000fd5b610d1b82610d168c84815181101515610c9c57fe5b906020019060200201518c85815181101515610cb457fe5b90602001906020020151610cc88d8861199f565b8c8c88815181101515610cd757fe5b906020019060200201518c89815181101515610cef57fe5b906020019060200201518c8a815181101515610d0757fe5b9060200190602002015161135a565b6119b6565b915087821415610d2a57610d33565b5b600101610c20565b8192505b5050979650505050505050565b6000610d4e611dc6565b60408051610160810190915260009081908088835b60209081029190910151600160a060020a03168252018860015b60209081029190910151600160a060020a03168252018860025b60209081029190910151600160a060020a03168252018860035b60209081029190910151600160a060020a03168252018860045b60209081029190910151600160a060020a03168252018760005b602090810291909101518252018760015b602090810291909101518252018760025b602090810291909101518252018760035b602090810291909101518252018760045b60200201518152602001610e3d8989611838565b9052805190935033600160a060020a03908116911614610e5d5760006000fd5b60008360a00151118015610e75575060008360c00151115b8015610e815750600085115b1515610e8d5760006000fd5b6101208301514210610ec95761014083015160005b60405160ff9190911690600080516020611e2383398151915290600090a36000935061102c565b610ee48360c00151610edf856101400151611121565b61199f565b9150610ef085836119d0565b9050801515610f2d576101408301516001610ea2565b60405160ff9190911690600080516020611e2383398151915290600090a36000935061102c565b610140830151600090815260036020526040902054610f4c90826119b6565b610140840151600090815260036020526040908190209190915580840180516060860180518451606060020a600160a060020a03948516810282529184169091026014820152935193849003602801909320608087015187519351945160c089015160a08a0151939692851695909416937f67d66f160bc93d925d05dae1794c90d2d6d6688b29b84ff069398a9b0458713193610fea918991611205565b6101408a015160408051600160a060020a0395861681529390941660208401528284019190915260608201889052608082015290519081900360a00190a48093505b5050509392505050565b600054600160a060020a031681565b60005b86518110156110f2576110e9878281518110151561106257fe5b90602001906020020151878381518110151561107a57fe5b90602001906020020151878481518110151561109257fe5b9060200190602002015187858151811015156110aa57fe5b9060200190602002015187868151811015156110c257fe5b9060200190602002015187878151811015156110da57fe5b906020019060200201516110fc565b5b600101611048565b5b50505050505050565b8361110d878787600088888861135a565b146111185760006000fd5b5b505050505050565b600081815260026020908152604080832054600390925282205461114591906119b6565b90505b919050565b604080517f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c8101869052815190819003603c018120600082815260208381018552928401819052835191825260ff8716828401528184018690526060820185905292516001926080808401939192601f1981019281900390910190868661646e5a03f115156111dc57fe5b505060206040510351600160a060020a031686600160a060020a03161490505b95945050505050565b600061121a6112148584611953565b84611982565b90505b9392505050565b600154600160a060020a031681565b60005b87518110156112e2576112d8888281518110151561125057fe5b90602001906020020151888381518110151561126857fe5b90602001906020020151888481518110151561128057fe5b9060200190602002015188888681518110151561129957fe5b9060200190602002015188878151811015156112b157fe5b906020019060200201518888815181101515610d0757fe5b9060200190602002015161135a565b505b600101611236565b5b5050505050505050565b60005b835181101561135357611349848281518110151561130a57fe5b90602001906020020151848381518110151561132257fe5b90602001906020020151848481518110151561133a57fe5b90602001906020020151610d44565b505b6001016112f0565b5b50505050565b6000611364611dc6565b6000600060006000610160604051908101604052808e600060058110151561138857fe5b60209081029190910151600160a060020a03168252018e60015b60209081029190910151600160a060020a03168252018e60025b60209081029190910151600160a060020a03168252018e60035b60209081029190910151600160a060020a03168252018e60045b60209081029190910151600160a060020a03168252018d60005b602090810291909101518252018d60015b602090810291909101518252018d60025b602090810291909101518252018d60035b602090810291909101518252018d60045b602002015181526020016114628f8f611838565b90526020810151909550600160a060020a03161580611496575033600160a060020a03168560200151600160a060020a0316145b15156114a25760006000fd5b60008560a001511180156114ba575060008560c00151115b80156114c6575060008b115b15156114d25760006000fd5b6114e885600001518661014001518b8b8b61114d565b15156114f45760006000fd5b61012085015142106115305761014085015160005b60405160ff9190911690600080516020611e2383398151915290600090a360009550611828565b61154b8560c00151610edf876101400151611121565b61199f565b93506115578b856119d0565b9550851515611594576101408501516001611509565b60405160ff9190911690600080516020611e2383398151915290600090a360009550611828565b6115a7868660c001518760a00151610ba9565b156115e0576101408501516002611509565b60405160ff9190911690600080516020611e2383398151915290600090a360009550611828565b891580156115f557506115f385876119ea565b155b1561162e576101408501516003611509565b60405160ff9190911690600080516020611e2383398151915290600090a360009550611828565b611641868660c001518760a00151611205565b61014086015160009081526002602052604090205490935061166390876119b6565b6101408601516000908152600260205260409081902091909155850151855161168e91903386611c46565b151561169a5760006000fd5b6116ae856060015133876000015189611c46565b15156116ba5760006000fd5b6080850151600160a060020a03161561176e5760008560e00151111561171c576116ed868660c001518760e00151611205565b6000548651608088015192945061171092600160a060020a039092169185611c46565b151561171c5760006000fd5b5b6000856101000151111561176e5761173f868660c00151876101000151611205565b600054608087015191925061176291600160a060020a0390911690339084611c46565b151561176e5760006000fd5b5b5b60408086018051606080890180518551606060020a600160a060020a0395861681028252918516909102601482015285519081900360280181206080808d01518d51975194516101408f0151338916865295881660208601528716848a01529483018b905282018d905260a0820189905260c0820188905260e08201929092529451909491831693909216917f0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb3918190036101000190a45b5050505050979650505050505050565b60003083825b60200201518460015b60200201518560025b60200201518660035b60200201518760045b60200201518760005b60200201518860015b60200201518960025b60200201518a60035b60200201518b60045b60200201518c60055b602002015160408051606060020a600160a060020a039e8f16810282529c8e168d0260148201529a8d168c0260288c0152988c168b02603c8b0152968b168a0260508a01529490991690970260648701526078860191909152609885015260b884019490945260d883019490945260f8820192909252610118810192909252519081900361013801902090505b92915050565b61138781565b604080518082019091526005815260dc60020a640312e302e302602082015281565b600082820283158061196f575082848281151561196c57fe5b04145b151561197757fe5b8091505b5092915050565b60006000828481151561199157fe5b0490508091505b5092915050565b6000828211156119ab57fe5b508082035b92915050565b60008282018381101561197757fe5b8091505b5092915050565b60008183106119df57816119e1565b825b90505b92915050565b600060006000600060006000600060006000339750611a128a8c60c001518d60a00151611205565b60808c0151909750600160a060020a031615611bc75760005460408c015160608d015160c08e015160e08f0151600160a060020a0394851693851684149a50939091169091149650611a66918c9190611205565b9350611a7c8a8c60c001518d6101000151611205565b925085611a895783611a93565b611a9387856119b6565b5b915084611aa15782611aab565b611aab8a846119b6565b5b6000548c519192508391611ac991600160a060020a031690611cd5565b1080611aee57506000548b518391611aec91600160a060020a0390911690611d50565b105b80611b0e57506000548190611b0c90600160a060020a03168a611cd5565b105b80611b2e57506000548190611b2c90600160a060020a03168a611d50565b105b15611b3c5760009850611c38565b85158015611b74575086611b588c604001518d60000151611cd5565b1080611b74575086611b728c604001518d60000151611d50565b105b5b15611b835760009850611c38565b84158015611bb3575089611b9b8c606001518a611cd5565b1080611bb3575089611bb18c606001518a611d50565b105b5b15611bc25760009850611c38565b611c32565b86611bda8c604001518d60000151611cd5565b1080611bf6575086611bf48c604001518d60000151611d50565b105b80611c0d575089611c0b8c606001518a611cd5565b105b80611c24575089611c228c606001518a611d50565b105b15611c325760009850611c38565b5b600198505b505050505050505092915050565b6001546040805160006020918201819052825160e160020a630aed65f5028152600160a060020a03898116600483015288811660248301528781166044830152606482018790529351919493909316926315dacbea92608480830193919282900301818787803b1515611cb557fe5b6102c65a03f11515611cc357fe5b5050604051519150505b949350505050565b600082600160a060020a03166370a0823161138761ffff16846040518363ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600088803b1515611d3557fe5b87f11515611d3f57fe5b505060405151925050505b92915050565b6001546040805160e160020a636eb1769f028152600160a060020a0384811660048301529283166024820152905160009285169163dd62ed3e916113879160448082019260209290919082900301818888803b1515611d3557fe5b87f11515611d3f57fe5b505060405151925050505b92915050565b6040805161016081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081018290526101008101829052610120810182905261014081019190915290560036d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e90a165627a7a723058204d97d325c74ccfe9265611080c9dadbe995124be2fa6e0eb6384a4474bc271600029",
"networks": {
- "50": {
+ "1": {
"links": {},
"events": {
"0x0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb3": {
@@ -722,8 +722,8 @@
"type": "event"
}
},
- "updated_at": 1502391794390,
- "address": "0x38024cc964e6f2745672c86ecf45f5965efe6310"
+ "updated_at": 1502480340000,
+ "address": "0x12459C951127e0c374FF9105DdA097662A027093"
},
"42": {
"links": {},
@@ -858,7 +858,7 @@
"updated_at": 1502391794390,
"address": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364"
},
- "1": {
+ "50": {
"links": {},
"events": {
"0x0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb3": {
@@ -988,10 +988,10 @@
"type": "event"
}
},
- "updated_at": 1502480340000,
- "address": "0x12459C951127e0c374FF9105DdA097662A027093"
+ "updated_at": 1513088404206,
+ "address": "0xb69e673309512a9d726f87304c6984054f87a93b"
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794390
-}
+ "updated_at": 1513088404206
+} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/MaliciousToken.json b/packages/contracts/build/contracts/MaliciousToken.json
index 61c48f26a..fc8c8faeb 100644
--- a/packages/contracts/build/contracts/MaliciousToken.json
+++ b/packages/contracts/build/contracts/MaliciousToken.json
@@ -169,7 +169,7 @@
"type": "event"
}
],
- "unlinked_binary": "0x60606040526003805460ff19166001179055341561001957fe5b5b610467806100296000396000f3006060604052361561005c5763ffffffff60e060020a600035041663095ea7b3811461005e57806318160ddd1461009157806323b872dd146100b357806370a08231146100ec578063a9059cbb1461011a578063dd62ed3e1461014d575bfe5b341561006657fe5b61007d600160a060020a0360043516602435610181565b604080519115158252519081900360200190f35b341561009957fe5b6100a16101ec565b60408051918252519081900360200190f35b34156100bb57fe5b61007d600160a060020a03600435811690602435166044356101f2565b604080519115158252519081900360200190f35b34156100f457fe5b6100a1600160a060020a03600435166102ee565b60408051918252519081900360200190f35b341561012257fe5b61007d600160a060020a0360043516602435610318565b604080519115158252519081900360200190f35b341561015557fe5b6100a1600160a060020a03600435811690602435166103ca565b60408051918252519081900360200190f35b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a0383166000908152602081905260408120548290108015906102425750600160a060020a0380851660009081526001602090815260408083203390941683529290522054829010155b80156102685750600160a060020a03831660009081526020819052604090205482810110155b156102e257600160a060020a03808416600081815260208181526040808320805488019055888516808452818420805489900390556001835281842033909616845294825291829020805487900390558151868152915192939260008051602061041c8339815191529281900390910190a35060016102e6565b5060005b5b9392505050565b60006102f8610402565b50600160a060020a0381166000908152602081905260409020545b919050565b600160a060020a03331660009081526020819052604081205482901080159061035b5750600160a060020a03831660009081526020819052604090205482810110155b156103bb57600160a060020a03338116600081815260208181526040808320805488900390559387168083529184902080548701905583518681529351919360008051602061041c833981519152929081900390910190a35060016101e6565b5060006101e6565b5b92915050565b60006103d4610402565b50600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b6003805460ff8082166001011660ff199091161790555b5600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a723058201238dbb2f96252f5d35040796309238210d3a5d9ac3261d0effff444e8f0cd0c0029",
+ "unlinked_binary": "0x60606040526003805460ff19166001179055341561001957fe5b5b610467806100296000396000f3006060604052361561005c5763ffffffff60e060020a600035041663095ea7b3811461005e57806318160ddd1461009157806323b872dd146100b357806370a08231146100ec578063a9059cbb1461011a578063dd62ed3e1461014d575bfe5b341561006657fe5b61007d600160a060020a0360043516602435610181565b604080519115158252519081900360200190f35b341561009957fe5b6100a16101ec565b60408051918252519081900360200190f35b34156100bb57fe5b61007d600160a060020a03600435811690602435166044356101f2565b604080519115158252519081900360200190f35b34156100f457fe5b6100a1600160a060020a03600435166102ee565b60408051918252519081900360200190f35b341561012257fe5b61007d600160a060020a0360043516602435610318565b604080519115158252519081900360200190f35b341561015557fe5b6100a1600160a060020a03600435811690602435166103ca565b60408051918252519081900360200190f35b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a0383166000908152602081905260408120548290108015906102425750600160a060020a0380851660009081526001602090815260408083203390941683529290522054829010155b80156102685750600160a060020a03831660009081526020819052604090205482810110155b156102e257600160a060020a03808416600081815260208181526040808320805488019055888516808452818420805489900390556001835281842033909616845294825291829020805487900390558151868152915192939260008051602061041c8339815191529281900390910190a35060016102e6565b5060005b5b9392505050565b60006102f8610402565b50600160a060020a0381166000908152602081905260409020545b919050565b600160a060020a03331660009081526020819052604081205482901080159061035b5750600160a060020a03831660009081526020819052604090205482810110155b156103bb57600160a060020a03338116600081815260208181526040808320805488900390559387168083529184902080548701905583518681529351919360008051602061041c833981519152929081900390910190a35060016101e6565b5060006101e6565b5b92915050565b60006103d4610402565b50600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b6003805460ff8082166001011660ff199091161790555b5600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a7230582078edadabd342b34dc605a47ad9eab0ab5ad8513193a546e042b2ab9c6101d5250029",
"networks": {
"50": {
"links": {},
@@ -219,9 +219,9 @@
"type": "event"
}
},
- "updated_at": 1502391794396
+ "updated_at": 1513088404210
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794396
+ "updated_at": 1513088404210
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/Migrations.json b/packages/contracts/build/contracts/Migrations.json
index e421c8130..a0643bb6c 100644
--- a/packages/contracts/build/contracts/Migrations.json
+++ b/packages/contracts/build/contracts/Migrations.json
@@ -64,9 +64,9 @@
"50": {
"links": {},
"events": {},
- "updated_at": 1502391794384
+ "updated_at": 1513088404203
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794384
+ "updated_at": 1513088404203
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/Mintable.json b/packages/contracts/build/contracts/Mintable.json
index 157d49a44..3d89194a0 100644
--- a/packages/contracts/build/contracts/Mintable.json
+++ b/packages/contracts/build/contracts/Mintable.json
@@ -182,8 +182,8 @@
"type": "event"
}
],
- "unlinked_binary": "0x6060604052341561000c57fe5b5b6104da8061001c6000396000f300606060405236156100675763ffffffff60e060020a600035041663095ea7b3811461006957806318160ddd1461009c57806323b872dd146100be57806370a08231146100f7578063a0712d6814610125578063a9059cbb1461013a578063dd62ed3e1461016d575bfe5b341561007157fe5b610088600160a060020a03600435166024356101a1565b604080519115158252519081900360200190f35b34156100a457fe5b6100ac61020c565b60408051918252519081900360200190f35b34156100c657fe5b610088600160a060020a0360043581169060243516604435610212565b604080519115158252519081900360200190f35b34156100ff57fe5b6100ac600160a060020a036004351661030e565b60408051918252519081900360200190f35b341561012d57fe5b61013860043561032d565b005b341561014257fe5b610088600160a060020a0360043516602435610395565b604080519115158252519081900360200190f35b341561017557fe5b6100ac600160a060020a0360043581169060243516610447565b60408051918252519081900360200190f35b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a0383166000908152602081905260408120548290108015906102625750600160a060020a0380851660009081526001602090815260408083203390941683529290522054829010155b80156102885750600160a060020a03831660009081526020819052604090205482810110155b1561030257600160a060020a03808416600081815260208181526040808320805488019055888516808452818420805489900390556001835281842033909616845294825291829020805487900390558151868152915192939260008051602061048f8339815191529281900390910190a3506001610306565b5060005b5b9392505050565b600160a060020a0381166000908152602081905260409020545b919050565b68056bc75e2d631000008111156103445760006000fd5b600160a060020a033316600090815260208190526040902054610368908290610474565b600160a060020a03331660009081526020819052604090205560025461038e9082610474565b6002555b50565b600160a060020a0333166000908152602081905260408120548290108015906103d85750600160a060020a03831660009081526020819052604090205482810110155b1561043857600160a060020a03338116600081815260208181526040808320805488900390559387168083529184902080548701905583518681529351919360008051602061048f833981519152929081900390910190a3506001610206565b506000610206565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b60008282018381101561048357fe5b8091505b50929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820fb9e3b0567bae493373766d7c9980e78be7513e22369cbce495956e5849c284d0029",
+ "unlinked_binary": "0x6060604052341561000c57fe5b5b6105018061001c6000396000f300606060405236156100675763ffffffff60e060020a600035041663095ea7b3811461006957806318160ddd1461009c57806323b872dd146100be57806370a08231146100f7578063a0712d6814610125578063a9059cbb1461013a578063dd62ed3e1461016d575bfe5b341561007157fe5b610088600160a060020a03600435166024356101a1565b604080519115158252519081900360200190f35b34156100a457fe5b6100ac61020c565b60408051918252519081900360200190f35b34156100c657fe5b610088600160a060020a0360043581169060243516604435610212565b604080519115158252519081900360200190f35b34156100ff57fe5b6100ac600160a060020a0360043516610335565b60408051918252519081900360200190f35b341561012d57fe5b610138600435610354565b005b341561014257fe5b610088600160a060020a03600435166024356103bc565b604080519115158252519081900360200190f35b341561017557fe5b6100ac600160a060020a036004358116906024351661046e565b60408051918252519081900360200190f35b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a03808416600081815260016020908152604080832033909516835293815283822054928252819052918220548390108015906102555750828110155b801561027b5750600160a060020a03841660009081526020819052604090205483810110155b1561032757600160a060020a03808516600090815260208190526040808220805487019055918716815220805484900390556000198110156102e557600160a060020a03808616600090815260016020908152604080832033909416835292905220805484900390555b83600160a060020a031685600160a060020a03166000805160206104b6833981519152856040518082815260200191505060405180910390a36001915061032c565b600091505b5b509392505050565b600160a060020a0381166000908152602081905260409020545b919050565b68056bc75e2d6310000081111561036b5760006000fd5b600160a060020a03331660009081526020819052604090205461038f90829061049b565b600160a060020a0333166000908152602081905260409020556002546103b5908261049b565b6002555b50565b600160a060020a0333166000908152602081905260408120548290108015906103ff5750600160a060020a03831660009081526020819052604090205482810110155b1561045f57600160a060020a0333811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191936000805160206104b6833981519152929081900390910190a3506001610206565b506000610206565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b6000828201838110156104aa57fe5b8091505b50929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820b1c955ed24ff28cfa482298867cac2a83e25903b0100a429152919223fdf653f0029",
"networks": {},
"schema_version": "0.0.5",
- "updated_at": 1502391449723
+ "updated_at": 1513088402049
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/MultiSigWallet.json b/packages/contracts/build/contracts/MultiSigWallet.json
index cb6be0217..931c8100d 100644
--- a/packages/contracts/build/contracts/MultiSigWallet.json
+++ b/packages/contracts/build/contracts/MultiSigWallet.json
@@ -510,8 +510,8 @@
"type": "event"
}
],
- "unlinked_binary": "0x606060405234156200000d57fe5b604051620022e9380380620022e9833981016040528080518201919060200180519060200190919050505b600082518260328211806200004c57508181115b80620000585750600081145b80620000645750600082145b15620000705760006000fd5b600092505b8451831015620001a9576002600086858151811015156200009257fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806200011e575060008584815181101515620000fc57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff16145b156200012a5760006000fd5b60016002600087868151811015156200013f57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b828060010193505062000075565b8460039080519060200190620001c1929190620001d6565b50836004819055505b5b5050505050620002ab565b82805482825590600052602060002090810192821562000252579160200282015b82811115620002515782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190620001f7565b5b50905062000261919062000265565b5090565b620002a891905b80821115620002a457600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016200026c565b5090565b90565b61202e80620002bb6000396000f3006060604052361561011b576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063025e7c271461017c578063173825d9146101dc57806320ea8d86146102125780632f54bf6e146102325780633411c81c1461028057806354741525146102d75780637065cb4814610318578063784547a71461034e5780638b51d13f146103865780639ace38c2146103ba578063a0e67e2b146104b5578063a8abe69a1461052a578063b5dc40c3146105cc578063b77bf6001461064f578063ba51a6df14610675578063c01a8c8414610695578063c6427474146106b5578063d74f8edd1461074b578063dc8452cd14610771578063e20056e614610797578063ee22610b146107ec575b61017a5b6000341115610177573373ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c346040518082815260200191505060405180910390a25b5b565b005b341561018457fe5b61019a600480803590602001909190505061080c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101e457fe5b610210600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061084c565b005b341561021a57fe5b6102306004808035906020019091905050610af4565b005b341561023a57fe5b610266600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ca5565b604051808215151515815260200191505060405180910390f35b341561028857fe5b6102bd600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cc5565b604051808215151515815260200191505060405180910390f35b34156102df57fe5b610302600480803515159060200190919080351515906020019091905050610cf4565b6040518082815260200191505060405180910390f35b341561032057fe5b61034c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d8b565b005b341561035657fe5b61036c6004808035906020019091905050610f8e565b604051808215151515815260200191505060405180910390f35b341561038e57fe5b6103a46004808035906020019091905050611078565b6040518082815260200191505060405180910390f35b34156103c257fe5b6103d86004808035906020019091905050611148565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001831515151581526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156104a35780601f10610478576101008083540402835291602001916104a3565b820191906000526020600020905b81548152906001019060200180831161048657829003601f168201915b50509550505050505060405180910390f35b34156104bd57fe5b6104c56111a4565b6040518080602001828103825283818151815260200191508051906020019060200280838360008314610517575b805182526020831115610517576020820191506020810190506020830392506104f3565b5050509050019250505060405180910390f35b341561053257fe5b610567600480803590602001909190803590602001909190803515159060200190919080351515906020019091905050611239565b60405180806020018281038252838181518152602001915080519060200190602002808383600083146105b9575b8051825260208311156105b957602082019150602081019050602083039250610595565b5050509050019250505060405180910390f35b34156105d457fe5b6105ea600480803590602001909190505061139d565b604051808060200182810382528381815181526020019150805190602001906020028083836000831461063c575b80518252602083111561063c57602082019150602081019050602083039250610618565b5050509050019250505060405180910390f35b341561065757fe5b61065f6115cf565b6040518082815260200191505060405180910390f35b341561067d57fe5b61069360048080359060200190919050506115d5565b005b341561069d57fe5b6106b3600480803590602001909190505061168c565b005b34156106bd57fe5b610735600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611871565b6040518082815260200191505060405180910390f35b341561075357fe5b61075b611891565b6040518082815260200191505060405180910390f35b341561077957fe5b610781611896565b6040518082815260200191505060405180910390f35b341561079f57fe5b6107ea600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061189c565b005b34156107f457fe5b61080a6004808035906020019091905050611bc1565b005b60038181548110151561081b57fe5b906000526020600020900160005b915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108895760006000fd5b81600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156108e35760006000fd5b6000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600091505b600160038054905003821015610a6f578273ffffffffffffffffffffffffffffffffffffffff1660038381548110151561097657fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610a615760036001600380549050038154811015156109d657fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600383815481101515610a1257fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610a6f565b5b8180600101925050610940565b6001600381818054905003915081610a879190611edd565b506003805490506004541115610aa657610aa56003805490506115d5565b5b8273ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405180905060405180910390a25b5b505b5050565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610b4e5760006000fd5b81336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610bba5760006000fd5b836000600082815260200190815260200160002060030160009054906101000a900460ff1615610bea5760006000fd5b60006001600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550843373ffffffffffffffffffffffffffffffffffffffff167ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e960405180905060405180910390a35b5b505b50505b5050565b60026020528060005260406000206000915054906101000a900460ff1681565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b60006000600090505b600554811015610d8357838015610d3557506000600082815260200190815260200160002060030160009054906101000a900460ff16155b80610d695750828015610d6857506000600082815260200190815260200160002060030160009054906101000a900460ff165b5b15610d75576001820191505b5b8080600101915050610cfd565b5b5092915050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610dc65760006000fd5b80600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610e1f5760006000fd5b8160008173ffffffffffffffffffffffffffffffffffffffff161415610e455760006000fd5b6001600380549050016004546032821180610e5f57508181115b80610e6a5750600081145b80610e755750600082145b15610e805760006000fd5b6001600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060038054806001018281610eec9190611f09565b916000526020600020900160005b87909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550508473ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405180905060405180910390a25b5b50505b505b505b50565b60006000600060009150600090505b60038054905081101561107057600160008581526020019081526020016000206000600383815481101515610fce57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561104f576001820191505b6004548214156110625760019250611071565b5b8080600101915050610f9d565b5b5050919050565b60006000600090505b600380549050811015611141576001600084815260200190815260200160002060006003838154811015156110b257fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611133576001820191505b5b8080600101915050611081565b5b50919050565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600101549080600201908060030160009054906101000a900460ff16905084565b6111ac611f35565b600380548060200260200160405190810160405280929190818152602001828054801561122e57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116111e4575b505050505090505b90565b611241611f49565b611249611f49565b6000600060055460405180591061125d5750595b908082528060200260200182016040525b50925060009150600090505b60055481101561131d578580156112b257506000600082815260200190815260200160002060030160009054906101000a900460ff16155b806112e657508480156112e557506000600082815260200190815260200160002060030160009054906101000a900460ff165b5b1561130f578083838151811015156112fa57fe5b90602001906020020181815250506001820191505b5b808060010191505061127a565b87870360405180591061132d5750595b908082528060200260200182016040525b5093508790505b8681101561139157828181518110151561135b57fe5b906020019060200201518489830381518110151561137557fe5b90602001906020020181815250505b8080600101915050611345565b5b505050949350505050565b6113a5611f35565b6113ad611f35565b600060006003805490506040518059106113c45750595b908082528060200260200182016040525b50925060009150600090505b6003805490508110156115275760016000868152602001908152602001600020600060038381548110151561141257fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156115195760038181548110151561149b57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683838151811015156114d657fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001820191505b5b80806001019150506113e1565b816040518059106115355750595b908082528060200260200182016040525b509350600090505b818110156115c657828181518110151561156457fe5b90602001906020020151848281518110151561157c57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b808060010191505061154e565b5b505050919050565b60055481565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156116105760006000fd5b60038054905081603282118061162557508181115b806116305750600081145b8061163b5750600082145b156116465760006000fd5b826004819055507fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a836040518082815260200191505060405180910390a15b5b50505b50565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156116e65760006000fd5b8160006000600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156117425760006000fd5b82336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156117ad5760006000fd5b60016001600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550843373ffffffffffffffffffffffffffffffffffffffff167f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef60405180905060405180910390a361186685611bc1565b5b5b50505b505b5050565b600061187e848484611d86565b90506118898161168c565b5b9392505050565b603281565b60045481565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118d95760006000fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156119335760006000fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561198c5760006000fd5b600092505b600380549050831015611a7a578473ffffffffffffffffffffffffffffffffffffffff166003848154811015156119c457fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a6c5783600384815481101515611a1d57fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611a7a565b5b8280600101935050611991565b6000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508473ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405180905060405180910390a28373ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405180905060405180910390a25b5b505b505b505050565b6000816000600082815260200190815260200160002060030160009054906101000a900460ff1615611bf35760006000fd5b611bfc83610f8e565b15611d7f5760006000848152602001908152602001600020915060018260030160006101000a81548160ff0219169083151502179055508160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168260010154836002016040518082805460018160011615610100020316600290048015611cdc5780601f10611cb157610100808354040283529160200191611cdc565b820191906000526020600020905b815481529060010190602001808311611cbf57829003601f168201915b505091505060006040518083038185876185025a03f19250505015611d3057827f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7560405180905060405180910390a2611d7e565b827f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923660405180905060405180910390a260008260030160006101000a81548160ff0219169083151502179055505b5b5b5b505050565b60008360008173ffffffffffffffffffffffffffffffffffffffff161415611dae5760006000fd5b60055491506080604051908101604052808673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001600015158152506000600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002019080519060200190611e6e929190611f5d565b5060608201518160030160006101000a81548160ff0219169083151502179055509050506001600560008282540192505081905550817fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5160405180905060405180910390a25b5b509392505050565b815481835581811511611f0457818360005260206000209182019101611f039190611fdd565b5b505050565b815481835581811511611f3057818360005260206000209182019101611f2f9190611fdd565b5b505050565b602060405190810160405280600081525090565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611f9e57805160ff1916838001178555611fcc565b82800160010185558215611fcc579182015b82811115611fcb578251825591602001919060010190611fb0565b5b509050611fd99190611fdd565b5090565b611fff91905b80821115611ffb576000816000905550600101611fe3565b5090565b905600a165627a7a7230582037376d0ddd0c0be43b8a9a66d16ad08c1e2fdbae90c81561ee56cd32dfb316730029",
+ "unlinked_binary": "0x606060405234156200000d57fe5b604051620018013803806200180183398101604052805160208201519101905b600082518260328211806200004157508181115b806200004b575080155b8062000055575081155b15620000615760006000fd5b600092505b845183101562000136576002600086858151811015156200008357fe5b6020908102909101810151600160a060020a031682528101919091526040016000205460ff1680620000d657508483815181101515620000bf57fe5b90602001906020020151600160a060020a03166000145b15620000e25760006000fd5b6001600260008786815181101515620000f757fe5b602090810291909101810151600160a060020a03168252810191909152604001600020805460ff19169115159190911790555b60019092019162000066565b84516200014b9060039060208801906200015e565b5060048490555b5b5050505050620001f7565b828054828255906000526020600020908101928215620001b6579160200282015b82811115620001b65782518254600160a060020a031916600160a060020a039091161782556020909201916001909101906200017f565b5b50620001c5929150620001c9565b5090565b620001f491905b80821115620001c5578054600160a060020a0319168155600101620001d0565b5090565b90565b6115fa80620002076000396000f300606060405236156101015763ffffffff60e060020a600035041663025e7c278114610153578063173825d91461018257806320ea8d86146101a05780632f54bf6e146101b55780633411c81c146101e557806354741525146102185780637065cb4814610244578063784547a7146102625780638b51d13f146102895780639ace38c2146102ae578063a0e67e2b1461036b578063a8abe69a146103d6578063b5dc40c314610451578063b77bf600146104bf578063ba51a6df146104e1578063c01a8c84146104f6578063c64274741461050b578063d74f8edd14610580578063dc8452cd146105a2578063e20056e6146105c4578063ee22610b146105e8575b6101515b600034111561014e57604080513481529051600160a060020a033316917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a25b5b565b005b341561015b57fe5b6101666004356105fd565b60408051600160a060020a039092168252519081900360200190f35b341561018a57fe5b610151600160a060020a036004351661062f565b005b34156101a857fe5b6101516004356107ce565b005b34156101bd57fe5b6101d1600160a060020a03600435166108ab565b604080519115158252519081900360200190f35b34156101ed57fe5b6101d1600435600160a060020a03602435166108c0565b604080519115158252519081900360200190f35b341561022057fe5b610232600435151560243515156108e0565b60408051918252519081900360200190f35b341561024c57fe5b610151600160a060020a036004351661094f565b005b341561026a57fe5b6101d1600435610a74565b604080519115158252519081900360200190f35b341561029157fe5b610232600435610b08565b60408051918252519081900360200190f35b34156102b657fe5b6102c1600435610b87565b60408051600160a060020a03861681526020810185905282151560608201526080918101828152845460026000196101006001841615020190911604928201839052909160a0830190859080156103595780601f1061032e57610100808354040283529160200191610359565b820191906000526020600020905b81548152906001019060200180831161033c57829003601f168201915b50509550505050505060405180910390f35b341561037357fe5b61037b610bbb565b60408051602080825283518183015283519192839290830191858101910280838382156103c3575b8051825260208311156103c357601f1990920191602091820191016103a3565b5050509050019250505060405180910390f35b34156103de57fe5b61037b60043560243560443515156064351515610c24565b60408051602080825283518183015283519192839290830191858101910280838382156103c3575b8051825260208311156103c357601f1990920191602091820191016103a3565b5050509050019250505060405180910390f35b341561045957fe5b61037b600435610d59565b60408051602080825283518183015283519192839290830191858101910280838382156103c3575b8051825260208311156103c357601f1990920191602091820191016103a3565b5050509050019250505060405180910390f35b34156104c757fe5b610232610ee1565b60408051918252519081900360200190f35b34156104e957fe5b610151600435610ee7565b005b34156104fe57fe5b610151600435610f77565b005b341561051357fe5b604080516020600460443581810135601f8101849004840285018401909552848452610232948235600160a060020a031694602480359560649492939190920191819084018382808284375094965061106595505050505050565b60408051918252519081900360200190f35b341561058857fe5b610232611085565b60408051918252519081900360200190f35b34156105aa57fe5b61023261108a565b60408051918252519081900360200190f35b34156105cc57fe5b610151600160a060020a0360043581169060243516611090565b005b34156105f057fe5b610151600435611228565b005b600380548290811061060b57fe5b906000526020600020900160005b915054906101000a9004600160a060020a031681565b600030600160a060020a031633600160a060020a03161415156106525760006000fd5b600160a060020a038216600090815260026020526040902054829060ff16151561067c5760006000fd5b600160a060020a0383166000908152600260205260408120805460ff1916905591505b600354600019018210156107775782600160a060020a03166003838154811015156106c657fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600160a060020a0316141561076b5760038054600019810190811061070757fe5b906000526020600020900160005b9054906101000a9004600160a060020a031660038381548110151561073657fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a03160217905550610777565b5b60019091019061069f565b60038054600019019061078a9082611476565b5060035460045411156107a3576003546107a390610ee7565b5b604051600160a060020a038416906000805160206115af83398151915290600090a25b5b505b5050565b33600160a060020a03811660009081526002602052604090205460ff1615156107f75760006000fd5b600082815260016020908152604080832033600160a060020a038116855292529091205483919060ff16151561082d5760006000fd5b600084815260208190526040902060030154849060ff161561084f5760006000fd5b6000858152600160209081526040808320600160a060020a0333168085529252808320805460ff191690555187927ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e991a35b5b505b50505b5050565b60026020526000908152604090205460ff1681565b600160209081526000928352604080842090915290825290205460ff1681565b6000805b6005548110156109475783801561090d575060008181526020819052604090206003015460ff16155b806109315750828015610931575060008181526020819052604090206003015460ff165b5b1561093e576001820191505b5b6001016108e4565b5b5092915050565b30600160a060020a031633600160a060020a03161415156109705760006000fd5b600160a060020a038116600090815260026020526040902054819060ff16156109995760006000fd5b81600160a060020a03811615156109b05760006000fd5b60038054905060010160045460328211806109ca57508181115b806109d3575080155b806109dc575081155b156109e75760006000fd5b600160a060020a0385166000908152600260205260409020805460ff191660019081179091556003805490918101610a1f8382611476565b916000526020600020900160005b8154600160a060020a03808a166101009390930a8381029102199091161790915560405190915060008051602061158f83398151915290600090a25b5b50505b505b505b50565b600080805b600354811015610b005760008481526001602052604081206003805491929184908110610aa257fe5b906000526020600020900160005b9054600160a060020a036101009290920a900416815260208101919091526040016000205460ff1615610ae4576001820191505b600454821415610af75760019250610b00565b5b600101610a79565b5b5050919050565b6000805b600354811015610b805760008381526001602052604081206003805491929184908110610b3557fe5b906000526020600020900160005b9054600160a060020a036101009290920a900416815260208101919091526040016000205460ff1615610b77576001820191505b5b600101610b0c565b5b50919050565b6000602081905290815260409020805460018201546003830154600160a060020a0390921692909160029091019060ff1684565b610bc36114ca565b6003805480602002602001604051908101604052809291908181526020018280548015610c1957602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610bfb575b505050505090505b90565b610c2c6114ca565b610c346114ca565b60006000600554604051805910610c485750595b908082528060200260200182016040525b50925060009150600090505b600554811015610ce257858015610c8e575060008181526020819052604090206003015460ff16155b80610cb25750848015610cb2575060008181526020819052604090206003015460ff165b5b15610cd957808383815181101515610cc757fe5b60209081029091010152600191909101905b5b600101610c65565b878703604051805910610cf25750595b908082528060200260200182016040525b5093508790505b86811015610d4d578281815181101515610d2057fe5b9060200190602002015184898303815181101515610d3a57fe5b602090810290910101525b600101610d0a565b5b505050949350505050565b610d616114ca565b610d696114ca565b6003546040516000918291805910610d7e5750595b908082528060200260200182016040525b50925060009150600090505b600354811015610e635760008581526001602052604081206003805491929184908110610dc457fe5b906000526020600020900160005b9054600160a060020a036101009290920a900416815260208101919091526040016000205460ff1615610e5a576003805482908110610e0d57fe5b906000526020600020900160005b9054906101000a9004600160a060020a03168383815181101515610e3b57fe5b600160a060020a03909216602092830290910190910152600191909101905b5b600101610d9b565b81604051805910610e715750595b908082528060200260200182016040525b509350600090505b81811015610ed8578281815181101515610ea057fe5b906020019060200201518482815181101515610eb857fe5b600160a060020a039092166020928302909101909101525b600101610e8a565b5b505050919050565b60055481565b30600160a060020a031633600160a060020a0316141515610f085760006000fd5b600354816032821180610f1a57508181115b80610f23575080155b80610f2c575081155b15610f375760006000fd5b60048390556040805184815290517fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a9181900360200190a15b5b50505b50565b33600160a060020a03811660009081526002602052604090205460ff161515610fa05760006000fd5b6000828152602081905260409020548290600160a060020a03161515610fc65760006000fd5b600083815260016020908152604080832033600160a060020a038116855292529091205484919060ff1615610ffb5760006000fd5b6000858152600160208181526040808420600160a060020a0333168086529252808420805460ff1916909317909255905187927f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef91a36108a185611228565b5b5b50505b505b5050565b6000611072848484611390565b905061107d81610f77565b5b9392505050565b603281565b60045481565b600030600160a060020a031633600160a060020a03161415156110b35760006000fd5b600160a060020a038316600090815260026020526040902054839060ff1615156110dd5760006000fd5b600160a060020a038316600090815260026020526040902054839060ff16156111065760006000fd5b600092505b6003548310156111ae5784600160a060020a031660038481548110151561112e57fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600160a060020a031614156111a2578360038481548110151561116d57fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a031602179055506111ae565b5b60019092019161110b565b600160a060020a03808616600081815260026020526040808220805460ff1990811690915593881682528082208054909416600117909355915190916000805160206115af83398151915291a2604051600160a060020a0385169060008051602061158f83398151915290600090a25b5b505b505b505050565b600081815260208190526040812060030154829060ff161561124a5760006000fd5b61125383610a74565b156107c7576000838152602081905260409081902060038101805460ff19166001908117909155815481830154935160028085018054959850600160a060020a03909316959492939192839285926000199183161561010002919091019091160480156113015780601f106112d657610100808354040283529160200191611301565b820191906000526020600020905b8154815290600101906020018083116112e457829003601f168201915b505091505060006040518083038185876187965a03f192505050156113505760405183907f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7590600090a26107c7565b60405183907f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923690600090a260038201805460ff191690555b5b5b5b505050565b600083600160a060020a03811615156113a95760006000fd5b60055460408051608081018252600160a060020a03888116825260208083018981528385018981526000606086018190528781528084529590952084518154600160a060020a0319169416939093178355516001830155925180519496509193909261141c9260028501929101906114ee565b50606091909101516003909101805460ff191691151591909117905560058054600101905560405182907fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5190600090a25b5b509392505050565b8154818355818115116107c7576000838152602090206107c791810190830161156d565b5b505050565b8154818355818115116107c7576000838152602090206107c791810190830161156d565b5b505050565b60408051602081019091526000815290565b60408051602081019091526000815290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061152f57805160ff191683800117855561155c565b8280016001018555821561155c579182015b8281111561155c578251825591602001919060010190611541565b5b5061156992915061156d565b5090565b610c2191905b808211156115695760008155600101611573565b5090565b905600f39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b90a165627a7a723058202f72592fe4e3a02180fe200a1e87105cc2db68ed7d59c782cc0e156fd816af640029",
"networks": {},
"schema_version": "0.0.5",
- "updated_at": 1502391449722
+ "updated_at": 1513088402049
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/MultiSigWalletWithTimeLock.json b/packages/contracts/build/contracts/MultiSigWalletWithTimeLock.json
index 8bab88188..a44d63919 100644
--- a/packages/contracts/build/contracts/MultiSigWalletWithTimeLock.json
+++ b/packages/contracts/build/contracts/MultiSigWalletWithTimeLock.json
@@ -587,7 +587,7 @@
"type": "event"
}
],
- "unlinked_binary": "0x606060405234156200000d57fe5b6040516200250138038062002501833981016040528080518201919060200180519060200190919080519060200190919050505b82825b600082518260328211806200005857508181115b80620000645750600081145b80620000705750600082145b156200007c5760006000fd5b600092505b8451831015620001b5576002600086858151811015156200009e57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806200012a5750600085848151811015156200010857fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff16145b15620001365760006000fd5b60016002600087868151811015156200014b57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b828060010193505062000081565b8460039080519060200190620001cd929190620001ed565b50836004819055505b5b5050505050806006819055505b505050620002c2565b82805482825590600052602060002090810192821562000269579160200282015b82811115620002685782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550916020019190600101906200020e565b5b5090506200027891906200027c565b5090565b620002bf91905b80821115620002bb57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555060010162000283565b5090565b90565b61222f80620002d26000396000f3006060604052361561013c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063025e7c271461019d578063173825d9146101fd57806320ea8d86146102335780632f54bf6e146102535780633411c81c146102a157806337bd78a0146102f8578063547415251461031e5780637065cb481461035f578063784547a7146103955780637ad28c51146103cd5780638b51d13f146103ed5780639ace38c214610421578063a0e67e2b1461051c578063a8abe69a14610591578063b5dc40c314610633578063b77bf600146106b6578063ba51a6df146106dc578063c01a8c84146106fc578063c64274741461071c578063d38f2d82146107b2578063d74f8edd146107e6578063dc8452cd1461080c578063e20056e614610832578063ee22610b14610887575b61019b5b6000341115610198573373ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c346040518082815260200191505060405180910390a25b5b565b005b34156101a557fe5b6101bb60048080359060200190919050506108a7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561020557fe5b610231600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108e7565b005b341561023b57fe5b6102516004808035906020019091905050610b8f565b005b341561025b57fe5b610287600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d59565b604051808215151515815260200191505060405180910390f35b34156102a957fe5b6102de600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d79565b604051808215151515815260200191505060405180910390f35b341561030057fe5b610308610da8565b6040518082815260200191505060405180910390f35b341561032657fe5b610349600480803515159060200190919080351515906020019091905050610dae565b6040518082815260200191505060405180910390f35b341561036757fe5b610393600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e45565b005b341561039d57fe5b6103b36004808035906020019091905050611048565b604051808215151515815260200191505060405180910390f35b34156103d557fe5b6103eb6004808035906020019091905050611132565b005b34156103f557fe5b61040b60048080359060200190919050506111b0565b6040518082815260200191505060405180910390f35b341561042957fe5b61043f6004808035906020019091905050611280565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018315151515815260200182810382528481815460018160011615610100020316600290048152602001915080546001816001161561010002031660029004801561050a5780601f106104df5761010080835404028352916020019161050a565b820191906000526020600020905b8154815290600101906020018083116104ed57829003601f168201915b50509550505050505060405180910390f35b341561052457fe5b61052c6112dc565b604051808060200182810382528381815181526020019150805190602001906020028083836000831461057e575b80518252602083111561057e5760208201915060208101905060208303925061055a565b5050509050019250505060405180910390f35b341561059957fe5b6105ce600480803590602001909190803590602001909190803515159060200190919080351515906020019091905050611371565b6040518080602001828103825283818151815260200191508051906020019060200280838360008314610620575b805182526020831115610620576020820191506020810190506020830392506105fc565b5050509050019250505060405180910390f35b341561063b57fe5b61065160048080359060200190919050506114d5565b60405180806020018281038252838181518152602001915080519060200190602002808383600083146106a3575b8051825260208311156106a35760208201915060208101905060208303925061067f565b5050509050019250505060405180910390f35b34156106be57fe5b6106c6611707565b6040518082815260200191505060405180910390f35b34156106e457fe5b6106fa600480803590602001909190505061170d565b005b341561070457fe5b61071a60048080359060200190919050506117c4565b005b341561072457fe5b61079c600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506119d2565b6040518082815260200191505060405180910390f35b34156107ba57fe5b6107d060048080359060200190919050506119f2565b6040518082815260200191505060405180910390f35b34156107ee57fe5b6107f6611a0a565b6040518082815260200191505060405180910390f35b341561081457fe5b61081c611a0f565b6040518082815260200191505060405180910390f35b341561083a57fe5b610885600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611a15565b005b341561088f57fe5b6108a56004808035906020019091905050611d3a565b005b6003818154811015156108b657fe5b906000526020600020900160005b915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109245760006000fd5b81600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561097e5760006000fd5b6000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600091505b600160038054905003821015610b0a578273ffffffffffffffffffffffffffffffffffffffff16600383815481101515610a1157fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610afc576003600160038054905003815481101515610a7157fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600383815481101515610aad57fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610b0a565b5b81806001019250506109db565b6001600381818054905003915081610b2291906120de565b506003805490506004541115610b4157610b4060038054905061170d565b5b8273ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405180905060405180910390a25b5b505b5050565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610be95760006000fd5b81336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610c555760006000fd5b836000600082815260200190815260200160002060030160009054906101000a900460ff1615610c855760006000fd5b84610c8f81611048565b151515610c9c5760006000fd5b60006001600088815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550853373ffffffffffffffffffffffffffffffffffffffff167ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e960405180905060405180910390a35b5b505b505b50505b5050565b60026020528060005260406000206000915054906101000a900460ff1681565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b60065481565b60006000600090505b600554811015610e3d57838015610def57506000600082815260200190815260200160002060030160009054906101000a900460ff16155b80610e235750828015610e2257506000600082815260200190815260200160002060030160009054906101000a900460ff165b5b15610e2f576001820191505b5b8080600101915050610db7565b5b5092915050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e805760006000fd5b80600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610ed95760006000fd5b8160008173ffffffffffffffffffffffffffffffffffffffff161415610eff5760006000fd5b6001600380549050016004546032821180610f1957508181115b80610f245750600081145b80610f2f5750600082145b15610f3a5760006000fd5b6001600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060038054806001018281610fa6919061210a565b916000526020600020900160005b87909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550508473ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405180905060405180910390a25b5b50505b505b505b50565b60006000600060009150600090505b60038054905081101561112a5760016000858152602001908152602001600020600060038381548110151561108857fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611109576001820191505b60045482141561111c576001925061112b565b5b8080600101915050611057565b5b5050919050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561116d5760006000fd5b806006819055507fd1c9101a34feff75cccef14a28785a0279cb0b49c1f321f21f5f422e746b4377816040518082815260200191505060405180910390a15b5b50565b60006000600090505b600380549050811015611279576001600084815260200190815260200160002060006003838154811015156111ea57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561126b576001820191505b5b80806001019150506111b9565b5b50919050565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600101549080600201908060030160009054906101000a900460ff16905084565b6112e4612136565b600380548060200260200160405190810160405280929190818152602001828054801561136657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001906001019080831161131c575b505050505090505b90565b61137961214a565b61138161214a565b600060006005546040518059106113955750595b908082528060200260200182016040525b50925060009150600090505b600554811015611455578580156113ea57506000600082815260200190815260200160002060030160009054906101000a900460ff16155b8061141e575084801561141d57506000600082815260200190815260200160002060030160009054906101000a900460ff165b5b156114475780838381518110151561143257fe5b90602001906020020181815250506001820191505b5b80806001019150506113b2565b8787036040518059106114655750595b908082528060200260200182016040525b5093508790505b868110156114c957828181518110151561149357fe5b90602001906020020151848983038151811015156114ad57fe5b90602001906020020181815250505b808060010191505061147d565b5b505050949350505050565b6114dd612136565b6114e5612136565b600060006003805490506040518059106114fc5750595b908082528060200260200182016040525b50925060009150600090505b60038054905081101561165f5760016000868152602001908152602001600020600060038381548110151561154a57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611651576003818154811015156115d357fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16838381518110151561160e57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001820191505b5b8080600101915050611519565b8160405180591061166d5750595b908082528060200260200182016040525b509350600090505b818110156116fe57828181518110151561169c57fe5b9060200190602002015184828151811015156116b457fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8080600101915050611686565b5b505050919050565b60055481565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156117485760006000fd5b60038054905081603282118061175d57508181115b806117685750600081145b806117735750600082145b1561177e5760006000fd5b826004819055507fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a836040518082815260200191505060405180910390a15b5b50505b50565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561181e5760006000fd5b8160006000600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561187a5760006000fd5b82336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156118e55760006000fd5b846118ef81611048565b1515156118fc5760006000fd5b60016001600088815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550853373ffffffffffffffffffffffffffffffffffffffff167f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef60405180905060405180910390a36119b586611048565b156119c5576119c48642611f32565b5b5b5b505b50505b505b5050565b60006119df848484611f87565b90506119ea816117c4565b5b9392505050565b60076020528060005260406000206000915090505481565b603281565b60045481565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611a525760006000fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611aac5760006000fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611b055760006000fd5b600092505b600380549050831015611bf3578473ffffffffffffffffffffffffffffffffffffffff16600384815481101515611b3d57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611be55783600384815481101515611b9657fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611bf3565b5b8280600101935050611b0a565b6000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508473ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405180905060405180910390a28373ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405180905060405180910390a25b5b505b505b505050565b6000816000600082815260200190815260200160002060030160009054906101000a900460ff1615611d6c5760006000fd5b82611d7681611048565b1515611d825760006000fd5b836006546007600083815260200190815260200160002054014210151515611daa5760006000fd5b60006000868152602001908152602001600020935060018460030160006101000a81548160ff0219169083151502179055508360000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168460010154856002016040518082805460018160011615610100020316600290048015611e855780601f10611e5a57610100808354040283529160200191611e85565b820191906000526020600020905b815481529060010190602001808311611e6857829003601f168201915b505091505060006040518083038185876185025a03f19250505015611ed957847f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7560405180905060405180910390a2611f27565b847f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923660405180905060405180910390a260008460030160006101000a81548160ff0219169083151502179055505b5b5b505b505b505050565b806007600084815260200190815260200160002081905550817f0b237afe65f1514fd7ea3f923ea4fe792bdd07000a912b6cd1602a8e7f573c8d826040518082815260200191505060405180910390a25b5050565b60008360008173ffffffffffffffffffffffffffffffffffffffff161415611faf5760006000fd5b60055491506080604051908101604052808673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001600015158152506000600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155604082015181600201908051906020019061206f92919061215e565b5060608201518160030160006101000a81548160ff0219169083151502179055509050506001600560008282540192505081905550817fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5160405180905060405180910390a25b5b509392505050565b8154818355818115116121055781836000526020600020918201910161210491906121de565b5b505050565b8154818355818115116121315781836000526020600020918201910161213091906121de565b5b505050565b602060405190810160405280600081525090565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061219f57805160ff19168380011785556121cd565b828001600101855582156121cd579182015b828111156121cc5782518255916020019190600101906121b1565b5b5090506121da91906121de565b5090565b61220091905b808211156121fc5760008160009055506001016121e4565b5090565b905600a165627a7a723058204556921b5aaeabf763e47d995d7dd454b524b39bf1564247a5711e05292a88c10029",
+ "unlinked_binary": "0x606060405234156200000d57fe5b604051620019bd380380620019bd83398101604090815281516020830151918301519201915b82825b600082518260328211806200004a57508181115b8062000054575080155b806200005e575081155b156200006a5760006000fd5b600092505b84518310156200013f576002600086858151811015156200008c57fe5b6020908102909101810151600160a060020a031682528101919091526040016000205460ff1680620000df57508483815181101515620000c857fe5b90602001906020020151600160a060020a03166000145b15620000eb5760006000fd5b60016002600087868151811015156200010057fe5b602090810291909101810151600160a060020a03168252810191909152604001600020805460ff19169115159190911790555b6001909201916200006f565b84516200015490600390602088019062000170565b5060048490555b5b505050600683905550505b50505062000209565b828054828255906000526020600020908101928215620001c8579160200282015b82811115620001c85782518254600160a060020a031916600160a060020a0390911617825560209092019160019091019062000191565b5b50620001d7929150620001db565b5090565b6200020691905b80821115620001d7578054600160a060020a0319168155600101620001e2565b5090565b90565b6117a480620002196000396000f300606060405236156101225763ffffffff60e060020a600035041663025e7c278114610174578063173825d9146101a357806320ea8d86146101c15780632f54bf6e146101d65780633411c81c1461020657806337bd78a014610239578063547415251461025b5780637065cb4814610287578063784547a7146102a55780637ad28c51146102cc5780638b51d13f146102e15780639ace38c214610306578063a0e67e2b146103c3578063a8abe69a1461042e578063b5dc40c3146104a9578063b77bf60014610517578063ba51a6df14610539578063c01a8c841461054e578063c642747414610563578063d38f2d82146105d8578063d74f8edd146105fd578063dc8452cd1461061f578063e20056e614610641578063ee22610b14610665575b6101725b600034111561016f57604080513481529051600160a060020a033316917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a25b5b565b005b341561017c57fe5b61018760043561067a565b60408051600160a060020a039092168252519081900360200190f35b34156101ab57fe5b610172600160a060020a03600435166106ac565b005b34156101c957fe5b61017260043561084b565b005b34156101de57fe5b6101f2600160a060020a036004351661093f565b604080519115158252519081900360200190f35b341561020e57fe5b6101f2600435600160a060020a0360243516610954565b604080519115158252519081900360200190f35b341561024157fe5b610249610974565b60408051918252519081900360200190f35b341561026357fe5b6102496004351515602435151561097a565b60408051918252519081900360200190f35b341561028f57fe5b610172600160a060020a03600435166109e9565b005b34156102ad57fe5b6101f2600435610b0e565b604080519115158252519081900360200190f35b34156102d457fe5b610172600435610ba2565b005b34156102e957fe5b610249600435610c00565b60408051918252519081900360200190f35b341561030e57fe5b610319600435610c7f565b60408051600160a060020a03861681526020810185905282151560608201526080918101828152845460026000196101006001841615020190911604928201839052909160a0830190859080156103b15780601f10610386576101008083540402835291602001916103b1565b820191906000526020600020905b81548152906001019060200180831161039457829003601f168201915b50509550505050505060405180910390f35b34156103cb57fe5b6103d3610cb3565b604080516020808252835181830152835191928392908301918581019102808383821561041b575b80518252602083111561041b57601f1990920191602091820191016103fb565b5050509050019250505060405180910390f35b341561043657fe5b6103d360043560243560443515156064351515610d1c565b604080516020808252835181830152835191928392908301918581019102808383821561041b575b80518252602083111561041b57601f1990920191602091820191016103fb565b5050509050019250505060405180910390f35b34156104b157fe5b6103d3600435610e51565b604080516020808252835181830152835191928392908301918581019102808383821561041b575b80518252602083111561041b57601f1990920191602091820191016103fb565b5050509050019250505060405180910390f35b341561051f57fe5b610249610fd9565b60408051918252519081900360200190f35b341561054157fe5b610172600435610fdf565b005b341561055657fe5b61017260043561106f565b005b341561056b57fe5b604080516020600460443581810135601f8101849004840285018401909552848452610249948235600160a060020a031694602480359560649492939190920191819084018382808284375094965061118495505050505050565b60408051918252519081900360200190f35b34156105e057fe5b6102496004356111a4565b60408051918252519081900360200190f35b341561060557fe5b6102496111b6565b60408051918252519081900360200190f35b341561062757fe5b6102496111bb565b60408051918252519081900360200190f35b341561064957fe5b610172600160a060020a03600435811690602435166111c1565b005b341561066d57fe5b610172600435611359565b005b600380548290811061068857fe5b906000526020600020900160005b915054906101000a9004600160a060020a031681565b600030600160a060020a031633600160a060020a03161415156106cf5760006000fd5b600160a060020a038216600090815260026020526040902054829060ff1615156106f95760006000fd5b600160a060020a0383166000908152600260205260408120805460ff1916905591505b600354600019018210156107f45782600160a060020a031660038381548110151561074357fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600160a060020a031614156107e85760038054600019810190811061078457fe5b906000526020600020900160005b9054906101000a9004600160a060020a03166003838154811015156107b357fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a031602179055506107f4565b5b60019091019061071c565b6003805460001901906108079082611620565b5060035460045411156108205760035461082090610fdf565b5b604051600160a060020a0384169060008051602061175983398151915290600090a25b5b505b5050565b33600160a060020a03811660009081526002602052604090205460ff1615156108745760006000fd5b600082815260016020908152604080832033600160a060020a038116855292529091205483919060ff1615156108aa5760006000fd5b600084815260208190526040902060030154849060ff16156108cc5760006000fd5b846108d681610b0e565b156108e15760006000fd5b6000868152600160209081526040808320600160a060020a0333168085529252808320805460ff191690555188927ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e991a35b5b505b505b50505b5050565b60026020526000908152604090205460ff1681565b600160209081526000928352604080842090915290825290205460ff1681565b60065481565b6000805b6005548110156109e1578380156109a7575060008181526020819052604090206003015460ff16155b806109cb57508280156109cb575060008181526020819052604090206003015460ff165b5b156109d8576001820191505b5b60010161097e565b5b5092915050565b30600160a060020a031633600160a060020a0316141515610a0a5760006000fd5b600160a060020a038116600090815260026020526040902054819060ff1615610a335760006000fd5b81600160a060020a0381161515610a4a5760006000fd5b6003805490506001016004546032821180610a6457508181115b80610a6d575080155b80610a76575081155b15610a815760006000fd5b600160a060020a0385166000908152600260205260409020805460ff191660019081179091556003805490918101610ab98382611620565b916000526020600020900160005b8154600160a060020a03808a166101009390930a8381029102199091161790915560405190915060008051602061173983398151915290600090a25b5b50505b505b505b50565b600080805b600354811015610b9a5760008481526001602052604081206003805491929184908110610b3c57fe5b906000526020600020900160005b9054600160a060020a036101009290920a900416815260208101919091526040016000205460ff1615610b7e576001820191505b600454821415610b915760019250610b9a565b5b600101610b13565b5b5050919050565b30600160a060020a031633600160a060020a0316141515610bc35760006000fd5b60068190556040805182815290517fd1c9101a34feff75cccef14a28785a0279cb0b49c1f321f21f5f422e746b43779181900360200190a15b5b50565b6000805b600354811015610c785760008381526001602052604081206003805491929184908110610c2d57fe5b906000526020600020900160005b9054600160a060020a036101009290920a900416815260208101919091526040016000205460ff1615610c6f576001820191505b5b600101610c04565b5b50919050565b6000602081905290815260409020805460018201546003830154600160a060020a0390921692909160029091019060ff1684565b610cbb611674565b6003805480602002602001604051908101604052809291908181526020018280548015610d1157602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610cf3575b505050505090505b90565b610d24611674565b610d2c611674565b60006000600554604051805910610d405750595b908082528060200260200182016040525b50925060009150600090505b600554811015610dda57858015610d86575060008181526020819052604090206003015460ff16155b80610daa5750848015610daa575060008181526020819052604090206003015460ff165b5b15610dd157808383815181101515610dbf57fe5b60209081029091010152600191909101905b5b600101610d5d565b878703604051805910610dea5750595b908082528060200260200182016040525b5093508790505b86811015610e45578281815181101515610e1857fe5b9060200190602002015184898303815181101515610e3257fe5b602090810290910101525b600101610e02565b5b505050949350505050565b610e59611674565b610e61611674565b6003546040516000918291805910610e765750595b908082528060200260200182016040525b50925060009150600090505b600354811015610f5b5760008581526001602052604081206003805491929184908110610ebc57fe5b906000526020600020900160005b9054600160a060020a036101009290920a900416815260208101919091526040016000205460ff1615610f52576003805482908110610f0557fe5b906000526020600020900160005b9054906101000a9004600160a060020a03168383815181101515610f3357fe5b600160a060020a03909216602092830290910190910152600191909101905b5b600101610e93565b81604051805910610f695750595b908082528060200260200182016040525b509350600090505b81811015610fd0578281815181101515610f9857fe5b906020019060200201518482815181101515610fb057fe5b600160a060020a039092166020928302909101909101525b600101610f82565b5b505050919050565b60055481565b30600160a060020a031633600160a060020a03161415156110005760006000fd5b60035481603282118061101257508181115b8061101b575080155b80611024575081155b1561102f5760006000fd5b60048390556040805184815290517fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a9181900360200190a15b5b50505b50565b33600160a060020a03811660009081526002602052604090205460ff1615156110985760006000fd5b6000828152602081905260409020548290600160a060020a031615156110be5760006000fd5b600083815260016020908152604080832033600160a060020a038116855292529091205484919060ff16156110f35760006000fd5b846110fd81610b0e565b156111085760006000fd5b6000868152600160208181526040808420600160a060020a0333168086529252808420805460ff1916909317909255905188927f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef91a361116786610b0e565b156109335761093386426114ee565b5b5b5b505b50505b505b5050565b600061119184848461153a565b905061119c8161106f565b5b9392505050565b60076020526000908152604090205481565b603281565b60045481565b600030600160a060020a031633600160a060020a03161415156111e45760006000fd5b600160a060020a038316600090815260026020526040902054839060ff16151561120e5760006000fd5b600160a060020a038316600090815260026020526040902054839060ff16156112375760006000fd5b600092505b6003548310156112df5784600160a060020a031660038481548110151561125f57fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600160a060020a031614156112d3578360038481548110151561129e57fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a031602179055506112df565b5b60019092019161123c565b600160a060020a03808616600081815260026020526040808220805460ff19908116909155938816825280822080549094166001179093559151909160008051602061175983398151915291a2604051600160a060020a0385169060008051602061173983398151915290600090a25b5b505b505b505050565b600081815260208190526040812060030154829060ff161561137b5760006000fd5b8261138581610b0e565b15156113915760006000fd5b6006546000858152600760205260409020548591014210156113b35760006000fd5b6000858152602081905260409081902060038101805460ff19166001908117909155815481830154935160028085018054959a50600160a060020a039093169594929391928392859260001991831615610100029190910190911604801561145c5780601f106114315761010080835404028352916020019161145c565b820191906000526020600020905b81548152906001019060200180831161143f57829003601f168201915b505091505060006040518083038185876187965a03f192505050156114ab5760405185907f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7590600090a2610936565b60405185907f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923690600090a260038401805460ff191690555b5b5b505b505b505050565b6000828152600760209081526040918290208390558151838152915184927f0b237afe65f1514fd7ea3f923ea4fe792bdd07000a912b6cd1602a8e7f573c8d92908290030190a25b5050565b600083600160a060020a03811615156115535760006000fd5b60055460408051608081018252600160a060020a03888116825260208083018981528385018981526000606086018190528781528084529590952084518154600160a060020a031916941693909317835551600183015592518051949650919390926115c6926002850192910190611698565b50606091909101516003909101805460ff191691151591909117905560058054600101905560405182907fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5190600090a25b5b509392505050565b81548183558181151161084457600083815260209020610844918101908301611717565b5b505050565b81548183558181151161084457600083815260209020610844918101908301611717565b5b505050565b60408051602081019091526000815290565b60408051602081019091526000815290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106116d957805160ff1916838001178555611706565b82800160010185558215611706579182015b828111156117065782518255916020019190600101906116eb565b5b50611713929150611717565b5090565b610d1991905b80821115611713576000815560010161171d565b5090565b905600f39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b90a165627a7a723058205024a3509522313181eded1d65dcc3b2507127d4c31a444ec98bf6a44e4747d00029",
"networks": {
"50": {
"links": {},
@@ -745,10 +745,10 @@
"type": "event"
}
},
- "updated_at": 1502391794388,
- "address": "0x6488c866dd2a8528c2f5a9009a9fcde6fe2a3736"
+ "updated_at": 1513088404204,
+ "address": "0x1d7022f5b17d2f8b695918fb48fa1089c9f85401"
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794388
+ "updated_at": 1513088404204
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json b/packages/contracts/build/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json
index a83a284e3..454c07961 100644
--- a/packages/contracts/build/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json
+++ b/packages/contracts/build/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json
@@ -635,7 +635,7 @@
"type": "event"
}
],
- "unlinked_binary": "0x606060405234156200000d57fe5b60405162002adb38038062002adb833981016040528080518201919060200180519060200190919080519060200190919080519060200190919050505b8383835b82825b600082518260328211806200006557508181115b80620000715750600081145b806200007d5750600082145b15620000895760006000fd5b600092505b8451831015620001c257600260008685815181101515620000ab57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680620001375750600085848151811015156200011557fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff16145b15620001435760006000fd5b60016002600087868151811015156200015857fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b82806001019350506200008e565b8460039080519060200190620001da92919062000240565b50836004819055505b5b5050505050806006819055505b50505080600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5050505062000315565b828054828255906000526020600020908101928215620002bc579160200282015b82811115620002bb5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019062000261565b5b509050620002cb9190620002cf565b5090565b6200031291905b808211156200030e57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550600101620002d6565b5090565b90565b6127b680620003256000396000f3006060604052361561015d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063025e7c27146101be578063173825d91461021e57806320ea8d86146102545780632f54bf6e146102745780633411c81c146102c257806337bd78a014610319578063547415251461033f578063553a48fd146103805780635711b311146103f25780637065cb4814610412578063784547a7146104485780637ad28c51146104805780638b51d13f146104a05780639ace38c2146104d4578063a0e67e2b146105cf578063a8abe69a14610644578063add1cbc5146106e6578063b5dc40c314610738578063b77bf600146107bb578063ba51a6df146107e1578063c01a8c8414610801578063c642747414610821578063d38f2d82146108b7578063d74f8edd146108eb578063dc8452cd14610911578063e20056e614610937578063ee22610b1461098c575b6101bc5b60003411156101b9573373ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c346040518082815260200191505060405180910390a25b5b565b005b34156101c657fe5b6101dc60048080359060200190919050506109ac565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561022657fe5b610252600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506109ec565b005b341561025c57fe5b6102726004808035906020019091905050610c94565b005b341561027c57fe5b6102a8600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e5e565b604051808215151515815260200191505060405180910390f35b34156102ca57fe5b6102ff600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e7e565b604051808215151515815260200191505060405180910390f35b341561032157fe5b610329610ead565b6040518082815260200191505060405180910390f35b341561034757fe5b61036a600480803515159060200190919080351515906020019091905050610eb3565b6040518082815260200191505060405180910390f35b341561038857fe5b6103d8600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610f4a565b604051808215151515815260200191505060405180910390f35b34156103fa57fe5b610410600480803590602001909190505061108b565b005b341561041a57fe5b610446600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506113a6565b005b341561045057fe5b61046660048080359060200190919050506115a9565b604051808215151515815260200191505060405180910390f35b341561048857fe5b61049e6004808035906020019091905050611693565b005b34156104a857fe5b6104be6004808035906020019091905050611711565b6040518082815260200191505060405180910390f35b34156104dc57fe5b6104f260048080359060200190919050506117e1565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001831515151581526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156105bd5780601f10610592576101008083540402835291602001916105bd565b820191906000526020600020905b8154815290600101906020018083116105a057829003601f168201915b50509550505050505060405180910390f35b34156105d757fe5b6105df61183d565b6040518080602001828103825283818151815260200191508051906020019060200280838360008314610631575b8051825260208311156106315760208201915060208101905060208303925061060d565b5050509050019250505060405180910390f35b341561064c57fe5b6106816004808035906020019091908035906020019091908035151590602001909190803515159060200190919050506118d2565b60405180806020018281038252838181518152602001915080519060200190602002808383600083146106d3575b8051825260208311156106d3576020820191506020810190506020830392506106af565b5050509050019250505060405180910390f35b34156106ee57fe5b6106f6611a36565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561074057fe5b6107566004808035906020019091905050611a5c565b60405180806020018281038252838181518152602001915080519060200190602002808383600083146107a8575b8051825260208311156107a857602082019150602081019050602083039250610784565b5050509050019250505060405180910390f35b34156107c357fe5b6107cb611c8e565b6040518082815260200191505060405180910390f35b34156107e957fe5b6107ff6004808035906020019091905050611c94565b005b341561080957fe5b61081f6004808035906020019091905050611d4b565b005b341561082957fe5b6108a1600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611f59565b6040518082815260200191505060405180910390f35b34156108bf57fe5b6108d56004808035906020019091905050611f79565b6040518082815260200191505060405180910390f35b34156108f357fe5b6108fb611f91565b6040518082815260200191505060405180910390f35b341561091957fe5b610921611f96565b6040518082815260200191505060405180910390f35b341561093f57fe5b61098a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611f9c565b005b341561099457fe5b6109aa60048080359060200190919050506122c1565b005b6003818154811015156109bb57fe5b906000526020600020900160005b915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a295760006000fd5b81600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610a835760006000fd5b6000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600091505b600160038054905003821015610c0f578273ffffffffffffffffffffffffffffffffffffffff16600383815481101515610b1657fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610c01576003600160038054905003815481101515610b7657fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600383815481101515610bb257fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610c0f565b5b8180600101925050610ae0565b6001600381818054905003915081610c279190612665565b506003805490506004541115610c4657610c45600380549050611c94565b5b8273ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405180905060405180910390a25b5b505b5050565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610cee5760006000fd5b81336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610d5a5760006000fd5b836000600082815260200190815260200160002060030160009054906101000a900460ff1615610d8a5760006000fd5b84610d94816115a9565b151515610da15760006000fd5b60006001600088815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550853373ffffffffffffffffffffffffffffffffffffffff167ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e960405180905060405180910390a35b5b505b505b50505b5050565b60026020528060005260406000206000915054906101000a900460ff1681565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b60065481565b60006000600090505b600554811015610f4257838015610ef457506000600082815260200190815260200160002060030160009054906101000a900460ff16155b80610f285750828015610f2757506000600082815260200190815260200160002060030160009054906101000a900460ff165b5b15610f34576001820191505b5b8080600101915050610ebc565b5b5092915050565b60006000600060405180807f72656d6f7665417574686f72697a656441646472657373286164647265737329815250602001905060405180910390209150600090505b600481101561107f578181600481101515610fa457fe5b1a7f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168482815181101515610ff757fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415156110715760006000fd5b5b8080600101915050610f8d565b600192505b5050919050565b6000816000600082815260200190815260200160002060030160009054906101000a900460ff16156110bd5760006000fd5b826110c7816115a9565b15156110d35760006000fd5b836000600060008381526020019081526020016000209050600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561116c5760006000fd5b611211816002018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112075780601f106111dc57610100808354040283529160200191611207565b820191906000526020600020905b8154815290600101906020018083116111ea57829003601f168201915b5050505050610f4a565b151561121d5760006000fd5b60006000878152602001908152602001600020945060018560030160006101000a81548160ff0219169083151502179055508460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1685600101548660020160405180828054600181600116156101000203166002900480156112f85780601f106112cd576101008083540402835291602001916112f8565b820191906000526020600020905b8154815290600101906020018083116112db57829003601f168201915b505091505060006040518083038185876185025a03f1925050501561134c57857f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7560405180905060405180910390a261139a565b857f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923660405180905060405180910390a260008560030160006101000a81548160ff0219169083151502179055505b5b5b50505b505b505050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113e15760006000fd5b80600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561143a5760006000fd5b8160008173ffffffffffffffffffffffffffffffffffffffff1614156114605760006000fd5b600160038054905001600454603282118061147a57508181115b806114855750600081145b806114905750600082145b1561149b5760006000fd5b6001600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600380548060010182816115079190612691565b916000526020600020900160005b87909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550508473ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405180905060405180910390a25b5b50505b505b505b50565b60006000600060009150600090505b60038054905081101561168b576001600085815260200190815260200160002060006003838154811015156115e957fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561166a576001820191505b60045482141561167d576001925061168c565b5b80806001019150506115b8565b5b5050919050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156116ce5760006000fd5b806006819055507fd1c9101a34feff75cccef14a28785a0279cb0b49c1f321f21f5f422e746b4377816040518082815260200191505060405180910390a15b5b50565b60006000600090505b6003805490508110156117da5760016000848152602001908152602001600020600060038381548110151561174b57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156117cc576001820191505b5b808060010191505061171a565b5b50919050565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600101549080600201908060030160009054906101000a900460ff16905084565b6118456126bd565b60038054806020026020016040519081016040528092919081815260200182805480156118c757602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001906001019080831161187d575b505050505090505b90565b6118da6126d1565b6118e26126d1565b600060006005546040518059106118f65750595b908082528060200260200182016040525b50925060009150600090505b6005548110156119b65785801561194b57506000600082815260200190815260200160002060030160009054906101000a900460ff16155b8061197f575084801561197e57506000600082815260200190815260200160002060030160009054906101000a900460ff165b5b156119a85780838381518110151561199357fe5b90602001906020020181815250506001820191505b5b8080600101915050611913565b8787036040518059106119c65750595b908082528060200260200182016040525b5093508790505b86811015611a2a5782818151811015156119f457fe5b9060200190602002015184898303815181101515611a0e57fe5b90602001906020020181815250505b80806001019150506119de565b5b505050949350505050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611a646126bd565b611a6c6126bd565b60006000600380549050604051805910611a835750595b908082528060200260200182016040525b50925060009150600090505b600380549050811015611be657600160008681526020019081526020016000206000600383815481101515611ad157fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611bd857600381815481101515611b5a57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff168383815181101515611b9557fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001820191505b5b8080600101915050611aa0565b81604051805910611bf45750595b908082528060200260200182016040525b509350600090505b81811015611c85578281815181101515611c2357fe5b906020019060200201518482815181101515611c3b57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8080600101915050611c0d565b5b505050919050565b60055481565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611ccf5760006000fd5b600380549050816032821180611ce457508181115b80611cef5750600081145b80611cfa5750600082145b15611d055760006000fd5b826004819055507fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a836040518082815260200191505060405180910390a15b5b50505b50565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611da55760006000fd5b8160006000600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611e015760006000fd5b82336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611e6c5760006000fd5b84611e76816115a9565b151515611e835760006000fd5b60016001600088815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550853373ffffffffffffffffffffffffffffffffffffffff167f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef60405180905060405180910390a3611f3c866115a9565b15611f4c57611f4b86426124b9565b5b5b5b505b50505b505b5050565b6000611f6684848461250e565b9050611f7181611d4b565b5b9392505050565b60076020528060005260406000206000915090505481565b603281565b60045481565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611fd95760006000fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156120335760006000fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561208c5760006000fd5b600092505b60038054905083101561217a578473ffffffffffffffffffffffffffffffffffffffff166003848154811015156120c457fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561216c578360038481548110151561211d57fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061217a565b5b8280600101935050612091565b6000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508473ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405180905060405180910390a28373ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405180905060405180910390a25b5b505b505b505050565b6000816000600082815260200190815260200160002060030160009054906101000a900460ff16156122f35760006000fd5b826122fd816115a9565b15156123095760006000fd5b8360065460076000838152602001908152602001600020540142101515156123315760006000fd5b60006000868152602001908152602001600020935060018460030160006101000a81548160ff0219169083151502179055508360000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846001015485600201604051808280546001816001161561010002031660029004801561240c5780601f106123e15761010080835404028352916020019161240c565b820191906000526020600020905b8154815290600101906020018083116123ef57829003601f168201915b505091505060006040518083038185876185025a03f1925050501561246057847f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7560405180905060405180910390a26124ae565b847f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923660405180905060405180910390a260008460030160006101000a81548160ff0219169083151502179055505b5b5b505b505b505050565b806007600084815260200190815260200160002081905550817f0b237afe65f1514fd7ea3f923ea4fe792bdd07000a912b6cd1602a8e7f573c8d826040518082815260200191505060405180910390a25b5050565b60008360008173ffffffffffffffffffffffffffffffffffffffff1614156125365760006000fd5b60055491506080604051908101604052808673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001600015158152506000600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015560408201518160020190805190602001906125f69291906126e5565b5060608201518160030160006101000a81548160ff0219169083151502179055509050506001600560008282540192505081905550817fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5160405180905060405180910390a25b5b509392505050565b81548183558181151161268c5781836000526020600020918201910161268b9190612765565b5b505050565b8154818355818115116126b8578183600052602060002091820191016126b79190612765565b5b505050565b602060405190810160405280600081525090565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061272657805160ff1916838001178555612754565b82800160010185558215612754579182015b82811115612753578251825591602001919060010190612738565b5b5090506127619190612765565b5090565b61278791905b8082111561278357600081600090555060010161276b565b5090565b905600a165627a7a72305820b0518e85781087b035c1e957799a90f8e67dc45520679ff50b77e0bc71b9cd440029",
+ "unlinked_binary": "0x606060405234156200000d57fe5b60405162001da438038062001da4833981016040908152815160208301519183015160608401519190930192905b8383835b82825b600082518260328211806200005657508181115b8062000060575080155b806200006a575081155b15620000765760006000fd5b600092505b84518310156200014b576002600086858151811015156200009857fe5b6020908102909101810151600160a060020a031682528101919091526040016000205460ff1680620000eb57508483815181101515620000d457fe5b90602001906020020151600160a060020a03166000145b15620000f75760006000fd5b60016002600087868151811015156200010c57fe5b602090810291909101810151600160a060020a03168252810191909152604001600020805460ff19169115159190911790555b6001909201916200007b565b8451620001609060039060208801906200019c565b5060048490555b5b505050600683905550505b505060088054600160a060020a031916600160a060020a038416179055505b5050505062000235565b828054828255906000526020600020908101928215620001f4579160200282015b82811115620001f45782518254600160a060020a031916600160a060020a03909116178255602090920191600190910190620001bd565b5b506200020392915062000207565b5090565b6200023291905b8082111562000203578054600160a060020a03191681556001016200020e565b5090565b90565b611b5f80620002456000396000f300606060405236156101435763ffffffff60e060020a600035041663025e7c278114610195578063173825d9146101c457806320ea8d86146101e25780632f54bf6e146101f75780633411c81c1461022757806337bd78a01461025a578063547415251461027c578063553a48fd146102a85780635711b311146103125780637065cb4814610327578063784547a7146103455780637ad28c511461036c5780638b51d13f146103815780639ace38c2146103a6578063a0e67e2b14610463578063a8abe69a146104ce578063add1cbc514610549578063b5dc40c314610575578063b77bf600146105e3578063ba51a6df14610605578063c01a8c841461061a578063c64274741461062f578063d38f2d82146106a4578063d74f8edd146106c9578063dc8452cd146106eb578063e20056e61461070d578063ee22610b14610731575b6101935b600034111561019057604080513481529051600160a060020a033316917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a25b5b565b005b341561019d57fe5b6101a8600435610746565b60408051600160a060020a039092168252519081900360200190f35b34156101cc57fe5b610193600160a060020a0360043516610778565b005b34156101ea57fe5b610193600435610917565b005b34156101ff57fe5b610213600160a060020a0360043516610a0b565b604080519115158252519081900360200190f35b341561022f57fe5b610213600435600160a060020a0360243516610a20565b604080519115158252519081900360200190f35b341561026257fe5b61026a610a40565b60408051918252519081900360200190f35b341561028457fe5b61026a60043515156024351515610a46565b60408051918252519081900360200190f35b34156102b057fe5b610213600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843750949650610ab595505050505050565b604080519115158252519081900360200190f35b341561031a57fe5b610193600435610b5a565b005b341561032f57fe5b610193600160a060020a0360043516610d79565b005b341561034d57fe5b610213600435610e9e565b604080519115158252519081900360200190f35b341561037457fe5b610193600435610f32565b005b341561038957fe5b61026a600435610f90565b60408051918252519081900360200190f35b34156103ae57fe5b6103b960043561100f565b60408051600160a060020a03861681526020810185905282151560608201526080918101828152845460026000196101006001841615020190911604928201839052909160a0830190859080156104515780601f1061042657610100808354040283529160200191610451565b820191906000526020600020905b81548152906001019060200180831161043457829003601f168201915b50509550505050505060405180910390f35b341561046b57fe5b610473611043565b60408051602080825283518183015283519192839290830191858101910280838382156104bb575b8051825260208311156104bb57601f19909201916020918201910161049b565b5050509050019250505060405180910390f35b34156104d657fe5b610473600435602435604435151560643515156110ac565b60408051602080825283518183015283519192839290830191858101910280838382156104bb575b8051825260208311156104bb57601f19909201916020918201910161049b565b5050509050019250505060405180910390f35b341561055157fe5b6101a86111e1565b60408051600160a060020a039092168252519081900360200190f35b341561057d57fe5b6104736004356111f0565b60408051602080825283518183015283519192839290830191858101910280838382156104bb575b8051825260208311156104bb57601f19909201916020918201910161049b565b5050509050019250505060405180910390f35b34156105eb57fe5b61026a611378565b60408051918252519081900360200190f35b341561060d57fe5b61019360043561137e565b005b341561062257fe5b61019360043561140e565b005b341561063757fe5b604080516020600460443581810135601f810184900484028501840190955284845261026a948235600160a060020a031694602480359560649492939190920191819084018382808284375094965061152395505050505050565b60408051918252519081900360200190f35b34156106ac57fe5b61026a600435611543565b60408051918252519081900360200190f35b34156106d157fe5b61026a611555565b60408051918252519081900360200190f35b34156106f357fe5b61026a61155a565b60408051918252519081900360200190f35b341561071557fe5b610193600160a060020a0360043581169060243516611560565b005b341561073957fe5b6101936004356116f8565b005b600380548290811061075457fe5b906000526020600020900160005b915054906101000a9004600160a060020a031681565b600030600160a060020a031633600160a060020a031614151561079b5760006000fd5b600160a060020a038216600090815260026020526040902054829060ff1615156107c55760006000fd5b600160a060020a0383166000908152600260205260408120805460ff1916905591505b600354600019018210156108c05782600160a060020a031660038381548110151561080f57fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600160a060020a031614156108b45760038054600019810190811061085057fe5b906000526020600020900160005b9054906101000a9004600160a060020a031660038381548110151561087f57fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a031602179055506108c0565b5b6001909101906107e8565b6003805460001901906108d3908261199b565b5060035460045411156108ec576003546108ec9061137e565b5b604051600160a060020a03841690600080516020611b1483398151915290600090a25b5b505b5050565b33600160a060020a03811660009081526002602052604090205460ff1615156109405760006000fd5b600082815260016020908152604080832033600160a060020a038116855292529091205483919060ff1615156109765760006000fd5b600084815260208190526040902060030154849060ff16156109985760006000fd5b846109a281610e9e565b156109ad5760006000fd5b6000868152600160209081526040808320600160a060020a0333168085529252808320805460ff191690555188927ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e991a35b5b505b505b50505b5050565b60026020526000908152604090205460ff1681565b600160209081526000928352604080842090915290825290205460ff1681565b60065481565b6000805b600554811015610aad57838015610a73575060008181526020819052604090206003015460ff16155b80610a975750828015610a97575060008181526020819052604090206003015460ff165b5b15610aa4576001820191505b5b600101610a4a565b5b5092915050565b604080517f72656d6f7665417574686f72697a65644164647265737328616464726573732981529051908190036020019020600090815b6004811015610b4e57818160048110610b0157fe5b1a60f860020a02600160f860020a0319168482815181101515610b2057fe5b60209101015160f860020a9081900402600160f860020a03191614610b455760006000fd5b5b600101610aec565b600192505b5050919050565b600081815260208190526040812060030154829060ff1615610b7c5760006000fd5b82610b8681610e9e565b1515610b925760006000fd5b60008481526020819052604090206008548154869291600160a060020a03918216911614610bc05760006000fd5b600281810180546040805160206001841615610100026000190190931694909404601f8101839004830285018301909152808452610c55939291830182828015610c4b5780601f10610c2057610100808354040283529160200191610c4b565b820191906000526020600020905b815481529060010190602001808311610c2e57829003601f168201915b5050505050610ab5565b1515610c615760006000fd5b6000868152602081905260409081902060038101805460ff19166001908117909155815481830154935160028085018054959b50600160a060020a0390931695949293919283928592600019918316156101000291909101909116048015610d0a5780601f10610cdf57610100808354040283529160200191610d0a565b820191906000526020600020905b815481529060010190602001808311610ced57829003601f168201915b505091505060006040518083038185876187965a03f19250505015610d47576040518690600080516020611af483398151915290600090a26109ff565b6040518690600080516020611ab483398151915290600090a260038501805460ff191690555b5b5b50505b505b505050565b30600160a060020a031633600160a060020a0316141515610d9a5760006000fd5b600160a060020a038116600090815260026020526040902054819060ff1615610dc35760006000fd5b81600160a060020a0381161515610dda5760006000fd5b6003805490506001016004546032821180610df457508181115b80610dfd575080155b80610e06575081155b15610e115760006000fd5b600160a060020a0385166000908152600260205260409020805460ff191660019081179091556003805490918101610e49838261199b565b916000526020600020900160005b8154600160a060020a03808a166101009390930a83810291021990911617909155604051909150600080516020611ad483398151915290600090a25b5b50505b505b505b50565b600080805b600354811015610b535760008481526001602052604081206003805491929184908110610ecc57fe5b906000526020600020900160005b9054600160a060020a036101009290920a900416815260208101919091526040016000205460ff1615610f0e576001820191505b600454821415610f215760019250610b53565b5b600101610ea3565b5b5050919050565b30600160a060020a031633600160a060020a0316141515610f535760006000fd5b60068190556040805182815290517fd1c9101a34feff75cccef14a28785a0279cb0b49c1f321f21f5f422e746b43779181900360200190a15b5b50565b6000805b6003548110156110085760008381526001602052604081206003805491929184908110610fbd57fe5b906000526020600020900160005b9054600160a060020a036101009290920a900416815260208101919091526040016000205460ff1615610fff576001820191505b5b600101610f94565b5b50919050565b6000602081905290815260409020805460018201546003830154600160a060020a0390921692909160029091019060ff1684565b61104b6119ef565b60038054806020026020016040519081016040528092919081815260200182805480156110a157602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311611083575b505050505090505b90565b6110b46119ef565b6110bc6119ef565b600060006005546040518059106110d05750595b908082528060200260200182016040525b50925060009150600090505b60055481101561116a57858015611116575060008181526020819052604090206003015460ff16155b8061113a575084801561113a575060008181526020819052604090206003015460ff165b5b156111615780838381518110151561114f57fe5b60209081029091010152600191909101905b5b6001016110ed565b87870360405180591061117a5750595b908082528060200260200182016040525b5093508790505b868110156111d55782818151811015156111a857fe5b90602001906020020151848983038151811015156111c257fe5b602090810290910101525b600101611192565b5b505050949350505050565b600854600160a060020a031681565b6111f86119ef565b6112006119ef565b60035460405160009182918059106112155750595b908082528060200260200182016040525b50925060009150600090505b6003548110156112fa576000858152600160205260408120600380549192918490811061125b57fe5b906000526020600020900160005b9054600160a060020a036101009290920a900416815260208101919091526040016000205460ff16156112f15760038054829081106112a457fe5b906000526020600020900160005b9054906101000a9004600160a060020a031683838151811015156112d257fe5b600160a060020a03909216602092830290910190910152600191909101905b5b600101611232565b816040518059106113085750595b908082528060200260200182016040525b509350600090505b8181101561136f57828181518110151561133757fe5b90602001906020020151848281518110151561134f57fe5b600160a060020a039092166020928302909101909101525b600101611321565b5b505050919050565b60055481565b30600160a060020a031633600160a060020a031614151561139f5760006000fd5b6003548160328211806113b157508181115b806113ba575080155b806113c3575081155b156113ce5760006000fd5b60048390556040805184815290517fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a9181900360200190a15b5b50505b50565b33600160a060020a03811660009081526002602052604090205460ff1615156114375760006000fd5b6000828152602081905260409020548290600160a060020a0316151561145d5760006000fd5b600083815260016020908152604080832033600160a060020a038116855292529091205484919060ff16156114925760006000fd5b8461149c81610e9e565b156114a75760006000fd5b6000868152600160208181526040808420600160a060020a0333168086529252808420805460ff1916909317909255905188927f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef91a361150686610e9e565b156109ff576109ff8642611869565b5b5b5b505b50505b505b5050565b60006115308484846118b5565b905061153b8161140e565b5b9392505050565b60076020526000908152604090205481565b603281565b60045481565b600030600160a060020a031633600160a060020a03161415156115835760006000fd5b600160a060020a038316600090815260026020526040902054839060ff1615156115ad5760006000fd5b600160a060020a038316600090815260026020526040902054839060ff16156115d65760006000fd5b600092505b60035483101561167e5784600160a060020a03166003848154811015156115fe57fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600160a060020a03161415611672578360038481548110151561163d57fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a0316021790555061167e565b5b6001909201916115db565b600160a060020a03808616600081815260026020526040808220805460ff199081169091559388168252808220805490941660011790935591519091600080516020611b1483398151915291a2604051600160a060020a03851690600080516020611ad483398151915290600090a25b5b505b505b505050565b600081815260208190526040812060030154829060ff161561171a5760006000fd5b8261172481610e9e565b15156117305760006000fd5b6006546000858152600760205260409020548591014210156117525760006000fd5b6000858152602081905260409081902060038101805460ff19166001908117909155815481830154935160028085018054959a50600160a060020a03909316959492939192839285926000199183161561010002919091019091160480156117fb5780601f106117d0576101008083540402835291602001916117fb565b820191906000526020600020905b8154815290600101906020018083116117de57829003601f168201915b505091505060006040518083038185876187965a03f19250505015611838576040518590600080516020611af483398151915290600090a2610a02565b6040518590600080516020611ab483398151915290600090a260038401805460ff191690555b5b5b505b505b505050565b6000828152600760209081526040918290208390558151838152915184927f0b237afe65f1514fd7ea3f923ea4fe792bdd07000a912b6cd1602a8e7f573c8d92908290030190a25b5050565b600083600160a060020a03811615156118ce5760006000fd5b60055460408051608081018252600160a060020a03888116825260208083018981528385018981526000606086018190528781528084529590952084518154600160a060020a03191694169390931783555160018301559251805194965091939092611941926002850192910190611a13565b50606091909101516003909101805460ff191691151591909117905560058054600101905560405182907fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5190600090a25b5b509392505050565b81548183558181151161091057600083815260209020610910918101908301611a92565b5b505050565b81548183558181151161091057600083815260209020610910918101908301611a92565b5b505050565b60408051602081019091526000815290565b60408051602081019091526000815290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611a5457805160ff1916838001178555611a81565b82800160010185558215611a81579182015b82811115611a81578251825591602001919060010190611a66565b5b50611a8e929150611a92565b5090565b6110a991905b80821115611a8e5760008155600101611a98565b5090565b905600526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b79236f39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed758001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b90a165627a7a723058204c9f0a36ec2dc83e3665c5e5ca7acb6417fd7a59062273d0351efee676bb280c0029",
"networks": {
"50": {
"links": {},
@@ -793,9 +793,9 @@
"type": "event"
}
},
- "updated_at": 1502391794394
+ "updated_at": 1513088404209
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794394
+ "updated_at": 1513088404209
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/Ownable.json b/packages/contracts/build/contracts/Ownable.json
index ebe5a1804..d0e73d497 100644
--- a/packages/contracts/build/contracts/Ownable.json
+++ b/packages/contracts/build/contracts/Ownable.json
@@ -33,8 +33,8 @@
"type": "constructor"
}
],
- "unlinked_binary": "0x6060604052341561000c57fe5b5b60008054600160a060020a03191633600160a060020a03161790555b5b60f3806100386000396000f300606060405263ffffffff60e060020a6000350416638da5cb5b8114602a578063f2fde38b146053575bfe5b3415603157fe5b6037606e565b60408051600160a060020a039092168252519081900360200190f35b3415605a57fe5b606c600160a060020a0360043516607d565b005b600054600160a060020a031681565b60005433600160a060020a0390811691161460985760006000fd5b600160a060020a0381161560c25760008054600160a060020a031916600160a060020a0383161790555b5b5b505600a165627a7a7230582009515308d7738f55dd8ba99e29943dc01d4a032197af5f4e1adc20b93fb927f20029",
+ "unlinked_binary": "0x6060604052341561000c57fe5b5b60008054600160a060020a03191633600160a060020a03161790555b5b60f3806100386000396000f300606060405263ffffffff60e060020a6000350416638da5cb5b8114602a578063f2fde38b146053575bfe5b3415603157fe5b6037606e565b60408051600160a060020a039092168252519081900360200190f35b3415605a57fe5b606c600160a060020a0360043516607d565b005b600054600160a060020a031681565b60005433600160a060020a0390811691161460985760006000fd5b600160a060020a0381161560c25760008054600160a060020a031916600160a060020a0383161790555b5b5b505600a165627a7a7230582048ccfb6ebb285c80c8b4030a0e4f2e6ec2a0619b363a2d7cd20692a0cfb170550029",
"networks": {},
"schema_version": "0.0.5",
- "updated_at": 1502391792217
+ "updated_at": 1513088402049
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/SafeMath.json b/packages/contracts/build/contracts/SafeMath.json
index 86782f47a..fe15df18b 100644
--- a/packages/contracts/build/contracts/SafeMath.json
+++ b/packages/contracts/build/contracts/SafeMath.json
@@ -1,8 +1,8 @@
{
"contract_name": "SafeMath",
"abi": [],
- "unlinked_binary": "0x60606040523415600b57fe5b5b60338060196000396000f30060606040525bfe00a165627a7a723058201f432ae32cd7cc9a0efb0b70b25524cf42d165202875a497f8b0122d77a6a5ba0029",
+ "unlinked_binary": "0x60606040523415600b57fe5b5b60338060196000396000f30060606040525bfe00a165627a7a72305820becdc80300a4dbf834bb9ab115616eb459f82b51a9133d360eb1e6e5402072eb0029",
"networks": {},
"schema_version": "0.0.5",
- "updated_at": 1502391792217
+ "updated_at": 1513088402049
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/StandardToken.json b/packages/contracts/build/contracts/StandardToken.json
index 4f67b8772..3f3f3921f 100644
--- a/packages/contracts/build/contracts/StandardToken.json
+++ b/packages/contracts/build/contracts/StandardToken.json
@@ -169,8 +169,8 @@
"type": "event"
}
],
- "unlinked_binary": "0x6060604052341561000c57fe5b5b6104388061001c6000396000f3006060604052361561005c5763ffffffff60e060020a600035041663095ea7b3811461005e57806318160ddd1461009157806323b872dd146100b357806370a08231146100ec578063a9059cbb1461011a578063dd62ed3e1461014d575bfe5b341561006657fe5b61007d600160a060020a0360043516602435610181565b604080519115158252519081900360200190f35b341561009957fe5b6100a16101ec565b60408051918252519081900360200190f35b34156100bb57fe5b61007d600160a060020a03600435811690602435166044356101f2565b604080519115158252519081900360200190f35b34156100f457fe5b6100a1600160a060020a03600435166102ee565b60408051918252519081900360200190f35b341561012257fe5b61007d600160a060020a036004351660243561030d565b604080519115158252519081900360200190f35b341561015557fe5b6100a1600160a060020a03600435811690602435166103bf565b60408051918252519081900360200190f35b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a0383166000908152602081905260408120548290108015906102425750600160a060020a0380851660009081526001602090815260408083203390941683529290522054829010155b80156102685750600160a060020a03831660009081526020819052604090205482810110155b156102e257600160a060020a0380841660008181526020818152604080832080548801905588851680845281842080548990039055600183528184203390961684529482529182902080548790039055815186815291519293926000805160206103ed8339815191529281900390910190a35060016102e6565b5060005b5b9392505050565b600160a060020a0381166000908152602081905260409020545b919050565b600160a060020a0333166000908152602081905260408120548290108015906103505750600160a060020a03831660009081526020819052604090205482810110155b156103b057600160a060020a0333811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191936000805160206103ed833981519152929081900390910190a35060016101e6565b5060006101e6565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a723058208bbb664bbcb187b9a351ec93e9763b53c0157b40e7ee3033bb5b59eddd9e575e0029",
+ "unlinked_binary": "0x6060604052341561000c57fe5b5b6104388061001c6000396000f3006060604052361561005c5763ffffffff60e060020a600035041663095ea7b3811461005e57806318160ddd1461009157806323b872dd146100b357806370a08231146100ec578063a9059cbb1461011a578063dd62ed3e1461014d575bfe5b341561006657fe5b61007d600160a060020a0360043516602435610181565b604080519115158252519081900360200190f35b341561009957fe5b6100a16101ec565b60408051918252519081900360200190f35b34156100bb57fe5b61007d600160a060020a03600435811690602435166044356101f2565b604080519115158252519081900360200190f35b34156100f457fe5b6100a1600160a060020a03600435166102ee565b60408051918252519081900360200190f35b341561012257fe5b61007d600160a060020a036004351660243561030d565b604080519115158252519081900360200190f35b341561015557fe5b6100a1600160a060020a03600435811690602435166103bf565b60408051918252519081900360200190f35b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60025481565b600160a060020a0383166000908152602081905260408120548290108015906102425750600160a060020a0380851660009081526001602090815260408083203390941683529290522054829010155b80156102685750600160a060020a03831660009081526020819052604090205482810110155b156102e257600160a060020a0380841660008181526020818152604080832080548801905588851680845281842080548990039055600183528184203390961684529482529182902080548790039055815186815291519293926000805160206103ed8339815191529281900390910190a35060016102e6565b5060005b5b9392505050565b600160a060020a0381166000908152602081905260409020545b919050565b600160a060020a0333166000908152602081905260408120548290108015906103505750600160a060020a03831660009081526020819052604090205482810110155b156103b057600160a060020a0333811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191936000805160206103ed833981519152929081900390910190a35060016101e6565b5060006101e6565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a7230582056d411baf4691cc9a0a55ffa6b4a4e9308ea12187fd2fa738228bbd266709d4d0029",
"networks": {},
"schema_version": "0.0.5",
- "updated_at": 1502391449723
+ "updated_at": 1513088402049
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/Token.json b/packages/contracts/build/contracts/Token.json
index 9487c0782..c16f36d98 100644
--- a/packages/contracts/build/contracts/Token.json
+++ b/packages/contracts/build/contracts/Token.json
@@ -169,8 +169,8 @@
"type": "event"
}
],
- "unlinked_binary": "0x6060604052341561000c57fe5b5b6101e08061001c6000396000f3006060604052361561005c5763ffffffff60e060020a600035041663095ea7b3811461005e57806318160ddd1461009157806323b872dd146100b357806370a08231146100ec578063a9059cbb1461005e578063dd62ed3e1461014d575bfe5b341561006657fe5b61007d600160a060020a0360043516602435610181565b604080519115158252519081900360200190f35b341561009957fe5b6100a161018a565b60408051918252519081900360200190f35b34156100bb57fe5b61007d600160a060020a0360043581169060243516604435610190565b604080519115158252519081900360200190f35b34156100f457fe5b6100a1600160a060020a036004351661019a565b60408051918252519081900360200190f35b341561006657fe5b61007d600160a060020a0360043516602435610181565b604080519115158252519081900360200190f35b341561015557fe5b6100a1600160a060020a0360043581169060243516610181565b60408051918252519081900360200190f35b60005b92915050565b60005b90565b60005b9392505050565b60005b919050565b60005b92915050565b60005b929150505600a165627a7a7230582082d46fcd9caa49348b3932d5c18807e1d10d0105371a8bce147cc647f3762a500029",
+ "unlinked_binary": "0x6060604052341561000c57fe5b5b6101e08061001c6000396000f3006060604052361561005c5763ffffffff60e060020a600035041663095ea7b3811461005e57806318160ddd1461009157806323b872dd146100b357806370a08231146100ec578063a9059cbb1461005e578063dd62ed3e1461014d575bfe5b341561006657fe5b61007d600160a060020a0360043516602435610181565b604080519115158252519081900360200190f35b341561009957fe5b6100a161018a565b60408051918252519081900360200190f35b34156100bb57fe5b61007d600160a060020a0360043581169060243516604435610190565b604080519115158252519081900360200190f35b34156100f457fe5b6100a1600160a060020a036004351661019a565b60408051918252519081900360200190f35b341561006657fe5b61007d600160a060020a0360043516602435610181565b604080519115158252519081900360200190f35b341561015557fe5b6100a1600160a060020a0360043581169060243516610181565b60408051918252519081900360200190f35b60005b92915050565b60005b90565b60005b9392505050565b60005b919050565b60005b92915050565b60005b929150505600a165627a7a72305820107c1e9e7aa669d21343c42639b4bb080602c349d00c1da14b8ea6b6dcc0b0f80029",
"networks": {},
"schema_version": "0.0.5",
- "updated_at": 1502391792217
+ "updated_at": 1513088402049
} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/TokenRegistry.json b/packages/contracts/build/contracts/TokenRegistry.json
index f7989ef8f..1dda2dc74 100644
--- a/packages/contracts/build/contracts/TokenRegistry.json
+++ b/packages/contracts/build/contracts/TokenRegistry.json
@@ -527,9 +527,9 @@
"type": "event"
}
],
- "unlinked_binary": "0x60606040525b60008054600160a060020a03191633600160a060020a03161790555b5b612cc5806100316000396000f300606060405236156100ca5763ffffffff60e060020a60003504166313baf1e681146100cc5780632fbfeba9146100ed5780633550b6d91461015f57806356318820146101d15780637abccac9146102335780638da5cb5b1461044d578063a880319d14610479578063c370c86d1461059a578063e4860339146105fc578063e5df8b841461082b578063e73fc0c31461085a578063ee8c24b814610aae578063eef05f6514610b19578063efa74f1f14610b7b578063f036417f14610dcf578063f2fde38b14610e31575bfe5b34156100d457fe5b6100eb600160a060020a0360043516602435610e4f565b005b34156100f557fe5b610143600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965061134895505050505050565b60408051600160a060020a039092168252519081900360200190f35b341561016757fe5b610143600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437509496506113bb95505050505050565b60408051600160a060020a039092168252519081900360200190f35b34156101d957fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a0316959394604494939290920191819084018382808284375094965061142e95505050505050565b005b341561023b57fe5b61024f600160a060020a03600435166115cf565b6040518087600160a060020a0316600160a060020a0316815260200180602001806020018660ff1660ff168152602001806020018060200185810385528a8181518152602001915080519060200190808383600083146102ca575b8051825260208311156102ca57601f1990920191602091820191016102aa565b505050905090810190601f1680156102f65780820380516001836020036101000a031916815260200191505b5085810384528951815289516020918201918b01908083838215610335575b80518252602083111561033557601f199092019160209182019101610315565b505050905090810190601f1680156103615780820380516001836020036101000a031916815260200191505b50858103835287518152875160209182019189019080838382156103a0575b8051825260208311156103a057601f199092019160209182019101610380565b505050905090810190601f1680156103cc5780820380516001836020036101000a031916815260200191505b508581038252865181528651602091820191880190808383821561040b575b80518252602083111561040b57601f1990920191602091820191016103eb565b505050905090810190601f1680156104375780820380516001836020036101000a031916815260200191505b509a505050505050505050505060405180910390f35b341561045557fe5b6101436118ba565b60408051600160a060020a039092168252519081900360200190f35b341561048157fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a0316959394604494939290920191819084018382808284375050604080516020601f89358b0180359182018390048302840183019094528083529799988101979196509182019450925082915084018382808284375050604080516020601f818a01358b0180359182018390048302840183018552818452989a60ff8b35169a90999401975091955091820193509150819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979998810197919650918201945092508291508401838280828437509496506118c995505050505050565b005b34156105a257fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a03169593946044949392909201918190840183828082843750949650611e7a95505050505050565b005b341561060457fe5b610618600160a060020a03600435166121a1565b60408051600160a060020a038816815260ff8516606082015260c0602082018181528854600260001961010060018416150201909116049183018290529192830190608084019060a085019060e08601908b9080156106b85780601f1061068d576101008083540402835291602001916106b8565b820191906000526020600020905b81548152906001019060200180831161069b57829003601f168201915b505085810384528954600260001961010060018416150201909116048082526020909101908a90801561072c5780601f106107015761010080835404028352916020019161072c565b820191906000526020600020905b81548152906001019060200180831161070f57829003601f168201915b50508581038352875460026000196101006001841615020190911604808252602090910190889080156107a05780601f10610775576101008083540402835291602001916107a0565b820191906000526020600020905b81548152906001019060200180831161078357829003601f168201915b50508581038252865460026000196101006001841615020190911604808252602090910190879080156108145780601f106107e957610100808354040283529160200191610814565b820191906000526020600020905b8154815290600101906020018083116107f757829003601f168201915b50509a505050505050505050505060405180910390f35b341561083357fe5b6101436004356121dc565b60408051600160a060020a039092168252519081900360200190f35b341561086257fe5b61024f600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965061220e95505050505050565b6040518087600160a060020a0316600160a060020a0316815260200180602001806020018660ff1660ff168152602001806020018060200185810385528a8181518152602001915080519060200190808383600083146102ca575b8051825260208311156102ca57601f1990920191602091820191016102aa565b505050905090810190601f1680156102f65780820380516001836020036101000a031916815260200191505b5085810384528951815289516020918201918b01908083838215610335575b80518252602083111561033557601f199092019160209182019101610315565b505050905090810190601f1680156103615780820380516001836020036101000a031916815260200191505b50858103835287518152875160209182019189019080838382156103a0575b8051825260208311156103a057601f199092019160209182019101610380565b505050905090810190601f1680156103cc5780820380516001836020036101000a031916815260200191505b508581038252865181528651602091820191880190808383821561040b575b80518252602083111561040b57601f1990920191602091820191016103eb565b505050905090810190601f1680156104375780820380516001836020036101000a031916815260200191505b509a505050505050505050505060405180910390f35b3415610ab657fe5b610abe6122c1565b6040805160208082528351818301528351919283929083019185810191028083838215610b06575b805182526020831115610b0657601f199092019160209182019101610ae6565b5050509050019250505060405180910390f35b3415610b2157fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a0316959394604494939290920191819084018382808284375094965061232a95505050505050565b005b3415610b8357fe5b61024f600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437509496506124cb95505050505050565b6040518087600160a060020a0316600160a060020a0316815260200180602001806020018660ff1660ff168152602001806020018060200185810385528a8181518152602001915080519060200190808383600083146102ca575b8051825260208311156102ca57601f1990920191602091820191016102aa565b505050905090810190601f1680156102f65780820380516001836020036101000a031916815260200191505b5085810384528951815289516020918201918b01908083838215610335575b80518252602083111561033557601f199092019160209182019101610315565b505050905090810190601f1680156103615780820380516001836020036101000a031916815260200191505b50858103835287518152875160209182019189019080838382156103a0575b8051825260208311156103a057601f199092019160209182019101610380565b505050905090810190601f1680156103cc5780820380516001836020036101000a031916815260200191505b508581038252865181528651602091820191880190808383821561040b575b80518252602083111561040b57601f1990920191602091820191016103eb565b505050905090810190601f1680156104375780820380516001836020036101000a031916815260200191505b509a505050505050505050505060405180910390f35b3415610dd757fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a0316959394604494939290920191819084018382808284375094965061257e95505050505050565b005b3415610e3957fe5b6100eb600160a060020a03600435166128a4565b005b6000805433600160a060020a03908116911614610e6c5760006000fd5b600160a060020a038084166000908152600160205260409020548491161515610e955760006000fd5b83600160a060020a0316600484815481101515610eae57fe5b906000526020600020900160005b9054600160a060020a036101009290920a90041614610edb5760006000fd5b600480546000198101908110610eed57fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600484815481101515610f1c57fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a031602179055506001600481818054905003915081610f6491906128f0565b50600160a060020a0380851660009081526001602081815260409283902080546003820154855160ff90911695810186905260a0808252838601805460026000199882161561010002989098011687900491830182905293995091909616957f32c54f1e2ea75844ded7517e7dbcd3895da7cd0c28f9ab9f9cf6ecf5f83762c695929489019360048a019260058b0192918291908201906060830190608084019060c08501908b9080156110595780601f1061102e57610100808354040283529160200191611059565b820191906000526020600020905b81548152906001019060200180831161103c57829003601f168201915b505085810384528954600260001961010060018416150201909116048082526020909101908a9080156110cd5780601f106110a2576101008083540402835291602001916110cd565b820191906000526020600020905b8154815290600101906020018083116110b057829003601f168201915b50508581038352875460026000196101006001841615020190911604808252602090910190889080156111415780601f1061111657610100808354040283529160200191611141565b820191906000526020600020905b81548152906001019060200180831161112457829003601f168201915b50508581038252865460026000196101006001841615020190911604808252602090910190879080156111b55780601f1061118a576101008083540402835291602001916111b5565b820191906000526020600020905b81548152906001019060200180831161119857829003601f168201915b5050995050505050505050505060405180910390a2600282600201604051808280546001816001161561010002031660029004801561122b5780601f1061120957610100808354040283529182019161122b565b820191906000526020600020905b815481529060010190602001808311611217575b5050915050908152602001604051809103902060006101000a815490600160a060020a03021916905560038260010160405180828054600181600116156101000203166002900480156112b55780601f106112935761010080835404028352918201916112b5565b820191906000526020600020905b8154815290600101906020018083116112a1575b5050928352505060408051602092819003830190208054600160a060020a0319908116909155600160a060020a038716600090815260019384905291822080549091168155916113079083018261291a565b61131560028301600061291a565b60038201805460ff1916905561132f60048301600061291a565b61133d60058301600061291a565b50505b5b505b505050565b60006003826040518082805190602001908083835b6020831061137c5780518252601f19909201916020918201910161135d565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a0316925050505b919050565b60006002826040518082805190602001908083835b6020831061137c5780518252601f19909201916020918201910161135d565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a0316925050505b919050565b6000805433600160a060020a0390811691161461144b5760006000fd5b600160a060020a0380841660009081526001602052604090205484911615156114745760006000fd5b600160a060020a0384166000818152600160208181526040928390208351848152600582018054600295811615610100026000190116949094049481018590529096507fc3168fdc13112e44a031057dbf6c609b33353addb4d8037d24543e22cbfe2acd9388928291908201906060830190869080156115355780601f1061150a57610100808354040283529160200191611535565b820191906000526020600020905b81548152906001019060200180831161151857829003601f168201915b505083810382528451815284516020918201918601908083838215611575575b80518252602083111561157557601f199092019160209182019101611555565b505050905090810190601f1680156115a15780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a282516115c590600584019060208601906129aa565b505b5b505b505050565b60006115d9612a29565b6115e1612a29565b60006115eb612a29565b6115f3612a29565b6115fb612a4d565b600160a060020a03888116600090815260016020818152604092839020835160c0810185528154909516855280830180548551600261010096831615969096026000190190911694909404601f8101849004840285018401909552848452909385830193928301828280156116b15780601f10611686576101008083540402835291602001916116b1565b820191906000526020600020905b81548152906001019060200180831161169457829003601f168201915b5050509183525050600282810180546040805160206001841615610100026000190190931694909404601f810183900483028501830190915280845293810193908301828280156117435780601f1061171857610100808354040283529160200191611743565b820191906000526020600020905b81548152906001019060200180831161172657829003601f168201915b5050509183525050600382015460ff1660208083019190915260048301805460408051601f600260001960018616156101000201909416939093049283018590048502810185018252828152940193928301828280156117e45780601f106117b9576101008083540402835291602001916117e4565b820191906000526020600020905b8154815290600101906020018083116117c757829003601f168201915b505050918352505060058201805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529382019392918301828280156118785780601f1061184d57610100808354040283529160200191611878565b820191906000526020600020905b81548152906001019060200180831161185b57829003601f168201915b5050509190925250508151602083015160408401516060850151608086015160a0870151949d50929b50909950975095509350909150505b5091939550919395565b600054600160a060020a031681565b60005433600160a060020a039081169116146118e55760006000fd5b600160a060020a038087166000908152600160205260409020548791161561190d5760006000fd5b86600160a060020a03811615156119245760006000fd5b856000600160a060020a03166002826040518082805190602001908083835b602083106119625780518252601f199092019160209182019101611943565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a03169290921491506119a990505760006000fd5b876000600160a060020a03166003826040518082805190602001908083835b602083106119e75780518252601f1990920191602091820191016119c8565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a0316929092149150611a2e90505760006000fd5b6040805160c081018252600160a060020a038c811680835260208084018e81528486018e905260ff8d166060860152608085018c905260a085018b9052600092835260018083529590922084518154600160a060020a03191694169390931783559051805193949293611aa89385019291909101906129aa565b5060408201518051611ac49160028401916020909101906129aa565b50606082015160038201805460ff191660ff90921691909117905560808201518051611afa9160048401916020909101906129aa565b5060a08201518051611b169160058401916020909101906129aa565b50506004805490915060018101611b2d83826128f0565b916000526020600020900160005b8c909190916101000a815481600160a060020a030219169083600160a060020a0316021790555050896002896040518082805190602001908083835b60208310611b965780518252601f199092019160209182019101611b77565b51815160209384036101000a600019018019909216911617905292019485525060405193849003810184208054600160a060020a031916600160a060020a03969096169590951790945550508a518c926003928d9290918291908401908083835b60208310611c165780518252601f199092019160209182019101611bf7565b51815160209384036101000a60001901801990921691161790529201948552506040805194859003820185208054600160a060020a031916600160a060020a0397881617905560ff8d169085015260a08085528e51908501528d51948f16947fd8d928b0b50ca11d9dc273236b46f3526515b03602f71f3a6af4f45bd9fa9144948f94508e93508d928d928d92918291828201916060840191608085019160c0860191908c01908083838215611ce7575b805182526020831115611ce757601f199092019160209182019101611cc7565b505050905090810190601f168015611d135780820380516001836020036101000a031916815260200191505b5085810384528951815289516020918201918b01908083838215611d52575b805182526020831115611d5257601f199092019160209182019101611d32565b505050905090810190601f168015611d7e5780820380516001836020036101000a031916815260200191505b5085810383528751815287516020918201918901908083838215611dbd575b805182526020831115611dbd57601f199092019160209182019101611d9d565b505050905090810190601f168015611de95780820380516001836020036101000a031916815260200191505b5085810382528651815286516020918201918801908083838215611e28575b805182526020831115611e2857601f199092019160209182019101611e08565b505050905090810190601f168015611e545780820380516001836020036101000a031916815260200191505b50995050505050505050505060405180910390a25b5b505b505b505b505b505050505050565b6000805433600160a060020a03908116911614611e975760006000fd5b600160a060020a038084166000908152600160205260409020548491161515611ec05760006000fd5b826000600160a060020a03166003826040518082805190602001908083835b60208310611efe5780518252601f199092019160209182019101611edf565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a0316929092149150611f4590505760006000fd5b600160a060020a03851660008181526001602081815260409283902083518481528184018054600295811615610100026000190116949094049481018590529097507f4a6dbfc867b179991dec22ff19960f0a94d8d9d891fc556f547764670340e8ae9389928291908201906060830190869080156120055780601f10611fda57610100808354040283529160200191612005565b820191906000526020600020905b815481529060010190602001808311611fe857829003601f168201915b505083810382528451815284516020918201918601908083838215612045575b80518252602083111561204557601f199092019160209182019101612025565b505050905090810190601f1680156120715780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a260038360010160405180828054600181600116156101000203166002900480156120e15780601f106120bf5761010080835404028352918201916120e1565b820191906000526020600020905b8154815290600101906020018083116120cd575b5050928352505060405190819003602090810182208054600160a060020a031916905585518792600392889282918401908083835b602083106121355780518252601f199092019160209182019101612116565b51815160209384036101000a60001901801990921691161790529201948552506040519384900381019093208054600160a060020a031916600160a060020a03959095169490941790935550855161133d925060018601918701906129aa565b505b5b505b505b505050565b600160208190526000918252604090912080546003820154600160a060020a0390911692820191600281019160ff1690600481019060050186565b60048054829081106121ea57fe5b906000526020600020900160005b915054906101000a9004600160a060020a031681565b6000612218612a29565b612220612a29565b600061222a612a29565b612232612a29565b60006003886040518082805190602001908083835b602083106122665780518252601f199092019160209182019101612247565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a031692506122aa91508290506115cf565b9650965096509650965096505b5091939550919395565b6122c9612a29565b600480548060200260200160405190810160405280929190818152602001828054801561231f57602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311612301575b505050505090505b90565b6000805433600160a060020a039081169116146123475760006000fd5b600160a060020a0380841660009081526001602052604090205484911615156123705760006000fd5b600160a060020a0384166000818152600160208181526040928390208351848152600482018054600295811615610100026000190116949094049481018590529096507f5b19f79ac4e8cfa820815502e11615f1a449e28155dc289ec5cac1a11f9086949388928291908201906060830190869080156124315780601f1061240657610100808354040283529160200191612431565b820191906000526020600020905b81548152906001019060200180831161241457829003601f168201915b505083810382528451815284516020918201918601908083838215612471575b80518252602083111561247157601f199092019160209182019101612451565b505050905090810190601f16801561249d5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a282516115c590600484019060208601906129aa565b505b5b505b505050565b60006124d5612a29565b6124dd612a29565b60006124e7612a29565b6124ef612a29565b60006002886040518082805190602001908083835b602083106122665780518252601f199092019160209182019101612247565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a031692506122aa91508290506115cf565b9650965096509650965096505b5091939550919395565b6000805433600160a060020a0390811691161461259b5760006000fd5b600160a060020a0380841660009081526001602052604090205484911615156125c45760006000fd5b826000600160a060020a03166002826040518082805190602001908083835b602083106126025780518252601f1990920191602091820191016125e3565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a031692909214915061264990505760006000fd5b600160a060020a038516600081815260016020818152604092839020835184815260028083018054958616156101000260001901909516049481018590529097507f53d878a6530e56c9bc96548fa0a8cae4f1d1f49c86b0e934c086b992ebb6998f9389928291908201906060830190869080156127085780601f106126dd57610100808354040283529160200191612708565b820191906000526020600020905b8154815290600101906020018083116126eb57829003601f168201915b505083810382528451815284516020918201918601908083838215612748575b80518252602083111561274857601f199092019160209182019101612728565b505050905090810190601f1680156127745780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a260028360020160405180828054600181600116156101000203166002900480156127e45780601f106127c25761010080835404028352918201916127e4565b820191906000526020600020905b8154815290600101906020018083116127d0575b5050928352505060405190819003602090810182208054600160a060020a031916905585518792600292889282918401908083835b602083106128385780518252601f199092019160209182019101612819565b51815160209384036101000a60001901801990921691161790529201948552506040519384900381019093208054600160a060020a031916600160a060020a03959095169490941790935550855161133d925060028601918701906129aa565b505b5b505b505b505050565b60005433600160a060020a039081169116146128c05760006000fd5b600160a060020a038116156128eb5760008054600160a060020a031916600160a060020a0383161790555b5b5b50565b81548183558181151161134357600083815260209020611343918101908301612c54565b5b505050565b50805460018160011615610100020316600290046000825580601f1061294057506128eb565b601f0160209004906000526020600020908101906128eb9190612c54565b5b50565b50805460018160011615610100020316600290046000825580601f1061294057506128eb565b601f0160209004906000526020600020908101906128eb9190612c54565b5b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129eb57805160ff1916838001178555612a18565b82800160010185558215612a18579182015b82811115612a185782518255916020019190600101906129fd565b5b50612a25929150612c54565b5090565b60408051602081019091526000815290565b60408051602081019091526000815290565b6040805160c081019091526000815260208101612a68612a29565b8152602001612a75612a29565b815260006020820152604001612a89612a29565b8152602001612a96612a29565b905290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129eb57805160ff1916838001178555612a18565b82800160010185558215612a18579182015b82811115612a185782518255916020019190600101906129fd565b5b50612a25929150612c54565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129eb57805160ff1916838001178555612a18565b82800160010185558215612a18579182015b82811115612a185782518255916020019190600101906129fd565b5b50612a25929150612c54565b5090565b81548183558181151161134357600083815260209020611343918101908301612c54565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129eb57805160ff1916838001178555612a18565b82800160010185558215612a18579182015b82811115612a185782518255916020019190600101906129fd565b5b50612a25929150612c54565b5090565b60408051602081019091526000815290565b61232791905b80821115612a255760008155600101612c5a565b5090565b90565b60408051602081019091526000815290565b604080516020810190915260008152905600a165627a7a723058202e91668072bb23c9d4066cdaabf7329783952016e7a08006744ebe0d0eb96f5d0029",
+ "unlinked_binary": "0x60606040525b60008054600160a060020a03191633600160a060020a03161790555b5b612cc5806100316000396000f300606060405236156100ca5763ffffffff60e060020a60003504166313baf1e681146100cc5780632fbfeba9146100ed5780633550b6d91461015f57806356318820146101d15780637abccac9146102335780638da5cb5b1461044d578063a880319d14610479578063c370c86d1461059a578063e4860339146105fc578063e5df8b841461082b578063e73fc0c31461085a578063ee8c24b814610aae578063eef05f6514610b19578063efa74f1f14610b7b578063f036417f14610dcf578063f2fde38b14610e31575bfe5b34156100d457fe5b6100eb600160a060020a0360043516602435610e4f565b005b34156100f557fe5b610143600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965061134895505050505050565b60408051600160a060020a039092168252519081900360200190f35b341561016757fe5b610143600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437509496506113bb95505050505050565b60408051600160a060020a039092168252519081900360200190f35b34156101d957fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a0316959394604494939290920191819084018382808284375094965061142e95505050505050565b005b341561023b57fe5b61024f600160a060020a03600435166115cf565b6040518087600160a060020a0316600160a060020a0316815260200180602001806020018660ff1660ff168152602001806020018060200185810385528a8181518152602001915080519060200190808383600083146102ca575b8051825260208311156102ca57601f1990920191602091820191016102aa565b505050905090810190601f1680156102f65780820380516001836020036101000a031916815260200191505b5085810384528951815289516020918201918b01908083838215610335575b80518252602083111561033557601f199092019160209182019101610315565b505050905090810190601f1680156103615780820380516001836020036101000a031916815260200191505b50858103835287518152875160209182019189019080838382156103a0575b8051825260208311156103a057601f199092019160209182019101610380565b505050905090810190601f1680156103cc5780820380516001836020036101000a031916815260200191505b508581038252865181528651602091820191880190808383821561040b575b80518252602083111561040b57601f1990920191602091820191016103eb565b505050905090810190601f1680156104375780820380516001836020036101000a031916815260200191505b509a505050505050505050505060405180910390f35b341561045557fe5b6101436118ba565b60408051600160a060020a039092168252519081900360200190f35b341561048157fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a0316959394604494939290920191819084018382808284375050604080516020601f89358b0180359182018390048302840183019094528083529799988101979196509182019450925082915084018382808284375050604080516020601f818a01358b0180359182018390048302840183018552818452989a60ff8b35169a90999401975091955091820193509150819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979998810197919650918201945092508291508401838280828437509496506118c995505050505050565b005b34156105a257fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a03169593946044949392909201918190840183828082843750949650611e7a95505050505050565b005b341561060457fe5b610618600160a060020a03600435166121a1565b60408051600160a060020a038816815260ff8516606082015260c0602082018181528854600260001961010060018416150201909116049183018290529192830190608084019060a085019060e08601908b9080156106b85780601f1061068d576101008083540402835291602001916106b8565b820191906000526020600020905b81548152906001019060200180831161069b57829003601f168201915b505085810384528954600260001961010060018416150201909116048082526020909101908a90801561072c5780601f106107015761010080835404028352916020019161072c565b820191906000526020600020905b81548152906001019060200180831161070f57829003601f168201915b50508581038352875460026000196101006001841615020190911604808252602090910190889080156107a05780601f10610775576101008083540402835291602001916107a0565b820191906000526020600020905b81548152906001019060200180831161078357829003601f168201915b50508581038252865460026000196101006001841615020190911604808252602090910190879080156108145780601f106107e957610100808354040283529160200191610814565b820191906000526020600020905b8154815290600101906020018083116107f757829003601f168201915b50509a505050505050505050505060405180910390f35b341561083357fe5b6101436004356121dc565b60408051600160a060020a039092168252519081900360200190f35b341561086257fe5b61024f600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965061220e95505050505050565b6040518087600160a060020a0316600160a060020a0316815260200180602001806020018660ff1660ff168152602001806020018060200185810385528a8181518152602001915080519060200190808383600083146102ca575b8051825260208311156102ca57601f1990920191602091820191016102aa565b505050905090810190601f1680156102f65780820380516001836020036101000a031916815260200191505b5085810384528951815289516020918201918b01908083838215610335575b80518252602083111561033557601f199092019160209182019101610315565b505050905090810190601f1680156103615780820380516001836020036101000a031916815260200191505b50858103835287518152875160209182019189019080838382156103a0575b8051825260208311156103a057601f199092019160209182019101610380565b505050905090810190601f1680156103cc5780820380516001836020036101000a031916815260200191505b508581038252865181528651602091820191880190808383821561040b575b80518252602083111561040b57601f1990920191602091820191016103eb565b505050905090810190601f1680156104375780820380516001836020036101000a031916815260200191505b509a505050505050505050505060405180910390f35b3415610ab657fe5b610abe6122c1565b6040805160208082528351818301528351919283929083019185810191028083838215610b06575b805182526020831115610b0657601f199092019160209182019101610ae6565b5050509050019250505060405180910390f35b3415610b2157fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a0316959394604494939290920191819084018382808284375094965061232a95505050505050565b005b3415610b8357fe5b61024f600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437509496506124cb95505050505050565b6040518087600160a060020a0316600160a060020a0316815260200180602001806020018660ff1660ff168152602001806020018060200185810385528a8181518152602001915080519060200190808383600083146102ca575b8051825260208311156102ca57601f1990920191602091820191016102aa565b505050905090810190601f1680156102f65780820380516001836020036101000a031916815260200191505b5085810384528951815289516020918201918b01908083838215610335575b80518252602083111561033557601f199092019160209182019101610315565b505050905090810190601f1680156103615780820380516001836020036101000a031916815260200191505b50858103835287518152875160209182019189019080838382156103a0575b8051825260208311156103a057601f199092019160209182019101610380565b505050905090810190601f1680156103cc5780820380516001836020036101000a031916815260200191505b508581038252865181528651602091820191880190808383821561040b575b80518252602083111561040b57601f1990920191602091820191016103eb565b505050905090810190601f1680156104375780820380516001836020036101000a031916815260200191505b509a505050505050505050505060405180910390f35b3415610dd757fe5b60408051602060046024803582810135601f81018590048502860185019096528585526100eb958335600160a060020a0316959394604494939290920191819084018382808284375094965061257e95505050505050565b005b3415610e3957fe5b6100eb600160a060020a03600435166128a4565b005b6000805433600160a060020a03908116911614610e6c5760006000fd5b600160a060020a038084166000908152600160205260409020548491161515610e955760006000fd5b83600160a060020a0316600484815481101515610eae57fe5b906000526020600020900160005b9054600160a060020a036101009290920a90041614610edb5760006000fd5b600480546000198101908110610eed57fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600484815481101515610f1c57fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a031602179055506001600481818054905003915081610f6491906128f0565b50600160a060020a0380851660009081526001602081815260409283902080546003820154855160ff90911695810186905260a0808252838601805460026000199882161561010002989098011687900491830182905293995091909616957f32c54f1e2ea75844ded7517e7dbcd3895da7cd0c28f9ab9f9cf6ecf5f83762c695929489019360048a019260058b0192918291908201906060830190608084019060c08501908b9080156110595780601f1061102e57610100808354040283529160200191611059565b820191906000526020600020905b81548152906001019060200180831161103c57829003601f168201915b505085810384528954600260001961010060018416150201909116048082526020909101908a9080156110cd5780601f106110a2576101008083540402835291602001916110cd565b820191906000526020600020905b8154815290600101906020018083116110b057829003601f168201915b50508581038352875460026000196101006001841615020190911604808252602090910190889080156111415780601f1061111657610100808354040283529160200191611141565b820191906000526020600020905b81548152906001019060200180831161112457829003601f168201915b50508581038252865460026000196101006001841615020190911604808252602090910190879080156111b55780601f1061118a576101008083540402835291602001916111b5565b820191906000526020600020905b81548152906001019060200180831161119857829003601f168201915b5050995050505050505050505060405180910390a2600282600201604051808280546001816001161561010002031660029004801561122b5780601f1061120957610100808354040283529182019161122b565b820191906000526020600020905b815481529060010190602001808311611217575b5050915050908152602001604051809103902060006101000a815490600160a060020a03021916905560038260010160405180828054600181600116156101000203166002900480156112b55780601f106112935761010080835404028352918201916112b5565b820191906000526020600020905b8154815290600101906020018083116112a1575b5050928352505060408051602092819003830190208054600160a060020a0319908116909155600160a060020a038716600090815260019384905291822080549091168155916113079083018261291a565b61131560028301600061291a565b60038201805460ff1916905561132f60048301600061291a565b61133d60058301600061291a565b50505b5b505b505050565b60006003826040518082805190602001908083835b6020831061137c5780518252601f19909201916020918201910161135d565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a0316925050505b919050565b60006002826040518082805190602001908083835b6020831061137c5780518252601f19909201916020918201910161135d565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a0316925050505b919050565b6000805433600160a060020a0390811691161461144b5760006000fd5b600160a060020a0380841660009081526001602052604090205484911615156114745760006000fd5b600160a060020a0384166000818152600160208181526040928390208351848152600582018054600295811615610100026000190116949094049481018590529096507fc3168fdc13112e44a031057dbf6c609b33353addb4d8037d24543e22cbfe2acd9388928291908201906060830190869080156115355780601f1061150a57610100808354040283529160200191611535565b820191906000526020600020905b81548152906001019060200180831161151857829003601f168201915b505083810382528451815284516020918201918601908083838215611575575b80518252602083111561157557601f199092019160209182019101611555565b505050905090810190601f1680156115a15780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a282516115c590600584019060208601906129aa565b505b5b505b505050565b60006115d9612a29565b6115e1612a29565b60006115eb612a29565b6115f3612a29565b6115fb612a4d565b600160a060020a03888116600090815260016020818152604092839020835160c0810185528154909516855280830180548551600261010096831615969096026000190190911694909404601f8101849004840285018401909552848452909385830193928301828280156116b15780601f10611686576101008083540402835291602001916116b1565b820191906000526020600020905b81548152906001019060200180831161169457829003601f168201915b5050509183525050600282810180546040805160206001841615610100026000190190931694909404601f810183900483028501830190915280845293810193908301828280156117435780601f1061171857610100808354040283529160200191611743565b820191906000526020600020905b81548152906001019060200180831161172657829003601f168201915b5050509183525050600382015460ff1660208083019190915260048301805460408051601f600260001960018616156101000201909416939093049283018590048502810185018252828152940193928301828280156117e45780601f106117b9576101008083540402835291602001916117e4565b820191906000526020600020905b8154815290600101906020018083116117c757829003601f168201915b505050918352505060058201805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529382019392918301828280156118785780601f1061184d57610100808354040283529160200191611878565b820191906000526020600020905b81548152906001019060200180831161185b57829003601f168201915b5050509190925250508151602083015160408401516060850151608086015160a0870151949d50929b50909950975095509350909150505b5091939550919395565b600054600160a060020a031681565b60005433600160a060020a039081169116146118e55760006000fd5b600160a060020a038087166000908152600160205260409020548791161561190d5760006000fd5b86600160a060020a03811615156119245760006000fd5b856000600160a060020a03166002826040518082805190602001908083835b602083106119625780518252601f199092019160209182019101611943565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a03169290921491506119a990505760006000fd5b876000600160a060020a03166003826040518082805190602001908083835b602083106119e75780518252601f1990920191602091820191016119c8565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a0316929092149150611a2e90505760006000fd5b6040805160c081018252600160a060020a038c811680835260208084018e81528486018e905260ff8d166060860152608085018c905260a085018b9052600092835260018083529590922084518154600160a060020a03191694169390931783559051805193949293611aa89385019291909101906129aa565b5060408201518051611ac49160028401916020909101906129aa565b50606082015160038201805460ff191660ff90921691909117905560808201518051611afa9160048401916020909101906129aa565b5060a08201518051611b169160058401916020909101906129aa565b50506004805490915060018101611b2d83826128f0565b916000526020600020900160005b8c909190916101000a815481600160a060020a030219169083600160a060020a0316021790555050896002896040518082805190602001908083835b60208310611b965780518252601f199092019160209182019101611b77565b51815160209384036101000a600019018019909216911617905292019485525060405193849003810184208054600160a060020a031916600160a060020a03969096169590951790945550508a518c926003928d9290918291908401908083835b60208310611c165780518252601f199092019160209182019101611bf7565b51815160209384036101000a60001901801990921691161790529201948552506040805194859003820185208054600160a060020a031916600160a060020a0397881617905560ff8d169085015260a08085528e51908501528d51948f16947fd8d928b0b50ca11d9dc273236b46f3526515b03602f71f3a6af4f45bd9fa9144948f94508e93508d928d928d92918291828201916060840191608085019160c0860191908c01908083838215611ce7575b805182526020831115611ce757601f199092019160209182019101611cc7565b505050905090810190601f168015611d135780820380516001836020036101000a031916815260200191505b5085810384528951815289516020918201918b01908083838215611d52575b805182526020831115611d5257601f199092019160209182019101611d32565b505050905090810190601f168015611d7e5780820380516001836020036101000a031916815260200191505b5085810383528751815287516020918201918901908083838215611dbd575b805182526020831115611dbd57601f199092019160209182019101611d9d565b505050905090810190601f168015611de95780820380516001836020036101000a031916815260200191505b5085810382528651815286516020918201918801908083838215611e28575b805182526020831115611e2857601f199092019160209182019101611e08565b505050905090810190601f168015611e545780820380516001836020036101000a031916815260200191505b50995050505050505050505060405180910390a25b5b505b505b505b505b505050505050565b6000805433600160a060020a03908116911614611e975760006000fd5b600160a060020a038084166000908152600160205260409020548491161515611ec05760006000fd5b826000600160a060020a03166003826040518082805190602001908083835b60208310611efe5780518252601f199092019160209182019101611edf565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a0316929092149150611f4590505760006000fd5b600160a060020a03851660008181526001602081815260409283902083518481528184018054600295811615610100026000190116949094049481018590529097507f4a6dbfc867b179991dec22ff19960f0a94d8d9d891fc556f547764670340e8ae9389928291908201906060830190869080156120055780601f10611fda57610100808354040283529160200191612005565b820191906000526020600020905b815481529060010190602001808311611fe857829003601f168201915b505083810382528451815284516020918201918601908083838215612045575b80518252602083111561204557601f199092019160209182019101612025565b505050905090810190601f1680156120715780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a260038360010160405180828054600181600116156101000203166002900480156120e15780601f106120bf5761010080835404028352918201916120e1565b820191906000526020600020905b8154815290600101906020018083116120cd575b5050928352505060405190819003602090810182208054600160a060020a031916905585518792600392889282918401908083835b602083106121355780518252601f199092019160209182019101612116565b51815160209384036101000a60001901801990921691161790529201948552506040519384900381019093208054600160a060020a031916600160a060020a03959095169490941790935550855161133d925060018601918701906129aa565b505b5b505b505b505050565b600160208190526000918252604090912080546003820154600160a060020a0390911692820191600281019160ff1690600481019060050186565b60048054829081106121ea57fe5b906000526020600020900160005b915054906101000a9004600160a060020a031681565b6000612218612a29565b612220612a29565b600061222a612a29565b612232612a29565b60006003886040518082805190602001908083835b602083106122665780518252601f199092019160209182019101612247565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a031692506122aa91508290506115cf565b9650965096509650965096505b5091939550919395565b6122c9612a29565b600480548060200260200160405190810160405280929190818152602001828054801561231f57602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311612301575b505050505090505b90565b6000805433600160a060020a039081169116146123475760006000fd5b600160a060020a0380841660009081526001602052604090205484911615156123705760006000fd5b600160a060020a0384166000818152600160208181526040928390208351848152600482018054600295811615610100026000190116949094049481018590529096507f5b19f79ac4e8cfa820815502e11615f1a449e28155dc289ec5cac1a11f9086949388928291908201906060830190869080156124315780601f1061240657610100808354040283529160200191612431565b820191906000526020600020905b81548152906001019060200180831161241457829003601f168201915b505083810382528451815284516020918201918601908083838215612471575b80518252602083111561247157601f199092019160209182019101612451565b505050905090810190601f16801561249d5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a282516115c590600484019060208601906129aa565b505b5b505b505050565b60006124d5612a29565b6124dd612a29565b60006124e7612a29565b6124ef612a29565b60006002886040518082805190602001908083835b602083106122665780518252601f199092019160209182019101612247565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a031692506122aa91508290506115cf565b9650965096509650965096505b5091939550919395565b6000805433600160a060020a0390811691161461259b5760006000fd5b600160a060020a0380841660009081526001602052604090205484911615156125c45760006000fd5b826000600160a060020a03166002826040518082805190602001908083835b602083106126025780518252601f1990920191602091820191016125e3565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a031692909214915061264990505760006000fd5b600160a060020a038516600081815260016020818152604092839020835184815260028083018054958616156101000260001901909516049481018590529097507f53d878a6530e56c9bc96548fa0a8cae4f1d1f49c86b0e934c086b992ebb6998f9389928291908201906060830190869080156127085780601f106126dd57610100808354040283529160200191612708565b820191906000526020600020905b8154815290600101906020018083116126eb57829003601f168201915b505083810382528451815284516020918201918601908083838215612748575b80518252602083111561274857601f199092019160209182019101612728565b505050905090810190601f1680156127745780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a260028360020160405180828054600181600116156101000203166002900480156127e45780601f106127c25761010080835404028352918201916127e4565b820191906000526020600020905b8154815290600101906020018083116127d0575b5050928352505060405190819003602090810182208054600160a060020a031916905585518792600292889282918401908083835b602083106128385780518252601f199092019160209182019101612819565b51815160209384036101000a60001901801990921691161790529201948552506040519384900381019093208054600160a060020a031916600160a060020a03959095169490941790935550855161133d925060028601918701906129aa565b505b5b505b505b505050565b60005433600160a060020a039081169116146128c05760006000fd5b600160a060020a038116156128eb5760008054600160a060020a031916600160a060020a0383161790555b5b5b50565b81548183558181151161134357600083815260209020611343918101908301612c54565b5b505050565b50805460018160011615610100020316600290046000825580601f1061294057506128eb565b601f0160209004906000526020600020908101906128eb9190612c54565b5b50565b50805460018160011615610100020316600290046000825580601f1061294057506128eb565b601f0160209004906000526020600020908101906128eb9190612c54565b5b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129eb57805160ff1916838001178555612a18565b82800160010185558215612a18579182015b82811115612a185782518255916020019190600101906129fd565b5b50612a25929150612c54565b5090565b60408051602081019091526000815290565b60408051602081019091526000815290565b6040805160c081019091526000815260208101612a68612a29565b8152602001612a75612a29565b815260006020820152604001612a89612a29565b8152602001612a96612a29565b905290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129eb57805160ff1916838001178555612a18565b82800160010185558215612a18579182015b82811115612a185782518255916020019190600101906129fd565b5b50612a25929150612c54565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129eb57805160ff1916838001178555612a18565b82800160010185558215612a18579182015b82811115612a185782518255916020019190600101906129fd565b5b50612a25929150612c54565b5090565b81548183558181151161134357600083815260209020611343918101908301612c54565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129eb57805160ff1916838001178555612a18565b82800160010185558215612a18579182015b82811115612a185782518255916020019190600101906129fd565b5b50612a25929150612c54565b5090565b60408051602081019091526000815290565b61232791905b80821115612a255760008155600101612c5a565b5090565b90565b60408051602081019091526000815290565b604080516020810190915260008152905600a165627a7a72305820eea167af82f9fa569e6816bc55cad0ce2239725a9d14f6aa5372ae5c886835ae0029",
"networks": {
- "50": {
+ "1": {
"links": {},
"events": {
"0xd8d928b0b50ca11d9dc273236b46f3526515b03602f71f3a6af4f45bd9fa9144": {
@@ -695,8 +695,8 @@
"type": "event"
}
},
- "updated_at": 1502391794385,
- "address": "0xf7c37d12f3355d052ef9ca60131118af615f5653"
+ "updated_at": 1502488442000,
+ "address": "0x926a74c5c36adf004c87399e65f75628b0f98d2c"
},
"42": {
"links": {},
@@ -867,7 +867,7 @@
"updated_at": 1502391794385,
"address": "0xf18e504561f4347bea557f3d4558f559dddbae7f"
},
- "1": {
+ "50": {
"links": {},
"events": {
"0xd8d928b0b50ca11d9dc273236b46f3526515b03602f71f3a6af4f45bd9fa9144": {
@@ -1033,10 +1033,10 @@
"type": "event"
}
},
- "updated_at": 1502488442000,
- "address": "0x926a74c5c36adf004c87399e65f75628b0f98d2c"
+ "updated_at": 1513088404203,
+ "address": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082"
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794385
-}
+ "updated_at": 1513088404203
+} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/TokenTransferProxy.json b/packages/contracts/build/contracts/TokenTransferProxy.json
index dc2c13f0c..4dd37f0bc 100644
--- a/packages/contracts/build/contracts/TokenTransferProxy.json
+++ b/packages/contracts/build/contracts/TokenTransferProxy.json
@@ -167,9 +167,9 @@
"type": "event"
}
],
- "unlinked_binary": "0x60606040525b60008054600160a060020a03191633600160a060020a03161790555b5b6106e6806100316000396000f300606060405236156100725763ffffffff60e060020a60003504166315dacbea811461007457806342f1181e146100b3578063494503d4146100d157806370712939146101005780638da5cb5b1461011e578063b91816111461014a578063d39de6e91461017a578063f2fde38b146101e5575bfe5b341561007c57fe5b61009f600160a060020a0360043581169060243581169060443516606435610203565b604080519115158252519081900360200190f35b34156100bb57fe5b6100cf600160a060020a03600435166102ae565b005b34156100d957fe5b6100e4600435610390565b60408051600160a060020a039092168252519081900360200190f35b341561010857fe5b6100cf600160a060020a03600435166103c2565b005b341561012657fe5b6100e461055a565b60408051600160a060020a039092168252519081900360200190f35b341561015257fe5b61009f600160a060020a0360043516610569565b604080519115158252519081900360200190f35b341561018257fe5b61018a61057e565b60408051602080825283518183015283519192839290830191858101910280838382156101d2575b8051825260208311156101d257601f1990920191602091820191016101b2565b5050509050019250505060405180910390f35b34156101ed57fe5b6100cf600160a060020a03600435166105e7565b005b600160a060020a03331660009081526001602052604081205460ff16151561022b5760006000fd5b6040805160006020918201819052825160e060020a6323b872dd028152600160a060020a0388811660048301528781166024830152604482018790529351938916936323b872dd9360648084019491938390030190829087803b151561028d57fe5b6102c65a03f1151561029b57fe5b5050604051519150505b5b949350505050565b60005433600160a060020a039081169116146102ca5760006000fd5b600160a060020a038116600090815260016020526040902054819060ff16156102f35760006000fd5b600160a060020a0382166000908152600160208190526040909120805460ff191682179055600280549091810161032a8382610633565b916000526020600020900160005b81546101009190910a600160a060020a0381810219909216868316918202179092556040513390911692507f94bb87f4c15c4587ff559a7584006fa01ddf9299359be6b512b94527aa961aca90600090a35b5b505b50565b600280548290811061039e57fe5b906000526020600020900160005b915054906101000a9004600160a060020a031681565b6000805433600160a060020a039081169116146103df5760006000fd5b600160a060020a038216600090815260016020526040902054829060ff1615156104095760006000fd5b600160a060020a0383166000908152600160205260408120805460ff1916905591505b6002548210156105195782600160a060020a031660028381548110151561044f57fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600160a060020a0316141561050d5760028054600019810190811061049057fe5b906000526020600020900160005b9054906101000a9004600160a060020a03166002838154811015156104bf57fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a0316021790555060016002818180549050039150816105079190610633565b50610519565b5b60019091019061042c565b604051600160a060020a0333811691908516907ff5b347a1e40749dd050f5f07fbdbeb7e3efa9756903044dd29401fd1d4bb4a1c90600090a35b5b505b5050565b600054600160a060020a031681565b60016020526000908152604090205460ff1681565b610586610687565b60028054806020026020016040519081016040528092919081815260200182805480156105dc57602002820191906000526020600020905b8154600160a060020a031681526001909101906020018083116105be575b505050505090505b90565b60005433600160a060020a039081169116146106035760006000fd5b600160a060020a0381161561038d5760008054600160a060020a031916600160a060020a0383161790555b5b5b50565b81548183558181151161055357600083815260209020610553918101908301610699565b5b505050565b81548183558181151161055357600083815260209020610553918101908301610699565b5b505050565b60408051602081019091526000815290565b6105e491905b808211156106b3576000815560010161069f565b5090565b905600a165627a7a723058200355c2e534da7274d090b5a2209d5fbe4679ee2760a73c55c16e6d0ff1af016c0029",
+ "unlinked_binary": "0x60606040525b60008054600160a060020a03191633600160a060020a03161790555b5b6106e6806100316000396000f300606060405236156100725763ffffffff60e060020a60003504166315dacbea811461007457806342f1181e146100b3578063494503d4146100d157806370712939146101005780638da5cb5b1461011e578063b91816111461014a578063d39de6e91461017a578063f2fde38b146101e5575bfe5b341561007c57fe5b61009f600160a060020a0360043581169060243581169060443516606435610203565b604080519115158252519081900360200190f35b34156100bb57fe5b6100cf600160a060020a03600435166102ae565b005b34156100d957fe5b6100e4600435610390565b60408051600160a060020a039092168252519081900360200190f35b341561010857fe5b6100cf600160a060020a03600435166103c2565b005b341561012657fe5b6100e461055a565b60408051600160a060020a039092168252519081900360200190f35b341561015257fe5b61009f600160a060020a0360043516610569565b604080519115158252519081900360200190f35b341561018257fe5b61018a61057e565b60408051602080825283518183015283519192839290830191858101910280838382156101d2575b8051825260208311156101d257601f1990920191602091820191016101b2565b5050509050019250505060405180910390f35b34156101ed57fe5b6100cf600160a060020a03600435166105e7565b005b600160a060020a03331660009081526001602052604081205460ff16151561022b5760006000fd5b6040805160006020918201819052825160e060020a6323b872dd028152600160a060020a0388811660048301528781166024830152604482018790529351938916936323b872dd9360648084019491938390030190829087803b151561028d57fe5b6102c65a03f1151561029b57fe5b5050604051519150505b5b949350505050565b60005433600160a060020a039081169116146102ca5760006000fd5b600160a060020a038116600090815260016020526040902054819060ff16156102f35760006000fd5b600160a060020a0382166000908152600160208190526040909120805460ff191682179055600280549091810161032a8382610633565b916000526020600020900160005b81546101009190910a600160a060020a0381810219909216868316918202179092556040513390911692507f94bb87f4c15c4587ff559a7584006fa01ddf9299359be6b512b94527aa961aca90600090a35b5b505b50565b600280548290811061039e57fe5b906000526020600020900160005b915054906101000a9004600160a060020a031681565b6000805433600160a060020a039081169116146103df5760006000fd5b600160a060020a038216600090815260016020526040902054829060ff1615156104095760006000fd5b600160a060020a0383166000908152600160205260408120805460ff1916905591505b6002548210156105195782600160a060020a031660028381548110151561044f57fe5b906000526020600020900160005b9054906101000a9004600160a060020a0316600160a060020a0316141561050d5760028054600019810190811061049057fe5b906000526020600020900160005b9054906101000a9004600160a060020a03166002838154811015156104bf57fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a0316021790555060016002818180549050039150816105079190610633565b50610519565b5b60019091019061042c565b604051600160a060020a0333811691908516907ff5b347a1e40749dd050f5f07fbdbeb7e3efa9756903044dd29401fd1d4bb4a1c90600090a35b5b505b5050565b600054600160a060020a031681565b60016020526000908152604090205460ff1681565b610586610687565b60028054806020026020016040519081016040528092919081815260200182805480156105dc57602002820191906000526020600020905b8154600160a060020a031681526001909101906020018083116105be575b505050505090505b90565b60005433600160a060020a039081169116146106035760006000fd5b600160a060020a0381161561038d5760008054600160a060020a031916600160a060020a0383161790555b5b5b50565b81548183558181151161055357600083815260209020610553918101908301610699565b5b505050565b81548183558181151161055357600083815260209020610553918101908301610699565b5b505050565b60408051602081019091526000815290565b6105e491905b808211156106b3576000815560010161069f565b5090565b905600a165627a7a72305820f53c9547789a008ccb8f24999a7b6fb4c8fb20655522030c87ba624e1fdb67ea0029",
"networks": {
- "50": {
+ "1": {
"links": {},
"events": {
"0x94bb87f4c15c4587ff559a7584006fa01ddf9299359be6b512b94527aa961aca": {
@@ -207,8 +207,8 @@
"type": "event"
}
},
- "updated_at": 1502391794384,
- "address": "0x168ead2eadb6b3b8f47d6ae0ff418451c1087239"
+ "updated_at": 1502478966000,
+ "address": "0x8da0d80f5007ef1e431dd2127178d224e32c2ef4"
},
"42": {
"links": {},
@@ -251,7 +251,7 @@
"updated_at": 1502391794384,
"address": "0x087Eed4Bc1ee3DE49BeFbd66C662B434B15d49d4"
},
- "1": {
+ "50": {
"links": {},
"events": {
"0x94bb87f4c15c4587ff559a7584006fa01ddf9299359be6b512b94527aa961aca": {
@@ -289,10 +289,10 @@
"type": "event"
}
},
- "updated_at": 1502478966000,
- "address": "0x8da0d80f5007ef1e431dd2127178d224e32c2ef4"
+ "updated_at": 1513088404202,
+ "address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794384
-}
+ "updated_at": 1513088404202
+} \ No newline at end of file
diff --git a/packages/contracts/build/contracts/ZRXToken.json b/packages/contracts/build/contracts/ZRXToken.json
index 3aac50ace..37a576c93 100644
--- a/packages/contracts/build/contracts/ZRXToken.json
+++ b/packages/contracts/build/contracts/ZRXToken.json
@@ -213,9 +213,9 @@
"type": "event"
}
],
- "unlinked_binary": "0x60606040526b033b2e3c9fd0803ce8000000600355341561001c57fe5b5b600354600160a060020a0333166000908152602081905260409020555b5b6106198061004a6000396000f3006060604052361561007d5763ffffffff60e060020a60003504166306fdde03811461007f578063095ea7b31461010f57806318160ddd1461014257806323b872dd14610164578063313ce5671461019d57806370a08231146101c357806395d89b41146101f1578063a9059cbb14610281578063dd62ed3e146102b4575bfe5b341561008757fe5b61008f6102e8565b6040805160208082528351818301528351919283929083019185019080838382156100d5575b8051825260208311156100d557601f1990920191602091820191016100b5565b505050905090810190601f1680156101015780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561011757fe5b61012e600160a060020a0360043516602435610316565b604080519115158252519081900360200190f35b341561014a57fe5b610152610381565b60408051918252519081900360200190f35b341561016c57fe5b61012e600160a060020a0360043581169060243516604435610387565b604080519115158252519081900360200190f35b34156101a557fe5b6101ad6104aa565b6040805160ff9092168252519081900360200190f35b34156101cb57fe5b610152600160a060020a03600435166104af565b60408051918252519081900360200190f35b34156101f957fe5b61008f6104ce565b6040805160208082528351818301528351919283929083019185019080838382156100d5575b8051825260208311156100d557601f1990920191602091820191016100b5565b505050905090810190601f1680156101015780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561028957fe5b61012e600160a060020a03600435166024356104ee565b604080519115158252519081900360200190f35b34156102bc57fe5b610152600160a060020a03600435811690602435166105a0565b60408051918252519081900360200190f35b6040805180820190915260118152607960020a70183c10283937ba37b1b7b6102a37b5b2b702602082015281565b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60035481565b600160a060020a03808416600081815260016020908152604080832033909516835293815283822054928252819052918220548390108015906103ca5750828110155b80156103f05750600160a060020a03841660009081526020819052604090205483810110155b1561049c57600160a060020a038085166000908152602081905260408082208054870190559187168152208054849003905560001981101561045a57600160a060020a03808616600090815260016020908152604080832033909416835292905220805484900390555b83600160a060020a031685600160a060020a03166000805160206105ce833981519152856040518082815260200191505060405180910390a3600191506104a1565b600091505b5b509392505050565b601281565b600160a060020a0381166000908152602081905260409020545b919050565b604080518082019091526003815260eb60020a620b4a4b02602082015281565b600160a060020a0333166000908152602081905260408120548290108015906105315750600160a060020a03831660009081526020819052604090205482810110155b1561059157600160a060020a0333811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191936000805160206105ce833981519152929081900390910190a350600161037b565b50600061037b565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820c3b32a51a49bb8e7b08cb40d70b018590761113b8e17709dace660ef94b069e30029",
+ "unlinked_binary": "0x60606040526b033b2e3c9fd0803ce8000000600355341561001c57fe5b5b600354600160a060020a0333166000908152602081905260409020555b5b6106198061004a6000396000f3006060604052361561007d5763ffffffff60e060020a60003504166306fdde03811461007f578063095ea7b31461010f57806318160ddd1461014257806323b872dd14610164578063313ce5671461019d57806370a08231146101c357806395d89b41146101f1578063a9059cbb14610281578063dd62ed3e146102b4575bfe5b341561008757fe5b61008f6102e8565b6040805160208082528351818301528351919283929083019185019080838382156100d5575b8051825260208311156100d557601f1990920191602091820191016100b5565b505050905090810190601f1680156101015780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561011757fe5b61012e600160a060020a0360043516602435610316565b604080519115158252519081900360200190f35b341561014a57fe5b610152610381565b60408051918252519081900360200190f35b341561016c57fe5b61012e600160a060020a0360043581169060243516604435610387565b604080519115158252519081900360200190f35b34156101a557fe5b6101ad6104aa565b6040805160ff9092168252519081900360200190f35b34156101cb57fe5b610152600160a060020a03600435166104af565b60408051918252519081900360200190f35b34156101f957fe5b61008f6104ce565b6040805160208082528351818301528351919283929083019185019080838382156100d5575b8051825260208311156100d557601f1990920191602091820191016100b5565b505050905090810190601f1680156101015780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561028957fe5b61012e600160a060020a03600435166024356104ee565b604080519115158252519081900360200190f35b34156102bc57fe5b610152600160a060020a03600435811690602435166105a0565b60408051918252519081900360200190f35b6040805180820190915260118152607960020a70183c10283937ba37b1b7b6102a37b5b2b702602082015281565b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60035481565b600160a060020a03808416600081815260016020908152604080832033909516835293815283822054928252819052918220548390108015906103ca5750828110155b80156103f05750600160a060020a03841660009081526020819052604090205483810110155b1561049c57600160a060020a038085166000908152602081905260408082208054870190559187168152208054849003905560001981101561045a57600160a060020a03808616600090815260016020908152604080832033909416835292905220805484900390555b83600160a060020a031685600160a060020a03166000805160206105ce833981519152856040518082815260200191505060405180910390a3600191506104a1565b600091505b5b509392505050565b601281565b600160a060020a0381166000908152602081905260409020545b919050565b604080518082019091526003815260eb60020a620b4a4b02602082015281565b600160a060020a0333166000908152602081905260408120548290108015906105315750600160a060020a03831660009081526020819052604090205482810110155b1561059157600160a060020a0333811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191936000805160206105ce833981519152929081900390910190a350600161037b565b50600061037b565b5b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a723058206964b3cfca2af9b1d1448e45eb8b04a5c1df55275a172242166d69e576e2a3b70029",
"networks": {
- "50": {
+ "1": {
"links": {},
"events": {
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": {
@@ -263,7 +263,8 @@
"type": "event"
}
},
- "updated_at": 1502391794391
+ "updated_at": 1502477311000,
+ "address": "0xe41d2489571d322189246dafa5ebde1f4699f498"
},
"42": {
"links": {},
@@ -315,8 +316,8 @@
},
"updated_at": 1502391794391,
"address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
- },
- "1": {
+ },
+ "50": {
"links": {},
"events": {
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": {
@@ -364,10 +365,9 @@
"type": "event"
}
},
- "updated_at": 1502477311000,
- "address": "0xe41d2489571d322189246dafa5ebde1f4699f498"
+ "updated_at": 1513088404207
}
},
"schema_version": "0.0.5",
- "updated_at": 1502391794391
-}
+ "updated_at": 1513088404207
+} \ No newline at end of file
diff --git a/packages/contracts/contracts/Exchange.sol b/packages/contracts/contracts/Exchange.sol
index 02deee967..a402e7ca5 100644
--- a/packages/contracts/contracts/Exchange.sol
+++ b/packages/contracts/contracts/Exchange.sol
@@ -16,11 +16,11 @@
*/
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
import "./TokenTransferProxy.sol";
-import "./base/Token.sol";
-import "./base/SafeMath.sol";
+import "./tokens/Token.sol";
+import "./utils/SafeMath.sol";
/// @title Exchange - Facilitates exchange of ERC20 tokens.
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
@@ -600,3 +600,4 @@ contract Exchange is SafeMath {
return Token(token).allowance.gas(EXTERNAL_QUERY_GAS_LIMIT)(owner, TOKEN_TRANSFER_PROXY_CONTRACT); // Limit gas to prevent reentrancy
}
}
+
diff --git a/packages/contracts/contracts/TokenRegistry.sol b/packages/contracts/contracts/TokenRegistry.sol
index d370f8cfe..d2570e71d 100644
--- a/packages/contracts/contracts/TokenRegistry.sol
+++ b/packages/contracts/contracts/TokenRegistry.sol
@@ -16,9 +16,9 @@
*/
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
-import "./base/Ownable.sol";
+import "./utils/Ownable.sol";
/// @title Token Registry - Stores metadata associated with ERC20 tokens. See ERC22 https://github.com/ethereum/EIPs/issues/22
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
@@ -306,3 +306,4 @@ contract TokenRegistry is Ownable {
return tokenAddresses;
}
}
+
diff --git a/packages/contracts/contracts/TokenTransferProxy.sol b/packages/contracts/contracts/TokenTransferProxy.sol
index 23b0b9e6d..fd2358496 100644
--- a/packages/contracts/contracts/TokenTransferProxy.sol
+++ b/packages/contracts/contracts/TokenTransferProxy.sol
@@ -16,10 +16,10 @@
*/
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
-import "./base/Token.sol";
-import "./base/Ownable.sol";
+import "./tokens/Token.sol";
+import "./utils/Ownable.sol";
/// @title TokenTransferProxy - Transfers tokens on behalf of contracts that have been approved via decentralized governance.
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
@@ -113,3 +113,4 @@ contract TokenTransferProxy is Ownable {
return authorities;
}
}
+
diff --git a/packages/contracts/contracts/base/SafeMath.sol b/packages/contracts/contracts/base/SafeMath.sol
deleted file mode 100644
index fac674a20..000000000
--- a/packages/contracts/contracts/base/SafeMath.sol
+++ /dev/null
@@ -1,41 +0,0 @@
-pragma solidity 0.4.11;
-
-contract SafeMath {
- function safeMul(uint a, uint b) internal constant returns (uint256) {
- uint c = a * b;
- assert(a == 0 || c / a == b);
- return c;
- }
-
- function safeDiv(uint a, uint b) internal constant returns (uint256) {
- uint c = a / b;
- return c;
- }
-
- function safeSub(uint a, uint b) internal constant returns (uint256) {
- assert(b <= a);
- return a - b;
- }
-
- function safeAdd(uint a, uint b) internal constant returns (uint256) {
- uint c = a + b;
- assert(c >= a);
- return c;
- }
-
- function max64(uint64 a, uint64 b) internal constant returns (uint64) {
- return a >= b ? a : b;
- }
-
- function min64(uint64 a, uint64 b) internal constant returns (uint64) {
- return a < b ? a : b;
- }
-
- function max256(uint256 a, uint256 b) internal constant returns (uint256) {
- return a >= b ? a : b;
- }
-
- function min256(uint256 a, uint256 b) internal constant returns (uint256) {
- return a < b ? a : b;
- }
-}
diff --git a/packages/contracts/contracts/base/MultiSigWallet.sol b/packages/contracts/contracts/multisig/MultiSigWallet.sol
index 7531224ea..ae7ef06fd 100644
--- a/packages/contracts/contracts/base/MultiSigWallet.sol
+++ b/packages/contracts/contracts/multisig/MultiSigWallet.sol
@@ -1,4 +1,4 @@
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <stefan.george@consensys.net>
@@ -363,3 +363,4 @@ contract MultiSigWallet {
_transactionIds[i - from] = transactionIdsTemp[i];
}
}
+
diff --git a/packages/contracts/contracts/MultiSigWalletWithTimeLock.sol b/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLock.sol
index 70123e6b6..62273eba3 100644
--- a/packages/contracts/contracts/MultiSigWalletWithTimeLock.sol
+++ b/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLock.sol
@@ -16,9 +16,9 @@
*/
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
-import "./base/MultiSigWallet.sol";
+import "./MultiSigWallet.sol";
/// @title Multisignature wallet with time lock- Allows multiple parties to execute a transaction after a time lock has passed.
/// @author Amir Bandeali - <amir@0xProject.com>
@@ -130,3 +130,4 @@ contract MultiSigWalletWithTimeLock is MultiSigWallet {
ConfirmationTimeSet(transactionId, confirmationTime);
}
}
+
diff --git a/packages/contracts/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol b/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
index 15fdb1d07..07beb9f5b 100644
--- a/packages/contracts/contracts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
+++ b/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
@@ -16,7 +16,7 @@
*/
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
import "./MultiSigWalletWithTimeLock.sol";
@@ -80,3 +80,4 @@ contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is MultiSigWall
return true;
}
}
+
diff --git a/packages/contracts/contracts/test/DummyToken.sol b/packages/contracts/contracts/test/DummyToken.sol
index 414c17b2a..046af3059 100644
--- a/packages/contracts/contracts/test/DummyToken.sol
+++ b/packages/contracts/contracts/test/DummyToken.sol
@@ -1,7 +1,7 @@
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
import "./Mintable.sol";
-import "./../base/Ownable.sol";
+import "./../utils/Ownable.sol";
contract DummyToken is Mintable, Ownable {
string public name;
@@ -21,7 +21,9 @@ contract DummyToken is Mintable, Ownable {
balances[msg.sender] = _totalSupply;
}
- function setBalance(address _target, uint _value) onlyOwner {
+ function setBalance(address _target, uint _value)
+ onlyOwner
+ {
uint currBalance = balanceOf(_target);
if (_value < currBalance) {
totalSupply = safeSub(totalSupply, safeSub(currBalance, _value));
@@ -31,3 +33,4 @@ contract DummyToken is Mintable, Ownable {
balances[_target] = _value;
}
}
+
diff --git a/packages/contracts/contracts/test/DummyToken_v2.sol b/packages/contracts/contracts/test/DummyToken_v2.sol
new file mode 100644
index 000000000..bd4d06be9
--- /dev/null
+++ b/packages/contracts/contracts/test/DummyToken_v2.sol
@@ -0,0 +1,38 @@
+pragma solidity 0.4.18;
+
+import "./Mintable_v2.sol";
+import "./../utils/Ownable_v2.sol";
+
+contract DummyToken_v2 is Mintable_v2, Ownable_v2 {
+ string public name;
+ string public symbol;
+ uint public decimals;
+
+ function DummyToken_v2(
+ string _name,
+ string _symbol,
+ uint _decimals,
+ uint _totalSupply)
+ public
+ {
+ name = _name;
+ symbol = _symbol;
+ decimals = _decimals;
+ totalSupply = _totalSupply;
+ balances[msg.sender] = _totalSupply;
+ }
+
+ function setBalance(address _target, uint _value)
+ public
+ onlyOwner
+ {
+ uint currBalance = balanceOf(_target);
+ if (_value < currBalance) {
+ totalSupply = safeSub(totalSupply, safeSub(currBalance, _value));
+ } else {
+ totalSupply = safeAdd(totalSupply, safeSub(_value, currBalance));
+ }
+ balances[_target] = _value;
+ }
+}
+
diff --git a/packages/contracts/contracts/test/MaliciousToken.sol b/packages/contracts/contracts/test/MaliciousToken.sol
index 3c1a53612..3e7d5d1a5 100644
--- a/packages/contracts/contracts/test/MaliciousToken.sol
+++ b/packages/contracts/contracts/test/MaliciousToken.sol
@@ -1,11 +1,13 @@
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
-import "./../base/StandardToken.sol";
+import "./../tokens/StandardToken.sol";
contract MaliciousToken is StandardToken {
uint8 stateToUpdate = 1; // Not null so that change only requires 5000 gas
- function updateState() internal {
+ function updateState()
+ internal
+ {
stateToUpdate++;
}
@@ -27,3 +29,4 @@ contract MaliciousToken is StandardToken {
return allowed[_owner][_spender];
}
}
+
diff --git a/packages/contracts/contracts/test/Mintable.sol b/packages/contracts/contracts/test/Mintable.sol
index c0438f304..3b91415ef 100644
--- a/packages/contracts/contracts/test/Mintable.sol
+++ b/packages/contracts/contracts/test/Mintable.sol
@@ -1,16 +1,19 @@
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
import "./../tokens/UnlimitedAllowanceToken.sol";
-import "./../base/SafeMath.sol";
+import "./../utils/SafeMath.sol";
/*
* Mintable
* Base contract that creates a mintable UnlimitedAllowanceToken
*/
contract Mintable is UnlimitedAllowanceToken, SafeMath {
- function mint(uint _value) {
+ function mint(uint _value)
+ public
+ {
require(_value <= 100000000000000000000);
balances[msg.sender] = safeAdd(_value, balances[msg.sender]);
totalSupply = safeAdd(totalSupply, _value);
}
}
+
diff --git a/packages/contracts/contracts/test/Mintable_v2.sol b/packages/contracts/contracts/test/Mintable_v2.sol
new file mode 100644
index 000000000..829145cfb
--- /dev/null
+++ b/packages/contracts/contracts/test/Mintable_v2.sol
@@ -0,0 +1,19 @@
+pragma solidity 0.4.18;
+
+import "./../tokens/UnlimitedAllowanceToken_v2.sol";
+import "./../utils/SafeMath_v2.sol";
+
+/*
+ * Mintable
+ * Base contract that creates a mintable UnlimitedAllowanceToken
+ */
+contract Mintable_v2 is UnlimitedAllowanceToken_v2, SafeMath_v2 {
+ function mint(uint _value)
+ public
+ {
+ require(_value <= 100000000000000000000);
+ balances[msg.sender] = safeAdd(_value, balances[msg.sender]);
+ totalSupply = safeAdd(totalSupply, _value);
+ }
+}
+
diff --git a/packages/contracts/contracts/tokens/ERC20Token.sol b/packages/contracts/contracts/tokens/ERC20Token.sol
new file mode 100644
index 000000000..318da8c01
--- /dev/null
+++ b/packages/contracts/contracts/tokens/ERC20Token.sol
@@ -0,0 +1,59 @@
+pragma solidity 0.4.18;
+
+import "./Token_v2.sol";
+
+contract ERC20Token is Token_v2 {
+
+ function transfer(address _to, uint _value)
+ public
+ returns (bool)
+ {
+ require(balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]);
+ balances[msg.sender] -= _value;
+ balances[_to] += _value;
+ Transfer(msg.sender, _to, _value);
+ return true;
+ }
+
+ function transferFrom(address _from, address _to, uint _value)
+ public
+ returns (bool)
+ {
+ require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value >= balances[_to]);
+ balances[_to] += _value;
+ balances[_from] -= _value;
+ allowed[_from][msg.sender] -= _value;
+ Transfer(_from, _to, _value);
+ return true;
+ }
+
+ function approve(address _spender, uint _value)
+ public
+ returns (bool)
+ {
+ allowed[msg.sender][_spender] = _value;
+ Approval(msg.sender, _spender, _value);
+ return true;
+ }
+
+ function balanceOf(address _owner)
+ public
+ view
+ returns (uint)
+ {
+ return balances[_owner];
+ }
+
+ function allowance(address _owner, address _spender)
+ public
+ view
+ returns (uint)
+ {
+ return allowed[_owner][_spender];
+ }
+
+ mapping (address => uint) balances;
+ mapping (address => mapping (address => uint)) allowed;
+ uint public totalSupply;
+}
+
diff --git a/packages/contracts/contracts/tokens/EtherToken.sol b/packages/contracts/contracts/tokens/EtherToken.sol
deleted file mode 100644
index 68148e095..000000000
--- a/packages/contracts/contracts/tokens/EtherToken.sol
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-
- Copyright 2017 ZeroEx Intl.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-pragma solidity 0.4.11;
-
-import "./UnlimitedAllowanceToken.sol";
-import "./../base/SafeMath.sol";
-
-contract EtherToken is UnlimitedAllowanceToken, SafeMath {
-
- string constant public name = "Ether Token";
- string constant public symbol = "WETH";
- uint8 constant public decimals = 18;
-
- /// @dev Fallback to calling deposit when ether is sent directly to contract.
- function()
- public
- payable
- {
- deposit();
- }
-
- /// @dev Buys tokens with Ether, exchanging them 1:1.
- function deposit()
- public
- payable
- {
- balances[msg.sender] = safeAdd(balances[msg.sender], msg.value);
- totalSupply = safeAdd(totalSupply, msg.value);
- }
-
- /// @dev Sells tokens in exchange for Ether, exchanging them 1:1.
- /// @param amount Number of tokens to sell.
- function withdraw(uint amount)
- public
- {
- balances[msg.sender] = safeSub(balances[msg.sender], amount);
- totalSupply = safeSub(totalSupply, amount);
- require(msg.sender.send(amount));
- }
-}
diff --git a/packages/contracts/contracts/base/StandardToken.sol b/packages/contracts/contracts/tokens/StandardToken.sol
index e0719d89a..9cd53d94a 100644
--- a/packages/contracts/contracts/base/StandardToken.sol
+++ b/packages/contracts/contracts/tokens/StandardToken.sol
@@ -1,4 +1,4 @@
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
import "./Token.sol";
@@ -42,3 +42,4 @@ contract StandardToken is Token {
mapping (address => mapping (address => uint)) allowed;
uint public totalSupply;
}
+
diff --git a/packages/contracts/contracts/base/Token.sol b/packages/contracts/contracts/tokens/Token.sol
index c6a55c2c0..507de9b12 100644
--- a/packages/contracts/contracts/base/Token.sol
+++ b/packages/contracts/contracts/tokens/Token.sol
@@ -1,4 +1,4 @@
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
contract Token {
@@ -36,3 +36,4 @@ contract Token {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
+
diff --git a/packages/contracts/contracts/tokens/Token_v2.sol b/packages/contracts/contracts/tokens/Token_v2.sol
new file mode 100644
index 000000000..e1088c560
--- /dev/null
+++ b/packages/contracts/contracts/tokens/Token_v2.sol
@@ -0,0 +1,36 @@
+pragma solidity 0.4.18;
+
+contract Token_v2 {
+
+ /// @notice send `_value` token to `_to` from `msg.sender`
+ /// @param _to The address of the recipient
+ /// @param _value The amount of token to be transferred
+ /// @return Whether the transfer was successful or not
+ function transfer(address _to, uint _value) public returns (bool) {}
+
+ /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
+ /// @param _from The address of the sender
+ /// @param _to The address of the recipient
+ /// @param _value The amount of token to be transferred
+ /// @return Whether the transfer was successful or not
+ function transferFrom(address _from, address _to, uint _value) public returns (bool) {}
+
+ /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
+ /// @param _spender The address of the account able to transfer the tokens
+ /// @param _value The amount of wei to be approved for transfer
+ /// @return Whether the approval was successful or not
+ function approve(address _spender, uint _value) public returns (bool) {}
+
+ /// @param _owner The address from which the balance will be retrieved
+ /// @return The balance
+ function balanceOf(address _owner) public view returns (uint) {}
+
+ /// @param _owner The address of the account owning tokens
+ /// @param _spender The address of the account able to transfer the tokens
+ /// @return Amount of remaining tokens allowed to spent
+ function allowance(address _owner, address _spender) public view returns (uint) {}
+
+ event Transfer(address indexed _from, address indexed _to, uint _value);
+ event Approval(address indexed _owner, address indexed _spender, uint _value);
+}
+
diff --git a/packages/contracts/contracts/tokens/UnlimitedAllowanceToken.sol b/packages/contracts/contracts/tokens/UnlimitedAllowanceToken.sol
index 40e01b360..0994cfae4 100644
--- a/packages/contracts/contracts/tokens/UnlimitedAllowanceToken.sol
+++ b/packages/contracts/contracts/tokens/UnlimitedAllowanceToken.sol
@@ -16,9 +16,9 @@
*/
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
-import "./../base/StandardToken.sol";
+import "./StandardToken.sol";
contract UnlimitedAllowanceToken is StandardToken {
@@ -50,3 +50,4 @@ contract UnlimitedAllowanceToken is StandardToken {
}
}
}
+
diff --git a/packages/contracts/contracts/tokens/UnlimitedAllowanceToken_v2.sol b/packages/contracts/contracts/tokens/UnlimitedAllowanceToken_v2.sol
new file mode 100644
index 000000000..b2caab8af
--- /dev/null
+++ b/packages/contracts/contracts/tokens/UnlimitedAllowanceToken_v2.sol
@@ -0,0 +1,47 @@
+/*
+
+ Copyright 2017 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity 0.4.18;
+
+import "./ERC20Token.sol";
+
+contract UnlimitedAllowanceToken_v2 is ERC20Token {
+
+ uint constant MAX_UINT = 2**256 - 1;
+
+ /// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. See https://github.com/ethereum/EIPs/issues/717
+ /// @param _from Address to transfer from.
+ /// @param _to Address to transfer to.
+ /// @param _value Amount to transfer.
+ /// @return Success of transfer.
+ function transferFrom(address _from, address _to, uint _value)
+ public
+ returns (bool)
+ {
+ uint allowance = allowed[_from][msg.sender];
+ require(balances[_from] >= _value && allowance >= _value && balances[_to] + _value >= balances[_to]);
+ balances[_to] += _value;
+ balances[_from] -= _value;
+ if (allowance < MAX_UINT) {
+ allowed[_from][msg.sender] -= _value;
+ }
+ Transfer(_from, _to, _value);
+ return true;
+ }
+}
+
diff --git a/packages/contracts/contracts/tokens/WETH9.sol b/packages/contracts/contracts/tokens/WETH9.sol
new file mode 100644
index 000000000..733ca414b
--- /dev/null
+++ b/packages/contracts/contracts/tokens/WETH9.sol
@@ -0,0 +1,756 @@
+// Copyright (C) 2015, 2016, 2017 Dapphub
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+pragma solidity ^0.4.18;
+
+contract WETH9 {
+ string public name = "Wrapped Ether";
+ string public symbol = "WETH";
+ uint8 public decimals = 18;
+
+ event Approval(address indexed src, address indexed guy, uint wad);
+ event Transfer(address indexed src, address indexed dst, uint wad);
+ event Deposit(address indexed dst, uint wad);
+ event Withdrawal(address indexed src, uint wad);
+
+ mapping (address => uint) public balanceOf;
+ mapping (address => mapping (address => uint)) public allowance;
+
+ function() public payable {
+ deposit();
+ }
+ function deposit() public payable {
+ balanceOf[msg.sender] += msg.value;
+ Deposit(msg.sender, msg.value);
+ }
+ function withdraw(uint wad) public {
+ require(balanceOf[msg.sender] >= wad);
+ balanceOf[msg.sender] -= wad;
+ msg.sender.transfer(wad);
+ Withdrawal(msg.sender, wad);
+ }
+
+ function totalSupply() public view returns (uint) {
+ return this.balance;
+ }
+
+ function approve(address guy, uint wad) public returns (bool) {
+ allowance[msg.sender][guy] = wad;
+ Approval(msg.sender, guy, wad);
+ return true;
+ }
+
+ function transfer(address dst, uint wad) public returns (bool) {
+ return transferFrom(msg.sender, dst, wad);
+ }
+
+ function transferFrom(address src, address dst, uint wad)
+ public
+ returns (bool)
+ {
+ require(balanceOf[src] >= wad);
+
+ if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
+ require(allowance[src][msg.sender] >= wad);
+ allowance[src][msg.sender] -= wad;
+ }
+
+ balanceOf[src] -= wad;
+ balanceOf[dst] += wad;
+
+ Transfer(src, dst, wad);
+
+ return true;
+ }
+}
+
+
+/*
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+
+*/
diff --git a/packages/contracts/contracts/tokens/ZRXToken.sol b/packages/contracts/contracts/tokens/ZRXToken.sol
index c8b9c08ab..af1dfac99 100644
--- a/packages/contracts/contracts/tokens/ZRXToken.sol
+++ b/packages/contracts/contracts/tokens/ZRXToken.sol
@@ -16,7 +16,7 @@
*/
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
import "./UnlimitedAllowanceToken.sol";
@@ -31,3 +31,4 @@ contract ZRXToken is UnlimitedAllowanceToken {
balances[msg.sender] = totalSupply;
}
}
+
diff --git a/packages/contracts/contracts/base/Ownable.sol b/packages/contracts/contracts/utils/Ownable.sol
index b7d6ac71c..77fdaf085 100644
--- a/packages/contracts/contracts/base/Ownable.sol
+++ b/packages/contracts/contracts/utils/Ownable.sol
@@ -1,4 +1,4 @@
-pragma solidity 0.4.11;
+pragma solidity ^0.4.11;
/*
* Ownable
@@ -25,3 +25,4 @@ contract Ownable {
}
}
}
+
diff --git a/packages/contracts/contracts/utils/Ownable_v2.sol b/packages/contracts/contracts/utils/Ownable_v2.sol
new file mode 100644
index 000000000..77e1fed08
--- /dev/null
+++ b/packages/contracts/contracts/utils/Ownable_v2.sol
@@ -0,0 +1,33 @@
+pragma solidity 0.4.18;
+
+/*
+ * Ownable
+ *
+ * Base contract with an owner.
+ * Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
+ */
+
+contract Ownable_v2 {
+ address public owner;
+
+ function Ownable_v2()
+ public
+ {
+ owner = msg.sender;
+ }
+
+ modifier onlyOwner() {
+ require(msg.sender == owner);
+ _;
+ }
+
+ function transferOwnership(address newOwner)
+ public
+ onlyOwner
+ {
+ if (newOwner != address(0)) {
+ owner = newOwner;
+ }
+ }
+}
+
diff --git a/packages/contracts/contracts/utils/SafeMath.sol b/packages/contracts/contracts/utils/SafeMath.sol
new file mode 100644
index 000000000..a7891a7af
--- /dev/null
+++ b/packages/contracts/contracts/utils/SafeMath.sol
@@ -0,0 +1,74 @@
+pragma solidity ^0.4.11;
+
+contract SafeMath {
+ function safeMul(uint a, uint b)
+ internal
+ constant
+ returns (uint256)
+ {
+ uint c = a * b;
+ assert(a == 0 || c / a == b);
+ return c;
+ }
+
+ function safeDiv(uint a, uint b)
+ internal
+ constant
+ returns (uint256)
+ {
+ uint c = a / b;
+ return c;
+ }
+
+ function safeSub(uint a, uint b)
+ internal
+ constant
+ returns (uint256)
+ {
+ assert(b <= a);
+ return a - b;
+ }
+
+ function safeAdd(uint a, uint b)
+ internal
+ constant
+ returns (uint256)
+ {
+ uint c = a + b;
+ assert(c >= a);
+ return c;
+ }
+
+ function max64(uint64 a, uint64 b)
+ internal
+ constant
+ returns (uint64)
+ {
+ return a >= b ? a : b;
+ }
+
+ function min64(uint64 a, uint64 b)
+ internal
+ constant
+ returns (uint64)
+ {
+ return a < b ? a : b;
+ }
+
+ function max256(uint256 a, uint256 b)
+ internal
+ constant
+ returns (uint256)
+ {
+ return a >= b ? a : b;
+ }
+
+ function min256(uint256 a, uint256 b)
+ internal
+ constant
+ returns (uint256)
+ {
+ return a < b ? a : b;
+ }
+}
+
diff --git a/packages/contracts/contracts/utils/SafeMath_v2.sol b/packages/contracts/contracts/utils/SafeMath_v2.sol
new file mode 100644
index 000000000..6eda03999
--- /dev/null
+++ b/packages/contracts/contracts/utils/SafeMath_v2.sol
@@ -0,0 +1,74 @@
+pragma solidity 0.4.18;
+
+contract SafeMath_v2 {
+ function safeMul(uint a, uint b)
+ internal
+ pure
+ returns (uint256)
+ {
+ uint c = a * b;
+ assert(a == 0 || c / a == b);
+ return c;
+ }
+
+ function safeDiv(uint a, uint b)
+ internal
+ pure
+ returns (uint256)
+ {
+ uint c = a / b;
+ return c;
+ }
+
+ function safeSub(uint a, uint b)
+ internal
+ pure
+ returns (uint256)
+ {
+ assert(b <= a);
+ return a - b;
+ }
+
+ function safeAdd(uint a, uint b)
+ internal
+ pure
+ returns (uint256)
+ {
+ uint c = a + b;
+ assert(c >= a);
+ return c;
+ }
+
+ function max64(uint64 a, uint64 b)
+ internal
+ pure
+ returns (uint256)
+ {
+ return a >= b ? a : b;
+ }
+
+ function min64(uint64 a, uint64 b)
+ internal
+ pure
+ returns (uint256)
+ {
+ return a < b ? a : b;
+ }
+
+ function max256(uint256 a, uint256 b)
+ internal
+ pure
+ returns (uint256)
+ {
+ return a >= b ? a : b;
+ }
+
+ function min256(uint256 a, uint256 b)
+ internal
+ pure
+ returns (uint256)
+ {
+ return a < b ? a : b;
+ }
+}
+
diff --git a/packages/contracts/deploy/migrations/migrate.ts b/packages/contracts/deploy/migrations/migrate.ts
deleted file mode 100644
index c3d38875e..000000000
--- a/packages/contracts/deploy/migrations/migrate.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import {BigNumber} from 'bignumber.js';
-import * as _ from 'lodash';
-import * as Web3 from 'web3';
-
-import {Deployer} from './../src/deployer';
-import {constants} from './../src/utils/constants';
-import {Token} from './../src/utils/types';
-import {tokenInfo} from './config/token_info';
-
-export const migrator = {
- /**
- * Custom migrations should be defined in this function. This will be called with the CLI 'migrate' command.
- * @param deployer Deployer instance.
- */
- async runMigrationsAsync(deployer: Deployer): Promise<void> {
- const web3Wrapper: Web3Wrapper = deployer.web3Wrapper;
- const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync();
-
- const independentContracts: Web3.ContractInstance[] = await Promise.all([
- deployer.deployAndSaveAsync('TokenTransferProxy'),
- deployer.deployAndSaveAsync('ZRXToken'),
- deployer.deployAndSaveAsync('EtherToken'),
- deployer.deployAndSaveAsync('TokenRegistry'),
- ]);
- const [tokenTransferProxy, zrxToken, etherToken, tokenReg] = independentContracts;
-
- const exchangeArgs = [zrxToken.address, tokenTransferProxy.address];
- const owners = [accounts[0], accounts[1]];
- const confirmationsRequired = new BigNumber(2);
- const secondsRequired = new BigNumber(0);
- const multiSigArgs = [owners, confirmationsRequired, secondsRequired, tokenTransferProxy.address];
- const dependentContracts: Web3.ContractInstance[] = await Promise.all([
- deployer.deployAndSaveAsync('Exchange', exchangeArgs),
- deployer.deployAndSaveAsync('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', multiSigArgs),
- ]);
- const [exchange, multiSig] = dependentContracts;
-
- const owner = accounts[0];
- await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {from: owner});
- await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, {from: owner});
-
- const tokensToRegister: Web3.ContractInstance[] = await Promise.all(
- _.map(tokenInfo, async (token: Token): Promise<Web3.ContractInstance> => {
- const totalSupply = new BigNumber(0);
- const args = [
- token.name,
- token.symbol,
- token.decimals,
- totalSupply,
- ];
- return deployer.deployAsync('DummyToken', args);
- }),
- );
- const addTokenGasEstimate = await tokenReg.addToken.estimateGasAsync(
- tokensToRegister[0].address,
- tokenInfo[0].name,
- tokenInfo[0].symbol,
- tokenInfo[0].decimals,
- tokenInfo[0].ipfsHash,
- tokenInfo[0].swarmHash,
- {from: owner},
- );
- const addTokenPromises = [
- tokenReg.addToken.sendTransactionAsync(
- zrxToken.address,
- '0x Protocol Token',
- 'ZRX',
- 18,
- constants.NULL_BYTES,
- constants.NULL_BYTES,
- {
- from: owner,
- gas: addTokenGasEstimate,
- },
- ),
- tokenReg.addToken.sendTransactionAsync(
- etherToken.address,
- 'Ether Token',
- 'WETH',
- 18,
- constants.NULL_BYTES,
- constants.NULL_BYTES,
- {
- from: owner,
- gas: addTokenGasEstimate,
- },
- ),
- ];
- const addDummyTokenPromises = _.map(tokenInfo, async (token: Token, i: number): Promise<void> => {
- return tokenReg.addToken.sendTransactionAsync(
- tokensToRegister[i].address,
- token.name,
- token.symbol,
- token.decimals,
- token.ipfsHash,
- token.swarmHash,
- {
- from: owner,
- gas: addTokenGasEstimate,
- },
- );
- });
- await Promise.all([...addDummyTokenPromises, ...addTokenPromises]);
- },
-};
diff --git a/packages/contracts/deploy/test/fixtures/exchange_bin.ts b/packages/contracts/deploy/test/fixtures/exchange_bin.ts
deleted file mode 100644
index 0ca87760e..000000000
--- a/packages/contracts/deploy/test/fixtures/exchange_bin.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-// tslint:disable-next-line:max-line-length
-export const constructor_args = '0x000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f4980000000000000000000000008da0d80f5007ef1e431dd2127178d224e32c2ef4';
-// tslint:disable-next-line:max-line-length
-export const exchange_binary = '0x6060604052341561000f57600080fd5b604051604080612c4d833981016040528080519060200190919080519060200190919050505b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50505b612b84806100c96000396000f300606060405236156100fa576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806314df96ee146100ff578063288cdc911461014c5780632ac1262214610187578063363349be146101c2578063394c21e7146103bc5780633b30ba591461044b5780634f150787146104a0578063741bcc93146106b25780637e9abb50146107535780638163681e1461078e57806398024a8b14610812578063add1cbc51461085b578063b7b2c7d6146108b0578063baa0181d14610acd578063bc61394a14610c1f578063cfc4d0ec14610cdf578063f06bbf7514610d6d578063ffa1ad7414610d9e575b600080fd5b341561010a57600080fd5b6101326004808035906020019091908035906020019091908035906020019091905050610e2d565b604051808215151515815260200191505060405180910390f35b341561015757600080fd5b610171600480803560001916906020019091905050610e7c565b6040518082815260200191505060405180910390f35b341561019257600080fd5b6101ac600480803560001916906020019091905050610e94565b6040518082815260200191505060405180910390f35b34156101cd57600080fd5b6103a660048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561024857848483905060a002016005806020026040519081016040528092919082600560200280828437820191505050505081526020019060010190610203565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156102c457848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061027f565b5050505050919080359060200190919080351515906020019091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050610eac565b6040518082815260200191505060405180910390f35b34156103c757600080fd5b6104356004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091908035906020019091905050611013565b6040518082815260200191505060405180910390f35b341561045657600080fd5b61045e6114fb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156104ab57600080fd5b6106b060048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561052657848483905060a0020160058060200260405190810160405280929190826005602002808284378201915050505050815260200190600101906104e1565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156105a257848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061055d565b50505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050611520565b005b34156106bd57600080fd5b6107516004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c00190600680602002604051908101604052809291908260066020028082843782019150505050509190803590602001909190803560ff1690602001909190803560001916906020019091908035600019169060200190919050506115df565b005b341561075e57600080fd5b610778600480803560001916906020019091905050611605565b6040518082815260200191505060405180910390f35b341561079957600080fd5b6107f8600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080356000191690602001909190803560ff16906020019091908035600019169060200190919080356000191690602001909190505061164f565b604051808215151515815260200191505060405180910390f35b341561081d57600080fd5b6108456004808035906020019091908035906020019091908035906020019091905050611757565b6040518082815260200191505060405180910390f35b341561086657600080fd5b61086e611776565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156108bb57600080fd5b610acb60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b8282101561093657848483905060a0020160058060200260405190810160405280929190826005602002808284378201915050505050815260200190600101906108f1565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b828210156109b257848483905060c00201600680602002604051908101604052809291908260066020028082843782019150505050508152602001906001019061096d565b50505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035151590602001909190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061179c565b005b3415610ad857600080fd5b610c1d60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610b5357848483905060a002016005806020026040519081016040528092919082600560200280828437820191505050505081526020019060010190610b0e565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020016000905b82821015610bcf57848483905060c002016006806020026040519081016040528092919082600660200280828437820191505050505081526020019060010190610b8a565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061185e565b005b3415610c2a57600080fd5b610cc96004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091908035906020019091908035151590602001909190803560ff1690602001909190803560001916906020019091908035600019169060200190919050506118d3565b6040518082815260200191505060405180910390f35b3415610cea57600080fd5b610d4f6004808060a001906005806020026040519081016040528092919082600560200280828437820191505050505091908060c001906006806020026040519081016040528092919082600660200280828437820191505050505091905050612073565b60405180826000191660001916815260200191505060405180910390f35b3415610d7857600080fd5b610d8061231f565b604051808261ffff1661ffff16815260200191505060405180910390f35b3415610da957600080fd5b610db1612325565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610df25780820151818401525b602081019050610dd6565b50505050905090810190601f168015610e1f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60008060008486850991506000821415610e4a5760009250610e73565b610e69610e5a83620f424061235e565b610e64888761235e565b612392565b90506103e8811192505b50509392505050565b60026020528060005260406000206000915090505481565b60036020528060005260406000206000915090505481565b6000806000809150600090505b895181101561100257896000815181101515610ed157fe5b906020019060200201516003600581101515610ee957fe5b602002015173ffffffffffffffffffffffffffffffffffffffff168a82815181101515610f1257fe5b906020019060200201516003600581101515610f2a57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16141515610f5157600080fd5b610fe582610fe08c84815181101515610f6657fe5b906020019060200201518c85815181101515610f7e57fe5b90602001906020020151610f928d886123ae565b8c8c88815181101515610fa157fe5b906020019060200201518c89815181101515610fb957fe5b906020019060200201518c8a815181101515610fd157fe5b906020019060200201516118d3565b6123c8565b915087821415610ff457611002565b5b8080600101915050610eb9565b8192505b5050979650505050505050565b600061101d612a8c565b6000806101606040519081016040528088600060058110151561103c57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200188600160058110151561106b57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200188600260058110151561109a57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018860036005811015156110c957fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018860046005811015156110f857fe5b602002015173ffffffffffffffffffffffffffffffffffffffff16815260200187600060068110151561112757fe5b6020020151815260200187600160068110151561114057fe5b6020020151815260200187600260068110151561115957fe5b6020020151815260200187600360068110151561117257fe5b6020020151815260200187600460068110151561118b57fe5b6020020151815260200161119f8989612073565b6000191681525092503373ffffffffffffffffffffffffffffffffffffffff16836000015173ffffffffffffffffffffffffffffffffffffffff161415156111e657600080fd5b60008360a001511180156111fe575060008360c00151115b801561120a5750600085115b151561121557600080fd5b8261012001514210151561127257826101400151600019166000600381111561123a57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a3600093506114f1565b61128d8360c00151611288856101400151611605565b6123ae565b915061129985836123e7565b905060008114156112f35782610140015160001916600160038111156112bb57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a3600093506114f1565b61131d600360008561014001516000191660001916815260200190815260200160002054826123c8565b60036000856101400151600019166000191681526020019081526020016000208190555082604001518360600151604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140192505050604051809103902060001916836080015173ffffffffffffffffffffffffffffffffffffffff16846000015173ffffffffffffffffffffffffffffffffffffffff167f67d66f160bc93d925d05dae1794c90d2d6d6688b29b84ff069398a9b0458713186604001518760600151611455878a60c001518b60a00151611757565b878a6101400151604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182600019166000191681526020019550505050505060405180910390a48093505b5050509392505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008090505b86518110156115d5576115c7878281518110151561154057fe5b90602001906020020151878381518110151561155857fe5b90602001906020020151878481518110151561157057fe5b90602001906020020151878581518110151561158857fe5b9060200190602002015187868151811015156115a057fe5b9060200190602002015187878151811015156115b857fe5b906020019060200201516115df565b5b8080600101915050611526565b5b50505050505050565b836115f087878760008888886118d3565b1415156115fc57600080fd5b5b505050505050565b600061164760026000846000191660001916815260200190815260200160002054600360008560001916600019168152602001908152602001600020546123c8565b90505b919050565b600060018560405180807f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250601c0182600019166000191681526020019150506040518091039020858585604051600081526020016040526000604051602001526040518085600019166000191681526020018460ff1660ff16815260200183600019166000191681526020018260001916600019168152602001945050505050602060405160208103908084039060008661646e5a03f1151561171457600080fd5b50506020604051035173ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161490505b95945050505050565b600061176c611766858461235e565b84612392565b90505b9392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008090505b87518110156118535761184488828151811015156117bc57fe5b9060200190602002015188838151811015156117d457fe5b9060200190602002015188848151811015156117ec57fe5b9060200190602002015188888681518110151561180557fe5b90602001906020020151888781518110151561181d57fe5b90602001906020020151888881518110151561183557fe5b906020019060200201516118d3565b505b80806001019150506117a2565b5b5050505050505050565b60008090505b83518110156118cc576118bd848281518110151561187e57fe5b90602001906020020151848381518110151561189657fe5b9060200190602002015184848151811015156118ae57fe5b90602001906020020151611013565b505b8080600101915050611864565b5b50505050565b60006118dd612a8c565b600080600080610160604051908101604052808e60006005811015156118ff57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600160058110151561192e57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600260058110151561195d57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e600360058110151561198c57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018e60046005811015156119bb57fe5b602002015173ffffffffffffffffffffffffffffffffffffffff1681526020018d60006006811015156119ea57fe5b602002015181526020018d6001600681101515611a0357fe5b602002015181526020018d6002600681101515611a1c57fe5b602002015181526020018d6003600681101515611a3557fe5b602002015181526020018d6004600681101515611a4e57fe5b60200201518152602001611a628f8f612073565b600019168152509450600073ffffffffffffffffffffffffffffffffffffffff16856020015173ffffffffffffffffffffffffffffffffffffffff161480611ad957503373ffffffffffffffffffffffffffffffffffffffff16856020015173ffffffffffffffffffffffffffffffffffffffff16145b1515611ae457600080fd5b60008560a00151118015611afc575060008560c00151115b8015611b08575060008b115b1515611b1357600080fd5b611b2985600001518661014001518b8b8b61164f565b1515611b3457600080fd5b84610120015142101515611b91578461014001516000191660006003811115611b5957fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611bac8560c00151611ba7876101400151611605565b6123ae565b9350611bb88b856123e7565b95506000861415611c12578461014001516000191660016003811115611bda57fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611c25868660c001518760a00151610e2d565b15611c79578461014001516000191660026003811115611c4157fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b89158015611c8e5750611c8c8587612401565b155b15611ce15784610140015160001916600380811115611ca957fe5b60ff167f36d86c59e00bd73dc19ba3adfe068e4b64ac7e92be35546adeddf1b956a87e9060405160405180910390a360009550612063565b611cf4868660c001518760a00151611757565b9250611d20600260008761014001516000191660001916815260200190815260200160002054876123c8565b600260008761014001516000191660001916815260200190815260200160002081905550611d58856040015186600001513386612751565b1515611d6357600080fd5b611d77856060015133876000015189612751565b1515611d8257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16856080015173ffffffffffffffffffffffffffffffffffffffff16141515611e815760008560e001511115611e1f57611ddc868660c001518760e00151611757565b9150611e136000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168660000151876080015185612751565b1515611e1e57600080fd5b5b60008561010001511115611e8057611e41868660c00151876101000151611757565b9050611e746000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633876080015184612751565b1515611e7f57600080fd5b5b5b84604001518560600151604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140192505050604051809103902060001916856080015173ffffffffffffffffffffffffffffffffffffffff16866000015173ffffffffffffffffffffffffffffffffffffffff167f0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb33389604001518a60600151898d8a8a8f6101400151604051808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200186815260200185815260200184815260200183815260200182600019166000191681526020019850505050505050505060405180910390a48595505b5050505050979650505050505050565b60003083600060058110151561208557fe5b602002015184600160058110151561209957fe5b60200201518560026005811015156120ad57fe5b60200201518660036005811015156120c157fe5b60200201518760046005811015156120d557fe5b60200201518760006006811015156120e957fe5b60200201518860016006811015156120fd57fe5b602002015189600260068110151561211157fe5b60200201518a600360068110151561212557fe5b60200201518b600460068110151561213957fe5b60200201518c600560068110151561214d57fe5b6020020151604051808d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018781526020018681526020018581526020018481526020018381526020018281526020019c50505050505050505050505050604051809103902090505b92915050565b61138781565b6040805190810160405280600581526020017f312e302e3000000000000000000000000000000000000000000000000000000081525081565b6000808284029050600084148061237f575082848281151561237c57fe5b04145b151561238757fe5b8091505b5092915050565b60008082848115156123a057fe5b0490508091505b5092915050565b60008282111515156123bc57fe5b81830390505b92915050565b60008082840190508381101515156123dc57fe5b8091505b5092915050565b60008183106123f657816123f8565b825b90505b92915050565b60008060008060008060008060003397506124258a8c60c001518d60a00151611757565b9650600073ffffffffffffffffffffffffffffffffffffffff168b6080015173ffffffffffffffffffffffffffffffffffffffff161415156126d2576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168b6040015173ffffffffffffffffffffffffffffffffffffffff161495506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168b6060015173ffffffffffffffffffffffffffffffffffffffff161494506125208a8c60c001518d60e00151611757565b93506125368a8c60c001518d6101000151611757565b925085612543578361254e565b61254d87856123c8565b5b91508461255b5782612566565b6125658a846123c8565b5b9050816125986000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168d600001516128ae565b10806125d15750816125cf6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168d60000151612972565b105b806126055750806126036000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a6128ae565b105b806126395750806126376000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a612972565b105b156126475760009850612743565b851580156126805750866126638c604001518d600001516128ae565b108061267f57508661267d8c604001518d60000151612972565b105b5b1561268e5760009850612743565b841580156126bf5750896126a68c606001518a6128ae565b10806126be5750896126bc8c606001518a612972565b105b5b156126cd5760009850612743565b61273e565b866126e58c604001518d600001516128ae565b10806127015750866126ff8c604001518d60000151612972565b105b806127185750896127168c606001518a6128ae565b105b8061272f57508961272d8c606001518a612972565b105b1561273d5760009850612743565b5b600198505b505050505050505092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166315dacbea868686866000604051602001526040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050602060405180830381600087803b151561288857600080fd5b6102c65a03f1151561289957600080fd5b5050506040518051905090505b949350505050565b60008273ffffffffffffffffffffffffffffffffffffffff166370a0823161138761ffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600088803b151561295157600080fd5b87f1151561295e57600080fd5b505050506040518051905090505b92915050565b60008273ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e61138761ffff1684600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600088803b1515612a6b57600080fd5b87f11515612a7857600080fd5b505050506040518051905090505b92915050565b61016060405190810160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016000801916815250905600a165627a7a72305820df5cabdc3a116e993e10bfb14823d18d9b798038d4c463a1703f9a584c456b7e0029';
diff --git a/packages/contracts/globals.d.ts b/packages/contracts/globals.d.ts
index df53e9372..2e5827324 100644
--- a/packages/contracts/globals.d.ts
+++ b/packages/contracts/globals.d.ts
@@ -1,8 +1,5 @@
-declare module 'bn.js';
-declare module 'ethereumjs-abi';
declare module 'chai-bignumber';
declare module 'dirty-chai';
-declare module 'yargs';
// HACK: In order to merge the bignumber declaration added by chai-bignumber to the chai Assertion
// interface we must use `namespace` as the Chai definitelyTyped definition does. Since we otherwise
@@ -31,6 +28,11 @@ declare module 'web3-eth-abi' {
export function encodeParameters(typesArray: string[], parameters: any[]): string;
}
+declare module 'ethereumjs-abi' {
+ const soliditySHA3: (argTypes: string[], args: any[]) => Buffer;
+ const methodID: (name: string, types: string[]) => Buffer;
+}
+
// Truffle injects the following into the global scope
declare var artifacts: any;
declare var contract: any;
diff --git a/packages/contracts/globalsAugment.d.ts b/packages/contracts/globalsAugment.d.ts
index 21f3742ae..9b16ce2ad 100644
--- a/packages/contracts/globalsAugment.d.ts
+++ b/packages/contracts/globalsAugment.d.ts
@@ -1,4 +1,4 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
// HACK: This module overrides the Chai namespace so that we can use BigNumber types inside.
// Source: https://github.com/Microsoft/TypeScript/issues/7352#issuecomment-191547232
@@ -16,4 +16,4 @@ declare global {
}
}
/* tslint:enable */
-} \ No newline at end of file
+}
diff --git a/packages/contracts/migrations/1_initial_migration.ts b/packages/contracts/migrations/1_initial_migration.ts
index b34bbc2a1..8661ee218 100644
--- a/packages/contracts/migrations/1_initial_migration.ts
+++ b/packages/contracts/migrations/1_initial_migration.ts
@@ -1,5 +1,5 @@
-import {Artifacts} from '../util/artifacts';
-const {Migrations} = new Artifacts(artifacts);
+import { Artifacts } from '../util/artifacts';
+const { Migrations } = new Artifacts(artifacts);
module.exports = (deployer: any) => {
deployer.deploy(Migrations);
diff --git a/packages/contracts/migrations/2_deploy_independent_contracts.ts b/packages/contracts/migrations/2_deploy_independent_contracts.ts
index 878860eb6..ac1752347 100644
--- a/packages/contracts/migrations/2_deploy_independent_contracts.ts
+++ b/packages/contracts/migrations/2_deploy_independent_contracts.ts
@@ -1,11 +1,6 @@
-import {Artifacts} from '../util/artifacts';
-import {ContractInstance, MultiSigConfigByNetwork} from '../util/types';
-const {
- MultiSigWalletWithTimeLock,
- TokenTransferProxy,
- EtherToken,
- TokenRegistry,
-} = new Artifacts(artifacts);
+import { Artifacts } from '../util/artifacts';
+import { MultiSigConfigByNetwork } from '../util/types';
+const { MultiSigWalletWithTimeLock, TokenTransferProxy, EtherToken, TokenRegistry } = new Artifacts(artifacts);
let multiSigConfigByNetwork: MultiSigConfigByNetwork;
try {
@@ -25,14 +20,16 @@ module.exports = (deployer: any, network: string, accounts: string[]) => {
};
const config = multiSigConfigByNetwork[network] || defaultConfig;
if (network !== 'live') {
- deployer.deploy(MultiSigWalletWithTimeLock, config.owners,
- config.confirmationsRequired, config.secondsRequired)
+ deployer
+ .deploy(MultiSigWalletWithTimeLock, config.owners, config.confirmationsRequired, config.secondsRequired)
.then(() => {
- return deployer.deploy(TokenTransferProxy);
- }).then(() => {
- return deployer.deploy(TokenRegistry);
- }).then(() => {
- return deployer.deploy(EtherToken);
+ return deployer.deploy(TokenTransferProxy);
+ })
+ .then(() => {
+ return deployer.deploy(TokenRegistry);
+ })
+ .then(() => {
+ return deployer.deploy(EtherToken);
});
} else {
deployer.deploy([
diff --git a/packages/contracts/migrations/3_register_tokens.ts b/packages/contracts/migrations/3_register_tokens.ts
index c72ac1510..d5cf63f94 100644
--- a/packages/contracts/migrations/3_register_tokens.ts
+++ b/packages/contracts/migrations/3_register_tokens.ts
@@ -1,86 +1,95 @@
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 { Artifacts } from '../util/artifacts';
+import { constants } from '../util/constants';
+import { ContractInstance, Token } from '../util/types';
-import {tokenInfo} from './config/token_info';
-const {
- DummyToken,
- EtherToken,
- ZRXToken,
- TokenRegistry,
-} = new Artifacts(artifacts);
+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: '',
+ 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(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,
+ 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,
);
- }).concat(tokenRegistry.addToken(
- zrx.address,
- zrx.name,
- zrx.symbol,
- zrx.decimals,
- zrx.ipfsHash,
- zrx.swarmHash,
- )), _.noop);
- }
- });
+ }
+ });
};
diff --git a/packages/contracts/migrations/4_configure_proxy.ts b/packages/contracts/migrations/4_configure_proxy.ts
index f4c4a725b..ff3b844d6 100644
--- a/packages/contracts/migrations/4_configure_proxy.ts
+++ b/packages/contracts/migrations/4_configure_proxy.ts
@@ -1,27 +1,22 @@
-import {Artifacts} from '../util/artifacts';
-import {ContractInstance} from '../util/types';
-const {
- TokenTransferProxy,
- Exchange,
- TokenRegistry,
-} = new Artifacts(artifacts);
+import { Artifacts } from '../util/artifacts';
+import { ContractInstance } from '../util/types';
+const { TokenTransferProxy, Exchange, TokenRegistry } = new Artifacts(artifacts);
let tokenTransferProxy: ContractInstance;
module.exports = (deployer: any) => {
- deployer.then(async () => {
- return Promise.all([
- TokenTransferProxy.deployed(),
- TokenRegistry.deployed(),
- ]);
- })
- .then((instances: ContractInstance[]) => {
- let tokenRegistry: ContractInstance;
- [tokenTransferProxy, tokenRegistry] = instances;
- return tokenRegistry.getTokenAddressBySymbol('ZRX');
- })
- .then((ptAddress: string) => {
- return deployer.deploy(Exchange, ptAddress, tokenTransferProxy.address);
- }).then(() => {
- return tokenTransferProxy.addAuthorizedAddress(Exchange.address);
- });
+ deployer
+ .then(async () => {
+ return Promise.all([TokenTransferProxy.deployed(), TokenRegistry.deployed()]);
+ })
+ .then((instances: ContractInstance[]) => {
+ let tokenRegistry: ContractInstance;
+ [tokenTransferProxy, tokenRegistry] = instances;
+ return tokenRegistry.getTokenAddressBySymbol('ZRX');
+ })
+ .then((ptAddress: string) => {
+ return deployer.deploy(Exchange, ptAddress, tokenTransferProxy.address);
+ })
+ .then(() => {
+ return tokenTransferProxy.addAuthorizedAddress(Exchange.address);
+ });
};
diff --git a/packages/contracts/migrations/5_transfer_ownership.ts b/packages/contracts/migrations/5_transfer_ownership.ts
index 17de9bc7b..a27801de3 100644
--- a/packages/contracts/migrations/5_transfer_ownership.ts
+++ b/packages/contracts/migrations/5_transfer_ownership.ts
@@ -1,25 +1,20 @@
-import {Artifacts} from '../util/artifacts';
-import {ContractInstance} from '../util/types';
-const {
- TokenTransferProxy,
- MultiSigWalletWithTimeLock,
- TokenRegistry,
-} = new Artifacts(artifacts);
+import { Artifacts } from '../util/artifacts';
+import { ContractInstance } from '../util/types';
+const { TokenTransferProxy, MultiSigWalletWithTimeLock, TokenRegistry } = new Artifacts(artifacts);
let tokenRegistry: ContractInstance;
module.exports = (deployer: any, network: string) => {
if (network !== 'development') {
deployer.then(async () => {
- return Promise.all([
- TokenTransferProxy.deployed(),
- TokenRegistry.deployed(),
- ]).then((instances: ContractInstance[]) => {
- let tokenTransferProxy: ContractInstance;
- [tokenTransferProxy, tokenRegistry] = instances;
- return tokenTransferProxy.transferOwnership(MultiSigWalletWithTimeLock.address);
- }).then(() => {
- return tokenRegistry.transferOwnership(MultiSigWalletWithTimeLock.address);
- });
+ return Promise.all([TokenTransferProxy.deployed(), TokenRegistry.deployed()])
+ .then((instances: ContractInstance[]) => {
+ let tokenTransferProxy: ContractInstance;
+ [tokenTransferProxy, tokenRegistry] = instances;
+ return tokenTransferProxy.transferOwnership(MultiSigWalletWithTimeLock.address);
+ })
+ .then(() => {
+ return tokenRegistry.transferOwnership(MultiSigWalletWithTimeLock.address);
+ });
});
}
};
diff --git a/packages/contracts/migrations/config/multisig_sample.ts b/packages/contracts/migrations/config/multisig_sample.ts
index eca54ba28..97cdc2eae 100644
--- a/packages/contracts/migrations/config/multisig_sample.ts
+++ b/packages/contracts/migrations/config/multisig_sample.ts
@@ -1,4 +1,4 @@
-import {MultiSigConfigByNetwork} from '../../util/types';
+import { MultiSigConfigByNetwork } from '../../util/types';
// Make a copy of this file named `multisig.js` and input custom params as needed
export const multiSig: MultiSigConfigByNetwork = {
diff --git a/packages/contracts/migrations/config/token_info.ts b/packages/contracts/migrations/config/token_info.ts
index 766a28664..6ae67175e 100644
--- a/packages/contracts/migrations/config/token_info.ts
+++ b/packages/contracts/migrations/config/token_info.ts
@@ -1,5 +1,5 @@
-import {constants} from '../../util/constants';
-import {TokenInfoByNetwork} from '../../util/types';
+import { constants } from '../../util/constants';
+import { TokenInfoByNetwork } from '../../util/types';
export const tokenInfo: TokenInfoByNetwork = {
development: [
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 92a9da53e..5a76bbf7f 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -1,71 +1,72 @@
{
- "name": "contracts",
- "version": "1.0.0",
- "description": "Smart contract components of 0x protocol",
- "main": "index.js",
- "directories": {
- "test": "test"
- },
- "scripts": {
- "build": "rm -rf ./lib; copyfiles ./build/**/* ./deploy/solc/solc_bin/* ./deploy/test/fixtures/contracts/**/* ./deploy/test/fixtures/contracts/* ./lib; tsc;",
- "test": "npm run build; truffle test",
- "compile": "npm run build; node lib/deploy/cli.js compile",
- "clean": "rm -rf ./lib",
- "migrate:truffle": "npm run build; truffle migrate",
- "migrate": "npm run build; node lib/deploy/cli.js migrate",
- "lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
- "test:deployer": "npm run build; mocha lib/deploy/test/*_test.js"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/0xProject/0x.js.git"
- },
- "author": "Amir Bandeali",
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/0x.js/issues"
- },
- "homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
- "devDependencies": {
- "@0xproject/tslint-config": "^0.2.0",
- "@0xproject/types": "^0.0.1",
- "@types/bluebird": "^3.5.3",
- "@types/isomorphic-fetch": "^0.0.34",
- "@types/lodash": "^4.14.86",
- "@types/node": "^8.0.53",
- "@types/request-promise-native": "^1.0.2",
- "@types/yargs": "^8.0.2",
- "chai": "^4.0.1",
- "chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.3",
- "chai-bignumber": "^2.0.1",
- "chai-typescript-typings": "^0.0.1",
- "copyfiles": "^1.2.0",
- "dirty-chai": "^2.0.1",
- "mocha": "^4.0.1",
- "solc": "^0.4.18",
- "truffle": "3.4.3",
- "tslint": "5.8.0",
- "types-bn": "^0.0.1",
- "types-ethereumjs-util": "0xProject/types-ethereumjs-util",
- "typescript": "~2.6.1",
- "web3-typescript-typings": "^0.7.2",
- "yargs": "^10.0.3"
- },
- "dependencies": {
- "0x.js": "^0.22.6",
- "@0xproject/web3-wrapper": "^0.0.1",
- "@0xproject/json-schemas": "^0.6.9",
- "@0xproject/utils": "^0.0.1",
- "bignumber.js": "~4.1.0",
- "bluebird": "^3.5.0",
- "bn.js": "^4.11.8",
- "ethereumjs-abi": "^0.6.4",
- "ethereumjs-util": "^5.1.1",
- "isomorphic-fetch": "^2.2.1",
- "lodash": "^4.17.4",
- "request": "^2.81.0",
- "web3": "^0.20.0",
- "web3-eth-abi": "^1.0.0-beta.24"
- }
+ "private": true,
+ "name": "contracts",
+ "version": "2.1.5",
+ "description": "Smart contract components of 0x protocol",
+ "main": "index.js",
+ "directories": {
+ "test": "test"
+ },
+ "scripts": {
+ "build": "rm -rf ./lib; copyfiles ./build/**/* ./deploy/solc/solc_bin/* ./deploy/test/fixtures/contracts/**/* ./deploy/test/fixtures/contracts/* ./lib; tsc;",
+ "test": "npm run build; truffle test",
+ "compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
+ "compile": "node ../deployer/lib/src/cli.js compile",
+ "clean": "rm -rf ./lib",
+ "migrate": "node ../deployer/lib/src/cli.js migrate",
+ "lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
+ "test:circleci": "yarn test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/0xProject/0x.js.git"
+ },
+ "author": "Amir Bandeali",
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/0x.js/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
+ "devDependencies": {
+ "@0xproject/dev-utils": "^0.0.6",
+ "@0xproject/tslint-config": "^0.4.3",
+ "@0xproject/types": "^0.1.5",
+ "@types/bluebird": "^3.5.3",
+ "@types/lodash": "^4.14.86",
+ "@types/node": "^8.0.53",
+ "@types/request-promise-native": "^1.0.2",
+ "@types/yargs": "^10.0.0",
+ "chai": "^4.0.1",
+ "chai-as-promised": "^7.1.0",
+ "chai-as-promised-typescript-typings": "^0.0.5",
+ "chai-bignumber": "^2.0.1",
+ "chai-typescript-typings": "^0.0.2",
+ "copyfiles": "^1.2.0",
+ "dirty-chai": "^2.0.1",
+ "mocha": "^4.0.1",
+ "solc": "^0.4.18",
+ "truffle": "^4.0.1",
+ "tslint": "5.8.0",
+ "types-bn": "^0.0.1",
+ "types-ethereumjs-util": "0xProject/types-ethereumjs-util",
+ "typescript": "~2.6.1",
+ "web3-typescript-typings": "^0.9.5",
+ "yargs": "^10.0.3"
+ },
+ "dependencies": {
+ "0x.js": "^0.30.1",
+ "@0xproject/deployer": "^0.0.2",
+ "@0xproject/json-schemas": "^0.7.4",
+ "@0xproject/utils": "^0.2.1",
+ "@0xproject/web3-wrapper": "^0.1.6",
+ "bluebird": "^3.5.0",
+ "bn.js": "^4.11.8",
+ "ethereumjs-abi": "^0.6.4",
+ "ethereumjs-util": "^5.1.1",
+ "isomorphic-fetch": "^2.2.1",
+ "lodash": "^4.17.4",
+ "request": "^2.81.0",
+ "web3": "^0.20.0",
+ "web3-eth-abi": "^1.0.0-beta.24"
+ }
}
diff --git a/packages/contracts/test/ts/ether_token.ts b/packages/contracts/test/ts/ether_token.ts
index dbb4d2ee6..f807cdaa3 100644
--- a/packages/contracts/test/ts/ether_token.ts
+++ b/packages/contracts/test/ts/ether_token.ts
@@ -1,14 +1,14 @@
-import {ZeroEx, ZeroExError} from '0x.js';
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx, ZeroExError } from '0x.js';
+import { BigNumber, promisify } from '@0xproject/utils';
import * as chai from 'chai';
import Web3 = require('web3');
-import {Artifacts} from '../../util/artifacts';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
-const {EtherToken} = new Artifacts(artifacts);
+const { EtherToken } = new Artifacts(artifacts);
chaiSetup.configure();
const expect = chai.expect;
@@ -22,11 +22,12 @@ contract('EtherToken', (accounts: string[]) => {
const gasPrice = ZeroEx.toBaseUnitAmount(new BigNumber(20), 9);
let zeroEx: ZeroEx;
let etherTokenAddress: string;
+
before(async () => {
etherTokenAddress = EtherToken.address;
zeroEx = new ZeroEx(web3.currentProvider, {
- gasPrice,
- etherTokenContractAddress: etherTokenAddress,
+ gasPrice,
+ networkId: constants.TESTRPC_NETWORK_ID,
});
});
@@ -42,8 +43,9 @@ contract('EtherToken', (accounts: string[]) => {
const initEthBalance = await getEthBalanceAsync(account);
const ethToDeposit = initEthBalance.plus(1);
- return expect(zeroEx.etherToken.depositAsync(ethToDeposit, account))
- .to.be.rejectedWith(ZeroExError.InsufficientEthBalanceForDeposit);
+ return expect(zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account)).to.be.rejectedWith(
+ ZeroExError.InsufficientEthBalanceForDeposit,
+ );
});
it('should convert deposited Ether to wrapped Ether tokens', async () => {
@@ -52,7 +54,7 @@ contract('EtherToken', (accounts: string[]) => {
const ethToDeposit = new BigNumber(web3.toWei(1, 'ether'));
- const txHash = await zeroEx.etherToken.depositAsync(ethToDeposit, account);
+ const txHash = await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
@@ -69,8 +71,9 @@ contract('EtherToken', (accounts: string[]) => {
const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
const ethTokensToWithdraw = initEthTokenBalance.plus(1);
- return expect(zeroEx.etherToken.withdrawAsync(ethTokensToWithdraw, account))
- .to.be.rejectedWith(ZeroExError.InsufficientWEthBalanceForWithdrawal);
+ return expect(
+ zeroEx.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account),
+ ).to.be.rejectedWith(ZeroExError.InsufficientWEthBalanceForWithdrawal);
});
it('should convert ether tokens to ether with sufficient balance', async () => {
@@ -78,15 +81,18 @@ contract('EtherToken', (accounts: string[]) => {
const initEthBalance = await getEthBalanceAsync(account);
const ethTokensToWithdraw = initEthTokenBalance;
expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0);
- const txHash = await zeroEx.etherToken.withdrawAsync(ethTokensToWithdraw, account);
+ const txHash = await zeroEx.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account, {
+ gasLimit: constants.MAX_ETHERTOKEN_WITHDRAW_GAS,
+ });
const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await getEthBalanceAsync(account);
const finalEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
- expect(finalEthBalance).to.be.bignumber
- .equal(initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)));
+ expect(finalEthBalance).to.be.bignumber.equal(
+ initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)),
+ );
expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.minus(ethTokensToWithdraw));
});
});
diff --git a/packages/contracts/test/ts/exchange/core.ts b/packages/contracts/test/ts/exchange/core.ts
index daf46ca37..770ef0c43 100644
--- a/packages/contracts/test/ts/exchange/core.ts
+++ b/packages/contracts/test/ts/exchange/core.ts
@@ -1,28 +1,22 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as Web3 from 'web3';
-import {Artifacts} from '../../../util/artifacts';
-import {Balances} from '../../../util/balances';
-import {constants} from '../../../util/constants';
-import {crypto} from '../../../util/crypto';
-import {ExchangeWrapper} from '../../../util/exchange_wrapper';
-import {Order} from '../../../util/order';
-import {OrderFactory} from '../../../util/order_factory';
-import {BalancesByOwner, ContractInstance, ExchangeContractErrs} from '../../../util/types';
-import {chaiSetup} from '../utils/chai_setup';
+import { Artifacts } from '../../../util/artifacts';
+import { Balances } from '../../../util/balances';
+import { constants } from '../../../util/constants';
+import { crypto } from '../../../util/crypto';
+import { ExchangeWrapper } from '../../../util/exchange_wrapper';
+import { Order } from '../../../util/order';
+import { OrderFactory } from '../../../util/order_factory';
+import { BalancesByOwner, ContractInstance, ExchangeContractErrs } from '../../../util/types';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {
- Exchange,
- TokenTransferProxy,
- DummyToken,
- TokenRegistry,
- MaliciousToken,
-} = new Artifacts(artifacts);
+const { Exchange, TokenTransferProxy, DummyToken, TokenRegistry, MaliciousToken } = new Artifacts(artifacts);
// In order to benefit from type-safety, we re-assign the global web3 instance injected by Truffle
// with type `any` to a variable of type `Web3`.
@@ -52,13 +46,11 @@ contract('Exchange', (accounts: string[]) => {
let zeroEx: ZeroEx;
before(async () => {
- [tokenRegistry, exchange] = await Promise.all([
- TokenRegistry.deployed(),
- Exchange.deployed(),
- ]);
+ [tokenRegistry, exchange] = await Promise.all([TokenRegistry.deployed(), Exchange.deployed()]);
exWrapper = new ExchangeWrapper(exchange);
zeroEx = new ZeroEx(web3.currentProvider, {
exchangeContractAddress: exchange.address,
+ networkId: constants.TESTRPC_NETWORK_ID,
});
const [repAddress, dgdAddress, zrxAddress] = await Promise.all([
@@ -87,18 +79,30 @@ contract('Exchange', (accounts: string[]) => {
]);
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
await Promise.all([
- rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker}),
- rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker}),
- rep.setBalance(maker, INITIAL_BALANCE, {from: tokenOwner}),
- rep.setBalance(taker, INITIAL_BALANCE, {from: tokenOwner}),
- dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker}),
- dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker}),
- dgd.setBalance(maker, INITIAL_BALANCE, {from: tokenOwner}),
- dgd.setBalance(taker, INITIAL_BALANCE, {from: tokenOwner}),
- zrx.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker}),
- zrx.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker}),
- zrx.setBalance(maker, INITIAL_BALANCE, {from: tokenOwner}),
- zrx.setBalance(taker, INITIAL_BALANCE, {from: tokenOwner}),
+ rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ }),
+ rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ }),
+ rep.setBalance(maker, INITIAL_BALANCE, { from: tokenOwner }),
+ rep.setBalance(taker, INITIAL_BALANCE, { from: tokenOwner }),
+ dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ }),
+ dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ }),
+ dgd.setBalance(maker, INITIAL_BALANCE, { from: tokenOwner }),
+ dgd.setBalance(taker, INITIAL_BALANCE, { from: tokenOwner }),
+ zrx.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ }),
+ zrx.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ }),
+ zrx.setBalance(maker, INITIAL_BALANCE, { from: tokenOwner }),
+ zrx.setBalance(taker, INITIAL_BALANCE, { from: tokenOwner }),
]);
});
@@ -132,22 +136,29 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: new BigNumber(3),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount1 = new BigNumber(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: fillTakerTokenAmount1});
+ await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: fillTakerTokenAmount1,
+ });
- const filledTakerTokenAmountAfter1 =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter1).to.be.bignumber.equal(fillTakerTokenAmount1);
const fillTakerTokenAmount2 = new BigNumber(1);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: fillTakerTokenAmount2});
+ await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: fillTakerTokenAmount2,
+ });
- const filledTakerTokenAmountAfter2 =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter2).to.be.bignumber.equal(filledTakerTokenAmountAfter1);
});
@@ -157,42 +168,51 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should transfer the correct amounts when makerTokenAmount > takerTokenAmount', async () => {
@@ -201,42 +221,51 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should transfer the correct amounts when makerTokenAmount < takerTokenAmount', async () => {
@@ -245,42 +274,51 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should transfer the correct amounts when taker is specified and order is claimed by taker', async () => {
@@ -290,78 +328,95 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const filledTakerTokenAmountBefore =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter =
- await zeroEx.exchange.getFilledTakerAmountAsync(order.params.orderHashHex);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ order.params.orderHashHex,
+ );
const expectedFillAmountTAfter = fillTakerTokenAmount.add(filledTakerTokenAmountBefore);
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(expectedFillAmountTAfter);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should fill remaining value if fillTakerTokenAmount > remaining takerTokenAmount', async () => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
- const res = await exWrapper.fillOrderAsync(order, taker,
- {fillTakerTokenAmount: order.params.takerTokenAmount});
+ const res = await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount,
+ });
- expect(res.logs[0].args.filledTakerTokenAmount)
- .to.be.bignumber.equal(order.params.takerTokenAmount.minus(fillTakerTokenAmount));
+ expect(res.logs[0].args.filledTakerTokenAmount).to.be.bignumber.equal(
+ order.params.takerTokenAmount.minus(fillTakerTokenAmount),
+ );
const newBalances = await dmyBalances.getAsync();
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(order.params.makerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(order.params.takerTokenAmount));
- expect(newBalances[maker][zrx.address])
- .to.be.bignumber.equal(balances[maker][zrx.address].minus(order.params.makerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(order.params.takerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(order.params.makerTokenAmount));
- expect(newBalances[taker][zrx.address])
- .to.be.bignumber.equal(balances[taker][zrx.address].minus(order.params.takerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(order.params.makerFee.add(order.params.takerFee)),
- );
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(order.params.makerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(order.params.takerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(order.params.makerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(order.params.takerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(order.params.makerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(order.params.takerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(order.params.makerFee.add(order.params.takerFee)),
+ );
});
it('should log 1 event with the correct arguments when order has a feeRecipient', async () => {
const divisor = 2;
- const res = await exWrapper.fillOrderAsync(order, taker,
- {fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor)});
+ const res = await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
+ });
expect(res.logs).to.have.length(1);
const logArgs = res.logs[0].args;
@@ -390,8 +445,9 @@ contract('Exchange', (accounts: string[]) => {
feeRecipient: ZeroEx.NULL_ADDRESS,
});
const divisor = 2;
- const res = await exWrapper.fillOrderAsync(order, taker,
- {fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor)});
+ const res = await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
+ });
expect(res.logs).to.have.length(1);
const logArgs = res.logs[0].args;
@@ -422,7 +478,7 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if signature is invalid', async () => {
@@ -432,7 +488,7 @@ contract('Exchange', (accounts: string[]) => {
order.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if makerTokenAmount is 0', async () => {
@@ -440,7 +496,7 @@ contract('Exchange', (accounts: string[]) => {
makerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if takerTokenAmount is 0', async () => {
@@ -448,19 +504,21 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if fillTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync();
- return expect(exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: new BigNumber(0)}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: new BigNumber(0),
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if maker balances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
order = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
@@ -471,19 +529,20 @@ contract('Exchange', (accounts: string[]) => {
});
it('should throw if maker balances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = true',
- async () => {
+ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
order = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
- return expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: true,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if taker balances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
order = await orderFactory.newSignedOrderAsync({
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
@@ -494,59 +553,70 @@ contract('Exchange', (accounts: string[]) => {
});
it('should throw if taker balances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = true',
- async () => {
+ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
order = await orderFactory.newSignedOrderAsync({
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
- return expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: true,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if maker allowances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
- await rep.approve(TokenTransferProxy.address, 0, {from: maker});
+ shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
+ await rep.approve(TokenTransferProxy.address, 0, { from: maker });
await exWrapper.fillOrderAsync(order, taker);
- await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker});
+ await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw if maker allowances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = true',
- async () => {
- await rep.approve(TokenTransferProxy.address, 0, {from: maker});
- expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
- await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker});
+ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
+ await rep.approve(TokenTransferProxy.address, 0, { from: maker });
+ expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: true,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
+ await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: maker,
+ });
});
it('should not change balances if taker allowances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
- await dgd.approve(TokenTransferProxy.address, 0, {from: taker});
+ shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
+ await dgd.approve(TokenTransferProxy.address, 0, { from: taker });
await exWrapper.fillOrderAsync(order, taker);
- await dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker});
+ await dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw if taker allowances are too low to fill order and \
- shouldThrowOnInsufficientBalanceOrAllowance = true',
- async () => {
- await dgd.approve(TokenTransferProxy.address, 0, {from: taker});
- expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
- await dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker});
+ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
+ await dgd.approve(TokenTransferProxy.address, 0, { from: taker });
+ expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: true,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
+ await dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {
+ from: taker,
+ });
});
it('should not change balances if makerToken is ZRX, makerTokenAmount + makerFee > maker balance, \
- and shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const makerZRXBalance = new BigNumber(balances[maker][zrx.address]);
order = await orderFactory.newSignedOrderAsync({
makerToken: zrx.address,
@@ -559,8 +629,7 @@ contract('Exchange', (accounts: string[]) => {
});
it('should not change balances if makerToken is ZRX, makerTokenAmount + makerFee > maker allowance, \
- and shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const makerZRXAllowance = await zrx.allowance(maker, TokenTransferProxy.address);
order = await orderFactory.newSignedOrderAsync({
makerToken: zrx.address,
@@ -573,8 +642,7 @@ contract('Exchange', (accounts: string[]) => {
});
it('should not change balances if takerToken is ZRX, takerTokenAmount + takerFee > taker balance, \
- and shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const takerZRXBalance = new BigNumber(balances[taker][zrx.address]);
order = await orderFactory.newSignedOrderAsync({
takerToken: zrx.address,
@@ -587,8 +655,7 @@ contract('Exchange', (accounts: string[]) => {
});
it('should not change balances if takerToken is ZRX, takerTokenAmount + takerFee > taker allowance, \
- and shouldThrowOnInsufficientBalanceOrAllowance = false',
- async () => {
+ and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const takerZRXAllowance = await zrx.allowance(taker, TokenTransferProxy.address);
order = await orderFactory.newSignedOrderAsync({
takerToken: zrx.address,
@@ -603,14 +670,17 @@ contract('Exchange', (accounts: string[]) => {
it('should throw if getBalance or getAllowance attempts to change state and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const maliciousToken = await MaliciousToken.new();
- await maliciousToken.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker});
+ await maliciousToken.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, { from: taker });
order = await orderFactory.newSignedOrderAsync({
takerToken: maliciousToken.address,
});
- return expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: false}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ exWrapper.fillOrderAsync(order, taker, {
+ shouldThrowOnInsufficientBalanceOrAllowance: false,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if an order is expired', async () => {
@@ -651,7 +721,7 @@ contract('Exchange', (accounts: string[]) => {
});
it('should throw if not sent by maker', async () => {
- return expect(exWrapper.cancelOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.cancelOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if makerTokenAmount is 0', async () => {
@@ -659,7 +729,7 @@ contract('Exchange', (accounts: string[]) => {
makerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if takerTokenAmount is 0', async () => {
@@ -667,19 +737,24 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if cancelTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync();
- return expect(exWrapper.cancelOrderAsync(order, maker, {cancelTakerTokenAmount: new BigNumber(0)}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ exWrapper.cancelOrderAsync(order, maker, {
+ cancelTakerTokenAmount: new BigNumber(0),
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should be able to cancel a full order', async () => {
await exWrapper.cancelOrderAsync(order, maker);
- await exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: order.params.takerTokenAmount.div(2)});
+ await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
@@ -687,43 +762,55 @@ contract('Exchange', (accounts: string[]) => {
it('should be able to cancel part of an order', async () => {
const cancelTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.cancelOrderAsync(order, maker, {cancelTakerTokenAmount});
+ await exWrapper.cancelOrderAsync(order, maker, {
+ cancelTakerTokenAmount,
+ });
- const res = await exWrapper.fillOrderAsync(order, taker,
- {fillTakerTokenAmount: order.params.takerTokenAmount});
- expect(res.logs[0].args.filledTakerTokenAmount)
- .to.be.bignumber.equal(order.params.takerTokenAmount.minus(cancelTakerTokenAmount));
+ const res = await exWrapper.fillOrderAsync(order, taker, {
+ fillTakerTokenAmount: order.params.takerTokenAmount,
+ });
+ expect(res.logs[0].args.filledTakerTokenAmount).to.be.bignumber.equal(
+ order.params.takerTokenAmount.minus(cancelTakerTokenAmount),
+ );
const newBalances = await dmyBalances.getAsync();
const cancelMakerTokenAmount = cancelTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
- .times(cancelMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(cancelMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
- .times(cancelMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(cancelMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(cancelTakerTokenAmount));
- expect(newBalances[maker][zrx.address])
- .to.be.bignumber.equal(balances[maker][zrx.address].minus(paidMakerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(cancelTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(cancelMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(paidTakerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)));
+ .times(cancelMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(cancelMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(cancelTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(paidMakerFee),
+ );
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(cancelTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(cancelMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(paidTakerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ );
});
it('should log 1 event with correct arguments', async () => {
const divisor = 2;
- const res = await exWrapper.cancelOrderAsync(order, maker,
- {cancelTakerTokenAmount: order.params.takerTokenAmount.div(divisor)});
+ const res = await exWrapper.cancelOrderAsync(order, maker, {
+ cancelTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
+ });
expect(res.logs).to.have.length(1);
const logArgs = res.logs[0].args;
@@ -747,7 +834,6 @@ contract('Exchange', (accounts: string[]) => {
const res = await exWrapper.cancelOrderAsync(order, maker);
expect(res.logs).to.have.length(1);
- const errId = res.logs[0].args.errorId.toNumber();
const errCode = res.logs[0].args.errorId.toNumber();
expect(errCode).to.be.equal(ExchangeContractErrs.ERROR_ORDER_FULLY_FILLED_OR_CANCELLED);
});
diff --git a/packages/contracts/test/ts/exchange/helpers.ts b/packages/contracts/test/ts/exchange/helpers.ts
index a39f4d9e2..95f68e419 100644
--- a/packages/contracts/test/ts/exchange/helpers.ts
+++ b/packages/contracts/test/ts/exchange/helpers.ts
@@ -1,21 +1,18 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
-import {Artifacts} from '../../../util/artifacts';
-import {ExchangeWrapper} from '../../../util/exchange_wrapper';
-import {Order} from '../../../util/order';
-import {OrderFactory} from '../../../util/order_factory';
-import {chaiSetup} from '../utils/chai_setup';
+import { Artifacts } from '../../../util/artifacts';
+import { ExchangeWrapper } from '../../../util/exchange_wrapper';
+import { Order } from '../../../util/order';
+import { OrderFactory } from '../../../util/order_factory';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {
- Exchange,
- TokenRegistry,
-} = new Artifacts(artifacts);
+const { Exchange, TokenRegistry } = new Artifacts(artifacts);
contract('Exchange', (accounts: string[]) => {
const maker = accounts[0];
@@ -26,10 +23,7 @@ contract('Exchange', (accounts: string[]) => {
let orderFactory: OrderFactory;
before(async () => {
- const [tokenRegistry, exchange] = await Promise.all([
- TokenRegistry.deployed(),
- Exchange.deployed(),
- ]);
+ const [tokenRegistry, exchange] = await Promise.all([TokenRegistry.deployed(), Exchange.deployed()]);
exchangeWrapper = new ExchangeWrapper(exchange);
const [repAddress, dgdAddress] = await Promise.all([
tokenRegistry.getTokenAddressBySymbol('REP'),
diff --git a/packages/contracts/test/ts/exchange/wrapper.ts b/packages/contracts/test/ts/exchange/wrapper.ts
index c40d60104..e69e08bcf 100644
--- a/packages/contracts/test/ts/exchange/wrapper.ts
+++ b/packages/contracts/test/ts/exchange/wrapper.ts
@@ -1,25 +1,20 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import {Artifacts} from '../../../util/artifacts';
-import {Balances} from '../../../util/balances';
-import {constants} from '../../../util/constants';
-import {ExchangeWrapper} from '../../../util/exchange_wrapper';
-import {Order} from '../../../util/order';
-import {OrderFactory} from '../../../util/order_factory';
-import {BalancesByOwner, ContractInstance} from '../../../util/types';
-import {chaiSetup} from '../utils/chai_setup';
+import { Artifacts } from '../../../util/artifacts';
+import { Balances } from '../../../util/balances';
+import { constants } from '../../../util/constants';
+import { ExchangeWrapper } from '../../../util/exchange_wrapper';
+import { Order } from '../../../util/order';
+import { OrderFactory } from '../../../util/order_factory';
+import { BalancesByOwner, ContractInstance } from '../../../util/types';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {
- Exchange,
- TokenTransferProxy,
- DummyToken,
- TokenRegistry,
-} = new Artifacts(artifacts);
+const { Exchange, TokenTransferProxy, DummyToken, TokenRegistry } = new Artifacts(artifacts);
contract('Exchange', (accounts: string[]) => {
const maker = accounts[0];
@@ -43,10 +38,7 @@ contract('Exchange', (accounts: string[]) => {
let orderFactory: OrderFactory;
before(async () => {
- [tokenRegistry, exchange] = await Promise.all([
- TokenRegistry.deployed(),
- Exchange.deployed(),
- ]);
+ [tokenRegistry, exchange] = await Promise.all([TokenRegistry.deployed(), Exchange.deployed()]);
exWrapper = new ExchangeWrapper(exchange);
const [repAddress, dgdAddress, zrxAddress] = await Promise.all([
tokenRegistry.getTokenAddressBySymbol('REP'),
@@ -74,18 +66,18 @@ contract('Exchange', (accounts: string[]) => {
]);
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
await Promise.all([
- rep.approve(TokenTransferProxy.address, INIT_ALLOW, {from: maker}),
- rep.approve(TokenTransferProxy.address, INIT_ALLOW, {from: taker}),
- rep.setBalance(maker, INIT_BAL, {from: tokenOwner}),
- rep.setBalance(taker, INIT_BAL, {from: tokenOwner}),
- dgd.approve(TokenTransferProxy.address, INIT_ALLOW, {from: maker}),
- dgd.approve(TokenTransferProxy.address, INIT_ALLOW, {from: taker}),
- dgd.setBalance(maker, INIT_BAL, {from: tokenOwner}),
- dgd.setBalance(taker, INIT_BAL, {from: tokenOwner}),
- zrx.approve(TokenTransferProxy.address, INIT_ALLOW, {from: maker}),
- zrx.approve(TokenTransferProxy.address, INIT_ALLOW, {from: taker}),
- zrx.setBalance(maker, INIT_BAL, {from: tokenOwner}),
- zrx.setBalance(taker, INIT_BAL, {from: tokenOwner}),
+ rep.approve(TokenTransferProxy.address, INIT_ALLOW, { from: maker }),
+ rep.approve(TokenTransferProxy.address, INIT_ALLOW, { from: taker }),
+ rep.setBalance(maker, INIT_BAL, { from: tokenOwner }),
+ rep.setBalance(taker, INIT_BAL, { from: tokenOwner }),
+ dgd.approve(TokenTransferProxy.address, INIT_ALLOW, { from: maker }),
+ dgd.approve(TokenTransferProxy.address, INIT_ALLOW, { from: taker }),
+ dgd.setBalance(maker, INIT_BAL, { from: tokenOwner }),
+ dgd.setBalance(taker, INIT_BAL, { from: tokenOwner }),
+ zrx.approve(TokenTransferProxy.address, INIT_ALLOW, { from: maker }),
+ zrx.approve(TokenTransferProxy.address, INIT_ALLOW, { from: taker }),
+ zrx.setBalance(maker, INIT_BAL, { from: tokenOwner }),
+ zrx.setBalance(taker, INIT_BAL, { from: tokenOwner }),
]);
});
@@ -100,31 +92,38 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrKillOrderAsync(order, taker, {fillTakerTokenAmount});
+ await exWrapper.fillOrKillOrderAsync(order, taker, {
+ fillTakerTokenAmount,
+ });
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const makerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const takerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken])
- .to.be.bignumber.equal(balances[maker][order.params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][order.params.takerToken])
- .to.be.bignumber.equal(balances[maker][order.params.takerToken].add(fillTakerTokenAmount));
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
+ expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ );
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(balances[maker][zrx.address].minus(makerFee));
- expect(newBalances[taker][order.params.takerToken])
- .to.be.bignumber.equal(balances[taker][order.params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][order.params.makerToken])
- .to.be.bignumber.equal(balances[taker][order.params.makerToken].add(fillMakerTokenAmount));
+ expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
+ balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ );
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(balances[taker][zrx.address].minus(takerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)));
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)),
+ );
});
it('should throw if an order is expired', async () => {
@@ -132,18 +131,18 @@ contract('Exchange', (accounts: string[]) => {
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- return expect(exWrapper.fillOrKillOrderAsync(order, taker))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrKillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if entire fillTakerTokenAmount not filled', async () => {
const order = await orderFactory.newSignedOrderAsync();
const from = taker;
- await exWrapper.fillOrderAsync(order, from, {fillTakerTokenAmount: order.params.takerTokenAmount.div(2)});
+ await exWrapper.fillOrderAsync(order, from, {
+ fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
+ });
- return expect(exWrapper.fillOrKillOrderAsync(order, taker))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrKillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
});
@@ -166,14 +165,14 @@ contract('Exchange', (accounts: string[]) => {
orders.forEach(order => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const makerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const takerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
@@ -181,11 +180,14 @@ contract('Exchange', (accounts: string[]) => {
balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
- balances[feeRecipient][zrx.address] =
- balances[feeRecipient][zrx.address].add(makerFee.add(takerFee));
+ balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
+ makerFee.add(takerFee),
+ );
});
- await exWrapper.batchFillOrdersAsync(orders, taker, {fillTakerTokenAmounts});
+ await exWrapper.batchFillOrdersAsync(orders, taker, {
+ fillTakerTokenAmounts,
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
@@ -200,14 +202,14 @@ contract('Exchange', (accounts: string[]) => {
orders.forEach(order => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
+ .times(order.params.makerTokenAmount)
+ .dividedToIntegerBy(order.params.takerTokenAmount);
const makerFee = order.params.makerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
const takerFee = order.params.takerFee
- .times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .times(fillMakerTokenAmount)
+ .dividedToIntegerBy(order.params.makerTokenAmount);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
@@ -215,11 +217,14 @@ contract('Exchange', (accounts: string[]) => {
balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
- balances[feeRecipient][zrx.address] =
- balances[feeRecipient][zrx.address].add(makerFee.add(takerFee));
+ balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
+ makerFee.add(takerFee),
+ );
});
- await exWrapper.batchFillOrKillOrdersAsync(orders, taker, {fillTakerTokenAmounts});
+ await exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
+ fillTakerTokenAmounts,
+ });
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
@@ -227,8 +232,6 @@ contract('Exchange', (accounts: string[]) => {
it('should throw if a single order does not fill the expected amount', async () => {
const fillTakerTokenAmounts: BigNumber[] = [];
- const makerToken = rep.address;
- const takerToken = dgd.address;
orders.forEach(order => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
@@ -236,57 +239,77 @@ contract('Exchange', (accounts: string[]) => {
await exWrapper.fillOrKillOrderAsync(orders[0], taker);
- return expect(exWrapper.batchFillOrKillOrdersAsync(orders, taker, {fillTakerTokenAmounts}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
+ fillTakerTokenAmounts,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
});
describe('fillOrdersUpTo', () => {
it('should stop when the entire fillTakerTokenAmount is filled', async () => {
- const fillTakerTokenAmount =
- orders[0].params.takerTokenAmount.plus(orders[1].params.takerTokenAmount.div(2));
- await exWrapper.fillOrdersUpToAsync(orders, taker, {fillTakerTokenAmount});
+ const fillTakerTokenAmount = orders[0].params.takerTokenAmount.plus(
+ orders[1].params.takerTokenAmount.div(2),
+ );
+ await exWrapper.fillOrdersUpToAsync(orders, taker, {
+ fillTakerTokenAmount,
+ });
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = orders[0].params.makerTokenAmount.add(
- orders[1].params.makerTokenAmount.dividedToIntegerBy(2));
+ orders[1].params.makerTokenAmount.dividedToIntegerBy(2),
+ );
const makerFee = orders[0].params.makerFee.add(orders[1].params.makerFee.dividedToIntegerBy(2));
const takerFee = orders[0].params.takerFee.add(orders[1].params.takerFee.dividedToIntegerBy(2));
- expect(newBalances[maker][orders[0].params.makerToken])
- .to.be.bignumber.equal(balances[maker][orders[0].params.makerToken].minus(fillMakerTokenAmount));
- expect(newBalances[maker][orders[0].params.takerToken])
- .to.be.bignumber.equal(balances[maker][orders[0].params.takerToken].add(fillTakerTokenAmount));
- expect(newBalances[maker][zrx.address]).to.be.bignumber
- .equal(balances[maker][zrx.address].minus(makerFee));
- expect(newBalances[taker][orders[0].params.takerToken])
- .to.be.bignumber.equal(balances[taker][orders[0].params.takerToken].minus(fillTakerTokenAmount));
- expect(newBalances[taker][orders[0].params.makerToken])
- .to.be.bignumber.equal(balances[taker][orders[0].params.makerToken].add(fillMakerTokenAmount));
- expect(newBalances[taker][zrx.address]).to.be.bignumber
- .equal(balances[taker][zrx.address].minus(takerFee));
- expect(newBalances[feeRecipient][zrx.address])
- .to.be.bignumber.equal(balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)));
+ expect(newBalances[maker][orders[0].params.makerToken]).to.be.bignumber.equal(
+ balances[maker][orders[0].params.makerToken].minus(fillMakerTokenAmount),
+ );
+ expect(newBalances[maker][orders[0].params.takerToken]).to.be.bignumber.equal(
+ balances[maker][orders[0].params.takerToken].add(fillTakerTokenAmount),
+ );
+ expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
+ balances[maker][zrx.address].minus(makerFee),
+ );
+ expect(newBalances[taker][orders[0].params.takerToken]).to.be.bignumber.equal(
+ balances[taker][orders[0].params.takerToken].minus(fillTakerTokenAmount),
+ );
+ expect(newBalances[taker][orders[0].params.makerToken]).to.be.bignumber.equal(
+ balances[taker][orders[0].params.makerToken].add(fillMakerTokenAmount),
+ );
+ expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
+ balances[taker][zrx.address].minus(takerFee),
+ );
+ expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)),
+ );
});
it('should fill all orders if cannot fill entire fillTakerTokenAmount', async () => {
const fillTakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
orders.forEach(order => {
- balances[maker][order.params.makerToken] = balances[maker][order.params.makerToken]
- .minus(order.params.makerTokenAmount);
- balances[maker][order.params.takerToken] = balances[maker][order.params.takerToken]
- .add(order.params.takerTokenAmount);
- balances[maker][zrx.address] = balances[maker][zrx.address]
- .minus(order.params.makerFee);
- balances[taker][order.params.makerToken] = balances[taker][order.params.makerToken]
- .add(order.params.makerTokenAmount);
- balances[taker][order.params.takerToken] = balances[taker][order.params.takerToken]
- .minus(order.params.takerTokenAmount);
+ balances[maker][order.params.makerToken] = balances[maker][order.params.makerToken].minus(
+ order.params.makerTokenAmount,
+ );
+ balances[maker][order.params.takerToken] = balances[maker][order.params.takerToken].add(
+ order.params.takerTokenAmount,
+ );
+ balances[maker][zrx.address] = balances[maker][zrx.address].minus(order.params.makerFee);
+ balances[taker][order.params.makerToken] = balances[taker][order.params.makerToken].add(
+ order.params.makerTokenAmount,
+ );
+ balances[taker][order.params.takerToken] = balances[taker][order.params.takerToken].minus(
+ order.params.takerTokenAmount,
+ );
balances[taker][zrx.address] = balances[taker][zrx.address].minus(order.params.takerFee);
- balances[feeRecipient][zrx.address] =
- balances[feeRecipient][zrx.address].add(order.params.makerFee.add(order.params.takerFee));
+ balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
+ order.params.makerFee.add(order.params.takerFee),
+ );
+ });
+ await exWrapper.fillOrdersUpToAsync(orders, taker, {
+ fillTakerTokenAmount,
});
- await exWrapper.fillOrdersUpToAsync(orders, taker, {fillTakerTokenAmount});
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
@@ -295,24 +318,28 @@ contract('Exchange', (accounts: string[]) => {
it('should throw when an order does not use the same takerToken', async () => {
orders = await Promise.all([
orderFactory.newSignedOrderAsync(),
- orderFactory.newSignedOrderAsync({takerToken: zrx.address}),
+ orderFactory.newSignedOrderAsync({ takerToken: zrx.address }),
orderFactory.newSignedOrderAsync(),
]);
return expect(
- exWrapper.fillOrdersUpToAsync(
- orders, taker, {fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18)}),
- ).to.be.rejectedWith(constants.INVALID_OPCODE);
+ exWrapper.fillOrdersUpToAsync(orders, taker, {
+ fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
});
describe('batchCancelOrders', () => {
it('should be able to cancel multiple orders', async () => {
const cancelTakerTokenAmounts = _.map(orders, order => order.params.takerTokenAmount);
- await exWrapper.batchCancelOrdersAsync(orders, maker, {cancelTakerTokenAmounts});
+ await exWrapper.batchCancelOrdersAsync(orders, maker, {
+ cancelTakerTokenAmounts,
+ });
- const res = await exWrapper.batchFillOrdersAsync(
- orders, taker, {fillTakerTokenAmounts: cancelTakerTokenAmounts});
+ await exWrapper.batchFillOrdersAsync(orders, taker, {
+ fillTakerTokenAmounts: cancelTakerTokenAmounts,
+ });
const newBalances = await dmyBalances.getAsync();
expect(balances).to.be.deep.equal(newBalances);
});
diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock.ts b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
index 6dd4dc3b2..ea939a758 100644
--- a/packages/contracts/test/ts/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
@@ -1,18 +1,18 @@
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
+import { RPC } from '@0xproject/dev-utils';
+import { BigNumber, promisify } from '@0xproject/utils';
import * as chai from 'chai';
import Web3 = require('web3');
import * as multiSigWalletJSON from '../../build/contracts/MultiSigWalletWithTimeLock.json';
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
-import {MultiSigWrapper} from '../../util/multi_sig_wrapper';
-import {RPC} from '../../util/rpc';
-import {ContractInstance} from '../../util/types';
+import * as truffleConf from '../../truffle.js';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { MultiSigWrapper } from '../../util/multi_sig_wrapper';
+import { ContractInstance } from '../../util/types';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
-const {MultiSigWalletWithTimeLock} = new Artifacts(artifacts);
+const { MultiSigWalletWithTimeLock } = new Artifacts(artifacts);
const MULTI_SIG_ABI = (multiSigWalletJSON as any).abi;
chaiSetup.configure();
@@ -38,13 +38,15 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
const secondsTimeLocked = await multiSig.secondsTimeLocked.call();
initialSecondsTimeLocked = secondsTimeLocked.toNumber();
- rpc = new RPC();
+ const rpcUrl = `http://${truffleConf.networks.development.host}:${truffleConf.networks.development.port}`;
+ rpc = new RPC(rpcUrl);
});
describe('changeTimeLock', () => {
it('should throw when not called by wallet', async () => {
- return expect(multiSig.changeTimeLock(SECONDS_TIME_LOCKED, {from: owners[0]}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.changeTimeLock(SECONDS_TIME_LOCKED, { from: owners[0] })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should throw without enough confirmations', async () => {
@@ -58,11 +60,11 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
txId = subRes.logs[0].args.transactionId.toNumber();
- return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should set confirmation time with enough confirmations', async () => {
- const res = await multiSig.confirmTransaction(txId, {from: owners[1]});
+ const res = await multiSig.confirmTransaction(txId, { from: owners[1] });
expect(res.logs).to.have.length(2);
const blockNum = await promisify<number>(web3.eth.getBlockNumber)();
const blockInfo = await promisify<Web3.BlockWithoutTransactionData>(web3.eth.getBlock)(blockNum);
@@ -94,10 +96,12 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
txId = subRes.logs[0].args.transactionId.toNumber();
- const confRes = await multiSig.confirmTransaction(txId, {from: owners[1]});
+ const confRes = await multiSig.confirmTransaction(txId, {
+ from: owners[1],
+ });
expect(confRes.logs).to.have.length(2);
- return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should execute if it has enough confirmations and is past the time lock', async () => {
diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts b/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts
index 97ccac2bd..62aa625fe 100644
--- a/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts
+++ b/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts
@@ -1,14 +1,14 @@
import * as chai from 'chai';
import * as tokenTransferProxyJSON from '../../build/contracts/TokenTransferProxy.json';
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
-import {crypto} from '../../util/crypto';
-import {MultiSigWrapper} from '../../util/multi_sig_wrapper';
-import {ContractInstance, TransactionDataParams} from '../../util/types';
-
-import {chaiSetup} from './utils/chai_setup';
-const {TokenTransferProxy, MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress} = new Artifacts(artifacts);
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { crypto } from '../../util/crypto';
+import { MultiSigWrapper } from '../../util/multi_sig_wrapper';
+import { ContractInstance, TransactionDataParams } from '../../util/types';
+
+import { chaiSetup } from './utils/chai_setup';
+const { TokenTransferProxy, MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress } = new Artifacts(artifacts);
const PROXY_ABI = (tokenTransferProxyJSON as any).abi;
chaiSetup.configure();
@@ -20,8 +20,14 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
const SECONDS_TIME_LOCKED = 1000000;
// initialize fake addresses
- const authorizedAddress = `0x${crypto.solSHA3([accounts[0]]).slice(0, 20).toString('hex')}`;
- const unauthorizedAddress = `0x${crypto.solSHA3([accounts[1]]).slice(0, 20).toString('hex')}`;
+ const authorizedAddress = `0x${crypto
+ .solSHA3([accounts[0]])
+ .slice(0, 20)
+ .toString('hex')}`;
+ const unauthorizedAddress = `0x${crypto
+ .solSHA3([accounts[1]])
+ .slice(0, 20)
+ .toString('hex')}`;
let tokenTransferProxy: ContractInstance;
let multiSig: ContractInstance;
@@ -31,11 +37,19 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
beforeEach(async () => {
const initialOwner = accounts[0];
- tokenTransferProxy = await TokenTransferProxy.new({from: initialOwner});
- await tokenTransferProxy.addAuthorizedAddress(authorizedAddress, {from: initialOwner});
+ tokenTransferProxy = await TokenTransferProxy.new({ from: initialOwner });
+ await tokenTransferProxy.addAuthorizedAddress(authorizedAddress, {
+ from: initialOwner,
+ });
multiSig = await MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.new(
- owners, requiredApprovals, SECONDS_TIME_LOCKED, tokenTransferProxy.address);
- await tokenTransferProxy.transferOwnership(multiSig.address, {from: initialOwner});
+ owners,
+ requiredApprovals,
+ SECONDS_TIME_LOCKED,
+ tokenTransferProxy.address,
+ );
+ await tokenTransferProxy.transferOwnership(multiSig.address, {
+ from: initialOwner,
+ });
multiSigWrapper = new MultiSigWrapper(multiSig);
validDestination = tokenTransferProxy.address;
});
@@ -43,8 +57,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
describe('isFunctionRemoveAuthorizedAddress', () => {
it('should throw if data is not for removeAuthorizedAddress', async () => {
const data = MultiSigWrapper.encodeFnArgs('addAuthorizedAddress', PROXY_ABI, [owners[0]]);
- return expect(multiSig.isFunctionRemoveAuthorizedAddress.call(data))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.isFunctionRemoveAuthorizedAddress.call(data)).to.be.rejectedWith(constants.REVERT);
});
it('should return true if data is for removeAuthorizedAddress', async () => {
@@ -64,7 +77,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
const res = await multiSigWrapper.submitTransactionAsync(validDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if tx destination is not the tokenTransferProxy', async () => {
@@ -77,11 +90,11 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
};
const res = await multiSigWrapper.submitTransactionAsync(invalidDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- await multiSig.confirmTransaction(txId, {from: owners[1]});
+ await multiSig.confirmTransaction(txId, { from: owners[1] });
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
- return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if tx data is not for removeAuthorizedAddress', async () => {
@@ -92,11 +105,11 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
};
const res = await multiSigWrapper.submitTransactionAsync(validDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- await multiSig.confirmTransaction(txId, {from: owners[1]});
+ await multiSig.confirmTransaction(txId, { from: owners[1] });
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
- return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should execute removeAuthorizedAddress for valid tokenTransferProxy if fully confirmed', async () => {
@@ -107,7 +120,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
};
const res = await multiSigWrapper.submitTransactionAsync(validDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- await multiSig.confirmTransaction(txId, {from: owners[1]});
+ await multiSig.confirmTransaction(txId, { from: owners[1] });
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
await multiSig.executeRemoveAuthorizedAddress(txId);
@@ -124,14 +137,14 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
};
const res = await multiSigWrapper.submitTransactionAsync(validDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- await multiSig.confirmTransaction(txId, {from: owners[1]});
+ await multiSig.confirmTransaction(txId, { from: owners[1] });
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
await multiSig.executeRemoveAuthorizedAddress(txId);
const tx = await multiSig.transactions.call(txId);
const isExecuted = tx[3];
expect(isExecuted).to.be.true();
- return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.REVERT);
});
});
});
diff --git a/packages/contracts/test/ts/token_registry.ts b/packages/contracts/test/ts/token_registry.ts
index ed0bbf55b..d1c551565 100644
--- a/packages/contracts/test/ts/token_registry.ts
+++ b/packages/contracts/test/ts/token_registry.ts
@@ -1,16 +1,16 @@
-import {ZeroEx} from '0x.js';
+import { ZeroEx } from '0x.js';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import {Artifacts} from '../../util/artifacts';
-import {constants} from '../../util/constants';
-import {TokenRegWrapper} from '../../util/token_registry_wrapper';
-import {ContractInstance} from '../../util/types';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { TokenRegWrapper } from '../../util/token_registry_wrapper';
+import { ContractInstance } from '../../util/types';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
-const {TokenRegistry} = new Artifacts(artifacts);
+const { TokenRegistry } = new Artifacts(artifacts);
chaiSetup.configure();
const expect = chai.expect;
@@ -58,7 +58,7 @@ contract('TokenRegistry', (accounts: string[]) => {
describe('addToken', () => {
it('should throw when not called by owner', async () => {
- return expect(tokenRegWrapper.addTokenAsync(token1, notOwner)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenRegWrapper.addTokenAsync(token1, notOwner)).to.be.rejectedWith(constants.REVERT);
});
it('should add token metadata when called by owner', async () => {
@@ -70,27 +70,31 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if token already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
- return expect(tokenRegWrapper.addTokenAsync(token1, owner)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenRegWrapper.addTokenAsync(token1, owner)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if token address is null', async () => {
- return expect(tokenRegWrapper.addTokenAsync(nullToken, owner)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenRegWrapper.addTokenAsync(nullToken, owner)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if name already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
- const duplicateNameToken = _.assign({}, token2, {name: token1.name});
+ const duplicateNameToken = _.assign({}, token2, { name: token1.name });
- return expect(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner)).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should throw if symbol already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
- const duplicateSymbolToken = _.assign({}, token2, {symbol: token1.symbol});
+ const duplicateSymbolToken = _.assign({}, token2, {
+ symbol: token1.symbol,
+ });
- return expect(tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner)).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
});
@@ -115,19 +119,22 @@ contract('TokenRegistry', (accounts: string[]) => {
describe('setTokenName', () => {
it('should throw when not called by owner', async () => {
- return expect(tokenReg.setTokenName(token1.address, token2.name, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ tokenReg.setTokenName(token1.address, token2.name, { from: notOwner }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should change the token name when called by owner', async () => {
- const res = await tokenReg.setTokenName(token1.address, token2.name, {from: owner});
+ const res = await tokenReg.setTokenName(token1.address, token2.name, {
+ from: owner,
+ });
expect(res.logs).to.have.length(1);
const [newData, oldData] = await Promise.all([
tokenRegWrapper.getTokenByNameAsync(token2.name),
tokenRegWrapper.getTokenByNameAsync(token1.name),
]);
- const expectedNewData = _.assign({}, token1, {name: token2.name});
+ const expectedNewData = _.assign({}, token1, { name: token2.name });
const expectedOldData = nullToken;
expect(newData).to.be.deep.equal(expectedNewData);
expect(oldData).to.be.deep.equal(expectedOldData);
@@ -136,31 +143,36 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if the name already exists', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
- return expect(tokenReg.setTokenName(token1.address, token2.name, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenReg.setTokenName(token1.address, token2.name, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should throw if token does not exist', async () => {
- return expect(tokenReg.setTokenName(nullToken.address, token2.name, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ tokenReg.setTokenName(nullToken.address, token2.name, { from: owner }),
+ ).to.be.rejectedWith(constants.REVERT);
});
});
describe('setTokenSymbol', () => {
it('should throw when not called by owner', async () => {
- return expect(tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ tokenReg.setTokenSymbol(token1.address, token2.symbol, {
+ from: notOwner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should change the token symbol when called by owner', async () => {
- const res = await tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: owner});
+ const res = await tokenReg.setTokenSymbol(token1.address, token2.symbol, { from: owner });
expect(res.logs).to.have.length(1);
const [newData, oldData] = await Promise.all([
tokenRegWrapper.getTokenBySymbolAsync(token2.symbol),
tokenRegWrapper.getTokenBySymbolAsync(token1.symbol),
]);
- const expectedNewData = _.assign({}, token1, {symbol: token2.symbol});
+ const expectedNewData = _.assign({}, token1, { symbol: token2.symbol });
const expectedOldData = nullToken;
expect(newData).to.be.deep.equal(expectedNewData);
expect(oldData).to.be.deep.equal(expectedOldData);
@@ -169,26 +181,35 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if the symbol already exists', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
- return expect(tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ tokenReg.setTokenSymbol(token1.address, token2.symbol, {
+ from: owner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should throw if token does not exist', async () => {
- return expect(tokenReg.setTokenSymbol(nullToken.address, token2.symbol, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ tokenReg.setTokenSymbol(nullToken.address, token2.symbol, {
+ from: owner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
});
describe('removeToken', () => {
it('should throw if not called by owner', async () => {
const index = 0;
- return expect(tokenReg.removeToken(token1.address, index, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenReg.removeToken(token1.address, index, { from: notOwner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should remove token metadata when called by owner', async () => {
const index = 0;
- const res = await tokenReg.removeToken(token1.address, index, {from: owner});
+ const res = await tokenReg.removeToken(token1.address, index, {
+ from: owner,
+ });
expect(res.logs).to.have.length(1);
const tokenData = await tokenRegWrapper.getTokenMetaDataAsync(token1.address);
expect(tokenData).to.be.deep.equal(nullToken);
@@ -196,17 +217,18 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if token does not exist', async () => {
const index = 0;
- return expect(tokenReg.removeToken(nullToken.address, index, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenReg.removeToken(nullToken.address, index, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should throw if token at given index does not match address', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
const incorrectIndex = 0;
- return expect(tokenReg.removeToken(token2.address, incorrectIndex, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenReg.removeToken(token2.address, incorrectIndex, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
-
});
});
});
diff --git a/packages/contracts/test/ts/token_transfer_proxy/auth.ts b/packages/contracts/test/ts/token_transfer_proxy/auth.ts
index 785fbc016..9ae0a8fc3 100644
--- a/packages/contracts/test/ts/token_transfer_proxy/auth.ts
+++ b/packages/contracts/test/ts/token_transfer_proxy/auth.ts
@@ -1,8 +1,8 @@
import * as chai from 'chai';
-import {constants} from '../../../util/constants';
-import {ContractInstance} from '../../../util/types';
-import {chaiSetup} from '../utils/chai_setup';
+import { constants } from '../../../util/constants';
+import { ContractInstance } from '../../../util/types';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
@@ -22,12 +22,15 @@ contract('TokenTransferProxy', (accounts: string[]) => {
describe('addAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
- return expect(tokenTransferProxy.addAuthorizedAddress(notOwner, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenTransferProxy.addAuthorizedAddress(notOwner, { from: notOwner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should allow owner to add an authorized address', async () => {
- await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {from: owner});
+ await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {
+ from: owner,
+ });
authorized = notAuthorized;
notAuthorized = null;
const isAuthorized = await tokenTransferProxy.authorized.call(authorized);
@@ -35,19 +38,25 @@ contract('TokenTransferProxy', (accounts: string[]) => {
});
it('should throw if owner attempts to authorize a duplicate address', async () => {
- return expect(tokenTransferProxy.addAuthorizedAddress(authorized, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenTransferProxy.addAuthorizedAddress(authorized, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
});
describe('removeAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
- return expect(tokenTransferProxy.removeAuthorizedAddress(authorized, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ tokenTransferProxy.removeAuthorizedAddress(authorized, {
+ from: notOwner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should allow owner to remove an authorized address', async () => {
- await tokenTransferProxy.removeAuthorizedAddress(authorized, {from: owner});
+ await tokenTransferProxy.removeAuthorizedAddress(authorized, {
+ from: owner,
+ });
notAuthorized = authorized;
authorized = null;
@@ -56,8 +65,11 @@ contract('TokenTransferProxy', (accounts: string[]) => {
});
it('should throw if owner attempts to remove an address that is not authorized', async () => {
- return expect(tokenTransferProxy.removeAuthorizedAddress(notAuthorized, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(
+ tokenTransferProxy.removeAuthorizedAddress(notAuthorized, {
+ from: owner,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
});
@@ -65,7 +77,9 @@ contract('TokenTransferProxy', (accounts: string[]) => {
it('should return all authorized addresses', async () => {
const initial = await tokenTransferProxy.getAuthorizedAddresses();
expect(initial).to.have.length(1);
- await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {from: owner});
+ await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {
+ from: owner,
+ });
authorized = notAuthorized;
notAuthorized = null;
@@ -73,7 +87,9 @@ contract('TokenTransferProxy', (accounts: string[]) => {
expect(afterAdd).to.have.length(2);
expect(afterAdd).to.include(authorized);
- await tokenTransferProxy.removeAuthorizedAddress(authorized, {from: owner});
+ await tokenTransferProxy.removeAuthorizedAddress(authorized, {
+ from: owner,
+ });
notAuthorized = authorized;
authorized = null;
const afterRemove = await tokenTransferProxy.getAuthorizedAddresses();
diff --git a/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts b/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts
index 6e0bfdc1a..e1aff6dae 100644
--- a/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts
+++ b/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts
@@ -1,18 +1,14 @@
import * as chai from 'chai';
-import {Artifacts} from '../../../util/artifacts';
-import {Balances} from '../../../util/balances';
-import {constants} from '../../../util/constants';
-import {ContractInstance} from '../../../util/types';
-import {chaiSetup} from '../utils/chai_setup';
+import { Artifacts } from '../../../util/artifacts';
+import { Balances } from '../../../util/balances';
+import { constants } from '../../../util/constants';
+import { ContractInstance } from '../../../util/types';
+import { chaiSetup } from '../utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {
- TokenTransferProxy,
- DummyToken,
- TokenRegistry,
-} = new Artifacts(artifacts);
+const { TokenTransferProxy, DummyToken, TokenRegistry } = new Artifacts(artifacts);
contract('TokenTransferProxy', (accounts: string[]) => {
const INIT_BAL = 100000000;
@@ -36,32 +32,42 @@ contract('TokenTransferProxy', (accounts: string[]) => {
dmyBalances = new Balances([rep], [accounts[0], accounts[1]]);
await Promise.all([
- rep.approve(TokenTransferProxy.address, INIT_ALLOW, {from: accounts[0]}),
- rep.setBalance(accounts[0], INIT_BAL, {from: owner}),
- rep.approve(TokenTransferProxy.address, INIT_ALLOW, {from: accounts[1]}),
- rep.setBalance(accounts[1], INIT_BAL, {from: owner}),
+ rep.approve(TokenTransferProxy.address, INIT_ALLOW, {
+ from: accounts[0],
+ }),
+ rep.setBalance(accounts[0], INIT_BAL, { from: owner }),
+ rep.approve(TokenTransferProxy.address, INIT_ALLOW, {
+ from: accounts[1],
+ }),
+ rep.setBalance(accounts[1], INIT_BAL, { from: owner }),
]);
});
describe('transferFrom', () => {
it('should throw when called by an unauthorized address', async () => {
- expect(tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1], 1000, {from: notAuthorized}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ expect(
+ tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1], 1000, { from: notAuthorized }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should allow an authorized address to transfer', async () => {
const balances = await dmyBalances.getAsync();
- await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {from: owner});
+ await tokenTransferProxy.addAuthorizedAddress(notAuthorized, {
+ from: owner,
+ });
const transferAmt = 10000;
- await tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1],
- transferAmt, {from: notAuthorized});
+ await tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1], transferAmt, {
+ from: notAuthorized,
+ });
const newBalances = await dmyBalances.getAsync();
- expect(newBalances[accounts[0]][rep.address])
- .to.be.bignumber.equal(balances[accounts[0]][rep.address].minus(transferAmt));
- expect(newBalances[accounts[1]][rep.address])
- .to.be.bignumber.equal(balances[accounts[1]][rep.address].add(transferAmt));
+ expect(newBalances[accounts[0]][rep.address]).to.be.bignumber.equal(
+ balances[accounts[0]][rep.address].minus(transferAmt),
+ );
+ expect(newBalances[accounts[1]][rep.address]).to.be.bignumber.equal(
+ balances[accounts[1]][rep.address].add(transferAmt),
+ );
});
});
});
diff --git a/packages/contracts/test/ts/unlimitedAllowanceToken.ts b/packages/contracts/test/ts/unlimited_allowance_token.ts
index ca3fcd7d2..c90a52095 100644
--- a/packages/contracts/test/ts/unlimitedAllowanceToken.ts
+++ b/packages/contracts/test/ts/unlimited_allowance_token.ts
@@ -1,20 +1,24 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as Web3 from 'web3';
-import {Artifacts} from '../../util/artifacts';
-import {ContractInstance} from '../../util/types';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { ContractInstance } from '../../util/types';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
-const {DummyToken} = new Artifacts(artifacts);
+const { DummyToken } = new Artifacts(artifacts);
const web3: Web3 = (global as any).web3;
chaiSetup.configure();
const expect = chai.expect;
contract('UnlimitedAllowanceToken', (accounts: string[]) => {
- const zeroEx = new ZeroEx(web3.currentProvider);
+ const config = {
+ networkId: constants.TESTRPC_NETWORK_ID,
+ };
+ const zeroEx = new ZeroEx(web3.currentProvider, config);
const owner = accounts[0];
const spender = accounts[1];
@@ -23,8 +27,8 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
let token: ContractInstance;
beforeEach(async () => {
- token = await DummyToken.new({from: owner});
- await token.mint(MAX_MINT_VALUE, {from: owner});
+ token = await DummyToken.new({ from: owner });
+ await token.mint(MAX_MINT_VALUE, { from: owner });
tokenAddress = token.address;
});
@@ -44,7 +48,9 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
});
it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await token.transfer.call(spender, 0, {from: owner});
+ const didReturnTrue = await token.transfer.call(spender, 0, {
+ from: owner,
+ });
expect(didReturnTrue).to.be.true();
});
});
@@ -54,7 +60,7 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
});
@@ -66,13 +72,13 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(spenderAllowanceIsInsufficient).to.be.true();
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
});
it('should return true on a 0 value transfer', async () => {
const amountToTransfer = 0;
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.true();
});
@@ -81,7 +87,9 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer);
+ await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ });
const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
@@ -92,7 +100,9 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = initOwnerBalance;
await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer);
+ await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ });
const newOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
const newSpenderBalance = await zeroEx.token.getBalanceAsync(tokenAddress, spender);
@@ -106,7 +116,9 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => {
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = initOwnerBalance;
await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer);
+ await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ });
const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
expect(newSpenderAllowance).to.be.bignumber.equal(0);
diff --git a/packages/contracts/test/ts/unlimited_allowance_token_v2.ts b/packages/contracts/test/ts/unlimited_allowance_token_v2.ts
new file mode 100644
index 000000000..1b29a02ba
--- /dev/null
+++ b/packages/contracts/test/ts/unlimited_allowance_token_v2.ts
@@ -0,0 +1,141 @@
+import { ZeroEx } from '0x.js';
+import { BigNumber } from '@0xproject/utils';
+import * as chai from 'chai';
+import * as Web3 from 'web3';
+
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { ContractInstance } from '../../util/types';
+
+import { chaiSetup } from './utils/chai_setup';
+
+const { DummyTokenV2 } = new Artifacts(artifacts);
+const web3: Web3 = (global as any).web3;
+chaiSetup.configure();
+const expect = chai.expect;
+
+contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => {
+ const config = {
+ networkId: constants.TESTRPC_NETWORK_ID,
+ };
+ const zeroEx = new ZeroEx(web3.currentProvider, config);
+ const owner = accounts[0];
+ const spender = accounts[1];
+
+ const MAX_MINT_VALUE = new BigNumber(100000000000000000000);
+ let tokenAddress: string;
+ let token: ContractInstance;
+
+ beforeEach(async () => {
+ token = await DummyTokenV2.new({ from: owner });
+ await token.mint(MAX_MINT_VALUE, { from: owner });
+ tokenAddress = token.address;
+ });
+
+ describe('transfer', () => {
+ it('should throw if owner has insufficient balance', async () => {
+ const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = ownerBalance.plus(1);
+ return expect(token.transfer.call(spender, amountToTransfer, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
+ });
+
+ it('should transfer balance from sender to receiver', async () => {
+ const receiver = spender;
+ const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = new BigNumber(1);
+ await zeroEx.token.transferAsync(tokenAddress, owner, receiver, amountToTransfer);
+ const finalOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const finalReceiverBalance = await zeroEx.token.getBalanceAsync(tokenAddress, receiver);
+
+ const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
+ const expectedFinalReceiverBalance = amountToTransfer;
+ expect(finalOwnerBalance).to.be.bignumber.equal(expectedFinalOwnerBalance);
+ expect(finalReceiverBalance).to.be.bignumber.equal(expectedFinalReceiverBalance);
+ });
+
+ it('should return true on a 0 value transfer', async () => {
+ const didReturnTrue = await token.transfer.call(spender, 0, {
+ from: owner,
+ });
+ expect(didReturnTrue).to.be.true();
+ });
+ });
+
+ describe('transferFrom', () => {
+ it('should throw if owner has insufficient balance', async () => {
+ const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = ownerBalance.plus(1);
+ await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
+ return expect(
+ token.transferFrom.call(owner, spender, amountToTransfer, {
+ from: spender,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
+ });
+
+ it('should throw if spender has insufficient allowance', async () => {
+ const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = ownerBalance;
+
+ const spenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
+ const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
+ expect(spenderAllowanceIsInsufficient).to.be.true();
+
+ return expect(
+ token.transferFrom.call(owner, spender, amountToTransfer, {
+ from: spender,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
+ });
+
+ it('should return true on a 0 value transfer', async () => {
+ const amountToTransfer = 0;
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
+ expect(didReturnTrue).to.be.true();
+ });
+
+ it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
+ const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = initOwnerBalance;
+ const initSpenderAllowance = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
+ await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
+ await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ });
+
+ const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
+ expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
+ });
+
+ it('should transfer the correct balances if spender has sufficient allowance', async () => {
+ const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = initOwnerBalance;
+ const initSpenderAllowance = initOwnerBalance;
+ await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
+ await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ });
+
+ const newOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const newSpenderBalance = await zeroEx.token.getBalanceAsync(tokenAddress, spender);
+
+ expect(newOwnerBalance).to.be.bignumber.equal(0);
+ expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance);
+ });
+
+ it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
+ const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = initOwnerBalance;
+ const initSpenderAllowance = initOwnerBalance;
+ await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
+ await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ });
+
+ const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
+ expect(newSpenderAllowance).to.be.bignumber.equal(0);
+ });
+ });
+});
diff --git a/packages/contracts/test/ts/zrxToken.ts b/packages/contracts/test/ts/zrx_token.ts
index 471ee93f2..766c94c2a 100644
--- a/packages/contracts/test/ts/zrxToken.ts
+++ b/packages/contracts/test/ts/zrx_token.ts
@@ -1,16 +1,17 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import Web3 = require('web3');
-import {Artifacts} from '../../util/artifacts';
-import {ContractInstance} from '../../util/types';
+import { Artifacts } from '../../util/artifacts';
+import { constants } from '../../util/constants';
+import { ContractInstance } from '../../util/types';
-import {chaiSetup} from './utils/chai_setup';
+import { chaiSetup } from './utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
-const {Exchange, ZRXToken} = new Artifacts(artifacts);
+const { Exchange, ZRXToken } = new Artifacts(artifacts);
const web3: Web3 = (global as any).web3;
contract('ZRXToken', (accounts: string[]) => {
@@ -25,10 +26,11 @@ contract('ZRXToken', (accounts: string[]) => {
beforeEach(async () => {
zeroEx = new ZeroEx(web3.currentProvider, {
- exchangeContractAddress: Exchange.address,
+ exchangeContractAddress: Exchange.address,
+ networkId: constants.TESTRPC_NETWORK_ID,
});
- zrxAddress = await zeroEx.exchange.getZRXTokenAddressAsync();
- zrx = await ZRXToken.at(zrxAddress);
+ zrx = await ZRXToken.new();
+ zrxAddress = zrx.address;
MAX_UINT = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
});
@@ -83,7 +85,9 @@ contract('ZRXToken', (accounts: string[]) => {
});
it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await zrx.transfer.call(spender, 0, {from: owner});
+ const didReturnTrue = await zrx.transfer.call(spender, 0, {
+ from: owner,
+ });
expect(didReturnTrue).to.be.true();
});
});
@@ -92,13 +96,12 @@ contract('ZRXToken', (accounts: string[]) => {
it('should return false if owner has insufficient balance', async () => {
const ownerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
- let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer);
+ const txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_APPROVE_GAS,
+ });
await zeroEx.awaitTransactionMinedAsync(txHash);
- const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
- // Reset allowance
- txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, new BigNumber(0));
- await zeroEx.awaitTransactionMinedAsync(txHash);
});
it('should return false if spender has insufficient allowance', async () => {
@@ -109,13 +112,13 @@ contract('ZRXToken', (accounts: string[]) => {
const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(spenderAllowanceIsInsufficient).to.be.true();
- const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.false();
});
it('should return true on a 0 value transfer', async () => {
const amountToTransfer = 0;
- const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
expect(didReturnTrue).to.be.true();
});
@@ -123,16 +126,17 @@ contract('ZRXToken', (accounts: string[]) => {
const initOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = MAX_UINT;
- let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance);
+ let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance, {
+ gasLimit: constants.MAX_TOKEN_APPROVE_GAS,
+ });
await zeroEx.awaitTransactionMinedAsync(txHash);
- txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer);
+ txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ });
await zeroEx.awaitTransactionMinedAsync(txHash);
const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(zrxAddress, owner, spender);
expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
- // Restore balance
- txHash = await zeroEx.token.transferAsync(zrxAddress, spender, owner, amountToTransfer);
- await zeroEx.awaitTransactionMinedAsync(txHash);
});
it('should transfer the correct balances if spender has sufficient allowance', async () => {
@@ -142,7 +146,9 @@ contract('ZRXToken', (accounts: string[]) => {
const initSpenderAllowance = initOwnerBalance;
let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance);
await zeroEx.awaitTransactionMinedAsync(txHash);
- txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer);
+ txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ });
await zeroEx.awaitTransactionMinedAsync(txHash);
const newOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
@@ -155,10 +161,11 @@ contract('ZRXToken', (accounts: string[]) => {
it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
const initOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner);
const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = initOwnerBalance;
- let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance);
+ let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer);
await zeroEx.awaitTransactionMinedAsync(txHash);
- txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer);
+ txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
+ gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ });
await zeroEx.awaitTransactionMinedAsync(txHash);
const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(zrxAddress, owner, spender);
diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json
index c51d5acc4..38008a542 100644
--- a/packages/contracts/tsconfig.json
+++ b/packages/contracts/tsconfig.json
@@ -1,17 +1,17 @@
{
+ "extends": "../../tsconfig",
"compilerOptions": {
- "outDir": "./lib/",
- "sourceMap": true,
- "noImplicitAny": true,
- "module": "commonjs",
- "target": "es6",
+ "outDir": "lib",
"baseUrl": ".",
+ "declaration": false,
+ "strictNullChecks": false,
+ "strictFunctionTypes": false,
"allowJs": true
},
"include": [
"../../node_modules/types-ethereumjs-util/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts",
"../../node_modules/chai-typescript-typings/index.d.ts",
+ "../../node_modules/web3-typescript-typings/index.d.ts",
"../../node_modules/chai-as-promised-typescript-typings/index.d.ts",
"../../node_modules/types-ethereumjs-util/index.d.ts",
"../../node_modules/types-bn/index.d.ts",
@@ -21,7 +21,5 @@
"./migrations/**/*",
"./deploy/**/*"
],
- "exclude": [
- "./deploy/solc/solc_bin"
- ]
+ "exclude": ["./deploy/solc/solc_bin"]
}
diff --git a/packages/contracts/tslint.json b/packages/contracts/tslint.json
index a07795151..ffaefe83a 100644
--- a/packages/contracts/tslint.json
+++ b/packages/contracts/tslint.json
@@ -1,5 +1,3 @@
{
- "extends": [
- "@0xproject/tslint-config"
- ]
+ "extends": ["@0xproject/tslint-config"]
}
diff --git a/packages/contracts/util/artifacts.ts b/packages/contracts/util/artifacts.ts
index b15c9216f..ecb18cbce 100644
--- a/packages/contracts/util/artifacts.ts
+++ b/packages/contracts/util/artifacts.ts
@@ -6,6 +6,7 @@ export class Artifacts {
public Exchange: any;
public ZRXToken: any;
public DummyToken: any;
+ public DummyTokenV2: any;
public EtherToken: any;
public MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress: any;
public MaliciousToken: any;
@@ -17,9 +18,11 @@ export class Artifacts {
this.Exchange = artifacts.require('Exchange');
this.ZRXToken = artifacts.require('ZRXToken');
this.DummyToken = artifacts.require('DummyToken');
- this.EtherToken = artifacts.require('EtherToken');
+ this.DummyTokenV2 = artifacts.require('DummyToken_v2');
+ this.EtherToken = artifacts.require('WETH9');
this.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress = artifacts.require(
- 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress');
+ 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress',
+ );
this.MaliciousToken = artifacts.require('MaliciousToken');
}
}
diff --git a/packages/contracts/util/balances.ts b/packages/contracts/util/balances.ts
index fce15db6d..6a1659ab1 100644
--- a/packages/contracts/util/balances.ts
+++ b/packages/contracts/util/balances.ts
@@ -1,22 +1,19 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import {bigNumberConfigs} from './bignumber_config';
-import {BalancesByOwner, ContractInstance} from './types';
-
-bigNumberConfigs.configure();
+import { BalancesByOwner, ContractInstance } from './types';
export class Balances {
- private tokenContractInstances: ContractInstance[];
- private ownerAddresses: string[];
+ private _tokenContractInstances: ContractInstance[];
+ private _ownerAddresses: string[];
constructor(tokenContractInstances: ContractInstance[], ownerAddresses: string[]) {
- this.tokenContractInstances = tokenContractInstances;
- this.ownerAddresses = ownerAddresses;
+ this._tokenContractInstances = tokenContractInstances;
+ this._ownerAddresses = ownerAddresses;
}
public async getAsync(): Promise<BalancesByOwner> {
const balancesByOwner: BalancesByOwner = {};
- for (const tokenContractInstance of this.tokenContractInstances) {
- for (const ownerAddress of this.ownerAddresses) {
+ for (const tokenContractInstance of this._tokenContractInstances) {
+ for (const ownerAddress of this._ownerAddresses) {
let balance = await tokenContractInstance.balanceOf(ownerAddress);
balance = new BigNumber(balance);
if (_.isUndefined(balancesByOwner[ownerAddress])) {
diff --git a/packages/contracts/util/bignumber_config.ts b/packages/contracts/util/bignumber_config.ts
deleted file mode 100644
index 38f59d341..000000000
--- a/packages/contracts/util/bignumber_config.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import {BigNumber} from 'bignumber.js';
-
-export const bigNumberConfigs = {
- configure() {
- // By default BigNumber's `toString` method converts to exponential notation if the value has
- // more then 20 digits. We want to avoid this behavior, so we set EXPONENTIAL_AT to a high number
- BigNumber.config({
- EXPONENTIAL_AT: 1000,
- });
- },
-};
diff --git a/packages/contracts/util/constants.ts b/packages/contracts/util/constants.ts
index 5beebc68c..e61b2f802 100644
--- a/packages/contracts/util/constants.ts
+++ b/packages/contracts/util/constants.ts
@@ -1,4 +1,9 @@
export const constants = {
NULL_BYTES: '0x',
INVALID_OPCODE: 'invalid opcode',
+ REVERT: 'revert',
+ TESTRPC_NETWORK_ID: 50,
+ MAX_ETHERTOKEN_WITHDRAW_GAS: 43000,
+ MAX_TOKEN_TRANSFERFROM_GAS: 80000,
+ MAX_TOKEN_APPROVE_GAS: 60000,
};
diff --git a/packages/contracts/util/crypto.ts b/packages/contracts/util/crypto.ts
index 5253b8c15..9173df643 100644
--- a/packages/contracts/util/crypto.ts
+++ b/packages/contracts/util/crypto.ts
@@ -1,4 +1,3 @@
-import {BigNumber} from 'bignumber.js';
import BN = require('bn.js');
import ABI = require('ethereumjs-abi');
import ethUtil = require('ethereumjs-util');
@@ -19,14 +18,14 @@ export const crypto = {
const isNumber = _.isFinite(arg);
if (isNumber) {
argTypes.push('uint8');
- } else if ((arg).isBigNumber) {
+ } else if (arg.isBigNumber) {
argTypes.push('uint256');
args[i] = new BN(arg.toString(10), 10);
} else if (ethUtil.isValidAddress(arg)) {
argTypes.push('address');
} else if (_.isString(arg)) {
argTypes.push('string');
- } else if (_.isBoolean(arg)) {
+ } else if (_.isBoolean(arg)) {
argTypes.push('bool');
} else {
throw new Error(`Unable to guess arg type: ${arg}`);
diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts
index 304dcdacf..ca79f92c4 100644
--- a/packages/contracts/util/exchange_wrapper.ts
+++ b/packages/contracts/util/exchange_wrapper.ts
@@ -1,23 +1,26 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import {formatters} from './formatters';
-import {Order} from './order';
-import {ContractInstance} from './types';
+import { formatters } from './formatters';
+import { Order } from './order';
+import { ContractInstance } from './types';
export class ExchangeWrapper {
- private exchange: ContractInstance;
+ private _exchange: ContractInstance;
constructor(exchangeContractInstance: ContractInstance) {
- this.exchange = exchangeContractInstance;
+ this._exchange = exchangeContractInstance;
}
- public async fillOrderAsync(order: Order, from: string,
- opts: {
- fillTakerTokenAmount?: BigNumber;
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
- } = {}) {
+ public async fillOrderAsync(
+ order: Order,
+ from: string,
+ opts: {
+ fillTakerTokenAmount?: BigNumber;
+ shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
+ } = {},
+ ) {
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
- const tx = await this.exchange.fillOrder(
+ const tx = await this._exchange.fillOrder(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
@@ -25,48 +28,52 @@ export class ExchangeWrapper {
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async cancelOrderAsync(order: Order, from: string,
- opts: {cancelTakerTokenAmount?: BigNumber} = {}) {
+ public async cancelOrderAsync(order: Order, from: string, opts: { cancelTakerTokenAmount?: BigNumber } = {}) {
const params = order.createCancel(opts.cancelTakerTokenAmount);
- const tx = await this.exchange.cancelOrder(
+ const tx = await this._exchange.cancelOrder(
params.orderAddresses,
params.orderValues,
params.cancelTakerTokenAmount,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async fillOrKillOrderAsync(order: Order, from: string,
- opts: {fillTakerTokenAmount?: BigNumber} = {}) {
+ public async fillOrKillOrderAsync(order: Order, from: string, opts: { fillTakerTokenAmount?: BigNumber } = {}) {
const shouldThrowOnInsufficientBalanceOrAllowance = true;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
- const tx = await this.exchange.fillOrKillOrder(
+ const tx = await this._exchange.fillOrKillOrder(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async batchFillOrdersAsync(orders: Order[], from: string,
- opts: {
- fillTakerTokenAmounts?: BigNumber[];
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
- } = {}) {
+ public async batchFillOrdersAsync(
+ orders: Order[],
+ from: string,
+ opts: {
+ fillTakerTokenAmounts?: BigNumber[];
+ shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
+ } = {},
+ ) {
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
const params = formatters.createBatchFill(
- orders, shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmounts);
- const tx = await this.exchange.batchFillOrders(
+ orders,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ opts.fillTakerTokenAmounts,
+ );
+ const tx = await this._exchange.batchFillOrders(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmounts,
@@ -74,36 +81,44 @@ export class ExchangeWrapper {
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async batchFillOrKillOrdersAsync(orders: Order[], from: string,
- opts: {fillTakerTokenAmounts?: BigNumber[]} = {}) {
+ public async batchFillOrKillOrdersAsync(
+ orders: Order[],
+ from: string,
+ opts: { fillTakerTokenAmounts?: BigNumber[] } = {},
+ ) {
const params = formatters.createBatchFill(orders, undefined, opts.fillTakerTokenAmounts);
- const tx = await this.exchange.batchFillOrKillOrders(
+ const tx = await this._exchange.batchFillOrKillOrders(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmounts,
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async fillOrdersUpToAsync(orders: Order[], from: string,
- opts: {
- fillTakerTokenAmount?: BigNumber;
- shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
- } = {}) {
+ public async fillOrdersUpToAsync(
+ orders: Order[],
+ from: string,
+ opts: {
+ fillTakerTokenAmount?: BigNumber;
+ shouldThrowOnInsufficientBalanceOrAllowance?: boolean;
+ } = {},
+ ) {
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
- const params = formatters.createFillUpTo(orders,
- shouldThrowOnInsufficientBalanceOrAllowance,
- opts.fillTakerTokenAmount);
- const tx = await this.exchange.fillOrdersUpTo(
+ const params = formatters.createFillUpTo(
+ orders,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ opts.fillTakerTokenAmount,
+ );
+ const tx = await this._exchange.fillOrdersUpTo(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
@@ -111,19 +126,22 @@ export class ExchangeWrapper {
params.v,
params.r,
params.s,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async batchCancelOrdersAsync(orders: Order[], from: string,
- opts: {cancelTakerTokenAmounts?: BigNumber[]} = {}) {
+ public async batchCancelOrdersAsync(
+ orders: Order[],
+ from: string,
+ opts: { cancelTakerTokenAmounts?: BigNumber[] } = {},
+ ) {
const params = formatters.createBatchCancel(orders, opts.cancelTakerTokenAmounts);
- const tx = await this.exchange.batchCancelOrders(
+ const tx = await this._exchange.batchCancelOrders(
params.orderAddresses,
params.orderValues,
params.cancelTakerTokenAmounts,
- {from},
+ { from },
);
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
@@ -131,11 +149,11 @@ export class ExchangeWrapper {
public async getOrderHashAsync(order: Order): Promise<string> {
const shouldThrowOnInsufficientBalanceOrAllowance = false;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance);
- const orderHash = await this.exchange.getOrderHash(params.orderAddresses, params.orderValues);
+ const orderHash = await this._exchange.getOrderHash(params.orderAddresses, params.orderValues);
return orderHash;
}
public async isValidSignatureAsync(order: Order): Promise<boolean> {
- const isValidSignature = await this.exchange.isValidSignature(
+ const isValidSignature = await this._exchange.isValidSignature(
order.params.maker,
order.params.orderHashHex,
order.params.v,
@@ -144,14 +162,20 @@ export class ExchangeWrapper {
);
return isValidSignature;
}
- public async isRoundingErrorAsync(numerator: BigNumber, denominator: BigNumber,
- target: BigNumber): Promise<boolean> {
- const isRoundingError = await this.exchange.isRoundingError(numerator, denominator, target);
+ public async isRoundingErrorAsync(
+ numerator: BigNumber,
+ denominator: BigNumber,
+ target: BigNumber,
+ ): Promise<boolean> {
+ const isRoundingError = await this._exchange.isRoundingError(numerator, denominator, target);
return isRoundingError;
}
- public async getPartialAmountAsync(numerator: BigNumber, denominator: BigNumber,
- target: BigNumber): Promise<BigNumber> {
- const partialAmount = new BigNumber(await this.exchange.getPartialAmount(numerator, denominator, target));
+ public async getPartialAmountAsync(
+ numerator: BigNumber,
+ denominator: BigNumber,
+ target: BigNumber,
+ ): Promise<BigNumber> {
+ const partialAmount = new BigNumber(await this._exchange.getPartialAmount(numerator, denominator, target));
return partialAmount;
}
}
diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts
index 0ad44481a..0d0ef6df4 100644
--- a/packages/contracts/util/formatters.ts
+++ b/packages/contracts/util/formatters.ts
@@ -1,13 +1,15 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import {Order} from './order';
-import {BatchCancelOrders, BatchFillOrders, FillOrdersUpTo} from './types';
+import { Order } from './order';
+import { BatchCancelOrders, BatchFillOrders, FillOrdersUpTo } from './types';
export const formatters = {
- createBatchFill(orders: Order[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- fillTakerTokenAmounts: BigNumber[] = []) {
+ createBatchFill(
+ orders: Order[],
+ shouldThrowOnInsufficientBalanceOrAllowance: boolean,
+ fillTakerTokenAmounts: BigNumber[] = [],
+ ) {
const batchFill: BatchFillOrders = {
orderAddresses: [],
orderValues: [],
@@ -18,11 +20,21 @@ export const formatters = {
s: [],
};
_.forEach(orders, order => {
- batchFill.orderAddresses.push([order.params.maker, order.params.taker, order.params.makerToken,
- order.params.takerToken, order.params.feeRecipient]);
- batchFill.orderValues.push([order.params.makerTokenAmount, order.params.takerTokenAmount,
- order.params.makerFee, order.params.takerFee,
- order.params.expirationTimestampInSec, order.params.salt]);
+ batchFill.orderAddresses.push([
+ order.params.maker,
+ order.params.taker,
+ order.params.makerToken,
+ order.params.takerToken,
+ order.params.feeRecipient,
+ ]);
+ batchFill.orderValues.push([
+ order.params.makerTokenAmount,
+ order.params.takerTokenAmount,
+ order.params.makerFee,
+ order.params.takerFee,
+ order.params.expirationTimestampInSec,
+ order.params.salt,
+ ]);
batchFill.v.push(order.params.v);
batchFill.r.push(order.params.r);
batchFill.s.push(order.params.s);
@@ -32,9 +44,11 @@ export const formatters = {
});
return batchFill;
},
- createFillUpTo(orders: Order[],
- shouldThrowOnInsufficientBalanceOrAllowance: boolean,
- fillTakerTokenAmount: BigNumber) {
+ createFillUpTo(
+ orders: Order[],
+ shouldThrowOnInsufficientBalanceOrAllowance: boolean,
+ fillTakerTokenAmount: BigNumber,
+ ) {
const fillUpTo: FillOrdersUpTo = {
orderAddresses: [],
orderValues: [],
@@ -45,11 +59,21 @@ export const formatters = {
s: [],
};
orders.forEach(order => {
- fillUpTo.orderAddresses.push([order.params.maker, order.params.taker, order.params.makerToken,
- order.params.takerToken, order.params.feeRecipient]);
- fillUpTo.orderValues.push([order.params.makerTokenAmount, order.params.takerTokenAmount,
- order.params.makerFee, order.params.takerFee,
- order.params.expirationTimestampInSec, order.params.salt]);
+ fillUpTo.orderAddresses.push([
+ order.params.maker,
+ order.params.taker,
+ order.params.makerToken,
+ order.params.takerToken,
+ order.params.feeRecipient,
+ ]);
+ fillUpTo.orderValues.push([
+ order.params.makerTokenAmount,
+ order.params.takerTokenAmount,
+ order.params.makerFee,
+ order.params.takerFee,
+ order.params.expirationTimestampInSec,
+ order.params.salt,
+ ]);
fillUpTo.v.push(order.params.v);
fillUpTo.r.push(order.params.r);
fillUpTo.s.push(order.params.s);
@@ -63,11 +87,21 @@ export const formatters = {
cancelTakerTokenAmounts,
};
orders.forEach(order => {
- batchCancel.orderAddresses.push([order.params.maker, order.params.taker, order.params.makerToken,
- order.params.takerToken, order.params.feeRecipient]);
- batchCancel.orderValues.push([order.params.makerTokenAmount, order.params.takerTokenAmount,
- order.params.makerFee, order.params.takerFee,
- order.params.expirationTimestampInSec, order.params.salt]);
+ batchCancel.orderAddresses.push([
+ order.params.maker,
+ order.params.taker,
+ order.params.makerToken,
+ order.params.takerToken,
+ order.params.feeRecipient,
+ ]);
+ batchCancel.orderValues.push([
+ order.params.makerTokenAmount,
+ order.params.takerTokenAmount,
+ order.params.makerFee,
+ order.params.takerFee,
+ order.params.expirationTimestampInSec,
+ order.params.salt,
+ ]);
if (cancelTakerTokenAmounts.length < orders.length) {
batchCancel.cancelTakerTokenAmounts.push(order.params.takerTokenAmount);
}
diff --git a/packages/contracts/util/multi_sig_wrapper.ts b/packages/contracts/util/multi_sig_wrapper.ts
index 4ad970ac9..0e2e671ec 100644
--- a/packages/contracts/util/multi_sig_wrapper.ts
+++ b/packages/contracts/util/multi_sig_wrapper.ts
@@ -3,12 +3,12 @@ import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import * as Web3 from 'web3';
-import {ContractInstance, TransactionDataParams} from './types';
+import { ContractInstance, TransactionDataParams } from './types';
export class MultiSigWrapper {
- private multiSig: ContractInstance;
+ private _multiSig: ContractInstance;
public static encodeFnArgs(name: string, abi: Web3.AbiDefinition[], args: any[]) {
- const abiEntity = _.find(abi, {name}) as Web3.MethodAbi;
+ const abiEntity = _.find(abi, { name }) as Web3.MethodAbi;
if (_.isUndefined(abiEntity)) {
throw new Error(`Did not find abi entry for name: ${name}`);
}
@@ -22,13 +22,18 @@ export class MultiSigWrapper {
return funcSig + argsData.join('');
}
constructor(multiSigContractInstance: ContractInstance) {
- this.multiSig = multiSigContractInstance;
+ this._multiSig = multiSigContractInstance;
}
- public async submitTransactionAsync(destination: string, from: string,
- dataParams: TransactionDataParams,
- value: number = 0) {
- const {name, abi, args = []} = dataParams;
+ public async submitTransactionAsync(
+ destination: string,
+ from: string,
+ dataParams: TransactionDataParams,
+ value: number = 0,
+ ) {
+ const { name, abi, args = [] } = dataParams;
const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args);
- return this.multiSig.submitTransaction(destination, value, encoded, {from});
+ return this._multiSig.submitTransaction(destination, value, encoded, {
+ from,
+ });
}
}
diff --git a/packages/contracts/util/order.ts b/packages/contracts/util/order.ts
index ec5362b66..e202d485b 100644
--- a/packages/contracts/util/order.ts
+++ b/packages/contracts/util/order.ts
@@ -1,11 +1,10 @@
-import {promisify} from '@0xproject/utils';
-import {BigNumber} from 'bignumber.js';
+import { BigNumber, promisify } from '@0xproject/utils';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import Web3 = require('web3');
-import {crypto} from './crypto';
-import {OrderParams} from './types';
+import { crypto } from './crypto';
+import { OrderParams } from './types';
// In order to benefit from type-safety, we re-assign the global web3 instance injected by Truffle
// with type `any` to a variable of type `Web3`.
@@ -17,11 +16,11 @@ export class Order {
this.params = params;
}
public isValidSignature() {
- const {v, r, s} = this.params;
+ const { v, r, s } = this.params;
if (_.isUndefined(v) || _.isUndefined(r) || _.isUndefined(s)) {
throw new Error('Cannot call isValidSignature on unsigned order');
}
- const orderHash = this.getOrderHash();
+ const orderHash = this._getOrderHash();
const msgHash = ethUtil.hashPersonalMessage(ethUtil.toBuffer(orderHash));
try {
const pubKey = ethUtil.ecrecover(msgHash, v, ethUtil.toBuffer(r), ethUtil.toBuffer(s));
@@ -32,9 +31,9 @@ export class Order {
}
}
public async signAsync() {
- const orderHash = this.getOrderHash();
+ const orderHash = this._getOrderHash();
const signature = await promisify<string>(web3.eth.sign)(this.params.maker, orderHash);
- const {v, r, s} = ethUtil.fromRpcSig(signature);
+ const { v, r, s } = ethUtil.fromRpcSig(signature);
this.params = _.assign(this.params, {
orderHashHex: orderHash,
v,
@@ -88,7 +87,7 @@ export class Order {
};
return cancel;
}
- private getOrderHash(): string {
+ private _getOrderHash(): string {
const orderHash = crypto.solSHA3([
this.params.exchangeContractAddress,
this.params.maker,
diff --git a/packages/contracts/util/order_factory.ts b/packages/contracts/util/order_factory.ts
index 526e229a4..a45877de0 100644
--- a/packages/contracts/util/order_factory.ts
+++ b/packages/contracts/util/order_factory.ts
@@ -1,22 +1,27 @@
-import {ZeroEx} from '0x.js';
-import {BigNumber} from 'bignumber.js';
+import { ZeroEx } from '0x.js';
+import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import {Order} from './order';
-import {DefaultOrderParams, OptionalOrderParams, OrderParams} from './types';
+import { Order } from './order';
+import { DefaultOrderParams, OptionalOrderParams, OrderParams } from './types';
export class OrderFactory {
- private defaultOrderParams: DefaultOrderParams;
+ private _defaultOrderParams: DefaultOrderParams;
constructor(defaultOrderParams: DefaultOrderParams) {
- this.defaultOrderParams = defaultOrderParams;
+ this._defaultOrderParams = defaultOrderParams;
}
public async newSignedOrderAsync(customOrderParams: OptionalOrderParams = {}) {
- const randomExpiration = new BigNumber(Math.floor((Date.now() + (Math.random() * 100000000000)) / 1000));
- const orderParams: OrderParams = _.assign({}, {
- expirationTimestampInSec: randomExpiration,
- salt: ZeroEx.generatePseudoRandomSalt(),
- taker: ZeroEx.NULL_ADDRESS,
- }, this.defaultOrderParams, customOrderParams);
+ const randomExpiration = new BigNumber(Math.floor((Date.now() + Math.random() * 100000000000) / 1000));
+ const orderParams: OrderParams = _.assign(
+ {},
+ {
+ expirationTimestampInSec: randomExpiration,
+ salt: ZeroEx.generatePseudoRandomSalt(),
+ taker: ZeroEx.NULL_ADDRESS,
+ },
+ this._defaultOrderParams,
+ customOrderParams,
+ );
const order = new Order(orderParams);
await order.signAsync();
return order;
diff --git a/packages/contracts/util/rpc.ts b/packages/contracts/util/rpc.ts
deleted file mode 100644
index 023602bd6..000000000
--- a/packages/contracts/util/rpc.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import 'isomorphic-fetch';
-
-import * as truffleConf from '../truffle.js';
-
-export class RPC {
- private host: string;
- private port: number;
- private id: number;
- constructor() {
- this.host = truffleConf.networks.development.host;
- this.port = truffleConf.networks.development.port;
- this.id = 0;
- }
- public async increaseTimeAsync(time: number) {
- const method = 'evm_increaseTime';
- const params = [time];
- const payload = this.toPayload(method, params);
- return this.sendAsync(payload);
- }
- public async mineBlockAsync() {
- const method = 'evm_mine';
- const payload = this.toPayload(method);
- return this.sendAsync(payload);
- }
- private toPayload(method: string, params: any[] = []) {
- const payload = JSON.stringify({
- id: this.id,
- method,
- params,
- });
- this.id++;
- return payload;
- }
- private async sendAsync(payload: string): Promise<any> {
- const opts = {
- method: 'POST',
- body: payload,
- };
- const response = await fetch(`http://${this.host}:${this.port}`, opts);
- const responsePayload = await response.json();
- return responsePayload;
- }
-}
diff --git a/packages/contracts/util/token_registry_wrapper.ts b/packages/contracts/util/token_registry_wrapper.ts
index 5e1c627cc..07a577dea 100644
--- a/packages/contracts/util/token_registry_wrapper.ts
+++ b/packages/contracts/util/token_registry_wrapper.ts
@@ -1,24 +1,24 @@
-import {ContractInstance, Token} from './types';
+import { ContractInstance, Token } from './types';
export class TokenRegWrapper {
- private tokenReg: ContractInstance;
+ private _tokenReg: ContractInstance;
constructor(tokenRegContractInstance: ContractInstance) {
- this.tokenReg = tokenRegContractInstance;
+ this._tokenReg = tokenRegContractInstance;
}
public addTokenAsync(token: Token, from: string) {
- const tx = this.tokenReg.addToken(
+ const tx = this._tokenReg.addToken(
token.address,
token.name,
token.symbol,
token.decimals,
token.ipfsHash,
token.swarmHash,
- {from},
+ { from },
);
return tx;
}
public async getTokenMetaDataAsync(tokenAddress: string) {
- const data = await this.tokenReg.getTokenMetaData(tokenAddress);
+ const data = await this._tokenReg.getTokenMetaData(tokenAddress);
const token: Token = {
address: data[0],
name: data[1],
@@ -30,7 +30,7 @@ export class TokenRegWrapper {
return token;
}
public async getTokenByNameAsync(tokenName: string) {
- const data = await this.tokenReg.getTokenByName(tokenName);
+ const data = await this._tokenReg.getTokenByName(tokenName);
const token: Token = {
address: data[0],
name: data[1],
@@ -42,7 +42,7 @@ export class TokenRegWrapper {
return token;
}
public async getTokenBySymbolAsync(tokenSymbol: string) {
- const data = await this.tokenReg.getTokenBySymbol(tokenSymbol);
+ const data = await this._tokenReg.getTokenBySymbol(tokenSymbol);
const token: Token = {
address: data[0],
name: data[1],
diff --git a/packages/contracts/util/types.ts b/packages/contracts/util/types.ts
index b2cf786df..e511ca9f4 100644
--- a/packages/contracts/util/types.ts
+++ b/packages/contracts/util/types.ts
@@ -1,4 +1,4 @@
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
import * as Web3 from 'web3';
export interface BalancesByOwner {
@@ -84,15 +84,6 @@ export interface TransactionDataParams {
args: any[];
}
-export interface Token {
- address?: string;
- name: string;
- symbol: string;
- decimals: number;
- ipfsHash: string;
- swarmHash: string;
-}
-
export interface MultiSigConfig {
owners: string[];
confirmationsRequired: number;
@@ -103,6 +94,15 @@ export interface MultiSigConfigByNetwork {
[networkName: string]: MultiSigConfig;
}
+export interface Token {
+ address?: string;
+ name: string;
+ symbol: string;
+ decimals: number;
+ ipfsHash: string;
+ swarmHash: string;
+}
+
export interface TokenInfoByNetwork {
development: Token[];
live: Token[];
diff --git a/packages/deployer/README.md b/packages/deployer/README.md
new file mode 100644
index 000000000..4293f82d4
--- /dev/null
+++ b/packages/deployer/README.md
@@ -0,0 +1,73 @@
+## @0xproject/deployer
+
+This repository contains a CLI tool that facilitates compiling and deployment of smart contracts.
+
+## Installation
+
+```bash
+yarn add @0xproject/deployer
+```
+
+## Usage
+
+```bash
+node ./node_modules/@0xproject/deployer/lib/cli.js --help
+cli.js [command]
+
+Commands:
+ cli.js compile compile contracts
+ cli.js migrate compile and deploy contracts using migration scripts
+ cli.js deploy deploy a single contract with provided arguments
+
+Options:
+ --version Show version number [boolean]
+ --contracts-dir path of contracts directory to compile
+ [string] [default: "/Users/leonidlogvinov/Dev/0x/0x.js/contracts"]
+ --network-id mainnet=1, kovan=42, testrpc=50 [number] [default: 50]
+ --should-optimize enable optimizer [boolean] [default: false]
+ --artifacts-dir path to write contracts artifacts to
+ [string] [default: "/Users/leonidlogvinov/Dev/0x/0x.js/build/artifacts/"]
+ --jsonrpc-port port connected to JSON RPC [number] [default: 8545]
+ --gas-price gasPrice to be used for transactions
+ [string] [default: "2000000000"]
+ --account account to use for deploying contracts [string]
+ --help Show help [boolean]
+```
+
+## Contributing
+
+We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install Dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Build
+
+```bash
+yarn build
+```
+
+### Lint
+
+```bash
+yarn lint
+```
+
+### Run Tests
+
+```bash
+yarn test
+```
diff --git a/packages/deployer/package.json b/packages/deployer/package.json
new file mode 100644
index 000000000..1ae0ca227
--- /dev/null
+++ b/packages/deployer/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "@0xproject/deployer",
+ "version": "0.0.2",
+ "description": "Smart contract deployer of 0x protocol",
+ "main": "lib/src/cli.js",
+ "scripts": {
+ "build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' src/solc/solc_bin/* ./lib && tsc",
+ "test": "npm run build; mocha lib/test/*_test.js",
+ "compile": "npm run build; node lib/src/cli.js compile",
+ "clean": "rm -rf ./lib",
+ "migrate": "npm run build; node lib/src/cli.js migrate",
+ "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
+ "test:circleci": "yarn test"
+ },
+ "bin": {
+ "0x-deployer": "lib/src/cli.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/0xProject/0x.js.git"
+ },
+ "author": "Amir Bandeali",
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/0x.js/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x.js/packages/deployer/README.md",
+ "devDependencies": {
+ "copyfiles": "^1.2.0",
+ "types-bn": "^0.0.1",
+ "typescript": "~2.6.1",
+ "web3-typescript-typings": "^0.9.5"
+ },
+ "dependencies": {
+ "@0xproject/utils": "^0.1.3",
+ "@0xproject/web3-wrapper": "^0.1.6",
+ "lodash": "^4.17.4",
+ "solc": "^0.4.18",
+ "web3": "^0.20.0",
+ "web3-eth-abi": "^1.0.0-beta.24",
+ "yargs": "^10.0.3"
+ }
+}
diff --git a/packages/deployer/scripts/postpublish.js b/packages/deployer/scripts/postpublish.js
new file mode 100644
index 000000000..24384b228
--- /dev/null
+++ b/packages/deployer/scripts/postpublish.js
@@ -0,0 +1,39 @@
+const execAsync = require('async-child-process').execAsync;
+const postpublish_utils = require('../../../scripts/postpublish_utils');
+const packageJSON = require('../package.json');
+
+const cwd = __dirname + '/..';
+const subPackageName = packageJSON.name;
+const S3BucketPath = 's3://connect-docs-jsons/';
+
+let tag;
+let version;
+postpublish_utils
+ .getLatestTagAndVersionAsync(subPackageName)
+ .then(function(result) {
+ tag = result.tag;
+ version = result.version;
+ const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
+ return postpublish_utils.publishReleaseNotes(tag, releaseName);
+ })
+ .then(function(release) {
+ console.log('POSTPUBLISH: Release successful, generating docs...');
+ const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
+ return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json', {
+ cwd,
+ });
+ })
+ .then(function(result) {
+ if (result.stderr !== '') {
+ throw new Error(result.stderr);
+ }
+ const fileName = 'v' + version + '.json';
+ console.log('POSTPUBLISH: Doc generation successful, uploading docs... as ', fileName);
+ const s3Url = S3BucketPath + fileName;
+ return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
+ cwd,
+ });
+ })
+ .catch(function(err) {
+ throw err;
+ });
diff --git a/packages/contracts/deploy/cli.ts b/packages/deployer/src/cli.ts
index 423523e21..decb37fdc 100644
--- a/packages/contracts/deploy/cli.ts
+++ b/packages/deployer/src/cli.ts
@@ -1,34 +1,30 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import {BigNumber} from 'bignumber.js';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import * as path from 'path';
import * as Web3 from 'web3';
import * as yargs from 'yargs';
-import {commands} from './src/commands';
-import {
- CliOptions,
- CompilerOptions,
- DeployerOptions,
-} from './src/utils/types';
+import { commands } from './commands';
+import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types';
const DEFAULT_OPTIMIZER_ENABLED = false;
const DEFAULT_CONTRACTS_DIR = path.resolve('contracts');
const DEFAULT_ARTIFACTS_DIR = `${path.resolve('build')}/artifacts/`;
const DEFAULT_NETWORK_ID = 50;
const DEFAULT_JSONRPC_PORT = 8545;
-const DEFAULT_GAS_PRICE = ((10 ** 9) * 2).toString();
+const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString();
/**
* Compiles all contracts with options passed in through CLI.
* @param argv Instance of process.argv provided by yargs.
*/
-async function onCompileCommand(args: CliOptions): Promise<void> {
+async function onCompileCommand(argv: CliOptions): Promise<void> {
const opts: CompilerOptions = {
- contractsDir: args.contractsDir,
- networkId: args.networkId,
- optimizerEnabled: args.shouldOptimize ? 1 : 0,
- artifactsDir: args.artifactsDir,
+ contractsDir: argv.contractsDir,
+ networkId: argv.networkId,
+ optimizerEnabled: argv.shouldOptimize ? 1 : 0,
+ artifactsDir: argv.artifactsDir,
};
await commands.compileAsync(opts);
}
@@ -108,11 +104,11 @@ function deployCommandBuilder(yargsInstance: any) {
description: 'comma separated list of constructor args to deploy contract with',
})
.demandOption(['contract', 'args'])
- .help()
- .argv;
+ .help().argv;
}
(() => {
+ const identityCommandBuilder = _.identity;
return yargs
.option('contracts-dir', {
type: 'string',
@@ -148,18 +144,13 @@ function deployCommandBuilder(yargsInstance: any) {
type: 'string',
description: 'account to use for deploying contracts',
})
- .command('compile',
- 'compile contracts',
- _.noop,
- onCompileCommand)
- .command('migrate',
- 'compile and deploy contracts using migration scripts',
- _.noop,
- onMigrateCommand)
- .command('deploy',
- 'deploy a single contract with provided arguments',
- deployCommandBuilder,
- onDeployCommand)
- .help()
- .argv;
+ .command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand)
+ .command(
+ 'migrate',
+ 'compile and deploy contracts using migration scripts',
+ identityCommandBuilder,
+ onMigrateCommand,
+ )
+ .command('deploy', 'deploy a single contract with provided arguments', deployCommandBuilder, onDeployCommand)
+ .help().argv;
})();
diff --git a/packages/contracts/deploy/src/commands.ts b/packages/deployer/src/commands.ts
index fc421a760..2acef8e8f 100644
--- a/packages/contracts/deploy/src/commands.ts
+++ b/packages/deployer/src/commands.ts
@@ -1,7 +1,7 @@
-import {migrator} from './../migrations/migrate';
-import {Compiler} from './compiler';
-import {Deployer} from './deployer';
-import {CompilerOptions, DeployerOptions} from './utils/types';
+import { migrator } from './migrations/migrate';
+import { Compiler } from './compiler';
+import { Deployer } from './deployer';
+import { CompilerOptions, DeployerOptions } from './utils/types';
export const commands = {
async compileAsync(opts: CompilerOptions): Promise<void> {
diff --git a/packages/contracts/deploy/src/compiler.ts b/packages/deployer/src/compiler.ts
index 8a44e94a3..63db6c865 100644
--- a/packages/contracts/deploy/src/compiler.ts
+++ b/packages/deployer/src/compiler.ts
@@ -1,12 +1,11 @@
-import {promisify} from '@0xproject/utils';
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
import * as path from 'path';
import solc = require('solc');
import * as Web3 from 'web3';
-import {binPaths} from './../solc/bin_paths';
-import {fsWrapper} from './utils/fs_wrapper';
+import { binPaths } from './solc/bin_paths';
+import { fsWrapper } from './utils/fs_wrapper';
import {
CompilerOptions,
ContractArtifact,
@@ -14,25 +13,24 @@ import {
ContractNetworks,
ContractSources,
ImportContents,
- SolcErrors,
} from './utils/types';
-import {utils} from './utils/utils';
+import { utils } from './utils/utils';
const SOLIDITY_FILE_EXTENSION = '.sol';
export class Compiler {
- private contractsDir: string;
- private networkId: number;
- private optimizerEnabled: number;
- private artifactsDir: string;
- private contractSourcesIfExists?: ContractSources;
- private solcErrors: Set<string>;
+ private _contractsDir: string;
+ private _networkId: number;
+ private _optimizerEnabled: number;
+ private _artifactsDir: string;
+ private _contractSourcesIfExists?: ContractSources;
+ private _solcErrors: Set<string>;
/**
* Recursively retrieves Solidity source code from directory.
* @param dirPath Directory to search.
* @return Mapping of contract name to contract source.
*/
- private static async getContractSourcesAsync(dirPath: string): Promise<ContractSources> {
+ private static async _getContractSourcesAsync(dirPath: string): Promise<ContractSources> {
let dirContents: string[] = [];
try {
dirContents = await fsWrapper.readdirAsync(dirPath);
@@ -54,7 +52,7 @@ export class Compiler {
}
} else {
try {
- const nestedSources = await Compiler.getContractSourcesAsync(contentPath);
+ const nestedSources = await Compiler._getContractSourcesAsync(contentPath);
sources = {
...sources,
...nestedSources,
@@ -71,7 +69,7 @@ export class Compiler {
* @param source Source code of contract.
* @return Solc compiler version.
*/
- private static parseSolidityVersion(source: string): string {
+ private static _parseSolidityVersion(source: string): string {
const solcVersionMatch = source.match(/(?:solidity\s\^?)([0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,2})/);
if (_.isNull(solcVersionMatch)) {
throw new Error('Could not find Solidity version in source');
@@ -87,7 +85,7 @@ export class Compiler {
* @param errMsg An error message from the compiled output.
* @return The error message with directories truncated from the contract path.
*/
- private static getNormalizedErrMsg(errMsg: string): string {
+ private static _getNormalizedErrMsg(errMsg: string): string {
const errPathMatch = errMsg.match(/(.*\.sol)/);
if (_.isNull(errPathMatch)) {
throw new Error('Could not find a path in error message');
@@ -103,26 +101,25 @@ export class Compiler {
* @return An instance of the Compiler class.
*/
constructor(opts: CompilerOptions) {
- this.contractsDir = opts.contractsDir;
- this.networkId = opts.networkId;
- this.optimizerEnabled = opts.optimizerEnabled;
- this.artifactsDir = opts.artifactsDir;
- this.solcErrors = new Set();
+ this._contractsDir = opts.contractsDir;
+ this._networkId = opts.networkId;
+ this._optimizerEnabled = opts.optimizerEnabled;
+ this._artifactsDir = opts.artifactsDir;
+ this._solcErrors = new Set();
}
/**
* Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir.
*/
public async compileAllAsync(): Promise<void> {
- await this.createArtifactsDirIfDoesNotExistAsync();
- this.contractSourcesIfExists = await Compiler.getContractSourcesAsync(this.contractsDir);
-
- const contractBaseNames = _.keys(this.contractSourcesIfExists);
+ await this._createArtifactsDirIfDoesNotExistAsync();
+ this._contractSourcesIfExists = await Compiler._getContractSourcesAsync(this._contractsDir);
+ const contractBaseNames = _.keys(this._contractSourcesIfExists);
const compiledContractPromises = _.map(contractBaseNames, async (contractBaseName: string): Promise<void> => {
- return this.compileContractAsync(contractBaseName);
+ return this._compileContractAsync(contractBaseName);
});
await Promise.all(compiledContractPromises);
- this.solcErrors.forEach(errMsg => {
+ this._solcErrors.forEach(errMsg => {
utils.consoleLog(errMsg);
});
}
@@ -130,14 +127,14 @@ export class Compiler {
* Compiles contract and saves artifact to artifactsDir.
* @param contractBaseName Name of contract with '.sol' extension.
*/
- private async compileContractAsync(contractBaseName: string): Promise<void> {
- if (_.isUndefined(this.contractSourcesIfExists)) {
+ private async _compileContractAsync(contractBaseName: string): Promise<void> {
+ if (_.isUndefined(this._contractSourcesIfExists)) {
throw new Error('Contract sources not yet initialized');
}
- const source = this.contractSourcesIfExists[contractBaseName];
+ const source = this._contractSourcesIfExists[contractBaseName];
const contractName = path.basename(contractBaseName, SOLIDITY_FILE_EXTENSION);
- const currentArtifactPath = `${this.artifactsDir}/${contractName}.json`;
+ const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`;
let currentArtifactString: string;
@@ -151,10 +148,11 @@ export class Compiler {
currentArtifactString = await fsWrapper.readFileAsync(currentArtifactPath, opts);
currentArtifact = JSON.parse(currentArtifactString);
oldNetworks = currentArtifact.networks;
- const oldNetwork: ContractData = oldNetworks[this.networkId];
- shouldCompile = _.isUndefined(oldNetwork) ||
- oldNetwork.keccak256 !== sourceHash ||
- oldNetwork.optimizer_enabled !== this.optimizerEnabled;
+ const oldNetwork: ContractData = oldNetworks[this._networkId];
+ shouldCompile =
+ _.isUndefined(oldNetwork) ||
+ oldNetwork.keccak256 !== sourceHash ||
+ oldNetwork.optimizer_enabled !== this._optimizerEnabled;
} catch (err) {
shouldCompile = true;
}
@@ -166,9 +164,9 @@ export class Compiler {
const input = {
[contractBaseName]: source,
};
- const solcVersion = Compiler.parseSolidityVersion(source);
+ const solcVersion = Compiler._parseSolidityVersion(source);
const fullSolcVersion = binPaths[solcVersion];
- const solcBinPath = `./../solc/solc_bin/${fullSolcVersion}`;
+ const solcBinPath = `./solc/solc_bin/${fullSolcVersion}`;
const solcBin = require(solcBinPath);
const solcInstance = solc.setupMethods(solcBin);
@@ -176,14 +174,16 @@ export class Compiler {
const sourcesToCompile = {
sources: input,
};
- const compiled = solcInstance.compile(sourcesToCompile,
- this.optimizerEnabled,
- this.findImportsIfSourcesExist.bind(this));
+ const compiled = solcInstance.compile(
+ sourcesToCompile,
+ this._optimizerEnabled,
+ this._findImportsIfSourcesExist.bind(this),
+ );
if (!_.isUndefined(compiled.errors)) {
_.each(compiled.errors, errMsg => {
- const normalizedErrMsg = Compiler.getNormalizedErrMsg(errMsg);
- this.solcErrors.add(normalizedErrMsg);
+ const normalizedErrMsg = Compiler._getNormalizedErrMsg(errMsg);
+ this._solcErrors.add(normalizedErrMsg);
});
}
@@ -194,7 +194,7 @@ export class Compiler {
const contractData: ContractData = {
solc_version: solcVersion,
keccak256: sourceHash,
- optimizer_enabled: this.optimizerEnabled,
+ optimizer_enabled: this._optimizerEnabled,
abi,
unlinked_binary,
updated_at,
@@ -206,14 +206,14 @@ export class Compiler {
...currentArtifact,
networks: {
...oldNetworks,
- [this.networkId]: contractData,
+ [this._networkId]: contractData,
},
};
} else {
newArtifact = {
contract_name: contractName,
networks: {
- [this.networkId]: contractData,
+ [this._networkId]: contractData,
},
};
}
@@ -228,12 +228,12 @@ export class Compiler {
* @param importPath Path to an imported dependency.
* @return Import contents object containing source code of dependency.
*/
- private findImportsIfSourcesExist(importPath: string): ImportContents {
- if (_.isUndefined(this.contractSourcesIfExists)) {
+ private _findImportsIfSourcesExist(importPath: string): ImportContents {
+ if (_.isUndefined(this._contractSourcesIfExists)) {
throw new Error('Contract sources not yet initialized');
}
const contractBaseName = path.basename(importPath);
- const source = this.contractSourcesIfExists[contractBaseName];
+ const source = this._contractSourcesIfExists[contractBaseName];
const importContents: ImportContents = {
contents: source,
};
@@ -242,10 +242,10 @@ export class Compiler {
/**
* Creates the artifacts directory if it does not already exist.
*/
- private async createArtifactsDirIfDoesNotExistAsync(): Promise<void> {
- if (!fsWrapper.doesPathExistSync(this.artifactsDir)) {
+ private async _createArtifactsDirIfDoesNotExistAsync(): Promise<void> {
+ if (!fsWrapper.doesPathExistSync(this._artifactsDir)) {
utils.consoleLog('Creating artifacts directory...');
- await fsWrapper.mkdirAsync(this.artifactsDir);
+ await fsWrapper.mkdirAsync(this._artifactsDir);
}
}
}
diff --git a/packages/contracts/deploy/src/deployer.ts b/packages/deployer/src/deployer.ts
index 4c8018ecc..6f03581e8 100644
--- a/packages/contracts/deploy/src/deployer.ts
+++ b/packages/deployer/src/deployer.ts
@@ -1,37 +1,32 @@
-import {TxData} from '@0xproject/types';
-import {promisify} from '@0xproject/utils';
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
+import { TxData } from '@0xproject/types';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import * as Web3 from 'web3';
-import {Contract} from './utils/contract';
-import {encoder} from './utils/encoder';
-import {fsWrapper} from './utils/fs_wrapper';
-import {
- ContractArtifact,
- ContractData,
- DeployerOptions,
-} from './utils/types';
-import {utils} from './utils/utils';
+import { Contract } from './utils/contract';
+import { encoder } from './utils/encoder';
+import { fsWrapper } from './utils/fs_wrapper';
+import { ContractArtifact, ContractData, DeployerOptions } from './utils/types';
+import { utils } from './utils/utils';
// Gas added to gas estimate to make sure there is sufficient gas for deployment.
const EXTRA_GAS = 200000;
export class Deployer {
public web3Wrapper: Web3Wrapper;
- private artifactsDir: string;
- private jsonrpcPort: number;
- private networkId: number;
- private defaults: Partial<TxData>;
+ private _artifactsDir: string;
+ private _jsonrpcPort: number;
+ private _networkId: number;
+ private _defaults: Partial<TxData>;
constructor(opts: DeployerOptions) {
- this.artifactsDir = opts.artifactsDir;
- this.jsonrpcPort = opts.jsonrpcPort;
- this.networkId = opts.networkId;
- const jsonrpcUrl = `http://localhost:${this.jsonrpcPort}`;
+ this._artifactsDir = opts.artifactsDir;
+ this._jsonrpcPort = opts.jsonrpcPort;
+ this._networkId = opts.networkId;
+ const jsonrpcUrl = `http://localhost:${this._jsonrpcPort}`;
const web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl);
- this.defaults = opts.defaults;
- this.web3Wrapper = new Web3Wrapper(web3Provider, this.defaults);
+ this._defaults = opts.defaults;
+ this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults);
}
/**
* Loads contract artifact and deploys contract with given arguments.
@@ -40,21 +35,21 @@ export class Deployer {
* @return Deployed contract instance.
*/
public async deployAsync(contractName: string, args: any[] = []): Promise<Web3.ContractInstance> {
- const contractArtifact: ContractArtifact = this.loadContractArtifactIfExists(contractName);
- const contractData: ContractData = this.getContractDataFromArtifactIfExists(contractArtifact);
+ const contractArtifact: ContractArtifact = this._loadContractArtifactIfExists(contractName);
+ const contractData: ContractData = this._getContractDataFromArtifactIfExists(contractArtifact);
const data = contractData.unlinked_binary;
- const from = await this.getFromAddressAsync();
- const gas = await this.getAllowableGasEstimateAsync(data);
+ const from = await this._getFromAddressAsync();
+ const gas = await this._getAllowableGasEstimateAsync(data);
const txData = {
- gasPrice: this.defaults.gasPrice,
+ gasPrice: this._defaults.gasPrice,
from,
data,
gas,
};
const abi = contractData.abi;
- const web3ContractInstance = await this.deployFromAbiAsync(abi, args, txData);
+ const web3ContractInstance = await this._deployFromAbiAsync(abi, args, txData);
utils.consoleLog(`${contractName}.sol successfully deployed at ${web3ContractInstance.address}`);
- const contractInstance = new Contract(web3ContractInstance, this.defaults);
+ const contractInstance = new Contract(web3ContractInstance, this._defaults);
return contractInstance;
}
/**
@@ -65,7 +60,7 @@ export class Deployer {
*/
public async deployAndSaveAsync(contractName: string, args: any[] = []): Promise<Web3.ContractInstance> {
const contractInstance = await this.deployAsync(contractName, args);
- await this.saveContractDataToArtifactAsync(contractName, contractInstance.address, args);
+ await this._saveContractDataToArtifactAsync(contractName, contractInstance.address, args);
return contractInstance;
}
/**
@@ -75,7 +70,7 @@ export class Deployer {
* @param txData Tx options used for deployment.
* @return Promise that resolves to a web3 contract instance.
*/
- private async deployFromAbiAsync(abi: Web3.ContractAbi, args: any[], txData: Web3.TxData): Promise<any> {
+ private async _deployFromAbiAsync(abi: Web3.ContractAbi, args: any[], txData: Web3.TxData): Promise<any> {
const contract: Web3.Contract<Web3.ContractInstance> = this.web3Wrapper.getContractFromAbi(abi);
const deployPromise = new Promise((resolve, reject) => {
/**
@@ -100,10 +95,13 @@ export class Deployer {
* @param contractAddress Contract address to save to artifact.
* @param args Contract constructor arguments that will be encoded and saved to artifact.
*/
- private async saveContractDataToArtifactAsync(contractName: string,
- contractAddress: string, args: any[]): Promise<void> {
- const contractArtifact: ContractArtifact = this.loadContractArtifactIfExists(contractName);
- const contractData: ContractData = this.getContractDataFromArtifactIfExists(contractArtifact);
+ private async _saveContractDataToArtifactAsync(
+ contractName: string,
+ contractAddress: string,
+ args: any[],
+ ): Promise<void> {
+ const contractArtifact: ContractArtifact = this._loadContractArtifactIfExists(contractName);
+ const contractData: ContractData = this._getContractDataFromArtifactIfExists(contractArtifact);
const abi = contractData.abi;
const encodedConstructorArgs = encoder.encodeConstructorArgsFromAbi(args, abi);
const newContractData = {
@@ -115,11 +113,11 @@ export class Deployer {
...contractArtifact,
networks: {
...contractArtifact.networks,
- [this.networkId]: newContractData,
+ [this._networkId]: newContractData,
},
};
const artifactString = utils.stringifyWithFormatting(newArtifact);
- const artifactPath = `${this.artifactsDir}/${contractName}.json`;
+ const artifactPath = `${this._artifactsDir}/${contractName}.json`;
await fsWrapper.writeFileAsync(artifactPath, artifactString);
}
/**
@@ -127,8 +125,8 @@ export class Deployer {
* @param contractName Name of the contract, without the extension.
* @return The contract artifact.
*/
- private loadContractArtifactIfExists(contractName: string): ContractArtifact {
- const artifactPath = `${this.artifactsDir}/${contractName}.json`;
+ private _loadContractArtifactIfExists(contractName: string): ContractArtifact {
+ const artifactPath = `${this._artifactsDir}/${contractName}.json`;
try {
const contractArtifact: ContractArtifact = require(artifactPath);
return contractArtifact;
@@ -141,8 +139,8 @@ export class Deployer {
* @param contractArtifact The contract artifact.
* @return Network specific contract data.
*/
- private getContractDataFromArtifactIfExists(contractArtifact: ContractArtifact): ContractData {
- const contractData = contractArtifact.networks[this.networkId];
+ private _getContractDataFromArtifactIfExists(contractArtifact: ContractArtifact): ContractData {
+ const contractData = contractArtifact.networks[this._networkId];
if (_.isUndefined(contractData)) {
throw new Error(`Data not found in artifact for contract: ${contractArtifact.contract_name}`);
}
@@ -152,13 +150,13 @@ export class Deployer {
* Gets the address to use for sending a transaction.
* @return The default from address. If not specified, returns the first address accessible by web3.
*/
- private async getFromAddressAsync(): Promise<string> {
+ private async _getFromAddressAsync(): Promise<string> {
let from: string;
- if (_.isUndefined(this.defaults.from)) {
+ if (_.isUndefined(this._defaults.from)) {
const accounts = await this.web3Wrapper.getAvailableAddressesAsync();
from = accounts[0];
} else {
- from = this.defaults.from;
+ from = this._defaults.from;
}
return from;
}
@@ -168,7 +166,7 @@ export class Deployer {
* @param data Bytecode to estimate gas for.
* @return Gas estimate for transaction data.
*/
- private async getAllowableGasEstimateAsync(data: string): Promise<number> {
+ private async _getAllowableGasEstimateAsync(data: string): Promise<number> {
const block = await this.web3Wrapper.getBlockAsync('latest');
let gas: number;
try {
diff --git a/packages/deployer/src/globals.d.ts b/packages/deployer/src/globals.d.ts
new file mode 100644
index 000000000..0a35002da
--- /dev/null
+++ b/packages/deployer/src/globals.d.ts
@@ -0,0 +1,8 @@
+declare module 'solc' {
+ export function compile(sources: any, optimizerEnabled: number, findImports: (importPath: string) => any): any;
+ export function setupMethods(solcBin: any): any;
+}
+
+declare module 'web3-eth-abi' {
+ export function encodeParameters(typesArray: string[], parameters: any[]): string;
+}
diff --git a/packages/deployer/src/migrations/config/multisig_sample.ts b/packages/deployer/src/migrations/config/multisig_sample.ts
new file mode 100644
index 000000000..dabeb7a4f
--- /dev/null
+++ b/packages/deployer/src/migrations/config/multisig_sample.ts
@@ -0,0 +1,10 @@
+import { MultiSigConfigByNetwork } from '../../types';
+
+// Make a copy of this file named `multisig.js` and input custom params as needed
+export const multiSig: MultiSigConfigByNetwork = {
+ kovan: {
+ owners: [],
+ confirmationsRequired: 0,
+ secondsRequired: 0,
+ },
+};
diff --git a/packages/contracts/deploy/migrations/config/token_info.ts b/packages/deployer/src/migrations/config/token_info.ts
index f56914ecb..7e822fc3b 100644
--- a/packages/contracts/deploy/migrations/config/token_info.ts
+++ b/packages/deployer/src/migrations/config/token_info.ts
@@ -1,5 +1,5 @@
-import {constants} from './../../src/utils/constants';
-import {Token} from './../../src/utils/types';
+import { constants } from '../../utils/constants';
+import { Token } from '../../types';
export const tokenInfo: Token[] = [
{
diff --git a/packages/deployer/src/migrations/migrate.ts b/packages/deployer/src/migrations/migrate.ts
new file mode 100644
index 000000000..393806b45
--- /dev/null
+++ b/packages/deployer/src/migrations/migrate.ts
@@ -0,0 +1,90 @@
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import * as _ from 'lodash';
+
+import { Deployer } from '../deployer';
+import { constants } from '../utils/constants';
+import { tokenInfo } from './config/token_info';
+
+export const migrator = {
+ /**
+ * Custom migrations should be defined in this function. This will be called with the CLI 'migrate' command.
+ * Some operations might be completed in parallel, but we don't do that on purpose.
+ * That way the addresses are deterministic.
+ * @param deployer Deployer instance.
+ */
+ async runMigrationsAsync(deployer: Deployer): Promise<void> {
+ const web3Wrapper: Web3Wrapper = deployer.web3Wrapper;
+ const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync();
+
+ const tokenTransferProxy = await deployer.deployAndSaveAsync('TokenTransferProxy');
+ const zrxToken = await deployer.deployAndSaveAsync('ZRXToken');
+ const etherToken = await deployer.deployAndSaveAsync('WETH9');
+ const tokenReg = await deployer.deployAndSaveAsync('TokenRegistry');
+
+ const exchangeArgs = [zrxToken.address, tokenTransferProxy.address];
+ const owners = [accounts[0], accounts[1]];
+ const confirmationsRequired = new BigNumber(2);
+ const secondsRequired = new BigNumber(0);
+ const multiSigArgs = [owners, confirmationsRequired, secondsRequired, tokenTransferProxy.address];
+ const exchange = await deployer.deployAndSaveAsync('Exchange', exchangeArgs);
+ const multiSig = await deployer.deployAndSaveAsync(
+ 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress',
+ multiSigArgs,
+ );
+
+ const owner = accounts[0];
+ await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
+ await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: owner });
+ const addTokenGasEstimate = await tokenReg.addToken.estimateGasAsync(
+ zrxToken.address,
+ tokenInfo[0].name,
+ tokenInfo[0].symbol,
+ tokenInfo[0].decimals,
+ tokenInfo[0].ipfsHash,
+ tokenInfo[0].swarmHash,
+ { from: owner },
+ );
+ await tokenReg.addToken.sendTransactionAsync(
+ zrxToken.address,
+ '0x Protocol Token',
+ 'ZRX',
+ 18,
+ constants.NULL_BYTES,
+ constants.NULL_BYTES,
+ {
+ from: owner,
+ gas: addTokenGasEstimate,
+ },
+ );
+ await tokenReg.addToken.sendTransactionAsync(
+ etherToken.address,
+ 'Ether Token',
+ 'WETH',
+ 18,
+ constants.NULL_BYTES,
+ constants.NULL_BYTES,
+ {
+ from: owner,
+ gas: addTokenGasEstimate,
+ },
+ );
+ for (const token of tokenInfo) {
+ const totalSupply = new BigNumber(0);
+ const args = [token.name, token.symbol, token.decimals, totalSupply];
+ const dummyToken = await deployer.deployAsync('DummyToken', args);
+ await tokenReg.addToken.sendTransactionAsync(
+ dummyToken.address,
+ token.name,
+ token.symbol,
+ token.decimals,
+ token.ipfsHash,
+ token.swarmHash,
+ {
+ from: owner,
+ gas: addTokenGasEstimate,
+ },
+ );
+ }
+ },
+};
diff --git a/packages/contracts/deploy/solc/bin_paths.ts b/packages/deployer/src/solc/bin_paths.ts
index a2d345bd7..e5b107101 100644
--- a/packages/contracts/deploy/solc/bin_paths.ts
+++ b/packages/deployer/src/solc/bin_paths.ts
@@ -1,4 +1,4 @@
-interface BinaryPaths {
+export interface BinaryPaths {
[key: string]: string;
}
diff --git a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.10+commit.f0d539ae.js b/packages/deployer/src/solc/solc_bin/soljson-v0.4.10+commit.f0d539ae.js
index abeaeef1a..abeaeef1a 100644
--- a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.10+commit.f0d539ae.js
+++ b/packages/deployer/src/solc/solc_bin/soljson-v0.4.10+commit.f0d539ae.js
diff --git a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.11+commit.68ef5810.js b/packages/deployer/src/solc/solc_bin/soljson-v0.4.11+commit.68ef5810.js
index 522ad2afe..522ad2afe 100644
--- a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.11+commit.68ef5810.js
+++ b/packages/deployer/src/solc/solc_bin/soljson-v0.4.11+commit.68ef5810.js
diff --git a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.12+commit.194ff033.js b/packages/deployer/src/solc/solc_bin/soljson-v0.4.12+commit.194ff033.js
index 959545448..959545448 100644
--- a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.12+commit.194ff033.js
+++ b/packages/deployer/src/solc/solc_bin/soljson-v0.4.12+commit.194ff033.js
diff --git a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.13+commit.fb4cb1a.js b/packages/deployer/src/solc/solc_bin/soljson-v0.4.13+commit.fb4cb1a.js
index 73705304e..73705304e 100644
--- a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.13+commit.fb4cb1a.js
+++ b/packages/deployer/src/solc/solc_bin/soljson-v0.4.13+commit.fb4cb1a.js
diff --git a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.14+commit.c2215d46.js b/packages/deployer/src/solc/solc_bin/soljson-v0.4.14+commit.c2215d46.js
index 56bba18f2..56bba18f2 100644
--- a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.14+commit.c2215d46.js
+++ b/packages/deployer/src/solc/solc_bin/soljson-v0.4.14+commit.c2215d46.js
diff --git a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.15+commit.bbb8e64f.js b/packages/deployer/src/solc/solc_bin/soljson-v0.4.15+commit.bbb8e64f.js
index c01807a87..c01807a87 100644
--- a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.15+commit.bbb8e64f.js
+++ b/packages/deployer/src/solc/solc_bin/soljson-v0.4.15+commit.bbb8e64f.js
diff --git a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.16+commit.d7661dd9.js b/packages/deployer/src/solc/solc_bin/soljson-v0.4.16+commit.d7661dd9.js
index 5a8b08af9..5a8b08af9 100644
--- a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.16+commit.d7661dd9.js
+++ b/packages/deployer/src/solc/solc_bin/soljson-v0.4.16+commit.d7661dd9.js
diff --git a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.17+commit.bdeb9e52.js b/packages/deployer/src/solc/solc_bin/soljson-v0.4.17+commit.bdeb9e52.js
index b91555a9f..b91555a9f 100644
--- a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.17+commit.bdeb9e52.js
+++ b/packages/deployer/src/solc/solc_bin/soljson-v0.4.17+commit.bdeb9e52.js
diff --git a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.18+commit.9cf6e910.js b/packages/deployer/src/solc/solc_bin/soljson-v0.4.18+commit.9cf6e910.js
index 5b99e8c72..5b99e8c72 100644
--- a/packages/contracts/deploy/solc/solc_bin/soljson-v0.4.18+commit.9cf6e910.js
+++ b/packages/deployer/src/solc/solc_bin/soljson-v0.4.18+commit.9cf6e910.js
diff --git a/packages/deployer/src/types.ts b/packages/deployer/src/types.ts
new file mode 100644
index 000000000..58d1e5b4f
--- /dev/null
+++ b/packages/deployer/src/types.ts