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

Commit

Permalink
Registrar-related script fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Jul 24, 2023
1 parent 172d78b commit bb43ac1
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 114 deletions.
82 changes: 41 additions & 41 deletions contract-address.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,30 +158,30 @@
},
"31337": {
"accounts": {
"diamond": "",
"diamond": "0x16fb8e3ab0AF1da9c6e6a589DD025E6558F496Bc",
"facets": {
"accountsDeployContract": "",
"accountsDepositWithdrawEndowments": "",
"accountsDonationMatch": "",
"accountsAllowance": "",
"accountsCreateEndowment": "",
"accountsDaoEndowments": "",
"accountsQueryEndowments": "",
"accountsStrategy": "",
"accountsSwapRouter": "",
"accountsUpdate": "",
"accountsUpdateEndowments": "",
"accountsUpdateEndowmentSettingsController": "",
"accountsUpdateStatusEndowments": "",
"diamondCutFacet": "",
"diamondInitFacet": "",
"diamondLoupeFacet": "",
"ownershipFacet": ""
"accountsDeployContract": "0xC4A743126DCcA4DF85B8f75B6eD113bb69dD65A1",
"accountsDepositWithdrawEndowments": "0xA303374bda3A6Ce7550514E6681228Ca12020BBA",
"accountsDonationMatch": "0xB6B18cae509Fcf3542FF6975C2Da06CAAc9773c5",
"accountsAllowance": "0x7F6D5d1bDFB4b281374285510A845cb140d4367b",
"accountsCreateEndowment": "0x455A2aC2F917956c0f2664992C1DDd9Cd6562976",
"accountsDaoEndowments": "0x4060eF0D5a7F0633c5927F7E05041dd7Fcd95f42",
"accountsQueryEndowments": "0xA9526DFDd289b2C2ADa83E07c6dd293AA2C5fEe9",
"accountsStrategy": "0x32Ed2BD67238Be274E127096F42f0a4061aC0Bff",
"accountsSwapRouter": "0x4dcA4bFA0bAa0C8ce741b92B255D967599d994f0",
"accountsUpdate": "0xD7a385546a6a2355C6a1DfAdf33b55c43e2C19B0",
"accountsUpdateEndowments": "0xfAB9d4FA5c03Aa5EaccE715d02E6db648cEE91a3",
"accountsUpdateEndowmentSettingsController": "0x715214AeEf7D4C78b9c329cc4D7375cC08670843",
"accountsUpdateStatusEndowments": "0x15E1268353F6F19D9de2722bD60eC1081b45D3a6",
"diamondCutFacet": "0x8e1f69CfFd8DaD657bF18B91D75BcD26CD6F43AC",
"diamondInitFacet": "0x904df20E7d5A1D577c3763FC7bF35EFa51Df94da",
"diamondLoupeFacet": "0x9cD5998cd48385cb69AE7AaDdFaC83A5DA185FaA",
"ownershipFacet": "0x43dFD957bB91b568176E976A8d4e8ab4E94aeBfD"
}
},
"axelar": {
"gasService": "",
"gateway": ""
"gasService": "0x2Eb2BBAAF8D16E8BA07BD40D141a7E25C6dD9945",
"gateway": "0x4ee108458a4D97dAa2f8eF90A73942AC7B3a9209"
},
"donationMatch": {
"emitter": "",
Expand All @@ -196,8 +196,8 @@
"proxy": ""
},
"gasFwd": {
"factory": "",
"implementation": ""
"factory": "0xf342D22125Eddc24c6c3D716E048388D1415C20d",
"implementation": "0x07dEF209701605580893ecd7C3cE2340f5b16875"
},
"giftcards": {
"implementation": "",
Expand Down Expand Up @@ -258,38 +258,38 @@
"implementation": ""
},
"indexFund": {
"implementation": "",
"proxy": ""
"implementation": "0x59c7E6B2c565Ff92B762523BD6B778CE66dC0302",
"proxy": "0x9A676e781A523b5d0C0e43731313A708CB607508"
},
"libraries": {
"angelCoreStruct": "",
"stringArray": ""
},
"multiSig": {
"charityApplications": {
"implementation": "",
"proxy": ""
"implementation": "0x9687796759CAbecC1674A4Aaf23889fC9EC2FCA2",
"proxy": "0xD63c1597435d2E16d7f216A12A3dA65B3bF12241"
},
"apTeam": {
"implementation": "0x712516e61C8B383dF4A63CFe83d7701Bce54B03e",
"proxy": "0xbCF26943C0197d2eE0E5D05c716Be60cc2761508"
"implementation": "0x5C15f56Ee55531f011c6025B205c1750EA469f75",
"proxy": "0xb3e2d928Da7c16d53a8d6DaA14314159fa262754"
},
"endowment": {
"emitter": {
"implementation": "",
"proxy": ""
"implementation": "0x6b07B7A11cF992B436DE5d3bf28F50eBA606649b",
"proxy": "0x05275a4799cd1B07D81319390fC62Bc7BDbDf269"
},
"factory": "",
"implementation": ""
"factory": "0x086bCD73D03A5e1163A9224Fa09dC5cF70d73094",
"implementation": "0x1F570bf89d86a2C43B9b8d0867267719FC58173D"
}
},
"registrar": {
"implementation": "0x59F2f1fCfE2474fD5F0b9BA1E73ca90b143Eb8d0",
"proxy": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"
"implementation": "0xADcb9331bfB37dC1b0db12d73c5aFeC3a6c99ce5",
"proxy": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1"
},
"router": {
"implementation": "",
"proxy": ""
"implementation": "0x6039565f9ff755754E9C52B6DFE4aB7bA6dB2957",
"proxy": "0x8896Dce0E60a706244553ADA1aAc5CDCc40a0428"
},
"subDao": {
"emitter": {
Expand All @@ -304,13 +304,13 @@
"dai": "",
"halo": "",
"reserveToken": "",
"seedAsset": "",
"usdc": "",
"wmatic": ""
"seedAsset": "0x1C3f3A797B80315faD4DB7D1a58f3AA934118e03",
"usdc": "0xb8348E945900083A270D9244614d09F9c4937d75",
"wmatic": "0x1D1aEE6D5dC35F3c15E2D11083D0e59C026b64c4"
},
"uniswap": {
"factory": "",
"swapRouter": ""
"factory": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"swapRouter": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
}
},
"80001": {
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/registrar/Registrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ contract Registrar is LocalRegistrar, Storage, ReentrancyGuard {
emit ConfigUpdated();

LocalRegistrarLib.LocalRegistrarStorage storage lrs = LocalRegistrarLib.localRegistrarStorage();
lrs.NetworkConnections["Polygon"] = IAccountsStrategy.NetworkInfo({
lrs.NetworkConnections[details.networkName] = IAccountsStrategy.NetworkInfo({
chainId: block.chainid,
router: details.router,
axelarGateway: details.axelarGateway,
ibcChannel: "",
transferChannel: "",
gasReceiver: details.axelarGasRecv,
gasReceiver: details.axelarGasService,
gasLimit: 0
});
emit NetworkConnectionPosted(block.chainid);
Expand Down
3 changes: 2 additions & 1 deletion contracts/core/registrar/message.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ library RegistrarMessages {
LibAccounts.SplitDetails splitToLiquid;
address router;
address axelarGateway;
address axelarGasRecv;
address axelarGasService;
string networkName;
}

struct UpdateConfigRequest {
Expand Down
30 changes: 21 additions & 9 deletions contracts/core/registrar/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import config from "config";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {ProxyContract__factory, Registrar__factory, LocalRegistrar__factory} from "typechain-types";
import {Deployment, getContractName, logger, updateAddresses, validateAddress} from "utils";
import {LocalRegistrar__factory, ProxyContract__factory, Registrar__factory} from "typechain-types";
import {
Deployment,
getChainId,
getContractName,
getNetworkNameFromChainId,
logger,
updateAddresses,
validateAddress,
} from "utils";

type RegistrarDeployData = {
axelarGateway: string;
Expand All @@ -11,7 +19,7 @@ type RegistrarDeployData = {
owner?: string;
deployer: SignerWithAddress;
proxyAdmin: SignerWithAddress;
treasuryAddress: string;
treasury: string;
};

export async function deployRegistrar(
Expand All @@ -22,13 +30,16 @@ export async function deployRegistrar(
owner = "",
deployer,
proxyAdmin,
treasuryAddress,
treasury,
}: RegistrarDeployData,
hre: HardhatRuntimeEnvironment
): Promise<Deployment | undefined> {
logger.out("Deploying Registrar...");

try {
const chainId = await getChainId(hre);
const networkName = getNetworkNameFromChainId(chainId);

validateAddress(axelarGateway, "axelarGateway");
validateAddress(axelarGasService, "axelarGasService");
validateAddress(owner, "owner");
Expand All @@ -44,14 +55,15 @@ export async function deployRegistrar(
// deploy proxy
logger.out("Deploying proxy...");
const initData = registrar.interface.encodeFunctionData(
"initialize((address,(uint256,uint256,uint256),address,address,address))",
"initialize((address,(uint256,uint256,uint256),address,address,address,string))",
[
{
treasury: treasuryAddress,
treasury,
splitToLiquid: config.REGISTRAR_DATA.splitToLiquid,
router: router,
axelarGateway: axelarGateway,
axelarGasRecv: axelarGasService,
router,
axelarGateway,
axelarGasService,
networkName,
},
]
);
Expand Down
18 changes: 13 additions & 5 deletions tasks/deploy/deployAngelProtocol.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import {task} from "hardhat/config";
import {Deployment, confirmAction, isLocalNetwork, logger, verify} from "utils";
import config from "config";
import {ADDRESS_ZERO, getSigners, resetAddresses} from "utils";
import {task} from "hardhat/config";
import {
ADDRESS_ZERO,
Deployment,
confirmAction,
getSigners,
isLocalNetwork,
logger,
resetAddresses,
verify,
} from "utils";

import {deployAccountsDiamond} from "contracts/core/accounts/scripts/deploy";
import {deployIndexFund} from "contracts/core/index-fund/scripts/deploy";
Expand All @@ -12,12 +20,12 @@ import {deployEndowmentMultiSig} from "contracts/normalized_endowment/endowment-
// import {deployEmitters} from "contracts/normalized_endowment/scripts/deployEmitter";
// import {deployImplementation} from "contracts/normalized_endowment/scripts/deployImplementation";

import {deployGasFwd} from "contracts/core/gasFwd/scripts/deploy";
import {
getOrDeployThirdPartyContracts,
updateRegistrarConfig,
updateRegistrarNetworkConnections,
} from "../helpers";
import {deployGasFwd} from "contracts/core/gasFwd/scripts/deploy";

task("deploy:AngelProtocol", "Will deploy complete Angel Protocol")
.addFlag("skipVerify", "Skip contract verification")
Expand Down Expand Up @@ -50,7 +58,7 @@ task("deploy:AngelProtocol", "Will deploy complete Angel Protocol")
owner: apTeamMultisig?.address,
deployer,
proxyAdmin,
treasuryAddress: treasury.address,
treasury: treasury.address,
},
hre
);
Expand Down
4 changes: 2 additions & 2 deletions tasks/deploy/deployRegistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ task(
owner: apTeamMultiSig,
deployer,
proxyAdmin,
treasuryAddress: treasury.address,
treasury: treasury.address,
},
hre
);
Expand Down Expand Up @@ -99,7 +99,7 @@ task(
}

await hre.run("manage:accounts:updateConfig", {
newRegistrar: registrarDeployment.address,
registrarContract: registrarDeployment.address,
yes: true,
});
await hre.run("manage:IndexFund:updateRegistrar", {
Expand Down
28 changes: 18 additions & 10 deletions tasks/helpers/updateRegistrar.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,52 @@
import { BigNumber } from "ethers";
import {HardhatRuntimeEnvironment} from "hardhat/types";
import {APTeamMultiSig__factory, Registrar__factory} from "typechain-types";
import {
IAccountsStrategy,
RegistrarMessages,
} from "typechain-types/contracts/core/registrar/interfaces/IRegistrar";
import {NetworkConnectionAction, getNetworkNameFromChainId, getSigners, logger, structToObject, validateAddress} from "utils";
import {
NetworkConnectionAction,
getChainId,
getNetworkNameFromChainId,
getSigners,
logger,
structToObject,
validateAddress,
} from "utils";

export async function updateRegistrarNetworkConnections(
registrar = "",
apTeamMultisig = "",
newNetworkInfo: Partial<IAccountsStrategy.NetworkInfoStruct>,
networkInfo: Partial<IAccountsStrategy.NetworkInfoStruct>,
hre: HardhatRuntimeEnvironment
) {
logger.divider();
logger.out(`Updating Registrar network info for chain id: ${newNetworkInfo.chainId}`);

try {
const chainId = await getChainId(hre);
const networkName = getNetworkNameFromChainId(chainId);

logger.out(`Updating Registrar network info for chain: ${networkName}`);

validateAddress(registrar, "registrar");
validateAddress(apTeamMultisig, "apTeamMultisig");

const network = await hre.ethers.provider.getNetwork();
const networkName = getNetworkNameFromChainId(network.chainId)

const {apTeamMultisigOwners} = await getSigners(hre);

const registrarContract = Registrar__factory.connect(registrar, apTeamMultisigOwners[0]);

logger.out("Fetching current Registrar's network connection data...");

const struct = await registrarContract.queryNetworkConnection(networkName);
const curNetworkConnection = structToObject(struct);
logger.out(curNetworkConnection);

logger.out("Network info to update:");
logger.out(newNetworkInfo);
logger.out(networkInfo);

const updateNetworkConnectionsData = registrarContract.interface.encodeFunctionData(
"updateNetworkConnections",
[networkName, {...curNetworkConnection, ...newNetworkInfo}, NetworkConnectionAction.POST]
[networkName, {...curNetworkConnection, ...networkInfo}, NetworkConnectionAction.POST]
);
const apTeamMultisigContract = APTeamMultiSig__factory.connect(
apTeamMultisig,
Expand Down
6 changes: 3 additions & 3 deletions tasks/manage/accounts/updateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type TaskArgs = {
earlyLockedWithdrawFeeBps?: number;
earlyLockedWithdrawFeePayoutAddress?: string;
maxGeneralCategoryId?: number;
newRegistrar?: string;
registrarContract?: string;
yes: boolean;
};

Expand All @@ -27,7 +27,7 @@ task("manage:accounts:updateConfig", "Will update Accounts Diamond config")
)
.addOptionalParam("maxGeneralCategoryId", "The max general category id.", undefined, types.int)
.addOptionalParam(
"newRegistrar",
"registrarContract",
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided."
)
.addFlag("yes", "Automatic yes to prompt.")
Expand Down Expand Up @@ -63,7 +63,7 @@ task("manage:accounts:updateConfig", "Will update Accounts Diamond config")
apTeamMultisigOwners[0]
);
const data = accountsUpdate.interface.encodeFunctionData("updateConfig", [
newConfig.newRegistrar || curConfig.registrarContract,
newConfig.registrarContract || curConfig.registrarContract,
newConfig.maxGeneralCategoryId || curConfig.maxGeneralCategoryId,
{
bps: newConfig.earlyLockedWithdrawFeeBps || curConfig.earlyLockedWithdrawFee.bps,
Expand Down
Loading

0 comments on commit bb43ac1

Please sign in to comment.