From 227477ead830a7710d37503dee3b8d213583460a Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 14:26:29 +0500 Subject: [PATCH 01/12] disambiguate just command --- libs/blockscout-db/justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/blockscout-db/justfile b/libs/blockscout-db/justfile index 46e9c397e..2cf584b9e 100644 --- a/libs/blockscout-db/justfile +++ b/libs/blockscout-db/justfile @@ -29,7 +29,7 @@ generate-entities database_url="postgres://postgres:admin@localhost:5432/blocksc DATABASE_URL={{database_url}} sea-orm-cli generate entity --lib -o entity/src cargo fmt --all -- --config imports_granularity=Crate -generate-entities-from-blockscout database_url="postgres://postgres:admin@localhost:5432/blockscout": +generate-entities-from-blockscout-image database_url="postgres://postgres:admin@localhost:5432/blockscout": docker run --network=host -e 'DATABASE_URL={{database_url}}' -e 'ECTO_USE_SSL=false' --entrypoint "/bin/sh" --rm blockscout/blockscout:{{blockscout-version}} -c 'bin/blockscout eval "Elixir.Explorer.ReleaseTasks.create_and_migrate()"' DATABASE_URL={{database_url}} sea-orm-cli generate entity --lib -o entity/src cargo fmt --all -- --config imports_granularity=Crate From a4af01e33bf904af2f75a44c942a9817eb6748b2 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 16:10:15 +0500 Subject: [PATCH 02/12] generate --- .../entity/src/address_coin_balances.rs | 2 +- .../entity/src/address_coin_balances_daily.rs | 2 +- .../src/address_current_token_balances.rs | 4 +- libs/blockscout-db/entity/src/address_tags.rs | 4 +- .../entity/src/address_token_balances.rs | 4 +- libs/blockscout-db/entity/src/addresses.rs | 13 +++- libs/blockscout-db/entity/src/beacon_blobs.rs | 26 +++++++ .../entity/src/beacon_blobs_transactions.rs | 43 +++++++++++ .../blockscout-db/entity/src/block_rewards.rs | 2 +- libs/blockscout-db/entity/src/blocks.rs | 14 ++-- .../entity/src/bridged_tokens.rs | 40 ++++++++++ .../entity/src/emission_rewards.rs | 2 +- .../entity/src/internal_transactions.rs | 6 +- .../entity/src/last_fetched_counters.rs | 2 +- libs/blockscout-db/entity/src/lib.rs | 17 ++--- .../entity/src/market_history.rs | 8 +- .../entity/src/migrations_status.rs | 2 + libs/blockscout-db/entity/src/prelude.rs | 22 +++--- .../entity/src/proxy_implementations.rs | 3 +- .../entity/src/scam_address_badge_mappings.rs | 36 +++++++++ .../entity/src/sea_orm_active_enums.rs | 26 +++++++ .../entity/src/signed_authorizations.rs | 49 ++++++++++++ .../entity/src/smart_contracts.rs | 1 + .../entity/src/token_instances.rs | 5 ++ .../entity/src/token_transfers.rs | 2 +- libs/blockscout-db/entity/src/tokens.rs | 19 +++-- .../entity/src/transaction_stats.rs | 4 +- libs/blockscout-db/entity/src/transactions.rs | 40 +++++++--- .../entity/src/user_operations.rs | 76 +++++++++++++++++++ .../entity/src/user_ops_indexer_migrations.rs | 16 ++++ libs/blockscout-db/entity/src/withdrawals.rs | 2 +- 31 files changed, 423 insertions(+), 69 deletions(-) create mode 100644 libs/blockscout-db/entity/src/beacon_blobs.rs create mode 100644 libs/blockscout-db/entity/src/beacon_blobs_transactions.rs create mode 100644 libs/blockscout-db/entity/src/bridged_tokens.rs create mode 100644 libs/blockscout-db/entity/src/scam_address_badge_mappings.rs create mode 100644 libs/blockscout-db/entity/src/signed_authorizations.rs create mode 100644 libs/blockscout-db/entity/src/user_operations.rs create mode 100644 libs/blockscout-db/entity/src/user_ops_indexer_migrations.rs diff --git a/libs/blockscout-db/entity/src/address_coin_balances.rs b/libs/blockscout-db/entity/src/address_coin_balances.rs index b32033879..12b64b53a 100644 --- a/libs/blockscout-db/entity/src/address_coin_balances.rs +++ b/libs/blockscout-db/entity/src/address_coin_balances.rs @@ -14,7 +14,7 @@ pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub block_number: i64, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub value: Option, + pub value: Option, pub value_fetched_at: Option, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/address_coin_balances_daily.rs b/libs/blockscout-db/entity/src/address_coin_balances_daily.rs index 080bac74c..895d20191 100644 --- a/libs/blockscout-db/entity/src/address_coin_balances_daily.rs +++ b/libs/blockscout-db/entity/src/address_coin_balances_daily.rs @@ -14,7 +14,7 @@ pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub day: Date, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub value: Option, + pub value: Option, pub inserted_at: DateTime, pub updated_at: DateTime, } diff --git a/libs/blockscout-db/entity/src/address_current_token_balances.rs b/libs/blockscout-db/entity/src/address_current_token_balances.rs index e867227b5..4a1a2bbeb 100644 --- a/libs/blockscout-db/entity/src/address_current_token_balances.rs +++ b/libs/blockscout-db/entity/src/address_current_token_balances.rs @@ -12,11 +12,11 @@ pub struct Model { pub block_number: i64, #[sea_orm(column_type = "VarBinary(StringLen::None)")] pub token_contract_address_hash: Vec, - pub value: Option, + pub value: Option, pub value_fetched_at: Option, pub inserted_at: DateTime, pub updated_at: DateTime, - pub old_value: Option, + pub old_value: Option, #[sea_orm(column_type = "Decimal(Some((78, 0)))", nullable)] pub token_id: Option, pub token_type: Option, diff --git a/libs/blockscout-db/entity/src/address_tags.rs b/libs/blockscout-db/entity/src/address_tags.rs index 53ee53db4..619cb1b2d 100644 --- a/libs/blockscout-db/entity/src/address_tags.rs +++ b/libs/blockscout-db/entity/src/address_tags.rs @@ -5,9 +5,9 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "address_tags")] pub struct Model { - #[sea_orm(unique, primary_key, auto_increment = false)] // changed: fix no key column + #[sea_orm(unique)] pub id: i32, - #[sea_orm(unique, primary_key, auto_increment = false)] // changed: fix no key columns + #[sea_orm(primary_key, auto_increment = false, unique)] pub label: String, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/address_token_balances.rs b/libs/blockscout-db/entity/src/address_token_balances.rs index 5d9b07820..db7210add 100644 --- a/libs/blockscout-db/entity/src/address_token_balances.rs +++ b/libs/blockscout-db/entity/src/address_token_balances.rs @@ -12,13 +12,15 @@ pub struct Model { pub block_number: i64, #[sea_orm(column_type = "VarBinary(StringLen::None)")] pub token_contract_address_hash: Vec, - pub value: Option, + pub value: Option, pub value_fetched_at: Option, pub inserted_at: DateTime, pub updated_at: DateTime, #[sea_orm(column_type = "Decimal(Some((78, 0)))", nullable)] pub token_id: Option, pub token_type: Option, + pub refetch_after: Option, + pub retries_count: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/addresses.rs b/libs/blockscout-db/entity/src/addresses.rs index be8320552..74967db85 100644 --- a/libs/blockscout-db/entity/src/addresses.rs +++ b/libs/blockscout-db/entity/src/addresses.rs @@ -6,7 +6,7 @@ use sea_orm::entity::prelude::*; #[sea_orm(table_name = "addresses")] pub struct Model { #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub fetched_coin_balance: Option, + pub fetched_coin_balance: Option, pub fetched_coin_balance_block_number: Option, #[sea_orm( primary_key, @@ -27,6 +27,15 @@ pub struct Model { } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} +pub enum Relation { + #[sea_orm(has_one = "super::scam_address_badge_mappings::Entity")] + ScamAddressBadgeMappings, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ScamAddressBadgeMappings.def() + } +} impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/beacon_blobs.rs b/libs/blockscout-db/entity/src/beacon_blobs.rs new file mode 100644 index 000000000..0b297535e --- /dev/null +++ b/libs/blockscout-db/entity/src/beacon_blobs.rs @@ -0,0 +1,26 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "beacon_blobs")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "VarBinary(StringLen::None)" + )] + pub hash: Vec, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub blob_data: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub kzg_commitment: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub kzg_proof: Option>, + pub inserted_at: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs b/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs new file mode 100644 index 000000000..e1cc33159 --- /dev/null +++ b/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs @@ -0,0 +1,43 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "beacon_blobs_transactions")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "VarBinary(StringLen::None)" + )] + pub hash: Vec, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub max_fee_per_blob_gas: Decimal, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub blob_gas_price: Decimal, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub blob_gas_used: Decimal, + pub blob_versioned_hashes: Vec>, + pub inserted_at: DateTime, + pub updated_at: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::transactions::Entity", + from = "Column::Hash", + to = "super::transactions::Column::Hash", + on_update = "NoAction", + on_delete = "Cascade" + )] + Transactions, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Transactions.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/block_rewards.rs b/libs/blockscout-db/entity/src/block_rewards.rs index d8a7d0014..571526b9b 100644 --- a/libs/blockscout-db/entity/src/block_rewards.rs +++ b/libs/blockscout-db/entity/src/block_rewards.rs @@ -20,7 +20,7 @@ pub struct Model { )] pub block_hash: Vec, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub reward: Option, + pub reward: Option, pub inserted_at: DateTime, pub updated_at: DateTime, } diff --git a/libs/blockscout-db/entity/src/blocks.rs b/libs/blockscout-db/entity/src/blocks.rs index 29fc1457f..e76fa57d0 100644 --- a/libs/blockscout-db/entity/src/blocks.rs +++ b/libs/blockscout-db/entity/src/blocks.rs @@ -7,11 +7,11 @@ use sea_orm::entity::prelude::*; pub struct Model { pub consensus: bool, #[sea_orm(column_type = "Decimal(Some((50, 0)))", nullable)] - pub difficulty: Option, + pub difficulty: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub gas_limit: BigDecimal, + pub gas_limit: Decimal, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub gas_used: BigDecimal, + pub gas_used: Decimal, #[sea_orm( primary_key, auto_increment = false, @@ -29,13 +29,17 @@ pub struct Model { pub size: Option, pub timestamp: DateTime, #[sea_orm(column_type = "Decimal(Some((50, 0)))", nullable)] - pub total_difficulty: Option, + pub total_difficulty: Option, pub inserted_at: DateTime, pub updated_at: DateTime, pub refetch_needed: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub base_fee_per_gas: Option, + pub base_fee_per_gas: Option, pub is_empty: Option, + #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] + pub blob_gas_used: Option, + #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] + pub excess_blob_gas: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/bridged_tokens.rs b/libs/blockscout-db/entity/src/bridged_tokens.rs new file mode 100644 index 000000000..78c012561 --- /dev/null +++ b/libs/blockscout-db/entity/src/bridged_tokens.rs @@ -0,0 +1,40 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "bridged_tokens")] +pub struct Model { + pub foreign_chain_id: Decimal, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub foreign_token_contract_address_hash: Vec, + pub exchange_rate: Option, + pub custom_metadata: Option, + pub lp_token: Option, + pub custom_cap: Option, + pub r#type: Option, + #[sea_orm(column_type = "VarBinary(StringLen::None)", unique)] + pub home_token_contract_address_hash: Vec, + pub inserted_at: DateTime, + pub updated_at: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::tokens::Entity", + from = "Column::HomeTokenContractAddressHash", + to = "super::tokens::Column::ContractAddressHash", + on_update = "NoAction", + on_delete = "Cascade" + )] + Tokens, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Tokens.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/emission_rewards.rs b/libs/blockscout-db/entity/src/emission_rewards.rs index fe1184e61..d679750ee 100644 --- a/libs/blockscout-db/entity/src/emission_rewards.rs +++ b/libs/blockscout-db/entity/src/emission_rewards.rs @@ -11,7 +11,7 @@ pub struct Model { column_type = "custom(\"int8range\")" )] pub block_range: String, - pub reward: Option, + pub reward: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/internal_transactions.rs b/libs/blockscout-db/entity/src/internal_transactions.rs index 9d55f4e6b..ffb2cab85 100644 --- a/libs/blockscout-db/entity/src/internal_transactions.rs +++ b/libs/blockscout-db/entity/src/internal_transactions.rs @@ -10,9 +10,9 @@ pub struct Model { pub created_contract_code: Option>, pub error: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub gas: Option, + pub gas: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub gas_used: Option, + pub gas_used: Option, pub index: i32, #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] pub init: Option>, @@ -23,7 +23,7 @@ pub struct Model { pub trace_address: Vec, pub r#type: String, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub value: BigDecimal, + pub value: Decimal, pub inserted_at: DateTime, pub updated_at: DateTime, #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] diff --git a/libs/blockscout-db/entity/src/last_fetched_counters.rs b/libs/blockscout-db/entity/src/last_fetched_counters.rs index 4d9df2939..430f34fac 100644 --- a/libs/blockscout-db/entity/src/last_fetched_counters.rs +++ b/libs/blockscout-db/entity/src/last_fetched_counters.rs @@ -8,7 +8,7 @@ pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub counter_type: String, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub value: Option, + pub value: Option, pub inserted_at: DateTime, pub updated_at: DateTime, } diff --git a/libs/blockscout-db/entity/src/lib.rs b/libs/blockscout-db/entity/src/lib.rs index e50c52747..020666ac9 100644 --- a/libs/blockscout-db/entity/src/lib.rs +++ b/libs/blockscout-db/entity/src/lib.rs @@ -2,16 +2,6 @@ pub mod prelude; -pub mod account_api_keys; -pub mod account_api_plans; -pub mod account_custom_abis; -pub mod account_identities; -pub mod account_public_tags_requests; -pub mod account_tag_addresses; -pub mod account_tag_transactions; -pub mod account_watchlist_addresses; -pub mod account_watchlist_notifications; -pub mod account_watchlists; pub mod address_coin_balances; pub mod address_coin_balances_daily; pub mod address_contract_code_fetch_attempts; @@ -22,9 +12,12 @@ pub mod address_to_tags; pub mod address_token_balances; pub mod addresses; pub mod administrators; +pub mod beacon_blobs; +pub mod beacon_blobs_transactions; pub mod block_rewards; pub mod block_second_degree_relations; pub mod blocks; +pub mod bridged_tokens; pub mod constants; pub mod contract_methods; pub mod contract_verification_status; @@ -42,8 +35,10 @@ pub mod missing_block_ranges; pub mod pending_block_operations; pub mod proxy_implementations; pub mod proxy_smart_contract_verification_statuses; +pub mod scam_address_badge_mappings; pub mod schema_migrations; pub mod sea_orm_active_enums; +pub mod signed_authorizations; pub mod smart_contract_audit_reports; pub mod smart_contracts; pub mod smart_contracts_additional_sources; @@ -57,6 +52,8 @@ pub mod transaction_forks; pub mod transaction_stats; pub mod transactions; pub mod user_contacts; +pub mod user_operations; +pub mod user_ops_indexer_migrations; pub mod users; pub mod validators; pub mod withdrawals; diff --git a/libs/blockscout-db/entity/src/market_history.rs b/libs/blockscout-db/entity/src/market_history.rs index 76f6df380..667bae691 100644 --- a/libs/blockscout-db/entity/src/market_history.rs +++ b/libs/blockscout-db/entity/src/market_history.rs @@ -8,10 +8,10 @@ pub struct Model { #[sea_orm(primary_key)] pub id: i64, pub date: Date, - pub closing_price: Option, - pub opening_price: Option, - pub market_cap: Option, - pub tvl: Option, + pub closing_price: Option, + pub opening_price: Option, + pub market_cap: Option, + pub tvl: Option, pub secondary_coin: Option, } diff --git a/libs/blockscout-db/entity/src/migrations_status.rs b/libs/blockscout-db/entity/src/migrations_status.rs index a4e519b10..711e38c73 100644 --- a/libs/blockscout-db/entity/src/migrations_status.rs +++ b/libs/blockscout-db/entity/src/migrations_status.rs @@ -10,6 +10,8 @@ pub struct Model { pub status: Option, pub inserted_at: DateTime, pub updated_at: DateTime, + #[sea_orm(column_type = "JsonBinary", nullable)] + pub meta: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/prelude.rs b/libs/blockscout-db/entity/src/prelude.rs index b01cc4159..a5de5ad37 100644 --- a/libs/blockscout-db/entity/src/prelude.rs +++ b/libs/blockscout-db/entity/src/prelude.rs @@ -1,15 +1,6 @@ //! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 pub use super::{ - account_api_keys::Entity as AccountApiKeys, account_api_plans::Entity as AccountApiPlans, - account_custom_abis::Entity as AccountCustomAbis, - account_identities::Entity as AccountIdentities, - account_public_tags_requests::Entity as AccountPublicTagsRequests, - account_tag_addresses::Entity as AccountTagAddresses, - account_tag_transactions::Entity as AccountTagTransactions, - account_watchlist_addresses::Entity as AccountWatchlistAddresses, - account_watchlist_notifications::Entity as AccountWatchlistNotifications, - account_watchlists::Entity as AccountWatchlists, address_coin_balances::Entity as AddressCoinBalances, address_coin_balances_daily::Entity as AddressCoinBalancesDaily, address_contract_code_fetch_attempts::Entity as AddressContractCodeFetchAttempts, @@ -17,9 +8,12 @@ pub use super::{ address_names::Entity as AddressNames, address_tags::Entity as AddressTags, address_to_tags::Entity as AddressToTags, address_token_balances::Entity as AddressTokenBalances, addresses::Entity as Addresses, - administrators::Entity as Administrators, block_rewards::Entity as BlockRewards, + administrators::Entity as Administrators, beacon_blobs::Entity as BeaconBlobs, + beacon_blobs_transactions::Entity as BeaconBlobsTransactions, + block_rewards::Entity as BlockRewards, block_second_degree_relations::Entity as BlockSecondDegreeRelations, blocks::Entity as Blocks, - constants::Entity as Constants, contract_methods::Entity as ContractMethods, + bridged_tokens::Entity as BridgedTokens, constants::Entity as Constants, + contract_methods::Entity as ContractMethods, contract_verification_status::Entity as ContractVerificationStatus, decompiled_smart_contracts::Entity as DecompiledSmartContracts, emission_rewards::Entity as EmissionRewards, event_notifications::Entity as EventNotifications, @@ -32,7 +26,9 @@ pub use super::{ pending_block_operations::Entity as PendingBlockOperations, proxy_implementations::Entity as ProxyImplementations, proxy_smart_contract_verification_statuses::Entity as ProxySmartContractVerificationStatuses, + scam_address_badge_mappings::Entity as ScamAddressBadgeMappings, schema_migrations::Entity as SchemaMigrations, + signed_authorizations::Entity as SignedAuthorizations, smart_contract_audit_reports::Entity as SmartContractAuditReports, smart_contracts::Entity as SmartContracts, smart_contracts_additional_sources::Entity as SmartContractsAdditionalSources, @@ -43,5 +39,7 @@ pub use super::{ transaction_actions::Entity as TransactionActions, transaction_forks::Entity as TransactionForks, transaction_stats::Entity as TransactionStats, transactions::Entity as Transactions, user_contacts::Entity as UserContacts, - users::Entity as Users, validators::Entity as Validators, withdrawals::Entity as Withdrawals, + user_operations::Entity as UserOperations, + user_ops_indexer_migrations::Entity as UserOpsIndexerMigrations, users::Entity as Users, + validators::Entity as Validators, withdrawals::Entity as Withdrawals, }; diff --git a/libs/blockscout-db/entity/src/proxy_implementations.rs b/libs/blockscout-db/entity/src/proxy_implementations.rs index 778496191..6b28d0636 100644 --- a/libs/blockscout-db/entity/src/proxy_implementations.rs +++ b/libs/blockscout-db/entity/src/proxy_implementations.rs @@ -12,8 +12,7 @@ pub struct Model { column_type = "VarBinary(StringLen::None)" )] pub proxy_address_hash: Vec, - // removed: sea-orm can't compile with Vec> - // pub address_hashes: Vec>, + pub address_hashes: Vec>, pub names: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/scam_address_badge_mappings.rs b/libs/blockscout-db/entity/src/scam_address_badge_mappings.rs new file mode 100644 index 000000000..272d6fc9b --- /dev/null +++ b/libs/blockscout-db/entity/src/scam_address_badge_mappings.rs @@ -0,0 +1,36 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "scam_address_badge_mappings")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "VarBinary(StringLen::None)" + )] + pub address_hash: Vec, + pub inserted_at: DateTime, + pub updated_at: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::addresses::Entity", + from = "Column::AddressHash", + to = "super::addresses::Column::Hash", + on_update = "NoAction", + on_delete = "Cascade" + )] + Addresses, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Addresses.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/sea_orm_active_enums.rs b/libs/blockscout-db/entity/src/sea_orm_active_enums.rs index de4f12965..0585f8f85 100644 --- a/libs/blockscout-db/entity/src/sea_orm_active_enums.rs +++ b/libs/blockscout-db/entity/src/sea_orm_active_enums.rs @@ -2,6 +2,18 @@ use sea_orm::entity::prelude::*; +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[sea_orm( + rs_type = "String", + db_type = "Enum", + enum_name = "entry_point_version" +)] +pub enum EntryPointVersion { + #[sea_orm(string_value = "v0.6")] + V06, + #[sea_orm(string_value = "v0.7")] + V07, +} #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "proxy_type")] pub enum ProxyType { @@ -21,6 +33,8 @@ pub enum ProxyType { Eip1967, #[sea_orm(string_value = "eip2535")] Eip2535, + #[sea_orm(string_value = "eip7702")] + Eip7702, #[sea_orm(string_value = "eip930")] Eip930, #[sea_orm(string_value = "master_copy")] @@ -29,6 +43,18 @@ pub enum ProxyType { Unknown, } #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "sponsor_type")] +pub enum SponsorType { + #[sea_orm(string_value = "paymaster_hybrid")] + PaymasterHybrid, + #[sea_orm(string_value = "paymaster_sponsor")] + PaymasterSponsor, + #[sea_orm(string_value = "wallet_balance")] + WalletBalance, + #[sea_orm(string_value = "wallet_deposit")] + WalletDeposit, +} +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[sea_orm( rs_type = "String", db_type = "Enum", diff --git a/libs/blockscout-db/entity/src/signed_authorizations.rs b/libs/blockscout-db/entity/src/signed_authorizations.rs new file mode 100644 index 000000000..347d1e308 --- /dev/null +++ b/libs/blockscout-db/entity/src/signed_authorizations.rs @@ -0,0 +1,49 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "signed_authorizations")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "VarBinary(StringLen::None)" + )] + pub transaction_hash: Vec, + #[sea_orm(primary_key, auto_increment = false)] + pub index: i32, + pub chain_id: i64, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub address: Vec, + pub nonce: i32, + pub v: i32, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub r: Decimal, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub s: Decimal, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub authority: Option>, + pub inserted_at: DateTime, + pub updated_at: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::transactions::Entity", + from = "Column::TransactionHash", + to = "super::transactions::Column::Hash", + on_update = "NoAction", + on_delete = "Cascade" + )] + Transactions, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Transactions.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/smart_contracts.rs b/libs/blockscout-db/entity/src/smart_contracts.rs index ee1614111..83d8010b5 100644 --- a/libs/blockscout-db/entity/src/smart_contracts.rs +++ b/libs/blockscout-db/entity/src/smart_contracts.rs @@ -38,6 +38,7 @@ pub struct Model { pub verified_via_verifier_alliance: Option, pub certified: Option, pub is_blueprint: Option, + pub language: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/token_instances.rs b/libs/blockscout-db/entity/src/token_instances.rs index 8caa5a5d4..d6aba6682 100644 --- a/libs/blockscout-db/entity/src/token_instances.rs +++ b/libs/blockscout-db/entity/src/token_instances.rs @@ -28,6 +28,11 @@ pub struct Model { pub owner_updated_at_log_index: Option, pub refetch_after: Option, pub retries_count: i16, + #[sea_orm(column_type = "JsonBinary", nullable)] + pub thumbnails: Option, + pub media_type: Option, + pub cdn_upload_error: Option, + pub is_banned: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/token_transfers.rs b/libs/blockscout-db/entity/src/token_transfers.rs index d25f6e4ad..d383c4fc7 100644 --- a/libs/blockscout-db/entity/src/token_transfers.rs +++ b/libs/blockscout-db/entity/src/token_transfers.rs @@ -17,7 +17,7 @@ pub struct Model { pub from_address_hash: Vec, #[sea_orm(column_type = "VarBinary(StringLen::None)")] pub to_address_hash: Vec, - pub amount: Option, + pub amount: Option, #[sea_orm(column_type = "VarBinary(StringLen::None)")] pub token_contract_address_hash: Vec, pub inserted_at: DateTime, diff --git a/libs/blockscout-db/entity/src/tokens.rs b/libs/blockscout-db/entity/src/tokens.rs index bf429ff62..dcb887d02 100644 --- a/libs/blockscout-db/entity/src/tokens.rs +++ b/libs/blockscout-db/entity/src/tokens.rs @@ -9,8 +9,8 @@ pub struct Model { pub name: Option, #[sea_orm(column_type = "Text", nullable)] pub symbol: Option, - pub total_supply: Option, - pub decimals: Option, + pub total_supply: Option, + pub decimals: Option, pub r#type: String, pub cataloged: Option, #[sea_orm( @@ -24,20 +24,29 @@ pub struct Model { pub updated_at: DateTime, pub holder_count: Option, pub skip_metadata: Option, - pub fiat_value: Option, - pub circulating_market_cap: Option, + pub fiat_value: Option, + pub circulating_market_cap: Option, pub total_supply_updated_at_block: Option, pub icon_url: Option, pub is_verified_via_admin_panel: Option, - pub volume_24h: Option, + pub bridged: Option, + pub volume_24h: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { + #[sea_orm(has_one = "super::bridged_tokens::Entity")] + BridgedTokens, #[sea_orm(has_many = "super::token_instances::Entity")] TokenInstances, } +impl Related for Entity { + fn to() -> RelationDef { + Relation::BridgedTokens.def() + } +} + impl Related for Entity { fn to() -> RelationDef { Relation::TokenInstances.def() diff --git a/libs/blockscout-db/entity/src/transaction_stats.rs b/libs/blockscout-db/entity/src/transaction_stats.rs index 3ff027812..43e0d3b89 100644 --- a/libs/blockscout-db/entity/src/transaction_stats.rs +++ b/libs/blockscout-db/entity/src/transaction_stats.rs @@ -11,9 +11,9 @@ pub struct Model { pub date: Option, pub number_of_transactions: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub gas_used: Option, + pub gas_used: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub total_fee: Option, + pub total_fee: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/transactions.rs b/libs/blockscout-db/entity/src/transactions.rs index cbc1e2b0d..c80ed7712 100644 --- a/libs/blockscout-db/entity/src/transactions.rs +++ b/libs/blockscout-db/entity/src/transactions.rs @@ -6,14 +6,14 @@ use sea_orm::entity::prelude::*; #[sea_orm(table_name = "transactions")] pub struct Model { #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub cumulative_gas_used: Option, + pub cumulative_gas_used: Option, pub error: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub gas: BigDecimal, + pub gas: Decimal, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub gas_price: Option, + pub gas_price: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub gas_used: Option, + pub gas_used: Option, #[sea_orm( primary_key, auto_increment = false, @@ -25,14 +25,14 @@ pub struct Model { pub input: Vec, pub nonce: i32, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub r: BigDecimal, + pub r: Decimal, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub s: BigDecimal, + pub s: Decimal, pub status: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub v: BigDecimal, + pub v: Decimal, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub value: BigDecimal, + pub value: Decimal, pub inserted_at: DateTime, pub updated_at: DateTime, #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] @@ -51,17 +51,19 @@ pub struct Model { #[sea_orm(column_type = "Text", nullable)] pub revert_reason: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub max_priority_fee_per_gas: Option, + pub max_priority_fee_per_gas: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub max_fee_per_gas: Option, + pub max_fee_per_gas: Option, pub r#type: Option, - pub has_error_in_internal_txs: Option, - pub block_timestamp: Option, + pub has_error_in_internal_transactions: Option, pub block_consensus: Option, + pub block_timestamp: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { + #[sea_orm(has_one = "super::beacon_blobs_transactions::Entity")] + BeaconBlobsTransactions, #[sea_orm( belongs_to = "super::blocks::Entity", from = "Column::BlockHash", @@ -74,6 +76,8 @@ pub enum Relation { InternalTransactions, #[sea_orm(has_many = "super::logs::Entity")] Logs, + #[sea_orm(has_many = "super::signed_authorizations::Entity")] + SignedAuthorizations, #[sea_orm(has_many = "super::token_transfers::Entity")] TokenTransfers, #[sea_orm(has_many = "super::transaction_actions::Entity")] @@ -82,6 +86,12 @@ pub enum Relation { TransactionForks, } +impl Related for Entity { + fn to() -> RelationDef { + Relation::BeaconBlobsTransactions.def() + } +} + impl Related for Entity { fn to() -> RelationDef { Relation::Blocks.def() @@ -100,6 +110,12 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + Relation::SignedAuthorizations.def() + } +} + impl Related for Entity { fn to() -> RelationDef { Relation::TokenTransfers.def() diff --git a/libs/blockscout-db/entity/src/user_operations.rs b/libs/blockscout-db/entity/src/user_operations.rs new file mode 100644 index 000000000..3ab5bf460 --- /dev/null +++ b/libs/blockscout-db/entity/src/user_operations.rs @@ -0,0 +1,76 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use super::sea_orm_active_enums::{EntryPointVersion, SponsorType}; +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "user_operations")] +pub struct Model { + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "VarBinary(StringLen::None)" + )] + pub hash: Vec, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub sender: Vec, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub nonce: Vec, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub init_code: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub call_data: Vec, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub call_gas_limit: Decimal, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub verification_gas_limit: Decimal, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub pre_verification_gas: Decimal, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub max_fee_per_gas: Decimal, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub max_priority_fee_per_gas: Decimal, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub paymaster_and_data: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub signature: Vec, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub aggregator: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub aggregator_signature: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub entry_point: Vec, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub transaction_hash: Vec, + pub block_number: i32, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub block_hash: Vec, + pub bundle_index: i32, + pub index: i32, + pub user_logs_start_index: i32, + pub user_logs_count: i32, + #[sea_orm(column_type = "VarBinary(StringLen::None)")] + pub bundler: Vec, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub factory: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub paymaster: Option>, + pub status: bool, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub revert_reason: Option>, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub gas: Decimal, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub gas_price: Decimal, + #[sea_orm(column_type = "Decimal(Some((100, 0)))")] + pub gas_used: Decimal, + pub sponsor_type: SponsorType, + pub inserted_at: DateTime, + pub updated_at: DateTime, + pub entry_point_version: EntryPointVersion, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/user_ops_indexer_migrations.rs b/libs/blockscout-db/entity/src/user_ops_indexer_migrations.rs new file mode 100644 index 000000000..1cf3a2d56 --- /dev/null +++ b/libs/blockscout-db/entity/src/user_ops_indexer_migrations.rs @@ -0,0 +1,16 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "user_ops_indexer_migrations")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub version: String, + pub applied_at: i64, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/withdrawals.rs b/libs/blockscout-db/entity/src/withdrawals.rs index 00d08f130..4715168cc 100644 --- a/libs/blockscout-db/entity/src/withdrawals.rs +++ b/libs/blockscout-db/entity/src/withdrawals.rs @@ -9,7 +9,7 @@ pub struct Model { pub index: i32, pub validator_index: i32, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub amount: BigDecimal, + pub amount: Decimal, pub inserted_at: DateTime, pub updated_at: DateTime, #[sea_orm(column_type = "VarBinary(StringLen::None)")] From 32df43298806ae7dad0a203843b9b2ed74aaef22 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 16:14:36 +0500 Subject: [PATCH 03/12] manually fix compilation --- .../blockscout-db/entity/src/beacon_blobs_transactions.rs | 3 ++- libs/blockscout-db/entity/src/bridged_tokens.rs | 8 +++++++- libs/blockscout-db/entity/src/proxy_implementations.rs | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs b/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs index e1cc33159..33f45ada9 100644 --- a/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs +++ b/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs @@ -17,7 +17,8 @@ pub struct Model { pub blob_gas_price: Decimal, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] pub blob_gas_used: Decimal, - pub blob_versioned_hashes: Vec>, + // removed: sea-orm can't compile with Vec> + // pub blob_versioned_hashes: Vec>, pub inserted_at: DateTime, pub updated_at: DateTime, } diff --git a/libs/blockscout-db/entity/src/bridged_tokens.rs b/libs/blockscout-db/entity/src/bridged_tokens.rs index 78c012561..c030bdad8 100644 --- a/libs/blockscout-db/entity/src/bridged_tokens.rs +++ b/libs/blockscout-db/entity/src/bridged_tokens.rs @@ -13,7 +13,13 @@ pub struct Model { pub lp_token: Option, pub custom_cap: Option, pub r#type: Option, - #[sea_orm(column_type = "VarBinary(StringLen::None)", unique)] + #[sea_orm( + column_type = "VarBinary(StringLen::None)", + unique, + // changed: fix no key columns + primary_key, + auto_increment = false + )] pub home_token_contract_address_hash: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/proxy_implementations.rs b/libs/blockscout-db/entity/src/proxy_implementations.rs index 6b28d0636..778496191 100644 --- a/libs/blockscout-db/entity/src/proxy_implementations.rs +++ b/libs/blockscout-db/entity/src/proxy_implementations.rs @@ -12,7 +12,8 @@ pub struct Model { column_type = "VarBinary(StringLen::None)" )] pub proxy_address_hash: Vec, - pub address_hashes: Vec>, + // removed: sea-orm can't compile with Vec> + // pub address_hashes: Vec>, pub names: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, From babe99b1ad73608231257ff2d19ee2f635e04073 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 16:15:23 +0500 Subject: [PATCH 04/12] remove unused tables --- .../entity/src/account_api_keys.rs | 34 ------- .../entity/src/account_api_plans.rs | 28 ------ .../entity/src/account_custom_abis.rs | 41 -------- .../entity/src/account_identities.rs | 94 ------------------- .../src/account_public_tags_requests.rs | 50 ---------- .../entity/src/account_tag_addresses.rs | 39 -------- .../entity/src/account_tag_transactions.rs | 39 -------- .../entity/src/account_watchlist_addresses.rs | 53 ----------- .../src/account_watchlist_notifications.rs | 44 --------- .../entity/src/account_watchlists.rs | 42 --------- 10 files changed, 464 deletions(-) delete mode 100644 libs/blockscout-db/entity/src/account_api_keys.rs delete mode 100644 libs/blockscout-db/entity/src/account_api_plans.rs delete mode 100644 libs/blockscout-db/entity/src/account_custom_abis.rs delete mode 100644 libs/blockscout-db/entity/src/account_identities.rs delete mode 100644 libs/blockscout-db/entity/src/account_public_tags_requests.rs delete mode 100644 libs/blockscout-db/entity/src/account_tag_addresses.rs delete mode 100644 libs/blockscout-db/entity/src/account_tag_transactions.rs delete mode 100644 libs/blockscout-db/entity/src/account_watchlist_addresses.rs delete mode 100644 libs/blockscout-db/entity/src/account_watchlist_notifications.rs delete mode 100644 libs/blockscout-db/entity/src/account_watchlists.rs diff --git a/libs/blockscout-db/entity/src/account_api_keys.rs b/libs/blockscout-db/entity/src/account_api_keys.rs deleted file mode 100644 index 5bb2c5fee..000000000 --- a/libs/blockscout-db/entity/src/account_api_keys.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_api_keys")] -pub struct Model { - pub identity_id: i64, - pub name: String, - #[sea_orm(primary_key, auto_increment = false)] - pub value: Uuid, - pub inserted_at: DateTime, - pub updated_at: DateTime, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::account_identities::Entity", - from = "Column::IdentityId", - to = "super::account_identities::Column::Id", - on_update = "NoAction", - on_delete = "Cascade" - )] - AccountIdentities, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountIdentities.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_api_plans.rs b/libs/blockscout-db/entity/src/account_api_plans.rs deleted file mode 100644 index 52b3dec09..000000000 --- a/libs/blockscout-db/entity/src/account_api_plans.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_api_plans")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i32, - pub max_req_per_second: Option, - pub name: String, - pub inserted_at: DateTime, - pub updated_at: DateTime, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm(has_many = "super::account_identities::Entity")] - AccountIdentities, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountIdentities.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_custom_abis.rs b/libs/blockscout-db/entity/src/account_custom_abis.rs deleted file mode 100644 index 21579040e..000000000 --- a/libs/blockscout-db/entity/src/account_custom_abis.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_custom_abis")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i32, - pub identity_id: i64, - #[sea_orm(column_type = "JsonBinary")] - pub abi: Json, - pub inserted_at: DateTime, - pub updated_at: DateTime, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub address_hash_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub address_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub name: Option>, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::account_identities::Entity", - from = "Column::IdentityId", - to = "super::account_identities::Column::Id", - on_update = "NoAction", - on_delete = "Cascade" - )] - AccountIdentities, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountIdentities.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_identities.rs b/libs/blockscout-db/entity/src/account_identities.rs deleted file mode 100644 index 2a67b267b..000000000 --- a/libs/blockscout-db/entity/src/account_identities.rs +++ /dev/null @@ -1,94 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_identities")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i64, - pub inserted_at: DateTime, - pub updated_at: DateTime, - pub plan_id: Option, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub uid: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable, unique)] - pub uid_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub email: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub name: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub nickname: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub avatar: Option>, - pub verification_email_sent_at: Option, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm(has_many = "super::account_api_keys::Entity")] - AccountApiKeys, - #[sea_orm( - belongs_to = "super::account_api_plans::Entity", - from = "Column::PlanId", - to = "super::account_api_plans::Column::Id", - on_update = "NoAction", - on_delete = "NoAction" - )] - AccountApiPlans, - #[sea_orm(has_many = "super::account_custom_abis::Entity")] - AccountCustomAbis, - #[sea_orm(has_many = "super::account_public_tags_requests::Entity")] - AccountPublicTagsRequests, - #[sea_orm(has_many = "super::account_tag_addresses::Entity")] - AccountTagAddresses, - #[sea_orm(has_many = "super::account_tag_transactions::Entity")] - AccountTagTransactions, - #[sea_orm(has_many = "super::account_watchlists::Entity")] - AccountWatchlists, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountApiKeys.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountApiPlans.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountCustomAbis.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountPublicTagsRequests.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountTagAddresses.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountTagTransactions.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountWatchlists.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_public_tags_requests.rs b/libs/blockscout-db/entity/src/account_public_tags_requests.rs deleted file mode 100644 index f186662ed..000000000 --- a/libs/blockscout-db/entity/src/account_public_tags_requests.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_public_tags_requests")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i64, - pub identity_id: Option, - pub company: Option, - pub website: Option, - pub tags: Option, - #[sea_orm(column_type = "Text", nullable)] - pub description: Option, - pub additional_comment: Option, - pub request_type: Option, - pub is_owner: Option, - #[sea_orm(column_type = "Text", nullable)] - pub remove_reason: Option, - pub request_id: Option, - pub inserted_at: DateTime, - pub updated_at: DateTime, - // removed: sea-orm can't compile with Vec> - // pub addresses: Option>>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub email: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub full_name: Option>, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::account_identities::Entity", - from = "Column::IdentityId", - to = "super::account_identities::Column::Id", - on_update = "NoAction", - on_delete = "NoAction" - )] - AccountIdentities, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountIdentities.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_tag_addresses.rs b/libs/blockscout-db/entity/src/account_tag_addresses.rs deleted file mode 100644 index 445aec2bd..000000000 --- a/libs/blockscout-db/entity/src/account_tag_addresses.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_tag_addresses")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i64, - pub identity_id: Option, - pub inserted_at: DateTime, - pub updated_at: DateTime, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub address_hash_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub name: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub address_hash: Option>, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::account_identities::Entity", - from = "Column::IdentityId", - to = "super::account_identities::Column::Id", - on_update = "NoAction", - on_delete = "Cascade" - )] - AccountIdentities, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountIdentities.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_tag_transactions.rs b/libs/blockscout-db/entity/src/account_tag_transactions.rs deleted file mode 100644 index 4776beda5..000000000 --- a/libs/blockscout-db/entity/src/account_tag_transactions.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_tag_transactions")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i64, - pub identity_id: Option, - pub inserted_at: DateTime, - pub updated_at: DateTime, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub tx_hash_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub name: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub tx_hash: Option>, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::account_identities::Entity", - from = "Column::IdentityId", - to = "super::account_identities::Column::Id", - on_update = "NoAction", - on_delete = "Cascade" - )] - AccountIdentities, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountIdentities.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_watchlist_addresses.rs b/libs/blockscout-db/entity/src/account_watchlist_addresses.rs deleted file mode 100644 index 5f61ba30a..000000000 --- a/libs/blockscout-db/entity/src/account_watchlist_addresses.rs +++ /dev/null @@ -1,53 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_watchlist_addresses")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i64, - pub watchlist_id: Option, - pub watch_coin_input: Option, - pub watch_coin_output: Option, - pub watch_erc_20_input: Option, - pub watch_erc_20_output: Option, - pub watch_erc_721_input: Option, - pub watch_erc_721_output: Option, - pub watch_erc_1155_input: Option, - pub watch_erc_1155_output: Option, - pub notify_email: Option, - pub notify_epns: Option, - pub notify_feed: Option, - pub notify_inapp: Option, - pub inserted_at: DateTime, - pub updated_at: DateTime, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub address_hash_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub name: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub address_hash: Option>, - pub watch_erc_404_input: Option, - pub watch_erc_404_output: Option, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::account_watchlists::Entity", - from = "Column::WatchlistId", - to = "super::account_watchlists::Column::Id", - on_update = "NoAction", - on_delete = "Cascade" - )] - AccountWatchlists, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountWatchlists.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_watchlist_notifications.rs b/libs/blockscout-db/entity/src/account_watchlist_notifications.rs deleted file mode 100644 index b968e85f5..000000000 --- a/libs/blockscout-db/entity/src/account_watchlist_notifications.rs +++ /dev/null @@ -1,44 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_watchlist_notifications")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i64, - pub watchlist_address_id: Option, - pub direction: Option, - pub r#type: Option, - pub method: Option, - pub block_number: Option, - pub amount: Option, - pub tx_fee: Option, - pub viewed_at: Option, - pub inserted_at: DateTime, - pub updated_at: DateTime, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub name: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub subject: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub from_address_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub to_address_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub transaction_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub subject_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub from_address_hash_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub to_address_hash_hash: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub transaction_hash_hash: Option>, - pub watchlist_id: i64, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_watchlists.rs b/libs/blockscout-db/entity/src/account_watchlists.rs deleted file mode 100644 index 5fe2e7d55..000000000 --- a/libs/blockscout-db/entity/src/account_watchlists.rs +++ /dev/null @@ -1,42 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "account_watchlists")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i64, - pub name: Option, - pub identity_id: Option, - pub inserted_at: DateTime, - pub updated_at: DateTime, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::account_identities::Entity", - from = "Column::IdentityId", - to = "super::account_identities::Column::Id", - on_update = "NoAction", - on_delete = "Cascade" - )] - AccountIdentities, - #[sea_orm(has_many = "super::account_watchlist_addresses::Entity")] - AccountWatchlistAddresses, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountIdentities.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::AccountWatchlistAddresses.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} From fd295f83cd6518a8fc014a02c9dae2e2ccde95b5 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 16:18:11 +0500 Subject: [PATCH 05/12] remove old files in just script --- libs/blockscout-db/justfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/blockscout-db/justfile b/libs/blockscout-db/justfile index 2cf584b9e..c68a862ea 100644 --- a/libs/blockscout-db/justfile +++ b/libs/blockscout-db/justfile @@ -26,10 +26,12 @@ new-migration name: sea-orm-cli migrate generate {{name}} generate-entities database_url="postgres://postgres:admin@localhost:5432/blockscout": + rm entity/src/* DATABASE_URL={{database_url}} sea-orm-cli generate entity --lib -o entity/src cargo fmt --all -- --config imports_granularity=Crate generate-entities-from-blockscout-image database_url="postgres://postgres:admin@localhost:5432/blockscout": + rm entity/src/* docker run --network=host -e 'DATABASE_URL={{database_url}}' -e 'ECTO_USE_SSL=false' --entrypoint "/bin/sh" --rm blockscout/blockscout:{{blockscout-version}} -c 'bin/blockscout eval "Elixir.Explorer.ReleaseTasks.create_and_migrate()"' DATABASE_URL={{database_url}} sea-orm-cli generate entity --lib -o entity/src cargo fmt --all -- --config imports_granularity=Crate From 66790cee2afc51a941ccd8947e4767039dc8f3c1 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 16:36:48 +0500 Subject: [PATCH 06/12] bump version --- libs/blockscout-db/Cargo.toml | 2 +- libs/blockscout-db/entity/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/blockscout-db/Cargo.toml b/libs/blockscout-db/Cargo.toml index 3ea8d3cd0..57f77ab49 100644 --- a/libs/blockscout-db/Cargo.toml +++ b/libs/blockscout-db/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blockscout-db" -version = "0.2.0+blockscout.6.8.0" +version = "0.3.0+blockscout.6.10.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/libs/blockscout-db/entity/Cargo.toml b/libs/blockscout-db/entity/Cargo.toml index a1c592652..f51a7a0cb 100644 --- a/libs/blockscout-db/entity/Cargo.toml +++ b/libs/blockscout-db/entity/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blockscout-db-entity" -version = "0.2.1+blockscout.6.8.0" +version = "0.3.0+blockscout.6.10.0" edition = "2021" publish = false From 12a62d1c7f28841ab5e3aae1ca37d5123f522267 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 16:54:11 +0500 Subject: [PATCH 07/12] fix justfile fail on failed rm and empty file produced after sed --- libs/blockscout-db/justfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/blockscout-db/justfile b/libs/blockscout-db/justfile index c68a862ea..b2ff75faa 100644 --- a/libs/blockscout-db/justfile +++ b/libs/blockscout-db/justfile @@ -26,12 +26,12 @@ new-migration name: sea-orm-cli migrate generate {{name}} generate-entities database_url="postgres://postgres:admin@localhost:5432/blockscout": - rm entity/src/* + rm entity/src/* || true DATABASE_URL={{database_url}} sea-orm-cli generate entity --lib -o entity/src cargo fmt --all -- --config imports_granularity=Crate generate-entities-from-blockscout-image database_url="postgres://postgres:admin@localhost:5432/blockscout": - rm entity/src/* + rm entity/src/* || true docker run --network=host -e 'DATABASE_URL={{database_url}}' -e 'ECTO_USE_SSL=false' --entrypoint "/bin/sh" --rm blockscout/blockscout:{{blockscout-version}} -c 'bin/blockscout eval "Elixir.Explorer.ReleaseTasks.create_and_migrate()"' DATABASE_URL={{database_url}} sea-orm-cli generate entity --lib -o entity/src cargo fmt --all -- --config imports_granularity=Crate @@ -40,4 +40,4 @@ generate-migration database_url="postgres://postgres:admin@localhost:5432/blocks docker run --network=host -e 'DATABASE_URL={{database_url}}' -e 'ECTO_USE_SSL=false' --entrypoint "/bin/sh" --rm blockscout/blockscout:{{blockscout-version}} -c 'bin/blockscout eval "Elixir.Explorer.ReleaseTasks.create_and_migrate()"' docker exec blockscout-postgres pg_dump -s --inserts -h localhost -U postgres blockscout > {{migration_file}} # remove unwanted config - sed -e '/SELECT pg_catalog.set_config/d' {{migration_file}} > {{migration_file}} \ No newline at end of file + sed -e '/SELECT pg_catalog.set_config/d' {{migration_file}} > {{migration_file}}_tmp && mv {{migration_file}}_tmp {{migration_file}} \ No newline at end of file From ac171b672a3aa83cb15cd71477a718f5a825a9a7 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 17:54:15 +0500 Subject: [PATCH 08/12] regenerate from blockscout image w/o user-operations --- .../entity/src/account_api_keys.rs | 34 ++++ .../entity/src/account_api_plans.rs | 28 +++ .../entity/src/account_custom_abis.rs | 42 +++++ .../entity/src/account_identities.rs | 91 ++++++++++ .../src/account_public_tags_requests.rs | 49 ++++++ .../entity/src/account_tag_addresses.rs | 40 +++++ .../entity/src/account_tag_transactions.rs | 40 +++++ .../entity/src/account_watchlist_addresses.rs | 54 ++++++ .../src/account_watchlist_notifications.rs | 44 +++++ .../entity/src/account_watchlists.rs | 42 +++++ libs/blockscout-db/entity/src/beacon_blobs.rs | 26 --- .../entity/src/beacon_blobs_transactions.rs | 44 ----- libs/blockscout-db/entity/src/blocks.rs | 4 - .../entity/src/bridged_tokens.rs | 46 ----- libs/blockscout-db/entity/src/lib.rs | 15 +- libs/blockscout-db/entity/src/prelude.rs | 20 ++- .../entity/src/proxy_implementations.rs | 3 +- .../entity/src/sea_orm_active_enums.rs | 24 --- libs/blockscout-db/entity/src/tokens.rs | 9 - libs/blockscout-db/entity/src/transactions.rs | 10 +- libs/blockscout-db/justfile | 2 +- .../blockscout-db/migration/src/migration.sql | 161 +++++++++++++++--- 22 files changed, 629 insertions(+), 199 deletions(-) create mode 100644 libs/blockscout-db/entity/src/account_api_keys.rs create mode 100644 libs/blockscout-db/entity/src/account_api_plans.rs create mode 100644 libs/blockscout-db/entity/src/account_custom_abis.rs create mode 100644 libs/blockscout-db/entity/src/account_identities.rs create mode 100644 libs/blockscout-db/entity/src/account_public_tags_requests.rs create mode 100644 libs/blockscout-db/entity/src/account_tag_addresses.rs create mode 100644 libs/blockscout-db/entity/src/account_tag_transactions.rs create mode 100644 libs/blockscout-db/entity/src/account_watchlist_addresses.rs create mode 100644 libs/blockscout-db/entity/src/account_watchlist_notifications.rs create mode 100644 libs/blockscout-db/entity/src/account_watchlists.rs delete mode 100644 libs/blockscout-db/entity/src/beacon_blobs.rs delete mode 100644 libs/blockscout-db/entity/src/beacon_blobs_transactions.rs delete mode 100644 libs/blockscout-db/entity/src/bridged_tokens.rs diff --git a/libs/blockscout-db/entity/src/account_api_keys.rs b/libs/blockscout-db/entity/src/account_api_keys.rs new file mode 100644 index 000000000..5bb2c5fee --- /dev/null +++ b/libs/blockscout-db/entity/src/account_api_keys.rs @@ -0,0 +1,34 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_api_keys")] +pub struct Model { + pub identity_id: i64, + pub name: String, + #[sea_orm(primary_key, auto_increment = false)] + pub value: Uuid, + pub inserted_at: DateTime, + pub updated_at: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::account_identities::Entity", + from = "Column::IdentityId", + to = "super::account_identities::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + AccountIdentities, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountIdentities.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_api_plans.rs b/libs/blockscout-db/entity/src/account_api_plans.rs new file mode 100644 index 000000000..52b3dec09 --- /dev/null +++ b/libs/blockscout-db/entity/src/account_api_plans.rs @@ -0,0 +1,28 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_api_plans")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub max_req_per_second: Option, + pub name: String, + pub inserted_at: DateTime, + pub updated_at: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::account_identities::Entity")] + AccountIdentities, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountIdentities.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_custom_abis.rs b/libs/blockscout-db/entity/src/account_custom_abis.rs new file mode 100644 index 000000000..7baa1aae6 --- /dev/null +++ b/libs/blockscout-db/entity/src/account_custom_abis.rs @@ -0,0 +1,42 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_custom_abis")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub identity_id: i64, + #[sea_orm(column_type = "JsonBinary")] + pub abi: Json, + pub inserted_at: DateTime, + pub updated_at: DateTime, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub address_hash_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub address_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub name: Option>, + pub user_created: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::account_identities::Entity", + from = "Column::IdentityId", + to = "super::account_identities::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + AccountIdentities, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountIdentities.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_identities.rs b/libs/blockscout-db/entity/src/account_identities.rs new file mode 100644 index 000000000..fade97125 --- /dev/null +++ b/libs/blockscout-db/entity/src/account_identities.rs @@ -0,0 +1,91 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_identities")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub inserted_at: DateTime, + pub updated_at: DateTime, + pub plan_id: Option, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub uid: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable, unique)] + pub uid_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub email: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub avatar: Option>, + pub verification_email_sent_at: Option, + pub otp_sent_at: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::account_api_keys::Entity")] + AccountApiKeys, + #[sea_orm( + belongs_to = "super::account_api_plans::Entity", + from = "Column::PlanId", + to = "super::account_api_plans::Column::Id", + on_update = "NoAction", + on_delete = "NoAction" + )] + AccountApiPlans, + #[sea_orm(has_many = "super::account_custom_abis::Entity")] + AccountCustomAbis, + #[sea_orm(has_many = "super::account_public_tags_requests::Entity")] + AccountPublicTagsRequests, + #[sea_orm(has_many = "super::account_tag_addresses::Entity")] + AccountTagAddresses, + #[sea_orm(has_many = "super::account_tag_transactions::Entity")] + AccountTagTransactions, + #[sea_orm(has_many = "super::account_watchlists::Entity")] + AccountWatchlists, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountApiKeys.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountApiPlans.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountCustomAbis.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountPublicTagsRequests.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountTagAddresses.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountTagTransactions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountWatchlists.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_public_tags_requests.rs b/libs/blockscout-db/entity/src/account_public_tags_requests.rs new file mode 100644 index 000000000..1e12fa3e2 --- /dev/null +++ b/libs/blockscout-db/entity/src/account_public_tags_requests.rs @@ -0,0 +1,49 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_public_tags_requests")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub identity_id: Option, + pub company: Option, + pub website: Option, + pub tags: Option, + #[sea_orm(column_type = "Text", nullable)] + pub description: Option, + pub additional_comment: Option, + pub request_type: Option, + pub is_owner: Option, + #[sea_orm(column_type = "Text", nullable)] + pub remove_reason: Option, + pub request_id: Option, + pub inserted_at: DateTime, + pub updated_at: DateTime, + pub addresses: Option>>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub email: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub full_name: Option>, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::account_identities::Entity", + from = "Column::IdentityId", + to = "super::account_identities::Column::Id", + on_update = "NoAction", + on_delete = "NoAction" + )] + AccountIdentities, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountIdentities.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_tag_addresses.rs b/libs/blockscout-db/entity/src/account_tag_addresses.rs new file mode 100644 index 000000000..e4650c346 --- /dev/null +++ b/libs/blockscout-db/entity/src/account_tag_addresses.rs @@ -0,0 +1,40 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_tag_addresses")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub identity_id: Option, + pub inserted_at: DateTime, + pub updated_at: DateTime, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub address_hash_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub name: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub address_hash: Option>, + pub user_created: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::account_identities::Entity", + from = "Column::IdentityId", + to = "super::account_identities::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + AccountIdentities, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountIdentities.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_tag_transactions.rs b/libs/blockscout-db/entity/src/account_tag_transactions.rs new file mode 100644 index 000000000..724c52b5c --- /dev/null +++ b/libs/blockscout-db/entity/src/account_tag_transactions.rs @@ -0,0 +1,40 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_tag_transactions")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub identity_id: Option, + pub inserted_at: DateTime, + pub updated_at: DateTime, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub transaction_hash_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub name: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub transaction_hash: Option>, + pub user_created: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::account_identities::Entity", + from = "Column::IdentityId", + to = "super::account_identities::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + AccountIdentities, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountIdentities.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_watchlist_addresses.rs b/libs/blockscout-db/entity/src/account_watchlist_addresses.rs new file mode 100644 index 000000000..4db888a48 --- /dev/null +++ b/libs/blockscout-db/entity/src/account_watchlist_addresses.rs @@ -0,0 +1,54 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_watchlist_addresses")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub watchlist_id: Option, + pub watch_coin_input: Option, + pub watch_coin_output: Option, + pub watch_erc_20_input: Option, + pub watch_erc_20_output: Option, + pub watch_erc_721_input: Option, + pub watch_erc_721_output: Option, + pub watch_erc_1155_input: Option, + pub watch_erc_1155_output: Option, + pub notify_email: Option, + pub notify_epns: Option, + pub notify_feed: Option, + pub notify_inapp: Option, + pub inserted_at: DateTime, + pub updated_at: DateTime, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub address_hash_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub name: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub address_hash: Option>, + pub watch_erc_404_input: Option, + pub watch_erc_404_output: Option, + pub user_created: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::account_watchlists::Entity", + from = "Column::WatchlistId", + to = "super::account_watchlists::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + AccountWatchlists, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountWatchlists.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_watchlist_notifications.rs b/libs/blockscout-db/entity/src/account_watchlist_notifications.rs new file mode 100644 index 000000000..a6cf73971 --- /dev/null +++ b/libs/blockscout-db/entity/src/account_watchlist_notifications.rs @@ -0,0 +1,44 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_watchlist_notifications")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub watchlist_address_id: Option, + pub direction: Option, + pub r#type: Option, + pub method: Option, + pub block_number: Option, + pub amount: Option, + pub transaction_fee: Option, + pub viewed_at: Option, + pub inserted_at: DateTime, + pub updated_at: DateTime, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub name: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub subject: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub from_address_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub to_address_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub transaction_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub subject_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub from_address_hash_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub to_address_hash_hash: Option>, + #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] + pub transaction_hash_hash: Option>, + pub watchlist_id: i64, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/account_watchlists.rs b/libs/blockscout-db/entity/src/account_watchlists.rs new file mode 100644 index 000000000..5fe2e7d55 --- /dev/null +++ b/libs/blockscout-db/entity/src/account_watchlists.rs @@ -0,0 +1,42 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "account_watchlists")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub name: Option, + pub identity_id: Option, + pub inserted_at: DateTime, + pub updated_at: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::account_identities::Entity", + from = "Column::IdentityId", + to = "super::account_identities::Column::Id", + on_update = "NoAction", + on_delete = "Cascade" + )] + AccountIdentities, + #[sea_orm(has_many = "super::account_watchlist_addresses::Entity")] + AccountWatchlistAddresses, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountIdentities.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::AccountWatchlistAddresses.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/beacon_blobs.rs b/libs/blockscout-db/entity/src/beacon_blobs.rs deleted file mode 100644 index 0b297535e..000000000 --- a/libs/blockscout-db/entity/src/beacon_blobs.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "beacon_blobs")] -pub struct Model { - #[sea_orm( - primary_key, - auto_increment = false, - column_type = "VarBinary(StringLen::None)" - )] - pub hash: Vec, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub blob_data: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub kzg_commitment: Option>, - #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub kzg_proof: Option>, - pub inserted_at: DateTime, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs b/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs deleted file mode 100644 index 33f45ada9..000000000 --- a/libs/blockscout-db/entity/src/beacon_blobs_transactions.rs +++ /dev/null @@ -1,44 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "beacon_blobs_transactions")] -pub struct Model { - #[sea_orm( - primary_key, - auto_increment = false, - column_type = "VarBinary(StringLen::None)" - )] - pub hash: Vec, - #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub max_fee_per_blob_gas: Decimal, - #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub blob_gas_price: Decimal, - #[sea_orm(column_type = "Decimal(Some((100, 0)))")] - pub blob_gas_used: Decimal, - // removed: sea-orm can't compile with Vec> - // pub blob_versioned_hashes: Vec>, - pub inserted_at: DateTime, - pub updated_at: DateTime, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::transactions::Entity", - from = "Column::Hash", - to = "super::transactions::Column::Hash", - on_update = "NoAction", - on_delete = "Cascade" - )] - Transactions, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Transactions.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/blocks.rs b/libs/blockscout-db/entity/src/blocks.rs index e76fa57d0..4fbde81da 100644 --- a/libs/blockscout-db/entity/src/blocks.rs +++ b/libs/blockscout-db/entity/src/blocks.rs @@ -36,10 +36,6 @@ pub struct Model { #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] pub base_fee_per_gas: Option, pub is_empty: Option, - #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub blob_gas_used: Option, - #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] - pub excess_blob_gas: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/bridged_tokens.rs b/libs/blockscout-db/entity/src/bridged_tokens.rs deleted file mode 100644 index c030bdad8..000000000 --- a/libs/blockscout-db/entity/src/bridged_tokens.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "bridged_tokens")] -pub struct Model { - pub foreign_chain_id: Decimal, - #[sea_orm(column_type = "VarBinary(StringLen::None)")] - pub foreign_token_contract_address_hash: Vec, - pub exchange_rate: Option, - pub custom_metadata: Option, - pub lp_token: Option, - pub custom_cap: Option, - pub r#type: Option, - #[sea_orm( - column_type = "VarBinary(StringLen::None)", - unique, - // changed: fix no key columns - primary_key, - auto_increment = false - )] - pub home_token_contract_address_hash: Vec, - pub inserted_at: DateTime, - pub updated_at: DateTime, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::tokens::Entity", - from = "Column::HomeTokenContractAddressHash", - to = "super::tokens::Column::ContractAddressHash", - on_update = "NoAction", - on_delete = "Cascade" - )] - Tokens, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Tokens.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/lib.rs b/libs/blockscout-db/entity/src/lib.rs index 020666ac9..86b70be5b 100644 --- a/libs/blockscout-db/entity/src/lib.rs +++ b/libs/blockscout-db/entity/src/lib.rs @@ -2,6 +2,16 @@ pub mod prelude; +pub mod account_api_keys; +pub mod account_api_plans; +pub mod account_custom_abis; +pub mod account_identities; +pub mod account_public_tags_requests; +pub mod account_tag_addresses; +pub mod account_tag_transactions; +pub mod account_watchlist_addresses; +pub mod account_watchlist_notifications; +pub mod account_watchlists; pub mod address_coin_balances; pub mod address_coin_balances_daily; pub mod address_contract_code_fetch_attempts; @@ -12,12 +22,9 @@ pub mod address_to_tags; pub mod address_token_balances; pub mod addresses; pub mod administrators; -pub mod beacon_blobs; -pub mod beacon_blobs_transactions; pub mod block_rewards; pub mod block_second_degree_relations; pub mod blocks; -pub mod bridged_tokens; pub mod constants; pub mod contract_methods; pub mod contract_verification_status; @@ -52,8 +59,6 @@ pub mod transaction_forks; pub mod transaction_stats; pub mod transactions; pub mod user_contacts; -pub mod user_operations; -pub mod user_ops_indexer_migrations; pub mod users; pub mod validators; pub mod withdrawals; diff --git a/libs/blockscout-db/entity/src/prelude.rs b/libs/blockscout-db/entity/src/prelude.rs index a5de5ad37..3da99813b 100644 --- a/libs/blockscout-db/entity/src/prelude.rs +++ b/libs/blockscout-db/entity/src/prelude.rs @@ -1,6 +1,15 @@ //! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 pub use super::{ + account_api_keys::Entity as AccountApiKeys, account_api_plans::Entity as AccountApiPlans, + account_custom_abis::Entity as AccountCustomAbis, + account_identities::Entity as AccountIdentities, + account_public_tags_requests::Entity as AccountPublicTagsRequests, + account_tag_addresses::Entity as AccountTagAddresses, + account_tag_transactions::Entity as AccountTagTransactions, + account_watchlist_addresses::Entity as AccountWatchlistAddresses, + account_watchlist_notifications::Entity as AccountWatchlistNotifications, + account_watchlists::Entity as AccountWatchlists, address_coin_balances::Entity as AddressCoinBalances, address_coin_balances_daily::Entity as AddressCoinBalancesDaily, address_contract_code_fetch_attempts::Entity as AddressContractCodeFetchAttempts, @@ -8,12 +17,9 @@ pub use super::{ address_names::Entity as AddressNames, address_tags::Entity as AddressTags, address_to_tags::Entity as AddressToTags, address_token_balances::Entity as AddressTokenBalances, addresses::Entity as Addresses, - administrators::Entity as Administrators, beacon_blobs::Entity as BeaconBlobs, - beacon_blobs_transactions::Entity as BeaconBlobsTransactions, - block_rewards::Entity as BlockRewards, + administrators::Entity as Administrators, block_rewards::Entity as BlockRewards, block_second_degree_relations::Entity as BlockSecondDegreeRelations, blocks::Entity as Blocks, - bridged_tokens::Entity as BridgedTokens, constants::Entity as Constants, - contract_methods::Entity as ContractMethods, + constants::Entity as Constants, contract_methods::Entity as ContractMethods, contract_verification_status::Entity as ContractVerificationStatus, decompiled_smart_contracts::Entity as DecompiledSmartContracts, emission_rewards::Entity as EmissionRewards, event_notifications::Entity as EventNotifications, @@ -39,7 +45,5 @@ pub use super::{ transaction_actions::Entity as TransactionActions, transaction_forks::Entity as TransactionForks, transaction_stats::Entity as TransactionStats, transactions::Entity as Transactions, user_contacts::Entity as UserContacts, - user_operations::Entity as UserOperations, - user_ops_indexer_migrations::Entity as UserOpsIndexerMigrations, users::Entity as Users, - validators::Entity as Validators, withdrawals::Entity as Withdrawals, + users::Entity as Users, validators::Entity as Validators, withdrawals::Entity as Withdrawals, }; diff --git a/libs/blockscout-db/entity/src/proxy_implementations.rs b/libs/blockscout-db/entity/src/proxy_implementations.rs index 778496191..6b28d0636 100644 --- a/libs/blockscout-db/entity/src/proxy_implementations.rs +++ b/libs/blockscout-db/entity/src/proxy_implementations.rs @@ -12,8 +12,7 @@ pub struct Model { column_type = "VarBinary(StringLen::None)" )] pub proxy_address_hash: Vec, - // removed: sea-orm can't compile with Vec> - // pub address_hashes: Vec>, + pub address_hashes: Vec>, pub names: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/sea_orm_active_enums.rs b/libs/blockscout-db/entity/src/sea_orm_active_enums.rs index 0585f8f85..315716cfc 100644 --- a/libs/blockscout-db/entity/src/sea_orm_active_enums.rs +++ b/libs/blockscout-db/entity/src/sea_orm_active_enums.rs @@ -2,18 +2,6 @@ use sea_orm::entity::prelude::*; -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] -#[sea_orm( - rs_type = "String", - db_type = "Enum", - enum_name = "entry_point_version" -)] -pub enum EntryPointVersion { - #[sea_orm(string_value = "v0.6")] - V06, - #[sea_orm(string_value = "v0.7")] - V07, -} #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "proxy_type")] pub enum ProxyType { @@ -43,18 +31,6 @@ pub enum ProxyType { Unknown, } #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "sponsor_type")] -pub enum SponsorType { - #[sea_orm(string_value = "paymaster_hybrid")] - PaymasterHybrid, - #[sea_orm(string_value = "paymaster_sponsor")] - PaymasterSponsor, - #[sea_orm(string_value = "wallet_balance")] - WalletBalance, - #[sea_orm(string_value = "wallet_deposit")] - WalletDeposit, -} -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[sea_orm( rs_type = "String", db_type = "Enum", diff --git a/libs/blockscout-db/entity/src/tokens.rs b/libs/blockscout-db/entity/src/tokens.rs index dcb887d02..36f561c3d 100644 --- a/libs/blockscout-db/entity/src/tokens.rs +++ b/libs/blockscout-db/entity/src/tokens.rs @@ -29,24 +29,15 @@ pub struct Model { pub total_supply_updated_at_block: Option, pub icon_url: Option, pub is_verified_via_admin_panel: Option, - pub bridged: Option, pub volume_24h: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm(has_one = "super::bridged_tokens::Entity")] - BridgedTokens, #[sea_orm(has_many = "super::token_instances::Entity")] TokenInstances, } -impl Related for Entity { - fn to() -> RelationDef { - Relation::BridgedTokens.def() - } -} - impl Related for Entity { fn to() -> RelationDef { Relation::TokenInstances.def() diff --git a/libs/blockscout-db/entity/src/transactions.rs b/libs/blockscout-db/entity/src/transactions.rs index c80ed7712..b91d82a2a 100644 --- a/libs/blockscout-db/entity/src/transactions.rs +++ b/libs/blockscout-db/entity/src/transactions.rs @@ -56,14 +56,12 @@ pub struct Model { pub max_fee_per_gas: Option, pub r#type: Option, pub has_error_in_internal_transactions: Option, - pub block_consensus: Option, pub block_timestamp: Option, + pub block_consensus: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { - #[sea_orm(has_one = "super::beacon_blobs_transactions::Entity")] - BeaconBlobsTransactions, #[sea_orm( belongs_to = "super::blocks::Entity", from = "Column::BlockHash", @@ -86,12 +84,6 @@ pub enum Relation { TransactionForks, } -impl Related for Entity { - fn to() -> RelationDef { - Relation::BeaconBlobsTransactions.def() - } -} - impl Related for Entity { fn to() -> RelationDef { Relation::Blocks.def() diff --git a/libs/blockscout-db/justfile b/libs/blockscout-db/justfile index b2ff75faa..6a4c5782f 100644 --- a/libs/blockscout-db/justfile +++ b/libs/blockscout-db/justfile @@ -4,7 +4,7 @@ default: just --list --unsorted -blockscout-version := env_var_or_default('BLOCKSCOUT_VERSION', "6.8.0") +blockscout-version := env_var_or_default('BLOCKSCOUT_VERSION', "6.10.0") start-postgres: # we run it in --rm mode, so all data will be deleted after stopping diff --git a/libs/blockscout-db/migration/src/migration.sql b/libs/blockscout-db/migration/src/migration.sql index 174d4ec50..a9b8360c5 100644 --- a/libs/blockscout-db/migration/src/migration.sql +++ b/libs/blockscout-db/migration/src/migration.sql @@ -2,12 +2,13 @@ -- PostgreSQL database dump -- --- Dumped from database version 16.2 (Debian 16.2-1.pgdg120+2) --- Dumped by pg_dump version 16.2 (Debian 16.2-1.pgdg120+2) +-- Dumped from database version 17.2 (Debian 17.2-1.pgdg120+1) +-- Dumped by pg_dump version 17.2 (Debian 17.2-1.pgdg120+1) SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; +SET transaction_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; @@ -71,6 +72,31 @@ CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; +-- +-- Name: log_id; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.log_id AS ( + transaction_hash bytea, + block_hash bytea, + log_index integer +); + + +ALTER TYPE public.log_id OWNER TO postgres; + +-- +-- Name: nft_id; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.nft_id AS ( + block_number bigint, + log_index integer +); + + +ALTER TYPE public.nft_id OWNER TO postgres; + -- -- Name: proxy_type; Type: TYPE; Schema: public; Owner: postgres -- @@ -86,6 +112,7 @@ CREATE TYPE public.proxy_type AS ENUM ( 'comptroller', 'eip2535', 'clone_with_immutable_arguments', + 'eip7702', 'unknown' ); @@ -229,7 +256,8 @@ CREATE TABLE public.account_custom_abis ( updated_at timestamp(0) without time zone NOT NULL, address_hash_hash bytea, address_hash bytea, - name bytea + name bytea, + user_created boolean DEFAULT true ); @@ -269,10 +297,9 @@ CREATE TABLE public.account_identities ( uid bytea, uid_hash bytea, email bytea, - name bytea, - nickname bytea, avatar bytea, - verification_email_sent_at timestamp without time zone + verification_email_sent_at timestamp without time zone, + otp_sent_at timestamp without time zone ); @@ -357,7 +384,8 @@ CREATE TABLE public.account_tag_addresses ( updated_at timestamp(0) without time zone NOT NULL, address_hash_hash bytea, name bytea, - address_hash bytea + address_hash bytea, + user_created boolean DEFAULT true ); @@ -393,9 +421,10 @@ CREATE TABLE public.account_tag_transactions ( identity_id bigint, inserted_at timestamp(0) without time zone NOT NULL, updated_at timestamp(0) without time zone NOT NULL, - tx_hash_hash bytea, + transaction_hash_hash bytea, name bytea, - tx_hash bytea + transaction_hash bytea, + user_created boolean DEFAULT true ); @@ -447,7 +476,8 @@ CREATE TABLE public.account_watchlist_addresses ( name bytea, address_hash bytea, watch_erc_404_input boolean DEFAULT true, - watch_erc_404_output boolean DEFAULT true + watch_erc_404_output boolean DEFAULT true, + user_created boolean DEFAULT true ); @@ -486,7 +516,7 @@ CREATE TABLE public.account_watchlist_notifications ( method character varying(255), block_number integer, amount numeric, - tx_fee numeric, + transaction_fee numeric, viewed_at timestamp without time zone, inserted_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, @@ -796,7 +826,9 @@ CREATE TABLE public.address_token_balances ( inserted_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, token_id numeric(78,0), - token_type character varying(255) + token_type character varying(255), + refetch_after timestamp without time zone, + retries_count smallint ); @@ -1215,7 +1247,8 @@ CREATE TABLE public.migrations_status ( migration_name character varying(255) NOT NULL, status character varying(255), inserted_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + meta jsonb ); @@ -1315,6 +1348,19 @@ CREATE TABLE public.proxy_smart_contract_verification_statuses ( ALTER TABLE public.proxy_smart_contract_verification_statuses OWNER TO postgres; +-- +-- Name: scam_address_badge_mappings; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.scam_address_badge_mappings ( + address_hash bytea NOT NULL, + inserted_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.scam_address_badge_mappings OWNER TO postgres; + -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: postgres -- @@ -1327,6 +1373,27 @@ CREATE TABLE public.schema_migrations ( ALTER TABLE public.schema_migrations OWNER TO postgres; +-- +-- Name: signed_authorizations; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.signed_authorizations ( + transaction_hash bytea NOT NULL, + index integer NOT NULL, + chain_id bigint NOT NULL, + address bytea NOT NULL, + nonce integer NOT NULL, + v integer NOT NULL, + r numeric(100,0) NOT NULL, + s numeric(100,0) NOT NULL, + authority bytea, + inserted_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +ALTER TABLE public.signed_authorizations OWNER TO postgres; + -- -- Name: smart_contract_audit_reports; Type: TABLE; Schema: public; Owner: postgres -- @@ -1403,7 +1470,8 @@ CREATE TABLE public.smart_contracts ( license_type smallint DEFAULT 1 NOT NULL, verified_via_verifier_alliance boolean, certified boolean, - is_blueprint boolean + is_blueprint boolean, + language smallint ); @@ -1497,7 +1565,11 @@ CREATE TABLE public.token_instances ( owner_updated_at_block bigint, owner_updated_at_log_index integer, refetch_after timestamp without time zone, - retries_count smallint DEFAULT 0 NOT NULL + retries_count smallint DEFAULT 0 NOT NULL, + thumbnails jsonb, + media_type character varying(255), + cdn_upload_error character varying(255), + is_banned boolean DEFAULT false ); @@ -1690,7 +1762,7 @@ CREATE TABLE public.transactions ( max_priority_fee_per_gas numeric(100,0), max_fee_per_gas numeric(100,0), type integer, - has_error_in_internal_txs boolean, + has_error_in_internal_transactions boolean, block_timestamp timestamp without time zone, block_consensus boolean DEFAULT true, CONSTRAINT collated_block_number CHECK (((block_hash IS NULL) OR (block_number IS NOT NULL))), @@ -2132,6 +2204,14 @@ ALTER TABLE ONLY public.address_names ADD CONSTRAINT address_names_pkey PRIMARY KEY (id); +-- +-- Name: address_tags address_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.address_tags + ADD CONSTRAINT address_tags_pkey PRIMARY KEY (label); + + -- -- Name: address_to_tags address_to_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- @@ -2364,6 +2444,14 @@ ALTER TABLE ONLY public.proxy_smart_contract_verification_statuses ADD CONSTRAINT proxy_smart_contract_verification_statuses_pkey PRIMARY KEY (uid); +-- +-- Name: scam_address_badge_mappings scam_address_badge_mappings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.scam_address_badge_mappings + ADD CONSTRAINT scam_address_badge_mappings_pkey PRIMARY KEY (address_hash); + + -- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- @@ -2380,6 +2468,14 @@ ALTER TABLE public.internal_transactions ADD CONSTRAINT selfdestruct_has_from_and_to_address CHECK ((((type)::text <> 'selfdestruct'::text) OR ((from_address_hash IS NOT NULL) AND (gas IS NULL) AND (to_address_hash IS NOT NULL)))) NOT VALID; +-- +-- Name: signed_authorizations signed_authorizations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.signed_authorizations + ADD CONSTRAINT signed_authorizations_pkey PRIMARY KEY (transaction_hash, index); + + -- -- Name: smart_contract_audit_reports smart_contract_audit_reports_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- @@ -2526,7 +2622,7 @@ CREATE UNIQUE INDEX account_api_plans_id_max_req_per_second_name_index ON public -- Name: account_custom_abis_identity_id_address_hash_hash_index; Type: INDEX; Schema: public; Owner: postgres -- -CREATE UNIQUE INDEX account_custom_abis_identity_id_address_hash_hash_index ON public.account_custom_abis USING btree (identity_id, address_hash_hash); +CREATE UNIQUE INDEX account_custom_abis_identity_id_address_hash_hash_index ON public.account_custom_abis USING btree (identity_id, address_hash_hash) WHERE (user_created = true); -- @@ -2554,7 +2650,7 @@ CREATE INDEX account_tag_addresses_address_hash_hash_index ON public.account_tag -- Name: account_tag_addresses_identity_id_address_hash_hash_index; Type: INDEX; Schema: public; Owner: postgres -- -CREATE UNIQUE INDEX account_tag_addresses_identity_id_address_hash_hash_index ON public.account_tag_addresses USING btree (identity_id, address_hash_hash); +CREATE UNIQUE INDEX account_tag_addresses_identity_id_address_hash_hash_index ON public.account_tag_addresses USING btree (identity_id, address_hash_hash) WHERE (user_created = true); -- @@ -2575,14 +2671,14 @@ CREATE INDEX account_tag_transactions_identity_id_index ON public.account_tag_tr -- Name: account_tag_transactions_identity_id_tx_hash_hash_index; Type: INDEX; Schema: public; Owner: postgres -- -CREATE UNIQUE INDEX account_tag_transactions_identity_id_tx_hash_hash_index ON public.account_tag_transactions USING btree (identity_id, tx_hash_hash); +CREATE UNIQUE INDEX account_tag_transactions_identity_id_tx_hash_hash_index ON public.account_tag_transactions USING btree (identity_id, transaction_hash_hash) WHERE (user_created = true); -- -- Name: account_tag_transactions_tx_hash_hash_index; Type: INDEX; Schema: public; Owner: postgres -- -CREATE INDEX account_tag_transactions_tx_hash_hash_index ON public.account_tag_transactions USING btree (tx_hash_hash); +CREATE INDEX account_tag_transactions_tx_hash_hash_index ON public.account_tag_transactions USING btree (transaction_hash_hash); -- @@ -3096,6 +3192,13 @@ CREATE INDEX pending_txs_index ON public.transactions USING btree (inserted_at, CREATE INDEX proxy_implementations_proxy_type_index ON public.proxy_implementations USING btree (proxy_type); +-- +-- Name: signed_authorizations_authority_nonce_index; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX signed_authorizations_authority_nonce_index ON public.signed_authorizations USING btree (authority, nonce); + + -- -- Name: smart_contract_audit_reports_address_hash_index; Type: INDEX; Schema: public; Owner: postgres -- @@ -3478,7 +3581,7 @@ CREATE UNIQUE INDEX unique_username ON public.users USING btree (username); -- Name: unique_watchlist_id_address_hash_hash_index; Type: INDEX; Schema: public; Owner: postgres -- -CREATE UNIQUE INDEX unique_watchlist_id_address_hash_hash_index ON public.account_watchlist_addresses USING btree (watchlist_id, address_hash_hash); +CREATE UNIQUE INDEX unique_watchlist_id_address_hash_hash_index ON public.account_watchlist_addresses USING btree (watchlist_id, address_hash_hash) WHERE (user_created = true); -- @@ -3639,6 +3742,22 @@ ALTER TABLE ONLY public.proxy_smart_contract_verification_statuses ADD CONSTRAINT proxy_smart_contract_verification_statuses_contract_address_has FOREIGN KEY (contract_address_hash) REFERENCES public.smart_contracts(address_hash) ON DELETE CASCADE; +-- +-- Name: scam_address_badge_mappings scam_address_badge_mappings_address_hash_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.scam_address_badge_mappings + ADD CONSTRAINT scam_address_badge_mappings_address_hash_fkey FOREIGN KEY (address_hash) REFERENCES public.addresses(hash) ON DELETE CASCADE; + + +-- +-- Name: signed_authorizations signed_authorizations_transaction_hash_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.signed_authorizations + ADD CONSTRAINT signed_authorizations_transaction_hash_fkey FOREIGN KEY (transaction_hash) REFERENCES public.transactions(hash) ON DELETE CASCADE; + + -- -- Name: smart_contract_audit_reports smart_contract_audit_reports_address_hash_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- From e42276701bc1338f29374c543703b39fb0d7e0a8 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 18:48:17 +0500 Subject: [PATCH 09/12] add user ops to generation + generate --- libs/blockscout-db/entity/src/lib.rs | 2 ++ libs/blockscout-db/entity/src/prelude.rs | 4 ++- .../entity/src/sea_orm_active_enums.rs | 24 ++++++++++++++++++ libs/blockscout-db/justfile | 25 ++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/libs/blockscout-db/entity/src/lib.rs b/libs/blockscout-db/entity/src/lib.rs index 86b70be5b..66ecb6e59 100644 --- a/libs/blockscout-db/entity/src/lib.rs +++ b/libs/blockscout-db/entity/src/lib.rs @@ -59,6 +59,8 @@ pub mod transaction_forks; pub mod transaction_stats; pub mod transactions; pub mod user_contacts; +pub mod user_operations; +pub mod user_ops_indexer_migrations; pub mod users; pub mod validators; pub mod withdrawals; diff --git a/libs/blockscout-db/entity/src/prelude.rs b/libs/blockscout-db/entity/src/prelude.rs index 3da99813b..69992d8da 100644 --- a/libs/blockscout-db/entity/src/prelude.rs +++ b/libs/blockscout-db/entity/src/prelude.rs @@ -45,5 +45,7 @@ pub use super::{ transaction_actions::Entity as TransactionActions, transaction_forks::Entity as TransactionForks, transaction_stats::Entity as TransactionStats, transactions::Entity as Transactions, user_contacts::Entity as UserContacts, - users::Entity as Users, validators::Entity as Validators, withdrawals::Entity as Withdrawals, + user_operations::Entity as UserOperations, + user_ops_indexer_migrations::Entity as UserOpsIndexerMigrations, users::Entity as Users, + validators::Entity as Validators, withdrawals::Entity as Withdrawals, }; diff --git a/libs/blockscout-db/entity/src/sea_orm_active_enums.rs b/libs/blockscout-db/entity/src/sea_orm_active_enums.rs index 315716cfc..0585f8f85 100644 --- a/libs/blockscout-db/entity/src/sea_orm_active_enums.rs +++ b/libs/blockscout-db/entity/src/sea_orm_active_enums.rs @@ -2,6 +2,18 @@ use sea_orm::entity::prelude::*; +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[sea_orm( + rs_type = "String", + db_type = "Enum", + enum_name = "entry_point_version" +)] +pub enum EntryPointVersion { + #[sea_orm(string_value = "v0.6")] + V06, + #[sea_orm(string_value = "v0.7")] + V07, +} #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "proxy_type")] pub enum ProxyType { @@ -31,6 +43,18 @@ pub enum ProxyType { Unknown, } #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "sponsor_type")] +pub enum SponsorType { + #[sea_orm(string_value = "paymaster_hybrid")] + PaymasterHybrid, + #[sea_orm(string_value = "paymaster_sponsor")] + PaymasterSponsor, + #[sea_orm(string_value = "wallet_balance")] + WalletBalance, + #[sea_orm(string_value = "wallet_deposit")] + WalletDeposit, +} +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[sea_orm( rs_type = "String", db_type = "Enum", diff --git a/libs/blockscout-db/justfile b/libs/blockscout-db/justfile index 6a4c5782f..abb354054 100644 --- a/libs/blockscout-db/justfile +++ b/libs/blockscout-db/justfile @@ -5,6 +5,7 @@ default: just --list --unsorted blockscout-version := env_var_or_default('BLOCKSCOUT_VERSION', "6.10.0") +user-ops-indexer-version := env_var_or_default('USER_OPS_INDEXER_VERSION', "1.3.0") start-postgres: # we run it in --rm mode, so all data will be deleted after stopping @@ -30,9 +31,31 @@ generate-entities database_url="postgres://postgres:admin@localhost:5432/blocksc DATABASE_URL={{database_url}} sea-orm-cli generate entity --lib -o entity/src cargo fmt --all -- --config imports_granularity=Crate -generate-entities-from-blockscout-image database_url="postgres://postgres:admin@localhost:5432/blockscout": +migrate-user-ops-up database_url="postgres://postgres:admin@localhost:5432/blockscout": + docker run --network=host \ + -e "USER_OPS_INDEXER__DATABASE__CONNECT__URL={{database_url}}" \ + -e "USER_OPS_INDEXER__SERVER__HTTP__MAX_BODY_SIZE=2097152" \ + -e "USER_OPS_INDEXER__API__MAX_PAGE_SIZE=100" \ + -e "USER_OPS_INDEXER__INDEXER__CONCURRENCY=10" \ + -e "USER_OPS_INDEXER__DATABASE__RUN_MIGRATIONS=true" \ + -e "USER_OPS_INDEXER__INDEXER__RPC_URL=1" \ + -e "USER_OPS_INDEXER__INDEXER__ENTRYPOINTS__V06=true" \ + -e "USER_OPS_INDEXER__INDEXER__ENTRYPOINTS__V07=true" \ + -e "USER_OPS_INDEXER__INDEXER__REALTIME__ENABLED=true" \ + -e "USER_OPS_INDEXER__INDEXER__PAST_RPC_LOGS_INDEXER__ENABLED=true" \ + -e "USER_OPS_INDEXER__INDEXER__PAST_RPC_LOGS_INDEXER__BLOCK_RANGE=1000" \ + -e "USER_OPS_INDEXER__INDEXER__PAST_DB_LOGS_INDEXER__ENABLED=true" \ + -e "USER_OPS_INDEXER__INDEXER__PAST_DB_LOGS_INDEXER__START_BLOCK=10723578" \ + -e "USER_OPS_INDEXER__INDEXER__PAST_DB_LOGS_INDEXER__END_BLOCK=0" \ + --entrypoint "/bin/sh" --rm --platform "linux/amd64" ghcr.io/blockscout/user-ops-indexer:v{{user-ops-indexer-version}} -c "./user-ops-indexer-server" \ + || true + echo "'Error: custom error: relative URL without a base' is an expected error, everything is ok" + + +generate-entities-from-images database_url="postgres://postgres:admin@localhost:5432/blockscout": rm entity/src/* || true docker run --network=host -e 'DATABASE_URL={{database_url}}' -e 'ECTO_USE_SSL=false' --entrypoint "/bin/sh" --rm blockscout/blockscout:{{blockscout-version}} -c 'bin/blockscout eval "Elixir.Explorer.ReleaseTasks.create_and_migrate()"' + just migrate-user-ops-up {{database_url}} DATABASE_URL={{database_url}} sea-orm-cli generate entity --lib -o entity/src cargo fmt --all -- --config imports_granularity=Crate From f500fc37695baf55a38ec3331f69cbaf61f1f576 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 18:52:17 +0500 Subject: [PATCH 10/12] manual fix again --- libs/blockscout-db/entity/src/account_public_tags_requests.rs | 3 ++- libs/blockscout-db/entity/src/proxy_implementations.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/blockscout-db/entity/src/account_public_tags_requests.rs b/libs/blockscout-db/entity/src/account_public_tags_requests.rs index 1e12fa3e2..f186662ed 100644 --- a/libs/blockscout-db/entity/src/account_public_tags_requests.rs +++ b/libs/blockscout-db/entity/src/account_public_tags_requests.rs @@ -21,7 +21,8 @@ pub struct Model { pub request_id: Option, pub inserted_at: DateTime, pub updated_at: DateTime, - pub addresses: Option>>, + // removed: sea-orm can't compile with Vec> + // pub addresses: Option>>, #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] pub email: Option>, #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] diff --git a/libs/blockscout-db/entity/src/proxy_implementations.rs b/libs/blockscout-db/entity/src/proxy_implementations.rs index 6b28d0636..778496191 100644 --- a/libs/blockscout-db/entity/src/proxy_implementations.rs +++ b/libs/blockscout-db/entity/src/proxy_implementations.rs @@ -12,7 +12,8 @@ pub struct Model { column_type = "VarBinary(StringLen::None)" )] pub proxy_address_hash: Vec, - pub address_hashes: Vec>, + // removed: sea-orm can't compile with Vec> + // pub address_hashes: Vec>, pub names: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, From bbcbb1f3b4b6e8e858f2e8fb352389063295147e Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 18:59:51 +0500 Subject: [PATCH 11/12] latest-latest --- libs/blockscout-db/Cargo.toml | 2 +- libs/blockscout-db/entity/Cargo.toml | 2 +- libs/blockscout-db/justfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/blockscout-db/Cargo.toml b/libs/blockscout-db/Cargo.toml index 57f77ab49..ed358e0ed 100644 --- a/libs/blockscout-db/Cargo.toml +++ b/libs/blockscout-db/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blockscout-db" -version = "0.3.0+blockscout.6.10.0" +version = "0.3.0+blockscout.6.10.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/libs/blockscout-db/entity/Cargo.toml b/libs/blockscout-db/entity/Cargo.toml index f51a7a0cb..644c02444 100644 --- a/libs/blockscout-db/entity/Cargo.toml +++ b/libs/blockscout-db/entity/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blockscout-db-entity" -version = "0.3.0+blockscout.6.10.0" +version = "0.3.0+blockscout.6.10.1" edition = "2021" publish = false diff --git a/libs/blockscout-db/justfile b/libs/blockscout-db/justfile index abb354054..4e68dff8b 100644 --- a/libs/blockscout-db/justfile +++ b/libs/blockscout-db/justfile @@ -4,7 +4,7 @@ default: just --list --unsorted -blockscout-version := env_var_or_default('BLOCKSCOUT_VERSION', "6.10.0") +blockscout-version := env_var_or_default('BLOCKSCOUT_VERSION', "6.10.1") user-ops-indexer-version := env_var_or_default('USER_OPS_INDEXER_VERSION', "1.3.0") start-postgres: From 855804057cebb1db9ea01bbd3d711a7c2ac026c0 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Tue, 14 Jan 2025 20:42:12 +0500 Subject: [PATCH 12/12] generate migrations --- .../blockscout-db/migration/src/migration.sql | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/libs/blockscout-db/migration/src/migration.sql b/libs/blockscout-db/migration/src/migration.sql index a9b8360c5..fa549114c 100644 --- a/libs/blockscout-db/migration/src/migration.sql +++ b/libs/blockscout-db/migration/src/migration.sql @@ -72,6 +72,18 @@ CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; +-- +-- Name: entry_point_version; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.entry_point_version AS ENUM ( + 'v0.6', + 'v0.7' +); + + +ALTER TYPE public.entry_point_version OWNER TO postgres; + -- -- Name: log_id; Type: TYPE; Schema: public; Owner: postgres -- @@ -119,6 +131,20 @@ CREATE TYPE public.proxy_type AS ENUM ( ALTER TYPE public.proxy_type OWNER TO postgres; +-- +-- Name: sponsor_type; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.sponsor_type AS ENUM ( + 'wallet_deposit', + 'wallet_balance', + 'paymaster_sponsor', + 'paymaster_hybrid' +); + + +ALTER TYPE public.sponsor_type OWNER TO postgres; + -- -- Name: transaction_actions_protocol; Type: TYPE; Schema: public; Owner: postgres -- @@ -1819,6 +1845,62 @@ ALTER SEQUENCE public.user_contacts_id_seq OWNER TO postgres; ALTER SEQUENCE public.user_contacts_id_seq OWNED BY public.user_contacts.id; +-- +-- Name: user_operations; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.user_operations ( + hash bytea NOT NULL, + sender bytea NOT NULL, + nonce bytea NOT NULL, + init_code bytea, + call_data bytea NOT NULL, + call_gas_limit numeric(100,0) NOT NULL, + verification_gas_limit numeric(100,0) NOT NULL, + pre_verification_gas numeric(100,0) NOT NULL, + max_fee_per_gas numeric(100,0) NOT NULL, + max_priority_fee_per_gas numeric(100,0) NOT NULL, + paymaster_and_data bytea, + signature bytea NOT NULL, + aggregator bytea, + aggregator_signature bytea, + entry_point bytea NOT NULL, + transaction_hash bytea NOT NULL, + block_number integer NOT NULL, + block_hash bytea NOT NULL, + bundle_index integer NOT NULL, + index integer NOT NULL, + user_logs_start_index integer NOT NULL, + user_logs_count integer NOT NULL, + bundler bytea NOT NULL, + factory bytea, + paymaster bytea, + status boolean NOT NULL, + revert_reason bytea, + gas numeric(100,0) NOT NULL, + gas_price numeric(100,0) NOT NULL, + gas_used numeric(100,0) NOT NULL, + sponsor_type public.sponsor_type NOT NULL, + inserted_at timestamp without time zone DEFAULT now() NOT NULL, + updated_at timestamp without time zone DEFAULT now() NOT NULL, + entry_point_version public.entry_point_version DEFAULT 'v0.6'::public.entry_point_version NOT NULL +); + + +ALTER TABLE public.user_operations OWNER TO postgres; + +-- +-- Name: user_ops_indexer_migrations; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.user_ops_indexer_migrations ( + version character varying NOT NULL, + applied_at bigint NOT NULL +); + + +ALTER TABLE public.user_ops_indexer_migrations OWNER TO postgres; + -- -- Name: users; Type: TABLE; Schema: public; Owner: postgres -- @@ -2580,6 +2662,22 @@ ALTER TABLE ONLY public.user_contacts ADD CONSTRAINT user_contacts_pkey PRIMARY KEY (id); +-- +-- Name: user_operations user_operations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_operations + ADD CONSTRAINT user_operations_pkey PRIMARY KEY (hash); + + +-- +-- Name: user_ops_indexer_migrations user_ops_indexer_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.user_ops_indexer_migrations + ADD CONSTRAINT user_ops_indexer_migrations_pkey PRIMARY KEY (version); + + -- -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- @@ -3584,6 +3682,55 @@ CREATE UNIQUE INDEX unique_username ON public.users USING btree (username); CREATE UNIQUE INDEX unique_watchlist_id_address_hash_hash_index ON public.account_watchlist_addresses USING btree (watchlist_id, address_hash_hash) WHERE (user_created = true); +-- +-- Name: user_operations_block_number_hash_index; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX user_operations_block_number_hash_index ON public.user_operations USING btree (block_number DESC, hash DESC); + + +-- +-- Name: user_operations_block_number_transaction_hash_bundle_index_inde; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX user_operations_block_number_transaction_hash_bundle_index_inde ON public.user_operations USING btree (block_number DESC, transaction_hash DESC, bundle_index DESC); + + +-- +-- Name: user_operations_bundler_transaction_hash_bundle_index_index; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX user_operations_bundler_transaction_hash_bundle_index_index ON public.user_operations USING btree (bundler, transaction_hash, bundle_index); + + +-- +-- Name: user_operations_factory_index; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX user_operations_factory_index ON public.user_operations USING btree (factory); + + +-- +-- Name: user_operations_paymaster_index; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX user_operations_paymaster_index ON public.user_operations USING btree (paymaster); + + +-- +-- Name: user_operations_sender_factory_index; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX user_operations_sender_factory_index ON public.user_operations USING btree (sender, factory); + + +-- +-- Name: user_operations_transaction_hash_index; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX user_operations_transaction_hash_index ON public.user_operations USING btree (transaction_hash); + + -- -- Name: withdrawals_address_hash_index; Type: INDEX; Schema: public; Owner: postgres --