From 36f9c0f1f75da829af8d69b431b25f495d450df9 Mon Sep 17 00:00:00 2001 From: katzman <84420280+stevieraykatz@users.noreply.github.com> Date: Wed, 26 Jul 2023 15:59:21 -0700 Subject: [PATCH 1/5] Cleanup query task (#237) * Add new task for queryting endowment details * Fix logging for endow query * Update tasks/manage/queryEndowments.ts Co-authored-by: SovereignAndrey <85138450+SovereignAndrey@users.noreply.github.com> --------- Co-authored-by: SovereignAndrey <85138450+SovereignAndrey@users.noreply.github.com> --- tasks/manage/queryEndowments.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tasks/manage/queryEndowments.ts b/tasks/manage/queryEndowments.ts index 03d12cd24..a081b27f9 100644 --- a/tasks/manage/queryEndowments.ts +++ b/tasks/manage/queryEndowments.ts @@ -1,15 +1,10 @@ import {task, types} from "hardhat/config"; -import { - AccountsCreateEndowment__factory, - AccountsQueryEndowments__factory, - CharityApplications__factory, -} from "typechain-types"; -import {AccountMessages} from "typechain-types/contracts/multisigs/CharityApplications"; +import {AccountsQueryEndowments__factory} from "typechain-types"; import {getAddresses, getSigners, logger, structToObject} from "utils"; type TaskArgs = {id: number}; -task("manage:queryEndowments", "Will create a new endowment") +task("manage:queryEndowments", "Will query an Endowment's details") .addParam("id", "the endowment id", 0, types.int) .setAction(async (taskArgs: TaskArgs, hre) => { try { @@ -22,7 +17,7 @@ task("manage:queryEndowments", "Will create a new endowment") apTeam1 ); - logger.out(await queryEndowmentFacet.queryEndowmentDetails(taskArgs.id)); + logger.out(structToObject(await queryEndowmentFacet.queryEndowmentDetails(taskArgs.id))); } catch (error) { logger.out(error, logger.Level.Error); } From 61c18a7ca1a1015c888bba05972443c10110f45a Mon Sep 17 00:00:00 2001 From: Nenad Misic Date: Thu, 27 Jul 2023 01:41:03 +0200 Subject: [PATCH 2/5] Add `manage:registrar:updateConfig` script (#240) * Add tx hash for proposal created in createEndowment * Add manage:registrar:updateConfig * Remove libraries addresses * Update script * Use manage:registrar:updateConfig in place of the helper --- contract-address.json | 12 - eth-sdk/eth-sdk.config.ts | 4 - tasks/deploy/deployAccountsDiamond.ts | 11 +- tasks/deploy/deployAngelProtocol.ts | 48 ++-- tasks/deploy/deployCharityApplications.ts | 23 +- tasks/deploy/deployEndowmentMultisig.ts | 32 +-- tasks/deploy/deployGasFwd.ts | 13 +- tasks/deploy/deployIndexFund.ts | 17 +- tasks/deploy/deployLocalRegistrar.ts | 14 +- tasks/deploy/deployRegistrar.ts | 44 ++-- tasks/helpers/updateRegistrar.ts | 57 +---- tasks/manage/createEndowment.ts | 4 +- tasks/manage/registrar/index.ts | 1 + tasks/manage/registrar/updateConfig.ts | 282 ++++++++++++++++++++++ tasks/manage/updateRegistrar.ts | 12 +- utils/manageAddressFile/helpers.ts | 4 - utils/manageAddressFile/types.ts | 4 - 17 files changed, 357 insertions(+), 225 deletions(-) create mode 100644 tasks/manage/registrar/updateConfig.ts diff --git a/contract-address.json b/contract-address.json index 7844b77b1..ee015257b 100644 --- a/contract-address.json +++ b/contract-address.json @@ -104,10 +104,6 @@ "implementation": "", "proxy": "" }, - "libraries": { - "angelCoreStruct": "", - "stringArray": "" - }, "multiSig": { "charityApplications": { "implementation": "", @@ -261,10 +257,6 @@ "implementation": "0x59c7E6B2c565Ff92B762523BD6B778CE66dC0302", "proxy": "0x9A676e781A523b5d0C0e43731313A708CB607508" }, - "libraries": { - "angelCoreStruct": "", - "stringArray": "" - }, "multiSig": { "charityApplications": { "implementation": "0x9687796759CAbecC1674A4Aaf23889fC9EC2FCA2", @@ -418,10 +410,6 @@ "implementation": "0x73cF9763985f5617AaF635A8707d89E3B697e112", "proxy": "0xf6B32b4a0371050321fC01672FDfad76aF55603f" }, - "libraries": { - "angelCoreStruct": "", - "stringArray": "" - }, "multiSig": { "charityApplications": { "implementation": "0xA89d149De8F8785c2a6c7ea99B6cC3De5A4c29Af", diff --git a/eth-sdk/eth-sdk.config.ts b/eth-sdk/eth-sdk.config.ts index 6d9c791a7..edb86e532 100644 --- a/eth-sdk/eth-sdk.config.ts +++ b/eth-sdk/eth-sdk.config.ts @@ -82,10 +82,6 @@ export default defineConfig({ implementation: parseAddress(mumbaiData.indexFund.implementation), proxy: parseAddress(mumbaiData.indexFund.proxy), }, - libraries: { - angelCoreStruct: parseAddress(mumbaiData.libraries.angelCoreStruct), - stringArray: parseAddress(mumbaiData.libraries.stringArray), - }, multiSig: { apTeam: { implementation: parseAddress(mumbaiData.multiSig.apTeam.implementation), diff --git a/tasks/deploy/deployAccountsDiamond.ts b/tasks/deploy/deployAccountsDiamond.ts index 2eb5180be..ccf4a10a3 100644 --- a/tasks/deploy/deployAccountsDiamond.ts +++ b/tasks/deploy/deployAccountsDiamond.ts @@ -1,7 +1,6 @@ import {deployAccountsDiamond} from "contracts/core/accounts/scripts/deploy"; import {task} from "hardhat/config"; import {confirmAction, getAddresses, isLocalNetwork, logger, verify} from "utils"; -import {updateRegistrarConfig} from "../helpers"; type TaskArgs = { apTeamMultisig?: string; @@ -38,12 +37,10 @@ task("AccountsDiamond", "It will deploy accounts diamond contracts") return; } - await updateRegistrarConfig( - registrar, - apTeam, - {accountsContract: deployData.diamond.address}, - hre - ); + await hre.run("manage:registrar:updateConfig", { + accountsContract: deployData.diamond.address, + yes: true, + }); await hre.run("manage:CharityApplications:updateConfig", { accountsDiamond: deployData.diamond.address, yes: true, diff --git a/tasks/deploy/deployAngelProtocol.ts b/tasks/deploy/deployAngelProtocol.ts index 5e9ebda59..64e0c6d1b 100644 --- a/tasks/deploy/deployAngelProtocol.ts +++ b/tasks/deploy/deployAngelProtocol.ts @@ -21,11 +21,7 @@ import {deployEndowmentMultiSig} from "contracts/normalized_endowment/endowment- // import {deployImplementation} from "contracts/normalized_endowment/scripts/deployImplementation"; import {deployGasFwd} from "contracts/core/gasFwd/scripts/deploy"; -import { - getOrDeployThirdPartyContracts, - updateRegistrarConfig, - updateRegistrarNetworkConnections, -} from "../helpers"; +import {getOrDeployThirdPartyContracts, updateRegistrarNetworkConnections} from "../helpers"; task("deploy:AngelProtocol", "Will deploy complete Angel Protocol") .addFlag("skipVerify", "Skip contract verification") @@ -97,29 +93,25 @@ task("deploy:AngelProtocol", "Will deploy complete Angel Protocol") const endowmentMultiSig = await deployEndowmentMultiSig(hre); - await updateRegistrarConfig( - registrar?.address, - apTeamMultisig?.address, - { - accountsContract: accounts?.diamond.address, //Address - splitMax: config.REGISTRAR_DATA.splitToLiquid.max, //uint256 - splitMin: config.REGISTRAR_DATA.splitToLiquid.min, //uint256 - splitDefault: config.REGISTRAR_DATA.splitToLiquid.defaultSplit, //uint256 - collectorShare: config.REGISTRAR_UPDATE_CONFIG.collectorShare, //uint256 - indexFundContract: indexFund?.address, //address - treasury: treasury.address, - uniswapRouter: thirdPartyAddresses.uniswap.swapRouter.address, //address - uniswapFactory: thirdPartyAddresses.uniswap.factory.address, //address - multisigFactory: endowmentMultiSig?.factory.address, //address - multisigEmitter: endowmentMultiSig?.emitter.address, //address - charityApplications: charityApplications?.address, //address - proxyAdmin: proxyAdmin.address, //address - usdcAddress: thirdPartyAddresses.usdcToken.address, - wMaticAddress: thirdPartyAddresses.wmaticToken.address, - gasFwdFactory: gasFwd?.factory.address, - }, - hre - ); + await hre.run("manage:registrar:updateConfig", { + accountsContract: accounts?.diamond.address, //Address + splitMax: config.REGISTRAR_DATA.splitToLiquid.max, //uint256 + splitMin: config.REGISTRAR_DATA.splitToLiquid.min, //uint256 + splitDefault: config.REGISTRAR_DATA.splitToLiquid.defaultSplit, //uint256 + collectorShare: config.REGISTRAR_UPDATE_CONFIG.collectorShare, //uint256 + indexFundContract: indexFund?.address, //address + treasury: treasury.address, + uniswapRouter: thirdPartyAddresses.uniswap.swapRouter.address, //address + uniswapFactory: thirdPartyAddresses.uniswap.factory.address, //address + multisigFactory: endowmentMultiSig?.factory.address, //address + multisigEmitter: endowmentMultiSig?.emitter.address, //address + charityApplications: charityApplications?.address, //address + proxyAdmin: proxyAdmin.address, //address + usdcAddress: thirdPartyAddresses.usdcToken.address, + wMaticAddress: thirdPartyAddresses.wmaticToken.address, + gasFwdFactory: gasFwd?.factory.address, + yes: true, + }); // Registrar NetworkInfo's Router address must be updated for the current network if (router) { diff --git a/tasks/deploy/deployCharityApplications.ts b/tasks/deploy/deployCharityApplications.ts index ec99e7648..00dd2f96b 100644 --- a/tasks/deploy/deployCharityApplications.ts +++ b/tasks/deploy/deployCharityApplications.ts @@ -1,13 +1,10 @@ import {deployCharityApplications} from "contracts/multisigs/scripts/deployCharityApplications"; import {task} from "hardhat/config"; import {confirmAction, getAddresses, isLocalNetwork, logger, verify} from "utils"; -import {updateRegistrarConfig} from "../helpers"; type TaskArgs = { accountsDiamond?: string; - apTeamMultisig?: string; charityApplications?: string; - registrar?: string; skipVerify: boolean; yes: boolean; }; @@ -17,14 +14,6 @@ task("deploy:CharityApplications", "Will deploy CharityApplication contract") "accountsDiamond", "Accounts Diamond contract address. Will do a local lookup from contract-address.json if none is provided." ) - .addOptionalParam( - "apTeamMultisig", - "APTeamMultiSig contract address. Will do a local lookup from contract-address.json if none is provided." - ) - .addOptionalParam( - "registrar", - "Registrar contract address. Will do a local lookup from contract-address.json if none is provided." - ) .addFlag("skipVerify", "Skip contract verification") .addFlag("yes", "Automatic yes to prompt.") .setAction(async (taskArgs: TaskArgs, hre) => { @@ -37,8 +26,6 @@ task("deploy:CharityApplications", "Will deploy CharityApplication contract") const addresses = await getAddresses(hre); const accountsDiamond = taskArgs.accountsDiamond || addresses.accounts.diamond; - const apTeamMultiSig = taskArgs.apTeamMultisig || addresses.multiSig.apTeam.proxy; - const registrar = taskArgs.registrar || addresses.registrar.proxy; const charityApplications = await deployCharityApplications( accountsDiamond, @@ -50,12 +37,10 @@ task("deploy:CharityApplications", "Will deploy CharityApplication contract") return; } - await updateRegistrarConfig( - registrar, - apTeamMultiSig, - {charityApplications: charityApplications.address}, - hre - ); + await hre.run("manage:registrar:updateConfig", { + charityApplications: charityApplications.address, + yes: true, + }); if (!isLocalNetwork(hre) && !taskArgs.skipVerify) { await verify(hre, charityApplications); diff --git a/tasks/deploy/deployEndowmentMultisig.ts b/tasks/deploy/deployEndowmentMultisig.ts index 4accf5615..b6c2244d9 100644 --- a/tasks/deploy/deployEndowmentMultisig.ts +++ b/tasks/deploy/deployEndowmentMultisig.ts @@ -1,24 +1,13 @@ import {deployEndowmentMultiSig} from "contracts/normalized_endowment/endowment-multisig/scripts/deploy"; import {task} from "hardhat/config"; -import {confirmAction, getAddresses, isLocalNetwork, logger, verify} from "utils"; -import {updateRegistrarConfig} from "../helpers"; +import {confirmAction, isLocalNetwork, logger, verify} from "utils"; type TaskArgs = { - apTeamMultisig?: string; - registrar?: string; skipVerify: boolean; yes: boolean; }; task("deploy:EndowmentMultiSig", "Will deploy EndowmentMultiSig contract") - .addOptionalParam( - "apTeamMultisig", - "APTeamMultiSig contract address. Will do a local lookup from contract-address.json if none is provided." - ) - .addOptionalParam( - "registrar", - "Registrar contract address. Will do a local lookup from contract-address.json if none is provided." - ) .addFlag("skipVerify", "Skip contract verification") .addFlag("yes", "Automatic yes to prompt.") .setAction(async (taskArgs: TaskArgs, hre) => { @@ -28,26 +17,17 @@ task("deploy:EndowmentMultiSig", "Will deploy EndowmentMultiSig contract") return logger.out("Confirmation denied.", logger.Level.Warn); } - const addresses = await getAddresses(hre); - - const apTeamMultiSig = taskArgs.apTeamMultisig || addresses.multiSig.apTeam.proxy; - const registrar = taskArgs.registrar || addresses.registrar.proxy; - const deployData = await deployEndowmentMultiSig(hre); if (!deployData) { return; } - await updateRegistrarConfig( - registrar, - apTeamMultiSig, - { - multisigFactory: deployData.factory.address, - multisigEmitter: deployData.emitter.address, - }, - hre - ); + await hre.run("manage:registrar:updateConfig", { + multisigFactory: deployData.factory.address, + multisigEmitter: deployData.emitter.address, + yes: true, + }); if (!isLocalNetwork(hre) && !taskArgs.skipVerify) { await verify(hre, deployData.emitter); diff --git a/tasks/deploy/deployGasFwd.ts b/tasks/deploy/deployGasFwd.ts index 437f607fe..b3b9f712e 100644 --- a/tasks/deploy/deployGasFwd.ts +++ b/tasks/deploy/deployGasFwd.ts @@ -1,7 +1,6 @@ import {deployGasFwd} from "contracts/core/gasFwd/scripts/deploy"; import {task} from "hardhat/config"; -import {updateRegistrarConfig} from "tasks/helpers"; -import {getSigners, getAddresses, isLocalNetwork, logger, verify} from "utils"; +import {getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils"; type TaskArgs = { skipVerify: boolean; @@ -23,12 +22,10 @@ task("deploy:GasFwd", "Will deploy the GasFwd implementation and factory") return; } - await updateRegistrarConfig( - addresses.registrar.proxy, - addresses.multiSig.apTeam.proxy, - {gasFwdFactory: gasFwdDeployment.factory.address}, - hre - ); + await hre.run("manage:registrar:updateConfig", { + gasFwdFactory: gasFwdDeployment.factory.address, + yes: true, + }); if (!isLocalNetwork(hre) && !taskArgs.skipVerify) { await verify(hre, gasFwdDeployment.implementation); diff --git a/tasks/deploy/deployIndexFund.ts b/tasks/deploy/deployIndexFund.ts index 3113fea61..c5ca95c47 100644 --- a/tasks/deploy/deployIndexFund.ts +++ b/tasks/deploy/deployIndexFund.ts @@ -1,10 +1,8 @@ import {deployIndexFund} from "contracts/core/index-fund/scripts/deploy"; import {task} from "hardhat/config"; import {confirmAction, getAddresses, isLocalNetwork, logger, verify} from "utils"; -import {updateRegistrarConfig} from "../helpers"; type TaskArgs = { - apTeamMultisig?: string; owner?: string; registrar?: string; skipVerify: boolean; @@ -12,10 +10,6 @@ type TaskArgs = { }; task("deploy:IndexFund", "Will deploy IndexFund contract") - .addOptionalParam( - "apTeamMultisig", - "APTeamMultiSig contract address. Will do a local lookup from contract-address.json if none is provided." - ) .addOptionalParam( "owner", "Address of the owner. By default set to AP team multisig proxy saved in contract-address.json." @@ -35,7 +29,6 @@ task("deploy:IndexFund", "Will deploy IndexFund contract") const addresses = await getAddresses(hre); - const apTeamMultiSig = taskArgs.apTeamMultisig || addresses.multiSig.apTeam.proxy; const registrar = taskArgs.registrar || addresses.registrar.proxy; const owner = taskArgs.owner || addresses.multiSig.apTeam.proxy; @@ -45,12 +38,10 @@ task("deploy:IndexFund", "Will deploy IndexFund contract") return; } - await updateRegistrarConfig( - registrar, - apTeamMultiSig, - {indexFundContract: deployment.address}, - hre - ); + await hre.run("manage:registrar:updateConfig", { + indexFundContract: deployment.address, + yes: true, + }); if (!isLocalNetwork(hre) && !taskArgs.skipVerify) { await verify(hre, deployment); diff --git a/tasks/deploy/deployLocalRegistrar.ts b/tasks/deploy/deployLocalRegistrar.ts index e6f464972..4fde584a5 100644 --- a/tasks/deploy/deployLocalRegistrar.ts +++ b/tasks/deploy/deployLocalRegistrar.ts @@ -1,19 +1,9 @@ import {deployLocalRegistrar} from "contracts/core/registrar/scripts/deploy"; import {deployRouter} from "contracts/core/router/scripts/deploy"; import {task} from "hardhat/config"; -import { - confirmAction, - getAddresses, - getSigners, - isLocalNetwork, - logger, - verify, - NetworkConnectionAction, -} from "utils"; -import {Registrar__factory} from "typechain-types"; import {IAccountsStrategy} from "typechain-types/contracts/core/registrar/interfaces/IRegistrar"; -import {updateRegistrarConfig, updateRegistrarNetworkConnections} from "../helpers"; -import {router} from "typechain-types/contracts/core"; +import {confirmAction, getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils"; +import {updateRegistrarNetworkConnections} from "../helpers"; type TaskArgs = { skipVerify: boolean; diff --git a/tasks/deploy/deployRegistrar.ts b/tasks/deploy/deployRegistrar.ts index 31a451442..14c81131d 100644 --- a/tasks/deploy/deployRegistrar.ts +++ b/tasks/deploy/deployRegistrar.ts @@ -3,7 +3,7 @@ import {deployRegistrar} from "contracts/core/registrar/scripts/deploy"; import {deployRouter} from "contracts/core/router/scripts/deploy"; import {task} from "hardhat/config"; import {confirmAction, getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils"; -import {updateRegistrarConfig, updateRegistrarNetworkConnections} from "../helpers"; +import {updateRegistrarNetworkConnections} from "../helpers"; type TaskArgs = { apTeamMultisig?: string; @@ -57,29 +57,25 @@ task( return; } - await updateRegistrarConfig( - registrarDeployment.address, - apTeamMultiSig, - { - accountsContract: addresses.accounts.diamond, - splitMax: config.REGISTRAR_DATA.splitToLiquid.max, - splitMin: config.REGISTRAR_DATA.splitToLiquid.min, - splitDefault: config.REGISTRAR_DATA.splitToLiquid.defaultSplit, - collectorShare: config.REGISTRAR_UPDATE_CONFIG.collectorShare, - gasFwdFactory: addresses.gasFwd.factory, - indexFundContract: addresses.indexFund.proxy, - treasury: treasury.address, - uniswapRouter: addresses.uniswap.swapRouter, - uniswapFactory: addresses.uniswap.factory, - multisigFactory: addresses.multiSig.endowment.factory, - multisigEmitter: addresses.multiSig.endowment.emitter.proxy, - charityApplications: addresses.multiSig.charityApplications.proxy, - proxyAdmin: proxyAdmin.address, - usdcAddress: addresses.tokens.usdc, - wMaticAddress: addresses.tokens.wmatic, - }, - hre - ); + await hre.run("manage:registrar:updateConfig", { + accountsContract: addresses.accounts.diamond, + splitMax: config.REGISTRAR_DATA.splitToLiquid.max, + splitMin: config.REGISTRAR_DATA.splitToLiquid.min, + splitDefault: config.REGISTRAR_DATA.splitToLiquid.defaultSplit, + collectorShare: config.REGISTRAR_UPDATE_CONFIG.collectorShare, + gasFwdFactory: addresses.gasFwd.factory, + indexFundContract: addresses.indexFund.proxy, + treasury: treasury.address, + uniswapRouter: addresses.uniswap.swapRouter, + uniswapFactory: addresses.uniswap.factory, + multisigFactory: addresses.multiSig.endowment.factory, + multisigEmitter: addresses.multiSig.endowment.emitter.proxy, + charityApplications: addresses.multiSig.charityApplications.proxy, + proxyAdmin: proxyAdmin.address, + usdcAddress: addresses.tokens.usdc, + wMaticAddress: addresses.tokens.wmatic, + yes: true, + }); const routerDeployment = await deployRouter( addresses.axelar.gateway, diff --git a/tasks/helpers/updateRegistrar.ts b/tasks/helpers/updateRegistrar.ts index 28efc6d88..a45bbe17f 100644 --- a/tasks/helpers/updateRegistrar.ts +++ b/tasks/helpers/updateRegistrar.ts @@ -1,9 +1,6 @@ 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 {IAccountsStrategy} from "typechain-types/contracts/core/registrar/interfaces/IRegistrar"; import { NetworkConnectionAction, getAxlNetworkName, @@ -75,55 +72,3 @@ export async function updateRegistrarNetworkConnections( logger.out(error, logger.Level.Error); } } - -export async function updateRegistrarConfig( - registrar = "", - apTeamMultisig = "", - updateConfigRequest: Partial, - hre: HardhatRuntimeEnvironment -) { - try { - logger.divider(); - logger.out("Updating Registrar config with new addresses..."); - - validateAddress(registrar, "registrar"); - validateAddress(apTeamMultisig, "apTeamMultisig"); - - const {apTeamMultisigOwners} = await getSigners(hre); - - const registrarContract = Registrar__factory.connect(registrar, apTeamMultisigOwners[0]); - - logger.out("Fetching current Registrar's config..."); - const struct = await registrarContract.queryConfig(); - const curConfig = structToObject(struct); - logger.out(curConfig); - - logger.out("Config data to update:"); - logger.out(updateConfigRequest); - - const {splitToLiquid, ...otherConfig} = curConfig; - const updateConfigData = registrarContract.interface.encodeFunctionData("updateConfig", [ - { - ...otherConfig, - splitMax: splitToLiquid.max, - splitMin: splitToLiquid.min, - splitDefault: splitToLiquid.defaultSplit, - ...updateConfigRequest, - }, - ]); - const apTeamMultisigContract = APTeamMultiSig__factory.connect( - apTeamMultisig, - apTeamMultisigOwners[0] - ); - const tx = await apTeamMultisigContract.submitTransaction(registrar, 0, updateConfigData, "0x"); - logger.out(`Tx hash: ${tx.hash}`); - await tx.wait(); - - logger.out("New config:"); - const newStruct = await registrarContract.queryConfig(); - const newConfig = structToObject(newStruct); - logger.out(newConfig); - } catch (error) { - logger.out(error, logger.Level.Error); - } -} diff --git a/tasks/manage/createEndowment.ts b/tasks/manage/createEndowment.ts index fe830e837..bbc4a980e 100644 --- a/tasks/manage/createEndowment.ts +++ b/tasks/manage/createEndowment.ts @@ -1,3 +1,4 @@ +import {BigNumber} from "ethers"; import {task, types} from "hardhat/config"; import { AccountsCreateEndowment__factory, @@ -98,6 +99,7 @@ task("manage:createEndowment", "Will create a new endowment") apTeam1 ); const tx = await charityApplications.proposeApplication(createEndowmentRequest, "0x"); + logger.out(`Tx hash: ${tx.hash}`); const receipt = await tx.wait(); if (!receipt.events?.length) { @@ -135,7 +137,7 @@ task("manage:createEndowment", "Will create a new endowment") const newEndowmentDetails = await queryEndowmentFacet.queryEndowmentDetails( config.nextAccountId ); - logger.out("Added endowment:"); + logger.out(`Added endowment with ID: ${config.nextAccountId.toNumber()}`); logger.out(structToObject(newEndowmentDetails)); logger.out(); } catch (error) { diff --git a/tasks/manage/registrar/index.ts b/tasks/manage/registrar/index.ts index 4b7ab4529..44554705e 100644 --- a/tasks/manage/registrar/index.ts +++ b/tasks/manage/registrar/index.ts @@ -8,3 +8,4 @@ import "./setStratApproval"; import "./setStratParams"; import "./setTokenAccepted"; import "./transferOwnership"; +import "./updateConfig"; diff --git a/tasks/manage/registrar/updateConfig.ts b/tasks/manage/registrar/updateConfig.ts new file mode 100644 index 000000000..9c41af13b --- /dev/null +++ b/tasks/manage/registrar/updateConfig.ts @@ -0,0 +1,282 @@ +import {task, types} from "hardhat/config"; +import {APTeamMultiSig__factory, Registrar__factory} from "typechain-types"; +import {RegistrarMessages} from "typechain-types/contracts/core/registrar/Registrar"; +import {confirmAction, getAddresses, getSigners, logger, structToObject} from "utils"; + +type TaskArgs = Partial & { + yes: boolean; +}; + +task("manage:registrar:updateConfig", "Will update Accounts Diamond config") + .addOptionalParam( + "accountsContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "splitMax", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.int + ) + .addOptionalParam( + "splitMin", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.int + ) + .addOptionalParam( + "splitDefault", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.int + ) + .addOptionalParam( + "collectorShare", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.int + ) + .addOptionalParam( + "indexFundContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "govContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "treasury", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "donationMatchCharitesContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "donationMatchEmitter", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "haloToken", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "haloTokenLpContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "charitySharesContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "fundraisingContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "uniswapRouter", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "uniswapFactory", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "multisigFactory", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "multisigEmitter", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "charityApplications", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "lockedWithdrawal", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "proxyAdmin", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "usdcAddress", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "wMaticAddress", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "subdaoGovContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "subdaoTokenContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "subdaoBondingTokenContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "subdaoCw900Contract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "subdaoDistributorContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "subdaoEmitter", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "donationMatchContract", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "cw900lvAddress", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addOptionalParam( + "gasFwdFactory", + "Registrar contract address. Will do a local lookup from contract-address.json if none is provided.", + undefined, + types.string + ) + .addFlag("yes", "Automatic yes to prompt.") + .setAction(async (taskArgs: TaskArgs, hre) => { + logger.divider(); + logger.out("Updating Registrar config..."); + + try { + const addresses = await getAddresses(hre); + const {apTeamMultisigOwners} = await getSigners(hre); + + const {yes, ...dirtyConfigValues} = taskArgs; + + const updateConfigRequest = assignDefinedValues(dirtyConfigValues); + + if (Object.keys(updateConfigRequest).length === 0) { + return logger.out("Nothing to update"); + } + + logger.out("Config data to update:"); + logger.out(updateConfigRequest); + + const isConfirmed = taskArgs.yes || (await confirmAction(`Updating Registrar config...`)); + if (!isConfirmed) { + return logger.out("Confirmation denied.", logger.Level.Warn); + } + + const registrarContract = Registrar__factory.connect( + addresses.registrar.proxy, + apTeamMultisigOwners[0] + ); + + logger.out("Fetching current Registrar's config..."); + const struct = await registrarContract.queryConfig(); + const curConfig = structToObject(struct); + logger.out(curConfig); + + const {splitToLiquid, ...otherConfig} = curConfig; + const updateConfigData = registrarContract.interface.encodeFunctionData("updateConfig", [ + { + ...otherConfig, + splitMax: splitToLiquid.max, + splitMin: splitToLiquid.min, + splitDefault: splitToLiquid.defaultSplit, + ...updateConfigRequest, + }, + ]); + const apTeamMultisigContract = APTeamMultiSig__factory.connect( + addresses.multiSig.apTeam.proxy, + apTeamMultisigOwners[0] + ); + const tx = await apTeamMultisigContract.submitTransaction( + addresses.registrar.proxy, + 0, + updateConfigData, + "0x" + ); + logger.out(`Tx hash: ${tx.hash}`); + await tx.wait(); + + logger.out("New config:"); + const newStruct = await registrarContract.queryConfig(); + logger.out(structToObject(newStruct)); + } catch (error) { + logger.out(error, logger.Level.Error); + } + }); + +function assignDefinedValues( + obj: Partial +): Partial { + const target: Partial = {}; + + (Object.keys(obj) as (keyof RegistrarMessages.UpdateConfigRequestStruct)[]).forEach((key) => { + const value = obj[key]; + if (value !== undefined && value !== null) { + target[key] = value as any; + } + }); + + return target; +} diff --git a/tasks/manage/updateRegistrar.ts b/tasks/manage/updateRegistrar.ts index 20eb560fe..74457f674 100644 --- a/tasks/manage/updateRegistrar.ts +++ b/tasks/manage/updateRegistrar.ts @@ -1,6 +1,5 @@ import config from "config"; import {task} from "hardhat/config"; -import {updateRegistrarConfig} from "tasks/helpers"; import {cliTypes} from "tasks/types"; import {RegistrarMessages} from "typechain-types/contracts/core/registrar/interfaces/IRegistrar"; import {ADDRESS_ZERO, getAddresses, getSigners, logger} from "utils"; @@ -63,12 +62,11 @@ task( lockedWithdrawal: ADDRESS_ZERO, gasFwdFactory: addresses.gasFwd.factory, }; - await updateRegistrarConfig( - addresses.registrar.proxy, - addresses.multiSig.apTeam.proxy, - newConfig, - hre - ); + + await hre.run("manage:registrar:updateConfig", { + ...newConfig, + yes: true, + }); if (taskArgs.acceptedTokens.length > 0) { logger.divider(); diff --git a/utils/manageAddressFile/helpers.ts b/utils/manageAddressFile/helpers.ts index a377acbab..9a8fcbff7 100644 --- a/utils/manageAddressFile/helpers.ts +++ b/utils/manageAddressFile/helpers.ts @@ -171,10 +171,6 @@ export function createEmptyAddressObj(): AddressObj { implementation: "", proxy: "", }, - libraries: { - angelCoreStruct: "", - stringArray: "", - }, multiSig: { charityApplications: { implementation: "", diff --git a/utils/manageAddressFile/types.ts b/utils/manageAddressFile/types.ts index fcbf122fe..ee9df1c3b 100644 --- a/utils/manageAddressFile/types.ts +++ b/utils/manageAddressFile/types.ts @@ -103,10 +103,6 @@ export type AddressObj = { implementation: string; proxy: string; }; - libraries: { - angelCoreStruct: string; - stringArray: string; - }; multiSig: { charityApplications: { implementation: string; From ffab4d20cf7f96e0467b2d6085d02ad503909ef9 Mon Sep 17 00:00:00 2001 From: Nenad Misic Date: Thu, 27 Jul 2023 11:05:44 +0200 Subject: [PATCH 3/5] Add task to upgrade `EndowmentMultiSigEmitter` implementation (+ the new impl. address) (#242) * Move upgradeEndowmentMultiSig -> /endowmentMultisig/upgradeImplementation * Make confirmAction's param optional * Add endow's upgradeEmitter task * Remove upgradeEndowmentMultiSig task * Log deploy tx hash * Deploy new emitter implementation --- contract-address.json | 2 +- tasks/upgrade/endowmentMultiSig/index.ts | 2 + .../endowmentMultiSig/upgradeEmitter.ts | 77 +++++++++++++++++++ .../upgradeImplementation.ts} | 4 +- tasks/upgrade/index.ts | 2 +- utils/confirmAction.ts | 6 +- 6 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 tasks/upgrade/endowmentMultiSig/index.ts create mode 100644 tasks/upgrade/endowmentMultiSig/upgradeEmitter.ts rename tasks/upgrade/{upgradeEndowmentMultiSig.ts => endowmentMultiSig/upgradeImplementation.ts} (97%) diff --git a/contract-address.json b/contract-address.json index ee015257b..8c10ad53e 100644 --- a/contract-address.json +++ b/contract-address.json @@ -421,7 +421,7 @@ }, "endowment": { "emitter": { - "implementation": "0xf1bBE8aCdd30E2998D1Db8eEaACE95E86DFE7a0a", + "implementation": "0x366478C1e2895017FaCb12Ea682CfcBF85720BAC", "proxy": "0x8a87385765871bD85d96B7675A3F1Fb663146E4d" }, "factory": "0xc4150f28a33a04B79B60560Bd4684d521edB99AE", diff --git a/tasks/upgrade/endowmentMultiSig/index.ts b/tasks/upgrade/endowmentMultiSig/index.ts new file mode 100644 index 000000000..6b6aaacc4 --- /dev/null +++ b/tasks/upgrade/endowmentMultiSig/index.ts @@ -0,0 +1,2 @@ +import "./upgradeEmitter"; +import "./upgradeImplementation"; diff --git a/tasks/upgrade/endowmentMultiSig/upgradeEmitter.ts b/tasks/upgrade/endowmentMultiSig/upgradeEmitter.ts new file mode 100644 index 000000000..aff71d835 --- /dev/null +++ b/tasks/upgrade/endowmentMultiSig/upgradeEmitter.ts @@ -0,0 +1,77 @@ +import {task} from "hardhat/config"; +import { + EndowmentMultiSigEmitter__factory, + ITransparentUpgradeableProxy__factory, +} from "typechain-types"; +import { + confirmAction, + getAddresses, + getSigners, + isLocalNetwork, + logger, + updateAddresses, + verify, +} from "utils"; + +type TaskArgs = { + factory?: string; + skipVerify: boolean; + yes: boolean; +}; + +task( + "upgrade:endowmentMultiSig:emitter", + "Will upgrade the EndowmentMultiSigEmitter implementation contract" +) + .addFlag("skipVerify", "Skip contract verification") + .addFlag("yes", "Automatic yes to prompt.") + .setAction(async (taskArgs: TaskArgs, hre) => { + try { + logger.divider(); + logger.out("Upgrading EndowmentMultiSigEmitter implementation contract..."); + + const isConfirmed = taskArgs.yes || (await confirmAction()); + if (!isConfirmed) { + return logger.out("Confirmation denied.", logger.Level.Warn); + } + + const {proxyAdmin} = await getSigners(hre); + + const addresses = await getAddresses(hre); + + logger.out("Deploying implementation..."); + const Emitter = new EndowmentMultiSigEmitter__factory(proxyAdmin); + const emitter = await Emitter.deploy(); + logger.out(`Tx hash: ${emitter.deployTransaction.hash}`); + await emitter.deployed(); + logger.out(`Address: ${emitter.address}`); + + logger.out("Upgrading proxy..."); + const proxy = ITransparentUpgradeableProxy__factory.connect( + addresses.multiSig.endowment.emitter.proxy, + proxyAdmin + ); + const tx = await proxy.upgradeTo(emitter.address); + logger.out(`Tx hash: ${tx.hash}`); + await tx.wait(); + + await updateAddresses( + { + multiSig: { + endowment: { + emitter: { + implementation: emitter.address, + }, + }, + }, + }, + hre + ); + + if (!isLocalNetwork(hre) && !taskArgs.skipVerify) { + await verify(hre, {address: emitter.address}); + } + } catch (error) { + logger.out(`EndowmentMultiSigEmitter upgrade failed, reason: ${error}`, logger.Level.Error); + } + }); diff --git a/tasks/upgrade/upgradeEndowmentMultiSig.ts b/tasks/upgrade/endowmentMultiSig/upgradeImplementation.ts similarity index 97% rename from tasks/upgrade/upgradeEndowmentMultiSig.ts rename to tasks/upgrade/endowmentMultiSig/upgradeImplementation.ts index fcece2c98..5a9495837 100644 --- a/tasks/upgrade/upgradeEndowmentMultiSig.ts +++ b/tasks/upgrade/endowmentMultiSig/upgradeImplementation.ts @@ -17,8 +17,8 @@ type TaskArgs = { }; task( - "upgrade:EndowmentMultiSig", - "Will upgrade the implementation of the EndowmentMultiSig contracts" + "upgrade:endowmentMultiSig:implementation", + "Will upgrade the implementation of the EndowmentMultiSig contract" ) .addOptionalParam( "factory", diff --git a/tasks/upgrade/index.ts b/tasks/upgrade/index.ts index 3a2dd8893..2d90e2c6c 100644 --- a/tasks/upgrade/index.ts +++ b/tasks/upgrade/index.ts @@ -1,6 +1,6 @@ +import "./endowmentMultiSig"; import "./upgradeAPTeamMultiSig"; import "./upgradeCharityApplications"; import "./upgradeContractsUsingAccountStorage"; -import "./upgradeEndowmentMultiSig"; import "./upgradeFacets"; import "./upgradeRegistrar"; diff --git a/utils/confirmAction.ts b/utils/confirmAction.ts index 70e48f390..38c2f75c0 100644 --- a/utils/confirmAction.ts +++ b/utils/confirmAction.ts @@ -1,8 +1,10 @@ import {question} from "readline-sync"; -export async function confirmAction(actionDescription: string): Promise { +export async function confirmAction(actionDescription?: string): Promise { const answer = question( - `${actionDescription}\nAre you sure you wish to perform this action? (y/N)` + `${ + actionDescription ? `${actionDescription}\n` : "" + }Are you sure you wish to perform this action? (y/N)` ).trim(); return /^(y|yes)$/i.test(answer); } From c47b6f810794177c6335540bf25e7aa3fa711616 Mon Sep 17 00:00:00 2001 From: SovereignAndrey <85138450+SovereignAndrey@users.noreply.github.com> Date: Fri, 28 Jul 2023 04:58:55 +0800 Subject: [PATCH 4/5] Donation match sender (#241) * use msg.sender for donation, save for those from IndexFund * clean up comments * refactor: add donationMatch field to DepositRequest; Update tests & affected contracts; --------- Co-authored-by: Andrey --- contracts/accessory/gift-cards/GiftCards.sol | 3 +- .../AccountsDepositWithdrawEndowments.sol | 21 ++- contracts/core/accounts/message.sol | 1 + contracts/core/index-fund/IndexFund.sol | 3 +- contracts/multisigs/CharityApplications.sol | 3 +- .../AccountsDepositWithdrawEndowments.ts | 176 +++++++++++++----- 6 files changed, 149 insertions(+), 58 deletions(-) diff --git a/contracts/accessory/gift-cards/GiftCards.sol b/contracts/accessory/gift-cards/GiftCards.sol index ef86679a7..7b6b31ae0 100644 --- a/contracts/accessory/gift-cards/GiftCards.sol +++ b/contracts/accessory/gift-cards/GiftCards.sol @@ -186,7 +186,8 @@ contract GiftCards is Storage, Initializable, OwnableUpgradeable, ReentrancyGuar AccountMessages.DepositRequest({ id: endowmentId, lockedPercentage: lockedPercentage, - liquidPercentage: liquidPercentage + liquidPercentage: liquidPercentage, + donationMatch: msg.sender }), tokenAddress, amount diff --git a/contracts/core/accounts/facets/AccountsDepositWithdrawEndowments.sol b/contracts/core/accounts/facets/AccountsDepositWithdrawEndowments.sol index a298e3315..81ba3ad79 100644 --- a/contracts/core/accounts/facets/AccountsDepositWithdrawEndowments.sol +++ b/contracts/core/accounts/facets/AccountsDepositWithdrawEndowments.sol @@ -115,7 +115,6 @@ contract AccountsDepositWithdrawEndowments is uint256 liquidSplitPercent = details.liquidPercentage; require(registrar_config.indexFundContract != address(0), "No Index Fund"); - if (msg.sender != registrar_config.indexFundContract) { if (tempEndowment.endowType == LibAccounts.EndowmentType.Charity) { // use the Registrar default split for Charities @@ -139,9 +138,13 @@ contract AccountsDepositWithdrawEndowments is uint256 lockedAmount = (amount.mul(lockedSplitPercent)).div(LibAccounts.PERCENT_BASIS); uint256 liquidAmount = (amount.mul(liquidSplitPercent)).div(LibAccounts.PERCENT_BASIS); - //donation matching flow - //execute donor match will always be called on an EOA + // donation matching flow if (lockedAmount > 0) { + address donationMatch = details.donationMatch; + if (donationMatch == address(0)) { + donationMatch = msg.sender; + } + if ( tempEndowment.endowType == LibAccounts.EndowmentType.Charity && registrar_config.donationMatchCharitesContract != address(0) @@ -149,17 +152,14 @@ contract AccountsDepositWithdrawEndowments is IDonationMatching(registrar_config.donationMatchCharitesContract).executeDonorMatch( details.id, lockedAmount, - tx.origin, + donationMatch, registrar_config.haloToken ); - } else if ( - tempEndowment.endowType == LibAccounts.EndowmentType.Normal && - tempEndowment.donationMatchContract != address(0) - ) { + } else if (tempEndowment.donationMatchContract != address(0)) { IDonationMatching(tempEndowment.donationMatchContract).executeDonorMatch( details.id, lockedAmount, - tx.origin, + donationMatch, tempEndowment.daoToken ); } @@ -330,7 +330,8 @@ contract AccountsDepositWithdrawEndowments is AccountMessages.DepositRequest({ id: beneficiaryEndowId, lockedPercentage: 0, - liquidPercentage: 100 + liquidPercentage: 100, + donationMatch: address(this) // all liquid so won't trigger a match }), tokens[t].addr, (amountLeftover - withdrawFeeEndow) diff --git a/contracts/core/accounts/message.sol b/contracts/core/accounts/message.sol index 18538cc12..0d8fa8aaf 100644 --- a/contracts/core/accounts/message.sol +++ b/contracts/core/accounts/message.sol @@ -121,6 +121,7 @@ library AccountMessages { uint32 id; uint256 lockedPercentage; uint256 liquidPercentage; + address donationMatch; } struct InvestRequest { diff --git a/contracts/core/index-fund/IndexFund.sol b/contracts/core/index-fund/IndexFund.sol index c3830913b..77aa4a8b4 100644 --- a/contracts/core/index-fund/IndexFund.sol +++ b/contracts/core/index-fund/IndexFund.sol @@ -508,7 +508,8 @@ contract IndexFund is IIndexFund, Storage, ReentrancyGuard, Initializable { AccountMessages.DepositRequest({ id: donationMessages.member_ids[i], lockedPercentage: donationMessages.lockedSplit[i], - liquidPercentage: donationMessages.liquidSplit[i] + liquidPercentage: donationMessages.liquidSplit[i], + donationMatch: msg.sender }), tokenaddress, donationMessages.locked_donation_amount[i] + donationMessages.liquid_donation_amount[i] diff --git a/contracts/multisigs/CharityApplications.sol b/contracts/multisigs/CharityApplications.sol index 3655eebc3..f4055b38f 100644 --- a/contracts/multisigs/CharityApplications.sol +++ b/contracts/multisigs/CharityApplications.sol @@ -239,7 +239,8 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp AccountMessages.DepositRequest({ id: endowmentId, lockedPercentage: 100 - config.seedSplitToLiquid, - liquidPercentage: config.seedSplitToLiquid + liquidPercentage: config.seedSplitToLiquid, + donationMatch: address(this) }), config.seedAsset, config.seedAmount diff --git a/test/core/accounts/AccountsDepositWithdrawEndowments.ts b/test/core/accounts/AccountsDepositWithdrawEndowments.ts index dd920b9b9..d23b89f77 100644 --- a/test/core/accounts/AccountsDepositWithdrawEndowments.ts +++ b/test/core/accounts/AccountsDepositWithdrawEndowments.ts @@ -38,11 +38,13 @@ describe("AccountsDepositWithdrawEndowments", function () { id: charityId, liquidPercentage: 40, lockedPercentage: 60, + donationMatch: ethers.constants.AddressZero, }; const depositToNormalEndow: AccountMessages.DepositRequestStruct = { id: normalEndowId, liquidPercentage: 40, lockedPercentage: 60, + donationMatch: ethers.constants.AddressZero, }; let accOwner: SignerWithAddress; @@ -165,6 +167,7 @@ describe("AccountsDepositWithdrawEndowments", function () { id: charityId, liquidPercentage: 10, lockedPercentage: 10, + donationMatch: ethers.constants.AddressZero, }; await expect(facet.depositMatic(invalidReq, {value})).to.be.revertedWith("InvalidSplit"); }); @@ -211,7 +214,15 @@ describe("AccountsDepositWithdrawEndowments", function () { await expect( facet .connect(indexFund) - .depositMatic({id: charityId, lockedPercentage: 0, liquidPercentage: 100}, {value}) + .depositMatic( + { + id: charityId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, + {value} + ) ) .to.emit(facet, "EndowmentDeposit") .withArgs(charityId, wmaticFake.address, expectedLockedAmt, expectedLiquidAmt); @@ -242,7 +253,15 @@ describe("AccountsDepositWithdrawEndowments", function () { await expect( facet .connect(indexFund) - .depositMatic({id: charityId, lockedPercentage: 0, liquidPercentage: 100}, {value}) + .depositMatic( + { + id: charityId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, + {value} + ) ) .to.emit(facet, "EndowmentDeposit") .withArgs(charityId, wmaticFake.address, expectedLockedAmt, expectedLiquidAmt); @@ -381,7 +400,12 @@ describe("AccountsDepositWithdrawEndowments", function () { facet .connect(indexFund) .depositMatic( - {id: normalEndowId, lockedPercentage: 0, liquidPercentage: 100}, + { + id: normalEndowId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, {value} ) ) @@ -412,12 +436,15 @@ describe("AccountsDepositWithdrawEndowments", function () { wmaticFake.transfer.returns(true); await expect( - facet - .connect(indexFund) - .depositMatic( - {id: normalEndowId, lockedPercentage: 0, liquidPercentage: 100}, - {value} - ) + facet.connect(indexFund).depositMatic( + { + id: normalEndowId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, + {value} + ) ) .to.emit(facet, "EndowmentDeposit") .withArgs(normalEndowId, wmaticFake.address, expectedLockedAmt, expectedLiquidAmt); @@ -547,7 +574,15 @@ describe("AccountsDepositWithdrawEndowments", function () { const expectedLiquidAmt = BigNumber.from(1000); await expect( - facet.depositMatic({id: charityId, lockedPercentage: 0, liquidPercentage: 100}, {value}) + facet.depositMatic( + { + id: charityId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, + {value} + ) ) .to.emit(facet, "EndowmentDeposit") .withArgs(charityId, wmaticFake.address, expectedLockedAmt, expectedLiquidAmt); @@ -576,7 +611,15 @@ describe("AccountsDepositWithdrawEndowments", function () { wmaticFake.transfer.returns(true); await expect( - facet.depositMatic({id: charityId, lockedPercentage: 0, liquidPercentage: 100}, {value}) + facet.depositMatic( + { + id: charityId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, + {value} + ) ) .to.emit(facet, "EndowmentDeposit") .withArgs(charityId, wmaticFake.address, expectedLockedAmt, expectedLiquidAmt); @@ -713,7 +756,12 @@ describe("AccountsDepositWithdrawEndowments", function () { await expect( facet.depositMatic( - {id: normalEndowId, lockedPercentage: 0, liquidPercentage: 100}, + { + id: normalEndowId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, {value} ) ) @@ -745,7 +793,12 @@ describe("AccountsDepositWithdrawEndowments", function () { await expect( facet.depositMatic( - {id: normalEndowId, lockedPercentage: 0, liquidPercentage: 100}, + { + id: normalEndowId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, {value} ) ) @@ -911,6 +964,7 @@ describe("AccountsDepositWithdrawEndowments", function () { id: charityId, liquidPercentage: 10, lockedPercentage: 10, + donationMatch: ethers.constants.AddressZero, }; await expect( facet.depositERC20(invalidReq, tokenFake.address, depositAmt) @@ -950,13 +1004,16 @@ describe("AccountsDepositWithdrawEndowments", function () { const expectedLiquidAmt = BigNumber.from(depositAmt); await expect( - facet - .connect(indexFund) - .depositERC20( - {id: charityId, lockedPercentage: 0, liquidPercentage: 100}, - tokenFake.address, - depositAmt - ) + facet.connect(indexFund).depositERC20( + { + id: charityId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, + tokenFake.address, + depositAmt + ) ) .to.emit(facet, "EndowmentDeposit") .withArgs(charityId, tokenFake.address, expectedLockedAmt, expectedLiquidAmt); @@ -983,13 +1040,16 @@ describe("AccountsDepositWithdrawEndowments", function () { await state.setEndowmentDetails(charityId, charityBps); await expect( - facet - .connect(indexFund) - .depositERC20( - {id: charityId, lockedPercentage: 0, liquidPercentage: 100}, - tokenFake.address, - depositAmt - ) + facet.connect(indexFund).depositERC20( + { + id: charityId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, + tokenFake.address, + depositAmt + ) ) .to.emit(facet, "EndowmentDeposit") .withArgs(charityId, tokenFake.address, expectedLockedAmt, expectedLiquidAmt); @@ -1111,13 +1171,16 @@ describe("AccountsDepositWithdrawEndowments", function () { const expectedLiquidAmt = BigNumber.from(depositAmt); await expect( - facet - .connect(indexFund) - .depositERC20( - {id: normalEndowId, lockedPercentage: 0, liquidPercentage: 100}, - tokenFake.address, - depositAmt - ) + facet.connect(indexFund).depositERC20( + { + id: normalEndowId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, + tokenFake.address, + depositAmt + ) ) .to.emit(facet, "EndowmentDeposit") .withArgs(normalEndowId, tokenFake.address, expectedLockedAmt, expectedLiquidAmt); @@ -1144,13 +1207,16 @@ describe("AccountsDepositWithdrawEndowments", function () { await state.setEndowmentDetails(normalEndowId, normalEndowBps); await expect( - facet - .connect(indexFund) - .depositERC20( - {id: normalEndowId, lockedPercentage: 0, liquidPercentage: 100}, - tokenFake.address, - depositAmt - ) + facet.connect(indexFund).depositERC20( + { + id: normalEndowId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, + tokenFake.address, + depositAmt + ) ) .to.emit(facet, "EndowmentDeposit") .withArgs(normalEndowId, tokenFake.address, expectedLockedAmt, expectedLiquidAmt); @@ -1288,7 +1354,12 @@ describe("AccountsDepositWithdrawEndowments", function () { await expect( facet.depositERC20( - {id: charityId, lockedPercentage: 0, liquidPercentage: 100}, + { + id: charityId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, tokenFake.address, depositAmt ) @@ -1319,7 +1390,12 @@ describe("AccountsDepositWithdrawEndowments", function () { await expect( facet.depositERC20( - {id: charityId, lockedPercentage: 0, liquidPercentage: 100}, + { + id: charityId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, tokenFake.address, depositAmt ) @@ -1439,7 +1515,12 @@ describe("AccountsDepositWithdrawEndowments", function () { await expect( facet.depositERC20( - {id: normalEndowId, lockedPercentage: 0, liquidPercentage: 100}, + { + id: normalEndowId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, tokenFake.address, depositAmt ) @@ -1470,7 +1551,12 @@ describe("AccountsDepositWithdrawEndowments", function () { await expect( facet.depositERC20( - {id: normalEndowId, lockedPercentage: 0, liquidPercentage: 100}, + { + id: normalEndowId, + lockedPercentage: 0, + liquidPercentage: 100, + donationMatch: ethers.constants.AddressZero, + }, tokenFake.address, depositAmt ) From 746ff55943e81a7dcb5694f2574d0afd42bc55c4 Mon Sep 17 00:00:00 2001 From: Nenad Misic Date: Fri, 28 Jul 2023 02:17:34 +0200 Subject: [PATCH 5/5] Fix randomly failing `Error: Cannot find module 'typechain-types'` during GH CI/CD (#233) * Add 'sleep' step to *ci.yml* * Remove compile ci step * Remove sleep step * Add back format step * Use compile script directly in package.json * Revert "Use compile script directly in package.json" This reverts commit 47897f9fc32601034d6b308b67e3463c44772051. * Run only compile (without clean) * Use bash script without clean * Add test func to AccountsCreateEndowment * Revert "Add test func to AccountsCreateEndowment" This reverts commit 4c354f08fc06279b16062a9df4e6c951fc91a238. --- compile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compile.sh b/compile.sh index 18cd166ad..24baec51f 100644 --- a/compile.sh +++ b/compile.sh @@ -5,7 +5,7 @@ set -x; # Shuttle `tasks/index.ts` file to temp file before cleaning/compiling starts mv -n ./tasks/index.ts ./tasks/temp_index.ts && touch ./tasks/index.ts; # Clean and compile all contracts. -hardhat clean && hardhat compile; +hardhat compile; # Shuttle `tasks/index.ts` file from temp file to orig location after cleaning/compiling ends # Run regardless of above line's failure or sucesss mv ./tasks/temp_index.ts ./tasks/index.ts;