Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Fix issues with deploy:Registrar and deploy:AngelProtocol #215

Merged
merged 10 commits into from
Jul 21, 2023
78 changes: 39 additions & 39 deletions contract-address.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"31337": {
"accounts": {
"diamond": "0x1D99a347B5EcdbAa3C5365470d461Cf66B77ECd2",
"diamond": "0x84227190685c25c4aF662EE1bD0E4cd82e57360D",
"facets": {
"accountsDeployContract": "0xbe241D1B7b54bF06742cefd45A3440C6562f7603",
"accountsDepositWithdrawEndowments": "0x3c705dB336C81c7FEFC5746e283aB2c0781A4B7b",
"accountsDonationMatch": "0xA82ED5224ba72f2f776e09B11DC99E30Ee65Da8d",
"accountsAllowance": "0x1dBDba33dfA381bCC89FCe74DFF69Aa96B53b503",
"accountsCreateEndowment": "0x7798A400cBe0Ca14a7D614ECa1CD15adE5055413",
"accountsDaoEndowments": "0x17C8b71E5eE01A726766c99d397D619219C8CAF3",
"accountsQueryEndowments": "0xE4F89Fb0dBb45378633c05ACAb071eB998F0A736",
"accountsStrategy": "0x9Fe28b717aDE38BA99E32c45BE3Ee4291f2E338B",
"accountsSwapRouter": "0x7B3Be2dDDdDf9A0a3fE1DC57B98980F662C3a422",
"accountsUpdate": "0x8990C5DAAA40673eF8826990A6Fd8284a0a17d61",
"accountsUpdateEndowments": "0x90352F820342f8BE0012848bCB8aBd37877d7ec2",
"accountsUpdateEndowmentSettingsController": "0x82B642D9deDb3Ad19b8E99FF3792A49d4d9d85Bf",
"accountsUpdateStatusEndowments": "0xf69E1dFAc3D43F438Bae80090b8E186B0231CFeb",
"diamondCutFacet": "0x49FcbCC4E425add3a45AFC82F4dD0E5c227A0Ff8",
"diamondInitFacet": "0x84227190685c25c4aF662EE1bD0E4cd82e57360D",
"diamondLoupeFacet": "0xDDEec1224034F4A68A2697eF13379a014fa60261",
"ownershipFacet": "0x199c27B10a195ee79e02d50846e59A4aFB82CAD1"
"accountsDeployContract": "0xA82ED5224ba72f2f776e09B11DC99E30Ee65Da8d",
"accountsDepositWithdrawEndowments": "0x1dBDba33dfA381bCC89FCe74DFF69Aa96B53b503",
"accountsDonationMatch": "0x17C8b71E5eE01A726766c99d397D619219C8CAF3",
"accountsAllowance": "0x7798A400cBe0Ca14a7D614ECa1CD15adE5055413",
"accountsCreateEndowment": "0x7B3Be2dDDdDf9A0a3fE1DC57B98980F662C3a422",
"accountsDaoEndowments": "0x8990C5DAAA40673eF8826990A6Fd8284a0a17d61",
"accountsQueryEndowments": "0xf69E1dFAc3D43F438Bae80090b8E186B0231CFeb",
"accountsStrategy": "0x650aEF4b63095e4EDe581BC79CdeA927e3ba553A",
"accountsSwapRouter": "0x90352F820342f8BE0012848bCB8aBd37877d7ec2",
"accountsUpdate": "0xE4F89Fb0dBb45378633c05ACAb071eB998F0A736",
"accountsUpdateEndowments": "0x82B642D9deDb3Ad19b8E99FF3792A49d4d9d85Bf",
"accountsUpdateEndowmentSettingsController": "0x9Fe28b717aDE38BA99E32c45BE3Ee4291f2E338B",
"accountsUpdateStatusEndowments": "0xDDEec1224034F4A68A2697eF13379a014fa60261",
"diamondCutFacet": "0x1D99a347B5EcdbAa3C5365470d461Cf66B77ECd2",
"diamondInitFacet": "0xbe241D1B7b54bF06742cefd45A3440C6562f7603",
"diamondLoupeFacet": "0x199c27B10a195ee79e02d50846e59A4aFB82CAD1",
"ownershipFacet": "0x3c705dB336C81c7FEFC5746e283aB2c0781A4B7b"
}
},
"axelar": {
"gasService": "0x55cb3b67D9E65F0Cf4eABCAC84564a1bE6E3b06A",
"gateway": "0x7290f72B5C67052DDE8e6E179F7803c493e90d3f"
"gasService": "0x7290f72B5C67052DDE8e6E179F7803c493e90d3f",
"gateway": "0x0AFdAcD509e73115EA1654B1a770f1a807e7c9C0"
},
"donationMatch": {
"emitter": "",
Expand All @@ -39,8 +39,8 @@
"proxy": ""
},
"gasFwd": {
"factory": "0x87F850cbC2cFfac086F20d0d7307E12d06fA2127",
"implementation": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853"
"factory": "0xB0748F8B73C53aB94b3DD1109f3427B7Bb2907F5",
"implementation": "0xDeBD0Bc00932E8b5bEfF65053989B0687c894b5F"
},
"giftcards": {
"implementation": "",
Expand Down Expand Up @@ -101,38 +101,38 @@
"implementation": ""
},
"indexFund": {
"implementation": "0x549bc7EE4B85A2Df5F74799f213483CE599F1999",
"proxy": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6"
"implementation": "0x34E59e53Bd4f1A60ca8b6c21572509027571341d",
"proxy": "0x0165878A594ca255338adfa4d48449f69242Eb8F"
},
"libraries": {
"angelCoreStruct": "",
"stringArray": ""
},
"multiSig": {
"charityApplications": {
"implementation": "0xDeBD0Bc00932E8b5bEfF65053989B0687c894b5F",
"proxy": "0xB0748F8B73C53aB94b3DD1109f3427B7Bb2907F5"
"implementation": "0x549bc7EE4B85A2Df5F74799f213483CE599F1999",
"proxy": "0xEe54514745B056F07040CaCF801f59031D801431"
},
"apTeam": {
"implementation": "0xa85b028984bC54A2a3D844B070544F59dDDf89DE",
"proxy": "0xD499f5F7d3C918D0e553BA03954c4E02af16B6e4"
"implementation": "0xD499f5F7d3C918D0e553BA03954c4E02af16B6e4",
"proxy": "0xDadd1125B8Df98A66Abd5EB302C0d9Ca5A061dC2"
},
"endowment": {
"emitter": {
"implementation": "0x20F43316cf784C821a65aE874c8060f30c30c7C4",
"proxy": "0x9B4aC8FAfC44575C6963fA22D50963379e899a49"
"implementation": "0xa115891Cae16388b84cb7a521A2032f6b354FE25",
"proxy": "0x6ad448bF2AdbF3A7Aa9BfE411eD908315566aE24"
},
"factory": "0x34E59e53Bd4f1A60ca8b6c21572509027571341d",
"implementation": "0xEe54514745B056F07040CaCF801f59031D801431"
"factory": "0x9B4aC8FAfC44575C6963fA22D50963379e899a49",
"implementation": "0x20F43316cf784C821a65aE874c8060f30c30c7C4"
}
},
"registrar": {
"implementation": "0xDadd1125B8Df98A66Abd5EB302C0d9Ca5A061dC2",
"proxy": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707"
"implementation": "0x2572e04Caf46ba8692Bd6B4CBDc46DAA3cA9647E",
"proxy": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0"
},
"router": {
"implementation": "0x23d351BA89eaAc4E328133Cb48e050064C219A1E",
"proxy": "0x35D2F51DBC8b401B11fA3FE04423E0f5cd9fEDb4"
"implementation": "0x72F375F23BCDA00078Ac12e7e9E7f6a8CA523e7D",
"proxy": "0xf23B8c9debCdCEa2a40E81c3f6d786987069D40d"
},
"subDao": {
"emitter": {
Expand All @@ -147,9 +147,9 @@
"dai": "",
"halo": "",
"reserveToken": "",
"seedAsset": "0x0AFdAcD509e73115EA1654B1a770f1a807e7c9C0",
"usdc": "0x1a6a3e7Bb246158dF31d8f924B84D961669Ba4e5",
"wmatic": "0xBa3e08b4753E68952031102518379ED2fDADcA30"
"seedAsset": "0xc63d2a04762529edB649d7a4cC3E57A0085e8544",
"usdc": "0x093e8F4d8f267d2CeEc9eB889E2054710d187beD",
"wmatic": "0x34ee84036C47d852901b7069aBD80171D9A489a6"
},
"uniswap": {
"factory": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
Expand Down
13 changes: 10 additions & 3 deletions contracts/core/gasFwd/GasFwdFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {IRegistrar} from "../registrar/interfaces/IRegistrar.sol";
import {RegistrarStorage} from "../registrar/storage.sol";

contract GasFwdFactory is IGasFwdFactory, Ownable {
address impl;
address admin;
address registrar;
address public impl;
address public admin;
address public registrar;

constructor(address _impl, address _admin, address _registrar) {
if (_impl == address(0)) {
Expand Down Expand Up @@ -44,4 +44,11 @@ contract GasFwdFactory is IGasFwdFactory, Ownable {
}
impl = _impl;
}

function updateRegistrar(address _registrar) external onlyOwner {
if (_registrar == address(0)) {
revert InvalidAddress("_registrar");
}
registrar = _registrar;
}
}
2 changes: 2 additions & 0 deletions contracts/core/gasFwd/IGasFwdFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ interface IGasFwdFactory {
function create() external returns (address);

function updateImplementation(address _impl) external;

function updateRegistrar(address _impl) external;
}
5 changes: 2 additions & 3 deletions contracts/core/gasFwd/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ import {GasFwdFactory__factory, GasFwd__factory} from "typechain-types";
import {Deployment, getAddresses, getContractName, logger, updateAddresses} from "utils";

type Data = {
deployer: SignerWithAddress;
admin: SignerWithAddress;
registrar?: string;
};

export async function deployGasFwd(
{deployer, admin, registrar}: Data,
{admin, registrar}: Data,
hre: HardhatRuntimeEnvironment
): Promise<{factory: Deployment; implementation: Deployment} | undefined> {
logger.out("Deploying Gas Forwarder...");

try {
logger.out("Deploying GasFwd implementation...");
const GF = new GasFwd__factory(deployer);
const GF = new GasFwd__factory(admin);
const gf = await GF.deploy();
await gf.deployed();
logger.out(`Address: ${gf.address}`);
Expand Down
1 change: 0 additions & 1 deletion tasks/deploy/deployAngelProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ task("deploy:AngelProtocol", "Will deploy complete Angel Protocol")

const gasFwd = await deployGasFwd(
{
deployer: deployer,
admin: proxyAdmin,
registrar: registrar?.address,
},
Expand Down
4 changes: 2 additions & 2 deletions tasks/deploy/deployGasFwd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ task("deploy:GasFwd", "Will deploy the GasFwd implementation and factory")
.setAction(async (taskArgs: TaskArgs, hre) => {
try {
const addresses = await getAddresses(hre);
const {deployer, proxyAdmin} = await getSigners(hre);
const {proxyAdmin} = await getSigners(hre);

const gasFwdDeployment = await deployGasFwd(
{deployer: deployer, admin: proxyAdmin, registrar: addresses.registrar.proxy},
{admin: proxyAdmin, registrar: addresses.registrar.proxy},
hre
);

Expand Down
8 changes: 6 additions & 2 deletions tasks/deploy/deployRegistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ task(
newRegistrar: registrarDeployment.address,
yes: true,
});
await hre.run("manage:IndexFund:updateOwner", {
to: registrarDeployment.address,
await hre.run("manage:IndexFund:updateRegistrar", {
newRegistrar: registrarDeployment.address,
yes: true,
});
await hre.run("manage:GasFwdFactory:updateRegistrar", {
newRegistrar: registrarDeployment.address,
yes: true,
});

Expand Down
4 changes: 2 additions & 2 deletions tasks/helpers/updateRegistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
IAccountsStrategy,
RegistrarMessages,
} from "typechain-types/contracts/core/registrar/interfaces/IRegistrar";
import {getSigners, logger, structToObject, validateAddress} from "utils";
import {NetworkConnectionAction, getSigners, logger, structToObject, validateAddress} from "utils";

export async function updateRegistrarNetworkConnections(
registrar = "",
Expand Down Expand Up @@ -35,7 +35,7 @@ export async function updateRegistrarNetworkConnections(

const updateNetworkConnectionsData = registrarContract.interface.encodeFunctionData(
"updateNetworkConnections",
[network.name, {...curNetworkConnection, ...newNetworkInfo}, "post"]
[network.name, {...curNetworkConnection, ...newNetworkInfo}, NetworkConnectionAction.POST]
);
const apTeamMultisigContract = APTeamMultiSig__factory.connect(
apTeamMultisig,
Expand Down
1 change: 1 addition & 0 deletions tasks/manage/gasFwdFactory/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./updateRegistrar";
48 changes: 48 additions & 0 deletions tasks/manage/gasFwdFactory/updateRegistrar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {task} from "hardhat/config";
import {GasFwdFactory__factory} from "typechain-types";
import {confirmAction, getAddresses, getSigners, logger} from "utils";

type TaskArgs = {newRegistrar: string; yes: boolean};

task(
"manage:GasFwdFactory:updateRegistrar",
"Will update the registrar address of the GasFwdFactory"
)
.addOptionalParam(
"newRegistrar",
"Address of the new registrar. Will default to `contract-address.json > registrar.proxy` if none is provided."
)
.addFlag("yes", "Automatic yes to prompt.")
.setAction(async (taskArgs: TaskArgs, hre) => {
try {
logger.divider();
const addresses = await getAddresses(hre);
const {proxyAdmin} = await getSigners(hre);

const newRegistrar = taskArgs.newRegistrar || addresses.registrar.proxy;

logger.out("Querying current GasFwdFactory registrar...");
const gasFwdFactory = GasFwdFactory__factory.connect(addresses.gasFwd.factory, proxyAdmin);
const curRegistrar = await gasFwdFactory.registrar();
if (curRegistrar === newRegistrar) {
return logger.out(`"${newRegistrar}" is already set as the registrar address.`);
}
logger.out(`Current registrar: ${curRegistrar}`);

const isConfirmed =
taskArgs.yes || (await confirmAction(`Update Registrar address to: ${newRegistrar}`));
if (!isConfirmed) {
return logger.out("Confirmation denied.", logger.Level.Warn);
}

logger.out(`Updating Registrar address to: ${newRegistrar}...`);
const tx = await gasFwdFactory.updateRegistrar(newRegistrar);
logger.out(`Tx hash: ${tx.hash}`);
await tx.wait();

const updatedRegistrar = await gasFwdFactory.registrar();
logger.out(`New registrar: ${updatedRegistrar}`);
} catch (error) {
logger.out(error, logger.Level.Error);
}
});
1 change: 1 addition & 0 deletions tasks/manage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "./changeOwner";
import "./charityApplications";
import "./createEndowment";
import "./createIndexFund";
import "./gasFwdFactory";
import "./indexFund";
import "./registrar";
import "./updateRegistrar";
Expand Down
1 change: 1 addition & 0 deletions tasks/manage/indexFund/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import "./updateOwner";
import "./updateRegistrar";
54 changes: 54 additions & 0 deletions tasks/manage/indexFund/updateRegistrar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {task} from "hardhat/config";
import {APTeamMultiSig__factory, IndexFund__factory} from "typechain-types";
import {confirmAction, getAddresses, getSigners, logger} from "utils";

type TaskArgs = {newRegistrar: string; yes: boolean};

task("manage:IndexFund:updateRegistrar", "Will update the registrar address of the IndexFund")
.addOptionalParam(
"newRegistrar",
"Address of the new registrar. Will default to `contract-address.json > registrar.proxy` if none is provided."
)
.addFlag("yes", "Automatic yes to prompt.")
.setAction(async (taskArgs: TaskArgs, hre) => {
try {
logger.divider();
const addresses = await getAddresses(hre);
const {apTeamMultisigOwners} = await getSigners(hre);

const newRegistrar = taskArgs.newRegistrar || addresses.registrar.proxy;

logger.out("Querying current IndexFund registrar...");
const indexFund = IndexFund__factory.connect(
addresses.indexFund.proxy,
apTeamMultisigOwners[0]
);
const curRegistrar = (await indexFund.queryConfig()).registrarContract;
if (curRegistrar === newRegistrar) {
return logger.out(`"${newRegistrar}" is already set as the registrar address.`);
}
logger.out(`Current registrar: ${curRegistrar}`);

const isConfirmed =
taskArgs.yes || (await confirmAction(`Update Registrar address to: ${newRegistrar}`));
if (!isConfirmed) {
return logger.out("Confirmation denied.", logger.Level.Warn);
}

logger.out(`Updating Registrar address to: ${newRegistrar}...`);
const curOwner = (await indexFund.queryConfig()).owner;
const apTeamMultiSig = APTeamMultiSig__factory.connect(
curOwner, // ensure connection to current owning APTeamMultiSig contract
apTeamMultisigOwners[0]
);
const data = indexFund.interface.encodeFunctionData("updateRegistrar", [newRegistrar]);
const tx = await apTeamMultiSig.submitTransaction(indexFund.address, 0, data, "0x");
logger.out(`Tx hash: ${tx.hash}`);
await tx.wait();

const updatedOwner = (await indexFund.queryConfig()).registrarContract;
logger.out(`New registrar: ${updatedOwner}`);
} catch (error) {
logger.out(error, logger.Level.Error);
}
});
6 changes: 6 additions & 0 deletions utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ import path from "path";
export const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";

export const DEFAULT_CONTRACT_ADDRESS_FILE_PATH = path.join(__dirname, "../contract-address.json");

export enum NetworkConnectionAction {
NONE,
POST,
DELETE,
}
Comment on lines +7 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a type not a constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enums in TS are actually objects (like many things in JS/TS it's confusing, I know).
https://www.typescriptlang.org/docs/handbook/enums.html#enums-at-runtime

Since we have many enums we need to create, we can store them in a separate enums.ts file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a good idea! Thanks for the info