feat: prompt for start block on rpc url networks in contract import#4
Conversation
JonoPrest
left a comment
There was a problem hiding this comment.
@DenhamPreen just noting I reviewed on the old repo. Perhaps you can check comments there.
e5cab59 to
79a7331
Compare
|
https://github.com/Float-Capital/indexer/pull/1511/files @JonoPrest this addresses all the feedback from your review here. Will fix tests |
| fn prompt_for_start_block() -> Result<u64> { | ||
| let prompt = Text::new( | ||
| "You have entered a network that is unsupported by HyperSync. Please provide a start block for this network \ | ||
| (this can be edited later in config.yaml):", | ||
| ) | ||
| .prompt(); | ||
|
|
||
| let start_block: String = prompt.context("Failed during start block prompt")?; | ||
| let start_block: u64 = start_block | ||
| .trim() | ||
| .parse() | ||
| .context("Failed to parse start block, start block must be a number")?; | ||
|
|
||
| Ok(start_block) | ||
| } |
There was a problem hiding this comment.
@DenhamPreen have a look at inquires docs on "CustomType" https://github.com/mikaelmello/inquire?tab=readme-ov-file#customtype
It's not a big one but the parsing then becomes built in and on top of that you get an error message where you can retry rather than a failure during the prompting process.
JonoPrest
left a comment
There was a problem hiding this comment.
Thanks Den!
I've disabled auto-merge because there's one more comment I made on the actual prompt code. It's non blocking but can be an improvement to stop annoying exits half way through the import process.
Migrated PR from Float-Capital/indexer#1511