Compare commits
	
		
			136 Commits
		
	
	
		
			@0x/migrat
			...
			monorepo@9
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 9e9e0d6592 | ||
|  | cb5f9ba97d | ||
|  | 34538f2ced | ||
|  | 2575644920 | ||
|  | b4b43a9e9e | ||
|  | df97b20913 | ||
|  | 9e3cc379ed | ||
|  | c1d78a94a2 | ||
|  | 7f4cbba076 | ||
|  | bdca84fe72 | ||
|  | cf8fd7103b | ||
|  | 8e8cdbd413 | ||
|  | 30f01681d4 | ||
|  | ecf1ad8da1 | ||
|  | 42dc112a13 | ||
|  | 58276cefce | ||
|  | 4b6501a739 | ||
|  | 724085e068 | ||
|  | 21fab3ef9f | ||
|  | db8837f4ce | ||
|  | 5781cdf6da | ||
|  | 874eb1602f | ||
|  | 82149917b7 | ||
|  | f11d8a5bd8 | ||
|  | f0d7d10fe7 | ||
|  | 9d4d9ce978 | ||
|  | 96a38602b8 | ||
|  | 90d3558d31 | ||
|  | e491a56dd0 | ||
|  | 4d8eb61924 | ||
|  | 17fab541c6 | ||
|  | 91de35e8e9 | ||
|  | f61964676a | ||
|  | 41a34c19bb | ||
|  | d90810d127 | ||
|  | 7f3d281faa | ||
|  | 812c306805 | ||
|  | fc1c59f374 | ||
|  | 35eac1e3ff | ||
|  | e16041d7fa | ||
|  | b8fc84ecc8 | ||
|  | 572c576e15 | ||
|  | 9df7f80fbb | ||
|  | f003400135 | ||
|  | ca7616c1d2 | ||
|  | a4a2bfdf35 | ||
|  | eb6bbb6e78 | ||
|  | 4d0172f634 | ||
|  | 3b61e0e126 | ||
|  | 1540a91835 | ||
|  | 2bcce9eed0 | ||
|  | 1e53564386 | ||
|  | d1c72706ef | ||
|  | bd9e531257 | ||
|  | 48436424db | ||
|  | 4f10d7f859 | ||
|  | 80e5a29444 | ||
|  | 0ec8a4a160 | ||
|  | 810bf7af0c | ||
|  | e7825206bf | ||
|  | 2b887c336a | ||
|  | 48ecd32d5d | ||
|  | 1f5a0987cb | ||
|  | f33a9d162a | ||
|  | c2919bcdb0 | ||
|  | 120d554a6b | ||
|  | 44f268a7ee | ||
|  | 3c7a0bcd85 | ||
|  | 8e2e9e9331 | ||
|  | 91c26fc046 | ||
|  | afcfe58add | ||
|  | 8d423be223 | ||
|  | 03b7314550 | ||
|  | 1a7e425780 | ||
|  | 8bc5faff3c | ||
|  | 2676278a66 | ||
|  | 6376b3baf3 | ||
|  | e569abe740 | ||
|  | 71be9ef92a | ||
|  | 4990c4903d | ||
|  | 9d468e2383 | ||
|  | 109cac013c | ||
|  | 0d8a9921cd | ||
|  | 2a5f5f7312 | ||
|  | fe54fbefbb | ||
|  | fc824b8d06 | ||
|  | d91a7b6d0e | ||
|  | aa4b3f93fa | ||
|  | efe8225d18 | ||
|  | b2c0f8c158 | ||
|  | 66dce8794d | ||
|  | 30d54407e6 | ||
|  | 6324a92ec5 | ||
|  | 67e7b5c124 | ||
|  | 35099d9b2f | ||
|  | e07f7b54e0 | ||
|  | 5c409929b4 | ||
|  | 1a504fdde9 | ||
|  | 4b06fd511b | ||
|  | def6727286 | ||
|  | bedaa0db16 | ||
|  | 90640a4fcf | ||
|  | 0142d07f10 | ||
|  | c9d85cfc7d | ||
|  | 64304c1991 | ||
|  | 993adc3578 | ||
|  | 8813bd26f6 | ||
|  | 35925de320 | ||
|  | 3b426a3f07 | ||
|  | 5104fd5dcf | ||
|  | a5a9ca9e46 | ||
|  | ba0f07e3b2 | ||
|  | 8614475324 | ||
|  | 744dda144b | ||
|  | 13d47915f4 | ||
|  | 3059b85e41 | ||
|  | 184ea4a67f | ||
|  | 8032f536ed | ||
|  | fba3870ef1 | ||
|  | 2915ee08ea | ||
|  | 86b76a3e75 | ||
|  | bc1dca3f6f | ||
|  | 5db1820123 | ||
|  | 657c35fb86 | ||
|  | 9432a84468 | ||
|  | 15a5bc02ef | ||
|  | f011be9347 | ||
|  | b6094fdb34 | ||
|  | 9e6ab9f585 | ||
|  | 869d2c02fa | ||
|  | 3b1dca0e70 | ||
|  | 595358fa69 | ||
|  | 8a8ec79c6c | ||
|  | 6252446bd3 | ||
|  | 403ceebff9 | ||
|  | 4767882ed3 | 
| @@ -219,7 +219,7 @@ jobs: | ||||
|             - image: 0xorg/launch-kit-backend:v3 | ||||
|               environment: | ||||
|                   RPC_URL: 'http://localhost:8545' | ||||
|                   NETWORK_ID: 50 | ||||
|                   CHAIN_ID: 1337 | ||||
|                   WHITELIST_ALL_TOKENS: True | ||||
|                   FEE_RECIPIENT: '0x0000000000000000000000000000000000000001' | ||||
|                   MAKER_FEE_UNIT_AMOUNT: 0 | ||||
|   | ||||
							
								
								
									
										2
									
								
								.github/autolabeler.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/autolabeler.yml
									
									
									
									
										vendored
									
									
								
							| @@ -32,5 +32,3 @@ contracts: ['contracts'] | ||||
