-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from pooltogether/pool-2291-update-v4-cli
fix(generateContractList): fix package version
- Loading branch information
Showing
7 changed files
with
70 additions
and
72 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,6 +1,6 @@ | ||
{ | ||
"name": "@pooltogether/v4-mainnet", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"main": "index.js", | ||
"repository": "[email protected]:pooltogether/v4-mainnet.git", | ||
"author": "PoolTogether Inc.", | ||
|
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,47 +1,40 @@ | ||
|
||
import fs from"fs"; | ||
import modulePackage from"../package.json"; | ||
import writeContractBlobToHistoryArchive from "./helpers/writeContractBlobToHistoryArchive"; | ||
import convertDeploymentsToContractList from "./helpers/convertDeploymentsToContractList"; | ||
import fs from 'fs'; | ||
import modulePackage from '../package.json'; | ||
import writeContractBlobToHistoryArchive from './helpers/writeContractBlobToHistoryArchive'; | ||
import convertDeploymentsToContractList from './helpers/convertDeploymentsToContractList'; | ||
|
||
const polygonDeployments = `${__dirname}/../deployments/polygon`; | ||
const mainnetDeployments = `${__dirname}/../deployments/mainnet`; | ||
const avalancheDeployments = `${__dirname}/../deployments/avalanche`; | ||
const versionSplit = modulePackage.version.split("."); | ||
const patchSplit = versionSplit[2].split("-"); | ||
const versionSplit = modulePackage.version.split('.'); | ||
const patchSplit = versionSplit[2].split('-'); | ||
|
||
const networkDeploymentPaths = [ | ||
mainnetDeployments, | ||
polygonDeployments, | ||
avalancheDeployments | ||
]; | ||
const networkDeploymentPaths = [mainnetDeployments, polygonDeployments, avalancheDeployments]; | ||
|
||
const PACKAGE_VERSION = { | ||
major: versionSplit[0], | ||
minor: versionSplit[1], | ||
patch: patchSplit[0], | ||
} | ||
major: Number(versionSplit[0]), | ||
minor: Number(versionSplit[1]), | ||
patch: Number(patchSplit[0]), | ||
}; | ||
|
||
const contractListDescription = { | ||
name: "PoolTogether V4 Mainnet", | ||
name: 'PoolTogether V4 Mainnet', | ||
version: PACKAGE_VERSION, | ||
tags: {}, | ||
contracts: [], | ||
}; | ||
const contractsNew = convertDeploymentsToContractList(networkDeploymentPaths); | ||
|
||
const contractsNew = convertDeploymentsToContractList(networkDeploymentPaths, PACKAGE_VERSION); | ||
const contractList = { | ||
...contractListDescription, | ||
contracts: contractsNew, | ||
} | ||
}; | ||
|
||
writeContractBlobToHistoryArchive(contractList); | ||
|
||
fs.writeFile( | ||
`${__dirname}/../contracts.json`, | ||
JSON.stringify(contractList), | ||
(err) => { | ||
if (err) { | ||
console.error(err); | ||
return; | ||
} | ||
fs.writeFile(`${__dirname}/../contracts.json`, JSON.stringify(contractList), (err) => { | ||
if (err) { | ||
console.error(err); | ||
return; | ||
} | ||
); | ||
}); |
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,33 +1,28 @@ | ||
const fs = require("fs"); | ||
import formatContractNew from "./formatContract"; | ||
const fs = require('fs'); | ||
|
||
function convertDeploymentsToContractList(networkDeploymentPaths:any) { | ||
let contractList = []; | ||
import formatContractNew, { Version } from './formatContract'; | ||
|
||
networkDeploymentPaths.forEach((networkDeploymentPath) => { | ||
const contractDeploymentPaths = fs | ||
.readdirSync(networkDeploymentPath) | ||
.filter((path) => path.endsWith(".json")); | ||
const chainId = Number( | ||
fs.readFileSync(`${networkDeploymentPath}/.chainId`, "utf8") | ||
); | ||
|
||
contractDeploymentPaths.forEach((contractDeploymentFileName) => { | ||
const contractName = contractDeploymentFileName.split(".")[0]; | ||
const contractDeployment = JSON.parse( | ||
fs.readFileSync( | ||
`${networkDeploymentPath}/${contractDeploymentFileName}`, | ||
"utf8" | ||
) | ||
); | ||
|
||
contractList.push( | ||
formatContractNew(chainId, contractName, contractDeployment) | ||
); | ||
}); | ||
export default function convertDeploymentsToContractList( | ||
networkDeploymentPaths: string[], | ||
version: Version, | ||
) { | ||
let contractList = []; | ||
|
||
networkDeploymentPaths.forEach((networkDeploymentPath) => { | ||
const contractDeploymentPaths = fs | ||
.readdirSync(networkDeploymentPath) | ||
.filter((path) => path.endsWith('.json')); | ||
const chainId = Number(fs.readFileSync(`${networkDeploymentPath}/.chainId`, 'utf8')); | ||
|
||
contractDeploymentPaths.forEach((contractDeploymentFileName) => { | ||
const contractName = contractDeploymentFileName.split('.')[0]; | ||
const contractDeployment = JSON.parse( | ||
fs.readFileSync(`${networkDeploymentPath}/${contractDeploymentFileName}`, 'utf8'), | ||
); | ||
|
||
contractList.push(formatContractNew(chainId, contractName, contractDeployment, version)); | ||
}); | ||
}); | ||
|
||
return contractList; | ||
return contractList; | ||
} | ||
|
||
export default convertDeploymentsToContractList; |
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,18 +1,27 @@ | ||
interface DeploymentBlob { | ||
address: string; | ||
abi: object; | ||
address: string; | ||
abi: object; | ||
} | ||
|
||
function formatContract(chainId: number, contractName: string, deploymentBlob: DeploymentBlob) { | ||
return { | ||
chainId, | ||
address: deploymentBlob.address, | ||
version: undefined, | ||
type: contractName, | ||
abi: deploymentBlob.abi, | ||
tags: [], | ||
extensions: {}, | ||
}; | ||
export type Version = { | ||
major: number; | ||
minor: number; | ||
patch: number; | ||
}; | ||
|
||
export default formatContract | ||
export default function formatContract( | ||
chainId: number, | ||
contractName: string, | ||
deploymentBlob: DeploymentBlob, | ||
version: Version, | ||
) { | ||
return { | ||
chainId, | ||
address: deploymentBlob.address, | ||
version, | ||
type: contractName, | ||
abi: deploymentBlob.abi, | ||
tags: [], | ||
extensions: {}, | ||
}; | ||
} |