-
Notifications
You must be signed in to change notification settings - Fork 32
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 #1068 from skalenetwork/skale-contracts
Add ABI generation
- Loading branch information
Showing
5 changed files
with
128 additions
and
49 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:16 | ||
FROM node:18 | ||
|
||
RUN mkdir /usr/src/manager | ||
WORKDIR /usr/src/manager | ||
|
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 +1 @@ | ||
1.10.0 | ||
2.0.0 |
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,50 @@ | ||
import { promises as fs } from 'fs'; | ||
import { contracts } from "../migrations/deploy"; | ||
import { ethers } from "hardhat"; | ||
import { getAbi, getVersion } from '@skalenetwork/upgrade-tools'; | ||
import { ContractFactory } from 'ethers'; | ||
import { Libraries } from '@nomiclabs/hardhat-ethers/types'; | ||
|
||
async function main() { | ||
const allContracts = contracts.concat(["SkaleToken", "TimeHelpersWithDebug"]) | ||
const abi: {[name: string]: []} = {}; | ||
const librariesRequirements: {[name: string]: string[]} = { | ||
"Nodes": [ | ||
"SegmentTree" | ||
], | ||
"SkaleDKG": [ | ||
"SkaleDkgAlright", | ||
"SkaleDkgBroadcast", | ||
"SkaleDkgComplaint", | ||
"SkaleDkgPreResponse", | ||
"SkaleDkgResponse" | ||
] | ||
} | ||
for (const contractName of allContracts) { | ||
console.log(`Load ABI of ${contractName}`); | ||
let factory: ContractFactory; | ||
if (Object.keys(librariesRequirements).includes(contractName)) { | ||
const libraries: Libraries = {}; | ||
for(const library of librariesRequirements[contractName]) { | ||
libraries[library] = ethers.constants.AddressZero; | ||
} | ||
factory = await ethers.getContractFactory(contractName, {libraries}); | ||
} else { | ||
factory = await ethers.getContractFactory(contractName); | ||
} | ||
abi[contractName] = getAbi(factory.interface); | ||
} | ||
const version = await getVersion(); | ||
const filename = `data/skale-manager-${version}-abi.json`; | ||
console.log(`Save to ${filename}`) | ||
await fs.writeFile(filename, JSON.stringify(abi, null, 4)); | ||
} | ||
|
||
if (require.main === module) { | ||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
} |