diff --git a/packages/sdk/src/id.ts b/packages/sdk/src/id.ts index 1f9130ea3..7f547f1fe 100644 --- a/packages/sdk/src/id.ts +++ b/packages/sdk/src/id.ts @@ -132,6 +132,11 @@ export const makeDefaultChannelStreamId = (spaceContractAddressOrId: string): st return makeStreamId(StreamPrefix.Channel, spaceContractAddressOrId + '0'.repeat(22)) } +export const spaceIdFromChannelId = (channelId: string): string => { + check(isChannelStreamId(channelId), 'Invalid channel id: ' + channelId) + return makeStreamId(StreamPrefix.Space, channelId.slice(2, 42) + '0'.repeat(22)) +} + export const isDefaultChannelId = (streamId: string): boolean => { const prefix = streamId.slice(0, 2) as StreamPrefix if (prefix !== StreamPrefix.Channel) {