Skip to content

Commit

Permalink
fix: subject template parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisht13 committed Sep 12, 2024
1 parent a1e812d commit b01b074
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/relayer/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CHAIN_ID=11155111 # Chain ID of the testnet.

SMTP_SERVER=

PROVER_ADDRESS="https://zkemail--email-auth-prover-body-parsing-v1-0-0-flask-app.modal.run"
PROVER_ADDRESS="https://zkemail--email-auth-prover-v1-3-0-flask-app.modal.run"

DATABASE_URL= "postgres://test@localhost/emailauth_test"
RELAYER_EMAIL_ADDR=
Expand Down
26 changes: 19 additions & 7 deletions packages/relayer/src/utils/command_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ pub fn extract_template_vals(input: &str, templates: Vec<String>) -> Result<Vec<
.unwrap()
.find(input_decomposed[input_idx])
.ok_or(anyhow!("No string found"))?;
if string_match.start() != 0
|| string_match.end() != input_decomposed[input_idx].len()
{
if string_match.start() != 0 {
return Err(anyhow!("String must be the whole word"));
}
let string = string_match.as_str().to_string();
let mut string = string_match.as_str().to_string();
if string.contains("</div>") {
string = string.split("</div>").collect::<Vec<&str>>()[0].to_string();
}
template_vals.push(TemplateValue::String(string));
}
"{uint}" => {
Expand All @@ -119,7 +120,11 @@ pub fn extract_template_vals(input: &str, templates: Vec<String>) -> Result<Vec<
{
return Err(anyhow!("Uint must be the whole word"));
}
let uint = U256::from_dec_str(uint_match.as_str()).unwrap();
let mut uint_match = uint_match.as_str();
if uint_match.contains("</div>") {
uint_match = uint_match.split("</div>").collect::<Vec<&str>>()[0];
}
let uint = U256::from_dec_str(uint_match).unwrap();
template_vals.push(TemplateValue::Uint(uint));
}
"{int}" => {
Expand All @@ -130,7 +135,11 @@ pub fn extract_template_vals(input: &str, templates: Vec<String>) -> Result<Vec<
if int_match.start() != 0 || int_match.end() != input_decomposed[input_idx].len() {
return Err(anyhow!("Int must be the whole word"));
}
let int = I256::from_dec_str(int_match.as_str()).unwrap();
let mut int_match = int_match.as_str();
if int_match.contains("</div>") {
int_match = int_match.split("</div>").collect::<Vec<&str>>()[0];
}
let int = I256::from_dec_str(int_match).unwrap();
template_vals.push(TemplateValue::Int(int));
}
"{decimals}" => {
Expand All @@ -143,7 +152,10 @@ pub fn extract_template_vals(input: &str, templates: Vec<String>) -> Result<Vec<
{
return Err(anyhow!("Decimals must be the whole word"));
}
let decimals = decimals_match.as_str().to_string();
let mut decimals = decimals_match.as_str().to_string();
if decimals.contains("</div>") {
decimals = decimals.split("</div>").collect::<Vec<&str>>()[0].to_string();
}
template_vals.push(TemplateValue::Decimals(decimals));
}
"{ethAddr}" => {
Expand Down

0 comments on commit b01b074

Please sign in to comment.