Merge branch 'development' into 3.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"version": "3.2.0",
|
||||
"version": "3.2.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Change ReentrancyGuard implementation to cheaper one",
|
||||
@@ -56,6 +56,38 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1565296576,
|
||||
"version": "3.2.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "3.2.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies.",
|
||||
"pr": 1995
|
||||
},
|
||||
{
|
||||
"note": "Added tests for decoding log arguments when artifact dependencies are included/excluded.",
|
||||
"pr": 1995
|
||||
}
|
||||
],
|
||||
"timestamp": 1564604963
|
||||
},
|
||||
{
|
||||
"timestamp": 1563957393,
|
||||
"version": "3.1.10",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1563193019,
|
||||
"version": "3.1.9",
|
||||
|
@@ -5,6 +5,19 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v3.2.1 - _August 8, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.2.0 - _July 31, 2019_
|
||||
|
||||
* Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies. (#1995)
|
||||
* Added tests for decoding log arguments when artifact dependencies are included/excluded. (#1995)
|
||||
|
||||
## v3.1.10 - _July 24, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.1.9 - _July 15, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
55
contracts/utils/contracts/test/TestLogDecoding.sol
Normal file
55
contracts/utils/contracts/test/TestLogDecoding.sol
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
|
||||
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 "./TestLogDecodingDownstream.sol";
|
||||
|
||||
|
||||
contract TestLogDecoding {
|
||||
|
||||
/// @dev arbitrary event; fields to not matter.
|
||||
event TestEvent(
|
||||
uint256 foo,
|
||||
bytes bar,
|
||||
string car
|
||||
);
|
||||
|
||||
/// @dev Emits a local event
|
||||
function emitEvent()
|
||||
public
|
||||
{
|
||||
emit TestEvent(256, hex'1234', "4321");
|
||||
}
|
||||
|
||||
/// @dev Emits an event in a downstream contract
|
||||
function emitEventDownstream()
|
||||
public
|
||||
{
|
||||
TestLogDecodingDownstream testLogDecodingDownstream = new TestLogDecodingDownstream();
|
||||
ITestLogDecodingDownstream(testLogDecodingDownstream).emitEvent();
|
||||
}
|
||||
|
||||
/// @dev Emits a local event and a downstream event
|
||||
function emitEventsLocalAndDownstream()
|
||||
public
|
||||
{
|
||||
emitEvent();
|
||||
emitEventDownstream();
|
||||
}
|
||||
}
|
48
contracts/utils/contracts/test/TestLogDecodingDownstream.sol
Normal file
48
contracts/utils/contracts/test/TestLogDecodingDownstream.sol
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
|
||||
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;
|
||||
|
||||
|
||||
contract ITestLogDecodingDownstream {
|
||||
|
||||
/// @dev Emits a local event
|
||||
function emitEvent() external;
|
||||
}
|
||||
|
||||
|
||||
contract TestLogDecodingDownstream is
|
||||
ITestLogDecodingDownstream
|
||||
{
|
||||
|
||||
/// @dev event with fields different than those in `TestLogDecoding.TestEvent`
|
||||
/// Note: do not include this in the interface
|
||||
/// For testing, we want to emit an event that is
|
||||
/// not known by the calling contract.
|
||||
event TestEvent2(
|
||||
uint256 lorem,
|
||||
string ipsum
|
||||
);
|
||||
|
||||
/// @dev Emits a local event
|
||||
function emitEvent()
|
||||
external
|
||||
{
|
||||
emit TestEvent2(256, "4321");
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-utils",
|
||||
"version": "3.1.9",
|
||||
"version": "3.2.1",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -34,7 +34,7 @@
|
||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
||||
},
|
||||
"config": {
|
||||
"abis": "./generated-artifacts/@(Authorizable|IAuthorizable|IOwnable|LibAddress|LibAddressArray|LibAddressArrayRichErrors|LibAuthorizableRichErrors|LibBytes|LibBytesRichErrors|LibEIP1271|LibEIP712|LibOwnableRichErrors|LibReentrancyGuardRichErrors|LibRichErrors|LibSafeMath|LibSafeMathRichErrors|Ownable|ReentrancyGuard|SafeMath|TestLibAddress|TestLibAddressArray|TestLibBytes|TestLibEIP712|TestLibRichErrors|TestOwnable|TestReentrancyGuard|TestSafeMath).json",
|
||||
"abis": "./generated-artifacts/@(Authorizable|IAuthorizable|IOwnable|LibAddress|LibAddressArray|LibAddressArrayRichErrors|LibAuthorizableRichErrors|LibBytes|LibBytesRichErrors|LibEIP1271|LibEIP712|LibOwnableRichErrors|LibReentrancyGuardRichErrors|LibRichErrors|LibSafeMath|LibSafeMathRichErrors|Ownable|ReentrancyGuard|SafeMath|TestLibAddress|TestLibAddressArray|TestLibBytes|TestLibEIP712|TestLibRichErrors|TestLogDecoding|TestLogDecodingDownstream|TestOwnable|TestReentrancyGuard|TestSafeMath).json",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||
},
|
||||
"repository": {
|
||||
@@ -47,21 +47,22 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/utils/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^2.1.1",
|
||||
"@0x/contracts-gen": "^1.0.10",
|
||||
"@0x/contracts-test-utils": "^3.1.10",
|
||||
"@0x/dev-utils": "^2.2.4",
|
||||
"@0x/sol-compiler": "^3.1.9",
|
||||
"@0x/abi-gen": "^4.1.0",
|
||||
"@0x/contracts-gen": "^1.0.13",
|
||||
"@0x/contracts-test-utils": "^3.1.13",
|
||||
"@0x/dev-utils": "^2.3.0",
|
||||
"@0x/sol-compiler": "^3.1.12",
|
||||
"@0x/tslint-config": "^3.0.1",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "*",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-bignumber": "^3.0.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^4.1.0",
|
||||
"mocha": "^6.2.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"solhint": "^1.4.1",
|
||||
@@ -69,14 +70,14 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^5.1.1",
|
||||
"@0x/order-utils": "^8.2.2",
|
||||
"@0x/types": "^2.4.0",
|
||||
"@0x/typescript-typings": "^4.2.3",
|
||||
"@0x/utils": "^4.4.0",
|
||||
"@0x/web3-wrapper": "^6.0.7",
|
||||
"@0x/base-contract": "^5.3.1",
|
||||
"@0x/order-utils": "^8.2.5",
|
||||
"@0x/types": "^2.4.1",
|
||||
"@0x/typescript-typings": "^4.2.4",
|
||||
"@0x/utils": "^4.5.0",
|
||||
"@0x/web3-wrapper": "^6.0.10",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereum-types": "^2.1.3",
|
||||
"ethereum-types": "^2.1.4",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"lodash": "^4.17.11"
|
||||
},
|
||||
|
@@ -29,6 +29,8 @@ import * as TestLibAddressArray from '../generated-artifacts/TestLibAddressArray
|
||||
import * as TestLibBytes from '../generated-artifacts/TestLibBytes.json';
|
||||
import * as TestLibEIP712 from '../generated-artifacts/TestLibEIP712.json';
|
||||
import * as TestLibRichErrors from '../generated-artifacts/TestLibRichErrors.json';
|
||||
import * as TestLogDecoding from '../generated-artifacts/TestLogDecoding.json';
|
||||
import * as TestLogDecodingDownstream from '../generated-artifacts/TestLogDecodingDownstream.json';
|
||||
import * as TestOwnable from '../generated-artifacts/TestOwnable.json';
|
||||
import * as TestReentrancyGuard from '../generated-artifacts/TestReentrancyGuard.json';
|
||||
import * as TestSafeMath from '../generated-artifacts/TestSafeMath.json';
|
||||
@@ -57,6 +59,8 @@ export const artifacts = {
|
||||
TestLibBytes: TestLibBytes as ContractArtifact,
|
||||
TestLibEIP712: TestLibEIP712 as ContractArtifact,
|
||||
TestLibRichErrors: TestLibRichErrors as ContractArtifact,
|
||||
TestLogDecoding: TestLogDecoding as ContractArtifact,
|
||||
TestLogDecodingDownstream: TestLogDecodingDownstream as ContractArtifact,
|
||||
TestOwnable: TestOwnable as ContractArtifact,
|
||||
TestReentrancyGuard: TestReentrancyGuard as ContractArtifact,
|
||||
TestSafeMath: TestSafeMath as ContractArtifact,
|
||||
|
@@ -27,6 +27,8 @@ export * from '../generated-wrappers/test_lib_address_array';
|
||||
export * from '../generated-wrappers/test_lib_bytes';
|
||||
export * from '../generated-wrappers/test_lib_e_i_p712';
|
||||
export * from '../generated-wrappers/test_lib_rich_errors';
|
||||
export * from '../generated-wrappers/test_log_decoding';
|
||||
export * from '../generated-wrappers/test_log_decoding_downstream';
|
||||
export * from '../generated-wrappers/test_ownable';
|
||||
export * from '../generated-wrappers/test_reentrancy_guard';
|
||||
export * from '../generated-wrappers/test_safe_math';
|
||||
|
@@ -31,6 +31,7 @@ describe('Authorizable', () => {
|
||||
artifacts.Authorizable,
|
||||
provider,
|
||||
txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
|
@@ -16,7 +16,12 @@ describe('LibAddress', () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
nonContract = (await web3Wrapper.getAvailableAddressesAsync())[0];
|
||||
// Deploy LibAddress
|
||||
lib = await TestLibAddressContract.deployFrom0xArtifactAsync(artifacts.TestLibAddress, provider, txDefaults);
|
||||
lib = await TestLibAddressContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestLibAddress,
|
||||
provider,
|
||||
txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
@@ -20,6 +20,7 @@ describe('LibAddressArray', () => {
|
||||
artifacts.TestLibAddressArray,
|
||||
provider,
|
||||
txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
});
|
||||
after(async () => {
|
||||
|
@@ -59,7 +59,12 @@ describe('LibBytes', () => {
|
||||
testAddress = accounts[1];
|
||||
testAddressB = accounts[2];
|
||||
// Deploy LibBytes
|
||||
libBytes = await TestLibBytesContract.deployFrom0xArtifactAsync(artifacts.TestLibBytes, provider, txDefaults);
|
||||
libBytes = await TestLibBytesContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestLibBytes,
|
||||
provider,
|
||||
txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
// Verify lengths of test data
|
||||
const byteArrayShorterThan32BytesLength = ethUtil.toBuffer(byteArrayShorterThan32Bytes).byteLength;
|
||||
expect(byteArrayShorterThan32BytesLength).to.be.lessThan(32);
|
||||
|
@@ -17,7 +17,7 @@ describe('LibEIP712', () => {
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
// Deploy LibEIP712
|
||||
lib = await TestLibEIP712Contract.deployFrom0xArtifactAsync(artifacts.TestLibEIP712, provider, txDefaults);
|
||||
lib = await TestLibEIP712Contract.deployFrom0xArtifactAsync(artifacts.TestLibEIP712, provider, txDefaults, {});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
@@ -20,6 +20,7 @@ describe('LibRichErrors', () => {
|
||||
artifacts.TestLibRichErrors,
|
||||
provider,
|
||||
txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
|
95
contracts/utils/test/log_decoding.ts
Normal file
95
contracts/utils/test/log_decoding.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { chaiSetup, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
import { DecodedLogArgs, LogWithDecodedArgs } from 'ethereum-types';
|
||||
|
||||
import { artifacts, TestLogDecodingContract } from '../src';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
||||
describe('TestLogDecoding', () => {
|
||||
let testLogDecodingWithDependencies: TestLogDecodingContract;
|
||||
let testLogDecodingDeployedWithoutDependencies: TestLogDecodingContract;
|
||||
const expectedEvent = {
|
||||
foo: new BigNumber(256),
|
||||
bar: '0x1234',
|
||||
car: '4321',
|
||||
};
|
||||
const expectedDownstreamEvent = {
|
||||
lorem: new BigNumber(256),
|
||||
ipsum: '4321',
|
||||
};
|
||||
const emptyDependencyList = {};
|
||||
|
||||
before(async () => {
|
||||
testLogDecodingDeployedWithoutDependencies = await TestLogDecodingContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestLogDecoding,
|
||||
provider,
|
||||
txDefaults,
|
||||
emptyDependencyList,
|
||||
);
|
||||
testLogDecodingWithDependencies = await TestLogDecodingContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestLogDecoding,
|
||||
provider,
|
||||
txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
|
||||
describe('Decoding Log Arguments', () => {
|
||||
it('should decode locally emitted event args when no dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEvent.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(1);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
|
||||
});
|
||||
it('should not decode event args when no dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventDownstream.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(1);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.undefined();
|
||||
});
|
||||
it('should decode args for local but not downstream event when no dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(2);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[1] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.undefined();
|
||||
});
|
||||
it('should decode locally emitted event args when dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingWithDependencies.emitEvent.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(1);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
|
||||
});
|
||||
it('should decode downstream event args when dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingWithDependencies.emitEventDownstream.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(1);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(
|
||||
expectedDownstreamEvent,
|
||||
);
|
||||
});
|
||||
it('should decode args for both local and downstream events when dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingWithDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(2);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[1] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(
|
||||
expectedDownstreamEvent,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
@@ -22,7 +22,7 @@ describe('Ownable', () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
// Deploy Ownable from the owner address
|
||||
txDefaults.from = owner;
|
||||
ownable = await TestOwnableContract.deployFrom0xArtifactAsync(artifacts.TestOwnable, provider, txDefaults);
|
||||
ownable = await TestOwnableContract.deployFrom0xArtifactAsync(artifacts.TestOwnable, provider, txDefaults, {});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
@@ -20,6 +20,7 @@ describe('ReentrancyGuard', () => {
|
||||
artifacts.TestReentrancyGuard,
|
||||
provider,
|
||||
txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
|
@@ -19,6 +19,7 @@ blockchainTests('SafeMath', env => {
|
||||
artifacts.TestSafeMath,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
|
@@ -27,6 +27,8 @@
|
||||
"generated-artifacts/TestLibBytes.json",
|
||||
"generated-artifacts/TestLibEIP712.json",
|
||||
"generated-artifacts/TestLibRichErrors.json",
|
||||
"generated-artifacts/TestLogDecoding.json",
|
||||
"generated-artifacts/TestLogDecodingDownstream.json",
|
||||
"generated-artifacts/TestOwnable.json",
|
||||
"generated-artifacts/TestReentrancyGuard.json",
|
||||
"generated-artifacts/TestSafeMath.json"
|
||||
|
Reference in New Issue
Block a user