Merge branch 'development' into feature/website/add-Lawrence-change-Mel-role-change-Alex-Browne-role
This commit is contained in:
@@ -200,7 +200,7 @@ jobs:
|
|||||||
docker:
|
docker:
|
||||||
- image: circleci/python
|
- image: circleci/python
|
||||||
- image: 0xorg/ganache-cli:2.2.2
|
- image: 0xorg/ganache-cli:2.2.2
|
||||||
- image: 0xorg/launch-kit-ci
|
- image: 0xorg/launch-kit-ci:0.0.1
|
||||||
command: |
|
command: |
|
||||||
yarn start:ts -p 3000:3000
|
yarn start:ts -p 3000:3000
|
||||||
steps:
|
steps:
|
||||||
|
@@ -1,11 +1,17 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "2.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
|
||||||
"note": "Set evmVersion to byzantium",
|
|
||||||
"pr": 1678
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"note": "Do not reexport external dependencies",
|
"note": "Do not reexport external dependencies",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
@@ -17,8 +23,13 @@
|
|||||||
{
|
{
|
||||||
"note": "Bumped solidity version to ^0.5.5",
|
"note": "Bumped solidity version to ^0.5.5",
|
||||||
"pr": 1701
|
"pr": 1701
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Integration testing for ERC1155Proxy",
|
||||||
|
"pr": 1673
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
|
@@ -5,6 +5,17 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v2.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v2.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Do not reexport external dependencies (#1682)
|
||||||
|
* Add ERC1155Proxy (#1661)
|
||||||
|
* Bumped solidity version to ^0.5.5 (#1701)
|
||||||
|
* Integration testing for ERC1155Proxy (#1673)
|
||||||
|
|
||||||
## v1.0.9 - _March 1, 2019_
|
## v1.0.9 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"isOfflineMode": false,
|
"isOfflineMode": false,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
|
@@ -26,7 +26,7 @@ contract ERC1155Proxy is
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Id of this proxy.
|
// Id of this proxy.
|
||||||
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC1155Token(address,uint256[],uint256[],bytes)"));
|
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC1155Assets(address,uint256[],uint256[],bytes)"));
|
||||||
|
|
||||||
function ()
|
function ()
|
||||||
external
|
external
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-asset-proxy",
|
"name": "@0x/contracts-asset-proxy",
|
||||||
"version": "1.0.9",
|
"version": "2.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -67,17 +67,17 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-erc20": "^1.0.9",
|
"@0x/contracts-erc1155": "^1.1.0",
|
||||||
"@0x/contracts-erc721": "^1.0.9",
|
"@0x/contracts-erc20": "^2.1.0",
|
||||||
"@0x/contracts-erc1155": "^1.0.0",
|
"@0x/contracts-erc721": "^2.1.0",
|
||||||
"@0x/contracts-utils": "^2.0.8",
|
"@0x/contracts-utils": "^3.1.0",
|
||||||
"@0x/order-utils": "^7.0.2",
|
"@0x/order-utils": "^7.1.1",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@@ -15,7 +15,7 @@ import {
|
|||||||
web3Wrapper,
|
web3Wrapper,
|
||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
import { RevertReason } from '@0x/types';
|
import { AssetProxyId, RevertReason } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||||
@@ -123,8 +123,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
});
|
});
|
||||||
it('should have an id of 0x9645780d', async () => {
|
it('should have an id of 0x9645780d', async () => {
|
||||||
const proxyId = await erc1155Proxy.getProxyId.callAsync();
|
const proxyId = await erc1155Proxy.getProxyId.callAsync();
|
||||||
// proxy computed using -- bytes4(keccak256("erc1155Token(address,uint256[],uint256[],bytes)"));
|
const expectedProxyId = AssetProxyId.ERC1155;
|
||||||
const expectedProxyId = '0x9645780d';
|
|
||||||
expect(proxyId).to.equal(expectedProxyId);
|
expect(proxyId).to.equal(expectedProxyId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -433,6 +432,50 @@ describe('ERC1155Proxy', () => {
|
|||||||
];
|
];
|
||||||
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
});
|
});
|
||||||
|
it('should successfully transfer value to a smart contract and trigger its callback, when callback `data` is NULL', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const tokenHolders = [spender, receiverContract];
|
||||||
|
const tokensToTransfer = fungibleTokens.slice(0, 1);
|
||||||
|
const valuesToTransfer = [fungibleValueToTransferLarge];
|
||||||
|
const valueMultiplier = valueMultiplierSmall;
|
||||||
|
const totalValuesTransferred = _.map(valuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(valueMultiplier);
|
||||||
|
});
|
||||||
|
// check balances before transfer
|
||||||
|
const expectedInitialBalances = [spenderInitialFungibleBalance, receiverContractInitialFungibleBalance];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// execute transfer
|
||||||
|
const nullReceiverCallbackData = '0x';
|
||||||
|
const txReceipt = await erc1155ProxyWrapper.transferFromWithLogsAsync(
|
||||||
|
spender,
|
||||||
|
receiverContract,
|
||||||
|
erc1155Contract.address,
|
||||||
|
tokensToTransfer,
|
||||||
|
valuesToTransfer,
|
||||||
|
valueMultiplier,
|
||||||
|
nullReceiverCallbackData,
|
||||||
|
authorized,
|
||||||
|
);
|
||||||
|
// check receiver log ignored extra asset data
|
||||||
|
expect(txReceipt.logs.length).to.be.equal(2);
|
||||||
|
const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs<
|
||||||
|
DummyERC1155ReceiverBatchTokenReceivedEventArgs
|
||||||
|
>;
|
||||||
|
expect(receiverLog.args.operator).to.be.equal(erc1155Proxy.address);
|
||||||
|
expect(receiverLog.args.from).to.be.equal(spender);
|
||||||
|
expect(receiverLog.args.tokenIds.length).to.be.deep.equal(1);
|
||||||
|
expect(receiverLog.args.tokenIds[0]).to.be.bignumber.equal(tokensToTransfer[0]);
|
||||||
|
expect(receiverLog.args.tokenValues.length).to.be.deep.equal(1);
|
||||||
|
expect(receiverLog.args.tokenValues[0]).to.be.bignumber.equal(totalValuesTransferred[0]);
|
||||||
|
// note - if the `extraData` is ignored then the receiver log should ignore it as well.
|
||||||
|
expect(receiverLog.args.data).to.be.deep.equal(nullReceiverCallbackData);
|
||||||
|
// check balances after transfer
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
expectedInitialBalances[0].minus(totalValuesTransferred[0]),
|
||||||
|
expectedInitialBalances[1].plus(totalValuesTransferred[0]),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
});
|
||||||
it('should successfully transfer value and ignore extra assetData', async () => {
|
it('should successfully transfer value and ignore extra assetData', async () => {
|
||||||
// setup test parameters
|
// setup test parameters
|
||||||
const tokenHolders = [spender, receiverContract];
|
const tokenHolders = [spender, receiverContract];
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { ERC1155MintableContract, Erc1155Wrapper } from '@0x/contracts-erc1155';
|
||||||
import {
|
import {
|
||||||
artifacts as erc20Artifacts,
|
artifacts as erc20Artifacts,
|
||||||
DummyERC20TokenContract,
|
DummyERC20TokenContract,
|
||||||
@@ -30,6 +31,7 @@ import * as _ from 'lodash';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
artifacts,
|
artifacts,
|
||||||
|
ERC1155ProxyWrapper,
|
||||||
ERC20ProxyContract,
|
ERC20ProxyContract,
|
||||||
ERC20Wrapper,
|
ERC20Wrapper,
|
||||||
ERC721ProxyContract,
|
ERC721ProxyContract,
|
||||||
@@ -77,6 +79,15 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
let erc721AFromTokenId: BigNumber;
|
let erc721AFromTokenId: BigNumber;
|
||||||
let erc721BFromTokenId: BigNumber;
|
let erc721BFromTokenId: BigNumber;
|
||||||
|
|
||||||
|
let erc1155Proxy: ERC721ProxyContract;
|
||||||
|
let erc1155ProxyWrapper: ERC1155ProxyWrapper;
|
||||||
|
let erc1155Contract: ERC1155MintableContract;
|
||||||
|
let erc1155Contract2: ERC1155MintableContract;
|
||||||
|
let erc1155Wrapper: Erc1155Wrapper;
|
||||||
|
let erc1155Wrapper2: Erc1155Wrapper;
|
||||||
|
let erc1155FungibleTokens: BigNumber[];
|
||||||
|
let erc1155NonFungibleTokensOwnedBySpender: BigNumber[];
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
});
|
});
|
||||||
@@ -127,6 +138,22 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Configure ERC115Proxy
|
||||||
|
erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner);
|
||||||
|
erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync();
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await erc1155Proxy.addAuthorizedAddress.sendTransactionAsync(authorized, {
|
||||||
|
from: owner,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await erc1155Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, {
|
||||||
|
from: owner,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
|
||||||
// Configure MultiAssetProxy
|
// Configure MultiAssetProxy
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await multiAssetProxy.addAuthorizedAddress.sendTransactionAsync(authorized, {
|
await multiAssetProxy.addAuthorizedAddress.sendTransactionAsync(authorized, {
|
||||||
@@ -146,6 +173,12 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
}),
|
}),
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await multiAssetProxy.registerAssetProxy.sendTransactionAsync(erc1155Proxy.address, {
|
||||||
|
from: owner,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
|
||||||
// Deploy and configure ERC20 tokens
|
// Deploy and configure ERC20 tokens
|
||||||
const numDummyErc20ToDeploy = 2;
|
const numDummyErc20ToDeploy = 2;
|
||||||
@@ -213,6 +246,22 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
const erc721Balances = await erc721Wrapper.getBalancesAsync();
|
const erc721Balances = await erc721Wrapper.getBalancesAsync();
|
||||||
erc721AFromTokenId = erc721Balances[fromAddress][erc721TokenA.address][0];
|
erc721AFromTokenId = erc721Balances[fromAddress][erc721TokenA.address][0];
|
||||||
erc721BFromTokenId = erc721Balances[fromAddress][erc721TokenB.address][0];
|
erc721BFromTokenId = erc721Balances[fromAddress][erc721TokenB.address][0];
|
||||||
|
|
||||||
|
// Deploy & configure ERC1155 tokens and receiver
|
||||||
|
[erc1155Wrapper, erc1155Wrapper2] = await erc1155ProxyWrapper.deployDummyContractsAsync();
|
||||||
|
erc1155Contract = erc1155Wrapper.getContract();
|
||||||
|
erc1155Contract2 = erc1155Wrapper2.getContract();
|
||||||
|
await erc1155ProxyWrapper.setBalancesAndAllowancesAsync();
|
||||||
|
erc1155FungibleTokens = erc1155ProxyWrapper.getFungibleTokenIds();
|
||||||
|
const nonFungibleTokens = erc1155ProxyWrapper.getNonFungibleTokenIds();
|
||||||
|
const tokenBalances = await erc1155ProxyWrapper.getBalancesAsync();
|
||||||
|
erc1155NonFungibleTokensOwnedBySpender = [];
|
||||||
|
_.each(nonFungibleTokens, (nonFungibleToken: BigNumber) => {
|
||||||
|
const nonFungibleTokenAsString = nonFungibleToken.toString();
|
||||||
|
const nonFungibleTokenHeldBySpender =
|
||||||
|
tokenBalances.nonFungible[fromAddress][erc1155Contract.address][nonFungibleTokenAsString][0];
|
||||||
|
erc1155NonFungibleTokensOwnedBySpender.push(nonFungibleTokenHeldBySpender);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
@@ -944,6 +993,314 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
expect(newOwnerFromAsset1).to.be.equal(toAddress);
|
expect(newOwnerFromAsset1).to.be.equal(toAddress);
|
||||||
expect(newOwnerFromAsset2).to.be.equal(toAddress);
|
expect(newOwnerFromAsset2).to.be.equal(toAddress);
|
||||||
});
|
});
|
||||||
|
it('should transfer a fungible ERC1155 token', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const tokenHolders = [fromAddress, toAddress];
|
||||||
|
const tokensToTransfer = erc1155FungibleTokens.slice(0, 1);
|
||||||
|
const valuesToTransfer = [new BigNumber(25)];
|
||||||
|
const valueMultiplier = new BigNumber(23);
|
||||||
|
const receiverCallbackData = '0x0102030405';
|
||||||
|
// check balances before transfer
|
||||||
|
const expectedInitialBalances = [
|
||||||
|
// from
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// to
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// encode erc1155 asset data
|
||||||
|
const erc1155AssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
tokensToTransfer,
|
||||||
|
valuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
// encode multi-asset data
|
||||||
|
const multiAssetAmount = new BigNumber(5);
|
||||||
|
const amounts = [valueMultiplier];
|
||||||
|
const nestedAssetData = [erc1155AssetData];
|
||||||
|
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||||
|
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||||
|
assetData,
|
||||||
|
fromAddress,
|
||||||
|
toAddress,
|
||||||
|
multiAssetAmount,
|
||||||
|
);
|
||||||
|
// execute transfer
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await web3Wrapper.sendTransactionAsync({
|
||||||
|
to: multiAssetProxy.address,
|
||||||
|
data,
|
||||||
|
from: authorized,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
// check balances
|
||||||
|
const totalValueTransferred = valuesToTransfer[0].times(valueMultiplier).times(multiAssetAmount);
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
// from
|
||||||
|
expectedInitialBalances[0].minus(totalValueTransferred),
|
||||||
|
// to
|
||||||
|
expectedInitialBalances[1].plus(totalValueTransferred),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
});
|
||||||
|
it('should successfully transfer multiple fungible tokens of the same ERC1155 contract', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const tokenHolders = [fromAddress, toAddress];
|
||||||
|
const tokensToTransfer = erc1155FungibleTokens.slice(0, 3);
|
||||||
|
const valuesToTransfer = [new BigNumber(25), new BigNumber(35), new BigNumber(45)];
|
||||||
|
const valueMultiplier = new BigNumber(23);
|
||||||
|
const receiverCallbackData = '0x0102030405';
|
||||||
|
// check balances before transfer
|
||||||
|
const expectedInitialBalances = [
|
||||||
|
// from
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// to
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// encode erc1155 asset data
|
||||||
|
const erc1155AssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
tokensToTransfer,
|
||||||
|
valuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
// encode multi-asset data
|
||||||
|
const multiAssetAmount = new BigNumber(5);
|
||||||
|
const amounts = [valueMultiplier];
|
||||||
|
const nestedAssetData = [erc1155AssetData];
|
||||||
|
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||||
|
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||||
|
assetData,
|
||||||
|
fromAddress,
|
||||||
|
toAddress,
|
||||||
|
multiAssetAmount,
|
||||||
|
);
|
||||||
|
// execute transfer
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await web3Wrapper.sendTransactionAsync({
|
||||||
|
to: multiAssetProxy.address,
|
||||||
|
data,
|
||||||
|
from: authorized,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
// check balances
|
||||||
|
const totalValuesTransferred = _.map(valuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(valueMultiplier).times(multiAssetAmount);
|
||||||
|
});
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
// from
|
||||||
|
expectedInitialBalances[0].minus(totalValuesTransferred[0]),
|
||||||
|
expectedInitialBalances[1].minus(totalValuesTransferred[1]),
|
||||||
|
expectedInitialBalances[2].minus(totalValuesTransferred[2]),
|
||||||
|
// to
|
||||||
|
expectedInitialBalances[3].plus(totalValuesTransferred[0]),
|
||||||
|
expectedInitialBalances[4].plus(totalValuesTransferred[1]),
|
||||||
|
expectedInitialBalances[5].plus(totalValuesTransferred[2]),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
});
|
||||||
|
it('should successfully transfer multiple fungible/non-fungible tokens of the same ERC1155 contract', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const tokenHolders = [fromAddress, toAddress];
|
||||||
|
const fungibleTokensToTransfer = erc1155FungibleTokens.slice(0, 1);
|
||||||
|
const nonFungibleTokensToTransfer = erc1155NonFungibleTokensOwnedBySpender.slice(0, 1);
|
||||||
|
const tokensToTransfer = fungibleTokensToTransfer.concat(nonFungibleTokensToTransfer);
|
||||||
|
const valuesToTransfer = [new BigNumber(25), new BigNumber(1)];
|
||||||
|
const valueMultiplier = new BigNumber(1);
|
||||||
|
const receiverCallbackData = '0x0102030405';
|
||||||
|
// check balances before transfer
|
||||||
|
const nftOwnerBalance = new BigNumber(1);
|
||||||
|
const nftNotOwnerBalance = new BigNumber(0);
|
||||||
|
const expectedInitialBalances = [
|
||||||
|
// from
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
nftOwnerBalance,
|
||||||
|
// to
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
nftNotOwnerBalance,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// encode erc1155 asset data
|
||||||
|
const erc1155AssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
tokensToTransfer,
|
||||||
|
valuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
// encode multi-asset data
|
||||||
|
const multiAssetAmount = new BigNumber(1);
|
||||||
|
const amounts = [valueMultiplier];
|
||||||
|
const nestedAssetData = [erc1155AssetData];
|
||||||
|
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||||
|
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||||
|
assetData,
|
||||||
|
fromAddress,
|
||||||
|
toAddress,
|
||||||
|
multiAssetAmount,
|
||||||
|
);
|
||||||
|
// execute transfer
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await web3Wrapper.sendTransactionAsync({
|
||||||
|
to: multiAssetProxy.address,
|
||||||
|
data,
|
||||||
|
from: authorized,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
// check balances
|
||||||
|
const totalValuesTransferred = _.map(valuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(valueMultiplier).times(multiAssetAmount);
|
||||||
|
});
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
// from
|
||||||
|
expectedInitialBalances[0].minus(totalValuesTransferred[0]),
|
||||||
|
expectedInitialBalances[1].minus(totalValuesTransferred[1]),
|
||||||
|
// to
|
||||||
|
expectedInitialBalances[2].plus(totalValuesTransferred[0]),
|
||||||
|
expectedInitialBalances[3].plus(totalValuesTransferred[1]),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
});
|
||||||
|
it('should successfully transfer multiple different ERC1155 tokens', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const tokenHolders = [fromAddress, toAddress];
|
||||||
|
const tokensToTransfer = erc1155FungibleTokens.slice(0, 1);
|
||||||
|
const valuesToTransfer = [new BigNumber(25)];
|
||||||
|
const valueMultiplier = new BigNumber(23);
|
||||||
|
const receiverCallbackData = '0x0102030405';
|
||||||
|
// check balances before transfer
|
||||||
|
const expectedInitialBalances = [
|
||||||
|
// from
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// to
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
await erc1155Wrapper2.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// encode erc1155 asset data
|
||||||
|
const erc1155AssetData1 = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
tokensToTransfer,
|
||||||
|
valuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
const erc1155AssetData2 = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract2.address,
|
||||||
|
tokensToTransfer,
|
||||||
|
valuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
// encode multi-asset data
|
||||||
|
const multiAssetAmount = new BigNumber(5);
|
||||||
|
const amounts = [valueMultiplier, valueMultiplier];
|
||||||
|
const nestedAssetData = [erc1155AssetData1, erc1155AssetData2];
|
||||||
|
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||||
|
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||||
|
assetData,
|
||||||
|
fromAddress,
|
||||||
|
toAddress,
|
||||||
|
multiAssetAmount,
|
||||||
|
);
|
||||||
|
// execute transfer
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await web3Wrapper.sendTransactionAsync({
|
||||||
|
to: multiAssetProxy.address,
|
||||||
|
data,
|
||||||
|
from: authorized,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
// check balances
|
||||||
|
const totalValueTransferred = valuesToTransfer[0].times(valueMultiplier).times(multiAssetAmount);
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
// from
|
||||||
|
expectedInitialBalances[0].minus(totalValueTransferred),
|
||||||
|
// to
|
||||||
|
expectedInitialBalances[1].plus(totalValueTransferred),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
await erc1155Wrapper2.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
});
|
||||||
|
it('should successfully transfer a combination of ERC20, ERC721, and ERC1155 tokens', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const inputAmount = new BigNumber(1);
|
||||||
|
const erc20Amount = new BigNumber(10);
|
||||||
|
const erc20AssetData = assetDataUtils.encodeERC20AssetData(erc20TokenA.address);
|
||||||
|
const erc721Amount = new BigNumber(1);
|
||||||
|
const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId);
|
||||||
|
const erc1155TokenHolders = [fromAddress, toAddress];
|
||||||
|
const erc1155TokensToTransfer = erc1155FungibleTokens.slice(0, 1);
|
||||||
|
const erc1155ValuesToTransfer = [new BigNumber(25)];
|
||||||
|
const erc1155Amount = new BigNumber(23);
|
||||||
|
const erc1155ReceiverCallbackData = '0x0102030405';
|
||||||
|
const erc1155AssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
erc1155TokensToTransfer,
|
||||||
|
erc1155ValuesToTransfer,
|
||||||
|
erc1155ReceiverCallbackData,
|
||||||
|
);
|
||||||
|
const amounts = [erc20Amount, erc721Amount, erc1155Amount];
|
||||||
|
const nestedAssetData = [erc20AssetData, erc721AssetData, erc1155AssetData];
|
||||||
|
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||||
|
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||||
|
assetData,
|
||||||
|
fromAddress,
|
||||||
|
toAddress,
|
||||||
|
inputAmount,
|
||||||
|
);
|
||||||
|
// check balances before transfer
|
||||||
|
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||||
|
const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId);
|
||||||
|
expect(ownerFromAsset).to.be.equal(fromAddress);
|
||||||
|
const erc1155ExpectedInitialBalances = [
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(
|
||||||
|
erc1155TokenHolders,
|
||||||
|
erc1155TokensToTransfer,
|
||||||
|
erc1155ExpectedInitialBalances,
|
||||||
|
);
|
||||||
|
// execute transfer
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await web3Wrapper.sendTransactionAsync({
|
||||||
|
to: multiAssetProxy.address,
|
||||||
|
data,
|
||||||
|
from: authorized,
|
||||||
|
gas: 1000000,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
// check balances after transfer
|
||||||
|
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||||
|
const totalAmount = inputAmount.times(erc20Amount);
|
||||||
|
expect(newBalances[fromAddress][erc20TokenA.address]).to.be.bignumber.equal(
|
||||||
|
erc20Balances[fromAddress][erc20TokenA.address].minus(totalAmount),
|
||||||
|
);
|
||||||
|
expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal(
|
||||||
|
erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount),
|
||||||
|
);
|
||||||
|
const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId);
|
||||||
|
expect(newOwnerFromAsset).to.be.equal(toAddress);
|
||||||
|
const erc1155TotalValueTransferred = erc1155ValuesToTransfer[0].times(erc1155Amount).times(inputAmount);
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
erc1155ExpectedInitialBalances[0].minus(erc1155TotalValueTransferred),
|
||||||
|
erc1155ExpectedInitialBalances[1].plus(erc1155TotalValueTransferred),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(
|
||||||
|
erc1155TokenHolders,
|
||||||
|
erc1155TokensToTransfer,
|
||||||
|
expectedFinalBalances,
|
||||||
|
);
|
||||||
|
});
|
||||||
it('should successfully transfer a combination of ERC20 and ERC721 tokens', async () => {
|
it('should successfully transfer a combination of ERC20 and ERC721 tokens', async () => {
|
||||||
const inputAmount = new BigNumber(1);
|
const inputAmount = new BigNumber(1);
|
||||||
const erc20Amount = new BigNumber(10);
|
const erc20Amount = new BigNumber(10);
|
||||||
|
@@ -1,6 +1,29 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"version": "0.0.1",
|
"version": "2.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Make `decodeOrdersFromFillData`, `getCoordinatorApprovalHash`, and `getTransactionHash` public",
|
||||||
|
"pr": 1729
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Make `assertValidTransactionOrdersApproval` internal",
|
||||||
|
"pr": 1729
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
{
|
||||||
"note": "Created Coordinator package"
|
"note": "Created Coordinator package"
|
||||||
@@ -12,7 +35,12 @@
|
|||||||
{
|
{
|
||||||
"note": "Add `SignatureType.Invalid`",
|
"note": "Add `SignatureType.Invalid`",
|
||||||
"pr": 1705
|
"pr": 1705
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Set `evmVersion` to `constantinople`",
|
||||||
|
"pr": 1707
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@@ -4,3 +4,14 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v1.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v1.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Created Coordinator package
|
||||||
|
* Use separate EIP712 domains for transactions and approvals (#1705)
|
||||||
|
* Add `SignatureType.Invalid` (#1705)
|
||||||
|
* Set `evmVersion` to `constantinople` (#1707)
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
"contractsDir": "./contracts",
|
"contractsDir": "./contracts",
|
||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
@@ -21,10 +21,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"contracts": [
|
"contracts": ["src/Coordinator.sol", "src/registry/CoordinatorRegistry.sol"]
|
||||||
"src/Coordinator.sol",
|
|
||||||
"src/registry/CoordinatorRegistry.sol",
|
|
||||||
"test/TestLibs.sol",
|
|
||||||
"test/TestMixins.sol"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ contract MixinCoordinatorApprovalVerifier is
|
|||||||
view
|
view
|
||||||
{
|
{
|
||||||
// Get the orders from the the Exchange calldata in the 0x transaction
|
// Get the orders from the the Exchange calldata in the 0x transaction
|
||||||
LibOrder.Order[] memory orders = decodeFillDataOrders(transaction.data);
|
LibOrder.Order[] memory orders = decodeOrdersFromFillData(transaction.data);
|
||||||
|
|
||||||
// No approval is required for non-fill methods
|
// No approval is required for non-fill methods
|
||||||
if (orders.length > 0) {
|
if (orders.length > 0) {
|
||||||
@@ -74,6 +74,57 @@ contract MixinCoordinatorApprovalVerifier is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @dev Decodes the orders from Exchange calldata representing any fill method.
|
||||||
|
/// @param data Exchange calldata representing a fill method.
|
||||||
|
/// @return The orders from the Exchange calldata.
|
||||||
|
function decodeOrdersFromFillData(bytes memory data)
|
||||||
|
public
|
||||||
|
pure
|
||||||
|
returns (LibOrder.Order[] memory orders)
|
||||||
|
{
|
||||||
|
bytes4 selector = data.readBytes4(0);
|
||||||
|
if (
|
||||||
|
selector == FILL_ORDER_SELECTOR ||
|
||||||
|
selector == FILL_ORDER_NO_THROW_SELECTOR ||
|
||||||
|
selector == FILL_OR_KILL_ORDER_SELECTOR
|
||||||
|
) {
|
||||||
|
// Decode single order
|
||||||
|
(LibOrder.Order memory order) = abi.decode(
|
||||||
|
data.slice(4, data.length),
|
||||||
|
(LibOrder.Order)
|
||||||
|
);
|
||||||
|
orders = new LibOrder.Order[](1);
|
||||||
|
orders[0] = order;
|
||||||
|
} else if (
|
||||||
|
selector == BATCH_FILL_ORDERS_SELECTOR ||
|
||||||
|
selector == BATCH_FILL_ORDERS_NO_THROW_SELECTOR ||
|
||||||
|
selector == BATCH_FILL_OR_KILL_ORDERS_SELECTOR ||
|
||||||
|
selector == MARKET_BUY_ORDERS_SELECTOR ||
|
||||||
|
selector == MARKET_BUY_ORDERS_NO_THROW_SELECTOR ||
|
||||||
|
selector == MARKET_SELL_ORDERS_SELECTOR ||
|
||||||
|
selector == MARKET_SELL_ORDERS_NO_THROW_SELECTOR
|
||||||
|
) {
|
||||||
|
// Decode all orders
|
||||||
|
// solhint-disable indent
|
||||||
|
(orders) = abi.decode(
|
||||||
|
data.slice(4, data.length),
|
||||||
|
(LibOrder.Order[])
|
||||||
|
);
|
||||||
|
} else if (selector == MATCH_ORDERS_SELECTOR) {
|
||||||
|
// Decode left and right orders
|
||||||
|
(LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder) = abi.decode(
|
||||||
|
data.slice(4, data.length),
|
||||||
|
(LibOrder.Order, LibOrder.Order)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create array of orders
|
||||||
|
orders = new LibOrder.Order[](2);
|
||||||
|
orders[0] = leftOrder;
|
||||||
|
orders[1] = rightOrder;
|
||||||
|
}
|
||||||
|
return orders;
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Validates that the feeRecipients of a batch of order have approved a 0x transaction.
|
/// @dev Validates that the feeRecipients of a batch of order have approved a 0x transaction.
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
||||||
/// @param orders Array of order structs containing order specifications.
|
/// @param orders Array of order structs containing order specifications.
|
||||||
@@ -89,7 +140,7 @@ contract MixinCoordinatorApprovalVerifier is
|
|||||||
uint256[] memory approvalExpirationTimeSeconds,
|
uint256[] memory approvalExpirationTimeSeconds,
|
||||||
bytes[] memory approvalSignatures
|
bytes[] memory approvalSignatures
|
||||||
)
|
)
|
||||||
public
|
internal
|
||||||
view
|
view
|
||||||
{
|
{
|
||||||
// Verify that Ethereum tx signer is the same as the approved txOrigin
|
// Verify that Ethereum tx signer is the same as the approved txOrigin
|
||||||
@@ -149,55 +200,4 @@ contract MixinCoordinatorApprovalVerifier is
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Decodes the orders from Exchange calldata representing any fill method.
|
|
||||||
/// @param data Exchange calldata representing a fill method.
|
|
||||||
/// @return The orders from the Exchange calldata.
|
|
||||||
function decodeFillDataOrders(bytes memory data)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (LibOrder.Order[] memory orders)
|
|
||||||
{
|
|
||||||
bytes4 selector = data.readBytes4(0);
|
|
||||||
if (
|
|
||||||
selector == FILL_ORDER_SELECTOR ||
|
|
||||||
selector == FILL_ORDER_NO_THROW_SELECTOR ||
|
|
||||||
selector == FILL_OR_KILL_ORDER_SELECTOR
|
|
||||||
) {
|
|
||||||
// Decode single order
|
|
||||||
(LibOrder.Order memory order) = abi.decode(
|
|
||||||
data.slice(4, data.length),
|
|
||||||
(LibOrder.Order)
|
|
||||||
);
|
|
||||||
orders = new LibOrder.Order[](1);
|
|
||||||
orders[0] = order;
|
|
||||||
} else if (
|
|
||||||
selector == BATCH_FILL_ORDERS_SELECTOR ||
|
|
||||||
selector == BATCH_FILL_ORDERS_NO_THROW_SELECTOR ||
|
|
||||||
selector == BATCH_FILL_OR_KILL_ORDERS_SELECTOR ||
|
|
||||||
selector == MARKET_BUY_ORDERS_SELECTOR ||
|
|
||||||
selector == MARKET_BUY_ORDERS_NO_THROW_SELECTOR ||
|
|
||||||
selector == MARKET_SELL_ORDERS_SELECTOR ||
|
|
||||||
selector == MARKET_SELL_ORDERS_NO_THROW_SELECTOR
|
|
||||||
) {
|
|
||||||
// Decode all orders
|
|
||||||
// solhint-disable indent
|
|
||||||
(orders) = abi.decode(
|
|
||||||
data.slice(4, data.length),
|
|
||||||
(LibOrder.Order[])
|
|
||||||
);
|
|
||||||
} else if (selector == MATCH_ORDERS_SELECTOR) {
|
|
||||||
// Decode left and right orders
|
|
||||||
(LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder) = abi.decode(
|
|
||||||
data.slice(4, data.length),
|
|
||||||
(LibOrder.Order, LibOrder.Order)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Create array of orders
|
|
||||||
orders = new LibOrder.Order[](2);
|
|
||||||
orders[0] = leftOrder;
|
|
||||||
orders[1] = rightOrder;
|
|
||||||
}
|
|
||||||
return orders;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -42,21 +42,11 @@ contract ICoordinatorApprovalVerifier {
|
|||||||
public
|
public
|
||||||
view;
|
view;
|
||||||
|
|
||||||
/// @dev Validates that the feeRecipients of a batch of order have approved a 0x transaction.
|
/// @dev Decodes the orders from Exchange calldata representing any fill method.
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
/// @param data Exchange calldata representing a fill method.
|
||||||
/// @param orders Array of order structs containing order specifications.
|
/// @return The orders from the Exchange calldata.
|
||||||
/// @param txOrigin Required signer of Ethereum transaction calling this function.
|
function decodeOrdersFromFillData(bytes memory data)
|
||||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
|
||||||
/// @param approvalExpirationTimeSeconds Array of expiration times in seconds for which each corresponding approval signature expires.
|
|
||||||
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each order.
|
|
||||||
function assertValidTransactionOrdersApproval(
|
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
|
||||||
LibOrder.Order[] memory orders,
|
|
||||||
address txOrigin,
|
|
||||||
bytes memory transactionSignature,
|
|
||||||
uint256[] memory approvalExpirationTimeSeconds,
|
|
||||||
bytes[] memory approvalSignatures
|
|
||||||
)
|
|
||||||
public
|
public
|
||||||
view;
|
pure
|
||||||
|
returns (LibOrder.Order[] memory orders);
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pragma solidity ^0.5.5;
|
pragma solidity ^0.5.5;
|
||||||
|
pragma experimental "ABIEncoderV2";
|
||||||
|
|
||||||
import "./LibEIP712Domain.sol";
|
import "./LibEIP712Domain.sol";
|
||||||
|
|
||||||
@@ -37,16 +38,16 @@ contract LibCoordinatorApproval is
|
|||||||
|
|
||||||
struct CoordinatorApproval {
|
struct CoordinatorApproval {
|
||||||
address txOrigin; // Required signer of Ethereum transaction that is submitting approval.
|
address txOrigin; // Required signer of Ethereum transaction that is submitting approval.
|
||||||
bytes32 transactionHash; // EIP712 hash of the transaction, using the domain separator of this contract.
|
bytes32 transactionHash; // EIP712 hash of the transaction.
|
||||||
bytes transactionSignature; // Signature of the 0x transaction.
|
bytes transactionSignature; // Signature of the 0x transaction.
|
||||||
uint256 approvalExpirationTimeSeconds; // Timestamp in seconds for which the signature expires.
|
uint256 approvalExpirationTimeSeconds; // Timestamp in seconds for which the approval expires.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Calculated the EIP712 hash of the Coordinator approval mesasage using the domain separator of this contract.
|
/// @dev Calculated the EIP712 hash of the Coordinator approval mesasage using the domain separator of this contract.
|
||||||
/// @param approval Coordinator approval message containing the transaction hash, transaction signature, and expiration of the approval.
|
/// @param approval Coordinator approval message containing the transaction hash, transaction signature, and expiration of the approval.
|
||||||
/// @return EIP712 hash of the Coordinator approval message with the domain separator of this contract.
|
/// @return EIP712 hash of the Coordinator approval message with the domain separator of this contract.
|
||||||
function getCoordinatorApprovalHash(CoordinatorApproval memory approval)
|
function getCoordinatorApprovalHash(CoordinatorApproval memory approval)
|
||||||
internal
|
public
|
||||||
view
|
view
|
||||||
returns (bytes32 approvalHash)
|
returns (bytes32 approvalHash)
|
||||||
{
|
{
|
||||||
@@ -71,9 +72,10 @@ contract LibCoordinatorApproval is
|
|||||||
// Assembly for more efficiently computing:
|
// Assembly for more efficiently computing:
|
||||||
// keccak256(abi.encodePacked(
|
// keccak256(abi.encodePacked(
|
||||||
// EIP712_COORDINATOR_APPROVAL_SCHEMA_HASH,
|
// EIP712_COORDINATOR_APPROVAL_SCHEMA_HASH,
|
||||||
|
// approval.txOrigin,
|
||||||
// approval.transactionHash,
|
// approval.transactionHash,
|
||||||
// keccak256(approval.transactionSignature)
|
// keccak256(approval.transactionSignature)
|
||||||
// approval.expiration,
|
// approval.approvalExpirationTimeSeconds,
|
||||||
// ));
|
// ));
|
||||||
|
|
||||||
assembly {
|
assembly {
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pragma solidity ^0.5.5;
|
pragma solidity ^0.5.5;
|
||||||
|
pragma experimental "ABIEncoderV2";
|
||||||
|
|
||||||
import "./LibEIP712Domain.sol";
|
import "./LibEIP712Domain.sol";
|
||||||
|
|
||||||
@@ -40,11 +41,11 @@ contract LibZeroExTransaction is
|
|||||||
bytes data; // AbiV2 encoded calldata.
|
bytes data; // AbiV2 encoded calldata.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Calculates the EIP712 hash of a 0x transaction using the domain separator of this contract.
|
/// @dev Calculates the EIP712 hash of a 0x transaction using the domain separator of the Exchange contract.
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
||||||
/// @return EIP712 hash of the transaction with the domain separator of this contract.
|
/// @return EIP712 hash of the transaction with the domain separator of this contract.
|
||||||
function getTransactionHash(ZeroExTransaction memory transaction)
|
function getTransactionHash(ZeroExTransaction memory transaction)
|
||||||
internal
|
public
|
||||||
view
|
view
|
||||||
returns (bytes32 transactionHash)
|
returns (bytes32 transactionHash)
|
||||||
{
|
{
|
||||||
|
@@ -26,11 +26,21 @@ import "../interfaces/ICoordinatorApprovalVerifier.sol";
|
|||||||
contract MCoordinatorApprovalVerifier is
|
contract MCoordinatorApprovalVerifier is
|
||||||
ICoordinatorApprovalVerifier
|
ICoordinatorApprovalVerifier
|
||||||
{
|
{
|
||||||
/// @dev Decodes the orders from Exchange calldata representing any fill method.
|
/// @dev Validates that the feeRecipients of a batch of order have approved a 0x transaction.
|
||||||
/// @param data Exchange calldata representing a fill method.
|
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
||||||
/// @return The orders from the Exchange calldata.
|
/// @param orders Array of order structs containing order specifications.
|
||||||
function decodeFillDataOrders(bytes memory data)
|
/// @param txOrigin Required signer of Ethereum transaction calling this function.
|
||||||
|
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
||||||
|
/// @param approvalExpirationTimeSeconds Array of expiration times in seconds for which each corresponding approval signature expires.
|
||||||
|
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each order.
|
||||||
|
function assertValidTransactionOrdersApproval(
|
||||||
|
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
||||||
|
LibOrder.Order[] memory orders,
|
||||||
|
address txOrigin,
|
||||||
|
bytes memory transactionSignature,
|
||||||
|
uint256[] memory approvalExpirationTimeSeconds,
|
||||||
|
bytes[] memory approvalSignatures
|
||||||
|
)
|
||||||
internal
|
internal
|
||||||
pure
|
view;
|
||||||
returns (LibOrder.Order[] memory orders);
|
|
||||||
}
|
}
|
||||||
|
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.5;
|
|
||||||
pragma experimental "ABIEncoderV2";
|
|
||||||
|
|
||||||
import "../src/libs/LibConstants.sol";
|
|
||||||
import "../src/libs/LibCoordinatorApproval.sol";
|
|
||||||
import "../src/libs/LibZeroExTransaction.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
|
||||||
contract TestLibs is
|
|
||||||
LibConstants,
|
|
||||||
LibCoordinatorApproval,
|
|
||||||
LibZeroExTransaction
|
|
||||||
{
|
|
||||||
constructor (address _exchange)
|
|
||||||
public
|
|
||||||
LibConstants(_exchange)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/// @dev Calculated the EIP712 hash of the Coordinator approval mesasage using the domain separator of this contract.
|
|
||||||
/// @param approval Coordinator approval message containing the transaction hash, transaction signature, and expiration of the approval.
|
|
||||||
/// @return EIP712 hash of the Coordinator approval message with the domain separator of this contract.
|
|
||||||
function publicGetCoordinatorApprovalHash(CoordinatorApproval memory approval)
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (bytes32 approvalHash)
|
|
||||||
{
|
|
||||||
approvalHash = getCoordinatorApprovalHash(approval);
|
|
||||||
return approvalHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Calculates the EIP712 hash of a 0x transaction using the domain separator of the Exchange contract.
|
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
/// @return EIP712 hash of the transaction with the domain separator of the Exchange contract.
|
|
||||||
function publicGetTransactionHash(ZeroExTransaction memory transaction)
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (bytes32 transactionHash)
|
|
||||||
{
|
|
||||||
transactionHash = getTransactionHash(transaction);
|
|
||||||
return transactionHash;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.5;
|
|
||||||
pragma experimental "ABIEncoderV2";
|
|
||||||
|
|
||||||
import "../src/libs/LibConstants.sol";
|
|
||||||
import "../src/MixinSignatureValidator.sol";
|
|
||||||
import "../src/MixinCoordinatorApprovalVerifier.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
|
||||||
contract TestMixins is
|
|
||||||
LibConstants,
|
|
||||||
MixinSignatureValidator,
|
|
||||||
MixinCoordinatorApprovalVerifier
|
|
||||||
{
|
|
||||||
constructor (address _exchange)
|
|
||||||
public
|
|
||||||
LibConstants(_exchange)
|
|
||||||
{}
|
|
||||||
}
|
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-coordinator",
|
"name": "@0x/contracts-coordinator",
|
||||||
"version": "0.0.1",
|
"version": "1.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis": "./generated-artifacts/@(Coordinator|CoordinatorRegistry|TestLibs|TestMixins).json",
|
"abis": "./generated-artifacts/@(Coordinator|CoordinatorRegistry).json",
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -67,18 +67,18 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-asset-proxy": "^1.0.9",
|
"@0x/contracts-asset-proxy": "^2.1.0",
|
||||||
"@0x/contracts-erc20": "^1.0.9",
|
"@0x/contracts-erc20": "^2.1.0",
|
||||||
"@0x/contracts-exchange": "1.0.2",
|
"@0x/contracts-exchange": "1.0.2",
|
||||||
"@0x/contracts-exchange-libs": "^1.1.3",
|
"@0x/contracts-exchange-libs": "^2.1.0",
|
||||||
"@0x/contracts-utils": "^2.0.8",
|
"@0x/contracts-utils": "^3.1.0",
|
||||||
"@0x/order-utils": "^7.0.2",
|
"@0x/order-utils": "^7.1.1",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"ethereumjs-util": "^5.1.1",
|
"ethereumjs-util": "^5.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
|
@@ -7,11 +7,7 @@ import { ContractArtifact } from 'ethereum-types';
|
|||||||
|
|
||||||
import * as Coordinator from '../generated-artifacts/Coordinator.json';
|
import * as Coordinator from '../generated-artifacts/Coordinator.json';
|
||||||
import * as CoordinatorRegistry from '../generated-artifacts/CoordinatorRegistry.json';
|
import * as CoordinatorRegistry from '../generated-artifacts/CoordinatorRegistry.json';
|
||||||
import * as TestLibs from '../generated-artifacts/TestLibs.json';
|
|
||||||
import * as TestMixins from '../generated-artifacts/TestMixins.json';
|
|
||||||
export const artifacts = {
|
export const artifacts = {
|
||||||
Coordinator: Coordinator as ContractArtifact,
|
Coordinator: Coordinator as ContractArtifact,
|
||||||
CoordinatorRegistry: CoordinatorRegistry as ContractArtifact,
|
CoordinatorRegistry: CoordinatorRegistry as ContractArtifact,
|
||||||
TestLibs: TestLibs as ContractArtifact,
|
|
||||||
TestMixins: TestMixins as ContractArtifact,
|
|
||||||
};
|
};
|
||||||
|
@@ -5,5 +5,3 @@
|
|||||||
*/
|
*/
|
||||||
export * from '../generated-wrappers/coordinator';
|
export * from '../generated-wrappers/coordinator';
|
||||||
export * from '../generated-wrappers/coordinator_registry';
|
export * from '../generated-wrappers/coordinator_registry';
|
||||||
export * from '../generated-wrappers/test_libs';
|
|
||||||
export * from '../generated-wrappers/test_mixins';
|
|
||||||
|
@@ -435,7 +435,7 @@ describe('Coordinator tests', () => {
|
|||||||
describe('cancels', () => {
|
describe('cancels', () => {
|
||||||
it('cancelOrder call should be successful without an approval', async () => {
|
it('cancelOrder call should be successful without an approval', async () => {
|
||||||
const orders = [await orderFactory.newSignedOrderAsync()];
|
const orders = [await orderFactory.newSignedOrderAsync()];
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(constants.CANCEL_ORDERS, orders);
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(constants.CANCEL_ORDER, orders);
|
||||||
const transaction = makerTransactionFactory.newSignedTransaction(data);
|
const transaction = makerTransactionFactory.newSignedTransaction(data);
|
||||||
const transactionReceipt = await web3Wrapper.awaitTransactionSuccessAsync(
|
const transactionReceipt = await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await coordinatorContract.executeTransaction.sendTransactionAsync(
|
await coordinatorContract.executeTransaction.sendTransactionAsync(
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
@@ -4,14 +4,14 @@ import { transactionHashUtils } from '@0x/order-utils';
|
|||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
|
|
||||||
import { artifacts, hashUtils, TestLibsContract } from '../src';
|
import { artifacts, CoordinatorContract, hashUtils } from '../src';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
|
|
||||||
describe('Libs tests', () => {
|
describe('Libs tests', () => {
|
||||||
let testLibs: TestLibsContract;
|
let coordinatorContract: CoordinatorContract;
|
||||||
const exchangeAddress = addressUtils.generatePseudoRandomAddress();
|
const exchangeAddress = addressUtils.generatePseudoRandomAddress();
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
@@ -21,8 +21,8 @@ describe('Libs tests', () => {
|
|||||||
await blockchainLifecycle.revertAsync();
|
await blockchainLifecycle.revertAsync();
|
||||||
});
|
});
|
||||||
before(async () => {
|
before(async () => {
|
||||||
testLibs = await TestLibsContract.deployFrom0xArtifactAsync(
|
coordinatorContract = await CoordinatorContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.TestLibs,
|
artifacts.Coordinator,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
exchangeAddress,
|
exchangeAddress,
|
||||||
@@ -44,7 +44,7 @@ describe('Libs tests', () => {
|
|||||||
data: '0x1234',
|
data: '0x1234',
|
||||||
};
|
};
|
||||||
const expectedTxHash = transactionHashUtils.getTransactionHashHex(tx);
|
const expectedTxHash = transactionHashUtils.getTransactionHashHex(tx);
|
||||||
const txHash = await testLibs.publicGetTransactionHash.callAsync(tx);
|
const txHash = await coordinatorContract.getTransactionHash.callAsync(tx);
|
||||||
expect(expectedTxHash).to.eq(txHash);
|
expect(expectedTxHash).to.eq(txHash);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -68,11 +68,11 @@ describe('Libs tests', () => {
|
|||||||
};
|
};
|
||||||
const expectedApprovalHash = hashUtils.getApprovalHashHex(
|
const expectedApprovalHash = hashUtils.getApprovalHashHex(
|
||||||
signedTx,
|
signedTx,
|
||||||
testLibs.address,
|
coordinatorContract.address,
|
||||||
txOrigin,
|
txOrigin,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
const approvalHash = await testLibs.publicGetCoordinatorApprovalHash.callAsync(approval);
|
const approvalHash = await coordinatorContract.getCoordinatorApprovalHash.callAsync(approval);
|
||||||
expect(expectedApprovalHash).to.eq(approvalHash);
|
expect(expectedApprovalHash).to.eq(approvalHash);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -16,7 +16,7 @@ import { BigNumber } 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';
|
||||||
|
|
||||||
import { ApprovalFactory, artifacts, constants, exchangeDataEncoder, TestMixinsContract } from '../src';
|
import { ApprovalFactory, artifacts, constants, CoordinatorContract, exchangeDataEncoder } from '../src';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
@@ -26,7 +26,7 @@ describe('Mixins tests', () => {
|
|||||||
let transactionSignerAddress: string;
|
let transactionSignerAddress: string;
|
||||||
let approvalSignerAddress1: string;
|
let approvalSignerAddress1: string;
|
||||||
let approvalSignerAddress2: string;
|
let approvalSignerAddress2: string;
|
||||||
let mixins: TestMixinsContract;
|
let mixins: CoordinatorContract;
|
||||||
let transactionFactory: TransactionFactory;
|
let transactionFactory: TransactionFactory;
|
||||||
let approvalFactory1: ApprovalFactory;
|
let approvalFactory1: ApprovalFactory;
|
||||||
let approvalFactory2: ApprovalFactory;
|
let approvalFactory2: ApprovalFactory;
|
||||||
@@ -40,8 +40,8 @@ describe('Mixins tests', () => {
|
|||||||
await blockchainLifecycle.revertAsync();
|
await blockchainLifecycle.revertAsync();
|
||||||
});
|
});
|
||||||
before(async () => {
|
before(async () => {
|
||||||
mixins = await TestMixinsContract.deployFrom0xArtifactAsync(
|
mixins = await CoordinatorContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.TestMixins,
|
artifacts.Coordinator,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
exchangeAddress,
|
exchangeAddress,
|
||||||
@@ -135,6 +135,70 @@ describe('Mixins tests', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('decodeOrdersFromFillData', () => {
|
||||||
|
for (const fnName of constants.SINGLE_FILL_FN_NAMES) {
|
||||||
|
it(`should correctly decode the orders for ${fnName} data`, async () => {
|
||||||
|
const orders = [defaultOrder];
|
||||||
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
||||||
|
const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data);
|
||||||
|
const decodedSignedOrders = decodedOrders.map(order => ({
|
||||||
|
...order,
|
||||||
|
exchangeAddress: devConstants.NULL_ADDRESS,
|
||||||
|
signature: devConstants.NULL_BYTES,
|
||||||
|
}));
|
||||||
|
expect(orders).to.deep.eq(decodedSignedOrders);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (const fnName of constants.BATCH_FILL_FN_NAMES) {
|
||||||
|
it(`should correctly decode the orders for ${fnName} data`, async () => {
|
||||||
|
const orders = [defaultOrder, defaultOrder];
|
||||||
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
||||||
|
const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data);
|
||||||
|
const decodedSignedOrders = decodedOrders.map(order => ({
|
||||||
|
...order,
|
||||||
|
exchangeAddress: devConstants.NULL_ADDRESS,
|
||||||
|
signature: devConstants.NULL_BYTES,
|
||||||
|
}));
|
||||||
|
expect(orders).to.deep.eq(decodedSignedOrders);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (const fnName of constants.MARKET_FILL_FN_NAMES) {
|
||||||
|
it(`should correctly decode the orders for ${fnName} data`, async () => {
|
||||||
|
const orders = [defaultOrder, defaultOrder];
|
||||||
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
||||||
|
const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data);
|
||||||
|
const decodedSignedOrders = decodedOrders.map(order => ({
|
||||||
|
...order,
|
||||||
|
exchangeAddress: devConstants.NULL_ADDRESS,
|
||||||
|
signature: devConstants.NULL_BYTES,
|
||||||
|
}));
|
||||||
|
expect(orders).to.deep.eq(decodedSignedOrders);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (const fnName of [constants.CANCEL_ORDER, constants.BATCH_CANCEL_ORDERS, constants.CANCEL_ORDERS_UP_TO]) {
|
||||||
|
it(`should correctly decode the orders for ${fnName} data`, async () => {
|
||||||
|
const orders = [defaultOrder, defaultOrder];
|
||||||
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
||||||
|
const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data);
|
||||||
|
const emptyArray: any[] = [];
|
||||||
|
expect(emptyArray).to.deep.eq(decodedOrders);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
it('should decode an empty array for invalid data', async () => {
|
||||||
|
const data = '0x0123456789';
|
||||||
|
const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data);
|
||||||
|
const emptyArray: any[] = [];
|
||||||
|
expect(emptyArray).to.deep.eq(decodedOrders);
|
||||||
|
});
|
||||||
|
it('should revert if data is less than 4 bytes long', async () => {
|
||||||
|
const data = '0x010203';
|
||||||
|
await expectContractCallFailedAsync(
|
||||||
|
mixins.decodeOrdersFromFillData.callAsync(data),
|
||||||
|
RevertReason.LibBytesGreaterOrEqualTo4LengthRequired,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Single order approvals', () => {
|
describe('Single order approvals', () => {
|
||||||
for (const fnName of constants.SINGLE_FILL_FN_NAMES) {
|
for (const fnName of constants.SINGLE_FILL_FN_NAMES) {
|
||||||
it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[approver1], expiration=[valid]`, async () => {
|
it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[approver1], expiration=[valid]`, async () => {
|
||||||
@@ -148,15 +212,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval.signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
@@ -181,15 +236,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval.signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
@@ -203,15 +249,6 @@ describe('Mixins tests', () => {
|
|||||||
const orders = [defaultOrder];
|
const orders = [defaultOrder];
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
||||||
const transaction = transactionFactory.newSignedTransaction(data);
|
const transaction = transactionFactory.newSignedTransaction(data);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
approvalSignerAddress1,
|
|
||||||
transaction.signature,
|
|
||||||
[],
|
|
||||||
[],
|
|
||||||
{ from: approvalSignerAddress1 },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
approvalSignerAddress1,
|
approvalSignerAddress1,
|
||||||
@@ -234,15 +271,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
approvalSignerAddress1,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval.signature],
|
|
||||||
{ from: approvalSignerAddress1 },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
approvalSignerAddress1,
|
approvalSignerAddress1,
|
||||||
@@ -256,15 +284,6 @@ describe('Mixins tests', () => {
|
|||||||
const orders = [defaultOrder];
|
const orders = [defaultOrder];
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
||||||
const transaction = transactionFactory.newSignedTransaction(data);
|
const transaction = transactionFactory.newSignedTransaction(data);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
approvalSignerAddress1,
|
|
||||||
transaction.signature,
|
|
||||||
[],
|
|
||||||
[],
|
|
||||||
{ from: approvalSignerAddress1 },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
approvalSignerAddress1,
|
approvalSignerAddress1,
|
||||||
@@ -288,18 +307,6 @@ describe('Mixins tests', () => {
|
|||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
const signature = `${approval.signature.slice(0, 4)}FFFFFFFF${approval.signature.slice(12)}`;
|
const signature = `${approval.signature.slice(0, 4)}FFFFFFFF${approval.signature.slice(12)}`;
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
),
|
|
||||||
RevertReason.InvalidApprovalSignature,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -323,18 +330,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval.signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
),
|
|
||||||
RevertReason.ApprovalExpired,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -358,18 +353,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval.signature],
|
|
||||||
{ from: approvalSignerAddress2 },
|
|
||||||
),
|
|
||||||
RevertReason.InvalidOrigin,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -401,15 +384,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval.signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
@@ -433,15 +407,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval.signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
@@ -458,15 +423,6 @@ describe('Mixins tests', () => {
|
|||||||
}));
|
}));
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
||||||
const transaction = transactionFactory.newSignedTransaction(data);
|
const transaction = transactionFactory.newSignedTransaction(data);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[],
|
|
||||||
[],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
@@ -487,15 +443,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval.signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
@@ -521,15 +468,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds, approvalExpirationTimeSeconds],
|
|
||||||
[approval1.signature, approval2.signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
@@ -543,15 +481,6 @@ describe('Mixins tests', () => {
|
|||||||
const orders = [defaultOrder, defaultOrder];
|
const orders = [defaultOrder, defaultOrder];
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
||||||
const transaction = transactionFactory.newSignedTransaction(data);
|
const transaction = transactionFactory.newSignedTransaction(data);
|
||||||
await mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
approvalSignerAddress1,
|
|
||||||
transaction.signature,
|
|
||||||
[],
|
|
||||||
[],
|
|
||||||
{ from: approvalSignerAddress1 },
|
|
||||||
);
|
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
approvalSignerAddress1,
|
approvalSignerAddress1,
|
||||||
@@ -572,18 +501,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval2.signature],
|
|
||||||
{ from: approvalSignerAddress1 },
|
|
||||||
),
|
|
||||||
RevertReason.InvalidOrigin,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -600,18 +517,6 @@ describe('Mixins tests', () => {
|
|||||||
const orders = [defaultOrder, defaultOrder];
|
const orders = [defaultOrder, defaultOrder];
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
||||||
const transaction = transactionFactory.newSignedTransaction(data);
|
const transaction = transactionFactory.newSignedTransaction(data);
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[],
|
|
||||||
[],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
),
|
|
||||||
RevertReason.InvalidApprovalSignature,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -636,18 +541,6 @@ describe('Mixins tests', () => {
|
|||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
const signature = `${approval.signature.slice(0, 4)}FFFFFFFF${approval.signature.slice(12)}`;
|
const signature = `${approval.signature.slice(0, 4)}FFFFFFFF${approval.signature.slice(12)}`;
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
),
|
|
||||||
RevertReason.InvalidApprovalSignature,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -677,18 +570,6 @@ describe('Mixins tests', () => {
|
|||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
const approvalSignature2 = `${approval2.signature.slice(0, 4)}FFFFFFFF${approval2.signature.slice(12)}`;
|
const approvalSignature2 = `${approval2.signature.slice(0, 4)}FFFFFFFF${approval2.signature.slice(12)}`;
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds, approvalExpirationTimeSeconds],
|
|
||||||
[approval1.signature, approvalSignature2],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
),
|
|
||||||
RevertReason.InvalidApprovalSignature,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -713,18 +594,6 @@ describe('Mixins tests', () => {
|
|||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
const approvalSignature2 = `${approval2.signature.slice(0, 4)}FFFFFFFF${approval2.signature.slice(12)}`;
|
const approvalSignature2 = `${approval2.signature.slice(0, 4)}FFFFFFFF${approval2.signature.slice(12)}`;
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
approvalSignerAddress1,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approvalSignature2],
|
|
||||||
{ from: approvalSignerAddress1 },
|
|
||||||
),
|
|
||||||
RevertReason.InvalidApprovalSignature,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -754,18 +623,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds2,
|
approvalExpirationTimeSeconds2,
|
||||||
);
|
);
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds1, approvalExpirationTimeSeconds2],
|
|
||||||
[approval1.signature, approval2.signature],
|
|
||||||
{ from: transactionSignerAddress },
|
|
||||||
),
|
|
||||||
RevertReason.ApprovalExpired,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -789,18 +646,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
approvalSignerAddress1,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval2.signature],
|
|
||||||
{ from: approvalSignerAddress1 },
|
|
||||||
),
|
|
||||||
RevertReason.ApprovalExpired,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -824,18 +669,6 @@ describe('Mixins tests', () => {
|
|||||||
transactionSignerAddress,
|
transactionSignerAddress,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
expectContractCallFailedAsync(
|
|
||||||
mixins.assertValidTransactionOrdersApproval.callAsync(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
transactionSignerAddress,
|
|
||||||
transaction.signature,
|
|
||||||
[approvalExpirationTimeSeconds],
|
|
||||||
[approval1.signature],
|
|
||||||
{ from: approvalSignerAddress2 },
|
|
||||||
),
|
|
||||||
RevertReason.InvalidOrigin,
|
|
||||||
);
|
|
||||||
expectContractCallFailedAsync(
|
expectContractCallFailedAsync(
|
||||||
mixins.assertValidCoordinatorApprovals.callAsync(
|
mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
@@ -851,9 +684,9 @@ describe('Mixins tests', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
describe('cancels', () => {
|
describe('cancels', () => {
|
||||||
it('should allow the tx signer to call `cancelOrders` without approval', async () => {
|
it('should allow the tx signer to call `cancelOrder` without approval', async () => {
|
||||||
const orders = [defaultOrder];
|
const orders = [defaultOrder];
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(constants.CANCEL_ORDERS, orders);
|
const data = exchangeDataEncoder.encodeOrdersToExchangeData(constants.CANCEL_ORDER, orders);
|
||||||
const transaction = transactionFactory.newSignedTransaction(data);
|
const transaction = transactionFactory.newSignedTransaction(data);
|
||||||
await mixins.assertValidCoordinatorApprovals.callAsync(
|
await mixins.assertValidCoordinatorApprovals.callAsync(
|
||||||
transaction,
|
transaction,
|
||||||
|
@@ -5,7 +5,7 @@ export const constants = {
|
|||||||
BATCH_FILL_FN_NAMES: ['batchFillOrders', 'batchFillOrKillOrders', 'batchFillOrdersNoThrow'],
|
BATCH_FILL_FN_NAMES: ['batchFillOrders', 'batchFillOrKillOrders', 'batchFillOrdersNoThrow'],
|
||||||
MARKET_FILL_FN_NAMES: ['marketBuyOrders', 'marketBuyOrdersNoThrow', 'marketSellOrders', 'marketSellOrdersNoThrow'],
|
MARKET_FILL_FN_NAMES: ['marketBuyOrders', 'marketBuyOrdersNoThrow', 'marketSellOrders', 'marketSellOrdersNoThrow'],
|
||||||
MATCH_ORDERS: 'matchOrders',
|
MATCH_ORDERS: 'matchOrders',
|
||||||
CANCEL_ORDERS: 'cancelOrders',
|
CANCEL_ORDER: 'cancelOrder',
|
||||||
BATCH_CANCEL_ORDERS: 'batchCancelOrders',
|
BATCH_CANCEL_ORDERS: 'batchCancelOrders',
|
||||||
CANCEL_ORDERS_UP_TO: 'cancelOrdersUpTo',
|
CANCEL_ORDERS_UP_TO: 'cancelOrdersUpTo',
|
||||||
TIME_BUFFER: new BigNumber(1000),
|
TIME_BUFFER: new BigNumber(1000),
|
||||||
|
@@ -37,7 +37,7 @@ export const exchangeDataEncoder = {
|
|||||||
orders[0].signature,
|
orders[0].signature,
|
||||||
orders[1].signature,
|
orders[1].signature,
|
||||||
);
|
);
|
||||||
} else if (fnName === constants.CANCEL_ORDERS) {
|
} else if (fnName === constants.CANCEL_ORDER) {
|
||||||
data = exchangeInstance.cancelOrder.getABIEncodedTransactionData(orders[0]);
|
data = exchangeInstance.cancelOrder.getABIEncodedTransactionData(orders[0]);
|
||||||
} else if (fnName === constants.BATCH_CANCEL_ORDERS) {
|
} else if (fnName === constants.BATCH_CANCEL_ORDERS) {
|
||||||
data = exchangeInstance.batchCancelOrders.getABIEncodedTransactionData(orders);
|
data = exchangeInstance.batchCancelOrders.getABIEncodedTransactionData(orders);
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { eip712Utils, transactionHashUtils } from '@0x/order-utils';
|
import { eip712Utils } from '@0x/order-utils';
|
||||||
import { constants } from '@0x/order-utils/lib/src/constants';
|
|
||||||
import { SignedZeroExTransaction } from '@0x/types';
|
import { SignedZeroExTransaction } from '@0x/types';
|
||||||
import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@@ -11,25 +10,11 @@ export const hashUtils = {
|
|||||||
txOrigin: string,
|
txOrigin: string,
|
||||||
approvalExpirationTimeSeconds: BigNumber,
|
approvalExpirationTimeSeconds: BigNumber,
|
||||||
): Buffer {
|
): Buffer {
|
||||||
const domain = {
|
const typedData = eip712Utils.createCoordinatorApprovalTypedData(
|
||||||
name: constants.COORDINATOR_DOMAIN_NAME,
|
transaction,
|
||||||
version: constants.COORDINATOR_DOMAIN_VERSION,
|
|
||||||
verifyingContractAddress,
|
verifyingContractAddress,
|
||||||
};
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
const approval = {
|
|
||||||
txOrigin,
|
txOrigin,
|
||||||
transactionHash,
|
approvalExpirationTimeSeconds,
|
||||||
transactionSignature: transaction.signature,
|
|
||||||
approvalExpirationTimeSeconds: approvalExpirationTimeSeconds.toString(),
|
|
||||||
};
|
|
||||||
const typedData = eip712Utils.createTypedData(
|
|
||||||
constants.COORDINATOR_APPROVAL_SCHEMA.name,
|
|
||||||
{
|
|
||||||
CoordinatorApproval: constants.COORDINATOR_APPROVAL_SCHEMA.parameters,
|
|
||||||
},
|
|
||||||
approval,
|
|
||||||
domain,
|
|
||||||
);
|
);
|
||||||
const hashBuffer = signTypedDataUtils.generateTypedDataHash(typedData);
|
const hashBuffer = signTypedDataUtils.generateTypedDataHash(typedData);
|
||||||
return hashBuffer;
|
return hashBuffer;
|
||||||
|
@@ -2,11 +2,6 @@
|
|||||||
"extends": "../../tsconfig",
|
"extends": "../../tsconfig",
|
||||||
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
|
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
|
||||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
||||||
"files": [
|
"files": ["generated-artifacts/Coordinator.json", "generated-artifacts/CoordinatorRegistry.json"],
|
||||||
"generated-artifacts/Coordinator.json",
|
|
||||||
"generated-artifacts/CoordinatorRegistry.json",
|
|
||||||
"generated-artifacts/TestLibs.json",
|
|
||||||
"generated-artifacts/TestMixins.json"
|
|
||||||
],
|
|
||||||
"exclude": ["./deploy/solc/solc_bin"]
|
"exclude": ["./deploy/solc/solc_bin"]
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,23 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "1.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1553091633,
|
||||||
|
"version": "1.0.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@@ -4,3 +4,15 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v1.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v1.0.1 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v1.0.0 - _Invalid date_
|
||||||
|
|
||||||
|
* Created ERC1155 contracts package (#1657)
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
"contractsDir": "contracts",
|
"contractsDir": "contracts",
|
||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": { "enabled": true, "runs": 1000000 },
|
"optimizer": { "enabled": true, "runs": 1000000 },
|
||||||
"outputSelection": {
|
"outputSelection": {
|
||||||
"*": {
|
"*": {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-erc1155",
|
"name": "@0x/contracts-erc1155",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -46,11 +46,10 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -67,13 +66,14 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-utils": "^2.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/contracts-utils": "^3.1.0",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"ethereum-types": "^2.1.0",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
|
"ethereum-types": "^2.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
@@ -1,16 +1,23 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "2.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
|
||||||
"note": "Set evmVersion to byzantium",
|
|
||||||
"pr": 1678
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"note": "Upgrade contracts to Solidity 0.5.5",
|
"note": "Upgrade contracts to Solidity 0.5.5",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v2.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v2.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Upgrade contracts to Solidity 0.5.5 (#1682)
|
||||||
|
|
||||||
## v1.0.9 - _March 1, 2019_
|
## v1.0.9 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"isOfflineMode": false,
|
"isOfflineMode": false,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-erc20",
|
"name": "@0x/contracts-erc20",
|
||||||
"version": "1.0.9",
|
"version": "2.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -67,14 +67,14 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-exchange-libs": "^1.1.3",
|
"@0x/contracts-exchange-libs": "^2.1.0",
|
||||||
"@0x/contracts-utils": "^2.0.8",
|
"@0x/contracts-utils": "^3.1.0",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
@@ -1,16 +1,23 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "2.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
|
||||||
"note": "Set evmVersion to byzantium",
|
|
||||||
"pr": 1678
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"note": "Upgrade contracts to Solidity 0.5.5",
|
"note": "Upgrade contracts to Solidity 0.5.5",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v2.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v2.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Upgrade contracts to Solidity 0.5.5 (#1682)
|
||||||
|
|
||||||
## v1.0.9 - _March 1, 2019_
|
## v1.0.9 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"isOfflineMode": false,
|
"isOfflineMode": false,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-erc721",
|
"name": "@0x/contracts-erc721",
|
||||||
"version": "1.0.9",
|
"version": "2.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -67,13 +67,13 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-utils": "^2.0.8",
|
"@0x/contracts-utils": "^3.1.0",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
@@ -1,16 +1,23 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "2.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
|
||||||
"note": "Set evmVersion to byzantium",
|
|
||||||
"pr": 1678
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"note": "Do not reexport external dependencies",
|
"note": "Do not reexport external dependencies",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v2.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v2.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Do not reexport external dependencies (#1682)
|
||||||
|
|
||||||
## v1.0.9 - _March 1, 2019_
|
## v1.0.9 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"isOfflineMode": false,
|
"isOfflineMode": false,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-exchange-forwarder",
|
"name": "@0x/contracts-exchange-forwarder",
|
||||||
"version": "1.0.9",
|
"version": "2.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -46,12 +46,12 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contract-wrappers": "^8.0.3",
|
"@0x/contract-wrappers": "^8.0.5",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -68,19 +68,19 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-asset-proxy": "^1.0.9",
|
"@0x/contracts-asset-proxy": "^2.1.0",
|
||||||
"@0x/contracts-erc20": "1.0.8",
|
"@0x/contracts-erc20": "1.0.8",
|
||||||
"@0x/contracts-erc721": "1.0.8",
|
"@0x/contracts-erc721": "1.0.8",
|
||||||
"@0x/contracts-exchange": "1.0.2",
|
"@0x/contracts-exchange": "1.0.2",
|
||||||
"@0x/contracts-exchange-libs": "1.0.2",
|
"@0x/contracts-exchange-libs": "1.0.2",
|
||||||
"@0x/contracts-utils": "2.0.1",
|
"@0x/contracts-utils": "2.0.1",
|
||||||
"@0x/order-utils": "^7.0.2",
|
"@0x/order-utils": "^7.1.1",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
@@ -1,16 +1,23 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "2.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
|
||||||
"note": "Set evmVersion to byzantium",
|
|
||||||
"pr": 1678
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"note": "Upgrade contracts to Solidity 0.5.5",
|
"note": "Upgrade contracts to Solidity 0.5.5",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v2.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v2.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Upgrade contracts to Solidity 0.5.5 (#1682)
|
||||||
|
|
||||||
## v1.1.3 - _March 1, 2019_
|
## v1.1.3 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"isOfflineMode": false,
|
"isOfflineMode": false,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-exchange-libs",
|
"name": "@0x/contracts-exchange-libs",
|
||||||
"version": "1.1.3",
|
"version": "2.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/libs/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/libs/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -67,14 +67,14 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-utils": "^2.0.8",
|
"@0x/contracts-utils": "^3.1.0",
|
||||||
"@0x/order-utils": "^7.0.2",
|
"@0x/order-utils": "^7.1.1",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
@@ -1,11 +1,17 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "2.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
|
||||||
"note": "Set evmVersion to byzantium",
|
|
||||||
"pr": 1678
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"note": "Do not reexport external dependencies",
|
"note": "Do not reexport external dependencies",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
@@ -13,8 +19,13 @@
|
|||||||
{
|
{
|
||||||
"note": "Upgrade contracts to Solidity 0.5.5",
|
"note": "Upgrade contracts to Solidity 0.5.5",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Integration testing for ERC1155Proxy",
|
||||||
|
"pr": 1673
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
|
@@ -5,6 +5,16 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v2.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v2.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Do not reexport external dependencies (#1682)
|
||||||
|
* Upgrade contracts to Solidity 0.5.5 (#1682)
|
||||||
|
* Integration testing for ERC1155Proxy (#1673)
|
||||||
|
|
||||||
## v1.0.9 - _March 1, 2019_
|
## v1.0.9 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"isOfflineMode": false,
|
"isOfflineMode": false,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-exchange",
|
"name": "@0x/contracts-exchange",
|
||||||
"version": "1.0.9",
|
"version": "2.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -67,18 +67,19 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-asset-proxy": "^1.0.9",
|
"@0x/contracts-asset-proxy": "^2.1.0",
|
||||||
"@0x/contracts-erc20": "^1.0.9",
|
"@0x/contracts-erc1155": "^1.1.0",
|
||||||
"@0x/contracts-erc721": "^1.0.9",
|
"@0x/contracts-erc20": "^2.1.0",
|
||||||
"@0x/contracts-exchange-libs": "^1.1.3",
|
"@0x/contracts-erc721": "^2.1.0",
|
||||||
"@0x/contracts-utils": "^2.0.8",
|
"@0x/contracts-exchange-libs": "^2.1.0",
|
||||||
"@0x/order-utils": "^7.0.2",
|
"@0x/contracts-utils": "^3.1.0",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/order-utils": "^7.1.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"ethereum-types": "^2.1.0",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
|
"ethereum-types": "^2.1.1",
|
||||||
"ethereumjs-util": "^5.1.1",
|
"ethereumjs-util": "^5.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
artifacts as proxyArtifacts,
|
artifacts as proxyArtifacts,
|
||||||
|
ERC1155ProxyWrapper,
|
||||||
ERC20ProxyContract,
|
ERC20ProxyContract,
|
||||||
ERC20Wrapper,
|
ERC20Wrapper,
|
||||||
ERC721ProxyContract,
|
ERC721ProxyContract,
|
||||||
ERC721Wrapper,
|
ERC721Wrapper,
|
||||||
MultiAssetProxyContract,
|
MultiAssetProxyContract,
|
||||||
} from '@0x/contracts-asset-proxy';
|
} from '@0x/contracts-asset-proxy';
|
||||||
|
import { ERC1155MintableContract } from '@0x/contracts-erc1155';
|
||||||
import {
|
import {
|
||||||
artifacts as erc20Artifacts,
|
artifacts as erc20Artifacts,
|
||||||
DummyERC20TokenContract,
|
DummyERC20TokenContract,
|
||||||
@@ -36,6 +38,7 @@ import { LogWithDecodedArgs } from 'ethereum-types';
|
|||||||
import ethUtil = require('ethereumjs-util');
|
import ethUtil = require('ethereumjs-util');
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import { Erc1155Wrapper } from '../../erc1155/lib/src';
|
||||||
import {
|
import {
|
||||||
artifacts,
|
artifacts,
|
||||||
ExchangeCancelEventArgs,
|
ExchangeCancelEventArgs,
|
||||||
@@ -64,19 +67,26 @@ describe('Exchange core', () => {
|
|||||||
let exchange: ExchangeContract;
|
let exchange: ExchangeContract;
|
||||||
let erc20Proxy: ERC20ProxyContract;
|
let erc20Proxy: ERC20ProxyContract;
|
||||||
let erc721Proxy: ERC721ProxyContract;
|
let erc721Proxy: ERC721ProxyContract;
|
||||||
|
let erc1155Proxy: ERC721ProxyContract;
|
||||||
let multiAssetProxy: MultiAssetProxyContract;
|
let multiAssetProxy: MultiAssetProxyContract;
|
||||||
let maliciousWallet: TestStaticCallReceiverContract;
|
let maliciousWallet: TestStaticCallReceiverContract;
|
||||||
let maliciousValidator: TestStaticCallReceiverContract;
|
let maliciousValidator: TestStaticCallReceiverContract;
|
||||||
|
let erc1155Contract: ERC1155MintableContract;
|
||||||
|
|
||||||
let signedOrder: SignedOrder;
|
let signedOrder: SignedOrder;
|
||||||
let erc20Balances: ERC20BalancesByOwner;
|
let erc20Balances: ERC20BalancesByOwner;
|
||||||
let exchangeWrapper: ExchangeWrapper;
|
let exchangeWrapper: ExchangeWrapper;
|
||||||
let erc20Wrapper: ERC20Wrapper;
|
let erc20Wrapper: ERC20Wrapper;
|
||||||
let erc721Wrapper: ERC721Wrapper;
|
let erc721Wrapper: ERC721Wrapper;
|
||||||
|
let erc1155Wrapper: Erc1155Wrapper;
|
||||||
|
let erc1155ProxyWrapper: ERC1155ProxyWrapper;
|
||||||
let orderFactory: OrderFactory;
|
let orderFactory: OrderFactory;
|
||||||
|
|
||||||
let erc721MakerAssetIds: BigNumber[];
|
let erc721MakerAssetIds: BigNumber[];
|
||||||
let erc721TakerAssetIds: BigNumber[];
|
let erc721TakerAssetIds: BigNumber[];
|
||||||
|
let erc1155FungibleTokens: BigNumber[];
|
||||||
|
let erc1155NonFungibleTokensOwnedByMaker: BigNumber[];
|
||||||
|
let erc1155NonFungibleTokensOwnedByTaker: BigNumber[];
|
||||||
|
|
||||||
let defaultMakerAssetAddress: string;
|
let defaultMakerAssetAddress: string;
|
||||||
let defaultTakerAssetAddress: string;
|
let defaultTakerAssetAddress: string;
|
||||||
@@ -93,6 +103,7 @@ describe('Exchange core', () => {
|
|||||||
|
|
||||||
erc20Wrapper = new ERC20Wrapper(provider, usedAddresses, owner);
|
erc20Wrapper = new ERC20Wrapper(provider, usedAddresses, owner);
|
||||||
erc721Wrapper = new ERC721Wrapper(provider, usedAddresses, owner);
|
erc721Wrapper = new ERC721Wrapper(provider, usedAddresses, owner);
|
||||||
|
erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner);
|
||||||
|
|
||||||
// Deploy AssetProxies, Exchange, tokens, and malicious contracts
|
// Deploy AssetProxies, Exchange, tokens, and malicious contracts
|
||||||
erc20Proxy = await erc20Wrapper.deployProxyAsync();
|
erc20Proxy = await erc20Wrapper.deployProxyAsync();
|
||||||
@@ -108,6 +119,9 @@ describe('Exchange core', () => {
|
|||||||
constants.DUMMY_TOKEN_DECIMALS,
|
constants.DUMMY_TOKEN_DECIMALS,
|
||||||
);
|
);
|
||||||
[erc721Token] = await erc721Wrapper.deployDummyTokensAsync();
|
[erc721Token] = await erc721Wrapper.deployDummyTokensAsync();
|
||||||
|
erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync();
|
||||||
|
[erc1155Wrapper] = await erc1155ProxyWrapper.deployDummyContractsAsync();
|
||||||
|
erc1155Contract = erc1155Wrapper.getContract();
|
||||||
exchange = await ExchangeContract.deployFrom0xArtifactAsync(
|
exchange = await ExchangeContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.Exchange,
|
artifacts.Exchange,
|
||||||
provider,
|
provider,
|
||||||
@@ -154,6 +168,20 @@ describe('Exchange core', () => {
|
|||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Configure ERC1155Proxy
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await erc1155Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
|
||||||
|
from: owner,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await erc1155Proxy.addAuthorizedAddress.sendTransactionAsync(multiAssetProxy.address, {
|
||||||
|
from: owner,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
|
||||||
// Configure MultiAssetProxy
|
// Configure MultiAssetProxy
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await multiAssetProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
|
await multiAssetProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
|
||||||
@@ -178,6 +206,7 @@ describe('Exchange core', () => {
|
|||||||
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
||||||
await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
|
await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
|
||||||
await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner);
|
await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner);
|
||||||
|
await exchangeWrapper.registerAssetProxyAsync(erc1155Proxy.address, owner);
|
||||||
await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, owner);
|
await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, owner);
|
||||||
|
|
||||||
// Configure ERC20 tokens
|
// Configure ERC20 tokens
|
||||||
@@ -189,6 +218,23 @@ describe('Exchange core', () => {
|
|||||||
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
|
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
|
||||||
erc721TakerAssetIds = erc721Balances[takerAddress][erc721Token.address];
|
erc721TakerAssetIds = erc721Balances[takerAddress][erc721Token.address];
|
||||||
|
|
||||||
|
// Configure ERC1155 tokens
|
||||||
|
await erc1155ProxyWrapper.setBalancesAndAllowancesAsync();
|
||||||
|
erc1155FungibleTokens = erc1155ProxyWrapper.getFungibleTokenIds();
|
||||||
|
const nonFungibleTokens = erc1155ProxyWrapper.getNonFungibleTokenIds();
|
||||||
|
const tokenBalances = await erc1155ProxyWrapper.getBalancesAsync();
|
||||||
|
erc1155NonFungibleTokensOwnedByMaker = [];
|
||||||
|
erc1155NonFungibleTokensOwnedByTaker = [];
|
||||||
|
_.each(nonFungibleTokens, (nonFungibleToken: BigNumber) => {
|
||||||
|
const nonFungibleTokenAsString = nonFungibleToken.toString();
|
||||||
|
const nonFungibleTokenHeldByMaker =
|
||||||
|
tokenBalances.nonFungible[makerAddress][erc1155Contract.address][nonFungibleTokenAsString][0];
|
||||||
|
erc1155NonFungibleTokensOwnedByMaker.push(nonFungibleTokenHeldByMaker);
|
||||||
|
const nonFungibleTokenHeldByTaker =
|
||||||
|
tokenBalances.nonFungible[takerAddress][erc1155Contract.address][nonFungibleTokenAsString][0];
|
||||||
|
erc1155NonFungibleTokensOwnedByTaker.push(nonFungibleTokenHeldByTaker);
|
||||||
|
});
|
||||||
|
|
||||||
// Configure order defaults
|
// Configure order defaults
|
||||||
defaultMakerAssetAddress = erc20TokenA.address;
|
defaultMakerAssetAddress = erc20TokenA.address;
|
||||||
defaultTakerAssetAddress = erc20TokenB.address;
|
defaultTakerAssetAddress = erc20TokenB.address;
|
||||||
@@ -1040,6 +1086,435 @@ describe('Exchange core', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('Testing exchange of erc1155 assets', () => {
|
||||||
|
it('should allow a single fungible erc1155 asset to be exchanged for another', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const tokenHolders = [makerAddress, takerAddress];
|
||||||
|
const makerAssetsToTransfer = erc1155FungibleTokens.slice(0, 1);
|
||||||
|
const takerAssetsToTransfer = erc1155FungibleTokens.slice(1, 2);
|
||||||
|
const makerValuesToTransfer = [new BigNumber(500)];
|
||||||
|
const takerValuesToTransfer = [new BigNumber(200)];
|
||||||
|
const tokensToTransfer = makerAssetsToTransfer.concat(takerAssetsToTransfer);
|
||||||
|
const makerAssetAmount = new BigNumber(1);
|
||||||
|
const takerAssetAmount = new BigNumber(1);
|
||||||
|
const totalMakerValuesTransferred = _.map(makerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(makerAssetAmount);
|
||||||
|
});
|
||||||
|
const totalTakerValuesTransferred = _.map(takerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(takerAssetAmount);
|
||||||
|
});
|
||||||
|
const receiverCallbackData = '0x';
|
||||||
|
const makerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
makerAssetsToTransfer,
|
||||||
|
makerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
const takerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
takerAssetsToTransfer,
|
||||||
|
takerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
|
makerAssetData,
|
||||||
|
takerAssetData,
|
||||||
|
makerAssetAmount,
|
||||||
|
takerAssetAmount,
|
||||||
|
makerFee: constants.ZERO_AMOUNT,
|
||||||
|
takerFee: constants.ZERO_AMOUNT,
|
||||||
|
});
|
||||||
|
const takerAssetFillAmount = new BigNumber(1);
|
||||||
|
// check balances before transfer
|
||||||
|
const expectedInitialBalances = [
|
||||||
|
// makerAddress / makerToken
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// makerAddress / takerToken
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / makerToken
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / takerToken
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// execute transfer
|
||||||
|
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
|
||||||
|
takerAssetFillAmount,
|
||||||
|
});
|
||||||
|
// check balances after transfer
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
// makerAddress / makerToken
|
||||||
|
expectedInitialBalances[0].minus(totalMakerValuesTransferred[0]),
|
||||||
|
// makerAddress / takerToken
|
||||||
|
expectedInitialBalances[1].plus(totalTakerValuesTransferred[0]),
|
||||||
|
// takerAddress / makerToken
|
||||||
|
expectedInitialBalances[2].plus(totalMakerValuesTransferred[0]),
|
||||||
|
// takerAddress / takerToken
|
||||||
|
expectedInitialBalances[3].minus(totalTakerValuesTransferred[0]),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
});
|
||||||
|
it('should allow a single non-fungible erc1155 asset to be exchanged for another', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const tokenHolders = [makerAddress, takerAddress];
|
||||||
|
const makerAssetsToTransfer = erc1155NonFungibleTokensOwnedByMaker.slice(0, 1);
|
||||||
|
const takerAssetsToTransfer = erc1155NonFungibleTokensOwnedByTaker.slice(0, 1);
|
||||||
|
const makerValuesToTransfer = [new BigNumber(1)];
|
||||||
|
const takerValuesToTransfer = [new BigNumber(1)];
|
||||||
|
const tokensToTransfer = makerAssetsToTransfer.concat(takerAssetsToTransfer);
|
||||||
|
const makerAssetAmount = new BigNumber(1);
|
||||||
|
const takerAssetAmount = new BigNumber(1);
|
||||||
|
const totalMakerValuesTransferred = _.map(makerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(makerAssetAmount);
|
||||||
|
});
|
||||||
|
const totalTakerValuesTransferred = _.map(takerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(takerAssetAmount);
|
||||||
|
});
|
||||||
|
const receiverCallbackData = '0x';
|
||||||
|
const makerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
makerAssetsToTransfer,
|
||||||
|
makerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
const takerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
takerAssetsToTransfer,
|
||||||
|
takerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
|
makerAssetData,
|
||||||
|
takerAssetData,
|
||||||
|
makerAssetAmount,
|
||||||
|
takerAssetAmount,
|
||||||
|
makerFee: constants.ZERO_AMOUNT,
|
||||||
|
takerFee: constants.ZERO_AMOUNT,
|
||||||
|
});
|
||||||
|
const takerAssetFillAmount = new BigNumber(1);
|
||||||
|
// check balances before transfer
|
||||||
|
const nftOwnerBalance = new BigNumber(1);
|
||||||
|
const nftNotOwnerBalance = new BigNumber(0);
|
||||||
|
const expectedInitialBalances = [
|
||||||
|
// makerAddress / makerToken
|
||||||
|
nftOwnerBalance,
|
||||||
|
// makerAddress / takerToken
|
||||||
|
nftNotOwnerBalance,
|
||||||
|
// takerAddress / makerToken
|
||||||
|
nftNotOwnerBalance,
|
||||||
|
// takerAddress / takerToken
|
||||||
|
nftOwnerBalance,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// execute transfer
|
||||||
|
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
|
||||||
|
takerAssetFillAmount,
|
||||||
|
});
|
||||||
|
// check balances after transfer
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
// makerAddress / makerToken
|
||||||
|
expectedInitialBalances[0].minus(totalMakerValuesTransferred[0]),
|
||||||
|
// makerAddress / takerToken
|
||||||
|
expectedInitialBalances[1].plus(totalTakerValuesTransferred[0]),
|
||||||
|
// takerAddress / makerToken
|
||||||
|
expectedInitialBalances[2].plus(totalMakerValuesTransferred[0]),
|
||||||
|
// takerAddress / takerToken
|
||||||
|
expectedInitialBalances[3].minus(totalTakerValuesTransferred[0]),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
});
|
||||||
|
it('should allow multiple erc1155 assets to be exchanged for a single asset', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
const tokenHolders = [makerAddress, takerAddress];
|
||||||
|
const makerAssetsToTransfer = erc1155FungibleTokens.slice(0, 3);
|
||||||
|
const takerAssetsToTransfer = erc1155NonFungibleTokensOwnedByTaker.slice(0, 1);
|
||||||
|
const makerValuesToTransfer = [new BigNumber(500), new BigNumber(700), new BigNumber(900)];
|
||||||
|
const takerValuesToTransfer = [new BigNumber(1)];
|
||||||
|
const tokensToTransfer = makerAssetsToTransfer.concat(takerAssetsToTransfer);
|
||||||
|
const makerAssetAmount = new BigNumber(1);
|
||||||
|
const takerAssetAmount = new BigNumber(1);
|
||||||
|
const totalMakerValuesTransferred = _.map(makerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(makerAssetAmount);
|
||||||
|
});
|
||||||
|
const totalTakerValuesTransferred = _.map(takerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(takerAssetAmount);
|
||||||
|
});
|
||||||
|
const receiverCallbackData = '0x';
|
||||||
|
const makerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
makerAssetsToTransfer,
|
||||||
|
makerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
const takerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
takerAssetsToTransfer,
|
||||||
|
takerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
|
makerAssetData,
|
||||||
|
takerAssetData,
|
||||||
|
makerAssetAmount,
|
||||||
|
takerAssetAmount,
|
||||||
|
makerFee: constants.ZERO_AMOUNT,
|
||||||
|
takerFee: constants.ZERO_AMOUNT,
|
||||||
|
});
|
||||||
|
const takerAssetFillAmount = new BigNumber(1);
|
||||||
|
// check balances before transfer
|
||||||
|
const nftOwnerBalance = new BigNumber(1);
|
||||||
|
const nftNotOwnerBalance = new BigNumber(0);
|
||||||
|
const expectedInitialBalances = [
|
||||||
|
// makerAddress / makerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// makerAddress / makerToken[1]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// makerAddress / makerToken[2]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// makerAddress / takerToken
|
||||||
|
nftNotOwnerBalance,
|
||||||
|
// takerAddress / makerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / makerToken[1]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / makerToken[2]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / takerToken
|
||||||
|
nftOwnerBalance,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// execute transfer
|
||||||
|
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
|
||||||
|
takerAssetFillAmount,
|
||||||
|
});
|
||||||
|
// check balances after transfer
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
// makerAddress / makerToken[0]
|
||||||
|
expectedInitialBalances[0].minus(totalMakerValuesTransferred[0]),
|
||||||
|
// makerAddress / makerToken[1]
|
||||||
|
expectedInitialBalances[1].minus(totalMakerValuesTransferred[1]),
|
||||||
|
// makerAddress / makerToken[2]
|
||||||
|
expectedInitialBalances[2].minus(totalMakerValuesTransferred[2]),
|
||||||
|
// makerAddress / takerToken
|
||||||
|
expectedInitialBalances[3].plus(totalTakerValuesTransferred[0]),
|
||||||
|
// takerAddress / makerToken[0]
|
||||||
|
expectedInitialBalances[4].plus(totalMakerValuesTransferred[0]),
|
||||||
|
// takerAddress / makerToken[1]
|
||||||
|
expectedInitialBalances[5].plus(totalMakerValuesTransferred[1]),
|
||||||
|
// takerAddress / makerToken[2]
|
||||||
|
expectedInitialBalances[6].plus(totalMakerValuesTransferred[2]),
|
||||||
|
// takerAddress / takerToken
|
||||||
|
expectedInitialBalances[7].minus(totalTakerValuesTransferred[0]),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
});
|
||||||
|
it('should allow multiple erc1155 assets to be exchanged for multiple erc1155 assets, mixed fungible/non-fungible', async () => {
|
||||||
|
// setup test parameters
|
||||||
|
// the maker is trading two fungibles & one non-fungible
|
||||||
|
// the taker is trading one fungible & two non-fungibles
|
||||||
|
const tokenHolders = [makerAddress, takerAddress];
|
||||||
|
const makerFungibleAssetsToTransfer = erc1155FungibleTokens.slice(0, 2);
|
||||||
|
const makerNonFungibleAssetsToTransfer = erc1155NonFungibleTokensOwnedByMaker.slice(0, 1);
|
||||||
|
const makerAssetsToTransfer = makerFungibleAssetsToTransfer.concat(makerNonFungibleAssetsToTransfer);
|
||||||
|
const takerFungibleAssetsToTransfer = erc1155FungibleTokens.slice(2, 3);
|
||||||
|
const takerNonFungibleAssetsToTransfer = erc1155NonFungibleTokensOwnedByTaker.slice(0, 2);
|
||||||
|
const takerAssetsToTransfer = takerFungibleAssetsToTransfer.concat(takerNonFungibleAssetsToTransfer);
|
||||||
|
const makerValuesToTransfer = [new BigNumber(500), new BigNumber(700), new BigNumber(1)];
|
||||||
|
const takerValuesToTransfer = [new BigNumber(900), new BigNumber(1), new BigNumber(1)];
|
||||||
|
const tokensToTransfer = makerAssetsToTransfer.concat(takerAssetsToTransfer);
|
||||||
|
const makerAssetAmount = new BigNumber(1);
|
||||||
|
const takerAssetAmount = new BigNumber(1);
|
||||||
|
const totalMakerValuesTransferred = _.map(makerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(makerAssetAmount);
|
||||||
|
});
|
||||||
|
const totalTakerValuesTransferred = _.map(takerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value.times(takerAssetAmount);
|
||||||
|
});
|
||||||
|
const receiverCallbackData = '0x';
|
||||||
|
const makerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
makerAssetsToTransfer,
|
||||||
|
makerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
const takerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
takerAssetsToTransfer,
|
||||||
|
takerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
|
makerAssetData,
|
||||||
|
takerAssetData,
|
||||||
|
makerAssetAmount,
|
||||||
|
takerAssetAmount,
|
||||||
|
makerFee: constants.ZERO_AMOUNT,
|
||||||
|
takerFee: constants.ZERO_AMOUNT,
|
||||||
|
});
|
||||||
|
const takerAssetFillAmount = new BigNumber(1);
|
||||||
|
// check balances before transfer
|
||||||
|
const nftOwnerBalance = new BigNumber(1);
|
||||||
|
const nftNotOwnerBalance = new BigNumber(0);
|
||||||
|
const expectedInitialBalances = [
|
||||||
|
// makerAddress / makerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// makerAddress / makerToken[1]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// makerAddress / makerToken[2]
|
||||||
|
nftOwnerBalance,
|
||||||
|
// makerAddress / takerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// makerAddress / takerToken[1]
|
||||||
|
nftNotOwnerBalance,
|
||||||
|
// makerAddress / takerToken[2]
|
||||||
|
nftNotOwnerBalance,
|
||||||
|
// takerAddress / makerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / makerToken[1]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / makerToken[2]
|
||||||
|
nftNotOwnerBalance,
|
||||||
|
// takerAddress / takerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / takerToken[1]
|
||||||
|
nftOwnerBalance,
|
||||||
|
// takerAddress / takerToken[2]
|
||||||
|
nftOwnerBalance,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// execute transfer
|
||||||
|
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
|
||||||
|
takerAssetFillAmount,
|
||||||
|
});
|
||||||
|
// check balances after transfer
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
// makerAddress / makerToken[0]
|
||||||
|
expectedInitialBalances[0].minus(totalMakerValuesTransferred[0]),
|
||||||
|
// makerAddress / makerToken[1]
|
||||||
|
expectedInitialBalances[1].minus(totalMakerValuesTransferred[1]),
|
||||||
|
// makerAddress / makerToken[2]
|
||||||
|
expectedInitialBalances[2].minus(totalMakerValuesTransferred[2]),
|
||||||
|
// makerAddress / takerToken[0]
|
||||||
|
expectedInitialBalances[3].plus(totalTakerValuesTransferred[0]),
|
||||||
|
// makerAddress / takerToken[1]
|
||||||
|
expectedInitialBalances[4].plus(totalTakerValuesTransferred[1]),
|
||||||
|
// makerAddress / takerToken[2]
|
||||||
|
expectedInitialBalances[5].plus(totalTakerValuesTransferred[2]),
|
||||||
|
// takerAddress / makerToken[0]
|
||||||
|
expectedInitialBalances[6].plus(totalMakerValuesTransferred[0]),
|
||||||
|
// takerAddress / makerToken[1]
|
||||||
|
expectedInitialBalances[7].plus(totalMakerValuesTransferred[1]),
|
||||||
|
// takerAddress / makerToken[2]
|
||||||
|
expectedInitialBalances[8].plus(totalMakerValuesTransferred[2]),
|
||||||
|
// takerAddress / takerToken[0]
|
||||||
|
expectedInitialBalances[9].minus(totalTakerValuesTransferred[0]),
|
||||||
|
// takerAddress / takerToken[1]
|
||||||
|
expectedInitialBalances[10].minus(totalTakerValuesTransferred[1]),
|
||||||
|
// takerAddress / takerToken[2]
|
||||||
|
expectedInitialBalances[11].minus(totalTakerValuesTransferred[2]),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
});
|
||||||
|
it('should allow an order exchanging erc1155 assets to be partially filled', async () => {
|
||||||
|
// NOTICE:
|
||||||
|
// As-per the eip1155 standard, there is no way to distinguish between a fungible or non-fungible erc1155 assets.
|
||||||
|
// Hence we cannot force partial fills to fail if there is a non-fungible asset (which should be fill or kill).
|
||||||
|
// We considered encoding whether an asset is fungible/non-fungible in erc1155 assetData, but
|
||||||
|
// this is no more robust than a simple check by the client. Enforcing this at the smart contract level
|
||||||
|
// is something that could be done with the upcoming static call proxy.
|
||||||
|
//
|
||||||
|
// setup test parameters
|
||||||
|
// the maker is trading two fungibles and the taker is trading one fungible
|
||||||
|
// note that this will result in a partial fill because the `takerAssetAmount`
|
||||||
|
// less than the `takerAssetAmount` of the order.
|
||||||
|
const takerAssetFillAmount = new BigNumber(6);
|
||||||
|
const tokenHolders = [makerAddress, takerAddress];
|
||||||
|
const makerAssetsToTransfer = erc1155FungibleTokens.slice(0, 2);
|
||||||
|
const takerAssetsToTransfer = erc1155FungibleTokens.slice(2, 3);
|
||||||
|
const makerValuesToTransfer = [new BigNumber(500), new BigNumber(700)];
|
||||||
|
const takerValuesToTransfer = [new BigNumber(900)];
|
||||||
|
const tokensToTransfer = makerAssetsToTransfer.concat(takerAssetsToTransfer);
|
||||||
|
const makerAssetAmount = new BigNumber(10);
|
||||||
|
const takerAssetAmount = new BigNumber(20);
|
||||||
|
const totalMakerValuesTransferred = _.map(makerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value
|
||||||
|
.times(makerAssetAmount)
|
||||||
|
.times(takerAssetFillAmount)
|
||||||
|
.dividedToIntegerBy(takerAssetAmount);
|
||||||
|
});
|
||||||
|
const totalTakerValuesTransferred = _.map(takerValuesToTransfer, (value: BigNumber) => {
|
||||||
|
return value
|
||||||
|
.times(takerAssetAmount)
|
||||||
|
.times(takerAssetFillAmount)
|
||||||
|
.dividedToIntegerBy(takerAssetAmount);
|
||||||
|
});
|
||||||
|
const receiverCallbackData = '0x';
|
||||||
|
const makerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
makerAssetsToTransfer,
|
||||||
|
makerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
const takerAssetData = assetDataUtils.encodeERC1155AssetData(
|
||||||
|
erc1155Contract.address,
|
||||||
|
takerAssetsToTransfer,
|
||||||
|
takerValuesToTransfer,
|
||||||
|
receiverCallbackData,
|
||||||
|
);
|
||||||
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
|
makerAssetData,
|
||||||
|
takerAssetData,
|
||||||
|
makerAssetAmount,
|
||||||
|
takerAssetAmount,
|
||||||
|
makerFee: constants.ZERO_AMOUNT,
|
||||||
|
takerFee: constants.ZERO_AMOUNT,
|
||||||
|
});
|
||||||
|
// check balances before transfer
|
||||||
|
const expectedInitialBalances = [
|
||||||
|
// makerAddress / makerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// makerAddress / makerToken[1]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// makerAddress / takerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / makerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / makerToken[1]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
// takerAddress / takerToken[0]
|
||||||
|
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedInitialBalances);
|
||||||
|
// execute transfer
|
||||||
|
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
|
||||||
|
takerAssetFillAmount,
|
||||||
|
});
|
||||||
|
// check balances after transfer
|
||||||
|
const expectedFinalBalances = [
|
||||||
|
// makerAddress / makerToken[0]
|
||||||
|
expectedInitialBalances[0].minus(totalMakerValuesTransferred[0]),
|
||||||
|
// makerAddress / makerToken[1]
|
||||||
|
expectedInitialBalances[1].minus(totalMakerValuesTransferred[1]),
|
||||||
|
// makerAddress / takerToken[0]
|
||||||
|
expectedInitialBalances[2].plus(totalTakerValuesTransferred[0]),
|
||||||
|
// takerAddress / makerToken[0]
|
||||||
|
expectedInitialBalances[3].plus(totalMakerValuesTransferred[0]),
|
||||||
|
// takerAddress / makerToken[1]
|
||||||
|
expectedInitialBalances[4].plus(totalMakerValuesTransferred[1]),
|
||||||
|
// takerAddress / takerToken[0]
|
||||||
|
expectedInitialBalances[5].minus(totalTakerValuesTransferred[0]),
|
||||||
|
];
|
||||||
|
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
|
||||||
|
// check that the order is partially filled
|
||||||
|
const orderInfo = await exchangeWrapper.getOrderInfoAsync(signedOrder);
|
||||||
|
const expectedOrderHash = orderHashUtils.getOrderHashHex(signedOrder);
|
||||||
|
const expectedTakerAssetFilledAmount = takerAssetFillAmount;
|
||||||
|
const expectedOrderStatus = OrderStatus.Fillable;
|
||||||
|
expect(orderInfo.orderHash).to.be.equal(expectedOrderHash);
|
||||||
|
expect(orderInfo.orderTakerAssetFilledAmount).to.be.bignumber.equal(expectedTakerAssetFilledAmount);
|
||||||
|
expect(orderInfo.orderStatus).to.equal(expectedOrderStatus);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('getOrderInfo', () => {
|
describe('getOrderInfo', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { artifacts as erc1155Artifacts } from '@0x/contracts-erc1155';
|
||||||
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
|
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
|
||||||
import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
|
import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
|
||||||
import {
|
import {
|
||||||
@@ -25,7 +26,12 @@ export class ExchangeWrapper {
|
|||||||
constructor(exchangeContract: ExchangeContract, provider: Web3ProviderEngine | ZeroExProvider) {
|
constructor(exchangeContract: ExchangeContract, provider: Web3ProviderEngine | ZeroExProvider) {
|
||||||
this._exchange = exchangeContract;
|
this._exchange = exchangeContract;
|
||||||
this._web3Wrapper = new Web3Wrapper(provider);
|
this._web3Wrapper = new Web3Wrapper(provider);
|
||||||
this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...erc20Artifacts, ...erc721Artifacts });
|
this._logDecoder = new LogDecoder(this._web3Wrapper, {
|
||||||
|
...artifacts,
|
||||||
|
...erc20Artifacts,
|
||||||
|
...erc721Artifacts,
|
||||||
|
...erc1155Artifacts,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public async fillOrderAsync(
|
public async fillOrderAsync(
|
||||||
signedOrder: SignedOrder,
|
signedOrder: SignedOrder,
|
||||||
|
@@ -1,11 +1,17 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "3.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
|
||||||
"note": "Set evmVersion to byzantium",
|
|
||||||
"pr": 1678
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"note": "Do not reexport external dependencies",
|
"note": "Do not reexport external dependencies",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
@@ -14,7 +20,8 @@
|
|||||||
"note": "Upgrade contracts to Solidity 0.5.5",
|
"note": "Upgrade contracts to Solidity 0.5.5",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
|
@@ -5,6 +5,15 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v3.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v3.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Do not reexport external dependencies (#1682)
|
||||||
|
* Upgrade contracts to Solidity 0.5.5 (#1682)
|
||||||
|
|
||||||
## v2.0.8 - _March 1, 2019_
|
## v2.0.8 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"isOfflineMode": false,
|
"isOfflineMode": false,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-extensions",
|
"name": "@0x/contracts-extensions",
|
||||||
"version": "2.0.8",
|
"version": "3.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -46,12 +46,12 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contract-wrappers": "^8.0.3",
|
"@0x/contract-wrappers": "^8.0.5",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -68,19 +68,19 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-asset-proxy": "^1.0.9",
|
"@0x/contracts-asset-proxy": "^2.1.0",
|
||||||
"@0x/contracts-erc20": "^1.0.9",
|
"@0x/contracts-erc20": "^2.1.0",
|
||||||
"@0x/contracts-erc721": "^1.0.9",
|
"@0x/contracts-erc721": "^2.1.0",
|
||||||
"@0x/contracts-exchange": "^1.0.9",
|
"@0x/contracts-exchange": "^2.1.0",
|
||||||
"@0x/contracts-exchange-libs": "^1.1.3",
|
"@0x/contracts-exchange-libs": "^2.1.0",
|
||||||
"@0x/contracts-utils": "^2.0.8",
|
"@0x/contracts-utils": "^3.1.0",
|
||||||
"@0x/order-utils": "^7.0.2",
|
"@0x/order-utils": "^7.1.1",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
@@ -1,16 +1,23 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "3.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Run Web3ProviderEngine without excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
|
||||||
"note": "Set evmVersion to byzantium",
|
|
||||||
"pr": 1678
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"note": "Do not reexport external dependencies",
|
"note": "Do not reexport external dependencies",
|
||||||
"pr": 1682
|
"pr": 1682
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v3.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Run Web3ProviderEngine without excess block polling (#1695)
|
||||||
|
|
||||||
|
## v3.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Do not reexport external dependencies (#1682)
|
||||||
|
|
||||||
## v2.0.8 - _March 1, 2019_
|
## v2.0.8 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"isOfflineMode": false,
|
"isOfflineMode": false,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-multisig",
|
"name": "@0x/contracts-multisig",
|
||||||
"version": "2.0.8",
|
"version": "3.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/multisig/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/multisig/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@@ -67,15 +67,15 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contracts-asset-proxy": "^1.0.9",
|
"@0x/contracts-asset-proxy": "^2.1.0",
|
||||||
"@0x/contracts-erc20": "^1.0.9",
|
"@0x/contracts-erc20": "^2.1.0",
|
||||||
"@0x/contracts-utils": "2.0.1",
|
"@0x/contracts-utils": "2.0.1",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider engine', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
|
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
|
@@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1553183790,
|
||||||
|
"version": "3.1.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
@@ -6,7 +15,8 @@
|
|||||||
"note": "Added ERC1155Proxy test constants and interfaces",
|
"note": "Added ERC1155Proxy test constants and interfaces",
|
||||||
"pr": 1661
|
"pr": 1661
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "3.0.9",
|
"version": "3.0.9",
|
||||||
|
@@ -5,6 +5,19 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v3.1.1 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v3.1.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Added ERC1155Proxy test constants and interfaces (#1661)
|
||||||
|
|
||||||
|
## v3.0.9 - _Invalid date_
|
||||||
|
|
||||||
|
* Set evmVersion to byzantium (#1678)
|
||||||
|
* Remove Coordinator EIP712 constants. They're now in the `order-utils` package. (#1705)
|
||||||
|
|
||||||
## v3.0.8 - _March 1, 2019_
|
## v3.0.8 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-test-utils",
|
"name": "@0x/contracts-test-utils",
|
||||||
"version": "3.0.8",
|
"version": "3.1.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -40,19 +40,19 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/order-utils": "^7.0.2",
|
"@0x/order-utils": "^7.1.1",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/sol-coverage": "^3.0.0",
|
"@0x/sol-coverage": "^3.0.2",
|
||||||
"@0x/sol-profiler": "^3.1.2",
|
"@0x/sol-profiler": "^3.1.4",
|
||||||
"@0x/sol-trace": "^2.0.8",
|
"@0x/sol-trace": "^2.0.10",
|
||||||
"@0x/subproviders": "^4.0.2",
|
"@0x/subproviders": "^4.0.4",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"@types/bn.js": "^4.11.0",
|
"@types/bn.js": "^4.11.0",
|
||||||
"@types/js-combinatorics": "^0.5.29",
|
"@types/js-combinatorics": "^0.5.29",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "^7.1.0",
|
||||||
"chai-bignumber": "^3.0.0",
|
"chai-bignumber": "^3.0.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"ethereumjs-util": "^5.1.1",
|
"ethereumjs-util": "^5.1.1",
|
||||||
"ethers": "~4.0.4",
|
"ethers": "~4.0.4",
|
||||||
"js-combinatorics": "^0.5.3",
|
"js-combinatorics": "^0.5.3",
|
||||||
|
@@ -38,7 +38,7 @@ export const constants = {
|
|||||||
NUM_DUMMY_ERC20_TO_DEPLOY: 3,
|
NUM_DUMMY_ERC20_TO_DEPLOY: 3,
|
||||||
NUM_DUMMY_ERC721_TO_DEPLOY: 2,
|
NUM_DUMMY_ERC721_TO_DEPLOY: 2,
|
||||||
NUM_ERC721_TOKENS_TO_MINT: 2,
|
NUM_ERC721_TOKENS_TO_MINT: 2,
|
||||||
NUM_DUMMY_ERC1155_CONTRACTS_TO_DEPLOY: 1,
|
NUM_DUMMY_ERC1155_CONTRACTS_TO_DEPLOY: 2,
|
||||||
NUM_ERC1155_FUNGIBLE_TOKENS_MINT: 3,
|
NUM_ERC1155_FUNGIBLE_TOKENS_MINT: 3,
|
||||||
NUM_ERC1155_NONFUNGIBLE_TOKENS_MINT: 3,
|
NUM_ERC1155_NONFUNGIBLE_TOKENS_MINT: 3,
|
||||||
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
||||||
|
@@ -1,11 +1,17 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "3.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Added `startProviderEngine` to `providerUtils`. Preventing excess block polling",
|
||||||
|
"pr": 1695
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
|
||||||
"note": "Set evmVersion to byzantium",
|
|
||||||
"pr": 1678
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"note": "Optimize loops in LibAddressArray",
|
"note": "Optimize loops in LibAddressArray",
|
||||||
"pr": 1668
|
"pr": 1668
|
||||||
@@ -17,8 +23,17 @@
|
|||||||
{
|
{
|
||||||
"note": "Added Address.sol with test for whether or not an address is a contract",
|
"note": "Added Address.sol with test for whether or not an address is a contract",
|
||||||
"pr": 1657
|
"pr": 1657
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Add unit tests for `LibAddressArray`",
|
||||||
|
"pr": 1712
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Fix `LibAddressArray.indexOf` returning incorrect index.",
|
||||||
|
"pr": 1712
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"timestamp": 1553091633
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
|
@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v3.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Added `startProviderEngine` to `providerUtils`. Preventing excess block polling (#1695)
|
||||||
|
|
||||||
|
## v3.0.0 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Optimize loops in LibAddressArray (#1668)
|
||||||
|
* Upgrade contracts to Solidity 0.5.5 (#1682)
|
||||||
|
* Added Address.sol with test for whether or not an address is a contract (#1657)
|
||||||
|
* Add unit tests for `LibAddressArray` (#1712)
|
||||||
|
* Fix `LibAddressArray.indexOf` returning incorrect index. (#1712)
|
||||||
|
|
||||||
## v2.0.8 - _March 1, 2019_
|
## v2.0.8 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"useDockerisedSolc": true,
|
"useDockerisedSolc": true,
|
||||||
"isOfflineMode": false,
|
"isOfflineMode": false,
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"evmVersion": "byzantium",
|
"evmVersion": "constantinople",
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"runs": 1000000,
|
"runs": 1000000,
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
"src/SafeMath.sol",
|
"src/SafeMath.sol",
|
||||||
"src/interfaces/IOwnable.sol",
|
"src/interfaces/IOwnable.sol",
|
||||||
"test/TestConstants.sol",
|
"test/TestConstants.sol",
|
||||||
|
"test/TestLibAddressArray.sol",
|
||||||
"test/TestLibBytes.sol"
|
"test/TestLibBytes.sol"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ library LibAddressArray {
|
|||||||
/// @param addressArray Array of addresses.
|
/// @param addressArray Array of addresses.
|
||||||
/// @param addressToAppend Address to append.
|
/// @param addressToAppend Address to append.
|
||||||
/// @return Array of addresses: [... addressArray, addressToAppend]
|
/// @return Array of addresses: [... addressArray, addressToAppend]
|
||||||
function append(address[] memory addressArray, address addressToAppend)
|
function append(address[] memory addressArray, address addressToAppend)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
returns (address[] memory)
|
returns (address[] memory)
|
||||||
@@ -148,7 +148,7 @@ library LibAddressArray {
|
|||||||
if eq(target, arrayElement) {
|
if eq(target, arrayElement) {
|
||||||
// Set success and index
|
// Set success and index
|
||||||
success := 1
|
success := 1
|
||||||
index := div(i, 32)
|
index := div(sub(i, arrayContentsStart), 32)
|
||||||
// Break loop
|
// Break loop
|
||||||
i := arrayContentsEnd
|
i := arrayContentsEnd
|
||||||
}
|
}
|
||||||
|
106
contracts/utils/contracts/test/TestLibAddressArray.sol
Normal file
106
contracts/utils/contracts/test/TestLibAddressArray.sol
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright 2018 ZeroEx Intl.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
pragma solidity ^0.5.5;
|
||||||
|
|
||||||
|
import "../src/LibAddressArray.sol";
|
||||||
|
|
||||||
|
|
||||||
|
contract TestLibAddressArray {
|
||||||
|
|
||||||
|
using LibAddressArray for address[];
|
||||||
|
|
||||||
|
/// @dev Append a new address to an array of addresses.
|
||||||
|
/// The `addressArray` may need to be reallocated to make space
|
||||||
|
/// for the new address. Because of this we return the resulting
|
||||||
|
/// memory location of `addressArray`.
|
||||||
|
/// @param addressArray Array of addresses.
|
||||||
|
/// @param addressToAppend Address to append.
|
||||||
|
/// @return Array of addresses: [... addressArray, addressToAppend]
|
||||||
|
function publicAppend(address[] memory addressArray, address addressToAppend)
|
||||||
|
public
|
||||||
|
pure
|
||||||
|
returns (address[] memory)
|
||||||
|
{
|
||||||
|
return addressArray.append(addressToAppend);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @dev Moves the free memory pointer by `freeMemOffset` bytes,
|
||||||
|
/// then performs the append.
|
||||||
|
/// This tests the behavior of the address array being reallocated if
|
||||||
|
/// the memory immediately after the old array is claimed.
|
||||||
|
/// @param addressArray Array of addresses.
|
||||||
|
/// @param freeMemOffset Number of (signed) bytes to offset the free memory pointer (0x40).
|
||||||
|
/// @param addressToAppend Address to append.
|
||||||
|
/// @return The new address array.
|
||||||
|
/// @return The memory address of the old address array.
|
||||||
|
/// @return The memory address of the new address array.
|
||||||
|
function testAppendRealloc(
|
||||||
|
address[] memory addressArray,
|
||||||
|
int256 freeMemOffset,
|
||||||
|
address addressToAppend
|
||||||
|
)
|
||||||
|
public
|
||||||
|
pure
|
||||||
|
returns (
|
||||||
|
address[] memory result,
|
||||||
|
uint256 oldArrayMemStart,
|
||||||
|
uint256 newArrayMemStart
|
||||||
|
)
|
||||||
|
{
|
||||||
|
assembly {
|
||||||
|
// Remember the original memory address of the array.
|
||||||
|
oldArrayMemStart := addressArray
|
||||||
|
// Move the free memory pointer.
|
||||||
|
mstore(0x40, add(mload(0x40), freeMemOffset))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call append.
|
||||||
|
result = addressArray.append(addressToAppend);
|
||||||
|
|
||||||
|
// Get the new array memory address.
|
||||||
|
assembly {
|
||||||
|
newArrayMemStart := result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @dev Checks if an address array contains the target address.
|
||||||
|
/// @param addressArray Array of addresses.
|
||||||
|
/// @param target Address to search for in array.
|
||||||
|
/// @return True if the addressArray contains the target.
|
||||||
|
function publicContains(address[] memory addressArray, address target)
|
||||||
|
public
|
||||||
|
pure
|
||||||
|
returns (bool success)
|
||||||
|
{
|
||||||
|
return addressArray.contains(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @dev Finds the index of an address within an array.
|
||||||
|
/// @param addressArray Array of addresses.
|
||||||
|
/// @param target Address to search for in array.
|
||||||
|
/// @return Existence and index of the target in the array.
|
||||||
|
function publicIndexOf(address[] memory addressArray, address target)
|
||||||
|
public
|
||||||
|
pure
|
||||||
|
returns (bool success, uint256 index)
|
||||||
|
{
|
||||||
|
(success, index) = addressArray.indexOf(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-utils",
|
"name": "@0x/contracts-utils",
|
||||||
"version": "2.0.8",
|
"version": "3.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis": "./generated-artifacts/@(IOwnable|LibBytes|Ownable|ReentrancyGuard|SafeMath|TestConstants|TestLibBytes).json",
|
"abis": "./generated-artifacts/@(Address|IOwnable|LibBytes|Ownable|ReentrancyGuard|SafeMath|TestConstants|TestLibAddressArray|TestLibBytes).json",
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/utils/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/utils/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/contracts-gen": "^1.0.5",
|
"@0x/contracts-gen": "^1.0.7",
|
||||||
"@0x/contracts-test-utils": "^3.0.8",
|
"@0x/contracts-test-utils": "^3.1.1",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/sol-compiler": "^3.1.3",
|
"@0x/sol-compiler": "^3.1.5",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/bn.js": "^4.11.0",
|
"@types/bn.js": "^4.11.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
@@ -68,14 +68,14 @@
|
|||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/order-utils": "^7.0.2",
|
"@0x/order-utils": "^7.1.1",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"bn.js": "^4.11.8",
|
"bn.js": "^4.11.8",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"ethereumjs-util": "^5.1.1",
|
"ethereumjs-util": "^5.1.1",
|
||||||
"lodash": "^4.17.11"
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
|
@@ -5,14 +5,17 @@
|
|||||||
*/
|
*/
|
||||||
import { ContractArtifact } from 'ethereum-types';
|
import { ContractArtifact } from 'ethereum-types';
|
||||||
|
|
||||||
|
import * as Address from '../generated-artifacts/Address.json';
|
||||||
import * as IOwnable from '../generated-artifacts/IOwnable.json';
|
import * as IOwnable from '../generated-artifacts/IOwnable.json';
|
||||||
import * as LibBytes from '../generated-artifacts/LibBytes.json';
|
import * as LibBytes from '../generated-artifacts/LibBytes.json';
|
||||||
import * as Ownable from '../generated-artifacts/Ownable.json';
|
import * as Ownable from '../generated-artifacts/Ownable.json';
|
||||||
import * as ReentrancyGuard from '../generated-artifacts/ReentrancyGuard.json';
|
import * as ReentrancyGuard from '../generated-artifacts/ReentrancyGuard.json';
|
||||||
import * as SafeMath from '../generated-artifacts/SafeMath.json';
|
import * as SafeMath from '../generated-artifacts/SafeMath.json';
|
||||||
import * as TestConstants from '../generated-artifacts/TestConstants.json';
|
import * as TestConstants from '../generated-artifacts/TestConstants.json';
|
||||||
|
import * as TestLibAddressArray from '../generated-artifacts/TestLibAddressArray.json';
|
||||||
import * as TestLibBytes from '../generated-artifacts/TestLibBytes.json';
|
import * as TestLibBytes from '../generated-artifacts/TestLibBytes.json';
|
||||||
export const artifacts = {
|
export const artifacts = {
|
||||||
|
Address: Address as ContractArtifact,
|
||||||
LibBytes: LibBytes as ContractArtifact,
|
LibBytes: LibBytes as ContractArtifact,
|
||||||
Ownable: Ownable as ContractArtifact,
|
Ownable: Ownable as ContractArtifact,
|
||||||
ReentrancyGuard: ReentrancyGuard as ContractArtifact,
|
ReentrancyGuard: ReentrancyGuard as ContractArtifact,
|
||||||
@@ -20,4 +23,5 @@ export const artifacts = {
|
|||||||
IOwnable: IOwnable as ContractArtifact,
|
IOwnable: IOwnable as ContractArtifact,
|
||||||
TestConstants: TestConstants as ContractArtifact,
|
TestConstants: TestConstants as ContractArtifact,
|
||||||
TestLibBytes: TestLibBytes as ContractArtifact,
|
TestLibBytes: TestLibBytes as ContractArtifact,
|
||||||
|
TestLibAddressArray: TestLibAddressArray as ContractArtifact,
|
||||||
};
|
};
|
||||||
|
@@ -3,10 +3,12 @@
|
|||||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
||||||
* -----------------------------------------------------------------------------
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
export * from '../generated-wrappers/address';
|
||||||
export * from '../generated-wrappers/i_ownable';
|
export * from '../generated-wrappers/i_ownable';
|
||||||
export * from '../generated-wrappers/lib_bytes';
|
export * from '../generated-wrappers/lib_bytes';
|
||||||
export * from '../generated-wrappers/ownable';
|
export * from '../generated-wrappers/ownable';
|
||||||
export * from '../generated-wrappers/reentrancy_guard';
|
export * from '../generated-wrappers/reentrancy_guard';
|
||||||
export * from '../generated-wrappers/safe_math';
|
export * from '../generated-wrappers/safe_math';
|
||||||
export * from '../generated-wrappers/test_constants';
|
export * from '../generated-wrappers/test_constants';
|
||||||
|
export * from '../generated-wrappers/test_lib_address_array';
|
||||||
export * from '../generated-wrappers/test_lib_bytes';
|
export * from '../generated-wrappers/test_lib_bytes';
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
import { env, EnvVars } from '@0x/dev-utils';
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
||||||
|
import { providerUtils } from '@0x/utils';
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
before('start web3 provider', () => {
|
||||||
provider.start();
|
providerUtils.startProviderEngine(provider);
|
||||||
});
|
});
|
||||||
after('generate coverage report', async () => {
|
after('generate coverage report', async () => {
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||||
|
161
contracts/utils/test/lib_address_array.ts
Normal file
161
contracts/utils/test/lib_address_array.ts
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
import {
|
||||||
|
addressUtils,
|
||||||
|
chaiSetup,
|
||||||
|
expectContractCallFailedAsync,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper,
|
||||||
|
} from '@0x/contracts-test-utils';
|
||||||
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
|
import { RevertReason } from '@0x/types';
|
||||||
|
import { BigNumber } from '@0x/utils';
|
||||||
|
import * as chai from 'chai';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import { artifacts, TestLibAddressArrayContract } from '../src';
|
||||||
|
|
||||||
|
chaiSetup.configure();
|
||||||
|
const expect = chai.expect;
|
||||||
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
|
|
||||||
|
describe('LibAddressArray', () => {
|
||||||
|
let lib: TestLibAddressArrayContract;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
await blockchainLifecycle.startAsync();
|
||||||
|
});
|
||||||
|
after(async () => {
|
||||||
|
await blockchainLifecycle.revertAsync();
|
||||||
|
});
|
||||||
|
before(async () => {
|
||||||
|
// Deploy LibAddressArray
|
||||||
|
lib = await TestLibAddressArrayContract.deployFrom0xArtifactAsync(
|
||||||
|
artifacts.TestLibAddressArray,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
beforeEach(async () => {
|
||||||
|
await blockchainLifecycle.startAsync();
|
||||||
|
});
|
||||||
|
afterEach(async () => {
|
||||||
|
await blockchainLifecycle.revertAsync();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('append', () => {
|
||||||
|
it('should append to empty array', async () => {
|
||||||
|
const addr = addressUtils.generatePseudoRandomAddress();
|
||||||
|
const result = await lib.publicAppend.callAsync([], addr);
|
||||||
|
const expected = [addr];
|
||||||
|
expect(result).to.deep.equal(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should append to non-empty array', async () => {
|
||||||
|
const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const addr = addressUtils.generatePseudoRandomAddress();
|
||||||
|
const expected = [...arr, addr];
|
||||||
|
const result = await lib.publicAppend.callAsync(arr, addr);
|
||||||
|
expect(result).to.deep.equal(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should revert if the free memory pointer was moved to before the end of the array', async () => {
|
||||||
|
const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const addr = addressUtils.generatePseudoRandomAddress();
|
||||||
|
const freeMemOffset = new BigNumber(-1);
|
||||||
|
return expectContractCallFailedAsync(
|
||||||
|
lib.testAppendRealloc.callAsync(arr, freeMemOffset, addr),
|
||||||
|
RevertReason.InvalidFreeMemoryPtr,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should keep the same memory address if free memory pointer does not move', async () => {
|
||||||
|
const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const addr = addressUtils.generatePseudoRandomAddress();
|
||||||
|
const freeMemOffset = new BigNumber(0);
|
||||||
|
const expected = [...arr, addr];
|
||||||
|
const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync(
|
||||||
|
arr,
|
||||||
|
freeMemOffset,
|
||||||
|
addr,
|
||||||
|
);
|
||||||
|
expect(result).to.deep.equal(expected);
|
||||||
|
expect(newArrayMemStart).bignumber.to.be.equal(oldArrayMemStart);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change memory address if free memory pointer advances', async () => {
|
||||||
|
const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const addr = addressUtils.generatePseudoRandomAddress();
|
||||||
|
const freeMemOffset = new BigNumber(1);
|
||||||
|
const expectedArray = [...arr, addr];
|
||||||
|
const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync(
|
||||||
|
arr,
|
||||||
|
freeMemOffset,
|
||||||
|
addr,
|
||||||
|
);
|
||||||
|
// The new location should be the end of the old array + freeMemOffset.
|
||||||
|
const expectedNewArrayMemStart = oldArrayMemStart.plus((arr.length + 1) * 32).plus(freeMemOffset);
|
||||||
|
expect(result).to.deep.equal(expectedArray);
|
||||||
|
expect(newArrayMemStart).bignumber.to.be.equal(expectedNewArrayMemStart);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('contains', () => {
|
||||||
|
it('should return false on an empty array', async () => {
|
||||||
|
const addr = addressUtils.generatePseudoRandomAddress();
|
||||||
|
const isFound = await lib.publicContains.callAsync([], addr);
|
||||||
|
expect(isFound).to.equal(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false on a missing item', async () => {
|
||||||
|
const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const addr = addressUtils.generatePseudoRandomAddress();
|
||||||
|
const isFound = await lib.publicContains.callAsync(arr, addr);
|
||||||
|
expect(isFound).to.equal(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true on an included item', async () => {
|
||||||
|
const arr = _.times(4, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const addr = _.sample(arr) as string;
|
||||||
|
const isFound = await lib.publicContains.callAsync(arr, addr);
|
||||||
|
expect(isFound).to.equal(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true on the only item in the array', async () => {
|
||||||
|
const arr = _.times(1, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const isFound = await lib.publicContains.callAsync(arr, arr[0]);
|
||||||
|
expect(isFound).to.equal(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('indexOf', () => {
|
||||||
|
it('should fail on an empty array', async () => {
|
||||||
|
const addr = addressUtils.generatePseudoRandomAddress();
|
||||||
|
const [isSuccess] = await lib.publicIndexOf.callAsync([], addr);
|
||||||
|
expect(isSuccess).to.equal(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail on a missing item', async () => {
|
||||||
|
const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const addr = addressUtils.generatePseudoRandomAddress();
|
||||||
|
const [isSuccess] = await lib.publicIndexOf.callAsync(arr, addr);
|
||||||
|
expect(isSuccess).to.equal(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should succeed on an included item', async () => {
|
||||||
|
const arr = _.times(4, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const expectedIndexOf = _.random(0, arr.length - 1);
|
||||||
|
const addr = arr[expectedIndexOf];
|
||||||
|
const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, addr);
|
||||||
|
expect(isSuccess).to.equal(true);
|
||||||
|
expect(index).bignumber.to.equal(expectedIndexOf);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should succeed on the only item in the array', async () => {
|
||||||
|
const arr = _.times(1, () => addressUtils.generatePseudoRandomAddress());
|
||||||
|
const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, arr[0]);
|
||||||
|
expect(isSuccess).to.equal(true);
|
||||||
|
expect(index).bignumber.to.equal(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// tslint:disable:max-file-line-count
|
@@ -3,12 +3,14 @@
|
|||||||
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
|
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
|
||||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
||||||
"files": [
|
"files": [
|
||||||
|
"generated-artifacts/Address.json",
|
||||||
"generated-artifacts/IOwnable.json",
|
"generated-artifacts/IOwnable.json",
|
||||||
"generated-artifacts/LibBytes.json",
|
"generated-artifacts/LibBytes.json",
|
||||||
"generated-artifacts/Ownable.json",
|
"generated-artifacts/Ownable.json",
|
||||||
"generated-artifacts/ReentrancyGuard.json",
|
"generated-artifacts/ReentrancyGuard.json",
|
||||||
"generated-artifacts/SafeMath.json",
|
"generated-artifacts/SafeMath.json",
|
||||||
"generated-artifacts/TestConstants.json",
|
"generated-artifacts/TestConstants.json",
|
||||||
|
"generated-artifacts/TestLibAddressArray.json",
|
||||||
"generated-artifacts/TestLibBytes.json"
|
"generated-artifacts/TestLibBytes.json"
|
||||||
],
|
],
|
||||||
"exclude": ["./deploy/solc/solc_bin"]
|
"exclude": ["./deploy/solc/solc_bin"]
|
||||||
|
@@ -1,4 +1,22 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1553183790,
|
||||||
|
"version": "6.0.5",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1553091633,
|
||||||
|
"version": "6.0.4",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
"version": "6.0.3",
|
"version": "6.0.3",
|
||||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v6.0.5 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v6.0.4 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
## v6.0.3 - _March 1, 2019_
|
## v6.0.3 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "0x.js",
|
"name": "0x.js",
|
||||||
"version": "6.0.3",
|
"version": "6.0.5",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -42,10 +42,10 @@
|
|||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen-wrappers": "^4.0.2",
|
"@0x/abi-gen-wrappers": "^4.1.0",
|
||||||
"@0x/contract-addresses": "^2.2.2",
|
"@0x/contract-addresses": "^2.3.0",
|
||||||
"@0x/dev-utils": "^2.1.3",
|
"@0x/dev-utils": "^2.2.0",
|
||||||
"@0x/migrations": "^4.0.3",
|
"@0x/migrations": "^4.1.0",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "^2.2.42",
|
||||||
@@ -72,18 +72,18 @@
|
|||||||
"webpack": "^4.20.2"
|
"webpack": "^4.20.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/assert": "^2.0.6",
|
"@0x/assert": "^2.0.8",
|
||||||
"@0x/base-contract": "^5.0.2",
|
"@0x/base-contract": "^5.0.4",
|
||||||
"@0x/contract-wrappers": "^8.0.3",
|
"@0x/contract-wrappers": "^8.0.5",
|
||||||
"@0x/order-utils": "^7.0.2",
|
"@0x/order-utils": "^7.1.1",
|
||||||
"@0x/order-watcher": "^4.0.3",
|
"@0x/order-watcher": "^4.0.5",
|
||||||
"@0x/subproviders": "^4.0.2",
|
"@0x/subproviders": "^4.0.4",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"@types/web3-provider-engine": "^14.0.0",
|
"@types/web3-provider-engine": "^14.0.0",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"ethers": "~4.0.4",
|
"ethers": "~4.0.4",
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.11",
|
||||||
"web3-provider-engine": "14.0.6"
|
"web3-provider-engine": "14.0.6"
|
||||||
|
@@ -1,4 +1,23 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "4.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Add Coordinator and CoordinatorRegistry contract wrappers",
|
||||||
|
"pr": 1689
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1553183790
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1553091633,
|
||||||
|
"version": "4.0.3",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v4.1.0 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Add Coordinator and CoordinatorRegistry contract wrappers (#1689)
|
||||||
|
|
||||||
|
## v4.0.3 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
## v4.0.2 - _March 1, 2019_
|
## v4.0.2 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/abi-gen-wrappers",
|
"name": "@0x/abi-gen-wrappers",
|
||||||
"version": "4.0.2",
|
"version": "4.1.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers"
|
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DutchAuction|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IValidator|IWallet|MultiAssetProxy|OrderValidator|WETH9|ZRXToken).json"
|
"abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DutchAuction|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IValidator|IWallet|MultiAssetProxy|OrderValidator|WETH9|ZRXToken|Coordinator|CoordinatorRegistry).json"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -30,19 +30,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^2.0.6",
|
"@0x/abi-gen": "^2.0.8",
|
||||||
"@0x/abi-gen-templates": "^2.0.1",
|
"@0x/abi-gen-templates": "^2.0.1",
|
||||||
"@0x/tslint-config": "^3.0.0",
|
"@0x/tslint-config": "^3.0.0",
|
||||||
"@0x/types": "^2.1.1",
|
"@0x/types": "^2.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"@0x/web3-wrapper": "^6.0.2",
|
"@0x/web3-wrapper": "^6.0.4",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"ethers": "~4.0.4",
|
"ethers": "~4.0.4",
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.11",
|
||||||
"shx": "^0.2.2"
|
"shx": "^0.2.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^5.0.2"
|
"@0x/base-contract": "^5.0.4"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
315
packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts
Normal file
315
packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts
Normal file
@@ -0,0 +1,315 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0x/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
|
import { SimpleContractArtifact } from '@0x/types';
|
||||||
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class CoordinatorContract extends BaseContract {
|
||||||
|
public getSignerAddress = {
|
||||||
|
async callAsync(
|
||||||
|
hash: string,
|
||||||
|
signature: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as CoordinatorContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [hash,
|
||||||
|
signature
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
const abiEncoder = self._lookupAbiEncoder('getSignerAddress(bytes32,bytes)');
|
||||||
|
// tslint:disable boolean-naming
|
||||||
|
const result = abiEncoder.strictDecodeReturnValue<string
|
||||||
|
>(rawCallResult);
|
||||||
|
// tslint:enable boolean-naming
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public executeTransaction = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
transaction: {salt: BigNumber;signerAddress: string;data: string},
|
||||||
|
txOrigin: string,
|
||||||
|
transactionSignature: string,
|
||||||
|
approvalExpirationTimeSeconds: BigNumber[],
|
||||||
|
approvalSignatures: string[],
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as CoordinatorContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
|
||||||
|
txOrigin,
|
||||||
|
transactionSignature,
|
||||||
|
approvalExpirationTimeSeconds,
|
||||||
|
approvalSignatures
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.executeTransaction.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
transaction,
|
||||||
|
txOrigin,
|
||||||
|
transactionSignature,
|
||||||
|
approvalExpirationTimeSeconds,
|
||||||
|
approvalSignatures
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
transaction: {salt: BigNumber;signerAddress: string;data: string},
|
||||||
|
txOrigin: string,
|
||||||
|
transactionSignature: string,
|
||||||
|
approvalExpirationTimeSeconds: BigNumber[],
|
||||||
|
approvalSignatures: string[],
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as CoordinatorContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
|
||||||
|
txOrigin,
|
||||||
|
transactionSignature,
|
||||||
|
approvalExpirationTimeSeconds,
|
||||||
|
approvalSignatures
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
transaction: {salt: BigNumber;signerAddress: string;data: string},
|
||||||
|
txOrigin: string,
|
||||||
|
transactionSignature: string,
|
||||||
|
approvalExpirationTimeSeconds: BigNumber[],
|
||||||
|
approvalSignatures: string[],
|
||||||
|
): string {
|
||||||
|
const self = this as any as CoordinatorContract;
|
||||||
|
const abiEncodedTransactionData = self._strictEncodeArguments('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
|
||||||
|
txOrigin,
|
||||||
|
transactionSignature,
|
||||||
|
approvalExpirationTimeSeconds,
|
||||||
|
approvalSignatures
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
transaction: {salt: BigNumber;signerAddress: string;data: string},
|
||||||
|
txOrigin: string,
|
||||||
|
transactionSignature: string,
|
||||||
|
approvalExpirationTimeSeconds: BigNumber[],
|
||||||
|
approvalSignatures: string[],
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as CoordinatorContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
|
||||||
|
txOrigin,
|
||||||
|
transactionSignature,
|
||||||
|
approvalExpirationTimeSeconds,
|
||||||
|
approvalSignatures
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
const abiEncoder = self._lookupAbiEncoder('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])');
|
||||||
|
// tslint:disable boolean-naming
|
||||||
|
const result = abiEncoder.strictDecodeReturnValue<void
|
||||||
|
>(rawCallResult);
|
||||||
|
// tslint:enable boolean-naming
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public assertValidCoordinatorApprovals = {
|
||||||
|
async callAsync(
|
||||||
|
transaction: {salt: BigNumber;signerAddress: string;data: string},
|
||||||
|
txOrigin: string,
|
||||||
|
transactionSignature: string,
|
||||||
|
approvalExpirationTimeSeconds: BigNumber[],
|
||||||
|
approvalSignatures: string[],
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as CoordinatorContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
|
||||||
|
txOrigin,
|
||||||
|
transactionSignature,
|
||||||
|
approvalExpirationTimeSeconds,
|
||||||
|
approvalSignatures
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
const abiEncoder = self._lookupAbiEncoder('assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])');
|
||||||
|
// tslint:disable boolean-naming
|
||||||
|
const result = abiEncoder.strictDecodeReturnValue<void
|
||||||
|
>(rawCallResult);
|
||||||
|
// tslint:enable boolean-naming
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public EIP712_DOMAIN_HASH = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as CoordinatorContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('EIP712_DOMAIN_HASH()', []);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
const abiEncoder = self._lookupAbiEncoder('EIP712_DOMAIN_HASH()');
|
||||||
|
// tslint:disable boolean-naming
|
||||||
|
const result = abiEncoder.strictDecodeReturnValue<string
|
||||||
|
>(rawCallResult);
|
||||||
|
// tslint:enable boolean-naming
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public assertValidTransactionOrdersApproval = {
|
||||||
|
async callAsync(
|
||||||
|
transaction: {salt: BigNumber;signerAddress: string;data: string},
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
txOrigin: string,
|
||||||
|
transactionSignature: string,
|
||||||
|
approvalExpirationTimeSeconds: BigNumber[],
|
||||||
|
approvalSignatures: string[],
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as CoordinatorContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('assertValidTransactionOrdersApproval((uint256,address,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address,bytes,uint256[],bytes[])', [transaction,
|
||||||
|
orders,
|
||||||
|
txOrigin,
|
||||||
|
transactionSignature,
|
||||||
|
approvalExpirationTimeSeconds,
|
||||||
|
approvalSignatures
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
const abiEncoder = self._lookupAbiEncoder('assertValidTransactionOrdersApproval((uint256,address,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address,bytes,uint256[],bytes[])');
|
||||||
|
// tslint:disable boolean-naming
|
||||||
|
const result = abiEncoder.strictDecodeReturnValue<void
|
||||||
|
>(rawCallResult);
|
||||||
|
// tslint:enable boolean-naming
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
supportedProvider: SupportedProvider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
_exchange: string,
|
||||||
|
): Promise<CoordinatorContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return CoordinatorContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
supportedProvider: SupportedProvider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
_exchange: string,
|
||||||
|
): Promise<CoordinatorContract> {
|
||||||
|
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[_exchange
|
||||||
|
] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[_exchange
|
||||||
|
],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, [_exchange
|
||||||
|
]);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`Coordinator successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new CoordinatorContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [_exchange
|
||||||
|
];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('Coordinator', abi, address, supportedProvider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
@@ -0,0 +1,182 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0x/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
|
import { SimpleContractArtifact } from '@0x/types';
|
||||||
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
export type CoordinatorRegistryEventArgs =
|
||||||
|
| CoordinatorRegistryCoordinatorEndpointSetEventArgs;
|
||||||
|
|
||||||
|
export enum CoordinatorRegistryEvents {
|
||||||
|
CoordinatorEndpointSet = 'CoordinatorEndpointSet',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CoordinatorRegistryCoordinatorEndpointSetEventArgs extends DecodedLogArgs {
|
||||||
|
coordinatorOperator: string;
|
||||||
|
coordinatorEndpoint: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class CoordinatorRegistryContract extends BaseContract {
|
||||||
|
public setCoordinatorEndpoint = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
coordinatorEndpoint: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as CoordinatorRegistryContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.setCoordinatorEndpoint.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
coordinatorEndpoint
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
coordinatorEndpoint: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as CoordinatorRegistryContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
coordinatorEndpoint: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as CoordinatorRegistryContract;
|
||||||
|
const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
coordinatorEndpoint: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as CoordinatorRegistryContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)');
|
||||||
|
// tslint:disable boolean-naming
|
||||||
|
const result = abiEncoder.strictDecodeReturnValue<void
|
||||||
|
>(rawCallResult);
|
||||||
|
// tslint:enable boolean-naming
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getCoordinatorEndpoint = {
|
||||||
|
async callAsync(
|
||||||
|
coordinatorOperator: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as CoordinatorRegistryContract;
|
||||||
|
const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [coordinatorOperator
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)');
|
||||||
|
// tslint:disable boolean-naming
|
||||||
|
const result = abiEncoder.strictDecodeReturnValue<string
|
||||||
|
>(rawCallResult);
|
||||||
|
// tslint:enable boolean-naming
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
supportedProvider: SupportedProvider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<CoordinatorRegistryContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return CoordinatorRegistryContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
supportedProvider: SupportedProvider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<CoordinatorRegistryContract> {
|
||||||
|
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, []);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`CoordinatorRegistry successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new CoordinatorRegistryContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('CoordinatorRegistry', abi, address, supportedProvider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
@@ -14,3 +14,5 @@ export * from './generated-wrappers/multi_asset_proxy';
|
|||||||
export * from './generated-wrappers/order_validator';
|
export * from './generated-wrappers/order_validator';
|
||||||
export * from './generated-wrappers/weth9';
|
export * from './generated-wrappers/weth9';
|
||||||
export * from './generated-wrappers/zrx_token';
|
export * from './generated-wrappers/zrx_token';
|
||||||
|
export * from './generated-wrappers/coordinator';
|
||||||
|
export * from './generated-wrappers/coordinator_registry';
|
||||||
|
@@ -1,4 +1,22 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1553183790,
|
||||||
|
"version": "2.0.8",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1553091633,
|
||||||
|
"version": "2.0.7",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
"version": "2.0.6",
|
"version": "2.0.6",
|
||||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v2.0.8 - _March 21, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v2.0.7 - _March 20, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
## v2.0.6 - _March 1, 2019_
|
## v2.0.6 - _March 1, 2019_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/abi-gen",
|
"name": "@0x/abi-gen",
|
||||||
"version": "2.0.6",
|
"version": "2.0.8",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -31,10 +31,10 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/typescript-typings": "^4.1.0",
|
"@0x/typescript-typings": "^4.2.1",
|
||||||
"@0x/utils": "^4.2.2",
|
"@0x/utils": "^4.3.0",
|
||||||
"chalk": "^2.3.0",
|
"chalk": "^2.3.0",
|
||||||
"ethereum-types": "^2.1.0",
|
"ethereum-types": "^2.1.1",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"handlebars": "^4.0.11",
|
"handlebars": "^4.0.11",
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.11",
|
||||||
|
@@ -1,4 +1,22 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1553183790,
|
||||||
|
"version": "2.0.8",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1553091633,
|
||||||
|
"version": "2.0.7",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
"version": "2.0.6",
|
"version": "2.0.6",
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user