Skip to content

Commit

Permalink
[parquet-sdk][token_v2] migrate token ownership table [pt2]
Browse files Browse the repository at this point in the history
  • Loading branch information
yuunlimm committed Dec 11, 2024
1 parent 6d18a30 commit 4993938
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 646 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl RawTokenOwnershipV2 {
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 @@ impl RawTokenOwnershipV2 {
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 @@ impl RawTokenOwnershipV2 {
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 @@ impl RawTokenOwnershipV2 {
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

0 comments on commit 4993938

Please sign in to comment.