Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade JS SDK and proto packages #16

Merged
merged 22 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8,835 changes: 5,814 additions & 3,021 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@
"scripts": {
"build": "npm run build --workspaces",
"lint": "npm run lint:eslint && npm run lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:eslint": "npm run lint:eslint --workspace=site && npm run lint:eslint --workspace=@xmtp/snap",
"lint:fix": "npm run lint:eslint --fix && npm run lint:misc --write",
"lint:misc": "prettier '**/*.md' '!**/CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"start": "concurrently \"npm start --workspace=site\" \"npm start --workspace=@xmtp/snap\"",
"test": "npm test --workspace=@xmtp/snap"
},
"devDependencies": {
"@metamask/eslint-config": "^10.0.0",
"@metamask/eslint-config-jest": "^10.0.0",
"@metamask/eslint-config-nodejs": "^10.0.0",
"@metamask/eslint-config-typescript": "^10.0.0",
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"concurrently": "^8.2.0",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.1.0",
"eslint": "^8.55.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.8.2",
"eslint-plugin-jsdoc": "^39.2.9",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-jsdoc": "^43.0.7",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.2.1",
"prettier-plugin-packagejson": "^2.2.18",
"semantic-release": "^21.0.7",
"typescript": "^4.7.4"
"typescript": "^5.1.0"
},
"engines": {
"node": ">=16.0.0"
Expand Down
9 changes: 7 additions & 2 deletions packages/site/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
module.exports = {
extends: ['../../.eslintrc.js'],

parserOptions: {
project: './tsconfig.eslint.json',
},
rules: {
'spaced-comment': 'off',
'import/unambiguous': 'off',
},
overrides: [
{
files: ['**/*.{ts,tsx}'],
Expand All @@ -9,6 +15,5 @@ module.exports = {
},
},
],

ignorePatterns: ['!.eslintrc.js', 'build/'],
};
16 changes: 0 additions & 16 deletions packages/site/gatsby-browser.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions packages/site/gatsby-config.ts

This file was deleted.

14 changes: 0 additions & 14 deletions packages/site/gatsby-ssr.tsx

This file was deleted.

13 changes: 13 additions & 0 deletions packages/site/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
34 changes: 19 additions & 15 deletions packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"private": true,
"license": "(MIT-0 OR Apache-2.0)",
"scripts": {
"build": "cross-env GATSBY_TELEMETRY_DISABLED=1 gatsby build",
"build": "vite build",
"clean": "rimraf public",
"lint": "npm run lint:eslint && npm run lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:fix": "npm run lint:eslint --fix && npm run lint:misc --write",
"lint:fix": "npm run lint:eslint -- --fix && npm run lint:misc -- --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path .gitignore",
"start": "cross-env GATSBY_TELEMETRY_DISABLED=1 gatsby develop",
"start": "vite",
"test": "echo TODO"
},
"browserslist": {
Expand All @@ -27,20 +27,21 @@
},
"dependencies": {
"@metamask/providers": "^9.0.0",
"@xmtp/proto": "^3.28.0-beta.1",
"@xmtp/xmtp-js": "^11.0.0-beta.8",
"@xmtp/proto": "^3.34.0",
"@xmtp/xmtp-js": "^11.3.0-beta.13",
"buffer": "^6.0.3",
"ethers": "^6.6.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"styled-components": "5.3.3"
"styled-components": "5.3.3",
"vite-plugin-wasm": "^3.2.2"
},
"devDependencies": {
"@metamask/eslint-config": "^10.0.0",
"@metamask/eslint-config-jest": "^10.0.0",
"@metamask/eslint-config-nodejs": "^10.0.0",
"@metamask/eslint-config-typescript": "^10.0.0",
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@svgr/webpack": "^6.4.0",
"@testing-library/dom": "^8.17.1",
"@testing-library/jest-dom": "^5.16.4",
Expand All @@ -52,13 +53,14 @@
"@types/styled-components": "^5.1.25",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"@vitejs/plugin-react": "^4.2.0",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.1.0",
"eslint": "^8.55.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.8.2",
"eslint-plugin-jsdoc": "^39.2.9",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-jsdoc": "^43.0.7",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"gatsby": "^4.25.7",
Expand All @@ -68,6 +70,8 @@
"prettier": "^2.2.1",
"prettier-plugin-packagejson": "^2.2.18",
"rimraf": "^3.0.2",
"typescript": "^4.7.4"
"typescript": "^5.1.0",
"vite": "^4.4.12",
"vite-plugin-svgr": "^4.2.0"
}
}
8 changes: 5 additions & 3 deletions packages/site/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// eslint-disable-next-line import/no-unassigned-import
import './polyfills';
import { FunctionComponent, ReactNode, useContext } from 'react';
import type { FunctionComponent, ReactNode } from 'react';
import { useContext } from 'react';
import styled from 'styled-components';
import { Footer, Header } from './components';

import { Footer, Header } from './components';
import { GlobalStyle } from './config/theme';
import { ToggleThemeContext } from './Root';
import { ToggleThemeContext } from './contexts/ToggleThemeContext';

const Wrapper = styled.div`
display: flex;
Expand Down
9 changes: 3 additions & 6 deletions packages/site/src/components/Buttons.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentProps } from 'react';
import type { ComponentProps } from 'react';
import styled from 'styled-components';
import { MetamaskState } from '../hooks';
import { ReactComponent as FlaskFox } from '../assets/flask_fox.svg';

import type { MetamaskState } from '../hooks';
import { shouldDisplayReconnectButton } from '../utils';

const Link = styled.a`
Expand Down Expand Up @@ -71,15 +71,13 @@ const ConnectedIndicator = styled.div`

export const InstallFlaskButton = () => (
<Link href="https://metamask.io/flask/" target="_blank">
<FlaskFox />
<ButtonText>Install MetaMask Flask</ButtonText>
</Link>
);

export const ConnectButton = (props: ComponentProps<typeof Button>) => {
return (
<Button {...props}>
<FlaskFox />
<ButtonText>Connect</ButtonText>
</Button>
);
Expand All @@ -88,7 +86,6 @@ export const ConnectButton = (props: ComponentProps<typeof Button>) => {
export const ReconnectButton = (props: ComponentProps<typeof Button>) => {
return (
<Button {...props}>
<FlaskFox />
<ButtonText>Reconnect</ButtonText>
</Button>
);
Expand Down
14 changes: 9 additions & 5 deletions packages/site/src/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from 'react';
import type { ReactNode } from 'react';
import styled from 'styled-components';

type CardProps = {
Expand Down Expand Up @@ -45,15 +45,19 @@ const Description = styled.div`
margin-bottom: 2.4rem;
`;

const Actions = styled.div`
display: flex;
gap: 1.6rem;
flex-wrap: wrap;
`;

export const Card = ({ content, disabled = false, fullWidth }: CardProps) => {
const { title, description, button } = content;
return (
<CardWrapper fullWidth={fullWidth} disabled={disabled}>
{title && (
<Title>{title}</Title>
)}
{title && <Title>{title}</Title>}
<Description>{description}</Description>
{button}
<Actions>{button}</Actions>
</CardWrapper>
);
};
3 changes: 1 addition & 2 deletions packages/site/src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled, { useTheme } from 'styled-components';
import { ReactComponent as MetaMaskFox } from '../assets/metamask_fox.svg';

import { MetaMask } from './MetaMask';
import { PoweredBy } from './PoweredBy';

Expand Down Expand Up @@ -36,7 +36,6 @@ export const Footer = () => {
return (
<FooterWrapper>
<PoweredByButton href="https://docs.metamask.io/" target="_blank">
<MetaMaskFox />
<PoweredByContainer>
<PoweredBy color={theme.colors.text.muted} />
<MetaMask color={theme.colors.text.default} />
Expand Down
19 changes: 11 additions & 8 deletions packages/site/src/components/ListConversations.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { Client } from '@xmtp/xmtp-js';
import { Card } from './Card';
import { Button } from './Buttons';
import type { Client } from '@xmtp/xmtp-js';
import { useCallback } from 'react';

import { Button } from './Buttons';
import { Card } from './Card';

export const ListConversations = ({ client }: { client: Client | null }) => {
const handleListConversations = useCallback(async () => {
if (!client) {
return;
}
try {
const conversations = await client.conversations.list();
alert(`Conversations:

${conversations.map((c) => c.peerAddress).join('\n')}`);
} catch (e) {
console.error(e);
const conversationsString = conversations
.map((convo) => convo.peerAddress)
.join('\n');
console.log('CONVERSATIONS =======================');
console.log(conversationsString);
} catch (error) {
console.error(error);
}
}, [client]);

Expand Down
45 changes: 45 additions & 0 deletions packages/site/src/components/ListUserPreferences.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { Client } from '@xmtp/xmtp-js';
import { useCallback } from 'react';

import { Button } from './Buttons';
import { Card } from './Card';

export const ListUserPreferences = ({ client }: { client: Client | null }) => {
const handleList = useCallback(async () => {
if (!client) {
return;
}
try {
const entries = await client.contacts.refreshConsentList();
const entriesString = entries
.map((entry) => `${entry.key}:${entry.permissionType}`)
.join('\n');
console.log('ENTRIES =======================');
console.log(entriesString);
} catch (error) {
console.error(error);
}
}, [client]);

if (!client) {
return null;
}

return (
<Card
content={{
title: 'List user preferences associated with connected client',
description: 'List user preferences',
button: (
<>
<Button onClick={handleList} disabled={!client}>
Execute
</Button>
</>
),
}}
disabled={!client}
fullWidth={false}
/>
);
};
Loading
Loading