Skip to content

Commit cb13d4d

Browse files
Merge pull request #271 from jsanchez556/feat/parse_string_function
Parse string utils function #264
2 parents 4063ddf + b029299 commit cb13d4d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/utils.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ macro_rules! pub_struct {
4242
}
4343
}
4444
}
45-
4645

4746
pub async fn get_nft(
4847
quest_id: u32,
@@ -826,4 +825,18 @@ impl Clone for Box<dyn WithState> {
826825
fn clone(&self) -> Box<dyn WithState> {
827826
self.box_clone()
828827
}
829-
}
828+
}
829+
830+
pub fn parse_string(input: &str, address: FieldElement) -> String {
831+
let mut result = input.to_string();
832+
833+
if input.contains("{addr_hex}") {
834+
result = result.replace("{addr_hex}", to_hex(address).as_str());
835+
}
836+
837+
if input.contains("{addr_dec}") {
838+
result = result.replace("{addr_dec}", address.to_string().as_str());
839+
}
840+
841+
result
842+
}

0 commit comments

Comments
 (0)