Merge development into 3.0 (#2170)

* Added longer timeout for algolia admin operations. Added an option to apply hidden and custom labels to filters from algolia. Added sorting guides (alphabetically) and tools (by community maintenance and alphabetically).

* Fixed some types in guides

* Updated webpack, webpack-dev-server, webpack-bundle-analyzer, webpack-cli versions

* Updated / cleaned up babel and mdx packages

* Updated terser webpack plugin; Removed uglify plugin (unused). Added parallel option for terser. Added target browsers and cache directory option for babel-loader

* Webpack changes: using eval-source-map for development, added parallel option to Terser plugin, added cache loader and caching directory to mdx / babel loaders.

* Removed unusued pkg: body-scroll-lock

* Removed unused jsonschema / @types/jsonschema packages

* Removed unused less node package, adjusted less loader rules to match other loaders in webpack config

* Removed unusued node-sass package. Left sass-loader for webpack intact.

* Removed unused package react-lazyload

* Removed unused package react-typist

* Removed react-tap-event types as it's not used anymore. Reinstalled node-sass as a dev dependency as it's needed by sass-loader

* Moves @0x/types and @0x/typescript-typings to devDependencies

* Replaced react loadable (only used in Icon) with the native react lazy / suspense. Removed loadable nad its types from package.json

* Removed unused make-promises-safe package

* Moved animations to public and compressed files

* Added opening step links in new tab if the url is valid

* Moved @0x/types back to dependencies.

* Added animation wrapper with positioning props. Updated animations for core concepts.

* Replaced images for core concepts. Fixed a bug causing duplicate props on image and its container in mdx

* Remove legacy FAQ

* Update yarn.lock

* Add MD docs diff test to CI

* Remove unused dep

* Update docs to latest format

* Update yarn.lock

* Update ts-doc-gen with fix for multi-link lines

* Final docs gen

* Fix home route

* Update yarn.lock

* Add Golang Mesh RPC package and update versions

* Update the tools MDX files from authoritative S3 before build and dev server start

* Gitignore the tool MDX files in website repo

* Redirect old docs pages and wiki to new doc pages

* Move out Algolia indexing command-line tool out of website and remove need to expose admin key

* Add updating tools from S3 and indexing content on Algolia to deployment commands

* Add note about admin API env var needed for indexing docs

* Remove scripts gitignore since we don't have monorepo scripts in each package anymore

* Segregate indexes by environment

* Fixed 404 display for docs pages

* Removed webpack bundle analyzer

* Fix search and indexing

* Use `yarn` because otherwise the flags don't get passed down properly

* Improve indexing comment

* Remove legacy doc pages

* Fix linter errors

* Fix clean command to remove bundles recursively

* Revert react and react-dom versions in Instant

* Remove old doc md files

* Fix links

* Fix prettier

* Combine @0x/utils exports

* Update doc links

* Remove unused components

* Fix TS error

* Add missing new line

* Update Guides

* Ignore auto-generated MDX in website repo

* Prettier fix

* Add all guides to the sitemap.txt

* Add MMing guide

* Fix Get Started links

* Add 0x Extensions guide

* Replace all links to wiki with links to guides section

* Fix all /docs/{pkg} links to /docs/tools/{pkg}

* Remove deployer endpoint that is no longer used

* Fix links in Core Concepts

* Fixed regex to not remove hashes on links beyond the initial one

* Fixed huge width on instant screenshot

* Cleaned up core concept illustrations

* Started updating tool titles

* Fixed sectionizing headings in docs: Nested sections do not get wrapped in parent sections anymore; only sectionizing headings that need to be sectionized (i.e. that appear in the table of contents)

* Stylstic fix for the new way we sectionize headings / table of contents

* Change CoordinatorWrapper constructor to take a provider

* Added autolinking headings in mdx docs

* Refactor doc generation script to only generate MD docs and to have them reflect what is exported in their respective index.ts files

* Update ts-doc-gen

* Pass in provider, not Web3Wrapper

* Add back logic to prune out private methods

* Write algolia_metadata to utils dir

* Remove duplicate algolia_meta

* Add more packages to those we generate docs for and remove unused flags

* Update reference.mdx files

* Hide tools from homepage that have isHidden flag

* Link 0x.js to it's reference page

* Update tool naming to be more human readable

* Remove order-watcher reference doc

* Add blurb about on-chain API Explorer

* Add "On-chain" prefix to section name

* Remove committed reference file

* Sorting guides by difficulty and alphabetically

* Pushed sorting guides titles case-insensitive

* Sorting tools by difficulty and alphabetically. Removed icons from featured tools. Extracted common difficultyOrder constant

* Update ts-doc-gen so that it properly converts module relative links to anchor links

* Update doc references

* Remove "Relayers" topic/tag

* Prettier fix

* Remove hr so we don't have a bunch in a row

* Cleaned up CLI tag and added link to tools on API page

* Cleaned up some Guide titles

* Added bug bounty program guide

* Fixed a bug in algolia_meta

* Thrid level of nesting / temporary webpack config

* Open help link in new tab

* Link Python tools to doc pages not PyPi

* Fix links in guides

* Remove unused variables

* Revert webpack config

* Extracted common styles for levels of nesting deeper than 1 in the mdx table of contents

* Smoother animation on active table of contents state change

* Autolink headings in mdx only up to h3. Added heading sizes (in px) for h4,h5,h6 in mdx headings

* Fix prettier

* Adjusted font-size for paragraph, ordered and unordered lists. Fixed line-heights and colors too.

* Update ts-doc-gen and the reference docs

* Replace 0xproject.com urls with 0x.org

* Update README links

* Fix header sizes to display optimally in sidebar

* Fixed an issue with other nodes than text being parsed incorrectly in the table of contents

* Fixed styles for table of contents

* Use a different babel plugin that works in a production webpack build

* Unbroke build process / generating toc

* Changed line-height to 1.6 for paragraph

* Adjust scrollbar / toc height to available space

* Fixed some types

* Remove unnecessary link

* Fix casing on TypeScript

* Fix casing of PyPI

* Remove doc gen from abi-gen-wrappers since it'll be tested via contract-wrappers

* Fix MD docs and make sure generated contract wrappers are being rendered

* Remove generated docs in clean

* Correctly copying code samples

* Several additional fixes to the reference MDX docs

* Changed tools to Tools & Libraries - top nav left as just tools

* Changed references from Asset Buyer to Asset Swapper

* Changed trader keyword to trading

* Nevermind, changed back to Trader

* Sneaking in updated product dropdown menu titles based on Will's feedback

* Removed the word wiki from resources dropdown

* Open legal guide in same window

* Removed the isCommunity filter / custom filter labels functionality (only used for that before)

* Update ts-doc-gen version to one that fixes issues with Object Literals and removes Hierarchy sections and Module headers

* update yarn.lock

* Remove unused code

* Remove unused import

* Remove unused imports

* Remove unused import

* Fix prettier

* Update outdating dep version

* Created a color scheme for code snippets. Fixed language not being passed to some code blocks in two guides.

* Update abi-gen-wrappers dep version

* Update Algolia to production account

* Fix prettier

* Fix prettier in algolia_meta

* Remove packages/dev-tools-pages folder and update yarn.lock

* Remove other random references to dev-tools-pages

* Fix website

* Changed the order of indices in search suggestions

* Removed a comment

* Added scrollbar size adjustment on resize / scroll

* Rendering sidebar on mobile without any event listeners / taxing calculations / changes in height

* Added a performance comment

* Simplified table of contents

* Update ganache-cli to later version

* Remove bundle dirs too

* Added keeping active link in view when scrolling content in the docs

* Increase available memory for webpack

* Update contract addresses

* Update market-making guide to mention Mesh as an alternative to SRA

* Update Web3 Provider Explained guide

* Re-wrote Ganache Setup guide into a Setting up a local 0x testnet guide

* Export more of abi-gen-wrappers from contract-wrappers

* Final update of reference docs

* Add contract-wrappers MD docs and update it's index.ts so that no types are missing

* Fix prettier

* Increase the memory allocation for building the website

* Remove use of remove type

* Check if link is a valid url in mdx inline link: if so, open in a new tab, if not, same tab.

* Print out which snapshot version is being downloaded

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/contracts-asset-proxy@2.2.7
 - @0x/contracts-coordinator@2.0.12
 - @0x/contracts-dev-utils@0.0.9
 - @0x/contracts-erc1155@1.1.14
 - @0x/contracts-erc20@2.2.13
 - @0x/contracts-erc721@2.1.14
 - @0x/contracts-exchange-forwarder@3.0.11
 - @0x/contracts-exchange-libs@3.0.7
 - @0x/contracts-exchange@2.1.13
 - @0x/contracts-extensions@4.0.7
 - @0x/contracts-multisig@3.1.13
 - @0x/contracts-test-utils@3.1.15
 - @0x/contracts-utils@3.2.3
 - 0x.js@7.0.1
 - @0x/abi-gen-wrappers@5.3.1
 - @0x/abi-gen@4.2.0
 - @0x/assert@2.1.5
 - @0x/asset-buyer@6.1.13
 - @0x/asset-swapper@1.0.3
 - @0x/base-contract@5.3.3
 - @0x/connect@5.0.18
 - @0x/contract-artifacts@2.2.1
 - @0x/contract-wrappers@12.0.0
 - @0x/contracts-gen@1.0.14
 - @0x/dev-tools-pages@0.0.30
 - @0x/dev-utils@2.3.2
 - ethereum-types@2.1.5
 - @0x/fill-scenarios@3.0.18
 - @0x/instant@1.0.30
 - @0x/json-schemas@4.0.1
 - @0x/migrations@4.3.1
 - @0x/monorepo-scripts@1.0.36
 - @0x/order-utils@8.3.1
 - @0x/sol-compiler@3.1.14
 - @0x/sol-coverage@3.0.11
 - @0x/sol-doc@2.0.18
 - @0x/sol-profiler@3.1.13
 - @0x/sol-resolver@2.0.10
 - @0x/sol-trace@2.0.19
 - @0x/sol-tracing-utils@6.0.18
 - @0x/sra-spec@2.0.16
 - @0x/subproviders@5.0.3
 - @0x/testnet-faucets@1.0.86
 - @0x/types@2.4.2
 - @0x/typescript-typings@4.2.5
 - @0x/utils@4.5.1
 - @0x/web3-wrapper@6.0.12
 - @0x/website@0.0.89

* Remove the website from the monorepo

* Update yarn.lock

* Remove website files that were accidentally merged back in

* Use local EVM for pure functions (#2108)

* add local evm for pure functions

* increase container size to >=8gb for static-tests

* increase max bundle size because of ethereumjs-vm dependency

* add declarations for ethereumjs-vm in @0x/typescript-typings

* Make `OrdersChannelSubscriptionOpts` conform to SRAv2

* Make it easier to use validateOrderFillableOrThrowAsync (#2096)

* make it easier to use validateOrderFillableOrThrowAsync

* add unit tests, use DevUtils

* remove dependency on @0x/order-utils from @0x/migrations

* add devUtils to contract-wrappers (#2146)

* Delete docs in S3 bucket before uploading latest version so we only ever have one version uploaded at a time

* Update to new ts-doc-gen version that fixes links in "Inherited from" lines

* try to fix instant build

* Remove redoc-cli as a dep from sra-spec

* Smooth out some last incompatible types

* Fix prettier

* Add terser-webpack-plugin to 0x.js deps

* @0x/orderbook

* AssetSwapper to use @0x/orderbook

* Remove unused imported type

* Prevent double websocket connections

* Fix build error

* fixed consumer inconsistency bug

* linted + added convenience functionality

* minor changes/typo fixes

* updated websocket

* updated for prettier

* Fix versions and exported types

* move log tests to @0x/abi-gen; delete exchange_wrapper_test (#2160)

* Remove unused exported types

* Fix exports from asset-swapper

* Update exported types for docs

* Update mesh client dep

* Move perPage and 18 precision lower to re-use

* fix ABI encoding/decoding functions (#2165)

* Fix typo at contract import (#2102)

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/contracts-asset-proxy@2.2.8
 - @0x/contracts-coordinator@2.0.13
 - @0x/contracts-dev-utils@0.0.10
 - @0x/contracts-erc1155@1.1.15
 - @0x/contracts-erc20@2.2.14
 - @0x/contracts-erc721@2.1.15
 - @0x/contracts-exchange-forwarder@3.0.12
 - @0x/contracts-exchange-libs@3.0.8
 - @0x/contracts-exchange@2.1.14
 - @0x/contracts-extensions@4.0.8
 - @0x/contracts-multisig@3.1.14
 - @0x/contracts-test-utils@3.1.16
 - @0x/contracts-utils@3.2.4
 - 0x.js@7.0.2
 - @0x/abi-gen-wrappers@5.3.2
 - @0x/abi-gen@4.2.1
 - @0x/assert@2.1.6
 - @0x/asset-buyer@6.1.14
 - @0x/asset-swapper@2.0.0
 - @0x/base-contract@5.4.0
 - @0x/connect@5.0.19
 - @0x/contract-addresses@3.2.0
 - @0x/contract-artifacts@2.2.2
 - @0x/contract-wrappers@12.1.0
 - @0x/contracts-gen@1.0.15
 - @0x/dev-utils@2.3.3
 - ethereum-types@2.1.6
 - @0x/fill-scenarios@3.0.19
 - @0x/instant@1.0.31
 - @0x/json-schemas@4.0.2
 - @0x/migrations@4.3.2
 - @0x/monorepo-scripts@1.0.37
 - @0x/order-utils@8.4.0
 - @0x/orderbook@0.0.2
 - @0x/sol-compiler@3.1.15
 - @0x/sol-coverage@3.0.12
 - @0x/sol-doc@2.0.19
 - @0x/sol-profiler@3.1.14
 - @0x/sol-resolver@2.0.11
 - @0x/sol-trace@2.0.20
 - @0x/sol-tracing-utils@6.0.19
 - @0x/sra-spec@2.0.17
 - @0x/subproviders@5.0.4
 - @0x/testnet-faucets@1.0.87
 - @0x/types@2.4.3
 - @0x/typescript-typings@4.3.0
 - @0x/utils@4.5.2
 - @0x/web3-wrapper@6.0.13

* fix circleci diff

* update changelog
This commit is contained in:
Xianny
2019-09-19 19:43:08 -07:00
committed by GitHub
parent 2253f214a6
commit a57dd427ca
1281 changed files with 81209 additions and 56841 deletions

View File

@@ -1,6 +1,6 @@
[
{
"version": "11.2.0",
"version": "12.2.0",
"changes": [
{
"note": "Use new `Order` and `ZeroExTransaction` structures with `domain` field",
@@ -12,6 +12,30 @@
}
]
},
{
"version": "12.1.0",
"changes": [
{
"note": "Add `devUtils` to `ContractWrappers` class.",
"pr": 2146
}
],
"timestamp": 1568744790
},
{
"version": "12.0.0",
"changes": [
{
"note": "Import wrappers from @0x/abi-gen-wrappers instead of directly implementing within this package.",
"pr": 2086
},
{
"note": "Change CoordinatorWrapper constructor to take a provider instead of a Web3Wrapper instance",
"pr": 2023
}
],
"timestamp": 1567521715
},
{
"version": "11.1.0",
"changes": [
@@ -19,7 +43,8 @@
"note": "Add `contractAddresses` to `ContractWrappers` class. Add `validateAndSendTransactionAsync` to all methods. Add interfaces ForwarderError, ContractError, TraderInfo, OrderAndTraderInfo.",
"pr": 2068
}
]
],
"timestamp": 1566446343
},
{
"version": "11.0.0",

View File

@@ -5,6 +5,19 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v12.1.0 - _September 17, 2019_
* Add `devUtils` to `ContractWrappers` class. (#2146)
## v12.0.0 - _September 3, 2019_
* Import wrappers from @0x/abi-gen-wrappers instead of directly implementing within this package. (#2086)
* Change CoordinatorWrapper constructor to take a provider instead of a Web3Wrapper instance (#2023)
## v11.1.0 - _August 22, 2019_
* Add `contractAddresses` to `ContractWrappers` class. Add `validateAndSendTransactionAsync` to all methods. Add interfaces ForwarderError, ContractError, TraderInfo, OrderAndTraderInfo. (#2068)
## v11.0.0 - _August 8, 2019_
* Use @0x/abi-gen to generate wrappers. For a full list of changes, see https://github.com/0xProject/0x-monorepo/issues/2040 (#2037)

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contract-wrappers",
"version": "11.0.0",
"version": "12.1.0",
"engines": {
"node": ">=6.12"
},
@@ -17,7 +17,7 @@
"test": "test"
},
"scripts": {
"build": "yarn pre_build && tsc -b",
"build": "tsc -b",
"build:ci": "yarn build",
"lint": "tslint --format stylish --project . --exclude **/lib/**/*",
"fix": "tslint --fix --format stylish --project .--exclude **/lib/**/*",
@@ -26,12 +26,13 @@
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"pre_build": "yarn generate_contract_wrappers && yarn prettier_contract_wrappers",
"prettier": "prettier --write **/* --config ../../.prettierrc",
"prettier_contract_wrappers": "prettier --write src/generated-wrappers/* --config ../../.prettierrc",
"clean": "shx rm -rf lib src/generated-wrappers",
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers",
"docs_test": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --out generated_docs ./src/generated-wrappers/*"
"clean": "shx rm -rf lib generated_docs",
"docs_test": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --out generated_docs ./src/generated-wrappers/*",
"diff_docs": "git diff --exit-code ./docs",
"s3:sync_md_docs": "aws s3 sync ./docs s3://docs-markdown/${npm_package_name}/v${npm_package_version} --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
"docs:md": "ts-doc-gen --sourceDir=./src --output=./docs --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json",
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DevUtils|DutchAuction|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IAssetProxy|IValidator|IWallet|MultiAssetProxy|OrderValidator|WETH9|ZRXToken|Coordinator|CoordinatorRegistry|EthBalanceChecker).json"
@@ -46,37 +47,40 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contract-wrappers/README.md",
"devDependencies": {
"@0x/abi-gen": "^4.1.0",
"@0x/abi-gen-templates": "^2.4.1",
"@0x/assert": "^2.1.3",
"@0x/contracts-test-utils": "^3.1.12",
"@0x/assert": "^2.1.6",
"@0x/contracts-test-utils": "^3.1.16",
"@0x/coordinator-server": "^0.1.3",
"@0x/json-schemas": "^3.1.13",
"@0x/dev-utils": "^2.3.3",
"@0x/fill-scenarios": "^3.0.19",
"@0x/json-schemas": "^4.0.2",
"@0x/migrations": "^4.3.2",
"@0x/subproviders": "^5.0.4",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^3.0.1",
"@0x/types": "^2.4.1",
"@0x/utils": "^4.5.0",
"@0x/web3-wrapper": "^6.0.10",
"@0x/types": "^2.4.3",
"@0x/utils": "^4.5.2",
"@0x/web3-wrapper": "^6.0.13",
"@types/nock": "^10.0.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereum-types": "^2.1.4",
"ethers": "~4.0.4",
"ethereum-types": "^2.1.6",
"lodash": "^4.17.11",
"mocha": "^6.2.0",
"nock": "^10.0.6",
"shx": "^0.2.2"
"shx": "^0.2.2",
"tslint": "5.11.0",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.3.1",
"@0x/contract-addresses": "^3.0.3",
"@0x/contract-artifacts": "^2.0.4",
"@0x/dev-utils": "^2.3.0",
"@0x/fill-scenarios": "^3.0.16",
"@0x/migrations": "^4.2.0",
"@0x/order-utils": "^8.2.5",
"@0x/subproviders": "^5.0.1",
"@0x/abi-gen-wrappers": "^5.3.2",
"@0x/base-contract": "^5.4.0",
"@0x/contract-addresses": "^3.2.0",
"@0x/contract-artifacts": "^2.2.2",
"@0x/order-utils": "^8.4.0",
"ethers": "~4.0.4",
"http-status-codes": "^1.3.2"
},
"publishConfig": {

View File

@@ -1,6 +1,17 @@
import {
DevUtilsContract,
DutchAuctionContract,
ERC20ProxyContract,
ERC721ProxyContract,
ExchangeContract,
ForwarderContract,
OrderValidatorContract,
WETH9Contract,
} from '@0x/abi-gen-wrappers';
import { ContractAddresses } from '@0x/contract-addresses';
import {
Coordinator,
DevUtils,
DutchAuction,
ERC20Proxy,
ERC20Token,
@@ -17,13 +28,6 @@ import { SupportedProvider } from 'ethereum-types';
import * as _ from 'lodash';
import { CoordinatorWrapper } from './coordinator_wrapper';
import { DutchAuctionContract } from './generated-wrappers/dutch_auction';
import { ERC20ProxyContract } from './generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from './generated-wrappers/erc721_proxy';
import { ExchangeContract } from './generated-wrappers/exchange';
import { ForwarderContract } from './generated-wrappers/forwarder';
import { OrderValidatorContract } from './generated-wrappers/order_validator';
import { WETH9Contract } from './generated-wrappers/weth9';
import { ContractWrappersConfigSchema } from './schemas/contract_wrappers_config_schema';
import { ContractWrappersConfig } from './types';
import { assert } from './utils/assert';
@@ -68,6 +72,10 @@ export class ContractWrappers {
* An instance of the DutchAuctionContract class containing methods for interacting with any DutchAuction smart contract.
*/
public dutchAuction: DutchAuctionContract;
/**
* An instance of the DevUtilsContract class containing methods for interacting with the DevUtils smart contract.
*/
public devUtils: DevUtilsContract;
/**
* An instance of the CoordinatorWrapper class containing methods for interacting with the Coordinator extension contract.
*/
@@ -89,6 +97,7 @@ export class ContractWrappers {
this._web3Wrapper = new Web3Wrapper(supportedProvider, txDefaults);
const artifactsArray = [
Coordinator,
DevUtils,
DutchAuction,
ERC20Proxy,
ERC20Token,
@@ -113,8 +122,9 @@ export class ContractWrappers {
this.forwarder = new ForwarderContract(contractAddresses.forwarder, this.getProvider());
this.orderValidator = new OrderValidatorContract(contractAddresses.orderValidator, this.getProvider());
this.dutchAuction = new DutchAuctionContract(contractAddresses.dutchAuction, this.getProvider());
this.devUtils = new DevUtilsContract(contractAddresses.devUtils, this.getProvider());
this.coordinator = new CoordinatorWrapper(
this._web3Wrapper,
this.getProvider(),
config.networkId,
contractAddresses.coordinator,
contractAddresses.exchange,

View File

@@ -5,11 +5,11 @@ import { generatePseudoRandomSalt, signatureUtils } from '@0x/order-utils';
import { Order, SignedOrder, SignedZeroExTransaction, ZeroExTransaction } from '@0x/types';
import { BigNumber, fetchAsync } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
import { ContractAbi, SupportedProvider } from 'ethereum-types';
import * as HttpStatus from 'http-status-codes';
import { flatten } from 'lodash';
import { CoordinatorContract, CoordinatorRegistryContract, ExchangeContract } from './index';
import { CoordinatorContract, CoordinatorRegistryContract, ExchangeContract } from '@0x/abi-gen-wrappers';
import { orderTxOptsSchema } from './schemas/order_tx_opts_schema';
import { txOptsSchema } from './schemas/tx_opts_schema';
@@ -54,7 +54,7 @@ export class CoordinatorWrapper {
* default to the known address corresponding to the networkId.
*/
constructor(
web3Wrapper: Web3Wrapper,
provider: SupportedProvider,
networkId: number,
address?: string,
exchangeAddress?: string,
@@ -65,7 +65,7 @@ export class CoordinatorWrapper {
this.address = address === undefined ? contractAddresses.coordinator : address;
this.exchangeAddress = exchangeAddress === undefined ? contractAddresses.coordinator : exchangeAddress;
this.registryAddress = registryAddress === undefined ? contractAddresses.coordinatorRegistry : registryAddress;
this._web3Wrapper = web3Wrapper;
this._web3Wrapper = new Web3Wrapper(provider);
this._contractInstance = new CoordinatorContract(
this.address,
@@ -793,7 +793,10 @@ export class CoordinatorWrapper {
salt: generatePseudoRandomSalt(),
signerAddress,
data,
verifyingContractAddress: this.exchangeAddress,
domain: {
verifyingContractAddress: this.exchangeAddress,
chainId: await this._web3Wrapper.getChainIdAsync(),
},
};
const signedTransaction = await signatureUtils.ecSignTransactionAsync(
this._web3Wrapper.getProvider(),

View File

@@ -1,36 +1,83 @@
export * from './generated-wrappers/asset_proxy_owner';
export * from './generated-wrappers/dev_utils';
export * from './generated-wrappers/dummy_erc20_token';
export * from './generated-wrappers/dummy_erc721_token';
export * from './generated-wrappers/dutch_auction';
export * from './generated-wrappers/erc20_proxy';
export * from './generated-wrappers/erc20_token';
export * from './generated-wrappers/erc721_proxy';
export * from './generated-wrappers/erc721_token';
export * from './generated-wrappers/exchange';
export * from './generated-wrappers/forwarder';
export * from './generated-wrappers/i_asset_proxy';
export * from './generated-wrappers/i_validator';
export * from './generated-wrappers/i_wallet';
export * from './generated-wrappers/multi_asset_proxy';
export * from './generated-wrappers/order_validator';
export * from './generated-wrappers/weth9';
export * from './generated-wrappers/zrx_token';
export * from './generated-wrappers/coordinator';
export * from './generated-wrappers/coordinator_registry';
export * from './generated-wrappers/eth_balance_checker';
export * from '@0x/contract-addresses';
export { ContractAddresses } from '@0x/contract-addresses';
export { ContractWrappers } from './contract_wrappers';
export { CoordinatorWrapper } from './coordinator_wrapper';
export { BlockRange } from '@0x/base-contract';
export {
ExchangeEventArgs,
ExchangeEvents,
ExchangeSignatureValidatorApprovalEventArgs,
ExchangeFillEventArgs,
ExchangeCancelEventArgs,
ExchangeCancelUpToEventArgs,
ExchangeAssetProxyRegisteredEventArgs,
ExchangeContract,
DevUtilsContract,
ForwarderContract,
DutchAuctionContract,
CoordinatorContract,
CoordinatorRegistryEventArgs,
CoordinatorRegistryEvents,
CoordinatorRegistryCoordinatorEndpointSetEventArgs,
CoordinatorRegistryContract,
IValidatorContract,
IWalletContract,
WETH9EventArgs,
WETH9Events,
WETH9ApprovalEventArgs,
WETH9TransferEventArgs,
WETH9DepositEventArgs,
WETH9WithdrawalEventArgs,
WETH9Contract,
ERC20TokenEventArgs,
ERC20TokenEvents,
ERC20TokenTransferEventArgs,
ERC20TokenApprovalEventArgs,
ERC20TokenContract,
ERC721TokenEventArgs,
ERC721TokenEvents,
ERC721TokenTransferEventArgs,
ERC721TokenApprovalEventArgs,
ERC721TokenApprovalForAllEventArgs,
ERC721TokenContract,
ERC1155ProxyEventArgs,
ERC1155ProxyEvents,
ERC1155ProxyAuthorizedAddressAddedEventArgs,
ERC1155ProxyAuthorizedAddressRemovedEventArgs,
ERC1155ProxyContract,
ZRXTokenEventArgs,
ZRXTokenEvents,
ZRXTokenTransferEventArgs,
ZRXTokenApprovalEventArgs,
ZRXTokenContract,
DummyERC20TokenEventArgs,
DummyERC20TokenEvents,
DummyERC20TokenTransferEventArgs,
DummyERC20TokenApprovalEventArgs,
DummyERC20TokenContract,
DummyERC721TokenEventArgs,
DummyERC721TokenEvents,
DummyERC721TokenTransferEventArgs,
DummyERC721TokenApprovalEventArgs,
DummyERC721TokenApprovalForAllEventArgs,
DummyERC721TokenContract,
ERC20ProxyEventArgs,
ERC20ProxyEvents,
ERC20ProxyContract,
ERC20ProxyAuthorizedAddressAddedEventArgs,
ERC20ProxyAuthorizedAddressRemovedEventArgs,
ERC721ProxyEventArgs,
ERC721ProxyEvents,
ERC721ProxyAuthorizedAddressAddedEventArgs,
ERC721ProxyAuthorizedAddressRemovedEventArgs,
ERC721ProxyContract,
OrderValidatorContract,
} from '@0x/abi-gen-wrappers';
export {
OrderStatus,
ContractError,
ForwarderError,
OrderAndTraderInfo,
CoordinatorServerCancellationResponse,
CoordinatorServerError,
IndexedFilterValues,
@@ -40,5 +87,72 @@ export {
OrderInfo,
EventCallback,
DecodedLogEvent,
TraderInfo,
} from './types';
export {
BlockRange,
SupportedProvider,
TxData,
ContractAbi,
ContractArtifact,
DataItem,
CallData,
BlockParam,
ContractEventArg,
DecodedLogArgs,
LogWithDecodedArgs,
CompilerOpts,
StandardContractOutput,
ContractNetworks,
EventParameter,
TupleDataItem,
TxDataPayable,
BlockParamLiteral,
AbiDefinition,
Web3JsProvider,
GanacheProvider,
EIP1193Provider,
ZeroExProvider,
LogEntry,
RawLog,
CompilerSettings,
ContractNetworkData,
EIP1193Event,
JSONRPCRequestPayload,
JSONRPCErrorCallback,
DecodedLogEntry,
LogEntryEvent,
DevdocOutput,
EvmOutput,
FunctionAbi,
EventAbi,
Web3JsV1Provider,
Web3JsV2Provider,
Web3JsV3Provider,
CompilerSettingsMetadata,
OptimizerSettings,
OutputField,
DecodedLogEntryEvent,
ParamDescription,
EvmBytecodeOutput,
JSONRPCResponsePayload,
MethodAbi,
ConstructorAbi,
FallbackAbi,
ConstructorStateMutability,
JSONRPCResponseError,
StateMutability,
} from 'ethereum-types';
export {
SimpleContractArtifact,
ZeroExTransaction,
SignedOrder,
Order,
SimpleStandardContractOutput,
SignedZeroExTransaction,
SimpleEvmOutput,
SimpleEvmBytecodeOutput,
} from '@0x/types';
export { AbiDecoder, DecodedCalldata } from '@0x/utils';

View File

@@ -1,4 +1,4 @@
import { ExchangeContract } from '../index';
import { ExchangeContract } from '@0x/abi-gen-wrappers';
/**
* Returns the ABI encoded transaction hash for a given method and arguments

File diff suppressed because one or more lines are too long

View File

@@ -1,550 +0,0 @@
import { BlockchainLifecycle, callbackErrorReporter } from '@0x/dev-utils';
import { FillScenarios } from '@0x/fill-scenarios';
import { assetDataUtils, orderHashUtils, signatureUtils } from '@0x/order-utils';
import { DoneCallback, SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { BlockParamLiteral } from 'ethereum-types';
import 'mocha';
import { ContractWrappers, ExchangeCancelEventArgs, ExchangeEvents, ExchangeFillEventArgs, OrderStatus } from '../src';
import { DecodedLogEvent } from '../src/types';
import { _getDefaultContractAddresses } from '../src/utils/contract_addresses';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { migrateOnceAsync } from './utils/migrate';
import { tokenUtils } from './utils/token_utils';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('ExchangeWrapper', () => {
let contractWrappers: ContractWrappers;
let userAddresses: string[];
let zrxTokenAddress: string;
let fillScenarios: FillScenarios;
let exchangeContractAddress: string;
let makerTokenAddress: string;
let takerTokenAddress: string;
let makerAddress: string;
let anotherMakerAddress: string;
let takerAddress: string;
let makerAssetData: string;
let takerAssetData: string;
const fillableAmount = new BigNumber(5);
const takerTokenFillAmount = new BigNumber(5);
let signedOrder: SignedOrder;
let anotherSignedOrder: SignedOrder;
before(async () => {
const contractAddresses = await migrateOnceAsync();
await blockchainLifecycle.startAsync();
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
contractAddresses,
blockPollingIntervalMs: 10,
};
contractWrappers = new ContractWrappers(provider, config);
exchangeContractAddress = contractWrappers.exchange.address;
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
zrxTokenAddress = contractAddresses.zrxToken;
fillScenarios = new FillScenarios(
provider,
userAddresses,
zrxTokenAddress,
exchangeContractAddress,
contractWrappers.erc20Proxy.address,
contractWrappers.erc721Proxy.address,
);
[, makerAddress, takerAddress, , anotherMakerAddress] = userAddresses;
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
[makerAssetData, takerAssetData] = [
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
];
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
makerAddress,
takerAddress,
fillableAmount,
);
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
makerAddress,
takerAddress,
fillableAmount,
);
});
after(async () => {
await blockchainLifecycle.revertAsync();
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
});
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('fill order(s)', () => {
describe('#fillOrderAsync', () => {
it('should fill a valid order', async () => {
await contractWrappers.exchange.fillOrder.awaitTransactionSuccessAsync(
signedOrder,
takerTokenFillAmount,
signedOrder.signature,
{ from: takerAddress },
);
});
});
describe('#fillOrderNoThrowAsync', () => {
it('should fill a valid order', async () => {
await contractWrappers.exchange.fillOrderNoThrow.awaitTransactionSuccessAsync(
signedOrder,
takerTokenFillAmount,
signedOrder.signature,
{ from: takerAddress },
);
const orderInfo = await contractWrappers.exchange.getOrderInfo.callAsync(signedOrder);
expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
});
});
describe('#fillOrKillOrderAsync', () => {
it('should fill or kill a valid order', async () => {
await contractWrappers.exchange.fillOrKillOrder.awaitTransactionSuccessAsync(
signedOrder,
takerTokenFillAmount,
signedOrder.signature,
{ from: takerAddress },
);
});
});
describe('#batchFillOrdersAsync', () => {
it('should fill a batch of valid orders', async () => {
const signedOrders = [signedOrder, anotherSignedOrder];
const takerAssetFillAmounts = [takerTokenFillAmount, takerTokenFillAmount];
await contractWrappers.exchange.batchFillOrders.awaitTransactionSuccessAsync(
signedOrders,
takerAssetFillAmounts,
signedOrders.map(o => o.signature),
{ from: takerAddress },
);
});
});
describe('#marketBuyOrdersAsync', () => {
it('should maker buy', async () => {
const signedOrders = [signedOrder, anotherSignedOrder];
const makerAssetFillAmount = takerTokenFillAmount;
await contractWrappers.exchange.marketBuyOrders.awaitTransactionSuccessAsync(
signedOrders,
makerAssetFillAmount,
signedOrders.map(o => o.signature),
{ from: takerAddress },
);
});
});
describe('#marketBuyOrdersNoThrowAsync', () => {
it('should no throw maker buy', async () => {
const signedOrders = [signedOrder, anotherSignedOrder];
const makerAssetFillAmount = takerTokenFillAmount;
await contractWrappers.exchange.marketBuyOrdersNoThrow.awaitTransactionSuccessAsync(
signedOrders,
makerAssetFillAmount,
signedOrders.map(o => o.signature),
{ from: takerAddress },
);
const orderInfo = await contractWrappers.exchange.getOrderInfo.callAsync(signedOrder);
expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
});
});
describe('#marketSellOrdersAsync', () => {
it('should maker sell', async () => {
const signedOrders = [signedOrder, anotherSignedOrder];
const takerAssetFillAmount = takerTokenFillAmount;
await contractWrappers.exchange.marketSellOrders.awaitTransactionSuccessAsync(
signedOrders,
takerAssetFillAmount,
signedOrders.map(o => o.signature),
{ from: takerAddress },
);
});
});
describe('#marketSellOrdersNoThrowAsync', () => {
it('should no throw maker sell', async () => {
const signedOrders = [signedOrder, anotherSignedOrder];
const takerAssetFillAmount = takerTokenFillAmount;
await contractWrappers.exchange.marketSellOrdersNoThrow.awaitTransactionSuccessAsync(
signedOrders,
takerAssetFillAmount,
signedOrders.map(o => o.signature),
{ from: takerAddress },
);
const orderInfo = await contractWrappers.exchange.getOrderInfo.callAsync(signedOrder);
expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
});
});
describe('#batchFillOrdersNoThrowAsync', () => {
it('should fill a batch of valid orders', async () => {
const signedOrders = [signedOrder, anotherSignedOrder];
const takerAssetFillAmounts = [takerTokenFillAmount, takerTokenFillAmount];
await contractWrappers.exchange.batchFillOrdersNoThrow.awaitTransactionSuccessAsync(
signedOrders,
takerAssetFillAmounts,
signedOrders.map(o => o.signature),
{ from: takerAddress },
);
let orderInfo = await contractWrappers.exchange.getOrderInfo.callAsync(signedOrder);
expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
orderInfo = await contractWrappers.exchange.getOrderInfo.callAsync(anotherSignedOrder);
expect(orderInfo.orderStatus).to.be.equal(OrderStatus.FullyFilled);
});
});
describe('#batchFillOrKillOrdersAsync', () => {
it('should fill or kill a batch of valid orders', async () => {
const signedOrders = [signedOrder, anotherSignedOrder];
const takerAssetFillAmounts = [takerTokenFillAmount, takerTokenFillAmount];
await contractWrappers.exchange.batchFillOrKillOrders.awaitTransactionSuccessAsync(
signedOrders,
takerAssetFillAmounts,
signedOrders.map(o => o.signature),
{ from: takerAddress },
);
});
});
describe('#matchOrdersAsync', () => {
it('should match two valid ordersr', async () => {
const matchingSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
takerAssetData,
makerAssetData,
makerAddress,
takerAddress,
fillableAmount,
);
await contractWrappers.exchange.matchOrders.awaitTransactionSuccessAsync(
signedOrder,
matchingSignedOrder,
signedOrder.signature,
matchingSignedOrder.signature,
{ from: takerAddress },
);
});
});
});
describe('cancel order(s)', () => {
describe('#cancelOrderAsync', () => {
it('should cancel a valid order', async () => {
await contractWrappers.exchange.cancelOrder.awaitTransactionSuccessAsync(signedOrder, {
from: makerAddress,
});
});
});
describe('#batchCancelOrdersAsync', () => {
it('should cancel a batch of valid orders', async () => {
const orders = [signedOrder, anotherSignedOrder];
await contractWrappers.exchange.batchCancelOrders.awaitTransactionSuccessAsync(orders, {
from: makerAddress,
});
});
});
describe('#cancelOrdersUpTo/getOrderEpochAsync', () => {
it('should cancel orders up to target order epoch', async () => {
const targetOrderEpoch = new BigNumber(42);
await contractWrappers.exchange.cancelOrdersUpTo.awaitTransactionSuccessAsync(targetOrderEpoch, {
from: makerAddress,
});
const orderEpoch = await contractWrappers.exchange.orderEpoch.callAsync(
makerAddress,
constants.NULL_ADDRESS,
);
expect(orderEpoch).to.be.bignumber.equal(targetOrderEpoch.plus(1));
});
});
});
describe('#getOrderInfoAsync', () => {
it('should get the order info', async () => {
const orderInfo = await contractWrappers.exchange.getOrderInfo.callAsync(signedOrder);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
expect(orderInfo.orderHash).to.be.equal(orderHash);
});
});
describe('#getOrdersInfoAsync', () => {
it('should get the orders info', async () => {
const ordersInfo = await contractWrappers.exchange.getOrdersInfo.callAsync([
signedOrder,
anotherSignedOrder,
]);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
expect(ordersInfo[0].orderHash).to.be.equal(orderHash);
const anotherOrderHash = orderHashUtils.getOrderHashHex(anotherSignedOrder);
expect(ordersInfo[1].orderHash).to.be.equal(anotherOrderHash);
});
});
describe('#isValidSignature', () => {
it('should check if the signature is valid', async () => {
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
let isValid = await contractWrappers.exchange.isValidSignature.callAsync(
orderHash,
signedOrder.makerAddress,
signedOrder.signature,
);
expect(isValid).to.be.true();
isValid = await contractWrappers.exchange.isValidSignature.callAsync(
orderHash,
signedOrder.takerAddress,
signedOrder.signature,
);
expect(isValid).to.be.false();
});
});
describe('#isAllowedValidatorAsync', () => {
it('should check if the validator is allowed', async () => {
const signerAddress = makerAddress;
const validatorAddress = constants.NULL_ADDRESS;
const isAllowed = await contractWrappers.exchange.allowedValidators.callAsync(
signerAddress,
validatorAddress,
);
expect(isAllowed).to.be.false();
});
});
describe('#setSignatureValidatorApproval', () => {
it('should set signature validator approval', async () => {
const validatorAddress = constants.NULL_ADDRESS;
const isApproved = true;
const senderAddress = makerAddress;
await contractWrappers.exchange.setSignatureValidatorApproval.awaitTransactionSuccessAsync(
validatorAddress,
isApproved,
{ from: senderAddress },
);
});
});
describe('#isTransactionExecutedAsync', () => {
it('should check if the transaction is executed', async () => {
const transactionHash = '0x0000000000000000000000000000000000000000000000000000000000000000';
const isExecuted = await contractWrappers.exchange.transactions.callAsync(transactionHash);
expect(isExecuted).to.be.false();
});
});
describe('#getAssetProxyBySignatureAsync', () => {
it('should fill or kill a valid order', async () => {
const erc20ProxyId = await contractWrappers.erc20Proxy.getProxyId.callAsync();
const erc20ProxyAddressById = await contractWrappers.exchange.getAssetProxy.callAsync(erc20ProxyId);
const erc20ProxyAddress = contractWrappers.erc20Proxy.address;
expect(erc20ProxyAddressById).to.be.equal(erc20ProxyAddress);
const erc721ProxyId = await contractWrappers.erc721Proxy.getProxyId.callAsync();
const erc721ProxyAddressById = await contractWrappers.exchange.getAssetProxy.callAsync(erc721ProxyId);
const erc721ProxyAddress = contractWrappers.erc721Proxy.address;
expect(erc721ProxyAddressById).to.be.equal(erc721ProxyAddress);
});
});
describe('#preSign/isPresigned', () => {
it('should preSign the hash', async () => {
const senderAddress = takerAddress;
const hash = orderHashUtils.getOrderHashHex(signedOrder);
const signerAddress = signedOrder.makerAddress;
let isPreSigned = await contractWrappers.exchange.preSigned.callAsync(hash, signerAddress);
expect(isPreSigned).to.be.false();
await contractWrappers.exchange.preSign.awaitTransactionSuccessAsync(
hash,
signerAddress,
signedOrder.signature,
{ from: senderAddress },
);
isPreSigned = await contractWrappers.exchange.preSigned.callAsync(hash, signerAddress);
expect(isPreSigned).to.be.true();
const preSignedSignature = '0x06';
const isValidSignature = await contractWrappers.exchange.isValidSignature.callAsync(
hash,
signerAddress,
preSignedSignature,
);
expect(isValidSignature).to.be.true();
// Test our TS implementation of signature validation
const isValidSignatureInTs = await signatureUtils.isValidSignatureAsync(
provider,
hash,
preSignedSignature,
signerAddress,
);
expect(isValidSignatureInTs).to.be.true();
});
});
describe('#getVersionAsync', () => {
it('should return version the hash', async () => {
const version = await contractWrappers.exchange.getVersionAsync();
const VERSION = '3.0.0';
expect(version).to.be.equal(VERSION);
});
});
describe('#subscribe', () => {
const indexFilterValues = {};
const takerTokenFillAmountInBaseUnits = new BigNumber(1);
beforeEach(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
makerAddress,
takerAddress,
fillableAmount,
);
});
afterEach(async () => {
contractWrappers.exchange.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 a sync 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 Fill event when an order is filled', (done: DoneCallback) => {
(async () => {
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)(
(logEvent: DecodedLogEvent<ExchangeFillEventArgs>) => {
expect(logEvent.log.event).to.be.equal(ExchangeEvents.Fill);
},
);
contractWrappers.exchange.subscribe(ExchangeEvents.Fill, indexFilterValues, callback);
await contractWrappers.exchange.fillOrder.awaitTransactionSuccessAsync(
signedOrder,
takerTokenFillAmountInBaseUnits,
signedOrder.signature,
{ from: takerAddress },
);
})().catch(done);
});
it('Should receive the LogCancel event when an order is cancelled', (done: DoneCallback) => {
(async () => {
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)(
(logEvent: DecodedLogEvent<ExchangeCancelEventArgs>) => {
expect(logEvent.log.event).to.be.equal(ExchangeEvents.Cancel);
},
);
contractWrappers.exchange.subscribe(ExchangeEvents.Cancel, indexFilterValues, callback);
await contractWrappers.exchange.cancelOrder.awaitTransactionSuccessAsync(signedOrder, {
from: makerAddress,
});
})().catch(done);
});
it('Outstanding subscriptions are cancelled when contractWrappers.unsubscribeAll called', (done: DoneCallback) => {
(async () => {
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
(logEvent: DecodedLogEvent<ExchangeFillEventArgs>) => {
done(new Error('Expected this subscription to have been cancelled'));
},
);
contractWrappers.exchange.subscribe(ExchangeEvents.Fill, indexFilterValues, callbackNeverToBeCalled);
contractWrappers.unsubscribeAll();
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)(
(logEvent: DecodedLogEvent<ExchangeFillEventArgs>) => {
expect(logEvent.log.event).to.be.equal(ExchangeEvents.Fill);
},
);
contractWrappers.exchange.subscribe(ExchangeEvents.Fill, indexFilterValues, callback);
await contractWrappers.exchange.fillOrder.awaitTransactionSuccessAsync(
signedOrder,
takerTokenFillAmountInBaseUnits,
signedOrder.signature,
{ from: takerAddress },
);
})().catch(done);
});
it('Should cancel subscription when unsubscribe called', (done: DoneCallback) => {
(async () => {
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
(_logEvent: DecodedLogEvent<ExchangeFillEventArgs>) => {
done(new Error('Expected this subscription to have been cancelled'));
},
);
const subscriptionToken = contractWrappers.exchange.subscribe(
ExchangeEvents.Fill,
indexFilterValues,
callbackNeverToBeCalled,
);
contractWrappers.exchange.unsubscribe(subscriptionToken);
await contractWrappers.exchange.fillOrder.awaitTransactionSuccessAsync(
signedOrder,
takerTokenFillAmountInBaseUnits,
signedOrder.signature,
{ from: takerAddress },
);
done();
})().catch(done);
});
});
describe('#getLogsAsync', () => {
const blockRange = {
fromBlock: 0,
toBlock: BlockParamLiteral.Latest,
};
it('should get logs with decoded args emitted by Fill', async () => {
await contractWrappers.exchange.fillOrder.awaitTransactionSuccessAsync(
signedOrder,
takerTokenFillAmount,
signedOrder.signature,
{ from: takerAddress },
);
const eventName = ExchangeEvents.Fill;
const indexFilterValues = {};
const logs = await contractWrappers.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 () => {
await contractWrappers.exchange.fillOrder.awaitTransactionSuccessAsync(
signedOrder,
takerTokenFillAmount,
signedOrder.signature,
{ from: takerAddress },
);
const differentEventName = ExchangeEvents.Cancel;
const indexFilterValues = {};
const logs = await contractWrappers.exchange.getLogsAsync(
differentEventName,
blockRange,
indexFilterValues,
);
expect(logs).to.have.length(0);
});
it('should only get the logs with the correct indexed fields', async () => {
await contractWrappers.exchange.fillOrder.awaitTransactionSuccessAsync(
signedOrder,
takerTokenFillAmount,
signedOrder.signature,
{ from: takerAddress },
);
const signedOrderWithAnotherMakerAddress = await fillScenarios.createFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
anotherMakerAddress,
takerAddress,
fillableAmount,
);
await contractWrappers.exchange.fillOrder.awaitTransactionSuccessAsync(
signedOrderWithAnotherMakerAddress,
takerTokenFillAmount,
signedOrderWithAnotherMakerAddress.signature,
{ from: takerAddress },
);
const eventName = ExchangeEvents.Fill;
const indexFilterValues = {
makerAddress: anotherMakerAddress,
};
const logs = await contractWrappers.exchange.getLogsAsync<ExchangeFillEventArgs>(
eventName,
blockRange,
indexFilterValues,
);
expect(logs).to.have.length(1);
const args = logs[0].args;
expect(args.makerAddress).to.be.equal(anotherMakerAddress);
});
});
}); // tslint:disable:max-file-line-count