diff --git a/.prettierignore b/.prettierignore index b316fa8865..d9aa5a46df 100644 --- a/.prettierignore +++ b/.prettierignore @@ -80,10 +80,8 @@ lib /contracts/erc1155/build/ /contracts/extensions/build/ /contracts/exchange-forwarder/build/ -/packages/asset-swapper/generated-artifacts -/packages/asset-swapper/generated-wrappers -/packages/asset-swapper/test/generated-artifacts -/packages/asset-swapper/test/generated-wrappers +/packages/asset-swapper/ +/packages/contract-wrappers/src/generated-wrappers/ package.json packages/*/docs docs/ diff --git a/contracts/erc20/src/artifacts.ts b/contracts/erc20/src/artifacts.ts index 58950e0e05..d8339aaafb 100644 --- a/contracts/erc20/src/artifacts.ts +++ b/contracts/erc20/src/artifacts.ts @@ -15,7 +15,7 @@ export const artifacts = { DummyERC20Token: DummyERC20Token as ContractArtifact, ERC20Token: ERC20Token as ContractArtifact, WETH9: WETH9 as ContractArtifact, - ZRXToken: (ZRXToken as any) as ContractArtifact, + ZRXToken: ZRXToken as any as ContractArtifact, DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, }; diff --git a/contracts/erc20/test/artifacts.ts b/contracts/erc20/test/artifacts.ts index a7249ae38a..54624be41f 100644 --- a/contracts/erc20/test/artifacts.ts +++ b/contracts/erc20/test/artifacts.ts @@ -28,7 +28,7 @@ export const artifacts = { MintableERC20Token: MintableERC20Token as ContractArtifact, UnlimitedAllowanceERC20Token: UnlimitedAllowanceERC20Token as ContractArtifact, WETH9: WETH9 as ContractArtifact, - ZRXToken: (ZRXToken as any) as ContractArtifact, + ZRXToken: ZRXToken as any as ContractArtifact, IERC20Token: IERC20Token as ContractArtifact, IEtherToken: IEtherToken as ContractArtifact, IERC20TokenV06: IERC20TokenV06 as ContractArtifact, diff --git a/contracts/test-utils/src/mocha_blockchain.ts b/contracts/test-utils/src/mocha_blockchain.ts index b9cf11e6d4..9d7260635b 100644 --- a/contracts/test-utils/src/mocha_blockchain.ts +++ b/contracts/test-utils/src/mocha_blockchain.ts @@ -236,7 +236,7 @@ export const describe = _.assign(mochaDescribe, { * Like mocha's `describe()`, but sets up a blockchain environment for you. */ export const blockchainTests: BlockchainContextDefinition = _.assign( - function(description: string, callback: BlockchainSuiteCallback): ISuite { + function (description: string, callback: BlockchainSuiteCallback): ISuite { return defineBlockchainSuite(StandardBlockchainTestsEnvironmentSingleton, description, callback, describe); }, { @@ -275,7 +275,7 @@ export const blockchainTests: BlockchainContextDefinition = _.assign( ); }, fork: _.assign( - function(description: string, callback: BlockchainSuiteCallback): ISuite | void { + function (description: string, callback: BlockchainSuiteCallback): ISuite | void { return defineBlockchainSuite( ForkedBlockchainTestsEnvironmentSingleton, description, @@ -319,7 +319,7 @@ export const blockchainTests: BlockchainContextDefinition = _.assign( }, ), live: _.assign( - function(description: string, callback: BlockchainSuiteCallback): ISuite | void { + function (description: string, callback: BlockchainSuiteCallback): ISuite | void { return defineBlockchainSuite( LiveBlockchainTestsEnvironmentSingleton, description, @@ -355,7 +355,7 @@ export const blockchainTests: BlockchainContextDefinition = _.assign( }, ), resets: _.assign( - function(description: string, callback: BlockchainSuiteCallback): ISuite { + function (description: string, callback: BlockchainSuiteCallback): ISuite { return defineResetsBlockchainSuite( StandardBlockchainTestsEnvironmentSingleton, description, @@ -399,7 +399,7 @@ function defineBlockchainSuite( callback: BlockchainSuiteCallback, describeCall: ContextDefinitionCallback, ): T { - return describeCall(description, function(this: ISuiteCallbackContext): void { + return describeCall(description, function (this: ISuiteCallbackContext): void { callback.call(this, envFactory.create()); }); } @@ -410,7 +410,7 @@ function defineResetsBlockchainSuite( callback: BlockchainSuiteCallback, describeCall: ContextDefinitionCallback, ): T { - return describeCall(description, function(this: ISuiteCallbackContext): void { + return describeCall(description, function (this: ISuiteCallbackContext): void { const env = envFactory.create(); beforeEach(async () => env.blockchainLifecycle.startAsync()); afterEach(async () => env.blockchainLifecycle.revertAsync()); diff --git a/contracts/test-utils/src/number_utils.ts b/contracts/test-utils/src/number_utils.ts index ecf3469c4c..86aba372b7 100644 --- a/contracts/test-utils/src/number_utils.ts +++ b/contracts/test-utils/src/number_utils.ts @@ -40,10 +40,7 @@ export function getRandomPortion(total: Numberish): BigNumber { export function getRandomFloat(min: Numberish, max: Numberish): BigNumber { // Generate a really high precision number between [0, 1] const r = new BigNumber(crypto.randomBytes(32).toString('hex'), 16).dividedBy(new BigNumber(2).pow(256).minus(1)); - return new BigNumber(max) - .minus(min) - .times(r) - .plus(min); + return new BigNumber(max).minus(min).times(r).plus(min); } export const FIXED_POINT_BASE = new BigNumber(2).pow(127); @@ -77,10 +74,7 @@ export function getNumericalDivergence(a: Numberish, b: Numberish, precision = 1 const base = 10 ** (precision - maxIntegerDigits); return n.times(base).integerValue(BigNumber.ROUND_DOWN); }; - return _toInteger(_a) - .minus(_toInteger(_b)) - .abs() - .toNumber(); + return _toInteger(_a).minus(_toInteger(_b)).abs().toNumber(); } /** @@ -97,10 +91,7 @@ export function assertRoughlyEquals(actual: Numberish, expected: Numberish, prec * Asserts that two numbers are equal with up to `maxError` difference between them. */ export function assertIntegerRoughlyEquals(actual: Numberish, expected: Numberish, maxError = 1, msg?: string): void { - const diff = new BigNumber(actual) - .minus(expected) - .abs() - .toNumber(); + const diff = new BigNumber(actual).minus(expected).abs().toNumber(); if (diff <= maxError) { return; } diff --git a/contracts/test-utils/src/order_utils.ts b/contracts/test-utils/src/order_utils.ts index 47d87d9bd2..85f1f00b92 100644 --- a/contracts/test-utils/src/order_utils.ts +++ b/contracts/test-utils/src/order_utils.ts @@ -8,10 +8,7 @@ import { BatchMatchOrder, CancelOrder, MatchOrder } from './types'; export const orderUtils = { getPartialAmountFloor(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber { - const partialAmount = numerator - .multipliedBy(target) - .div(denominator) - .integerValue(BigNumber.ROUND_FLOOR); + const partialAmount = numerator.multipliedBy(target).div(denominator).integerValue(BigNumber.ROUND_FLOOR); return partialAmount; }, createFill: (signedOrder: SignedOrder, takerAssetFillAmount?: BigNumber) => { diff --git a/contracts/test-utils/test/mocha_blockchain.ts b/contracts/test-utils/test/mocha_blockchain.ts index 071a1c7255..afd510e7ff 100644 --- a/contracts/test-utils/test/mocha_blockchain.ts +++ b/contracts/test-utils/test/mocha_blockchain.ts @@ -97,7 +97,7 @@ blockchainTests('mocha blockchain extensions', env => { function createHookedObject(obj: any, handler: (name: string) => void, methods: string[]): any { const hookedMethods = _.map(methods, methodName => { // tslint:disable: only-arrow-functions - return function(this: any, ...args: any[]): any { + return function (this: any, ...args: any[]): any { handler(methodName); return obj[methodName].call(this, ...args); }; diff --git a/contracts/test-utils/test/order_hash_test.ts b/contracts/test-utils/test/order_hash_test.ts index 8fe0347c11..5e72f3724c 100644 --- a/contracts/test-utils/test/order_hash_test.ts +++ b/contracts/test-utils/test/order_hash_test.ts @@ -55,7 +55,7 @@ describe('Order hashing', () => { it('throws a readable error message if taker format is invalid', async () => { const orderWithInvalidtakerFormat = { ...order, - takerAddress: (null as any) as string, + takerAddress: null as any as string, }; const expectedErrorMessage = `Expected order to conform to schema`; expect(() => orderHashUtils.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage); diff --git a/contracts/utils/test/lib_bytes.ts b/contracts/utils/test/lib_bytes.ts index 5f20d8b4a9..f76e9adaaf 100644 --- a/contracts/utils/test/lib_bytes.ts +++ b/contracts/utils/test/lib_bytes.ts @@ -748,15 +748,7 @@ blockchainTests('LibBytes', env => { const result = await libBytes .publicWriteLength(byteArrayLongerThan32Bytes, newLen, constants.NULL_BYTES) .callAsync(); - expect(result).to.eq( - byteArrayLongerThan32Bytes.slice( - 0, - newLen - .multipliedBy(2) - .plus(2) - .toNumber(), - ), - ); + expect(result).to.eq(byteArrayLongerThan32Bytes.slice(0, newLen.multipliedBy(2).plus(2).toNumber())); }); it("should right pad with 0's if new length is greater than original and no extra bytes are appended", async () => { const byteLen = fromHex(byteArrayLongerThan32Bytes).length; diff --git a/contracts/zero-ex/test/artifacts.ts b/contracts/zero-ex/test/artifacts.ts index 82b7284332..d4e7e073aa 100644 --- a/contracts/zero-ex/test/artifacts.ts +++ b/contracts/zero-ex/test/artifacts.ts @@ -389,7 +389,8 @@ export const artifacts = { TestNoEthRecipient: TestNoEthRecipient as ContractArtifact, TestOrderSignerRegistryWithContractWallet: TestOrderSignerRegistryWithContractWallet as ContractArtifact, TestPermissionlessTransformerDeployerSuicidal: TestPermissionlessTransformerDeployerSuicidal as ContractArtifact, - TestPermissionlessTransformerDeployerTransformer: TestPermissionlessTransformerDeployerTransformer as ContractArtifact, + TestPermissionlessTransformerDeployerTransformer: + TestPermissionlessTransformerDeployerTransformer as ContractArtifact, TestPropertyValidator: TestPropertyValidator as ContractArtifact, TestRfqOriginRegistration: TestRfqOriginRegistration as ContractArtifact, TestSimpleFunctionRegistryFeatureImpl1: TestSimpleFunctionRegistryFeatureImpl1 as ContractArtifact, diff --git a/contracts/zero-ex/test/features/native_orders_feature_test.ts b/contracts/zero-ex/test/features/native_orders_feature_test.ts index adefdce4c8..e2c2df5052 100644 --- a/contracts/zero-ex/test/features/native_orders_feature_test.ts +++ b/contracts/zero-ex/test/features/native_orders_feature_test.ts @@ -61,15 +61,8 @@ blockchainTests.resets('NativeOrdersFeature', env => { before(async () => { let owner; - [ - owner, - maker, - taker, - notMaker, - notTaker, - contractWalletOwner, - contractWalletSigner, - ] = await env.getAccountAddressesAsync(); + [owner, maker, taker, notMaker, notTaker, contractWalletOwner, contractWalletSigner] = + await env.getAccountAddressesAsync(); [makerToken, takerToken, wethToken] = await Promise.all( [...new Array(3)].map(async () => TestMintableERC20TokenContract.deployFrom0xArtifactAsync( @@ -761,11 +754,8 @@ blockchainTests.resets('NativeOrdersFeature', env => { receipt: undefined, ...opts, }; - const { - makerTokenFilledAmount, - takerTokenFilledAmount, - takerTokenFeeFilledAmount, - } = computeLimitOrderFilledAmounts(order, takerTokenFillAmount, takerTokenAlreadyFilledAmount); + const { makerTokenFilledAmount, takerTokenFilledAmount, takerTokenFeeFilledAmount } = + computeLimitOrderFilledAmounts(order, takerTokenFillAmount, takerTokenAlreadyFilledAmount); const makerBalance = await takerToken.balanceOf(maker).callAsync(); const takerBalance = await makerToken.balanceOf(taker).callAsync(); const feeRecipientBalance = await takerToken.balanceOf(order.feeRecipient).callAsync(); diff --git a/contracts/zero-ex/test/features/otc_orders_test.ts b/contracts/zero-ex/test/features/otc_orders_test.ts index 24a49c9ef8..a50c091768 100644 --- a/contracts/zero-ex/test/features/otc_orders_test.ts +++ b/contracts/zero-ex/test/features/otc_orders_test.ts @@ -42,17 +42,8 @@ blockchainTests.resets('OtcOrdersFeature', env => { // Useful for ETH balance accounting const txDefaults = { ...env.txDefaults, gasPrice: 0 }; let owner; - [ - owner, - maker, - taker, - notMaker, - notTaker, - contractWalletOwner, - contractWalletSigner, - txOrigin, - notTxOrigin, - ] = await env.getAccountAddressesAsync(); + [owner, maker, taker, notMaker, notTaker, contractWalletOwner, contractWalletSigner, txOrigin, notTxOrigin] = + await env.getAccountAddressesAsync(); [makerToken, takerToken] = await Promise.all( [...new Array(2)].map(async () => TestMintableERC20TokenContract.deployFrom0xArtifactAsync( diff --git a/contracts/zero-ex/test/transformers/fill_quote_transformer_test.ts b/contracts/zero-ex/test/transformers/fill_quote_transformer_test.ts index 08a3ce0ee8..e411dd1ab0 100644 --- a/contracts/zero-ex/test/transformers/fill_quote_transformer_test.ts +++ b/contracts/zero-ex/test/transformers/fill_quote_transformer_test.ts @@ -334,17 +334,13 @@ blockchainTests.resets('FillQuoteTransformer', env => { async function getBalancesAsync(owner: string): Promise { const balances = { ...ZERO_BALANCES }; - [ - balances.makerTokenBalance, - balances.takerTokensBalance, - balances.takerFeeBalance, - balances.ethBalance, - ] = await Promise.all([ - makerToken.balanceOf(owner).callAsync(), - takerToken.balanceOf(owner).callAsync(), - takerFeeToken.balanceOf(owner).callAsync(), - env.web3Wrapper.getBalanceInWeiAsync(owner), - ]); + [balances.makerTokenBalance, balances.takerTokensBalance, balances.takerFeeBalance, balances.ethBalance] = + await Promise.all([ + makerToken.balanceOf(owner).callAsync(), + takerToken.balanceOf(owner).callAsync(), + takerFeeToken.balanceOf(owner).callAsync(), + env.web3Wrapper.getBalanceInWeiAsync(owner), + ]); return balances; } @@ -365,11 +361,7 @@ blockchainTests.resets('FillQuoteTransformer', env => { function normalizeFillAmount(raw: BigNumber, balance: BigNumber): BigNumber { if (raw.gte(HIGH_BIT)) { - return raw - .minus(HIGH_BIT) - .div('1e18') - .times(balance) - .integerValue(BigNumber.ROUND_DOWN); + return raw.minus(HIGH_BIT).div('1e18').times(balance).integerValue(BigNumber.ROUND_DOWN); } return raw; } diff --git a/contracts/zero-ex/test/utils/orders.ts b/contracts/zero-ex/test/utils/orders.ts index 13f89eef14..73ea06cc3c 100644 --- a/contracts/zero-ex/test/utils/orders.ts +++ b/contracts/zero-ex/test/utils/orders.ts @@ -217,11 +217,8 @@ export class NativeOrdersTestEnvironment { takerTokenFillAmount: BigNumber = order.takerAmount, takerTokenAlreadyFilledAmount: BigNumber = ZERO, ): IZeroExLimitOrderFilledEventArgs { - const { - makerTokenFilledAmount, - takerTokenFilledAmount, - takerTokenFeeFilledAmount, - } = computeLimitOrderFilledAmounts(order, takerTokenFillAmount, takerTokenAlreadyFilledAmount); + const { makerTokenFilledAmount, takerTokenFilledAmount, takerTokenFeeFilledAmount } = + computeLimitOrderFilledAmounts(order, takerTokenFillAmount, takerTokenAlreadyFilledAmount); const protocolFee = order.taker !== NULL_ADDRESS ? ZERO : this.protocolFee; return { takerTokenFilledAmount, diff --git a/package.json b/package.json index 501fb10fe4..6ae01b89b8 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "lcov-result-merger": "^3.0.0", "lerna": "^3.0.0-beta.25", "npm-run-all": "^4.1.2", - "prettier": "1.19.1", + "prettier": "2.7.1", "source-map-support": "^0.5.6", "typescript": "4.6.3", "wsrun": "^5.2.4" diff --git a/packages/protocol-utils/src/orders.ts b/packages/protocol-utils/src/orders.ts index e3c83e484d..b17b349767 100644 --- a/packages/protocol-utils/src/orders.ts +++ b/packages/protocol-utils/src/orders.ts @@ -368,9 +368,7 @@ export class OtcOrder extends OrderBase { public nonceBucket: BigNumber; public nonce: BigNumber; - public static parseExpiryAndNonce( - expiryAndNonce: BigNumber, - ): { + public static parseExpiryAndNonce(expiryAndNonce: BigNumber): { expiry: BigNumber; nonceBucket: BigNumber; nonce: BigNumber; diff --git a/yarn.lock b/yarn.lock index 530b00ded2..f05161dd47 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14140,16 +14140,16 @@ prettier-plugin-solidity@^1.0.0-alpha.4: solidity-comments-extractor "^0.0.7" string-width "^4.2.3" -prettier@1.19.1, prettier@^1.14.3, prettier@^1.16.3: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== - -prettier@^2.3.1: +prettier@2.7.1, prettier@^2.3.1: version "2.7.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +prettier@^1.14.3, prettier@^1.16.3: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + pretty-bytes@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84"