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

Move all helper types to utils/* folder #246

Merged
merged 8 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tasks/manage/registrar/setFeeSetting.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {task, types} from "hardhat/config";
import {Registrar__factory, APTeamMultiSig__factory} from "typechain-types";
import {getAddresses, getSigners, logger} from "utils";
import {APTeamMultiSig__factory, Registrar__factory} from "typechain-types";
import {FeeTypes, getAddresses, getEnumKeys, getSigners, logger} from "utils";

type TaskArgs = {feeType: number; payoutAddress: string; bps: number};

task("manage:registrar:setFeeSettings")
.addParam(
"feeType",
"The enum of the fee. {0:DEFAULT, 1:HARVEST, 2:WITHDRAWCHARITY, 3:WITHDRAWNORMAL, 4:EARLYLOCKEDWITHDRAWCHARITY, 5:EARLYLOCKEDWITHDRAWNORMAL}",
`The enum of the fee, possible values: ${getEnumKeys(FeeTypes)
.map((key) => `${key} - ${FeeTypes[key]}`)
.join(", ")}`,
0,
types.int
)
Expand Down
15 changes: 13 additions & 2 deletions tasks/manage/registrar/setStratApproval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import {task, types} from "hardhat/config";
import {Registrar__factory, APTeamMultiSig__factory} from "typechain-types";
import {getAddresses, getSigners, StratConfig, logger} from "utils";
import {
getAddresses,
getSigners,
StratConfig,
logger,
StrategyApprovalState,
getEnumKeys,
} from "utils";
import {allStrategyConfigs} from "../../../contracts/integrations/stratConfig";

type TaskArgs = {name: string; approvalState: number};
Expand All @@ -16,7 +23,11 @@ task("manage:registrar:setStratApproval")
)
.addParam(
"approvalState",
"Whether the strategy is currently approved or not, enum of {NOT_APPROVED,APPROVED,WITHDRAW_ONLY,DEPRECATED}",
`Whether the strategy is currently approved or not, possible values: ${getEnumKeys(
StrategyApprovalState
)
.map((key) => `${key} - ${StrategyApprovalState[key]}`)
.join(", ")}`,
0,
types.int
)
Expand Down
4 changes: 2 additions & 2 deletions test/core/accounts/AccountsCreateEndowment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {expect, use} from "chai";
import {BigNumber} from "ethers";
import hre from "hardhat";
import {DEFAULT_REGISTRAR_CONFIG, FeeTypes} from "test/utils";
import {DEFAULT_REGISTRAR_CONFIG} from "test/utils";
import {
AccountsCreateEndowment,
AccountsCreateEndowment__factory,
Expand All @@ -18,7 +18,7 @@ import {
import {AccountMessages} from "typechain-types/contracts/core/accounts/facets/AccountsCreateEndowment";
import {LocalRegistrarLib} from "typechain-types/contracts/core/registrar/LocalRegistrar";
import {RegistrarStorage} from "typechain-types/contracts/core/registrar/Registrar";
import {genWallet, getSigners} from "utils";
import {FeeTypes, genWallet, getSigners} from "utils";
import {deployFacetAsProxy} from "./utils";

use(smock.matchers);
Expand Down
4 changes: 2 additions & 2 deletions test/core/accounts/AccountsDeployContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {impersonateAccount, setBalance} from "@nomicfoundation/hardhat-network-h
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {expect, use} from "chai";
import hre from "hardhat";
import {DEFAULT_REGISTRAR_CONFIG, EndowmentType, TokenType, VeTypeEnum} from "test/utils";
import {DEFAULT_REGISTRAR_CONFIG} from "test/utils";
import {
AccountsDeployContract,
AccountsDeployContract__factory,
Expand All @@ -17,7 +17,7 @@ import {
} from "typechain-types";
import {SubDaoMessages} from "typechain-types/contracts/core/accounts/facets/AccountsDeployContract";
import {RegistrarStorage} from "typechain-types/contracts/core/registrar/Registrar";
import {genWallet, getSigners} from "utils";
import {EndowmentType, TokenType, VeTypeEnum, genWallet, getSigners} from "utils";
import {deployFacetAsProxy} from "./utils/deployTestFacet";

use(smock.matchers);
Expand Down
64 changes: 29 additions & 35 deletions test/core/accounts/AccountsDepositWithdrawEndowments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {expect, use} from "chai";
import {BigNumber} from "ethers";
import hre from "hardhat";
import {DEFAULT_CHARITY_ENDOWMENT, DEFAULT_REGISTRAR_CONFIG, FeeTypes, VaultType} from "test/utils";
import {DEFAULT_CHARITY_ENDOWMENT, DEFAULT_REGISTRAR_CONFIG} from "test/utils";
import {
AccountsDepositWithdrawEndowments,
AccountsDepositWithdrawEndowments__factory,
Expand All @@ -23,7 +23,7 @@ import {
import {AccountMessages} from "typechain-types/contracts/core/accounts/facets/AccountsDepositWithdrawEndowments";
import {LibAccounts, RegistrarStorage} from "typechain-types/contracts/core/registrar/Registrar";
import {AccountStorage} from "typechain-types/contracts/test/accounts/TestFacetProxyContract";
import {genWallet, getSigners} from "utils";
import {FeeTypes, VaultType, genWallet, getSigners} from "utils";
import {deployFacetAsProxy} from "./utils";

use(smock.matchers);
Expand Down Expand Up @@ -212,17 +212,15 @@ describe("AccountsDepositWithdrawEndowments", function () {
const expectedLiquidAmt = BigNumber.from(value);

await expect(
facet
.connect(indexFund)
.depositMatic(
{
id: charityId,
lockedPercentage: 0,
liquidPercentage: 100,
donationMatch: ethers.constants.AddressZero,
},
{value}
)
facet.connect(indexFund).depositMatic(
{
id: charityId,
lockedPercentage: 0,
liquidPercentage: 100,
donationMatch: ethers.constants.AddressZero,
},
{value}
)
)
.to.emit(facet, "EndowmentDeposit")
.withArgs(charityId, wmaticFake.address, expectedLockedAmt, expectedLiquidAmt);
Expand Down Expand Up @@ -251,17 +249,15 @@ describe("AccountsDepositWithdrawEndowments", function () {
wmaticFake.transfer.returns(true);

await expect(
facet
.connect(indexFund)
.depositMatic(
{
id: charityId,
lockedPercentage: 0,
liquidPercentage: 100,
donationMatch: ethers.constants.AddressZero,
},
{value}
)
facet.connect(indexFund).depositMatic(
{
id: charityId,
lockedPercentage: 0,
liquidPercentage: 100,
donationMatch: ethers.constants.AddressZero,
},
{value}
)
)
.to.emit(facet, "EndowmentDeposit")
.withArgs(charityId, wmaticFake.address, expectedLockedAmt, expectedLiquidAmt);
Expand Down Expand Up @@ -397,17 +393,15 @@ describe("AccountsDepositWithdrawEndowments", function () {
const expectedLiquidAmt = BigNumber.from(value);

await expect(
facet
.connect(indexFund)
.depositMatic(
{
id: normalEndowId,
lockedPercentage: 0,
liquidPercentage: 100,
donationMatch: ethers.constants.AddressZero,
},
{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);
Expand Down
4 changes: 2 additions & 2 deletions test/core/accounts/AccountsDonationMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {expect, use} from "chai";
import {BigNumber} from "ethers";
import hre from "hardhat";
import {DEFAULT_CHARITY_ENDOWMENT, DEFAULT_REGISTRAR_CONFIG, DonationMatchEnum} from "test/utils";
import {DEFAULT_CHARITY_ENDOWMENT, DEFAULT_REGISTRAR_CONFIG} from "test/utils";
import {
AccountsDonationMatch,
AccountsDonationMatch__factory,
Expand All @@ -21,7 +21,7 @@ import {AccountMessages} from "typechain-types/contracts/core/accounts/facets/Ac
import {RegistrarStorage} from "typechain-types/contracts/core/registrar/Registrar";
import {DonationMatchStorage} from "typechain-types/contracts/normalized_endowment/donation-match/DonationMatchEmitter";
import {AccountStorage} from "typechain-types/contracts/test/accounts/TestFacetProxyContract";
import {genWallet, getSigners} from "utils";
import {DonationMatchEnum, genWallet, getSigners} from "utils";
import {deployFacetAsProxy} from "./utils";

use(smock.matchers);
Expand Down
20 changes: 9 additions & 11 deletions test/core/accounts/AccountsStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import {
DEFAULT_SETTINGS_STRUCT,
DEFAULT_STRATEGY_PARAMS,
DEFAULT_STRATEGY_SELECTOR,
StrategyApprovalState,
VaultActionStatus,
VaultActionStructToArray,
convertVaultActionStructToArray,
deployDummyERC20,
deployDummyGateway,
deployDummyVault,
Expand All @@ -42,7 +40,7 @@ import {
} from "typechain-types";
import {IAccountsStrategy} from "typechain-types/contracts/core/registrar/Registrar";
import {AccountStorage} from "typechain-types/contracts/test/accounts/TestFacetProxyContract";
import {getSigners} from "utils";
import {StrategyApprovalState, VaultActionStatus, getSigners} from "utils";
import {deployFacetAsProxy} from "./utils";

use(smock.matchers);
Expand Down Expand Up @@ -1129,7 +1127,7 @@ describe("AccountsStrategy", function () {
status: VaultActionStatus.UNPROCESSED,
};
const payload = packActionData(action);
const returnedAction = VaultActionStructToArray(action);
const returnedAction = convertVaultActionStructToArray(action);
await expect(
facet.execute(ethers.utils.formatBytes32String("true"), "NotNet", owner.address, payload)
)
Expand All @@ -1149,7 +1147,7 @@ describe("AccountsStrategy", function () {
status: VaultActionStatus.UNPROCESSED,
};
const payload = packActionData(action);
const returnedAction = VaultActionStructToArray(action);
const returnedAction = convertVaultActionStructToArray(action);
await expect(
facet.executeWithToken(
ethers.utils.formatBytes32String("true"),
Expand All @@ -1176,7 +1174,7 @@ describe("AccountsStrategy", function () {
status: VaultActionStatus.UNPROCESSED,
};
const payload = packActionData(action);
const returnedAction = VaultActionStructToArray(action);
const returnedAction = convertVaultActionStructToArray(action);
await expect(
facet.execute(ethers.utils.formatBytes32String("true"), "ThatNet", owner.address, payload)
)
Expand All @@ -1196,7 +1194,7 @@ describe("AccountsStrategy", function () {
status: VaultActionStatus.UNPROCESSED,
};
const payload = packActionData(action);
const returnedAction = VaultActionStructToArray(action);
const returnedAction = convertVaultActionStructToArray(action);
await expect(
facet.executeWithToken(
ethers.utils.formatBytes32String("true"),
Expand All @@ -1223,7 +1221,7 @@ describe("AccountsStrategy", function () {
status: VaultActionStatus.FAIL_TOKENS_FALLBACK,
};
const payload = packActionData(action);
const returnedAction = VaultActionStructToArray(action);
const returnedAction = convertVaultActionStructToArray(action);
expect(
await facet.execute(
ethers.utils.formatBytes32String("true"),
Expand All @@ -1248,7 +1246,7 @@ describe("AccountsStrategy", function () {
status: VaultActionStatus.UNPROCESSED,
};
const payload = packActionData(action);
const returnedAction = VaultActionStructToArray(action);
const returnedAction = convertVaultActionStructToArray(action);
await expect(
facet.execute(ethers.utils.formatBytes32String("true"), "ThatNet", router.address, payload)
)
Expand Down Expand Up @@ -1419,7 +1417,7 @@ describe("AccountsStrategy", function () {
status: VaultActionStatus.UNPROCESSED,
};
const payload = packActionData(action);
const returnedAction = VaultActionStructToArray(action);
const returnedAction = convertVaultActionStructToArray(action);

const apParams = {
...DEFAULT_AP_PARAMS,
Expand Down
3 changes: 1 addition & 2 deletions test/core/accounts/AccountsSwapRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
DEFAULT_CHARITY_ENDOWMENT,
DEFAULT_PERMISSIONS_STRUCT,
DEFAULT_REGISTRAR_CONFIG,
VaultType,
} from "test/utils";
import {
AccountsSwapRouter,
Expand All @@ -24,7 +23,7 @@ import {
Registrar__factory,
TestFacetProxyContract,
} from "typechain-types";
import {genWallet, getSigners} from "utils";
import {VaultType, genWallet, getSigners} from "utils";
import {deployFacetAsProxy} from "./utils";

use(smock.matchers);
Expand Down
4 changes: 2 additions & 2 deletions test/core/accounts/AccountsUpdateEndowments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {expect, use} from "chai";
import {BigNumberish} from "ethers";
import hre from "hardhat";
import {ControllerSettingOption, DEFAULT_CHARITY_ENDOWMENT, DelegateAction} from "test/utils";
import {DEFAULT_CHARITY_ENDOWMENT} from "test/utils";
import {
AccountsUpdateEndowments,
AccountsUpdateEndowments__factory,
Expand All @@ -18,7 +18,7 @@ import {
AccountStorage,
LibAccounts,
} from "typechain-types/contracts/test/accounts/TestFacetProxyContract";
import {genWallet, getSigners} from "utils";
import {ControllerSettingOption, DelegateAction, genWallet, getSigners} from "utils";
import {deployFacetAsProxy, updateAllSettings, updateSettings} from "./utils";

use(smock.matchers);
Expand Down
2 changes: 1 addition & 1 deletion test/core/accounts/utils/updateSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
LibAccounts,
TestFacetProxyContract,
} from "typechain-types/contracts/test/accounts/TestFacetProxyContract";
import {DeepPartial} from "types";
import {DeepPartial} from "utils/types";

/**
* Updates endowment's setting's permissions field in a way that has no side-effects
Expand Down
4 changes: 2 additions & 2 deletions test/core/registrar/LocalRegistrar.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {SignerWithAddress} from "@nomiclabs/hardhat-ethers/signers";
import {expect} from "chai";
import hre from "hardhat";
import {getSigners} from "utils";
import {StrategyApprovalState, getSigners} from "utils";

import {LocalRegistrar, LocalRegistrar__factory} from "typechain-types";
import {DEFAULT_NETWORK_INFO, StrategyApprovalState} from "test/utils";
import {DEFAULT_NETWORK_INFO} from "test/utils";

describe("Local Registrar", function () {
const {ethers, upgrades} = hre;
Expand Down
Loading