Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add production environment, update content types #627

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mean-emus-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@xmtp/mls-client": patch
---

Add production environment
1 change: 1 addition & 0 deletions packages/mls-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
},
"dependencies": {
"@xmtp/content-type-primitives": "^1.0.1",
"@xmtp/content-type-text": "^1.0.0",
"@xmtp/mls-client-bindings-node": "^0.0.4",
"@xmtp/proto": "^3.61.1"
},
Expand Down
13 changes: 7 additions & 6 deletions packages/mls-client/src/Client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { join } from 'node:path'
import process from 'node:process'
import type {
ContentCodec,
ContentTypeId,
EncodedContent,
} from '@xmtp/content-type-primitives'
import { TextCodec } from '@xmtp/content-type-text'
import {
createClient,
generateInboxId,
Expand All @@ -8,12 +14,6 @@ import {
type NapiClient,
type NapiMessage,
} from '@xmtp/mls-client-bindings-node'
import {
TextCodec,
type ContentCodec,
type ContentTypeId,
type EncodedContent,
} from '@xmtp/xmtp-js'
import {
ContentTypeGroupUpdated,
GroupUpdatedCodec,
Expand All @@ -23,6 +23,7 @@ import { Conversations } from '@/Conversations'
export const ApiUrls = {
local: 'http://localhost:5556',
dev: 'https://grpc.dev.xmtp.network:443',
production: 'https://grpc.production.xmtp.network:443',
} as const

export type XmtpEnv = keyof typeof ApiUrls
Expand Down
2 changes: 1 addition & 1 deletion packages/mls-client/src/Conversation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ContentTypeId } from '@xmtp/content-type-primitives'
import type {
NapiGroup,
NapiListMessagesOptions,
} from '@xmtp/mls-client-bindings-node'
import type { ContentTypeId } from '@xmtp/xmtp-js'
import { AsyncStream, type StreamCallback } from '@/AsyncStream'
import type { Client } from '@/Client'
import { DecodedMessage } from '@/DecodedMessage'
Expand Down
2 changes: 1 addition & 1 deletion packages/mls-client/src/DecodedMessage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ContentTypeId } from '@xmtp/content-type-primitives'
import {
NapiDeliveryStatus,
NapiGroupMessageKind,
type NapiMessage,
} from '@xmtp/mls-client-bindings-node'
import { ContentTypeId } from '@xmtp/xmtp-js'
import type { Client } from '@/Client'
import { nsToDate } from '@/helpers/date'

Expand Down
2 changes: 1 addition & 1 deletion packages/mls-client/test/Conversation.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContentTypeText } from '@xmtp/xmtp-js'
import { ContentTypeText } from '@xmtp/content-type-text'
import { describe, expect, it } from 'vitest'
import { createRegisteredClient, createUser } from '@test/helpers'

Expand Down
2 changes: 1 addition & 1 deletion packages/mls-client/test/Conversations.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContentTypeText } from '@xmtp/xmtp-js'
import { ContentTypeText } from '@xmtp/content-type-text'
import { describe, expect, it } from 'vitest'
import { createRegisteredClient, createUser } from '@test/helpers'

Expand Down
10 changes: 5 additions & 5 deletions packages/mls-client/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url'
import { createWalletClient, http, toBytes } from 'viem'
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
import { sepolia } from 'viem/chains'
import { Client } from '@/Client'
import { Client, type XmtpEnv } from '@/Client'

const __dirname = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -33,14 +33,14 @@ export const getSignature = async (client: Client, user: User) => {
return null
}

export const createClient = async (user: User) =>
export const createClient = async (user: User, env?: XmtpEnv) =>
Client.create(user.account.address, {
env: 'local',
env: env ?? 'local',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

dbPath: join(__dirname, `./test-${user.account.address}.db3`),
})

export const createRegisteredClient = async (user: User) => {
const client = await createClient(user)
export const createRegisteredClient = async (user: User, env?: XmtpEnv) => {
const client = await createClient(user, env)
if (!client.isRegistered) {
const signature = await getSignature(client, user)
if (signature) {
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2872,6 +2872,15 @@ __metadata:
languageName: node
linkType: hard

"@xmtp/content-type-text@npm:^1.0.0":
version: 1.0.0
resolution: "@xmtp/content-type-text@npm:1.0.0"
dependencies:
"@xmtp/content-type-primitives": "npm:^1.0.1"
checksum: 10/b195060ad5686a6ace2772d5208d535d1f5062820629764aec52cedf3f2630885b5913aea6d2f0186a49139845c20d2ded783c6bf998884f09374c07b183141f
languageName: node
linkType: hard

"@xmtp/mls-client-bindings-node@npm:^0.0.4":
version: 0.0.4
resolution: "@xmtp/mls-client-bindings-node@npm:0.0.4"
Expand All @@ -2891,6 +2900,7 @@ __metadata:
"@typescript-eslint/parser": "npm:^7.8.0"
"@vitest/coverage-v8": "npm:^1.6.0"
"@xmtp/content-type-primitives": "npm:^1.0.1"
"@xmtp/content-type-text": "npm:^1.0.0"
"@xmtp/mls-client-bindings-node": "npm:^0.0.4"
"@xmtp/proto": "npm:^3.61.1"
"@xmtp/xmtp-js": "workspace:^"
Expand Down
Loading