Skip to content

Commit

Permalink
Merge pull request #370 from xmtp-labs/dj/metamask-snaps
Browse files Browse the repository at this point in the history
Add snaps flow
  • Loading branch information
daria-github authored Sep 25, 2023
2 parents 8b40da0 + 9e583b1 commit 2707dd9
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 93 deletions.
143 changes: 77 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.2",
"buffer": "^6.0.3",
"date-fns": "^2.29.3",
"dexie": "^3.2.4",
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
10 changes: 5 additions & 5 deletions src/helpers/tests/keys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ 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);
});
});

describe("wipeKeys", () => {
it("removes address key from local storage", () => {
const walletAddress = "testWalletAddress";
wipeKeys(walletAddress);
expect(loadKeys(walletAddress)).toBe(null);
expect(loadKeys(walletAddress)).toBe(undefined);
});
});
Loading

1 comment on commit 2707dd9

@vercel
Copy link

@vercel vercel bot commented on 2707dd9 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.