add Zod validation of state chain objects, infer types#1485
add Zod validation of state chain objects, infer types#1485
Conversation
|
|
||
| // Version number of latest known migration | ||
| const latest = Math.max(...Object.keys(migrations).map((n) => parseInt(n))) | ||
| const latest = migrations[migrations.length - 1].version |
There was a problem hiding this comment.
You might use dynamic import to avoid having to specify new migrations here each time, something like
- get array of dirNames in migrations dir
- map array to dynamic import of each migration index file
- sort as on line 9 above
There was a problem hiding this comment.
I thought about this but deferred as it would make the migration process async and I thought it might be too much of a moving target to change the sync/async nature of the entire startup flow on top of all of these other changes. I do think this makes sense as a future optimization though as it will make it easier to manage migrations and not have to worry about adding them in two places.
There was a problem hiding this comment.
gonna just try a couple things though to see if there's something easy here
There was a problem hiding this comment.
ahh yeah I think we'd need to use top-level await and that would require us changing our TS config, so at a minimum I think this is best left for another PR
| export default { | ||
| version: 35, | ||
| migrate | ||
| } |
There was a problem hiding this comment.
Prefer to use named exports and, e.g. import * as migration35 when exporting objects like this. If using the dynamic import I suggested above a named export will play nicer too
There was a problem hiding this comment.
I want to leave it as is, at least for now, as I don't want these modules exporting multiple different things (ie a field called version and function called migrate), I want them exporting just one thing: an object of type Migration
* add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing
* add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing
* add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing
* add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing
* add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing
* add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing
* Integrate pylon evm (#1478) * bump version * remove infura and alchemy presets, use pylon * update package lock * remove gnosis chain preset * fix chain name * move migrations to separate files, use TS (#1482) * add Zod validation of state chain objects, infer types (#1485) * add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing * Choose summon keybinding (#1494) Co-authored-by: goosewobbler <[email protected]> Co-authored-by: goosewobbler <[email protected]> * re-order migrations * convert hot signers to TS, make tests run reliably * more commits * update comment * remove unneeded assignment * make worker interaction more typesafe * remove unused code * remove unused interface * fix tests * revert weird test change * try revert file * try move * decouple worker controller and launch script, write controller tests * fix worker exit in tests * remove double cast * rename some files * remove ignore * clean up worker interface * last cleanup, fix typed data * more type safety * rebase, add bip39 type * remove ts-ignores * remove rebase artifact * remove migration files * update package lock --------- Co-authored-by: goosewobbler <[email protected]> Co-authored-by: goosewobbler <[email protected]>
* add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing
* Integrate pylon evm (#1478) * bump version * remove infura and alchemy presets, use pylon * update package lock * remove gnosis chain preset * fix chain name * move migrations to separate files, use TS (#1482) * add Zod validation of state chain objects, infer types (#1485) * add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing * Choose summon keybinding (#1494) Co-authored-by: goosewobbler <[email protected]> Co-authored-by: goosewobbler <[email protected]> * re-order migrations * convert hot signers to TS, make tests run reliably * more commits * update comment * remove unneeded assignment * make worker interaction more typesafe * remove unused code * remove unused interface * fix tests * revert weird test change * try revert file * try move * decouple worker controller and launch script, write controller tests * fix worker exit in tests * remove double cast * rename some files * remove ignore * clean up worker interface * last cleanup, fix typed data * more type safety * rebase, add bip39 type * remove ts-ignores * remove rebase artifact * remove migration files * update package lock --------- Co-authored-by: goosewobbler <[email protected]> Co-authored-by: goosewobbler <[email protected]>
* add Zod validation of state chain objects, infer types * move state files to TS, add more inferred types * fix persist mock for tests * add types to main state * update test * add mute notification schema * move type export to state main * move legacy file to TS * try new migration format * update legacy migrations and tests * fix gas fees type * fix gas type * move legacy mapping * final migration prototype * finish migration poc * finish cleaning up migrations * test cleanup * fix compilation error * fix state parsing
No description provided.