@gooddollar/goodprotocol
Version:
GoodDollar Protocol
51 lines (50 loc) • 3.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deploySuperGoodDollar = void 0;
require("@openzeppelin/hardhat-upgrades");
const hardhat_1 = require("hardhat");
const SuperGoodDollar_json_1 = __importDefault(require("../artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.json"));
const UUPSProxy_json_1 = __importDefault(require("../artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.json"));
const IdentityV2_json_1 = __importDefault(require("../artifacts/contracts/identity/IdentityV2.sol/IdentityV2.json"));
const FeeFormula_json_1 = __importDefault(require("@gooddollar/goodcontracts/build/contracts/FeeFormula.json"));
const ERC1967Proxy_json_1 = __importDefault(require("../artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.json"));
const deploySuperGoodDollar = async (signer, sfContracts, tokenArgs = []) => {
const IdentityFactory = new hardhat_1.ethers.ContractFactory(IdentityV2_json_1.default.abi, IdentityV2_json_1.default.bytecode, signer);
const FeeFormulaFactory = new hardhat_1.ethers.ContractFactory(FeeFormula_json_1.default.abi, FeeFormula_json_1.default.bytecode, signer);
const FeeFormula = await FeeFormulaFactory.deploy(0);
const proxyFactory = new hardhat_1.ethers.ContractFactory(ERC1967Proxy_json_1.default.abi, ERC1967Proxy_json_1.default.bytecode, signer);
const idProxy = await proxyFactory.deploy();
const idLogic = await IdentityFactory.deploy();
const encodedInit = idLogic.interface.encodeFunctionData("initialize", [
await signer.getAddress(),
hardhat_1.ethers.constants.AddressZero
]);
await idProxy.initialize(idLogic.address, encodedInit);
// const Identity = await upgrades.deployProxy(
// IdentityFactory,
// [await signer.getAddress(), ethers.constants.AddressZero],
// { kind: "uups" }
// );
const initializeArgs = [
"GoodDollar",
"G$",
0, // cap
FeeFormula.address,
idProxy.address,
hardhat_1.ethers.constants.AddressZero,
await signer.getAddress(),
...tokenArgs
];
const SuperGoodDollarFactory = new hardhat_1.ethers.ContractFactory(SuperGoodDollar_json_1.default.abi, SuperGoodDollar_json_1.default.bytecode, signer);
const SuperGoodDollar = await SuperGoodDollarFactory.deploy(sfContracts.host);
const GoodDollarProxyFactory = new hardhat_1.ethers.ContractFactory(UUPSProxy_json_1.default.abi, UUPSProxy_json_1.default.bytecode, signer);
const GoodDollarProxy = await GoodDollarProxyFactory.deploy();
await GoodDollarProxy.initializeProxy(SuperGoodDollar.address);
const GoodDollar = SuperGoodDollar.attach(GoodDollarProxy.address);
await GoodDollar["initialize(string,string,uint256,address,address,address,address,address,address)"](...initializeArgs);
return { GoodDollar, Identity: idLogic.attach(idProxy.address) };
};
exports.deploySuperGoodDollar = deploySuperGoodDollar;