From 980523cd3130b52d4752258136ec1ed8b5b12467 Mon Sep 17 00:00:00 2001 From: pshenmic Date: Fri, 9 Aug 2024 13:36:10 +0700 Subject: [PATCH 1/3] Drop identity aliases unique index (it is not one-to-many) --- .../migrations/V41__drop_identity_aliases_unque_index.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 packages/indexer/migrations/V41__drop_identity_aliases_unque_index.sql diff --git a/packages/indexer/migrations/V41__drop_identity_aliases_unque_index.sql b/packages/indexer/migrations/V41__drop_identity_aliases_unque_index.sql new file mode 100644 index 000000000..931bdcfa5 --- /dev/null +++ b/packages/indexer/migrations/V41__drop_identity_aliases_unque_index.sql @@ -0,0 +1,2 @@ +DROP INDEX identity_aliases_alias; + From c4f296e18b6a0934521e1eaa9a553385bda3b714 Mon Sep 17 00:00:00 2001 From: pshenmic Date: Fri, 9 Aug 2024 13:36:44 +0700 Subject: [PATCH 2/3] Update identity aliases indexer to latest DPNS contract schema --- packages/indexer/src/processor/psql/mod.rs | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/packages/indexer/src/processor/psql/mod.rs b/packages/indexer/src/processor/psql/mod.rs index 984ddf012..27663ca01 100644 --- a/packages/indexer/src/processor/psql/mod.rs +++ b/packages/indexer/src/processor/psql/mod.rs @@ -9,7 +9,7 @@ use crate::processor::psql::dao::PostgresDAO; use base64::{Engine as _, engine::{general_purpose}}; use data_contracts::SystemDataContract; use dpp::identifier::Identifier; -use dpp::platform_value::{platform_value, BinaryData}; +use dpp::platform_value::{platform_value, BinaryData, Value}; use dpp::platform_value::btreemap_extensions::BTreeValueMapPathHelper; use dpp::platform_value::string_encoding::Encoding::Base58; use dpp::serialization::PlatformSerializable; @@ -91,6 +91,9 @@ impl PSQLProcessor { for (_, document_transition) in transitions.iter().enumerate() { let document = Document::from(document_transition.clone()); + + self.dao.create_document(document, Some(st_hash.clone())).await.unwrap(); + let document_type = document_transition.document_type_name(); if document_type == "domain" && document_transition.data_contract_id() == SystemDataContract::DPNS.id() { @@ -103,24 +106,15 @@ impl PSQLProcessor { let normalized_parent_domain_name = document_transition .data() .unwrap() - .get_str_at_path("normalizedParentDomainName") + .get_str_at_path("parentDomainName") .unwrap(); - let primary_alias = document_transition + let identity_identifier = document_transition .data() .unwrap() - .get_optional_at_path("records.dashUniqueIdentityId").unwrap(); - - let identity_identifier = match primary_alias { - None => { - document_transition - .data() - .unwrap() - .get_optional_at_path("records.dashAliasIdentityId").unwrap() - .expect("Could not find dashAliasIdentityId") - } - Some(value) => value - }; + .get_optional_at_path("records.identity") + .unwrap() + .expect("Could not find DPNS domain document identity identifier"); let identity_identifier = Identifier::from_bytes(&identity_identifier.clone().into_identifier_bytes().unwrap()).unwrap().to_string(Base58); let identity = self.dao.get_identity_by_identifier(identity_identifier.clone()).await.unwrap().expect(&format!("Could not find identity with identifier {}", identity_identifier)); @@ -157,9 +151,6 @@ impl PSQLProcessor { println!("Failed to set custom data contract name for contract {}, owner of the tx {} does not match data contract", st_hash, document.identifier.to_string(Base58)); } } - - - self.dao.create_document(document, Some(st_hash.clone())).await.unwrap(); } } From cda77f90a3018a9638cedcf82ae456bc3206ab95 Mon Sep 17 00:00:00 2001 From: pshenmic Date: Fri, 9 Aug 2024 13:42:31 +0700 Subject: [PATCH 3/3] Fix value borrowed is moved --- packages/indexer/src/processor/psql/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/indexer/src/processor/psql/mod.rs b/packages/indexer/src/processor/psql/mod.rs index 27663ca01..e002f45e9 100644 --- a/packages/indexer/src/processor/psql/mod.rs +++ b/packages/indexer/src/processor/psql/mod.rs @@ -91,6 +91,7 @@ impl PSQLProcessor { for (_, document_transition) in transitions.iter().enumerate() { let document = Document::from(document_transition.clone()); + let document_identifier = document.identifier.clone(); self.dao.create_document(document, Some(st_hash.clone())).await.unwrap(); @@ -148,7 +149,7 @@ impl PSQLProcessor { if data_contract.owner == state_transition.owner_id() { self.dao.set_data_contract_name(data_contract, String::from(data_contract_name)).await.unwrap(); } else { - println!("Failed to set custom data contract name for contract {}, owner of the tx {} does not match data contract", st_hash, document.identifier.to_string(Base58)); + println!("Failed to set custom data contract name for contract {}, owner of the tx {} does not match data contract", st_hash, document_identifier.to_string(Base58)); } } }