Skip to content

Commit 6ac04e0

Browse files
authored
docs(specification): fip-2 changes (#84)
1 parent b620d18 commit 6ac04e0

1 file changed

Lines changed: 38 additions & 16 deletions

File tree

docs/SPECIFICATION.md

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,18 @@ Casts are added with a `CastAdd` message and removed with a tombstone `CastRemov
260260

261261
```protobuf
262262
message CastAddBody {
263-
repeated string embeds = 1; // URIs to embed alongside the text
264-
repeated uint64 mentions = 2; // User fids mentioned in the text
265-
oneof parent {
266-
CastId parent_cast_id = 3; // Optional parent of the cast
263+
repeated string embeds_deprecated = 1; // Deprecated embeds field
264+
repeated uint64 mentions = 2; // User fids mentioned in the text
265+
oneof parent { // Optional parent of the cast
266+
CastId parent_cast_id = 3;
267+
string parent_url = 7; // Parent URL
267268
};
268-
string text = 4; // Text of the cast
269-
repeated uint32 mentions_positions = 5; // Byte positions of the mentions in the text
269+
string text = 4; // Text of the cast
270+
repeated uint32 mentions_positions = 5; // Byte positions of the mentions in the text
271+
repeated Embed embeds = 6; // URIs or CastIds to embedded in the cast
270272
}
271273
274+
272275
message CastRemoveBody {
273276
bytes target_hash = 1; // Message.hash value of the cast being removed
274277
}
@@ -277,19 +280,27 @@ message CastId {
277280
uint64 fid = 1; // Fid of the cast's author
278281
bytes hash = 2; // Message.hash value of the cast
279282
}
283+
284+
message Embed {
285+
oneof embed {
286+
string url = 1;
287+
CastId cast_id = 2;
288+
}
289+
}
280290
```
281291

282292
A CastAddBody in a message `m` is valid only if it passes these validations:
283293

284294
1. `m.signature_scheme` must be `SIGNATURE_SCHEME_ED25519`.
285295
2. `m.data.type` must be `MESSAGE_TYPE_CAST_ADD`.
286296
3. `m.data.body.type` must be `CastAddBody`.
287-
4. `m.data.body.embeds` can contain up to 2 valid utf8 strings are between 1 and 256 bytes inclusive.
297+
4. `m.data.body.embeds_deprecated` can contain up to 2 valid UTF8 strings whose lengths are >=1 byte and <= 256 bytes if the timestamp is <= 73612800 (5/3/23 00:00 UTC).
288298
5. `m.data.body.mentions` must contain between 0 and 10 256-bit integer values.
289-
6. `m.data.body.parent`, if present, must be a valid CastId
290-
7. `m.data.body.text` must contain <= 320 bytes and be a valid utf8 string.
299+
6. `m.data.body.parent`, if present, must be a valid CastId or a UTF8 string whose length is >= 1 byte and <= 256 bytes.
300+
7. `m.data.body.text` must contain <= 320 bytes and be a valid UTF8 string.
291301
8. `m.data.body.mentions_positions` must have unique integers between 0 and length of `text` inclusive.
292302
9. `m.data.body.mentions_positions` integers must be in ascending order and must have as many elements as `mentions`.
303+
10. `m.data.body.embeds` can contain up to 2 embeds, each of which is a CastId or valid UTF8 string whose length is >=1 byte and <= 256bytes.
293304

294305
A CastRemoveBody in a message `m` is valid only if it passes these validations:
295306

@@ -313,7 +324,8 @@ Reactions are added with a `ReactionAdd` message and removed with a `ReactionRem
313324
message ReactionBody {
314325
ReactionType type = 1; // Type of reaction
315326
oneof target {
316-
CastId target_cast_id = 2; // CastId of the Cast to react to
327+
CastId target_cast_id = 2; // CastId being reacted to
328+
string target_url = 3; // URL being reacted to
317329
}
318330
}
319331
@@ -330,7 +342,7 @@ A Reaction message `m` must pass these validations and the validations for React
330342
1. `m.signature_scheme` must be `SIGNATURE_SCHEME_ED25519`.
331343
2. `m.data.body` must be `ReactionBody`.
332344
3. `m.data.body.type` must be a valid, non-zero ReactionType
333-
4. `m.data.body.target` must be a valid CastId
345+
4. `m.data.body.target` must be a valid CastId or a UTF8 string between 1 and 256 bytes inclusive.
334346

335347
A ReactionAdd message `m` is valid only if it passes these validations:
336348

@@ -709,7 +721,8 @@ service HubService {
709721
// Reactions
710722
rpc GetReaction(ReactionRequest) returns (Message);
711723
rpc GetReactionsByFid(ReactionsByFidRequest) returns (MessagesResponse);
712-
rpc GetReactionsByCast(ReactionsByCastRequest) returns (MessagesResponse);
724+
rpc GetReactionsByCast(ReactionsByTargetRequest) returns (MessagesResponse); // To be deprecated
725+
rpc GetReactionsByTarget(ReactionsByTargetRequest) returns (MessagesResponse);
713726
714727
// User Data
715728
rpc GetUserData(UserDataRequest) returns (Message);
@@ -768,7 +781,10 @@ message MessagesResponse {
768781
}
769782
770783
message CastsByParentRequest {
771-
CastId cast_id = 1;
784+
oneof parent {
785+
CastId parent_cast_id = 1;
786+
string parent_url = 5;
787+
}
772788
optional uint32 page_size = 2;
773789
optional bytes page_token = 3;
774790
optional bool reverse = 4;
@@ -777,7 +793,10 @@ message CastsByParentRequest {
777793
message ReactionRequest {
778794
uint64 fid = 1;
779795
ReactionType reaction_type = 2;
780-
CastId cast_id = 3;
796+
oneof target {
797+
CastId target_cast_id = 3;
798+
string target_url = 4;
799+
}
781800
}
782801
783802
message ReactionsByFidRequest {
@@ -788,8 +807,11 @@ message ReactionsByFidRequest {
788807
optional bool reverse = 5;
789808
}
790809
791-
message ReactionsByCastRequest {
792-
CastId cast_id = 1;
810+
message ReactionsByTargetRequest {
811+
oneof target {
812+
CastId target_cast_id = 1;
813+
string target_url = 6;
814+
}
793815
optional ReactionType reaction_type = 2;
794816
optional uint32 page_size = 3;
795817
optional bytes page_token = 4;

0 commit comments

Comments
 (0)