From b883b183a6c6011e306fee4338eb4d0da698911a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 7 Feb 2019 01:03:43 +0000 Subject: Stop exporting EIP712 schemas --- packages/order-utils/CHANGELOG.json | 6 ++++++ packages/order-utils/src/eip712_utils.ts | 20 +++++++------------- packages/order-utils/src/index.ts | 9 +-------- packages/order-utils/test/eip712_utils_test.ts | 17 ++++++----------- 4 files changed, 20 insertions(+), 32 deletions(-) diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index b5eb209d7..fcecdd48e 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -1,4 +1,10 @@ [ + { + "version": "6.0.0", + "changes": { + "note": "Stop exporting the EIP712 schemas" + } + }, { "version": "5.0.0", "changes": [ diff --git a/packages/order-utils/src/eip712_utils.ts b/packages/order-utils/src/eip712_utils.ts index 313653c63..685fdc8c8 100644 --- a/packages/order-utils/src/eip712_utils.ts +++ b/packages/order-utils/src/eip712_utils.ts @@ -12,12 +12,6 @@ import * as _ from 'lodash'; import { constants } from './constants'; -export const DEFAULT_DOMAIN_SCHEMA = constants.DEFAULT_DOMAIN_SCHEMA; -export const EXCHANGE_DOMAIN_NAME = constants.EXCHANGE_DOMAIN_NAME; -export const EXCHANGE_DOMAIN_VERSION = constants.EXCHANGE_DOMAIN_VERSION; -export const EXCHANGE_ORDER_SCHEMA = constants.EXCHANGE_ORDER_SCHEMA; -export const EXCHANGE_ZEROEX_TRANSACTION_SCHEMA = constants.EXCHANGE_ZEROEX_TRANSACTION_SCHEMA; - export const eip712Utils = { /** * Creates a EIP712TypedData object specific to the 0x protocol for use with signTypedData. @@ -37,12 +31,12 @@ export const eip712Utils = { assert.isString('primaryType', primaryType); const typedData = { types: { - EIP712Domain: DEFAULT_DOMAIN_SCHEMA.parameters, + EIP712Domain: constants.DEFAULT_DOMAIN_SCHEMA.parameters, ...types, }, domain: { - name: _.isUndefined(domain.name) ? EXCHANGE_DOMAIN_NAME : domain.name, - version: _.isUndefined(domain.version) ? EXCHANGE_DOMAIN_VERSION : domain.version, + name: _.isUndefined(domain.name) ? constants.EXCHANGE_DOMAIN_NAME : domain.name, + version: _.isUndefined(domain.version) ? constants.EXCHANGE_DOMAIN_VERSION : domain.version, verifyingContract: domain.verifyingContractAddress, }, message, @@ -65,8 +59,8 @@ export const eip712Utils = { verifyingContractAddress: order.exchangeAddress, }; const typedData = eip712Utils.createTypedData( - EXCHANGE_ORDER_SCHEMA.name, - { Order: EXCHANGE_ORDER_SCHEMA.parameters }, + constants.EXCHANGE_ORDER_SCHEMA.name, + { Order: constants.EXCHANGE_ORDER_SCHEMA.parameters }, normalizedOrder, domain, ); @@ -88,8 +82,8 @@ export const eip712Utils = { verifyingContractAddress: zeroExTransaction.verifyingContractAddress, }; const typedData = eip712Utils.createTypedData( - EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.name, - { ZeroExTransaction: EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.parameters }, + constants.EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.name, + { ZeroExTransaction: constants.EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.parameters }, normalizedTransaction, domain, ); diff --git a/packages/order-utils/src/index.ts b/packages/order-utils/src/index.ts index 436677efc..ff37d7088 100644 --- a/packages/order-utils/src/index.ts +++ b/packages/order-utils/src/index.ts @@ -19,14 +19,7 @@ export { ExchangeTransferSimulator } from './exchange_transfer_simulator'; export { BalanceAndProxyAllowanceLazyStore } from './store/balance_and_proxy_allowance_lazy_store'; export { OrderFilledCancelledLazyStore } from './store/order_filled_cancelled_lazy_store'; -export { - eip712Utils, - DEFAULT_DOMAIN_SCHEMA, - EXCHANGE_DOMAIN_NAME, - EXCHANGE_DOMAIN_VERSION, - EXCHANGE_ORDER_SCHEMA, - EXCHANGE_ZEROEX_TRANSACTION_SCHEMA, -} from './eip712_utils'; +export { eip712Utils } from './eip712_utils'; export { Provider, diff --git a/packages/order-utils/test/eip712_utils_test.ts b/packages/order-utils/test/eip712_utils_test.ts index 4208e9beb..c97bed144 100644 --- a/packages/order-utils/test/eip712_utils_test.ts +++ b/packages/order-utils/test/eip712_utils_test.ts @@ -3,12 +3,7 @@ import * as chai from 'chai'; import 'mocha'; import { constants } from '../src/constants'; -import { - eip712Utils, - EXCHANGE_DOMAIN_NAME, - EXCHANGE_DOMAIN_VERSION, - EXCHANGE_ZEROEX_TRANSACTION_SCHEMA, -} from '../src/eip712_utils'; +import { eip712Utils } from '../src/eip712_utils'; import { chaiSetup } from './utils/chai_setup'; @@ -28,8 +23,8 @@ describe('EIP712 Utils', () => { expect(typedData.domain).to.not.be.undefined(); expect(typedData.types.EIP712Domain).to.not.be.undefined(); const domainObject = typedData.domain; - expect(domainObject.name).to.eq(EXCHANGE_DOMAIN_NAME); - expect(domainObject.version).to.eq(EXCHANGE_DOMAIN_VERSION); + expect(domainObject.name).to.eq(constants.EXCHANGE_DOMAIN_NAME); + expect(domainObject.version).to.eq(constants.EXCHANGE_DOMAIN_VERSION); expect(domainObject.verifyingContract).to.eq(constants.NULL_ADDRESS); expect(typedData.primaryType).to.eq(primaryType); }); @@ -60,11 +55,11 @@ describe('EIP712 Utils', () => { signerAddress: constants.NULL_ADDRESS, verifyingContractAddress: constants.NULL_ADDRESS, }); - expect(typedData.primaryType).to.eq(EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.name); + expect(typedData.primaryType).to.eq(constants.EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.name); expect(typedData.types.EIP712Domain).to.not.be.undefined(); const domainObject = typedData.domain; - expect(domainObject.name).to.eq(EXCHANGE_DOMAIN_NAME); - expect(domainObject.version).to.eq(EXCHANGE_DOMAIN_VERSION); + expect(domainObject.name).to.eq(constants.EXCHANGE_DOMAIN_NAME); + expect(domainObject.version).to.eq(constants.EXCHANGE_DOMAIN_VERSION); expect(domainObject.verifyingContract).to.eq(constants.NULL_ADDRESS); }); }); -- cgit v1.2.3