Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating new OrderbookYaml and DotrainYaml structs #1043

Closed
wants to merge 14 commits into from

Conversation

findolor
Copy link
Collaborator

@findolor findolor commented Dec 4, 2024

Motivation

See issue: #1035

Solution

  • Created two new structs called OrderbookYaml and DotrainYaml
  • Implemented the constructor function that converts a yaml string to each struct
  • Added tests

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Missing things

  • Plot support in charts field in DotrainYaml
  • Data validation during initialization and setter functions
  • Field validation during initialization and setter functions
  • Getter functions for each struct

@findolor findolor self-assigned this Dec 4, 2024
@findolor findolor linked an issue Dec 4, 2024 that may be closed by this pull request
@findolor findolor marked this pull request as ready for review December 6, 2024 11:42
@findolor findolor requested a review from hardyjosh December 6, 2024 11:43
chain_id: require_string(
&value,
Some("chain-id"),
Some(format!("chain-id string missing in network: {key}")),
Copy link
Contributor

Choose a reason for hiding this comment

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

i think saying string here is a bit confusing, because it's also an error in the next step if it's a string (because it can't be parsed to a u64). from the user perspective if they put "one", that's not valid, but this error indicates it would be

let key = key.as_str().unwrap_or_default().to_string();
let network = Network {
document: document.clone(),
name: key.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

i know it's not part of this PR, but i think the name field should be renamed to "key" as it's more generic and can be used across all the structs, whereas "name" collides with Token name for example

@@ -45,9 +47,81 @@ impl Network {
}
}

pub fn parse_networks_from_yaml(
Copy link
Contributor

Choose a reason for hiding this comment

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

if we make this generic like parse_all_from_yaml could it be trait?

.map(|(key, value)| {
let key = key.as_str().unwrap_or_default().to_string();
let network = Network {
document: document.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

if you clone the document it will still hold the reference back to the original right?

@findolor findolor closed this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use strictyaml for parsing dotrain yaml
2 participants