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

feat(Gas Oracle): Conversion rate component #1319

Conversation

SantiagoPittella
Copy link

What ❔

Why ❔

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zk fmt and zk lint.
  • Spellcheck has been run via zk spellcheck.
  • Linkcheck has been run via zk linkcheck.

@lferrigno lferrigno marked this pull request as ready for review March 6, 2024 14:32
@jrchatruc jrchatruc requested a review from popzxc March 7, 2024 13:34
Comment on lines 35 to 36
let mut rng = rand::thread_rng();
let random_number: u64 = rng.gen_range(1..=100);
Copy link
Member

Choose a reason for hiding this comment

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

I think it'll be too volatile for any actual usage. Let's hardcode this as a const for now and later alter the logic as soon as it's needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in latest commit:

async fn get_conversion_rate(extract::Path(_token_address): extract::Path<String>) -> Json<u64> {
    tracing::info!("Received request for conversion rate");
    Json(42)
}

Comment on lines 239 to 240
/// Conversion rate API, for local development.
ConversionRateApi,
Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to prepend it with Dev here and everywhere else to clearly indicate that it's a local development utility and not something that is needed for production.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Member

@popzxc popzxc left a comment

Choose a reason for hiding this comment

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

A few leftovers

// basic handler that responds with a static string
async fn get_conversion_rate(extract::Path(_token_address): extract::Path<String>) -> Json<u64> {
tracing::info!("Received request for conversion rate");
Json(42)
Copy link
Member

Choose a reason for hiding this comment

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

Nice.

@@ -270,6 +273,7 @@ impl FromStr for Components {
"eth_tx_manager" => Ok(Components(vec![Component::EthTxManager])),
"proof_data_handler" => Ok(Components(vec![Component::ProofDataHandler])),
"native_token_fetcher" => Ok(Components(vec![Component::NativeTokenFetcher])),
"conversion_rate_api" => Ok(Components(vec![Component::DevConversionRateApi])),
Copy link
Member

Choose a reason for hiding this comment

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

conversion_rate_api -> dev_conversion_rate_api

Copy link
Contributor

Choose a reason for hiding this comment

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

Done!

@@ -76,6 +76,7 @@ use crate::{
},
};

pub mod api_conversion_rate;
Copy link
Member

Choose a reason for hiding this comment

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

api_conversion_rate -> dev_api_conversion_rate

Copy link
Contributor

Choose a reason for hiding this comment

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

Changed too.

@jrchatruc jrchatruc changed the title Conversion rate component feat(Gas Oracle): Conversion rate component Mar 11, 2024
@jrchatruc jrchatruc merged commit feaf132 into matter-labs:lambdaclass_gas_oracle Mar 11, 2024
2 of 3 checks passed
@jrchatruc jrchatruc deleted the conversion_rate_component branch March 11, 2024 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants