Make internal functions public
This commit is contained in:
@@ -3,10 +3,7 @@
|
||||
"contractsDir": "./contracts",
|
||||
"useDockerisedSolc": true,
|
||||
"compilerSettings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 1000000
|
||||
},
|
||||
"optimizer": { "enabled": true, "runs": 1000000 },
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
@@ -19,5 +16,5 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"contracts": ["TEC", "TestLibs", "TestInternals"]
|
||||
"contracts": ["TEC", "TestLibs", "MixinSignatureValidator"]
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ contract MixinSignatureValidator is
|
||||
/// @param hash Any 32 byte hash.
|
||||
/// @param signature Proof that the hash has been signed by signer.
|
||||
function getSignerAddress(bytes32 hash, bytes memory signature)
|
||||
internal
|
||||
public
|
||||
pure
|
||||
returns (address signerAddress)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ contract MixinTECApprovalVerifier is
|
||||
uint256[] memory approvalExpirationTimeSeconds,
|
||||
bytes[] memory approvalSignatures
|
||||
)
|
||||
internal
|
||||
public
|
||||
view
|
||||
{
|
||||
// Hash 0x transaction
|
||||
@@ -147,7 +147,7 @@ contract MixinTECApprovalVerifier is
|
||||
uint256 approvalExpirationTimeSeconds,
|
||||
bytes memory approvalSignature
|
||||
)
|
||||
internal
|
||||
public
|
||||
view
|
||||
{
|
||||
// Do not check approval if the order's senderAddress is null
|
||||
@@ -195,16 +195,16 @@ contract MixinTECApprovalVerifier is
|
||||
uint256[] memory approvalExpirationTimeSeconds,
|
||||
bytes[] memory approvalSignatures
|
||||
)
|
||||
internal
|
||||
public
|
||||
view
|
||||
{
|
||||
// Create empty list of approval signers
|
||||
address[] memory approvalSignerAddresses = new address[](0);
|
||||
|
||||
uint256 signaturesLength = approvalSignatures.length;
|
||||
uint256 currentApprovalExpirationTimeseconds = approvalExpirationTimeSeconds[i];
|
||||
for (uint256 i = 0; i < signaturesLength; i++) {
|
||||
// Create approval message
|
||||
uint256 currentApprovalExpirationTimeseconds = approvalExpirationTimeSeconds[i];
|
||||
TECApproval memory approval = TECApproval({
|
||||
transactionHash: transactionHash,
|
||||
transactionSignature: transactionSignature,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
|
||||
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.3;
|
||||
|
||||
|
||||
contract ISignatureValidator {
|
||||
|
||||
/// @dev Recovers the address of a signer given a hash and signature.
|
||||
/// @param hash Any 32 byte hash.
|
||||
/// @param signature Proof that the hash has been signed by signer.
|
||||
function getSignerAddress(bytes32 hash, bytes memory signature)
|
||||
public
|
||||
pure
|
||||
returns (address signerAddress);
|
||||
}
|
||||
@@ -19,25 +19,11 @@
|
||||
pragma solidity ^0.5.3;
|
||||
pragma experimental "ABIEncoderV2";
|
||||
|
||||
import "../src/MixinSignatureValidator.sol";
|
||||
import "../src/MixinTECApprovalVerifier.sol";
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||
import "../libs/LibZeroExTransaction.sol";
|
||||
|
||||
|
||||
contract TestInternals is
|
||||
MixinSignatureValidator,
|
||||
MixinTECApprovalVerifier
|
||||
{
|
||||
/// @dev Recovers the address of a signer given a hash and signature.
|
||||
/// @param hash Any 32 byte hash.
|
||||
/// @param signature Proof that the hash has been signed by signer.
|
||||
function publicGetSignerAddress(bytes32 hash, bytes memory signature)
|
||||
public
|
||||
pure
|
||||
returns (address signerAddress)
|
||||
{
|
||||
signerAddress = getSignerAddress(hash, signature);
|
||||
return signerAddress;
|
||||
}
|
||||
contract ITECApprovalVerifier {
|
||||
|
||||
/// @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.
|
||||
@@ -45,24 +31,14 @@ contract TestInternals 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 publicAssertValidTECApproval(
|
||||
function assertValidTECApproval(
|
||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
||||
bytes memory transactionSignature,
|
||||
uint256[] memory approvalExpirationTimeSeconds,
|
||||
bytes[] memory approvalSignatures
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
assertValidTECApproval(
|
||||
transaction,
|
||||
transactionSignature,
|
||||
approvalExpirationTimeSeconds,
|
||||
approvalSignatures
|
||||
);
|
||||
return true;
|
||||
}
|
||||
view;
|
||||
|
||||
/// @dev Validates that the feeRecipient of a single order has approved a 0x transaction.
|
||||
/// @param order Order struct containing order specifications.
|
||||
@@ -70,7 +46,7 @@ contract TestInternals is
|
||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
||||
/// @param approvalExpirationTimeSeconds Expiration times in seconds for which the approval signature expires.
|
||||
/// @param approvalSignature Signatures that corresponds to the feeRecipient of the order.
|
||||
function publicAssertValidSingleOrderApproval(
|
||||
function assertValidSingleOrderApproval(
|
||||
LibOrder.Order memory order,
|
||||
bytes32 transactionHash,
|
||||
bytes memory transactionSignature,
|
||||
@@ -78,18 +54,7 @@ contract TestInternals is
|
||||
bytes memory approvalSignature
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
assertValidSingleOrderApproval(
|
||||
order,
|
||||
transactionHash,
|
||||
transactionSignature,
|
||||
approvalExpirationTimeSeconds,
|
||||
approvalSignature
|
||||
);
|
||||
return true;
|
||||
}
|
||||
view;
|
||||
|
||||
/// @dev Validates that the feeRecipient of a single order has approved a 0x transaction.
|
||||
/// @param orders Array of order structs containing order specifications.
|
||||
@@ -97,7 +62,7 @@ contract TestInternals 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.
|
||||
function publicAssertValidBatchOrderApproval(
|
||||
function assertValidBatchOrderApproval(
|
||||
LibOrder.Order[] memory orders,
|
||||
bytes32 transactionHash,
|
||||
bytes memory transactionSignature,
|
||||
@@ -105,16 +70,5 @@ contract TestInternals is
|
||||
bytes[] memory approvalSignatures
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
assertValidBatchOrderApproval(
|
||||
orders,
|
||||
transactionHash,
|
||||
transactionSignature,
|
||||
approvalExpirationTimeSeconds,
|
||||
approvalSignatures
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
view;
|
||||
}
|
||||
@@ -18,9 +18,12 @@
|
||||
|
||||
pragma solidity ^0.5.3;
|
||||
|
||||
import "../interfaces/ISignatureValidator.sol";
|
||||
|
||||
contract MSignatureValidator {
|
||||
|
||||
contract MSignatureValidator is
|
||||
ISignatureValidator
|
||||
{
|
||||
// Allowed signature types.
|
||||
enum SignatureType {
|
||||
Illegal, // 0x00, default value
|
||||
@@ -28,12 +31,4 @@ contract MSignatureValidator {
|
||||
EthSign, // 0x02
|
||||
NSignatureTypes // 0x03, number of signature types. Always leave at end.
|
||||
}
|
||||
|
||||
/// @dev Recovers the address of a signer given a hash and signature.
|
||||
/// @param hash Any 32 byte hash.
|
||||
/// @param signature Proof that the hash has been signed by signer.
|
||||
function getSignerAddress(bytes32 hash, bytes memory signature)
|
||||
internal
|
||||
pure
|
||||
returns (address signerAddress);
|
||||
}
|
||||
|
||||
@@ -19,56 +19,9 @@
|
||||
pragma solidity ^0.5.3;
|
||||
pragma experimental "ABIEncoderV2";
|
||||
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||
import "../libs/LibZeroExTransaction.sol";
|
||||
import "../interfaces/ITECApprovalVerifier.sol";
|
||||
|
||||
|
||||
contract MTECApprovalVerifier {
|
||||
|
||||
/// @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 assertValidTECApproval(
|
||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
||||
bytes memory transactionSignature,
|
||||
uint256[] memory approvalExpirationTimeSeconds,
|
||||
bytes[] memory approvalSignatures
|
||||
)
|
||||
internal
|
||||
view;
|
||||
|
||||
/// @dev Validates that the feeRecipient of a single order has approved a 0x transaction.
|
||||
/// @param order Order struct containing order specifications.
|
||||
/// @param transactionHash EIP712 hash of the 0x transaction.
|
||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
||||
/// @param approvalExpirationTimeSeconds Expiration times in seconds for which the approval signature expires.
|
||||
/// @param approvalSignature Signatures that corresponds to the feeRecipient of the order.
|
||||
function assertValidSingleOrderApproval(
|
||||
LibOrder.Order memory order,
|
||||
bytes32 transactionHash,
|
||||
bytes memory transactionSignature,
|
||||
uint256 approvalExpirationTimeSeconds,
|
||||
bytes memory approvalSignature
|
||||
)
|
||||
internal
|
||||
view;
|
||||
|
||||
/// @dev Validates that the feeRecipient of a single order has approved a 0x transaction.
|
||||
/// @param orders Array of order structs containing order specifications.
|
||||
/// @param transactionHash EIP712 hash of the 0x transaction.
|
||||
/// @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 assertValidBatchOrderApproval(
|
||||
LibOrder.Order[] memory orders,
|
||||
bytes32 transactionHash,
|
||||
bytes memory transactionSignature,
|
||||
uint256[] memory approvalExpirationTimeSeconds,
|
||||
bytes[] memory approvalSignatures
|
||||
)
|
||||
internal
|
||||
view;
|
||||
}
|
||||
contract MTECApprovalVerifier is
|
||||
ITECApprovalVerifier
|
||||
{}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { eip712Utils, EXCHANGE_ZEROEX_TRANSACTION_SCHEMA } from '@0x/order-utils';
|
||||
import { eip712Utils } from '@0x/order-utils';
|
||||
import { constants as orderUtilsConstants } from '@0x/order-utils/lib/src/constants';
|
||||
import { SignedZeroExTransaction, ZeroExTransaction } from '@0x/types';
|
||||
import { BigNumber, signTypedDataUtils } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
@@ -45,8 +46,8 @@ export const approvalHashUtils = {
|
||||
return !_.isString(value) ? value.toString() : value;
|
||||
});
|
||||
const typedData = eip712Utils.createTypedData(
|
||||
EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.name,
|
||||
{ ZeroExTransaction: EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.parameters },
|
||||
orderUtilsConstants.EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.name,
|
||||
{ ZeroExTransaction: orderUtilsConstants.EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.parameters },
|
||||
normalizedTransaction,
|
||||
domain,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user