| @0x/json-schemas: ['packages/json-schemas'] | ||||
| @0x/ethereum-types: ['ethereum-types'] | ||||
| @0x/connect: ['packages/connect'] | ||||
| @0x/testnet-faucets: ['packages/testnet-faucets'] | ||||
| @0x/monorepo-scripts: ['packages/monorepo-scripts'] | ||||
|   | ||||
							
								
								
									
										34
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										34
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -78,24 +78,35 @@ TODO.md | ||||
| # VSCode file | ||||
| .vscode | ||||
|  | ||||
| # server cli | ||||
| packages/testnet-faucets/server/ | ||||
|  | ||||
| # generated contract artifacts/ | ||||
| contracts/integrations/generated-artifacts/ | ||||
| contracts/integrations/test/generated-artifacts/ | ||||
| contracts/staking/generated-artifacts/ | ||||
| contracts/staking/test/generated-artifacts/ | ||||
| contracts/coordinator/generated-artifacts/ | ||||
| contracts/coordinator/test/generated-artifacts/ | ||||
| contracts/exchange/generated-artifacts/ | ||||
| contracts/exchange/test/generated-artifacts/ | ||||
| contracts/asset-proxy/generated-artifacts/ | ||||
| contracts/asset-proxy/test/generated-artifacts/ | ||||
| contracts/multisig/generated-artifacts/ | ||||
| contracts/multisig/test/generated-artifacts/ | ||||
| contracts/utils/generated-artifacts/ | ||||
| contracts/utils/test/generated-artifacts/ | ||||
| contracts/exchange-libs/generated-artifacts/ | ||||
| contracts/exchange-libs/test/generated-artifacts/ | ||||
| contracts/erc20/generated-artifacts/ | ||||
| contracts/erc20/test/generated-artifacts/ | ||||
| contracts/erc721/generated-artifacts/ | ||||
| contracts/erc721/test/generated-artifacts/ | ||||
| contracts/erc1155/generated-artifacts/ | ||||
| contracts/erc1155/test/generated-artifacts/ | ||||
| contracts/extensions/generated-artifacts/ | ||||
| contracts/extensions/test/generated-artifacts/ | ||||
| contracts/exchange-forwarder/generated-artifacts/ | ||||
| contracts/exchange-forwarder/test/generated-artifacts/ | ||||
| contracts/dev-utils/generated-artifacts/ | ||||
| contracts/dev-utils/test/generated-artifacts/ | ||||
| packages/sol-tracing-utils/test/fixtures/artifacts/ | ||||
| python-packages/contract_artifacts/src/zero_ex/contract_artifacts/artifacts/ | ||||
|  | ||||
| @@ -117,19 +128,33 @@ contracts/dev-utils/build/ | ||||
| # generated contract wrappers | ||||
| packages/python-contract-wrappers/generated/ | ||||
| contracts/integrations/generated-wrappers/ | ||||
| contracts/integrations/test/generated-wrappers/ | ||||
| contracts/staking/generated-wrappers/ | ||||
| contracts/staking/test/generated-wrappers/ | ||||
| contracts/coordinator/generated-wrappers/ | ||||
| contracts/coordinator/test/generated-wrappers/ | ||||
| contracts/exchange/generated-wrappers/ | ||||
| contracts/exchange/test/generated-wrappers/ | ||||
| contracts/asset-proxy/generated-wrappers/ | ||||
| contracts/asset-proxy/test/generated-wrappers/ | ||||
| contracts/multisig/generated-wrappers/ | ||||
| contracts/multisig/test/generated-wrappers/ | ||||
| contracts/utils/generated-wrappers/ | ||||
| contracts/utils/test/generated-wrappers/ | ||||
| contracts/exchange-libs/generated-wrappers/ | ||||
| contracts/exchange-libs/test/generated-wrappers/ | ||||
| contracts/erc20/generated-wrappers/ | ||||
| contracts/erc20/test/generated-wrappers/ | ||||
| contracts/erc721/generated-wrappers/ | ||||
| contracts/erc721/test/generated-wrappers/ | ||||
| contracts/erc1155/generated-wrappers/ | ||||
| contracts/erc1155/test/generated-wrappers/ | ||||
| contracts/extensions/generated-wrappers/ | ||||
| contracts/extensions/test/generated-wrappers/ | ||||
| contracts/exchange-forwarder/generated-wrappers/ | ||||
| contracts/exchange-forwarder/test/generated-wrappers/ | ||||
| contracts/dev-utils/generated-wrappers/ | ||||
| contracts/dev-utils/test/generated-wrappers/ | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/dev_utils/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc20_token/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/exchange/__init__.py | ||||
| @@ -144,13 +169,14 @@ python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc1155_proxy/__ | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc20_proxy/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc721_proxy/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc721_token/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/eth_balance_checker/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/forwarder/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/i_asset_proxy/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/i_validator/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/i_wallet/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/multi_asset_proxy/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/order_validator/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/staking/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/staking_proxy/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/static_call_proxy/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/weth9/__init__.py | ||||
| python-packages/contract_wrappers/src/zero_ex/contract_wrappers/zrx_token/__init__.py | ||||
|   | ||||
| @@ -1,33 +1,61 @@ | ||||
| lib | ||||
| .nyc_output | ||||
| /contracts/integrations/generated-wrappers | ||||
| /contracts/integrations/test/generated-wrappers | ||||
| /contracts/integrations/generated-artifacts | ||||
| /contracts/integrations/test/generated-artifacts | ||||
| /contracts/staking/generated-wrappers | ||||
| /contracts/staking/test/generated-wrappers | ||||
| /contracts/staking/generated-artifacts | ||||
| /contracts/staking/test/generated-artifacts | ||||
| /contracts/coordinator/generated-wrappers | ||||
| /contracts/coordinator/test/generated-wrappers | ||||
| /contracts/coordinator/generated-artifacts | ||||
| /contracts/coordinator/test/generated-artifacts | ||||
| /contracts/exchange/generated-wrappers | ||||
| /contracts/exchange/test/generated-wrappers | ||||
| /contracts/exchange/generated-artifacts | ||||
| /contracts/exchange/test/generated-artifacts | ||||
| /contracts/asset-proxy/generated-wrappers | ||||
| /contracts/asset-proxy/test/generated-wrappers | ||||
| /contracts/asset-proxy/generated-artifacts | ||||
| /contracts/asset-proxy/test/generated-artifacts | ||||
| /contracts/multisig/generated-wrappers | ||||
| /contracts/multisig/test/generated-wrappers | ||||
| /contracts/multisig/generated-artifacts | ||||
| /contracts/multisig/test/generated-artifacts | ||||
| /contracts/utils/generated-wrappers | ||||
| /contracts/utils/test/generated-wrappers | ||||
| /contracts/utils/generated-artifacts | ||||
| /contracts/utils/test/generated-artifacts | ||||
| /contracts/exchange-libs/generated-wrappers | ||||
| /contracts/exchange-libs/test/generated-wrappers | ||||
| /contracts/exchange-libs/generated-artifacts | ||||
| /contracts/exchange-libs/test/generated-artifacts | ||||
| /contracts/erc20/generated-wrappers | ||||
| /contracts/erc20/test/generated-wrappers | ||||
| /contracts/erc20/generated-artifacts | ||||
| /contracts/erc20/test/generated-artifacts | ||||
| /contracts/erc721/generated-wrappers | ||||
| /contracts/erc721/test/generated-wrappers | ||||
| /contracts/erc721/generated-artifacts | ||||
| /contracts/erc721/test/generated-artifacts | ||||
| /contracts/erc1155/generated-wrappers | ||||
| /contracts/erc1155/test/generated-wrappers | ||||
| /contracts/erc1155/generated-artifacts | ||||
| /contracts/erc1155/test/generated-artifacts | ||||
| /contracts/extensions/generated-wrappers | ||||
| /contracts/extensions/test/generated-wrappers | ||||
| /contracts/extensions/generated-artifacts | ||||
| /contracts/extensions/test/generated-artifacts | ||||
| /contracts/exchange-forwarder/generated-wrappers | ||||
| /contracts/exchange-forwarder/test/generated-wrappers | ||||
| /contracts/exchange-forwarder/generated-artifacts | ||||
| /contracts/exchange-forwarder/test/generated-artifacts | ||||
| /contracts/dev-utils/generated-wrappers | ||||
| /contracts/dev-utils/test/generated-wrappers | ||||
| /contracts/dev-utils/generated-artifacts | ||||
| /contracts/dev-utils/test/generated-artifacts | ||||
| /contracts/staking/build/ | ||||
| /contracts/coordinator/build/ | ||||
| /contracts/exchange/build/ | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "tabWidth": 4, | ||||
|     "printWidth": 120, | ||||
|     "trailingComma": all, | ||||
|     "singleQuote": true | ||||
|     "tabWidth": 4, | ||||
|     "singleQuote": true, | ||||
|     "trailingComma": "all" | ||||
| } | ||||
|   | ||||
| @@ -96,10 +96,9 @@ These packages are all under development. See [/contracts/README.md](/contracts/ | ||||
|  | ||||
| #### Private Packages | ||||
|  | ||||
| | Package                                            | Description                                                                      | | ||||
| | -------------------------------------------------- | -------------------------------------------------------------------------------- | | ||||
| | [`@0x/instant`](/packages/instant)                 | A free and flexible way to offer simple crypto purchasing in any app or website. | | ||||
| | [`@0x/testnet-faucets`](/packages/testnet-faucets) | A faucet micro-service that dispenses test ERC20 tokens or Ether                 | | ||||
| | Package                            | Description                                                                      | | ||||
| | ---------------------------------- | -------------------------------------------------------------------------------- | | ||||
| | [`@0x/instant`](/packages/instant) | A free and flexible way to offer simple crypto purchasing in any app or website. | | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
|   | ||||
							
								
								
									
										10
									
								
								contracts/asset-proxy/.npmignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								contracts/asset-proxy/.npmignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # Blacklist all files | ||||
| .* | ||||
| * | ||||
| # Whitelist lib | ||||
| !lib/**/* | ||||
| # Whitelist Solidity contracts | ||||
| !contracts/src/**/* | ||||
| # Blacklist tests in lib | ||||
| /lib/test/* | ||||
| # Package specific ignore | ||||
| @@ -1,4 +1,14 @@ | ||||
| [ | ||||
|     { | ||||
|         "version": "2.3.0-beta.2", | ||||
|         "changes": [ | ||||
|             { | ||||
|                 "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", | ||||
|                 "pr": 2330 | ||||
|             } | ||||
|         ], | ||||
|         "timestamp": 1574030254 | ||||
|     }, | ||||
|     { | ||||
|         "version": "2.3.0-beta.1", | ||||
|         "changes": [ | ||||
|   | ||||
| @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. | ||||
|  | ||||
| CHANGELOG | ||||
|  | ||||
| ## v2.3.0-beta.2 - _November 17, 2019_ | ||||
|  | ||||
|     * Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330) | ||||
|  | ||||
| ## v2.3.0-beta.1 - _November 7, 2019_ | ||||
|  | ||||
|     * ERC20Wrapper and ERC1155ProxyWrapper constructors now require an instance of DevUtilsContract (#2034) | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|     "artifactsDir": "./generated-artifacts", | ||||
|     "artifactsDir": "./test/generated-artifacts", | ||||
|     "contractsDir": "./contracts", | ||||
|     "useDockerisedSolc": false, | ||||
|     "isOfflineMode": false, | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "name": "@0x/contracts-asset-proxy", | ||||
|     "version": "2.3.0-beta.1", | ||||
|     "version": "2.3.0-beta.2", | ||||
|     "engines": { | ||||
|         "node": ">=6.12" | ||||
|     }, | ||||
| @@ -12,7 +12,7 @@ | ||||
|     "scripts": { | ||||
|         "build": "yarn pre_build && tsc -b", | ||||
|         "build:ci": "yarn build", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", | ||||
|         "test": "yarn run_mocha", | ||||
|         "rebuild_and_test": "run-s build test", | ||||
|         "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", | ||||
| @@ -21,21 +21,23 @@ | ||||
|         "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", | ||||
|         "compile": "sol-compiler", | ||||
|         "watch": "sol-compiler -w", | ||||
|         "clean": "shx rm -rf lib generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "coverage:report:text": "istanbul report text", | ||||
|         "coverage:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "profiler:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "coverage:report:lcov": "istanbul report lcov", | ||||
|         "test:circleci": "yarn test", | ||||
|         "contracts:gen": "contracts-gen", | ||||
|         "contracts:gen": "contracts-gen generate", | ||||
|         "contracts:copy": "contracts-gen copy", | ||||
|         "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", | ||||
|         "compile:truffle": "truffle compile" | ||||
|     }, | ||||
|     "config": { | ||||
|         "abis": "./generated-artifacts/@(ERC1155Proxy|ERC20BridgeProxy|ERC20Proxy|ERC721Proxy|Eth2DaiBridge|IAssetData|IAssetProxy|IAssetProxyDispatcher|IAuthorizable|IERC20Bridge|IEth2Dai|IUniswapExchange|IUniswapExchangeFactory|MixinAssetProxyDispatcher|MixinAuthorizable|MultiAssetProxy|Ownable|StaticCallProxy|TestERC20Bridge|TestEth2DaiBridge|TestStaticCallTarget|TestUniswapBridge|UniswapBridge).json", | ||||
|         "publicInterfaceContracts": "ERC1155Proxy,ERC20Proxy,ERC721Proxy,MultiAssetProxy,StaticCallProxy,ERC20BridgeProxy,Eth2DaiBridge,IAssetData,IAssetProxy,UniswapBridge,TestStaticCallTarget", | ||||
|         "abis": "./test/generated-artifacts/@(ERC1155Proxy|ERC20BridgeProxy|ERC20Proxy|ERC721Proxy|Eth2DaiBridge|IAssetData|IAssetProxy|IAssetProxyDispatcher|IAuthorizable|IERC20Bridge|IEth2Dai|IUniswapExchange|IUniswapExchangeFactory|MixinAssetProxyDispatcher|MixinAuthorizable|MultiAssetProxy|Ownable|StaticCallProxy|TestERC20Bridge|TestEth2DaiBridge|TestStaticCallTarget|TestUniswapBridge|UniswapBridge).json", | ||||
|         "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." | ||||
|     }, | ||||
|     "repository": { | ||||
| @@ -48,12 +50,14 @@ | ||||
|     }, | ||||
|     "homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md", | ||||
|     "devDependencies": { | ||||
|         "@0x/abi-gen": "^4.4.0-beta.1", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.1", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.1", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.1", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.1", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.1", | ||||
|         "@0x/abi-gen": "^4.4.0-beta.2", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.2", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.2", | ||||
|         "@0x/contracts-utils": "^3.3.0-beta.2", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.2", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.2", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.2", | ||||
|         "@0x/types": "^2.5.0-beta.2", | ||||
|         "@types/lodash": "4.14.104", | ||||
|         "@types/mocha": "^5.2.7", | ||||
|         "@types/node": "*", | ||||
| @@ -61,6 +65,7 @@ | ||||
|         "chai-as-promised": "^7.1.0", | ||||
|         "chai-bignumber": "^3.0.0", | ||||
|         "dirty-chai": "^2.0.1", | ||||
|         "ethereumjs-util": "^5.1.1", | ||||
|         "make-promises-safe": "^1.1.0", | ||||
|         "mocha": "^6.2.0", | ||||
|         "npm-run-all": "^4.1.2", | ||||
| @@ -71,19 +76,16 @@ | ||||
|         "typescript": "3.0.1" | ||||
|     }, | ||||
|     "dependencies": { | ||||
|         "@0x/base-contract": "^5.5.0-beta.1", | ||||
|         "@0x/contracts-dev-utils": "^0.1.0-beta.1", | ||||
|         "@0x/contracts-erc1155": "^1.2.0-beta.1", | ||||
|         "@0x/contracts-erc20": "^2.3.0-beta.1", | ||||
|         "@0x/contracts-erc721": "^2.2.0-beta.1", | ||||
|         "@0x/contracts-utils": "^3.3.0-beta.1", | ||||
|         "@0x/order-utils": "^8.5.0-beta.1", | ||||
|         "@0x/types": "^2.5.0-beta.1", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.1", | ||||
|         "@0x/utils": "^4.6.0-beta.1", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.1", | ||||
|         "ethereum-types": "^2.2.0-beta.1", | ||||
|         "ethereumjs-util": "^5.1.1", | ||||
|         "@0x/base-contract": "^5.5.0-beta.2", | ||||
|         "@0x/contracts-dev-utils": "^0.1.0-beta.2", | ||||
|         "@0x/contracts-erc1155": "^1.2.0-beta.2", | ||||
|         "@0x/contracts-erc20": "^2.3.0-beta.2", | ||||
|         "@0x/contracts-erc721": "^2.2.0-beta.2", | ||||
|         "@0x/order-utils": "^8.5.0-beta.2", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.2", | ||||
|         "@0x/utils": "^4.6.0-beta.2", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.2", | ||||
|         "ethereum-types": "^2.2.0-beta.2", | ||||
|         "lodash": "^4.17.11" | ||||
|     }, | ||||
|     "publishConfig": { | ||||
|   | ||||
| @@ -12,44 +12,20 @@ import * as ERC721Proxy from '../generated-artifacts/ERC721Proxy.json'; | ||||
| import * as Eth2DaiBridge from '../generated-artifacts/Eth2DaiBridge.json'; | ||||
| import * as IAssetData from '../generated-artifacts/IAssetData.json'; | ||||
| import * as IAssetProxy from '../generated-artifacts/IAssetProxy.json'; | ||||
| import * as IAssetProxyDispatcher from '../generated-artifacts/IAssetProxyDispatcher.json'; | ||||
| import * as IAuthorizable from '../generated-artifacts/IAuthorizable.json'; | ||||
| import * as IERC20Bridge from '../generated-artifacts/IERC20Bridge.json'; | ||||
| import * as IEth2Dai from '../generated-artifacts/IEth2Dai.json'; | ||||
| import * as IUniswapExchange from '../generated-artifacts/IUniswapExchange.json'; | ||||
| import * as IUniswapExchangeFactory from '../generated-artifacts/IUniswapExchangeFactory.json'; | ||||
| import * as MixinAssetProxyDispatcher from '../generated-artifacts/MixinAssetProxyDispatcher.json'; | ||||
| import * as MixinAuthorizable from '../generated-artifacts/MixinAuthorizable.json'; | ||||
| import * as MultiAssetProxy from '../generated-artifacts/MultiAssetProxy.json'; | ||||
| import * as Ownable from '../generated-artifacts/Ownable.json'; | ||||
| import * as StaticCallProxy from '../generated-artifacts/StaticCallProxy.json'; | ||||
| import * as TestERC20Bridge from '../generated-artifacts/TestERC20Bridge.json'; | ||||
| import * as TestEth2DaiBridge from '../generated-artifacts/TestEth2DaiBridge.json'; | ||||
| import * as TestStaticCallTarget from '../generated-artifacts/TestStaticCallTarget.json'; | ||||
| import * as TestUniswapBridge from '../generated-artifacts/TestUniswapBridge.json'; | ||||
| import * as UniswapBridge from '../generated-artifacts/UniswapBridge.json'; | ||||
| export const artifacts = { | ||||
|     MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact, | ||||
|     MixinAuthorizable: MixinAuthorizable as ContractArtifact, | ||||
|     Ownable: Ownable as ContractArtifact, | ||||
|     ERC1155Proxy: ERC1155Proxy as ContractArtifact, | ||||
|     ERC20BridgeProxy: ERC20BridgeProxy as ContractArtifact, | ||||
|     ERC20Proxy: ERC20Proxy as ContractArtifact, | ||||
|     ERC721Proxy: ERC721Proxy as ContractArtifact, | ||||
|     MultiAssetProxy: MultiAssetProxy as ContractArtifact, | ||||
|     StaticCallProxy: StaticCallProxy as ContractArtifact, | ||||
|     ERC20BridgeProxy: ERC20BridgeProxy as ContractArtifact, | ||||
|     Eth2DaiBridge: Eth2DaiBridge as ContractArtifact, | ||||
|     UniswapBridge: UniswapBridge as ContractArtifact, | ||||
|     IAssetData: IAssetData as ContractArtifact, | ||||
|     IAssetProxy: IAssetProxy as ContractArtifact, | ||||
|     IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact, | ||||
|     IAuthorizable: IAuthorizable as ContractArtifact, | ||||
|     IERC20Bridge: IERC20Bridge as ContractArtifact, | ||||
|     IEth2Dai: IEth2Dai as ContractArtifact, | ||||
|     IUniswapExchange: IUniswapExchange as ContractArtifact, | ||||
|     IUniswapExchangeFactory: IUniswapExchangeFactory as ContractArtifact, | ||||
|     TestERC20Bridge: TestERC20Bridge as ContractArtifact, | ||||
|     TestEth2DaiBridge: TestEth2DaiBridge as ContractArtifact, | ||||
|     UniswapBridge: UniswapBridge as ContractArtifact, | ||||
|     TestStaticCallTarget: TestStaticCallTarget as ContractArtifact, | ||||
|     TestUniswapBridge: TestUniswapBridge as ContractArtifact, | ||||
| }; | ||||
|   | ||||
| @@ -13,7 +13,9 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; | ||||
| import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; | ||||
| import * as _ from 'lodash'; | ||||
| 
 | ||||
| import { artifacts, ERC1155ProxyContract, IAssetProxyContract } from '../../src'; | ||||
| import { artifacts } from './artifacts'; | ||||
| 
 | ||||
| import { ERC1155ProxyContract, IAssetProxyContract } from './wrappers'; | ||||
| 
 | ||||
| export class ERC1155ProxyWrapper { | ||||
|     private readonly _tokenOwnerAddresses: string[]; | ||||
| @@ -74,7 +76,7 @@ export class ERC1155ProxyWrapper { | ||||
|             txDefaults, | ||||
|             artifacts, | ||||
|         ); | ||||
|         this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); | ||||
|         this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync(); | ||||
|         return this._proxyContract; | ||||
|     } | ||||
|     /** | ||||
| @@ -111,19 +113,13 @@ export class ERC1155ProxyWrapper { | ||||
|         this._validateProxyContractExistsOrThrow(); | ||||
|         const assetData = | ||||
|             assetData_ === undefined | ||||
|                 ? await this._devUtils.encodeERC1155AssetData.callAsync( | ||||
|                       contractAddress, | ||||
|                       tokensToTransfer, | ||||
|                       valuesToTransfer, | ||||
|                       receiverCallbackData, | ||||
|                   ) | ||||
|                 ? await this._devUtils | ||||
|                       .encodeERC1155AssetData(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData) | ||||
|                       .callAsync() | ||||
|                 : assetData_; | ||||
|         const data = this._assetProxyInterface.transferFrom.getABIEncodedTransactionData( | ||||
|             assetData, | ||||
|             from, | ||||
|             to, | ||||
|             valueMultiplier, | ||||
|         ); | ||||
|         const data = this._assetProxyInterface | ||||
|             .transferFrom(assetData, from, to, valueMultiplier) | ||||
|             .getABIEncodedTransactionData(); | ||||
|         return data; | ||||
|     } | ||||
|     /** | ||||
| @@ -171,19 +167,13 @@ export class ERC1155ProxyWrapper { | ||||
|         this._validateProxyContractExistsOrThrow(); | ||||
|         const assetData = | ||||
|             assetData_ === undefined | ||||
|                 ? await this._devUtils.encodeERC1155AssetData.callAsync( | ||||
|                       contractAddress, | ||||
|                       tokensToTransfer, | ||||
|                       valuesToTransfer, | ||||
|                       receiverCallbackData, | ||||
|                   ) | ||||
|                 ? await this._devUtils | ||||
|                       .encodeERC1155AssetData(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData) | ||||
|                       .callAsync() | ||||
|                 : assetData_; | ||||
|         const data = this._assetProxyInterface.transferFrom.getABIEncodedTransactionData( | ||||
|             assetData, | ||||
|             from, | ||||
|             to, | ||||
|             valueMultiplier, | ||||
|         ); | ||||
|         const data = this._assetProxyInterface | ||||
|             .transferFrom(assetData, from, to, valueMultiplier) | ||||
|             .getABIEncodedTransactionData(); | ||||
|         const txHash = await this._web3Wrapper.sendTransactionAsync({ | ||||
|             to: (this._proxyContract as ERC1155ProxyContract).address, | ||||
|             data, | ||||
| @@ -364,7 +354,7 @@ export class ERC1155ProxyWrapper { | ||||
|         this._validateProxyContractExistsOrThrow(); | ||||
|         const tokenContract = this._getContractFromAddress(contractAddress); | ||||
|         const operator = (this._proxyContract as ERC1155ProxyContract).address; | ||||
|         const didApproveAll = await tokenContract.isApprovedForAll.callAsync(userAddress, operator); | ||||
|         const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync(); | ||||
|         return didApproveAll; | ||||
|     } | ||||
|     public getFungibleTokenIds(): BigNumber[] { | ||||
| @@ -5,7 +5,9 @@ import { BigNumber } from '@0x/utils'; | ||||
| import { ZeroExProvider } from 'ethereum-types'; | ||||
| import * as _ from 'lodash'; | ||||
| 
 | ||||
| import { artifacts, ERC20ProxyContract } from '../../src'; | ||||
| import { artifacts } from './artifacts'; | ||||
| 
 | ||||
| import { ERC20ProxyContract } from './wrappers'; | ||||
| 
 | ||||
| export class ERC20Wrapper { | ||||
|     private readonly _tokenOwnerAddresses: string[]; | ||||
| @@ -56,7 +58,7 @@ export class ERC20Wrapper { | ||||
|             txDefaults, | ||||
|             artifacts, | ||||
|         ); | ||||
|         this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); | ||||
|         this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync(); | ||||
|         return this._proxyContract; | ||||
|     } | ||||
|     public getProxyId(): string { | ||||
| @@ -68,43 +70,39 @@ export class ERC20Wrapper { | ||||
|         this._validateProxyContractExistsOrThrow(); | ||||
|         for (const dummyTokenContract of this._dummyTokenContracts) { | ||||
|             for (const tokenOwnerAddress of this._tokenOwnerAddresses) { | ||||
|                 await dummyTokenContract.setBalance.awaitTransactionSuccessAsync( | ||||
|                     tokenOwnerAddress, | ||||
|                     constants.INITIAL_ERC20_BALANCE, | ||||
|                     { from: this._contractOwnerAddress }, | ||||
|                 ); | ||||
|                 await dummyTokenContract.approve.awaitTransactionSuccessAsync( | ||||
|                     (this._proxyContract as ERC20ProxyContract).address, | ||||
|                     constants.INITIAL_ERC20_ALLOWANCE, | ||||
|                     { from: tokenOwnerAddress }, | ||||
|                 ); | ||||
|                 await dummyTokenContract | ||||
|                     .setBalance(tokenOwnerAddress, constants.INITIAL_ERC20_BALANCE) | ||||
|                     .awaitTransactionSuccessAsync({ from: this._contractOwnerAddress }); | ||||
|                 await dummyTokenContract | ||||
|                     .approve((this._proxyContract as ERC20ProxyContract).address, constants.INITIAL_ERC20_ALLOWANCE) | ||||
|                     .awaitTransactionSuccessAsync({ from: tokenOwnerAddress }); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     public async getBalanceAsync(userAddress: string, assetData: string): Promise<BigNumber> { | ||||
|         const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); | ||||
|         const balance = new BigNumber(await tokenContract.balanceOf.callAsync(userAddress)); | ||||
|         const balance = new BigNumber(await tokenContract.balanceOf(userAddress).callAsync()); | ||||
|         return balance; | ||||
|     } | ||||
|     public async setBalanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> { | ||||
|         const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); | ||||
|         await tokenContract.setBalance.awaitTransactionSuccessAsync( | ||||
|             userAddress, | ||||
|             amount, | ||||
|             { from: this._contractOwnerAddress }, | ||||
|             { pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS }, | ||||
|         ); | ||||
|         await tokenContract | ||||
|             .setBalance(userAddress, amount) | ||||
|             .awaitTransactionSuccessAsync( | ||||
|                 { from: this._contractOwnerAddress }, | ||||
|                 { pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS }, | ||||
|             ); | ||||
|     } | ||||
|     public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> { | ||||
|         const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); | ||||
|         const proxyAddress = (this._proxyContract as ERC20ProxyContract).address; | ||||
|         const allowance = new BigNumber(await tokenContract.allowance.callAsync(userAddress, proxyAddress)); | ||||
|         const allowance = new BigNumber(await tokenContract.allowance(userAddress, proxyAddress).callAsync()); | ||||
|         return allowance; | ||||
|     } | ||||
|     public async setAllowanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> { | ||||
|         const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData); | ||||
|         const proxyAddress = (this._proxyContract as ERC20ProxyContract).address; | ||||
|         await tokenContract.approve.awaitTransactionSuccessAsync(proxyAddress, amount, { from: userAddress }); | ||||
|         await tokenContract.approve(proxyAddress, amount).awaitTransactionSuccessAsync({ from: userAddress }); | ||||
|     } | ||||
|     public async getBalancesAsync(): Promise<ERC20BalancesByOwner> { | ||||
|         this._validateDummyTokenContractsExistOrThrow(); | ||||
| @@ -113,7 +111,7 @@ export class ERC20Wrapper { | ||||
|         const balanceInfo: Array<{ tokenOwnerAddress: string; tokenAddress: string }> = []; | ||||
|         for (const dummyTokenContract of this._dummyTokenContracts) { | ||||
|             for (const tokenOwnerAddress of this._tokenOwnerAddresses) { | ||||
|                 balances.push(await dummyTokenContract.balanceOf.callAsync(tokenOwnerAddress)); | ||||
|                 balances.push(await dummyTokenContract.balanceOf(tokenOwnerAddress).callAsync()); | ||||
|                 balanceInfo.push({ | ||||
|                     tokenOwnerAddress, | ||||
|                     tokenAddress: dummyTokenContract.address, | ||||
| @@ -147,7 +145,7 @@ export class ERC20Wrapper { | ||||
|         return tokenAddresses; | ||||
|     } | ||||
|     private async _getTokenContractFromAssetDataAsync(assetData: string): Promise<DummyERC20TokenContract> { | ||||
|         const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData.callAsync(assetData); // tslint:disable-line:no-unused-variable
 | ||||
|         const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData(assetData).callAsync(); // tslint:disable-line:no-unused-variable
 | ||||
|         const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress); | ||||
|         if (tokenContractIfExists === undefined) { | ||||
|             throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`); | ||||
| @@ -5,7 +5,9 @@ import { BigNumber } from '@0x/utils'; | ||||
| import { ZeroExProvider } from 'ethereum-types'; | ||||
| import * as _ from 'lodash'; | ||||
| 
 | ||||
| import { artifacts, ERC721ProxyContract } from '../../src'; | ||||
| import { artifacts } from './artifacts'; | ||||
| 
 | ||||
| import { ERC721ProxyContract } from './wrappers'; | ||||
| 
 | ||||
| export class ERC721Wrapper { | ||||
|     private readonly _tokenOwnerAddresses: string[]; | ||||
| @@ -44,7 +46,7 @@ export class ERC721Wrapper { | ||||
|             txDefaults, | ||||
|             artifacts, | ||||
|         ); | ||||
|         this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync(); | ||||
|         this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync(); | ||||
|         return this._proxyContract; | ||||
|     } | ||||
|     public getProxyId(): string { | ||||
| @@ -78,7 +80,7 @@ export class ERC721Wrapper { | ||||
|     } | ||||
|     public async doesTokenExistAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> { | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         const owner = await tokenContract.ownerOf.callAsync(tokenId); | ||||
|         const owner = await tokenContract.ownerOf(tokenId).callAsync(); | ||||
|         const doesExist = owner !== constants.NULL_ADDRESS; | ||||
|         return doesExist; | ||||
|     } | ||||
| @@ -93,14 +95,14 @@ export class ERC721Wrapper { | ||||
|     ): Promise<void> { | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         const proxyAddress = (this._proxyContract as ERC721ProxyContract).address; | ||||
|         await tokenContract.setApprovalForAll.awaitTransactionSuccessAsync(proxyAddress, isApproved, { | ||||
|         await tokenContract.setApprovalForAll(proxyAddress, isApproved).awaitTransactionSuccessAsync({ | ||||
|             from: ownerAddress, | ||||
|         }); | ||||
|     } | ||||
|     public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise<void> { | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId); | ||||
|         await tokenContract.approve.awaitTransactionSuccessAsync(to, tokenId, { from: tokenOwner }); | ||||
|         await tokenContract.approve(to, tokenId).awaitTransactionSuccessAsync({ from: tokenOwner }); | ||||
|     } | ||||
|     public async transferFromAsync( | ||||
|         tokenAddress: string, | ||||
| @@ -109,28 +111,28 @@ export class ERC721Wrapper { | ||||
|         userAddress: string, | ||||
|     ): Promise<void> { | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         await tokenContract.transferFrom.awaitTransactionSuccessAsync(currentOwner, userAddress, tokenId, { | ||||
|         await tokenContract.transferFrom(currentOwner, userAddress, tokenId).awaitTransactionSuccessAsync({ | ||||
|             from: currentOwner, | ||||
|         }); | ||||
|     } | ||||
|     public async mintAsync(tokenAddress: string, tokenId: BigNumber, userAddress: string): Promise<void> { | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         await tokenContract.mint.awaitTransactionSuccessAsync(userAddress, tokenId, { | ||||
|         await tokenContract.mint(userAddress, tokenId).awaitTransactionSuccessAsync({ | ||||
|             from: this._contractOwnerAddress, | ||||
|         }); | ||||
|     } | ||||
|     public async burnAsync(tokenAddress: string, tokenId: BigNumber, owner: string): Promise<void> { | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         await tokenContract.burn.awaitTransactionSuccessAsync(owner, tokenId, { from: this._contractOwnerAddress }); | ||||
|         await tokenContract.burn(owner, tokenId).awaitTransactionSuccessAsync({ from: this._contractOwnerAddress }); | ||||
|     } | ||||
|     public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise<string> { | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         const owner = await tokenContract.ownerOf.callAsync(tokenId); | ||||
|         const owner = await tokenContract.ownerOf(tokenId).callAsync(); | ||||
|         return owner; | ||||
|     } | ||||
|     public async isOwnerAsync(userAddress: string, tokenAddress: string, tokenId: BigNumber): Promise<boolean> { | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         const tokenOwner = await tokenContract.ownerOf.callAsync(tokenId); | ||||
|         const tokenOwner = await tokenContract.ownerOf(tokenId).callAsync(); | ||||
|         const isOwner = tokenOwner === userAddress; | ||||
|         return isOwner; | ||||
|     } | ||||
| @@ -138,13 +140,13 @@ export class ERC721Wrapper { | ||||
|         this._validateProxyContractExistsOrThrow(); | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         const operator = (this._proxyContract as ERC721ProxyContract).address; | ||||
|         const didApproveAll = await tokenContract.isApprovedForAll.callAsync(userAddress, operator); | ||||
|         const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync(); | ||||
|         return didApproveAll; | ||||
|     } | ||||
|     public async isProxyApprovedAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> { | ||||
|         this._validateProxyContractExistsOrThrow(); | ||||
|         const tokenContract = this._getTokenContractFromAssetData(tokenAddress); | ||||
|         const approvedAddress = await tokenContract.getApproved.callAsync(tokenId); | ||||
|         const approvedAddress = await tokenContract.getApproved(tokenId).callAsync(); | ||||
|         const proxyAddress = (this._proxyContract as ERC721ProxyContract).address; | ||||
|         const isProxyAnApprovedOperator = approvedAddress === proxyAddress; | ||||
|         return isProxyAnApprovedOperator; | ||||
| @@ -161,7 +163,7 @@ export class ERC721Wrapper { | ||||
|                     dummyTokenContract.address | ||||
|                 ]; | ||||
|                 for (const tokenId of initialTokenOwnerIds) { | ||||
|                     tokenOwnerAddresses.push(await dummyTokenContract.ownerOf.callAsync(tokenId)); | ||||
|                     tokenOwnerAddresses.push(await dummyTokenContract.ownerOf(tokenId).callAsync()); | ||||
|                     tokenInfo.push({ | ||||
|                         tokenId, | ||||
|                         tokenAddress: dummyTokenContract.address, | ||||
| @@ -1,3 +1,6 @@ | ||||
| export * from './artifacts'; | ||||
| export * from './wrappers'; | ||||
| export * from '../test/utils'; | ||||
|  | ||||
| export { ERC20Wrapper } from './erc20_wrapper'; | ||||
| export { ERC721Wrapper } from './erc721_wrapper'; | ||||
| export { ERC1155ProxyWrapper } from './erc1155_proxy_wrapper'; | ||||
|   | ||||
| @@ -10,19 +10,7 @@ export * from '../generated-wrappers/erc721_proxy'; | ||||
| export * from '../generated-wrappers/eth2_dai_bridge'; | ||||
| export * from '../generated-wrappers/i_asset_data'; | ||||
| export * from '../generated-wrappers/i_asset_proxy'; | ||||
| export * from '../generated-wrappers/i_asset_proxy_dispatcher'; | ||||
| export * from '../generated-wrappers/i_authorizable'; | ||||
| export * from '../generated-wrappers/i_erc20_bridge'; | ||||
| export * from '../generated-wrappers/i_eth2_dai'; | ||||
| export * from '../generated-wrappers/i_uniswap_exchange'; | ||||
| export * from '../generated-wrappers/i_uniswap_exchange_factory'; | ||||
| export * from '../generated-wrappers/mixin_asset_proxy_dispatcher'; | ||||
| export * from '../generated-wrappers/mixin_authorizable'; | ||||
| export * from '../generated-wrappers/multi_asset_proxy'; | ||||
| export * from '../generated-wrappers/ownable'; | ||||
| export * from '../generated-wrappers/static_call_proxy'; | ||||
| export * from '../generated-wrappers/test_erc20_bridge'; | ||||
| export * from '../generated-wrappers/test_eth2_dai_bridge'; | ||||
| export * from '../generated-wrappers/test_static_call_target'; | ||||
| export * from '../generated-wrappers/test_uniswap_bridge'; | ||||
| export * from '../generated-wrappers/uniswap_bridge'; | ||||
|   | ||||
							
								
								
									
										55
									
								
								contracts/asset-proxy/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								contracts/asset-proxy/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| import { ContractArtifact } from 'ethereum-types'; | ||||
|  | ||||
| import * as ERC1155Proxy from '../test/generated-artifacts/ERC1155Proxy.json'; | ||||
| import * as ERC20BridgeProxy from '../test/generated-artifacts/ERC20BridgeProxy.json'; | ||||
| import * as ERC20Proxy from '../test/generated-artifacts/ERC20Proxy.json'; | ||||
| import * as ERC721Proxy from '../test/generated-artifacts/ERC721Proxy.json'; | ||||
| import * as Eth2DaiBridge from '../test/generated-artifacts/Eth2DaiBridge.json'; | ||||
| import * as IAssetData from '../test/generated-artifacts/IAssetData.json'; | ||||
| import * as IAssetProxy from '../test/generated-artifacts/IAssetProxy.json'; | ||||
| import * as IAssetProxyDispatcher from '../test/generated-artifacts/IAssetProxyDispatcher.json'; | ||||
| import * as IAuthorizable from '../test/generated-artifacts/IAuthorizable.json'; | ||||
| import * as IERC20Bridge from '../test/generated-artifacts/IERC20Bridge.json'; | ||||
| import * as IEth2Dai from '../test/generated-artifacts/IEth2Dai.json'; | ||||
| import * as IUniswapExchange from '../test/generated-artifacts/IUniswapExchange.json'; | ||||
| import * as IUniswapExchangeFactory from '../test/generated-artifacts/IUniswapExchangeFactory.json'; | ||||
| import * as MixinAssetProxyDispatcher from '../test/generated-artifacts/MixinAssetProxyDispatcher.json'; | ||||
| import * as MixinAuthorizable from '../test/generated-artifacts/MixinAuthorizable.json'; | ||||
| import * as MultiAssetProxy from '../test/generated-artifacts/MultiAssetProxy.json'; | ||||
| import * as Ownable from '../test/generated-artifacts/Ownable.json'; | ||||
| import * as StaticCallProxy from '../test/generated-artifacts/StaticCallProxy.json'; | ||||
| import * as TestERC20Bridge from '../test/generated-artifacts/TestERC20Bridge.json'; | ||||
| import * as TestEth2DaiBridge from '../test/generated-artifacts/TestEth2DaiBridge.json'; | ||||
| import * as TestStaticCallTarget from '../test/generated-artifacts/TestStaticCallTarget.json'; | ||||
| import * as TestUniswapBridge from '../test/generated-artifacts/TestUniswapBridge.json'; | ||||
| import * as UniswapBridge from '../test/generated-artifacts/UniswapBridge.json'; | ||||
| export const artifacts = { | ||||
|     MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact, | ||||
|     MixinAuthorizable: MixinAuthorizable as ContractArtifact, | ||||
|     Ownable: Ownable as ContractArtifact, | ||||
|     ERC1155Proxy: ERC1155Proxy as ContractArtifact, | ||||
|     ERC20BridgeProxy: ERC20BridgeProxy as ContractArtifact, | ||||
|     ERC20Proxy: ERC20Proxy as ContractArtifact, | ||||
|     ERC721Proxy: ERC721Proxy as ContractArtifact, | ||||
|     MultiAssetProxy: MultiAssetProxy as ContractArtifact, | ||||
|     StaticCallProxy: StaticCallProxy as ContractArtifact, | ||||
|     Eth2DaiBridge: Eth2DaiBridge as ContractArtifact, | ||||
|     UniswapBridge: UniswapBridge as ContractArtifact, | ||||
|     IAssetData: IAssetData as ContractArtifact, | ||||
|     IAssetProxy: IAssetProxy as ContractArtifact, | ||||
|     IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact, | ||||
|     IAuthorizable: IAuthorizable as ContractArtifact, | ||||
|     IERC20Bridge: IERC20Bridge as ContractArtifact, | ||||
|     IEth2Dai: IEth2Dai as ContractArtifact, | ||||
|     IUniswapExchange: IUniswapExchange as ContractArtifact, | ||||
|     IUniswapExchangeFactory: IUniswapExchangeFactory as ContractArtifact, | ||||
|     TestERC20Bridge: TestERC20Bridge as ContractArtifact, | ||||
|     TestEth2DaiBridge: TestEth2DaiBridge as ContractArtifact, | ||||
|     TestStaticCallTarget: TestStaticCallTarget as ContractArtifact, | ||||
|     TestUniswapBridge: TestUniswapBridge as ContractArtifact, | ||||
| }; | ||||
| @@ -5,7 +5,9 @@ import { BigNumber } from '@0x/utils'; | ||||
| import * as chai from 'chai'; | ||||
| import * as _ from 'lodash'; | ||||
|  | ||||
| import { artifacts, MixinAuthorizableContract } from '../src'; | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| import { MixinAuthorizableContract } from './wrappers'; | ||||
|  | ||||
| chaiSetup.configure(); | ||||
| const expect = chai.expect; | ||||
| @@ -47,21 +49,21 @@ describe('Authorizable', () => { | ||||
|     describe('addAuthorizedAddress', () => { | ||||
|         it('should revert if not called by owner', async () => { | ||||
|             await expectTransactionFailedAsync( | ||||
|                 authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }), | ||||
|                 authorizable.addAuthorizedAddress(notOwner).sendTransactionAsync({ from: notOwner }), | ||||
|                 RevertReason.OnlyContractOwner, | ||||
|             ); | ||||
|         }); | ||||
|  | ||||
|         it('should allow owner to add an authorized address', async () => { | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             const isAuthorized = await authorizable.authorized.callAsync(address); | ||||
|             await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             const isAuthorized = await authorizable.authorized(address).callAsync(); | ||||
|             expect(isAuthorized).to.be.true(); | ||||
|         }); | ||||
|  | ||||
|         it('should revert if owner attempts to authorize a duplicate address', async () => { | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             return expectTransactionFailedAsync( | ||||
|                 authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }), | ||||
|                 authorizable.addAuthorizedAddress(address).sendTransactionAsync({ from: owner }), | ||||
|                 RevertReason.TargetAlreadyAuthorized, | ||||
|             ); | ||||
|         }); | ||||
| @@ -69,23 +71,23 @@ describe('Authorizable', () => { | ||||
|  | ||||
|     describe('removeAuthorizedAddress', () => { | ||||
|         it('should revert if not called by owner', async () => { | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             await expectTransactionFailedAsync( | ||||
|                 authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner }), | ||||
|                 authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: notOwner }), | ||||
|                 RevertReason.OnlyContractOwner, | ||||
|             ); | ||||
|         }); | ||||
|  | ||||
|         it('should allow owner to remove an authorized address', async () => { | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             const isAuthorized = await authorizable.authorized.callAsync(address); | ||||
|             await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             const isAuthorized = await authorizable.authorized(address).callAsync(); | ||||
|             expect(isAuthorized).to.be.false(); | ||||
|         }); | ||||
|  | ||||
|         it('should revert if owner attempts to remove an address that is not authorized', async () => { | ||||
|             return expectTransactionFailedAsync( | ||||
|                 authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { | ||||
|                 authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ | ||||
|                     from: owner, | ||||
|                 }), | ||||
|                 RevertReason.TargetNotAuthorized, | ||||
| @@ -95,10 +97,10 @@ describe('Authorizable', () => { | ||||
|  | ||||
|     describe('removeAuthorizedAddressAtIndex', () => { | ||||
|         it('should revert if not called by owner', async () => { | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             const index = new BigNumber(0); | ||||
|             await expectTransactionFailedAsync( | ||||
|                 authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { | ||||
|                 authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ | ||||
|                     from: notOwner, | ||||
|                 }), | ||||
|                 RevertReason.OnlyContractOwner, | ||||
| @@ -106,10 +108,10 @@ describe('Authorizable', () => { | ||||
|         }); | ||||
|  | ||||
|         it('should revert if index is >= authorities.length', async () => { | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             const index = new BigNumber(1); | ||||
|             return expectTransactionFailedAsync( | ||||
|                 authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { | ||||
|                 authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ | ||||
|                     from: owner, | ||||
|                 }), | ||||
|                 RevertReason.IndexOutOfBounds, | ||||
| @@ -119,7 +121,7 @@ describe('Authorizable', () => { | ||||
|         it('should revert if owner attempts to remove an address that is not authorized', async () => { | ||||
|             const index = new BigNumber(0); | ||||
|             return expectTransactionFailedAsync( | ||||
|                 authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { | ||||
|                 authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({ | ||||
|                     from: owner, | ||||
|                 }), | ||||
|                 RevertReason.TargetNotAuthorized, | ||||
| @@ -129,11 +131,11 @@ describe('Authorizable', () => { | ||||
|         it('should revert if address at index does not match target', async () => { | ||||
|             const address1 = address; | ||||
|             const address2 = notOwner; | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address1, { from: owner }); | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address2, { from: owner }); | ||||
|             await authorizable.addAuthorizedAddress(address1).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             await authorizable.addAuthorizedAddress(address2).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             const address1Index = new BigNumber(0); | ||||
|             return expectTransactionFailedAsync( | ||||
|                 authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, { | ||||
|                 authorizable.removeAuthorizedAddressAtIndex(address2, address1Index).sendTransactionAsync({ | ||||
|                     from: owner, | ||||
|                 }), | ||||
|                 RevertReason.AuthorizedAddressMismatch, | ||||
| @@ -141,26 +143,26 @@ describe('Authorizable', () => { | ||||
|         }); | ||||
|  | ||||
|         it('should allow owner to remove an authorized address', async () => { | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             const index = new BigNumber(0); | ||||
|             await authorizable.removeAuthorizedAddressAtIndex.awaitTransactionSuccessAsync(address, index, { | ||||
|             await authorizable.removeAuthorizedAddressAtIndex(address, index).awaitTransactionSuccessAsync({ | ||||
|                 from: owner, | ||||
|             }); | ||||
|             const isAuthorized = await authorizable.authorized.callAsync(address); | ||||
|             const isAuthorized = await authorizable.authorized(address).callAsync(); | ||||
|             expect(isAuthorized).to.be.false(); | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     describe('getAuthorizedAddresses', () => { | ||||
|         it('should return all authorized addresses', async () => { | ||||
|             const initial = await authorizable.getAuthorizedAddresses.callAsync(); | ||||
|             const initial = await authorizable.getAuthorizedAddresses().callAsync(); | ||||
|             expect(initial).to.have.length(0); | ||||
|             await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             const afterAdd = await authorizable.getAuthorizedAddresses.callAsync(); | ||||
|             await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             const afterAdd = await authorizable.getAuthorizedAddresses().callAsync(); | ||||
|             expect(afterAdd).to.have.length(1); | ||||
|             expect(afterAdd).to.include(address); | ||||
|             await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner }); | ||||
|             const afterRemove = await authorizable.getAuthorizedAddresses.callAsync(); | ||||
|             await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|             const afterRemove = await authorizable.getAuthorizedAddresses().callAsync(); | ||||
|             expect(afterRemove).to.have.length(0); | ||||
|         }); | ||||
|     }); | ||||
|   | ||||
| @@ -15,15 +15,19 @@ import { | ||||
|     txDefaults, | ||||
|     web3Wrapper, | ||||
| } from '@0x/contracts-test-utils'; | ||||
| import { SafeMathRevertErrors } from '@0x/contracts-utils'; | ||||
| import { BlockchainLifecycle } from '@0x/dev-utils'; | ||||
| import { AssetProxyId, RevertReason } from '@0x/types'; | ||||
| import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; | ||||
| import { BigNumber } from '@0x/utils'; | ||||
| import * as chai from 'chai'; | ||||
| import { LogWithDecodedArgs } from 'ethereum-types'; | ||||
| import * as ethUtil from 'ethereumjs-util'; | ||||
| import * as _ from 'lodash'; | ||||
|  | ||||
| import { artifacts, ERC1155ProxyContract, ERC1155ProxyWrapper, IAssetDataContract } from '../src'; | ||||
| import { ERC1155ProxyWrapper } from '../src/erc1155_proxy_wrapper'; | ||||
| import { ERC1155ProxyContract, IAssetDataContract } from '../src/wrappers'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| chaiSetup.configure(); | ||||
| const expect = chai.expect; | ||||
| @@ -74,8 +78,8 @@ describe('ERC1155Proxy', () => { | ||||
|         const usedAddresses = ([owner, notAuthorized, authorized, spender, receiver] = _.slice(accounts, 0, 5)); | ||||
|         erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner); | ||||
|         erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync(); | ||||
|         await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner }); | ||||
|         await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: owner }); | ||||
|         await erc1155Proxy.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner }); | ||||
|         await erc1155Proxy.addAuthorizedAddress(erc1155Proxy.address).awaitTransactionSuccessAsync({ from: owner }); | ||||
|         // deploy & configure ERC1155 tokens and receiver | ||||
|         [erc1155Wrapper] = await erc1155ProxyWrapper.deployDummyContractsAsync(); | ||||
|         erc1155Contract = erc1155Wrapper.getContract(); | ||||
| @@ -119,7 +123,7 @@ describe('ERC1155Proxy', () => { | ||||
|             ); | ||||
|         }); | ||||
|         it('should have an id of 0xa7cb5fb7', async () => { | ||||
|             const proxyId = await erc1155Proxy.getProxyId.callAsync(); | ||||
|             const proxyId = await erc1155Proxy.getProxyId().callAsync(); | ||||
|             const expectedProxyId = AssetProxyId.ERC1155; | ||||
|             expect(proxyId).to.equal(expectedProxyId); | ||||
|         }); | ||||
| @@ -634,12 +638,14 @@ describe('ERC1155Proxy', () => { | ||||
|                 return value.times(valueMultiplier); | ||||
|             }); | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             const extraData = '0102030405060708091001020304050607080910010203040506070809100102'; | ||||
|             const assetDataWithExtraData = `${assetData}${extraData}`; | ||||
|             // check balances before transfer | ||||
| @@ -694,14 +700,16 @@ describe('ERC1155Proxy', () => { | ||||
|                 // create token | ||||
|                 await erc1155Wrapper | ||||
|                     .getContract() | ||||
|                     .createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, { | ||||
|                     .createWithType(tokenToCreate, tokenUri) | ||||
|                     .awaitTransactionSuccessAsync({ | ||||
|                         from: owner, | ||||
|                     }); | ||||
|  | ||||
|                 // mint balance for spender | ||||
|                 await erc1155Wrapper | ||||
|                     .getContract() | ||||
|                     .mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], { | ||||
|                     .mintFungible(tokenToCreate, [spender], [spenderInitialBalance]) | ||||
|                     .awaitTransactionSuccessAsync({ | ||||
|                         from: owner, | ||||
|                     }); | ||||
|             } | ||||
| @@ -739,7 +747,7 @@ describe('ERC1155Proxy', () => { | ||||
|  | ||||
|             // hand encode optimized assetData because our tooling (based on LibAssetData.sol/encodeERC1155AssetData) does not use optimized encoding | ||||
|             const assetDataContract = new IAssetDataContract(constants.NULL_ADDRESS, provider); | ||||
|             const selector = assetDataContract.ERC1155Assets.getSelector(); | ||||
|             const selector = assetDataContract.getSelector('ERC1155Assets'); | ||||
|             const assetDataWithoutContractAddress = | ||||
|                 '0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040102030400000000000000000000000000000000000000000000000000000000'; | ||||
|             const assetData = `${selector}000000000000000000000000${erc1155ContractAddress.substr( | ||||
| @@ -794,14 +802,16 @@ describe('ERC1155Proxy', () => { | ||||
|                 // create token | ||||
|                 await erc1155Wrapper | ||||
|                     .getContract() | ||||
|                     .createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, { | ||||
|                     .createWithType(tokenToCreate, tokenUri) | ||||
|                     .awaitTransactionSuccessAsync({ | ||||
|                         from: owner, | ||||
|                     }); | ||||
|  | ||||
|                 // mint balance for spender | ||||
|                 await erc1155Wrapper | ||||
|                     .getContract() | ||||
|                     .mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], { | ||||
|                     .mintFungible(tokenToCreate, [spender], [spenderInitialBalance]) | ||||
|                     .awaitTransactionSuccessAsync({ | ||||
|                         from: owner, | ||||
|                     }); | ||||
|             } | ||||
| @@ -847,12 +857,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [new BigNumber(2), new BigNumber(2)]; | ||||
|             const valueMultiplier = new BigNumber(2); | ||||
|             // create callback data that is the encoded version of `valuesToTransfer` | ||||
|             const generatedAssetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const generatedAssetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // remove the function selector and contract address from check, as these change on each test | ||||
|             const offsetToTokenIds = 74; | ||||
|             const assetDataSelectorAndContractAddress = generatedAssetData.substr(0, offsetToTokenIds); | ||||
| @@ -919,14 +931,16 @@ describe('ERC1155Proxy', () => { | ||||
|                 // create token | ||||
|                 await erc1155Wrapper | ||||
|                     .getContract() | ||||
|                     .createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, { | ||||
|                     .createWithType(tokenToCreate, tokenUri) | ||||
|                     .awaitTransactionSuccessAsync({ | ||||
|                         from: owner, | ||||
|                     }); | ||||
|  | ||||
|                 // mint balance for spender | ||||
|                 await erc1155Wrapper | ||||
|                     .getContract() | ||||
|                     .mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], { | ||||
|                     .mintFungible(tokenToCreate, [spender], [spenderInitialBalance]) | ||||
|                     .awaitTransactionSuccessAsync({ | ||||
|                         from: owner, | ||||
|                     }); | ||||
|             } | ||||
| @@ -969,12 +983,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [new BigNumber(1), new BigNumber(2)]; | ||||
|             const valueMultiplier = new BigNumber(2); | ||||
|             // create callback data that is the encoded version of `valuesToTransfer` | ||||
|             const generatedAssetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const generatedAssetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // remove the function selector and contract address from check, as these change on each test | ||||
|             const offsetToTokenIds = 74; | ||||
|             const assetDataSelectorAndContractAddress = generatedAssetData.substr(0, offsetToTokenIds); | ||||
| @@ -1032,12 +1048,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // The asset data we just generated will look like this: | ||||
|             // a7cb5fb7 | ||||
|             // 0x         0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 | ||||
| @@ -1079,12 +1097,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // The asset data we just generated will look like this: | ||||
|             // a7cb5fb7 | ||||
|             // 0x         0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 | ||||
| @@ -1130,12 +1150,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // The asset data we just generated will look like this: | ||||
|             // a7cb5fb7 | ||||
|             // 0x         0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 | ||||
| @@ -1181,12 +1203,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // The asset data we just generated will look like this: | ||||
|             // a7cb5fb7 | ||||
|             // 0x         0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 | ||||
| @@ -1232,12 +1256,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // The asset data we just generated will look like this: | ||||
|             // a7cb5fb7 | ||||
|             // 0x         0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 | ||||
| @@ -1284,12 +1310,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // The asset data we just generated will look like this: | ||||
|             // a7cb5fb7 | ||||
|             // 0x         0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 | ||||
| @@ -1331,12 +1359,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // The asset data we just generated will look like this: | ||||
|             // a7cb5fb7 | ||||
|             // 0x         0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 | ||||
| @@ -1382,12 +1412,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // The asset data we just generated will look like this: | ||||
|             // a7cb5fb7 | ||||
|             // 0x         0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 | ||||
| @@ -1429,12 +1461,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             // The asset data we just generated will look like this: | ||||
|             // a7cb5fb7 | ||||
|             // 0x         0000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082 | ||||
| @@ -1480,12 +1514,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             const txData = await erc1155ProxyWrapper.getTransferFromAbiEncodedTxDataAsync( | ||||
|                 spender, | ||||
|                 receiverContract, | ||||
| @@ -1511,12 +1547,14 @@ describe('ERC1155Proxy', () => { | ||||
|             const valuesToTransfer = [fungibleValueToTransferLarge]; | ||||
|             const valueMultiplier = valueMultiplierSmall; | ||||
|             const erc1155ContractAddress = erc1155Wrapper.getContract().address; | ||||
|             const assetData = await devUtils.encodeERC1155AssetData.callAsync( | ||||
|                 erc1155ContractAddress, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeERC1155AssetData( | ||||
|                     erc1155ContractAddress, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                 ) | ||||
|                 .callAsync(); | ||||
|             const txData = await erc1155ProxyWrapper.getTransferFromAbiEncodedTxDataAsync( | ||||
|                 spender, | ||||
|                 receiverContract, | ||||
| @@ -1640,7 +1678,7 @@ describe('ERC1155Proxy', () => { | ||||
|         it('should propagate revert reason from erc1155 contract failure', async () => { | ||||
|             // disable transfers | ||||
|             const shouldRejectTransfer = true; | ||||
|             await erc1155Receiver.setRejectTransferFlag.awaitTransactionSuccessAsync(shouldRejectTransfer, { | ||||
|             await erc1155Receiver.setRejectTransferFlag(shouldRejectTransfer).awaitTransactionSuccessAsync({ | ||||
|                 from: owner, | ||||
|             }); | ||||
|             // setup test parameters | ||||
|   | ||||
| @@ -9,17 +9,15 @@ import { | ||||
|     Numberish, | ||||
|     randomAddress, | ||||
| } from '@0x/contracts-test-utils'; | ||||
| import { AuthorizableRevertErrors } from '@0x/contracts-utils'; | ||||
| import { AssetProxyId } from '@0x/types'; | ||||
| import { AbiEncoder, AuthorizableRevertErrors, BigNumber, StringRevertError } from '@0x/utils'; | ||||
| import { AbiEncoder, BigNumber, StringRevertError } from '@0x/utils'; | ||||
| import { DecodedLogs } from 'ethereum-types'; | ||||
| import * as _ from 'lodash'; | ||||
|  | ||||
| import { | ||||
|     artifacts, | ||||
|     ERC20BridgeProxyContract, | ||||
|     TestERC20BridgeBridgeWithdrawToEventArgs, | ||||
|     TestERC20BridgeContract, | ||||
| } from '../src'; | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| import { ERC20BridgeProxyContract, TestERC20BridgeContract } from './wrappers'; | ||||
|  | ||||
| blockchainTests.resets('ERC20BridgeProxy unit tests', env => { | ||||
|     const PROXY_ID = AssetProxyId.ERC20Bridge; | ||||
| @@ -44,8 +42,8 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { | ||||
|             env.txDefaults, | ||||
|             artifacts, | ||||
|         ); | ||||
|         testTokenAddress = await bridgeContract.testToken.callAsync(); | ||||
|         await assetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(owner); | ||||
|         testTokenAddress = await bridgeContract.testToken().callAsync(); | ||||
|         await assetProxy.addAuthorizedAddress(owner).awaitTransactionSuccessAsync(); | ||||
|     }); | ||||
|  | ||||
|     interface AssetDataOpts { | ||||
| @@ -102,7 +100,7 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { | ||||
|     } | ||||
|  | ||||
|     async function setTestTokenBalanceAsync(_owner: string, balance: Numberish): Promise<void> { | ||||
|         await bridgeContract.setTestTokenBalance.awaitTransactionSuccessAsync(_owner, new BigNumber(balance)); | ||||
|         await bridgeContract.setTestTokenBalance(_owner, new BigNumber(balance)).awaitTransactionSuccessAsync(); | ||||
|     } | ||||
|  | ||||
|     describe('transferFrom()', () => { | ||||
| @@ -132,13 +130,9 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { | ||||
|  | ||||
|         async function transferFromAsync(opts?: Partial<TransferFromOpts>, caller?: string): Promise<DecodedLogs> { | ||||
|             const _opts = createTransferFromOpts(opts); | ||||
|             const { logs } = await assetProxy.transferFrom.awaitTransactionSuccessAsync( | ||||
|                 encodeAssetData(_opts.assetData), | ||||
|                 _opts.from, | ||||
|                 _opts.to, | ||||
|                 new BigNumber(_opts.amount), | ||||
|                 { from: caller }, | ||||
|             ); | ||||
|             const { logs } = await assetProxy | ||||
|                 .transferFrom(encodeAssetData(_opts.assetData), _opts.from, _opts.to, new BigNumber(_opts.amount)) | ||||
|                 .awaitTransactionSuccessAsync({ from: caller }); | ||||
|             return (logs as any) as DecodedLogs; | ||||
|         } | ||||
|  | ||||
| @@ -164,7 +158,7 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { | ||||
|             const opts = createTransferFromOpts(); | ||||
|             const logs = await transferFromAsync(opts); | ||||
|             expect(logs.length).to.eq(1); | ||||
|             const args = logs[0].args as TestERC20BridgeBridgeWithdrawToEventArgs; | ||||
|             const args = logs[0].args; | ||||
|             expect(args.tokenAddress).to.eq(opts.assetData.tokenAddress); | ||||
|             expect(args.from).to.eq(opts.from); | ||||
|             expect(args.to).to.eq(opts.to); | ||||
| @@ -180,12 +174,9 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { | ||||
|         it('fails if asset data is truncated', async () => { | ||||
|             const opts = createTransferFromOpts(); | ||||
|             const truncatedAssetData = hexSlice(encodeAssetData(opts.assetData), 0, -1); | ||||
|             const tx = assetProxy.transferFrom.awaitTransactionSuccessAsync( | ||||
|                 truncatedAssetData, | ||||
|                 opts.from, | ||||
|                 opts.to, | ||||
|                 new BigNumber(opts.amount), | ||||
|             ); | ||||
|             const tx = assetProxy | ||||
|                 .transferFrom(truncatedAssetData, opts.from, opts.to, new BigNumber(opts.amount)) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             return expect(tx).to.be.rejected(); | ||||
|         }); | ||||
|  | ||||
| @@ -281,18 +272,18 @@ blockchainTests.resets('ERC20BridgeProxy unit tests', env => { | ||||
|         it('retrieves the balance of the encoded token', async () => { | ||||
|             const _owner = randomAddress(); | ||||
|             const balance = getRandomInteger(1, 100e18); | ||||
|             await bridgeContract.setTestTokenBalance.awaitTransactionSuccessAsync(_owner, balance); | ||||
|             await bridgeContract.setTestTokenBalance(_owner, balance).awaitTransactionSuccessAsync(); | ||||
|             const assetData = createAssetData({ | ||||
|                 tokenAddress: testTokenAddress, | ||||
|             }); | ||||
|             const actualBalance = await assetProxy.balanceOf.callAsync(encodeAssetData(assetData), _owner); | ||||
|             const actualBalance = await assetProxy.balanceOf(encodeAssetData(assetData), _owner).callAsync(); | ||||
|             expect(actualBalance).to.bignumber.eq(balance); | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     describe('getProxyId()', () => { | ||||
|         it('returns the correct proxy ID', async () => { | ||||
|             const proxyId = await assetProxy.getProxyId.callAsync(); | ||||
|             const proxyId = await assetProxy.getProxyId().callAsync(); | ||||
|             expect(proxyId).to.eq(PROXY_ID); | ||||
|         }); | ||||
|     }); | ||||
|   | ||||
| @@ -8,24 +8,23 @@ import { | ||||
|     hexRandom, | ||||
|     Numberish, | ||||
|     randomAddress, | ||||
|     TransactionHelper, | ||||
| } from '@0x/contracts-test-utils'; | ||||
| import { AssetProxyId } from '@0x/types'; | ||||
| import { BigNumber, RawRevertError } from '@0x/utils'; | ||||
| import { DecodedLogs } from 'ethereum-types'; | ||||
| import * as _ from 'lodash'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| import { | ||||
|     artifacts, | ||||
|     TestEth2DaiBridgeContract, | ||||
|     TestEth2DaiBridgeEvents, | ||||
|     TestEth2DaiBridgeSellAllAmountEventArgs, | ||||
|     TestEth2DaiBridgeTokenApproveEventArgs, | ||||
|     TestEth2DaiBridgeTokenTransferEventArgs, | ||||
| } from '../src'; | ||||
| } from './wrappers'; | ||||
|  | ||||
| blockchainTests.resets('Eth2DaiBridge unit tests', env => { | ||||
|     const txHelper = new TransactionHelper(env.web3Wrapper, artifacts); | ||||
|     let testContract: TestEth2DaiBridgeContract; | ||||
|  | ||||
|     before(async () => { | ||||
| @@ -40,7 +39,7 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { | ||||
|     describe('isValidSignature()', () => { | ||||
|         it('returns success bytes', async () => { | ||||
|             const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381'; | ||||
|             const result = await testContract.isValidSignature.callAsync(hexRandom(), hexRandom(_.random(0, 32))); | ||||
|             const result = await testContract.isValidSignature(hexRandom(), hexRandom(_.random(0, 32))).callAsync(); | ||||
|             expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE); | ||||
|         }); | ||||
|     }); | ||||
| @@ -80,32 +79,30 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { | ||||
|         async function withdrawToAsync(opts?: Partial<WithdrawToOpts>): Promise<WithdrawToResult> { | ||||
|             const _opts = createWithdrawToOpts(opts); | ||||
|             // Set the fill behavior. | ||||
|             await testContract.setFillBehavior.awaitTransactionSuccessAsync( | ||||
|                 _opts.revertReason, | ||||
|                 new BigNumber(_opts.fillAmount), | ||||
|             ); | ||||
|             await testContract | ||||
|                 .setFillBehavior(_opts.revertReason, new BigNumber(_opts.fillAmount)) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             // Create tokens and balances. | ||||
|             if (_opts.fromTokenAddress === undefined) { | ||||
|                 [_opts.fromTokenAddress] = await txHelper.getResultAndReceiptAsync( | ||||
|                     testContract.createToken, | ||||
|                     new BigNumber(_opts.fromTokenBalance), | ||||
|                 ); | ||||
|                 const createTokenFn = testContract.createToken(new BigNumber(_opts.fromTokenBalance)); | ||||
|                 _opts.fromTokenAddress = await createTokenFn.callAsync(); | ||||
|                 await createTokenFn.awaitTransactionSuccessAsync(); | ||||
|             } | ||||
|             if (_opts.toTokenAddress === undefined) { | ||||
|                 [_opts.toTokenAddress] = await txHelper.getResultAndReceiptAsync( | ||||
|                     testContract.createToken, | ||||
|                     constants.ZERO_AMOUNT, | ||||
|                 ); | ||||
|                 const createTokenFn = testContract.createToken(constants.ZERO_AMOUNT); | ||||
|                 _opts.toTokenAddress = await createTokenFn.callAsync(); | ||||
|                 await createTokenFn.awaitTransactionSuccessAsync(); | ||||
|             } | ||||
|             // Set the transfer behavior of `toTokenAddress`. | ||||
|             await testContract.setTransferBehavior.awaitTransactionSuccessAsync( | ||||
|                 _opts.toTokenAddress, | ||||
|                 _opts.toTokentransferRevertReason, | ||||
|                 _opts.toTokenTransferReturnData, | ||||
|             ); | ||||
|             await testContract | ||||
|                 .setTransferBehavior( | ||||
|                     _opts.toTokenAddress, | ||||
|                     _opts.toTokentransferRevertReason, | ||||
|                     _opts.toTokenTransferReturnData, | ||||
|                 ) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             // Call bridgeTransferFrom(). | ||||
|             const [result, { logs }] = await txHelper.getResultAndReceiptAsync( | ||||
|                 testContract.bridgeTransferFrom, | ||||
|             const bridgeTransferFromFn = testContract.bridgeTransferFrom( | ||||
|                 // "to" token address | ||||
|                 _opts.toTokenAddress, | ||||
|                 // Random from address. | ||||
| @@ -116,6 +113,8 @@ blockchainTests.resets('Eth2DaiBridge unit tests', env => { | ||||
|                 // ABI-encode the "from" token address as the bridge data. | ||||
|                 hexLeftPad(_opts.fromTokenAddress as string), | ||||
|             ); | ||||
|             const result = await bridgeTransferFromFn.callAsync(); | ||||
|             const { logs } = await bridgeTransferFromFn.awaitTransactionSuccessAsync(); | ||||
|             return { | ||||
|                 opts: _opts, | ||||
|                 result, | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -14,7 +14,9 @@ import { AbiEncoder, BigNumber } from '@0x/utils'; | ||||
| import * as chai from 'chai'; | ||||
| import * as ethUtil from 'ethereumjs-util'; | ||||
|  | ||||
| import { artifacts, IAssetProxyContract, StaticCallProxyContract, TestStaticCallTargetContract } from '../src'; | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| import { IAssetProxyContract, StaticCallProxyContract, TestStaticCallTargetContract } from './wrappers'; | ||||
|  | ||||
| chaiSetup.configure(); | ||||
| const expect = chai.expect; | ||||
| @@ -79,26 +81,21 @@ describe('StaticCallProxy', () => { | ||||
|             ); | ||||
|         }); | ||||
|         it('should have an id of 0xc339d10a', async () => { | ||||
|             const proxyId = await staticCallProxy.getProxyId.callAsync(); | ||||
|             const proxyId = await staticCallProxy.getProxyId().callAsync(); | ||||
|             const expectedProxyId = AssetProxyId.StaticCall; | ||||
|             expect(proxyId).to.equal(expectedProxyId); | ||||
|         }); | ||||
|     }); | ||||
|     describe('transferFrom', () => { | ||||
|         it('should revert if assetData lies outside the bounds of calldata', async () => { | ||||
|             const staticCallData = staticCallTarget.noInputFunction.getABIEncodedTransactionData(); | ||||
|             const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData(); | ||||
|             const expectedResultHash = constants.KECCAK256_NULL; | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             const txData = staticCallProxy.transferFrom.getABIEncodedTransactionData( | ||||
|                 assetData, | ||||
|                 fromAddress, | ||||
|                 toAddress, | ||||
|                 amount, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             const txData = staticCallProxy | ||||
|                 .transferFrom(assetData, fromAddress, toAddress, amount) | ||||
|                 .getABIEncodedTransactionData(); | ||||
|             const offsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000080'; | ||||
|             const txDataEndBuffer = ethUtil.toBuffer((txData.length - 2) / 2 - 4); | ||||
|             const paddedTxDataEndBuffer = ethUtil.setLengthLeft(txDataEndBuffer, 32); | ||||
| @@ -116,25 +113,21 @@ describe('StaticCallProxy', () => { | ||||
|         it('should revert if the length of assetData is less than 100 bytes', async () => { | ||||
|             const staticCallData = constants.NULL_BYTES; | ||||
|             const expectedResultHash = constants.KECCAK256_NULL; | ||||
|             const assetData = (await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             )).slice(0, -128); | ||||
|             const assetData = (await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync()).slice(0, -128); | ||||
|             const assetDataByteLen = (assetData.length - 2) / 2; | ||||
|             expect((assetDataByteLen - 4) % 32).to.equal(0); | ||||
|             await expectTransactionFailedWithoutReasonAsync( | ||||
|                 staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), | ||||
|                 staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), | ||||
|             ); | ||||
|         }); | ||||
|         it('should revert if the offset to `staticCallData` points to outside of assetData', async () => { | ||||
|             const staticCallData = staticCallTarget.noInputFunction.getABIEncodedTransactionData(); | ||||
|             const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData(); | ||||
|             const expectedResultHash = constants.KECCAK256_NULL; | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             const offsetToStaticCallData = '0000000000000000000000000000000000000000000000000000000000000060'; | ||||
|             const assetDataEndBuffer = ethUtil.toBuffer((assetData.length - 2) / 2 - 4); | ||||
|             const paddedAssetDataEndBuffer = ethUtil.setLengthLeft(assetDataEndBuffer, 32); | ||||
| @@ -145,94 +138,88 @@ describe('StaticCallProxy', () => { | ||||
|                 invalidOffsetToStaticCallData, | ||||
|             )}${newStaticCallData}`; | ||||
|             await expectTransactionFailedWithoutReasonAsync( | ||||
|                 staticCallProxy.transferFrom.sendTransactionAsync(badAssetData, fromAddress, toAddress, amount), | ||||
|                 staticCallProxy.transferFrom(badAssetData, fromAddress, toAddress, amount).sendTransactionAsync(), | ||||
|             ); | ||||
|         }); | ||||
|         it('should revert if the callTarget attempts to write to state', async () => { | ||||
|             const staticCallData = staticCallTarget.updateState.getABIEncodedTransactionData(); | ||||
|             const staticCallData = staticCallTarget.updateState().getABIEncodedTransactionData(); | ||||
|             const expectedResultHash = constants.KECCAK256_NULL; | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             await expectTransactionFailedWithoutReasonAsync( | ||||
|                 staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), | ||||
|                 staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), | ||||
|             ); | ||||
|         }); | ||||
|         it('should revert with data provided by the callTarget if the staticcall reverts', async () => { | ||||
|             const staticCallData = staticCallTarget.assertEvenNumber.getABIEncodedTransactionData(new BigNumber(1)); | ||||
|             const staticCallData = staticCallTarget.assertEvenNumber(new BigNumber(1)).getABIEncodedTransactionData(); | ||||
|             const expectedResultHash = constants.KECCAK256_NULL; | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             await expectTransactionFailedAsync( | ||||
|                 staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), | ||||
|                 staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), | ||||
|                 RevertReason.TargetNotEven, | ||||
|             ); | ||||
|         }); | ||||
|         it('should revert if the hash of the output is different than expected expected', async () => { | ||||
|             const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(0)); | ||||
|             const staticCallData = staticCallTarget.isOddNumber(new BigNumber(0)).getABIEncodedTransactionData(); | ||||
|             const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); | ||||
|             const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             await expectTransactionFailedAsync( | ||||
|                 staticCallProxy.transferFrom.sendTransactionAsync(assetData, fromAddress, toAddress, amount), | ||||
|                 staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(), | ||||
|                 RevertReason.UnexpectedStaticCallResult, | ||||
|             ); | ||||
|         }); | ||||
|         it('should be successful if a function call with no inputs and no outputs is successful', async () => { | ||||
|             const staticCallData = staticCallTarget.noInputFunction.getABIEncodedTransactionData(); | ||||
|             const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData(); | ||||
|             const expectedResultHash = constants.KECCAK256_NULL; | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             await staticCallProxy | ||||
|                 .transferFrom(assetData, fromAddress, toAddress, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|         it('should be successful if the staticCallTarget is not a contract and no return value is expected', async () => { | ||||
|             const staticCallData = '0x0102030405060708'; | ||||
|             const expectedResultHash = constants.KECCAK256_NULL; | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 toAddress, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(toAddress, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             await staticCallProxy | ||||
|                 .transferFrom(assetData, fromAddress, toAddress, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|         it('should be successful if a function call with one static input returns the correct value', async () => { | ||||
|             const staticCallData = staticCallTarget.isOddNumber.getABIEncodedTransactionData(new BigNumber(1)); | ||||
|             const staticCallData = staticCallTarget.isOddNumber(new BigNumber(1)).getABIEncodedTransactionData(); | ||||
|             const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001'); | ||||
|             const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer)); | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             await staticCallProxy | ||||
|                 .transferFrom(assetData, fromAddress, toAddress, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|         it('should be successful if a function with one dynamic input is successful', async () => { | ||||
|             const dynamicInput = '0x0102030405060708'; | ||||
|             const staticCallData = staticCallTarget.dynamicInputFunction.getABIEncodedTransactionData(dynamicInput); | ||||
|             const staticCallData = staticCallTarget.dynamicInputFunction(dynamicInput).getABIEncodedTransactionData(); | ||||
|             const expectedResultHash = constants.KECCAK256_NULL; | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             await staticCallProxy | ||||
|                 .transferFrom(assetData, fromAddress, toAddress, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|         it('should be successful if a function call returns a complex type', async () => { | ||||
|             const a = new BigNumber(1); | ||||
|             const b = new BigNumber(2); | ||||
|             const staticCallData = staticCallTarget.returnComplexType.getABIEncodedTransactionData(a, b); | ||||
|             const staticCallData = staticCallTarget.returnComplexType(a, b).getABIEncodedTransactionData(); | ||||
|             const abiEncoder = new AbiEncoder.DynamicBytes({ | ||||
|                 name: '', | ||||
|                 type: 'bytes', | ||||
| @@ -245,12 +232,12 @@ describe('StaticCallProxy', () => { | ||||
|             const expectedResultHash = ethUtil.bufferToHex( | ||||
|                 ethUtil.sha3(ethUtil.toBuffer(encodedExpectedResultWithOffset)), | ||||
|             ); | ||||
|             const assetData = await devUtils.encodeStaticCallAssetData.callAsync( | ||||
|                 staticCallTarget.address, | ||||
|                 staticCallData, | ||||
|                 expectedResultHash, | ||||
|             ); | ||||
|             await staticCallProxy.transferFrom.awaitTransactionSuccessAsync(assetData, fromAddress, toAddress, amount); | ||||
|             const assetData = await devUtils | ||||
|                 .encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash) | ||||
|                 .callAsync(); | ||||
|             await staticCallProxy | ||||
|                 .transferFrom(assetData, fromAddress, toAddress, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|     }); | ||||
| }); | ||||
|   | ||||
| @@ -9,15 +9,15 @@ import { | ||||
|     hexRandom, | ||||
|     Numberish, | ||||
|     randomAddress, | ||||
|     TransactionHelper, | ||||
| } from '@0x/contracts-test-utils'; | ||||
| import { AssetProxyId } from '@0x/types'; | ||||
| import { BigNumber } from '@0x/utils'; | ||||
| import { DecodedLogs } from 'ethereum-types'; | ||||
| import * as _ from 'lodash'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| import { | ||||
|     artifacts, | ||||
|     TestUniswapBridgeContract, | ||||
|     TestUniswapBridgeEthToTokenTransferInputEventArgs as EthToTokenTransferInputArgs, | ||||
|     TestUniswapBridgeEvents as ContractEvents, | ||||
| @@ -27,10 +27,9 @@ import { | ||||
|     TestUniswapBridgeTokenTransferEventArgs as TokenTransferArgs, | ||||
|     TestUniswapBridgeWethDepositEventArgs as WethDepositArgs, | ||||
|     TestUniswapBridgeWethWithdrawEventArgs as WethWithdrawArgs, | ||||
| } from '../src'; | ||||
| } from './wrappers'; | ||||
|  | ||||
| blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|     const txHelper = new TransactionHelper(env.web3Wrapper, artifacts); | ||||
|     let testContract: TestUniswapBridgeContract; | ||||
|     let wethTokenAddress: string; | ||||
|  | ||||
| @@ -41,13 +40,13 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|             env.txDefaults, | ||||
|             artifacts, | ||||
|         ); | ||||
|         wethTokenAddress = await testContract.wethToken.callAsync(); | ||||
|         wethTokenAddress = await testContract.wethToken().callAsync(); | ||||
|     }); | ||||
|  | ||||
|     describe('isValidSignature()', () => { | ||||
|         it('returns success bytes', async () => { | ||||
|             const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381'; | ||||
|             const result = await testContract.isValidSignature.callAsync(hexRandom(), hexRandom(_.random(0, 32))); | ||||
|             const result = await testContract.isValidSignature(hexRandom(), hexRandom(_.random(0, 32))).callAsync(); | ||||
|             expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE); | ||||
|         }); | ||||
|     }); | ||||
| @@ -89,35 +88,35 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|  | ||||
|         async function withdrawToAsync(opts?: Partial<WithdrawToOpts>): Promise<WithdrawToResult> { | ||||
|             const _opts = createWithdrawToOpts(opts); | ||||
|             const callData = { value: new BigNumber(_opts.exchangeFillAmount) }; | ||||
|             // Create the "from" token and exchange. | ||||
|             [[_opts.fromTokenAddress]] = await txHelper.getResultAndReceiptAsync( | ||||
|                 testContract.createTokenAndExchange, | ||||
|             const createFromTokenFn = testContract.createTokenAndExchange( | ||||
|                 _opts.fromTokenAddress, | ||||
|                 _opts.exchangeRevertReason, | ||||
|                 { value: new BigNumber(_opts.exchangeFillAmount) }, | ||||
|             ); | ||||
|             [_opts.fromTokenAddress] = await createFromTokenFn.callAsync(callData); | ||||
|             await createFromTokenFn.awaitTransactionSuccessAsync(callData); | ||||
|  | ||||
|             // Create the "to" token and exchange. | ||||
|             [[_opts.toTokenAddress]] = await txHelper.getResultAndReceiptAsync( | ||||
|                 testContract.createTokenAndExchange, | ||||
|             const createToTokenFn = testContract.createTokenAndExchange( | ||||
|                 _opts.toTokenAddress, | ||||
|                 _opts.exchangeRevertReason, | ||||
|                 { value: new BigNumber(_opts.exchangeFillAmount) }, | ||||
|             ); | ||||
|             await testContract.setTokenRevertReason.awaitTransactionSuccessAsync( | ||||
|                 _opts.toTokenAddress, | ||||
|                 _opts.toTokenRevertReason, | ||||
|             ); | ||||
|             await testContract.setTokenRevertReason.awaitTransactionSuccessAsync( | ||||
|                 _opts.fromTokenAddress, | ||||
|                 _opts.fromTokenRevertReason, | ||||
|             ); | ||||
|             [_opts.toTokenAddress] = await createToTokenFn.callAsync(callData); | ||||
|             await createToTokenFn.awaitTransactionSuccessAsync(callData); | ||||
|  | ||||
|             await testContract | ||||
|                 .setTokenRevertReason(_opts.toTokenAddress, _opts.toTokenRevertReason) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             await testContract | ||||
|                 .setTokenRevertReason(_opts.fromTokenAddress, _opts.fromTokenRevertReason) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             // Set the token balance for the token we're converting from. | ||||
|             await testContract.setTokenBalance.awaitTransactionSuccessAsync(_opts.fromTokenAddress, { | ||||
|             await testContract.setTokenBalance(_opts.fromTokenAddress).awaitTransactionSuccessAsync({ | ||||
|                 value: new BigNumber(_opts.fromTokenBalance), | ||||
|             }); | ||||
|             // Call bridgeTransferFrom(). | ||||
|             const [result, receipt] = await txHelper.getResultAndReceiptAsync( | ||||
|                 testContract.bridgeTransferFrom, | ||||
|             const bridgeTransferFromFn = testContract.bridgeTransferFrom( | ||||
|                 // The "to" token address. | ||||
|                 _opts.toTokenAddress, | ||||
|                 // The "from" address. | ||||
| @@ -129,6 +128,8 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|                 // ABI-encoded "from" token address. | ||||
|                 hexLeftPad(_opts.fromTokenAddress), | ||||
|             ); | ||||
|             const result = await bridgeTransferFromFn.callAsync(); | ||||
|             const receipt = await bridgeTransferFromFn.awaitTransactionSuccessAsync(); | ||||
|             return { | ||||
|                 opts: _opts, | ||||
|                 result, | ||||
| @@ -138,7 +139,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|         } | ||||
|  | ||||
|         async function getExchangeForTokenAsync(tokenAddress: string): Promise<string> { | ||||
|             return testContract.getExchange.callAsync(tokenAddress); | ||||
|             return testContract.getExchange(tokenAddress).callAsync(); | ||||
|         } | ||||
|  | ||||
|         it('returns magic bytes on success', async () => { | ||||
| @@ -147,11 +148,9 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|         }); | ||||
|  | ||||
|         it('just transfers tokens to `to` if the same tokens are in play', async () => { | ||||
|             const [[tokenAddress]] = await txHelper.getResultAndReceiptAsync( | ||||
|                 testContract.createTokenAndExchange, | ||||
|                 constants.NULL_ADDRESS, | ||||
|                 '', | ||||
|             ); | ||||
|             const createTokenFn = await testContract.createTokenAndExchange(constants.NULL_ADDRESS, ''); | ||||
|             const [tokenAddress] = await createTokenFn.callAsync(); | ||||
|             await createTokenFn.awaitTransactionSuccessAsync(); | ||||
|             const { opts, result, logs } = await withdrawToAsync({ | ||||
|                 fromTokenAddress: tokenAddress, | ||||
|                 toTokenAddress: tokenAddress, | ||||
| @@ -203,14 +202,16 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|             }); | ||||
|  | ||||
|             it('fails if "from" token does not exist', async () => { | ||||
|                 const tx = testContract.bridgeTransferFrom.awaitTransactionSuccessAsync( | ||||
|                     randomAddress(), | ||||
|                     randomAddress(), | ||||
|                     randomAddress(), | ||||
|                     getRandomInteger(1, 1e18), | ||||
|                     hexLeftPad(randomAddress()), | ||||
|                 ); | ||||
|                 return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); | ||||
|                 const tx = testContract | ||||
|                     .bridgeTransferFrom( | ||||
|                         randomAddress(), | ||||
|                         randomAddress(), | ||||
|                         randomAddress(), | ||||
|                         getRandomInteger(1, 1e18), | ||||
|                         hexLeftPad(randomAddress()), | ||||
|                     ) | ||||
|                     .awaitTransactionSuccessAsync(); | ||||
|                 return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); | ||||
|             }); | ||||
|  | ||||
|             it('fails if the exchange fails', async () => { | ||||
| @@ -218,7 +219,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|                 const tx = withdrawToAsync({ | ||||
|                     exchangeRevertReason: revertReason, | ||||
|                 }); | ||||
|                 return expect(tx).to.revertWith(revertReason); | ||||
|                 return expect(tx).to.eventually.be.rejectedWith(revertReason); | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
| @@ -275,14 +276,16 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|             }); | ||||
|  | ||||
|             it('fails if "from" token does not exist', async () => { | ||||
|                 const tx = testContract.bridgeTransferFrom.awaitTransactionSuccessAsync( | ||||
|                     randomAddress(), | ||||
|                     randomAddress(), | ||||
|                     randomAddress(), | ||||
|                     getRandomInteger(1, 1e18), | ||||
|                     hexLeftPad(wethTokenAddress), | ||||
|                 ); | ||||
|                 return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); | ||||
|                 const tx = testContract | ||||
|                     .bridgeTransferFrom( | ||||
|                         randomAddress(), | ||||
|                         randomAddress(), | ||||
|                         randomAddress(), | ||||
|                         getRandomInteger(1, 1e18), | ||||
|                         hexLeftPad(wethTokenAddress), | ||||
|                     ) | ||||
|                     .awaitTransactionSuccessAsync(); | ||||
|                 return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); | ||||
|             }); | ||||
|  | ||||
|             it('fails if `WETH.deposit()` fails', async () => { | ||||
| @@ -291,7 +294,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|                     toTokenAddress: wethTokenAddress, | ||||
|                     toTokenRevertReason: revertReason, | ||||
|                 }); | ||||
|                 return expect(tx).to.revertWith(revertReason); | ||||
|                 return expect(tx).to.eventually.be.rejectedWith(revertReason); | ||||
|             }); | ||||
|  | ||||
|             it('fails if the exchange fails', async () => { | ||||
| @@ -300,7 +303,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|                     toTokenAddress: wethTokenAddress, | ||||
|                     exchangeRevertReason: revertReason, | ||||
|                 }); | ||||
|                 return expect(tx).to.revertWith(revertReason); | ||||
|                 return expect(tx).to.eventually.be.rejectedWith(revertReason); | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
| @@ -333,14 +336,16 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|             }); | ||||
|  | ||||
|             it('fails if "to" token does not exist', async () => { | ||||
|                 const tx = testContract.bridgeTransferFrom.awaitTransactionSuccessAsync( | ||||
|                     wethTokenAddress, | ||||
|                     randomAddress(), | ||||
|                     randomAddress(), | ||||
|                     getRandomInteger(1, 1e18), | ||||
|                     hexLeftPad(randomAddress()), | ||||
|                 ); | ||||
|                 return expect(tx).to.revertWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); | ||||
|                 const tx = testContract | ||||
|                     .bridgeTransferFrom( | ||||
|                         wethTokenAddress, | ||||
|                         randomAddress(), | ||||
|                         randomAddress(), | ||||
|                         getRandomInteger(1, 1e18), | ||||
|                         hexLeftPad(randomAddress()), | ||||
|                     ) | ||||
|                     .awaitTransactionSuccessAsync(); | ||||
|                 return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN'); | ||||
|             }); | ||||
|  | ||||
|             it('fails if the `WETH.withdraw()` fails', async () => { | ||||
| @@ -349,7 +354,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|                     fromTokenAddress: wethTokenAddress, | ||||
|                     fromTokenRevertReason: revertReason, | ||||
|                 }); | ||||
|                 return expect(tx).to.revertWith(revertReason); | ||||
|                 return expect(tx).to.eventually.be.rejectedWith(revertReason); | ||||
|             }); | ||||
|  | ||||
|             it('fails if the exchange fails', async () => { | ||||
| @@ -358,7 +363,7 @@ blockchainTests.resets('UniswapBridge unit tests', env => { | ||||
|                     fromTokenAddress: wethTokenAddress, | ||||
|                     exchangeRevertReason: revertReason, | ||||
|                 }); | ||||
|                 return expect(tx).to.revertWith(revertReason); | ||||
|                 return expect(tx).to.eventually.be.rejectedWith(revertReason); | ||||
|             }); | ||||
|         }); | ||||
|     }); | ||||
|   | ||||
| @@ -1,3 +0,0 @@ | ||||
| export * from './erc20_wrapper'; | ||||
| export * from './erc721_wrapper'; | ||||
| export * from './erc1155_proxy_wrapper'; | ||||
							
								
								
									
										28
									
								
								contracts/asset-proxy/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								contracts/asset-proxy/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| export * from '../test/generated-wrappers/erc1155_proxy'; | ||||
| export * from '../test/generated-wrappers/erc20_bridge_proxy'; | ||||
| export * from '../test/generated-wrappers/erc20_proxy'; | ||||
| export * from '../test/generated-wrappers/erc721_proxy'; | ||||
| export * from '../test/generated-wrappers/eth2_dai_bridge'; | ||||
| export * from '../test/generated-wrappers/i_asset_data'; | ||||
| export * from '../test/generated-wrappers/i_asset_proxy'; | ||||
| export * from '../test/generated-wrappers/i_asset_proxy_dispatcher'; | ||||
| export * from '../test/generated-wrappers/i_authorizable'; | ||||
| export * from '../test/generated-wrappers/i_erc20_bridge'; | ||||
| export * from '../test/generated-wrappers/i_eth2_dai'; | ||||
| export * from '../test/generated-wrappers/i_uniswap_exchange'; | ||||
| export * from '../test/generated-wrappers/i_uniswap_exchange_factory'; | ||||
| export * from '../test/generated-wrappers/mixin_asset_proxy_dispatcher'; | ||||
| export * from '../test/generated-wrappers/mixin_authorizable'; | ||||
| export * from '../test/generated-wrappers/multi_asset_proxy'; | ||||
| export * from '../test/generated-wrappers/ownable'; | ||||
| export * from '../test/generated-wrappers/static_call_proxy'; | ||||
| export * from '../test/generated-wrappers/test_erc20_bridge'; | ||||
| export * from '../test/generated-wrappers/test_eth2_dai_bridge'; | ||||
| export * from '../test/generated-wrappers/test_static_call_target'; | ||||
| export * from '../test/generated-wrappers/test_uniswap_bridge'; | ||||
| export * from '../test/generated-wrappers/uniswap_bridge'; | ||||
| @@ -10,22 +10,33 @@ | ||||
|         "generated-artifacts/Eth2DaiBridge.json", | ||||
|         "generated-artifacts/IAssetData.json", | ||||
|         "generated-artifacts/IAssetProxy.json", | ||||
|         "generated-artifacts/IAssetProxyDispatcher.json", | ||||
|         "generated-artifacts/IAuthorizable.json", | ||||
|         "generated-artifacts/IERC20Bridge.json", | ||||
|         "generated-artifacts/IEth2Dai.json", | ||||
|         "generated-artifacts/IUniswapExchange.json", | ||||
|         "generated-artifacts/IUniswapExchangeFactory.json", | ||||
|         "generated-artifacts/MixinAssetProxyDispatcher.json", | ||||
|         "generated-artifacts/MixinAuthorizable.json", | ||||
|         "generated-artifacts/MultiAssetProxy.json", | ||||
|         "generated-artifacts/Ownable.json", | ||||
|         "generated-artifacts/StaticCallProxy.json", | ||||
|         "generated-artifacts/TestERC20Bridge.json", | ||||
|         "generated-artifacts/TestEth2DaiBridge.json", | ||||
|         "generated-artifacts/TestStaticCallTarget.json", | ||||
|         "generated-artifacts/TestUniswapBridge.json", | ||||
|         "generated-artifacts/UniswapBridge.json" | ||||
|         "generated-artifacts/UniswapBridge.json", | ||||
|         "test/generated-artifacts/ERC1155Proxy.json", | ||||
|         "test/generated-artifacts/ERC20BridgeProxy.json", | ||||
|         "test/generated-artifacts/ERC20Proxy.json", | ||||
|         "test/generated-artifacts/ERC721Proxy.json", | ||||
|         "test/generated-artifacts/Eth2DaiBridge.json", | ||||
|         "test/generated-artifacts/IAssetData.json", | ||||
|         "test/generated-artifacts/IAssetProxy.json", | ||||
|         "test/generated-artifacts/IAssetProxyDispatcher.json", | ||||
|         "test/generated-artifacts/IAuthorizable.json", | ||||
|         "test/generated-artifacts/IERC20Bridge.json", | ||||
|         "test/generated-artifacts/IEth2Dai.json", | ||||
|         "test/generated-artifacts/IUniswapExchange.json", | ||||
|         "test/generated-artifacts/IUniswapExchangeFactory.json", | ||||
|         "test/generated-artifacts/MixinAssetProxyDispatcher.json", | ||||
|         "test/generated-artifacts/MixinAuthorizable.json", | ||||
|         "test/generated-artifacts/MultiAssetProxy.json", | ||||
|         "test/generated-artifacts/Ownable.json", | ||||
|         "test/generated-artifacts/StaticCallProxy.json", | ||||
|         "test/generated-artifacts/TestERC20Bridge.json", | ||||
|         "test/generated-artifacts/TestEth2DaiBridge.json", | ||||
|         "test/generated-artifacts/TestStaticCallTarget.json", | ||||
|         "test/generated-artifacts/TestUniswapBridge.json", | ||||
|         "test/generated-artifacts/UniswapBridge.json" | ||||
|     ], | ||||
|     "exclude": ["./deploy/solc/solc_bin"] | ||||
| } | ||||
|   | ||||
							
								
								
									
										10
									
								
								contracts/coordinator/.npmignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								contracts/coordinator/.npmignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # Blacklist all files | ||||
| .* | ||||
| * | ||||
| # Whitelist lib | ||||
| !lib/**/* | ||||
| # Whitelist Solidity contracts | ||||
| !contracts/src/**/* | ||||
| # Blacklist tests in lib | ||||
| /lib/test/* | ||||
| # Package specific ignore | ||||
| @@ -1,4 +1,22 @@ | ||||
| [ | ||||
|     { | ||||
|         "version": "2.1.0-beta.2", | ||||
|         "changes": [ | ||||
|             { | ||||
|                 "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", | ||||
|                 "pr": 2330 | ||||
|             }, | ||||
|             { | ||||
|                 "note": "Introduced new export CoordinatorRevertErrors", | ||||
|                 "pr": 2321 | ||||
|             }, | ||||
|             { | ||||
|                 "note": "Added dependency on @0x/contracts-utils", | ||||
|                 "pr": 2321 | ||||
|             } | ||||
|         ], | ||||
|         "timestamp": 1574030254 | ||||
|     }, | ||||
|     { | ||||
|         "version": "2.1.0-beta.1", | ||||
|         "changes": [ | ||||
|   | ||||
| @@ -5,6 +5,12 @@ Edit the package's CHANGELOG.json file only. | ||||
|  | ||||
| CHANGELOG | ||||
|  | ||||
| ## v2.1.0-beta.2 - _November 17, 2019_ | ||||
|  | ||||
|     * Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330) | ||||
|     * Introduced new export CoordinatorRevertErrors (#2321) | ||||
|     * Added dependency on @0x/contracts-utils (#2321) | ||||
|  | ||||
| ## v2.1.0-beta.1 - _November 7, 2019_ | ||||
|  | ||||
|     * Dependencies updated | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|     "artifactsDir": "./generated-artifacts", | ||||
|     "artifactsDir": "./test/generated-artifacts", | ||||
|     "contractsDir": "./contracts", | ||||
|     "useDockerisedSolc": false, | ||||
|     "compilerSettings": { | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "name": "@0x/contracts-coordinator", | ||||
|     "version": "2.1.0-beta.1", | ||||
|     "version": "2.1.0-beta.2", | ||||
|     "engines": { | ||||
|         "node": ">=6.12" | ||||
|     }, | ||||
| @@ -12,7 +12,7 @@ | ||||
|     "scripts": { | ||||
|         "build": "yarn pre_build && tsc -b", | ||||
|         "build:ci": "yarn build", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", | ||||
|         "test": "yarn run_mocha", | ||||
|         "rebuild_and_test": "run-s build test", | ||||
|         "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", | ||||
| @@ -21,21 +21,23 @@ | ||||
|         "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", | ||||
|         "compile": "sol-compiler", | ||||
|         "watch": "sol-compiler -w", | ||||
|         "clean": "shx rm -rf lib generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "coverage:report:text": "istanbul report text", | ||||
|         "coverage:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "profiler:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "coverage:report:lcov": "istanbul report lcov", | ||||
|         "test:circleci": "yarn test", | ||||
|         "contracts:gen": "contracts-gen", | ||||
|         "contracts:gen": "contracts-gen generate", | ||||
|         "contracts:copy": "contracts-gen copy", | ||||
|         "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", | ||||
|         "compile:truffle": "truffle compile" | ||||
|     }, | ||||
|     "config": { | ||||
|         "abis": "./generated-artifacts/@(Coordinator|CoordinatorRegistry|ICoordinatorApprovalVerifier|ICoordinatorCore|ICoordinatorRegistryCore|ICoordinatorSignatureValidator|LibConstants|LibCoordinatorApproval|LibCoordinatorRichErrors|LibEIP712CoordinatorDomain|MixinCoordinatorApprovalVerifier|MixinCoordinatorCore|MixinCoordinatorRegistryCore|MixinSignatureValidator).json", | ||||
|         "publicInterfaceContracts": "Coordinator,CoordinatorRegistry,LibCoordinatorApproval,LibCoordinatorRichErrors,LibEIP712CoordinatorDomain,LibConstants", | ||||
|         "abis": "./test/generated-artifacts/@(Coordinator|CoordinatorRegistry|ICoordinatorApprovalVerifier|ICoordinatorCore|ICoordinatorRegistryCore|ICoordinatorSignatureValidator|LibConstants|LibCoordinatorApproval|LibCoordinatorRichErrors|LibEIP712CoordinatorDomain|MixinCoordinatorApprovalVerifier|MixinCoordinatorCore|MixinCoordinatorRegistryCore|MixinSignatureValidator).json", | ||||
|         "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." | ||||
|     }, | ||||
|     "repository": { | ||||
| @@ -48,17 +50,18 @@ | ||||
|     }, | ||||
|     "homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md", | ||||
|     "devDependencies": { | ||||
|         "@0x/abi-gen": "^4.4.0-beta.1", | ||||
|         "@0x/contracts-asset-proxy": "^2.3.0-beta.1", | ||||
|         "@0x/contracts-dev-utils": "^0.1.0-beta.1", | ||||
|         "@0x/contracts-erc20": "^2.3.0-beta.1", | ||||
|         "@0x/contracts-exchange": "^2.2.0-beta.1", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.1", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.1", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.1", | ||||
|         "@0x/order-utils": "^8.5.0-beta.1", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.1", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.1", | ||||
|         "@0x/abi-gen": "^4.4.0-beta.2", | ||||
|         "@0x/contracts-asset-proxy": "^2.3.0-beta.2", | ||||
|         "@0x/contracts-dev-utils": "^0.1.0-beta.2", | ||||
|         "@0x/contracts-erc20": "^2.3.0-beta.2", | ||||
|         "@0x/contracts-exchange": "^2.2.0-beta.2", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.2", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.2", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.2", | ||||
|         "@0x/order-utils": "^8.5.0-beta.2", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.2", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.2", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.2", | ||||
|         "@types/lodash": "4.14.104", | ||||
|         "@types/mocha": "^5.2.7", | ||||
|         "@types/node": "*", | ||||
| @@ -77,13 +80,12 @@ | ||||
|         "typescript": "3.0.1" | ||||
|     }, | ||||
|     "dependencies": { | ||||
|         "@0x/base-contract": "^5.5.0-beta.1", | ||||
|         "@0x/types": "^2.5.0-beta.1", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.1", | ||||
|         "@0x/utils": "^4.6.0-beta.1", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.1", | ||||
|         "ethereum-types": "^2.2.0-beta.1", | ||||
|         "ethereumjs-util": "^5.1.1" | ||||
|         "@0x/base-contract": "^5.5.0-beta.2", | ||||
|         "@0x/contracts-utils": "^3.3.0-beta.2", | ||||
|         "@0x/types": "^2.5.0-beta.2", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.2", | ||||
|         "@0x/utils": "^4.6.0-beta.2", | ||||
|         "ethereum-types": "^2.2.0-beta.2" | ||||
|     }, | ||||
|     "publishConfig": { | ||||
|         "access": "public" | ||||
|   | ||||
| @@ -1,7 +1,8 @@ | ||||
| import { hexConcat, signingUtils } from '@0x/contracts-test-utils'; | ||||
| import { SignatureType, SignedZeroExTransaction } from '@0x/types'; | ||||
| 
 | ||||
| import { hashUtils, SignedCoordinatorApproval } from './index'; | ||||
| import { hashUtils } from './hash_utils'; | ||||
| import { SignedCoordinatorApproval } from './types'; | ||||
| 
 | ||||
| export class ApprovalFactory { | ||||
|     private readonly _privateKey: Buffer; | ||||
| @@ -12,12 +13,16 @@ export class ApprovalFactory { | ||||
|         this._verifyingContractAddress = verifyingContract; | ||||
|     } | ||||
| 
 | ||||
|     public newSignedApproval( | ||||
|     public async newSignedApprovalAsync( | ||||
|         transaction: SignedZeroExTransaction, | ||||
|         txOrigin: string, | ||||
|         signatureType: SignatureType = SignatureType.EthSign, | ||||
|     ): SignedCoordinatorApproval { | ||||
|         const approvalHashBuff = hashUtils.getApprovalHashBuffer(transaction, this._verifyingContractAddress, txOrigin); | ||||
|     ): Promise<SignedCoordinatorApproval> { | ||||
|         const approvalHashBuff = await hashUtils.getApprovalHashBufferAsync( | ||||
|             transaction, | ||||
|             this._verifyingContractAddress, | ||||
|             txOrigin, | ||||
|         ); | ||||
|         const signatureBuff = signingUtils.signMessage(approvalHashBuff, this._privateKey, signatureType); | ||||
|         const signedApproval = { | ||||
|             txOrigin, | ||||
| @@ -7,31 +7,15 @@ import { ContractArtifact } from 'ethereum-types'; | ||||
|  | ||||
| import * as Coordinator from '../generated-artifacts/Coordinator.json'; | ||||
| import * as CoordinatorRegistry from '../generated-artifacts/CoordinatorRegistry.json'; | ||||
| import * as ICoordinatorApprovalVerifier from '../generated-artifacts/ICoordinatorApprovalVerifier.json'; | ||||
| import * as ICoordinatorCore from '../generated-artifacts/ICoordinatorCore.json'; | ||||
| import * as ICoordinatorRegistryCore from '../generated-artifacts/ICoordinatorRegistryCore.json'; | ||||
| import * as ICoordinatorSignatureValidator from '../generated-artifacts/ICoordinatorSignatureValidator.json'; | ||||
| import * as LibConstants from '../generated-artifacts/LibConstants.json'; | ||||
| import * as LibCoordinatorApproval from '../generated-artifacts/LibCoordinatorApproval.json'; | ||||
| import * as LibCoordinatorRichErrors from '../generated-artifacts/LibCoordinatorRichErrors.json'; | ||||
| import * as LibEIP712CoordinatorDomain from '../generated-artifacts/LibEIP712CoordinatorDomain.json'; | ||||
| import * as MixinCoordinatorApprovalVerifier from '../generated-artifacts/MixinCoordinatorApprovalVerifier.json'; | ||||
| import * as MixinCoordinatorCore from '../generated-artifacts/MixinCoordinatorCore.json'; | ||||
| import * as MixinCoordinatorRegistryCore from '../generated-artifacts/MixinCoordinatorRegistryCore.json'; | ||||
| import * as MixinSignatureValidator from '../generated-artifacts/MixinSignatureValidator.json'; | ||||
| export const artifacts = { | ||||
|     Coordinator: Coordinator as ContractArtifact, | ||||
|     MixinCoordinatorApprovalVerifier: MixinCoordinatorApprovalVerifier as ContractArtifact, | ||||
|     MixinCoordinatorCore: MixinCoordinatorCore as ContractArtifact, | ||||
|     MixinSignatureValidator: MixinSignatureValidator as ContractArtifact, | ||||
|     ICoordinatorApprovalVerifier: ICoordinatorApprovalVerifier as ContractArtifact, | ||||
|     ICoordinatorCore: ICoordinatorCore as ContractArtifact, | ||||
|     ICoordinatorSignatureValidator: ICoordinatorSignatureValidator as ContractArtifact, | ||||
|     LibConstants: LibConstants as ContractArtifact, | ||||
|     CoordinatorRegistry: CoordinatorRegistry as ContractArtifact, | ||||
|     LibCoordinatorApproval: LibCoordinatorApproval as ContractArtifact, | ||||
|     LibCoordinatorRichErrors: LibCoordinatorRichErrors as ContractArtifact, | ||||
|     LibEIP712CoordinatorDomain: LibEIP712CoordinatorDomain as ContractArtifact, | ||||
|     CoordinatorRegistry: CoordinatorRegistry as ContractArtifact, | ||||
|     MixinCoordinatorRegistryCore: MixinCoordinatorRegistryCore as ContractArtifact, | ||||
|     ICoordinatorRegistryCore: ICoordinatorRegistryCore as ContractArtifact, | ||||
|     LibConstants: LibConstants as ContractArtifact, | ||||
| }; | ||||
|   | ||||
							
								
								
									
										28
									
								
								contracts/coordinator/src/hash_utils.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								contracts/coordinator/src/hash_utils.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| import { hexConcat } from '@0x/contracts-test-utils'; | ||||
| import { eip712Utils } from '@0x/order-utils'; | ||||
| import { SignedZeroExTransaction } from '@0x/types'; | ||||
| import { signTypedDataUtils } from '@0x/utils'; | ||||
|  | ||||
| export const hashUtils = { | ||||
|     async getApprovalHashBufferAsync( | ||||
|         transaction: SignedZeroExTransaction, | ||||
|         verifyingContract: string, | ||||
|         txOrigin: string, | ||||
|     ): Promise<Buffer> { | ||||
|         const typedData = await eip712Utils.createCoordinatorApprovalTypedDataAsync( | ||||
|             transaction, | ||||
|             verifyingContract, | ||||
|             txOrigin, | ||||
|         ); | ||||
|         const hashBuffer = signTypedDataUtils.generateTypedDataHash(typedData); | ||||
|         return hashBuffer; | ||||
|     }, | ||||
|     async getApprovalHashHexAsync( | ||||
|         transaction: SignedZeroExTransaction, | ||||
|         verifyingContract: string, | ||||
|         txOrigin: string, | ||||
|     ): Promise<string> { | ||||
|         const hashHex = hexConcat(await hashUtils.getApprovalHashBufferAsync(transaction, verifyingContract, txOrigin)); | ||||
|         return hashHex; | ||||
|     }, | ||||
| }; | ||||
| @@ -1,3 +1,5 @@ | ||||
| export * from './artifacts'; | ||||
| export * from './wrappers'; | ||||
| export * from '../test/utils'; | ||||
| export import CoordinatorRevertErrors = require('./revert_errors'); | ||||
| export { ApprovalFactory } from './approval_factory'; | ||||
| export { SignedCoordinatorApproval } from './types'; | ||||
|   | ||||
| @@ -5,15 +5,7 @@ | ||||
|  */ | ||||
| export * from '../generated-wrappers/coordinator'; | ||||
| export * from '../generated-wrappers/coordinator_registry'; | ||||
| export * from '../generated-wrappers/i_coordinator_approval_verifier'; | ||||
| export * from '../generated-wrappers/i_coordinator_core'; | ||||
| export * from '../generated-wrappers/i_coordinator_registry_core'; | ||||
| export * from '../generated-wrappers/i_coordinator_signature_validator'; | ||||
| export * from '../generated-wrappers/lib_constants'; | ||||
| export * from '../generated-wrappers/lib_coordinator_approval'; | ||||
| export * from '../generated-wrappers/lib_coordinator_rich_errors'; | ||||
| export * from '../generated-wrappers/lib_e_i_p712_coordinator_domain'; | ||||
| export * from '../generated-wrappers/mixin_coordinator_approval_verifier'; | ||||
| export * from '../generated-wrappers/mixin_coordinator_core'; | ||||
| export * from '../generated-wrappers/mixin_coordinator_registry_core'; | ||||
| export * from '../generated-wrappers/mixin_signature_validator'; | ||||
|   | ||||
							
								
								
									
										37
									
								
								contracts/coordinator/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								contracts/coordinator/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| import { ContractArtifact } from 'ethereum-types'; | ||||
|  | ||||
| import * as Coordinator from '../test/generated-artifacts/Coordinator.json'; | ||||
| import * as CoordinatorRegistry from '../test/generated-artifacts/CoordinatorRegistry.json'; | ||||
| import * as ICoordinatorApprovalVerifier from '../test/generated-artifacts/ICoordinatorApprovalVerifier.json'; | ||||
| import * as ICoordinatorCore from '../test/generated-artifacts/ICoordinatorCore.json'; | ||||
| import * as ICoordinatorRegistryCore from '../test/generated-artifacts/ICoordinatorRegistryCore.json'; | ||||
| import * as ICoordinatorSignatureValidator from '../test/generated-artifacts/ICoordinatorSignatureValidator.json'; | ||||
| import * as LibConstants from '../test/generated-artifacts/LibConstants.json'; | ||||
| import * as LibCoordinatorApproval from '../test/generated-artifacts/LibCoordinatorApproval.json'; | ||||
| import * as LibCoordinatorRichErrors from '../test/generated-artifacts/LibCoordinatorRichErrors.json'; | ||||
| import * as LibEIP712CoordinatorDomain from '../test/generated-artifacts/LibEIP712CoordinatorDomain.json'; | ||||
| import * as MixinCoordinatorApprovalVerifier from '../test/generated-artifacts/MixinCoordinatorApprovalVerifier.json'; | ||||
| import * as MixinCoordinatorCore from '../test/generated-artifacts/MixinCoordinatorCore.json'; | ||||
| import * as MixinCoordinatorRegistryCore from '../test/generated-artifacts/MixinCoordinatorRegistryCore.json'; | ||||
| import * as MixinSignatureValidator from '../test/generated-artifacts/MixinSignatureValidator.json'; | ||||
| export const artifacts = { | ||||
|     Coordinator: Coordinator as ContractArtifact, | ||||
|     MixinCoordinatorApprovalVerifier: MixinCoordinatorApprovalVerifier as ContractArtifact, | ||||
|     MixinCoordinatorCore: MixinCoordinatorCore as ContractArtifact, | ||||
|     MixinSignatureValidator: MixinSignatureValidator as ContractArtifact, | ||||
|     ICoordinatorApprovalVerifier: ICoordinatorApprovalVerifier as ContractArtifact, | ||||
|     ICoordinatorCore: ICoordinatorCore as ContractArtifact, | ||||
|     ICoordinatorSignatureValidator: ICoordinatorSignatureValidator as ContractArtifact, | ||||
|     LibConstants: LibConstants as ContractArtifact, | ||||
|     LibCoordinatorApproval: LibCoordinatorApproval as ContractArtifact, | ||||
|     LibCoordinatorRichErrors: LibCoordinatorRichErrors as ContractArtifact, | ||||
|     LibEIP712CoordinatorDomain: LibEIP712CoordinatorDomain as ContractArtifact, | ||||
|     CoordinatorRegistry: CoordinatorRegistry as ContractArtifact, | ||||
|     MixinCoordinatorRegistryCore: MixinCoordinatorRegistryCore as ContractArtifact, | ||||
|     ICoordinatorRegistryCore: ICoordinatorRegistryCore as ContractArtifact, | ||||
| }; | ||||
| @@ -1,6 +1,8 @@ | ||||
| import { blockchainTests, expect, verifyEvents } from '@0x/contracts-test-utils'; | ||||
|  | ||||
| import { artifacts, CoordinatorRegistryContract, CoordinatorRegistryCoordinatorEndpointSetEventArgs } from '../src'; | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| import { CoordinatorRegistryContract, CoordinatorRegistryCoordinatorEndpointSetEventArgs } from './wrappers'; | ||||
|  | ||||
| // tslint:disable:no-unnecessary-type-assertion | ||||
| blockchainTests.resets('Coordinator Registry tests', env => { | ||||
| @@ -23,43 +25,42 @@ blockchainTests.resets('Coordinator Registry tests', env => { | ||||
|     }); | ||||
|     describe('core', () => { | ||||
|         it('Should successfully set a Coordinator endpoint', async () => { | ||||
|             await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync(coordinatorEndpoint, { | ||||
|             await coordinatorRegistry.setCoordinatorEndpoint(coordinatorEndpoint).awaitTransactionSuccessAsync({ | ||||
|                 from: coordinatorOperator, | ||||
|             }); | ||||
|             const recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( | ||||
|                 coordinatorOperator, | ||||
|             ); | ||||
|             const recordedCoordinatorEndpoint = await coordinatorRegistry | ||||
|                 .getCoordinatorEndpoint(coordinatorOperator) | ||||
|                 .callAsync(); | ||||
|             expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint); | ||||
|         }); | ||||
|         it('Should successfully unset a Coordinator endpoint', async () => { | ||||
|             // set Coordinator endpoint | ||||
|             await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync(coordinatorEndpoint, { | ||||
|             await coordinatorRegistry.setCoordinatorEndpoint(coordinatorEndpoint).awaitTransactionSuccessAsync({ | ||||
|                 from: coordinatorOperator, | ||||
|             }); | ||||
|             let recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( | ||||
|                 coordinatorOperator, | ||||
|             ); | ||||
|             let recordedCoordinatorEndpoint = await coordinatorRegistry | ||||
|                 .getCoordinatorEndpoint(coordinatorOperator) | ||||
|                 .callAsync(); | ||||
|             expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint); | ||||
|             // unset Coordinator endpoint | ||||
|             await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync(nilCoordinatorEndpoint, { | ||||
|             await coordinatorRegistry.setCoordinatorEndpoint(nilCoordinatorEndpoint).awaitTransactionSuccessAsync({ | ||||
|                 from: coordinatorOperator, | ||||
|             }); | ||||
|             recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( | ||||
|                 coordinatorOperator, | ||||
|             ); | ||||
|             recordedCoordinatorEndpoint = await coordinatorRegistry | ||||
|                 .getCoordinatorEndpoint(coordinatorOperator) | ||||
|                 .callAsync(); | ||||
|             expect(recordedCoordinatorEndpoint).to.be.equal(nilCoordinatorEndpoint); | ||||
|         }); | ||||
|         it('Should emit an event when setting Coordinator endpoint', async () => { | ||||
|             // set Coordinator endpoint | ||||
|             const txReceipt = await coordinatorRegistry.setCoordinatorEndpoint.awaitTransactionSuccessAsync( | ||||
|                 coordinatorEndpoint, | ||||
|                 { | ||||
|             const txReceipt = await coordinatorRegistry | ||||
|                 .setCoordinatorEndpoint(coordinatorEndpoint) | ||||
|                 .awaitTransactionSuccessAsync({ | ||||
|                     from: coordinatorOperator, | ||||
|                 }, | ||||
|             ); | ||||
|             const recordedCoordinatorEndpoint = await coordinatorRegistry.getCoordinatorEndpoint.callAsync( | ||||
|                 coordinatorOperator, | ||||
|             ); | ||||
|                 }); | ||||
|             const recordedCoordinatorEndpoint = await coordinatorRegistry | ||||
|                 .getCoordinatorEndpoint(coordinatorOperator) | ||||
|                 .callAsync(); | ||||
|             expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint); | ||||
|             // validate event | ||||
|             const expectedEvent: CoordinatorRegistryCoordinatorEndpointSetEventArgs = { | ||||
|   | ||||
| @@ -1,8 +1,11 @@ | ||||
| import { blockchainTests, constants, expect, randomAddress } from '@0x/contracts-test-utils'; | ||||
| import { transactionHashUtils } from '@0x/order-utils'; | ||||
| import { blockchainTests, constants, expect, randomAddress, transactionHashUtils } from '@0x/contracts-test-utils'; | ||||
| import { BigNumber } from '@0x/utils'; | ||||
|  | ||||
| import { artifacts, CoordinatorContract, hashUtils } from '../src'; | ||||
| import { hashUtils } from '../src/hash_utils'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| import { CoordinatorContract } from './wrappers'; | ||||
|  | ||||
| blockchainTests.resets('Libs tests', env => { | ||||
|     let coordinatorContract: CoordinatorContract; | ||||
| @@ -41,8 +44,12 @@ blockchainTests.resets('Libs tests', env => { | ||||
|                 transactionHash: transactionHashUtils.getTransactionHashHex(signedTx), | ||||
|                 transactionSignature: signedTx.signature, | ||||
|             }; | ||||
|             const expectedApprovalHash = hashUtils.getApprovalHashHex(signedTx, coordinatorContract.address, txOrigin); | ||||
|             const approvalHash = await coordinatorContract.getCoordinatorApprovalHash.callAsync(approval); | ||||
|             const expectedApprovalHash = await hashUtils.getApprovalHashHexAsync( | ||||
|                 signedTx, | ||||
|                 coordinatorContract.address, | ||||
|                 txOrigin, | ||||
|             ); | ||||
|             const approvalHash = await coordinatorContract.getCoordinatorApprovalHash(approval).callAsync(); | ||||
|             expect(expectedApprovalHash).to.eq(approvalHash); | ||||
|         }); | ||||
|     }); | ||||
|   | ||||
| @@ -1,18 +1,26 @@ | ||||
| import { constants as exchangeConstants, exchangeDataEncoder, ExchangeFunctionName } from '@0x/contracts-exchange'; | ||||
| import { exchangeDataEncoder } from '@0x/contracts-exchange'; | ||||
| import { | ||||
|     blockchainTests, | ||||
|     constants, | ||||
|     ExchangeFunctionName, | ||||
|     expect, | ||||
|     hexConcat, | ||||
|     hexSlice, | ||||
|     randomAddress, | ||||
|     TransactionFactory, | ||||
|     transactionHashUtils, | ||||
| } from '@0x/contracts-test-utils'; | ||||
| import { CoordinatorRevertErrors, transactionHashUtils } from '@0x/order-utils'; | ||||
| import { LibBytesRevertErrors } from '@0x/contracts-utils'; | ||||
| import { SignatureType, SignedOrder } from '@0x/types'; | ||||
| import { BigNumber, LibBytesRevertErrors } from '@0x/utils'; | ||||
| import { BigNumber } from '@0x/utils'; | ||||
|  | ||||
| import { ApprovalFactory, artifacts, CoordinatorContract } from '../src'; | ||||
| import CoordinatorRevertErrors = require('../src/revert_errors'); | ||||
|  | ||||
| import { ApprovalFactory } from '../src/approval_factory'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| import { CoordinatorContract } from './wrappers'; | ||||
|  | ||||
| blockchainTests.resets('Mixins tests', env => { | ||||
|     let chainId: number; | ||||
| @@ -70,14 +78,14 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|             const data = constants.NULL_BYTES; | ||||
|             const transaction = await transactionFactory.newSignedTransactionAsync({ data }, SignatureType.EthSign); | ||||
|             const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|             const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature); | ||||
|             const signerAddress = await mixins.getSignerAddress(transactionHash, transaction.signature).callAsync(); | ||||
|             expect(transaction.signerAddress).to.eq(signerAddress); | ||||
|         }); | ||||
|         it('should return the correct address using the EIP712 signature type', async () => { | ||||
|             const data = constants.NULL_BYTES; | ||||
|             const transaction = await transactionFactory.newSignedTransactionAsync({ data }, SignatureType.EIP712); | ||||
|             const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|             const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature); | ||||
|             const signerAddress = await mixins.getSignerAddress(transactionHash, transaction.signature).callAsync(); | ||||
|             expect(transaction.signerAddress).to.eq(signerAddress); | ||||
|         }); | ||||
|         it('should revert with with the Illegal signature type', async () => { | ||||
| @@ -88,7 +96,7 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 SignatureType.Illegal, | ||||
|             ); | ||||
|             const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|             expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( | ||||
|             expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( | ||||
|                 new CoordinatorRevertErrors.SignatureError( | ||||
|                     CoordinatorRevertErrors.SignatureErrorCodes.Illegal, | ||||
|                     transactionHash, | ||||
| @@ -101,7 +109,7 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|             const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|             transaction.signature = hexConcat(SignatureType.Invalid); | ||||
|             const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|             expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( | ||||
|             expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( | ||||
|                 new CoordinatorRevertErrors.SignatureError( | ||||
|                     CoordinatorRevertErrors.SignatureErrorCodes.Invalid, | ||||
|                     transactionHash, | ||||
| @@ -117,7 +125,7 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 SignatureType.NSignatureTypes, | ||||
|             ); | ||||
|             const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|             expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( | ||||
|             expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( | ||||
|                 new CoordinatorRevertErrors.SignatureError( | ||||
|                     CoordinatorRevertErrors.SignatureErrorCodes.Unsupported, | ||||
|                     transactionHash, | ||||
| @@ -133,7 +141,7 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 SignatureType.Wallet, | ||||
|             ); | ||||
|             const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|             expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.revertWith( | ||||
|             expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith( | ||||
|                 new CoordinatorRevertErrors.SignatureError( | ||||
|                     CoordinatorRevertErrors.SignatureErrorCodes.Unsupported, | ||||
|                     transactionHash, | ||||
| @@ -144,11 +152,11 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|     }); | ||||
|  | ||||
|     describe('decodeOrdersFromFillData', () => { | ||||
|         for (const fnName of exchangeConstants.SINGLE_FILL_FN_NAMES) { | ||||
|         for (const fnName of constants.SINGLE_FILL_FN_NAMES) { | ||||
|             it(`should correctly decode the orders for ${fnName} data`, async () => { | ||||
|                 const orders = [defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); | ||||
|                 const decodedSignedOrders = decodedOrders.map(order => ({ | ||||
|                     ...order, | ||||
|                     signature: constants.NULL_BYTES, | ||||
| @@ -158,11 +166,11 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 expect(orders).to.deep.eq(decodedSignedOrders); | ||||
|             }); | ||||
|         } | ||||
|         for (const fnName of exchangeConstants.BATCH_FILL_FN_NAMES) { | ||||
|         for (const fnName of constants.BATCH_FILL_FN_NAMES) { | ||||
|             it(`should correctly decode the orders for ${fnName} data`, async () => { | ||||
|                 const orders = [defaultOrder, defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); | ||||
|                 const decodedSignedOrders = decodedOrders.map(order => ({ | ||||
|                     ...order, | ||||
|                     signature: constants.NULL_BYTES, | ||||
| @@ -172,11 +180,11 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 expect(orders).to.deep.eq(decodedSignedOrders); | ||||
|             }); | ||||
|         } | ||||
|         for (const fnName of exchangeConstants.MARKET_FILL_FN_NAMES) { | ||||
|         for (const fnName of constants.MARKET_FILL_FN_NAMES) { | ||||
|             it(`should correctly decode the orders for ${fnName} data`, async () => { | ||||
|                 const orders = [defaultOrder, defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); | ||||
|                 const decodedSignedOrders = decodedOrders.map(order => ({ | ||||
|                     ...order, | ||||
|                     signature: constants.NULL_BYTES, | ||||
| @@ -186,11 +194,11 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 expect(orders).to.deep.eq(decodedSignedOrders); | ||||
|             }); | ||||
|         } | ||||
|         for (const fnName of exchangeConstants.MATCH_ORDER_FN_NAMES) { | ||||
|         for (const fnName of constants.MATCH_ORDER_FN_NAMES) { | ||||
|             it(`should correctly decode the orders for ${fnName} data`, async () => { | ||||
|                 const orders = [defaultOrder, defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); | ||||
|                 const decodedSignedOrders = decodedOrders.map(order => ({ | ||||
|                     ...order, | ||||
|                     signature: constants.NULL_BYTES, | ||||
| @@ -200,18 +208,18 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 expect(orders).to.deep.eq(decodedSignedOrders); | ||||
|             }); | ||||
|         } | ||||
|         for (const fnName of exchangeConstants.CANCEL_ORDER_FN_NAMES) { | ||||
|         for (const fnName of constants.CANCEL_ORDER_FN_NAMES) { | ||||
|             it(`should correctly decode the orders for ${fnName} data`, async () => { | ||||
|                 const orders = [defaultOrder, defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); | ||||
|                 const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); | ||||
|                 const emptyArray: any[] = []; | ||||
|                 expect(emptyArray).to.deep.eq(decodedOrders); | ||||
|             }); | ||||
|         } | ||||
|         it('should decode an empty array for invalid data', async () => { | ||||
|             const data = '0x0123456789'; | ||||
|             const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data); | ||||
|             const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync(); | ||||
|             const emptyArray: any[] = []; | ||||
|             expect(emptyArray).to.deep.eq(decodedOrders); | ||||
|         }); | ||||
| @@ -222,24 +230,22 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 new BigNumber(3), // the length of data | ||||
|                 new BigNumber(4), | ||||
|             ); | ||||
|             return expect(mixins.decodeOrdersFromFillData.callAsync(data)).to.revertWith(expectedError); | ||||
|             return expect(mixins.decodeOrdersFromFillData(data).callAsync()).to.revertWith(expectedError); | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     describe('Single order approvals', () => { | ||||
|         for (const fnName of exchangeConstants.SINGLE_FILL_FN_NAMES) { | ||||
|         for (const fnName of constants.SINGLE_FILL_FN_NAMES) { | ||||
|             it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[approver1]`, async () => { | ||||
|                 const orders = [defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval.signature], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|             }); | ||||
|             it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[null], approval_sig=[approver1]`, async () => { | ||||
|                 const order = { | ||||
| @@ -249,73 +255,59 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 const orders = [order]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval.signature], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|             }); | ||||
|             it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[]`, async () => { | ||||
|                 const orders = [defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     approvalSignerAddress1, | ||||
|                     transaction.signature, | ||||
|                     [], | ||||
|                     { | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, []) | ||||
|                     .callAsync({ | ||||
|                         from: approvalSignerAddress1, | ||||
|                     }, | ||||
|                 ); | ||||
|                     }); | ||||
|             }); | ||||
|             it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[approver1]`, async () => { | ||||
|                 const orders = [defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     approvalSignerAddress1, | ||||
|                     transaction.signature, | ||||
|                     [approval.signature], | ||||
|                     { from: approvalSignerAddress1 }, | ||||
|                 ); | ||||
|                 const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [ | ||||
|                         approval.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: approvalSignerAddress1 }); | ||||
|             }); | ||||
|             it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[]`, async () => { | ||||
|                 const orders = [defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     approvalSignerAddress1, | ||||
|                     transaction.signature, | ||||
|                     [], | ||||
|                     { | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, []) | ||||
|                     .callAsync({ | ||||
|                         from: approvalSignerAddress1, | ||||
|                     }, | ||||
|                 ); | ||||
|                     }); | ||||
|             }); | ||||
|             it(`Should revert: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[invalid]`, async () => { | ||||
|                 const orders = [defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 const signature = hexConcat( | ||||
|                     hexSlice(approval.signature, 0, 2), | ||||
|                     '0xFFFFFFFF', | ||||
|                     hexSlice(approval.signature, 6), | ||||
|                 ); | ||||
|                 const tx = mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [signature], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const tx = mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|  | ||||
|                 const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|                 expect(tx).to.revertWith( | ||||
| @@ -326,37 +318,33 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 const orders = [defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|  | ||||
|                 const tx = mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval.signature], | ||||
|                     { from: approvalSignerAddress2 }, | ||||
|                 ); | ||||
|                 const tx = mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: approvalSignerAddress2 }); | ||||
|                 expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress)); | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
|     describe('Batch order approvals', () => { | ||||
|         for (const fnName of [ | ||||
|             ...exchangeConstants.BATCH_FILL_FN_NAMES, | ||||
|             ...exchangeConstants.MARKET_FILL_FN_NAMES, | ||||
|             ...exchangeConstants.MATCH_ORDER_FN_NAMES, | ||||
|             ...constants.BATCH_FILL_FN_NAMES, | ||||
|             ...constants.MARKET_FILL_FN_NAMES, | ||||
|             ...constants.MATCH_ORDER_FN_NAMES, | ||||
|         ]) { | ||||
|             it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => { | ||||
|                 const orders = [defaultOrder, defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval.signature], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|             }); | ||||
|             it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => { | ||||
|                 const orders = [defaultOrder, defaultOrder].map(order => ({ | ||||
| @@ -365,14 +353,12 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 })); | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval.signature], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|             }); | ||||
|             it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[]`, async () => { | ||||
|                 const orders = [defaultOrder, defaultOrder].map(order => ({ | ||||
| @@ -381,79 +367,62 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 })); | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|             }); | ||||
|             it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,null], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => { | ||||
|                 const orders = [defaultOrder, { ...defaultOrder, senderAddress: constants.NULL_ADDRESS }]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval.signature], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|             }); | ||||
|             it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver2], approval_sig=[approver1,approver2]`, async () => { | ||||
|                 const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval1 = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 const approval2 = approvalFactory2.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval1.signature, approval2.signature], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const approval1 = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 const approval2 = await approvalFactory2.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval1.signature, | ||||
|                         approval2.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|             }); | ||||
|             it(`Should be successful: function=${fnName} caller=approver1, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver1], approval_sig=[]`, async () => { | ||||
|                 const orders = [defaultOrder, defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     approvalSignerAddress1, | ||||
|                     transaction.signature, | ||||
|                     [], | ||||
|                     { from: approvalSignerAddress1 }, | ||||
|                 ); | ||||
|                 await mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, []) | ||||
|                     .callAsync({ from: approvalSignerAddress1 }); | ||||
|             }); | ||||
|             it(`Should revert: function=${fnName} caller=approver1, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver2], approval_sig=[approver2]`, async () => { | ||||
|                 const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval2 = approvalFactory2.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 const approval2 = await approvalFactory2.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|  | ||||
|                 const tx = mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval2.signature], | ||||
|                     { from: approvalSignerAddress1 }, | ||||
|                 ); | ||||
|                 const tx = mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval2.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: approvalSignerAddress1 }); | ||||
|                 expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress)); | ||||
|             }); | ||||
|             it(`Should revert: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1, approver1], approval_sig=[]`, async () => { | ||||
|                 const orders = [defaultOrder, defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const tx = mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const tx = mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|  | ||||
|                 const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|                 expect(tx).to.revertWith( | ||||
| @@ -464,19 +433,17 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 const orders = [defaultOrder, defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 const signature = hexConcat( | ||||
|                     hexSlice(approval.signature, 0, 2), | ||||
|                     '0xFFFFFFFF', | ||||
|                     hexSlice(approval.signature, 6), | ||||
|                 ); | ||||
|                 const tx = mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [signature], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const tx = mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|  | ||||
|                 const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|                 expect(tx).to.revertWith( | ||||
| @@ -487,20 +454,19 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval1 = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 const approval2 = approvalFactory2.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 const approval1 = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 const approval2 = await approvalFactory2.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 const approvalSignature2 = hexConcat( | ||||
|                     hexSlice(approval2.signature, 0, 2), | ||||
|                     '0xFFFFFFFF', | ||||
|                     hexSlice(approval2.signature, 6), | ||||
|                 ); | ||||
|                 const tx = mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval1.signature, approvalSignature2], | ||||
|                     { from: transactionSignerAddress }, | ||||
|                 ); | ||||
|                 const tx = mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval1.signature, | ||||
|                         approvalSignature2, | ||||
|                     ]) | ||||
|                     .callAsync({ from: transactionSignerAddress }); | ||||
|  | ||||
|                 const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|                 expect(tx).to.revertWith( | ||||
| @@ -511,19 +477,17 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval2 = approvalFactory2.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 const approval2 = await approvalFactory2.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|                 const approvalSignature2 = hexConcat( | ||||
|                     hexSlice(approval2.signature, 0, 2), | ||||
|                     '0xFFFFFFFF', | ||||
|                     hexSlice(approval2.signature, 6), | ||||
|                 ); | ||||
|                 const tx = mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     approvalSignerAddress1, | ||||
|                     transaction.signature, | ||||
|                     [approvalSignature2], | ||||
|                     { from: approvalSignerAddress1 }, | ||||
|                 ); | ||||
|                 const tx = mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [ | ||||
|                         approvalSignature2, | ||||
|                     ]) | ||||
|                     .callAsync({ from: approvalSignerAddress1 }); | ||||
|  | ||||
|                 const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); | ||||
|                 expect(tx).to.revertWith( | ||||
| @@ -534,15 +498,13 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|                 const orders = [defaultOrder, defaultOrder]; | ||||
|                 const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); | ||||
|                 const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|                 const approval1 = approvalFactory1.newSignedApproval(transaction, transactionSignerAddress); | ||||
|                 const approval1 = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress); | ||||
|  | ||||
|                 const tx = mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                     transaction, | ||||
|                     transactionSignerAddress, | ||||
|                     transaction.signature, | ||||
|                     [approval1.signature], | ||||
|                     { from: approvalSignerAddress2 }, | ||||
|                 ); | ||||
|                 const tx = mixins | ||||
|                     .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [ | ||||
|                         approval1.signature, | ||||
|                     ]) | ||||
|                     .callAsync({ from: approvalSignerAddress2 }); | ||||
|                 expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress)); | ||||
|             }); | ||||
|         } | ||||
| @@ -552,36 +514,24 @@ blockchainTests.resets('Mixins tests', env => { | ||||
|             const orders = [defaultOrder]; | ||||
|             const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.CancelOrder, orders); | ||||
|             const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|             await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                 transaction, | ||||
|                 transactionSignerAddress, | ||||
|                 transaction.signature, | ||||
|                 [], | ||||
|                 { from: transactionSignerAddress }, | ||||
|             ); | ||||
|             await mixins | ||||
|                 .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) | ||||
|                 .callAsync({ from: transactionSignerAddress }); | ||||
|         }); | ||||
|         it('should allow the tx signer to call `batchCancelOrders` without approval', async () => { | ||||
|             const orders = [defaultOrder, defaultOrder]; | ||||
|             const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.BatchCancelOrders, orders); | ||||
|             const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|             await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                 transaction, | ||||
|                 transactionSignerAddress, | ||||
|                 transaction.signature, | ||||
|                 [], | ||||
|                 { from: transactionSignerAddress }, | ||||
|             ); | ||||
|             await mixins | ||||
|                 .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) | ||||
|                 .callAsync({ from: transactionSignerAddress }); | ||||
|         }); | ||||
|         it('should allow the tx signer to call `cancelOrdersUpTo` without approval', async () => { | ||||
|             const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.CancelOrdersUpTo); | ||||
|             const transaction = await transactionFactory.newSignedTransactionAsync({ data }); | ||||
|             await mixins.assertValidCoordinatorApprovals.callAsync( | ||||
|                 transaction, | ||||
|                 transactionSignerAddress, | ||||
|                 transaction.signature, | ||||
|                 [], | ||||
|                 { from: transactionSignerAddress }, | ||||
|             ); | ||||
|             await mixins | ||||
|                 .assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, []) | ||||
|                 .callAsync({ from: transactionSignerAddress }); | ||||
|         }); | ||||
|     }); | ||||
| }); | ||||
|   | ||||
| @@ -1,16 +0,0 @@ | ||||
| import { hexConcat } from '@0x/contracts-test-utils'; | ||||
| import { eip712Utils } from '@0x/order-utils'; | ||||
| import { SignedZeroExTransaction } from '@0x/types'; | ||||
| import { signTypedDataUtils } from '@0x/utils'; | ||||
|  | ||||
| export const hashUtils = { | ||||
|     getApprovalHashBuffer(transaction: SignedZeroExTransaction, verifyingContract: string, txOrigin: string): Buffer { | ||||
|         const typedData = eip712Utils.createCoordinatorApprovalTypedData(transaction, verifyingContract, txOrigin); | ||||
|         const hashBuffer = signTypedDataUtils.generateTypedDataHash(typedData); | ||||
|         return hashBuffer; | ||||
|     }, | ||||
|     getApprovalHashHex(transaction: SignedZeroExTransaction, verifyingContract: string, txOrigin: string): string { | ||||
|         const hashHex = hexConcat(hashUtils.getApprovalHashBuffer(transaction, verifyingContract, txOrigin)); | ||||
|         return hashHex; | ||||
|     }, | ||||
| }; | ||||
| @@ -1,3 +0,0 @@ | ||||
| export { hashUtils } from './hash_utils'; | ||||
| export { ApprovalFactory } from './approval_factory'; | ||||
| export * from './types'; | ||||
							
								
								
									
										19
									
								
								contracts/coordinator/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								contracts/coordinator/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| export * from '../test/generated-wrappers/coordinator'; | ||||
| export * from '../test/generated-wrappers/coordinator_registry'; | ||||
| export * from '../test/generated-wrappers/i_coordinator_approval_verifier'; | ||||
| export * from '../test/generated-wrappers/i_coordinator_core'; | ||||
| export * from '../test/generated-wrappers/i_coordinator_registry_core'; | ||||
| export * from '../test/generated-wrappers/i_coordinator_signature_validator'; | ||||
| export * from '../test/generated-wrappers/lib_constants'; | ||||
| export * from '../test/generated-wrappers/lib_coordinator_approval'; | ||||
| export * from '../test/generated-wrappers/lib_coordinator_rich_errors'; | ||||
| export * from '../test/generated-wrappers/lib_e_i_p712_coordinator_domain'; | ||||
| export * from '../test/generated-wrappers/mixin_coordinator_approval_verifier'; | ||||
| export * from '../test/generated-wrappers/mixin_coordinator_core'; | ||||
| export * from '../test/generated-wrappers/mixin_coordinator_registry_core'; | ||||
| export * from '../test/generated-wrappers/mixin_signature_validator'; | ||||
| @@ -5,18 +5,24 @@ | ||||
|     "files": [ | ||||
|         "generated-artifacts/Coordinator.json", | ||||
|         "generated-artifacts/CoordinatorRegistry.json", | ||||
|         "generated-artifacts/ICoordinatorApprovalVerifier.json", | ||||
|         "generated-artifacts/ICoordinatorCore.json", | ||||
|         "generated-artifacts/ICoordinatorRegistryCore.json", | ||||
|         "generated-artifacts/ICoordinatorSignatureValidator.json", | ||||
|         "generated-artifacts/LibConstants.json", | ||||
|         "generated-artifacts/LibCoordinatorApproval.json", | ||||
|         "generated-artifacts/LibCoordinatorRichErrors.json", | ||||
|         "generated-artifacts/LibEIP712CoordinatorDomain.json", | ||||
|         "generated-artifacts/MixinCoordinatorApprovalVerifier.json", | ||||
|         "generated-artifacts/MixinCoordinatorCore.json", | ||||
|         "generated-artifacts/MixinCoordinatorRegistryCore.json", | ||||
|         "generated-artifacts/MixinSignatureValidator.json" | ||||
|         "test/generated-artifacts/Coordinator.json", | ||||
|         "test/generated-artifacts/CoordinatorRegistry.json", | ||||
|         "test/generated-artifacts/ICoordinatorApprovalVerifier.json", | ||||
|         "test/generated-artifacts/ICoordinatorCore.json", | ||||
|         "test/generated-artifacts/ICoordinatorRegistryCore.json", | ||||
|         "test/generated-artifacts/ICoordinatorSignatureValidator.json", | ||||
|         "test/generated-artifacts/LibConstants.json", | ||||
|         "test/generated-artifacts/LibCoordinatorApproval.json", | ||||
|         "test/generated-artifacts/LibCoordinatorRichErrors.json", | ||||
|         "test/generated-artifacts/LibEIP712CoordinatorDomain.json", | ||||
|         "test/generated-artifacts/MixinCoordinatorApprovalVerifier.json", | ||||
|         "test/generated-artifacts/MixinCoordinatorCore.json", | ||||
|         "test/generated-artifacts/MixinCoordinatorRegistryCore.json", | ||||
|         "test/generated-artifacts/MixinSignatureValidator.json" | ||||
|     ], | ||||
|     "exclude": ["./deploy/solc/solc_bin"] | ||||
| } | ||||
|   | ||||
							
								
								
									
										10
									
								
								contracts/dev-utils/.npmignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								contracts/dev-utils/.npmignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # Blacklist all files | ||||
| .* | ||||
| * | ||||
| # Whitelist lib | ||||
| !lib/**/* | ||||
| # Whitelist Solidity contracts | ||||
| !contracts/src/**/* | ||||
| # Blacklist tests in lib | ||||
| /lib/test/* | ||||
| # Package specific ignore | ||||
| @@ -1,4 +1,22 @@ | ||||
| [ | ||||
|     { | ||||
|         "version": "0.1.0-beta.2", | ||||
|         "changes": [ | ||||
|             { | ||||
|                 "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", | ||||
|                 "pr": 2330 | ||||
|             }, | ||||
|             { | ||||
|                 "note": "Add new method getOrderHash() to DevUtils contract", | ||||
|                 "pr": 2321 | ||||
|             }, | ||||
|             { | ||||
|                 "note": "Add new method getTransactionHash() to DevUtils contract", | ||||
|                 "pr": 2321 | ||||
|             } | ||||
|         ], | ||||
|         "timestamp": 1574030254 | ||||
|     }, | ||||
|     { | ||||
|         "version": "0.1.0-beta.1", | ||||
|         "changes": [ | ||||
|   | ||||
| @@ -5,6 +5,12 @@ Edit the package's CHANGELOG.json file only. | ||||
|  | ||||
| CHANGELOG | ||||
|  | ||||
| ## v0.1.0-beta.2 - _November 17, 2019_ | ||||
|  | ||||
|     * Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330) | ||||
|     * Add new method getOrderHash() to DevUtils contract (#2321) | ||||
|     * Add new method getTransactionHash() to DevUtils contract (#2321) | ||||
|  | ||||
| ## v0.1.0-beta.1 - _November 7, 2019_ | ||||
|  | ||||
|     * Add `encodeStaticCallAssetData` and `decodeStaticCallAssetData` in LibAssetData (#2034) | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|     "artifactsDir": "./generated-artifacts", | ||||
|     "artifactsDir": "./test/generated-artifacts", | ||||
|     "contractsDir": "./contracts", | ||||
|     "useDockerisedSolc": false, | ||||
|     "isOfflineMode": false, | ||||
| @@ -7,7 +7,7 @@ | ||||
|         "evmVersion": "constantinople", | ||||
|         "optimizer": { | ||||
|             "enabled": true, | ||||
|             "runs": 10000, | ||||
|             "runs": 1666, | ||||
|             "details": { "yul": true, "deduplicate": true, "cse": true, "constantOptimizer": true } | ||||
|         }, | ||||
|         "outputSelection": { | ||||
|   | ||||
| @@ -19,6 +19,11 @@ | ||||
| pragma solidity ^0.5.5; | ||||
| pragma experimental ABIEncoderV2; | ||||
|  | ||||
| import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol"; | ||||
| import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; | ||||
| import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol"; | ||||
| import "@0x/contracts-utils/contracts/src/LibEIP712.sol"; | ||||
| import "@0x/contracts-utils/contracts/src/LibBytes.sol"; | ||||
| import "./OrderValidationUtils.sol"; | ||||
| import "./OrderTransferSimulationUtils.sol"; | ||||
| import "./LibTransactionDecoder.sol"; | ||||
| @@ -29,6 +34,7 @@ import "./EthBalanceChecker.sol"; | ||||
| contract DevUtils is | ||||
|     OrderValidationUtils, | ||||
|     LibTransactionDecoder, | ||||
|     LibEIP712ExchangeDomain, | ||||
|     EthBalanceChecker, | ||||
|     OrderTransferSimulationUtils | ||||
| { | ||||
| @@ -36,5 +42,32 @@ contract DevUtils is | ||||
|         public | ||||
|         OrderValidationUtils(_exchange) | ||||
|         OrderTransferSimulationUtils(_exchange) | ||||
|         LibEIP712ExchangeDomain(uint256(0), address(0)) // null args because because we only use constants | ||||
|     {} | ||||
|  | ||||
|     function getOrderHash(LibOrder.Order memory order, uint256 chainId, address exchange) | ||||
|         public | ||||
|         pure | ||||
|         returns (bytes32 orderHash) | ||||
|     { | ||||
|         return LibOrder.getTypedDataHash( | ||||
|             order, | ||||
|             LibEIP712.hashEIP712Domain(_EIP712_EXCHANGE_DOMAIN_NAME, _EIP712_EXCHANGE_DOMAIN_VERSION, chainId, exchange) | ||||
|         ); | ||||
|     } | ||||
|  | ||||
|     function getTransactionHash( | ||||
|         LibZeroExTransaction.ZeroExTransaction memory transaction, | ||||
|         uint256 chainId, | ||||
|         address exchange | ||||
|     ) | ||||
|         public | ||||
|         pure | ||||
|         returns (bytes32 transactionHash) | ||||
|     { | ||||
|         return LibZeroExTransaction.getTypedDataHash( | ||||
|             transaction, | ||||
|             LibEIP712.hashEIP712Domain(_EIP712_EXCHANGE_DOMAIN_NAME, _EIP712_EXCHANGE_DOMAIN_VERSION, chainId, exchange) | ||||
|         ); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "name": "@0x/contracts-dev-utils", | ||||
|     "version": "0.1.0-beta.1", | ||||
|     "version": "0.1.0-beta.2", | ||||
|     "engines": { | ||||
|         "node": ">=6.12" | ||||
|     }, | ||||
| @@ -8,22 +8,25 @@ | ||||
|     "main": "lib/src/index.js", | ||||
|     "scripts": { | ||||
|         "build": "yarn pre_build && tsc -b", | ||||
|         "test": "echo !!! Run tests in @0x/contracts-tests instead !!!", | ||||
|         "test": "yarn assert_deployable && echo !!! Tests are run via @0x/contracts-tests !!!", | ||||
|         "assert_deployable": "node -e \"const bytecodeLen = (require('./generated-artifacts/DevUtils.json').compilerOutput.evm.bytecode.object.length-2)/2; assert(bytecodeLen<=0x6000,'DevUtils contract is too big to deploy, per EIP-170. '+bytecodeLen+'>'+0x6000)\"", | ||||
|         "build:ci": "yarn build", | ||||
|         "pre_build": "run-s compile quantify_bytecode contracts:gen generate_contract_wrappers", | ||||
|         "pre_build": "run-s compile quantify_bytecode contracts:gen generate_contract_wrappers contracts:copy", | ||||
|         "compile": "sol-compiler", | ||||
|         "watch": "sol-compiler -w", | ||||
|         "clean": "shx rm -rf lib generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "contracts:gen": "contracts-gen", | ||||
|         "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "contracts:gen": "contracts-gen generate", | ||||
|         "contracts:copy": "contracts-gen copy", | ||||
|         "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", | ||||
|         "quantify_bytecode": "echo EVM bytecode object lengths:;for i in ./generated-artifacts/*.json; do node -e \"console.log('$i\t' + (require('$i').compilerOutput.evm.bytecode.object.length - 2) / 2)\"; done", | ||||
|         "quantify_bytecode": "echo EVM bytecode object lengths:;for i in ./test/generated-artifacts/*.json; do node -e \"console.log('$i\t' + (require('$i').compilerOutput.evm.bytecode.object.length - 2) / 2)\"; done", | ||||
|         "compile:truffle": "truffle compile" | ||||
|     }, | ||||
|     "config": { | ||||
|         "abis": "./generated-artifacts/@(DevUtils|EthBalanceChecker|LibAssetData|LibTransactionDecoder|OrderTransferSimulationUtils|OrderValidationUtils).json", | ||||
|         "publicInterfaceContracts": "DevUtils,LibAssetData,LibTransactionDecoder", | ||||
|         "abis": "./test/generated-artifacts/@(DevUtils|EthBalanceChecker|LibAssetData|LibTransactionDecoder|OrderTransferSimulationUtils|OrderValidationUtils).json", | ||||
|         "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." | ||||
|     }, | ||||
|     "repository": { | ||||
| @@ -36,11 +39,13 @@ | ||||
|     }, | ||||
|     "homepage": "https://github.com/0xProject/0x-monorepo/contracts/dev-utils/README.md", | ||||
|     "devDependencies": { | ||||
|         "@0x/abi-gen": "^4.4.0-beta.1", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.1", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.1", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.1", | ||||
|         "@0x/abi-gen": "^4.4.0-beta.2", | ||||
|         "@0x/assert": "^2.2.0-beta.2", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.2", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.2", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.2", | ||||
|         "@types/node": "*", | ||||
|         "ethers": "~4.0.4", | ||||
|         "npm-run-all": "^4.1.2", | ||||
|         "shx": "^0.2.2", | ||||
|         "solhint": "^1.4.1", | ||||
| @@ -49,15 +54,8 @@ | ||||
|         "typescript": "3.0.1" | ||||
|     }, | ||||
|     "dependencies": { | ||||
|         "@0x/assert": "^2.2.0-beta.1", | ||||
|         "@0x/base-contract": "^5.5.0-beta.1", | ||||
|         "@0x/contract-addresses": "^3.3.0-beta.2", | ||||
|         "@0x/json-schemas": "^4.1.0-beta.1", | ||||
|         "@0x/types": "^2.5.0-beta.1", | ||||
|         "@0x/utils": "^4.6.0-beta.1", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.1", | ||||
|         "ethereum-types": "^2.2.0-beta.1", | ||||
|         "ethers": "~4.0.4" | ||||
|         "@0x/base-contract": "^5.5.0-beta.2", | ||||
|         "ethereum-types": "^2.2.0-beta.2" | ||||
|     }, | ||||
|     "publishConfig": { | ||||
|         "access": "public" | ||||
|   | ||||
| @@ -6,16 +6,10 @@ | ||||
| import { ContractArtifact } from 'ethereum-types'; | ||||
|  | ||||
| import * as DevUtils from '../generated-artifacts/DevUtils.json'; | ||||
| import * as EthBalanceChecker from '../generated-artifacts/EthBalanceChecker.json'; | ||||
| import * as LibAssetData from '../generated-artifacts/LibAssetData.json'; | ||||
| import * as LibTransactionDecoder from '../generated-artifacts/LibTransactionDecoder.json'; | ||||
| import * as OrderTransferSimulationUtils from '../generated-artifacts/OrderTransferSimulationUtils.json'; | ||||
| import * as OrderValidationUtils from '../generated-artifacts/OrderValidationUtils.json'; | ||||
| export const artifacts = { | ||||
|     DevUtils: DevUtils as ContractArtifact, | ||||
|     EthBalanceChecker: EthBalanceChecker as ContractArtifact, | ||||
|     LibAssetData: LibAssetData as ContractArtifact, | ||||
|     LibTransactionDecoder: LibTransactionDecoder as ContractArtifact, | ||||
|     OrderTransferSimulationUtils: OrderTransferSimulationUtils as ContractArtifact, | ||||
|     OrderValidationUtils: OrderValidationUtils as ContractArtifact, | ||||
| }; | ||||
|   | ||||
| @@ -4,8 +4,5 @@ | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| export * from '../generated-wrappers/dev_utils'; | ||||
| export * from '../generated-wrappers/eth_balance_checker'; | ||||
| export * from '../generated-wrappers/lib_asset_data'; | ||||
| export * from '../generated-wrappers/lib_transaction_decoder'; | ||||
| export * from '../generated-wrappers/order_transfer_simulation_utils'; | ||||
| export * from '../generated-wrappers/order_validation_utils'; | ||||
|   | ||||
							
								
								
									
										21
									
								
								contracts/dev-utils/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								contracts/dev-utils/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| import { ContractArtifact } from 'ethereum-types'; | ||||
|  | ||||
| import * as DevUtils from '../test/generated-artifacts/DevUtils.json'; | ||||
| import * as EthBalanceChecker from '../test/generated-artifacts/EthBalanceChecker.json'; | ||||
| import * as LibAssetData from '../test/generated-artifacts/LibAssetData.json'; | ||||
| import * as LibTransactionDecoder from '../test/generated-artifacts/LibTransactionDecoder.json'; | ||||
| import * as OrderTransferSimulationUtils from '../test/generated-artifacts/OrderTransferSimulationUtils.json'; | ||||
| import * as OrderValidationUtils from '../test/generated-artifacts/OrderValidationUtils.json'; | ||||
| export const artifacts = { | ||||
|     DevUtils: DevUtils as ContractArtifact, | ||||
|     EthBalanceChecker: EthBalanceChecker as ContractArtifact, | ||||
|     LibAssetData: LibAssetData as ContractArtifact, | ||||
|     LibTransactionDecoder: LibTransactionDecoder as ContractArtifact, | ||||
|     OrderTransferSimulationUtils: OrderTransferSimulationUtils as ContractArtifact, | ||||
|     OrderValidationUtils: OrderValidationUtils as ContractArtifact, | ||||
| }; | ||||
							
								
								
									
										11
									
								
								contracts/dev-utils/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								contracts/dev-utils/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| export * from '../test/generated-wrappers/dev_utils'; | ||||
| export * from '../test/generated-wrappers/eth_balance_checker'; | ||||
| export * from '../test/generated-wrappers/lib_asset_data'; | ||||
| export * from '../test/generated-wrappers/lib_transaction_decoder'; | ||||
| export * from '../test/generated-wrappers/order_transfer_simulation_utils'; | ||||
| export * from '../test/generated-wrappers/order_validation_utils'; | ||||
| @@ -4,11 +4,14 @@ | ||||
|     "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], | ||||
|     "files": [ | ||||
|         "generated-artifacts/DevUtils.json", | ||||
|         "generated-artifacts/EthBalanceChecker.json", | ||||
|         "generated-artifacts/LibAssetData.json", | ||||
|         "generated-artifacts/LibTransactionDecoder.json", | ||||
|         "generated-artifacts/OrderTransferSimulationUtils.json", | ||||
|         "generated-artifacts/OrderValidationUtils.json" | ||||
|         "test/generated-artifacts/DevUtils.json", | ||||
|         "test/generated-artifacts/EthBalanceChecker.json", | ||||
|         "test/generated-artifacts/LibAssetData.json", | ||||
|         "test/generated-artifacts/LibTransactionDecoder.json", | ||||
|         "test/generated-artifacts/OrderTransferSimulationUtils.json", | ||||
|         "test/generated-artifacts/OrderValidationUtils.json" | ||||
|     ], | ||||
|     "exclude": ["./deploy/solc/solc_bin"] | ||||
| } | ||||
|   | ||||
							
								
								
									
										10
									
								
								contracts/erc1155/.npmignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								contracts/erc1155/.npmignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # Blacklist all files | ||||
| .* | ||||
| * | ||||
| # Whitelist lib | ||||
| !lib/**/* | ||||
| # Whitelist Solidity contracts | ||||
| !contracts/src/**/* | ||||
| # Blacklist tests in lib | ||||
| /lib/test/* | ||||
| # Package specific ignore | ||||
| @@ -1,4 +1,14 @@ | ||||
| [ | ||||
|     { | ||||
|         "version": "1.2.0-beta.2", | ||||
|         "changes": [ | ||||
|             { | ||||
|                 "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", | ||||
|                 "pr": 2330 | ||||
|             } | ||||
|         ], | ||||
|         "timestamp": 1574030254 | ||||
|     }, | ||||
|     { | ||||
|         "version": "1.2.0-beta.1", | ||||
|         "changes": [ | ||||
|   | ||||
| @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. | ||||
|  | ||||
| CHANGELOG | ||||
|  | ||||
| ## v1.2.0-beta.2 - _November 17, 2019_ | ||||
|  | ||||
|     * Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330) | ||||
|  | ||||
| ## v1.2.0-beta.1 - _November 7, 2019_ | ||||
|  | ||||
|     * Dependencies updated | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|     "artifactsDir": "./generated-artifacts", | ||||
|     "artifactsDir": "./test/generated-artifacts", | ||||
|     "contractsDir": "./contracts", | ||||
|     "useDockerisedSolc": false, | ||||
|     "isOfflineMode": false, | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "name": "@0x/contracts-erc1155", | ||||
|     "version": "1.2.0-beta.1", | ||||
|     "version": "1.2.0-beta.2", | ||||
|     "engines": { | ||||
|         "node": ">=6.12" | ||||
|     }, | ||||
| @@ -12,7 +12,7 @@ | ||||
|     "scripts": { | ||||
|         "build": "yarn pre_build && tsc -b", | ||||
|         "build:ci": "yarn build", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", | ||||
|         "test": "yarn run_mocha", | ||||
|         "rebuild_and_test": "run-s build test", | ||||
|         "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", | ||||
| @@ -21,21 +21,23 @@ | ||||
|         "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", | ||||
|         "compile": "sol-compiler", | ||||
|         "watch": "sol-compiler -w", | ||||
|         "clean": "shx rm -rf lib generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "coverage:report:text": "istanbul report text", | ||||
|         "coverage:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "profiler:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "coverage:report:lcov": "istanbul report lcov", | ||||
|         "test:circleci": "yarn test", | ||||
|         "contracts:gen": "contracts-gen", | ||||
|         "contracts:gen": "contracts-gen generate", | ||||
|         "contracts:copy": "contracts-gen copy", | ||||
|         "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", | ||||
|         "compile:truffle": "truffle compile" | ||||
|     }, | ||||
|     "config": { | ||||
|         "abis": "./generated-artifacts/@(DummyERC1155Receiver|ERC1155|ERC1155Mintable|IERC1155|IERC1155Mintable|IERC1155Receiver|MixinNonFungibleToken).json", | ||||
|         "publicInterfaceContracts": "ERC1155,ERC1155Mintable,IERC1155Receiver,DummyERC1155Receiver", | ||||
|         "abis": "./test/generated-artifacts/@(DummyERC1155Receiver|ERC1155|ERC1155Mintable|IERC1155|IERC1155Mintable|IERC1155Receiver|MixinNonFungibleToken).json", | ||||
|         "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." | ||||
|     }, | ||||
|     "repository": { | ||||
| @@ -48,11 +50,13 @@ | ||||
|     }, | ||||
|     "homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md", | ||||
|     "devDependencies": { | ||||
|         "@0x/abi-gen": "^4.4.0-beta.1", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.1", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.1", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.1", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.1", | ||||
|         "@0x/abi-gen": "^4.4.0-beta.2", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.2", | ||||
|         "@0x/contracts-utils": "^3.3.0-beta.2", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.2", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.2", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.2", | ||||
|         "@0x/types": "^2.5.0-beta.2", | ||||
|         "@types/lodash": "4.14.104", | ||||
|         "@types/mocha": "^5.2.7", | ||||
|         "@types/node": "*", | ||||
| @@ -70,14 +74,12 @@ | ||||
|         "typescript": "3.0.1" | ||||
|     }, | ||||
|     "dependencies": { | ||||
|         "@0x/base-contract": "^5.5.0-beta.1", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.1", | ||||
|         "@0x/contracts-utils": "^3.3.0-beta.1", | ||||
|         "@0x/types": "^2.5.0-beta.1", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.1", | ||||
|         "@0x/utils": "^4.6.0-beta.1", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.1", | ||||
|         "ethereum-types": "^2.2.0-beta.1", | ||||
|         "@0x/base-contract": "^5.5.0-beta.2", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.2", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.2", | ||||
|         "@0x/utils": "^4.6.0-beta.2", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.2", | ||||
|         "ethereum-types": "^2.2.0-beta.2", | ||||
|         "lodash": "^4.17.11" | ||||
|     }, | ||||
|     "publishConfig": { | ||||
|   | ||||
| @@ -8,16 +8,10 @@ import { ContractArtifact } from 'ethereum-types'; | ||||
| import * as DummyERC1155Receiver from '../generated-artifacts/DummyERC1155Receiver.json'; | ||||
| import * as ERC1155 from '../generated-artifacts/ERC1155.json'; | ||||
| import * as ERC1155Mintable from '../generated-artifacts/ERC1155Mintable.json'; | ||||
| import * as IERC1155 from '../generated-artifacts/IERC1155.json'; | ||||
| import * as IERC1155Mintable from '../generated-artifacts/IERC1155Mintable.json'; | ||||
| import * as IERC1155Receiver from '../generated-artifacts/IERC1155Receiver.json'; | ||||
| import * as MixinNonFungibleToken from '../generated-artifacts/MixinNonFungibleToken.json'; | ||||
| export const artifacts = { | ||||
|     ERC1155: ERC1155 as ContractArtifact, | ||||
|     ERC1155Mintable: ERC1155Mintable as ContractArtifact, | ||||
|     MixinNonFungibleToken: MixinNonFungibleToken as ContractArtifact, | ||||
|     IERC1155: IERC1155 as ContractArtifact, | ||||
|     IERC1155Mintable: IERC1155Mintable as ContractArtifact, | ||||
|     IERC1155Receiver: IERC1155Receiver as ContractArtifact, | ||||
|     DummyERC1155Receiver: DummyERC1155Receiver as ContractArtifact, | ||||
| }; | ||||
|   | ||||
| @@ -5,7 +5,9 @@ import * as chai from 'chai'; | ||||
| import { LogWithDecodedArgs, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; | ||||
| import * as _ from 'lodash'; | ||||
| 
 | ||||
| import { artifacts, ERC1155MintableContract, ERC1155TransferSingleEventArgs } from '../../src'; | ||||
| import { ERC1155MintableContract, ERC1155TransferSingleEventArgs } from './wrappers'; | ||||
| 
 | ||||
| import { artifacts } from './artifacts'; | ||||
| 
 | ||||
| const expect = chai.expect; | ||||
| 
 | ||||
| @@ -25,7 +27,7 @@ export class Erc1155Wrapper { | ||||
|         return this._erc1155Contract; | ||||
|     } | ||||
|     public async getBalancesAsync(owners: string[], tokens: BigNumber[]): Promise<BigNumber[]> { | ||||
|         const balances = await this._erc1155Contract.balanceOfBatch.callAsync(owners, tokens); | ||||
|         const balances = await this._erc1155Contract.balanceOfBatch(owners, tokens).callAsync(); | ||||
|         return balances; | ||||
|     } | ||||
|     public async safeTransferFromAsync( | ||||
| @@ -39,7 +41,7 @@ export class Erc1155Wrapper { | ||||
|         const spender = delegatedSpender === undefined ? from : delegatedSpender; | ||||
|         const callbackDataHex = callbackData === undefined ? '0x' : callbackData; | ||||
|         const tx = await this._logDecoder.getTxWithDecodedLogsAsync( | ||||
|             await this._erc1155Contract.safeTransferFrom.sendTransactionAsync(from, to, token, value, callbackDataHex, { | ||||
|             await this._erc1155Contract.safeTransferFrom(from, to, token, value, callbackDataHex).sendTransactionAsync({ | ||||
|                 from: spender, | ||||
|             }), | ||||
|         ); | ||||
| @@ -56,14 +58,9 @@ export class Erc1155Wrapper { | ||||
|         const spender = delegatedSpender === undefined ? from : delegatedSpender; | ||||
|         const callbackDataHex = callbackData === undefined ? '0x' : callbackData; | ||||
|         const tx = await this._logDecoder.getTxWithDecodedLogsAsync( | ||||
|             await this._erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( | ||||
|                 from, | ||||
|                 to, | ||||
|                 tokens, | ||||
|                 values, | ||||
|                 callbackDataHex, | ||||
|                 { from: spender }, | ||||
|             ), | ||||
|             await this._erc1155Contract | ||||
|                 .safeBatchTransferFrom(from, to, tokens, values, callbackDataHex) | ||||
|                 .sendTransactionAsync({ from: spender }), | ||||
|         ); | ||||
|         return tx; | ||||
|     } | ||||
| @@ -74,7 +71,7 @@ export class Erc1155Wrapper { | ||||
|         const tokenUri = 'dummyFungibleToken'; | ||||
|         const tokenIsNonFungible = false; | ||||
|         const tx = await this._logDecoder.getTxWithDecodedLogsAsync( | ||||
|             await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, { | ||||
|             await this._erc1155Contract.create(tokenUri, tokenIsNonFungible).sendTransactionAsync({ | ||||
|                 from: this._contractOwner, | ||||
|             }), | ||||
|         ); | ||||
| @@ -95,25 +92,22 @@ export class Erc1155Wrapper { | ||||
|                 tokenAmountsAsArray.push(tokenAmounts); | ||||
|             }); | ||||
|         } | ||||
|         await this._erc1155Contract.mintFungible.awaitTransactionSuccessAsync( | ||||
|             tokenId, | ||||
|             beneficiaries, | ||||
|             tokenAmountsAsArray, | ||||
|             { from: this._contractOwner }, | ||||
|         ); | ||||
|         await this._erc1155Contract | ||||
|             .mintFungible(tokenId, beneficiaries, tokenAmountsAsArray) | ||||
|             .awaitTransactionSuccessAsync({ from: this._contractOwner }); | ||||
|     } | ||||
|     public async mintNonFungibleTokensAsync(beneficiaries: string[]): Promise<[BigNumber, BigNumber[]]> { | ||||
|         const tokenUri = 'dummyNonFungibleToken'; | ||||
|         const tokenIsNonFungible = true; | ||||
|         const tx = await this._logDecoder.getTxWithDecodedLogsAsync( | ||||
|             await this._erc1155Contract.create.sendTransactionAsync(tokenUri, tokenIsNonFungible, { | ||||
|             await this._erc1155Contract.create(tokenUri, tokenIsNonFungible).sendTransactionAsync({ | ||||
|                 from: this._contractOwner, | ||||
|             }), | ||||
|         ); | ||||
|         // tslint:disable-next-line no-unnecessary-type-assertion
 | ||||
|         const createFungibleTokenLog = tx.logs[0] as LogWithDecodedArgs<ERC1155TransferSingleEventArgs>; | ||||
|         const token = createFungibleTokenLog.args.id; | ||||
|         await this._erc1155Contract.mintNonFungible.awaitTransactionSuccessAsync(token, beneficiaries, { | ||||
|         await this._erc1155Contract.mintNonFungible(token, beneficiaries).awaitTransactionSuccessAsync({ | ||||
|             from: this._contractOwner, | ||||
|         }); | ||||
|         const encodedNftIds: BigNumber[] = []; | ||||
| @@ -132,14 +126,14 @@ export class Erc1155Wrapper { | ||||
|         isApproved: boolean, | ||||
|     ): Promise<TransactionReceiptWithDecodedLogs> { | ||||
|         const tx = await this._logDecoder.getTxWithDecodedLogsAsync( | ||||
|             await this._erc1155Contract.setApprovalForAll.sendTransactionAsync(beneficiary, isApproved, { | ||||
|             await this._erc1155Contract.setApprovalForAll(beneficiary, isApproved).sendTransactionAsync({ | ||||
|                 from: owner, | ||||
|             }), | ||||
|         ); | ||||
|         return tx; | ||||
|     } | ||||
|     public async isApprovedForAllAsync(owner: string, beneficiary: string): Promise<boolean> { | ||||
|         const isApprovedForAll = await this._erc1155Contract.isApprovedForAll.callAsync(owner, beneficiary); | ||||
|         const isApprovedForAll = await this._erc1155Contract.isApprovedForAll(owner, beneficiary).callAsync(); | ||||
|         return isApprovedForAll; | ||||
|     } | ||||
|     public async assertBalancesAsync( | ||||
| @@ -161,18 +155,18 @@ export class Erc1155Wrapper { | ||||
|         }); | ||||
|     } | ||||
|     public async isNonFungibleItemAsync(tokenId: BigNumber): Promise<boolean> { | ||||
|         return this._erc1155Contract.isNonFungibleItem.callAsync(tokenId); | ||||
|         return this._erc1155Contract.isNonFungibleItem(tokenId).callAsync(); | ||||
|     } | ||||
|     public async isFungibleItemAsync(tokenId: BigNumber): Promise<boolean> { | ||||
|         return !(await this.isNonFungibleItemAsync(tokenId)); | ||||
|     } | ||||
|     public async getOwnerOfAsync(tokenId: BigNumber): Promise<string> { | ||||
|         return this._erc1155Contract.ownerOf.callAsync(tokenId); | ||||
|         return this._erc1155Contract.ownerOf(tokenId).callAsync(); | ||||
|     } | ||||
|     /** | ||||
|      * @dev Get the balance of an ERC1155 token for a given owner and token ID. | ||||
|      */ | ||||
|     public async getBalanceAsync(ownerAddress: string, tokenId: BigNumber): Promise<BigNumber> { | ||||
|         return this._erc1155Contract.balanceOf.callAsync(ownerAddress, tokenId); | ||||
|         return this._erc1155Contract.balanceOf(ownerAddress, tokenId).callAsync(); | ||||
|     } | ||||
| } | ||||
| @@ -1,3 +1,3 @@ | ||||
| export * from './wrappers'; | ||||
| export * from './artifacts'; | ||||
| export { Erc1155Wrapper } from '../test/utils/erc1155_wrapper'; | ||||
| export { Erc1155Wrapper } from './erc1155_wrapper'; | ||||
|   | ||||
| @@ -6,7 +6,4 @@ | ||||
| export * from '../generated-wrappers/dummy_erc1155_receiver'; | ||||
| export * from '../generated-wrappers/erc1155'; | ||||
| export * from '../generated-wrappers/erc1155_mintable'; | ||||
| export * from '../generated-wrappers/i_erc1155_mintable'; | ||||
| export * from '../generated-wrappers/i_erc1155_receiver'; | ||||
| export * from '../generated-wrappers/ierc1155'; | ||||
| export * from '../generated-wrappers/mixin_non_fungible_token'; | ||||
|   | ||||
							
								
								
									
										23
									
								
								contracts/erc1155/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								contracts/erc1155/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| import { ContractArtifact } from 'ethereum-types'; | ||||
|  | ||||
| import * as DummyERC1155Receiver from '../test/generated-artifacts/DummyERC1155Receiver.json'; | ||||
| import * as ERC1155 from '../test/generated-artifacts/ERC1155.json'; | ||||
| import * as ERC1155Mintable from '../test/generated-artifacts/ERC1155Mintable.json'; | ||||
| import * as IERC1155 from '../test/generated-artifacts/IERC1155.json'; | ||||
| import * as IERC1155Mintable from '../test/generated-artifacts/IERC1155Mintable.json'; | ||||
| import * as IERC1155Receiver from '../test/generated-artifacts/IERC1155Receiver.json'; | ||||
| import * as MixinNonFungibleToken from '../test/generated-artifacts/MixinNonFungibleToken.json'; | ||||
| export const artifacts = { | ||||
|     ERC1155: ERC1155 as ContractArtifact, | ||||
|     ERC1155Mintable: ERC1155Mintable as ContractArtifact, | ||||
|     MixinNonFungibleToken: MixinNonFungibleToken as ContractArtifact, | ||||
|     IERC1155: IERC1155 as ContractArtifact, | ||||
|     IERC1155Mintable: IERC1155Mintable as ContractArtifact, | ||||
|     IERC1155Receiver: IERC1155Receiver as ContractArtifact, | ||||
|     DummyERC1155Receiver: DummyERC1155Receiver as ContractArtifact, | ||||
| }; | ||||
| @@ -6,21 +6,19 @@ import { | ||||
|     txDefaults, | ||||
|     web3Wrapper, | ||||
| } from '@0x/contracts-test-utils'; | ||||
| import { SafeMathRevertErrors } from '@0x/contracts-utils'; | ||||
| import { BlockchainLifecycle } from '@0x/dev-utils'; | ||||
| import { RevertReason } from '@0x/types'; | ||||
| import { BigNumber, SafeMathRevertErrors } from '@0x/utils'; | ||||
| import { BigNumber } from '@0x/utils'; | ||||
| import * as chai from 'chai'; | ||||
| import { LogWithDecodedArgs } from 'ethereum-types'; | ||||
| import * as _ from 'lodash'; | ||||
|  | ||||
| import { | ||||
|     artifacts, | ||||
|     DummyERC1155ReceiverBatchTokenReceivedEventArgs, | ||||
|     DummyERC1155ReceiverContract, | ||||
|     ERC1155MintableContract, | ||||
| } from '../src'; | ||||
| import { Erc1155Wrapper } from '../src/erc1155_wrapper'; | ||||
| import { ERC1155MintableContract } from '../src/wrappers'; | ||||
|  | ||||
| import { Erc1155Wrapper } from './utils/erc1155_wrapper'; | ||||
| import { artifacts } from './artifacts'; | ||||
| import { DummyERC1155ReceiverBatchTokenReceivedEventArgs, DummyERC1155ReceiverContract } from './wrappers'; | ||||
| chaiSetup.configure(); | ||||
| const expect = chai.expect; | ||||
| const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); | ||||
| @@ -179,14 +177,9 @@ describe('ERC1155Token', () => { | ||||
|                 valueToTransfer, | ||||
|             ); | ||||
|             // execute transfer | ||||
|             const tx = erc1155Contract.safeTransferFrom.sendTransactionAsync( | ||||
|                 spender, | ||||
|                 receiver, | ||||
|                 tokenToTransfer, | ||||
|                 valueToTransfer, | ||||
|                 receiverCallbackData, | ||||
|                 { from: spender }, | ||||
|             ); | ||||
|             const tx = erc1155Contract | ||||
|                 .safeTransferFrom(spender, receiver, tokenToTransfer, valueToTransfer, receiverCallbackData) | ||||
|                 .sendTransactionAsync({ from: spender }); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
|         it('should revert if callback reverts', async () => { | ||||
| @@ -196,19 +189,14 @@ describe('ERC1155Token', () => { | ||||
|             // set receiver to reject balances | ||||
|             const shouldRejectTransfer = true; | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await erc1155Receiver.setRejectTransferFlag.sendTransactionAsync(shouldRejectTransfer), | ||||
|                 await erc1155Receiver.setRejectTransferFlag(shouldRejectTransfer).sendTransactionAsync(), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             // execute transfer | ||||
|             await expectTransactionFailedAsync( | ||||
|                 erc1155Contract.safeTransferFrom.sendTransactionAsync( | ||||
|                     spender, | ||||
|                     receiver, | ||||
|                     tokenToTransfer, | ||||
|                     valueToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                     { from: spender }, | ||||
|                 ), | ||||
|                 erc1155Contract | ||||
|                     .safeTransferFrom(spender, receiver, tokenToTransfer, valueToTransfer, receiverCallbackData) | ||||
|                     .sendTransactionAsync({ from: spender }), | ||||
|                 RevertReason.TransferRejected, | ||||
|             ); | ||||
|         }); | ||||
| @@ -355,14 +343,9 @@ describe('ERC1155Token', () => { | ||||
|                 valuesToTransfer[0], | ||||
|             ); | ||||
|             // execute transfer | ||||
|             const tx = erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( | ||||
|                 spender, | ||||
|                 receiver, | ||||
|                 tokensToTransfer, | ||||
|                 valuesToTransfer, | ||||
|                 receiverCallbackData, | ||||
|                 { from: spender }, | ||||
|             ); | ||||
|             const tx = erc1155Contract | ||||
|                 .safeBatchTransferFrom(spender, receiver, tokensToTransfer, valuesToTransfer, receiverCallbackData) | ||||
|                 .sendTransactionAsync({ from: spender }); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
|         it('should revert if callback reverts', async () => { | ||||
| @@ -372,19 +355,14 @@ describe('ERC1155Token', () => { | ||||
|             // set receiver to reject balances | ||||
|             const shouldRejectTransfer = true; | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await erc1155Receiver.setRejectTransferFlag.sendTransactionAsync(shouldRejectTransfer), | ||||
|                 await erc1155Receiver.setRejectTransferFlag(shouldRejectTransfer).sendTransactionAsync(), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             // execute transfer | ||||
|             await expectTransactionFailedAsync( | ||||
|                 erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( | ||||
|                     spender, | ||||
|                     receiver, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                     { from: spender }, | ||||
|                 ), | ||||
|                 erc1155Contract | ||||
|                     .safeBatchTransferFrom(spender, receiver, tokensToTransfer, valuesToTransfer, receiverCallbackData) | ||||
|                     .sendTransactionAsync({ from: spender }), | ||||
|                 RevertReason.TransferRejected, | ||||
|             ); | ||||
|         }); | ||||
| @@ -432,14 +410,9 @@ describe('ERC1155Token', () => { | ||||
|             await erc1155Wrapper.assertBalancesAsync(tokenHolders, [tokenToTransfer], expectedInitialBalances); | ||||
|             // execute transfer | ||||
|             await expectTransactionFailedAsync( | ||||
|                 erc1155Contract.safeTransferFrom.sendTransactionAsync( | ||||
|                     spender, | ||||
|                     receiver, | ||||
|                     tokenToTransfer, | ||||
|                     valueToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                     { from: delegatedSpender }, | ||||
|                 ), | ||||
|                 erc1155Contract | ||||
|                     .safeTransferFrom(spender, receiver, tokenToTransfer, valueToTransfer, receiverCallbackData) | ||||
|                     .sendTransactionAsync({ from: delegatedSpender }), | ||||
|                 RevertReason.InsufficientAllowance, | ||||
|             ); | ||||
|         }); | ||||
| @@ -485,14 +458,9 @@ describe('ERC1155Token', () => { | ||||
|             await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances); | ||||
|             // execute transfer | ||||
|             await expectTransactionFailedAsync( | ||||
|                 erc1155Contract.safeBatchTransferFrom.sendTransactionAsync( | ||||
|                     spender, | ||||
|                     receiver, | ||||
|                     tokensToTransfer, | ||||
|                     valuesToTransfer, | ||||
|                     receiverCallbackData, | ||||
|                     { from: delegatedSpender }, | ||||
|                 ), | ||||
|                 erc1155Contract | ||||
|                     .safeBatchTransferFrom(spender, receiver, tokensToTransfer, valuesToTransfer, receiverCallbackData) | ||||
|                     .sendTransactionAsync({ from: delegatedSpender }), | ||||
|                 RevertReason.InsufficientAllowance, | ||||
|             ); | ||||
|         }); | ||||
|   | ||||
							
								
								
									
										12
									
								
								contracts/erc1155/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								contracts/erc1155/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| export * from '../test/generated-wrappers/dummy_erc1155_receiver'; | ||||
| export * from '../test/generated-wrappers/erc1155'; | ||||
| export * from '../test/generated-wrappers/erc1155_mintable'; | ||||
| export * from '../test/generated-wrappers/i_erc1155_mintable'; | ||||
| export * from '../test/generated-wrappers/i_erc1155_receiver'; | ||||
| export * from '../test/generated-wrappers/ierc1155'; | ||||
| export * from '../test/generated-wrappers/mixin_non_fungible_token'; | ||||
| @@ -6,10 +6,14 @@ | ||||
|         "generated-artifacts/DummyERC1155Receiver.json", | ||||
|         "generated-artifacts/ERC1155.json", | ||||
|         "generated-artifacts/ERC1155Mintable.json", | ||||
|         "generated-artifacts/IERC1155.json", | ||||
|         "generated-artifacts/IERC1155Mintable.json", | ||||
|         "generated-artifacts/IERC1155Receiver.json", | ||||
|         "generated-artifacts/MixinNonFungibleToken.json" | ||||
|         "test/generated-artifacts/DummyERC1155Receiver.json", | ||||
|         "test/generated-artifacts/ERC1155.json", | ||||
|         "test/generated-artifacts/ERC1155Mintable.json", | ||||
|         "test/generated-artifacts/IERC1155.json", | ||||
|         "test/generated-artifacts/IERC1155Mintable.json", | ||||
|         "test/generated-artifacts/IERC1155Receiver.json", | ||||
|         "test/generated-artifacts/MixinNonFungibleToken.json" | ||||
|     ], | ||||
|     "exclude": ["./deploy/solc/solc_bin"] | ||||
| } | ||||
|   | ||||
							
								
								
									
										10
									
								
								contracts/erc20/.npmignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								contracts/erc20/.npmignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # Blacklist all files | ||||
| .* | ||||
| * | ||||
| # Whitelist lib | ||||
| !lib/**/* | ||||
| # Whitelist Solidity contracts | ||||
| !contracts/src/**/* | ||||
| # Blacklist tests in lib | ||||
| /lib/test/* | ||||
| # Package specific ignore | ||||
| @@ -1,4 +1,14 @@ | ||||
| [ | ||||
|     { | ||||
|         "version": "2.3.0-beta.2", | ||||
|         "changes": [ | ||||
|             { | ||||
|                 "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", | ||||
|                 "pr": 2330 | ||||
|             } | ||||
|         ], | ||||
|         "timestamp": 1574030254 | ||||
|     }, | ||||
|     { | ||||
|         "version": "2.3.0-beta.1", | ||||
|         "changes": [ | ||||
|   | ||||
| @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. | ||||
|  | ||||
| CHANGELOG | ||||
|  | ||||
| ## v2.3.0-beta.2 - _November 17, 2019_ | ||||
|  | ||||
|     * Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330) | ||||
|  | ||||
| ## v2.3.0-beta.1 - _November 7, 2019_ | ||||
|  | ||||
|     * Create `LibERC20Token` (#2309) | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|     "artifactsDir": "./generated-artifacts", | ||||
|     "artifactsDir": "./test/generated-artifacts", | ||||
|     "contractsDir": "./contracts", | ||||
|     "useDockerisedSolc": false, | ||||
|     "isOfflineMode": false, | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "name": "@0x/contracts-erc20", | ||||
|     "version": "2.3.0-beta.1", | ||||
|     "version": "2.3.0-beta.2", | ||||
|     "engines": { | ||||
|         "node": ">=6.12" | ||||
|     }, | ||||
| @@ -12,7 +12,7 @@ | ||||
|     "scripts": { | ||||
|         "build": "yarn pre_build && tsc -b", | ||||
|         "build:ci": "yarn build", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", | ||||
|         "test": "yarn run_mocha", | ||||
|         "rebuild_and_test": "run-s build test", | ||||
|         "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", | ||||
| @@ -21,20 +21,22 @@ | ||||
|         "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", | ||||
|         "compile": "sol-compiler", | ||||
|         "watch": "sol-compiler -w", | ||||
|         "clean": "shx rm -rf lib generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "coverage:report:text": "istanbul report text", | ||||
|         "coverage:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "profiler:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "coverage:report:lcov": "istanbul report lcov", | ||||
|         "test:circleci": "yarn test", | ||||
|         "contracts:gen": "contracts-gen", | ||||
|         "contracts:gen": "contracts-gen generate", | ||||
|         "contracts:copy": "contracts-gen copy", | ||||
|         "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" | ||||
|     }, | ||||
|     "config": { | ||||
|         "abis": "./generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IEtherToken|LibERC20Token|MintableERC20Token|TestLibERC20Token|TestLibERC20TokenTarget|UnlimitedAllowanceERC20Token|UntransferrableDummyERC20Token|WETH9|ZRXToken).json", | ||||
|         "publicInterfaceContracts": "DummyERC20Token,ERC20Token,WETH9,ZRXToken,DummyNoReturnERC20Token,DummyMultipleReturnERC20Token", | ||||
|         "abis": "./test/generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IEtherToken|LibERC20Token|MintableERC20Token|TestLibERC20Token|TestLibERC20TokenTarget|UnlimitedAllowanceERC20Token|UntransferrableDummyERC20Token|WETH9|ZRXToken).json", | ||||
|         "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." | ||||
|     }, | ||||
|     "repository": { | ||||
| @@ -47,12 +49,15 @@ | ||||
|     }, | ||||
|     "homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md", | ||||
|     "devDependencies": { | ||||
|         "@0x/abi-gen": "^4.4.0-beta.1", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.1", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.1", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.1", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.1", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.1", | ||||
|         "@0x/abi-gen": "^4.4.0-beta.2", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.2", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.2", | ||||
|         "@0x/contracts-utils": "^3.3.0-beta.2", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.2", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.2", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.2", | ||||
|         "@0x/utils": "^4.6.0-beta.2", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.2", | ||||
|         "@types/lodash": "4.14.104", | ||||
|         "@types/mocha": "^5.2.7", | ||||
|         "@types/node": "*", | ||||
| @@ -60,6 +65,7 @@ | ||||
|         "chai-as-promised": "^7.1.0", | ||||
|         "chai-bignumber": "^3.0.0", | ||||
|         "dirty-chai": "^2.0.1", | ||||
|         "lodash": "^4.17.11", | ||||
|         "make-promises-safe": "^1.1.0", | ||||
|         "mocha": "^6.2.0", | ||||
|         "npm-run-all": "^4.1.2", | ||||
| @@ -69,14 +75,10 @@ | ||||
|         "typescript": "3.0.1" | ||||
|     }, | ||||
|     "dependencies": { | ||||
|         "@0x/base-contract": "^5.5.0-beta.1", | ||||
|         "@0x/contracts-utils": "^3.3.0-beta.1", | ||||
|         "@0x/types": "^2.5.0-beta.1", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.1", | ||||
|         "@0x/utils": "^4.6.0-beta.1", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.1", | ||||
|         "ethereum-types": "^2.2.0-beta.1", | ||||
|         "lodash": "^4.17.11" | ||||
|         "@0x/base-contract": "^5.5.0-beta.2", | ||||
|         "@0x/types": "^2.5.0-beta.2", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.2", | ||||
|         "ethereum-types": "^2.2.0-beta.2" | ||||
|     }, | ||||
|     "publishConfig": { | ||||
|         "access": "public" | ||||
|   | ||||
| @@ -9,29 +9,13 @@ import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; | ||||
| import * as DummyMultipleReturnERC20Token from '../generated-artifacts/DummyMultipleReturnERC20Token.json'; | ||||
| import * as DummyNoReturnERC20Token from '../generated-artifacts/DummyNoReturnERC20Token.json'; | ||||
| import * as ERC20Token from '../generated-artifacts/ERC20Token.json'; | ||||
| import * as IERC20Token from '../generated-artifacts/IERC20Token.json'; | ||||
| import * as IEtherToken from '../generated-artifacts/IEtherToken.json'; | ||||
| import * as LibERC20Token from '../generated-artifacts/LibERC20Token.json'; | ||||
| import * as MintableERC20Token from '../generated-artifacts/MintableERC20Token.json'; | ||||
| import * as TestLibERC20Token from '../generated-artifacts/TestLibERC20Token.json'; | ||||
| import * as TestLibERC20TokenTarget from '../generated-artifacts/TestLibERC20TokenTarget.json'; | ||||
| import * as UnlimitedAllowanceERC20Token from '../generated-artifacts/UnlimitedAllowanceERC20Token.json'; | ||||
| import * as UntransferrableDummyERC20Token from '../generated-artifacts/UntransferrableDummyERC20Token.json'; | ||||
| import * as WETH9 from '../generated-artifacts/WETH9.json'; | ||||
| import * as ZRXToken from '../generated-artifacts/ZRXToken.json'; | ||||
| export const artifacts = { | ||||
|     DummyERC20Token: DummyERC20Token as ContractArtifact, | ||||
|     ERC20Token: ERC20Token as ContractArtifact, | ||||
|     LibERC20Token: LibERC20Token as ContractArtifact, | ||||
|     MintableERC20Token: MintableERC20Token as ContractArtifact, | ||||
|     UnlimitedAllowanceERC20Token: UnlimitedAllowanceERC20Token as ContractArtifact, | ||||
|     WETH9: WETH9 as ContractArtifact, | ||||
|     ZRXToken: (ZRXToken as any) as ContractArtifact, | ||||
|     IERC20Token: IERC20Token as ContractArtifact, | ||||
|     IEtherToken: IEtherToken as ContractArtifact, | ||||
|     DummyERC20Token: DummyERC20Token as ContractArtifact, | ||||
|     DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, | ||||
|     DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, | ||||
|     TestLibERC20Token: TestLibERC20Token as ContractArtifact, | ||||
|     TestLibERC20TokenTarget: TestLibERC20TokenTarget as ContractArtifact, | ||||
|     UntransferrableDummyERC20Token: UntransferrableDummyERC20Token as ContractArtifact, | ||||
|     DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, | ||||
| }; | ||||
|   | ||||
| @@ -7,13 +7,5 @@ export * from '../generated-wrappers/dummy_erc20_token'; | ||||
| export * from '../generated-wrappers/dummy_multiple_return_erc20_token'; | ||||
| export * from '../generated-wrappers/dummy_no_return_erc20_token'; | ||||
| export * from '../generated-wrappers/erc20_token'; | ||||
| export * from '../generated-wrappers/i_erc20_token'; | ||||
| export * from '../generated-wrappers/i_ether_token'; | ||||
| export * from '../generated-wrappers/lib_erc20_token'; | ||||
| export * from '../generated-wrappers/mintable_erc20_token'; | ||||
| export * from '../generated-wrappers/test_lib_erc20_token'; | ||||
| export * from '../generated-wrappers/test_lib_erc20_token_target'; | ||||
| export * from '../generated-wrappers/unlimited_allowance_erc20_token'; | ||||
| export * from '../generated-wrappers/untransferrable_dummy_erc20_token'; | ||||
| export * from '../generated-wrappers/weth9'; | ||||
| export * from '../generated-wrappers/zrx_token'; | ||||
|   | ||||
							
								
								
									
										37
									
								
								contracts/erc20/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								contracts/erc20/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| import { ContractArtifact } from 'ethereum-types'; | ||||
|  | ||||
| import * as DummyERC20Token from '../test/generated-artifacts/DummyERC20Token.json'; | ||||
| import * as DummyMultipleReturnERC20Token from '../test/generated-artifacts/DummyMultipleReturnERC20Token.json'; | ||||
| import * as DummyNoReturnERC20Token from '../test/generated-artifacts/DummyNoReturnERC20Token.json'; | ||||
| import * as ERC20Token from '../test/generated-artifacts/ERC20Token.json'; | ||||
| import * as IERC20Token from '../test/generated-artifacts/IERC20Token.json'; | ||||
| import * as IEtherToken from '../test/generated-artifacts/IEtherToken.json'; | ||||
| import * as LibERC20Token from '../test/generated-artifacts/LibERC20Token.json'; | ||||
| import * as MintableERC20Token from '../test/generated-artifacts/MintableERC20Token.json'; | ||||
| import * as TestLibERC20Token from '../test/generated-artifacts/TestLibERC20Token.json'; | ||||
| import * as TestLibERC20TokenTarget from '../test/generated-artifacts/TestLibERC20TokenTarget.json'; | ||||
| import * as UnlimitedAllowanceERC20Token from '../test/generated-artifacts/UnlimitedAllowanceERC20Token.json'; | ||||
| import * as UntransferrableDummyERC20Token from '../test/generated-artifacts/UntransferrableDummyERC20Token.json'; | ||||
| import * as WETH9 from '../test/generated-artifacts/WETH9.json'; | ||||
| import * as ZRXToken from '../test/generated-artifacts/ZRXToken.json'; | ||||
| export const artifacts = { | ||||
|     ERC20Token: ERC20Token as ContractArtifact, | ||||
|     LibERC20Token: LibERC20Token as ContractArtifact, | ||||
|     MintableERC20Token: MintableERC20Token as ContractArtifact, | ||||
|     UnlimitedAllowanceERC20Token: UnlimitedAllowanceERC20Token as ContractArtifact, | ||||
|     WETH9: WETH9 as ContractArtifact, | ||||
|     ZRXToken: (ZRXToken as any) as ContractArtifact, | ||||
|     IERC20Token: IERC20Token as ContractArtifact, | ||||
|     IEtherToken: IEtherToken as ContractArtifact, | ||||
|     DummyERC20Token: DummyERC20Token as ContractArtifact, | ||||
|     DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, | ||||
|     DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, | ||||
|     TestLibERC20Token: TestLibERC20Token as ContractArtifact, | ||||
|     TestLibERC20TokenTarget: TestLibERC20TokenTarget as ContractArtifact, | ||||
|     UntransferrableDummyERC20Token: UntransferrableDummyERC20Token as ContractArtifact, | ||||
| }; | ||||
| @@ -9,7 +9,9 @@ import { | ||||
| } from '@0x/contracts-test-utils'; | ||||
| import { RawRevertError, StringRevertError } from '@0x/utils'; | ||||
|  | ||||
| import { artifacts, TestLibERC20TokenContract, TestLibERC20TokenTargetEvents } from '../src'; | ||||
| import { TestLibERC20TokenContract, TestLibERC20TokenTargetEvents } from './wrappers'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| blockchainTests('LibERC20Token', env => { | ||||
|     let testContract: TestLibERC20TokenContract; | ||||
| @@ -37,13 +39,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('calls the target with the correct arguments', async () => { | ||||
|             const spender = randomAddress(); | ||||
|             const allowance = getRandomInteger(0, 100e18); | ||||
|             const { logs } = await testContract.testApprove.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TRUE, | ||||
|                 spender, | ||||
|                 allowance, | ||||
|             ); | ||||
|             const { logs } = await testContract | ||||
|                 .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, spender, allowance) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             expect(logs).to.be.length(1); | ||||
|             verifyEventsFromLogs(logs, [{ spender, allowance }], TestLibERC20TokenTargetEvents.ApproveCalled); | ||||
|         }); | ||||
| @@ -51,37 +49,25 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('succeeds if the target returns true', async () => { | ||||
|             const spender = randomAddress(); | ||||
|             const allowance = getRandomInteger(0, 100e18); | ||||
|             await testContract.testApprove.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TRUE, | ||||
|                 spender, | ||||
|                 allowance, | ||||
|             ); | ||||
|             await testContract | ||||
|                 .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, spender, allowance) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|  | ||||
|         it('succeeds if the target returns nothing', async () => { | ||||
|             const spender = randomAddress(); | ||||
|             const allowance = getRandomInteger(0, 100e18); | ||||
|             await testContract.testApprove.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 constants.NULL_BYTES, | ||||
|                 spender, | ||||
|                 allowance, | ||||
|             ); | ||||
|             await testContract | ||||
|                 .testApprove(false, encodeRevert(REVERT_STRING), constants.NULL_BYTES, spender, allowance) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|  | ||||
|         it('fails if the target returns false', async () => { | ||||
|             const spender = randomAddress(); | ||||
|             const allowance = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testApprove.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_FALSE, | ||||
|                 spender, | ||||
|                 allowance, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_FALSE, spender, allowance) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_FALSE); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -89,13 +75,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('fails if the target returns nonzero and not true', async () => { | ||||
|             const spender = randomAddress(); | ||||
|             const allowance = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testApprove.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TWO, | ||||
|                 spender, | ||||
|                 allowance, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_TWO, spender, allowance) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_TWO); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -103,13 +85,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('fails if the target returns less than 32 bytes', async () => { | ||||
|             const spender = randomAddress(); | ||||
|             const allowance = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testApprove.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_SHORT_TRUE, | ||||
|                 spender, | ||||
|                 allowance, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_SHORT_TRUE, spender, allowance) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -117,13 +95,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('fails if the target returns greater than 32 bytes', async () => { | ||||
|             const spender = randomAddress(); | ||||
|             const allowance = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testApprove.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_LONG_TRUE, | ||||
|                 spender, | ||||
|                 allowance, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testApprove(false, encodeRevert(REVERT_STRING), ENCODED_LONG_TRUE, spender, allowance) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_LONG_TRUE); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -131,26 +105,18 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('fails if the target reverts', async () => { | ||||
|             const spender = randomAddress(); | ||||
|             const allowance = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testApprove.awaitTransactionSuccessAsync( | ||||
|                 true, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TRUE, | ||||
|                 spender, | ||||
|                 allowance, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testApprove(true, encodeRevert(REVERT_STRING), ENCODED_TRUE, spender, allowance) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             return expect(tx).to.revertWith(REVERT_STRING); | ||||
|         }); | ||||
|  | ||||
|         it('fails if the target reverts with no data', async () => { | ||||
|             const spender = randomAddress(); | ||||
|             const allowance = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testApprove.awaitTransactionSuccessAsync( | ||||
|                 true, | ||||
|                 constants.NULL_BYTES, | ||||
|                 ENCODED_TRUE, | ||||
|                 spender, | ||||
|                 allowance, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testApprove(true, constants.NULL_BYTES, ENCODED_TRUE, spender, allowance) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             return expect(tx).to.be.rejectedWith('revert'); | ||||
|         }); | ||||
|     }); | ||||
| @@ -159,13 +125,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('calls the target with the correct arguments', async () => { | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const { logs } = await testContract.testTransfer.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TRUE, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const { logs } = await testContract | ||||
|                 .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             expect(logs).to.be.length(1); | ||||
|             verifyEventsFromLogs(logs, [{ to, amount }], TestLibERC20TokenTargetEvents.TransferCalled); | ||||
|         }); | ||||
| @@ -173,37 +135,25 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('succeeds if the target returns true', async () => { | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             await testContract.testTransfer.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TRUE, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             await testContract | ||||
|                 .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|  | ||||
|         it('succeeds if the target returns nothing', async () => { | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             await testContract.testTransfer.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 constants.NULL_BYTES, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             await testContract | ||||
|                 .testTransfer(false, encodeRevert(REVERT_STRING), constants.NULL_BYTES, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|  | ||||
|         it('fails if the target returns false', async () => { | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransfer.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_FALSE, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_FALSE, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_FALSE); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -211,13 +161,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('fails if the target returns nonzero and not true', async () => { | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransfer.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TWO, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_TWO, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_TWO); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -225,13 +171,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('fails if the target returns less than 32 bytes', async () => { | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransfer.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_SHORT_TRUE, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_SHORT_TRUE, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -239,13 +181,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('fails if the target returns greater than 32 bytes', async () => { | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransfer.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_LONG_TRUE, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransfer(false, encodeRevert(REVERT_STRING), ENCODED_LONG_TRUE, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_LONG_TRUE); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -253,26 +191,18 @@ blockchainTests('LibERC20Token', env => { | ||||
|         it('fails if the target reverts', async () => { | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransfer.awaitTransactionSuccessAsync( | ||||
|                 true, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TRUE, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransfer(true, encodeRevert(REVERT_STRING), ENCODED_TRUE, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             return expect(tx).to.revertWith(REVERT_STRING); | ||||
|         }); | ||||
|  | ||||
|         it('fails if the target reverts with no data', async () => { | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransfer.awaitTransactionSuccessAsync( | ||||
|                 true, | ||||
|                 constants.NULL_BYTES, | ||||
|                 ENCODED_TRUE, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransfer(true, constants.NULL_BYTES, ENCODED_TRUE, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             return expect(tx).to.be.rejectedWith('revert'); | ||||
|         }); | ||||
|     }); | ||||
| @@ -282,14 +212,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|             const owner = randomAddress(); | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const { logs } = await testContract.testTransferFrom.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TRUE, | ||||
|                 owner, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const { logs } = await testContract | ||||
|                 .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, owner, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             expect(logs).to.be.length(1); | ||||
|             verifyEventsFromLogs(logs, [{ from: owner, to, amount }], TestLibERC20TokenTargetEvents.TransferFromCalled); | ||||
|         }); | ||||
| @@ -298,42 +223,27 @@ blockchainTests('LibERC20Token', env => { | ||||
|             const owner = randomAddress(); | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             await testContract.testTransferFrom.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TRUE, | ||||
|                 owner, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             await testContract | ||||
|                 .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_TRUE, owner, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|  | ||||
|         it('succeeds if the target returns nothing', async () => { | ||||
|             const owner = randomAddress(); | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             await testContract.testTransferFrom.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 constants.NULL_BYTES, | ||||
|                 owner, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             await testContract | ||||
|                 .testTransferFrom(false, encodeRevert(REVERT_STRING), constants.NULL_BYTES, owner, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|         }); | ||||
|  | ||||
|         it('fails if the target returns false', async () => { | ||||
|             const owner = randomAddress(); | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_FALSE, | ||||
|                 owner, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_FALSE, owner, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_FALSE); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -342,14 +252,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|             const owner = randomAddress(); | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TWO, | ||||
|                 owner, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_TWO, owner, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_TWO); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -358,14 +263,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|             const owner = randomAddress(); | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_SHORT_TRUE, | ||||
|                 owner, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_SHORT_TRUE, owner, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -374,14 +274,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|             const owner = randomAddress(); | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( | ||||
|                 false, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_LONG_TRUE, | ||||
|                 owner, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransferFrom(false, encodeRevert(REVERT_STRING), ENCODED_LONG_TRUE, owner, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             const expectedError = new RawRevertError(ENCODED_LONG_TRUE); | ||||
|             return expect(tx).to.revertWith(expectedError); | ||||
|         }); | ||||
| @@ -390,14 +285,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|             const owner = randomAddress(); | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( | ||||
|                 true, | ||||
|                 encodeRevert(REVERT_STRING), | ||||
|                 ENCODED_TRUE, | ||||
|                 owner, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransferFrom(true, encodeRevert(REVERT_STRING), ENCODED_TRUE, owner, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             return expect(tx).to.revertWith(REVERT_STRING); | ||||
|         }); | ||||
|  | ||||
| @@ -405,14 +295,9 @@ blockchainTests('LibERC20Token', env => { | ||||
|             const owner = randomAddress(); | ||||
|             const to = randomAddress(); | ||||
|             const amount = getRandomInteger(0, 100e18); | ||||
|             const tx = testContract.testTransferFrom.awaitTransactionSuccessAsync( | ||||
|                 true, | ||||
|                 constants.NULL_BYTES, | ||||
|                 ENCODED_TRUE, | ||||
|                 owner, | ||||
|                 to, | ||||
|                 amount, | ||||
|             ); | ||||
|             const tx = testContract | ||||
|                 .testTransferFrom(true, constants.NULL_BYTES, ENCODED_TRUE, owner, to, amount) | ||||
|                 .awaitTransactionSuccessAsync(); | ||||
|             return expect(tx).to.be.rejectedWith('revert'); | ||||
|         }); | ||||
|     }); | ||||
|   | ||||
| @@ -11,7 +11,9 @@ import { RevertReason } from '@0x/types'; | ||||
| import { BigNumber } from '@0x/utils'; | ||||
| import * as chai from 'chai'; | ||||
|  | ||||
| import { artifacts, DummyERC20TokenContract } from '../src'; | ||||
| import { DummyERC20TokenContract } from './wrappers'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| chaiSetup.configure(); | ||||
| const expect = chai.expect; | ||||
| @@ -44,7 +46,7 @@ describe('UnlimitedAllowanceToken', () => { | ||||
|             constants.DUMMY_TOKEN_TOTAL_SUPPLY, | ||||
|         ); | ||||
|         await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|             await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner }), | ||||
|             await token.mint(MAX_MINT_VALUE).sendTransactionAsync({ from: owner }), | ||||
|             constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|         ); | ||||
|     }); | ||||
| @@ -56,24 +58,24 @@ describe('UnlimitedAllowanceToken', () => { | ||||
|     }); | ||||
|     describe('transfer', () => { | ||||
|         it('should revert if owner has insufficient balance', async () => { | ||||
|             const ownerBalance = await token.balanceOf.callAsync(owner); | ||||
|             const ownerBalance = await token.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = ownerBalance.plus(1); | ||||
|             return expectContractCallFailedAsync( | ||||
|                 token.transfer.callAsync(spender, amountToTransfer, { from: owner }), | ||||
|                 token.transfer(spender, amountToTransfer).callAsync({ from: owner }), | ||||
|                 RevertReason.Erc20InsufficientBalance, | ||||
|             ); | ||||
|         }); | ||||
|  | ||||
|         it('should transfer balance from sender to receiver', async () => { | ||||
|             const receiver = spender; | ||||
|             const initOwnerBalance = await token.balanceOf.callAsync(owner); | ||||
|             const initOwnerBalance = await token.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = new BigNumber(1); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }), | ||||
|                 await token.transfer(receiver, amountToTransfer).sendTransactionAsync({ from: owner }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             const finalOwnerBalance = await token.balanceOf.callAsync(owner); | ||||
|             const finalReceiverBalance = await token.balanceOf.callAsync(receiver); | ||||
|             const finalOwnerBalance = await token.balanceOf(owner).callAsync(); | ||||
|             const finalReceiverBalance = await token.balanceOf(receiver).callAsync(); | ||||
|  | ||||
|             const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer); | ||||
|             const expectedFinalReceiverBalance = amountToTransfer; | ||||
| @@ -82,7 +84,7 @@ describe('UnlimitedAllowanceToken', () => { | ||||
|         }); | ||||
|  | ||||
|         it('should return true on a 0 value transfer', async () => { | ||||
|             const didReturnTrue = await token.transfer.callAsync(spender, new BigNumber(0), { | ||||
|             const didReturnTrue = await token.transfer(spender, new BigNumber(0)).callAsync({ | ||||
|                 from: owner, | ||||
|             }); | ||||
|             expect(didReturnTrue).to.be.true(); | ||||
| @@ -91,14 +93,14 @@ describe('UnlimitedAllowanceToken', () => { | ||||
|  | ||||
|     describe('transferFrom', () => { | ||||
|         it('should revert if owner has insufficient balance', async () => { | ||||
|             const ownerBalance = await token.balanceOf.callAsync(owner); | ||||
|             const ownerBalance = await token.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = ownerBalance.plus(1); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }), | ||||
|                 await token.approve(spender, amountToTransfer).sendTransactionAsync({ from: owner }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             return expectContractCallFailedAsync( | ||||
|                 token.transferFrom.callAsync(owner, spender, amountToTransfer, { | ||||
|                 token.transferFrom(owner, spender, amountToTransfer).callAsync({ | ||||
|                     from: spender, | ||||
|                 }), | ||||
|                 RevertReason.Erc20InsufficientBalance, | ||||
| @@ -106,15 +108,15 @@ describe('UnlimitedAllowanceToken', () => { | ||||
|         }); | ||||
|  | ||||
|         it('should revert if spender has insufficient allowance', async () => { | ||||
|             const ownerBalance = await token.balanceOf.callAsync(owner); | ||||
|             const ownerBalance = await token.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = ownerBalance; | ||||
|  | ||||
|             const spenderAllowance = await token.allowance.callAsync(owner, spender); | ||||
|             const spenderAllowance = await token.allowance(owner, spender).callAsync(); | ||||
|             const isSpenderAllowanceInsufficient = spenderAllowance.comparedTo(amountToTransfer) < 0; | ||||
|             expect(isSpenderAllowanceInsufficient).to.be.true(); | ||||
|  | ||||
|             return expectContractCallFailedAsync( | ||||
|                 token.transferFrom.callAsync(owner, spender, amountToTransfer, { | ||||
|                 token.transferFrom(owner, spender, amountToTransfer).callAsync({ | ||||
|                     from: spender, | ||||
|                 }), | ||||
|                 RevertReason.Erc20InsufficientAllowance, | ||||
| @@ -123,72 +125,72 @@ describe('UnlimitedAllowanceToken', () => { | ||||
|  | ||||
|         it('should return true on a 0 value transfer', async () => { | ||||
|             const amountToTransfer = new BigNumber(0); | ||||
|             const didReturnTrue = await token.transferFrom.callAsync(owner, spender, amountToTransfer, { | ||||
|             const didReturnTrue = await token.transferFrom(owner, spender, amountToTransfer).callAsync({ | ||||
|                 from: spender, | ||||
|             }); | ||||
|             expect(didReturnTrue).to.be.true(); | ||||
|         }); | ||||
|  | ||||
|         it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => { | ||||
|             const initOwnerBalance = await token.balanceOf.callAsync(owner); | ||||
|             const initOwnerBalance = await token.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = initOwnerBalance; | ||||
|             const initSpenderAllowance = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), | ||||
|                 await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { | ||||
|                 await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ | ||||
|                     from: spender, | ||||
|                     gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, | ||||
|                 }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|  | ||||
|             const newSpenderAllowance = await token.allowance.callAsync(owner, spender); | ||||
|             const newSpenderAllowance = await token.allowance(owner, spender).callAsync(); | ||||
|             expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); | ||||
|         }); | ||||
|  | ||||
|         it('should transfer the correct balances if spender has sufficient allowance', async () => { | ||||
|             const initOwnerBalance = await token.balanceOf.callAsync(owner); | ||||
|             const initOwnerBalance = await token.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = initOwnerBalance; | ||||
|             const initSpenderAllowance = initOwnerBalance; | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), | ||||
|                 await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { | ||||
|                 await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ | ||||
|                     from: spender, | ||||
|                     gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, | ||||
|                 }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|  | ||||
|             const newOwnerBalance = await token.balanceOf.callAsync(owner); | ||||
|             const newSpenderBalance = await token.balanceOf.callAsync(spender); | ||||
|             const newOwnerBalance = await token.balanceOf(owner).callAsync(); | ||||
|             const newSpenderBalance = await token.balanceOf(spender).callAsync(); | ||||
|  | ||||
|             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 token.balanceOf.callAsync(owner); | ||||
|             const initOwnerBalance = await token.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = initOwnerBalance; | ||||
|             const initSpenderAllowance = initOwnerBalance; | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), | ||||
|                 await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { | ||||
|                 await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ | ||||
|                     from: spender, | ||||
|                     gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, | ||||
|                 }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|  | ||||
|             const newSpenderAllowance = await token.allowance.callAsync(owner, spender); | ||||
|             const newSpenderAllowance = await token.allowance(owner, spender).callAsync(); | ||||
|             expect(newSpenderAllowance).to.be.bignumber.equal(0); | ||||
|         }); | ||||
|     }); | ||||
|   | ||||
| @@ -12,7 +12,9 @@ import { BigNumber } from '@0x/utils'; | ||||
| import { Web3Wrapper } from '@0x/web3-wrapper'; | ||||
| import * as chai from 'chai'; | ||||
|  | ||||
| import { artifacts, WETH9Contract } from '../src'; | ||||
| import { WETH9Contract } from './wrappers'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| chaiSetup.configure(); | ||||
| const expect = chai.expect; | ||||
| @@ -54,16 +56,16 @@ describe('EtherToken', () => { | ||||
|             const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); | ||||
|             const ethToDeposit = initEthBalance.plus(1); | ||||
|  | ||||
|             return expectInsufficientFundsAsync(etherToken.deposit.sendTransactionAsync({ value: ethToDeposit })); | ||||
|             return expectInsufficientFundsAsync(etherToken.deposit().sendTransactionAsync({ value: ethToDeposit })); | ||||
|         }); | ||||
|  | ||||
|         it('should convert deposited Ether to wrapped Ether tokens', async () => { | ||||
|             const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); | ||||
|             const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); | ||||
|             const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); | ||||
|  | ||||
|             const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1))); | ||||
|  | ||||
|             const txHash = await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }); | ||||
|             const txHash = await etherToken.deposit().sendTransactionAsync({ value: ethToDeposit }); | ||||
|             const receipt = await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 txHash, | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
| @@ -71,7 +73,7 @@ describe('EtherToken', () => { | ||||
|  | ||||
|             const ethSpentOnGas = gasPrice.times(receipt.gasUsed); | ||||
|             const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); | ||||
|             const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account); | ||||
|             const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); | ||||
|  | ||||
|             expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); | ||||
|             expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit)); | ||||
| @@ -80,25 +82,25 @@ describe('EtherToken', () => { | ||||
|  | ||||
|     describe('withdraw', () => { | ||||
|         it('should revert if caller attempts to withdraw greater than caller balance', async () => { | ||||
|             const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); | ||||
|             const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); | ||||
|             const ethTokensToWithdraw = initEthTokenBalance.plus(1); | ||||
|  | ||||
|             return expectTransactionFailedWithoutReasonAsync( | ||||
|                 etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw), | ||||
|                 etherToken.withdraw(ethTokensToWithdraw).sendTransactionAsync(), | ||||
|             ); | ||||
|         }); | ||||
|  | ||||
|         it('should convert ether tokens to ether with sufficient balance', async () => { | ||||
|             const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1))); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }), | ||||
|                 await etherToken.deposit().sendTransactionAsync({ value: ethToDeposit }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); | ||||
|             const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); | ||||
|             const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); | ||||
|             const ethTokensToWithdraw = initEthTokenBalance; | ||||
|             expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0); | ||||
|             const txHash = await etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw, { | ||||
|             const txHash = await etherToken.withdraw(ethTokensToWithdraw).sendTransactionAsync({ | ||||
|                 gas: constants.MAX_ETHERTOKEN_WITHDRAW_GAS, | ||||
|             }); | ||||
|             const receipt = await web3Wrapper.awaitTransactionSuccessAsync( | ||||
| @@ -108,7 +110,7 @@ describe('EtherToken', () => { | ||||
|  | ||||
|             const ethSpentOnGas = gasPrice.times(receipt.gasUsed); | ||||
|             const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); | ||||
|             const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account); | ||||
|             const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); | ||||
|  | ||||
|             expect(finalEthBalance).to.be.bignumber.equal( | ||||
|                 initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)), | ||||
| @@ -120,7 +122,7 @@ describe('EtherToken', () => { | ||||
|     describe('fallback', () => { | ||||
|         it('should convert sent ether to ether tokens', async () => { | ||||
|             const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); | ||||
|             const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); | ||||
|             const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); | ||||
|  | ||||
|             const ethToDeposit = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18); | ||||
|  | ||||
| @@ -138,7 +140,7 @@ describe('EtherToken', () => { | ||||
|  | ||||
|             const ethSpentOnGas = gasPrice.times(receipt.gasUsed); | ||||
|             const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); | ||||
|             const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account); | ||||
|             const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); | ||||
|  | ||||
|             expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); | ||||
|             expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit)); | ||||
|   | ||||
							
								
								
									
										19
									
								
								contracts/erc20/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								contracts/erc20/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| export * from '../test/generated-wrappers/dummy_erc20_token'; | ||||
| export * from '../test/generated-wrappers/dummy_multiple_return_erc20_token'; | ||||
| export * from '../test/generated-wrappers/dummy_no_return_erc20_token'; | ||||
| export * from '../test/generated-wrappers/erc20_token'; | ||||
| export * from '../test/generated-wrappers/i_erc20_token'; | ||||
| export * from '../test/generated-wrappers/i_ether_token'; | ||||
| export * from '../test/generated-wrappers/lib_erc20_token'; | ||||
| export * from '../test/generated-wrappers/mintable_erc20_token'; | ||||
| export * from '../test/generated-wrappers/test_lib_erc20_token'; | ||||
| export * from '../test/generated-wrappers/test_lib_erc20_token_target'; | ||||
| export * from '../test/generated-wrappers/unlimited_allowance_erc20_token'; | ||||
| export * from '../test/generated-wrappers/untransferrable_dummy_erc20_token'; | ||||
| export * from '../test/generated-wrappers/weth9'; | ||||
| export * from '../test/generated-wrappers/zrx_token'; | ||||
| @@ -4,7 +4,9 @@ import { BigNumber } from '@0x/utils'; | ||||
| import { Web3Wrapper } from '@0x/web3-wrapper'; | ||||
| import * as chai from 'chai'; | ||||
|  | ||||
| import { artifacts, ZRXTokenContract } from '../src'; | ||||
| import { ZRXTokenContract } from './wrappers'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| chaiSetup.configure(); | ||||
| const expect = chai.expect; | ||||
| @@ -42,25 +44,25 @@ describe('ZRXToken', () => { | ||||
|     }); | ||||
|     describe('constants', () => { | ||||
|         it('should have 18 decimals', async () => { | ||||
|             const decimals = new BigNumber(await zrxToken.decimals.callAsync()); | ||||
|             const decimals = new BigNumber(await zrxToken.decimals().callAsync()); | ||||
|             const expectedDecimals = 18; | ||||
|             expect(decimals).to.be.bignumber.equal(expectedDecimals); | ||||
|         }); | ||||
|  | ||||
|         it('should have a total supply of 1 billion tokens', async () => { | ||||
|             const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync()); | ||||
|             const totalSupply = new BigNumber(await zrxToken.totalSupply().callAsync()); | ||||
|             const expectedTotalSupply = 1000000000; | ||||
|             expect(Web3Wrapper.toUnitAmount(totalSupply, 18)).to.be.bignumber.equal(expectedTotalSupply); | ||||
|         }); | ||||
|  | ||||
|         it('should be named 0x Protocol Token', async () => { | ||||
|             const name = await zrxToken.name.callAsync(); | ||||
|             const name = await zrxToken.name().callAsync(); | ||||
|             const expectedName = '0x Protocol Token'; | ||||
|             expect(name).to.be.equal(expectedName); | ||||
|         }); | ||||
|  | ||||
|         it('should have the symbol ZRX', async () => { | ||||
|             const symbol = await zrxToken.symbol.callAsync(); | ||||
|             const symbol = await zrxToken.symbol().callAsync(); | ||||
|             const expectedSymbol = 'ZRX'; | ||||
|             expect(symbol).to.be.equal(expectedSymbol); | ||||
|         }); | ||||
| @@ -68,8 +70,8 @@ describe('ZRXToken', () => { | ||||
|  | ||||
|     describe('constructor', () => { | ||||
|         it('should initialize owner balance to totalSupply', async () => { | ||||
|             const ownerBalance = await zrxToken.balanceOf.callAsync(owner); | ||||
|             const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync()); | ||||
|             const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); | ||||
|             const totalSupply = new BigNumber(await zrxToken.totalSupply().callAsync()); | ||||
|             expect(totalSupply).to.be.bignumber.equal(ownerBalance); | ||||
|         }); | ||||
|     }); | ||||
| @@ -77,14 +79,14 @@ describe('ZRXToken', () => { | ||||
|     describe('transfer', () => { | ||||
|         it('should transfer balance from sender to receiver', async () => { | ||||
|             const receiver = spender; | ||||
|             const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); | ||||
|             const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = new BigNumber(1); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await zrxToken.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }), | ||||
|                 await zrxToken.transfer(receiver, amountToTransfer).sendTransactionAsync({ from: owner }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             const finalOwnerBalance = await zrxToken.balanceOf.callAsync(owner); | ||||
|             const finalReceiverBalance = await zrxToken.balanceOf.callAsync(receiver); | ||||
|             const finalOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); | ||||
|             const finalReceiverBalance = await zrxToken.balanceOf(receiver).callAsync(); | ||||
|  | ||||
|             const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer); | ||||
|             const expectedFinalReceiverBalance = amountToTransfer; | ||||
| @@ -93,7 +95,7 @@ describe('ZRXToken', () => { | ||||
|         }); | ||||
|  | ||||
|         it('should return true on a 0 value transfer', async () => { | ||||
|             const didReturnTrue = await zrxToken.transfer.callAsync(spender, new BigNumber(0), { | ||||
|             const didReturnTrue = await zrxToken.transfer(spender, new BigNumber(0)).callAsync({ | ||||
|                 from: owner, | ||||
|             }); | ||||
|             expect(didReturnTrue).to.be.true(); | ||||
| @@ -102,30 +104,30 @@ describe('ZRXToken', () => { | ||||
|  | ||||
|     describe('transferFrom', () => { | ||||
|         it('should return false if owner has insufficient balance', async () => { | ||||
|             const ownerBalance = await zrxToken.balanceOf.callAsync(owner); | ||||
|             const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = ownerBalance.plus(1); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer, { | ||||
|                 await zrxToken.approve(spender, amountToTransfer).sendTransactionAsync({ | ||||
|                     from: owner, | ||||
|                     gas: constants.MAX_TOKEN_APPROVE_GAS, | ||||
|                 }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { | ||||
|             const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ | ||||
|                 from: spender, | ||||
|             }); | ||||
|             expect(didReturnTrue).to.be.false(); | ||||
|         }); | ||||
|  | ||||
|         it('should return false if spender has insufficient allowance', async () => { | ||||
|             const ownerBalance = await zrxToken.balanceOf.callAsync(owner); | ||||
|             const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = ownerBalance; | ||||
|  | ||||
|             const spenderAllowance = await zrxToken.allowance.callAsync(owner, spender); | ||||
|             const spenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); | ||||
|             const isSpenderAllowanceInsufficient = spenderAllowance.comparedTo(amountToTransfer) < 0; | ||||
|             expect(isSpenderAllowanceInsufficient).to.be.true(); | ||||
|  | ||||
|             const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { | ||||
|             const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ | ||||
|                 from: spender, | ||||
|             }); | ||||
|             expect(didReturnTrue).to.be.false(); | ||||
| @@ -133,75 +135,75 @@ describe('ZRXToken', () => { | ||||
|  | ||||
|         it('should return true on a 0 value transfer', async () => { | ||||
|             const amountToTransfer = new BigNumber(0); | ||||
|             const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, { | ||||
|             const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ | ||||
|                 from: spender, | ||||
|             }); | ||||
|             expect(didReturnTrue).to.be.true(); | ||||
|         }); | ||||
|  | ||||
|         it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => { | ||||
|             const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); | ||||
|             const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = initOwnerBalance; | ||||
|             const initSpenderAllowance = MAX_UINT; | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance, { | ||||
|                 await zrxToken.approve(spender, initSpenderAllowance).sendTransactionAsync({ | ||||
|                     from: owner, | ||||
|                     gas: constants.MAX_TOKEN_APPROVE_GAS, | ||||
|                 }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { | ||||
|                 await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ | ||||
|                     from: spender, | ||||
|                     gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, | ||||
|                 }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|  | ||||
|             const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender); | ||||
|             const newSpenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); | ||||
|             expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); | ||||
|         }); | ||||
|  | ||||
|         it('should transfer the correct balances if spender has sufficient allowance', async () => { | ||||
|             const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); | ||||
|             const initSpenderBalance = await zrxToken.balanceOf.callAsync(spender); | ||||
|             const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); | ||||
|             const initSpenderBalance = await zrxToken.balanceOf(spender).callAsync(); | ||||
|             const amountToTransfer = initOwnerBalance; | ||||
|             const initSpenderAllowance = initOwnerBalance; | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance), | ||||
|                 await zrxToken.approve(spender, initSpenderAllowance).sendTransactionAsync(), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { | ||||
|                 await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ | ||||
|                     from: spender, | ||||
|                     gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, | ||||
|                 }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|  | ||||
|             const newOwnerBalance = await zrxToken.balanceOf.callAsync(owner); | ||||
|             const newSpenderBalance = await zrxToken.balanceOf.callAsync(spender); | ||||
|             const newOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); | ||||
|             const newSpenderBalance = await zrxToken.balanceOf(spender).callAsync(); | ||||
|  | ||||
|             expect(newOwnerBalance).to.be.bignumber.equal(0); | ||||
|             expect(newSpenderBalance).to.be.bignumber.equal(initSpenderBalance.plus(initOwnerBalance)); | ||||
|         }); | ||||
|  | ||||
|         it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => { | ||||
|             const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner); | ||||
|             const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); | ||||
|             const amountToTransfer = initOwnerBalance; | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer), | ||||
|                 await zrxToken.approve(spender, amountToTransfer).sendTransactionAsync(), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { | ||||
|                 await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ | ||||
|                     from: spender, | ||||
|                     gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, | ||||
|                 }), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|  | ||||
|             const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender); | ||||
|             const newSpenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); | ||||
|             expect(newSpenderAllowance).to.be.bignumber.equal(0); | ||||
|         }); | ||||
|     }); | ||||
|   | ||||
| @@ -7,16 +7,22 @@ | ||||
|         "generated-artifacts/DummyMultipleReturnERC20Token.json", | ||||
|         "generated-artifacts/DummyNoReturnERC20Token.json", | ||||
|         "generated-artifacts/ERC20Token.json", | ||||
|         "generated-artifacts/IERC20Token.json", | ||||
|         "generated-artifacts/IEtherToken.json", | ||||
|         "generated-artifacts/LibERC20Token.json", | ||||
|         "generated-artifacts/MintableERC20Token.json", | ||||
|         "generated-artifacts/TestLibERC20Token.json", | ||||
|         "generated-artifacts/TestLibERC20TokenTarget.json", | ||||
|         "generated-artifacts/UnlimitedAllowanceERC20Token.json", | ||||
|         "generated-artifacts/UntransferrableDummyERC20Token.json", | ||||
|         "generated-artifacts/WETH9.json", | ||||
|         "generated-artifacts/ZRXToken.json" | ||||
|         "generated-artifacts/ZRXToken.json", | ||||
|         "test/generated-artifacts/DummyERC20Token.json", | ||||
|         "test/generated-artifacts/DummyMultipleReturnERC20Token.json", | ||||
|         "test/generated-artifacts/DummyNoReturnERC20Token.json", | ||||
|         "test/generated-artifacts/ERC20Token.json", | ||||
|         "test/generated-artifacts/IERC20Token.json", | ||||
|         "test/generated-artifacts/IEtherToken.json", | ||||
|         "test/generated-artifacts/LibERC20Token.json", | ||||
|         "test/generated-artifacts/MintableERC20Token.json", | ||||
|         "test/generated-artifacts/TestLibERC20Token.json", | ||||
|         "test/generated-artifacts/TestLibERC20TokenTarget.json", | ||||
|         "test/generated-artifacts/UnlimitedAllowanceERC20Token.json", | ||||
|         "test/generated-artifacts/UntransferrableDummyERC20Token.json", | ||||
|         "test/generated-artifacts/WETH9.json", | ||||
|         "test/generated-artifacts/ZRXToken.json" | ||||
|     ], | ||||
|     "exclude": ["./deploy/solc/solc_bin"] | ||||
| } | ||||
|   | ||||
							
								
								
									
										10
									
								
								contracts/erc721/.npmignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								contracts/erc721/.npmignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # Blacklist all files | ||||
| .* | ||||
| * | ||||
| # Whitelist lib | ||||
| !lib/**/* | ||||
| # Whitelist Solidity contracts | ||||
| !contracts/src/**/* | ||||
| # Blacklist tests in lib | ||||
| /lib/test/* | ||||
| # Package specific ignore | ||||
| @@ -1,4 +1,14 @@ | ||||
| [ | ||||
|     { | ||||
|         "version": "2.2.0-beta.2", | ||||
|         "changes": [ | ||||
|             { | ||||
|                 "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", | ||||
|                 "pr": 2330 | ||||
|             } | ||||
|         ], | ||||
|         "timestamp": 1574030254 | ||||
|     }, | ||||
|     { | ||||
|         "version": "2.2.0-beta.1", | ||||
|         "changes": [ | ||||
|   | ||||
| @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. | ||||
|  | ||||
| CHANGELOG | ||||
|  | ||||
| ## v2.2.0-beta.2 - _November 17, 2019_ | ||||
|  | ||||
|     * Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330) | ||||
|  | ||||
| ## v2.2.0-beta.1 - _November 7, 2019_ | ||||
|  | ||||
|     * Dependencies updated | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|     "artifactsDir": "./generated-artifacts", | ||||
|     "artifactsDir": "./test/generated-artifacts", | ||||
|     "contractsDir": "./contracts", | ||||
|     "useDockerisedSolc": false, | ||||
|     "isOfflineMode": false, | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "name": "@0x/contracts-erc721", | ||||
|     "version": "2.2.0-beta.1", | ||||
|     "version": "2.2.0-beta.2", | ||||
|     "engines": { | ||||
|         "node": ">=6.12" | ||||
|     }, | ||||
| @@ -12,7 +12,7 @@ | ||||
|     "scripts": { | ||||
|         "build": "yarn pre_build && tsc -b", | ||||
|         "build:ci": "yarn build", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers", | ||||
|         "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", | ||||
|         "test": "yarn run_mocha", | ||||
|         "rebuild_and_test": "run-s build test", | ||||
|         "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", | ||||
| @@ -21,21 +21,23 @@ | ||||
|         "run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit", | ||||
|         "compile": "sol-compiler", | ||||
|         "watch": "sol-compiler -w", | ||||
|         "clean": "shx rm -rf lib generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", | ||||
|         "generate_contract_wrappers": "abi-gen --debug --abis  ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", | ||||
|         "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", | ||||
|         "coverage:report:text": "istanbul report text", | ||||
|         "coverage:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "profiler:report:html": "istanbul report html && open coverage/index.html", | ||||
|         "coverage:report:lcov": "istanbul report lcov", | ||||
|         "test:circleci": "yarn test", | ||||
|         "contracts:gen": "contracts-gen", | ||||
|         "contracts:gen": "contracts-gen generate", | ||||
|         "contracts:copy": "contracts-gen copy", | ||||
|         "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol", | ||||
|         "compile:truffle": "truffle compile" | ||||
|     }, | ||||
|     "config": { | ||||
|         "abis": "./generated-artifacts/@(DummyERC721Receiver|DummyERC721Token|ERC721Token|IERC721Receiver|IERC721Token|InvalidERC721Receiver|MintableERC721Token).json", | ||||
|         "publicInterfaceContracts": "DummyERC721Token,ERC721Token,IERC721Receiver,DummyERC721Receiver", | ||||
|         "abis": "./test/generated-artifacts/@(DummyERC721Receiver|DummyERC721Token|ERC721Token|IERC721Receiver|IERC721Token|InvalidERC721Receiver|MintableERC721Token).json", | ||||
|         "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." | ||||
|     }, | ||||
|     "repository": { | ||||
| @@ -48,12 +50,16 @@ | ||||
|     }, | ||||
|     "homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md", | ||||
|     "devDependencies": { | ||||
|         "@0x/abi-gen": "^4.4.0-beta.1", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.1", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.1", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.1", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.1", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.1", | ||||
|         "@0x/abi-gen": "^4.4.0-beta.2", | ||||
|         "@0x/contracts-gen": "^1.1.0-beta.2", | ||||
|         "@0x/contracts-test-utils": "^3.2.0-beta.2", | ||||
|         "@0x/contracts-utils": "^3.3.0-beta.2", | ||||
|         "@0x/dev-utils": "^2.4.0-beta.2", | ||||
|         "@0x/sol-compiler": "^3.2.0-beta.2", | ||||
|         "@0x/tslint-config": "^3.1.0-beta.2", | ||||
|         "@0x/types": "^2.5.0-beta.2", | ||||
|         "@0x/utils": "^4.6.0-beta.2", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.2", | ||||
|         "@types/lodash": "4.14.104", | ||||
|         "@types/mocha": "^5.2.7", | ||||
|         "@types/node": "*", | ||||
| @@ -61,6 +67,7 @@ | ||||
|         "chai-as-promised": "^7.1.0", | ||||
|         "chai-bignumber": "^3.0.0", | ||||
|         "dirty-chai": "^2.0.1", | ||||
|         "lodash": "^4.17.11", | ||||
|         "make-promises-safe": "^1.1.0", | ||||
|         "mocha": "^6.2.0", | ||||
|         "npm-run-all": "^4.1.2", | ||||
| @@ -71,14 +78,9 @@ | ||||
|         "typescript": "3.0.1" | ||||
|     }, | ||||
|     "dependencies": { | ||||
|         "@0x/base-contract": "^5.5.0-beta.1", | ||||
|         "@0x/contracts-utils": "^3.3.0-beta.1", | ||||
|         "@0x/types": "^2.5.0-beta.1", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.1", | ||||
|         "@0x/utils": "^4.6.0-beta.1", | ||||
|         "@0x/web3-wrapper": "^6.1.0-beta.1", | ||||
|         "ethereum-types": "^2.2.0-beta.1", | ||||
|         "lodash": "^4.17.11" | ||||
|         "@0x/base-contract": "^5.5.0-beta.2", | ||||
|         "@0x/typescript-typings": "^4.4.0-beta.2", | ||||
|         "ethereum-types": "^2.2.0-beta.2" | ||||
|     }, | ||||
|     "publishConfig": { | ||||
|         "access": "public" | ||||
|   | ||||
| @@ -9,15 +9,9 @@ import * as DummyERC721Receiver from '../generated-artifacts/DummyERC721Receiver | ||||
| import * as DummyERC721Token from '../generated-artifacts/DummyERC721Token.json'; | ||||
| import * as ERC721Token from '../generated-artifacts/ERC721Token.json'; | ||||
| import * as IERC721Receiver from '../generated-artifacts/IERC721Receiver.json'; | ||||
| import * as IERC721Token from '../generated-artifacts/IERC721Token.json'; | ||||
| import * as InvalidERC721Receiver from '../generated-artifacts/InvalidERC721Receiver.json'; | ||||
| import * as MintableERC721Token from '../generated-artifacts/MintableERC721Token.json'; | ||||
| export const artifacts = { | ||||
|     ERC721Token: ERC721Token as ContractArtifact, | ||||
|     MintableERC721Token: MintableERC721Token as ContractArtifact, | ||||
|     IERC721Receiver: IERC721Receiver as ContractArtifact, | ||||
|     IERC721Token: IERC721Token as ContractArtifact, | ||||
|     DummyERC721Receiver: DummyERC721Receiver as ContractArtifact, | ||||
|     DummyERC721Token: DummyERC721Token as ContractArtifact, | ||||
|     InvalidERC721Receiver: InvalidERC721Receiver as ContractArtifact, | ||||
|     ERC721Token: ERC721Token as ContractArtifact, | ||||
|     IERC721Receiver: IERC721Receiver as ContractArtifact, | ||||
|     DummyERC721Receiver: DummyERC721Receiver as ContractArtifact, | ||||
| }; | ||||
|   | ||||
| @@ -7,6 +7,3 @@ export * from '../generated-wrappers/dummy_erc721_receiver'; | ||||
| export * from '../generated-wrappers/dummy_erc721_token'; | ||||
| export * from '../generated-wrappers/erc721_token'; | ||||
| export * from '../generated-wrappers/i_erc721_receiver'; | ||||
| export * from '../generated-wrappers/i_erc721_token'; | ||||
| export * from '../generated-wrappers/invalid_erc721_receiver'; | ||||
| export * from '../generated-wrappers/mintable_erc721_token'; | ||||
|   | ||||
							
								
								
									
										23
									
								
								contracts/erc721/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								contracts/erc721/test/artifacts.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| import { ContractArtifact } from 'ethereum-types'; | ||||
|  | ||||
| import * as DummyERC721Receiver from '../test/generated-artifacts/DummyERC721Receiver.json'; | ||||
| import * as DummyERC721Token from '../test/generated-artifacts/DummyERC721Token.json'; | ||||
| import * as ERC721Token from '../test/generated-artifacts/ERC721Token.json'; | ||||
| import * as IERC721Receiver from '../test/generated-artifacts/IERC721Receiver.json'; | ||||
| import * as IERC721Token from '../test/generated-artifacts/IERC721Token.json'; | ||||
| import * as InvalidERC721Receiver from '../test/generated-artifacts/InvalidERC721Receiver.json'; | ||||
| import * as MintableERC721Token from '../test/generated-artifacts/MintableERC721Token.json'; | ||||
| export const artifacts = { | ||||
|     ERC721Token: ERC721Token as ContractArtifact, | ||||
|     MintableERC721Token: MintableERC721Token as ContractArtifact, | ||||
|     IERC721Receiver: IERC721Receiver as ContractArtifact, | ||||
|     IERC721Token: IERC721Token as ContractArtifact, | ||||
|     DummyERC721Receiver: DummyERC721Receiver as ContractArtifact, | ||||
|     DummyERC721Token: DummyERC721Token as ContractArtifact, | ||||
|     InvalidERC721Receiver: InvalidERC721Receiver as ContractArtifact, | ||||
| }; | ||||
| @@ -15,13 +15,14 @@ import * as chai from 'chai'; | ||||
| import { LogWithDecodedArgs } from 'ethereum-types'; | ||||
|  | ||||
| import { | ||||
|     artifacts, | ||||
|     DummyERC721ReceiverContract, | ||||
|     DummyERC721ReceiverTokenReceivedEventArgs, | ||||
|     DummyERC721TokenContract, | ||||
|     DummyERC721TokenTransferEventArgs, | ||||
|     InvalidERC721ReceiverContract, | ||||
| } from '../src'; | ||||
| } from './wrappers'; | ||||
|  | ||||
| import { artifacts } from './artifacts'; | ||||
|  | ||||
| chaiSetup.configure(); | ||||
| const expect = chai.expect; | ||||
| @@ -60,7 +61,7 @@ describe('ERC721Token', () => { | ||||
|         ); | ||||
|         logDecoder = new LogDecoder(web3Wrapper, artifacts); | ||||
|         await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|             await token.mint.sendTransactionAsync(owner, tokenId, { from: owner }), | ||||
|             await token.mint(owner, tokenId).sendTransactionAsync({ from: owner }), | ||||
|             constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|         ); | ||||
|     }); | ||||
| @@ -77,7 +78,7 @@ describe('ERC721Token', () => { | ||||
|             const to = erc721Receiver.address; | ||||
|             const unownedTokenId = new BigNumber(2); | ||||
|             await expectTransactionFailedAsync( | ||||
|                 token.transferFrom.sendTransactionAsync(from, to, unownedTokenId), | ||||
|                 token.transferFrom(from, to, unownedTokenId).sendTransactionAsync(), | ||||
|                 RevertReason.Erc721ZeroOwner, | ||||
|             ); | ||||
|         }); | ||||
| @@ -85,7 +86,7 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = constants.NULL_ADDRESS; | ||||
|             await expectTransactionFailedAsync( | ||||
|                 token.transferFrom.sendTransactionAsync(from, to, tokenId), | ||||
|                 token.transferFrom(from, to, tokenId).sendTransactionAsync(), | ||||
|                 RevertReason.Erc721ZeroToAddress, | ||||
|             ); | ||||
|         }); | ||||
| @@ -93,7 +94,7 @@ describe('ERC721Token', () => { | ||||
|             const from = spender; | ||||
|             const to = erc721Receiver.address; | ||||
|             await expectTransactionFailedAsync( | ||||
|                 token.transferFrom.sendTransactionAsync(from, to, tokenId), | ||||
|                 token.transferFrom(from, to, tokenId).sendTransactionAsync(), | ||||
|                 RevertReason.Erc721OwnerMismatch, | ||||
|             ); | ||||
|         }); | ||||
| @@ -101,7 +102,7 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = erc721Receiver.address; | ||||
|             await expectTransactionFailedAsync( | ||||
|                 token.transferFrom.sendTransactionAsync(from, to, tokenId, { from: spender }), | ||||
|                 token.transferFrom(from, to, tokenId).sendTransactionAsync({ from: spender }), | ||||
|                 RevertReason.Erc721InvalidSpender, | ||||
|             ); | ||||
|         }); | ||||
| @@ -109,9 +110,9 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = erc721Receiver.address; | ||||
|             const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( | ||||
|                 await token.transferFrom.sendTransactionAsync(from, to, tokenId), | ||||
|                 await token.transferFrom(from, to, tokenId).sendTransactionAsync(), | ||||
|             ); | ||||
|             const newOwner = await token.ownerOf.callAsync(tokenId); | ||||
|             const newOwner = await token.ownerOf(tokenId).callAsync(); | ||||
|             expect(newOwner).to.be.equal(to); | ||||
|             const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>; | ||||
|             expect(log.args._from).to.be.equal(from); | ||||
| @@ -121,16 +122,16 @@ describe('ERC721Token', () => { | ||||
|         it('should transfer the token if spender is approved for all', async () => { | ||||
|             const isApproved = true; | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.setApprovalForAll.sendTransactionAsync(spender, isApproved), | ||||
|                 await token.setApprovalForAll(spender, isApproved).sendTransactionAsync(), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|  | ||||
|             const from = owner; | ||||
|             const to = erc721Receiver.address; | ||||
|             const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( | ||||
|                 await token.transferFrom.sendTransactionAsync(from, to, tokenId), | ||||
|                 await token.transferFrom(from, to, tokenId).sendTransactionAsync(), | ||||
|             ); | ||||
|             const newOwner = await token.ownerOf.callAsync(tokenId); | ||||
|             const newOwner = await token.ownerOf(tokenId).callAsync(); | ||||
|             expect(newOwner).to.be.equal(to); | ||||
|             const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>; | ||||
|             expect(log.args._from).to.be.equal(from); | ||||
| @@ -139,19 +140,19 @@ describe('ERC721Token', () => { | ||||
|         }); | ||||
|         it('should transfer the token if spender is individually approved', async () => { | ||||
|             await web3Wrapper.awaitTransactionSuccessAsync( | ||||
|                 await token.approve.sendTransactionAsync(spender, tokenId), | ||||
|                 await token.approve(spender, tokenId).sendTransactionAsync(), | ||||
|                 constants.AWAIT_TRANSACTION_MINED_MS, | ||||
|             ); | ||||
|  | ||||
|             const from = owner; | ||||
|             const to = erc721Receiver.address; | ||||
|             const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( | ||||
|                 await token.transferFrom.sendTransactionAsync(from, to, tokenId), | ||||
|                 await token.transferFrom(from, to, tokenId).sendTransactionAsync(), | ||||
|             ); | ||||
|             const newOwner = await token.ownerOf.callAsync(tokenId); | ||||
|             const newOwner = await token.ownerOf(tokenId).callAsync(); | ||||
|             expect(newOwner).to.be.equal(to); | ||||
|  | ||||
|             const approvedAddress = await token.getApproved.callAsync(tokenId); | ||||
|             const approvedAddress = await token.getApproved(tokenId).callAsync(); | ||||
|             expect(approvedAddress).to.be.equal(constants.NULL_ADDRESS); | ||||
|             const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>; | ||||
|             expect(log.args._from).to.be.equal(from); | ||||
| @@ -164,9 +165,9 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = spender; | ||||
|             const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( | ||||
|                 await token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), | ||||
|                 await token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), | ||||
|             ); | ||||
|             const newOwner = await token.ownerOf.callAsync(tokenId); | ||||
|             const newOwner = await token.ownerOf(tokenId).callAsync(); | ||||
|             expect(newOwner).to.be.equal(to); | ||||
|             const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>; | ||||
|             expect(log.args._from).to.be.equal(from); | ||||
| @@ -185,7 +186,7 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = contract.address; | ||||
|             await expectTransactionFailedWithoutReasonAsync( | ||||
|                 token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), | ||||
|                 token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), | ||||
|             ); | ||||
|         }); | ||||
|         it('should revert if onERC721Received does not return the correct value', async () => { | ||||
| @@ -198,7 +199,7 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = invalidErc721Receiver.address; | ||||
|             await expectTransactionFailedAsync( | ||||
|                 token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), | ||||
|                 token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), | ||||
|                 RevertReason.Erc721InvalidSelector, | ||||
|             ); | ||||
|         }); | ||||
| @@ -206,9 +207,9 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = erc721Receiver.address; | ||||
|             const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( | ||||
|                 await token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId), | ||||
|                 await token.safeTransferFrom1(from, to, tokenId).sendTransactionAsync(), | ||||
|             ); | ||||
|             const newOwner = await token.ownerOf.callAsync(tokenId); | ||||
|             const newOwner = await token.ownerOf(tokenId).callAsync(); | ||||
|             expect(newOwner).to.be.equal(to); | ||||
|             const transferLog = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>; | ||||
|             const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs<DummyERC721ReceiverTokenReceivedEventArgs>; | ||||
| @@ -227,9 +228,9 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = spender; | ||||
|             const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( | ||||
|                 await token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), | ||||
|                 await token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), | ||||
|             ); | ||||
|             const newOwner = await token.ownerOf.callAsync(tokenId); | ||||
|             const newOwner = await token.ownerOf(tokenId).callAsync(); | ||||
|             expect(newOwner).to.be.equal(to); | ||||
|             const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>; | ||||
|             expect(log.args._from).to.be.equal(from); | ||||
| @@ -248,7 +249,7 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = contract.address; | ||||
|             await expectTransactionFailedWithoutReasonAsync( | ||||
|                 token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), | ||||
|                 token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), | ||||
|             ); | ||||
|         }); | ||||
|         it('should revert if onERC721Received does not return the correct value', async () => { | ||||
| @@ -261,7 +262,7 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = invalidErc721Receiver.address; | ||||
|             await expectTransactionFailedAsync( | ||||
|                 token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), | ||||
|                 token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), | ||||
|                 RevertReason.Erc721InvalidSelector, | ||||
|             ); | ||||
|         }); | ||||
| @@ -269,9 +270,9 @@ describe('ERC721Token', () => { | ||||
|             const from = owner; | ||||
|             const to = erc721Receiver.address; | ||||
|             const txReceipt = await logDecoder.getTxWithDecodedLogsAsync( | ||||
|                 await token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data), | ||||
|                 await token.safeTransferFrom2(from, to, tokenId, data).sendTransactionAsync(), | ||||
|             ); | ||||
|             const newOwner = await token.ownerOf.callAsync(tokenId); | ||||
|             const newOwner = await token.ownerOf(tokenId).callAsync(); | ||||
|             expect(newOwner).to.be.equal(to); | ||||
|             const transferLog = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>; | ||||
|             const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs<DummyERC721ReceiverTokenReceivedEventArgs>; | ||||
|   | ||||
							
								
								
									
										12
									
								
								contracts/erc721/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								contracts/erc721/test/wrappers.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| /* | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  * Warning: This file is auto-generated by contracts-gen. Don't edit manually. | ||||
|  * ----------------------------------------------------------------------------- | ||||
|  */ | ||||
| export * from '../test/generated-wrappers/dummy_erc721_receiver'; | ||||
| export * from '../test/generated-wrappers/dummy_erc721_token'; | ||||
| export * from '../test/generated-wrappers/erc721_token'; | ||||
| export * from '../test/generated-wrappers/i_erc721_receiver'; | ||||
| export * from '../test/generated-wrappers/i_erc721_token'; | ||||
| export * from '../test/generated-wrappers/invalid_erc721_receiver'; | ||||
| export * from '../test/generated-wrappers/mintable_erc721_token'; | ||||
| @@ -7,9 +7,13 @@ | ||||
|         "generated-artifacts/DummyERC721Token.json", | ||||
|         "generated-artifacts/ERC721Token.json", | ||||
|         "generated-artifacts/IERC721Receiver.json", | ||||
|         "generated-artifacts/IERC721Token.json", | ||||
|         "generated-artifacts/InvalidERC721Receiver.json", | ||||
|         "generated-artifacts/MintableERC721Token.json" | ||||
|         "test/generated-artifacts/DummyERC721Receiver.json", | ||||
|         "test/generated-artifacts/DummyERC721Token.json", | ||||
|         "test/generated-artifacts/ERC721Token.json", | ||||
|         "test/generated-artifacts/IERC721Receiver.json", | ||||
|         "test/generated-artifacts/IERC721Token.json", | ||||
|         "test/generated-artifacts/InvalidERC721Receiver.json", | ||||
|         "test/generated-artifacts/MintableERC721Token.json" | ||||
|     ], | ||||
|     "exclude": ["./deploy/solc/solc_bin"] | ||||
| } | ||||
|   | ||||
							
								
								
									
										10
									
								
								contracts/exchange-forwarder/.npmignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								contracts/exchange-forwarder/.npmignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # Blacklist all files | ||||
| .* | ||||
| * | ||||
| # Whitelist lib | ||||
| !lib/**/* | ||||
| # Whitelist Solidity contracts | ||||
| !contracts/src/**/* | ||||
| # Blacklist tests in lib | ||||
| /lib/test/* | ||||
| # Package specific ignore | ||||
| @@ -1,4 +1,18 @@ | ||||
| [ | ||||
|     { | ||||
|         "version": "3.1.0-beta.2", | ||||
|         "changes": [ | ||||
|             { | ||||
|                 "note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils", | ||||
|                 "pr": 2330 | ||||
|             }, | ||||
|             { | ||||
|                 "note": "Introduced new export ForwarderRevertErrors", | ||||
|                 "pr": 2321 | ||||
|             } | ||||
|         ], | ||||
|         "timestamp": 1574030254 | ||||
|     }, | ||||
|     { | ||||
|         "version": "3.1.0-beta.1", | ||||
|         "changes": [ | ||||
|   | ||||
| @@ -5,6 +5,11 @@ Edit the package's CHANGELOG.json file only. | ||||
|  | ||||
| CHANGELOG | ||||
|  | ||||
| ## v3.1.0-beta.2 - _November 17, 2019_ | ||||
|  | ||||
|     * Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330) | ||||
|     * Introduced new export ForwarderRevertErrors (#2321) | ||||
|  | ||||
| ## v3.1.0-beta.1 - _November 7, 2019_ | ||||
|  | ||||
|     * Use `LibERC20Token` in `MixinAssets` (#2309) | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user