-
Notifications
You must be signed in to change notification settings - Fork 189
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
chore: implement From<BigUint>
for address type
#2488
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
use alloy_primitives::U256; | ||
use katana_db::mdbx::{test_utils, DbEnvKind}; | ||
use katana_primitives::address; | ||
use katana_primitives::block::{BlockHash, FinalityStatus}; | ||
use katana_primitives::class::CompiledClass; | ||
use katana_primitives::contract::ContractAddress; | ||
|
@@ -49,7 +50,7 @@ | |
/// - An account with simple `__execute__` function, deployed at address `0x1`. | ||
pub fn create_genesis_for_testing() -> Genesis { | ||
let class_hash = felt!("0x111"); | ||
let address = ContractAddress::from(felt!("0x1")); | ||
let address = address!("0x1"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Ohayo sensei! I've identified several instances where 🔗 Analysis chainExcellent use of the new The change from To ensure consistency, let's check if this new macro is used throughout the codebase: This will help us identify any remaining instances of the old method and confirm the adoption of the new macro across the project. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for consistent usage of the address! macro
# Search for ContractAddress::from usage
echo "Checking for remaining ContractAddress::from usage:"
rg --type rust "ContractAddress::from\(felt!\(" -g '!test_utils.rs'
# Search for address! macro usage
echo "Checking for address! macro usage:"
rg --type rust "address!\(" -g '!test_utils.rs'
Length of output: 14172 |
||
|
||
// TODO: we should have a genesis builder that can do all of this for us. | ||
let class = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Ohayo, sensei! The new
From
implementations look great!The added implementations for
From<&BigUint>
andFrom<BigUint>
forContractAddress
are well-structured and align perfectly with the PR objectives. They provide a clean way to convert fromBigUint
toContractAddress
, which enhances the flexibility of theContractAddress
type.A small optimization suggestion:
Consider reusing the
From<&BigUint>
implementation in theFrom<BigUint>
implementation to reduce code duplication:This change would make the code more DRY and easier to maintain.
📝 Committable suggestion