Skip to content

Commit

Permalink
Fix coin selection
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Mar 6, 2024
1 parent 1606eee commit 63bd0b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 5 additions & 1 deletion pycardano/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

from pycardano.exception import DeserializeException
from pycardano.hash import PoolKeyHash, ScriptHash, VerificationKeyHash
from pycardano.serialization import ArrayCBORSerializable, limit_primitive_type, ArrayBase
from pycardano.serialization import (
ArrayCBORSerializable,
limit_primitive_type,
ArrayBase,
)

__all__ = [
"Certificate",
Expand Down
26 changes: 11 additions & 15 deletions pycardano/coinselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,18 @@ def _split_by_asset(value: Value) -> List[Value]:
assets = [Value(value.coin)]

# Extract native assets
for policy_id in value.multi_asset:
for asset_name in value.multi_asset[policy_id]:
assets.append(
Value.from_primitive(
[
0,
{
policy_id.payload: {
asset_name.payload: value.multi_asset[policy_id][
asset_name
]
}
},
]
)
for policy_id, policy_id_dict in value.multi_asset.items():
for asset_name, amount in policy_id_dict.items():
if not amount:
# skip 0 amounts
continue
value = Value.from_primitive(
[
0,
{policy_id.payload: {asset_name.payload: amount}},
]
)
assets.append(value)

return assets

Expand Down

0 comments on commit 63bd0b6

Please sign in to comment.