Fix bridge request creation and clean up debug statements
- Bridge request creation now works with both 0x and ait1 addresses - ait1 addresses must be at least 39 characters (Bech32 format) - AITBCWalletAdapter correctly selected for chain IDs 1000/1001 - Removed debug print statements from create_bridge_request, validate_address, factory, and bridge initialization - Bridge ID auto-generated by database (no manual assignment)
This commit is contained in:
@@ -858,7 +858,6 @@ class AITBCWalletAdapter(EnhancedWalletAdapter):
|
|||||||
# Also accept 0x addresses for backward compatibility
|
# Also accept 0x addresses for backward compatibility
|
||||||
if address.startswith("0x") and len(address) == 42:
|
if address.startswith("0x") and len(address) == 42:
|
||||||
return True
|
return True
|
||||||
logger.debug(f"Address validation failed for {address}: starts with 'ait1': {address.startswith('ait1')}, len: {len(address)}")
|
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Address validation exception for {address}: {e}")
|
logger.error(f"Address validation exception for {address}: {e}")
|
||||||
@@ -978,7 +977,6 @@ class WalletAdapterFactory:
|
|||||||
if not adapter_class:
|
if not adapter_class:
|
||||||
raise ValueError(f"Unsupported chain ID: {chain_id}")
|
raise ValueError(f"Unsupported chain ID: {chain_id}")
|
||||||
|
|
||||||
logger.info(f"Creating {adapter_class.__name__} adapter for chain {chain_id}")
|
|
||||||
return adapter_class(rpc_url, security_level)
|
return adapter_class(rpc_url, security_level)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ class CrossChainBridgeService:
|
|||||||
async def initialize_bridge(self, chain_configs: dict[int, dict[str, Any]]) -> None:
|
async def initialize_bridge(self, chain_configs: dict[int, dict[str, Any]]) -> None:
|
||||||
"""Initialize bridge service with chain configurations"""
|
"""Initialize bridge service with chain configurations"""
|
||||||
try:
|
try:
|
||||||
logger.info(f"Initializing bridge service for chain configs: {list(chain_configs.keys())}")
|
|
||||||
for chain_id, config in chain_configs.items():
|
for chain_id, config in chain_configs.items():
|
||||||
# Create wallet adapter for each chain
|
# Create wallet adapter for each chain
|
||||||
adapter = WalletAdapterFactory.create_adapter(
|
adapter = WalletAdapterFactory.create_adapter(
|
||||||
@@ -96,7 +95,6 @@ class CrossChainBridgeService:
|
|||||||
security_level=SecurityLevel(config.get("security_level", "medium")),
|
security_level=SecurityLevel(config.get("security_level", "medium")),
|
||||||
)
|
)
|
||||||
self.wallet_adapters[chain_id] = adapter
|
self.wallet_adapters[chain_id] = adapter
|
||||||
logger.info(f"Initialized adapter for chain {chain_id}: {type(adapter).__name__}")
|
|
||||||
|
|
||||||
# Initialize bridge protocol
|
# Initialize bridge protocol
|
||||||
protocol = config.get("protocol", BridgeProtocol.ATOMIC_SWAP)
|
protocol = config.get("protocol", BridgeProtocol.ATOMIC_SWAP)
|
||||||
@@ -132,8 +130,14 @@ class CrossChainBridgeService:
|
|||||||
deadline_minutes: int = 30,
|
deadline_minutes: int = 30,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Create a new cross-chain bridge request"""
|
"""Create a new cross-chain bridge request"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Check whitelist first
|
||||||
|
if (source_chain_id, target_chain_id) not in self.allowed_transfers:
|
||||||
|
logger.warning(f"Chain pair {source_chain_id}->{target_chain_id} not in whitelist")
|
||||||
|
raise ValueError(
|
||||||
|
f"Cross-chain transfer from chain {source_chain_id} to {target_chain_id} "
|
||||||
|
"is not permitted (chain isolation policy)"
|
||||||
|
)
|
||||||
# Validate chains
|
# Validate chains
|
||||||
if source_chain_id not in self.wallet_adapters or target_chain_id not in self.wallet_adapters:
|
if source_chain_id not in self.wallet_adapters or target_chain_id not in self.wallet_adapters:
|
||||||
raise ValueError("Unsupported chain ID")
|
raise ValueError("Unsupported chain ID")
|
||||||
|
|||||||
Reference in New Issue
Block a user