-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
720fd4d
commit b997d18
Showing
9 changed files
with
83 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test/* | ||
package.abis.json | ||
README.abis.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
packages/protocol/scripts/bash/prepare-contracts-and-abis-publishing.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +0,0 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
mkdir -p ./build/contracts/types | ||
ts-node ./scripts/build.ts --ethersTypes ./build/contracts/types/ethers | ||
ts-node ./scripts/build.ts --web3Types ./build/contracts/types/web3 | ||
ts-node ./scripts/build.ts --truffleTypes ./build/contracts/types/truffle | ||
|
||
cp ./contracts/package.abis.json ./build/contracts/package.json | ||
cp ./contracts/README.abis.md ./build/contracts/README.md | ||
68 changes: 68 additions & 0 deletions
68
packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import * as child_process from 'child_process' | ||
import * as fs from 'fs' | ||
import * as path from 'path' | ||
import rimraf from 'rimraf' | ||
import { version } from '../package.json' | ||
|
||
const SRC_DIR = path.join(__dirname, '../contracts') | ||
const BUILD_DIR = path.join(__dirname, '../build/contracts') | ||
const TYPES_DIR = path.join(BUILD_DIR, 'types') | ||
const BUILD_EXECUTABLE = path.join(__dirname, 'build.ts') | ||
|
||
rimraf.sync(TYPES_DIR) | ||
rimraf.sync(path.join(BUILD_DIR, 'package.json')) | ||
rimraf.sync(path.join(BUILD_DIR, 'README.md')) | ||
fs.mkdirSync(TYPES_DIR, { recursive: true }) | ||
|
||
const allFiles = lsRecursive(SRC_DIR) | ||
|
||
child_process.execSync( | ||
`ts-node ${BUILD_EXECUTABLE} --ethersTypes ${path.join(TYPES_DIR, 'ethers')}`, | ||
{ stdio: 'inherit' } | ||
) | ||
child_process.execSync(`ts-node ${BUILD_EXECUTABLE} --web3Types ${path.join(TYPES_DIR, 'web3')}`, { | ||
stdio: 'inherit', | ||
}) | ||
child_process.execSync( | ||
`ts-node ${BUILD_EXECUTABLE} --truffleTypes ${path.join(TYPES_DIR, 'truffle')}`, | ||
{ stdio: 'inherit' } | ||
) | ||
|
||
allFiles.forEach((filePath) => { | ||
const name = path.basename(filePath) | ||
if (filePath.includes('/test/') || name.startsWith('Mock')) { | ||
console.log('deleting', name) | ||
rimraf.sync(path.join(BUILD_DIR, name.replace('sol', 'json'))) | ||
rimraf.sync(path.join(TYPES_DIR, 'ethers', name.replace('sol', '.d.ts'))) | ||
rimraf.sync(path.join(TYPES_DIR, 'web3', name.replace('sol', '.ts'))) | ||
} | ||
}) | ||
|
||
fs.copyFileSync(path.join(SRC_DIR, 'package.abis.json'), path.join(BUILD_DIR, 'package.json')) | ||
fs.copyFileSync(path.join(SRC_DIR, 'README.abis.md'), path.join(BUILD_DIR, 'README.md')) | ||
|
||
if (process.env.RELEASE_TYPE === 'release') { | ||
process.env.RELEASE_ABIS_VERSION = version | ||
} else { | ||
const latestRelease = child_process.execSync(`npm view @celo/contracts version`) | ||
console.log(latestRelease.toString()) | ||
process.env.RELEASE_ABIS_VERSION = latestRelease.toString() | ||
} | ||
|
||
function lsRecursive(dir: string): string[] { | ||
const filesAndDirectories = fs.readdirSync(dir, { withFileTypes: true }) | ||
return filesAndDirectories.reduce((fileNames, fileOrDir) => { | ||
const filePath = path.join(dir, fileOrDir.name) | ||
if (fileOrDir.isDirectory()) { | ||
return fileNames.concat(lsRecursive(filePath)) | ||
} | ||
return fileNames.concat([filePath]) | ||
}, []) | ||
} | ||
|
||
/* | ||
❯ du -h build/contracts/ | ||
0B build/contracts//types | ||
62M build/contracts/ | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters