-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Transaction Debugger - マルチチェーン対応基盤
概要
複数のブロックチェーン(Polygon, BSC, Arbitrum等)に対応するための基盤を実装
実装内容
# lib/transaction_debugger/chains.rb
module TransactionDebugger
class Chains
SUPPORTED_CHAINS = {
ethereum: {
chain_id: 1,
name: 'Ethereum Mainnet',
rpc_urls: ['https://eth.llamarpc.com'],
explorer: 'https://etherscan.io'
},
polygon: {
chain_id: 137,
name: 'Polygon',
rpc_urls: ['https://polygon-rpc.com'],
explorer: 'https://polygonscan.com'
},
arbitrum: {
chain_id: 42161,
name: 'Arbitrum One',
rpc_urls: ['https://arb1.arbitrum.io/rpc'],
explorer: 'https://arbiscan.io'
},
bsc: {
chain_id: 56,
name: 'BNB Smart Chain',
rpc_urls: ['https://bsc-dataseed.binance.org'],
explorer: 'https://bscscan.com'
}
}.freeze
def self.get(chain_name)
SUPPORTED_CHAINS[chain_name.to_sym] or raise Error, "Unsupported chain: #{chain_name}"
end
def self.detect_from_chain_id(chain_id)
SUPPORTED_CHAINS.find { |_, config| config[:chain_id] == chain_id }&.first
end
end
endClientの拡張
# lib/transaction_debugger/client.rb に追加
module TransactionDebugger
class Client
def initialize(rpc_url = nil, chain: :ethereum)
@chain_config = Chains.get(chain)
@rpc_url = rpc_url || @chain_config[:rpc_urls].first
# ... 既存のコード
end
def chain_id
@chain_config[:chain_id]
end
def explorer_url(tx_hash)
"#{@chain_config[:explorer]}/tx/#{tx_hash}"
end
end
endCLIの拡張
# 使用例
tx-debug analyze 0xTX_HASH --chain polygon
tx-debug analyze 0xTX_HASH --chain arbitrum完了条件
- 主要チェーンの設定が追加されている
- Clientが複数チェーンに対応している
- CLIで --chain オプションが使える
- エクスプローラーURLが正しく生成される
- テストが全てパスする
Phase
Phase 3 - 高度な機能
Dependencies
- Issue [Core] Implement Ethereum JSON-RPC client #6: [Core] Implement Ethereum JSON-RPC client
Metadata
Metadata
Assignees
Labels
No labels