File tree Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 5
5
6
6
from pycardano .exception import DeserializeException
7
7
from pycardano .hash import PoolKeyHash , ScriptHash , VerificationKeyHash
8
- from pycardano .serialization import ArrayCBORSerializable , limit_primitive_type , ArrayBase
8
+ from pycardano .serialization import (
9
+ ArrayCBORSerializable ,
10
+ limit_primitive_type ,
11
+ ArrayBase ,
12
+ )
9
13
10
14
__all__ = [
11
15
"Certificate" ,
Original file line number Diff line number Diff line change @@ -186,22 +186,18 @@ def _split_by_asset(value: Value) -> List[Value]:
186
186
assets = [Value (value .coin )]
187
187
188
188
# Extract native assets
189
- for policy_id in value .multi_asset :
190
- for asset_name in value .multi_asset [policy_id ]:
191
- assets .append (
192
- Value .from_primitive (
193
- [
194
- 0 ,
195
- {
196
- policy_id .payload : {
197
- asset_name .payload : value .multi_asset [policy_id ][
198
- asset_name
199
- ]
200
- }
201
- },
202
- ]
203
- )
189
+ for policy_id , policy_id_dict in value .multi_asset .items ():
190
+ for asset_name , amount in policy_id_dict .items ():
191
+ if not amount :
192
+ # skip 0 amounts
193
+ continue
194
+ value = Value .from_primitive (
195
+ [
196
+ 0 ,
197
+ {policy_id .payload : {asset_name .payload : amount }},
198
+ ]
204
199
)
200
+ assets .append (value )
205
201
206
202
return assets
207
203
You can’t perform that action at this time.
0 commit comments