diff --git a/libs/blockscout-db/Cargo.toml b/libs/blockscout-db/Cargo.toml index 3ea8d3cd0..ed358e0ed 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.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 a1c592652..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.2.1+blockscout.6.8.0" +version = "0.3.0+blockscout.6.10.1" edition = "2021" publish = false diff --git a/libs/blockscout-db/entity/src/account_custom_abis.rs b/libs/blockscout-db/entity/src/account_custom_abis.rs index 21579040e..7baa1aae6 100644 --- a/libs/blockscout-db/entity/src/account_custom_abis.rs +++ b/libs/blockscout-db/entity/src/account_custom_abis.rs @@ -18,6 +18,7 @@ pub struct Model { 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)] diff --git a/libs/blockscout-db/entity/src/account_identities.rs b/libs/blockscout-db/entity/src/account_identities.rs index 2a67b267b..fade97125 100644 --- a/libs/blockscout-db/entity/src/account_identities.rs +++ b/libs/blockscout-db/entity/src/account_identities.rs @@ -17,12 +17,9 @@ pub struct Model { #[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, + pub otp_sent_at: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/account_tag_addresses.rs b/libs/blockscout-db/entity/src/account_tag_addresses.rs index 445aec2bd..e4650c346 100644 --- a/libs/blockscout-db/entity/src/account_tag_addresses.rs +++ b/libs/blockscout-db/entity/src/account_tag_addresses.rs @@ -16,6 +16,7 @@ pub struct Model { 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)] diff --git a/libs/blockscout-db/entity/src/account_tag_transactions.rs b/libs/blockscout-db/entity/src/account_tag_transactions.rs index 4776beda5..724c52b5c 100644 --- a/libs/blockscout-db/entity/src/account_tag_transactions.rs +++ b/libs/blockscout-db/entity/src/account_tag_transactions.rs @@ -11,11 +11,12 @@ pub struct Model { pub inserted_at: DateTime, pub updated_at: DateTime, #[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)] - pub tx_hash_hash: Option>, + 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 tx_hash: Option>, + pub transaction_hash: Option>, + pub user_created: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/libs/blockscout-db/entity/src/account_watchlist_addresses.rs b/libs/blockscout-db/entity/src/account_watchlist_addresses.rs index 5f61ba30a..4db888a48 100644 --- a/libs/blockscout-db/entity/src/account_watchlist_addresses.rs +++ b/libs/blockscout-db/entity/src/account_watchlist_addresses.rs @@ -30,6 +30,7 @@ pub struct Model { 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)] diff --git a/libs/blockscout-db/entity/src/account_watchlist_notifications.rs b/libs/blockscout-db/entity/src/account_watchlist_notifications.rs index b968e85f5..a6cf73971 100644 --- a/libs/blockscout-db/entity/src/account_watchlist_notifications.rs +++ b/libs/blockscout-db/entity/src/account_watchlist_notifications.rs @@ -12,8 +12,8 @@ pub struct Model { pub r#type: Option, pub method: Option, pub block_number: Option, - pub amount: Option, - pub tx_fee: Option, + pub amount: Option, + pub transaction_fee: Option, pub viewed_at: Option, pub inserted_at: DateTime, pub updated_at: DateTime, 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/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..4fbde81da 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,12 +29,12 @@ 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, } 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..66ecb6e59 100644 --- a/libs/blockscout-db/entity/src/lib.rs +++ b/libs/blockscout-db/entity/src/lib.rs @@ -42,8 +42,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 +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/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..69992d8da 100644 --- a/libs/blockscout-db/entity/src/prelude.rs +++ b/libs/blockscout-db/entity/src/prelude.rs @@ -32,7 +32,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 +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/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..36f561c3d 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,12 +24,12 @@ 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 volume_24h: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 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..b91d82a2a 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,11 +51,11 @@ 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 has_error_in_internal_transactions: Option, pub block_timestamp: Option, pub block_consensus: Option, } @@ -74,6 +74,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")] @@ -100,6 +102,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)")] diff --git a/libs/blockscout-db/justfile b/libs/blockscout-db/justfile index 46e9c397e..4e68dff8b 100644 --- a/libs/blockscout-db/justfile +++ b/libs/blockscout-db/justfile @@ -4,7 +4,8 @@ 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.1") +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 @@ -26,11 +27,35 @@ new-migration name: sea-orm-cli migrate generate {{name}} generate-entities database_url="postgres://postgres:admin@localhost:5432/blockscout": + 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 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 @@ -38,4 +63,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 diff --git a/libs/blockscout-db/migration/src/migration.sql b/libs/blockscout-db/migration/src/migration.sql index 174d4ec50..fa549114c 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,43 @@ 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 +-- + +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,12 +124,27 @@ CREATE TYPE public.proxy_type AS ENUM ( 'comptroller', 'eip2535', 'clone_with_immutable_arguments', + 'eip7702', 'unknown' ); 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 -- @@ -229,7 +282,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 +323,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 +410,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 +447,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 +502,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 +542,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 +852,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 +1273,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 +1374,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 +1399,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 +1496,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 +1591,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 +1788,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))), @@ -1747,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 -- @@ -2132,6 +2286,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 +2526,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 +2550,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 -- @@ -2484,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 -- @@ -2526,7 +2720,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 +2748,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 +2769,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 +3290,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 +3679,56 @@ 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); + + +-- +-- 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); -- @@ -3639,6 +3889,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 --