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

Upgrade dependencies #644

Merged
merged 12 commits into from
Jul 16, 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
8 changes: 0 additions & 8 deletions .changeset/README.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/fresh-poems-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@xmtp/xmtp-js": patch
"@xmtp/mls-client": patch
---

Upgrade dependencies
2 changes: 1 addition & 1 deletion .github/workflows/noop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

pull_request:
paths:
- '.changeset/**'
- '.changeset/config.json'
- '.github/**'
- '!.github/workflows/js-sdk.yml'
- '!.github/workflows/mls-client.yml'
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
CODEOWNERS
.yarn
.changeset/**/*.md
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@changesets/cli": "^2.27.7"
},
"devDependencies": {
"prettier": "^3.3.2",
"prettier-plugin-packagejson": "^2.5.0",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.5.1",
"turbo": "^2.0.6"
},
"packageManager": "[email protected]",
Expand Down
30 changes: 15 additions & 15 deletions packages/js-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,52 +101,52 @@
"@xmtp/consent-proof-signature": "^0.1.3",
"@xmtp/content-type-primitives": "^1.0.1",
"@xmtp/content-type-text": "^1.0.0",
"@xmtp/proto": "3.54.0",
"@xmtp/proto": "^3.62.1",
"@xmtp/user-preferences-bindings-wasm": "^0.3.6",
"async-mutex": "^0.5.0",
"elliptic": "^6.5.4",
"elliptic": "^6.5.5",
"long": "^5.2.3",
"viem": "2.7.15"
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.3.0",
"@metamask/providers": "^14.0.2",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@metamask/providers": "^17.1.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/benchmark": "^2.1.5",
"@types/bl": "^5.1.0",
"@types/callback-to-async-iterator": "^1.1.7",
"@types/elliptic": "^6.4.18",
"@types/node": "^20.14.9",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@vitest/coverage-v8": "^1.6.0",
"@types/node": "^20.14.10",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@vitest/coverage-v8": "^2.0.3",
"@xmtp/rollup-plugin-resolve-extensions": "1.0.1",
"benny": "^3.7.1",
"dd-trace": "5.5.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.5.0",
"eslint-plugin-jsdoc": "^48.7.0",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.4.0",
"ethers": "^5.7.2",
"happy-dom": "^14.12.3",
"prettier": "^3.3.2",
"prettier-plugin-packagejson": "^2.5.0",
"rollup": "^4.18.0",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.5.1",
"rollup": "^4.18.1",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-tsconfig-paths": "^1.5.2",
"typedoc": "^0.26.3",
"typedoc": "^0.26.4",
"typescript": "^5.5.3",
"vite": "5.3.3",
"vite": "5.3.4",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
"vitest": "^2.0.3"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
2 changes: 2 additions & 0 deletions packages/js-sdk/src/Contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ export class ConsentList {
: undefined,
allowGroup: undefined,
denyGroup: undefined,
allowInboxId: undefined,
denyInboxId: undefined,
}
return result.concat(
privatePreferences.PrivatePreferencesAction.encode(action).finish()
Expand Down
24 changes: 12 additions & 12 deletions packages/mls-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@
"dependencies": {
"@xmtp/content-type-primitives": "^1.0.1",
"@xmtp/content-type-text": "^1.0.0",
"@xmtp/mls-client-bindings-node": "^0.0.8",
"@xmtp/proto": "^3.61.1"
"@xmtp/mls-client-bindings-node": "^0.0.9",
"@xmtp/proto": "^3.62.1"
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.3.0",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.14.9",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@vitest/coverage-v8": "^1.6.0",
"@types/node": "^20.14.10",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@vitest/coverage-v8": "^2.0.3",
"@xmtp/xmtp-js": "workspace:^",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -75,17 +75,17 @@
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.4.0",
"fast-glob": "^3.3.2",
"prettier": "^3.3.2",
"prettier-plugin-packagejson": "^2.5.0",
"rollup": "^4.18.0",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.5.1",
"rollup": "^4.18.1",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-tsconfig-paths": "^1.5.2",
"typescript": "^5.5.3",
"viem": "^2.13.6",
"vite": "5.3.3",
"vite": "5.3.4",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
"vitest": "^2.0.3"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
28 changes: 28 additions & 0 deletions packages/mls-client/src/Conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ export class Conversation {
return this.#group.updateGroupDescription(description)
}

get pinnedFrameUrl() {
return this.#group.groupPinnedFrameUrl()
}

async updatePinnedFrameUrl(pinnedFrameUrl: string) {
return this.#group.updateGroupPinnedFrameUrl(pinnedFrameUrl)
}

get isActive() {
return this.#group.isActive()
}
Expand Down Expand Up @@ -85,6 +93,7 @@ export class Conversation {
get permissions() {
return {
policyType: this.#group.groupPermissions().policyType(),
policySet: this.#group.groupPermissions().policySet(),
}
}

Expand Down Expand Up @@ -146,6 +155,25 @@ export class Conversation {
return this.#group.removeSuperAdmin(inboxId)
}

async publishMessages() {
return this.#group.publishMessages()
}

sendOptimistic(content: any, contentType?: ContentTypeId) {
if (typeof content !== 'string' && !contentType) {
throw new Error(
'Content type is required when sending content other than text'
)
}

const encodedContent =
typeof content === 'string'
? this.#client.encodeContent(content, contentType ?? ContentTypeText)
: this.#client.encodeContent(content, contentType!)

return this.#group.sendOptimistic(encodedContent)
}

async send(content: any, contentType?: ContentTypeId) {
if (typeof content !== 'string' && !contentType) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion packages/mls-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export {
GroupUpdatedCodec,
} from './codecs/GroupUpdatedCodec'
export type { StreamCallback } from './AsyncStream'
export { GroupPermissions } from '@xmtp/mls-client-bindings-node'
export type * from '@xmtp/mls-client-bindings-node'
81 changes: 81 additions & 0 deletions packages/mls-client/test/Conversation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,32 @@ describe('Conversation', () => {
expect(conversation2.messages().length).toBe(1)
})

it('should update conversation pinned frame URL', async () => {
const user1 = createUser()
const user2 = createUser()
const client1 = await createRegisteredClient(user1)
const client2 = await createRegisteredClient(user2)
const conversation = await client1.conversations.newConversation([
user2.account.address,
])
const pinnedFrameUrl = 'https://foo/bar'
await conversation.updatePinnedFrameUrl(pinnedFrameUrl)
expect(conversation.pinnedFrameUrl).toBe(pinnedFrameUrl)
const messages = conversation.messages()
expect(messages.length).toBe(2)

await client2.conversations.sync()
const conversations = await client2.conversations.list()
expect(conversations.length).toBe(1)

const conversation2 = conversations[0]
expect(conversation2).toBeDefined()
await conversation2.sync()
expect(conversation2.id).toBe(conversation.id)
expect(conversation2.pinnedFrameUrl).toBe(pinnedFrameUrl)
expect(conversation2.messages().length).toBe(1)
})

it('should add and remove members', async () => {
const user1 = createUser()
const user2 = createUser()
Expand Down Expand Up @@ -199,6 +225,61 @@ describe('Conversation', () => {
).resolves.not.toThrow()
})

it('should optimistically send and list messages', async () => {
const user1 = createUser()
const user2 = createUser()
const client1 = await createRegisteredClient(user1)
const client2 = await createRegisteredClient(user2)
const conversation = await client1.conversations.newConversation([
user2.account.address,
])

const text = 'gm'
conversation.sendOptimistic(text)

const messages = conversation.messages()
expect(messages.length).toBe(2)
expect(messages[1].content).toBe(text)

await client2.conversations.sync()
const conversations = await client2.conversations.list()
expect(conversations.length).toBe(1)

const conversation2 = conversations[0]
expect(conversation2).toBeDefined()

await conversation2.sync()
expect(conversation2.id).toBe(conversation.id)

const messages2 = conversation2.messages()
expect(messages2.length).toBe(0)

await conversation.publishMessages()
await conversation2.sync()

const messages4 = conversation2.messages()
expect(messages4.length).toBe(1)
expect(messages4[0].content).toBe(text)
})

it('should require content type when optimistically sending non-string content', async () => {
const user1 = createUser()
const user2 = createUser()
const client1 = await createRegisteredClient(user1, {
codecs: [new TestCodec()],
})
await createRegisteredClient(user2)
const conversation = await client1.conversations.newConversation([
user2.account.address,
])

expect(() => conversation.sendOptimistic(1)).toThrow()
expect(() => conversation.sendOptimistic({ foo: 'bar' })).toThrow()
expect(() =>
conversation.sendOptimistic({ foo: 'bar' }, ContentTypeTest)
).not.toThrow()
})

it('should throw when sending content without a codec', async () => {
const user1 = createUser()
const user2 = createUser()
Expand Down
41 changes: 37 additions & 4 deletions packages/mls-client/test/Conversations.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GroupPermissions } from '@xmtp/mls-client-bindings-node'
import { NapiGroupPermissionsOptions } from '@xmtp/mls-client-bindings-node'
import { describe, expect, it } from 'vitest'
import { createRegisteredClient, createUser } from '@test/helpers'

Expand Down Expand Up @@ -28,8 +28,18 @@ describe('Conversations', () => {
expect(conversation.isActive).toBe(true)
expect(conversation.name).toBe('')
expect(conversation.permissions.policyType).toBe(
GroupPermissions.EveryoneIsAdmin
NapiGroupPermissionsOptions.AllMembers
)
expect(conversation.permissions.policySet).toEqual({
addMemberPolicy: 0,
removeMemberPolicy: 2,
addAdminPolicy: 3,
removeAdminPolicy: 3,
updateGroupNamePolicy: 0,
updateGroupDescriptionPolicy: 0,
updateGroupImageUrlSquarePolicy: 0,
updateGroupPinnedFrameUrlPolicy: 0,
})
expect(conversation.addedByInboxId).toBe(client1.inboxId)
expect(conversation.messages().length).toBe(1)
expect(conversation.members.length).toBe(2)
Expand Down Expand Up @@ -128,16 +138,27 @@ describe('Conversations', () => {
const groupWithPermissions = await client1.conversations.newConversation(
[user4.account.address],
{
permissions: GroupPermissions.GroupCreatorIsAdmin,
permissions: NapiGroupPermissionsOptions.AdminOnly,
}
)
expect(groupWithPermissions).toBeDefined()
expect(groupWithPermissions.name).toBe('')
expect(groupWithPermissions.imageUrl).toBe('')
expect(groupWithPermissions.permissions.policyType).toBe(
GroupPermissions.GroupCreatorIsAdmin
NapiGroupPermissionsOptions.AdminOnly
)

expect(groupWithPermissions.permissions.policySet).toEqual({
addMemberPolicy: 2,
removeMemberPolicy: 2,
addAdminPolicy: 3,
removeAdminPolicy: 3,
updateGroupNamePolicy: 2,
updateGroupDescriptionPolicy: 2,
updateGroupImageUrlSquarePolicy: 2,
updateGroupPinnedFrameUrlPolicy: 2,
})

const groupWithDescription = await client1.conversations.newConversation(
[user2.account.address],
{
Expand All @@ -148,6 +169,18 @@ describe('Conversations', () => {
expect(groupWithDescription.name).toBe('')
expect(groupWithDescription.imageUrl).toBe('')
expect(groupWithDescription.description).toBe('foo')

const groupWithPinnedFrameUrl = await client1.conversations.newConversation(
[user2.account.address],
{
groupPinnedFrameUrl: 'https://foo/bar',
}
)
expect(groupWithPinnedFrameUrl).toBeDefined()
expect(groupWithPinnedFrameUrl.name).toBe('')
expect(groupWithPinnedFrameUrl.imageUrl).toBe('')
expect(groupWithPinnedFrameUrl.description).toBe('')
expect(groupWithPinnedFrameUrl.pinnedFrameUrl).toBe('https://foo/bar')
})

it('should stream new conversations', async () => {
Expand Down
Loading