diff options
Diffstat (limited to 'packages')
6 files changed, 42 insertions, 22 deletions
diff --git a/packages/contract-wrappers/test/calldata_optimization_utils_test.ts b/packages/contract-wrappers/test/calldata_optimization_utils_test.ts index a4cea772f..a3abb8503 100644 --- a/packages/contract-wrappers/test/calldata_optimization_utils_test.ts +++ b/packages/contract-wrappers/test/calldata_optimization_utils_test.ts @@ -1,4 +1,4 @@ -import { orderFactory } from '@0xproject/order-utils'; +import { orderFactory } from '@0xproject/order-utils/lib/src/order_factory'; import * as chai from 'chai'; import * as _ from 'lodash'; import 'mocha'; diff --git a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts index 84fb9d20c..777d908fb 100644 --- a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts +++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts @@ -1,15 +1,14 @@ -import * as _ from 'lodash'; - -import { constants } from '../constants'; -import { utils } from './utils'; - import { readFileSync, writeFileSync } from 'fs'; +import * as _ from 'lodash'; import * as path from 'path'; import { exec as execAsync } from 'promisify-child-process'; import * as ts from 'typescript'; +import { constants } from '../constants'; import { ExportPathToExportedItems } from '../types'; +import { utils } from './utils'; + interface ExportInfo { exportPathToExportedItems: ExportPathToExportedItems; exportPathOrder: string[]; @@ -83,8 +82,8 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging: } if (!_.startsWith(innerExportPath, './')) { throw new Error( - `GENERATE_UPLOAD_DOCS: WARNING - ${packageName} is exporting one of ${innerExportItems} which is - itself exported from an external package. To fix this, export the external dependency directly, + `GENERATE_UPLOAD_DOCS: WARNING - ${packageName} is exporting one of ${innerExportItems} which is + itself exported from an external package. To fix this, export the external dependency directly, not indirectly through ${innerExportPath}.`, ); } else { @@ -192,6 +191,8 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging: // Remove the generated docs directory await execAsync(`rm -rf ${jsonFilePath}`, { cwd, + }); +} function getAllReferenceNames(propertyName: string, node: any, referenceNames: string[]): string[] { let updatedReferenceNames = referenceNames; diff --git a/packages/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts index d466bb00d..40bbcef98 100644 --- a/packages/order-utils/src/signature_utils.ts +++ b/packages/order-utils/src/signature_utils.ts @@ -49,7 +49,7 @@ export const signatureUtils = { case SignatureType.EthSign: { const ecSignature = signatureUtils.parseECSignature(signature); - const prefixedMessageHex = signatureUtils.addSignedMessagePrefix(data, SignerType.EthSign); + const prefixedMessageHex = signatureUtils.addSignedMessagePrefix(data, SignerType.Default); return signatureUtils.isValidECSignature(prefixedMessageHex, ecSignature, signerAddress); } diff --git a/packages/order-utils/test/market_utils_test.ts b/packages/order-utils/test/market_utils_test.ts index 21c0a4802..5d94cc55c 100644 --- a/packages/order-utils/test/market_utils_test.ts +++ b/packages/order-utils/test/market_utils_test.ts @@ -2,7 +2,8 @@ import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import 'mocha'; -import { constants, marketUtils } from '../src'; +import { marketUtils } from '../src'; +import { constants } from '../src/constants'; import { chaiSetup } from './utils/chai_setup'; import { testOrderFactory } from './utils/test_order_factory'; diff --git a/packages/order-utils/test/signature_utils_test.ts b/packages/order-utils/test/signature_utils_test.ts index 06ff86515..4ce99a1c7 100644 --- a/packages/order-utils/test/signature_utils_test.ts +++ b/packages/order-utils/test/signature_utils_test.ts @@ -6,8 +6,8 @@ import * as _ from 'lodash'; import 'mocha'; import * as Sinon from 'sinon'; -import { signatureUtils, generatePseudoRandomSalt } from '../src'; -import { convertECSignatureToSignatureHex, isValidSignatureAsync } from '../src/signature_utils'; +import { generatePseudoRandomSalt } from '../src'; +import { signatureUtils } from '../src/signature_utils'; import { chaiSetup } from './utils/chai_setup'; import { provider, web3Wrapper } from './utils/web3_wrapper'; @@ -16,7 +16,7 @@ chaiSetup.configure(); const expect = chai.expect; describe('Signature utils', () => { - describe('#isValidSignature', () => { + describe('#isValidSignatureAsync', () => { let dataHex = '0x6927e990021d23b1eb7b8789f6a6feaf98fe104bb0cf8259421b79f9a34222b0'; const ethSignSignature = '0x1B61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace225403'; @@ -255,7 +255,12 @@ describe('Signature utils', () => { SignerType.Default, ); - const isValidSignature = await isValidSignatureAsync(provider, orderHash, ecSignature, makerAddress); + const isValidSignature = await signatureUtils.isValidSignatureAsync( + provider, + orderHash, + ecSignature, + makerAddress, + ); expect(isValidSignature).to.be.true(); }); }); @@ -268,32 +273,44 @@ describe('Signature utils', () => { it('should concatenate v,r,s and append the Trezor signature type', async () => { const expectedSignatureWithSignatureType = '0x1baca7da997ad177f040240cdccf6905b71ab16b74434388c3a72f34fd25d6439346b2bac274ff29b48b3ea6e2d04c1336eaceafda3c53ab483fc3ff12fac3ebf208'; - const signatureWithSignatureType = convertECSignatureToSignatureHex(ecSignature, SignerType.Trezor); + const signatureWithSignatureType = signatureUtils.convertECSignatureToSignatureHex( + ecSignature, + SignerType.Trezor, + ); expect(signatureWithSignatureType).to.equal(expectedSignatureWithSignatureType); }); it('should concatenate v,r,s and append the EthSign signature type when SignerType is Default', async () => { const expectedSignatureWithSignatureType = '0x1baca7da997ad177f040240cdccf6905b71ab16b74434388c3a72f34fd25d6439346b2bac274ff29b48b3ea6e2d04c1336eaceafda3c53ab483fc3ff12fac3ebf203'; - const signatureWithSignatureType = convertECSignatureToSignatureHex(ecSignature, SignerType.Default); + const signatureWithSignatureType = signatureUtils.convertECSignatureToSignatureHex( + ecSignature, + SignerType.Default, + ); expect(signatureWithSignatureType).to.equal(expectedSignatureWithSignatureType); }); it('should concatenate v,r,s and append the EthSign signature type when SignerType is Ledger', async () => { const expectedSignatureWithSignatureType = '0x1baca7da997ad177f040240cdccf6905b71ab16b74434388c3a72f34fd25d6439346b2bac274ff29b48b3ea6e2d04c1336eaceafda3c53ab483fc3ff12fac3ebf203'; - const signatureWithSignatureType = convertECSignatureToSignatureHex(ecSignature, SignerType.Ledger); + const signatureWithSignatureType = signatureUtils.convertECSignatureToSignatureHex( + ecSignature, + SignerType.Ledger, + ); expect(signatureWithSignatureType).to.equal(expectedSignatureWithSignatureType); }); it('should concatenate v,r,s and append the EthSign signature type when SignerType is Metamask', async () => { const expectedSignatureWithSignatureType = '0x1baca7da997ad177f040240cdccf6905b71ab16b74434388c3a72f34fd25d6439346b2bac274ff29b48b3ea6e2d04c1336eaceafda3c53ab483fc3ff12fac3ebf203'; - const signatureWithSignatureType = convertECSignatureToSignatureHex(ecSignature, SignerType.Metamask); + const signatureWithSignatureType = signatureUtils.convertECSignatureToSignatureHex( + ecSignature, + SignerType.Metamask, + ); expect(signatureWithSignatureType).to.equal(expectedSignatureWithSignatureType); }); it('should throw if the SignerType is invalid', async () => { const expectedMessage = 'Unrecognized SignerType: INVALID_SIGNER'; - expect(() => convertECSignatureToSignatureHex(ecSignature, 'INVALID_SIGNER' as SignerType)).to.throw( - expectedMessage, - ); + expect(() => + signatureUtils.convertECSignatureToSignatureHex(ecSignature, 'INVALID_SIGNER' as SignerType), + ).to.throw(expectedMessage); }); }); }); diff --git a/packages/order-utils/test/utils/test_order_factory.ts b/packages/order-utils/test/utils/test_order_factory.ts index 75dc6f1f2..69184f129 100644 --- a/packages/order-utils/test/utils/test_order_factory.ts +++ b/packages/order-utils/test/utils/test_order_factory.ts @@ -1,7 +1,8 @@ import { Order, SignedOrder } from '@0xproject/types'; import * as _ from 'lodash'; -import { constants, orderFactory } from '../../src'; +import { constants } from '../../src/constants'; +import { orderFactory } from '../../src/order_factory'; const BASE_TEST_ORDER: Order = orderFactory.createOrder( constants.NULL_ADDRESS, |