@@ -95,8 +95,8 @@ class CATWallet:
9595 wallet_info_type : ClassVar [type [CATInfo ]] = CATInfo
9696
9797 @staticmethod
98- def default_wallet_name_for_unknown_cat (limitations_program_hash_hex : str ) -> str :
99- return f"CAT { limitations_program_hash_hex [:16 ]} ..."
98+ def default_wallet_name_for_unknown_cat (limitations_program_hash : bytes32 ) -> str :
99+ return f"CAT { limitations_program_hash . hex () [:16 ]} ..."
100100
101101 @staticmethod
102102 async def create_new_cat_wallet (
@@ -152,7 +152,7 @@ async def create_new_cat_wallet(
152152 # since we didn't yet know the TAIL. Now we know the TAIL, we can update the name
153153 # according to the template name for unknown/new CATs.
154154 if original_name is None :
155- name = self .default_wallet_name_for_unknown_cat (self .cat_info .limitations_program_hash . hex () )
155+ name = self .default_wallet_name_for_unknown_cat (self .cat_info .limitations_program_hash )
156156 await self .set_name (name )
157157
158158 # Change and actual CAT coin
@@ -200,30 +200,27 @@ async def get_or_create_wallet_for_cat(
200200 cls ,
201201 wallet_state_manager : WalletStateManager ,
202202 wallet : Wallet ,
203- limitations_program_hash_hex : str ,
203+ limitations_program_hash : bytes32 ,
204204 name : str | None = None ,
205205 ) -> Self :
206206 self = cls ()
207207 self .standard_wallet = wallet
208208 self .log = logging .getLogger (__name__ )
209209
210- limitations_program_hash_hex = bytes32 .from_hexstr (limitations_program_hash_hex ).hex () # Normalize the format
211-
212210 for id , w in wallet_state_manager .wallets .items ():
213211 if w .type () == cls .type ():
214212 assert isinstance (w , cls )
215- if w .get_asset_id () == limitations_program_hash_hex :
213+ if w .get_asset_id () == limitations_program_hash :
216214 self .log .warning ("Not creating wallet for already existing CAT wallet" )
217215 return w
218216
219217 self .wallet_state_manager = wallet_state_manager
220- if limitations_program_hash_hex in DEFAULT_CATS :
221- cat_info = DEFAULT_CATS [limitations_program_hash_hex ]
218+ if limitations_program_hash . hex () in DEFAULT_CATS :
219+ cat_info = DEFAULT_CATS [limitations_program_hash . hex () ]
222220 name = cat_info ["name" ]
223221 elif name is None :
224- name = self .default_wallet_name_for_unknown_cat (limitations_program_hash_hex )
222+ name = self .default_wallet_name_for_unknown_cat (limitations_program_hash )
225223
226- limitations_program_hash = bytes32 .from_hexstr (limitations_program_hash_hex )
227224 self .cat_info = cls .wallet_info_type (limitations_program_hash , None )
228225 info_as_string = bytes (self .cat_info ).hex ()
229226 self .wallet_info = await wallet_state_manager .user_store .create_wallet (name , self .wallet_type , info_as_string )
@@ -274,7 +271,7 @@ async def create_from_puzzle_info(
274271 return await cls .get_or_create_wallet_for_cat (
275272 wallet_state_manager ,
276273 wallet ,
277- puzzle_driver ["tail" ]. hex () ,
274+ puzzle_driver ["tail" ],
278275 name ,
279276 )
280277
@@ -356,8 +353,8 @@ async def set_name(self, new_name: str) -> None:
356353 self .wallet_info = new_info
357354 await self .wallet_state_manager .user_store .update_wallet (self .wallet_info )
358355
359- def get_asset_id (self ) -> str :
360- return bytes ( self .cat_info .limitations_program_hash ). hex ()
356+ def get_asset_id (self ) -> bytes32 :
357+ return self .cat_info .limitations_program_hash
361358
362359 async def coin_added (
363360 self , coin : Coin , height : uint32 , peer : WSChiaConnection , parent_coin_data : CATCoinData | None
@@ -821,12 +818,12 @@ async def save_info(self, cat_info: CATInfo) -> None:
821818 async def match_puzzle_info (self , puzzle_driver : PuzzleInfo ) -> bool :
822819 return (
823820 AssetType (puzzle_driver .type ()) == AssetType .CAT
824- and puzzle_driver ["tail" ] == bytes . fromhex ( self .get_asset_id () )
821+ and puzzle_driver ["tail" ] == self .get_asset_id ()
825822 and puzzle_driver .also () is None
826823 )
827824
828825 async def get_puzzle_info (self , asset_id : bytes32 ) -> PuzzleInfo :
829- return PuzzleInfo ({"type" : AssetType .CAT .value , "tail" : "0x" + self .get_asset_id ()})
826+ return PuzzleInfo ({"type" : AssetType .CAT .value , "tail" : "0x" + self .get_asset_id (). hex () })
830827
831828 async def get_coins_to_offer (
832829 self ,
0 commit comments