Skip to content

Commit

Permalink
feat: updated sdk and added configs for vite
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony23991 committed Jan 15, 2025
1 parent ccfae26 commit a8db304
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 191 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@uiw/react-color-github": "^2.3.0",
"@usecapsule/react-sdk": "^4.6.1",
"@usecapsule/wagmi-v2-integration": "^3.6.1",
"@xmtp/browser-sdk": "^0.0.13",
"@xmtp/browser-sdk": "^0.0.15",
"@xmtp/content-type-reaction": "^1.1.11",
"@xmtp/content-type-read-receipt": "^1.1.12",
"@xmtp/content-type-remote-attachment": "^1.1.12",
Expand Down
10 changes: 8 additions & 2 deletions packages/@justweb3/xmtp-plugin/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ const config: StorybookConfig = {
name: '@storybook/react-vite',
options: {},
},

viteFinal: async (config) =>
mergeConfig(config, {
plugins: [react(), nxViteTsPaths()],
server: {
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin',
},
},
define: {
'process.env': process.env,
},
optimizeDeps: {
exclude: ['@xmtp/user-preferences-bindings-wasm'],
exclude: ['@xmtp/browser-sdk', '@xmtp/user-preferences-bindings-wasm'],
include: ['@xmtp/proto'],
},
}),
typescript: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ export const ChatMenuButton: React.FC<ChatMenuButtonProps> = ({
handleOpen,
env,
}) => {
const { conversationsInfo, initializeXmtp } = useJustWeb3XMTP();
const { conversationsInfo } = useJustWeb3XMTP();
const totalUnreadCount = useMemo(() => {
return conversationsInfo
.filter((conversation) => conversation.consent === 'allowed')
.reduce((acc, curr) => acc + curr.unreadCount, 0);
}, [conversationsInfo]);
const { client } = useXMTPClient();
const { client, initializeXmtp } = useXMTPClient();

const handleChat = async () => {
if (!client) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const ChatList: React.FC<ChatListProps> = ({
{conversationsInfo
?.sort((a, b) => {
if (a.lastMessage?.sentAtNs && b.lastMessage?.sentAtNs) {
// a.lastMessage.sentAt and b.lastMessage.sentA are Date objects
return (
Number(b.lastMessage.sentAtNs - a.lastMessage.sentAtNs)
);
Expand Down
122 changes: 0 additions & 122 deletions packages/@justweb3/xmtp-plugin/src/lib/content-types/readReceipt.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export function useXMTPClient(env: 'dev' | 'production' | 'local' = 'dev') {
new ReadReceiptCodec(),
],
};

const newClient = await Client.create(signer, encryptionKey, options);
if (newClient.accountAddress !== address) {
wipeKeys(address, env);
Expand All @@ -77,7 +76,7 @@ export function useXMTPClient(env: 'dev' | 'production' | 'local' = 'dev') {
setClient(newClient);
}
} catch (e) {
console.error('Failed to initialize XMTP Client:', error);
console.error('Failed to initialize XMTP Client:', e, error);
wipeKeys(address ?? '', env);
setError(e as Error);
setRejected(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const groupMessagesByDate = (
messages: MessageWithReaction[],
): GroupedMessages => {
const groupedMessages = messages.reduce<GroupedMessages>((acc, message) => {
const date = new Date(message.sentAt)
const date = new Date(Number(message.sentAtNs))
const formattedDate = getFormattedDate(date)

if (!acc[formattedDate]) {
Expand Down
50 changes: 0 additions & 50 deletions packages/@justweb3/xmtp-plugin/src/stories/xmtp.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,56 +91,6 @@ export const Example = () => {
<ConnectButton />
</JustWeb3Button>
</div>

{/*<div style={{ display: 'flex', gap: '10px', flexWrap: 'wrap' }}>*/}
{/* <JustEnsCard addressOrEns={'mely.eth'} />*/}
{/* <JustEnsCard addressOrEns={'nick.eth'} />*/}
{/* <JustEnsCard addressOrEns={'brantly.eth'} />*/}
{/* <JustEnsCard addressOrEns={'vitalik.eth'} />*/}
{/* <JustEnsCard addressOrEns={'dr3a.eth'} />*/}
{/* <JustEnsCard addressOrEns={'josh.box'} />*/}
{/* <JustEnsCard addressOrEns={'justghadi.eth'} />*/}
{/* <JustEnsCard addressOrEns={'justan.id'} />*/}
{/* <JustEnsCard addressOrEns={'jesse.base.eth'} />*/}
{/* <JustEnsCard addressOrEns={'dave.base.eth'} />*/}
{/* <JustEnsCard addressOrEns={'xhris.eth'} />*/}
{/* <JustEnsCard addressOrEns={'raffy.eth'} />*/}
{/* <JustEnsCard addressOrEns={'slobo.eth'} />*/}
{/* <JustEnsCard addressOrEns={'obi-wan.eth'} />*/}
{/* <JustEnsCard addressOrEns={'threadgirl.eth'} />*/}
{/* <JustEnsCard addressOrEns={'bianc8.eth'} />*/}
{/* <JustEnsCard*/}
{/* addressOrEns={'justanthony.jaw.eth'}*/}
{/* chainId={11155111}*/}
{/* />*/}
{/* <JustEnsCard*/}
{/* addressOrEns={'0x7Ca2C8acAcf728CeFB6c8cd8E9b2063C8763feB1'}*/}
{/* chainId={1}*/}
{/* />*/}
{/* <JustEnsCard*/}
{/* addressOrEns={'hadikhai.jaw.eth'}*/}
{/* chainId={11155111}*/}
{/* />*/}
{/*</div>*/}
{/*<div*/}
{/* style={{*/}
{/* marginTop: '100vh',*/}
{/* display: 'flex',*/}
{/* gap: '10px',*/}
{/* flexWrap: 'wrap',*/}
{/* }}*/}
{/*>*/}
{/* <JustEnsCard addressOrEns={'mely.eth'} expanded />*/}
{/* <JustEnsCard addressOrEns={'nick.eth'} expanded />*/}
{/* <JustEnsCard addressOrEns={'brantly.eth'} expanded />*/}
{/* <JustEnsCard addressOrEns={'vitalik.eth'} expanded />*/}
{/* <JustEnsCard addressOrEns={'dr3a.eth'} expanded />*/}
{/* <JustEnsCard*/}
{/* addressOrEns={'hadikhai.jaw.eth'}*/}
{/* chainId={11155111}*/}
{/* expanded*/}
{/* />*/}
{/*</div>*/}
</div>
</JustWeb3Provider>
</RainbowKitProvider>
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12589,17 +12589,17 @@ __metadata:
languageName: node
linkType: hard

"@xmtp/browser-sdk@npm:^0.0.13":
version: 0.0.13
resolution: "@xmtp/browser-sdk@npm:0.0.13"
"@xmtp/browser-sdk@npm:^0.0.15":
version: 0.0.15
resolution: "@xmtp/browser-sdk@npm:0.0.15"
dependencies:
"@xmtp/content-type-group-updated": "npm:^2.0.0"
"@xmtp/content-type-primitives": "npm:^2.0.0"
"@xmtp/content-type-text": "npm:^2.0.0"
"@xmtp/proto": "npm:^3.72.3"
"@xmtp/wasm-bindings": "npm:^0.0.11"
"@xmtp/wasm-bindings": "npm:^0.0.12"
uuid: "npm:^11.0.3"
checksum: 10c0/669feda60294f163294ea58de7ca872fd3f226ff403535ee39e22b8e24b7bcb3b19baf4409fa61fb89b1cdb130d4b033c7ca55119f594a183163f59edbb117b7
checksum: 10c0/ac0557f46c544590a6ef9a6da0eb3c29495fe4917ae14bbe93d2d767911c969a8591c9c85d6578e685bb6c43f7bb71e357b392b0e9297c13d507b0b9685f7e23
languageName: node
linkType: hard

Expand Down Expand Up @@ -12752,10 +12752,10 @@ __metadata:
languageName: node
linkType: hard

"@xmtp/wasm-bindings@npm:^0.0.11":
version: 0.0.11
resolution: "@xmtp/wasm-bindings@npm:0.0.11"
checksum: 10c0/fe880406265437b95803a138e10b68c2ad201826bda93ad94d6f2d4bc6331d60ead1d68149f5f88011dd9afa8c07a0ac7b5b7d9d405e451f0e0351d9c2129a73
"@xmtp/wasm-bindings@npm:^0.0.12":
version: 0.0.12
resolution: "@xmtp/wasm-bindings@npm:0.0.12"
checksum: 10c0/0efc950e5629689d0cd4ddc45f191d7b2ef3c48dd21fae735706ce9741285b2c8fa8a8f16ae62069f84e4fc1eac19b3d41d4fd45144b57ab1f449e95382d42fb
languageName: node
linkType: hard

Expand Down Expand Up @@ -23912,7 +23912,7 @@ __metadata:
"@usecapsule/react-sdk": "npm:^4.6.1"
"@usecapsule/wagmi-v2-integration": "npm:^3.6.1"
"@vitejs/plugin-react": "npm:^4.2.0"
"@xmtp/browser-sdk": "npm:^0.0.13"
"@xmtp/browser-sdk": "npm:^0.0.15"
"@xmtp/content-type-reaction": "npm:^1.1.11"
"@xmtp/content-type-read-receipt": "npm:^1.1.12"
"@xmtp/content-type-remote-attachment": "npm:^1.1.12"
Expand Down

0 comments on commit a8db304

Please sign in to comment.