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

Commit

Permalink
update tests; fix TS errors; Manage IF updateReg >> updateConfig;
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey authored and Andrey committed Aug 2, 2023
1 parent 0c57010 commit c664572
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 108 deletions.
2 changes: 1 addition & 1 deletion contracts/core/index-fund/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion tasks/deploy/deployIndexFund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 0 additions & 24 deletions tasks/manage/changeOwner.ts

This file was deleted.

1 change: 0 additions & 1 deletion tasks/manage/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "./accounts";
import "./addMultisigOwner";
import "./changeAdmin";
import "./changeOwner";
import "./charityApplications";
import "./createEndowment";
import "./createIndexFund";
Expand Down
3 changes: 1 addition & 2 deletions tasks/manage/indexFund/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
import "./updateOwner";
import "./updateRegistrar";
import "./updateConfig";
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
54 changes: 0 additions & 54 deletions tasks/manage/indexFund/updateRegistrar.ts

This file was deleted.

9 changes: 5 additions & 4 deletions test/core/IndexFund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand All @@ -507,15 +508,15 @@ 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"
);
});

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(
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/core/accounts/AccountsUpdateStatusEndowments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
});

Expand Down

0 comments on commit c664572

Please sign in to comment.