aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-06-08 02:11:40 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-06-08 06:39:40 +0800
commitf457a56d4a0a4e5a5b5b11289f65df64cf2c7f1f (patch)
treecb7b5a072cf546e132ed8e1ad4a7726474b339a0 /packages
parentdb086de84ae7a238b91b5ce79fcc1a8e4c830ac5 (diff)
downloaddexon-0x-contracts-f457a56d4a0a4e5a5b5b11289f65df64cf2c7f1f.tar.gz
dexon-0x-contracts-f457a56d4a0a4e5a5b5b11289f65df64cf2c7f1f.tar.zst
dexon-0x-contracts-f457a56d4a0a4e5a5b5b11289f65df64cf2c7f1f.zip
Style updates to contracts
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol2
-rw-r--r--packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol28
-rw-r--r--packages/contracts/src/utils/artifacts.ts2
-rw-r--r--packages/contracts/test/asset_proxy/decoder.ts6
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts5
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts3
-rw-r--r--packages/order-utils/src/asset_proxy_utils.ts5
7 files changed, 23 insertions, 28 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol
index 499d8d96e..25136133d 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol
+++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol
@@ -116,7 +116,7 @@ contract ERC721Proxy is
if (length > 53) {
receiverData = readBytes(assetData, 52);
}
- proxyId = uint8(assetData[length-1]);
+ proxyId = uint8(assetData[length - 1]);
return (
proxyId,
diff --git a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol
index 8f6647d20..282455ea0 100644
--- a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol
+++ b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol
@@ -25,11 +25,11 @@ contract LibBytes is
{
// Revert reasons
- string constant GT_ZERO_LENGTH_REQUIRED = "Length must be greater than 0.";
- string constant GTE_4_LENGTH_REQUIRED = "Length must be greater than or equal to 4.";
- string constant GTE_20_LENGTH_REQUIRED = "Length must be greater than or equal to 20.";
- string constant GTE_32_LENGTH_REQUIRED = "Length must be greater than or equal to 32.";
- string constant INDEX_OUT_OF_BOUNDS = "Specified array index is out of bounds.";
+ string constant GREATER_THAN_ZERO_LENGTH_REQUIRED = "GREATER_THAN_ZERO_LENGTH_REQUIRED";
+ string constant GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED = "GREATER_THAN_4_LENGTH_REQUIRED";
+ string constant GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED = "GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED";
+ string constant GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED = "GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED";
+ string constant GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED = "GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED";
/// @dev Pops the last byte off of a byte array by modifying its length.
/// @param b Byte array that will be modified.
@@ -41,7 +41,7 @@ contract LibBytes is
{
require(
b.length > 0,
- GT_ZERO_LENGTH_REQUIRED
+ GREATER_THAN_ZERO_LENGTH_REQUIRED
);
// Store last byte.
@@ -65,7 +65,7 @@ contract LibBytes is
{
require(
b.length >= 20,
- GTE_20_LENGTH_REQUIRED
+ GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED
);
// Store last 20 bytes.
@@ -128,7 +128,7 @@ contract LibBytes is
{
require(
b.length >= index + 20, // 20 is length of address
- GTE_20_LENGTH_REQUIRED
+ GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED
);
// Add offset to index:
@@ -160,7 +160,7 @@ contract LibBytes is
{
require(
b.length >= index + 20, // 20 is length of address
- GTE_20_LENGTH_REQUIRED
+ GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED
);
// Add offset to index:
@@ -199,7 +199,7 @@ contract LibBytes is
{
require(
b.length >= index + 32,
- GTE_32_LENGTH_REQUIRED
+ GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED
);
// Arrays are prefixed by a 256 bit length parameter
@@ -226,7 +226,7 @@ contract LibBytes is
{
require(
b.length >= index + 32,
- GTE_32_LENGTH_REQUIRED
+ GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED
);
// Arrays are prefixed by a 256 bit length parameter
@@ -278,7 +278,7 @@ contract LibBytes is
{
require(
b.length >= 4,
- GTE_4_LENGTH_REQUIRED
+ GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED
);
assembly {
result := mload(add(b, 32))
@@ -306,7 +306,7 @@ contract LibBytes is
// length of nested bytes
require(
b.length >= index + nestedBytesLength,
- GTE_32_LENGTH_REQUIRED
+ GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED
);
// Allocate memory and copy value to result
@@ -336,7 +336,7 @@ contract LibBytes is
// length of input
require(
b.length >= index + 32 /* 32 bytes to store length */ + input.length,
- GTE_32_LENGTH_REQUIRED
+ GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED
);
// Copy <input> into <b>
diff --git a/packages/contracts/src/utils/artifacts.ts b/packages/contracts/src/utils/artifacts.ts
index 42de7c921..bf7221d6d 100644
--- a/packages/contracts/src/utils/artifacts.ts
+++ b/packages/contracts/src/utils/artifacts.ts
@@ -10,8 +10,8 @@ import * as Exchange from '../artifacts/Exchange.json';
import * as MixinAuthorizable from '../artifacts/MixinAuthorizable.json';
import * as MultiSigWallet from '../artifacts/MultiSigWallet.json';
import * as MultiSigWalletWithTimeLock from '../artifacts/MultiSigWalletWithTimeLock.json';
-import * as TestAssetProxyDispatcher from '../artifacts/TestAssetProxyDispatcher.json';
import * as TestAssetDataDecoders from '../artifacts/TestAssetDataDecoders.json';
+import * as TestAssetProxyDispatcher from '../artifacts/TestAssetProxyDispatcher.json';
import * as TestLibBytes from '../artifacts/TestLibBytes.json';
import * as TestLibMem from '../artifacts/TestLibMem.json';
import * as TestLibs from '../artifacts/TestLibs.json';
diff --git a/packages/contracts/test/asset_proxy/decoder.ts b/packages/contracts/test/asset_proxy/decoder.ts
index 2577dbba5..16486f4fd 100644
--- a/packages/contracts/test/asset_proxy/decoder.ts
+++ b/packages/contracts/test/asset_proxy/decoder.ts
@@ -1,11 +1,9 @@
-import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
import { AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import BN = require('bn.js');
import * as chai from 'chai';
-import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as Web3 from 'web3';
@@ -19,7 +17,7 @@ chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-describe.only('TestAssetDataDecoders', () => {
+describe('TestAssetDataDecoders', () => {
let owner: string;
let testAssetProxyDecoder: TestAssetDataDecodersContract;
let testAddress: string;
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index a7dc54efc..7687d4648 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -1,6 +1,5 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { generatePseudoRandomSalt } from '@0xproject/order-utils';
-import { assetProxyUtils } from '@0xproject/order-utils';
+import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
import { AssetProxyId } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -30,8 +29,6 @@ const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('Asset Transfer Proxies', () => {
- const nullDataHex = '0x';
-
let owner: string;
let notAuthorized: string;
let exchangeAddress: string;
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index 9ae95d518..5830c5753 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -1,6 +1,5 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetProxyUtils } from '@0xproject/order-utils';
-import { generatePseudoRandomSalt } from '@0xproject/order-utils';
+import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
import { AssetProxyId } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import BN = require('bn.js');
diff --git a/packages/order-utils/src/asset_proxy_utils.ts b/packages/order-utils/src/asset_proxy_utils.ts
index 1d34172c7..ed8832b18 100644
--- a/packages/order-utils/src/asset_proxy_utils.ts
+++ b/packages/order-utils/src/asset_proxy_utils.ts
@@ -4,6 +4,8 @@ import BN = require('bn.js');
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
+import { constants } from '../../src/utils/constants';
+
const ERC20_ASSET_DATA_BYTE_LENGTH = 21;
const ERC721_ASSET_DATA_BYTE_LENGTH = 53;
@@ -117,8 +119,7 @@ export const assetProxyUtils = {
const tokenAddress = assetProxyUtils.decodeAddress(encodedTokenAddress);
const encodedTokenId = encodedAssetData.slice(tokenIdOffset, receiverDataLengthOffset);
const tokenId = assetProxyUtils.decodeUint256(encodedTokenId);
- const nullData = '0x';
- let receiverData = nullData;
+ let receiverData = constants.NULL_BYTE;
const lengthUpToReceiverDataLength = receiverDataLengthOffset + 1;
if (encodedAssetData.byteLength > lengthUpToReceiverDataLength) {
const encodedReceiverDataLength = encodedAssetData.slice(receiverDataLengthOffset, receiverDataOffset);