Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Commit 36fecdf

Browse files
authored
Merge pull request #284 from xmtp/rygine/db-update
Upgrade dexie, remove DB versioning
2 parents 6e2af06 + 85802e8 commit 36fecdf

23 files changed

+144
-157
lines changed

.changeset/forty-radios-scream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@xmtp/react-sdk": major
3+
---
4+
5+
Upgrade dexie, remove DB versioning

apps/react/src/controllers/AppController.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import {
77
import { WalletProvider } from "../contexts/WalletContext";
88
import { App } from "../components/App";
99

10-
const DB_VERSION = 1;
11-
1210
const contentTypeConfigs = [
1311
attachmentContentTypeConfig,
1412
reactionContentTypeConfig,
@@ -17,9 +15,7 @@ const contentTypeConfigs = [
1715

1816
export const AppController: React.FC = () => (
1917
<WalletProvider>
20-
<XMTPProvider
21-
dbVersion={DB_VERSION}
22-
contentTypeConfigs={contentTypeConfigs}>
18+
<XMTPProvider contentTypeConfigs={contentTypeConfigs}>
2319
<App />
2420
</XMTPProvider>
2521
</WalletProvider>

packages/react-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"@xmtp/content-type-text": "^1.0.0",
7575
"async-mutex": "^0.5.0",
7676
"date-fns": "^3.6.0",
77-
"dexie": "^3.2.6",
77+
"dexie": "^4.0.8",
7878
"dexie-react-hooks": "^1.1.7",
7979
"uuid": "^10.0.0",
8080
"zod": "^3.23.8"

packages/react-sdk/src/contexts/XMTPContext.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import type { XMTPProviderProps } from "@/contexts/XMTPContext";
55
import { XMTPProvider } from "@/contexts/XMTPContext";
66

77
type TestWrapperProps = PropsWithChildren &
8-
Pick<XMTPProviderProps, "dbVersion" | "contentTypeConfigs">;
8+
Pick<XMTPProviderProps, "contentTypeConfigs">;
99

1010
const TestWrapper: React.FC<TestWrapperProps> = ({
1111
contentTypeConfigs,
1212
children,
13-
dbVersion,
1413
}) => (
15-
<XMTPProvider contentTypeConfigs={contentTypeConfigs} dbVersion={dbVersion}>
14+
<XMTPProvider contentTypeConfigs={contentTypeConfigs}>
1615
{children}
1716
</XMTPProvider>
1817
);

packages/react-sdk/src/contexts/XMTPContext.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,12 @@ export type XMTPProviderProps = React.PropsWithChildren & {
6565
* processing of messages
6666
*/
6767
contentTypeConfigs?: ContentTypeConfiguration[];
68-
/**
69-
* Database version to use for the local cache
70-
*
71-
* This number should be incremented when adding support for additional
72-
* content types
73-
*/
74-
dbVersion?: number;
7568
};
7669

7770
export const XMTPProvider: React.FC<XMTPProviderProps> = ({
7871
children,
7972
client: initialClient,
8073
contentTypeConfigs,
81-
dbVersion,
8274
}) => {
8375
const [client, setClient] = useState<Client | undefined>(initialClient);
8476

@@ -112,9 +104,8 @@ export const XMTPProvider: React.FC<XMTPProviderProps> = ({
112104
getDbInstance({
113105
db: initialDb,
114106
contentTypeConfigs,
115-
version: dbVersion,
116107
}),
117-
[dbVersion, contentTypeConfigs],
108+
[contentTypeConfigs],
118109
);
119110

120111
// memo-ize the context value to prevent unnecessary re-renders

packages/react-sdk/src/helpers/caching/contentTypes/attachment.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
hasAttachment,
1616
attachmentContentTypeConfig,
1717
} from "./attachment";
18-
import { type CachedMessageWithId } from "@/helpers/caching/messages";
18+
import { type CachedMessage } from "@/helpers/caching/messages";
1919
import { createRandomWallet } from "@/helpers/testing";
2020

2121
const testWallet = createRandomWallet();
@@ -53,7 +53,7 @@ describe("ContentTypeRemoteAttachment caching", () => {
5353
senderAddress: "testWalletAddress",
5454
uuid: "testUuid",
5555
xmtpID: "testXmtpId",
56-
} satisfies CachedMessageWithId<Attachment>;
56+
} satisfies CachedMessage<Attachment>;
5757

5858
const attachment = getAttachment(testMessage);
5959
expect(attachment).toEqual(testContent);
@@ -82,7 +82,7 @@ describe("ContentTypeRemoteAttachment caching", () => {
8282
senderAddress: "testWalletAddress",
8383
uuid: "testUuid",
8484
xmtpID: "testXmtpId",
85-
} satisfies CachedMessageWithId<RemoteAttachment>;
85+
} satisfies CachedMessage<RemoteAttachment>;
8686

8787
const attachment2 = getAttachment(testMessage2);
8888
expect(attachment2).toEqual(testContent2);
@@ -101,7 +101,7 @@ describe("ContentTypeRemoteAttachment caching", () => {
101101
senderAddress: "testWalletAddress",
102102
uuid: "testUuid",
103103
xmtpID: "testXmtpId",
104-
} satisfies CachedMessageWithId;
104+
} satisfies CachedMessage;
105105

106106
const attachment3 = getAttachment(testMessage3);
107107
expect(attachment3).toBeUndefined();
@@ -129,7 +129,7 @@ describe("ContentTypeRemoteAttachment caching", () => {
129129
senderAddress: "testWalletAddress",
130130
uuid: "testUuid",
131131
xmtpID: "testXmtpId",
132-
} satisfies CachedMessageWithId<Attachment>;
132+
} satisfies CachedMessage<Attachment>;
133133

134134
const attachment = hasAttachment(testMessage);
135135
expect(attachment).toBe(true);
@@ -148,7 +148,7 @@ describe("ContentTypeRemoteAttachment caching", () => {
148148
senderAddress: "testWalletAddress",
149149
uuid: "testUuid",
150150
xmtpID: "testXmtpId",
151-
} satisfies CachedMessageWithId;
151+
} satisfies CachedMessage;
152152

153153
const attachment2 = hasAttachment(testMessage2);
154154
expect(attachment2).toBe(false);

packages/react-sdk/src/helpers/caching/contentTypes/reaction.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import {
1616
} from "./reaction";
1717
import {
1818
saveMessage,
19-
type CachedMessageWithId,
19+
type CachedMessage,
2020
getMessageByXmtpID,
2121
} from "@/helpers/caching/messages";
2222
import { getDbInstance, clearCache } from "@/helpers/caching/db";
23-
import type { CachedConversationWithId } from "@/helpers/caching/conversations";
23+
import type { CachedConversation } from "@/helpers/caching/conversations";
2424
import { createRandomWallet } from "@/helpers/testing";
2525

2626
const testWallet = createRandomWallet();
@@ -91,7 +91,7 @@ describe("ContentTypeReaction", () => {
9191
topic: "testTopic",
9292
peerAddress: "testPeerAddress",
9393
walletAddress: testWallet.account.address,
94-
} satisfies CachedConversationWithId;
94+
} satisfies CachedConversation;
9595
const testTextMessage = {
9696
id: 1,
9797
walletAddress: testWallet.account.address,
@@ -106,7 +106,7 @@ describe("ContentTypeReaction", () => {
106106
senderAddress: "testWalletAddress",
107107
uuid: "testUuid1",
108108
xmtpID: "testXmtpId1",
109-
} satisfies CachedMessageWithId;
109+
} satisfies CachedMessage;
110110

111111
await saveMessage(testTextMessage, db);
112112

@@ -131,7 +131,7 @@ describe("ContentTypeReaction", () => {
131131
senderAddress: "testWalletAddress",
132132
uuid: "testUuid2",
133133
xmtpID: "testXmtpId2",
134-
} satisfies CachedMessageWithId<Reaction>;
134+
} satisfies CachedMessage<Reaction>;
135135

136136
const updateConversationMetadata = vi.fn();
137137
await processReaction({
@@ -173,7 +173,7 @@ describe("ContentTypeReaction", () => {
173173
senderAddress: "testWalletAddress",
174174
uuid: "testUuid3",
175175
xmtpID: "testXmtpId3",
176-
} satisfies CachedMessageWithId<Reaction>;
176+
} satisfies CachedMessage<Reaction>;
177177

178178
await processReaction({
179179
client: testClient,
@@ -201,7 +201,7 @@ describe("ContentTypeReaction", () => {
201201
topic: "testTopic",
202202
peerAddress: "testPeerAddress",
203203
walletAddress: testWallet.account.address,
204-
} satisfies CachedConversationWithId;
204+
} satisfies CachedConversation;
205205
const testMessage = {
206206
id: 1,
207207
walletAddress: testWallet.account.address,
@@ -216,7 +216,7 @@ describe("ContentTypeReaction", () => {
216216
senderAddress: "testWalletAddress",
217217
uuid: "testUuid",
218218
xmtpID: "testXmtpId",
219-
} satisfies CachedMessageWithId;
219+
} satisfies CachedMessage;
220220

221221
const updateConversationMetadata = vi.fn();
222222
await processReaction({

packages/react-sdk/src/helpers/caching/contentTypes/reply.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import {
1313
} from "./reply";
1414
import {
1515
saveMessage,
16-
type CachedMessageWithId,
16+
type CachedMessage,
1717
getMessageByXmtpID,
1818
} from "@/helpers/caching/messages";
1919
import { getDbInstance, clearCache } from "@/helpers/caching/db";
20-
import type { CachedConversationWithId } from "@/helpers/caching/conversations";
20+
import type { CachedConversation } from "@/helpers/caching/conversations";
2121
import { createRandomWallet } from "@/helpers/testing";
2222

2323
const testWallet = createRandomWallet();
@@ -53,7 +53,7 @@ describe("ContentTypeReply", () => {
5353
topic: "testTopic",
5454
peerAddress: "testPeerAddress",
5555
walletAddress: testWallet.account.address,
56-
} satisfies CachedConversationWithId;
56+
} satisfies CachedConversation;
5757
const testTextMessage = {
5858
id: 1,
5959
walletAddress: testWallet.account.address,
@@ -68,7 +68,7 @@ describe("ContentTypeReply", () => {
6868
senderAddress: "testWalletAddress",
6969
uuid: "testUuid1",
7070
xmtpID: "testXmtpId1",
71-
} satisfies CachedMessageWithId;
71+
} satisfies CachedMessage;
7272

7373
await saveMessage(testTextMessage, db);
7474

@@ -92,7 +92,7 @@ describe("ContentTypeReply", () => {
9292
senderAddress: "testWalletAddress",
9393
uuid: "testUuid2",
9494
xmtpID: "testXmtpId2",
95-
} satisfies CachedMessageWithId<Reply>;
95+
} satisfies CachedMessage<Reply>;
9696

9797
await saveMessage(testReplyMessage, db);
9898

@@ -130,7 +130,7 @@ describe("ContentTypeReply", () => {
130130
topic: "testTopic",
131131
peerAddress: "testPeerAddress",
132132
walletAddress: testWallet.account.address,
133-
} satisfies CachedConversationWithId;
133+
} satisfies CachedConversation;
134134
const testMessage = {
135135
id: 1,
136136
walletAddress: testWallet.account.address,
@@ -145,7 +145,7 @@ describe("ContentTypeReply", () => {
145145
senderAddress: "testWalletAddress",
146146
uuid: "testUuid",
147147
xmtpID: "testXmtpId",
148-
} satisfies CachedMessageWithId;
148+
} satisfies CachedMessage;
149149

150150
const updateConversationMetadata = vi.fn();
151151
await processReply({
@@ -175,7 +175,7 @@ describe("ContentTypeReply", () => {
175175
senderAddress: "testWalletAddress",
176176
uuid: "testUuid1",
177177
xmtpID: "testXmtpId1",
178-
} satisfies CachedMessageWithId;
178+
} satisfies CachedMessage;
179179

180180
const originalMessageFromReply = await getOriginalMessageFromReply(
181181
testTextMessage,
@@ -201,7 +201,7 @@ describe("ContentTypeReply", () => {
201201
senderAddress: "testWalletAddress",
202202
uuid: "testUuid2",
203203
xmtpID: "testXmtpId2",
204-
} satisfies CachedMessageWithId<Reply>;
204+
} satisfies CachedMessage<Reply>;
205205

206206
const originalMessageFromReply2 = await getOriginalMessageFromReply(
207207
testReplyMessage,
@@ -227,7 +227,7 @@ describe("ContentTypeReply", () => {
227227
senderAddress: "testWalletAddress",
228228
uuid: "testUuid1",
229229
xmtpID: "testXmtpId1",
230-
} satisfies CachedMessageWithId;
230+
} satisfies CachedMessage;
231231

232232
const replies = await getReplies(testTextMessage, db);
233233
expect(replies).toEqual([]);
@@ -250,7 +250,7 @@ describe("ContentTypeReply", () => {
250250
senderAddress: "testWalletAddress",
251251
uuid: "testUuid1",
252252
xmtpID: "testXmtpId1",
253-
} satisfies CachedMessageWithId;
253+
} satisfies CachedMessage;
254254

255255
const testReplyMessage1 = {
256256
id: 2,
@@ -270,7 +270,7 @@ describe("ContentTypeReply", () => {
270270
senderAddress: "testWalletAddress",
271271
uuid: "testUuid2",
272272
xmtpID: "testXmtpId2",
273-
} satisfies CachedMessageWithId;
273+
} satisfies CachedMessage;
274274

275275
await saveMessage(testReplyMessage1, db);
276276

@@ -292,7 +292,7 @@ describe("ContentTypeReply", () => {
292292
senderAddress: "testWalletAddress",
293293
uuid: "testUuid3",
294294
xmtpID: "testXmtpId3",
295-
} satisfies CachedMessageWithId;
295+
} satisfies CachedMessage;
296296

297297
await saveMessage(testReplyMessage2, db);
298298

packages/react-sdk/src/helpers/caching/contentTypes/reply.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { z } from "zod";
55
import { ContentTypeId } from "@xmtp/content-type-primitives";
66
import type {
77
CachedMessage,
8-
CachedMessageWithId,
98
CachedMessagesTable,
109
} from "@/helpers/caching/messages";
1110
import type {
@@ -75,7 +74,7 @@ export const getReplies = async (message: CachedMessage, db: Dexie) => {
7574
.where("xmtpID")
7675
.anyOf(replies.map((reply) => reply.xmtpID))
7776
.sortBy("sentAt");
78-
return replyMessages as CachedMessageWithId[];
77+
return replyMessages;
7978
}
8079
return [];
8180
};

0 commit comments

Comments
 (0)