Skip to content

Modify client coins endpoint so None for asset_id returns all asset_ids instead of AssetId::default() #2960

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

Open
MitchTurner opened this issue Apr 17, 2025 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@MitchTurner
Copy link
Member

Currently the coins endpoint on the client will request AssetId::default() if asset_id field is None. This is not expected behavior, and even the query side expects to return all if None:

let coins = query
                .owned_coins(&owner, (*start).map(Into::into), direction)
                .filter_map(|result| {
                    if let (Ok(coin), Some(filter_asset_id)) = (&result, &filter.asset_id)
                    {
                        if *coin.asset_id() != filter_asset_id.0 {
                            return None
                        }
                    }

                    Some(result)
                })
                .map(|res| res.map(|coin| ((*coin.utxo_id()).into(), coin.into())));

            Ok(coins)

We should consider removing this code from coins:

        let asset_id: schema::AssetId = match asset_id {
            Some(asset_id) => (*asset_id).into(),
            None => schema::AssetId::default(),
        };
@MitchTurner MitchTurner added the enhancement New feature or request label Apr 17, 2025
@MitchTurner MitchTurner added bug Something isn't working good first issue Good for newcomers labels Apr 24, 2025 — with Linear
Copy link
Member Author

Also, it's not clear that AssetId::default() is the base asset. That's also a bug.

@EDOHWARES
Copy link

Hi, I'm EDOHWAREZ, a software developer with years of experience in building scalable software. I'll like to work on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants