Skip to content

Commit

Permalink
fix: updated some generics for groups
Browse files Browse the repository at this point in the history
Update generics for groups and client creation
  • Loading branch information
Alex Risch authored and Alex Risch committed Feb 13, 2024
1 parent 8282ee2 commit f924131
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ export async function sendMessageToGroup(
)
}

export async function groupMessages(
client: Client<any>,
export async function groupMessages<
ContentTypes extends DefaultContentTypes = DefaultContentTypes,
>(
client: Client<ContentTypes>,
id: string
): Promise<DecodedMessage[]> {
): Promise<DecodedMessage<ContentTypes>[]> {
const messages = await XMTPModule.groupMessages(client.address, id)
return messages.map((json: string) => {
return DecodedMessage.from(json, client)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ export class Client<
>(
wallet: Signer | WalletClient | null,
opts?: Partial<ClientOptions> & { codecs?: ContentCodecs }
): Promise<Client<DefaultContentTypes>> {
): Promise<Client<ContentCodecs>> {
const options = defaultOptions(opts)
const { enableSubscription, createSubscription } =
this.setupSubscriptions(options)
const signer = getSigner(wallet)
if (!signer) {
throw new Error('Signer is not configured')
}
return new Promise<Client<DefaultContentTypes>>((resolve, reject) => {
return new Promise<Client<ContentCodecs>>((resolve, reject) => {
;(async () => {
this.signSubscription = XMTPModule.emitter.addListener(
'sign',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Group<
}
}

async messages(): Promise<DecodedMessage[]> {
async messages(): Promise<DecodedMessage<ContentTypes>[]> {
return await XMTP.groupMessages(this.client, this.id)
}

Expand Down

0 comments on commit f924131

Please sign in to comment.