aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-12-13 08:44:28 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-12-21 01:13:36 +0800
commit0a5ecec3e222ae0c5e70e0d3092e57df5dfb75cd (patch)
treecc4c7d17a46d62a0e8e5a31e27f37ff11be412d7
parentb6f4c5c7da7d0afe65c0e3dba97aa64e11934595 (diff)
downloaddexon-sol-tools-0a5ecec3e222ae0c5e70e0d3092e57df5dfb75cd.tar
dexon-sol-tools-0a5ecec3e222ae0c5e70e0d3092e57df5dfb75cd.tar.gz
dexon-sol-tools-0a5ecec3e222ae0c5e70e0d3092e57df5dfb75cd.tar.bz2
dexon-sol-tools-0a5ecec3e222ae0c5e70e0d3092e57df5dfb75cd.tar.lz
dexon-sol-tools-0a5ecec3e222ae0c5e70e0d3092e57df5dfb75cd.tar.xz
dexon-sol-tools-0a5ecec3e222ae0c5e70e0d3092e57df5dfb75cd.tar.zst
dexon-sol-tools-0a5ecec3e222ae0c5e70e0d3092e57df5dfb75cd.zip
update comments
-rw-r--r--contracts/core/test/extensions/order_matcher.ts12
-rw-r--r--contracts/extensions/contracts/OrderMatcher/MixinAssets.sol7
-rw-r--r--contracts/extensions/contracts/OrderMatcher/MixinMatchOrders.sol5
-rw-r--r--contracts/extensions/contracts/OrderMatcher/interfaces/IMatchOrders.sol2
-rw-r--r--contracts/extensions/contracts/OrderMatcher/interfaces/IOrderMatcher.sol2
-rw-r--r--contracts/extensions/contracts/OrderMatcher/libs/LibConstants.sol2
6 files changed, 17 insertions, 13 deletions
diff --git a/contracts/core/test/extensions/order_matcher.ts b/contracts/core/test/extensions/order_matcher.ts
index e61d0f8e0..4ea95bc49 100644
--- a/contracts/core/test/extensions/order_matcher.ts
+++ b/contracts/core/test/extensions/order_matcher.ts
@@ -11,6 +11,7 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import { artifacts as tokenArtifacts, DummyERC20TokenContract, DummyERC721TokenContract } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason } from '@0x/types';
@@ -20,8 +21,6 @@ import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import { ExchangeContract, ExchangeFillEventArgs } from '../../generated-wrappers/exchange';
@@ -444,7 +443,7 @@ describe('OrderMatcher', () => {
signedOrderLeft.signature,
signedOrderRight.signature,
);
- const logDecoder = new LogDecoder(web3Wrapper, artifacts);
+ const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokenArtifacts });
const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
await web3Wrapper.sendTransactionAsync({
data,
@@ -457,6 +456,7 @@ describe('OrderMatcher', () => {
txReceipt.logs,
log => (log as LogWithDecodedArgs<ExchangeFillEventArgs>).event === 'Fill',
);
+ // Only 2 Fill logs should exist for `matchOrders` call. `fillOrder` should not have been called and should not have emitted a Fill event.
expect(fillLogs.length).to.be.equal(2);
});
it('should only take a spread in rightMakerAsset if entire leftMakerAssetSpread amount can be used to fill rightOrder after matchOrders call', async () => {
@@ -680,7 +680,7 @@ describe('OrderMatcher', () => {
});
it('should allow owner to withdraw ERC721 tokens', async () => {
const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Token,
+ tokenArtifacts.DummyERC721Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@@ -725,7 +725,7 @@ describe('OrderMatcher', () => {
});
it('should be able to approve an ERC721 token by passing in allowance = 1', async () => {
const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Token,
+ tokenArtifacts.DummyERC721Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@@ -742,7 +742,7 @@ describe('OrderMatcher', () => {
});
it('should be able to approve an ERC721 token by passing in allowance > 1', async () => {
const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Token,
+ tokenArtifacts.DummyERC721Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
diff --git a/contracts/extensions/contracts/OrderMatcher/MixinAssets.sol b/contracts/extensions/contracts/OrderMatcher/MixinAssets.sol
index 43e19c19e..323998705 100644
--- a/contracts/extensions/contracts/OrderMatcher/MixinAssets.sol
+++ b/contracts/extensions/contracts/OrderMatcher/MixinAssets.sol
@@ -20,8 +20,8 @@ pragma solidity 0.4.24;
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
-import "../../tokens/ERC20Token/IERC20Token.sol";
-import "../../tokens/ERC721Token/IERC721Token.sol";
+import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol";
+import "@0x/contracts-tokens/contracts/tokens/ERC721Token/IERC721Token.sol";
import "./mixins/MAssets.sol";
import "./libs/LibConstants.sol";
@@ -98,6 +98,7 @@ contract MixinAssets is
)
internal
{
+ // 4 byte id + 12 0 bytes before ABI encoded token address.
address token = assetData.readAddress(16);
// Transfer tokens.
@@ -149,7 +150,9 @@ contract MixinAssets is
"INVALID_AMOUNT"
);
// Decode asset data.
+ // 4 byte id + 12 0 bytes before ABI encoded token address.
address token = assetData.readAddress(16);
+ // 4 byte id + 32 byte ABI encoded token address before token id.
uint256 tokenId = assetData.readUint256(36);
// Perform transfer.
diff --git a/contracts/extensions/contracts/OrderMatcher/MixinMatchOrders.sol b/contracts/extensions/contracts/OrderMatcher/MixinMatchOrders.sol
index ffe037ee7..866523190 100644
--- a/contracts/extensions/contracts/OrderMatcher/MixinMatchOrders.sol
+++ b/contracts/extensions/contracts/OrderMatcher/MixinMatchOrders.sol
@@ -230,7 +230,7 @@ contract MixinMatchOrders is
// | 932 | a | rightMakerAssetData Contents |
// | 932 + a | 32 | rightTakerAssetData Length |
// | 964 | b | rightTakerAssetData Contents |
- // | 964 + b | 32 | rightSigature Length (always 0) |
+ // | 964 + b | 32 | rightSignature Length (always 0) |
// We assume that `leftOrder.makerAssetData == rightOrder.takerAssetData` and `leftOrder.takerAssetData == rightOrder.makerAssetData`
// `EXCHANGE.matchOrders` already makes this assumption, so it is likely
@@ -280,6 +280,7 @@ contract MixinMatchOrders is
)
mstore(rightSignatureStart, 0)
+ // function selector (4 bytes) + 3 params (3 * 32 bytes) must be stored before `rightOrderStart`
let cdStart := sub(rightOrderStart, 100)
// `fillOrder` selector = 0xb4be83d5
@@ -288,7 +289,7 @@ contract MixinMatchOrders is
// Write offset to `rightOrder`
mstore(add(cdStart, 4), 96)
- // Write `takerAssetFillAmount`
+ // Write `takerAssetFillAmount`, which will be the `leftMakerAssetSpreadAmount` received from the `matchOrders` call
mstore(add(cdStart, 36), mload(256))
// Write offset to `rightSignature`
diff --git a/contracts/extensions/contracts/OrderMatcher/interfaces/IMatchOrders.sol b/contracts/extensions/contracts/OrderMatcher/interfaces/IMatchOrders.sol
index 455259238..19bcbb326 100644
--- a/contracts/extensions/contracts/OrderMatcher/interfaces/IMatchOrders.sol
+++ b/contracts/extensions/contracts/OrderMatcher/interfaces/IMatchOrders.sol
@@ -19,7 +19,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
-import "../../../protocol/Exchange/libs/LibOrder.sol";
+import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
contract IMatchOrders {
diff --git a/contracts/extensions/contracts/OrderMatcher/interfaces/IOrderMatcher.sol b/contracts/extensions/contracts/OrderMatcher/interfaces/IOrderMatcher.sol
index ed4aee925..9b6ea26d8 100644
--- a/contracts/extensions/contracts/OrderMatcher/interfaces/IOrderMatcher.sol
+++ b/contracts/extensions/contracts/OrderMatcher/interfaces/IOrderMatcher.sol
@@ -18,7 +18,7 @@
pragma solidity 0.4.24;
-import "../../../utils/Ownable/IOwnable.sol";
+import "@0x/contract-utils/contracts/utils/Ownable/IOwnable.sol";
import "./IMatchOrders.sol";
import "./IAssets.sol";
diff --git a/contracts/extensions/contracts/OrderMatcher/libs/LibConstants.sol b/contracts/extensions/contracts/OrderMatcher/libs/LibConstants.sol
index a7c170b42..43bbdeec2 100644
--- a/contracts/extensions/contracts/OrderMatcher/libs/LibConstants.sol
+++ b/contracts/extensions/contracts/OrderMatcher/libs/LibConstants.sol
@@ -18,7 +18,7 @@
pragma solidity 0.4.24;
-import "../../../protocol/Exchange/interfaces/IExchange.sol";
+import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol";
contract LibConstants {