@0x/order-utils refactors for v3: orderParsingUtils, signatureUtils, orderHashUtils, RevertErrors, transactionHashUtils (#2321)
* move orderParsingUtils from order-utils to connect * Remove many functions from signatureUtils Removed from the exported object, that is. All of them are used in other existing code, so they were all moved to be as local to their usage as possible. * remove orderHashUtils.isValidOrderHash() * Move all *RevertErrors from order-utils... ...into their respective @0x/contracts- packages. * Refactor @0x/order-utils' orderHashUtils away - Move existing routines into @0x/contracts-test-utils - Migrate non-contract-test callers to a newly-exposed getOrderHash() method in DevUtils. * Move all *RevertErrors from @0x/utils... ...into their respective @0x/contracts- packages. * rm transactionHashUtils.isValidTransactionHash() * DevUtils.sol: Fail yarn test if too big to deploy * Refactor @0x/order-utils transactionHashUtils away - Move existing routines into @0x/contracts-test-utils - Migrate non-contract-test callers to a newly-exposed getTransactionHash() method in DevUtils. * Consolidate `Removed export...` CHANGELOG entries * Rm EthBalanceChecker from devutils wrapper exports * Stop importing from '.' or '.../src' * fix builds * fix prettier; dangling promise * increase max bundle size
This commit is contained in:
parent
f0d7d10fe7
commit
f11d8a5bd8
@ -15,9 +15,10 @@ 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';
|
||||
|
@ -9,8 +9,9 @@ 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';
|
||||
|
||||
|
@ -5,6 +5,14 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -81,6 +81,7 @@
|
||||
},
|
||||
"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",
|
||||
|
@ -13,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,
|
||||
|
@ -4,13 +4,25 @@ 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);
|
||||
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;
|
||||
},
|
||||
getApprovalHashHex(transaction: SignedZeroExTransaction, verifyingContract: string, txOrigin: string): string {
|
||||
const hashHex = hexConcat(hashUtils.getApprovalHashBuffer(transaction, verifyingContract, txOrigin));
|
||||
async getApprovalHashHexAsync(
|
||||
transaction: SignedZeroExTransaction,
|
||||
verifyingContract: string,
|
||||
txOrigin: string,
|
||||
): Promise<string> {
|
||||
const hashHex = hexConcat(await hashUtils.getApprovalHashBufferAsync(transaction, verifyingContract, txOrigin));
|
||||
return hashHex;
|
||||
},
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
export * from './artifacts';
|
||||
export * from './wrappers';
|
||||
export import CoordinatorRevertErrors = require('./revert_errors');
|
||||
export { ApprovalFactory } from './approval_factory';
|
||||
export { SignedCoordinatorApproval } from './types';
|
||||
|
@ -1,5 +1,4 @@
|
||||
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 { hashUtils } from '../src/hash_utils';
|
||||
@ -45,7 +44,11 @@ blockchainTests.resets('Libs tests', env => {
|
||||
transactionHash: transactionHashUtils.getTransactionHashHex(signedTx),
|
||||
transactionSignature: signedTx.signature,
|
||||
};
|
||||
const expectedApprovalHash = hashUtils.getApprovalHashHex(signedTx, coordinatorContract.address, txOrigin);
|
||||
const expectedApprovalHash = await hashUtils.getApprovalHashHexAsync(
|
||||
signedTx,
|
||||
coordinatorContract.address,
|
||||
txOrigin,
|
||||
);
|
||||
const approvalHash = await coordinatorContract.getCoordinatorApprovalHash(approval).callAsync();
|
||||
expect(expectedApprovalHash).to.eq(approvalHash);
|
||||
});
|
||||
|
@ -8,10 +8,13 @@ import {
|
||||
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 CoordinatorRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { ApprovalFactory } from '../src/approval_factory';
|
||||
|
||||
@ -237,7 +240,7 @@ 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);
|
||||
await mixins
|
||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
||||
approval.signature,
|
||||
@ -252,7 +255,7 @@ 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);
|
||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
||||
await mixins
|
||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
||||
approval.signature,
|
||||
@ -273,7 +276,7 @@ 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);
|
||||
await mixins
|
||||
.assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [
|
||||
approval.signature,
|
||||
@ -294,7 +297,7 @@ 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 signature = hexConcat(
|
||||
hexSlice(approval.signature, 0, 2),
|
||||
'0xFFFFFFFF',
|
||||
@ -315,7 +318,7 @@ 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(transaction, transactionSignerAddress, transaction.signature, [
|
||||
@ -336,7 +339,7 @@ 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);
|
||||
await mixins
|
||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
||||
approval.signature,
|
||||
@ -350,7 +353,7 @@ blockchainTests.resets('Mixins tests', env => {
|
||||
}));
|
||||
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);
|
||||
await mixins
|
||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
||||
approval.signature,
|
||||
@ -372,7 +375,7 @@ blockchainTests.resets('Mixins tests', env => {
|
||||
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);
|
||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
||||
await mixins
|
||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
||||
approval.signature,
|
||||
@ -383,8 +386,8 @@ 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);
|
||||
await mixins
|
||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
||||
approval1.signature,
|
||||
@ -404,7 +407,7 @@ 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 tx = mixins
|
||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
||||
@ -430,7 +433,7 @@ 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',
|
||||
@ -451,8 +454,8 @@ 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',
|
||||
@ -474,7 +477,7 @@ 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',
|
||||
@ -495,7 +498,7 @@ 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(transaction, transactionSignerAddress, transaction.signature, [
|
||||
|
@ -5,6 +5,14 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@
|
||||
"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 contracts:copy",
|
||||
"compile": "sol-compiler",
|
||||
|
@ -6,9 +6,10 @@ 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';
|
||||
|
@ -5,6 +5,10 @@
|
||||
{
|
||||
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
|
||||
"pr": 2330
|
||||
},
|
||||
{
|
||||
"note": "Introduced new export ForwarderRevertErrors",
|
||||
"pr": 2321
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1,2 +1,3 @@
|
||||
export * from './artifacts';
|
||||
export * from './wrappers';
|
||||
export import ForwarderRevertErrors = require('./revert_errors');
|
||||
|
@ -5,6 +5,10 @@
|
||||
{
|
||||
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
|
||||
"pr": 2330
|
||||
},
|
||||
{
|
||||
"note": "Introduced new export LibMathRevertErrors",
|
||||
"pr": 2321
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1,5 +1,6 @@
|
||||
export * from './artifacts';
|
||||
export * from './wrappers';
|
||||
export import LibMathRevertErrors = require('./lib_math_revert_errors');
|
||||
|
||||
import * as ReferenceFunctionsToExport from './reference_functions';
|
||||
export import ReferenceFunctions = ReferenceFunctionsToExport;
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { ReferenceFunctions } from '@0x/contracts-utils';
|
||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||
import { FillResults, Order } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import LibMathRevertErrors = require('./lib_math_revert_errors');
|
||||
|
||||
const { safeAdd, safeSub, safeMul, safeDiv } = ReferenceFunctions;
|
||||
|
||||
/**
|
||||
|
@ -7,12 +7,13 @@ import {
|
||||
testCombinatoriallyWithReferenceFunc,
|
||||
uint256Values,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { FillResults, MatchedFillResults, Order } from '@0x/types';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import LibMathRevertErrors = require('../src/lib_math_revert_errors');
|
||||
import { addFillResults, calculateFillResults, getPartialAmountFloor } from '../src/reference_functions';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
|
@ -6,9 +6,10 @@ import {
|
||||
testCombinatoriallyWithReferenceFunc,
|
||||
uint256Values,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import LibMathRevertErrors = require('../src/lib_math_revert_errors');
|
||||
import {
|
||||
getPartialAmountCeil,
|
||||
getPartialAmountFloor,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { blockchainTests, constants, describe, expect, hexRandom } from '@0x/contracts-test-utils';
|
||||
import { eip712Utils, orderHashUtils } from '@0x/order-utils';
|
||||
import { blockchainTests, constants, describe, expect, hexRandom, orderHashUtils } from '@0x/contracts-test-utils';
|
||||
import { eip712Utils } from '@0x/order-utils';
|
||||
import { Order } from '@0x/types';
|
||||
import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
|
@ -1,5 +1,12 @@
|
||||
import { blockchainTests, constants, describe, expect, hexRandom } from '@0x/contracts-test-utils';
|
||||
import { eip712Utils, transactionHashUtils } from '@0x/order-utils';
|
||||
import {
|
||||
blockchainTests,
|
||||
constants,
|
||||
describe,
|
||||
expect,
|
||||
hexRandom,
|
||||
transactionHashUtils,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { eip712Utils } from '@0x/order-utils';
|
||||
import { ZeroExTransaction } from '@0x/types';
|
||||
import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { constants, describe, expect } from '@0x/contracts-test-utils';
|
||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import LibMathRevertErrors = require('../src/lib_math_revert_errors');
|
||||
import {
|
||||
addFillResults,
|
||||
getPartialAmountCeil,
|
||||
|
@ -5,6 +5,10 @@
|
||||
{
|
||||
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
|
||||
"pr": 2330
|
||||
},
|
||||
{
|
||||
"note": "Introduced new export ExchangeRevertErrors",
|
||||
"pr": 2321
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { constants, ExchangeFunctionName, provider } from '@0x/contracts-test-utils';
|
||||
import { orderHashUtils } from '@0x/order-utils';
|
||||
import { constants, ExchangeFunctionName, orderHashUtils, provider } from '@0x/contracts-test-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
|
||||
import { IExchangeContract } from './wrappers';
|
||||
|
@ -1,5 +1,6 @@
|
||||
export * from './artifacts';
|
||||
export * from './wrappers';
|
||||
export import ExchangeRevertErrors = require('./revert_errors');
|
||||
export { BlockchainBalanceStore } from './balance_stores/blockchain_balance_store';
|
||||
export { LocalBalanceStore } from './balance_stores/local_balance_store';
|
||||
export { exchangeDataEncoder } from './exchange_data_encoder';
|
||||
|
@ -5,10 +5,10 @@ import {
|
||||
expect,
|
||||
FillEventArgs,
|
||||
filterLogsToArguments,
|
||||
orderHashUtils,
|
||||
OrderStatus,
|
||||
orderUtils,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { orderHashUtils } from '@0x/order-utils';
|
||||
import { FillResults, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
|
@ -18,6 +18,7 @@ import {
|
||||
DummyNoReturnERC20TokenContract,
|
||||
} from '@0x/contracts-erc20';
|
||||
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
|
||||
import { LibMathRevertErrors } from '@0x/contracts-exchange-libs';
|
||||
import {
|
||||
blockchainTests,
|
||||
constants,
|
||||
@ -28,18 +29,20 @@ import {
|
||||
hexConcat,
|
||||
increaseTimeAndMineBlockAsync,
|
||||
OrderFactory,
|
||||
orderHashUtils,
|
||||
OrderStatus,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { ExchangeRevertErrors, LibMathRevertErrors, orderHashUtils } from '@0x/order-utils';
|
||||
import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
|
||||
import { BigNumber, providerUtils, StringRevertError } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { ValidatorWalletAction } from './utils/constants';
|
||||
import { ExchangeWrapper } from './utils/exchange_wrapper';
|
||||
|
||||
|
@ -16,14 +16,16 @@ import {
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { OwnableRevertErrors } from '@0x/contracts-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { ExchangeRevertErrors } from '@0x/order-utils';
|
||||
import { AssetProxyId, RevertReason } from '@0x/types';
|
||||
import { BigNumber, OwnableRevertErrors, StringRevertError } from '@0x/utils';
|
||||
import { BigNumber, StringRevertError } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { TestAssetProxyDispatcherAssetProxyRegisteredEventArgs, TestAssetProxyDispatcherContract } from './wrappers';
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||
import { blockchainTests, constants, expect, hexRandom } from '@0x/contracts-test-utils';
|
||||
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
||||
import { blockchainTests, constants, expect, hexRandom, orderHashUtils } from '@0x/contracts-test-utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { Order } from '@0x/types';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import {
|
||||
TestExchangeInternalsContract,
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||
import { LibMathRevertErrors, ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||
import { blockchainTests, constants, expect, hexRandom } from '@0x/contracts-test-utils';
|
||||
import { ExchangeRevertErrors, LibMathRevertErrors } from '@0x/order-utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { FillResults, OrderInfo, OrderStatus, SignatureType } from '@0x/types';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import {
|
||||
AssetBalances,
|
||||
createBadAssetData,
|
||||
|
@ -7,10 +7,12 @@ import {
|
||||
orderUtils,
|
||||
randomAddress,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { ExchangeRevertErrors, generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { BigNumber, RevertError } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { TestLibExchangeRichErrorDecoderContract } from './wrappers';
|
||||
|
||||
|
@ -17,19 +17,21 @@ import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
OrderFactory,
|
||||
orderHashUtils,
|
||||
orderUtils,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
||||
import { OrderStatus, SignedOrder } from '@0x/types';
|
||||
import { BigNumber, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { ExchangeWrapper } from './utils/exchange_wrapper';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { blockchainTests, constants, expect } from '@0x/contracts-test-utils';
|
||||
import { BigNumber, OwnableRevertErrors } from '@0x/utils';
|
||||
import { OwnableRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||
import { LibMathRevertErrors, ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||
import { constants, describe, expect } from '@0x/contracts-test-utils';
|
||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { Order } from '@0x/types';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
describe('Reference functions', () => {
|
||||
|
@ -7,16 +7,19 @@ import {
|
||||
hexRandom,
|
||||
LogDecoder,
|
||||
OrderFactory,
|
||||
orderHashUtils,
|
||||
orderUtils,
|
||||
randomAddress,
|
||||
TransactionFactory,
|
||||
transactionHashUtils,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { ExchangeRevertErrors, orderHashUtils, transactionHashUtils } from '@0x/order-utils';
|
||||
import { SignatureType, SignedOrder, SignedZeroExTransaction } from '@0x/types';
|
||||
import { BigNumber, StringRevertError } from '@0x/utils';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
import ethUtil = require('ethereumjs-util');
|
||||
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import {
|
||||
IEIP1271DataContract,
|
||||
|
@ -10,9 +10,10 @@ import {
|
||||
expect,
|
||||
getLatestBlockTimestampAsync,
|
||||
OrderFactory,
|
||||
orderHashUtils,
|
||||
TransactionFactory,
|
||||
transactionHashUtils,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { ExchangeRevertErrors, orderHashUtils, transactionHashUtils } from '@0x/order-utils';
|
||||
import { FillResults, OrderStatus } from '@0x/types';
|
||||
import { AbiEncoder, BigNumber } from '@0x/utils';
|
||||
import { LogWithDecodedArgs, MethodAbi } from 'ethereum-types';
|
||||
@ -20,6 +21,7 @@ import * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { exchangeDataEncoder } from '../src/exchange_data_encoder';
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { artifacts as localArtifacts } from './artifacts';
|
||||
import { ExchangeWrapper } from './utils/exchange_wrapper';
|
||||
|
@ -1,10 +1,18 @@
|
||||
import { blockchainTests, constants, describe, expect, hexRandom } from '@0x/contracts-test-utils';
|
||||
import { ExchangeRevertErrors, transactionHashUtils } from '@0x/order-utils';
|
||||
import {
|
||||
blockchainTests,
|
||||
constants,
|
||||
describe,
|
||||
expect,
|
||||
hexRandom,
|
||||
transactionHashUtils,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { EIP712DomainWithDefaultSchema, ZeroExTransaction } from '@0x/types';
|
||||
import { BigNumber, StringRevertError } from '@0x/utils';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { TestTransactionsContract, TestTransactionsTransactionExecutionEventArgs } from './wrappers';
|
||||
|
||||
|
@ -6,8 +6,7 @@ import {
|
||||
MultiAssetProxyContract,
|
||||
} from '@0x/contracts-asset-proxy';
|
||||
import { DevUtilsContract } from '@0x/contracts-dev-utils';
|
||||
import { constants, expect, LogDecoder, orderUtils, signingUtils } from '@0x/contracts-test-utils';
|
||||
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
||||
import { constants, expect, LogDecoder, orderHashUtils, orderUtils, signingUtils } from '@0x/contracts-test-utils';
|
||||
import { FillResults, Order, SignatureType, SignedOrder } from '@0x/types';
|
||||
import { BigNumber, errorUtils, providerUtils, RevertError, StringRevertError } from '@0x/utils';
|
||||
import { SupportedProvider, Web3Wrapper } from '@0x/web3-wrapper';
|
||||
@ -15,6 +14,8 @@ import { LogWithDecodedArgs, TxData } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
import 'make-promises-safe';
|
||||
|
||||
import ExchangeRevertErrors = require('../../src/revert_errors');
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
|
||||
import { ExchangeContract, ExchangeFillEventArgs } from '../wrappers';
|
||||
|
@ -1,5 +1,9 @@
|
||||
import { constants, filterLogsToArguments, txDefaults as testTxDefaults } from '@0x/contracts-test-utils';
|
||||
import { orderHashUtils } from '@0x/order-utils';
|
||||
import {
|
||||
constants,
|
||||
filterLogsToArguments,
|
||||
orderHashUtils,
|
||||
txDefaults as testTxDefaults,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { FillResults, Order, OrderInfo, SignatureType } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { TxData, Web3Wrapper } from '@0x/web3-wrapper';
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { ERC1155ProxyWrapper, ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
|
||||
import { DevUtilsContract } from '@0x/contracts-dev-utils';
|
||||
import { constants, ERC1155HoldingsByOwner, expect, OrderStatus } from '@0x/contracts-test-utils';
|
||||
import { orderHashUtils } from '@0x/order-utils';
|
||||
import { constants, ERC1155HoldingsByOwner, expect, orderHashUtils, OrderStatus } from '@0x/contracts-test-utils';
|
||||
import { AssetProxyId, BatchMatchedFillResults, FillResults, MatchedFillResults, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
|
@ -1,14 +1,15 @@
|
||||
import { ContractTxFunctionObj } from '@0x/base-contract';
|
||||
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||
import { blockchainTests, constants, describe, expect, hexRandom } from '@0x/contracts-test-utils';
|
||||
import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils';
|
||||
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
||||
import { blockchainTests, constants, describe, expect, hexRandom, orderHashUtils } from '@0x/contracts-test-utils';
|
||||
import { ReferenceFunctions as UtilReferenceFunctions, SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { FillResults, Order } from '@0x/types';
|
||||
import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils';
|
||||
import { AnyRevertError, BigNumber, StringRevertError } from '@0x/utils';
|
||||
import { LogEntry, LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as ethjs from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import ExchangeRevertErrors = require('../src/revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import {
|
||||
TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs,
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { DevUtilsContract } from '@0x/contracts-dev-utils';
|
||||
import { ExchangeContract } from '@0x/contracts-exchange';
|
||||
import { ExchangeRevertErrors } from '@0x/contracts-exchange';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { ExchangeRevertErrors } from '@0x/order-utils';
|
||||
import { Order, RevertReason, SignedOrder } from '@0x/types';
|
||||
import { BigNumber, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
import { DevUtilsContract } from '@0x/contracts-dev-utils';
|
||||
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
|
||||
import { artifacts as erc721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721';
|
||||
import { ExchangeContract } from '@0x/contracts-exchange';
|
||||
import { ExchangeContract, ExchangeRevertErrors } from '@0x/contracts-exchange';
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
@ -22,7 +22,6 @@ import {
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { ExchangeRevertErrors } from '@0x/order-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
import { BigNumber, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
|
@ -10,11 +10,11 @@ interface FeeRecipientConfig extends ActorConfig {
|
||||
|
||||
export interface FeeRecipientInterface {
|
||||
approvalFactory?: ApprovalFactory;
|
||||
signCoordinatorApproval: (
|
||||
signCoordinatorApprovalAsync: (
|
||||
transaction: SignedZeroExTransaction,
|
||||
txOrigin: string,
|
||||
signatureType?: SignatureType,
|
||||
) => SignedCoordinatorApproval;
|
||||
) => Promise<SignedCoordinatorApproval>;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,15 +45,15 @@ export function FeeRecipientMixin<TBase extends Constructor>(Base: TBase): TBase
|
||||
/**
|
||||
* Signs an coordinator transaction.
|
||||
*/
|
||||
public signCoordinatorApproval(
|
||||
public async signCoordinatorApprovalAsync(
|
||||
transaction: SignedZeroExTransaction,
|
||||
txOrigin: string,
|
||||
signatureType: SignatureType = SignatureType.EthSign,
|
||||
): SignedCoordinatorApproval {
|
||||
): Promise<SignedCoordinatorApproval> {
|
||||
if (this.approvalFactory === undefined) {
|
||||
throw new Error('No verifying contract provided in FeeRecipient constructor');
|
||||
}
|
||||
return this.approvalFactory.newSignedApproval(transaction, txOrigin, signatureType);
|
||||
return this.approvalFactory.newSignedApprovalAsync(transaction, txOrigin, signatureType);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { CoordinatorContract, SignedCoordinatorApproval } from '@0x/contracts-coordinator';
|
||||
import { CoordinatorContract, CoordinatorRevertErrors, SignedCoordinatorApproval } from '@0x/contracts-coordinator';
|
||||
import { DevUtilsContract } from '@0x/contracts-dev-utils';
|
||||
import {
|
||||
BlockchainBalanceStore,
|
||||
@ -16,10 +16,11 @@ import {
|
||||
expect,
|
||||
hexConcat,
|
||||
hexSlice,
|
||||
orderHashUtils,
|
||||
provider,
|
||||
transactionHashUtils,
|
||||
verifyEvents,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { CoordinatorRevertErrors, orderHashUtils, transactionHashUtils } from '@0x/order-utils';
|
||||
import { SignedOrder, SignedZeroExTransaction } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
@ -181,7 +182,7 @@ blockchainTests.resets('Coordinator integration tests', env => {
|
||||
data,
|
||||
gasPrice: DeploymentManager.gasPrice,
|
||||
});
|
||||
approval = feeRecipient.signCoordinatorApproval(transaction, taker.address);
|
||||
approval = await feeRecipient.signCoordinatorApprovalAsync(transaction, taker.address);
|
||||
});
|
||||
|
||||
it(`${fnName} should fill the order with a signed approval`, async () => {
|
||||
@ -299,7 +300,7 @@ blockchainTests.resets('Coordinator integration tests', env => {
|
||||
data,
|
||||
gasPrice: DeploymentManager.gasPrice,
|
||||
});
|
||||
approval = feeRecipient.signCoordinatorApproval(transaction, taker.address);
|
||||
approval = await feeRecipient.signCoordinatorApprovalAsync(transaction, taker.address);
|
||||
});
|
||||
|
||||
it(`${fnName} should fill the orders with a signed approval`, async () => {
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
ExchangeContract,
|
||||
LocalBalanceStore,
|
||||
} from '@0x/contracts-exchange';
|
||||
import { artifacts, ForwarderContract } from '@0x/contracts-exchange-forwarder';
|
||||
import { artifacts, ForwarderContract, ForwarderRevertErrors } from '@0x/contracts-exchange-forwarder';
|
||||
import {
|
||||
blockchainTests,
|
||||
constants,
|
||||
@ -17,7 +17,6 @@ import {
|
||||
provider,
|
||||
toBaseUnitAmount,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { ForwarderRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import { Actor, actorAddressesByName, FeeRecipient, Maker } from '../actors';
|
||||
|
@ -2,6 +2,7 @@ import { DevUtilsContract } from '@0x/contracts-dev-utils';
|
||||
import { ERC20TokenEvents, ERC20TokenTransferEventArgs } from '@0x/contracts-erc20';
|
||||
import {
|
||||
BlockchainBalanceStore,
|
||||
ExchangeRevertErrors,
|
||||
IExchangeEvents,
|
||||
IExchangeFillEventArgs,
|
||||
LocalBalanceStore,
|
||||
@ -14,11 +15,11 @@ import {
|
||||
expect,
|
||||
getLatestBlockTimestampAsync,
|
||||
Numberish,
|
||||
orderHashUtils,
|
||||
provider,
|
||||
toBaseUnitAmount,
|
||||
verifyEvents,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
||||
import { FillResults, OrderStatus, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
|
@ -15,8 +15,15 @@ import {
|
||||
IStakingEventsRewardsPaidEventArgs,
|
||||
IStakingEventsStakingPoolEarnedRewardsInEpochEventArgs,
|
||||
} from '@0x/contracts-staking';
|
||||
import { blockchainTests, constants, expect, provider, toBaseUnitAmount, verifyEvents } from '@0x/contracts-test-utils';
|
||||
import { orderHashUtils } from '@0x/order-utils';
|
||||
import {
|
||||
blockchainTests,
|
||||
constants,
|
||||
expect,
|
||||
orderHashUtils,
|
||||
provider,
|
||||
toBaseUnitAmount,
|
||||
verifyEvents,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { blockchainTests, constants, expect, getLatestBlockTimestampAsync, hexRandom } from '@0x/contracts-test-utils';
|
||||
import { LibBytesRevertErrors } from '@0x/contracts-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
import { BigNumber, LibBytesRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { LogEntry, LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
|
@ -5,6 +5,10 @@
|
||||
{
|
||||
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
|
||||
"pr": 2330
|
||||
},
|
||||
{
|
||||
"note": "Introduce new exports FixedMathRevertErrors and StakingRevertErrors",
|
||||
"pr": 2321
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { BigNumber } from './configured_bignumber';
|
||||
import { RevertError } from './revert_error';
|
||||
import { BigNumber, RevertError } from '@0x/utils';
|
||||
|
||||
// tslint:disable:max-classes-per-file
|
||||
|
@ -1,5 +1,7 @@
|
||||
export * from './wrappers';
|
||||
export * from './artifacts';
|
||||
export import FixedMathRevertErrors = require('./fixed_math_revert_errors');
|
||||
export import StakingRevertErrors = require('./staking_revert_errors');
|
||||
export { constants } from './constants';
|
||||
export {
|
||||
GlobalStakeByStatus,
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { blockchainTests, constants, expect, filterLogsToArguments } from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { AuthorizableRevertErrors, BigNumber, StringRevertError } from '@0x/utils';
|
||||
import { AuthorizableRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber, StringRevertError } from '@0x/utils';
|
||||
|
||||
import { constants as stakingConstants } from '../src/constants';
|
||||
import StakingRevertErrors = require('../src/staking_revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { ERC20Wrapper } from '@0x/contracts-asset-proxy';
|
||||
import { blockchainTests, constants, expect } from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants as stakingConstants } from '../src/constants';
|
||||
import StakingRevertErrors = require('../src/staking_revert_errors');
|
||||
|
||||
import { MakerActor } from './actors/maker_actor';
|
||||
import { PoolOperatorActor } from './actors/pool_operator_actor';
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { ERC20Wrapper } from '@0x/contracts-asset-proxy';
|
||||
import { blockchainTests, constants, describe, expect, shortZip } from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import StakingRevertErrors = require('../src/staking_revert_errors');
|
||||
import { DelegatorsByPoolId, OperatorByPoolId, StakeInfo, StakeStatus } from '../src/types';
|
||||
|
||||
import { FinalizerActor } from './actors/finalizer_actor';
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { ERC20Wrapper } from '@0x/contracts-asset-proxy';
|
||||
import { blockchainTests, describe } from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import StakingRevertErrors = require('../src/staking_revert_errors');
|
||||
import { StakeInfo, StakeStatus } from '../src/types';
|
||||
|
||||
import { StakerActor } from './actors/staker_actor';
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { blockchainTests, expect } from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { AuthorizableRevertErrors } from '@0x/utils';
|
||||
import { AuthorizableRevertErrors } from '@0x/contracts-utils';
|
||||
import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
|
||||
import StakingRevertErrors = require('../../src/staking_revert_errors');
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import {
|
||||
TestExchangeManagerContract,
|
||||
|
@ -7,12 +7,13 @@ import {
|
||||
Numberish,
|
||||
shortZip,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { LogEntry } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants as stakingConstants } from '../../src/constants';
|
||||
import StakingRevertErrors = require('../../src/staking_revert_errors');
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import { assertIntegerRoughlyEquals, getRandomInteger, toBaseUnitAmount } from '../utils/number_utils';
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { blockchainTests, expect, hexRandom, Numberish } from '@0x/contracts-test-utils';
|
||||
import { BigNumber, FixedMathRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Decimal } from 'decimal.js';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import FixedMathRevertErrors = require('../../src/fixed_math_revert_errors');
|
||||
import { assertRoughlyEquals, fromFixed, toDecimal, toFixed } from '../utils/number_utils';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { blockchainTests, expect, Numberish } from '@0x/contracts-test-utils';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import { TestLibSafeDowncastContract } from '../wrappers';
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { blockchainTests, constants, expect, verifyEventsFromLogs } from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
|
||||
import { constants as stakingConstants } from '../../src/constants';
|
||||
import StakingRevertErrors = require('../../src/staking_revert_errors');
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import {
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { blockchainTests, expect, Numberish } from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import { constants } from '../../src/constants';
|
||||
import { StoredBalance } from '../../src/types';
|
||||
|
||||
import { StakingRevertErrors } from '../../src';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import { TestMixinStakeStorageContract } from '../wrappers';
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { blockchainTests, expect, filterLogsToArguments } from '@0x/contracts-test-utils';
|
||||
import { AuthorizableRevertErrors, BigNumber } from '@0x/utils';
|
||||
import { AuthorizableRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
|
@ -7,11 +7,12 @@ import {
|
||||
Numberish,
|
||||
randomAddress,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { LogEntry } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import StakingRevertErrors = require('../../src/staking_revert_errors');
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import {
|
||||
IStakingEventsEvents,
|
||||
|
@ -6,7 +6,8 @@ import {
|
||||
hexRandom,
|
||||
randomAddress,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import { TestMixinStakeBalancesContract } from '../wrappers';
|
||||
|
@ -9,10 +9,10 @@ import {
|
||||
Numberish,
|
||||
shortZip,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import StakingRevertErrors = require('../../src/staking_revert_errors');
|
||||
import { StakeStatus } from '../../src/types';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
|
@ -8,10 +8,12 @@ import {
|
||||
toHex,
|
||||
verifyEventsFromLogs,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { StakingRevertErrors } from '../../src';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import {
|
||||
TestMixinStakingPoolContract,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { blockchainTests, constants, expect, verifyEventsFromLogs } from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { AuthorizableRevertErrors, BigNumber } from '@0x/utils';
|
||||
import { AuthorizableRevertErrors } from '@0x/contracts-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
@ -12,6 +12,7 @@ import {
|
||||
} from '../wrappers';
|
||||
|
||||
import { constants as stakingConstants } from '../../src/constants';
|
||||
import StakingRevertErrors = require('../../src/staking_revert_errors');
|
||||
|
||||
blockchainTests.resets('StakingProxy unit tests', env => {
|
||||
const testString = 'Hello, World!';
|
||||
|
@ -8,12 +8,13 @@ import {
|
||||
filterLogsToArguments,
|
||||
provider,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { AuthorizableRevertErrors, SafeMathRevertErrors } from '@0x/contracts-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
import { AuthorizableRevertErrors, BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
|
||||
import { constants as stakingConstants } from '../../src/constants';
|
||||
import StakingRevertErrors = require('../../src/staking_revert_errors');
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import {
|
||||
|
@ -6,6 +6,10 @@
|
||||
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
|
||||
"pr": 2330
|
||||
},
|
||||
{
|
||||
"note": "Add new exports orderHashUtils and transactionHashUtils",
|
||||
"pr": 2321
|
||||
},
|
||||
{
|
||||
"note": "Remove TransactionHelper and MutatorContractFunction",
|
||||
"pr": 2325
|
||||
|
@ -42,9 +42,11 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/assert": "2.2.0-beta.1",
|
||||
"@0x/dev-utils": "2.4.0-beta.1",
|
||||
"@0x/base-contract": "^5.5.0-beta.0",
|
||||
"@0x/dev-utils": "^2.4.0-beta.1",
|
||||
"@0x/order-utils": "^8.5.0-beta.1",
|
||||
"@0x/json-schemas": "4.1.0-beta.1",
|
||||
"@0x/sol-coverage": "^3.1.0-beta.1",
|
||||
"@0x/sol-profiler": "^3.2.0-beta.1",
|
||||
"@0x/sol-trace": "^2.1.0-beta.1",
|
||||
|
@ -72,3 +72,5 @@ export {
|
||||
getPercentageOfValue,
|
||||
toBaseUnitAmount,
|
||||
} from './number_utils';
|
||||
export { orderHashUtils } from './order_hash';
|
||||
export { transactionHashUtils } from './transaction_hash';
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { generatePseudoRandomSalt, orderHashUtils } from '@0x/order-utils';
|
||||
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { Order, SignatureType, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import { getLatestBlockTimestampAsync } from './block_timestamp';
|
||||
import { constants } from './constants';
|
||||
import { orderHashUtils } from './order_hash';
|
||||
import { signingUtils } from './signing_utils';
|
||||
|
||||
export class OrderFactory {
|
||||
|
@ -1,30 +1,15 @@
|
||||
import { schemas, SchemaValidator } from '@0x/json-schemas';
|
||||
import { assert } from '@0x/assert';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import { eip712Utils } from '@0x/order-utils';
|
||||
import { Order, SignedOrder } from '@0x/types';
|
||||
import { signTypedDataUtils } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { assert } from './assert';
|
||||
import { constants } from './constants';
|
||||
import { eip712Utils } from './eip712_utils';
|
||||
|
||||
const INVALID_TAKER_FORMAT = 'instance.takerAddress is not of a type(s) string';
|
||||
|
||||
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
|
||||
export const orderHashUtils = {
|
||||
/**
|
||||
* Checks if the supplied hex encoded order hash is valid.
|
||||
* Note: Valid means it has the expected format, not that an order with the orderHash exists.
|
||||
* Use this method when processing orderHashes submitted as user input.
|
||||
* @param orderHash Hex encoded orderHash.
|
||||
* @return Whether the supplied orderHash has the expected format.
|
||||
*/
|
||||
isValidOrderHash(orderHash: string): boolean {
|
||||
// Since this method can be called to check if any arbitrary string conforms to an orderHash's
|
||||
// format, we only assert that we were indeed passed a string.
|
||||
assert.isString('orderHash', orderHash);
|
||||
const schemaValidator = new SchemaValidator();
|
||||
const isValid = schemaValidator.validate(orderHash, schemas.orderHashSchema).valid;
|
||||
return isValid;
|
||||
},
|
||||
/**
|
||||
* Computes the orderHash for a supplied order.
|
||||
* @param order An object that conforms to the Order or SignedOrder interface definitions.
|
||||
@ -35,9 +20,7 @@ export const orderHashUtils = {
|
||||
assert.doesConformToSchema('order', order, schemas.orderSchema, [schemas.hexSchema]);
|
||||
} catch (error) {
|
||||
if (_.includes(error.message, INVALID_TAKER_FORMAT)) {
|
||||
const errMsg = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${
|
||||
constants.NULL_ADDRESS
|
||||
}`;
|
||||
const errMsg = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${NULL_ADDRESS}`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
throw error;
|
||||
@ -57,9 +40,7 @@ export const orderHashUtils = {
|
||||
assert.doesConformToSchema('order', order, schemas.orderSchema, [schemas.hexSchema]);
|
||||
} catch (error) {
|
||||
if (_.includes(error.message, INVALID_TAKER_FORMAT)) {
|
||||
const errMsg = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${
|
||||
constants.NULL_ADDRESS
|
||||
}`;
|
||||
const errMsg = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${NULL_ADDRESS}`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
throw error;
|
@ -1,8 +1,10 @@
|
||||
import { generatePseudoRandomSalt, transactionHashUtils } from '@0x/order-utils';
|
||||
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { SignatureType, SignedZeroExTransaction, ZeroExTransaction } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
|
||||
import { transactionHashUtils } from '../src';
|
||||
|
||||
import { getLatestBlockTimestampAsync } from './block_timestamp';
|
||||
import { constants } from './constants';
|
||||
import { signingUtils } from './signing_utils';
|
||||
|
@ -1,27 +1,11 @@
|
||||
import { schemas, SchemaValidator } from '@0x/json-schemas';
|
||||
import { assert } from '@0x/assert';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import { eip712Utils } from '@0x/order-utils';
|
||||
import { SignedZeroExTransaction, ZeroExTransaction } from '@0x/types';
|
||||
import { signTypedDataUtils } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { assert } from './assert';
|
||||
import { eip712Utils } from './eip712_utils';
|
||||
|
||||
export const transactionHashUtils = {
|
||||
/**
|
||||
* Checks if the supplied hex encoded 0x transaction hash is valid.
|
||||
* Note: Valid means it has the expected format, not that a transaction with the transactionHash exists.
|
||||
* Use this method when processing transactionHashes submitted as user input.
|
||||
* @param transactionHash Hex encoded transactionHash.
|
||||
* @return Whether the supplied transactionHash has the expected format.
|
||||
*/
|
||||
isValidTransactionHash(transactionHash: string): boolean {
|
||||
// Since this method can be called to check if any arbitrary string conforms to an transactionHash's
|
||||
// format, we only assert that we were indeed passed a string.
|
||||
assert.isString('transactionHash', transactionHash);
|
||||
const schemaValidator = new SchemaValidator();
|
||||
const isValid = schemaValidator.validate(transactionHash, schemas.orderHashSchema).valid;
|
||||
return isValid;
|
||||
},
|
||||
/**
|
||||
* Computes the transactionHash for a supplied 0x transaction.
|
||||
* @param transaction An object that conforms to the ZeroExTransaction or SignedZeroExTransaction interface definitions.
|
@ -1,3 +1,4 @@
|
||||
import { chaiSetup } from '@0x/dev-utils';
|
||||
import { Order } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
@ -7,8 +8,6 @@ import { orderHashUtils } from '../src';
|
||||
|
||||
import { constants } from '../src/constants';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
@ -64,19 +63,4 @@ describe('Order hashing', () => {
|
||||
expect(() => orderHashUtils.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage);
|
||||
});
|
||||
});
|
||||
describe('#isValidOrderHash', () => {
|
||||
it('returns false if the value is not a hex string', () => {
|
||||
const isValid = orderHashUtils.isValidOrderHash('not a hex');
|
||||
expect(isValid).to.be.false();
|
||||
});
|
||||
it('returns false if the length is wrong', () => {
|
||||
const isValid = orderHashUtils.isValidOrderHash('0xdeadbeef');
|
||||
expect(isValid).to.be.false();
|
||||
});
|
||||
it('returns true if order hash is correct', () => {
|
||||
const orderHashLength = 65;
|
||||
const isValid = orderHashUtils.isValidOrderHash(`0x${Array(orderHashLength).join('0')}`);
|
||||
expect(isValid).to.be.true();
|
||||
});
|
||||
});
|
||||
});
|
@ -1,3 +1,4 @@
|
||||
import { chaiSetup } from '@0x/dev-utils';
|
||||
import { ZeroExTransaction } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
@ -7,8 +8,6 @@ import { transactionHashUtils } from '../src';
|
||||
|
||||
import { constants } from '../src/constants';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
@ -46,19 +45,4 @@ describe('0x transaction hashing', () => {
|
||||
expect(transactionHash).to.be.equal(expectedTransactionHash);
|
||||
});
|
||||
});
|
||||
describe('#isValidTransactionHash', () => {
|
||||
it('returns false if the value is not a hex string', () => {
|
||||
const isValid = transactionHashUtils.isValidTransactionHash('not a hex');
|
||||
expect(isValid).to.be.false();
|
||||
});
|
||||
it('returns false if the length is wrong', () => {
|
||||
const isValid = transactionHashUtils.isValidTransactionHash('0xdeadbeef');
|
||||
expect(isValid).to.be.false();
|
||||
});
|
||||
it('returns true if order hash is correct', () => {
|
||||
const orderHashLength = 65;
|
||||
const isValid = transactionHashUtils.isValidTransactionHash(`0x${Array(orderHashLength).join('0')}`);
|
||||
expect(isValid).to.be.true();
|
||||
});
|
||||
});
|
||||
});
|
41
contracts/tests/test/dev-utils/get_order_hash.ts
Normal file
41
contracts/tests/test/dev-utils/get_order_hash.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { DevUtilsContract } from '@0x/contracts-dev-utils/lib/generated-wrappers/dev_utils';
|
||||
import { Order } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { chaiSetup } from '@0x/contracts-test-utils';
|
||||
import { SupportedProvider } from 'ethereum-types';
|
||||
|
||||
import * as chai from 'chai';
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
const NULL_ADDRESS = '0x' + '00'.repeat(20);
|
||||
|
||||
describe('DevUtils.getOrderHash', () => {
|
||||
it('should return the order hash', async () => {
|
||||
const expectedOrderHash = '0x331cb7e07a757bae130702da6646c26531798c92bcfaf671817268fd2c188531';
|
||||
const exchangeAddress = '0x1dc4c1cefef38a777b15aa20260a54e584b16c48';
|
||||
const chainId = 50;
|
||||
const order: Order = {
|
||||
makerAddress: NULL_ADDRESS,
|
||||
takerAddress: NULL_ADDRESS,
|
||||
senderAddress: NULL_ADDRESS,
|
||||
feeRecipientAddress: NULL_ADDRESS,
|
||||
makerAssetData: NULL_ADDRESS,
|
||||
takerAssetData: NULL_ADDRESS,
|
||||
makerFeeAssetData: NULL_ADDRESS,
|
||||
takerFeeAssetData: NULL_ADDRESS,
|
||||
salt: new BigNumber(0),
|
||||
makerFee: new BigNumber(0),
|
||||
takerFee: new BigNumber(0),
|
||||
makerAssetAmount: new BigNumber(0),
|
||||
takerAssetAmount: new BigNumber(0),
|
||||
expirationTimeSeconds: new BigNumber(0),
|
||||
exchangeAddress,
|
||||
chainId,
|
||||
};
|
||||
const devUtilsContract = new DevUtilsContract(NULL_ADDRESS, { isEIP1193: true } as SupportedProvider);
|
||||
expect(
|
||||
await devUtilsContract.getOrderHash(order, new BigNumber(chainId), exchangeAddress).callAsync(),
|
||||
).to.be.equal(expectedOrderHash);
|
||||
});
|
||||
});
|
@ -26,7 +26,7 @@ import { BigNumber, providerUtils, StringRevertError } from '@0x/utils';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
|
||||
import { artifacts, LibAssetDataContract } from '@0x/contracts-dev-utils';
|
||||
import { InvalidByteOperationError } from '@0x/utils/lib/src/lib_bytes_revert_errors';
|
||||
import { InvalidByteOperationError } from '@0x/contracts-utils/lib/src/lib_bytes_revert_errors';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -12,6 +12,7 @@ import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
orderHashUtils,
|
||||
OrderFactory,
|
||||
OrderStatus,
|
||||
provider,
|
||||
@ -19,7 +20,6 @@ import {
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { orderHashUtils } from '@0x/order-utils';
|
||||
import { OrderTransferResults, SignedOrder } from '@0x/types';
|
||||
import { BigNumber, providerUtils } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
|
@ -5,6 +5,10 @@
|
||||
{
|
||||
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
|
||||
"pr": 2330
|
||||
},
|
||||
{
|
||||
"note": "Introduced new exports AuthorizableRevertErrors, LibAddressArrayRevertErrors, LibBytesRevertErrors, OwnableRevertErrors, ReentrancyGuardRevertErrors and SafeMathRevertErrors",
|
||||
"pr": 2321
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { BigNumber } from './configured_bignumber';
|
||||
import { RevertError } from './revert_error';
|
||||
import { BigNumber, RevertError } from '@0x/utils';
|
||||
|
||||
// tslint:disable:max-classes-per-file
|
||||
export class AuthorizedAddressMismatchError extends RevertError {
|
@ -3,3 +3,10 @@ export * from './wrappers';
|
||||
|
||||
import * as ReferenceFunctionsToExport from './reference_functions';
|
||||
export import ReferenceFunctions = ReferenceFunctionsToExport;
|
||||
|
||||
export import AuthorizableRevertErrors = require('./authorizable_revert_errors');
|
||||
export import LibAddressArrayRevertErrors = require('./lib_address_array_revert_errors');
|
||||
export import LibBytesRevertErrors = require('./lib_bytes_revert_errors');
|
||||
export import OwnableRevertErrors = require('./ownable_revert_errors');
|
||||
export import ReentrancyGuardRevertErrors = require('./reentrancy_guard_revert_errors');
|
||||
export import SafeMathRevertErrors = require('./safe_math_revert_errors');
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { BigNumber } from './configured_bignumber';
|
||||
import { RevertError } from './revert_error';
|
||||
import { BigNumber, RevertError } from '@0x/utils';
|
||||
|
||||
export class MismanagedMemoryError extends RevertError {
|
||||
constructor(freeMemPtr?: BigNumber, addressArrayEndPtr?: BigNumber) {
|
@ -1,5 +1,4 @@
|
||||
import { BigNumber } from './configured_bignumber';
|
||||
import { RevertError } from './revert_error';
|
||||
import { BigNumber, RevertError } from '@0x/utils';
|
||||
|
||||
export enum InvalidByteOperationErrorCodes {
|
||||
FromLessThanOrEqualsToRequired,
|
@ -1,4 +1,4 @@
|
||||
import { RevertError } from './revert_error';
|
||||
import { RevertError } from '@0x/utils';
|
||||
|
||||
// tslint:disable:max-classes-per-file
|
||||
export class OnlyOwnerError extends RevertError {
|
@ -1,4 +1,4 @@
|
||||
import { RevertError } from './revert_error';
|
||||
import { RevertError } from '@0x/utils';
|
||||
|
||||
export class IllegalReentrancyError extends RevertError {
|
||||
constructor() {
|
@ -1,4 +1,6 @@
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import SafeMathRevertErrors = require('./safe_math_revert_errors');
|
||||
|
||||
const MAX_UINT256 = new BigNumber(2).pow(256).minus(1);
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { BigNumber } from './configured_bignumber';
|
||||
import { RevertError } from './revert_error';
|
||||
import { BigNumber, RevertError } from '@0x/utils';
|
||||
|
||||
// tslint:disable:max-classes-per-file
|
||||
|
@ -1,9 +1,12 @@
|
||||
import { chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { AuthorizableRevertErrors, BigNumber, OwnableRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import AuthorizableRevertErrors = require('../src/authorizable_revert_errors');
|
||||
import OwnableRevertErrors = require('../src/ownable_revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { AuthorizableContract } from './wrappers';
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { chaiSetup, provider, randomAddress, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { BigNumber, LibAddressArrayRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import LibAddressArrayRevertErrors = require('../src/lib_address_array_revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { TestLibAddressArrayContract } from './wrappers';
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { blockchainTests, constants, expect } from '@0x/contracts-test-utils';
|
||||
import { BigNumber, LibBytesRevertErrors } from '@0x/utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import BN = require('bn.js');
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import LibBytesRevertErrors = require('../src/lib_bytes_revert_errors');
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { TestLibBytesContract } from './wrappers';
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user