diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-04 16:09:08 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-04 16:09:08 +0800 |
commit | 7759e67a5a51a213e19083f63df13e80ea4aefa2 (patch) | |
tree | 9eedc8e87196c080787f0a6841bdb67199cbcfed | |
parent | 4d75689790075f734df9a2e3b80443c85e1ddc95 (diff) | |
download | dexon-sol-tools-7759e67a5a51a213e19083f63df13e80ea4aefa2.tar.gz dexon-sol-tools-7759e67a5a51a213e19083f63df13e80ea4aefa2.tar.zst dexon-sol-tools-7759e67a5a51a213e19083f63df13e80ea4aefa2.zip |
Rename EIP712Utils to eip712Utils since objectLiterals shouldn't start with caps
-rw-r--r-- | packages/contracts/test/exchange/libs.ts | 4 | ||||
-rw-r--r-- | packages/contracts/test/utils/transaction_factory.ts | 6 | ||||
-rw-r--r-- | packages/order-utils/src/eip712_utils.ts | 20 | ||||
-rw-r--r-- | packages/order-utils/src/index.ts | 2 | ||||
-rw-r--r-- | packages/order-utils/src/order_hash.ts | 8 |
5 files changed, 20 insertions, 20 deletions
diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts index 5c9f9aac7..6c3305d1d 100644 --- a/packages/contracts/test/exchange/libs.ts +++ b/packages/contracts/test/exchange/libs.ts @@ -1,5 +1,5 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; -import { assetDataUtils, EIP712Utils, orderHashUtils } from '@0xproject/order-utils'; +import { assetDataUtils, eip712Utils, orderHashUtils } from '@0xproject/order-utils'; import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; @@ -109,7 +109,7 @@ describe('Exchange libs', () => { describe('getDomainSeparatorSchema', () => { it('should output the correct domain separator schema hash', async () => { const domainSeparatorSchema = await libs.getDomainSeparatorSchemaHash.callAsync(); - const domainSchemaBuffer = EIP712Utils._getDomainSeparatorSchemaBuffer(); + const domainSchemaBuffer = eip712Utils._getDomainSeparatorSchemaBuffer(); const schemaHashHex = `0x${domainSchemaBuffer.toString('hex')}`; expect(schemaHashHex).to.be.equal(domainSeparatorSchema); }); diff --git a/packages/contracts/test/utils/transaction_factory.ts b/packages/contracts/test/utils/transaction_factory.ts index 281c1e30d..8465a6a30 100644 --- a/packages/contracts/test/utils/transaction_factory.ts +++ b/packages/contracts/test/utils/transaction_factory.ts @@ -1,4 +1,4 @@ -import { EIP712Schema, EIP712Types, EIP712Utils, generatePseudoRandomSalt } from '@0xproject/order-utils'; +import { EIP712Schema, EIP712Types, eip712Utils, generatePseudoRandomSalt } from '@0xproject/order-utils'; import { SignatureType } from '@0xproject/types'; import * as ethUtil from 'ethereumjs-util'; @@ -31,11 +31,11 @@ export class TransactionFactory { signerAddress, data, }; - const executeTransactionHashBuff = EIP712Utils.structHash( + const executeTransactionHashBuff = eip712Utils.structHash( EIP712_ZEROEX_TRANSACTION_SCHEMA, executeTransactionData, ); - const txHash = EIP712Utils.createEIP712Message(executeTransactionHashBuff, this._exchangeAddress); + const txHash = eip712Utils.createEIP712Message(executeTransactionHashBuff, this._exchangeAddress); const signature = signingUtils.signMessage(txHash, this._privateKey, signatureType); const signedTx = { exchangeAddress: this._exchangeAddress, diff --git a/packages/order-utils/src/eip712_utils.ts b/packages/order-utils/src/eip712_utils.ts index c7b20f824..b303c93dc 100644 --- a/packages/order-utils/src/eip712_utils.ts +++ b/packages/order-utils/src/eip712_utils.ts @@ -18,14 +18,14 @@ const EIP712_DOMAIN_SCHEMA: EIP712Schema = { ], }; -export const EIP712Utils = { +export const eip712Utils = { /** * Compiles the EIP712Schema and returns the hash of the schema. * @param schema The EIP712 schema. * @return The hash of the compiled schema */ compileSchema(schema: EIP712Schema): Buffer { - const eip712Schema = EIP712Utils._encodeType(schema); + const eip712Schema = eip712Utils._encodeType(schema); const eip712SchemaHashBuffer = crypto.solSHA3([eip712Schema]); return eip712SchemaHashBuffer; }, @@ -36,7 +36,7 @@ export const EIP712Utils = { * @return The hash of an EIP712 message with domain separator prefixed */ createEIP712Message(hashStruct: Buffer, contractAddress: string): Buffer { - const domainSeparatorHashBuffer = EIP712Utils._getDomainSeparatorHashBuffer(contractAddress); + const domainSeparatorHashBuffer = eip712Utils._getDomainSeparatorHashBuffer(contractAddress); const messageBuff = crypto.solSHA3([EIP191_PREFIX, domainSeparatorHashBuffer, hashStruct]); return messageBuff; }, @@ -47,7 +47,7 @@ export const EIP712Utils = { */ pad32Address(address: string): Buffer { const addressBuffer = ethUtil.toBuffer(address); - const addressPadded = EIP712Utils.pad32Buffer(addressBuffer); + const addressPadded = eip712Utils.pad32Buffer(addressBuffer); return addressPadded; }, /** @@ -66,17 +66,17 @@ export const EIP712Utils = { * @return A buffer containing the SHA256 hash of the schema and encoded data */ structHash(schema: EIP712Schema, data: { [key: string]: any }): Buffer { - const encodedData = EIP712Utils._encodeData(schema, data); - const schemaHash = EIP712Utils.compileSchema(schema); + const encodedData = eip712Utils._encodeData(schema, data); + const schemaHash = eip712Utils.compileSchema(schema); const hashBuffer = crypto.solSHA3([schemaHash, ...encodedData]); return hashBuffer; }, _getDomainSeparatorSchemaBuffer(): Buffer { - return EIP712Utils.compileSchema(EIP712_DOMAIN_SCHEMA); + return eip712Utils.compileSchema(EIP712_DOMAIN_SCHEMA); }, _getDomainSeparatorHashBuffer(exchangeAddress: string): Buffer { - const domainSeparatorSchemaBuffer = EIP712Utils._getDomainSeparatorSchemaBuffer(); - const encodedData = EIP712Utils._encodeData(EIP712_DOMAIN_SCHEMA, { + const domainSeparatorSchemaBuffer = eip712Utils._getDomainSeparatorSchemaBuffer(); + const encodedData = eip712Utils._encodeData(EIP712_DOMAIN_SCHEMA, { name: EIP712_DOMAIN_NAME, version: EIP712_DOMAIN_VERSION, verifyingContract: exchangeAddress, @@ -99,7 +99,7 @@ export const EIP712Utils = { } else if (parameter.type === EIP712Types.Uint256) { encodedValues.push(value); } else if (parameter.type === EIP712Types.Address) { - encodedValues.push(EIP712Utils.pad32Address(value)); + encodedValues.push(eip712Utils.pad32Address(value)); } else { throw new Error(`Unable to encode ${parameter.type}`); } diff --git a/packages/order-utils/src/index.ts b/packages/order-utils/src/index.ts index 50a5106ca..f3b00a583 100644 --- a/packages/order-utils/src/index.ts +++ b/packages/order-utils/src/index.ts @@ -2,7 +2,7 @@ export { orderHashUtils } from './order_hash'; export { signatureUtils } from './signature_utils'; export { generatePseudoRandomSalt } from './salt'; export { assetDataUtils } from './asset_data_utils'; -export { EIP712Utils } from './eip712_utils'; +export { eip712Utils } from './eip712_utils'; export { OrderStateUtils } from './order_state_utils'; export { AbstractBalanceAndProxyAllowanceFetcher } from './abstract/abstract_balance_and_proxy_allowance_fetcher'; diff --git a/packages/order-utils/src/order_hash.ts b/packages/order-utils/src/order_hash.ts index 54c500653..8e98f8767 100644 --- a/packages/order-utils/src/order_hash.ts +++ b/packages/order-utils/src/order_hash.ts @@ -3,7 +3,7 @@ import { Order, SignedOrder } from '@0xproject/types'; import * as _ from 'lodash'; import { assert } from './assert'; -import { EIP712Utils } from './eip712_utils'; +import { eip712Utils } from './eip712_utils'; import { EIP712Schema, EIP712Types } from './types'; const INVALID_TAKER_FORMAT = 'instance.takerAddress is not of a type(s) string'; @@ -69,11 +69,11 @@ export const orderHashUtils = { * @return The resulting orderHash from hashing the supplied order as a Buffer */ getOrderHashBuffer(order: SignedOrder | Order): Buffer { - const orderParamsHashBuff = EIP712Utils.structHash(EIP712_ORDER_SCHEMA, order); - const orderHashBuff = EIP712Utils.createEIP712Message(orderParamsHashBuff, order.exchangeAddress); + const orderParamsHashBuff = eip712Utils.structHash(EIP712_ORDER_SCHEMA, order); + const orderHashBuff = eip712Utils.createEIP712Message(orderParamsHashBuff, order.exchangeAddress); return orderHashBuff; }, _getOrderSchemaBuffer(): Buffer { - return EIP712Utils.compileSchema(EIP712_ORDER_SCHEMA); + return eip712Utils.compileSchema(EIP712_ORDER_SCHEMA); }, }; |