From c2ae6399a6d829db07bca7048b5ed2314ca80393 Mon Sep 17 00:00:00 2001 From: daria-github Date: Mon, 25 Sep 2023 11:29:38 -0700 Subject: [PATCH 1/4] add snaps flow --- package-lock.json | 143 ++++++++++++++++++--------------- package.json | 2 +- src/helpers/keys.ts | 4 +- src/helpers/tests/keys.test.ts | 10 +-- src/hooks/useInitXmtpClient.ts | 89 +++++++++++++++----- 5 files changed, 155 insertions(+), 93 deletions(-) diff --git a/package-lock.json b/package-lock.json index 559a2c4b..e782272a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@vitejs/plugin-react": "^4.0.0", "@wagmi/core": "^0.10.11", "@xmtp/content-type-remote-attachment": "^1.0.7", - "@xmtp/react-sdk": "^1.3.7", + "@xmtp/react-sdk": "^1.4.0-beta.1", "buffer": "^6.0.3", "date-fns": "^2.29.3", "dexie": "^3.2.4", @@ -33,7 +33,6 @@ "interweave-autolink": "^5.1.0", "interweave-emoji": "^7.0.0", "lodash": "^4.17.21", - "lodash.throttle": "^4.1.1", "process": "^0.11.10", "react": "18.2.0", "react-blockies": "^1.4.1", @@ -14078,9 +14077,9 @@ } }, "node_modules/@xmtp/content-type-reaction": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@xmtp/content-type-reaction/-/content-type-reaction-1.0.1.tgz", - "integrity": "sha512-1O507MUAvB8ukt0anyQONieaLYYv2T76yWwh3I+HAfLt0UUKBKlyVUctGwu5tzeCni2cw7coB5LVS2E9Il1OPg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@xmtp/content-type-reaction/-/content-type-reaction-1.1.1.tgz", + "integrity": "sha512-sU7cy33VUDeDOA2ZIeL05nI9OM07p9GJ9H8ghw782EeLgOC9+N+lVPZFWo3W/3I7XKB/1zdMvtZ5TscGlspx5w==", "dependencies": { "@xmtp/xmtp-js": "^9.1.7" }, @@ -14089,9 +14088,9 @@ } }, "node_modules/@xmtp/content-type-read-receipt": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@xmtp/content-type-read-receipt/-/content-type-read-receipt-1.0.1.tgz", - "integrity": "sha512-jHyCqr9lBxShHM0mq3mQEJrqgnXrmMSqdTEG9r1j2/1Ceh8y2Tzb9tjsrVOX53GVjlCSlJeGRRUI4lYfV45ilQ==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@xmtp/content-type-read-receipt/-/content-type-read-receipt-1.1.2.tgz", + "integrity": "sha512-N/K7zFbTt9L106NEZdk2TOPJ39ldesDoNVNyF31VNdEeaahawhKieyNSLg/bP5KSFe3nEnc6tiFKoJlB/4hkig==", "dependencies": { "@xmtp/proto": "^3.26.0", "@xmtp/xmtp-js": "^9.2.0" @@ -14101,22 +14100,22 @@ } }, "node_modules/@xmtp/content-type-remote-attachment": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@xmtp/content-type-remote-attachment/-/content-type-remote-attachment-1.0.7.tgz", - "integrity": "sha512-xq40kwul2b8JnqfIo7+9VgzeKURwXRD+34Wq1kTK2YVSJB4uW10vhdSQhN7JLJS4CuU9Z8R1tmVCJf5IbG+Iag==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@xmtp/content-type-remote-attachment/-/content-type-remote-attachment-1.1.1.tgz", + "integrity": "sha512-fze71dXyAWt4UgkeDB7Iuasf08xz2/LpRz1WbfFQRfL/NnkOy7MI7SEADNgaqiacvYssazMgRDXDbsw9PTNwuQ==", "dependencies": { "@noble/secp256k1": "^1.7.1", "@xmtp/proto": "^3.25.0", - "@xmtp/xmtp-js": "^9.1.6" + "@xmtp/xmtp-js": "^9.1.7" }, "peerDependencies": { - "@xmtp/xmtp-js": "^9.1.6" + "@xmtp/xmtp-js": "^9.1.7" } }, "node_modules/@xmtp/content-type-reply": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@xmtp/content-type-reply/-/content-type-reply-1.0.0.tgz", - "integrity": "sha512-apHTHARZFi0O5I0W0Dx4mz6huioFgOifTSOJMN3oTtxqHbPs1Le5xrHcgRM6XcEidBFOcKNg4tJYDyYFWr++pw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@xmtp/content-type-reply/-/content-type-reply-1.1.2.tgz", + "integrity": "sha512-B4I3EiROJtFj7k2m82iZuZNLuCe1zND2zXv9v5LlNOJqF8pdS6HM6TaGDIp5N5EsO4aFFO6rNtY9shRgyh94tw==", "dependencies": { "@xmtp/proto": "^3.26.0", "@xmtp/xmtp-js": "^9.2.0" @@ -14137,15 +14136,15 @@ } }, "node_modules/@xmtp/react-sdk": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/@xmtp/react-sdk/-/react-sdk-1.3.7.tgz", - "integrity": "sha512-4+E8pmFuHGBk7bqG6tD/0H1trKThjvgKskK16/FutF5gvVQLZ8WwOeTyFR7p63swb3NqQdKzMdV87i+t1Jw7Dw==", - "dependencies": { - "@xmtp/content-type-reaction": "^1.0.1", - "@xmtp/content-type-read-receipt": "^1.0.1", - "@xmtp/content-type-remote-attachment": "^1.0.7", - "@xmtp/content-type-reply": "^1.0.0", - "@xmtp/xmtp-js": "^10.2.1", + "version": "1.4.0-beta.1", + "resolved": "https://registry.npmjs.org/@xmtp/react-sdk/-/react-sdk-1.4.0-beta.1.tgz", + "integrity": "sha512-v/P+1iJ3JP8UNm/b6exfnpDzRW4sznSKjc1pn3lh1QKunvzrTJdcUWgRYqkSgk3o1CWmKw1knV3fz6KvBrewuw==", + "dependencies": { + "@xmtp/content-type-reaction": "^1.1.0", + "@xmtp/content-type-read-receipt": "^1.1.0", + "@xmtp/content-type-remote-attachment": "^1.1.0", + "@xmtp/content-type-reply": "^1.1.0", + "@xmtp/xmtp-js": "^11.0.0-beta.9", "async-mutex": "^0.4.0", "date-fns": "^2.30.0", "dexie": "^3.2.4", @@ -14158,17 +14157,28 @@ "node": ">=18" }, "peerDependencies": { - "@xmtp/xmtp-js": "^10.2.1", + "@xmtp/xmtp-js": "^11.0.0-beta.9", "react": ">=16.14" } }, + "node_modules/@xmtp/react-sdk/node_modules/@xmtp/proto": { + "version": "3.28.0-beta.1", + "resolved": "https://registry.npmjs.org/@xmtp/proto/-/proto-3.28.0-beta.1.tgz", + "integrity": "sha512-gbDQ1FXKZe0j9RZxBK0Ohyy8C4z5I+ko58xmHk+QGO4QYb+cGsJyDSe0Re3oUa1tlnNudV0fkTR4nxcq4D+oIw==", + "dependencies": { + "long": "^5.2.0", + "protobufjs": "^7.0.0", + "rxjs": "^7.8.0", + "undici": "^5.8.1" + } + }, "node_modules/@xmtp/react-sdk/node_modules/@xmtp/xmtp-js": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@xmtp/xmtp-js/-/xmtp-js-10.2.1.tgz", - "integrity": "sha512-GbT1wYHv6XJp6WndCxVParEe7SsPFMBZso0AUO7pGaRe3n3BYXLFB7ZM8x81HMlxj5bEgLrjqNdrsUyr/G7KtA==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@xmtp/xmtp-js/-/xmtp-js-11.0.0.tgz", + "integrity": "sha512-Ng6L+bUS+NAksNxQD6T5LCxaPhd26qwZRe0RbskWttI+/nhh9GF3AqEPZBT2qBzusgyE5b+zQ6+wOeIcHzJenA==", "dependencies": { "@noble/secp256k1": "^1.5.2", - "@xmtp/proto": "^3.24.0", + "@xmtp/proto": "^3.28.0-beta.1", "async-mutex": "^0.4.0", "elliptic": "^6.5.4", "ethers": "^5.5.3", @@ -24045,11 +24055,6 @@ "integrity": "sha512-wbu3SF1XC5ijqm0piNxw59yCbuUf2kaShumYBLWUrcCvwh6C8odz6SY/wGVzCWTQTFL/1Ygbvqg2eLtspUVVAQ==", "dev": true }, - "node_modules/lodash.throttle": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", - "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==" - }, "node_modules/lodash.topairs": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.topairs/-/lodash.topairs-4.3.0.tgz", @@ -42362,36 +42367,36 @@ } }, "@xmtp/content-type-reaction": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@xmtp/content-type-reaction/-/content-type-reaction-1.0.1.tgz", - "integrity": "sha512-1O507MUAvB8ukt0anyQONieaLYYv2T76yWwh3I+HAfLt0UUKBKlyVUctGwu5tzeCni2cw7coB5LVS2E9Il1OPg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@xmtp/content-type-reaction/-/content-type-reaction-1.1.1.tgz", + "integrity": "sha512-sU7cy33VUDeDOA2ZIeL05nI9OM07p9GJ9H8ghw782EeLgOC9+N+lVPZFWo3W/3I7XKB/1zdMvtZ5TscGlspx5w==", "requires": { "@xmtp/xmtp-js": "^9.1.7" } }, "@xmtp/content-type-read-receipt": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@xmtp/content-type-read-receipt/-/content-type-read-receipt-1.0.1.tgz", - "integrity": "sha512-jHyCqr9lBxShHM0mq3mQEJrqgnXrmMSqdTEG9r1j2/1Ceh8y2Tzb9tjsrVOX53GVjlCSlJeGRRUI4lYfV45ilQ==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@xmtp/content-type-read-receipt/-/content-type-read-receipt-1.1.2.tgz", + "integrity": "sha512-N/K7zFbTt9L106NEZdk2TOPJ39ldesDoNVNyF31VNdEeaahawhKieyNSLg/bP5KSFe3nEnc6tiFKoJlB/4hkig==", "requires": { "@xmtp/proto": "^3.26.0", "@xmtp/xmtp-js": "^9.2.0" } }, "@xmtp/content-type-remote-attachment": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@xmtp/content-type-remote-attachment/-/content-type-remote-attachment-1.0.7.tgz", - "integrity": "sha512-xq40kwul2b8JnqfIo7+9VgzeKURwXRD+34Wq1kTK2YVSJB4uW10vhdSQhN7JLJS4CuU9Z8R1tmVCJf5IbG+Iag==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@xmtp/content-type-remote-attachment/-/content-type-remote-attachment-1.1.1.tgz", + "integrity": "sha512-fze71dXyAWt4UgkeDB7Iuasf08xz2/LpRz1WbfFQRfL/NnkOy7MI7SEADNgaqiacvYssazMgRDXDbsw9PTNwuQ==", "requires": { "@noble/secp256k1": "^1.7.1", "@xmtp/proto": "^3.25.0", - "@xmtp/xmtp-js": "^9.1.6" + "@xmtp/xmtp-js": "^9.1.7" } }, "@xmtp/content-type-reply": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@xmtp/content-type-reply/-/content-type-reply-1.0.0.tgz", - "integrity": "sha512-apHTHARZFi0O5I0W0Dx4mz6huioFgOifTSOJMN3oTtxqHbPs1Le5xrHcgRM6XcEidBFOcKNg4tJYDyYFWr++pw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@xmtp/content-type-reply/-/content-type-reply-1.1.2.tgz", + "integrity": "sha512-B4I3EiROJtFj7k2m82iZuZNLuCe1zND2zXv9v5LlNOJqF8pdS6HM6TaGDIp5N5EsO4aFFO6rNtY9shRgyh94tw==", "requires": { "@xmtp/proto": "^3.26.0", "@xmtp/xmtp-js": "^9.2.0" @@ -42409,15 +42414,15 @@ } }, "@xmtp/react-sdk": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/@xmtp/react-sdk/-/react-sdk-1.3.7.tgz", - "integrity": "sha512-4+E8pmFuHGBk7bqG6tD/0H1trKThjvgKskK16/FutF5gvVQLZ8WwOeTyFR7p63swb3NqQdKzMdV87i+t1Jw7Dw==", - "requires": { - "@xmtp/content-type-reaction": "^1.0.1", - "@xmtp/content-type-read-receipt": "^1.0.1", - "@xmtp/content-type-remote-attachment": "^1.0.7", - "@xmtp/content-type-reply": "^1.0.0", - "@xmtp/xmtp-js": "^10.2.1", + "version": "1.4.0-beta.1", + "resolved": "https://registry.npmjs.org/@xmtp/react-sdk/-/react-sdk-1.4.0-beta.1.tgz", + "integrity": "sha512-v/P+1iJ3JP8UNm/b6exfnpDzRW4sznSKjc1pn3lh1QKunvzrTJdcUWgRYqkSgk3o1CWmKw1knV3fz6KvBrewuw==", + "requires": { + "@xmtp/content-type-reaction": "^1.1.0", + "@xmtp/content-type-read-receipt": "^1.1.0", + "@xmtp/content-type-remote-attachment": "^1.1.0", + "@xmtp/content-type-reply": "^1.1.0", + "@xmtp/xmtp-js": "^11.0.0-beta.9", "async-mutex": "^0.4.0", "date-fns": "^2.30.0", "dexie": "^3.2.4", @@ -42427,13 +42432,24 @@ "zod": "^3.22.1" }, "dependencies": { + "@xmtp/proto": { + "version": "3.28.0-beta.1", + "resolved": "https://registry.npmjs.org/@xmtp/proto/-/proto-3.28.0-beta.1.tgz", + "integrity": "sha512-gbDQ1FXKZe0j9RZxBK0Ohyy8C4z5I+ko58xmHk+QGO4QYb+cGsJyDSe0Re3oUa1tlnNudV0fkTR4nxcq4D+oIw==", + "requires": { + "long": "^5.2.0", + "protobufjs": "^7.0.0", + "rxjs": "^7.8.0", + "undici": "^5.8.1" + } + }, "@xmtp/xmtp-js": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/@xmtp/xmtp-js/-/xmtp-js-10.2.1.tgz", - "integrity": "sha512-GbT1wYHv6XJp6WndCxVParEe7SsPFMBZso0AUO7pGaRe3n3BYXLFB7ZM8x81HMlxj5bEgLrjqNdrsUyr/G7KtA==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@xmtp/xmtp-js/-/xmtp-js-11.0.0.tgz", + "integrity": "sha512-Ng6L+bUS+NAksNxQD6T5LCxaPhd26qwZRe0RbskWttI+/nhh9GF3AqEPZBT2qBzusgyE5b+zQ6+wOeIcHzJenA==", "requires": { "@noble/secp256k1": "^1.5.2", - "@xmtp/proto": "^3.24.0", + "@xmtp/proto": "^3.28.0-beta.1", "async-mutex": "^0.4.0", "elliptic": "^6.5.4", "ethers": "^5.5.3", @@ -50114,11 +50130,6 @@ "integrity": "sha512-wbu3SF1XC5ijqm0piNxw59yCbuUf2kaShumYBLWUrcCvwh6C8odz6SY/wGVzCWTQTFL/1Ygbvqg2eLtspUVVAQ==", "dev": true }, - "lodash.throttle": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", - "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==" - }, "lodash.topairs": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.topairs/-/lodash.topairs-4.3.0.tgz", diff --git a/package.json b/package.json index d9e3a63a..eb10f07c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@vitejs/plugin-react": "^4.0.0", "@wagmi/core": "^0.10.11", "@xmtp/content-type-remote-attachment": "^1.0.7", - "@xmtp/react-sdk": "^1.3.7", + "@xmtp/react-sdk": "^1.4.0-beta.1", "buffer": "^6.0.3", "date-fns": "^2.29.3", "dexie": "^3.2.4", diff --git a/src/helpers/keys.ts b/src/helpers/keys.ts index 264d7e40..28a80c72 100644 --- a/src/helpers/keys.ts +++ b/src/helpers/keys.ts @@ -5,9 +5,9 @@ const ENCODING = "binary"; export const buildLocalStorageKey = (walletAddress?: string) => walletAddress ? `xmtp:${getEnv()}:keys:${walletAddress}` : ""; -export const loadKeys = (walletAddress?: string): Uint8Array | null => { +export const loadKeys = (walletAddress?: string): Uint8Array | undefined => { const val = localStorage.getItem(buildLocalStorageKey(walletAddress)); - return val ? Buffer.from(val, ENCODING) : null; + return val ? Buffer.from(val, ENCODING) : undefined; }; export const storeKeys = (walletAddress: string, keys: Uint8Array) => { diff --git a/src/helpers/tests/keys.test.ts b/src/helpers/tests/keys.test.ts index 6d1b2c7e..54dfbbb1 100644 --- a/src/helpers/tests/keys.test.ts +++ b/src/helpers/tests/keys.test.ts @@ -42,12 +42,12 @@ describe("loadKeys", () => { '{"type":"Buffer","data":[0,0]}', ); }); - it("returns null when wallet address exists but key not found in localStorage", () => { + it("returns undefined when wallet address exists but key not found in localStorage", () => { const walletAddress = "differentWalletAddress"; - expect(loadKeys(walletAddress)).toBe(null); + expect(loadKeys(walletAddress)).toBe(undefined); }); - it("handles empty input by returning null", () => { - expect(loadKeys()).toBe(null); + it("handles empty input by returning undefined", () => { + expect(loadKeys()).toBe(undefined); }); }); @@ -55,6 +55,6 @@ describe("wipeKeys", () => { it("removes address key from local storage", () => { const walletAddress = "testWalletAddress"; wipeKeys(walletAddress); - expect(loadKeys(walletAddress)).toBe(null); + expect(loadKeys(walletAddress)).toBe(undefined); }); }); diff --git a/src/hooks/useInitXmtpClient.ts b/src/hooks/useInitXmtpClient.ts index 1f0ca90c..9033aa7b 100644 --- a/src/hooks/useInitXmtpClient.ts +++ b/src/hooks/useInitXmtpClient.ts @@ -1,3 +1,4 @@ +import type { ClientOptions } from "@xmtp/react-sdk"; import { Client, useClient, useCanMessage } from "@xmtp/react-sdk"; import { useEffect, useMemo, useRef, useState } from "react"; import { useConnect, useSigner } from "wagmi"; @@ -19,6 +20,18 @@ type ClientStatus = "new" | "created" | "enabled"; type ResolveReject = (value: T | PromiseLike) => void; +interface Ethereum { + request(args: { + method: "wallet_requestSnaps"; + params: { + [snapName: string]: object; + }; + }): Promise<{ + [snapName: string]: { + enabled: boolean; + }; + }>; +} /** * This is a helper function for creating a new promise and getting access * to the resolve and reject callbacks for external use. @@ -42,7 +55,7 @@ const clientOptions = { apiUrl: import.meta.env.VITE_XMTP_API_URL, env: getEnv(), appVersion: getAppVersion(), -}; +} as Partial; const useInitXmtpClient = () => { // track if onboarding is in progress @@ -139,7 +152,7 @@ const useInitXmtpClient = () => { if (!client && signer) { onboardingRef.current = true; const address = await signer.getAddress(); - let keys = loadKeys(address); + let keys: Uint8Array | undefined = loadKeys(address); // check if we already have the keys if (keys) { // resolve client promises @@ -167,23 +180,61 @@ const useInitXmtpClient = () => { setStatus("new"); } } - // get client keys - keys = await Client.getKeys(signer, { - ...clientOptions, - // we don't need to publish the contact here since it - // will happen when we create the client later - skipContactPublishing: true, - // we can skip persistence on the keystore for this short-lived - // instance - persistConversations: false, - preCreateIdentityCallback, - preEnableIdentityCallback, - }); - // all signatures have been accepted - setStatus("enabled"); - setSigning(false); - // persist client keys - storeKeys(address, keys); + + if (window.ethereum?.isMetaMask) { + // Check snaps flow + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call + const browserSupportSnaps = await Client.isSnapsReady(); + if (browserSupportSnaps) { + try { + const result = await ( + window.ethereum as unknown as Ethereum + ).request({ + method: "wallet_requestSnaps", + params: { + "npm:@xmtp/snap": {}, + }, + }); + + if (result && result?.["npm:@xmtp/snap"].enabled) { + createResolve(); + enableResolve(); + setStatus("enabled"); + + keys = undefined; + clientOptions.useSnaps = true; + clientOptions.preCreateIdentityCallback = + preCreateIdentityCallback; + clientOptions.preEnableIdentityCallback = + preEnableIdentityCallback; + } else if (result && !result.enabled) { + throw new Error("snaps not enabled with XMTP"); + } + } catch (error) { + await updateStatus(); + } + } else { + await updateStatus(); + } + } else { + // get client keys + keys = await Client.getKeys(signer, { + ...clientOptions, + // we don't need to publish the contact here since it + // will happen when we create the client later + skipContactPublishing: true, + // we can skip persistence on the keystore for this short-lived + // instance + persistConversations: false, + preCreateIdentityCallback, + preEnableIdentityCallback, + }); + // all signatures have been accepted + setStatus("enabled"); + setSigning(false); + // persist client keys + storeKeys(address, keys); + } } // initialize client const xmtpClient = await initialize({ From f95179c5236c81d527820975fdfc50e22c9a2224 Mon Sep 17 00:00:00 2001 From: daria-github Date: Mon, 25 Sep 2023 15:50:10 -0700 Subject: [PATCH 2/4] bump version to fix e2e tests --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index e782272a..3cf0bcb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@vitejs/plugin-react": "^4.0.0", "@wagmi/core": "^0.10.11", "@xmtp/content-type-remote-attachment": "^1.0.7", - "@xmtp/react-sdk": "^1.4.0-beta.1", + "@xmtp/react-sdk": "^1.4.0-beta.2", "buffer": "^6.0.3", "date-fns": "^2.29.3", "dexie": "^3.2.4", @@ -14136,9 +14136,9 @@ } }, "node_modules/@xmtp/react-sdk": { - "version": "1.4.0-beta.1", - "resolved": "https://registry.npmjs.org/@xmtp/react-sdk/-/react-sdk-1.4.0-beta.1.tgz", - "integrity": "sha512-v/P+1iJ3JP8UNm/b6exfnpDzRW4sznSKjc1pn3lh1QKunvzrTJdcUWgRYqkSgk3o1CWmKw1knV3fz6KvBrewuw==", + "version": "1.4.0-beta.2", + "resolved": "https://registry.npmjs.org/@xmtp/react-sdk/-/react-sdk-1.4.0-beta.2.tgz", + "integrity": "sha512-UPbdKEMdXRo5rdDQY/N26U2ko1sNYNdpRrjpjJdwYaTAbhoSl+iUgSVNfCKTlOVihweA8jEmNMTPTkEt8Oa3Qg==", "dependencies": { "@xmtp/content-type-reaction": "^1.1.0", "@xmtp/content-type-read-receipt": "^1.1.0", @@ -42414,9 +42414,9 @@ } }, "@xmtp/react-sdk": { - "version": "1.4.0-beta.1", - "resolved": "https://registry.npmjs.org/@xmtp/react-sdk/-/react-sdk-1.4.0-beta.1.tgz", - "integrity": "sha512-v/P+1iJ3JP8UNm/b6exfnpDzRW4sznSKjc1pn3lh1QKunvzrTJdcUWgRYqkSgk3o1CWmKw1knV3fz6KvBrewuw==", + "version": "1.4.0-beta.2", + "resolved": "https://registry.npmjs.org/@xmtp/react-sdk/-/react-sdk-1.4.0-beta.2.tgz", + "integrity": "sha512-UPbdKEMdXRo5rdDQY/N26U2ko1sNYNdpRrjpjJdwYaTAbhoSl+iUgSVNfCKTlOVihweA8jEmNMTPTkEt8Oa3Qg==", "requires": { "@xmtp/content-type-reaction": "^1.1.0", "@xmtp/content-type-read-receipt": "^1.1.0", diff --git a/package.json b/package.json index eb10f07c..07a7a8af 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@vitejs/plugin-react": "^4.0.0", "@wagmi/core": "^0.10.11", "@xmtp/content-type-remote-attachment": "^1.0.7", - "@xmtp/react-sdk": "^1.4.0-beta.1", + "@xmtp/react-sdk": "^1.4.0-beta.2", "buffer": "^6.0.3", "date-fns": "^2.29.3", "dexie": "^3.2.4", From adae6db08bbfa0cc0c66ec4e135622e63c6b5e04 Mon Sep 17 00:00:00 2001 From: daria-github Date: Mon, 25 Sep 2023 15:56:22 -0700 Subject: [PATCH 3/4] updated type --- src/hooks/useInitXmtpClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useInitXmtpClient.ts b/src/hooks/useInitXmtpClient.ts index 9033aa7b..c625119a 100644 --- a/src/hooks/useInitXmtpClient.ts +++ b/src/hooks/useInitXmtpClient.ts @@ -22,7 +22,7 @@ type ResolveReject = (value: T | PromiseLike) => void; interface Ethereum { request(args: { - method: "wallet_requestSnaps"; + method: string; params: { [snapName: string]: object; }; From 9e583b10ead1bddbe2e14ccc91e3ce3b1bdbf453 Mon Sep 17 00:00:00 2001 From: daria-github Date: Mon, 25 Sep 2023 16:30:14 -0700 Subject: [PATCH 4/4] add comment --- src/hooks/useInitXmtpClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useInitXmtpClient.ts b/src/hooks/useInitXmtpClient.ts index c625119a..3ed573ee 100644 --- a/src/hooks/useInitXmtpClient.ts +++ b/src/hooks/useInitXmtpClient.ts @@ -182,7 +182,7 @@ const useInitXmtpClient = () => { } if (window.ethereum?.isMetaMask) { - // Check snaps flow + // Snaps flow — TODO: move to SDK side after ironing out all edge cases. // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call const browserSupportSnaps = await Client.isSnapsReady(); if (browserSupportSnaps) {