diff --git a/.changeset/slimy-keys-melt.md b/.changeset/slimy-keys-melt.md new file mode 100644 index 00000000..f21b465d --- /dev/null +++ b/.changeset/slimy-keys-melt.md @@ -0,0 +1,5 @@ +--- +"@status-im/js": patch +--- + +Update encode-url-data.ts diff --git a/packages/status-js/src/utils/encode-url-data.test.ts b/packages/status-js/src/utils/encode-url-data.test.ts index f7cdf6fe..99844b5c 100644 --- a/packages/status-js/src/utils/encode-url-data.test.ts +++ b/packages/status-js/src/utils/encode-url-data.test.ts @@ -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\\", diff --git a/packages/status-js/src/utils/encode-url-data.ts b/packages/status-js/src/utils/encode-url-data.ts index 5505d54f..05c2dd6d 100644 --- a/packages/status-js/src/utils/encode-url-data.ts +++ b/packages/status-js/src/utils/encode-url-data.ts @@ -25,8 +25,7 @@ export function encodeCommunityURLData( return encodeURLData(new Community(data).toBinary()) as EncodedURLData } -// note: PlainMessage type does not ensure returning of only own properties -export function decodeCommunityURLData(data: string): PlainMessage { +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 { 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, - 'community' -> & { - community: Pick, 'displayName'> -} { +export function decodeChannelURLData(data: string) { const deserialized = decodeURLData(data) const channel = Channel.fromBinary(deserialized.content).toJson()