-
Notifications
You must be signed in to change notification settings - Fork 320
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
CIP-0030 Suggestions #171
Comments
Would the wallet do something like ordering all utxos and then have the returned generator remember the last returned one and query the wallet for the next one in whatever arbitrary ordering they chose yielding that until it's there are none? I'm not primarily a javascript dev (more C++/Rust) and haven't worked with this feature before so I just want to be sure this would be easily doable and solve the issues with the current API.
The idea was they would pick a
Do you mean including all the types that are defined via
This was discussed in #88 here but we never finalized any changes. Perhaps it's time to continue that discussion that was started there and get to a final solution. @KtorZ @SebastienGllmt @alessandrokonrad
Do we expect the dApp to filter them all to see if they've ever been used on-chain before? I think people would be using the two endpoints (used and unused) for very different purposes. We could change the API description to mention that they shouldn't expect there to always be addresses if that would help. We should see what others think though. |
I think we should be thinking in terms of sets of utxo (unordered).
I think we shouldn't assume any specific wallet implementation or data source. It could already have all utxo in memory, could be fetching it from some server, or loading from indexeddb. Generator implementation would depend on wallet internals, but from API user point of view it would be a generator of the most recent snapshot of the utxo set.
Not yielding duplicates should be trivial to implement regardless of where the wallet is sourcing the utxo (checking by tx id + index). The wallets can also not yield a utxo once it's spent, even if it's spent after returning the generator. There might still be a situation where a utxo that was yielded is spent before the generator completes. There could be an error for that. For this specific function of
I thought the
A common pattern is to return something like
Yes, you wouldn't know the total number of items, but you can stop taking them when you got enough.
That's one option, but I suggest
The discussion seems to be about total vs available balance/utxo. I think it's ok for the connector to always return available balance/utxo (would be great to document it though). My question was about what this balance consists of. I suggest returning something like that:
Yes I was thinking the dApp would filter them, but now that you mention very different purposes I no longer think that consolidating them is a good idea. Changing the description would be a good improvement. |
Thanks for all the feedback.
I wasn't saying it should be in the spec, I was just thinking of a possible way to implement it that would solve both issues with the previous approach, those being that you might skip utxos if the set changed mid-iteration (e.g. you are on page 5 and something in pages 1-4 was spent so now everything shifts and you might miss a utxo) and that maybe new utxos will be skipped in a similar way. Having some kind of ordering was just the first idea that came to mind for me in order to implement it in a way that solves both of those issues - I didn't mean to have it sound like I was mandating it as the only way.
We might have been overly conservative of which endpoints might need pagination since it is optional functionality anyway. If you don't pass in a
The problem is that |
Thanks for considering my suggestions.
If we think about the issues separately, duplicate items issue is really just some complexity that needs to be handled either by the wallets or by the dapps. Both can do it, but I think this API should aim to make dapp development easy. I have an alternative suggestion. Instead of optional pagination argument, how about a separate API method that you would use like this: const pageSize = 10;
const { numPages, getPage } = await api.paginateUsedAddresses(pageSize);
for (let page=0; page<numPages; page++) {
const addressesPage = await getPage(page); // an array of addresses with length up to pageSize
}
I think
Oh, I see. I misunderstood the purpose of that type def. Thanks for an explanation. |
To avoid this issue we could change API functions with pagination to return an async iterator instead of
Promise
.Is the dApp supposed to try to call the method with
{limit: Number.POSITIVE_INFINITY}
to figure out max size? I think it's an odd API and if we keep the concept of pagination there should be a way to get the limit without an error.I initially thought that
TransactionUnspentOutput
wasn't cbor, the definition could use better consistency: I think we should either define all types ascbor<[type]>
or list all type definitions under Data Types.Does it include rewards and deposit? Need to make this explicit, as using these funds requires certificates in the transaction.
There will be different types of wallets. Some might be single address and not have any unused addresses. Given this API, dApp will probably expect to always get some unused addresses, which might not be the case. The dApp itself can figure out if it was used or not. I suggest to consolidate these to
api.getAddresses(paginate: Paginate = undefined): Promise<cbor<address>[]>
.@rooooooooob
The text was updated successfully, but these errors were encountered: