From 7a1e6cccfd3b45a1b8121f6e677d1449043473d3 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Fri, 1 Feb 2019 14:00:48 -0800 Subject: [PATCH] Add public wrappers for libs --- contracts/tec/compiler.json | 2 +- contracts/tec/contracts/test/TestLibs.sol | 53 +++++++++++++++++++++++ contracts/tec/package.json | 2 +- contracts/tec/src/artifacts/index.ts | 2 + contracts/tec/src/wrappers/index.ts | 1 + contracts/tec/tsconfig.json | 2 +- 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 contracts/tec/contracts/test/TestLibs.sol diff --git a/contracts/tec/compiler.json b/contracts/tec/compiler.json index 66a3b85d12..15dd34eeaa 100644 --- a/contracts/tec/compiler.json +++ b/contracts/tec/compiler.json @@ -18,5 +18,5 @@ } } }, - "contracts": ["TEC"] + "contracts": ["TEC", "TestLibs"] } diff --git a/contracts/tec/contracts/test/TestLibs.sol b/contracts/tec/contracts/test/TestLibs.sol new file mode 100644 index 0000000000..8c0ba095bc --- /dev/null +++ b/contracts/tec/contracts/test/TestLibs.sol @@ -0,0 +1,53 @@ +/* + + 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.2; +pragma experimental "ABIEncoderV2"; + +import "../src/libs/LibTECApproval.sol"; +import "../src/libs/LibZeroExTransaction.sol"; + + +contract TestLibs is + LibTECApproval, + 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) + public + view + returns (bytes32 approvalHash) + { + approvalHash = getTECApprovalHash(approval); + return approvalHash; + } + + /// @dev Calculates the EIP712 hash of a 0x transaction using the domain separator of this contract. + /// @param transaction 0x transaction containing salt, signerAddress, and data. + /// @return EIP712 hash of the transaction with the domain separator of this contract. + function publicGetTransactionHash(ZeroExTransaction memory transaction) + public + view + returns (bytes32 transactionHash) + { + transactionHash = getTransactionHash(transaction); + return transactionHash; + } +} \ No newline at end of file diff --git a/contracts/tec/package.json b/contracts/tec/package.json index a3319d9cad..f1cd850ae6 100644 --- a/contracts/tec/package.json +++ b/contracts/tec/package.json @@ -32,7 +32,7 @@ "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "generated-artifacts/@(TEC).json" + "abis": "generated-artifacts/@(TEC|TestLibs).json" }, "repository": { "type": "git", diff --git a/contracts/tec/src/artifacts/index.ts b/contracts/tec/src/artifacts/index.ts index c2bb7a21d5..c481f0dc64 100644 --- a/contracts/tec/src/artifacts/index.ts +++ b/contracts/tec/src/artifacts/index.ts @@ -1,7 +1,9 @@ import { ContractArtifact } from 'ethereum-types'; import * as TEC from '../../generated-artifacts/TEC.json'; +import * as TestLibs from '../../generated-artifacts/TestLibs.json'; export const artifacts = { TEC: TEC as ContractArtifact, + TestLibs: TestLibs as ContractArtifact, }; diff --git a/contracts/tec/src/wrappers/index.ts b/contracts/tec/src/wrappers/index.ts index 326e5bc23c..a360bd9355 100644 --- a/contracts/tec/src/wrappers/index.ts +++ b/contracts/tec/src/wrappers/index.ts @@ -1 +1,2 @@ export * from '../../generated-wrappers/tec'; +export * from '../../generated-wrappers/test_libs'; diff --git a/contracts/tec/tsconfig.json b/contracts/tec/tsconfig.json index 50ebbe9a67..23a44a7db9 100644 --- a/contracts/tec/tsconfig.json +++ b/contracts/tec/tsconfig.json @@ -6,6 +6,6 @@ "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], - "files": ["./generated-artifacts/TEC.json"], + "files": ["./generated-artifacts/TEC.json", "./generated-artifacts/TestLibs.json"], "exclude": ["./deploy/solc/solc_bin"] }