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

[parquet-sdk][token_v2] migrate token ownership table [pt2] #638

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
prior_nft_ownership: &AHashMap<String, NFTOwnershipV2>,
tokens_burned: &TokenV2Burned,
object_metadatas: &ObjectAggregatedDataMapping,
conn: &mut DbPoolConnection<'_>,
conn: &mut Option<DbPoolConnection<'_>>,
query_retries: u32,
query_retry_delay_ms: u64,
) -> anyhow::Result<Option<(Self, RawCurrentTokenOwnershipV2)>> {
Expand Down Expand Up @@ -344,7 +344,7 @@
txn_timestamp: chrono::NaiveDateTime,
prior_nft_ownership: &AHashMap<String, NFTOwnershipV2>,
tokens_burned: &TokenV2Burned,
conn: &mut DbPoolConnection<'_>,
conn: &mut Option<DbPoolConnection<'_>>,
query_retries: u32,
query_retry_delay_ms: u64,
) -> anyhow::Result<Option<(Self, RawCurrentTokenOwnershipV2)>> {
Expand All @@ -370,7 +370,7 @@
txn_timestamp: chrono::NaiveDateTime,
prior_nft_ownership: &AHashMap<String, NFTOwnershipV2>,
tokens_burned: &TokenV2Burned,
conn: &mut DbPoolConnection<'_>,
conn: &mut Option<DbPoolConnection<'_>>,
query_retries: u32,
query_retry_delay_ms: u64,
) -> anyhow::Result<Option<(Self, RawCurrentTokenOwnershipV2)>> {
Expand All @@ -387,23 +387,36 @@
match prior_nft_ownership.get(&token_address) {
Some(inner) => inner.owner_address.clone(),
None => {
match CurrentTokenOwnershipV2Query::get_latest_owned_nft_by_token_data_id(
conn,
&token_address,
query_retries,
query_retry_delay_ms,
)
.await
{
Ok(nft) => nft.owner_address.clone(),
Err(_) => {
match conn {

Check warning on line 390 in rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs

View check run for this annotation

Codecov / codecov/patch

rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs#L390

Added line #L390 was not covered by tests
None => {
// TODO: update message
tracing::error!(
transaction_version = txn_version,
lookup_key = &token_address,
"Failed to find current_token_ownership_v2 for burned token. You probably should backfill db."
);
DEFAULT_OWNER_ADDRESS.to_string()
},
Some(ref mut conn) => {
match CurrentTokenOwnershipV2Query::get_latest_owned_nft_by_token_data_id(
conn,
&token_address,
query_retries,
query_retry_delay_ms,
)
.await

Check warning on line 407 in rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs

View check run for this annotation

Codecov / codecov/patch

rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs#L400-L407

Added lines #L400 - L407 were not covered by tests
{
Ok(nft) => nft.owner_address.clone(),

Check warning on line 409 in rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs

View check run for this annotation

Codecov / codecov/patch

rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs#L409

Added line #L409 was not covered by tests
Err(_) => {
tracing::error!(

Check warning on line 411 in rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs

View check run for this annotation

Codecov / codecov/patch

rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs#L411

Added line #L411 was not covered by tests
transaction_version = txn_version,
lookup_key = &token_address,
"Failed to find current_token_ownership_v2 for burned token. You probably should backfill db."

Check warning on line 414 in rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs

View check run for this annotation

Codecov / codecov/patch

rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs#L413-L414

Added lines #L413 - L414 were not covered by tests
);
DEFAULT_OWNER_ADDRESS.to_string()

Check warning on line 416 in rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs

View check run for this annotation

Codecov / codecov/patch

rust/processor/src/db/common/models/token_v2_models/raw_v2_token_ownerships.rs#L416

Added line #L416 was not covered by tests
},
}
}
}
},
}
Expand Down
Loading
Loading