Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blockscout-db): add user-ops-indexer to generation and update entities #1186

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion libs/blockscout-db/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion libs/blockscout-db/entity/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions libs/blockscout-db/entity/src/account_custom_abis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct Model {
pub address_hash: Option<Vec<u8>>,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub name: Option<Vec<u8>>,
pub user_created: Option<bool>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
5 changes: 1 addition & 4 deletions libs/blockscout-db/entity/src/account_identities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ pub struct Model {
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub email: Option<Vec<u8>>,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub name: Option<Vec<u8>>,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub nickname: Option<Vec<u8>>,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub avatar: Option<Vec<u8>>,
pub verification_email_sent_at: Option<DateTime>,
pub otp_sent_at: Option<DateTime>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ pub struct Model {
pub request_id: Option<String>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
// removed: sea-orm can't compile with Vec<Vec<u8>>
// pub addresses: Option<Vec<Vec<u8>>>,
pub addresses: Option<Vec<Vec<u8>>>,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub email: Option<Vec<u8>>,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
Expand Down
1 change: 1 addition & 0 deletions libs/blockscout-db/entity/src/account_tag_addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct Model {
pub name: Option<Vec<u8>>,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub address_hash: Option<Vec<u8>>,
pub user_created: Option<bool>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
5 changes: 3 additions & 2 deletions libs/blockscout-db/entity/src/account_tag_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<u8>>,
pub transaction_hash_hash: Option<Vec<u8>>,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub name: Option<Vec<u8>>,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub tx_hash: Option<Vec<u8>>,
pub transaction_hash: Option<Vec<u8>>,
pub user_created: Option<bool>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct Model {
pub address_hash: Option<Vec<u8>>,
pub watch_erc_404_input: Option<bool>,
pub watch_erc_404_output: Option<bool>,
pub user_created: Option<bool>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub struct Model {
pub r#type: Option<String>,
pub method: Option<String>,
pub block_number: Option<i32>,
pub amount: Option<BigDecimal>,
pub tx_fee: Option<BigDecimal>,
pub amount: Option<Decimal>,
pub transaction_fee: Option<Decimal>,
pub viewed_at: Option<DateTime>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
Expand Down
2 changes: 1 addition & 1 deletion libs/blockscout-db/entity/src/address_coin_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BigDecimal>,
pub value: Option<Decimal>,
pub value_fetched_at: Option<DateTime>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BigDecimal>,
pub value: Option<Decimal>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ pub struct Model {
pub block_number: i64,
#[sea_orm(column_type = "VarBinary(StringLen::None)")]
pub token_contract_address_hash: Vec<u8>,
pub value: Option<BigDecimal>,
pub value: Option<Decimal>,
pub value_fetched_at: Option<DateTime>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
pub old_value: Option<BigDecimal>,
pub old_value: Option<Decimal>,
#[sea_orm(column_type = "Decimal(Some((78, 0)))", nullable)]
pub token_id: Option<Decimal>,
pub token_type: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions libs/blockscout-db/entity/src/address_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
bragov4ik marked this conversation as resolved.
Show resolved Hide resolved
pub inserted_at: DateTime,
pub updated_at: DateTime,
Expand Down
4 changes: 3 additions & 1 deletion libs/blockscout-db/entity/src/address_token_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ pub struct Model {
pub block_number: i64,
#[sea_orm(column_type = "VarBinary(StringLen::None)")]
pub token_contract_address_hash: Vec<u8>,
pub value: Option<BigDecimal>,
pub value: Option<Decimal>,
pub value_fetched_at: Option<DateTime>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
#[sea_orm(column_type = "Decimal(Some((78, 0)))", nullable)]
pub token_id: Option<Decimal>,
pub token_type: Option<String>,
pub refetch_after: Option<DateTime>,
pub retries_count: Option<i16>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
13 changes: 11 additions & 2 deletions libs/blockscout-db/entity/src/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BigDecimal>,
pub fetched_coin_balance: Option<Decimal>,
pub fetched_coin_balance_block_number: Option<i64>,
#[sea_orm(
primary_key,
Expand All @@ -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<super::scam_address_badge_mappings::Entity> for Entity {
fn to() -> RelationDef {
Relation::ScamAddressBadgeMappings.def()
}
}

impl ActiveModelBehavior for ActiveModel {}
2 changes: 1 addition & 1 deletion libs/blockscout-db/entity/src/block_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Model {
)]
pub block_hash: Vec<u8>,
#[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)]
pub reward: Option<BigDecimal>,
pub reward: Option<Decimal>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
}
Expand Down
10 changes: 5 additions & 5 deletions libs/blockscout-db/entity/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BigDecimal>,
pub difficulty: Option<Decimal>,
#[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,
Expand All @@ -29,12 +29,12 @@ pub struct Model {
pub size: Option<i32>,
pub timestamp: DateTime,
#[sea_orm(column_type = "Decimal(Some((50, 0)))", nullable)]
pub total_difficulty: Option<BigDecimal>,
pub total_difficulty: Option<Decimal>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
pub refetch_needed: Option<bool>,
#[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)]
pub base_fee_per_gas: Option<BigDecimal>,
pub base_fee_per_gas: Option<Decimal>,
pub is_empty: Option<bool>,
}

Expand Down
2 changes: 1 addition & 1 deletion libs/blockscout-db/entity/src/emission_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct Model {
column_type = "custom(\"int8range\")"
)]
pub block_range: String,
pub reward: Option<BigDecimal>,
pub reward: Option<Decimal>,
bragov4ik marked this conversation as resolved.
Show resolved Hide resolved
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
6 changes: 3 additions & 3 deletions libs/blockscout-db/entity/src/internal_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub struct Model {
pub created_contract_code: Option<Vec<u8>>,
pub error: Option<String>,
#[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)]
pub gas: Option<BigDecimal>,
pub gas: Option<Decimal>,
#[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)]
pub gas_used: Option<BigDecimal>,
pub gas_used: Option<Decimal>,
pub index: i32,
#[sea_orm(column_type = "VarBinary(StringLen::None)", nullable)]
pub init: Option<Vec<u8>>,
Expand All @@ -23,7 +23,7 @@ pub struct Model {
pub trace_address: Vec<i32>,
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)]
Expand Down
2 changes: 1 addition & 1 deletion libs/blockscout-db/entity/src/last_fetched_counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BigDecimal>,
pub value: Option<Decimal>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
}
Expand Down
4 changes: 4 additions & 0 deletions libs/blockscout-db/entity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
8 changes: 4 additions & 4 deletions libs/blockscout-db/entity/src/market_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
pub date: Date,
pub closing_price: Option<BigDecimal>,
pub opening_price: Option<BigDecimal>,
pub market_cap: Option<BigDecimal>,
pub tvl: Option<BigDecimal>,
pub closing_price: Option<Decimal>,
pub opening_price: Option<Decimal>,
pub market_cap: Option<Decimal>,
pub tvl: Option<Decimal>,
pub secondary_coin: Option<bool>,
}

Expand Down
2 changes: 2 additions & 0 deletions libs/blockscout-db/entity/src/migrations_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub struct Model {
pub status: Option<String>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub meta: Option<Json>,
bragov4ik marked this conversation as resolved.
Show resolved Hide resolved
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
6 changes: 5 additions & 1 deletion libs/blockscout-db/entity/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
};
3 changes: 1 addition & 2 deletions libs/blockscout-db/entity/src/proxy_implementations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ pub struct Model {
column_type = "VarBinary(StringLen::None)"
)]
pub proxy_address_hash: Vec<u8>,
// removed: sea-orm can't compile with Vec<Vec<u8>>
// pub address_hashes: Vec<Vec<u8>>,
pub address_hashes: Vec<Vec<u8>>,
pub names: Vec<String>,
pub inserted_at: DateTime,
pub updated_at: DateTime,
Expand Down
36 changes: 36 additions & 0 deletions libs/blockscout-db/entity/src/scam_address_badge_mappings.rs
Original file line number Diff line number Diff line change
@@ -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<u8>,
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<super::addresses::Entity> for Entity {
fn to() -> RelationDef {
Relation::Addresses.def()
}
}

impl ActiveModelBehavior for ActiveModel {}
Loading
Loading