upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiatjaf <fiatjaf@gmail.com>2026-04-02 03:08:26 -0300
committerfiatjaf <fiatjaf@gmail.com>2026-04-02 03:09:42 -0300
commit5b5f9feb016541c0043e3e73ff1556a2c17f63a7 (patch)
treef99323e696690c12388a6c3d3840e8f3d2a03fec
parentceadf373a3c8b8207ad8c0fcc6a5a2d754edce1a (diff)
address @TheAwiteb comments.
-rw-r--r--5C.md16
1 files changed, 8 insertions, 8 deletions
diff --git a/5C.md b/5C.md
index 73f5333..a4e655e 100644
--- a/5C.md
+++ b/5C.md
@@ -30,7 +30,7 @@ Clients can publish a list of favorite scrolls using a NIP-51 standard list even
30 30
31## String Convention 31## String Convention
32 32
33Unless noted otherwise (for hex pubkeys and ids), the module passes strings to the host as `(ptr: i32, len: i32)` pairs into its linear memory. The host returns strings (and other variable-length data) by returning an `i32` pointer to a buffer in linear memory whose first 4 bytes are the `u32_be` byte-length of the payload that follows. 33Unless noted otherwise (i.e. for hex pubkeys and ids), the module passes strings to the host as `(ptr: i32, len: i32)` pairs into its linear memory. The host returns strings (and other variable-length data) by returning an `i32` pointer to a buffer in linear memory whose first 4 bytes are the `u32_be` byte-length of the payload that follows.
34 34
35For example, if `nostr.get_content(handle)` returns `7165` that will be a pointer to a buffer at location `7165`. If that buffer starts with `[ 00 00 00 03 ]` that means it contains 3 bytes (aside from the initial four), so we can keep reading it `[ 00 00 00 03 66 6f 6f ]` and conclude that the string is `"foo"`. 35For example, if `nostr.get_content(handle)` returns `7165` that will be a pointer to a buffer at location `7165`. If that buffer starts with `[ 00 00 00 03 ]` that means it contains 3 bytes (aside from the initial four), so we can keep reading it `[ 00 00 00 03 66 6f 6f ]` and conclude that the string is `"foo"`.
36 36
@@ -172,9 +172,9 @@ Add a kind integer to the `kinds` filter.
172 172
173Add a value to a tag filter. `tag_ptr/tag_len` points to the tag name (e.g. `"p"` -- will be added to the filter as `"#p"`); `value_ptr/value_len` points to the tag value to match. The value is treated as a string. 173Add a value to a tag filter. `tag_ptr/tag_len` points to the tag name (e.g. `"p"` -- will be added to the filter as `"#p"`); `value_ptr/value_len` points to the tag value to match. The value is treated as a string.
174 174
175### `nostr.req_add_tag_bin32(req: i32, tag_ptr: i32, value_ptr: i32) -> void` 175### `nostr.req_add_tag_bin32(req: i32, tag_ptr: i32, tag_len: i32, value_ptr: i32) -> void`
176 176
177Same as `req_add_tag` but the value is a 32-byte binary buffer that the host will convert to hex. `value_ptr` must point to a 32-byte buffer. This is useful for `#p`, `#e`, and other tag filters that need pubkey or event ID values. 177Same as `req_add_tag` but the value is a pointer to the 32-byte binary buffer that the host will convert to hex. This is useful for `#p`, `#e`, and other tag filters that need pubkey or event ID values.
178 178
179Hosts may deduplicate filter values (authors, ids, kinds, and tag values) when the module adds the same value more than once via `req_add_*`. 179Hosts may deduplicate filter values (authors, ids, kinds, and tag values) when the module adds the same value more than once via `req_add_*`.
180 180
@@ -245,7 +245,7 @@ Returns the unix timestamp directly.
245 245
246### `nostr.event_get_content(event_handle: i32) -> i32` 246### `nostr.event_get_content(event_handle: i32) -> i32`
247 247
248Returns a pointer to a buffer containing the event content. 248Returns a pointer to a buffer containing the event content (follows the String Convention above).
249 249
250### `nostr.event_get_tag_count(event_handle: i32) -> i32` 250### `nostr.event_get_tag_count(event_handle: i32) -> i32`
251 251
@@ -257,11 +257,11 @@ Returns the number of items in the tag at `tag_index`.
257 257
258### `nostr.event_get_tag_item(event_handle: i32, tag_index: i32, item_index: i32) -> i32` 258### `nostr.event_get_tag_item(event_handle: i32, tag_index: i32, item_index: i32) -> i32`
259 259
260Returns a pointer to a buffer containing the item at `(tag_index, item_index)`. 260Returns a pointer to a buffer containing the item at `(tag_index, item_index)` (follows the String Convention above).
261 261
262### `nostr.event_get_tag_item_bin32(event_handle: i32, tag_index: i32, item_index: i32) -> i32` 262### `nostr.event_get_tag_item_bin32(event_handle: i32, tag_index: i32, item_index: i32) -> i32`
263 263
264Same as `event_get_tag_item`, but returns a 32-byte buffer of the item if it happened to be a pubkey or an event id; 0 otherwise. 264Same as `event_get_tag_item`, but returns a pointer to a 32-byte buffer of the item if it happened to be a pubkey or an event id; 0 otherwise.
265 265
266### `nostr.event_get_tag_item_by_name(event_handle: i32, name_ptr: i32, name_len: i32, item_index: i32) -> i32` 266### `nostr.event_get_tag_item_by_name(event_handle: i32, name_ptr: i32, name_len: i32, item_index: i32) -> i32`
267 267
@@ -269,7 +269,7 @@ Finds the first tag whose name (item 0) matches the string at `name_ptr/name_len
269 269
270### `nostr.event_get_tag_item_by_name_bin32(event_handle: i32, name_ptr: i32, name_len: i32, item_index: i32) -> i32` 270### `nostr.event_get_tag_item_by_name_bin32(event_handle: i32, name_ptr: i32, name_len: i32, item_index: i32) -> i32`
271 271
272Same as `event_get_tag_item_by_name`, but returns a 32-byte buffer of the value if it happened to be a pubkey or an event id; 0 otherwise. 272Same as `event_get_tag_item_by_name`, but returns a pointer to a 32-byte buffer of the value if it happened to be a pubkey or an event id; 0 otherwise.
273 273
274### `nostr.display(event: i32) -> void` 274### `nostr.display(event: i32) -> void`
275 275
@@ -281,7 +281,7 @@ Emit a log message to the host's debug console or developer tooling. The string
281 281
282### `nostr.drop(handle: i32) -> void` 282### `nostr.drop(handle: i32) -> void`
283 283
284Releases any handle: unconsumed request, active subscription (cancels it), individual event, or list (also releases all contained event handles). 284Releases any handle: unconsumed request, active subscription (cancels it), individual event.
285 285
286--- 286---
287 287