Update 01.md

Improves type definitions in each json
This commit is contained in:
Vitor Pamplona 2024-01-04 10:59:22 -05:00 committed by GitHub
parent b36336b937
commit 5d06af8af5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

49
01.md
View File

@ -12,19 +12,19 @@ This NIP defines the mandatory part of the Nostr protocol. New NIPs may add new
Event is the only object type available. It is a hashed and signed payload in the following format:
```json
```jsonc
{
"id": <32-byte lowercase hex-encoded sha256 of the serialized event data>,
"pubkey": <32-byte lowercase hex-encoded public key used to sign>,
"created_at": <unix timestamp in seconds>,
"id": <string 32-byte lowercase hex-encoded sha256 of the serialized event data>,
"pubkey": <string 32-byte lowercase hex-encoded public key used to sign>,
"created_at": <integer unix timestamp in seconds>,
"kind": <integer between 0 and 65535>,
"tags": [
[<tag1-name>, <tag1-value>, ...],
[<tag2-name>, <tag2-value>, ...],
[<string tag1-name>, <string tag1-value>, ...],
[<string tag2-name>, <string tag2-value>, ...],
...
],
"content": <arbitrary string>,
"sig": <64-byte lowercase hex of the signature of the id>
"content": <string>,
"sig": <string 64-byte lowercase hex of the signature of the id>
}
```
@ -36,14 +36,14 @@ Signatures and encodings are done according to the [Schnorr signatures standard
To assemble the `.id`, hex encode the result of a `sha256` of the UTF-8 byte array of a JSON-serialized string in the following structure:
```
```js
[
0,
<pubkey, as a lowercase hex string>,
<created_at, as a number>,
<kind, as a number>,
<tags, as an array of arrays of non-null strings>,
<content, as a string>
<string pubkey, as a lowercase hex>,
<integer created_at>,
<integer kind>,
<stringarray tags, as an array of arrays of non-null strings>,
<string content>
]
```
@ -136,16 +136,17 @@ To open and update, and close subscriptions, Clients MUST use the following form
`<filterX>` is a JSON object that determines what events will be sent in that subscription, it can have the following attributes:
```json
```js
{
"ids": [<id1>, <id2>, ...],
"authors": [<pubkey1>, <pubkey2>, ...],
"kinds": [<kind1>, <kind2>, ...],
"#<tag-name1 (single-letter a-zA-Z)>": [<tag value1>, <tag value2>, ...],
"#<tag-name2 (single-letter a-zA-Z)>": [<tag value1>, <tag value2>, ...],
"since": <an integer unix timestamp in seconds, events must be newer than this to pass>,
"until": <an integer unix timestamp in seconds, events must be older than this to pass>,
"limit": <maximum number of events to return, sorted by created_at desc>
"ids": [<string id1>, <string id2>, ...],
"authors": [<string pubkey1>, <string pubkey2>, ...],
"kinds": [<integer kind1>, <integer kind2>, ...],
"#<tag1-name (single-letter a-zA-Z)>": [<string tag1 value1>, <string tag1 value2>, ...],
"#<tag2-name (single-letter a-zA-Z)>": [<string tag2 value1>, <string tag2 value2>, ...],
...,
"since": <integer unix timestamp in seconds, events must be newer than this to pass>,
"until": <integer unix timestamp in seconds, events must be older than this to pass>,
"limit": <integer maximum number of events to return, sorted by created_at desc>
}
```
@ -212,4 +213,4 @@ Some examples:
* `["CLOSED", "sub1", "duplicate: sub1 already opened"]`
* `["CLOSED", "sub1", "unsupported: filter contains unknown elements"]`
* `["CLOSED", "sub1", "error: could not connect to the database"]`
* `["CLOSED", "sub1", "error: shutting down idle subscription"]`
* `["CLOSED", "sub1", "error: shutting down idle subscription"]`