Style updates to contracts
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user