nips icon indicating copy to clipboard operation
nips copied to clipboard

NIP-46 optional values: null or empty string?

Open alexgleason opened this issue 1 year ago • 1 comments

Positional arguments 2 and 3 of the connect method are "optional":

[<remote_user_pubkey>, <optional_secret>, <optional_requested_permissions>]

But what if I don't want to specify a secret, but I do want to specify permissions?

image

There is no way to avoid null in here, thus the type of params cannot be string[] as many existing apps expect, but (string | null)[]

The only other way is to use an empty string in "optional" arguments. Then the type remains string[]. But this could be a gotcha in languages where empty string is not considered falsy.

alexgleason avatar May 28 '24 19:05 alexgleason

I think that it would make the most sense to use null for no value but unfortunately there are NIPs that already use "" to mean that (e.g., NIP-10, NIP-1 optional relay url).

So I'd say empty string or consistently define nullas the way to convey no value everywhere (nobody will want this lol).

sant0s12 avatar May 29 '24 10:05 sant0s12