From a2e267c5bb46a2d392d01b58372f3750aa72c523 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Sat, 23 Nov 2024 23:33:44 +1100 Subject: [PATCH 1/2] refactor: Update SPECIFICATION.md to include long cast validation rules from FIP-16 --- docs/SPECIFICATION.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/SPECIFICATION.md b/docs/SPECIFICATION.md index 8fc3d92..a0c3578 100644 --- a/docs/SPECIFICATION.md +++ b/docs/SPECIFICATION.md @@ -303,14 +303,15 @@ A CastAddBody in a message `m` is valid only if it passes these validations: 1. `m.signature_scheme` must be `SIGNATURE_SCHEME_ED25519`. 2. `m.data.type` must be `MESSAGE_TYPE_CAST_ADD`. -3. `m.data.body.type` must be `CastAddBody`. +3. `m.data.body` must be `CastAddBody` type. 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). 5. `m.data.body.mentions` must contain between 0 and 10 256-bit integer values. 6. `m.data.body.parent`, if present, must be a valid CastId or a UTF8 string whose length is >= 1 byte and <= 256 bytes. -7. `m.data.body.text` must contain <= 320 bytes and be a valid UTF8 string. -8. `m.data.body.mentions_positions` must have unique integers between 0 and length of `text` inclusive. -9. `m.data.body.mentions_positions` integers must be in ascending order and must have as many elements as `mentions`. -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. +7. `m.data.body.text` must contain <= 1024 bytes and be a valid UTF8 string. +8. `m.data.body.type` must be either `CastType.CAST` for casts with text length of 0 <= length <= 320 and `CastType.LONG` for casts that are 321 <= length <= 1024 +9. `m.data.body.mentions_positions` must have unique integers between 0 and length of `text` inclusive. +10. `m.data.body.mentions_positions` integers must be in ascending order and must have as many elements as `mentions`. +11. `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. A CastRemoveBody in a message `m` is valid only if it passes these validations: From d7441218730d6a25be7eda9930099a8e1fe5bcb2 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Sat, 23 Nov 2024 23:39:08 +1100 Subject: [PATCH 2/2] fix: proper proto enum name --- docs/SPECIFICATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/SPECIFICATION.md b/docs/SPECIFICATION.md index a0c3578..e96a290 100644 --- a/docs/SPECIFICATION.md +++ b/docs/SPECIFICATION.md @@ -308,7 +308,7 @@ A CastAddBody in a message `m` is valid only if it passes these validations: 5. `m.data.body.mentions` must contain between 0 and 10 256-bit integer values. 6. `m.data.body.parent`, if present, must be a valid CastId or a UTF8 string whose length is >= 1 byte and <= 256 bytes. 7. `m.data.body.text` must contain <= 1024 bytes and be a valid UTF8 string. -8. `m.data.body.type` must be either `CastType.CAST` for casts with text length of 0 <= length <= 320 and `CastType.LONG` for casts that are 321 <= length <= 1024 +8. `m.data.body.type` must be either `CastType.CAST` for casts with text length of 0 <= length <= 320 and `CastType.LONG_CAST` for casts that are 321 <= length <= 1024 9. `m.data.body.mentions_positions` must have unique integers between 0 and length of `text` inclusive. 10. `m.data.body.mentions_positions` integers must be in ascending order and must have as many elements as `mentions`. 11. `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.