Skip to content

Commit

Permalink
Decouple content types from the JS SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Jun 14, 2024
1 parent 7c8b957 commit 965279f
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 266 deletions.
2 changes: 2 additions & 0 deletions packages/js-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
"dependencies": {
"@noble/secp256k1": "1.7.1",
"@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/user-preferences-bindings-wasm": "^0.3.6",
"async-mutex": "^0.5.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/js-sdk/src/Client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
ContentTypeId,
type ContentCodec,
type EncodedContent,
} from '@xmtp/content-type-primitives'
import { ContentTypeText, TextCodec } from '@xmtp/content-type-text'
import { messageApi, content as proto } from '@xmtp/proto'
import { getAddress, type WalletClient } from 'viem'
import KeystoreAuthenticator from '@/authn/KeystoreAuthenticator'
Expand Down Expand Up @@ -29,7 +35,6 @@ import HttpApiClient, {
type ApiClient,
type PublishParams,
} from './ApiClient'
import { ContentTypeText, TextCodec } from './codecs/Text'
import { compress, decompress } from './Compression'
import { decodeContactBundle, encodeContactBundle } from './ContactBundle'
import { Contacts } from './Contacts'
Expand All @@ -40,11 +45,6 @@ import { hasMetamaskWithSnaps } from './keystore/snapHelpers'
import type BackupClient from './message-backup/BackupClient'
import { BackupType } from './message-backup/BackupClient'
import { createBackupClient } from './message-backup/BackupClientFactory'
import {
ContentTypeId,
type ContentCodec,
type EncodedContent,
} from './MessageContent'
import { packageName, version } from './snapInfo.json'
import type { ExtractDecodedType } from './types/client'
import type { Signer } from './types/Signer'
Expand Down
2 changes: 1 addition & 1 deletion packages/js-sdk/src/Message.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ContentTypeId } from '@xmtp/content-type-primitives'
import { message as proto, type conversationReference } from '@xmtp/proto'
import Long from 'long'
import { PublicKey } from '@/crypto/PublicKey'
Expand All @@ -12,7 +13,6 @@ import Ciphertext from './crypto/Ciphertext'
import { sha256 } from './crypto/encryption'
import { bytesToHex } from './crypto/utils'
import type { KeystoreInterfaces } from './keystore/rpcDefinitions'
import type { ContentTypeId } from './MessageContent'
import { dateToNs, nsToDate } from './utils/date'
import { buildDecryptV1Request, getResultOrThrow } from './utils/keystore'

Expand Down
75 changes: 0 additions & 75 deletions packages/js-sdk/src/MessageContent.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/js-sdk/src/codecs/Composite.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { composite as proto } from '@xmtp/proto'
import {
ContentTypeId,
type CodecRegistry,
type ContentCodec,
type EncodedContent,
} from '@/MessageContent'
} from '@xmtp/content-type-primitives'
import { composite as proto } from '@xmtp/proto'

// xmtp.org/composite
//
Expand Down
50 changes: 0 additions & 50 deletions packages/js-sdk/src/codecs/Text.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/js-sdk/src/conversations/Conversation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ContentTypeText } from '@xmtp/content-type-text'
import {
message,
content as proto,
Expand All @@ -13,7 +14,6 @@ import type {
SendOptions,
} from '@/Client'
import type Client from '@/Client'
import { ContentTypeText } from '@/codecs/Text'
import type { ConsentState } from '@/Contacts'
import { sha256 } from '@/crypto/encryption'
import { SignedPublicKey } from '@/crypto/PublicKey'
Expand Down
7 changes: 0 additions & 7 deletions packages/js-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ export {
export type { Conversation } from '@/conversations/Conversation'
export { ConversationV1, ConversationV2 } from '@/conversations/Conversation'
export { default as Conversations } from '@/conversations/Conversations'
export type {
CodecRegistry,
ContentCodec,
EncodedContent,
} from './MessageContent'
export { ContentTypeId, ContentTypeFallback } from './MessageContent'
export { TextCodec, ContentTypeText } from './codecs/Text'
export type { Composite } from './codecs/Composite'
export { CompositeCodec, ContentTypeComposite } from './codecs/Composite'
export type {
Expand Down
2 changes: 1 addition & 1 deletion packages/js-sdk/src/types/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ContentCodec } from '@xmtp/content-type-primitives'
import type Client from '@/Client'
import type { ContentCodec } from '@/MessageContent'

export type GetMessageContentTypeFromClient<C> =
C extends Client<infer T> ? T : never
Expand Down
2 changes: 1 addition & 1 deletion packages/js-sdk/test/Client.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ContentTypeText, TextCodec } from '@xmtp/content-type-text'
import { message } from '@xmtp/proto'
import type { PublishResponse } from '@xmtp/proto/ts/dist/types/message_api/v1/message_api.pb'
import { Wallet } from 'ethers'
Expand All @@ -8,7 +9,6 @@ import { assert, vi } from 'vitest'
import HttpApiClient, { ApiUrls } from '@/ApiClient'
import Client, { Compression, type ClientOptions } from '@/Client'
import { CompositeCodec } from '@/codecs/Composite'
import { ContentTypeText, TextCodec } from '@/codecs/Text'
import { PrivateKey } from '@/crypto/PrivateKey'
import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle'
import InMemoryPersistence from '@/keystore/persistence/InMemoryPersistence'
Expand Down
2 changes: 1 addition & 1 deletion packages/js-sdk/test/Compression.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContentTypeText } from '@xmtp/content-type-text'
import { content as proto } from '@xmtp/proto'
import { ContentTypeText } from '@/codecs/Text'
import {
compress,
decompress,
Expand Down
6 changes: 3 additions & 3 deletions packages/js-sdk/test/ContentTypeTestKey.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { publicKey } from '@xmtp/proto'
import { PublicKey } from '@/crypto/PublicKey'
import {
ContentTypeId,
type ContentCodec,
type EncodedContent,
} from '@/MessageContent'
} from '@xmtp/content-type-primitives'
import { publicKey } from '@xmtp/proto'
import { PublicKey } from '@/crypto/PublicKey'

export const ContentTypeTestKey = new ContentTypeId({
authorityId: 'xmtp.test',
Expand Down
2 changes: 1 addition & 1 deletion packages/js-sdk/test/Message.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ContentTypeText } from '@xmtp/content-type-text'
import type { Wallet } from 'ethers'
import { createWalletClient, http } from 'viem'
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
import Client from '@/Client'
import { ContentTypeText } from '@/codecs/Text'
import { ConversationV1 } from '@/conversations/Conversation'
import { sha256 } from '@/crypto/encryption'
import { PrivateKeyBundleV1 } from '@/crypto/PrivateKeyBundle'
Expand Down
55 changes: 0 additions & 55 deletions packages/js-sdk/test/MessageContent.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/js-sdk/test/codecs/Composite.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContentTypeText } from '@xmtp/content-type-text'
import { CompositeCodec, ContentTypeComposite } from '@/codecs/Composite'
import { ContentTypeText } from '@/codecs/Text'
import { CodecRegistry } from '@test/helpers'

describe('CompositeType', () => {
Expand Down
57 changes: 0 additions & 57 deletions packages/js-sdk/test/codecs/Text.test.ts

This file was deleted.

Loading

0 comments on commit 965279f

Please sign in to comment.