refactor: typescript refactoring ♻️

This commit is contained in:
PedroCailleret
2022-11-14 09:34:53 -03:00
parent 67f9cbb9a7
commit b1fe0a574c
91 changed files with 19768 additions and 30240 deletions

View File

@@ -1,31 +0,0 @@
const fs = require('fs');
const { network } = require("hardhat");
async function main() {
let deploysJson = {}
try {
const data = fs.readFileSync(`./deploys/${network.name}.json`, {encoding:"utf-8"});
deploysJson = JSON.parse(data);
} catch (err) {
console.log('Error loading Master address: ', err);
process.exit(1);
}
const P2PIX = await ethers.getContractFactory("P2PIX");
const p2pix = await P2PIX.deploy(2, deploysJson.signers);
await p2pix.deployed();
deploysJson.p2pix = p2pix.address
console.log("🚀 P2PIX Deployed:", p2pix.address);
fs.writeFileSync(`./deploys/${network.name}.json`, JSON.stringify(deploysJson, undefined, 2));
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

55
scripts/1-deploy-p2pix.ts Normal file
View File

@@ -0,0 +1,55 @@
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
import * as fs from "fs";
import { ethers, network } from "hardhat";
// import hre from "hardhat";
interface Deploys {
signers: string[];
p2pix: string;
token: string;
}
let deploysJson: Deploys;
const main = async () => {
try {
const data = fs.readFileSync(
`./deploys/${network.name}.json`,
{ encoding: "utf-8" },
);
deploysJson = JSON.parse(data);
} catch (err) {
console.log("Error loading Master address: ", err);
process.exit(1);
}
const [deployer] = await ethers.getSigners();
console.log(`Deploying contracts with ${deployer.address}`);
const P2PIX = await ethers.getContractFactory("P2PIX");
const p2pix = await P2PIX.deploy(2, deploysJson.signers);
await p2pix.deployed();
deploysJson.p2pix = p2pix.address;
console.log("🚀 P2PIX Deployed:", p2pix.address);
fs.writeFileSync(
`./deploys/${network.name}.json`,
JSON.stringify(deploysJson, undefined, 2),
);
/* UNCOMMENT WHEN DEPLOYING TO MAINNET */
//verify
// await hre.run("verify:verify", {
// address: p2pix.address,
// constructorArguments: [2, deploysJson.signers],
// });
};
main()
.then(() => process.exit(0))
.catch(error => {
console.log(error);
process.exit(1);
});

View File

@@ -1,31 +0,0 @@
const fs = require('fs');
const { network } = require("hardhat");
async function main() {
let deploysJson = {}
try {
const data = fs.readFileSync(`./deploys/${network.name}.json`, {encoding:"utf-8"});
deploysJson = JSON.parse(data);
} catch (err) {
console.log('Error loading Master address: ', err);
process.exit(1);
}
const ERC20Factory = await ethers.getContractFactory("MockToken");
const erc20 = await ERC20Factory.deploy(ethers.utils.parseEther('20000000', 'wei'));
await erc20.deployed();
deploysJson.token = erc20.address
console.log("🚀 Mock Token Deployed:", erc20.address);
fs.writeFileSync(`./deploys/${network.name}.json`, JSON.stringify(deploysJson, undefined, 2));
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

View File

@@ -0,0 +1,59 @@
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
import { BigNumber } from "ethers";
import * as fs from "fs";
import { ethers, network } from "hardhat";
// import hre from "hardhat";
interface Deploys {
signers: string[];
p2pix: string;
token: string;
}
let deploysJson: Deploys;
const supply: BigNumber = ethers.utils.parseEther("20000000");
const main = async () => {
try {
const data = fs.readFileSync(
`./deploys/${network.name}.json`,
{ encoding: "utf-8" },
);
deploysJson = JSON.parse(data);
} catch (err) {
console.log("Error loading Master address: ", err);
process.exit(1);
}
const [deployer] = await ethers.getSigners();
console.log(`Deploying contracts with ${deployer.address}`);
const ERC20Factory = await ethers.getContractFactory(
"MockToken",
);
const erc20 = await ERC20Factory.deploy(supply);
await erc20.deployed();
deploysJson.token = erc20.address;
console.log("🚀 Mock Token Deployed:", erc20.address);
fs.writeFileSync(
`./deploys/${network.name}.json`,
JSON.stringify(deploysJson, undefined, 2),
);
/* UNCOMMENT WHEN DEPLOYING TO MAINNET */
//verify
// await hre.run("verify:verify", {
// address: erc20.address,
// constructorArguments: supply,
// });
};
main()
.then(() => process.exit(0))
.catch(error => {
console.log(error);
process.exit(1);
});