Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(torii-sqlite): erc721 tokens upsert do nothing #2986

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Changes from 1 commit
Commits
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
13 changes: 12 additions & 1 deletion crates/torii/sqlite/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,19 @@ impl<'c, P: Provider + Sync + Send + 'static> Executor<'c, P> {
QueryType::RegisterErc721Token(register_erc721_token) => {
let semaphore = self.semaphore.clone();
let provider = self.provider.clone();

let token_exists =
sqlx::query_scalar::<_, i64>("SELECT COUNT(*) FROM tokens WHERE id = ?")
.bind(register_erc721_token.id.to_string())
.fetch_one(&mut **tx)
.await?;

if token_exists > 0 {
return Ok(());
}

let res = sqlx::query_as::<_, (String, String)>(&format!(
"SELECT name, symbol FROM {TOKENS_TABLE} WHERE contract_address = ? LIMIT 1"
"SELECT name, symbol FROM {TOKENS_TABLE} WHERE id = ? LIMIT 1"
))
.bind(felt_to_sql_string(&register_erc721_token.contract_address))
.fetch_one(&mut **tx)
Expand Down
Loading