From dd38916a96e1ed7b6bb50d5866d515339274972b Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Wed, 6 Nov 2024 10:14:58 -0600 Subject: [PATCH 1/7] Add stream callback test --- sdks/node-sdk/test/Conversation.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdks/node-sdk/test/Conversation.test.ts b/sdks/node-sdk/test/Conversation.test.ts index b2aced232..b8d628ef8 100644 --- a/sdks/node-sdk/test/Conversation.test.ts +++ b/sdks/node-sdk/test/Conversation.test.ts @@ -320,7 +320,11 @@ describe("Conversation", () => { expect(conversation2.length).toBe(1); expect(conversation2[0].id).toBe(conversation.id); - const stream = conversation2[0].stream(); + const streamedMessages: string[] = []; + const stream = conversation2[0].stream((_, message) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + streamedMessages.push(message.content); + }); await conversation.send("gm"); await conversation.send("gm2"); @@ -337,6 +341,8 @@ describe("Conversation", () => { break; } } + + expect(streamedMessages).toEqual(["gm", "gm2"]); }); it("should add and remove admins", async () => { From 9d596aca0b24185703be573b4714b31c932c3c5c Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Wed, 6 Nov 2024 16:38:31 -0600 Subject: [PATCH 2/7] Upgrade node bindings --- sdks/node-sdk/package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sdks/node-sdk/package.json b/sdks/node-sdk/package.json index cf6363efb..a5895f32d 100644 --- a/sdks/node-sdk/package.json +++ b/sdks/node-sdk/package.json @@ -52,7 +52,7 @@ "@xmtp/content-type-group-updated": "^1.0.0", "@xmtp/content-type-primitives": "^1.0.2", "@xmtp/content-type-text": "^1.0.0", - "@xmtp/node-bindings": "^0.0.16", + "@xmtp/node-bindings": "^0.0.17", "@xmtp/proto": "^3.62.1" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index b62dfcb22..28da8a6aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4832,10 +4832,10 @@ __metadata: languageName: unknown linkType: soft -"@xmtp/node-bindings@npm:^0.0.16": - version: 0.0.16 - resolution: "@xmtp/node-bindings@npm:0.0.16" - checksum: 10/d6bf406c0e2802061a1d5808dac17fc7c0bcf01b1d3917805832e38fa5a69ccfdb0b0283fe47da2e9c302214cf693271207c466d061f8a7096b86edf7fa12c8e +"@xmtp/node-bindings@npm:^0.0.17": + version: 0.0.17 + resolution: "@xmtp/node-bindings@npm:0.0.17" + checksum: 10/2f461623966ba04dfcf7710f5229f762a9bffceedbc01474d58eb7bbb1f2f138e0e2891eadef416fb03f9fcfa3d32edadf050e007656b64f1cd9da1989c5ee9d languageName: node linkType: hard @@ -4850,7 +4850,7 @@ __metadata: "@xmtp/content-type-group-updated": "npm:^1.0.0" "@xmtp/content-type-primitives": "npm:^1.0.2" "@xmtp/content-type-text": "npm:^1.0.0" - "@xmtp/node-bindings": "npm:^0.0.16" + "@xmtp/node-bindings": "npm:^0.0.17" "@xmtp/proto": "npm:^3.62.1" "@xmtp/xmtp-js": "workspace:^" fast-glob: "npm:^3.3.2" From 6c42c3dd6943607cc689a3b40e2deb8c8c847bd6 Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Wed, 6 Nov 2024 16:38:57 -0600 Subject: [PATCH 3/7] Refactor AsyncStream types --- sdks/node-sdk/src/AsyncStream.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sdks/node-sdk/src/AsyncStream.ts b/sdks/node-sdk/src/AsyncStream.ts index e0f488299..70e929b94 100644 --- a/sdks/node-sdk/src/AsyncStream.ts +++ b/sdks/node-sdk/src/AsyncStream.ts @@ -5,12 +5,15 @@ type ResolveValue = { type ResolveNext = (resolveValue: ResolveValue) => void; -export type StreamCallback = (err: Error | null, value: T) => void; +export type StreamCallback = ( + err: Error | null, + value: T | undefined, +) => void; export class AsyncStream { #done = false; #resolveNext: ResolveNext | null; - #queue: T[]; + #queue: (T | undefined)[]; onReturn: (() => void) | undefined = undefined; @@ -62,7 +65,7 @@ export class AsyncStream { } }; - return = (value: T) => { + return = (value: T | undefined) => { this.#done = true; this.onReturn?.(); return Promise.resolve({ From 5f99c83ec956f7489a2e3c7e2f09f7326f276643 Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Wed, 6 Nov 2024 16:41:20 -0600 Subject: [PATCH 4/7] Refactor code to match new type exports --- sdks/node-sdk/src/Client.ts | 28 ++++++++++++++-------------- sdks/node-sdk/src/Conversation.ts | 14 +++++++------- sdks/node-sdk/src/Conversations.ts | 20 +++++++++----------- sdks/node-sdk/src/DecodedMessage.ts | 18 +++++++++--------- 4 files changed, 39 insertions(+), 41 deletions(-) diff --git a/sdks/node-sdk/src/Client.ts b/sdks/node-sdk/src/Client.ts index dde05fda0..4eb9214df 100644 --- a/sdks/node-sdk/src/Client.ts +++ b/sdks/node-sdk/src/Client.ts @@ -14,12 +14,12 @@ import { createClient, generateInboxId, getInboxIdForAddress, - NapiGroupMessageKind, - type NapiClient, - type NapiConsent, - type NapiConsentEntityType, - type NapiMessage, - type NapiSignatureRequestType, + GroupMessageKind, + type Consent, + type ConsentEntityType, + type Message, + type Client as NodeClient, + type SignatureRequestType, } from "@xmtp/node-bindings"; import { Conversations } from "@/Conversations"; @@ -84,11 +84,11 @@ export type ClientOptions = NetworkOptions & OtherOptions; export class Client { - #innerClient: NapiClient; + #innerClient: NodeClient; #conversations: Conversations; #codecs: Map; - constructor(client: NapiClient, codecs: ContentCodec[]) { + constructor(client: NodeClient, codecs: ContentCodec[]) { this.#innerClient = client; this.#conversations = new Conversations(this, client.conversations()); this.#codecs = new Map( @@ -186,7 +186,7 @@ export class Client { } addSignature( - signatureType: NapiSignatureRequestType, + signatureType: SignatureRequestType, signatureBytes: Uint8Array, ) { void this.#innerClient.addSignature(signatureType, signatureBytes); @@ -221,7 +221,7 @@ export class Client { return encoded; } - decodeContent(message: NapiMessage, contentType: ContentTypeId) { + decodeContent(message: Message, contentType: ContentTypeId) { const codec = this.codecFor(contentType); if (!codec) { throw new Error(`no codec for ${contentType.toString()}`); @@ -230,7 +230,7 @@ export class Client { // throw an error if there's an invalid group membership change message if ( contentType.sameAs(ContentTypeGroupUpdated) && - message.kind !== NapiGroupMessageKind.MembershipChange + message.kind !== GroupMessageKind.MembershipChange ) { throw new Error("Error decoding group membership change"); } @@ -240,7 +240,7 @@ export class Client { } async requestHistorySync() { - return this.#innerClient.requestHistorySync(); + return this.#innerClient.sendHistorySyncRequest(); } async getInboxIdByAddress(accountAddress: string) { @@ -265,11 +265,11 @@ export class Client { ); } - async setConsentStates(consentStates: NapiConsent[]) { + async setConsentStates(consentStates: Consent[]) { return this.#innerClient.setConsentStates(consentStates); } - async getConsentState(entityType: NapiConsentEntityType, entity: string) { + async getConsentState(entityType: ConsentEntityType, entity: string) { return this.#innerClient.getConsentState(entityType, entity); } } diff --git a/sdks/node-sdk/src/Conversation.ts b/sdks/node-sdk/src/Conversation.ts index f5d8715bc..8a68ec9da 100644 --- a/sdks/node-sdk/src/Conversation.ts +++ b/sdks/node-sdk/src/Conversation.ts @@ -1,9 +1,9 @@ import type { ContentTypeId } from "@xmtp/content-type-primitives"; import { ContentTypeText } from "@xmtp/content-type-text"; import type { - NapiConsentState, - NapiGroup, - NapiListMessagesOptions, + ConsentState, + Conversation as Group, + ListMessagesOptions, } from "@xmtp/node-bindings"; import { AsyncStream, type StreamCallback } from "@/AsyncStream"; import type { Client } from "@/Client"; @@ -12,9 +12,9 @@ import { nsToDate } from "@/helpers/date"; export class Conversation { #client: Client; - #group: NapiGroup; + #group: Group; - constructor(client: Client, group: NapiGroup) { + constructor(client: Client, group: Group) { this.#client = client; this.#group = group; } @@ -192,7 +192,7 @@ export class Conversation { return this.#group.send(encodedContent); } - messages(options?: NapiListMessagesOptions): DecodedMessage[] { + messages(options?: ListMessagesOptions): DecodedMessage[] { return ( this.#group .findMessages(options) @@ -206,7 +206,7 @@ export class Conversation { return this.#group.consentState(); } - updateConsentState(consentState: NapiConsentState) { + updateConsentState(consentState: ConsentState) { this.#group.updateConsentState(consentState); } diff --git a/sdks/node-sdk/src/Conversations.ts b/sdks/node-sdk/src/Conversations.ts index 295e9a87b..9078b8435 100644 --- a/sdks/node-sdk/src/Conversations.ts +++ b/sdks/node-sdk/src/Conversations.ts @@ -1,7 +1,7 @@ import type { - NapiConversations, - NapiCreateGroupOptions, - NapiListConversationsOptions, + CreateGroupOptions, + ListConversationsOptions, + Conversations as NodeConversations, } from "@xmtp/node-bindings"; import { AsyncStream, type StreamCallback } from "@/AsyncStream"; import type { Client } from "@/Client"; @@ -10,9 +10,9 @@ import { DecodedMessage } from "@/DecodedMessage"; export class Conversations { #client: Client; - #conversations: NapiConversations; + #conversations: NodeConversations; - constructor(client: Client, conversations: NapiConversations) { + constructor(client: Client, conversations: NodeConversations) { this.#client = client; this.#conversations = conversations; } @@ -49,7 +49,7 @@ export class Conversations { async newConversation( accountAddresses: string[], - options?: NapiCreateGroupOptions, + options?: CreateGroupOptions, ) { const group = await this.#conversations.createGroup( accountAddresses, @@ -65,7 +65,7 @@ export class Conversations { return conversation; } - async list(options?: NapiListConversationsOptions) { + async list(options?: ListConversationsOptions) { const groups = await this.#conversations.list(options); return groups.map((group) => { const conversation = new Conversation(this.#client, group); @@ -74,7 +74,7 @@ export class Conversations { } async listGroups( - options?: Omit, + options?: Omit, ) { const groups = await this.#conversations.listGroups(options); return groups.map((group) => { @@ -83,9 +83,7 @@ export class Conversations { }); } - async listDms( - options?: Omit, - ) { + async listDms(options?: Omit) { const groups = await this.#conversations.listDms(options); return groups.map((group) => { const conversation = new Conversation(this.#client, group); diff --git a/sdks/node-sdk/src/DecodedMessage.ts b/sdks/node-sdk/src/DecodedMessage.ts index c5cdb7905..fa1acc834 100644 --- a/sdks/node-sdk/src/DecodedMessage.ts +++ b/sdks/node-sdk/src/DecodedMessage.ts @@ -1,8 +1,8 @@ import { ContentTypeId } from "@xmtp/content-type-primitives"; import { - NapiDeliveryStatus, - NapiGroupMessageKind, - type NapiMessage, + DeliveryStatus, + GroupMessageKind, + type Message, } from "@xmtp/node-bindings"; import type { Client } from "@/Client"; import { nsToDate } from "@/helpers/date"; @@ -25,7 +25,7 @@ export class DecodedMessage { sentAt: Date; sentAtNs: number; - constructor(client: Client, message: NapiMessage) { + constructor(client: Client, message: Message) { this.#client = client; this.id = message.id; this.sentAtNs = message.sentAtNs; @@ -34,23 +34,23 @@ export class DecodedMessage { this.senderInboxId = message.senderInboxId; switch (message.kind) { - case NapiGroupMessageKind.Application: + case GroupMessageKind.Application: this.kind = "application"; break; - case NapiGroupMessageKind.MembershipChange: + case GroupMessageKind.MembershipChange: this.kind = "membership_change"; break; // no default } switch (message.deliveryStatus) { - case NapiDeliveryStatus.Unpublished: + case DeliveryStatus.Unpublished: this.deliveryStatus = "unpublished"; break; - case NapiDeliveryStatus.Published: + case DeliveryStatus.Published: this.deliveryStatus = "published"; break; - case NapiDeliveryStatus.Failed: + case DeliveryStatus.Failed: this.deliveryStatus = "failed"; break; // no default From a241007bdaa55a70ef8227695add189752b8bec2 Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Wed, 6 Nov 2024 16:41:51 -0600 Subject: [PATCH 5/7] Fix streaming callback when there's an error --- sdks/node-sdk/src/Conversation.ts | 10 ++++--- sdks/node-sdk/src/Conversations.ts | 44 ++++++++++++++++++------------ 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/sdks/node-sdk/src/Conversation.ts b/sdks/node-sdk/src/Conversation.ts index 8a68ec9da..4d5b1e2fc 100644 --- a/sdks/node-sdk/src/Conversation.ts +++ b/sdks/node-sdk/src/Conversation.ts @@ -113,10 +113,12 @@ export class Conversation { stream(callback?: StreamCallback) { const asyncStream = new AsyncStream(); - const stream = this.#group.stream((err, message) => { - const decodedMessage = new DecodedMessage(this.#client, message); - asyncStream.callback(err, decodedMessage); - callback?.(err, decodedMessage); + const stream = this.#group.stream((error, value) => { + const message = value + ? new DecodedMessage(this.#client, value) + : undefined; + asyncStream.callback(error, message); + callback?.(error, message); }); asyncStream.onReturn = stream.end.bind(stream); diff --git a/sdks/node-sdk/src/Conversations.ts b/sdks/node-sdk/src/Conversations.ts index 9078b8435..6312cd332 100644 --- a/sdks/node-sdk/src/Conversations.ts +++ b/sdks/node-sdk/src/Conversations.ts @@ -98,8 +98,10 @@ export class Conversations { stream(callback?: StreamCallback) { const asyncStream = new AsyncStream(); - const stream = this.#conversations.stream((err, group) => { - const conversation = new Conversation(this.#client, group); + const stream = this.#conversations.stream((err, value) => { + const conversation = value + ? new Conversation(this.#client, value) + : undefined; asyncStream.callback(err, conversation); callback?.(err, conversation); }); @@ -112,8 +114,10 @@ export class Conversations { streamGroups(callback?: StreamCallback) { const asyncStream = new AsyncStream(); - const stream = this.#conversations.streamGroups((err, group) => { - const conversation = new Conversation(this.#client, group); + const stream = this.#conversations.streamGroups((err, value) => { + const conversation = value + ? new Conversation(this.#client, value) + : undefined; asyncStream.callback(err, conversation); callback?.(err, conversation); }); @@ -126,8 +130,10 @@ export class Conversations { streamDms(callback?: StreamCallback) { const asyncStream = new AsyncStream(); - const stream = this.#conversations.streamDms((err, group) => { - const conversation = new Conversation(this.#client, group); + const stream = this.#conversations.streamDms((err, value) => { + const conversation = value + ? new Conversation(this.#client, value) + : undefined; asyncStream.callback(err, conversation); callback?.(err, conversation); }); @@ -143,8 +149,10 @@ export class Conversations { const asyncStream = new AsyncStream(); - const stream = this.#conversations.streamAllMessages((err, message) => { - const decodedMessage = new DecodedMessage(this.#client, message); + const stream = this.#conversations.streamAllMessages((err, value) => { + const decodedMessage = value + ? new DecodedMessage(this.#client, value) + : undefined; asyncStream.callback(err, decodedMessage); callback?.(err, decodedMessage); }); @@ -160,13 +168,13 @@ export class Conversations { const asyncStream = new AsyncStream(); - const stream = this.#conversations.streamAllGroupMessages( - (err, message) => { - const decodedMessage = new DecodedMessage(this.#client, message); - asyncStream.callback(err, decodedMessage); - callback?.(err, decodedMessage); - }, - ); + const stream = this.#conversations.streamAllGroupMessages((err, value) => { + const decodedMessage = value + ? new DecodedMessage(this.#client, value) + : undefined; + asyncStream.callback(err, decodedMessage); + callback?.(err, decodedMessage); + }); asyncStream.onReturn = stream.end.bind(stream); @@ -179,8 +187,10 @@ export class Conversations { const asyncStream = new AsyncStream(); - const stream = this.#conversations.streamAllDmMessages((err, message) => { - const decodedMessage = new DecodedMessage(this.#client, message); + const stream = this.#conversations.streamAllDmMessages((err, value) => { + const decodedMessage = value + ? new DecodedMessage(this.#client, value) + : undefined; asyncStream.callback(err, decodedMessage); callback?.(err, decodedMessage); }); From 03ee42e58f9050f9e7e03b83b4234db067db6de3 Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Wed, 6 Nov 2024 16:43:29 -0600 Subject: [PATCH 6/7] Refactor tests with new type naming --- sdks/node-sdk/test/Client.test.ts | 47 ++++++++++-------------- sdks/node-sdk/test/Conversation.test.ts | 12 +++--- sdks/node-sdk/test/Conversations.test.ts | 15 +++----- sdks/node-sdk/test/helpers.ts | 4 +- 4 files changed, 33 insertions(+), 45 deletions(-) diff --git a/sdks/node-sdk/test/Client.test.ts b/sdks/node-sdk/test/Client.test.ts index aadb98b05..bee24fcf4 100644 --- a/sdks/node-sdk/test/Client.test.ts +++ b/sdks/node-sdk/test/Client.test.ts @@ -1,7 +1,7 @@ import { - NapiConsentEntityType, - NapiConsentState, - NapiSignatureRequestType, + ConsentEntityType, + ConsentState, + SignatureRequestType, } from "@xmtp/node-bindings"; import { v4 } from "uuid"; import { toBytes } from "viem"; @@ -116,11 +116,8 @@ describe("Client", () => { message: signatureText!, }); - client.addSignature(NapiSignatureRequestType.AddWallet, toBytes(signature)); - client.addSignature( - NapiSignatureRequestType.AddWallet, - toBytes(signature2), - ); + client.addSignature(SignatureRequestType.AddWallet, toBytes(signature)); + client.addSignature(SignatureRequestType.AddWallet, toBytes(signature2)); await client.applySignatures(); const inboxState = await client.inboxState(); expect(inboxState.accountAddresses.length).toEqual(2); @@ -150,11 +147,8 @@ describe("Client", () => { message: signatureText!, }); - client.addSignature(NapiSignatureRequestType.AddWallet, toBytes(signature)); - client.addSignature( - NapiSignatureRequestType.AddWallet, - toBytes(signature2), - ); + client.addSignature(SignatureRequestType.AddWallet, toBytes(signature)); + client.addSignature(SignatureRequestType.AddWallet, toBytes(signature2)); await client.applySignatures(); const signatureText2 = await client.revokeWalletSignatureText( @@ -167,10 +161,7 @@ describe("Client", () => { message: signatureText2!, }); - client.addSignature( - NapiSignatureRequestType.RevokeWallet, - toBytes(signature3), - ); + client.addSignature(SignatureRequestType.RevokeWallet, toBytes(signature3)); await client.applySignatures(); const inboxState = await client.inboxState(); expect(inboxState.accountAddresses).toEqual([ @@ -204,7 +195,7 @@ describe("Client", () => { }); client3.addSignature( - NapiSignatureRequestType.RevokeInstallations, + SignatureRequestType.RevokeInstallations, toBytes(signature), ); await client3.applySignatures(); @@ -229,27 +220,27 @@ describe("Client", () => { expect(group2).not.toBeNull(); expect( - await client2.getConsentState(NapiConsentEntityType.GroupId, group2!.id), - ).toBe(NapiConsentState.Unknown); + await client2.getConsentState(ConsentEntityType.GroupId, group2!.id), + ).toBe(ConsentState.Unknown); await client2.setConsentStates([ { - entityType: NapiConsentEntityType.GroupId, + entityType: ConsentEntityType.GroupId, entity: group2!.id, - state: NapiConsentState.Allowed, + state: ConsentState.Allowed, }, ]); expect( - await client2.getConsentState(NapiConsentEntityType.GroupId, group2!.id), - ).toBe(NapiConsentState.Allowed); + await client2.getConsentState(ConsentEntityType.GroupId, group2!.id), + ).toBe(ConsentState.Allowed); - expect(group2!.consentState).toBe(NapiConsentState.Allowed); + expect(group2!.consentState).toBe(ConsentState.Allowed); - group2!.updateConsentState(NapiConsentState.Denied); + group2!.updateConsentState(ConsentState.Denied); expect( - await client2.getConsentState(NapiConsentEntityType.GroupId, group2!.id), - ).toBe(NapiConsentState.Denied); + await client2.getConsentState(ConsentEntityType.GroupId, group2!.id), + ).toBe(ConsentState.Denied); }); }); diff --git a/sdks/node-sdk/test/Conversation.test.ts b/sdks/node-sdk/test/Conversation.test.ts index b8d628ef8..0002e2319 100644 --- a/sdks/node-sdk/test/Conversation.test.ts +++ b/sdks/node-sdk/test/Conversation.test.ts @@ -1,4 +1,4 @@ -import { NapiConsentState } from "@xmtp/node-bindings"; +import { ConsentState } from "@xmtp/node-bindings"; import { describe, expect, it } from "vitest"; import { ContentTypeTest, @@ -323,7 +323,7 @@ describe("Conversation", () => { const streamedMessages: string[] = []; const stream = conversation2[0].stream((_, message) => { // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - streamedMessages.push(message.content); + streamedMessages.push(message!.content); }); await conversation.send("gm"); @@ -414,15 +414,15 @@ describe("Conversation", () => { await client2.conversations.sync(); const group2 = client2.conversations.getConversationById(group.id); expect(group2).toBeDefined(); - expect(group2!.consentState).toBe(NapiConsentState.Unknown); + expect(group2!.consentState).toBe(ConsentState.Unknown); await group2!.send("gm!"); - expect(group2!.consentState).toBe(NapiConsentState.Allowed); + expect(group2!.consentState).toBe(ConsentState.Allowed); await client3.conversations.sync(); const dmGroup2 = client3.conversations.getConversationById(dmGroup.id); expect(dmGroup2).toBeDefined(); - expect(dmGroup2!.consentState).toBe(NapiConsentState.Unknown); + expect(dmGroup2!.consentState).toBe(ConsentState.Unknown); await dmGroup2!.send("gm!"); - expect(dmGroup2!.consentState).toBe(NapiConsentState.Allowed); + expect(dmGroup2!.consentState).toBe(ConsentState.Allowed); }); }); diff --git a/sdks/node-sdk/test/Conversations.test.ts b/sdks/node-sdk/test/Conversations.test.ts index b041d8bd7..a6dc93df7 100644 --- a/sdks/node-sdk/test/Conversations.test.ts +++ b/sdks/node-sdk/test/Conversations.test.ts @@ -1,7 +1,4 @@ -import { - NapiConsentState, - NapiGroupPermissionsOptions, -} from "@xmtp/node-bindings"; +import { ConsentState, GroupPermissionsOptions } from "@xmtp/node-bindings"; import { describe, expect, it } from "vitest"; import { createRegisteredClient, createUser } from "@test/helpers"; @@ -33,7 +30,7 @@ describe("Conversations", () => { expect(conversation.isActive).toBe(true); expect(conversation.name).toBe(""); expect(conversation.permissions.policyType).toBe( - NapiGroupPermissionsOptions.AllMembers, + GroupPermissionsOptions.AllMembers, ); expect(conversation.permissions.policySet).toEqual({ addMemberPolicy: 0, @@ -87,7 +84,7 @@ describe("Conversations", () => { expect(group.isActive).toBe(true); expect(group.name).toBe(""); expect(group.permissions.policyType).toBe( - NapiGroupPermissionsOptions.CustomPolicy, + GroupPermissionsOptions.CustomPolicy, ); expect(group.permissions.policySet).toEqual({ addAdminPolicy: 1, @@ -109,7 +106,7 @@ describe("Conversations", () => { expect(group.metadata.conversationType).toBe("dm"); expect(group.metadata.creatorInboxId).toBe(client1.inboxId); - expect(group.consentState).toBe(NapiConsentState.Allowed); + expect(group.consentState).toBe(ConsentState.Allowed); const group1 = await client1.conversations.list(); expect(group1.length).toBe(1); @@ -214,14 +211,14 @@ describe("Conversations", () => { const groupWithPermissions = await client1.conversations.newConversation( [user4.account.address], { - permissions: NapiGroupPermissionsOptions.AdminOnly, + permissions: GroupPermissionsOptions.AdminOnly, }, ); expect(groupWithPermissions).toBeDefined(); expect(groupWithPermissions.name).toBe(""); expect(groupWithPermissions.imageUrl).toBe(""); expect(groupWithPermissions.permissions.policyType).toBe( - NapiGroupPermissionsOptions.AdminOnly, + GroupPermissionsOptions.AdminOnly, ); expect(groupWithPermissions.permissions.policySet).toEqual({ diff --git a/sdks/node-sdk/test/helpers.ts b/sdks/node-sdk/test/helpers.ts index fb55a1986..4b306a5ce 100644 --- a/sdks/node-sdk/test/helpers.ts +++ b/sdks/node-sdk/test/helpers.ts @@ -5,7 +5,7 @@ import { type ContentCodec, type EncodedContent, } from "@xmtp/content-type-primitives"; -import { NapiSignatureRequestType } from "@xmtp/node-bindings"; +import { SignatureRequestType } from "@xmtp/node-bindings"; import { v4 } from "uuid"; import { createWalletClient, http, toBytes } from "viem"; import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; @@ -61,7 +61,7 @@ export const createRegisteredClient = async ( if (!client.isRegistered) { const signature = await getSignature(client, user); if (signature) { - client.addSignature(NapiSignatureRequestType.CreateInbox, signature); + client.addSignature(SignatureRequestType.CreateInbox, signature); } await client.registerIdentity(); } From 5a41542b8d7ebbef72259c7d05fa939b0b3b660c Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Wed, 6 Nov 2024 16:51:53 -0600 Subject: [PATCH 7/7] Create metal-boxes-marry.md --- .changeset/metal-boxes-marry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/metal-boxes-marry.md diff --git a/.changeset/metal-boxes-marry.md b/.changeset/metal-boxes-marry.md new file mode 100644 index 000000000..9f24f05d9 --- /dev/null +++ b/.changeset/metal-boxes-marry.md @@ -0,0 +1,5 @@ +--- +"@xmtp/node-sdk": patch +--- + +Upgrade node bindings