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

Weird behaviour in knowThisMintOfTokenJson #244

Open
prusnak opened this issue Oct 17, 2024 · 2 comments
Open

Weird behaviour in knowThisMintOfTokenJson #244

prusnak opened this issue Oct 17, 2024 · 2 comments

Comments

@prusnak
Copy link
Contributor

prusnak commented Oct 17, 2024

Function knowThisMintOfTokenJson is weird.

knowThisMintOfTokenJson: function (tokenJson) {
const mintStore = useMintsStore();
// check if we have all mints
for (var i = 0; i < tokenJson.token.length; i++) {
if (
!mintStore.mints.map((m) => m.url).includes(token.getMint(tokenJson))
) {
return false;
}
}
return true;
},

It iterates over i, but then the i variable is not used anywhere.

It seems like this is not intended.

@ok300
Copy link

ok300 commented Oct 21, 2024

You may want to separate by token type.

For V4, the token contains a single mint URL and all included proofs are for that mint:

V4 tokens are a space-efficient way of serializing tokens using the CBOR binary format. All field are single characters and hex strings are encoded in binary. V4 tokens can only hold proofs from a single mint.
https://github.com/cashubtc/nuts/blob/main/00.md

Then you don't need to iterate over the tokens in the JSON, as the mint URL is included in the root: https://github.com/cashubtc/nuts/blob/main/00.md#token-format-1

For V3, yes a token can have proofs from multiple mints: https://github.com/cashubtc/nuts/blob/main/00.md#example

You could also just deprecate V3 and keep it simple.

@prusnak
Copy link
Contributor Author

prusnak commented Dec 16, 2024

Has been fixed in f39eb7f

We can close this issue.

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

No branches or pull requests

2 participants