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

Add must_pay_many #16

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add must_pay_many #16

wants to merge 4 commits into from

Conversation

shapeshed
Copy link

This requires that two and only two of the specified denoms are sent

This requires that two and only two of the specified denoms are sent
@hashedone
Copy link
Contributor

I don't think it is the best approach. must_pay is a convinence functinon for the super common case of one coin needed, so we want to provide the nice API for this case. I understand the need of accepting more coins for some cases, but I feel, that going with must_pay_two_coins we should also add must_pay_three_coins, must_pay_four_coins and so on - at least until clippy complains for too many args.
If you want to provide the better API for more than one coin, I suggest the function like must_pay_many(&[&str]) - with this generic signature you will support arbitrarly amount of tokens with fairly simplified API.

@shapeshed
Copy link
Author

Ok fair point, I will have a think about reworking the api

@shapeshed shapeshed changed the title Add must_pay_two_coins Add must_pay_many Oct 4, 2023
@shapeshed
Copy link
Author

Function signature updated to

pub fn must_pay_many(
    info: &MessageInfo,
    required_denoms: &[&str],
) -> Result<Vec<Coin>, PaymentError> {

Also updated to use a Hashmap and check for duplicates

@shapeshed
Copy link
Author

Are you consider merging this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants