Skip to content

Commit

Permalink
use default token id from util
Browse files Browse the repository at this point in the history
  • Loading branch information
harrysolovay committed Oct 3, 2024
1 parent 58d9502 commit f6cea97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/api/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use serde::Serialize;
use sqlx::FromRow;

use crate::{
ChainStatus, InternalCommandType, MinaMesh, MinaMeshError, OperationStatus, OperationType, TransactionStatus,
UserCommandType,
util::DEFAULT_TOKEN_ID, ChainStatus, InternalCommandType, MinaMesh, MinaMeshError, OperationStatus, OperationType,
TransactionStatus, UserCommandType,
};

/// https://github.com/MinaProtocol/mina/blob/985eda49bdfabc046ef9001d3c406e688bc7ec45/src/app/rosetta/lib/block.ml#L7
Expand Down Expand Up @@ -245,6 +245,3 @@ fn operation(
metadata: None, // TODO: get the correct metadata
}
}

// cspell:disable-next-line
static DEFAULT_TOKEN_ID: &str = "wSHV2S4qX9jFsLjQo8r1BsMLH2ZRKsZx6EJd1sbozGPieEC4Jf";
4 changes: 2 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ impl<T: Serialize, E: ToString> IntoResponse for Wrapper<Result<T, E>> {
}

impl Wrapper<Option<serde_json::Value>> {
pub fn to_token_id(self) -> Result<String, MinaMeshError> {
match self.0 {
pub fn to_token_id(&self) -> Result<String, MinaMeshError> {
match &self.0 {
None => Ok(DEFAULT_TOKEN_ID.to_string()),
Some(serde_json::Value::Object(map)) => {
Ok(map.get("token_id").map(|v| v.to_string()).ok_or(MinaMeshError::JsonParse(None))?)
Expand Down

0 comments on commit f6cea97

Please sign in to comment.