Ran prettier & linter.
Updated CHANGELOGs.
This commit is contained in:
parent
616907eff8
commit
54c17b0068
@ -4,6 +4,9 @@
|
|||||||
"changes": [
|
"changes": [
|
||||||
{
|
{
|
||||||
"note": "Created Coordinator package"
|
"note": "Created Coordinator package"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Use mixed EIP712 domains for transactions and approvals."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ pragma solidity ^0.5.5;
|
|||||||
|
|
||||||
import "./LibConstants.sol";
|
import "./LibConstants.sol";
|
||||||
|
|
||||||
|
|
||||||
contract LibEIP712Domain is
|
contract LibEIP712Domain is
|
||||||
LibConstants
|
LibConstants
|
||||||
{
|
{
|
||||||
@ -39,7 +40,6 @@ contract LibEIP712Domain is
|
|||||||
// EIP712 Domain Version value for the Exchange
|
// EIP712 Domain Version value for the Exchange
|
||||||
string constant internal EIP712_EXCHANGE_DOMAIN_VERSION = "2";
|
string constant internal EIP712_EXCHANGE_DOMAIN_VERSION = "2";
|
||||||
|
|
||||||
|
|
||||||
// Hash of the EIP712 Domain Separator Schema
|
// Hash of the EIP712 Domain Separator Schema
|
||||||
bytes32 constant internal EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH = keccak256(abi.encodePacked(
|
bytes32 constant internal EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH = keccak256(abi.encodePacked(
|
||||||
"EIP712Domain(",
|
"EIP712Domain(",
|
||||||
|
@ -24,6 +24,7 @@ import "../src/libs/LibCoordinatorApproval.sol";
|
|||||||
import "../src/libs/LibZeroExTransaction.sol";
|
import "../src/libs/LibZeroExTransaction.sol";
|
||||||
|
|
||||||
|
|
||||||
|
// solhint-disable no-empty-blocks
|
||||||
contract TestLibs is
|
contract TestLibs is
|
||||||
LibConstants,
|
LibConstants,
|
||||||
LibCoordinatorApproval,
|
LibCoordinatorApproval,
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
import {
|
import { addressUtils, chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
||||||
addressUtils,
|
|
||||||
chaiSetup,
|
|
||||||
constants,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
web3Wrapper
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
import { transactionHashUtils } from '@0x/order-utils';
|
import { transactionHashUtils } from '@0x/order-utils';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
|
@ -16,13 +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 {
|
import { ApprovalFactory, artifacts, constants, exchangeDataEncoder, TestMixinsContract } from '../src';
|
||||||
ApprovalFactory,
|
|
||||||
artifacts,
|
|
||||||
constants,
|
|
||||||
exchangeDataEncoder,
|
|
||||||
TestMixinsContract,
|
|
||||||
} from '../src';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
@ -88,20 +82,14 @@ describe('Mixins tests', () => {
|
|||||||
describe('getSignerAddress', () => {
|
describe('getSignerAddress', () => {
|
||||||
it('should return the correct address using the EthSign signature type', async () => {
|
it('should return the correct address using the EthSign signature type', async () => {
|
||||||
const data = devConstants.NULL_BYTES;
|
const data = devConstants.NULL_BYTES;
|
||||||
const transaction = transactionFactory.newSignedTransaction(
|
const transaction = transactionFactory.newSignedTransaction(data, SignatureType.EthSign);
|
||||||
data,
|
|
||||||
SignatureType.EthSign,
|
|
||||||
);
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
||||||
const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature);
|
const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature);
|
||||||
expect(transaction.signerAddress).to.eq(signerAddress);
|
expect(transaction.signerAddress).to.eq(signerAddress);
|
||||||
});
|
});
|
||||||
it('should return the correct address using the EIP712 signature type', async () => {
|
it('should return the correct address using the EIP712 signature type', async () => {
|
||||||
const data = devConstants.NULL_BYTES;
|
const data = devConstants.NULL_BYTES;
|
||||||
const transaction = transactionFactory.newSignedTransaction(
|
const transaction = transactionFactory.newSignedTransaction(data, SignatureType.EIP712);
|
||||||
data,
|
|
||||||
SignatureType.EIP712,
|
|
||||||
);
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
||||||
const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature);
|
const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature);
|
||||||
expect(transaction.signerAddress).to.eq(signerAddress);
|
expect(transaction.signerAddress).to.eq(signerAddress);
|
||||||
|
@ -9,10 +9,7 @@ export class ApprovalFactory {
|
|||||||
private readonly _privateKey: Buffer;
|
private readonly _privateKey: Buffer;
|
||||||
private readonly _verifyingContractAddress: string;
|
private readonly _verifyingContractAddress: string;
|
||||||
|
|
||||||
constructor(
|
constructor(privateKey: Buffer, verifyingContractAddress: string) {
|
||||||
privateKey: Buffer,
|
|
||||||
verifyingContractAddress: string) {
|
|
||||||
|
|
||||||
this._privateKey = privateKey;
|
this._privateKey = privateKey;
|
||||||
this._verifyingContractAddress = verifyingContractAddress;
|
this._verifyingContractAddress = verifyingContractAddress;
|
||||||
}
|
}
|
||||||
@ -23,21 +20,16 @@ export class ApprovalFactory {
|
|||||||
approvalExpirationTimeSeconds: BigNumber,
|
approvalExpirationTimeSeconds: BigNumber,
|
||||||
signatureType: SignatureType = SignatureType.EthSign,
|
signatureType: SignatureType = SignatureType.EthSign,
|
||||||
): SignedCoordinatorApproval {
|
): SignedCoordinatorApproval {
|
||||||
|
|
||||||
const approvalHashBuff = hashUtils.getApprovalHashBuffer(
|
const approvalHashBuff = hashUtils.getApprovalHashBuffer(
|
||||||
transaction,
|
transaction,
|
||||||
this._verifyingContractAddress,
|
this._verifyingContractAddress,
|
||||||
txOrigin,
|
txOrigin,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
);
|
);
|
||||||
const signatureBuff = signingUtils.signMessage(
|
const signatureBuff = signingUtils.signMessage(approvalHashBuff, this._privateKey, signatureType);
|
||||||
approvalHashBuff,
|
|
||||||
this._privateKey,
|
|
||||||
signatureType,
|
|
||||||
);
|
|
||||||
const signedApproval = {
|
const signedApproval = {
|
||||||
txOrigin,
|
txOrigin,
|
||||||
transaction: transaction,
|
transaction,
|
||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
signature: ethUtil.addHexPrefix(signatureBuff.toString('hex')),
|
signature: ethUtil.addHexPrefix(signatureBuff.toString('hex')),
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { constants, eip712Utils, transactionHashUtils } from '@0x/order-utils';
|
import { constants, eip712Utils, transactionHashUtils } from '@0x/order-utils';
|
||||||
import { SignedZeroExTransaction, ZeroExTransaction } 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';
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ export const hashUtils = {
|
|||||||
const domain = {
|
const domain = {
|
||||||
name: constants.COORDINATOR_DOMAIN_NAME,
|
name: constants.COORDINATOR_DOMAIN_NAME,
|
||||||
version: constants.COORDINATOR_DOMAIN_VERSION,
|
version: constants.COORDINATOR_DOMAIN_VERSION,
|
||||||
verifyingContractAddress: verifyingContractAddress,
|
verifyingContractAddress,
|
||||||
};
|
};
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
||||||
const approval = {
|
const approval = {
|
||||||
@ -40,12 +40,7 @@ export const hashUtils = {
|
|||||||
approvalExpirationTimeSeconds: BigNumber,
|
approvalExpirationTimeSeconds: BigNumber,
|
||||||
): string {
|
): string {
|
||||||
const hashHex = `0x${hashUtils
|
const hashHex = `0x${hashUtils
|
||||||
.getApprovalHashBuffer(
|
.getApprovalHashBuffer(transaction, verifyingContractAddress, txOrigin, approvalExpirationTimeSeconds)
|
||||||
transaction,
|
|
||||||
verifyingContractAddress,
|
|
||||||
txOrigin,
|
|
||||||
approvalExpirationTimeSeconds,
|
|
||||||
)
|
|
||||||
.toString('hex')}`;
|
.toString('hex')}`;
|
||||||
return hashHex;
|
return hashHex;
|
||||||
},
|
},
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
{
|
{
|
||||||
"note": "Set evmVersion to byzantium",
|
"note": "Set evmVersion to byzantium",
|
||||||
"pr": 1678
|
"pr": 1678
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Remove Coordinator EIP712 constants. They're now in the `order-utils` package."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version" : "7.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Add Coordinator EIP712 constants"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Export constants"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1551479279,
|
"timestamp": 1551479279,
|
||||||
"version": "7.0.2",
|
"version": "7.0.2",
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
{
|
{
|
||||||
"note": "Added ERC1155 revert reasons",
|
"note": "Added ERC1155 revert reasons",
|
||||||
"pr": 1657
|
"pr": 1657
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Add `RevertReason.SignatureInvalid` thrown by Coordinator"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
25
yarn.lock
25
yarn.lock
@ -13507,15 +13507,6 @@ react-dom@^16.3.2:
|
|||||||
object-assign "^4.1.1"
|
object-assign "^4.1.1"
|
||||||
prop-types "^15.6.0"
|
prop-types "^15.6.0"
|
||||||
|
|
||||||
react-dom@^16.4.2:
|
|
||||||
version "16.8.4"
|
|
||||||
resolved "https://registry.npmjs.org/react-dom/-/react-dom-16.8.4.tgz#1061a8e01a2b3b0c8160037441c3bf00a0e3bc48"
|
|
||||||
dependencies:
|
|
||||||
loose-envify "^1.1.0"
|
|
||||||
object-assign "^4.1.1"
|
|
||||||
prop-types "^15.6.2"
|
|
||||||
scheduler "^0.13.4"
|
|
||||||
|
|
||||||
react-dom@^16.5.2:
|
react-dom@^16.5.2:
|
||||||
version "16.5.2"
|
version "16.5.2"
|
||||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.5.2.tgz#b69ee47aa20bab5327b2b9d7c1fe2a30f2cfa9d7"
|
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.5.2.tgz#b69ee47aa20bab5327b2b9d7c1fe2a30f2cfa9d7"
|
||||||
@ -13817,15 +13808,6 @@ react@^16.3.2:
|
|||||||
object-assign "^4.1.1"
|
object-assign "^4.1.1"
|
||||||
prop-types "^15.6.0"
|
prop-types "^15.6.0"
|
||||||
|
|
||||||
react@^16.4.2:
|
|
||||||
version "16.8.4"
|
|
||||||
resolved "https://registry.npmjs.org/react/-/react-16.8.4.tgz#fdf7bd9ae53f03a9c4cd1a371432c206be1c4768"
|
|
||||||
dependencies:
|
|
||||||
loose-envify "^1.1.0"
|
|
||||||
object-assign "^4.1.1"
|
|
||||||
prop-types "^15.6.2"
|
|
||||||
scheduler "^0.13.4"
|
|
||||||
|
|
||||||
react@^16.5.2:
|
react@^16.5.2:
|
||||||
version "16.5.2"
|
version "16.5.2"
|
||||||
resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42"
|
resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42"
|
||||||
@ -14697,13 +14679,6 @@ schedule@^0.5.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
object-assign "^4.1.1"
|
object-assign "^4.1.1"
|
||||||
|
|
||||||
scheduler@^0.13.4:
|
|
||||||
version "0.13.4"
|
|
||||||
resolved "https://registry.npmjs.org/scheduler/-/scheduler-0.13.4.tgz#8fef05e7a3580c76c0364d2df5e550e4c9140298"
|
|
||||||
dependencies:
|
|
||||||
loose-envify "^1.1.0"
|
|
||||||
object-assign "^4.1.1"
|
|
||||||
|
|
||||||
schema-utils@^0.4.4:
|
schema-utils@^0.4.4:
|
||||||
version "0.4.7"
|
version "0.4.7"
|
||||||
resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"
|
resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user