Lawrence Forman 901d400d62
Address spot check feedback (#251)
* UniswapV3 VIP (#237)

* `@0x/contracts-zero-ex`: Add UniswapV3Feature

* `@0x/contracts-zero-ex`: Add UniswapV3 VIP
`@0x/contract-artifacts`: Regenerate.
`@0x/contract-wrappers`: Regenerate.
`@0x/asset-swapper`: Add UniswapV3 VIP support.

* address review comments and appease linter

* `@0x/contracts-zero-ex`: Add UniswapV3Feature tests

* Multiplex UniswapV3 (#241)

* Add UniswapV3 support to Multiplex batchFill

* Add AssetSwapper support for Multiplex UniswapV3

* fix repo scripts that use PKG= env var (#242)

Co-authored-by: Lawrence Forman <me@merklejerk.com>

* `@0x/asset-swapper`: Adjust uniswap gas overhead

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>

* OTC orders feature (#244)

* Add OTC orders feature contracts

* Address PR feedback

* Remove partial fills for takerSigned variant

* Add function to query the min valid nonce

* Add ETH support

* Tightly pack expiry, nonceBucket, and nonce

* Address PR feedback

* OTC orders unit tests

* Bump prettier version

* Skip unnecessary math if takerTokenFillAmount == order.takerAmount

* appease CI

* Update contract-artifacts and contract-wrappers and CHANGELOGs

* `@0x/contracts-zero-ex`: Address spot check feedback

* `regen wrappers

* prettier

* `@0x/asset-swapper`: prettier and tweak gas schedule slightly for uni3

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>
2021-06-02 14:21:14 +10:00

53 lines
2.0 KiB
TypeScript

import { logUtils } from '@0x/utils';
import * as fs from 'fs';
import * as path from 'path';
import * as artifacts from './index';
const MONOREPO_ROOT = path.join(__dirname, '../../../..');
// HACK (xianny): can't import the root package.json normally because it is outside rootDir of this project
const pkgJson = JSON.parse(fs.readFileSync(path.join(MONOREPO_ROOT, 'package.json')).toString());
const pkgNames = pkgJson.config.contractsPackages.split(' ');
const artifactsToPublish = Object.keys(artifacts);
const contractsDirs = [];
for (const pkgName of pkgNames) {
if (!pkgName.startsWith('@0x/contracts-')) {
throw new Error(`Invalid package name: [${pkgName}]. Contracts packages must be prefixed with 'contracts-'`);
}
contractsDirs.push(pkgName.split('/contracts-')[1]);
}
const contractsPath = path.join(MONOREPO_ROOT, 'contracts');
const allArtifactPaths = [];
for (const dir of contractsDirs) {
const artifactsDir = path.join(contractsPath, dir, 'generated-artifacts');
if (!fs.existsSync(artifactsDir)) {
continue;
}
const artifactPaths: string[] = fs
.readdirSync(artifactsDir)
.filter(artifact => {
const artifactWithoutExt = artifact.split('.')[0];
return artifactsToPublish.includes(artifactWithoutExt);
})
.map(artifact => path.join(artifactsDir, artifact));
allArtifactPaths.push(...artifactPaths);
}
if (allArtifactPaths.length < pkgNames.length) {
throw new Error(
`Expected ${pkgNames.length} artifacts, found ${allArtifactPaths.length}. Please ensure artifacts are present in ${contractsPath}/**/generated-artifacts`,
);
}
for (const _path of allArtifactPaths) {
const fileName = _path.split('/').slice(-1)[0];
const targetPath = path.join(__dirname, '../../artifacts', fileName);
fs.copyFileSync(_path, targetPath);
logUtils.log(`Copied ${_path}`);
}
logUtils.log(`Finished copying contract-artifacts. Remember to transform artifacts before publishing or using abi-gen`);