Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
"dependencies": {
"ajv": "^8.10.2",
"ajv-formats": "^2.1.1",
"fs-extra": "^10.1.0",
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@types/fs-extra": "^9.0.13",
"@types/js-yaml": "^4.0.5",
"@types/node": "^16.11.38",
"json-schema-to-typescript": "^10.1.5",
Expand Down
15 changes: 11 additions & 4 deletions src/utils/generate-grants-contract-chains.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { writeFile } from "fs/promises"
import { copySync } from "fs-extra"
import { join } from "path"
import { ChainData } from "../types"

const generateGrantsContractChains = async(
const METADATA_FOLDER = "./contracts/evm/.openzeppelin/"

const generateGrantsContractChains = async (
repoPath: string,
chains: { [_: string]: Pick<ChainData, 'chainName' | 'chainId' | 'rpcUrls'> }
) => {
// sort the chains so they're always committed in the same order
const chainsList = Object.values(chains)
chainsList.sort((a, b) => a.chainName.localeCompare(b.chainName))

// construct the chains JSON that contains only the ID & RPC url
// this is used on the grants-contracts repo to deploy contracts
const chainsMap: { [_: string]: { id: number, rpcUrl: string } } = { }
for(const chain of chainsList) {
const chainsMap: { [_: string]: { id: number, rpcUrl: string } } = {}
for (const chain of chainsList) {
chainsMap[chain.chainName] = {
id: chain.chainId,
rpcUrl: chain.rpcUrls[0]
Expand All @@ -23,6 +26,10 @@ const generateGrantsContractChains = async(
const chainsJson = JSON.stringify(chainsMap, null, 2)

await writeFile(join(repoPath, './chains.json'), chainsJson)

// Copy files generated by openzeppelin inside ./openzeppelin folder.
// These files are used during smart contract upgradation
await copySync(METADATA_FOLDER, join(repoPath, '.openzeppelin/'))
}

export default generateGrantsContractChains
Loading