diff --git a/contracts/core/index-fund/scripts/deploy.ts b/contracts/core/index-fund/scripts/deploy.ts index 273c22856..4c764c0ad 100644 --- a/contracts/core/index-fund/scripts/deploy.ts +++ b/contracts/core/index-fund/scripts/deploy.ts @@ -32,7 +32,7 @@ export async function deployIndexFund( // deploy proxy logger.out("Deploying proxy..."); - const initData = indexFund.interface.encodeFunctionData("initialize(address,uint256,uint256)", [ + const initData = indexFund.interface.encodeFunctionData("initialize", [ registrar, config.INDEX_FUND_DATA.fundRotation, config.INDEX_FUND_DATA.fundingGoal, diff --git a/tasks/deploy/deployIndexFund.ts b/tasks/deploy/deployIndexFund.ts index 2d35a70f1..c5ca95c47 100644 --- a/tasks/deploy/deployIndexFund.ts +++ b/tasks/deploy/deployIndexFund.ts @@ -30,8 +30,9 @@ task("deploy:IndexFund", "Will deploy IndexFund contract") const addresses = await getAddresses(hre); const registrar = taskArgs.registrar || addresses.registrar.proxy; + const owner = taskArgs.owner || addresses.multiSig.apTeam.proxy; - const deployment = await deployIndexFund(registrar, hre); + const deployment = await deployIndexFund(registrar, owner, hre); if (!deployment) { return; diff --git a/tasks/manage/changeOwner.ts b/tasks/manage/changeOwner.ts deleted file mode 100644 index a9d95f3c9..000000000 --- a/tasks/manage/changeOwner.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {task} from "hardhat/config"; -import type {TaskArguments} from "hardhat/types"; -import {IndexFund__factory} from "typechain-types"; -import {getAddresses, getSigners, logger} from "utils"; - -task("manage:changeOwner", "Will update the owner of the specified contract").setAction( - async (_taskArguments: TaskArguments, hre) => { - try { - const addresses = await getAddresses(hre); - const {proxyAdmin} = await getSigners(hre); - const indexfund = IndexFund__factory.connect(addresses.indexFund.proxy, proxyAdmin); - - logger.out("Current owner:"); - let currentConfig = await indexfund.queryConfig(); - logger.out(currentConfig.owner); - - logger.out("Changing owner to:"); - logger.out(addresses.multiSig.apTeam.proxy); - await indexfund.updateOwner(addresses.multiSig.apTeam.proxy); - } catch (error) { - logger.out(error, logger.Level.Error); - } - } -); diff --git a/tasks/manage/index.ts b/tasks/manage/index.ts index f79b6ef53..a421da06f 100644 --- a/tasks/manage/index.ts +++ b/tasks/manage/index.ts @@ -1,7 +1,6 @@ import "./accounts"; import "./addMultisigOwner"; import "./changeAdmin"; -import "./changeOwner"; import "./charityApplications"; import "./createEndowment"; import "./createIndexFund"; diff --git a/tasks/manage/indexFund/index.ts b/tasks/manage/indexFund/index.ts index 2b6ab803a..b59a7f442 100644 --- a/tasks/manage/indexFund/index.ts +++ b/tasks/manage/indexFund/index.ts @@ -1,2 +1 @@ -import "./updateOwner"; -import "./updateRegistrar"; +import "./updateConfig"; diff --git a/tasks/manage/indexFund/updateOwner.ts b/tasks/manage/indexFund/updateConfig.ts similarity index 50% rename from tasks/manage/indexFund/updateOwner.ts rename to tasks/manage/indexFund/updateConfig.ts index aad426c77..32c783ec1 100644 --- a/tasks/manage/indexFund/updateOwner.ts +++ b/tasks/manage/indexFund/updateConfig.ts @@ -2,51 +2,50 @@ import {task} from "hardhat/config"; import {APTeamMultiSig__factory, IndexFund__factory} from "typechain-types"; import {confirmAction, getAddresses, getSigners, logger} from "utils"; -type TaskArgs = {to: string; yes: boolean}; +type TaskArgs = { + newConfig: {registrarContract: string; fundingGoal: number; fundingRotation: number}; + yes: boolean; +}; -task("manage:IndexFund:updateOwner", "Will update the owner of the IndexFund") - .addOptionalParam( - "to", - "Address of the new owner. Ensure at least one of `apTeamMultisigOwners` is the controller of this address. Will default to `contract-address.json > multiSig.apTeam.proxy` if none is provided." +task("manage:IndexFund:updateConfig", "Will update the config of the IndexFund") + .addParam( + "newConfig", + "New Config. Registrar Contract address, funding rotation blocks & funding goal amount." ) .addFlag("yes", "Automatic yes to prompt.") .setAction(async (taskArgs: TaskArgs, hre) => { try { + let newConfig = taskArgs.newConfig; + logger.divider(); const addresses = await getAddresses(hre); const {apTeamMultisigOwners} = await getSigners(hre); - const newOwner = taskArgs.to || addresses.multiSig.apTeam.proxy; - - logger.out("Querying current IndexFund owner..."); + logger.out("Querying current IndexFund registrar..."); const indexFund = IndexFund__factory.connect( addresses.indexFund.proxy, apTeamMultisigOwners[0] ); - const curOwner = (await indexFund.queryConfig()).owner; - if (curOwner === newOwner) { - return logger.out(`"${newOwner}" is already the owner.`); - } - logger.out(`Current owner: ${curOwner}`); const isConfirmed = - taskArgs.yes || (await confirmAction(`Transfer ownership to: ${newOwner}`)); + taskArgs.yes || + (await confirmAction(`Update Registrar address to: ${newConfig.registrarContract}`)); if (!isConfirmed) { return logger.out("Confirmation denied.", logger.Level.Warn); } - logger.out(`Transferring ownership to: ${newOwner}...`); - const data = indexFund.interface.encodeFunctionData("updateOwner", [newOwner]); const apTeamMultiSig = APTeamMultiSig__factory.connect( - curOwner, // ensure connection to current owning APTeamMultiSig contract + addresses.multiSig.apTeam.proxy, // ensure connection to current owning APTeamMultiSig contract apTeamMultisigOwners[0] ); + const data = indexFund.interface.encodeFunctionData("updateConfig", [ + newConfig.registrarContract, + newConfig.fundingRotation, + newConfig.fundingGoal, + ]); const tx = await apTeamMultiSig.submitTransaction(indexFund.address, 0, data, "0x"); logger.out(`Tx hash: ${tx.hash}`); await tx.wait(); - - const updatedOwner = (await indexFund.queryConfig()).owner; - logger.out(`New owner: ${updatedOwner}`); } catch (error) { logger.out(error, logger.Level.Error); } diff --git a/tasks/manage/indexFund/updateRegistrar.ts b/tasks/manage/indexFund/updateRegistrar.ts deleted file mode 100644 index 9a804dae2..000000000 --- a/tasks/manage/indexFund/updateRegistrar.ts +++ /dev/null @@ -1,54 +0,0 @@ -import {task} from "hardhat/config"; -import {APTeamMultiSig__factory, IndexFund__factory} from "typechain-types"; -import {confirmAction, getAddresses, getSigners, logger} from "utils"; - -type TaskArgs = {newRegistrar: string; yes: boolean}; - -task("manage:IndexFund:updateRegistrar", "Will update the registrar address of the IndexFund") - .addOptionalParam( - "newRegistrar", - "Address of the new registrar. Will default to `contract-address.json > registrar.proxy` if none is provided." - ) - .addFlag("yes", "Automatic yes to prompt.") - .setAction(async (taskArgs: TaskArgs, hre) => { - try { - logger.divider(); - const addresses = await getAddresses(hre); - const {apTeamMultisigOwners} = await getSigners(hre); - - const newRegistrar = taskArgs.newRegistrar || addresses.registrar.proxy; - - logger.out("Querying current IndexFund registrar..."); - const indexFund = IndexFund__factory.connect( - addresses.indexFund.proxy, - apTeamMultisigOwners[0] - ); - const curRegistrar = (await indexFund.queryConfig()).registrarContract; - if (curRegistrar === newRegistrar) { - return logger.out(`"${newRegistrar}" is already set as the registrar address.`); - } - logger.out(`Current registrar: ${curRegistrar}`); - - const isConfirmed = - taskArgs.yes || (await confirmAction(`Update Registrar address to: ${newRegistrar}`)); - if (!isConfirmed) { - return logger.out("Confirmation denied.", logger.Level.Warn); - } - - logger.out(`Updating Registrar address to: ${newRegistrar}...`); - const curOwner = (await indexFund.queryConfig()).owner; - const apTeamMultiSig = APTeamMultiSig__factory.connect( - curOwner, // ensure connection to current owning APTeamMultiSig contract - apTeamMultisigOwners[0] - ); - const data = indexFund.interface.encodeFunctionData("updateRegistrar", [newRegistrar]); - const tx = await apTeamMultiSig.submitTransaction(indexFund.address, 0, data, "0x"); - logger.out(`Tx hash: ${tx.hash}`); - await tx.wait(); - - const updatedOwner = (await indexFund.queryConfig()).registrarContract; - logger.out(`New registrar: ${updatedOwner}`); - } catch (error) { - logger.out(error, logger.Level.Error); - } - }); diff --git a/test/core/IndexFund.ts b/test/core/IndexFund.ts index d78b84ab3..d98b0a4a0 100644 --- a/test/core/IndexFund.ts +++ b/test/core/IndexFund.ts @@ -28,6 +28,7 @@ import { import {genWallet, getSigners} from "utils"; import {deployFacetAsProxy} from "test/core/accounts/utils/deployTestFacet"; import {AccountStorage} from "typechain-types/contracts/test/accounts/TestFacetProxyContract"; +import {RegistrarStorage} from "typechain-types/contracts/core/registrar/Registrar"; describe("IndexFund", function () { const {ethers, upgrades} = hre; @@ -498,7 +499,7 @@ describe("IndexFund", function () { currTime + 42069 ) ) - .to.emit("FundCreated") + .to.emit(indexFund, "FundCreated") .withArgs(3); time.increase(42069); // move time forward so Fund #3 is @ expiry @@ -507,7 +508,7 @@ describe("IndexFund", function () { expect(activeFund.id).to.equal(3); // should fail when prep clean up process removes the expired fund, leaving 0 funds available - expect(indexFund.depositERC20(0, token.address, 500, 0)).to.be.revertedWith( + expect(indexFund.depositERC20(0, token.address, 500)).to.be.revertedWith( "Must have rotating funds active to pass a Fund ID of 0" ); }); @@ -515,7 +516,7 @@ describe("IndexFund", function () { it("passes for a specific fund, amount > min & token is valid", async function () { // create 1 active, rotating fund expect(await indexFund.createIndexFund("Test Fund #4", "Test fund", [2, 3], true, 50, 0)) - .to.emit("FundCreated") + .to.emit(indexFund, "FundCreated") .withArgs(4); expect( @@ -531,7 +532,7 @@ describe("IndexFund", function () { it("passes for an active fund donation(amount-based rotation), amount > min & token is valid", async function () { // create 1 more active, rotating fund for full rotation testing expect(await indexFund.createIndexFund("Test Fund #5", "Test fund", [2], true, 100, 0)) - .to.emit("FundCreated") + .to.emit(indexFund, "FundCreated") .withArgs(5); let ifState = await indexFund.queryState(); diff --git a/test/core/accounts/AccountsUpdateStatusEndowments.ts b/test/core/accounts/AccountsUpdateStatusEndowments.ts index 8873a7783..3aa262448 100644 --- a/test/core/accounts/AccountsUpdateStatusEndowments.ts +++ b/test/core/accounts/AccountsUpdateStatusEndowments.ts @@ -172,7 +172,7 @@ describe("AccountsUpdateStatusEndowments", function () { expect(endowState[1].enumData).to.equal(1); expect(endowState[1].data.addr).to.equal(ethers.constants.AddressZero); expect(endowState[1].data.endowId).to.equal(0); - expect(endowState[1].data.fundId).to.equal(funds[0].id); + expect(endowState[1].data.fundId).to.equal(funds[0]); }); });