-
Notifications
You must be signed in to change notification settings - Fork 325
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
CIP30: getUtxos null instead of undefined #181
Conversation
I'm not even sure if |
It's not filtering by an asset -- it's filtering by an amount Honestly though I think taking in an argument list for everything in CIP30 was a mistake. We should have made function only have a single parameter -- a JS object. It would have make backward/forward compatibility much easier -- especially for functions like this where people may want to add different filters, etc. in the future but can't anymore because of the optional parameter |
Yeah, but as you say it's filtering, so normally when I apply a filter on an array I always get back an array again regardless of the result. |
Returning an empty array would only make sense if this was element-wise filtering though. Otherwise you wouldn't be able to differentiate between a wallet with no UTXOs and a wallet with UTXOs but just not enough to sum to the value you requested |
Agree. I'm wondering what is the intended use case for this filtering. If it's for input selection then this interface is not sufficient and should be redesigned in my opinion (see this comment). |
Replaced undefined with null to be compatible with cardano-foundation#181
* Adding `getCollateralUtxos` function * Changed undefined return to null Replaced undefined with null to be compatible with #181 * Updated the spec to rename the function and change the arguments to an object * Fixing wording * Update README.md * Tried to clarify the description a bit more
Currently CIP30 defines the
getUtxos
endpoint should returnundefined
if the requested amount can't be satisfiedThe problem is that browser message passing uses JSON and
undefined
is not valid JSON. This can easily introduce subtle bugs (some libraries silently convertundefined
tonull
) and it's needless complexity when we could just define the spec to return null instead.Strictly speaking this is a breaking change, but I'm not sure if it will affect app at the moment.
Another option would be to return an error instead of null which I think also makes sense