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

Make manage:registrar:setStrarParam more intuitive #395

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

0xNeshi
Copy link
Contributor

@0xNeshi 0xNeshi commented Oct 2, 2023

Explanation of the solution

Fixes issues with and addresses #384 (review)

Instructions on making this work

  • run yarn or yarn install to install npm dependencies

@0xNeshi 0xNeshi added bug Something isn't working enhancement New feature or request labels Oct 2, 2023
@0xNeshi 0xNeshi self-assigned this Oct 2, 2023
@@ -12,7 +12,7 @@ export type StratConfig = {
params: LocalRegistrarLib.StrategyParamsStruct;
};

export type AllStratConfigs = Record<string, StratConfig>;
export type AllStratConfigs = Record<"dummy" | "flux", StratConfig>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better type-safety

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of this change. It means that each new strategy has to modify a Type which doesn't seem like it's a meaningful Type def. I would prefer the only edits necessary to be in the StratConfig.ts. Are there other ways we could make this more type safe without being overly restrictive here?

Copy link
Contributor Author

@0xNeshi 0xNeshi Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevieraykatz

Are there other ways we could make this more type safe without being overly restrictive here?

I think type-safety and restrictiveness come in a package 😕

I understood this type to be to strategy-addresses.json what type AddressObj is to contract-address.json. In order to make it even more so, defining keys strictly (this change) makes it so that we know for sure what the expected strategy names are; then we can do things like:

export async function deployStrategySet(
strategyName: keyof AllStratConfigs,

If you think we better leave this change for some other time, I'll remove it for now

@@ -75,9 +75,9 @@ const booleanArray: CLIArgumentType<Array<boolean>> = {
},
};

const stratConfig: CLIArgumentType<StratConfig> = {
const stratConfig: CLIArgumentType<string> = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cliTypes.stratConfig now expects the passed argument to be a key defined in allStrategyConfigs (atm: dummy, flux).
It no longer converts this key into type StratConfig, but lets the task to this itself, thus aligning the expected parameter type and resulting parameter type (for more info see: #384 (review))


type TaskArgs = {
stratConfig: StratConfig;
strategyName: keyof AllStratConfigs;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the expected type in cliTypes.stratConfig.validate

@@ -15,7 +16,7 @@ import {deployVaultPair} from "contracts/core/vault/scripts/deployVaultPair";
import {HardhatRuntimeEnvironment} from "hardhat/types";

export async function deployStrategySet(
strategyName: string,
strategyName: keyof AllStratConfigs,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better type-safety

@@ -12,7 +12,7 @@ export type StratConfig = {
params: LocalRegistrarLib.StrategyParamsStruct;
};

export type AllStratConfigs = Record<string, StratConfig>;
export type AllStratConfigs = Record<"dummy" | "flux", StratConfig>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of this change. It means that each new strategy has to modify a Type which doesn't seem like it's a meaningful Type def. I would prefer the only edits necessary to be in the StratConfig.ts. Are there other ways we could make this more type safe without being overly restrictive here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants