Skip to content

Commit

Permalink
Merge branch 'main' into 01/13/25-theme-responsive-raindex-logo
Browse files Browse the repository at this point in the history
  • Loading branch information
hardyjosh authored Jan 14, 2025
2 parents 424f22f + 2a65df5 commit d55d4b1
Show file tree
Hide file tree
Showing 16 changed files with 697 additions and 208 deletions.
3 changes: 3 additions & 0 deletions crates/js_api/src/gui/order_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ impl DotrainOrderGui {
let deployment = self.get_current_deployment()?;
self.check_token_addresses()?;
self.populate_vault_ids(&deployment)?;
let deployment = self.get_current_deployment()?;

let token_deposits = self
.get_vaults_and_deposits(&deployment)?
Expand Down Expand Up @@ -217,6 +218,7 @@ impl DotrainOrderGui {
self.check_token_addresses()?;
self.populate_vault_ids(&deployment)?;
self.update_config_source_bindings(&deployment)?;
let deployment = self.get_current_deployment()?;

let calldata = self
.dotrain_order
Expand All @@ -233,6 +235,7 @@ impl DotrainOrderGui {
self.check_token_addresses()?;
self.populate_vault_ids(&deployment)?;
self.update_config_source_bindings(&deployment)?;
let deployment = self.get_current_deployment()?;

let token_deposits = self
.get_vaults_and_deposits(&deployment)?
Expand Down
10 changes: 6 additions & 4 deletions crates/settings/src/deployer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use strict_yaml_rust::StrictYaml;
use thiserror::Error;
use typeshare::typeshare;
use yaml::{
default_document, optional_string, require_hash, require_string, YamlError, YamlParsableHash,
context::Context, default_document, optional_string, require_hash, require_string, YamlError,
YamlParsableHash,
};

#[cfg(target_family = "wasm")]
Expand Down Expand Up @@ -101,6 +102,7 @@ impl DeployerConfigSource {
impl YamlParsableHash for Deployer {
fn parse_all_from_yaml(
documents: Vec<Arc<RwLock<StrictYaml>>>,
_: Option<&Context>,
) -> Result<HashMap<String, Self>, YamlError> {
let mut deployers = HashMap::new();

Expand All @@ -123,7 +125,7 @@ impl YamlParsableHash for Deployer {
Some(network_name) => network_name,
None => deployer_key.clone(),
};
let network = Network::parse_from_yaml(documents.clone(), &network_name)?;
let network = Network::parse_from_yaml(documents.clone(), &network_name, None)?;

let deployer = Deployer {
document: document.clone(),
Expand Down Expand Up @@ -236,7 +238,7 @@ deployers:
"#;

let documents = vec![get_document(yaml_one), get_document(yaml_two)];
let deployers = Deployer::parse_all_from_yaml(documents).unwrap();
let deployers = Deployer::parse_all_from_yaml(documents, None).unwrap();

assert_eq!(deployers.len(), 2);
assert!(deployers.contains_key("DeployerOne"));
Expand Down Expand Up @@ -272,7 +274,7 @@ deployers:
"#;

let documents = vec![get_document(yaml_one), get_document(yaml_two)];
let error = Deployer::parse_all_from_yaml(documents).unwrap_err();
let error = Deployer::parse_all_from_yaml(documents, None).unwrap_err();

assert_eq!(
error,
Expand Down
71 changes: 45 additions & 26 deletions crates/settings/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use std::{
use strict_yaml_rust::StrictYaml;
use thiserror::Error;
use typeshare::typeshare;
use yaml::{default_document, require_hash, require_string, YamlError, YamlParsableHash};
use yaml::{
context::Context, default_document, require_hash, require_string, YamlError, YamlParsableHash,
};

#[cfg(target_family = "wasm")]
use rain_orderbook_bindings::{impl_all_wasm_traits, wasm_traits::prelude::*};
Expand All @@ -31,6 +33,7 @@ impl_all_wasm_traits!(Deployment);
impl YamlParsableHash for Deployment {
fn parse_all_from_yaml(
documents: Vec<Arc<RwLock<StrictYaml>>>,
_: Option<&Context>,
) -> Result<HashMap<String, Self>, YamlError> {
let mut deployments = HashMap::new();

Expand All @@ -41,26 +44,30 @@ impl YamlParsableHash for Deployment {
for (key_yaml, deployment_yaml) in deployments_hash {
let deployment_key = key_yaml.as_str().unwrap_or_default().to_string();

let scenario = Scenario::parse_from_yaml(
let order = Order::parse_from_yaml(
documents.clone(),
&require_string(
deployment_yaml,
Some("scenario"),
Some("order"),
Some(format!(
"scenario string missing in deployment: {deployment_key}"
"order string missing in deployment: {deployment_key}"
)),
)?,
None,
)?;

let order = Order::parse_from_yaml(
let context = Context::with_order(Arc::new(order.clone()));

let scenario = Scenario::parse_from_yaml(
documents.clone(),
&require_string(
deployment_yaml,
Some("order"),
Some("scenario"),
Some(format!(
"order string missing in deployment: {deployment_key}"
"scenario string missing in deployment: {deployment_key}"
)),
)?,
Some(&context),
)?;

if let Some(deployer) = &order.deployer {
Expand Down Expand Up @@ -238,7 +245,7 @@ mod tests {
let yaml = r#"
test: test
"#;
let error = Deployment::parse_all_from_yaml(vec![get_document(yaml)]).unwrap_err();
let error = Deployment::parse_all_from_yaml(vec![get_document(yaml)], None).unwrap_err();
assert_eq!(
error,
YamlError::ParseError("missing field: deployments".to_string())
Expand All @@ -249,10 +256,10 @@ deployments:
deployment1:
test: test
"#;
let error = Deployment::parse_all_from_yaml(vec![get_document(yaml)]).unwrap_err();
let error = Deployment::parse_all_from_yaml(vec![get_document(yaml)], None).unwrap_err();
assert_eq!(
error,
YamlError::ParseError("scenario string missing in deployment: deployment1".to_string())
YamlError::ParseError("order string missing in deployment: deployment1".to_string())
);

let yaml = r#"
Expand All @@ -264,20 +271,26 @@ deployers:
deployer1:
address: 0x0000000000000000000000000000000000000000
network: network1
scenarios:
scenario1:
bindings:
test: test
tokens:
token1:
address: 0x0000000000000000000000000000000000000000
network: network1
orders:
order1:
inputs:
- token: token1
outputs:
- token: token1
deployer: deployer1
deployments:
deployment1:
scenario: scenario1
order: order1
test: test
"#;
let error = Deployment::parse_all_from_yaml(vec![get_document(yaml)]).unwrap_err();
let error = Deployment::parse_all_from_yaml(vec![get_document(yaml)], None).unwrap_err();
assert_eq!(
error,
YamlError::ParseError("order string missing in deployment: deployment1".to_string())
YamlError::ParseError("scenario string missing in deployment: deployment1".to_string())
);

let yaml = r#"
Expand Down Expand Up @@ -316,7 +329,7 @@ deployments:
scenario: scenario1
order: order1
"#;
let error = Deployment::parse_all_from_yaml(vec![get_document(yaml)]).unwrap_err();
let error = Deployment::parse_all_from_yaml(vec![get_document(yaml)], None).unwrap_err();
assert_eq!(
error.to_string(),
YamlError::ParseDeploymentConfigSourceError(ParseDeploymentConfigSourceError::NoMatch)
Expand Down Expand Up @@ -385,10 +398,13 @@ deployments:
order: order2
"#;

let deployments = Deployment::parse_all_from_yaml(vec![
get_document(&format!("{PREFIX}{yaml_one}")),
get_document(yaml_two),
])
let deployments = Deployment::parse_all_from_yaml(
vec![
get_document(&format!("{PREFIX}{yaml_one}")),
get_document(yaml_two),
],
None,
)
.unwrap();

assert_eq!(deployments.len(), 2);
Expand Down Expand Up @@ -420,10 +436,13 @@ deployments:
order: order2
"#;

let error = Deployment::parse_all_from_yaml(vec![
get_document(&format!("{PREFIX}{yaml_one}")),
get_document(yaml_two),
])
let error = Deployment::parse_all_from_yaml(
vec![
get_document(&format!("{PREFIX}{yaml_one}")),
get_document(yaml_two),
],
None,
)
.unwrap_err();

assert_eq!(
Expand Down
Loading

0 comments on commit d55d4b1

Please sign in to comment.