Skip to content

Commit

Permalink
Generate entities for code, contracts and contract_deployments tables…
Browse files Browse the repository at this point in the history
… with ownership and modification fields
  • Loading branch information
rimrakhimov committed Jul 22, 2024
1 parent 2abd448 commit 22081f3
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions eth-bytecode-db/eth-bytecode-db-server/tests/verifier_alliance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ async fn insert_contract_deployment(txn: &DatabaseTransaction, test_case: &TestC

contract_deployments::ActiveModel {
id: Default::default(),
created_at: Default::default(),
updated_at: Default::default(),
created_by: Default::default(),
updated_by: Default::default(),
chain_id: Set(test_case.chain_id.into()),
address: Set(test_case.address.to_vec()),
transaction_hash: Set(test_case.transaction_hash.to_vec()),
Expand Down Expand Up @@ -258,6 +262,10 @@ async fn insert_contract(

contracts::ActiveModel {
id: Default::default(),
created_at: Default::default(),
updated_at: Default::default(),
created_by: Default::default(),
updated_by: Default::default(),
creation_code_hash: Set(creation_code_hash.clone()),
runtime_code_hash: Set(runtime_code_hash.clone()),
}
Expand All @@ -281,6 +289,10 @@ async fn insert_code(txn: &DatabaseTransaction, code: Vec<u8>) -> Vec<u8> {
let code_hash_keccak = keccak_hash::keccak(&code).0.to_vec();
code::ActiveModel {
code_hash: Set(code_hash.clone()),
created_at: Default::default(),
updated_at: Default::default(),
created_by: Default::default(),
updated_by: Default::default(),
code_hash_keccak: Set(code_hash_keccak),
code: Set(Some(code)),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ async fn insert_contract_deployment<C: ConnectionTrait>(
) -> Result<contract_deployments::Model, anyhow::Error> {
let active_model = contract_deployments::ActiveModel {
id: Default::default(),
created_at: Default::default(),
updated_at: Default::default(),
created_by: Default::default(),
updated_by: Default::default(),
chain_id: Set(deployment_data.chain_id.into()),
address: Set(deployment_data.contract_address.clone()),
transaction_hash: Set(deployment_data.transaction_hash.clone()),
Expand Down Expand Up @@ -325,6 +329,10 @@ async fn insert_contract<C: ConnectionTrait>(

let active_model = contracts::ActiveModel {
id: Default::default(),
created_at: Default::default(),
updated_at: Default::default(),
created_by: Default::default(),
updated_by: Default::default(),
creation_code_hash: Set(creation_code_hash.clone()),
runtime_code_hash: Set(runtime_code_hash.clone()),
};
Expand Down Expand Up @@ -353,6 +361,10 @@ async fn insert_code<C: ConnectionTrait>(

let active_model = code::ActiveModel {
code_hash: Set(code_hash.clone()),
created_at: Default::default(),
updated_at: Default::default(),
created_by: Default::default(),
updated_by: Default::default(),
code_hash_keccak: Set(code_hash_keccak),
code: Set(Some(code)),
};
Expand Down
12 changes: 12 additions & 0 deletions eth-bytecode-db/eth-bytecode-db/tests/verifier_alliance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ async fn insert_contract_deployment(txn: &DatabaseTransaction, test_case: &TestC

contract_deployments::ActiveModel {
id: Default::default(),
created_at: Default::default(),
updated_at: Default::default(),
created_by: Default::default(),
updated_by: Default::default(),
chain_id: Set(test_case.chain_id.into()),
address: Set(test_case.address.to_vec()),
transaction_hash: Set(test_case.transaction_hash.to_vec()),
Expand Down Expand Up @@ -250,6 +254,10 @@ async fn insert_contract(

contracts::ActiveModel {
id: Default::default(),
created_at: Default::default(),
updated_at: Default::default(),
created_by: Default::default(),
updated_by: Default::default(),
creation_code_hash: Set(creation_code_hash.clone()),
runtime_code_hash: Set(runtime_code_hash.clone()),
}
Expand All @@ -273,6 +281,10 @@ async fn insert_code(txn: &DatabaseTransaction, code: Vec<u8>) -> Vec<u8> {
let code_hash_keccak = keccak_hash::keccak(&code).0.to_vec();
code::ActiveModel {
code_hash: Set(code_hash.clone()),
created_at: Default::default(),
updated_at: Default::default(),
created_by: Default::default(),
updated_by: Default::default(),
code_hash_keccak: Set(code_hash_keccak),
code: Set(Some(code)),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ pub struct Model {
column_type = "Binary(BlobSize::Blob(None))"
)]
pub code_hash: Vec<u8>,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
pub created_by: String,
pub updated_by: String,
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
pub code_hash_keccak: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
pub created_by: String,
pub updated_by: String,
pub chain_id: Decimal,
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
pub address: Vec<u8>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
pub created_by: String,
pub updated_by: String,
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
pub creation_code_hash: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
Expand Down

0 comments on commit 22081f3

Please sign in to comment.