@@ -110,50 +110,181 @@ def app_opted_in(
110
110
return account .is_opted_in (app )
111
111
112
112
113
- class _AcctParamsGet :
114
- def __getattr__ (
115
- self , name : str
116
- ) -> typing .Callable [
117
- [algopy .Account | algopy .UInt64 | int ], tuple [algopy .UInt64 | algopy .Account , bool ]
118
- ]:
119
- def get_account_param (
120
- a : algopy .Account | algopy .UInt64 | int ,
121
- ) -> tuple [algopy .UInt64 | algopy .Account , bool ]:
122
- account = _get_account (a )
123
- field = name .removeprefix ("acct_" )
124
- if field == "auth_addr" :
125
- field = "auth_address"
126
-
127
- return getattr (account , field ), account .balance != 0
128
-
129
- return get_account_param
130
-
131
-
132
- AcctParamsGet = _AcctParamsGet ()
133
-
134
-
135
- class _AssetParamsGet :
136
- def __getattr__ (
137
- self , name : str
138
- ) -> typing .Callable [[algopy .Asset | algopy .UInt64 | int ], tuple [typing .Any , bool ]]:
139
- def get_asset_param (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [typing .Any , bool ]:
140
- try :
141
- asset = _get_asset (a )
142
- except ValueError :
143
- return UInt64 (0 ), False
144
-
145
- short_name = name .removeprefix ("asset_" )
146
- try :
147
- return getattr (asset , short_name ), True
148
- except AttributeError :
149
- raise AttributeError (
150
- f"'{ self .__class__ .__name__ } ' object has no attribute '{ name } '"
151
- ) from None
152
-
153
- return get_asset_param
154
-
155
-
156
- AssetParamsGet = _AssetParamsGet ()
113
+ class AcctParamsGet :
114
+ @staticmethod
115
+ def acct_auth_addr (a : algopy .Account | algopy .UInt64 | int ) -> tuple [algopy .Account , bool ]:
116
+ account = _get_account (a )
117
+ return account .auth_address , account .balance != 0
118
+
119
+ @staticmethod
120
+ def acct_balance (a : algopy .Account | algopy .UInt64 | int ) -> tuple [algopy .UInt64 , bool ]:
121
+ account = _get_account (a )
122
+ return account .balance , account .balance != 0
123
+
124
+ @staticmethod
125
+ def acct_min_balance (a : algopy .Account | algopy .UInt64 | int ) -> tuple [algopy .UInt64 , bool ]:
126
+ account = _get_account (a )
127
+ return account .min_balance , account .balance != 0
128
+
129
+ @staticmethod
130
+ def acct_auth_address (a : algopy .Account | algopy .UInt64 | int ) -> tuple [algopy .UInt64 , bool ]:
131
+ account = _get_account (a )
132
+ return account .auth_address , account .balance != 0
133
+
134
+ @staticmethod
135
+ def acct_total_num_uint (a : algopy .Account | algopy .UInt64 | int ) -> tuple [algopy .UInt64 , bool ]:
136
+ account = _get_account (a )
137
+ return account .total_num_uint , account .balance != 0
138
+
139
+ @staticmethod
140
+ def acct_total_num_byte_slice (
141
+ a : algopy .Account | algopy .UInt64 | int ,
142
+ ) -> tuple [algopy .UInt64 , bool ]:
143
+ account = _get_account (a )
144
+ return account .total_num_byte_slice , account .balance != 0
145
+
146
+ @staticmethod
147
+ def acct_total_extra_app_pages (
148
+ a : algopy .Account | algopy .UInt64 | int ,
149
+ ) -> tuple [algopy .UInt64 , bool ]:
150
+ account = _get_account (a )
151
+ return account .total_extra_app_pages , account .balance != 0
152
+
153
+ @staticmethod
154
+ def acct_total_apps_created (
155
+ a : algopy .Account | algopy .UInt64 | int ,
156
+ ) -> tuple [algopy .UInt64 , bool ]:
157
+ account = _get_account (a )
158
+ return account .total_apps_created , account .balance != 0
159
+
160
+ @staticmethod
161
+ def acct_total_apps_opted_in (
162
+ a : algopy .Account | algopy .UInt64 | int ,
163
+ ) -> tuple [algopy .UInt64 , bool ]:
164
+ account = _get_account (a )
165
+ return account .total_apps_opted_in , account .balance != 0
166
+
167
+ @staticmethod
168
+ def acct_total_assets_created (
169
+ a : algopy .Account | algopy .UInt64 | int ,
170
+ ) -> tuple [algopy .UInt64 , bool ]:
171
+ account = _get_account (a )
172
+ return account .total_assets_created , account .balance != 0
173
+
174
+ @staticmethod
175
+ def acct_total_assets (a : algopy .Account | algopy .UInt64 | int ) -> tuple [algopy .UInt64 , bool ]:
176
+ account = _get_account (a )
177
+ return account .total_assets , account .balance != 0
178
+
179
+ @staticmethod
180
+ def acct_total_boxes (a : algopy .Account | algopy .UInt64 | int ) -> tuple [algopy .UInt64 , bool ]:
181
+ account = _get_account (a )
182
+ return account .total_boxes , account .balance != 0
183
+
184
+ @staticmethod
185
+ def acct_total_box_bytes (
186
+ a : algopy .Account | algopy .UInt64 | int ,
187
+ ) -> tuple [algopy .UInt64 , bool ]:
188
+ account = _get_account (a )
189
+ return account .total_box_bytes , account .balance != 0
190
+
191
+
192
+ class AssetParamsGet :
193
+ @staticmethod
194
+ def asset_clawback (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .Account , bool ]:
195
+ try :
196
+ asset = _get_asset (a )
197
+ except ValueError :
198
+ return UInt64 (0 ), False # type: ignore[return-value]
199
+ return asset .clawback , True
200
+
201
+ @staticmethod
202
+ def asset_creator (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .Account , bool ]:
203
+ try :
204
+ asset = _get_asset (a )
205
+ except ValueError :
206
+ return UInt64 (0 ), False # type: ignore[return-value]
207
+ return asset .creator , True
208
+
209
+ @staticmethod
210
+ def asset_freeze (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .Account , bool ]:
211
+ try :
212
+ asset = _get_asset (a )
213
+ except ValueError :
214
+ return UInt64 (0 ), False # type: ignore[return-value]
215
+ return asset .freeze , True
216
+
217
+ @staticmethod
218
+ def asset_manager (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .Account , bool ]:
219
+ try :
220
+ asset = _get_asset (a )
221
+ except ValueError :
222
+ return UInt64 (0 ), False # type: ignore[return-value]
223
+ return asset .manager , True
224
+
225
+ @staticmethod
226
+ def asset_reserve (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .Account , bool ]:
227
+ try :
228
+ asset = _get_asset (a )
229
+ except ValueError :
230
+ return UInt64 (0 ), False # type: ignore[return-value]
231
+ return asset .reserve , True
232
+
233
+ @staticmethod
234
+ def asset_total (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .UInt64 , bool ]:
235
+ try :
236
+ asset = _get_asset (a )
237
+ except ValueError :
238
+ return UInt64 (0 ), False
239
+ return asset .total , True
240
+
241
+ @staticmethod
242
+ def asset_decimals (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .UInt64 , bool ]:
243
+ try :
244
+ asset = _get_asset (a )
245
+ except ValueError :
246
+ return UInt64 (0 ), False
247
+ return asset .decimals , True
248
+
249
+ @staticmethod
250
+ def asset_default_frozen (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [bool , bool ]:
251
+ try :
252
+ asset = _get_asset (a )
253
+ except ValueError :
254
+ return UInt64 (0 ), False # type: ignore[return-value]
255
+ return asset .default_frozen , True
256
+
257
+ @staticmethod
258
+ def asset_unit_name (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .Bytes , bool ]:
259
+ try :
260
+ asset = _get_asset (a )
261
+ except ValueError :
262
+ return UInt64 (0 ), False # type: ignore[return-value]
263
+ return asset .unit_name , True
264
+
265
+ @staticmethod
266
+ def asset_name (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .Bytes , bool ]:
267
+ try :
268
+ asset = _get_asset (a )
269
+ except ValueError :
270
+ return UInt64 (0 ), False # type: ignore[return-value]
271
+ return asset .name , True
272
+
273
+ @staticmethod
274
+ def asset_url (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .Bytes , bool ]:
275
+ try :
276
+ asset = _get_asset (a )
277
+ except ValueError :
278
+ return UInt64 (0 ), False # type: ignore[return-value]
279
+ return asset .url , True
280
+
281
+ @staticmethod
282
+ def asset_metadata_hash (a : algopy .Asset | algopy .UInt64 | int ) -> tuple [algopy .Bytes , bool ]:
283
+ try :
284
+ asset = _get_asset (a )
285
+ except ValueError :
286
+ return UInt64 (0 ), False # type: ignore[return-value]
287
+ return asset .metadata_hash , True
157
288
158
289
159
290
class _AssetHoldingGet :
0 commit comments