@@ -77,10 +77,8 @@ def __init__(
7777 hyperliquid_domain : int | None = None ,
7878 mainnet_domain : int | None = None ,
7979 cctp_finality_threshold : int = DEFAULT_CCTP_FINALITY_THRESHOLD ,
80- flexible_vault_proof_blob : Mapping [str , Any ] | None = None ,
80+ flexible_vault_proof_blob : Mapping [str , Any ] | Sequence [ Mapping [ str , Any ]] | None = None ,
8181 disable_call_verification : bool = False ,
82- hl_strategy_json_name : str | None = None ,
83- bridge_strategy_json_name : str | None = None ,
8482 ) -> None :
8583 hl_address = Web3 .to_checksum_address (hl_strategy_address )
8684 bridge_address = Web3 .to_checksum_address (bridge_strategy_address )
@@ -130,17 +128,13 @@ def __init__(
130128 self ._session ,
131129 verification_resolver = self ._flexible_proof_resolver ,
132130 disable_call_verification = self ._call_verification_disabled ,
133- mainnet_json_name = bridge_strategy_json_name , # For operations originating on mainnet
134- hyperliquid_json_name = hl_strategy_json_name , # For operations originating on HyperEVM
135131 )
136132
137133 self ._asset_by_symbol = self ._metadata .asset_by_symbol
138134 self ._token_index_by_symbol = self ._metadata .token_index_by_symbol
139135 self ._metadata_loaded = self ._metadata .metadata_loaded
140136 self ._hype_token_index : int | None = None
141137 self ._connected = False
142- self ._hl_strategy_json_name = hl_strategy_json_name
143- self ._bridge_strategy_json_name = bridge_strategy_json_name
144138
145139 # ------------------------------------------------------------------
146140 # Connection management
@@ -372,7 +366,6 @@ def limit_order(
372366 "tif" : tif_uint ,
373367 "cloid" : cloid_uint ,
374368 }
375- # All these operations happen on HyperEVM chain
376369 json_name = self ._get_json_name_for_chain ("hyperliquid" )
377370 payload = self ._resolve_verification_payload (
378371 "CoreWriter.sendRawAction{action: limit_order}(anyBytes)" , json_name , context
@@ -402,7 +395,7 @@ def cancel_order_by_oid(self, asset: str, order_id: int) -> Response:
402395 asset_id = self ._resolve_asset_id (asset )
403396 oid = int (order_id )
404397 context = {"asset" : asset_id , "oid" : oid }
405- # All these operations happen on HyperEVM chain
398+
406399 json_name = self ._get_json_name_for_chain ("hyperliquid" )
407400 payload = self ._resolve_verification_payload (
408401 "CoreWriter.sendRawAction{action: cancel_oid}(anyBytes)" , json_name , context
@@ -423,7 +416,6 @@ def cancel_order_by_cloid(self, asset: str, cloid: str) -> Response:
423416 asset_id = self ._resolve_asset_id (asset )
424417 cloid_uint = cloid_to_uint128 (cloid )
425418 context = {"asset" : asset_id , "cloid" : cloid_uint }
426- # All these operations happen on HyperEVM chain
427419 json_name = self ._get_json_name_for_chain ("hyperliquid" )
428420 payload = self ._resolve_verification_payload (
429421 "CoreWriter.sendRawAction{action: cancel_cloid}(anyBytes)" , json_name , context
@@ -451,7 +443,7 @@ def vault_transfer(self, vault: str, is_deposit: bool, usd: float) -> Response:
451443 def spot_send (self , recipient : str , token : str , amount : float , destination : str ) -> Response :
452444 amount_uint = to_uint64 (amount , 8 )
453445 context = {"token" : token , "amount" : amount_uint , "recipient" : recipient }
454- # All these operations happen on HyperEVM chain
446+
455447 json_name = self ._get_json_name_for_chain ("hyperliquid" )
456448 payload = self ._resolve_verification_payload (
457449 "CoreWriter.sendRawAction{action: spot_send}(anyBytes)" , json_name , context
@@ -510,7 +502,7 @@ def bridge_hyperliquid_to_mainnet(
510502 def usd_class_transfer_to_perp (self , amount : float ) -> Response :
511503 amount_uint = to_uint64 (amount , 6 )
512504 context = {"amount" : amount_uint }
513- # All these operations happen on HyperEVM chain
505+
514506 json_name = self ._get_json_name_for_chain ("hyperliquid" )
515507 payload = self ._resolve_verification_payload (
516508 "CoreWriter.sendRawAction{action: usd_transfer}(anyBytes)" , json_name , context
@@ -530,7 +522,7 @@ def usd_class_transfer_to_perp(self, amount: float) -> Response:
530522 def usd_class_transfer_to_spot (self , amount : float ) -> Response :
531523 amount_uint = to_uint64 (amount , 6 )
532524 context = {"amount" : amount_uint }
533- # All these operations happen on HyperEVM chain
525+
534526 json_name = self ._get_json_name_for_chain ("hyperliquid" )
535527 payload = self ._resolve_verification_payload (
536528 "CoreWriter.sendRawAction{action: usd_transfer}(anyBytes)" , json_name , context
@@ -662,31 +654,22 @@ def _get_json_name_for_chain(self, chain: str = "hyperliquid") -> str:
662654 Args:
663655 chain: Either "hyperliquid" for operations on HyperEVM or "mainnet" for operations on mainnet
664656 """
665- if chain == "mainnet" :
666- if self ._bridge_strategy_json_name :
667- return self ._bridge_strategy_json_name
668- # Try to auto-detect from available datasets if resolver exists
669- if self ._flexible_proof_resolver and hasattr (
670- self ._flexible_proof_resolver , "_datasets"
671- ):
672- # Look for a dataset for mainnet operations
657+ if self ._flexible_proof_resolver and hasattr (self ._flexible_proof_resolver , "_datasets" ):
658+ if chain == "mainnet" :
673659 for title in self ._flexible_proof_resolver ._datasets .keys ():
674660 if "mainnet" in title .lower () or "ethereum" in title .lower ():
675661 return title
676- else : # hyperliquid chain operations
677- if self ._hl_strategy_json_name :
678- return self ._hl_strategy_json_name
679- # Try to auto-detect from available datasets
680- if self ._flexible_proof_resolver and hasattr (
681- self ._flexible_proof_resolver , "_datasets"
682- ):
683- # Look for a dataset for HyperEVM operations
662+ elif chain == "hyperliquid" : # hyperliquid chain operations
684663 for title in self ._flexible_proof_resolver ._datasets .keys ():
685664 if "hyperevm" in title .lower () or "hyperliquid" in title .lower ():
686665 return title
666+ else :
667+ raise ValidationError (
668+ "Chain must be either 'hyperliquid' or 'mainnet'" ,
669+ field = "chain" ,
670+ value = chain ,
671+ )
687672
688- # If no specific json_name found, try to use the first available
689- if self ._flexible_proof_resolver and hasattr (self ._flexible_proof_resolver , "_datasets" ):
690673 datasets = self ._flexible_proof_resolver ._datasets
691674 if datasets :
692675 return next (iter (datasets .keys ()))
0 commit comments