-
Notifications
You must be signed in to change notification settings - Fork 0
Make manage:registrar:setStrarParam
more intuitive
#395
base: master
Are you sure you want to change the base?
Conversation
@@ -12,7 +12,7 @@ export type StratConfig = { | |||
params: LocalRegistrarLib.StrategyParamsStruct; | |||
}; | |||
|
|||
export type AllStratConfigs = Record<string, StratConfig>; | |||
export type AllStratConfigs = Record<"dummy" | "flux", StratConfig>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better type-safety
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
evm-smart-contracts/tasks/deploy/integrations/helpers/fullStrategy.ts
Lines 18 to 19 in 48bcff3
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> = { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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>; |
There was a problem hiding this comment.
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?
Explanation of the solution
Fixes issues with and addresses #384 (review)
Instructions on making this work
yarn
oryarn install
to install npm dependencies