Merge pull request #2212 from 0xProject/refactor/no-domain-in-order
Remove domain from Order and remove OrderWithoutDomain type
This commit is contained in:
@@ -111,10 +111,8 @@ describe('Coordinator tests', () => {
|
|||||||
takerAssetData: assetDataUtils.encodeERC20AssetData(erc20TokenB.address),
|
takerAssetData: assetDataUtils.encodeERC20AssetData(erc20TokenB.address),
|
||||||
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(makerFeeToken.address),
|
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(makerFeeToken.address),
|
||||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(makerFeeToken.address),
|
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(makerFeeToken.address),
|
||||||
domain: {
|
exchangeAddress: exchange.address,
|
||||||
verifyingContract: exchange.address,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
const makerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
const makerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||||
const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)];
|
const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)];
|
||||||
|
@@ -12,7 +12,7 @@ import {
|
|||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
import { transactionHashUtils } from '@0x/order-utils';
|
import { transactionHashUtils } from '@0x/order-utils';
|
||||||
import { EIP712DomainWithDefaultSchema, RevertReason, SignatureType, SignedOrder } from '@0x/types';
|
import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
|
||||||
import { BigNumber, LibBytesRevertErrors, providerUtils } from '@0x/utils';
|
import { BigNumber, LibBytesRevertErrors, providerUtils } from '@0x/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as ethUtil from 'ethereumjs-util';
|
import * as ethUtil from 'ethereumjs-util';
|
||||||
@@ -34,7 +34,6 @@ describe('Mixins tests', () => {
|
|||||||
let approvalFactory2: ApprovalFactory;
|
let approvalFactory2: ApprovalFactory;
|
||||||
let defaultOrder: SignedOrder;
|
let defaultOrder: SignedOrder;
|
||||||
const exchangeAddress = randomAddress();
|
const exchangeAddress = randomAddress();
|
||||||
let exchangeDomain: EIP712DomainWithDefaultSchema;
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
@@ -54,10 +53,6 @@ describe('Mixins tests', () => {
|
|||||||
);
|
);
|
||||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
[transactionSignerAddress, approvalSignerAddress1, approvalSignerAddress2] = accounts.slice(0, 3);
|
[transactionSignerAddress, approvalSignerAddress1, approvalSignerAddress2] = accounts.slice(0, 3);
|
||||||
exchangeDomain = {
|
|
||||||
verifyingContract: constants.NULL_ADDRESS,
|
|
||||||
chainId,
|
|
||||||
};
|
|
||||||
defaultOrder = {
|
defaultOrder = {
|
||||||
makerAddress: constants.NULL_ADDRESS,
|
makerAddress: constants.NULL_ADDRESS,
|
||||||
takerAddress: constants.NULL_ADDRESS,
|
takerAddress: constants.NULL_ADDRESS,
|
||||||
@@ -74,7 +69,8 @@ describe('Mixins tests', () => {
|
|||||||
expirationTimeSeconds: constants.ZERO_AMOUNT,
|
expirationTimeSeconds: constants.ZERO_AMOUNT,
|
||||||
salt: constants.ZERO_AMOUNT,
|
salt: constants.ZERO_AMOUNT,
|
||||||
signature: constants.NULL_BYTES,
|
signature: constants.NULL_BYTES,
|
||||||
domain: exchangeDomain,
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
|
chainId,
|
||||||
};
|
};
|
||||||
const transactionSignerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(transactionSignerAddress)];
|
const transactionSignerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(transactionSignerAddress)];
|
||||||
const approvalSignerPrivateKey1 = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(approvalSignerAddress1)];
|
const approvalSignerPrivateKey1 = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(approvalSignerAddress1)];
|
||||||
@@ -152,7 +148,8 @@ describe('Mixins tests', () => {
|
|||||||
const decodedSignedOrders = decodedOrders.map(order => ({
|
const decodedSignedOrders = decodedOrders.map(order => ({
|
||||||
...order,
|
...order,
|
||||||
signature: constants.NULL_BYTES,
|
signature: constants.NULL_BYTES,
|
||||||
domain: exchangeDomain,
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
|
chainId,
|
||||||
}));
|
}));
|
||||||
expect(orders).to.deep.eq(decodedSignedOrders);
|
expect(orders).to.deep.eq(decodedSignedOrders);
|
||||||
});
|
});
|
||||||
@@ -165,7 +162,8 @@ describe('Mixins tests', () => {
|
|||||||
const decodedSignedOrders = decodedOrders.map(order => ({
|
const decodedSignedOrders = decodedOrders.map(order => ({
|
||||||
...order,
|
...order,
|
||||||
signature: constants.NULL_BYTES,
|
signature: constants.NULL_BYTES,
|
||||||
domain: exchangeDomain,
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
|
chainId,
|
||||||
}));
|
}));
|
||||||
expect(orders).to.deep.eq(decodedSignedOrders);
|
expect(orders).to.deep.eq(decodedSignedOrders);
|
||||||
});
|
});
|
||||||
@@ -178,7 +176,8 @@ describe('Mixins tests', () => {
|
|||||||
const decodedSignedOrders = decodedOrders.map(order => ({
|
const decodedSignedOrders = decodedOrders.map(order => ({
|
||||||
...order,
|
...order,
|
||||||
signature: constants.NULL_BYTES,
|
signature: constants.NULL_BYTES,
|
||||||
domain: exchangeDomain,
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
|
chainId,
|
||||||
}));
|
}));
|
||||||
expect(orders).to.deep.eq(decodedSignedOrders);
|
expect(orders).to.deep.eq(decodedSignedOrders);
|
||||||
});
|
});
|
||||||
|
@@ -120,10 +120,8 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => {
|
|||||||
takerAssetData: erc20AssetData2,
|
takerAssetData: erc20AssetData2,
|
||||||
makerFeeAssetData: feeAssetData,
|
makerFeeAssetData: feeAssetData,
|
||||||
takerFeeAssetData: feeAssetData,
|
takerFeeAssetData: feeAssetData,
|
||||||
domain: {
|
exchangeAddress: exchange.address,
|
||||||
verifyingContract: exchange.address,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||||
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
||||||
|
@@ -120,10 +120,8 @@ blockchainTests(ContractName.Forwarder, env => {
|
|||||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||||
makerFee: Web3Wrapper.toBaseUnitAmount(0, DECIMALS_DEFAULT),
|
makerFee: Web3Wrapper.toBaseUnitAmount(0, DECIMALS_DEFAULT),
|
||||||
takerFee: Web3Wrapper.toBaseUnitAmount(0, DECIMALS_DEFAULT),
|
takerFee: Web3Wrapper.toBaseUnitAmount(0, DECIMALS_DEFAULT),
|
||||||
domain: {
|
exchangeAddress: exchangeInstance.address,
|
||||||
verifyingContract: exchangeInstance.address,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||||
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { ReferenceFunctions } from '@0x/contracts-utils';
|
import { ReferenceFunctions } from '@0x/contracts-utils';
|
||||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||||
import { FillResults, OrderWithoutDomain } from '@0x/types';
|
import { FillResults, Order } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
|
|
||||||
const { safeAdd, safeSub, safeMul, safeDiv } = ReferenceFunctions;
|
const { safeAdd, safeSub, safeMul, safeDiv } = ReferenceFunctions;
|
||||||
@@ -94,7 +94,7 @@ export function addFillResults(a: FillResults, b: FillResults): FillResults {
|
|||||||
* Calculates amounts filled and fees paid by maker and taker.
|
* Calculates amounts filled and fees paid by maker and taker.
|
||||||
*/
|
*/
|
||||||
export function calculateFillResults(
|
export function calculateFillResults(
|
||||||
order: OrderWithoutDomain,
|
order: Order,
|
||||||
takerAssetFilledAmount: BigNumber,
|
takerAssetFilledAmount: BigNumber,
|
||||||
protocolFeeMultiplier: BigNumber,
|
protocolFeeMultiplier: BigNumber,
|
||||||
gasPrice: BigNumber,
|
gasPrice: BigNumber,
|
||||||
|
@@ -8,7 +8,7 @@ import {
|
|||||||
uint256Values,
|
uint256Values,
|
||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||||
import { FillResults, MatchedFillResults, OrderWithoutDomain as Order } from '@0x/types';
|
import { FillResults, MatchedFillResults, Order } from '@0x/types';
|
||||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@@ -39,6 +39,8 @@ blockchainTests('LibFillResults', env => {
|
|||||||
salt: constants.ZERO_AMOUNT,
|
salt: constants.ZERO_AMOUNT,
|
||||||
feeRecipientAddress: constants.NULL_ADDRESS,
|
feeRecipientAddress: constants.NULL_ADDRESS,
|
||||||
expirationTimeSeconds: constants.ZERO_AMOUNT,
|
expirationTimeSeconds: constants.ZERO_AMOUNT,
|
||||||
|
chainId: 1,
|
||||||
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
};
|
};
|
||||||
|
|
||||||
const randomAddress = () => hexRandom(constants.ADDRESS_LENGTH);
|
const randomAddress = () => hexRandom(constants.ADDRESS_LENGTH);
|
||||||
@@ -536,10 +538,8 @@ blockchainTests('LibFillResults', env => {
|
|||||||
feeRecipientAddress: randomAddress(),
|
feeRecipientAddress: randomAddress(),
|
||||||
expirationTimeSeconds: randomUint256(),
|
expirationTimeSeconds: randomUint256(),
|
||||||
salt: randomUint256(),
|
salt: randomUint256(),
|
||||||
domain: {
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
verifyingContract: constants.NULL_ADDRESS,
|
chainId: 1337, // The chain id for the isolated exchange
|
||||||
chainId: 1337, // The chain id for the isolated exchange
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function makeOrder(details?: Partial<Order>): Order {
|
function makeOrder(details?: Partial<Order>): Order {
|
||||||
@@ -547,7 +547,7 @@ blockchainTests('LibFillResults', env => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
ORDER_DEFAULTS.domain.verifyingContract = libsContract.address;
|
ORDER_DEFAULTS.exchangeAddress = libsContract.address;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly calculate the results when only the right order is fully filled', async () => {
|
it('should correctly calculate the results when only the right order is fully filled', async () => {
|
||||||
@@ -1209,10 +1209,8 @@ blockchainTests('LibFillResults', env => {
|
|||||||
feeRecipientAddress: randomAddress(),
|
feeRecipientAddress: randomAddress(),
|
||||||
expirationTimeSeconds: randomUint256(),
|
expirationTimeSeconds: randomUint256(),
|
||||||
salt: randomUint256(),
|
salt: randomUint256(),
|
||||||
domain: {
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
verifyingContract: constants.NULL_ADDRESS,
|
chainId: 1337, // The chain id for the isolated exchange
|
||||||
chainId: 1337, // The chain id for the isolated exchange
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function makeOrder(details?: Partial<Order>): Order {
|
function makeOrder(details?: Partial<Order>): Order {
|
||||||
@@ -1220,7 +1218,7 @@ blockchainTests('LibFillResults', env => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
ORDER_DEFAULTS.domain.verifyingContract = libsContract.address;
|
ORDER_DEFAULTS.exchangeAddress = libsContract.address;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should transfer correct amounts when right order is fully filled', async () => {
|
it('should transfer correct amounts when right order is fully filled', async () => {
|
||||||
|
@@ -16,10 +16,8 @@ blockchainTests('LibOrder', env => {
|
|||||||
const randomAssetData = () => hexRandom(36);
|
const randomAssetData = () => hexRandom(36);
|
||||||
|
|
||||||
const EMPTY_ORDER: Order = {
|
const EMPTY_ORDER: Order = {
|
||||||
domain: {
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
verifyingContract: constants.NULL_ADDRESS,
|
chainId: 0,
|
||||||
chainId: 0,
|
|
||||||
},
|
|
||||||
senderAddress: constants.NULL_ADDRESS,
|
senderAddress: constants.NULL_ADDRESS,
|
||||||
makerAddress: constants.NULL_ADDRESS,
|
makerAddress: constants.NULL_ADDRESS,
|
||||||
takerAddress: constants.NULL_ADDRESS,
|
takerAddress: constants.NULL_ADDRESS,
|
||||||
@@ -52,7 +50,8 @@ blockchainTests('LibOrder', env => {
|
|||||||
const expectedHash = orderHashUtils.getOrderHashHex(order);
|
const expectedHash = orderHashUtils.getOrderHashHex(order);
|
||||||
const domainHash = ethUtil.bufferToHex(
|
const domainHash = ethUtil.bufferToHex(
|
||||||
signTypedDataUtils.generateDomainHash({
|
signTypedDataUtils.generateDomainHash({
|
||||||
...order.domain,
|
chainId: order.chainId,
|
||||||
|
verifyingContract: order.exchangeAddress,
|
||||||
name: constants.EIP712_DOMAIN_NAME,
|
name: constants.EIP712_DOMAIN_NAME,
|
||||||
version: constants.EIP712_DOMAIN_VERSION,
|
version: constants.EIP712_DOMAIN_VERSION,
|
||||||
}),
|
}),
|
||||||
@@ -65,19 +64,14 @@ blockchainTests('LibOrder', env => {
|
|||||||
it('should correctly hash an empty order', async () => {
|
it('should correctly hash an empty order', async () => {
|
||||||
await testGetTypedDataHashAsync({
|
await testGetTypedDataHashAsync({
|
||||||
...EMPTY_ORDER,
|
...EMPTY_ORDER,
|
||||||
domain: {
|
exchangeAddress: libOrderContract.address,
|
||||||
...EMPTY_ORDER.domain,
|
|
||||||
verifyingContract: libOrderContract.address,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly hash a non-empty order', async () => {
|
it('should correctly hash a non-empty order', async () => {
|
||||||
await testGetTypedDataHashAsync({
|
await testGetTypedDataHashAsync({
|
||||||
domain: {
|
exchangeAddress: libOrderContract.address,
|
||||||
verifyingContract: libOrderContract.address,
|
chainId: 1337,
|
||||||
chainId: 1337,
|
|
||||||
},
|
|
||||||
senderAddress: randomAddress(),
|
senderAddress: randomAddress(),
|
||||||
makerAddress: randomAddress(),
|
makerAddress: randomAddress(),
|
||||||
takerAddress: randomAddress(),
|
takerAddress: randomAddress(),
|
||||||
@@ -98,14 +92,15 @@ blockchainTests('LibOrder', env => {
|
|||||||
it('orderHash should differ if the domain hash is different', async () => {
|
it('orderHash should differ if the domain hash is different', async () => {
|
||||||
const domainHash1 = ethUtil.bufferToHex(
|
const domainHash1 = ethUtil.bufferToHex(
|
||||||
signTypedDataUtils.generateDomainHash({
|
signTypedDataUtils.generateDomainHash({
|
||||||
...EMPTY_ORDER.domain,
|
chainId: EMPTY_ORDER.chainId,
|
||||||
|
verifyingContract: EMPTY_ORDER.exchangeAddress,
|
||||||
name: constants.EIP712_DOMAIN_NAME,
|
name: constants.EIP712_DOMAIN_NAME,
|
||||||
version: constants.EIP712_DOMAIN_VERSION,
|
version: constants.EIP712_DOMAIN_VERSION,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const domainHash2 = ethUtil.bufferToHex(
|
const domainHash2 = ethUtil.bufferToHex(
|
||||||
signTypedDataUtils.generateDomainHash({
|
signTypedDataUtils.generateDomainHash({
|
||||||
...EMPTY_ORDER.domain,
|
verifyingContract: EMPTY_ORDER.exchangeAddress,
|
||||||
name: constants.EIP712_DOMAIN_NAME,
|
name: constants.EIP712_DOMAIN_NAME,
|
||||||
version: constants.EIP712_DOMAIN_VERSION,
|
version: constants.EIP712_DOMAIN_VERSION,
|
||||||
chainId: 1337,
|
chainId: 1337,
|
||||||
@@ -135,10 +130,8 @@ blockchainTests('LibOrder', env => {
|
|||||||
it('should correctly hash a non-empty order', async () => {
|
it('should correctly hash a non-empty order', async () => {
|
||||||
await testGetStructHashAsync({
|
await testGetStructHashAsync({
|
||||||
// The domain is not used in this test, so it's okay if it is left empty.
|
// The domain is not used in this test, so it's okay if it is left empty.
|
||||||
domain: {
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
verifyingContract: constants.NULL_ADDRESS,
|
chainId: 0,
|
||||||
chainId: 0,
|
|
||||||
},
|
|
||||||
senderAddress: randomAddress(),
|
senderAddress: randomAddress(),
|
||||||
makerAddress: randomAddress(),
|
makerAddress: randomAddress(),
|
||||||
takerAddress: randomAddress(),
|
takerAddress: randomAddress(),
|
||||||
|
@@ -217,10 +217,8 @@ blockchainTests.resets('Exchange core', () => {
|
|||||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||||
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeAssetAddress),
|
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeAssetAddress),
|
||||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeAssetAddress),
|
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeAssetAddress),
|
||||||
domain: {
|
exchangeAddress: exchange.address,
|
||||||
verifyingContract: exchange.address,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||||
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||||
import { blockchainTests, constants, expect, hexRandom, LogDecoder } from '@0x/contracts-test-utils';
|
import { blockchainTests, constants, expect, hexRandom, LogDecoder } from '@0x/contracts-test-utils';
|
||||||
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
||||||
import { Order, OrderWithoutDomain } from '@0x/types';
|
import { Order } from '@0x/types';
|
||||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||||
@@ -56,10 +56,8 @@ blockchainTests('Exchange core internal functions', env => {
|
|||||||
salt: new BigNumber(_.random(0, 1e8)),
|
salt: new BigNumber(_.random(0, 1e8)),
|
||||||
feeRecipientAddress: randomAddress(),
|
feeRecipientAddress: randomAddress(),
|
||||||
expirationTimeSeconds: new BigNumber(_.random(0, 1e8)),
|
expirationTimeSeconds: new BigNumber(_.random(0, 1e8)),
|
||||||
domain: {
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
verifyingContract: constants.NULL_ADDRESS,
|
chainId: 1337, // The chain id for the isolated exchange
|
||||||
chainId: 1337, // The chain id for the isolated exchange
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function makeOrder(details?: Partial<Order>): Order {
|
function makeOrder(details?: Partial<Order>): Order {
|
||||||
@@ -67,7 +65,7 @@ blockchainTests('Exchange core internal functions', env => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
ORDER_DEFAULTS.domain.verifyingContract = testExchange.address;
|
ORDER_DEFAULTS.exchangeAddress = testExchange.address;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should revert if the maker asset multiplication should overflow', async () => {
|
it('should revert if the maker asset multiplication should overflow', async () => {
|
||||||
@@ -160,14 +158,16 @@ blockchainTests('Exchange core internal functions', env => {
|
|||||||
salt: new BigNumber(_.random(0, 1e8)),
|
salt: new BigNumber(_.random(0, 1e8)),
|
||||||
feeRecipientAddress: randomAddress(),
|
feeRecipientAddress: randomAddress(),
|
||||||
expirationTimeSeconds: new BigNumber(_.random(0, 1e8)),
|
expirationTimeSeconds: new BigNumber(_.random(0, 1e8)),
|
||||||
|
chainId: 1337,
|
||||||
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
};
|
};
|
||||||
|
|
||||||
function makeOrder(details?: Partial<OrderWithoutDomain>): OrderWithoutDomain {
|
function makeOrder(details?: Partial<Order>): Order {
|
||||||
return _.assign({}, ORDER_DEFAULTS, details);
|
return _.assign({}, ORDER_DEFAULTS, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function testUpdateFilledStateAsync(
|
async function testUpdateFilledStateAsync(
|
||||||
order: OrderWithoutDomain,
|
order: Order,
|
||||||
orderTakerAssetFilledAmount: BigNumber,
|
orderTakerAssetFilledAmount: BigNumber,
|
||||||
takerAddress: string,
|
takerAddress: string,
|
||||||
takerAssetFillAmount: BigNumber,
|
takerAssetFillAmount: BigNumber,
|
||||||
|
@@ -36,6 +36,8 @@ blockchainTests('Isolated fillOrder() tests', env => {
|
|||||||
takerAssetData: createGoodAssetData(),
|
takerAssetData: createGoodAssetData(),
|
||||||
makerFeeAssetData: createGoodAssetData(),
|
makerFeeAssetData: createGoodAssetData(),
|
||||||
takerFeeAssetData: createGoodAssetData(),
|
takerFeeAssetData: createGoodAssetData(),
|
||||||
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
|
chainId: 1,
|
||||||
};
|
};
|
||||||
const DEFAULT_GAS_PRICE = new BigNumber(20000);
|
const DEFAULT_GAS_PRICE = new BigNumber(20000);
|
||||||
const DEFAULT_PROTOCOL_FEE_MULTIPLIER = new BigNumber(15000);
|
const DEFAULT_PROTOCOL_FEE_MULTIPLIER = new BigNumber(15000);
|
||||||
|
@@ -198,10 +198,7 @@ describe('matchOrders', () => {
|
|||||||
defaultFeeTokenAddress = erc20Tokens[2].address;
|
defaultFeeTokenAddress = erc20Tokens[2].address;
|
||||||
defaultERC721AssetAddress = erc721Token.address;
|
defaultERC721AssetAddress = erc721Token.address;
|
||||||
defaultERC1155AssetAddress = erc1155Token.address;
|
defaultERC1155AssetAddress = erc1155Token.address;
|
||||||
const domain = {
|
|
||||||
verifyingContract: exchange.address,
|
|
||||||
chainId,
|
|
||||||
};
|
|
||||||
// Create default order parameters
|
// Create default order parameters
|
||||||
const defaultOrderParamsLeft = {
|
const defaultOrderParamsLeft = {
|
||||||
...constants.STATIC_ORDER_PARAMS,
|
...constants.STATIC_ORDER_PARAMS,
|
||||||
@@ -211,7 +208,8 @@ describe('matchOrders', () => {
|
|||||||
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeTokenAddress),
|
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeTokenAddress),
|
||||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeTokenAddress),
|
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeTokenAddress),
|
||||||
feeRecipientAddress: feeRecipientAddressLeft,
|
feeRecipientAddress: feeRecipientAddressLeft,
|
||||||
domain,
|
exchangeAddress: exchange.address,
|
||||||
|
chainId,
|
||||||
};
|
};
|
||||||
const defaultOrderParamsRight = {
|
const defaultOrderParamsRight = {
|
||||||
...constants.STATIC_ORDER_PARAMS,
|
...constants.STATIC_ORDER_PARAMS,
|
||||||
@@ -221,7 +219,8 @@ describe('matchOrders', () => {
|
|||||||
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeTokenAddress),
|
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeTokenAddress),
|
||||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeTokenAddress),
|
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeTokenAddress),
|
||||||
feeRecipientAddress: feeRecipientAddressRight,
|
feeRecipientAddress: feeRecipientAddressRight,
|
||||||
domain,
|
exchangeAddress: exchange.address,
|
||||||
|
chainId,
|
||||||
};
|
};
|
||||||
const privateKeyLeft = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddressLeft)];
|
const privateKeyLeft = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddressLeft)];
|
||||||
orderFactoryLeft = new OrderFactory(privateKeyLeft, defaultOrderParamsLeft);
|
orderFactoryLeft = new OrderFactory(privateKeyLeft, defaultOrderParamsLeft);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||||
import { constants, describe, expect } from '@0x/contracts-test-utils';
|
import { constants, describe, expect } from '@0x/contracts-test-utils';
|
||||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||||
import { OrderWithoutDomain as Order } from '@0x/types';
|
import { Order } from '@0x/types';
|
||||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
@@ -24,6 +24,8 @@ describe('Reference functions', () => {
|
|||||||
salt: constants.ZERO_AMOUNT,
|
salt: constants.ZERO_AMOUNT,
|
||||||
feeRecipientAddress: constants.NULL_ADDRESS,
|
feeRecipientAddress: constants.NULL_ADDRESS,
|
||||||
expirationTimeSeconds: constants.ZERO_AMOUNT,
|
expirationTimeSeconds: constants.ZERO_AMOUNT,
|
||||||
|
chainId: 1,
|
||||||
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('calculateFillResults', () => {
|
describe('calculateFillResults', () => {
|
||||||
|
@@ -435,10 +435,8 @@ blockchainTests.resets('MixinSignatureValidator', env => {
|
|||||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(randomAddress()),
|
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(randomAddress()),
|
||||||
makerFee: constants.ZERO_AMOUNT,
|
makerFee: constants.ZERO_AMOUNT,
|
||||||
takerFee: constants.ZERO_AMOUNT,
|
takerFee: constants.ZERO_AMOUNT,
|
||||||
domain: {
|
exchangeAddress: signatureValidator.address,
|
||||||
verifyingContract: signatureValidator.address,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
orderFactory = new OrderFactory(signerPrivateKey, defaultOrderParams);
|
orderFactory = new OrderFactory(signerPrivateKey, defaultOrderParams);
|
||||||
});
|
});
|
||||||
|
@@ -11,7 +11,7 @@ import {
|
|||||||
TransactionFactory,
|
TransactionFactory,
|
||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { assetDataUtils, ExchangeRevertErrors, orderHashUtils, transactionHashUtils } from '@0x/order-utils';
|
import { assetDataUtils, ExchangeRevertErrors, orderHashUtils, transactionHashUtils } from '@0x/order-utils';
|
||||||
import { EIP712DomainWithDefaultSchema, FillResults, OrderStatus } from '@0x/types';
|
import { FillResults, OrderStatus } from '@0x/types';
|
||||||
import { AbiEncoder, BigNumber } from '@0x/utils';
|
import { AbiEncoder, BigNumber } from '@0x/utils';
|
||||||
import { LogWithDecodedArgs, MethodAbi } from 'ethereum-types';
|
import { LogWithDecodedArgs, MethodAbi } from 'ethereum-types';
|
||||||
import * as ethUtil from 'ethereumjs-util';
|
import * as ethUtil from 'ethereumjs-util';
|
||||||
@@ -51,7 +51,6 @@ blockchainTests.resets('Exchange transactions', env => {
|
|||||||
let exchangeInstance: ExchangeContract;
|
let exchangeInstance: ExchangeContract;
|
||||||
let erc20Proxy: ERC20ProxyContract;
|
let erc20Proxy: ERC20ProxyContract;
|
||||||
|
|
||||||
let domain: EIP712DomainWithDefaultSchema;
|
|
||||||
let orderFactory: OrderFactory;
|
let orderFactory: OrderFactory;
|
||||||
let makerTransactionFactory: TransactionFactory;
|
let makerTransactionFactory: TransactionFactory;
|
||||||
let takerTransactionFactory: TransactionFactory;
|
let takerTransactionFactory: TransactionFactory;
|
||||||
@@ -107,11 +106,6 @@ blockchainTests.resets('Exchange transactions', env => {
|
|||||||
defaultMakerFeeTokenAddress = makerFeeToken.address;
|
defaultMakerFeeTokenAddress = makerFeeToken.address;
|
||||||
defaultTakerFeeTokenAddress = takerFeeToken.address;
|
defaultTakerFeeTokenAddress = takerFeeToken.address;
|
||||||
|
|
||||||
domain = {
|
|
||||||
verifyingContract: exchangeInstance.address,
|
|
||||||
chainId,
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultOrderParams = {
|
const defaultOrderParams = {
|
||||||
...constants.STATIC_ORDER_PARAMS,
|
...constants.STATIC_ORDER_PARAMS,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -120,7 +114,8 @@ blockchainTests.resets('Exchange transactions', env => {
|
|||||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerTokenAddress),
|
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerTokenAddress),
|
||||||
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerFeeTokenAddress),
|
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerFeeTokenAddress),
|
||||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerFeeTokenAddress),
|
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerFeeTokenAddress),
|
||||||
domain,
|
exchangeAddress: exchangeInstance.address,
|
||||||
|
chainId,
|
||||||
};
|
};
|
||||||
makerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
makerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||||
takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)];
|
takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)];
|
||||||
|
@@ -6,7 +6,7 @@ import {
|
|||||||
txDefaults as testTxDefaults,
|
txDefaults as testTxDefaults,
|
||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { orderHashUtils } from '@0x/order-utils';
|
import { orderHashUtils } from '@0x/order-utils';
|
||||||
import { FillResults, OrderInfo, OrderWithoutDomain, SignatureType } from '@0x/types';
|
import { FillResults, Order, OrderInfo, SignatureType } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import { TxData, Web3Wrapper } from '@0x/web3-wrapper';
|
import { TxData, Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
@@ -28,7 +28,7 @@ export interface IsolatedExchangeEvents {
|
|||||||
transferFromCalls: DispatchTransferFromCallArgs[];
|
transferFromCalls: DispatchTransferFromCallArgs[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Order = OrderWithoutDomain;
|
export type Order = Order;
|
||||||
export type Numberish = string | number | BigNumber;
|
export type Numberish = string | number | BigNumber;
|
||||||
|
|
||||||
export const DEFAULT_GOOD_SIGNATURE = createGoodSignature();
|
export const DEFAULT_GOOD_SIGNATURE = createGoodSignature();
|
||||||
@@ -101,11 +101,11 @@ export class IsolatedExchangeWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getOrderHash(order: Order): string {
|
public getOrderHash(order: Order): string {
|
||||||
const domain = {
|
const domainInfo = {
|
||||||
verifyingContract: this.instance.address,
|
exchangeAddress: this.instance.address,
|
||||||
chainId: IsolatedExchangeWrapper.CHAIN_ID,
|
chainId: IsolatedExchangeWrapper.CHAIN_ID,
|
||||||
};
|
};
|
||||||
return orderHashUtils.getOrderHashHex({ ...order, domain });
|
return orderHashUtils.getOrderHashHex({ ...order, ...domainInfo });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getOrderInfoAsync(order: Order): Promise<OrderInfo> {
|
public async getOrderInfoAsync(order: Order): Promise<OrderInfo> {
|
||||||
|
@@ -430,10 +430,8 @@ export class OrderFactoryFromScenario {
|
|||||||
salt: generatePseudoRandomSalt(),
|
salt: generatePseudoRandomSalt(),
|
||||||
feeRecipientAddress,
|
feeRecipientAddress,
|
||||||
expirationTimeSeconds,
|
expirationTimeSeconds,
|
||||||
domain: {
|
exchangeAddress: this._exchangeAddress,
|
||||||
verifyingContract: this._exchangeAddress,
|
chainId: this._chainId,
|
||||||
chainId: this._chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return order;
|
return order;
|
||||||
|
@@ -97,10 +97,8 @@ blockchainTests.resets('Exchange wrappers', env => {
|
|||||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||||
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeAssetAddress),
|
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeAssetAddress),
|
||||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeAssetAddress),
|
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(defaultFeeAssetAddress),
|
||||||
domain: {
|
exchangeAddress: exchange.address,
|
||||||
verifyingContract: exchange.address,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||||
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
||||||
|
@@ -10,7 +10,7 @@ import {
|
|||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils';
|
import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils';
|
||||||
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
||||||
import { FillResults, OrderWithoutDomain as Order } from '@0x/types';
|
import { FillResults, Order } from '@0x/types';
|
||||||
import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils';
|
import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils';
|
||||||
import { LogEntry, LogWithDecodedArgs } from 'ethereum-types';
|
import { LogEntry, LogWithDecodedArgs } from 'ethereum-types';
|
||||||
import * as ethjs from 'ethereumjs-util';
|
import * as ethjs from 'ethereumjs-util';
|
||||||
@@ -83,20 +83,12 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
|||||||
takerAssetData: randomAssetData(),
|
takerAssetData: randomAssetData(),
|
||||||
makerFeeAssetData: randomAssetData(),
|
makerFeeAssetData: randomAssetData(),
|
||||||
takerFeeAssetData: randomAssetData(),
|
takerFeeAssetData: randomAssetData(),
|
||||||
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
|
chainId: CHAIN_ID,
|
||||||
...(fields || {}),
|
...(fields || {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpectedOrderHash(order: Order): string {
|
|
||||||
return orderHashUtils.getOrderHashHex({
|
|
||||||
...order,
|
|
||||||
domain: {
|
|
||||||
verifyingContract: testContract.address,
|
|
||||||
chainId: CHAIN_ID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Computes the expected (fake) fill results from `TestWrapperFunctions` `_fillOrder` implementation.
|
// Computes the expected (fake) fill results from `TestWrapperFunctions` `_fillOrder` implementation.
|
||||||
function getExpectedFillResults(order: Order, signature: string): FillResults {
|
function getExpectedFillResults(order: Order, signature: string): FillResults {
|
||||||
if (order.salt === ALWAYS_FAILING_SALT) {
|
if (order.salt === ALWAYS_FAILING_SALT) {
|
||||||
@@ -114,7 +106,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
|||||||
// Creates a deterministic order signature, even though no signature validation
|
// Creates a deterministic order signature, even though no signature validation
|
||||||
// actually occurs in the test contract.
|
// actually occurs in the test contract.
|
||||||
function createOrderSignature(order: Order): string {
|
function createOrderSignature(order: Order): string {
|
||||||
return ethjs.bufferToHex(ethjs.sha3(ethjs.toBuffer(getExpectedOrderHash(order))));
|
return ethjs.bufferToHex(ethjs.sha3(ethjs.toBuffer(orderHashUtils.getOrderHashHex(order))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asserts that `_fillOrder()` was called in the same order and with the same
|
// Asserts that `_fillOrder()` was called in the same order and with the same
|
||||||
|
@@ -177,10 +177,8 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), DECIMALS_DEFAULT),
|
makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), DECIMALS_DEFAULT),
|
||||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(150), DECIMALS_DEFAULT),
|
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(150), DECIMALS_DEFAULT),
|
||||||
senderAddress: erc721BalanceThresholdFilterInstance.address,
|
senderAddress: erc721BalanceThresholdFilterInstance.address,
|
||||||
domain: {
|
exchangeAddress: exchangeInstance.address,
|
||||||
verifyingContract: exchangeInstance.address,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
// Create two order factories with valid makers (who meet the threshold balance), and
|
// Create two order factories with valid makers (who meet the threshold balance), and
|
||||||
// one factory for an invalid address (that does not meet the threshold balance)
|
// one factory for an invalid address (that does not meet the threshold balance)
|
||||||
|
@@ -163,10 +163,8 @@ describe(ContractName.DutchAuction, () => {
|
|||||||
expirationTimeSeconds: auctionEndTimeSeconds,
|
expirationTimeSeconds: auctionEndTimeSeconds,
|
||||||
makerFee: constants.ZERO_AMOUNT,
|
makerFee: constants.ZERO_AMOUNT,
|
||||||
takerFee: constants.ZERO_AMOUNT,
|
takerFee: constants.ZERO_AMOUNT,
|
||||||
domain: {
|
exchangeAddress: exchangeInstance.address,
|
||||||
verifyingContract: exchangeInstance.address,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
// Default buy order is for the auction begin price
|
// Default buy order is for the auction begin price
|
||||||
const buyerDefaultOrderParams = {
|
const buyerDefaultOrderParams = {
|
||||||
|
@@ -166,11 +166,6 @@ describe('OrderMatcher', () => {
|
|||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
|
|
||||||
const domain = {
|
|
||||||
verifyingContract: exchange.address,
|
|
||||||
chainId,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create default order parameters
|
// Create default order parameters
|
||||||
const defaultOrderParamsLeft = {
|
const defaultOrderParamsLeft = {
|
||||||
...constants.STATIC_ORDER_PARAMS,
|
...constants.STATIC_ORDER_PARAMS,
|
||||||
@@ -180,7 +175,8 @@ describe('OrderMatcher', () => {
|
|||||||
feeRecipientAddress: feeRecipientAddressLeft,
|
feeRecipientAddress: feeRecipientAddressLeft,
|
||||||
makerFee: constants.ZERO_AMOUNT,
|
makerFee: constants.ZERO_AMOUNT,
|
||||||
takerFee: constants.ZERO_AMOUNT,
|
takerFee: constants.ZERO_AMOUNT,
|
||||||
domain,
|
exchangeAddress: exchange.address,
|
||||||
|
chainId,
|
||||||
};
|
};
|
||||||
const defaultOrderParamsRight = {
|
const defaultOrderParamsRight = {
|
||||||
...constants.STATIC_ORDER_PARAMS,
|
...constants.STATIC_ORDER_PARAMS,
|
||||||
@@ -190,7 +186,8 @@ describe('OrderMatcher', () => {
|
|||||||
feeRecipientAddress: feeRecipientAddressRight,
|
feeRecipientAddress: feeRecipientAddressRight,
|
||||||
makerFee: constants.ZERO_AMOUNT,
|
makerFee: constants.ZERO_AMOUNT,
|
||||||
takerFee: constants.ZERO_AMOUNT,
|
takerFee: constants.ZERO_AMOUNT,
|
||||||
domain,
|
exchangeAddress: exchange.address,
|
||||||
|
chainId,
|
||||||
};
|
};
|
||||||
const privateKeyLeft = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddressLeft)];
|
const privateKeyLeft = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddressLeft)];
|
||||||
orderFactoryLeft = new OrderFactory(privateKeyLeft, defaultOrderParamsLeft);
|
orderFactoryLeft = new OrderFactory(privateKeyLeft, defaultOrderParamsLeft);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
||||||
import { crypto } from '@0x/order-utils/lib/src/crypto';
|
import { crypto } from '@0x/order-utils/lib/src/crypto';
|
||||||
import { OrderWithoutDomain, SignedOrder } from '@0x/types';
|
import { Order, SignedOrder } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ export const orderUtils = {
|
|||||||
},
|
},
|
||||||
createFill: (signedOrder: SignedOrder, takerAssetFillAmount?: BigNumber) => {
|
createFill: (signedOrder: SignedOrder, takerAssetFillAmount?: BigNumber) => {
|
||||||
const fill = {
|
const fill = {
|
||||||
order: orderUtils.getOrderWithoutDomain(signedOrder),
|
order: signedOrder,
|
||||||
takerAssetFillAmount: takerAssetFillAmount || signedOrder.takerAssetAmount,
|
takerAssetFillAmount: takerAssetFillAmount || signedOrder.takerAssetAmount,
|
||||||
signature: signedOrder.signature,
|
signature: signedOrder.signature,
|
||||||
};
|
};
|
||||||
@@ -25,19 +25,19 @@ export const orderUtils = {
|
|||||||
},
|
},
|
||||||
createCancel(signedOrder: SignedOrder, takerAssetCancelAmount?: BigNumber): CancelOrder {
|
createCancel(signedOrder: SignedOrder, takerAssetCancelAmount?: BigNumber): CancelOrder {
|
||||||
const cancel = {
|
const cancel = {
|
||||||
order: orderUtils.getOrderWithoutDomain(signedOrder),
|
order: signedOrder,
|
||||||
takerAssetCancelAmount: takerAssetCancelAmount || signedOrder.takerAssetAmount,
|
takerAssetCancelAmount: takerAssetCancelAmount || signedOrder.takerAssetAmount,
|
||||||
};
|
};
|
||||||
return cancel;
|
return cancel;
|
||||||
},
|
},
|
||||||
getOrderWithoutDomain(signedOrder: SignedOrder): OrderWithoutDomain {
|
createOrderWithoutSignature(signedOrder: SignedOrder): Order {
|
||||||
return _.omit(signedOrder, ['signature', 'domain']) as OrderWithoutDomain;
|
return _.omit(signedOrder, ['signature']) as Order;
|
||||||
},
|
},
|
||||||
createBatchMatchOrders(signedOrdersLeft: SignedOrder[], signedOrdersRight: SignedOrder[]): BatchMatchOrder {
|
createBatchMatchOrders(signedOrdersLeft: SignedOrder[], signedOrdersRight: SignedOrder[]): BatchMatchOrder {
|
||||||
return {
|
return {
|
||||||
leftOrders: signedOrdersLeft.map(order => orderUtils.getOrderWithoutDomain(order)),
|
leftOrders: signedOrdersLeft.map(order => orderUtils.createOrderWithoutSignature(order)),
|
||||||
rightOrders: signedOrdersRight.map(order => {
|
rightOrders: signedOrdersRight.map(order => {
|
||||||
const right = orderUtils.getOrderWithoutDomain(order);
|
const right = orderUtils.createOrderWithoutSignature(order);
|
||||||
right.makerAssetData = constants.NULL_BYTES;
|
right.makerAssetData = constants.NULL_BYTES;
|
||||||
right.takerAssetData = constants.NULL_BYTES;
|
right.takerAssetData = constants.NULL_BYTES;
|
||||||
return right;
|
return right;
|
||||||
@@ -48,8 +48,8 @@ export const orderUtils = {
|
|||||||
},
|
},
|
||||||
createMatchOrders(signedOrderLeft: SignedOrder, signedOrderRight: SignedOrder): MatchOrder {
|
createMatchOrders(signedOrderLeft: SignedOrder, signedOrderRight: SignedOrder): MatchOrder {
|
||||||
const fill = {
|
const fill = {
|
||||||
left: orderUtils.getOrderWithoutDomain(signedOrderLeft),
|
left: orderUtils.createOrderWithoutSignature(signedOrderLeft),
|
||||||
right: orderUtils.getOrderWithoutDomain(signedOrderRight),
|
right: orderUtils.createOrderWithoutSignature(signedOrderRight),
|
||||||
leftSignature: signedOrderLeft.signature,
|
leftSignature: signedOrderLeft.signature,
|
||||||
rightSignature: signedOrderRight.signature,
|
rightSignature: signedOrderRight.signature,
|
||||||
};
|
};
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { OrderWithoutDomain } from '@0x/types';
|
import { Order } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import { AbiDefinition } from 'ethereum-types';
|
import { AbiDefinition } from 'ethereum-types';
|
||||||
|
|
||||||
@@ -42,25 +42,25 @@ export interface SubmissionContractEventArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface BatchFillOrders {
|
export interface BatchFillOrders {
|
||||||
orders: OrderWithoutDomain[];
|
orders: Order[];
|
||||||
signatures: string[];
|
signatures: string[];
|
||||||
takerAssetFillAmounts: BigNumber[];
|
takerAssetFillAmounts: BigNumber[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MarketSellOrders {
|
export interface MarketSellOrders {
|
||||||
orders: OrderWithoutDomain[];
|
orders: Order[];
|
||||||
signatures: string[];
|
signatures: string[];
|
||||||
takerAssetFillAmount: BigNumber;
|
takerAssetFillAmount: BigNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MarketBuyOrders {
|
export interface MarketBuyOrders {
|
||||||
orders: OrderWithoutDomain[];
|
orders: Order[];
|
||||||
signatures: string[];
|
signatures: string[];
|
||||||
makerAssetFillAmount: BigNumber;
|
makerAssetFillAmount: BigNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BatchCancelOrders {
|
export interface BatchCancelOrders {
|
||||||
orders: OrderWithoutDomain[];
|
orders: Order[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CancelOrdersBefore {
|
export interface CancelOrdersBefore {
|
||||||
@@ -120,20 +120,20 @@ export enum ContractName {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CancelOrder {
|
export interface CancelOrder {
|
||||||
order: OrderWithoutDomain;
|
order: Order;
|
||||||
takerAssetCancelAmount: BigNumber;
|
takerAssetCancelAmount: BigNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BatchMatchOrder {
|
export interface BatchMatchOrder {
|
||||||
leftOrders: OrderWithoutDomain[];
|
leftOrders: Order[];
|
||||||
rightOrders: OrderWithoutDomain[];
|
rightOrders: Order[];
|
||||||
leftSignatures: string[];
|
leftSignatures: string[];
|
||||||
rightSignatures: string[];
|
rightSignatures: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MatchOrder {
|
export interface MatchOrder {
|
||||||
left: OrderWithoutDomain;
|
left: Order;
|
||||||
right: OrderWithoutDomain;
|
right: Order;
|
||||||
leftSignature: string;
|
leftSignature: string;
|
||||||
rightSignature: string;
|
rightSignature: string;
|
||||||
}
|
}
|
||||||
|
@@ -102,14 +102,17 @@ describe('AssetBuyer', () => {
|
|||||||
|
|
||||||
// TODO (xianny): needs to be updated to new SignedOrder interface
|
// TODO (xianny): needs to be updated to new SignedOrder interface
|
||||||
describe('assetData is supported', () => {
|
describe('assetData is supported', () => {
|
||||||
|
const chainId = 1;
|
||||||
// orders
|
// orders
|
||||||
const sellTwoTokensFor1Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
const sellTwoTokensFor1Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
makerAssetAmount: baseUnitAmount(2),
|
makerAssetAmount: baseUnitAmount(2),
|
||||||
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
|
||||||
|
chainId,
|
||||||
});
|
});
|
||||||
const sellTenTokensFor10Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
const sellTenTokensFor10Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
makerAssetAmount: baseUnitAmount(10),
|
makerAssetAmount: baseUnitAmount(10),
|
||||||
takerAssetAmount: baseUnitAmount(10, WETH_DECIMALS),
|
takerAssetAmount: baseUnitAmount(10, WETH_DECIMALS),
|
||||||
|
chainId,
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@@ -24,6 +24,7 @@ describe('buyQuoteCalculator', () => {
|
|||||||
let ordersAndFillableAmounts: OrdersAndFillableAmounts;
|
let ordersAndFillableAmounts: OrdersAndFillableAmounts;
|
||||||
let smallFeeOrderAndFillableAmount: OrdersAndFillableAmounts;
|
let smallFeeOrderAndFillableAmount: OrdersAndFillableAmounts;
|
||||||
let allFeeOrdersAndFillableAmounts: OrdersAndFillableAmounts;
|
let allFeeOrdersAndFillableAmounts: OrdersAndFillableAmounts;
|
||||||
|
const chainId = 1;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// generate two orders for our desired maker asset
|
// generate two orders for our desired maker asset
|
||||||
// the first order has a rate of 4 makerAsset / WETH with a takerFee of 200 ZRX and has only 200 / 400 makerAsset units left to fill (half fillable)
|
// the first order has a rate of 4 makerAsset / WETH with a takerFee of 200 ZRX and has only 200 / 400 makerAsset units left to fill (half fillable)
|
||||||
@@ -34,12 +35,14 @@ describe('buyQuoteCalculator', () => {
|
|||||||
makerAssetAmount: new BigNumber(400),
|
makerAssetAmount: new BigNumber(400),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
takerFee: new BigNumber(200),
|
takerFee: new BigNumber(200),
|
||||||
|
chainId,
|
||||||
});
|
});
|
||||||
firstRemainingFillAmount = new BigNumber(200);
|
firstRemainingFillAmount = new BigNumber(200);
|
||||||
secondOrder = orderFactory.createSignedOrderFromPartial({
|
secondOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
makerAssetAmount: new BigNumber(200),
|
makerAssetAmount: new BigNumber(200),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
takerFee: new BigNumber(100),
|
takerFee: new BigNumber(100),
|
||||||
|
chainId,
|
||||||
});
|
});
|
||||||
secondRemainingFillAmount = secondOrder.makerAssetAmount;
|
secondRemainingFillAmount = secondOrder.makerAssetAmount;
|
||||||
ordersAndFillableAmounts = {
|
ordersAndFillableAmounts = {
|
||||||
@@ -49,6 +52,7 @@ describe('buyQuoteCalculator', () => {
|
|||||||
const smallFeeOrder = orderFactory.createSignedOrderFromPartial({
|
const smallFeeOrder = orderFactory.createSignedOrderFromPartial({
|
||||||
makerAssetAmount: new BigNumber(100),
|
makerAssetAmount: new BigNumber(100),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
|
chainId,
|
||||||
});
|
});
|
||||||
smallFeeOrderAndFillableAmount = {
|
smallFeeOrderAndFillableAmount = {
|
||||||
orders: [smallFeeOrder],
|
orders: [smallFeeOrder],
|
||||||
@@ -58,6 +62,7 @@ describe('buyQuoteCalculator', () => {
|
|||||||
makerAssetAmount: new BigNumber(113),
|
makerAssetAmount: new BigNumber(113),
|
||||||
takerAssetAmount: new BigNumber(200),
|
takerAssetAmount: new BigNumber(200),
|
||||||
takerFee: new BigNumber(11),
|
takerFee: new BigNumber(11),
|
||||||
|
chainId,
|
||||||
});
|
});
|
||||||
allFeeOrdersAndFillableAmounts = {
|
allFeeOrdersAndFillableAmounts = {
|
||||||
orders: [smallFeeOrder, largeFeeOrder],
|
orders: [smallFeeOrder, largeFeeOrder],
|
||||||
@@ -133,6 +138,7 @@ describe('buyQuoteCalculator', () => {
|
|||||||
makerAssetAmount: new BigNumber(123),
|
makerAssetAmount: new BigNumber(123),
|
||||||
takerAssetAmount: new BigNumber(100),
|
takerAssetAmount: new BigNumber(100),
|
||||||
takerFee: new BigNumber(200),
|
takerFee: new BigNumber(200),
|
||||||
|
chainId,
|
||||||
});
|
});
|
||||||
const completelyFillableOrdersAndFillableAmount: OrdersAndFillableAmounts = {
|
const completelyFillableOrdersAndFillableAmount: OrdersAndFillableAmounts = {
|
||||||
orders: [completelyFillableOrder],
|
orders: [completelyFillableOrder],
|
||||||
@@ -155,6 +161,7 @@ describe('buyQuoteCalculator', () => {
|
|||||||
makerAssetAmount: new BigNumber(1),
|
makerAssetAmount: new BigNumber(1),
|
||||||
takerAssetAmount: new BigNumber(1),
|
takerAssetAmount: new BigNumber(1),
|
||||||
takerFee: new BigNumber(0),
|
takerFee: new BigNumber(0),
|
||||||
|
chainId,
|
||||||
});
|
});
|
||||||
const errorFunction = () => {
|
const errorFunction = () => {
|
||||||
buyQuoteCalculator.calculate(
|
buyQuoteCalculator.calculate(
|
||||||
@@ -173,6 +180,7 @@ describe('buyQuoteCalculator', () => {
|
|||||||
makerAssetAmount: new BigNumber(1),
|
makerAssetAmount: new BigNumber(1),
|
||||||
takerAssetAmount: new BigNumber(1),
|
takerAssetAmount: new BigNumber(1),
|
||||||
takerFee: new BigNumber(0),
|
takerFee: new BigNumber(0),
|
||||||
|
chainId,
|
||||||
});
|
});
|
||||||
const errorFunction = () => {
|
const errorFunction = () => {
|
||||||
buyQuoteCalculator.calculate(
|
buyQuoteCalculator.calculate(
|
||||||
|
@@ -82,10 +82,8 @@ describe('ExchangeSwapQuoteConsumer', () => {
|
|||||||
takerAssetData,
|
takerAssetData,
|
||||||
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(contractAddresses.zrxToken),
|
makerFeeAssetData: assetDataUtils.encodeERC20AssetData(contractAddresses.zrxToken),
|
||||||
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(contractAddresses.zrxToken),
|
takerFeeAssetData: assetDataUtils.encodeERC20AssetData(contractAddresses.zrxToken),
|
||||||
domain: {
|
exchangeAddress: contractAddresses.exchange,
|
||||||
verifyingContract: contractAddresses.exchange,
|
chainId: networkId,
|
||||||
chainId: networkId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
const privateKey = devConstants.TESTRPC_PRIVATE_KEYS[userAddresses.indexOf(makerAddress)];
|
const privateKey = devConstants.TESTRPC_PRIVATE_KEYS[userAddresses.indexOf(makerAddress)];
|
||||||
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
||||||
|
@@ -12,8 +12,11 @@
|
|||||||
"salt": "1532559225",
|
"salt": "1532559225",
|
||||||
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
|
"makerFeeAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
|
"takerFeeAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||||
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
|
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33",
|
||||||
|
"chainId": 1
|
||||||
},
|
},
|
||||||
"metaData": {}
|
"metaData": {}
|
||||||
}
|
}
|
||||||
|
@@ -14,8 +14,11 @@ export const orderResponse = {
|
|||||||
salt: new BigNumber('1532559225'),
|
salt: new BigNumber('1532559225'),
|
||||||
makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
|
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
|
takerFeeAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||||
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
||||||
|
chainId: 1,
|
||||||
},
|
},
|
||||||
metaData: {},
|
metaData: {},
|
||||||
};
|
};
|
||||||
|
@@ -18,8 +18,11 @@
|
|||||||
"salt": "1532559225",
|
"salt": "1532559225",
|
||||||
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
|
"makerFeeAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
|
"takerFeeAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||||
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
|
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33",
|
||||||
|
"chainId": 1
|
||||||
},
|
},
|
||||||
"metaData": {}
|
"metaData": {}
|
||||||
}
|
}
|
||||||
@@ -44,8 +47,11 @@
|
|||||||
"salt": "1532559225",
|
"salt": "1532559225",
|
||||||
"makerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
"makerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
"takerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
"takerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
|
"makerFeeAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
|
"takerFeeAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||||
"signature": "0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891"
|
"signature": "0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891",
|
||||||
|
"chainId": 1
|
||||||
},
|
},
|
||||||
"metaData": {}
|
"metaData": {}
|
||||||
}
|
}
|
||||||
|
@@ -25,10 +25,8 @@ export const orderbookResponse: OrderbookResponse = {
|
|||||||
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
takerFeeAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
takerFeeAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
||||||
domain: {
|
chainId: 1,
|
||||||
chainId: 1,
|
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||||
verifyingContract: '0x12459c951127e0c374ff9105dda097662a027093',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
metaData: {},
|
metaData: {},
|
||||||
},
|
},
|
||||||
@@ -56,10 +54,8 @@ export const orderbookResponse: OrderbookResponse = {
|
|||||||
makerFeeAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
makerFeeAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
signature: '0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891',
|
signature: '0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891',
|
||||||
domain: {
|
chainId: 1,
|
||||||
chainId: 1,
|
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||||
verifyingContract: '0x12459c951127e0c374ff9105dda097662a027093',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
metaData: {},
|
metaData: {},
|
||||||
},
|
},
|
||||||
|
@@ -17,8 +17,11 @@
|
|||||||
"salt": "1532559225",
|
"salt": "1532559225",
|
||||||
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
|
"makerFeeAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
|
"takerFeeAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||||
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
|
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33",
|
||||||
|
"chainId": 1
|
||||||
},
|
},
|
||||||
"metaData": {}
|
"metaData": {}
|
||||||
}
|
}
|
||||||
|
@@ -24,10 +24,8 @@ export const ordersResponse: OrdersResponse = {
|
|||||||
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
takerFeeAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
takerFeeAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
||||||
domain: {
|
chainId: 1,
|
||||||
chainId: 1,
|
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||||
verifyingContract: '0x12459c951127e0c374ff9105dda097662a027093',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
metaData: {},
|
metaData: {},
|
||||||
},
|
},
|
||||||
|
@@ -39,8 +39,8 @@ describe('ABI Decoding Calldata', () => {
|
|||||||
const [privateKeyLeft, privateKeyRight] = constants.TESTRPC_PRIVATE_KEYS;
|
const [privateKeyLeft, privateKeyRight] = constants.TESTRPC_PRIVATE_KEYS;
|
||||||
const exchangeAddress = addressUtils.generatePseudoRandomAddress();
|
const exchangeAddress = addressUtils.generatePseudoRandomAddress();
|
||||||
const feeRecipientAddress = addressUtils.generatePseudoRandomAddress();
|
const feeRecipientAddress = addressUtils.generatePseudoRandomAddress();
|
||||||
const domain = {
|
const domainInfo = {
|
||||||
verifyingContract: exchangeAddress,
|
exchangeAddress,
|
||||||
chainId,
|
chainId,
|
||||||
};
|
};
|
||||||
// Create orders to match.
|
// Create orders to match.
|
||||||
@@ -78,9 +78,9 @@ describe('ABI Decoding Calldata', () => {
|
|||||||
salt: new BigNumber(50010),
|
salt: new BigNumber(50010),
|
||||||
};
|
};
|
||||||
const orderFactoryLeft = new OrderFactory(privateKeyLeft, orderLeft);
|
const orderFactoryLeft = new OrderFactory(privateKeyLeft, orderLeft);
|
||||||
signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ domain });
|
signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync(domainInfo);
|
||||||
const orderFactoryRight = new OrderFactory(privateKeyRight, orderRight);
|
const orderFactoryRight = new OrderFactory(privateKeyRight, orderRight);
|
||||||
signedOrderRight = await orderFactoryRight.newSignedOrderAsync({ domain });
|
signedOrderRight = await orderFactoryRight.newSignedOrderAsync(domainInfo);
|
||||||
// Encode match orders transaction
|
// Encode match orders transaction
|
||||||
contractAddresses = await migrateOnceAsync();
|
contractAddresses = await migrateOnceAsync();
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
|
@@ -101,10 +101,8 @@ describe.skip('CoordinatorWrapper', () => {
|
|||||||
makerFeeAssetData: feeAssetData,
|
makerFeeAssetData: feeAssetData,
|
||||||
takerFeeAssetData: feeAssetData,
|
takerFeeAssetData: feeAssetData,
|
||||||
senderAddress: contractAddresses.coordinator,
|
senderAddress: contractAddresses.coordinator,
|
||||||
domain: {
|
exchangeAddress: exchangeContractAddress,
|
||||||
verifyingContract: exchangeContractAddress,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
const privateKey = constants.TESTRPC_PRIVATE_KEYS[userAddresses.indexOf(makerAddress)];
|
const privateKey = constants.TESTRPC_PRIVATE_KEYS[userAddresses.indexOf(makerAddress)];
|
||||||
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { DummyERC20TokenContract, DummyERC721TokenContract, ExchangeContract } from '@0x/abi-gen-wrappers';
|
import { DummyERC20TokenContract, DummyERC721TokenContract, ExchangeContract } from '@0x/abi-gen-wrappers';
|
||||||
import { assetDataUtils } from '@0x/order-utils';
|
import { assetDataUtils } from '@0x/order-utils';
|
||||||
import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
|
import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
|
||||||
import { OrderWithoutDomain, SignedOrder } from '@0x/types';
|
import { Order, SignedOrder } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { SupportedProvider } from 'ethereum-types';
|
import { SupportedProvider } from 'ethereum-types';
|
||||||
@@ -124,15 +124,15 @@ export class FillScenarios {
|
|||||||
fillableAmount,
|
fillableAmount,
|
||||||
);
|
);
|
||||||
const exchangeInstance = new ExchangeContract(
|
const exchangeInstance = new ExchangeContract(
|
||||||
signedOrder.domain.verifyingContract,
|
signedOrder.exchangeAddress,
|
||||||
this._web3Wrapper.getProvider(),
|
this._web3Wrapper.getProvider(),
|
||||||
this._web3Wrapper.getContractDefaults(),
|
this._web3Wrapper.getContractDefaults(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const orderWithoutDomain = _.omit(signedOrder, ['signature', 'domain']) as OrderWithoutDomain;
|
const order = _.omit(signedOrder, ['signature']) as Order;
|
||||||
|
|
||||||
const txHash = await exchangeInstance.fillOrder.sendTransactionAsync(
|
const txHash = await exchangeInstance.fillOrder.sendTransactionAsync(
|
||||||
orderWithoutDomain,
|
order,
|
||||||
partialFillAmount,
|
partialFillAmount,
|
||||||
signedOrder.signature,
|
signedOrder.signature,
|
||||||
{ from: takerAddress },
|
{ from: takerAddress },
|
||||||
|
@@ -1,21 +1,54 @@
|
|||||||
{
|
{
|
||||||
"id": "/orderSchema",
|
"id": "/orderSchema",
|
||||||
"properties": {
|
"properties": {
|
||||||
"makerAddress": { "$ref": "/addressSchema" },
|
"makerAddress": {
|
||||||
"takerAddress": { "$ref": "/addressSchema" },
|
"$ref": "/addressSchema"
|
||||||
"makerFee": { "$ref": "/wholeNumberSchema" },
|
},
|
||||||
"takerFee": { "$ref": "/wholeNumberSchema" },
|
"takerAddress": {
|
||||||
"senderAddress": { "$ref": "/addressSchema" },
|
"$ref": "/addressSchema"
|
||||||
"makerAssetAmount": { "$ref": "/wholeNumberSchema" },
|
},
|
||||||
"takerAssetAmount": { "$ref": "/wholeNumberSchema" },
|
"makerFee": {
|
||||||
"makerAssetData": { "$ref": "/hexSchema" },
|
"$ref": "/wholeNumberSchema"
|
||||||
"takerAssetData": { "$ref": "/hexSchema" },
|
},
|
||||||
"makerFeeAssetData": { "$ref": "/hexSchema" },
|
"takerFee": {
|
||||||
"takerFeeAssetData": { "$ref": "/hexSchema" },
|
"$ref": "/wholeNumberSchema"
|
||||||
"salt": { "$ref": "/wholeNumberSchema" },
|
},
|
||||||
"feeRecipientAddress": { "$ref": "/addressSchema" },
|
"senderAddress": {
|
||||||
"expirationTimeSeconds": { "$ref": "/wholeNumberSchema" },
|
"$ref": "/addressSchema"
|
||||||
"domain": { "$ref": "/eip712DomainSchema" }
|
},
|
||||||
|
"makerAssetAmount": {
|
||||||
|
"$ref": "/wholeNumberSchema"
|
||||||
|
},
|
||||||
|
"takerAssetAmount": {
|
||||||
|
"$ref": "/wholeNumberSchema"
|
||||||
|
},
|
||||||
|
"makerAssetData": {
|
||||||
|
"$ref": "/hexSchema"
|
||||||
|
},
|
||||||
|
"takerAssetData": {
|
||||||
|
"$ref": "/hexSchema"
|
||||||
|
},
|
||||||
|
"makerFeeAssetData": {
|
||||||
|
"$ref": "/hexSchema"
|
||||||
|
},
|
||||||
|
"takerFeeAssetData": {
|
||||||
|
"$ref": "/hexSchema"
|
||||||
|
},
|
||||||
|
"salt": {
|
||||||
|
"$ref": "/wholeNumberSchema"
|
||||||
|
},
|
||||||
|
"feeRecipientAddress": {
|
||||||
|
"$ref": "/addressSchema"
|
||||||
|
},
|
||||||
|
"expirationTimeSeconds": {
|
||||||
|
"$ref": "/wholeNumberSchema"
|
||||||
|
},
|
||||||
|
"chainId": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"exchangeAddress": {
|
||||||
|
"$ref": "/addressSchema"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"makerAddress",
|
"makerAddress",
|
||||||
@@ -32,7 +65,8 @@
|
|||||||
"salt",
|
"salt",
|
||||||
"feeRecipientAddress",
|
"feeRecipientAddress",
|
||||||
"expirationTimeSeconds",
|
"expirationTimeSeconds",
|
||||||
"domain"
|
"chainId",
|
||||||
|
"exchangeAddress"
|
||||||
],
|
],
|
||||||
"type": "object"
|
"type": "object"
|
||||||
}
|
}
|
||||||
|
@@ -219,10 +219,8 @@ describe('Schema', () => {
|
|||||||
salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500',
|
salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500',
|
||||||
feeRecipientAddress: NULL_ADDRESS,
|
feeRecipientAddress: NULL_ADDRESS,
|
||||||
expirationTimeSeconds: '42',
|
expirationTimeSeconds: '42',
|
||||||
domain: {
|
exchangeAddress: NULL_ADDRESS,
|
||||||
verifyingContract: NULL_ADDRESS,
|
chainId: CHAIN_ID,
|
||||||
chainId: CHAIN_ID,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
const relayerApiOrder = {
|
const relayerApiOrder = {
|
||||||
order,
|
order,
|
||||||
|
@@ -296,7 +296,7 @@ export const assetDataUtils = {
|
|||||||
throw new Error(
|
throw new Error(
|
||||||
`Could not decode assetData. Expected length of encoded data to be at least 10. Got ${
|
`Could not decode assetData. Expected length of encoded data to be at least 10. Got ${
|
||||||
assetData.length
|
assetData.length
|
||||||
}`,
|
} for assetData ${assetData}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const assetProxyId = assetData.slice(0, constants.SELECTOR_CHAR_LENGTH_WITH_PREFIX);
|
const assetProxyId = assetData.slice(0, constants.SELECTOR_CHAR_LENGTH_WITH_PREFIX);
|
||||||
|
@@ -59,11 +59,17 @@ export const eip712Utils = {
|
|||||||
const normalizedOrder = _.mapValues(order, value => {
|
const normalizedOrder = _.mapValues(order, value => {
|
||||||
return !_.isString(value) ? value.toString() : value;
|
return !_.isString(value) ? value.toString() : value;
|
||||||
});
|
});
|
||||||
|
const partialDomain = {
|
||||||
|
chainId: order.chainId,
|
||||||
|
verifyingContract: order.exchangeAddress,
|
||||||
|
};
|
||||||
|
// Since we are passing in the EXCHANGE_ORDER_SCHEMA
|
||||||
|
// order paramaters that are not in there get ignored at hashing time
|
||||||
const typedData = eip712Utils.createTypedData(
|
const typedData = eip712Utils.createTypedData(
|
||||||
constants.EXCHANGE_ORDER_SCHEMA.name,
|
constants.EXCHANGE_ORDER_SCHEMA.name,
|
||||||
{ Order: constants.EXCHANGE_ORDER_SCHEMA.parameters },
|
{ Order: constants.EXCHANGE_ORDER_SCHEMA.parameters },
|
||||||
normalizedOrder,
|
normalizedOrder,
|
||||||
order.domain,
|
partialDomain,
|
||||||
);
|
);
|
||||||
return typedData;
|
return typedData;
|
||||||
},
|
},
|
||||||
|
@@ -52,10 +52,8 @@ export const orderFactory = {
|
|||||||
salt: createOrderOpts.salt || defaultCreateOrderOpts.salt,
|
salt: createOrderOpts.salt || defaultCreateOrderOpts.salt,
|
||||||
expirationTimeSeconds:
|
expirationTimeSeconds:
|
||||||
createOrderOpts.expirationTimeSeconds || defaultCreateOrderOpts.expirationTimeSeconds,
|
createOrderOpts.expirationTimeSeconds || defaultCreateOrderOpts.expirationTimeSeconds,
|
||||||
domain: {
|
exchangeAddress,
|
||||||
verifyingContract: exchangeAddress,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
return order;
|
return order;
|
||||||
},
|
},
|
||||||
@@ -87,7 +85,7 @@ export const orderFactory = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getChainIdFromPartial(partialOrder: Partial<Order> | Partial<SignedOrder>): number {
|
function getChainIdFromPartial(partialOrder: Partial<Order> | Partial<SignedOrder>): number {
|
||||||
const chainId: number = _.get(partialOrder, ['domain', 'chainId']);
|
const chainId = partialOrder.chainId;
|
||||||
if (!_.isNumber(chainId)) {
|
if (!_.isNumber(chainId)) {
|
||||||
throw new Error('chainId must be valid');
|
throw new Error('chainId must be valid');
|
||||||
}
|
}
|
||||||
@@ -117,10 +115,8 @@ function generateEmptyOrder(chainId: number): Order {
|
|||||||
salt: generatePseudoRandomSalt(),
|
salt: generatePseudoRandomSalt(),
|
||||||
feeRecipientAddress: constants.NULL_ADDRESS,
|
feeRecipientAddress: constants.NULL_ADDRESS,
|
||||||
expirationTimeSeconds: constants.INFINITE_TIMESTAMP_SEC,
|
expirationTimeSeconds: constants.INFINITE_TIMESTAMP_SEC,
|
||||||
domain: {
|
exchangeAddress: constants.NULL_ADDRESS,
|
||||||
verifyingContract: constants.NULL_ADDRESS,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,10 +32,8 @@ describe('Order hashing', () => {
|
|||||||
makerAssetAmount: new BigNumber(0),
|
makerAssetAmount: new BigNumber(0),
|
||||||
takerAssetAmount: new BigNumber(0),
|
takerAssetAmount: new BigNumber(0),
|
||||||
expirationTimeSeconds: new BigNumber(0),
|
expirationTimeSeconds: new BigNumber(0),
|
||||||
domain: {
|
exchangeAddress: fakeExchangeContractAddress,
|
||||||
verifyingContract: fakeExchangeContractAddress,
|
chainId: fakeChainID,
|
||||||
chainId: fakeChainID,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
it('calculates the order hash', async () => {
|
it('calculates the order hash', async () => {
|
||||||
const orderHash = orderHashUtils.getOrderHashHex(order);
|
const orderHash = orderHashUtils.getOrderHashHex(order);
|
||||||
|
@@ -59,10 +59,8 @@ describe('RemainingFillableCalculator', () => {
|
|||||||
takerFeeAssetData,
|
takerFeeAssetData,
|
||||||
salt: zero,
|
salt: zero,
|
||||||
expirationTimeSeconds: zero,
|
expirationTimeSeconds: zero,
|
||||||
domain: {
|
exchangeAddress: zeroAddress,
|
||||||
verifyingContract: zeroAddress,
|
chainId,
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
describe('Maker asset is not fee asset', () => {
|
describe('Maker asset is not fee asset', () => {
|
||||||
|
@@ -41,10 +41,8 @@ describe('Signature utils', () => {
|
|||||||
makerAssetAmount: new BigNumber(0),
|
makerAssetAmount: new BigNumber(0),
|
||||||
takerAssetAmount: new BigNumber(0),
|
takerAssetAmount: new BigNumber(0),
|
||||||
expirationTimeSeconds: new BigNumber(0),
|
expirationTimeSeconds: new BigNumber(0),
|
||||||
domain: {
|
exchangeAddress: fakeExchangeContractAddress,
|
||||||
verifyingContract: fakeExchangeContractAddress,
|
chainId: fakeChainId,
|
||||||
chainId: fakeChainId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
transaction = {
|
transaction = {
|
||||||
domain: {
|
domain: {
|
||||||
|
@@ -10,12 +10,15 @@ describe('Utils', () => {
|
|||||||
takerAddress: '0x0000000000000000000000000000000000000000',
|
takerAddress: '0x0000000000000000000000000000000000000000',
|
||||||
takerAssetData: '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
takerAssetData: '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
takerAssetAmount: '1000000000000000061',
|
takerAssetAmount: '1000000000000000061',
|
||||||
|
makerFeeAssetData: '0xf47261b00000000000000000000000000f5d2fb29fb7d3cfee444a200298f468908cc942',
|
||||||
|
takerFeeAssetData: '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
takerFee: '0',
|
takerFee: '0',
|
||||||
senderAddress: '0x0000000000000000000000000000000000000000',
|
senderAddress: '0x0000000000000000000000000000000000000000',
|
||||||
exchangeAddress: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b',
|
exchangeAddress: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b',
|
||||||
feeRecipientAddress: '0xa258b39954cef5cb142fd567a46cddb31a670124',
|
feeRecipientAddress: '0xa258b39954cef5cb142fd567a46cddb31a670124',
|
||||||
expirationTimeSeconds: '1559422407',
|
expirationTimeSeconds: '1559422407',
|
||||||
salt: '1559422141994',
|
salt: '1559422141994',
|
||||||
|
chainId: 1,
|
||||||
signature:
|
signature:
|
||||||
'0x1cf16c2f3a210965b5e17f51b57b869ba4ddda33df92b0017b4d8da9dacd3152b122a73844eaf50ccde29a42950239ba36a525ed7f1698a8a5e1896cf7d651aed203',
|
'0x1cf16c2f3a210965b5e17f51b57b869ba4ddda33df92b0017b4d8da9dacd3152b122a73844eaf50ccde29a42950239ba36a525ed7f1698a8a5e1896cf7d651aed203',
|
||||||
};
|
};
|
||||||
@@ -23,7 +26,7 @@ describe('Utils', () => {
|
|||||||
const orderHash = utils.getOrderHash(order as any);
|
const orderHash = utils.getOrderHash(order as any);
|
||||||
const calculatedOrderHash = utils.getOrderHash({ order: order as any, metaData: {} });
|
const calculatedOrderHash = utils.getOrderHash({ order: order as any, metaData: {} });
|
||||||
expect(orderHash).toBe(calculatedOrderHash);
|
expect(orderHash).toBe(calculatedOrderHash);
|
||||||
expect(orderHash).toBe('0x96e6eb6174dbf0458686bdae44c9a330d9a9eb563962512a7be545c4ecc13fd4');
|
expect(orderHash).toBe('0x5a0f346c671a39b832a487d2d7eb63ca19301554cf1f8a98a19d478a3a8be32c');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('.attemptAsync', () => {
|
describe('.attemptAsync', () => {
|
||||||
|
@@ -10,10 +10,8 @@ export const createOrder = (makerAssetData: string, takerAssetData: string): API
|
|||||||
takerAssetData,
|
takerAssetData,
|
||||||
makerFeeAssetData: makerAssetData,
|
makerFeeAssetData: makerAssetData,
|
||||||
takerFeeAssetData: takerAssetData,
|
takerFeeAssetData: takerAssetData,
|
||||||
domain: {
|
chainId: 0,
|
||||||
chainId: 0,
|
exchangeAddress: '0x00',
|
||||||
verifyingContract: '0x00',
|
|
||||||
},
|
|
||||||
senderAddress: '0x00',
|
senderAddress: '0x00',
|
||||||
makerAssetAmount: new BigNumber(1),
|
makerAssetAmount: new BigNumber(1),
|
||||||
takerAssetAmount: new BigNumber(1),
|
takerAssetAmount: new BigNumber(1),
|
||||||
|
@@ -182,10 +182,8 @@ export class Handler {
|
|||||||
// tslint:disable-next-line:custom-no-magic-numbers
|
// tslint:disable-next-line:custom-no-magic-numbers
|
||||||
.div(1000)
|
.div(1000)
|
||||||
.integerValue(BigNumber.ROUND_FLOOR),
|
.integerValue(BigNumber.ROUND_FLOOR),
|
||||||
domain: {
|
exchangeAddress: networkConfig.contractWrappers.exchange.address,
|
||||||
verifyingContract: networkConfig.contractWrappers.exchange.address,
|
chainId: networkConfig.networkId,
|
||||||
chainId: networkConfig.networkId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
const orderHash = orderHashUtils.getOrderHashHex(order);
|
const orderHash = orderHashUtils.getOrderHashHex(order);
|
||||||
const signature = await signatureUtils.ecSignHashAsync(
|
const signature = await signatureUtils.ecSignHashAsync(
|
||||||
|
@@ -3,28 +3,9 @@
|
|||||||
import { BigNumber } from 'bignumber.js';
|
import { BigNumber } from 'bignumber.js';
|
||||||
import { ContractAbi, ContractNetworks, DevdocOutput } from 'ethereum-types';
|
import { ContractAbi, ContractNetworks, DevdocOutput } from 'ethereum-types';
|
||||||
|
|
||||||
// HACK: Rather then extending from OrderWithoutDomain
|
|
||||||
// we don't, because our docs don't expand inherited types, and it's unnecessarily
|
|
||||||
// confusing to introduce the user to the OrderWithoutDomain type.
|
|
||||||
export interface Order {
|
export interface Order {
|
||||||
domain: EIP712DomainWithDefaultSchema;
|
chainId: number;
|
||||||
makerAddress: string;
|
exchangeAddress: string;
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
makerFeeAssetData: string;
|
|
||||||
takerFeeAssetData: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OrderWithoutDomain {
|
|
||||||
makerAddress: string;
|
makerAddress: string;
|
||||||
takerAddress: string;
|
takerAddress: string;
|
||||||
feeRecipientAddress: string;
|
feeRecipientAddress: string;
|
||||||
|
Reference in New Issue
Block a user