Token ICO/IDO/ILO launchpad smart contract. It has all functions of Pinksale
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
launchpad-contracts/utils/readStatic.js

33 lines
1.1 KiB

const path = require("path")
const fs = require("fs")
function getDeploymentAddresses(networkName) {
const PROJECT_ROOT = path.resolve(__dirname, "..")
const DEPLOYMENT_PATH = path.resolve(PROJECT_ROOT, "deployments")
let folderName = networkName
if (networkName === "hardhat") {
folderName = "localhost"
}
const networkFolderName = fs.readdirSync(DEPLOYMENT_PATH).filter((f) => f === folderName)[0]
if (networkFolderName === undefined) {
throw new Error("missing deployment files for endpoint " + folderName)
}
let rtnAddresses = {}
const networkFolderPath = path.resolve(DEPLOYMENT_PATH, folderName)
const files = fs.readdirSync(networkFolderPath).filter((f) => f.includes(".json"))
files.forEach((file) => {
const filepath = path.resolve(networkFolderPath, file)
const data = JSON.parse(fs.readFileSync(filepath))
const contractName = file.split(".")[0]
rtnAddresses[contractName] = data.address
})
return rtnAddresses
}
module.exports = {
getDeploymentAddresses
}