-
Notifications
You must be signed in to change notification settings - Fork 25
Refactor #125
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
Refactor #125
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,7 +29,6 @@ def self.event_signature(event_name) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def transaction_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tx_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sig { params(block_result: T.untyped, receipt_result: T.untyped).returns(T::Array[EthTransaction]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def self.from_rpc_result(block_result, receipt_result) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -66,8 +65,8 @@ def self.ethscription_txs_from_rpc_results(block_results, receipt_results, ethsc | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eth_txs.sort_by(&:transaction_index).each do |eth_tx| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| next unless eth_tx.is_success? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Build deposits using the unified builder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deposits = EthscriptionTransactionBuilder.build_deposits(eth_tx, ethscriptions_block) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Build deposits directly from this EthTransaction instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deposits = eth_tx.build_ethscription_deposits(ethscriptions_block) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| all_deposits.concat(deposits) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -83,4 +82,182 @@ def is_success? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def ethscription_source_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tx_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Build deposit transactions (EthscriptionTransaction objects) from this L1 transaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sig { params(ethscriptions_block: EthscriptionsBlock).returns(T::Array[EthscriptionTransaction]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def build_ethscription_deposits(ethscriptions_block) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @transactions = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 1. Process calldata (try as creation, then as transfer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process_calldata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 2. Process events (creations and transfers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process_events | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @transactions.compact | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def process_calldata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return unless to_address.present? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try_calldata_creation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try_calldata_transfer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+89
to
+106
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @transactions = [] | |
| # 1. Process calldata (try as creation, then as transfer) | |
| process_calldata | |
| # 2. Process events (creations and transfers) | |
| process_events | |
| @transactions.compact | |
| end | |
| private | |
| def process_calldata | |
| return unless to_address.present? | |
| try_calldata_creation | |
| try_calldata_transfer | |
| transactions = [] | |
| # 1. Process calldata (try as creation, then as transfer) | |
| process_calldata(transactions) | |
| # 2. Process events (creations and transfers) | |
| process_events(transactions) | |
| transactions.compact | |
| end | |
| private | |
| def process_calldata(transactions) | |
| # ... (implementation not shown, but replace @transactions with transactions) | |
| end | |
| return unless to_address.present? | |
| try_calldata_creation(transactions) | |
| try_calldata_transfer(transactions) |
Copilot
AI
Oct 21, 2025
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.
The build_create_ethscription factory method now returns nil when DataUri.valid? fails (line 48 in ethscription_transaction.rb). This will add nil values to @transactions, which could cause issues. Add a guard to only append non-nil transactions: @transactions << transaction if transaction.
| @transactions << transaction | |
| @transactions << transaction if transaction |
Copilot
AI
Oct 21, 2025
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.
[nitpick] Similar to the creation case, this appends the transaction without checking if it's nil. Since build_transfer always returns a transaction object currently, this may be safe, but for consistency and defensive programming, consider adding a nil check: @transactions << transaction if transaction.
| @transactions << transaction | |
| @transactions << transaction if transaction |
Copilot
AI
Oct 21, 2025
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.
The build_create_ethscription method can return nil if the content_uri is invalid. This will add nil to @transactions. Add a guard: @transactions << transaction if transaction.
| @transactions << transaction | |
| @transactions << transaction if transaction |
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.
[nitpick] The
privatekeyword is placed after the public methodbuild_ethscription_deposits, but several other public methods (transaction_hash,is_success?,ethscription_source_hash) are defined before theprivatesection. Consider moving all public methods before theprivatekeyword to maintain consistent visibility organization.