fix channel schema `encode-url-data.ts` (#549)

* Update encode-url-data.ts

* Create slimy-keys-melt.md

* f

* f
This commit is contained in:
Felicio Mununga 2024-04-22 17:02:39 +02:00 committed by GitHub
parent 2d9dbdd49e
commit 13f7ed5415
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 27 deletions

View File

@ -0,0 +1,5 @@
---
"@status-im/js": patch
---
Update encode-url-data.ts

View File

@ -107,15 +107,6 @@ describe('Encode URL data', () => {
],
\\"message\\": \\"Required\\"
},
{
\\"code\\": \\"invalid_type\\",
\\"expected\\": \\"string\\",
\\"received\\": \\"undefined\\",
\\"path\\": [
\\"emoji\\"
],
\\"message\\": \\"Required\\"
},
{
\\"code\\": \\"invalid_type\\",
\\"expected\\": \\"string\\",
@ -188,15 +179,6 @@ describe('Encode URL data', () => {
],
\\"message\\": \\"Required\\"
},
{
\\"code\\": \\"invalid_type\\",
\\"expected\\": \\"string\\",
\\"received\\": \\"undefined\\",
\\"path\\": [
\\"emoji\\"
],
\\"message\\": \\"Required\\"
},
{
\\"code\\": \\"invalid_type\\",
\\"expected\\": \\"string\\",

View File

@ -25,8 +25,7 @@ export function encodeCommunityURLData(
return encodeURLData(new Community(data).toBinary()) as EncodedURLData
}
// note: PlainMessage<T> type does not ensure returning of only own properties
export function decodeCommunityURLData(data: string): PlainMessage<Community> {
export function decodeCommunityURLData(data: string) {
const deserialized = decodeURLData(data)
const community = Community.fromBinary(deserialized.content).toJson()
@ -37,7 +36,7 @@ export function decodeCommunityURLData(data: string): PlainMessage<Community> {
const channelSchema = z.object({
displayName: z.string().max(24).nonempty(),
description: z.string().max(140).nonempty(),
emoji: z.string().emoji(),
emoji: z.string().emoji().optional(),
color: colorSchema,
community: z.object({
displayName: communityDisplayName,
@ -51,12 +50,7 @@ export function encodeChannelURLData(
return encodeURLData(new Channel(data).toBinary()) as EncodedURLData
}
export function decodeChannelURLData(data: string): Omit<
PlainMessage<Channel>,
'community'
> & {
community: Pick<PlainMessage<Community>, 'displayName'>
} {
export function decodeChannelURLData(data: string) {
const deserialized = decodeURLData(data)
const channel = Channel.fromBinary(deserialized.content).toJson()