diff --git a/.gitignore b/.gitignore index 81b297f19..3f2a49d13 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ yarn-error.log .env .prettierrc .nvmrc -contract-address-local.json dist #Hardhat files diff --git a/contract-address.json b/contract-address.json index db9c02dba..7cab5a83e 100644 --- a/contract-address.json +++ b/contract-address.json @@ -19,8 +19,7 @@ "diamondCutFacet": "", "diamondInitFacet": "", "diamondLoupeFacet": "", - "ownershipFacet": "", - "reentrancyGuardFacet": "" + "ownershipFacet": "" } }, "charityApplication": { @@ -153,30 +152,29 @@ }, "80001": { "accounts": { - "diamond": "0x6878A6A4892299184d16Ef181acE84C6A2076ac1", + "diamond": "0xFCbE277d74027455A92fA67253FA16385F0579F4", "facets": { - "accountDeployContract": "", - "accountDepositWithdrawEndowments": "", - "accountDonationMatch": "", - "accountsAllowance": "", - "accountsCreateEndowment": "", - "accountsDAOEndowments": "", - "accountsQueryEndowments": "", - "accountsSwapEndowments": "", - "accountsUpdate": "", - "accountsUpdateEndowments": "", - "accountsUpdateEndowmentSettingsController": "", - "accountsUpdateStatusEndowments": "", - "accountsVaultFacet": "", - "diamondCutFacet": "", - "diamondInitFacet": "", - "diamondLoupeFacet": "", - "ownershipFacet": "", - "reentrancyGuardFacet": "" + "accountDeployContract": "0xCebb4FbC3b20042d0D7cCf6658e4150B4A680DCd", + "accountDepositWithdrawEndowments": "0xb43421526bB09ECe4Fd8Ee58C4F33F19162c1E3c", + "accountDonationMatch": "0x8d1200931Ff1e176e2eA033C3CDB2C8d0B7b4e29", + "accountsAllowance": "0x76d7E8D8BA2D488a0f532D59EE0C7E43CCA2a509", + "accountsCreateEndowment": "0xB432B1CEf376B77c0B1bdBFa54d84A103435f226", + "accountsDAOEndowments": "0x04EffDae32A5dDFf2CC8B80efdbcB4898E26864C", + "accountsQueryEndowments": "0xB402E09EDEB25eF21f7c9a0a58A1a576Afd2853a", + "accountsSwapEndowments": "0x66E476a818ADd9D3BE6AbD949F476DEBD07BdEFb", + "accountsUpdate": "0x01023ffDFaE05b3b213430C84Dd383AA5236473F", + "accountsUpdateEndowments": "0xBF4965f8B7cB1c4acfA4dE9c5C289c6C6f820798", + "accountsUpdateEndowmentSettingsController": "0x0EA69a77087798526ccF59fF862e0Ed29E18f0f4", + "accountsUpdateStatusEndowments": "0x2EdB4a8E0b8d5f3D024c3175525Eb8F31FaaF0b2", + "accountsVaultFacet": "0x715Eb3f116de163af10DdbF4eD231916893833a9", + "diamondCutFacet": "0xB5602EB190943fb897999C9Df49c92faa27F9672", + "diamondInitFacet": "0x9908870F15E1626FB2944c622791f2e929EC2f58", + "diamondLoupeFacet": "0x76bd4D306B494287b3d87164bAC6665f275D7359", + "ownershipFacet": "0x9934602ad547c33e9B4615be9b824caF563368d2" } }, "charityApplication": { - "implementation": "", + "implementation": "0x79eB828d1bBdfBC2c8415435676433572E1b2C55", "proxy": "" }, "donationMatch": { @@ -303,4 +301,4 @@ "weth": "" } } -} \ No newline at end of file +} diff --git a/contracts/core/accounts/scripts/deploy/updateDiamond.ts b/contracts/core/accounts/scripts/deploy/cutDiamond.ts similarity index 74% rename from contracts/core/accounts/scripts/deploy/updateDiamond.ts rename to contracts/core/accounts/scripts/deploy/cutDiamond.ts index cae93f478..2abf4c224 100644 --- a/contracts/core/accounts/scripts/deploy/updateDiamond.ts +++ b/contracts/core/accounts/scripts/deploy/cutDiamond.ts @@ -2,8 +2,9 @@ import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers"; import {HardhatRuntimeEnvironment} from "hardhat/types"; import {DiamondCutFacet__factory, DiamondInit} from "typechain-types"; import {FacetCut} from "./types"; +import {logger} from "utils"; -export default async function updateDiamond( +export default async function cutDiamond( address: string, diamondInit: DiamondInit, admin: SignerWithAddress, @@ -12,20 +13,20 @@ export default async function updateDiamond( facetCuts: FacetCut[], hre: HardhatRuntimeEnvironment ) { - console.log("Updating Diamond facets..."); + logger.out("Cutting the Diamond with new facets..."); const diamondCut = DiamondCutFacet__factory.connect(address, admin); const calldata = diamondInit.interface.encodeFunctionData("init", [owner, registrar]); const cuts = facetCuts.map((x) => x.cut); const tx = await diamondCut.diamondCut(cuts, diamondInit.address, calldata); - console.log("Cutting diamond tx: ", tx.hash); + logger.out(`Cutting Diamond tx: ${tx.hash}`); const receipt = await hre.ethers.provider.waitForTransaction(tx.hash); if (!receipt.status) { - throw Error(`Diamond upgrade failed: ${tx.hash}`); + throw new Error(`Diamond cut failed: ${tx.hash}`); } - console.log("Completed diamond cut."); + logger.out("Completed Diamond cut."); } diff --git a/contracts/core/accounts/scripts/deploy/deploy.ts b/contracts/core/accounts/scripts/deploy/deploy.ts index 145373e9f..371a3f47a 100644 --- a/contracts/core/accounts/scripts/deploy/deploy.ts +++ b/contracts/core/accounts/scripts/deploy/deploy.ts @@ -9,62 +9,56 @@ import { Diamond__factory, } from "typechain-types"; import deployFacets from "./deployFacets"; -import updateDiamond from "./updateDiamond"; +import cutDiamond from "./cutDiamond"; import verify from "./verify"; import {getSigners, logger, updateAddresses} from "utils"; -export async function deployDiamond( +export async function deployAccountsDiamond( owner: string, registrar: string, ANGEL_CORE_STRUCT: string, - STRING_LIBRARY: string, - hre: HardhatRuntimeEnvironment, - verify_contracts = false + verify_contracts: boolean, + hre: HardhatRuntimeEnvironment ) { - try { - const {proxyAdmin: diamondAdmin} = await getSigners(hre.ethers); - const diamondCut = await deployDiamondCutFacet(diamondAdmin); + logger.out("Deploying and setting up Accounts Diamond and all its facets..."); - const diamond = await _deployDiamond(diamondAdmin, diamondCut.address, hre); + const {proxyAdmin} = await getSigners(hre.ethers); - const diamondInit = await deployDiamondInit(diamondAdmin); + const {diamond, diamondCutFacet} = await deployDiamond(proxyAdmin, hre); - const cuts = await deployFacets(diamondAdmin, ANGEL_CORE_STRUCT, STRING_LIBRARY); + const diamondInit = await deployDiamondInit(proxyAdmin, hre); - await updateDiamond(diamond.address, diamondInit, diamondAdmin, owner, registrar, cuts, hre); + const cuts = await deployFacets(proxyAdmin, ANGEL_CORE_STRUCT, hre); - if (verify_contracts) { - await verify(diamond.address, diamondCut.address, cuts, diamondAdmin, hre); - } + await cutDiamond(diamond.address, diamondInit, proxyAdmin, owner, registrar, cuts, hre); - return Promise.resolve(diamond.address); - } catch (error) { - return Promise.reject(error); + if (verify_contracts) { + await verify(diamond.address, diamondCutFacet.address, cuts, proxyAdmin, hre); } + + return diamond; } -async function deployDiamondCutFacet(admin: SignerWithAddress): Promise { +async function deployDiamond( + admin: SignerWithAddress, + hre: HardhatRuntimeEnvironment +): Promise<{diamond: Diamond; diamondCutFacet: DiamondCutFacet}> { const DiamondCutFacet = new DiamondCutFacet__factory(admin); const diamondCutFacet = await DiamondCutFacet.deploy(); await diamondCutFacet.deployed(); - console.log("DiamondCutFacet deployed:", diamondCutFacet.address); - return diamondCutFacet; -} + logger.out(`DiamondCutFacet deployed at: ${diamondCutFacet.address}`); -async function _deployDiamond( - admin: SignerWithAddress, - diamondCut: string, - hre: HardhatRuntimeEnvironment -): Promise { const Diamond = new Diamond__factory(admin); - const diamond = await Diamond.deploy(admin.address, diamondCut); + const diamond = await Diamond.deploy(admin.address, diamondCutFacet.address); await diamond.deployed(); - console.log("Diamond deployed:", diamond.address); + logger.out(`Diamond deployed at: ${diamond.address}`); - logger.out("Saving address to contract-address.json..."); - await updateAddresses({accounts: {diamond: diamond.address}}, hre); + await updateAddresses( + {accounts: {diamond: diamond.address, facets: {diamondCutFacet: diamondCutFacet.address}}}, + hre + ); - return diamond; + return {diamond, diamondCutFacet}; } /** @@ -72,10 +66,16 @@ async function _deployDiamond( * Read about how the diamondCut function works here: https://eips.ethereum.org/EIPS/eip-2535#addingreplacingremoving-functions * @param admin signer representing administrator of the contract */ -async function deployDiamondInit(admin: SignerWithAddress): Promise { +async function deployDiamondInit( + admin: SignerWithAddress, + hre: HardhatRuntimeEnvironment +): Promise { const DiamondInit = new DiamondInit__factory(admin); const diamondInit = await DiamondInit.deploy(); await diamondInit.deployed(); - console.log("DiamondInit deployed:", diamondInit.address, "\n"); + logger.out(`DiamondInit deployed at: ${diamondInit.address}`); + + await updateAddresses({accounts: {facets: {diamondInitFacet: diamondInit.address}}}, hre); + return diamondInit; } diff --git a/contracts/core/accounts/scripts/deploy/deployFacets.ts b/contracts/core/accounts/scripts/deploy/deployFacets.ts index 179d4d462..90a6120ed 100644 --- a/contracts/core/accounts/scripts/deploy/deployFacets.ts +++ b/contracts/core/accounts/scripts/deploy/deployFacets.ts @@ -1,45 +1,29 @@ import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers"; -import {ContractFactory} from "ethers"; -import { - AccountDeployContract__factory, - AccountDepositWithdrawEndowments__factory, - AccountDonationMatch__factory, - AccountsAllowance__factory, - AccountsCreateEndowment__factory, - AccountsDAOEndowments__factory, - AccountsQueryEndowments__factory, - AccountsSwapEndowments__factory, - AccountsUpdateEndowmentSettingsController__factory, - AccountsUpdateEndowments__factory, - AccountsUpdateStatusEndowments__factory, - AccountsUpdate__factory, - AccountsVaultFacet__factory, - DiamondLoupeFacet__factory, - OwnershipFacet__factory, -} from "typechain-types"; -import {logger} from "utils"; +import {HardhatRuntimeEnvironment} from "hardhat/types"; +import {getContractName, getFacetFactoryEntries, logger, updateAddresses} from "utils"; import {FacetCutAction, getSelectors} from "../libraries/diamond"; import {FacetCut} from "./types"; export default async function deployFacets( diamondOwner: SignerWithAddress, corestruct: string, - stringlib: string + hre: HardhatRuntimeEnvironment ): Promise { - console.log("Deploying facets..."); + logger.out("Deploying facets..."); const cuts: FacetCut[] = []; - console.log("Instantiating factories..."); + const factoryEntries = await getFacetFactoryEntries(diamondOwner, corestruct); - const factories = await getFactories(diamondOwner, corestruct); - - for (const Factory of factories) { - const contractName = Factory.constructor.name.replace("__factory", ""); + for (const entry of factoryEntries) { + const contractName = getContractName(entry.factory); try { - const facet = await Factory.deploy(); + const facet = await entry.factory.deploy(); await facet.deployed(); - console.log(`${contractName} deployed: ${facet.address}`); + logger.out(`${contractName} deployed at: ${facet.address}`); + + await updateAddresses({accounts: {facets: {[entry.addressField]: facet.address}}}, hre); + cuts.push({ facetName: contractName, cut: { @@ -53,57 +37,5 @@ export default async function deployFacets( } } - console.log("\nDiamond Cut:", cuts); - return cuts; } - -// Getting factories instantiated in bulk as they share the deploy/cut creation logic. -async function getFactories( - diamondOwner: SignerWithAddress, - corestruct: string -): Promise { - const factories = [ - // no lib - new AccountDeployContract__factory(diamondOwner), - new AccountsDAOEndowments__factory(diamondOwner), - new AccountDonationMatch__factory(diamondOwner), - new AccountsUpdate__factory(diamondOwner), - new AccountsQueryEndowments__factory(diamondOwner), - new AccountsUpdateStatusEndowments__factory(diamondOwner), - // core lib - new AccountsVaultFacet__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ), - new AccountsAllowance__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ), - new AccountsCreateEndowment__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ), - new AccountsSwapEndowments__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ), - new AccountsUpdateEndowments__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ), - new AccountsUpdateEndowmentSettingsController__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ), - new AccountDepositWithdrawEndowments__factory( - { - "contracts/core/struct.sol:AngelCoreStruct": corestruct, - }, - diamondOwner - ), - new DiamondLoupeFacet__factory(diamondOwner), - new OwnershipFacet__factory(diamondOwner), - ]; - return factories; -} diff --git a/contracts/core/accounts/scripts/deploy/verify.ts b/contracts/core/accounts/scripts/deploy/verify.ts index 8829cdf03..c12d7b9b4 100644 --- a/contracts/core/accounts/scripts/deploy/verify.ts +++ b/contracts/core/accounts/scripts/deploy/verify.ts @@ -10,15 +10,16 @@ export default async function verify( admin: SignerWithAddress, hre: HardhatRuntimeEnvironment ): Promise { - logger.out("Verifying newly deployed facets..."); + logger.out("Verifying newly deployed contracts:"); for (const {facetName, cut} of facetCuts) { try { + logger.out(`Verifying ${facetName}...`); + await hre.run("verify:verify", { address: cut.facetAddress, constructorArguments: [], }); - logger.out(`${facetName} verified.`); } catch (error) { logger.out( `Failed to verify ${facetName} at ${cut.facetAddress}. Error: ${error}`, @@ -27,9 +28,9 @@ export default async function verify( } } - logger.out("Verifying the Diamond..."); - try { + logger.out("Verifying the Diamond..."); + await hre.run("verify:verify", { address: diamondAddress, constructorArguments: [admin.address, diamondCutAddress], diff --git a/package.json b/package.json index 8c4c594fd..2e5a72473 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "format": "prettier --write './**/*.{ts,tsx,js}' --write contracts/**/*.sol", "test": "hardhat test", "compile": "hardhat compile && yarn format", - "deploy": "hardhat compile && hardhat run ./scripts/deploy.ts", + "clean-compile": "set -x && mv ./tasks/index.ts ./tasks/temp_index.ts && touch ./tasks/index.ts && hardhat clean && yarn compile && mv ./tasks/temp_index.ts ./tasks/index.ts && set +x", + "deploy": "yarn compile && hardhat run ./scripts/deploy.ts", "abi": "hardhat export-abi" }, "engines": { diff --git a/scripts/deployTask.ts b/scripts/deployTask.ts index 79396d177..9de829d4f 100644 --- a/scripts/deployTask.ts +++ b/scripts/deployTask.ts @@ -1,7 +1,7 @@ // This is a script for deploying your contracts. You can adapt it to deploy // yours, or create new ones. -import {deployDiamond} from "contracts/core/accounts/scripts/deploy"; +import {deployAccountsDiamond} from "contracts/core/accounts/scripts/deploy"; import {deployRegistrar} from "contracts/core/registrar/scripts/deploy"; import {deployImplementation} from "contracts/normalized_endowment/scripts/deployImplementation"; import {deployMultisig} from "contracts/multisigs/scripts/deploy"; @@ -148,27 +148,24 @@ export async function mainTask(verify_contracts = false, hre: HardhatRuntimeEnvi hre ); - const ACCOUNT_ADDRESS = await deployDiamond( + const accountsDiamond = await deployAccountsDiamond( multisigAddress.APTeamMultiSig, REGISTRAR_ADDRESS, ANGEL_CORE_STRUCT.address, - STRING_LIBRARY.address, - hre, - verify_contracts + verify_contracts, + hre ); - addressWriter.accountDiamond = ACCOUNT_ADDRESS; - - console.log("Account contract deployed at:-", ACCOUNT_ADDRESS); + console.log("Account contract deployed at:-", accountsDiamond.address); - let emitters = await deployEmitters(ACCOUNT_ADDRESS, verify_contracts, hre); + let emitters = await deployEmitters(accountsDiamond.address, verify_contracts, hre); console.log("emitters Contract deployed at:-", emitters); let charityApplicationsData: Parameters[0] = [ config.CHARITY_APPLICATION_DATA.expiry, multisigAddress.ApplicationsMultiSig, - ACCOUNT_ADDRESS, + accountsDiamond.address, config.CHARITY_APPLICATION_DATA.seedSplitToLiquid, config.CHARITY_APPLICATION_DATA.newEndowGasMoney, config.CHARITY_APPLICATION_DATA.gasAmount, @@ -186,7 +183,7 @@ export async function mainTask(verify_contracts = false, hre: HardhatRuntimeEnvi const SWAP_ROUTER = await deploySwapRouter( REGISTRAR_ADDRESS, - ACCOUNT_ADDRESS, + accountsDiamond.address, config.SWAP_ROUTER_DATA.SWAP_FACTORY_ADDRESS, config.SWAP_ROUTER_DATA.SWAP_ROUTER_ADDRESS, verify_contracts, @@ -372,7 +369,7 @@ export async function mainTask(verify_contracts = false, hre: HardhatRuntimeEnvi config.REGISTRAR_DATA.acceptedTokens.cw20.push(haloToken.address); updateConfig = { - accountsContract: ACCOUNT_ADDRESS, //Address + accountsContract: accountsDiamond.address, //Address approved_charities: [], //string[] splitMax: 100, //uint256 splitMin: 0, //uint256 @@ -426,7 +423,7 @@ export async function mainTask(verify_contracts = false, hre: HardhatRuntimeEnvi }, dai: config.REGISTRAR_UPDATE_CONFIG.DAI_address, registrar: REGISTRAR_ADDRESS, - account: ACCOUNT_ADDRESS, + account: accountsDiamond, multisigAddress, charityApplicationsAddress, swapRouter: SWAP_ROUTER, diff --git a/tasks/deploy/deployAccountsDiamond.ts b/tasks/deploy/deployAccountsDiamond.ts new file mode 100644 index 000000000..21c4c5c62 --- /dev/null +++ b/tasks/deploy/deployAccountsDiamond.ts @@ -0,0 +1,23 @@ +import {deployAccountsDiamond} from "contracts/core/accounts/scripts/deploy"; +import {task} from "hardhat/config"; +import {getAddresses, isLocalNetwork, logger} from "utils"; + +task("Deploy:AccountsDiamond", "It will deploy accounts diamond contracts").setAction( + async (_, hre) => { + try { + const addresses = await getAddresses(hre); + const verify_contracts = !isLocalNetwork(hre.network); + await deployAccountsDiamond( + addresses.multiSig.apTeam.proxy, + addresses.registrar.proxy, + addresses.libraries.ANGEL_CORE_STRUCT_LIBRARY, + verify_contracts, + hre + ); + } catch (error) { + logger.out(`Diamond deployment failed, reason: ${error}`, logger.Level.Error); + } finally { + logger.out("Done."); + } + } +); diff --git a/tasks/deploy/deployDiamond.ts b/tasks/deploy/deployDiamond.ts deleted file mode 100644 index aebeefb70..000000000 --- a/tasks/deploy/deployDiamond.ts +++ /dev/null @@ -1,27 +0,0 @@ -import {deployDiamond} from "contracts/core/accounts/scripts/deploy"; -import {task} from "hardhat/config"; -import {logger} from "utils"; - -task("Deploy:deployAccountDiamond", "It will deploy account diamond contracts") - .addParam("apteammultisig", "APTeamMultiSig address") - .addParam("registrar", "registrar contracts") - .addParam("corestruct", "core struct address") - .addParam("stringlib", "string lib address") - .setAction(async (taskArgs, hre) => { - try { - const verify_contracts = hre.network.name !== "hardhat" && hre.network.name !== "localhost"; - - await deployDiamond( - taskArgs.apteammultisig, - taskArgs.registrar, - taskArgs.corestruct, - taskArgs.stringlib, - hre, - verify_contracts - ); - - logger.out("Done."); - } catch (error) { - logger.out(`Diamond deployment failed, reason: ${error}`, logger.Level.Error); - } - }); diff --git a/tasks/deploy/index.ts b/tasks/deploy/index.ts index dfc54d21c..5bfd1d1d3 100644 --- a/tasks/deploy/index.ts +++ b/tasks/deploy/index.ts @@ -1,6 +1,6 @@ +import "./deployAccountsDiamond"; import "./deployAngelProtocol"; import "./deployCharityApplications"; -import "./deployDiamond"; import "./deployEmitters"; import "./deployEndowmentMultisig"; import "./deployFundraising"; diff --git a/tasks/upgrade/upgradeContractsUsingAccountStorage.ts b/tasks/upgrade/upgradeContractsUsingAccountStorage.ts index 4c1d6ea75..b6e6a2c6d 100644 --- a/tasks/upgrade/upgradeContractsUsingAccountStorage.ts +++ b/tasks/upgrade/upgradeContractsUsingAccountStorage.ts @@ -1,18 +1,5 @@ import {task} from "hardhat/config"; -import { - AccountDepositWithdrawEndowments__factory, - AccountDonationMatch__factory, - AccountsAllowance__factory, - AccountsCreateEndowment__factory, - AccountsDAOEndowments__factory, - AccountsQueryEndowments__factory, - AccountsSwapEndowments__factory, - AccountsUpdateEndowmentSettingsController__factory, - AccountsUpdateEndowments__factory, - AccountsUpdateStatusEndowments__factory, - AccountsVaultFacet__factory, -} from "typechain-types"; -import {getContractName, logger} from "utils"; +import {logger} from "utils"; task( "upgrade:upgradeContractsUsingAccountStorage", @@ -20,7 +7,7 @@ task( ).setAction(async (_taskArguments, hre) => { try { await hre.run("upgrade:upgradeCharityApplication"); - await hre.run("upgrade:upgradeFacets", {facets}); + await hre.run("upgrade:facets", {facets: ["all"]}); } catch (error) { logger.out( `Redeployment of all contracts that use AccountStorage struct failed, reason: ${error}`, @@ -28,17 +15,3 @@ task( ); } }); - -const facets: string[] = [ - getContractName(AccountsAllowance__factory), - getContractName(AccountsDAOEndowments__factory), - getContractName(AccountDonationMatch__factory), - getContractName(AccountsCreateEndowment__factory), - getContractName(AccountsQueryEndowments__factory), - getContractName(AccountsSwapEndowments__factory), - getContractName(AccountsUpdateEndowments__factory), - getContractName(AccountsUpdateEndowmentSettingsController__factory), - getContractName(AccountsUpdateStatusEndowments__factory), - getContractName(AccountDepositWithdrawEndowments__factory), - getContractName(AccountsVaultFacet__factory), -]; diff --git a/tasks/upgrade/upgradeFacets/createFacetCuts/createFacetCuts.ts b/tasks/upgrade/upgradeFacets/createFacetCuts/createFacetCuts.ts index eb9d95766..f48d7f2c8 100644 --- a/tasks/upgrade/upgradeFacets/createFacetCuts/createFacetCuts.ts +++ b/tasks/upgrade/upgradeFacets/createFacetCuts/createFacetCuts.ts @@ -1,7 +1,7 @@ import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers"; import {FacetCutAction} from "contracts/core/accounts/scripts/libraries/diamond"; import {DiamondLoupeFacet__factory} from "typechain-types"; -import {logger} from "utils"; +import {ADDRESS_ZERO, logger} from "utils"; import {Facet, FacetCut} from "../types"; import getFacetSelectors from "./getFacetSelectors"; @@ -45,7 +45,7 @@ export default async function createFacetCuts( facetCuts.push({ facetName: facet.name, cut: { - facetAddress: facet.contract.address, + facetAddress: ADDRESS_ZERO, action: FacetCutAction.Remove, functionSelectors: toRemove, }, diff --git a/tasks/upgrade/upgradeFacets/cutDiamond.ts b/tasks/upgrade/upgradeFacets/cutDiamond.ts index f60505aa1..bdae21ec0 100644 --- a/tasks/upgrade/upgradeFacets/cutDiamond.ts +++ b/tasks/upgrade/upgradeFacets/cutDiamond.ts @@ -16,5 +16,9 @@ export default async function cutDiamond( const diamondInit = DiamondInit__factory.connect(diamondAddress, diamondOwner); const cuts = facetCuts.map((x) => x.cut); const tx = await diamondCut.diamondCut(cuts, diamondInit.address, "0x"); - await hre.ethers.provider.waitForTransaction(tx.hash); + const receipt = await hre.ethers.provider.waitForTransaction(tx.hash); + + if (!receipt.status) { + throw new Error("Diamond cut failed."); + } } diff --git a/tasks/upgrade/upgradeFacets/deployFacets.ts b/tasks/upgrade/upgradeFacets/deployFacets.ts index 62624e9e3..0970358e1 100644 --- a/tasks/upgrade/upgradeFacets/deployFacets.ts +++ b/tasks/upgrade/upgradeFacets/deployFacets.ts @@ -1,156 +1,50 @@ import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers"; -import {ContractFactory} from "ethers"; -import { - AccountDepositWithdrawEndowments__factory, - AccountDonationMatch__factory, - AccountsAllowance__factory, - AccountsCreateEndowment__factory, - AccountsDAOEndowments__factory, - AccountsQueryEndowments__factory, - AccountsStrategiesCopyEndowments__factory, - AccountsStrategiesUpdateEndowments__factory, - AccountsSwapEndowments__factory, - AccountsUpdateEndowmentSettingsController__factory, - AccountsUpdateEndowments__factory, - AccountsUpdateStatusEndowments__factory, - AccountsVaultFacet__factory, - AxelarExecutionContract__factory, -} from "typechain-types"; -import {getContractName, logger} from "utils"; +import {getContractName, getFacetFactoryEntries, logger, updateAddresses} from "utils"; import {Facet} from "./types"; +import {HardhatRuntimeEnvironment} from "hardhat/types"; export default async function deployFacets( facetNames: string[], diamondOwner: SignerWithAddress, corestruct: string, - stringlib: string + hre: HardhatRuntimeEnvironment ): Promise { - const facets: Facet[] = []; - - logger.out("Instantiating factories..."); + logger.out("Deploying facets..."); - const facetFactories = await getFacetFactories(facetNames, diamondOwner, corestruct, stringlib); + const facets: Facet[] = []; - logger.out("Deploying facets..."); + const facetEntries = await getFacetsToUpgrade(facetNames, diamondOwner, corestruct); - for (const facetFactory of facetFactories) { - const {facetName, factory} = facetFactory; + for (const entry of facetEntries) { + const facetName = getContractName(entry.factory); try { - const facet = await factory.deploy(); + const facet = await entry.factory.deploy(); await facet.deployed(); logger.out(`${facetName} deployed: ${facet.address}`); + + await updateAddresses({accounts: {facets: {[entry.addressField]: facet.address}}}, hre); + facets.push({name: facetName, contract: facet}); } catch (error) { logger.out(`Failed to deploy ${facetName}, reason: ${error}`, logger.Level.Error); } } + return facets; } -type FacetFactory = {facetName: string; factory: ContractFactory}; - -// Getting factories instantiated in bulk as they share the deploy/cut creation logic. -async function getFacetFactories( +async function getFacetsToUpgrade( facetNames: string[], diamondOwner: SignerWithAddress, - corestruct: string, - stringlib: string -): Promise { - const factories: FacetFactory[] = []; - const nonExistentFacets: string[] = []; - - facetNames.forEach((facetName) => { - const factory = getFacetFactory(facetName, diamondOwner, corestruct, stringlib); - if (typeof factory === "string") { - nonExistentFacets.push(factory); - } else { - factories.push({facetName, factory}); + corestruct: string +) { + const factoryEntries = await getFacetFactoryEntries(diamondOwner, corestruct); + const facetsToUpgrade = facetNames.map((facetName) => { + const factoryEntry = factoryEntries.find((entry) => getContractName(entry.factory)); + if (!factoryEntry) { + throw new Error(`Nonexistent facet detected: ${facetName}.`); } + return factoryEntry; }); - - if (!nonExistentFacets.length) { - return factories; - } - - throw new Error(`Nonexistent facets detected: ${nonExistentFacets.join(", ")}.`); -} - -function getFacetFactory( - facetName: string, - diamondOwner: SignerWithAddress, - corestruct: string, - stringlib: string -): ContractFactory | string { - switch (facetName) { - // no lib - case getContractName(AccountsAllowance__factory): - return new AccountsAllowance__factory(diamondOwner); - case getContractName(AccountsDAOEndowments__factory): - return new AccountsDAOEndowments__factory(diamondOwner); - case getContractName(AccountDonationMatch__factory): - return new AccountDonationMatch__factory(diamondOwner); - case getContractName(AccountsStrategiesCopyEndowments__factory): - return new AccountsStrategiesCopyEndowments__factory(diamondOwner); - // core lib - case getContractName(AccountsCreateEndowment__factory): - return new AccountsCreateEndowment__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ); - case getContractName(AccountsQueryEndowments__factory): - return new AccountsQueryEndowments__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ); - case getContractName(AccountsSwapEndowments__factory): - return new AccountsSwapEndowments__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ); - case getContractName(AccountsUpdateEndowments__factory): - return new AccountsUpdateEndowments__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ); - case getContractName(AccountsUpdateEndowmentSettingsController__factory): - return new AccountsUpdateEndowmentSettingsController__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ); - case getContractName(AxelarExecutionContract__factory): - return new AxelarExecutionContract__factory( - {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, - diamondOwner - ); - // string lib - case getContractName(AccountsStrategiesUpdateEndowments__factory): - return new AccountsStrategiesUpdateEndowments__factory( - {"contracts/lib/Strings/string.sol:StringArray": stringlib}, - diamondOwner - ); - case getContractName(AccountsUpdateStatusEndowments__factory): - return new AccountsUpdateStatusEndowments__factory( - {"contracts/lib/Strings/string.sol:StringArray": stringlib}, - diamondOwner - ); - // all libs - case getContractName(AccountDepositWithdrawEndowments__factory): - return new AccountDepositWithdrawEndowments__factory( - { - "contracts/core/struct.sol:AngelCoreStruct": corestruct, - "contracts/lib/Strings/string.sol:StringArray": stringlib, - }, - diamondOwner - ); - case getContractName(AccountsVaultFacet__factory): - return new AccountsVaultFacet__factory( - { - "contracts/core/struct.sol:AngelCoreStruct": corestruct, - "contracts/lib/Strings/string.sol:StringArray": stringlib, - }, - diamondOwner - ); - default: - return facetName; - } + return facetsToUpgrade; } diff --git a/tasks/upgrade/upgradeFacets/upgradeFacets.ts b/tasks/upgrade/upgradeFacets/upgradeFacets.ts index 8af1b257c..bc96d6fb4 100644 --- a/tasks/upgrade/upgradeFacets/upgradeFacets.ts +++ b/tasks/upgrade/upgradeFacets/upgradeFacets.ts @@ -1,5 +1,27 @@ import {task} from "hardhat/config"; -import {confirmAction, getAddresses, getSigners, logger, shouldVerify} from "utils"; +import { + AccountDeployContract__factory, + AccountDepositWithdrawEndowments__factory, + AccountDonationMatch__factory, + AccountsAllowance__factory, + AccountsCreateEndowment__factory, + AccountsDAOEndowments__factory, + AccountsQueryEndowments__factory, + AccountsSwapEndowments__factory, + AccountsUpdateEndowmentSettingsController__factory, + AccountsUpdateEndowments__factory, + AccountsUpdateStatusEndowments__factory, + AccountsUpdate__factory, + AccountsVaultFacet__factory, +} from "typechain-types"; +import { + confirmAction, + getAddresses, + getContractName, + getSigners, + logger, + shouldVerify, +} from "utils"; import createFacetCuts from "./createFacetCuts"; import cutDiamond from "./cutDiamond"; import deployFacets from "./deployFacets"; @@ -7,12 +29,23 @@ import verify from "./verify"; type TaskArguments = {facets: string[]}; -task("upgrade:upgradeFacets", "Will redeploy and upgrade all facets that use AccountStorage struct") - .addVariadicPositionalParam("facets", "List of facets to upgrade") +task("upgrade:facets", "Will redeploy and upgrade all facets that use AccountStorage struct") + .addVariadicPositionalParam( + "facets", + "List of facets to upgrade. If set to 'all', will upgrade all facets." + ) .setAction(async (taskArguments: TaskArguments, hre) => { try { + if (taskArguments.facets.length === 0) { + throw new Error("Must provide at least one facet name or pass 'all'"); + } + + const facetsToUpgrade = /^all$/i.test(taskArguments.facets[0]) + ? allFacets + : taskArguments.facets; + const isConfirmed = await confirmAction( - `You're about to upgrade the following facets:\n- ${taskArguments.facets.join("\n- ")}` + `You're about to upgrade the following facets:\n- ${facetsToUpgrade.join("\n- ")}` ); if (!isConfirmed) { return logger.out("Aborting..."); @@ -23,10 +56,10 @@ task("upgrade:upgradeFacets", "Will redeploy and upgrade all facets that use Acc const addresses = await getAddresses(hre); const facets = await deployFacets( - taskArguments.facets, + facetsToUpgrade, proxyAdmin, addresses.libraries.ANGEL_CORE_STRUCT_LIBRARY, - addresses.libraries.STRING_LIBRARY + hre ); const facetCuts = await createFacetCuts(facets, addresses.accounts.diamond, proxyAdmin); @@ -42,3 +75,19 @@ task("upgrade:upgradeFacets", "Will redeploy and upgrade all facets that use Acc logger.out("Done."); } }); + +const allFacets: string[] = [ + getContractName(AccountDeployContract__factory), + getContractName(AccountDepositWithdrawEndowments__factory), + getContractName(AccountDonationMatch__factory), + getContractName(AccountsAllowance__factory), + getContractName(AccountsCreateEndowment__factory), + getContractName(AccountsDAOEndowments__factory), + getContractName(AccountsQueryEndowments__factory), + getContractName(AccountsSwapEndowments__factory), + getContractName(AccountsUpdateEndowmentSettingsController__factory), + getContractName(AccountsUpdateEndowments__factory), + getContractName(AccountsUpdateStatusEndowments__factory), + getContractName(AccountsUpdate__factory), + getContractName(AccountsVaultFacet__factory), +]; diff --git a/tasks/upgrade/upgradeFacets/verify.ts b/tasks/upgrade/upgradeFacets/verify.ts index df6b93f34..50a2378b9 100644 --- a/tasks/upgrade/upgradeFacets/verify.ts +++ b/tasks/upgrade/upgradeFacets/verify.ts @@ -1,6 +1,7 @@ import {HardhatRuntimeEnvironment} from "hardhat/types"; import {logger} from "utils"; import {FacetCut} from "./types"; +import {FacetCutAction} from "contracts/core/accounts/scripts/libraries/diamond"; export default async function verify( facetCuts: FacetCut[], @@ -8,7 +9,9 @@ export default async function verify( ): Promise { logger.out("Verifying newly deployed facets..."); - for (const {facetName, cut} of facetCuts) { + const facetsToVerify = facetCuts.filter((cut) => cut.cut.action !== FacetCutAction.Remove); + + for (const {facetName, cut} of facetsToVerify) { try { logger.out(`Verifying ${facetName}...`); await hre.run("verify:verify", { diff --git a/typechain-types/factories/contracts/core/accounts/facets/AccountDepositWithdrawEndowments__factory.ts b/typechain-types/factories/contracts/core/accounts/facets/AccountDepositWithdrawEndowments__factory.ts index a9fa5adac..39f7a24d2 100644 --- a/typechain-types/factories/contracts/core/accounts/facets/AccountDepositWithdrawEndowments__factory.ts +++ b/typechain-types/factories/contracts/core/accounts/facets/AccountDepositWithdrawEndowments__factory.ts @@ -2236,7 +2236,7 @@ const _abi = [ ] as const; const _bytecode = - "0x608080604052346100165761316a908161001c8239f35b600080fdfe60a0604052600436101561001257600080fd5b60003560e01c80631b13439114611080578063244dbab014610cb75763f91a34c11461003d57600080fd5b34610c9c5760a0366003190112610c9c5763ffffffff806004351660043503610c9c5760026024351015610c9c576044356001600160a01b0381169003610c9c57806064351660643503610c9c5767ffffffffffffffff608435818111610c9c5736602382011215610c9c578060040135918211610ca157604051916100c960208260051b01846112c7565b80835260208301913660248360061b83010111610c9c579160248301925b60248360061b8201018410610c5457858561010061303c565b61010b60043561142c565b9161012660ff600461011d81356113f7565b01541615611461565b815115610c1a57600a825111610baf5760005b825181101561022f576001600160a01b036101548285612fcb565b515116156101d65760206101688285612fcb565b5101511561017e5761017990612fbc565b610139565b60405162461bcd60e51b815260206004820152602a60248201527f496e76616c696420776974686472617720746f6b656e207061737365643a207a604482015269195c9bc8185b5bdd5b9d60b21b6064820152608490fd5b60405162461bcd60e51b815260206004820152602b60248201527f496e76616c696420776974686472617720746f6b656e207061737365643a207a60448201526a65726f206164647265737360a81b6064820152608490fd5b506000805160206131158339815191525460405163e68f909d60e01b815290839085906103e090849060049082906001600160a01b03165afa92831561058f57600093610b7c575b506008810154928315159384610b71575b5060005b8351811015610b675760006102a2602435611789565b6024351580610b5f575b610a97575b60ff6005850154166102c281611789565b6001811461085a575b6102d481611789565b6107e957600080516020613115833981519152546040805163b6c54a5d60e01b81526002600482015291829060249082906001600160a01b03165afa801561058f576020916000916107ba575b500151905b610331602435611789565b6024356107865760016103456004356113f7565b016001600160a01b036103588589612fcb565b5151166000526020526040600020545b60206103748589612fcb565b510151101561074d5761271061039b610401936020610393878b612fcb565b5101516118f2565b0460206001600160a01b036103b0868a612fcb565b515160608801516001600160a01b031691166103cc8585611766565b60405163a9059cbb60e01b81526001600160a01b03909316600484015260248301529094859190829060009082906044820190565b03925af190811561058f576104256104399261043e9560009161072e575b50611728565b6020610431868a612fcb565b510151612faf565b612faf565b9060009180151580610721575b610640575b6044356001600160a01b03161561059b576000926020916104be9161048a906001600160a01b03610481878c612fcb565b51511692612faf565b60405163a9059cbb60e01b8152604480356001600160a01b0316600483015260248201929092529586938492839190820190565b03925af191821561058f5761053f926104de916000916105605750611728565b6104e9602435611789565b6024356105445760206104fc8287612fcb565b510151600161050c6004356113f7565b016001600160a01b0361051f8489612fcb565b5151166000526020526105386040600020918254612faf565b9055612fbc565b61028c565b60206105508287612fcb565b510151600361050c6004356113f7565b610582915060203d602011610588575b61057a81836112c7565b810190611710565b8961041f565b503d610570565b6040513d6000823e3d90fd5b60ff60046105aa6064356113f7565b0154166105fb5761053f926105f6916105f0604051926105c984611297565b6004358c16845260006020850152606460408501526001600160a01b03610481878c612fcb565b91611cb7565b6104de565b60405162461bcd60e51b815260206004820152601f60248201527f42656e656669636961727920656e646f776d656e7420697320636c6f736564006044820152606490fd5b9150612710610653601f860154846118f2565b04916106b06020846001600160a01b0361066d868b612fcb565b5151601e8a015460405163a9059cbb60e01b81526001600160a01b0390911660048201526024810193909352919384929190911690829060009082906044820190565b03925af190811561058f57600091610702575b506104505760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742046756e647360701b6044820152606490fd5b61071b915060203d6020116105885761057a81836112c7565b896106c3565b50601f850154151561044b565b610747915060203d6020116105885761057a81836112c7565b8c61041f565b60405162461bcd60e51b8152602060048201526011602482015270496e73756666696369656e7446756e647360781b6044820152606490fd5b60036107936004356113f7565b016001600160a01b036107a68589612fcb565b515116600052602052604060002054610368565b6107dc915060403d6040116107e2575b6107d481836112c7565b810190612ff5565b89610321565b503d6107ca565b600080516020613115833981519152546040805163b6c54a5d60e01b81526003600482015291829060249082906001600160a01b03165afa801561058f5760209160009161083b575b50015190610326565b610854915060403d6040116107e2576107d481836112c7565b89610832565b6000871561098f57601b86015480156109215760005b8181106108e457505015610884575b6102cb565b60405162461bcd60e51b815260206004820152603260248201527f53656e6465722061646472657373206973206e6f74206c697374656420696e2060448201527136b0ba3ab934ba3ca0b63637bbb634b9ba1760711b6064820152608490fd5b6108f181601b8a01613024565b905460039190911b1c6001600160a01b03163314610918575b61091390612fbc565b610870565b6001925061090a565b505084546001600160a01b0316331461087f5760405162461bcd60e51b815260206004820152602d60248201527f53656e6465722061646472657373206973206e6f742074686520456e646f776d60448201526c32b73a1026bab63a34b9b4b39760991b6064820152608490fd5b6019860154806109a1575b50506102cb565b60005b818110610a5a5750508015610a47575b156109c057888061099a565b60405162461bcd60e51b815260206004820152605360248201527f53656e6465722061646472657373206973206e6f74206c697374656420696e2060448201527f616c6c6f776c697374656442656e65666963696172696573206f72207468652060648201527222b73237bbb6b2b73a1026bab63a34b9b4b39760691b608482015260a490fd5b5084546001600160a01b031633146109b4565b610a678160198a01613024565b905460039190911b1c6001600160a01b03163314610a8e575b610a8990612fbc565b6109a4565b60019250610a80565b50600160ff600585015416610aab81611789565b03610ad657612710610ad06020610ac28488612fcb565b510151601d860154906118f2565b046102b1565b60246020610ae48387612fcb565b510151600080516020613115833981519152546040805163b6c54a5d60e01b815260048082015293909184919082906001600160a01b03165afa90811561058f576020610ad09261271094600091610b40575b500151906118f2565b610b59915060403d6040116107e2576107d481836112c7565b8b610b37565b5085156102ac565b610b6f6130dd565b005b421015935085610288565b610ba19193506103e03d6103e011610ba8575b610b9981836112c7565b8101906114b7565b9184610277565b503d610b8f565b60405162461bcd60e51b815260206004820152603760248201527f55707065722d6c696d69742069732074656e2831302920756e6971756520455260448201527f43323020746f6b656e73207065722077697468647261770000000000000000006064820152608490fd5b60405162461bcd60e51b8152602060048201526012602482015271139bc81d1bdad95b9cc81c1c9bdd9a59195960721b6044820152606490fd5b604084360312610c9c57604051610c6a8161127b565b84356001600160a01b0381168103610c9c576024938260209260409452828801358382015281520194019391506100e7565b600080fd5b634e487b7160e01b600052604160045260246000fd5b6060366003190112610c9c57610ccc366112e9565b610cd461303c565b341561104a5760405190610140820182811067ffffffffffffffff821117610ca15760405260018060a01b0390817ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d455416835281604051938460007ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d468054610d5b81611327565b808552916001918083169081156110235750600114610fc1575b50505090610d849103866112c7565b60209485820152610ed560ff600461011d600080516020613115833981519152546040860195878216875263ffffffff809260a01c1660608201527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d48546080820152877ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d49541660a0820152877ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4a541660c0820152847ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4b5489811660e084015260a01c16151561010082015261012060405191610e7f8361127b565b897ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4c541683527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4d548d84015201528751166113f7565b511691604051809363e68f909d60e01b82528160046103e09687935afa93841561058f57600094610f9f575b50508383948261028060049601511660405195868092631d727ceb60e21b825234905af193841561058f57600094610f6e575b50610b67947fa848a32340995bb12bf943995fb951bb27b67c71c4ffa1f4df96cfc7eab0d11b61034092604051878152a101511690611cb7565b9080945081813d8311610f98575b610f8681836112c7565b81010312610c9c575192610b67610f34565b503d610f7c565b600494509081610fba92903d10610ba857610b9981836112c7565b9285610f01565b600090815292507febb685a78b10aaac3bab71ad259c60cb6817d2de30fb2196f0835ca255c2a8975b828410611003575050508101602001610d848880610d75565b602092959650819450805483858c01015201910190928792879594610fea565b915050610d84949350602092915060ff191682840152151560051b82010190918880610d75565b60405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908105b5bdd5b9d60921b6044820152606490fd5b34610c9c5760a0366003190112610c9c5761109a366112e9565b6001600160a01b039060643582811691828203610c9c57608435926110bd61303c565b801561123e5763ffffffff946110dc60ff600461011d898751166113f7565b60008051602061311583398151915254166040519586916302b05ecb60e11b83528360048401528260246020998a935afa91821561058f5760009261121f575b5081156111da575b50156111955793806000956064604051809881936323b872dd60e01b83523360048401523060248401528960448401525af1801561058f57610b679561117392600092611178575b5050611728565b611cb7565b61118e9250803d106105885761057a81836112c7565b868061116c565b60405162461bcd60e51b815260048101869052601e60248201527f4e6f7420696e20616e20416363657074656420546f6b656e73204c69737400006044820152606490fd5b90508251166000527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d448552604060002081600052855260ff6040600020541686611124565b611237919250873d89116105885761057a81836112c7565b908761111c565b60405162461bcd60e51b8152602060048201526015602482015274496e76616c696420546f6b656e204164647265737360581b6044820152606490fd5b6040810190811067ffffffffffffffff821117610ca157604052565b6060810190811067ffffffffffffffff821117610ca157604052565b67ffffffffffffffff8111610ca157604052565b90601f8019910116810190811067ffffffffffffffff821117610ca157604052565b6060906003190112610c9c576040519061130282611297565b8160043563ffffffff81168103610c9c57815260243560208201526040604435910152565b90600182811c92168015611357575b602083101461134157565b634e487b7160e01b600052602260045260246000fd5b91607f1691611336565b906000929180549161137283611327565b9182825260019384811690816000146113d45750600114611394575b50505050565b90919394506000526020928360002092846000945b8386106113c057505050500101903880808061138e565b8054858701830152940193859082016113a9565b9294505050602093945060ff191683830152151560051b0101903880808061138e565b63ffffffff166000527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d41602052604060002090565b63ffffffff166000527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d42602052604060002090565b1561146857565b60405162461bcd60e51b8152602060048201526013602482015272115b991bdddb595b9d081a5cc818db1bdcd959606a1b6044820152606490fd5b51906001600160a01b0382168203610c9c57565b8091036103e08112610c9c576040918251926103a0928385019085821067ffffffffffffffff831117610ca15760609183526114f2846114a3565b8652611500602085016114a3565b60208701526115108385016114a3565b8387015261151f8285016114a3565b8287015261152f608085016114a3565b608087015261154060a085016114a3565b60a087015261155160c085016114a3565b60c087015261156260e085016114a3565b60e08701526101006115758186016114a3565b908701526101206115878186016114a3565b908701526101406115998186016114a3565b908701526101606115ab8186016114a3565b908701526101806115bd8186016114a3565b9087015261019f190112610c9c5761170991816116ff6103c09351956115e287611297565b6101a0968785015181526101c0978886015160208301526101e0948587015190830152890152610200966116178886016114a3565b908901526102209261162a8486016114a3565b908901526102409661163d8886016114a3565b908901526102609283850151908901526102809661165c8886016114a3565b908901526102a09261166f8486016114a3565b908901526102c0966116828886016114a3565b908901526102e0926116958486016114a3565b90890152610300966116a88886016114a3565b90890152610320926116bb8486016114a3565b90890152610340966116ce8886016114a3565b90890152610360926116e18486016114a3565b90890152610380966116f48886016114a3565b9089015283016114a3565b90860152016114a3565b9082015290565b90816020910312610c9c57518015158103610c9c5790565b1561172f57565b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606490fd5b9190820180921161177357565b634e487b7160e01b600052601160045260246000fd5b6002111561179357565b634e487b7160e01b600052602160045260246000fd5b9190826040910312610c9c576020825192015190565b8181106117ca575050565b600081556001016117bf565b908082146118ee576117e88154611327565b9067ffffffffffffffff8211610ca15781906118048454611327565b601f81116118b1575b50600090601f83116001146118455760009261183a575b50508160011b916000199060031b1c1916179055565b015490503880611824565b81526020808220858352818320935090601f1985169083905b82821061189857505090846001959493921061187f575b505050811b019055565b015460001960f88460031b161c19169055388080611875565b849581929585015481556001809101960194019061185e565b6118de90856000526020600020601f850160051c810191602086106118e4575b601f0160051c01906117bf565b3861180d565b90915081906118d1565b5050565b8181029291811591840414171561177357565b9181811061191257505050565b61192892600052602060002091820191016117bf565b565b8181146118ee5781549167ffffffffffffffff8311610ca157600160401b8311610ca15761195d83835481855584611905565b60005260206000209060005260206000208154916000925b848410611983575050505050565b6001809192019384549281850155019290611975565b8181146118ee57815491600160401b8311610ca15781548383558084106119fa575b506000526020600020906000526020600020906000905b8382106119df5750505050565b806119ec600192856117d6565b9281019291810191016119d2565b600083815260208581832093840193015b838110611a1a575050506119bb565b8083611a2860019354611327565b80611a36575b505001611a0b565b601f8082118514611a4d57505081555b8338611a2e565b611a6690848452868420920160051c82018583016117bf565b81835555611a46565b818103611a7a575050565b60038083611a8b6119289585611999565b611a9b600182016001860161192a565b611aab6002820160028601611999565b01910161192a565b8181146118ee5781549167ffffffffffffffff8311610ca157600160401b8311610ca157611ae683835481855584611905565b60005260206000209060005260206000208154916000925b848410611b0c575050505050565b600191820180546001600160a01b0390921684860155939091019290611afe565b90808203611b39575050565b805482546001600160a01b0319166001600160a01b0391909116178255600190810154910155565b90815480825260208092019260005281600020916000905b828210611b87575050505090565b835485529384019360019384019390910190611b79565b908154808252602080920191828260051b84019460005281600020936000915b848310611bce5750505050505090565b909192939495846001611be7838583950387528a611361565b9801930193019194939290611bbe565b906003611c469260808352611c37611c26611c156080860184611b9e565b858103602087015260018401611b61565b848103604086015260028301611b9e565b92606081850391015201611b61565b90565b90815480825260208092019260005281600020916000905b828210611c6f575050505090565b83546001600160a01b031685529384019360019384019390910190611c61565b805460ff161515825260018101546001600160a01b0316602083015260020154604090910152565b9291906000611ccc63ffffffff86511661142c565b916001600160a01b03811615612f74576064611cf16020880151604089015190611766565b03612f40576000805160206131158339815191525460405163e68f909d60e01b815291906103e090839060049082906001600160a01b03165afa918215612f35578392612f12575b50602184015480612e35575b5060208701519460408801516101a0968785015160018060a01b0360208701511615612e005760208601516001600160a01b03163303612c90575b50611d9591611d9c91612710938491866118f2565b04936118f2565b049281612aeb575b5073__$2e6ee47b30d794e0597b4af30f16ddb84c$__90611dcb63ffffffff8a51166113f7565b90823b15612ac457604051631bccc68560e21b80825260048201939093526001600160a01b038516602482015260448101919091528581606481865af48015612ae057908691612ac8575b50506002611e2a63ffffffff8b51166113f7565b0190823b15612ac45760405190815260048101919091526001600160a01b039290921660248301526044820192909252908290829060649082905af48015612ab957612aa2575b505063ffffffff84611ea7827f28c1b2f18a3e71d2e6df5b0732ff252e57dc097525c7b3a6aa087522506a5b369697511661142c565b8381036122bf575b50511690605b6120cc60405194859485526040602086015260018060a01b038454166040860152610b8060608601526120b86120a4611ef5610bc0880160018801611361565b9263ffffffff611fc1611fad611f8e611f7a8b8d60c0611f42603f199c8d84820301608085015260408152611f306040820160028701611b61565b90602081830391015260038501611b61565b92600481015460a084015260ff60805260056080519101541691611f6583611789565b01528d81038a0160e08f015260068d01611361565b8c810389016101008e015260078c01611361565b60088b01546101208d0152878c8203016101408d015260098b01611bf7565b868b8203016101608c0152600d8a01611bf7565b601189015460808051821615156101808d0152600882901c8416948c0194909452602881901c83166101c08c01528351604882901c1615156101e08c0152605081901c83166102008c015260701c9091166102208a0152815160128901541615156102408a015260138801546102608a015260148801546102808a015260158801546001600160a01b039081166102a08b0152601689015481166102c08b015260178901548082166102e08c0152925160a09390931c90921615156103008a01526018880154909116610320890152878103840161034089015260198701611c49565b8287820301610360880152601a8601611c49565b9085820301610380860152601b8401611c49565b601c8301546001600160a01b03166103a0850152601d8301546103c085015291601e8101546001600160a01b03166103e0850152601f81015461040085015260208101546001600160a01b0316610420850152602181015461044085015260228101546001600160a01b0316610460850152602381015461048085015261215a6104a0850160248301611c8f565b61216b610500850160278301611c8f565b61217c6105608501602a8301611c8f565b61218d6105c08501602d8301611c8f565b61219e610620850160308301611c8f565b6121af610680850160338301611c8f565b6121c06106e0850160368301611c8f565b6121d1610740850160398301611c8f565b6121e26107a08501603c8301611c8f565b6121f36108008501603f8301611c8f565b612204610860850160428301611c8f565b6122156108c0850160458301611c8f565b612226610920850160488301611c8f565b6122376109808501604b8301611c8f565b6122486109e08501604e8301611c8f565b612259610a40850160518301611c8f565b61226a610aa0850160548301611c8f565b605781015463ffffffff8116610b008601526080519060201c161515610b208501526122b2610b40850160588301600260409180548452600181015460208501520154910152565b0154610ba08301520390a1565b60018060a01b038454166bffffffffffffffffffffffff60a01b90818354161782556122f160018601600184016117d6565b6002820160028601808203612a82575b505060048501546004830155600582019060ff918260058801541661232581611789565b60ff1982541617905561233e60068701600685016117d6565b61234e60078701600785016117d6565b600886015460088401556123686009870160098501611a6f565b612378600d8701600d8501611a6f565b60118301601187018082036129b1575b50506123a982601288015416601285019060ff801983541691151516179055565b60138601546013840155601486015460148401556015830160018060a01b03601588015416828254161790556016830160018060a01b0360168801541682825416179055601783016017870160018060a01b03815416825491818584161784558560ff60a01b915460a01c16151560a01b16916affffffffffffffffffffff60a81b1617179055601883019060018060a01b03601888015416908254161790556124596019860160198401611ab3565b612469601a8601601a8401611ab3565b612479601b8601601b8401611ab3565b612489601c8601601c8401611b2d565b612499601e8601601e8401611b2d565b6124a96020860160208401611b2d565b6124b96022860160228401611b2d565b602482016024860190828282141580612548575b505050506057820190605786019064ff00000000868354169184549383891986161786555460201c16151560201b169164ffffffffff191617179055605881016058850180820361252a575b5050605b8085015491015538611eaf565b54905560598401546059820155605a840154605a8201553880612519565b612983575b50505060278201602786019082828203612955575b505050602a8201602a86019082828203612927575b505050602d8201602d860190828282036128f9575b505050603082016030860190828282036128cb575b5050506033820160338601908282820361289d575b5050506036820160368601908282820361286f575b50505060398201603986019082828203612841575b505050603c8201603c86019082828203612813575b505050603f8201603f860190828282036127e5575b505050604282016042860190828282036127b7575b50505060458201604586019082828203612789575b5050506048820160488601908282820361275b575b505050604b8201604b8601908282820361272d575b505050604e8201604e860190828282036126ff575b505050605182016051860190828282036126d1575b505050605482016054860190828282036126a3575b816124cd565b6126b992541660ff801983541691151516179055565b6126c96055860160558401611b2d565b38808261269d565b6126e792541660ff801983541691151516179055565b6126f76052860160528401611b2d565b388082612688565b61271592541660ff801983541691151516179055565b612725604f8601604f8401611b2d565b388082612673565b61274392541660ff801983541691151516179055565b612753604c8601604c8401611b2d565b38808261265e565b61277192541660ff801983541691151516179055565b6127816049860160498401611b2d565b388082612649565b61279f92541660ff801983541691151516179055565b6127af6046860160468401611b2d565b388082612634565b6127cd92541660ff801983541691151516179055565b6127dd6043860160438401611b2d565b38808261261f565b6127fb92541660ff801983541691151516179055565b61280b6040860160408401611b2d565b38808261260a565b61282992541660ff801983541691151516179055565b612839603d8601603d8401611b2d565b3880826125f5565b61285792541660ff801983541691151516179055565b612867603a8601603a8401611b2d565b3880826125e0565b61288592541660ff801983541691151516179055565b6128956037860160378401611b2d565b3880826125cb565b6128b392541660ff801983541691151516179055565b6128c36034860160348401611b2d565b3880826125b6565b6128e192541660ff801983541691151516179055565b6128f16031860160318401611b2d565b3880826125a1565b61290f92541660ff801983541691151516179055565b61291f602e8601602e8401611b2d565b38808261258c565b61293d92541660ff801983541691151516179055565b61294d602b8601602b8401611b2d565b388082612577565b61296b92541660ff801983541691151516179055565b61297b6028860160288401611b2d565b388082612562565b61299992541660ff801983541691151516179055565b6129a96025860160258401611b2d565b38808261254d565b6129ca84825416839060ff801983541691151516179055565b80549064ffffffff00835492168064ffffffff0019841617845568ffffffff0000000000825416808268ffffffffffffffff001986161717855569ff00000000000000000087845460481c16151560481b1691828169ffffffffffffffffff001987161783171786558a60501b8454169384826dffffffffffffffffffffffffff0019881617841785171787558b60701b9054169471ffffffffffffffffffffffffffffffffff001916171717171790553880612388565b612a8b9161192a565b612a9b600386016003840161192a565b3880612301565b612aac82916112b3565b612ab65780611e71565b80fd5b6040513d84823e3d90fd5b8580fd5b612ad1906112b3565b612adc578438611e16565b8480fd5b6040513d88823e3d90fd5b60ff600587015416612afc81611789565b801580612c79575b15612bb9575061016081015189516101c0909201516001600160a01b039081169291169063ffffffff16813b15612bb55760405163d61e991b60e01b815263ffffffff9091166004820152602481018490523260448201526001600160a01b039092166064830152859082908183816084810103925af18015612baa57908591612b92575b50505b38611da4565b612b9b906112b3565b612ba6578338612b89565b8380fd5b6040513d87823e3d90fd5b8680fd5b60019150612bc681611789565b1480612c63575b15612b8c576018850154885160178701546001600160a01b0390811692169063ffffffff16813b15612bb55760405163d61e991b60e01b815263ffffffff9091166004820152602481018490523260448201526001600160a01b039092166064830152859082908183816084810103925af18015612baa57612c50575b50612b8c565b612c5c909491946112b3565b9238612c4a565b5060188501546001600160a01b03161515612bcd565b506101608201516001600160a01b03161515612b04565b9160ff600589015416612ca281611789565b612d5a5760ff605789015460201c1691604080519463b9fb75c560e01b865280516004870152602081015160248701520151604485015260648401526084830152151560a482015260408160c48173__$2e6ee47b30d794e0597b4af30f16ddb84c$__5af48015612baa57611d9591611d9c9187918891612d29575b50905b915091611d80565b9050612d4d915060403d604011612d53575b612d4581836112c7565b8101906117a9565b38612d1e565b503d612d3b565b605788015460405163b9fb75c560e01b815260588a0154600482015260598a01546024820152605a8a01546044820152935060201c60ff169160648401526084830152151560a482015260408160c48173__$2e6ee47b30d794e0597b4af30f16ddb84c$__5af48015612baa57611d9591611d9c9187918891612ddf575b5090612d21565b9050612dfa915060403d604011612d5357612d4581836112c7565b38612dd8565b60405162461bcd60e51b815260206004820152600d60248201526c139bc8125b99195e08119d5b99609a1b6044820152606490fd5b6020612e52612710612e4a612e88948a6118f2565b048098612faf565b8187015460405163a9059cbb60e01b81526001600160a01b03909116600482015260248101989098529691829081906044820190565b0381876001600160a01b0387165af1908115612f07578491612ee8575b5015612eb15738611d45565b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8811985a5b1959608a1b6044820152606490fd5b612f01915060203d6020116105885761057a81836112c7565b38612ea5565b6040513d86823e3d90fd5b612f2e9192506103e03d6103e011610ba857610b9981836112c7565b9038611d39565b6040513d85823e3d90fd5b60405162461bcd60e51b815260206004820152600c60248201526b125b9d985b1a5914dc1b1a5d60a21b6044820152606490fd5b60405162461bcd60e51b815260206004820152601360248201527224b73b30b634b21022a9219918103a37b5b2b760691b6044820152606490fd5b9190820391821161177357565b60001981146117735760010190565b8051821015612fdf5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b90816040910312610c9c5760206040519161300f8361127b565b613018816114a3565b83520151602082015290565b8054821015612fdf5760005260206000200190600090565b7ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4b805460ff8160a01c161580156130d4575b1561308f5733300361307e575050565b60ff60a01b1916600160a01b179055565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b5033301461306e565b3330036130e657565b7ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4b805460ff60a01b1916905556fef42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d47a264697066735822122026f90f0a195c3c4680665514f247f3777701cca2919600d43c98a4380b3689cb64736f6c63430008120033"; + "0x608080604052346100165761316a908161001c8239f35b600080fdfe60a0604052600436101561001257600080fd5b60003560e01c80631b13439114611080578063244dbab014610cb75763f91a34c11461003d57600080fd5b34610c9c5760a0366003190112610c9c5763ffffffff806004351660043503610c9c5760026024351015610c9c576044356001600160a01b0381169003610c9c57806064351660643503610c9c5767ffffffffffffffff608435818111610c9c5736602382011215610c9c578060040135918211610ca157604051916100c960208260051b01846112c7565b80835260208301913660248360061b83010111610c9c579160248301925b60248360061b8201018410610c5457858561010061303c565b61010b60043561142c565b9161012660ff600461011d81356113f7565b01541615611461565b815115610c1a57600a825111610baf5760005b825181101561022f576001600160a01b036101548285612fcb565b515116156101d65760206101688285612fcb565b5101511561017e5761017990612fbc565b610139565b60405162461bcd60e51b815260206004820152602a60248201527f496e76616c696420776974686472617720746f6b656e207061737365643a207a604482015269195c9bc8185b5bdd5b9d60b21b6064820152608490fd5b60405162461bcd60e51b815260206004820152602b60248201527f496e76616c696420776974686472617720746f6b656e207061737365643a207a60448201526a65726f206164647265737360a81b6064820152608490fd5b506000805160206131158339815191525460405163e68f909d60e01b815290839085906103e090849060049082906001600160a01b03165afa92831561058f57600093610b7c575b506008810154928315159384610b71575b5060005b8351811015610b675760006102a2602435611789565b6024351580610b5f575b610a97575b60ff6005850154166102c281611789565b6001811461085a575b6102d481611789565b6107e957600080516020613115833981519152546040805163b6c54a5d60e01b81526002600482015291829060249082906001600160a01b03165afa801561058f576020916000916107ba575b500151905b610331602435611789565b6024356107865760016103456004356113f7565b016001600160a01b036103588589612fcb565b5151166000526020526040600020545b60206103748589612fcb565b510151101561074d5761271061039b610401936020610393878b612fcb565b5101516118f2565b0460206001600160a01b036103b0868a612fcb565b515160608801516001600160a01b031691166103cc8585611766565b60405163a9059cbb60e01b81526001600160a01b03909316600484015260248301529094859190829060009082906044820190565b03925af190811561058f576104256104399261043e9560009161072e575b50611728565b6020610431868a612fcb565b510151612faf565b612faf565b9060009180151580610721575b610640575b6044356001600160a01b03161561059b576000926020916104be9161048a906001600160a01b03610481878c612fcb565b51511692612faf565b60405163a9059cbb60e01b8152604480356001600160a01b0316600483015260248201929092529586938492839190820190565b03925af191821561058f5761053f926104de916000916105605750611728565b6104e9602435611789565b6024356105445760206104fc8287612fcb565b510151600161050c6004356113f7565b016001600160a01b0361051f8489612fcb565b5151166000526020526105386040600020918254612faf565b9055612fbc565b61028c565b60206105508287612fcb565b510151600361050c6004356113f7565b610582915060203d602011610588575b61057a81836112c7565b810190611710565b8961041f565b503d610570565b6040513d6000823e3d90fd5b60ff60046105aa6064356113f7565b0154166105fb5761053f926105f6916105f0604051926105c984611297565b6004358c16845260006020850152606460408501526001600160a01b03610481878c612fcb565b91611cb7565b6104de565b60405162461bcd60e51b815260206004820152601f60248201527f42656e656669636961727920656e646f776d656e7420697320636c6f736564006044820152606490fd5b9150612710610653601f860154846118f2565b04916106b06020846001600160a01b0361066d868b612fcb565b5151601e8a015460405163a9059cbb60e01b81526001600160a01b0390911660048201526024810193909352919384929190911690829060009082906044820190565b03925af190811561058f57600091610702575b506104505760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742046756e647360701b6044820152606490fd5b61071b915060203d6020116105885761057a81836112c7565b896106c3565b50601f850154151561044b565b610747915060203d6020116105885761057a81836112c7565b8c61041f565b60405162461bcd60e51b8152602060048201526011602482015270496e73756666696369656e7446756e647360781b6044820152606490fd5b60036107936004356113f7565b016001600160a01b036107a68589612fcb565b515116600052602052604060002054610368565b6107dc915060403d6040116107e2575b6107d481836112c7565b810190612ff5565b89610321565b503d6107ca565b600080516020613115833981519152546040805163b6c54a5d60e01b81526003600482015291829060249082906001600160a01b03165afa801561058f5760209160009161083b575b50015190610326565b610854915060403d6040116107e2576107d481836112c7565b89610832565b6000871561098f57601b86015480156109215760005b8181106108e457505015610884575b6102cb565b60405162461bcd60e51b815260206004820152603260248201527f53656e6465722061646472657373206973206e6f74206c697374656420696e2060448201527136b0ba3ab934ba3ca0b63637bbb634b9ba1760711b6064820152608490fd5b6108f181601b8a01613024565b905460039190911b1c6001600160a01b03163314610918575b61091390612fbc565b610870565b6001925061090a565b505084546001600160a01b0316331461087f5760405162461bcd60e51b815260206004820152602d60248201527f53656e6465722061646472657373206973206e6f742074686520456e646f776d60448201526c32b73a1026bab63a34b9b4b39760991b6064820152608490fd5b6019860154806109a1575b50506102cb565b60005b818110610a5a5750508015610a47575b156109c057888061099a565b60405162461bcd60e51b815260206004820152605360248201527f53656e6465722061646472657373206973206e6f74206c697374656420696e2060448201527f616c6c6f776c697374656442656e65666963696172696573206f72207468652060648201527222b73237bbb6b2b73a1026bab63a34b9b4b39760691b608482015260a490fd5b5084546001600160a01b031633146109b4565b610a678160198a01613024565b905460039190911b1c6001600160a01b03163314610a8e575b610a8990612fbc565b6109a4565b60019250610a80565b50600160ff600585015416610aab81611789565b03610ad657612710610ad06020610ac28488612fcb565b510151601d860154906118f2565b046102b1565b60246020610ae48387612fcb565b510151600080516020613115833981519152546040805163b6c54a5d60e01b815260048082015293909184919082906001600160a01b03165afa90811561058f576020610ad09261271094600091610b40575b500151906118f2565b610b59915060403d6040116107e2576107d481836112c7565b8b610b37565b5085156102ac565b610b6f6130dd565b005b421015935085610288565b610ba19193506103e03d6103e011610ba8575b610b9981836112c7565b8101906114b7565b9184610277565b503d610b8f565b60405162461bcd60e51b815260206004820152603760248201527f55707065722d6c696d69742069732074656e2831302920756e6971756520455260448201527f43323020746f6b656e73207065722077697468647261770000000000000000006064820152608490fd5b60405162461bcd60e51b8152602060048201526012602482015271139bc81d1bdad95b9cc81c1c9bdd9a59195960721b6044820152606490fd5b604084360312610c9c57604051610c6a8161127b565b84356001600160a01b0381168103610c9c576024938260209260409452828801358382015281520194019391506100e7565b600080fd5b634e487b7160e01b600052604160045260246000fd5b6060366003190112610c9c57610ccc366112e9565b610cd461303c565b341561104a5760405190610140820182811067ffffffffffffffff821117610ca15760405260018060a01b0390817ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d455416835281604051938460007ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d468054610d5b81611327565b808552916001918083169081156110235750600114610fc1575b50505090610d849103866112c7565b60209485820152610ed560ff600461011d600080516020613115833981519152546040860195878216875263ffffffff809260a01c1660608201527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d48546080820152877ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d49541660a0820152877ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4a541660c0820152847ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4b5489811660e084015260a01c16151561010082015261012060405191610e7f8361127b565b897ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4c541683527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4d548d84015201528751166113f7565b511691604051809363e68f909d60e01b82528160046103e09687935afa93841561058f57600094610f9f575b50508383948261028060049601511660405195868092631d727ceb60e21b825234905af193841561058f57600094610f6e575b50610b67947fa848a32340995bb12bf943995fb951bb27b67c71c4ffa1f4df96cfc7eab0d11b61034092604051878152a101511690611cb7565b9080945081813d8311610f98575b610f8681836112c7565b81010312610c9c575192610b67610f34565b503d610f7c565b600494509081610fba92903d10610ba857610b9981836112c7565b9285610f01565b600090815292507febb685a78b10aaac3bab71ad259c60cb6817d2de30fb2196f0835ca255c2a8975b828410611003575050508101602001610d848880610d75565b602092959650819450805483858c01015201910190928792879594610fea565b915050610d84949350602092915060ff191682840152151560051b82010190918880610d75565b60405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908105b5bdd5b9d60921b6044820152606490fd5b34610c9c5760a0366003190112610c9c5761109a366112e9565b6001600160a01b039060643582811691828203610c9c57608435926110bd61303c565b801561123e5763ffffffff946110dc60ff600461011d898751166113f7565b60008051602061311583398151915254166040519586916302b05ecb60e11b83528360048401528260246020998a935afa91821561058f5760009261121f575b5081156111da575b50156111955793806000956064604051809881936323b872dd60e01b83523360048401523060248401528960448401525af1801561058f57610b679561117392600092611178575b5050611728565b611cb7565b61118e9250803d106105885761057a81836112c7565b868061116c565b60405162461bcd60e51b815260048101869052601e60248201527f4e6f7420696e20616e20416363657074656420546f6b656e73204c69737400006044820152606490fd5b90508251166000527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d448552604060002081600052855260ff6040600020541686611124565b611237919250873d89116105885761057a81836112c7565b908761111c565b60405162461bcd60e51b8152602060048201526015602482015274496e76616c696420546f6b656e204164647265737360581b6044820152606490fd5b6040810190811067ffffffffffffffff821117610ca157604052565b6060810190811067ffffffffffffffff821117610ca157604052565b67ffffffffffffffff8111610ca157604052565b90601f8019910116810190811067ffffffffffffffff821117610ca157604052565b6060906003190112610c9c576040519061130282611297565b8160043563ffffffff81168103610c9c57815260243560208201526040604435910152565b90600182811c92168015611357575b602083101461134157565b634e487b7160e01b600052602260045260246000fd5b91607f1691611336565b906000929180549161137283611327565b9182825260019384811690816000146113d45750600114611394575b50505050565b90919394506000526020928360002092846000945b8386106113c057505050500101903880808061138e565b8054858701830152940193859082016113a9565b9294505050602093945060ff191683830152151560051b0101903880808061138e565b63ffffffff166000527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d41602052604060002090565b63ffffffff166000527ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d42602052604060002090565b1561146857565b60405162461bcd60e51b8152602060048201526013602482015272115b991bdddb595b9d081a5cc818db1bdcd959606a1b6044820152606490fd5b51906001600160a01b0382168203610c9c57565b8091036103e08112610c9c576040918251926103a0928385019085821067ffffffffffffffff831117610ca15760609183526114f2846114a3565b8652611500602085016114a3565b60208701526115108385016114a3565b8387015261151f8285016114a3565b8287015261152f608085016114a3565b608087015261154060a085016114a3565b60a087015261155160c085016114a3565b60c087015261156260e085016114a3565b60e08701526101006115758186016114a3565b908701526101206115878186016114a3565b908701526101406115998186016114a3565b908701526101606115ab8186016114a3565b908701526101806115bd8186016114a3565b9087015261019f190112610c9c5761170991816116ff6103c09351956115e287611297565b6101a0968785015181526101c0978886015160208301526101e0948587015190830152890152610200966116178886016114a3565b908901526102209261162a8486016114a3565b908901526102409661163d8886016114a3565b908901526102609283850151908901526102809661165c8886016114a3565b908901526102a09261166f8486016114a3565b908901526102c0966116828886016114a3565b908901526102e0926116958486016114a3565b90890152610300966116a88886016114a3565b90890152610320926116bb8486016114a3565b90890152610340966116ce8886016114a3565b90890152610360926116e18486016114a3565b90890152610380966116f48886016114a3565b9089015283016114a3565b90860152016114a3565b9082015290565b90816020910312610c9c57518015158103610c9c5790565b1561172f57565b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606490fd5b9190820180921161177357565b634e487b7160e01b600052601160045260246000fd5b6002111561179357565b634e487b7160e01b600052602160045260246000fd5b9190826040910312610c9c576020825192015190565b8181106117ca575050565b600081556001016117bf565b908082146118ee576117e88154611327565b9067ffffffffffffffff8211610ca15781906118048454611327565b601f81116118b1575b50600090601f83116001146118455760009261183a575b50508160011b916000199060031b1c1916179055565b015490503880611824565b81526020808220858352818320935090601f1985169083905b82821061189857505090846001959493921061187f575b505050811b019055565b015460001960f88460031b161c19169055388080611875565b849581929585015481556001809101960194019061185e565b6118de90856000526020600020601f850160051c810191602086106118e4575b601f0160051c01906117bf565b3861180d565b90915081906118d1565b5050565b8181029291811591840414171561177357565b9181811061191257505050565b61192892600052602060002091820191016117bf565b565b8181146118ee5781549167ffffffffffffffff8311610ca157600160401b8311610ca15761195d83835481855584611905565b60005260206000209060005260206000208154916000925b848410611983575050505050565b6001809192019384549281850155019290611975565b8181146118ee57815491600160401b8311610ca15781548383558084106119fa575b506000526020600020906000526020600020906000905b8382106119df5750505050565b806119ec600192856117d6565b9281019291810191016119d2565b600083815260208581832093840193015b838110611a1a575050506119bb565b8083611a2860019354611327565b80611a36575b505001611a0b565b601f8082118514611a4d57505081555b8338611a2e565b611a6690848452868420920160051c82018583016117bf565b81835555611a46565b818103611a7a575050565b60038083611a8b6119289585611999565b611a9b600182016001860161192a565b611aab6002820160028601611999565b01910161192a565b8181146118ee5781549167ffffffffffffffff8311610ca157600160401b8311610ca157611ae683835481855584611905565b60005260206000209060005260206000208154916000925b848410611b0c575050505050565b600191820180546001600160a01b0390921684860155939091019290611afe565b90808203611b39575050565b805482546001600160a01b0319166001600160a01b0391909116178255600190810154910155565b90815480825260208092019260005281600020916000905b828210611b87575050505090565b835485529384019360019384019390910190611b79565b908154808252602080920191828260051b84019460005281600020936000915b848310611bce5750505050505090565b909192939495846001611be7838583950387528a611361565b9801930193019194939290611bbe565b906003611c469260808352611c37611c26611c156080860184611b9e565b858103602087015260018401611b61565b848103604086015260028301611b9e565b92606081850391015201611b61565b90565b90815480825260208092019260005281600020916000905b828210611c6f575050505090565b83546001600160a01b031685529384019360019384019390910190611c61565b805460ff161515825260018101546001600160a01b0316602083015260020154604090910152565b9291906000611ccc63ffffffff86511661142c565b916001600160a01b03811615612f74576064611cf16020880151604089015190611766565b03612f40576000805160206131158339815191525460405163e68f909d60e01b815291906103e090839060049082906001600160a01b03165afa918215612f35578392612f12575b50602184015480612e35575b5060208701519460408801516101a0968785015160018060a01b0360208701511615612e005760208601516001600160a01b03163303612c90575b50611d9591611d9c91612710938491866118f2565b04936118f2565b049281612aeb575b5073__$2e6ee47b30d794e0597b4af30f16ddb84c$__90611dcb63ffffffff8a51166113f7565b90823b15612ac457604051631bccc68560e21b80825260048201939093526001600160a01b038516602482015260448101919091528581606481865af48015612ae057908691612ac8575b50506002611e2a63ffffffff8b51166113f7565b0190823b15612ac45760405190815260048101919091526001600160a01b039290921660248301526044820192909252908290829060649082905af48015612ab957612aa2575b505063ffffffff84611ea7827f28c1b2f18a3e71d2e6df5b0732ff252e57dc097525c7b3a6aa087522506a5b369697511661142c565b8381036122bf575b50511690605b6120cc60405194859485526040602086015260018060a01b038454166040860152610b8060608601526120b86120a4611ef5610bc0880160018801611361565b9263ffffffff611fc1611fad611f8e611f7a8b8d60c0611f42603f199c8d84820301608085015260408152611f306040820160028701611b61565b90602081830391015260038501611b61565b92600481015460a084015260ff60805260056080519101541691611f6583611789565b01528d81038a0160e08f015260068d01611361565b8c810389016101008e015260078c01611361565b60088b01546101208d0152878c8203016101408d015260098b01611bf7565b868b8203016101608c0152600d8a01611bf7565b601189015460808051821615156101808d0152600882901c8416948c0194909452602881901c83166101c08c01528351604882901c1615156101e08c0152605081901c83166102008c015260701c9091166102208a0152815160128901541615156102408a015260138801546102608a015260148801546102808a015260158801546001600160a01b039081166102a08b0152601689015481166102c08b015260178901548082166102e08c0152925160a09390931c90921615156103008a01526018880154909116610320890152878103840161034089015260198701611c49565b8287820301610360880152601a8601611c49565b9085820301610380860152601b8401611c49565b601c8301546001600160a01b03166103a0850152601d8301546103c085015291601e8101546001600160a01b03166103e0850152601f81015461040085015260208101546001600160a01b0316610420850152602181015461044085015260228101546001600160a01b0316610460850152602381015461048085015261215a6104a0850160248301611c8f565b61216b610500850160278301611c8f565b61217c6105608501602a8301611c8f565b61218d6105c08501602d8301611c8f565b61219e610620850160308301611c8f565b6121af610680850160338301611c8f565b6121c06106e0850160368301611c8f565b6121d1610740850160398301611c8f565b6121e26107a08501603c8301611c8f565b6121f36108008501603f8301611c8f565b612204610860850160428301611c8f565b6122156108c0850160458301611c8f565b612226610920850160488301611c8f565b6122376109808501604b8301611c8f565b6122486109e08501604e8301611c8f565b612259610a40850160518301611c8f565b61226a610aa0850160548301611c8f565b605781015463ffffffff8116610b008601526080519060201c161515610b208501526122b2610b40850160588301600260409180548452600181015460208501520154910152565b0154610ba08301520390a1565b60018060a01b038454166bffffffffffffffffffffffff60a01b90818354161782556122f160018601600184016117d6565b6002820160028601808203612a82575b505060048501546004830155600582019060ff918260058801541661232581611789565b60ff1982541617905561233e60068701600685016117d6565b61234e60078701600785016117d6565b600886015460088401556123686009870160098501611a6f565b612378600d8701600d8501611a6f565b60118301601187018082036129b1575b50506123a982601288015416601285019060ff801983541691151516179055565b60138601546013840155601486015460148401556015830160018060a01b03601588015416828254161790556016830160018060a01b0360168801541682825416179055601783016017870160018060a01b03815416825491818584161784558560ff60a01b915460a01c16151560a01b16916affffffffffffffffffffff60a81b1617179055601883019060018060a01b03601888015416908254161790556124596019860160198401611ab3565b612469601a8601601a8401611ab3565b612479601b8601601b8401611ab3565b612489601c8601601c8401611b2d565b612499601e8601601e8401611b2d565b6124a96020860160208401611b2d565b6124b96022860160228401611b2d565b602482016024860190828282141580612548575b505050506057820190605786019064ff00000000868354169184549383891986161786555460201c16151560201b169164ffffffffff191617179055605881016058850180820361252a575b5050605b8085015491015538611eaf565b54905560598401546059820155605a840154605a8201553880612519565b612983575b50505060278201602786019082828203612955575b505050602a8201602a86019082828203612927575b505050602d8201602d860190828282036128f9575b505050603082016030860190828282036128cb575b5050506033820160338601908282820361289d575b5050506036820160368601908282820361286f575b50505060398201603986019082828203612841575b505050603c8201603c86019082828203612813575b505050603f8201603f860190828282036127e5575b505050604282016042860190828282036127b7575b50505060458201604586019082828203612789575b5050506048820160488601908282820361275b575b505050604b8201604b8601908282820361272d575b505050604e8201604e860190828282036126ff575b505050605182016051860190828282036126d1575b505050605482016054860190828282036126a3575b816124cd565b6126b992541660ff801983541691151516179055565b6126c96055860160558401611b2d565b38808261269d565b6126e792541660ff801983541691151516179055565b6126f76052860160528401611b2d565b388082612688565b61271592541660ff801983541691151516179055565b612725604f8601604f8401611b2d565b388082612673565b61274392541660ff801983541691151516179055565b612753604c8601604c8401611b2d565b38808261265e565b61277192541660ff801983541691151516179055565b6127816049860160498401611b2d565b388082612649565b61279f92541660ff801983541691151516179055565b6127af6046860160468401611b2d565b388082612634565b6127cd92541660ff801983541691151516179055565b6127dd6043860160438401611b2d565b38808261261f565b6127fb92541660ff801983541691151516179055565b61280b6040860160408401611b2d565b38808261260a565b61282992541660ff801983541691151516179055565b612839603d8601603d8401611b2d565b3880826125f5565b61285792541660ff801983541691151516179055565b612867603a8601603a8401611b2d565b3880826125e0565b61288592541660ff801983541691151516179055565b6128956037860160378401611b2d565b3880826125cb565b6128b392541660ff801983541691151516179055565b6128c36034860160348401611b2d565b3880826125b6565b6128e192541660ff801983541691151516179055565b6128f16031860160318401611b2d565b3880826125a1565b61290f92541660ff801983541691151516179055565b61291f602e8601602e8401611b2d565b38808261258c565b61293d92541660ff801983541691151516179055565b61294d602b8601602b8401611b2d565b388082612577565b61296b92541660ff801983541691151516179055565b61297b6028860160288401611b2d565b388082612562565b61299992541660ff801983541691151516179055565b6129a96025860160258401611b2d565b38808261254d565b6129ca84825416839060ff801983541691151516179055565b80549064ffffffff00835492168064ffffffff0019841617845568ffffffff0000000000825416808268ffffffffffffffff001986161717855569ff00000000000000000087845460481c16151560481b1691828169ffffffffffffffffff001987161783171786558a60501b8454169384826dffffffffffffffffffffffffff0019881617841785171787558b60701b9054169471ffffffffffffffffffffffffffffffffff001916171717171790553880612388565b612a8b9161192a565b612a9b600386016003840161192a565b3880612301565b612aac82916112b3565b612ab65780611e71565b80fd5b6040513d84823e3d90fd5b8580fd5b612ad1906112b3565b612adc578438611e16565b8480fd5b6040513d88823e3d90fd5b60ff600587015416612afc81611789565b801580612c79575b15612bb9575061016081015189516101c0909201516001600160a01b039081169291169063ffffffff16813b15612bb55760405163d61e991b60e01b815263ffffffff9091166004820152602481018490523260448201526001600160a01b039092166064830152859082908183816084810103925af18015612baa57908591612b92575b50505b38611da4565b612b9b906112b3565b612ba6578338612b89565b8380fd5b6040513d87823e3d90fd5b8680fd5b60019150612bc681611789565b1480612c63575b15612b8c576018850154885160178701546001600160a01b0390811692169063ffffffff16813b15612bb55760405163d61e991b60e01b815263ffffffff9091166004820152602481018490523260448201526001600160a01b039092166064830152859082908183816084810103925af18015612baa57612c50575b50612b8c565b612c5c909491946112b3565b9238612c4a565b5060188501546001600160a01b03161515612bcd565b506101608201516001600160a01b03161515612b04565b9160ff600589015416612ca281611789565b612d5a5760ff605789015460201c1691604080519463b9fb75c560e01b865280516004870152602081015160248701520151604485015260648401526084830152151560a482015260408160c48173__$2e6ee47b30d794e0597b4af30f16ddb84c$__5af48015612baa57611d9591611d9c9187918891612d29575b50905b915091611d80565b9050612d4d915060403d604011612d53575b612d4581836112c7565b8101906117a9565b38612d1e565b503d612d3b565b605788015460405163b9fb75c560e01b815260588a0154600482015260598a01546024820152605a8a01546044820152935060201c60ff169160648401526084830152151560a482015260408160c48173__$2e6ee47b30d794e0597b4af30f16ddb84c$__5af48015612baa57611d9591611d9c9187918891612ddf575b5090612d21565b9050612dfa915060403d604011612d5357612d4581836112c7565b38612dd8565b60405162461bcd60e51b815260206004820152600d60248201526c139bc8125b99195e08119d5b99609a1b6044820152606490fd5b6020612e52612710612e4a612e88948a6118f2565b048098612faf565b8187015460405163a9059cbb60e01b81526001600160a01b03909116600482015260248101989098529691829081906044820190565b0381876001600160a01b0387165af1908115612f07578491612ee8575b5015612eb15738611d45565b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8811985a5b1959608a1b6044820152606490fd5b612f01915060203d6020116105885761057a81836112c7565b38612ea5565b6040513d86823e3d90fd5b612f2e9192506103e03d6103e011610ba857610b9981836112c7565b9038611d39565b6040513d85823e3d90fd5b60405162461bcd60e51b815260206004820152600c60248201526b125b9d985b1a5914dc1b1a5d60a21b6044820152606490fd5b60405162461bcd60e51b815260206004820152601360248201527224b73b30b634b21022a9219918103a37b5b2b760691b6044820152606490fd5b9190820391821161177357565b60001981146117735760010190565b8051821015612fdf5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b90816040910312610c9c5760206040519161300f8361127b565b613018816114a3565b83520151602082015290565b8054821015612fdf5760005260206000200190600090565b7ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4b805460ff8160a01c161580156130d4575b1561308f5733300361307e575050565b60ff60a01b1916600160a01b179055565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b5033301461306e565b3330036130e657565b7ff42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d4b805460ff60a01b1916905556fef42c870234ce1595c214fdf331f4ac5d8ba4c010e9f64d466736c93812624d47a2646970667358221220015fbbc79931fd63f60fcc9ef313f38905120ed3384176a80a46c42979c4fa3864736f6c63430008120033"; type AccountDepositWithdrawEndowmentsConstructorParams = | [linkLibraryAddresses: AccountDepositWithdrawEndowmentsLibraryAddresses, signer?: Signer] diff --git a/utils/getContractName.ts b/utils/getContractName.ts index 2c6479558..250f5a11d 100644 --- a/utils/getContractName.ts +++ b/utils/getContractName.ts @@ -1,7 +1,12 @@ import {ContractFactory} from "ethers"; +export function getContractName(factory: ContractFactory): string; export function getContractName( factoryType: new (...args: any) => T +): string; + +export function getContractName( + factory: ContractFactory | (new (...args: any) => T) ): string { - return factoryType.name.replace("__factory", ""); + return factory.constructor.name.replace("__factory", ""); } diff --git a/utils/getFacetFactoryEntries.ts b/utils/getFacetFactoryEntries.ts new file mode 100644 index 000000000..2573e9fdf --- /dev/null +++ b/utils/getFacetFactoryEntries.ts @@ -0,0 +1,110 @@ +import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers"; +import {ContractFactory} from "ethers"; +import { + AccountDeployContract__factory, + AccountDepositWithdrawEndowments__factory, + AccountDonationMatch__factory, + AccountsAllowance__factory, + AccountsCreateEndowment__factory, + AccountsDAOEndowments__factory, + AccountsQueryEndowments__factory, + AccountsSwapEndowments__factory, + AccountsUpdateEndowmentSettingsController__factory, + AccountsUpdateEndowments__factory, + AccountsUpdateStatusEndowments__factory, + AccountsUpdate__factory, + AccountsVaultFacet__factory, + DiamondLoupeFacet__factory, + OwnershipFacet__factory, +} from "typechain-types"; +import {AddressObj} from "utils"; + +// Getting factories instantiated in bulk as they share the deploy/cut creation logic. +export async function getFacetFactoryEntries( + diamondOwner: SignerWithAddress, + corestruct: string +): Promise< + { + factory: ContractFactory; + addressField: keyof AddressObj["accounts"]["facets"]; + }[] +> { + return [ + // no lib + { + addressField: "accountDeployContract", + factory: new AccountDeployContract__factory(diamondOwner), + }, + { + addressField: "accountDonationMatch", + factory: new AccountDonationMatch__factory(diamondOwner), + }, + { + addressField: "accountsDAOEndowments", + factory: new AccountsDAOEndowments__factory(diamondOwner), + }, + {addressField: "accountsUpdate", factory: new AccountsUpdate__factory(diamondOwner)}, + { + addressField: "accountsQueryEndowments", + factory: new AccountsQueryEndowments__factory(diamondOwner), + }, + { + addressField: "accountsUpdateStatusEndowments", + factory: new AccountsUpdateStatusEndowments__factory(diamondOwner), + }, + {addressField: "diamondLoupeFacet", factory: new DiamondLoupeFacet__factory(diamondOwner)}, + {addressField: "ownershipFacet", factory: new OwnershipFacet__factory(diamondOwner)}, + // core lib + { + addressField: "accountDepositWithdrawEndowments", + factory: new AccountDepositWithdrawEndowments__factory( + { + "contracts/core/struct.sol:AngelCoreStruct": corestruct, + }, + diamondOwner + ), + }, + { + addressField: "accountsAllowance", + factory: new AccountsAllowance__factory( + {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, + diamondOwner + ), + }, + { + addressField: "accountsCreateEndowment", + factory: new AccountsCreateEndowment__factory( + {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, + diamondOwner + ), + }, + { + addressField: "accountsSwapEndowments", + factory: new AccountsSwapEndowments__factory( + {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, + diamondOwner + ), + }, + { + addressField: "accountsUpdateEndowments", + factory: new AccountsUpdateEndowments__factory( + {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, + diamondOwner + ), + }, + { + addressField: "accountsUpdateEndowmentSettingsController", + factory: new AccountsUpdateEndowmentSettingsController__factory( + {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, + diamondOwner + ), + }, + { + addressField: "accountsVaultFacet", + factory: new AccountsVaultFacet__factory( + {"contracts/core/struct.sol:AngelCoreStruct": corestruct}, + diamondOwner + ), + }, + ]; +} diff --git a/utils/index.ts b/utils/index.ts index a9f3096a2..735c77d1d 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -2,6 +2,7 @@ export * from "./confirmAction"; export * from "./constants"; export * from "./env.config"; export * from "./getContractName"; +export * from "./getFacetFactoryEntries"; export * from "./getSigners"; export * from "./keygen"; export * as logger from "./logger"; diff --git a/utils/manageAddressFile/helpers.ts b/utils/manageAddressFile/helpers.ts index fcc2c6e4b..282d87d83 100644 --- a/utils/manageAddressFile/helpers.ts +++ b/utils/manageAddressFile/helpers.ts @@ -86,7 +86,6 @@ function createEmpty(): AddressObj { diamondInitFacet: "", diamondLoupeFacet: "", ownershipFacet: "", - reentrancyGuardFacet: "", }, }, charityApplication: { diff --git a/utils/manageAddressFile/types.ts b/utils/manageAddressFile/types.ts index 600cc10d2..b13e65554 100644 --- a/utils/manageAddressFile/types.ts +++ b/utils/manageAddressFile/types.ts @@ -19,7 +19,6 @@ export type AddressObj = { diamondInitFacet: string; diamondLoupeFacet: string; ownershipFacet: string; - reentrancyGuardFacet: string; }; }; charityApplication: {