Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fcf55d8
update select token component to display token dropdown
findolor Jun 13, 2025
3298991
update deployment steps
findolor Jun 13, 2025
92fa80a
add token dropdown test
findolor Jun 13, 2025
3a2e94f
update tests
findolor Jun 13, 2025
55b27db
update tests
findolor Jun 13, 2025
3e723cc
update deployment tests
findolor Jun 13, 2025
820b49e
fix remote tokens logic
findolor Jun 13, 2025
5bf388d
update registry
findolor Jun 13, 2025
2454a1c
Merge branch 'main' into 2025-06-13-token-dropdown-webapp
findolor Jun 17, 2025
44344c1
update
findolor Jun 17, 2025
8f21059
update
findolor Jun 18, 2025
77d9c83
update select token logic
findolor Jun 18, 2025
88c9f66
update tests
findolor Jun 18, 2025
0226880
rename file
findolor Jun 18, 2025
0ac19da
update tests
findolor Jun 18, 2025
a893f8b
Merge branch 'main' into 2025-06-13-token-dropdown-webapp
findolor Jun 18, 2025
f8c2215
Merge branch 'main' into 2025-06-13-token-dropdown-webapp
findolor Jul 10, 2025
d000b2f
update registry url
findolor Jul 10, 2025
c6f0e25
get yaml documents without using dotrain order
findolor Jul 10, 2025
0d5dc0b
refactor remote token fetch logic
findolor Jul 10, 2025
7185df2
update tests
findolor Jul 10, 2025
78a9bba
update registry link
findolor Jul 10, 2025
f7beba7
remove log
findolor Jul 10, 2025
af16884
update registry url
findolor Jul 11, 2025
71f78ae
update link
findolor Jul 11, 2025
77eca64
update test
findolor Jul 11, 2025
02ea7c2
update test
findolor Jul 11, 2025
450a864
Merge branch 'main' into 2025-06-13-token-dropdown-webapp
findolor Jul 11, 2025
0dd652e
update tests
findolor Jul 11, 2025
885c913
increase full deployment timeouts
findolor Jul 12, 2025
d0ddece
update timeouts
findolor Jul 12, 2025
a371a3a
Merge branch 'main' into 2025-06-13-token-dropdown-webapp
findolor Jul 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions crates/common/src/raindex_client/add_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,10 @@ mod tests {
mod non_wasm {
use super::*;
use crate::raindex_client::tests::{get_test_yaml, CHAIN_ID_1_ORDERBOOK_ADDRESS};
use alloy::{
hex::encode_prefixed,
primitives::{Address, B256, U256},
sol_types::SolValue,
};
use alloy_ethers_typecast::rpc::Response;
use alloy::primitives::{Address, U256};
use httpmock::MockServer;
use rain_orderbook_app_settings::spec_version::SpecVersion;
use rain_orderbook_bindings::IOrderBookV4::IO;
use serde_json::json;
use std::{collections::HashMap, str::FromStr};
use std::str::FromStr;

#[tokio::test]
async fn test_get_transaction_add_orders() {
Expand Down
33 changes: 20 additions & 13 deletions crates/js_api/src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ use rain_orderbook_common::{
erc20::ERC20,
};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::io::prelude::*;
use std::{
collections::BTreeMap,
sync::{Arc, RwLock},
};
use strict_yaml_rust::StrictYaml;
use thiserror::Error;
use wasm_bindgen_utils::{impl_wasm_traits, prelude::*, wasm_export};

Expand Down Expand Up @@ -98,10 +102,8 @@ impl DotrainOrderGui {
)]
dotrain: String,
) -> Result<Vec<String>, GuiError> {
let dotrain_order = DotrainOrder::create(dotrain.clone(), None).await?;
Ok(GuiCfg::parse_deployment_keys(
dotrain_order.dotrain_yaml().documents.clone(),
)?)
let documents = DotrainOrderGui::get_yaml_documents(&dotrain)?;
Ok(GuiCfg::parse_deployment_keys(documents)?)
}

/// Creates a new GUI instance for managing a specific deployment configuration.
Expand Down Expand Up @@ -402,10 +404,8 @@ impl DotrainOrderGui {
pub async fn get_strategy_details(
#[wasm_export(param_description = "Complete dotrain YAML content")] dotrain: String,
) -> Result<NameAndDescriptionCfg, GuiError> {
let dotrain_order = DotrainOrder::create(dotrain.clone(), None).await?;
let details =
GuiCfg::parse_strategy_details(dotrain_order.dotrain_yaml().documents.clone())?;
Ok(details)
let documents = DotrainOrderGui::get_yaml_documents(&dotrain)?;
Ok(GuiCfg::parse_strategy_details(documents)?)
}

/// Gets metadata for all deployments defined in the configuration.
Expand Down Expand Up @@ -443,10 +443,8 @@ impl DotrainOrderGui {
pub async fn get_deployment_details(
#[wasm_export(param_description = "Complete dotrain YAML content")] dotrain: String,
) -> Result<BTreeMap<String, NameAndDescriptionCfg>, GuiError> {
let dotrain_order = DotrainOrder::create(dotrain.clone(), None).await?;
Ok(GuiCfg::parse_deployment_details(
dotrain_order.dotrain_yaml().documents.clone(),
)?)
let documents = DotrainOrderGui::get_yaml_documents(&dotrain)?;
Ok(GuiCfg::parse_deployment_details(documents)?)
}

/// Gets metadata for a specific deployment by key.
Expand Down Expand Up @@ -592,6 +590,15 @@ impl DotrainOrderGui {
Ok(rainlang)
}
}
impl DotrainOrderGui {
pub fn get_yaml_documents(dotrain: &str) -> Result<Vec<Arc<RwLock<StrictYaml>>>, GuiError> {
let frontmatter = RainDocument::get_front_matter(&dotrain)
.unwrap_or("")
.to_string();
let dotrain_yaml = DotrainYaml::new(vec![frontmatter.clone()], false)?;
Ok(dotrain_yaml.documents)
}
Comment on lines +594 to +600
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Jul 11, 2025

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Well-implemented YAML parsing helper function

The get_yaml_documents helper function correctly extracts frontmatter and creates a DotrainYaml instance. The error handling is appropriate, and the use of unwrap_or("") for missing frontmatter is consistent with the codebase patterns.

Consider eliminating the unnecessary clone:

 pub fn get_yaml_documents(dotrain: &str) -> Result<Vec<Arc<RwLock<StrictYaml>>>, GuiError> {
-    let frontmatter = RainDocument::get_front_matter(&dotrain)
+    let frontmatter = RainDocument::get_front_matter(dotrain)
         .unwrap_or("")
         .to_string();
-    let dotrain_yaml = DotrainYaml::new(vec![frontmatter.clone()], false)?;
+    let dotrain_yaml = DotrainYaml::new(vec![frontmatter], false)?;
     Ok(dotrain_yaml.documents)
 }

This avoids the unnecessary clone since frontmatter is moved into the vector anyway.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pub fn get_yaml_documents(dotrain: &str) -> Result<Vec<Arc<RwLock<StrictYaml>>>, GuiError> {
let frontmatter = RainDocument::get_front_matter(&dotrain)
.unwrap_or("")
.to_string();
let dotrain_yaml = DotrainYaml::new(vec![frontmatter.clone()], false)?;
Ok(dotrain_yaml.documents)
}
pub fn get_yaml_documents(dotrain: &str) -> Result<Vec<Arc<RwLock<StrictYaml>>>, GuiError> {
let frontmatter = RainDocument::get_front_matter(dotrain)
.unwrap_or("")
.to_string();
let dotrain_yaml = DotrainYaml::new(vec![frontmatter], false)?;
Ok(dotrain_yaml.documents)
}
🤖 Prompt for AI Agents
In crates/js_api/src/gui/mod.rs around lines 594 to 600, the variable
`frontmatter` is cloned unnecessarily when creating the vector for
`DotrainYaml::new`. Remove the `.clone()` call and move `frontmatter` directly
into the vector to avoid the redundant clone operation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we don't need to do this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@findolor Understood, we'll keep the current implementation as is. The suggestion was a minor optimization but not necessary for the current PR's objectives.


🧠 Learnings used
Learnt from: findolor
PR: rainlanguage/rain.orderbook#1983
File: crates/js_api/src/gui/mod.rs:964-1199
Timestamp: 2025-07-11T06:40:49.491Z
Learning: In crates/js_api/src/gui/mod.rs tests, findolor prefers to keep large hardcoded YAML strings (like the validation test YAML) inline in the test file rather than extracting them to separate external files for maintainability purposes.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1956
File: crates/common/src/raindex_client/add_orders.rs:132-132
Timestamp: 2025-07-04T10:24:29.750Z
Learning: In the rain.orderbook codebase, findolor prefers to use `unwrap_or("")` for optional frontmatter in dotrain parsing, allowing empty strings to be handled by downstream validation in `NewConfig::try_from_yaml()` rather than adding explicit early validation checks at the extraction point.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1687
File: crates/js_api/src/gui/mod.rs:258-259
Timestamp: 2025-04-22T12:50:39.581Z
Learning: In `DotrainOrderGui::generate_dotrain_text()`, the call to `.to_string()` on `self.dotrain_order.dotrain()` is necessary because there are two different implementations of the `dotrain()` method - one for WASM targets returning a String and one for non-WASM targets returning a &str. The `.to_string()` ensures type compatibility across different compilation targets.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1474
File: crates/js_api/src/yaml/mod.rs:37-44
Timestamp: 2025-03-31T14:36:11.049Z
Learning: The OrderbookYaml implementation in crates/js_api/src/yaml/mod.rs intentionally parses YAML on demand without caching results. This is a deliberate design choice by the author to process YAML only when needed rather than optimizing for repeated calls.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1477
File: crates/settings/src/yaml/dotrain.rs:20-20
Timestamp: 2025-03-31T18:53:12.208Z
Learning: In the DotrainYaml struct, the cache field is kept public (`pub cache: Cache`) without additional getter methods, which is consistent with the existing design pattern in the codebase where other fields like `documents` are also public.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1474
File: crates/js_api/src/yaml/mod.rs:31-34
Timestamp: 2025-03-31T13:57:59.660Z
Learning: The OrderbookYaml constructor in crates/js_api/src/yaml/mod.rs does not need early YAML validation. The author prefers to validate YAML only when it's actually used rather than during initialization.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1838
File: crates/cli/src/output.rs:29-41
Timestamp: 2025-05-19T07:14:24.219Z
Learning: For the rainlanguage/rain.orderbook repository, findolor prefers minimal documentation for straightforward functions like `output` in crates/cli/src/output.rs where the implementation is self-explanatory.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1483
File: crates/settings/src/yaml/dotrain.rs:20-20
Timestamp: 2025-04-07T09:52:30.960Z
Learning: In the DotrainYaml struct, the newly added `cache` field is kept public without documentation, which the maintainer confirmed is acceptable for now.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1917
File: tauri-app/src/routes/orders/add/+page.svelte:45-47
Timestamp: 2025-06-11T11:39:15.239Z
Learning: In the rain.orderbook codebase, every instance of `Config` (returned by helpers such as `parseDotrainAndYaml`) is guaranteed to include the `dotrainOrder` property; it is never `undefined`.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1599
File: crates/common/src/fuzz/impls.rs:91-113
Timestamp: 2025-04-11T05:55:22.504Z
Learning: Empty frontmatter validation is already handled in DotrainYaml::new through the YamlError::EmptyFile error when the yaml parser produces empty documents.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/settings/src/yaml/mod.rs:176-178
Timestamp: 2025-06-18T19:23:33.747Z
Learning: In crates/settings/src/yaml/mod.rs, the YamlError enum has two distinct error variants: `KeyNotFound(String)` for when a specific YAML key is not found in a hash/map, and `NotFound(String)` for when other types of entities (like networks, orderbooks, etc.) are not found in the configuration. These serve different purposes and should not be consolidated.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1689
File: crates/common/src/frontmatter.rs:6-8
Timestamp: 2025-05-08T06:43:46.920Z
Learning: The user (findolor) prefers to keep documentation minimal and doesn't require explicit @param documentation for the `validate` parameter in the `parse_frontmatter` function.

Learnt from: hardingjam
PR: rainlanguage/rain.orderbook#1515
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/layout.test.ts:0-0
Timestamp: 2025-03-26T16:22:50.224Z
Learning: In the Rain Orderbook project, the DotrainOrderGui.getDeploymentDetail method resolves promises with objects that may contain either a value property or an error property, rather than rejecting promises on errors.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1907
File: packages/orderbook/test/common/test.test.ts:75-77
Timestamp: 2025-06-04T10:21:01.388Z
Learning: The DotrainOrder.create API in packages/orderbook/test/common/test.test.ts is internal and not used directly in consumer applications, so API changes here don't require external breaking change documentation.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1903
File: crates/js_api/src/subgraph/vault.rs:129-138
Timestamp: 2025-06-17T16:33:58.549Z
Learning: findolor prefers downstream error handling over early validation checks for empty RPC lists in vault functions, allowing errors to bubble up from provider creation logic naturally.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1916
File: packages/webapp/src/routes/+layout.ts:26-26
Timestamp: 2025-06-10T12:01:07.418Z
Learning: The user findolor prefers to keep string concatenation using the plus operator over template literals in the rainlanguage/rain.orderbook project, even when static analysis tools suggest the change.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1947
File: crates/common/src/raindex_client/orders.rs:462-1643
Timestamp: 2025-06-24T08:45:10.971Z
Learning: User findolor prefers to keep tests simple and avoid refactoring for maintainability when the code is stable and viewed as "one time thing" that won't require frequent changes.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1975
File: crates/js_api/src/config.rs:44-45
Timestamp: 2025-07-09T07:42:48.458Z
Learning: User findolor prefers to defer code improvements and refactoring suggestions to future PRs when they are not directly related to the current PR's scope, even when the suggestions are valid improvements.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T21:26:31.566Z
Learning: For PR #1884 and future PRs in rainlanguage/rain.orderbook repository, provide PR size reports in a separate comment with ONLY the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number", without any additional text or explanation. Reports should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any additional text or formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.

Learnt from: brusherru
PR: rainlanguage/rain.orderbook#1957
File: packages/ui-components/src/lib/components/tables/OrdersListTable.svelte:86-94
Timestamp: 2025-06-27T18:41:18.194Z
Learning: In the rain.orderbook UI components, the tokensQuery should use `enabled: true` rather than `Object.keys($activeSubgraphs).length > 0` because tokens are needed for filtering functionality even when no specific subgraphs are selected. The multiSubgraphArgs falls back to default subgraphs from settings, so disabling the query when no subgraphs are active would break the token filtering feature.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T23:34:42.328Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must use the format:
TOTAL:number
ADDITIONS:number
DELETIONS:number
with no extra text, formatting blocks, or explanations, and must still exclude lock files and reassess after each new commit.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:46:08.530Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report should be the only content in the comment - no text before it, no text after it, no formatting blocks, just the raw report in the exact format: "TOTAL=number\nADDITIONS=number\nDELETIONS=number". The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/js_api/src/raindex/mod.rs:102-118
Timestamp: 2025-06-18T12:56:44.290Z
Learning: In the rainlanguage/rain.orderbook codebase, it's acceptable to scaffold unused enum variants in initial implementation PRs when they will be implemented in future PRs, as confirmed by findolor.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:35:26.448Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very last part of any comment, after any learning used section or other content.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:35:26.448Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very last part of any comment, after any learning used section or other content.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:47:21.927Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very beginning of any comment, before any learning used section or other content.

}

#[derive(Error, Debug)]
pub enum GuiError {
Expand Down
32 changes: 14 additions & 18 deletions crates/js_api/src/gui/select_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,13 @@ impl DotrainOrderGui {
.await;
results.extend(fetched_results);
results.sort_by(|a, b| {
let na = a.name.to_lowercase();
let nb = b.name.to_lowercase();
na.cmp(&nb).then_with(|| a.address.cmp(&b.address))
a.address
.to_string()
.to_lowercase()
.cmp(&b.address.to_string().to_lowercase())
});
results.dedup_by(|a, b| {
a.address.to_string().to_lowercase() == b.address.to_string().to_lowercase()
});
Comment thread
0xgleb marked this conversation as resolved.

Ok(results)
Expand Down Expand Up @@ -553,26 +557,18 @@ mod tests {
assert_eq!(tokens.len(), 4);
assert_eq!(
tokens[0].address.to_string(),
"0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
);
assert_eq!(
tokens[1].address.to_string(),
"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063"
);
assert_eq!(
tokens[2].address.to_string(),
"0x0000000000000000000000000000000000000001"
);
assert_eq!(tokens[2].decimals, 18);
assert_eq!(tokens[2].name, "Token 3");
assert_eq!(tokens[2].symbol, "T3");
assert_eq!(tokens[0].decimals, 18);
assert_eq!(tokens[0].name, "Token 3");
assert_eq!(tokens[0].symbol, "T3");
assert_eq!(
tokens[3].address.to_string(),
tokens[1].address.to_string(),
"0x0000000000000000000000000000000000000002"
);
assert_eq!(tokens[3].decimals, 6);
assert_eq!(tokens[3].name, "Token 4");
assert_eq!(tokens[3].symbol, "T4");
assert_eq!(tokens[1].decimals, 6);
assert_eq!(tokens[1].name, "Token 4");
assert_eq!(tokens[1].symbol, "T4");
}
}

Expand Down
44 changes: 24 additions & 20 deletions crates/settings/src/remote/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct Tokens {
pub keywords: Vec<String>,
pub version: Version,
pub tokens: Vec<Token>,
#[serde(rename = "logoURI")]
pub logo_uri: String,
}

Expand All @@ -43,28 +44,31 @@ impl Token {
self,
networks: &HashMap<String, NetworkCfg>,
document: Arc<RwLock<StrictYaml>>,
) -> Result<TokenCfg, RemoteTokensError> {
let network = networks
) -> Result<Option<TokenCfg>, RemoteTokensError> {
match networks
.values()
.find(|network| network.chain_id == self.chain_id)
.ok_or(RemoteTokensError::NetworkNotFound(format!(
"network with chain_id {}",
self.chain_id
)))
.cloned()?;

let token_cfg = TokenCfg {
document: document.clone(),
key: self.name.to_lowercase().replace(' ', "-").clone(),
network: Arc::new(network),
address: Address::from_str(&self.address)
.map_err(|e| RemoteTokensError::ParseTokenAddressError(e.to_string()))?,
decimals: Some(self.decimals as u8),
label: Some(self.name.clone()),
symbol: Some(self.symbol),
};

Ok(token_cfg)
{
Some(network) => {
let token_cfg = TokenCfg {
document: document.clone(),
key: format!(
"{}-{}-{}",
network.key,
self.name.replace(' ', "-").clone(),
self.address.to_lowercase()
),
network: Arc::new(network.clone()),
address: Address::from_str(&self.address)
.map_err(|e| RemoteTokensError::ParseTokenAddressError(e.to_string()))?,
decimals: Some(self.decimals as u8),
label: Some(self.name.clone()),
symbol: Some(self.symbol),
};
Ok(Some(token_cfg))
}
None => Ok(None),
}
}
}

Expand Down
51 changes: 31 additions & 20 deletions crates/settings/src/remote_tokens.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::remote::tokens::{RemoteTokensError, Tokens};
use crate::remote::tokens::{RemoteTokensError, Token, Tokens};
use crate::yaml::context::Context;
use crate::yaml::{
default_document, optional_vec, require_string, FieldErrorKind, YamlError, YamlParseableValue,
Expand Down Expand Up @@ -41,17 +41,24 @@ impl RemoteTokensCfg {
.json::<Tokens>()
.await?;

let mut unique_tokens: HashMap<(u32, String), Token> = HashMap::new();
for token in &tokens_res.tokens {
let token_cfg = token
.clone()
.try_into_token_cfg(networks, remote_tokens.document.clone())?;
let token_id = (token.chain_id, token.address.to_lowercase());
unique_tokens.insert(token_id, token.clone());
}

if tokens.contains_key(&token_cfg.key) {
return Err(ParseRemoteTokensError::ConflictingTokens(
token_cfg.key.clone(),
));
for token in unique_tokens.values() {
if let Some(token_cfg) = token
.clone()
.try_into_token_cfg(networks, remote_tokens.document.clone())?
{
if tokens.contains_key(&token_cfg.key) {
return Err(ParseRemoteTokensError::ConflictingTokens(
token_cfg.key.clone(),
));
}
tokens.insert(token_cfg.key.clone(), token_cfg);
}
tokens.insert(token_cfg.key.clone(), token_cfg);
}
Comment on lines +44 to 62
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Jul 11, 2025

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Excellent token deduplication implementation

The deduplication logic correctly identifies unique tokens by (chain_id, lowercase_address) and handles conflicts appropriately. The approach of collecting unique tokens first, then processing them, ensures no duplicate tokens are processed.

Consider a minor performance optimization to avoid cloning tokens:

-            for token in unique_tokens.values() {
-                if let Some(token_cfg) = token
-                    .clone()
-                    .try_into_token_cfg(networks, remote_tokens.document.clone())?
+            for token in unique_tokens.into_values() {
+                if let Some(token_cfg) = token
+                    .try_into_token_cfg(networks, remote_tokens.document.clone())?

This avoids cloning tokens during iteration by consuming the HashMap.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let mut unique_tokens: HashMap<(u32, String), Token> = HashMap::new();
for token in &tokens_res.tokens {
let token_cfg = token
.clone()
.try_into_token_cfg(networks, remote_tokens.document.clone())?;
let token_id = (token.chain_id, token.address.to_lowercase());
unique_tokens.insert(token_id, token.clone());
}
if tokens.contains_key(&token_cfg.key) {
return Err(ParseRemoteTokensError::ConflictingTokens(
token_cfg.key.clone(),
));
for token in unique_tokens.values() {
if let Some(token_cfg) = token
.clone()
.try_into_token_cfg(networks, remote_tokens.document.clone())?
{
if tokens.contains_key(&token_cfg.key) {
return Err(ParseRemoteTokensError::ConflictingTokens(
token_cfg.key.clone(),
));
}
tokens.insert(token_cfg.key.clone(), token_cfg);
}
tokens.insert(token_cfg.key.clone(), token_cfg);
}
let mut unique_tokens: HashMap<(u32, String), Token> = HashMap::new();
for token in &tokens_res.tokens {
let token_id = (token.chain_id, token.address.to_lowercase());
unique_tokens.insert(token_id, token.clone());
}
for token in unique_tokens.into_values() {
if let Some(token_cfg) = token
.try_into_token_cfg(networks, remote_tokens.document.clone())?
{
if tokens.contains_key(&token_cfg.key) {
return Err(ParseRemoteTokensError::ConflictingTokens(
token_cfg.key.clone(),
));
}
tokens.insert(token_cfg.key.clone(), token_cfg);
}
}
🤖 Prompt for AI Agents
In crates/settings/src/remote_tokens.rs around lines 44 to 62, the current code
clones tokens when iterating over unique_tokens.values(), which is unnecessary
and impacts performance. To fix this, change the iteration to consume the
HashMap by iterating over unique_tokens.into_values() instead of
unique_tokens.values(), so tokens are moved rather than cloned. This avoids
cloning tokens during processing and improves efficiency.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we don't need to implement this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@findolor You're absolutely right - that optimization is outside the scope of this PR. Thanks for keeping the focus on the token dropdown implementation!

The deduplication logic you've implemented here works well for supporting the new token selection UI.


🧠 Learnings used
Learnt from: findolor
PR: rainlanguage/rain.orderbook#1483
File: crates/settings/src/remote_tokens.rs:32-57
Timestamp: 2025-04-07T09:51:52.614Z
Learning: The implementation for remote token fetching in `crates/settings/src/remote_tokens.rs` does not include explicit timeouts/retries, as the team considers the current implementation sufficient for now.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1477
File: crates/settings/src/remote_networks.rs:40-75
Timestamp: 2025-04-03T09:45:04.200Z
Learning: The RemoteNetworksCfg implementation in crates/settings/src/remote_networks.rs intentionally fetches remote networks sequentially rather than in parallel.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1483
File: crates/settings/src/yaml/cache.rs:23-25
Timestamp: 2025-04-07T09:50:54.715Z
Learning: The Cache implementation in crates/settings/src/yaml/cache.rs returns cloned HashMaps in getter methods (like get_remote_networks) rather than references. This design choice was explicitly accepted by the maintainer.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1483
File: crates/settings/src/yaml/cache.rs:20-22
Timestamp: 2025-04-07T09:55:44.798Z
Learning: The Cache implementation in crates/settings/src/yaml/cache.rs is designed to overwrite existing entries without warning when using update methods like update_remote_network. This behavior is an intentional design choice.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/settings/src/yaml/mod.rs:176-178
Timestamp: 2025-06-18T19:23:33.747Z
Learning: In crates/settings/src/yaml/mod.rs, the YamlError enum has two distinct error variants: `KeyNotFound(String)` for when a specific YAML key is not found in a hash/map, and `NotFound(String)` for when other types of entities (like networks, orderbooks, etc.) are not found in the configuration. These serve different purposes and should not be consolidated.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/settings/src/yaml/orderbook.rs:185-199
Timestamp: 2025-06-18T19:24:40.518Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers not to refactor get_orderbook_by_network_key to handle multiple orderbooks per network key since their current architecture maintains a one-to-one mapping between orderbooks and networks. They would consider the refactoring if the system evolves to support multiple orderbooks per network in the future.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/settings/src/yaml/orderbook.rs:180-199
Timestamp: 2025-06-18T18:24:32.049Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to avoid refactoring duplicate search logic between get_orderbook_by_address and get_orderbook_by_network_key when there are only 2 functions, indicating they would consider it if more similar functions are added in the future.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1947
File: crates/common/src/raindex_client/orders.rs:98-125
Timestamp: 2025-06-24T08:46:03.368Z
Learning: In the vault merging logic in crates/common/src/raindex_client/orders.rs, optimization isn't necessary because the maximum list items are usually around 5 items. For such small datasets, the simple three-loop approach is preferred over HashMap-based optimization due to clarity and minimal performance impact.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1956
File: crates/common/src/raindex_client/mod.rs:116-135
Timestamp: 2025-07-04T10:26:24.289Z
Learning: In crates/common/src/raindex_client/mod.rs, the get_multi_subgraph_args method intentionally treats Some(empty vector) the same as None for chain_ids parameter. Both cases should return all networks to support UI behavior where no selection or empty selection means "show all networks". Only when specific chain IDs are provided should the results be filtered.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1903
File: crates/settings/src/yaml/orderbook.rs:371-377
Timestamp: 2025-06-17T16:21:24.384Z
Learning: In crates/settings/src/yaml/orderbook.rs tests, the user findolor considers RPC ordering in Vec<Url> assertions to be intentional and not a test brittleness issue. The ordering of RPCs in tests should be preserved as specified.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1975
File: crates/js_api/src/config.rs:44-45
Timestamp: 2025-07-09T07:42:48.458Z
Learning: User findolor prefers to defer code improvements and refactoring suggestions to future PRs when they are not directly related to the current PR's scope, even when the suggestions are valid improvements.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any additional text or formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:46:08.530Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report should be the only content in the comment - no text before it, no text after it, no formatting blocks, just the raw report in the exact format: "TOTAL=number\nADDITIONS=number\nDELETIONS=number". The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T21:26:31.566Z
Learning: For PR #1884 and future PRs in rainlanguage/rain.orderbook repository, provide PR size reports in a separate comment with ONLY the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number", without any additional text or explanation. Reports should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T23:34:42.328Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must use the format:
TOTAL:number
ADDITIONS:number
DELETIONS:number
with no extra text, formatting blocks, or explanations, and must still exclude lock files and reassess after each new commit.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:35:26.448Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very last part of any comment, after any learning used section or other content.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:35:26.448Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very last part of any comment, after any learning used section or other content.

Learnt from: hardingjam
PR: rainlanguage/rain.orderbook#1738
File: packages/ui-components/src/lib/providers/toasts/useToasts.ts:46-52
Timestamp: 2025-05-07T16:51:13.418Z
Learning: UX enhancements for toast notifications, such as pausing timeout on hover, were considered out of scope for the toast refactoring PR.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T21:24:42.275Z
Learning: For PR #1884, after each commit review, I should provide a new comment with a PR size report in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding irrelevant files such as lock files (package-lock.json, cargo.lock, etc.).

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1903
File: crates/js_api/src/subgraph/vault.rs:129-138
Timestamp: 2025-06-17T16:33:58.549Z
Learning: findolor prefers downstream error handling over early validation checks for empty RPC lists in vault functions, allowing errors to bubble up from provider creation logic naturally.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1916
File: packages/webapp/src/routes/+layout.ts:26-26
Timestamp: 2025-06-10T12:01:07.418Z
Learning: The user findolor prefers to keep string concatenation using the plus operator over template literals in the rainlanguage/rain.orderbook project, even when static analysis tools suggest the change.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1947
File: crates/common/src/raindex_client/orders.rs:462-1643
Timestamp: 2025-06-24T08:45:10.971Z
Learning: User findolor prefers to keep tests simple and avoid refactoring for maintainability when the code is stable and viewed as "one time thing" that won't require frequent changes.

Learnt from: brusherru
PR: rainlanguage/rain.orderbook#1957
File: packages/ui-components/src/lib/components/tables/OrdersListTable.svelte:86-94
Timestamp: 2025-06-27T18:41:18.194Z
Learning: In the rain.orderbook UI components, the tokensQuery should use `enabled: true` rather than `Object.keys($activeSubgraphs).length > 0` because tokens are needed for filtering functionality even when no specific subgraphs are selected. The multiSubgraphArgs falls back to default subgraphs from settings, so disabling the query when no subgraphs are active would break the token filtering feature.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/js_api/src/raindex/mod.rs:102-118
Timestamp: 2025-06-18T12:56:44.290Z
Learning: In the rainlanguage/rain.orderbook codebase, it's acceptable to scaffold unused enum variants in initial implementation PRs when they will be implemented in future PRs, as confirmed by findolor.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:47:21.927Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very beginning of any comment, before any learning used section or other content.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@findolor, understood! I'll note your preference for future reviews.


✏️ Learnings added
Learnt from: findolor
PR: rainlanguage/rain.orderbook#1925
File: crates/settings/src/remote_tokens.rs:44-62
Timestamp: 2025-07-11T08:45:43.939Z
Learning: findolor prefers to avoid performance micro-optimizations like changing `.values()` to `.into_values()` in HashMap iterations in the rainlanguage/rain.orderbook codebase, even when they would eliminate unnecessary cloning.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: findolor
PR: rainlanguage/rain.orderbook#1483
File: crates/settings/src/remote_tokens.rs:32-57
Timestamp: 2025-04-07T09:51:52.614Z
Learning: The implementation for remote token fetching in `crates/settings/src/remote_tokens.rs` does not include explicit timeouts/retries, as the team considers the current implementation sufficient for now.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1477
File: crates/settings/src/remote_networks.rs:40-75
Timestamp: 2025-04-03T09:45:04.200Z
Learning: The RemoteNetworksCfg implementation in crates/settings/src/remote_networks.rs intentionally fetches remote networks sequentially rather than in parallel.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1483
File: crates/settings/src/yaml/cache.rs:23-25
Timestamp: 2025-04-07T09:50:54.715Z
Learning: The Cache implementation in crates/settings/src/yaml/cache.rs returns cloned HashMaps in getter methods (like get_remote_networks) rather than references. This design choice was explicitly accepted by the maintainer.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1483
File: crates/settings/src/yaml/cache.rs:20-22
Timestamp: 2025-04-07T09:55:44.798Z
Learning: The Cache implementation in crates/settings/src/yaml/cache.rs is designed to overwrite existing entries without warning when using update methods like update_remote_network. This behavior is an intentional design choice.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/settings/src/yaml/mod.rs:176-178
Timestamp: 2025-06-18T19:23:33.747Z
Learning: In crates/settings/src/yaml/mod.rs, the YamlError enum has two distinct error variants: `KeyNotFound(String)` for when a specific YAML key is not found in a hash/map, and `NotFound(String)` for when other types of entities (like networks, orderbooks, etc.) are not found in the configuration. These serve different purposes and should not be consolidated.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/settings/src/yaml/orderbook.rs:185-199
Timestamp: 2025-06-18T19:24:40.518Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers not to refactor get_orderbook_by_network_key to handle multiple orderbooks per network key since their current architecture maintains a one-to-one mapping between orderbooks and networks. They would consider the refactoring if the system evolves to support multiple orderbooks per network in the future.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/settings/src/yaml/orderbook.rs:180-199
Timestamp: 2025-06-18T18:24:32.049Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to avoid refactoring duplicate search logic between get_orderbook_by_address and get_orderbook_by_network_key when there are only 2 functions, indicating they would consider it if more similar functions are added in the future.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1947
File: crates/common/src/raindex_client/orders.rs:98-125
Timestamp: 2025-06-24T08:46:03.368Z
Learning: In the vault merging logic in crates/common/src/raindex_client/orders.rs, optimization isn't necessary because the maximum list items are usually around 5 items. For such small datasets, the simple three-loop approach is preferred over HashMap-based optimization due to clarity and minimal performance impact.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1956
File: crates/common/src/raindex_client/mod.rs:116-135
Timestamp: 2025-07-04T10:26:24.289Z
Learning: In crates/common/src/raindex_client/mod.rs, the get_multi_subgraph_args method intentionally treats Some(empty vector) the same as None for chain_ids parameter. Both cases should return all networks to support UI behavior where no selection or empty selection means "show all networks". Only when specific chain IDs are provided should the results be filtered.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/js_api/src/raindex/mod.rs:92-99
Timestamp: 2025-06-18T18:18:44.330Z
Learning: In crates/js_api/src/raindex/mod.rs, the get_subgraph_url_for_chain method and get_multi_subgraph_args method intentionally duplicate lookup logic because they serve different purposes: get_subgraph_url_for_chain returns only the URL string, while get_multi_subgraph_args returns MultiSubgraphArgs structures containing both URL and network information (name/label). This duplication is acceptable and by design.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1903
File: crates/settings/src/yaml/orderbook.rs:371-377
Timestamp: 2025-06-17T16:21:24.384Z
Learning: In crates/settings/src/yaml/orderbook.rs tests, the user findolor considers RPC ordering in Vec<Url> assertions to be intentional and not a test brittleness issue. The ordering of RPCs in tests should be preserved as specified.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1903
File: crates/js_api/src/subgraph/vault.rs:129-138
Timestamp: 2025-06-17T16:33:58.549Z
Learning: findolor prefers downstream error handling over early validation checks for empty RPC lists in vault functions, allowing errors to bubble up from provider creation logic naturally.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1916
File: packages/webapp/src/routes/+layout.ts:26-26
Timestamp: 2025-06-10T12:01:07.418Z
Learning: The user findolor prefers to keep string concatenation using the plus operator over template literals in the rainlanguage/rain.orderbook project, even when static analysis tools suggest the change.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1947
File: crates/common/src/raindex_client/orders.rs:462-1643
Timestamp: 2025-06-24T08:45:10.971Z
Learning: User findolor prefers to keep tests simple and avoid refactoring for maintainability when the code is stable and viewed as "one time thing" that won't require frequent changes.

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1975
File: crates/js_api/src/config.rs:44-45
Timestamp: 2025-07-09T07:42:48.458Z
Learning: User findolor prefers to defer code improvements and refactoring suggestions to future PRs when they are not directly related to the current PR's scope, even when the suggestions are valid improvements.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T21:26:31.566Z
Learning: For PR #1884 and future PRs in rainlanguage/rain.orderbook repository, provide PR size reports in a separate comment with ONLY the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number", without any additional text or explanation. Reports should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any additional text or formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.

Learnt from: brusherru
PR: rainlanguage/rain.orderbook#1957
File: packages/ui-components/src/lib/components/tables/OrdersListTable.svelte:86-94
Timestamp: 2025-06-27T18:41:18.194Z
Learning: In the rain.orderbook UI components, the tokensQuery should use `enabled: true` rather than `Object.keys($activeSubgraphs).length > 0` because tokens are needed for filtering functionality even when no specific subgraphs are selected. The multiSubgraphArgs falls back to default subgraphs from settings, so disabling the query when no subgraphs are active would break the token filtering feature.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T23:34:42.328Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must use the format:
TOTAL:number
ADDITIONS:number
DELETIONS:number
with no extra text, formatting blocks, or explanations, and must still exclude lock files and reassess after each new commit.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:46:08.530Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report should be the only content in the comment - no text before it, no text after it, no formatting blocks, just the raw report in the exact format: "TOTAL=number\nADDITIONS=number\nDELETIONS=number". The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).

Learnt from: findolor
PR: rainlanguage/rain.orderbook#1938
File: crates/js_api/src/raindex/mod.rs:102-118
Timestamp: 2025-06-18T12:56:44.290Z
Learning: In the rainlanguage/rain.orderbook codebase, it's acceptable to scaffold unused enum variants in initial implementation PRs when they will be implemented in future PRs, as confirmed by findolor.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:35:26.448Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very last part of any comment, after any learning used section or other content.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:35:26.448Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very last part of any comment, after any learning used section or other content.

Learnt from: rouzwelt
PR: rainlanguage/rain.orderbook#0
File: :0-0
Timestamp: 2025-05-21T22:47:21.927Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report must always be placed at the very beginning of any comment, before any learning used section or other content.

}

Expand Down Expand Up @@ -235,7 +242,7 @@ using-tokens-from:
"decimals": 18
}
],
"logoUri": "http://localhost.com"
"logoURI": "http://localhost.com"
}
"#;
server
Expand Down Expand Up @@ -279,17 +286,19 @@ using-tokens-from:

assert_eq!(tokens.len(), 2_usize);

let token = tokens.get("token1").unwrap();
assert_eq!(token.key, "token1");
let token1_key = "remote-network-Token1-0x0000000000000000000000000000000000000001";
let token = tokens.get(token1_key).unwrap();
assert_eq!(token.key, token1_key);
assert_eq!(
token.address,
Address::from_str("0x0000000000000000000000000000000000000001").unwrap()
);
assert_eq!(token.network.key, "remote-network");
assert_eq!(token.network.chain_id, 123);

let token = tokens.get("token2").unwrap();
assert_eq!(token.key, "token2");
let token2_key = "remote2-network-Token2-0x0000000000000000000000000000000000000002";
let token = tokens.get(token2_key).unwrap();
assert_eq!(token.key, token2_key);
assert_eq!(
token.address,
Address::from_str("0x0000000000000000000000000000000000000002").unwrap()
Expand Down Expand Up @@ -343,7 +352,7 @@ using-tokens-from:
"decimals": 18
}
],
"logoUri": "http://localhost.com"
"logoURI": "http://localhost.com"
}
"#;

Expand Down Expand Up @@ -373,7 +382,7 @@ using-tokens-from:
"decimals": 18
}
],
"logoUri": "http://localhost.com"
"logoURI": "http://localhost.com"
}
"#;

Expand Down Expand Up @@ -452,17 +461,19 @@ using-tokens-from:

assert_eq!(tokens.len(), 4_usize);

let token = tokens.get("token3").unwrap();
assert_eq!(token.key, "token3");
let token3_key = "remote3-network-Token3-0x0000000000000000000000000000000000000003";
let token = tokens.get(token3_key).unwrap();
assert_eq!(token.key, token3_key);
assert_eq!(
token.address,
Address::from_str("0x0000000000000000000000000000000000000003").unwrap()
);
assert_eq!(token.network.key, "remote3-network");
assert_eq!(token.network.chain_id, 345);

let token = tokens.get("token4").unwrap();
assert_eq!(token.key, "token4");
let token4_key = "remote4-network-Token4-0x0000000000000000000000000000000000000004";
let token = tokens.get(token4_key).unwrap();
assert_eq!(token.key, token4_key);
assert_eq!(
token.address,
Address::from_str("0x0000000000000000000000000000000000000004").unwrap()
Expand Down
Loading