Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coinselection #329

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions pycardano/coinselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,19 @@ def _random_select_subset(
@staticmethod
def _split_by_asset(value: Value) -> List[Value]:
# Extract ADA
assets = [Value(value.coin)]
assets = [Value(value.coin)] if value.coin else []

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