@@ -23,9 +23,9 @@ def __init__(self, allow_ungated_transfer, owner):
2323 self .allow_ungated_transfer = allow_ungated_transfer
2424 self .owner = owner
2525
26- @staticmethod
27- def parse (resource : dict [str , Any ]) -> Object :
28- return Object (
26+ @classmethod
27+ def parse (cls , resource : dict [str , Any ]) -> Object :
28+ return cls (
2929 resource ["allow_ungated_transfer" ],
3030 AccountAddress .from_str_relaxed (resource ["owner" ]),
3131 )
@@ -51,9 +51,9 @@ def __init__(self, creator, description, name, uri):
5151 def __str__ (self ) -> str :
5252 return f"AccountAddress[creator: { self .creator } , description: { self .description } , name: { self .name } , ur: { self .uri } ]"
5353
54- @staticmethod
55- def parse (resource : dict [str , Any ]) -> Collection :
56- return Collection (
54+ @classmethod
55+ def parse (cls , resource : dict [str , Any ]) -> Collection :
56+ return cls (
5757 AccountAddress .from_str_relaxed (resource ["creator" ]),
5858 resource ["description" ],
5959 resource ["name" ],
@@ -76,9 +76,9 @@ def __init__(self, numerator, denominator, payee_address):
7676 def __str__ (self ) -> str :
7777 return f"Royalty[numerator: { self .numerator } , denominator: { self .denominator } , payee_address: { self .payee_address } ]"
7878
79- @staticmethod
80- def parse (resource : dict [str , Any ]) -> Royalty :
81- return Royalty (
79+ @classmethod
80+ def parse (cls , resource : dict [str , Any ]) -> Royalty :
81+ return cls (
8282 resource ["numerator" ],
8383 resource ["denominator" ],
8484 AccountAddress .from_str_relaxed (resource ["payee_address" ]),
@@ -111,9 +111,9 @@ def __init__(
111111 def __str__ (self ) -> str :
112112 return f"Token[collection: { self .collection } , index: { self .index } , description: { self .description } , name: { self .name } , uri: { self .uri } ]"
113113
114- @staticmethod
115- def parse (resource : dict [str , Any ]):
116- return Token (
114+ @classmethod
115+ def parse (cls , resource : dict [str , Any ]):
116+ return cls (
117117 AccountAddress .from_str_relaxed (resource ["collection" ]["inner" ]),
118118 int (resource ["index" ]),
119119 resource ["description" ],
@@ -190,67 +190,67 @@ def to_transaction_arguments(self) -> List[TransactionArgument]:
190190 TransactionArgument (self .serialize_value (), Serializer .to_bytes ),
191191 ]
192192
193- @staticmethod
194- def parse (name : str , property_type : int , value : bytes ) -> Property :
193+ @classmethod
194+ def parse (cls , name : str , property_type : int , value : bytes ) -> Property :
195195 deserializer = Deserializer (value )
196196
197197 if property_type == Property .BOOL :
198- return Property (name , "bool" , deserializer .bool ())
198+ return cls (name , "bool" , deserializer .bool ())
199199 elif property_type == Property .U8 :
200- return Property (name , "u8" , deserializer .u8 ())
200+ return cls (name , "u8" , deserializer .u8 ())
201201 elif property_type == Property .U16 :
202- return Property (name , "u16" , deserializer .u16 ())
202+ return cls (name , "u16" , deserializer .u16 ())
203203 elif property_type == Property .U32 :
204- return Property (name , "u32" , deserializer .u32 ())
204+ return cls (name , "u32" , deserializer .u32 ())
205205 elif property_type == Property .U64 :
206- return Property (name , "u64" , deserializer .u64 ())
206+ return cls (name , "u64" , deserializer .u64 ())
207207 elif property_type == Property .U128 :
208- return Property (name , "u128" , deserializer .u128 ())
208+ return cls (name , "u128" , deserializer .u128 ())
209209 elif property_type == Property .U256 :
210- return Property (name , "u256" , deserializer .u256 ())
210+ return cls (name , "u256" , deserializer .u256 ())
211211 elif property_type == Property .ADDRESS :
212- return Property (name , "address" , AccountAddress .deserialize (deserializer ))
212+ return cls (name , "address" , AccountAddress .deserialize (deserializer ))
213213 elif property_type == Property .STRING :
214- return Property (name , "0x1::string::String" , deserializer .str ())
214+ return cls (name , "0x1::string::String" , deserializer .str ())
215215 elif property_type == Property .BYTE_VECTOR :
216- return Property (name , "vector<u8>" , deserializer .to_bytes ())
216+ return cls (name , "vector<u8>" , deserializer .to_bytes ())
217217 raise InvalidPropertyType (property_type )
218218
219- @staticmethod
220- def bool (name : str , value : bool ) -> Property :
221- return Property (name , "bool" , value )
219+ @classmethod
220+ def bool (cls , name : str , value : bool ) -> Property :
221+ return cls (name , "bool" , value )
222222
223- @staticmethod
224- def u8 (name : str , value : int ) -> Property :
225- return Property (name , "u8" , value )
223+ @classmethod
224+ def u8 (cls , name : str , value : int ) -> Property :
225+ return cls (name , "u8" , value )
226226
227- @staticmethod
228- def u16 (name : str , value : int ) -> Property :
229- return Property (name , "u16" , value )
227+ @classmethod
228+ def u16 (cls , name : str , value : int ) -> Property :
229+ return cls (name , "u16" , value )
230230
231- @staticmethod
232- def u32 (name : str , value : int ) -> Property :
233- return Property (name , "u32" , value )
231+ @classmethod
232+ def u32 (cls , name : str , value : int ) -> Property :
233+ return cls (name , "u32" , value )
234234
235- @staticmethod
236- def u64 (name : str , value : int ) -> Property :
237- return Property (name , "u64" , value )
235+ @classmethod
236+ def u64 (cls , name : str , value : int ) -> Property :
237+ return cls (name , "u64" , value )
238238
239- @staticmethod
240- def u128 (name : str , value : int ) -> Property :
241- return Property (name , "u128" , value )
239+ @classmethod
240+ def u128 (cls , name : str , value : int ) -> Property :
241+ return cls (name , "u128" , value )
242242
243- @staticmethod
244- def u256 (name : str , value : int ) -> Property :
245- return Property (name , "u256" , value )
243+ @classmethod
244+ def u256 (cls , name : str , value : int ) -> Property :
245+ return cls (name , "u256" , value )
246246
247- @staticmethod
248- def string (name : str , value : str ) -> Property :
249- return Property (name , "0x1::string::String" , value )
247+ @classmethod
248+ def string (cls , name : str , value : str ) -> Property :
249+ return cls (name , "0x1::string::String" , value )
250250
251- @staticmethod
252- def bytes (name : str , value : bytes ) -> Property :
253- return Property (name , "vector<u8>" , value )
251+ @classmethod
252+ def bytes (cls , name : str , value : bytes ) -> Property :
253+ return cls (name , "vector<u8>" , value )
254254
255255
256256class PropertyMap :
@@ -282,8 +282,8 @@ def to_tuple(self) -> Tuple[List[str], List[str], List[bytes]]:
282282
283283 return (names , types , values )
284284
285- @staticmethod
286- def parse (resource : dict [str , Any ]) -> PropertyMap :
285+ @classmethod
286+ def parse (cls , resource : dict [str , Any ]) -> PropertyMap :
287287 props = resource ["inner" ]["data" ]
288288 properties = []
289289 for prop in props :
@@ -295,7 +295,7 @@ def parse(resource: dict[str, Any]) -> PropertyMap:
295295 )
296296 )
297297
298- return PropertyMap (properties )
298+ return cls (properties )
299299
300300
301301class ReadObject :
0 commit comments