mirror of
https://github.com/nostr-protocol/nips.git
synced 2026-08-12 00:47:39 +00:00
address @TheAwiteb comments.
This commit is contained in:
@@ -30,7 +30,7 @@ Clients can publish a list of favorite scrolls using a NIP-51 standard list even
|
||||
|
||||
## String Convention
|
||||
|
||||
Unless 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.
|
||||
Unless 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.
|
||||
|
||||
For 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"`.
|
||||
|
||||
@@ -172,9 +172,9 @@ Add a kind integer to the `kinds` filter.
|
||||
|
||||
Add 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.
|
||||
|
||||
### `nostr.req_add_tag_bin32(req: i32, tag_ptr: i32, value_ptr: i32) -> void`
|
||||
### `nostr.req_add_tag_bin32(req: i32, tag_ptr: i32, tag_len: i32, value_ptr: i32) -> void`
|
||||
|
||||
Same 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.
|
||||
Same 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.
|
||||
|
||||
Hosts may deduplicate filter values (authors, ids, kinds, and tag values) when the module adds the same value more than once via `req_add_*`.
|
||||
|
||||
@@ -245,7 +245,7 @@ Returns the unix timestamp directly.
|
||||
|
||||
### `nostr.event_get_content(event_handle: i32) -> i32`
|
||||
|
||||
Returns a pointer to a buffer containing the event content.
|
||||
Returns a pointer to a buffer containing the event content (follows the String Convention above).
|
||||
|
||||
### `nostr.event_get_tag_count(event_handle: i32) -> i32`
|
||||
|
||||
@@ -257,11 +257,11 @@ Returns the number of items in the tag at `tag_index`.
|
||||
|
||||
### `nostr.event_get_tag_item(event_handle: i32, tag_index: i32, item_index: i32) -> i32`
|
||||
|
||||
Returns a pointer to a buffer containing the item at `(tag_index, item_index)`.
|
||||
Returns a pointer to a buffer containing the item at `(tag_index, item_index)` (follows the String Convention above).
|
||||
|
||||
### `nostr.event_get_tag_item_bin32(event_handle: i32, tag_index: i32, item_index: i32) -> i32`
|
||||
|
||||
Same 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.
|
||||
Same 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.
|
||||
|
||||
### `nostr.event_get_tag_item_by_name(event_handle: i32, name_ptr: i32, name_len: i32, item_index: i32) -> i32`
|
||||
|
||||
@@ -269,7 +269,7 @@ Finds the first tag whose name (item 0) matches the string at `name_ptr/name_len
|
||||
|
||||
### `nostr.event_get_tag_item_by_name_bin32(event_handle: i32, name_ptr: i32, name_len: i32, item_index: i32) -> i32`
|
||||
|
||||
Same 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.
|
||||
Same 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.
|
||||
|
||||
### `nostr.display(event: i32) -> void`
|
||||
|
||||
@@ -281,7 +281,7 @@ Emit a log message to the host's debug console or developer tooling. The string
|
||||
|
||||
### `nostr.drop(handle: i32) -> void`
|
||||
|
||||
Releases any handle: unconsumed request, active subscription (cancels it), individual event, or list (also releases all contained event handles).
|
||||
Releases any handle: unconsumed request, active subscription (cancels it), individual event.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user