Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Rename TEC to Coordinator in contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
hysz committed Mar 6, 2019
1 parent 4457a30 commit d8148e0
Show file tree
Hide file tree
Showing 25 changed files with 177 additions and 177 deletions.
10 changes: 5 additions & 5 deletions contracts/tec/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## Trade Execution Coordinator (TEC)
## Trade Execution Coordinator (Coordinator)

This package contains a contract that allows users to call arbitrary functions on the Exchange contract with permission from one or more TECs (Trade Execution Coordinators). Addresses of the deployed contracts can be found in the 0x [wiki](https://0xproject.com/wiki#Deployed-Addresses) or the [DEPLOYS](./DEPLOYS.json) file within this package.
This package contains a contract that allows users to call arbitrary functions on the Exchange contract with permission from one or more Coordinators (Trade Execution Coordinators). Addresses of the deployed contracts can be found in the 0x [wiki](https://0xproject.com/wiki#Deployed-Addresses) or the [DEPLOYS](./DEPLOYS.json) file within this package.

## Installation

**Install**

```bash
npm install @0x/contracts-tec --save
npm install @0x/contracts-coordinator --save
```

## Bug bounty
Expand Down Expand Up @@ -41,13 +41,13 @@ yarn install
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:

```bash
PKG=@0x/contracts-tec yarn build
PKG=@0x/contracts-coordinator yarn build
```

Or continuously rebuild on change:

```bash
PKG=@0x/contracts-tec yarn watch
PKG=@0x/contracts-coordinator yarn watch
```

### Clean
Expand Down
2 changes: 1 addition & 1 deletion contracts/tec/compiler.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
}
}
},
"contracts": ["src/TEC.sol", "test/TestLibs.sol", "test/TestMixins.sol"]
"contracts": ["src/Coordinator.sol", "test/TestLibs.sol", "test/TestMixins.sol"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ pragma experimental "ABIEncoderV2";

import "./libs/LibConstants.sol";
import "./MixinSignatureValidator.sol";
import "./MixinTECApprovalVerifier.sol";
import "./MixinTECCore.sol";
import "./MixinCoordinatorApprovalVerifier.sol";
import "./MixinCoordinatorCore.sol";


// solhint-disable no-empty-blocks
contract TEC is
contract Coordinator is
LibConstants,
MixinSignatureValidator,
MixinTECApprovalVerifier,
MixinTECCore
MixinCoordinatorApprovalVerifier,
MixinCoordinatorCore
{
constructor (address _exchange)
public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ import "@0x/contracts-exchange-libs/contracts/src/LibExchangeSelectors.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
import "./libs/LibTECApproval.sol";
import "./libs/LibCoordinatorApproval.sol";
import "./libs/LibZeroExTransaction.sol";
import "./mixins/MSignatureValidator.sol";
import "./mixins/MTECApprovalVerifier.sol";
import "./mixins/MCoordinatorApprovalVerifier.sol";


// solhint-disable avoid-tx-origin
contract MixinTECApprovalVerifier is
contract MixinCoordinatorApprovalVerifier is
LibExchangeSelectors,
LibTECApproval,
LibCoordinatorApproval,
LibZeroExTransaction,
MSignatureValidator,
MTECApprovalVerifier
MCoordinatorApprovalVerifier
{
using LibBytes for bytes;
using LibAddressArray for address[];
Expand All @@ -46,7 +46,7 @@ contract MixinTECApprovalVerifier is
/// @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 in the transaction's Exchange calldata.
function assertValidTECApprovals(
function assertValidCoordinatorApprovals(
LibZeroExTransaction.ZeroExTransaction memory transaction,
bytes memory transactionSignature,
uint256[] memory approvalExpirationTimeSeconds,
Expand Down Expand Up @@ -97,7 +97,7 @@ contract MixinTECApprovalVerifier is
for (uint256 i = 0; i < signaturesLength; i++) {
// Create approval message
uint256 currentApprovalExpirationTimeSeconds = approvalExpirationTimeSeconds[i];
TECApproval memory approval = TECApproval({
CoordinatorApproval memory approval = CoordinatorApproval({
transactionHash: transactionHash,
transactionSignature: transactionSignature,
approvalExpirationTimeSeconds: currentApprovalExpirationTimeSeconds
Expand All @@ -111,7 +111,7 @@ contract MixinTECApprovalVerifier is
);

// Hash approval message and recover signer address
bytes32 approvalHash = getTECApprovalHash(approval);
bytes32 approvalHash = getCoordinatorApprovalHash(approval);
address approvalSignerAddress = getSignerAddress(approvalHash, approvalSignatures[i]);

// Add approval signer to list of signers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ pragma experimental "ABIEncoderV2";

import "./libs/LibZeroExTransaction.sol";
import "./libs/LibConstants.sol";
import "./mixins/MTECApprovalVerifier.sol";
import "./interfaces/ITECCore.sol";
import "./mixins/MCoordinatorApprovalVerifier.sol";
import "./interfaces/ICoordinatorCore.sol";


contract MixinTECCore is
contract MixinCoordinatorCore is
LibConstants,
MTECApprovalVerifier,
ITECCore
MCoordinatorApprovalVerifier,
ICoordinatorCore
{
/// @dev Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata.
/// @param transaction 0x transaction containing salt, signerAddress, and data.
Expand All @@ -44,7 +44,7 @@ contract MixinTECCore is
public
{
// Validate that the 0x transaction has been approves by each feeRecipient
assertValidTECApprovals(
assertValidCoordinatorApprovals(
transaction,
transactionSignature,
approvalExpirationTimeSeconds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "../libs/LibZeroExTransaction.sol";


contract ITECApprovalVerifier {
contract ICoordinatorApprovalVerifier {

/// @dev Validates that the 0x transaction has been approved by all of the feeRecipients
/// that correspond to each order in the transaction's Exchange calldata.
/// @param transaction 0x transaction containing salt, signerAddress, and 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 in the transaction's Exchange calldata.
function assertValidTECApprovals(
function assertValidCoordinatorApprovals(
LibZeroExTransaction.ZeroExTransaction memory transaction,
bytes memory transactionSignature,
uint256[] memory approvalExpirationTimeSeconds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pragma experimental "ABIEncoderV2";
import "../libs/LibZeroExTransaction.sol";


contract ITECCore {
contract ICoordinatorCore {

/// @dev Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata.
/// @param transaction 0x transaction containing salt, signerAddress, and data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,53 @@ pragma solidity ^0.5.3;
import "./LibEIP712Domain.sol";


contract LibTECApproval is
contract LibCoordinatorApproval is
LibEIP712Domain
{
// Hash for the EIP712 TEC approval message
bytes32 constant internal EIP712_TEC_APPROVAL_SCHEMA_HASH = keccak256(abi.encodePacked(
"TECApproval(",
// Hash for the EIP712 Coordinator approval message
bytes32 constant internal EIP712_Coordinator_APPROVAL_SCHEMA_HASH = keccak256(abi.encodePacked(
"CoordinatorApproval(",
"bytes32 transactionHash,",
"bytes transactionSignature,",
"uint256 approvalExpirationTimeSeconds",
")"
));

struct TECApproval {
struct CoordinatorApproval {
bytes32 transactionHash; // EIP712 hash of the transaction, using the domain separator of this contract.
bytes transactionSignature; // Signature of the 0x transaction.
uint256 approvalExpirationTimeSeconds; // Timestamp in seconds for which the signature expires.
}

/// @dev Calculated the EIP712 hash of the TEC approval mesasage using the domain separator of this contract.
/// @param approval TEC approval message containing the transaction hash, transaction signature, and expiration of the approval.
/// @return EIP712 hash of the TEC approval message with the domain separator of this contract.
function getTECApprovalHash(TECApproval memory approval)
/// @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 getCoordinatorApprovalHash(CoordinatorApproval memory approval)
internal
view
returns (bytes32 approvalHash)
{
approvalHash = hashEIP712Message(hashTECApproval(approval));
approvalHash = hashEIP712Message(hashCoordinatorApproval(approval));
return approvalHash;
}

/// @dev Calculated the EIP712 hash of the TEC approval mesasage with no domain separator.
/// @param approval TEC approval message containing the transaction hash, transaction signature, and expiration of the approval.
/// @return EIP712 hash of the TEC approval message with no domain separator.
function hashTECApproval(TECApproval memory approval)
/// @dev Calculated the EIP712 hash of the Coordinator approval mesasage with no domain separator.
/// @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 no domain separator.
function hashCoordinatorApproval(CoordinatorApproval memory approval)
internal
pure
returns (bytes32 result)
{
bytes32 schemaHash = EIP712_TEC_APPROVAL_SCHEMA_HASH;
bytes32 schemaHash = EIP712_Coordinator_APPROVAL_SCHEMA_HASH;
bytes32 transactionSignatureHash = keccak256(approval.transactionSignature);
// TODO(abandeali1): optimize by loading from memory in assembly
bytes32 transactionHash = approval.transactionHash;
uint256 approvalExpirationTimeSeconds = approval.approvalExpirationTimeSeconds;

// Assembly for more efficiently computing:
// keccak256(abi.encodePacked(
// EIP712_TEC_APPROVAL_SCHEMA_HASH,
// EIP712_Coordinator_APPROVAL_SCHEMA_HASH,
// approval.transactionHash,
// keccak256(approval.transactionSignature)
// approval.expiration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ pragma solidity ^0.5.3;
pragma experimental "ABIEncoderV2";

import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "../interfaces/ITECApprovalVerifier.sol";
import "../interfaces/ICoordinatorApprovalVerifier.sol";


contract MTECApprovalVerifier is
ITECApprovalVerifier
contract MCoordinatorApprovalVerifier is
ICoordinatorApprovalVerifier
{
/// @dev Decodes the orders from Exchange calldata representing any fill method.
/// @param data Exchange calldata representing a fill method.
Expand Down
14 changes: 7 additions & 7 deletions contracts/tec/contracts/test/TestLibs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
pragma solidity ^0.5.3;
pragma experimental "ABIEncoderV2";

import "../src/libs/LibTECApproval.sol";
import "../src/libs/LibCoordinatorApproval.sol";
import "../src/libs/LibZeroExTransaction.sol";


contract TestLibs is
LibTECApproval,
LibCoordinatorApproval,
LibZeroExTransaction
{
/// @dev Calculated the EIP712 hash of the TEC approval mesasage using the domain separator of this contract.
/// @param approval TEC approval message containing the transaction hash, transaction signature, and expiration of the approval.
/// @return EIP712 hash of the TEC approval message with the domain separator of this contract.
function publicGetTECApprovalHash(TECApproval memory approval)
/// @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 = getTECApprovalHash(approval);
approvalHash = getCoordinatorApprovalHash(approval);
return approvalHash;
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/tec/contracts/test/TestMixins.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ pragma solidity 0.5.3;
pragma experimental "ABIEncoderV2";

import "../src/MixinSignatureValidator.sol";
import "../src/MixinTECApprovalVerifier.sol";
import "../src/MixinCoordinatorApprovalVerifier.sol";


// solhint-disable no-empty-blocks
contract TestMixins is
MixinSignatureValidator,
MixinTECApprovalVerifier
MixinCoordinatorApprovalVerifier
{}
2 changes: 1 addition & 1 deletion contracts/tec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "./generated-artifacts/@(IExchange|TEC|TestLibs|TestMixins).json",
"abis": "./generated-artifacts/@(Coordinator|TestLibs|TestMixins).json",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
},
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions contracts/tec/src/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
*/
import { ContractArtifact } from 'ethereum-types';

import * as TEC from '../generated-artifacts/TEC.json';
import * as Coordinator from '../generated-artifacts/Coordinator.json';
import * as TestLibs from '../generated-artifacts/TestLibs.json';
import * as TestMixins from '../generated-artifacts/TestMixins.json';
export const artifacts = {
TEC: TEC as ContractArtifact,
Coordinator: Coordinator as ContractArtifact,
TestLibs: TestLibs as ContractArtifact,
TestMixins: TestMixins as ContractArtifact,
};
2 changes: 1 addition & 1 deletion contracts/tec/src/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/tec';
export * from '../generated-wrappers/coordinator';
export * from '../generated-wrappers/test_libs';
export * from '../generated-wrappers/test_mixins';
Loading

0 comments on commit d8148e0

Please sign in to comment.