Skip to content

Commit

Permalink
Merge pull request #271 from jsanchez556/feat/parse_string_function
Browse files Browse the repository at this point in the history
Parse string utils function #264
  • Loading branch information
Marchand-Nicolas authored Sep 28, 2024
2 parents 4063ddf + b029299 commit cb13d4d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ macro_rules! pub_struct {
}
}
}


pub async fn get_nft(
quest_id: u32,
Expand Down Expand Up @@ -826,4 +825,18 @@ impl Clone for Box<dyn WithState> {
fn clone(&self) -> Box<dyn WithState> {
self.box_clone()
}
}
}

pub fn parse_string(input: &str, address: FieldElement) -> String {
let mut result = input.to_string();

if input.contains("{addr_hex}") {
result = result.replace("{addr_hex}", to_hex(address).as_str());
}

if input.contains("{addr_dec}") {
result = result.replace("{addr_dec}", address.to_string().as_str());
}

result
}

0 comments on commit cb13d4d

Please sign in to comment.