lp_ui: hello world stack
Change-Id: I966a1829e549c90c9b1dd01e403db7b31a18cb46
This commit is contained in:
parent
88dfab6e29
commit
5b51dffe6d
|
@ -0,0 +1,23 @@
|
|||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
|
@ -0,0 +1,28 @@
|
|||
## Prerequisites
|
||||
|
||||
- Docker
|
||||
- NodeJS v14+
|
||||
|
||||
Run the following from the root of this repo
|
||||
|
||||
```bash
|
||||
DOCKER_BUILDKIT=1 docker build -- --target node-export -f Dockerfile.proto -o type=local,dest=. .
|
||||
DOCKER_BUILDKIT=1 docker build -- -f Dockerfile.wasm -o type=local,dest=.. .
|
||||
npm ci --prefix ethereum
|
||||
npm ci --prefix sdk/js
|
||||
npm run build --prefix sdk/js
|
||||
```
|
||||
|
||||
The remaining steps can be run from this folder
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
```
|
||||
|
||||
## Develop
|
||||
|
||||
```bash
|
||||
npm start
|
||||
```
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"name": "lp_ui",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@certusone/wormhole-sdk": "file:..\\sdk\\js",
|
||||
"@material-ui/core": "^4.12.2",
|
||||
"@material-ui/icons": "^4.11.2",
|
||||
"@material-ui/lab": "^4.0.0-alpha.60",
|
||||
"@solana/spl-token": "^0.1.6",
|
||||
"@solana/spl-token-registry": "^0.2.216",
|
||||
"@solana/wallet-adapter-base": "^0.4.1",
|
||||
"@solana/wallet-adapter-material-ui": "^0.7.1",
|
||||
"@solana/wallet-adapter-phantom": "^0.4.1",
|
||||
"@solana/wallet-adapter-react": "^0.7.1",
|
||||
"@solana/wallet-adapter-wallets": "^0.6.1",
|
||||
"@solana/wallet-base": "^0.0.1",
|
||||
"@solana/web3.js": "^1.24.1",
|
||||
"@testing-library/jest-dom": "^5.11.4",
|
||||
"@testing-library/react": "^11.1.0",
|
||||
"@testing-library/user-event": "^12.1.10",
|
||||
"@types/node": "^16.9.1",
|
||||
"@types/react": "^17.0.20",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "4.0.3",
|
||||
"typescript": "^4.4.2",
|
||||
"web-vitals": "^1.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
|
@ -0,0 +1,7 @@
|
|||
import Main from "./views/Main";
|
||||
|
||||
function App() {
|
||||
return <Main />;
|
||||
}
|
||||
|
||||
export default App;
|
|
@ -0,0 +1,40 @@
|
|||
import {
|
||||
Container,
|
||||
makeStyles,
|
||||
Typography,
|
||||
Paper,
|
||||
Button,
|
||||
} from "@material-ui/core";
|
||||
import { useEffect } from "react";
|
||||
import SolanaWalletKey from "../components/SolanaWalletKey";
|
||||
import { useLogger } from "../contexts/Logger";
|
||||
import { useSolanaWallet } from "../contexts/SolanaWalletContext";
|
||||
|
||||
const useStyles = makeStyles(() => ({}));
|
||||
|
||||
function LogWatcher() {
|
||||
const { logs, clear, log } = useLogger();
|
||||
|
||||
useEffect(() => {
|
||||
log("Instantiated the logger.");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Paper style={{ padding: "1rem", maxHeight: "600px", overflow: "auto" }}>
|
||||
<Typography variant="h5">Logs</Typography>
|
||||
{logs.map((x) => (
|
||||
<Typography>{x}</Typography>
|
||||
))}
|
||||
<Button
|
||||
onClick={clear}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
style={{ marginTop: "2rem" }}
|
||||
>
|
||||
Clear All Logs
|
||||
</Button>
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
|
||||
export default LogWatcher;
|
|
@ -0,0 +1,37 @@
|
|||
import { makeStyles } from "@material-ui/core";
|
||||
import DisconnectIcon from "@material-ui/icons/LinkOff";
|
||||
import {
|
||||
WalletDisconnectButton,
|
||||
WalletMultiButton,
|
||||
} from "@solana/wallet-adapter-material-ui";
|
||||
import { useSolanaWallet } from "../contexts/SolanaWalletContext";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
textAlign: "center",
|
||||
margin: `${theme.spacing(1)}px auto`,
|
||||
width: "100%",
|
||||
maxWidth: 400,
|
||||
},
|
||||
disconnectButton: {
|
||||
marginLeft: theme.spacing(1),
|
||||
},
|
||||
}));
|
||||
|
||||
const SolanaWalletKey = () => {
|
||||
const classes = useStyles();
|
||||
const wallet = useSolanaWallet();
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<WalletMultiButton />
|
||||
{wallet && (
|
||||
<WalletDisconnectButton
|
||||
startIcon={<DisconnectIcon />}
|
||||
className={classes.disconnectButton}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SolanaWalletKey;
|
|
@ -0,0 +1,49 @@
|
|||
import React, {
|
||||
ReactChildren,
|
||||
useCallback,
|
||||
useContext,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
interface LoggerContext {
|
||||
log: (value: string) => void;
|
||||
clear: () => void;
|
||||
logs: string[];
|
||||
}
|
||||
|
||||
const LoggerProviderContext = React.createContext<LoggerContext>({
|
||||
log: (value: string) => {},
|
||||
clear: () => {},
|
||||
logs: [],
|
||||
});
|
||||
|
||||
export const LoggerProvider = ({ children }: { children: ReactChildren }) => {
|
||||
const [logs, setLogs] = useState<string[]>([]);
|
||||
const clear = useCallback(() => setLogs([]), [setLogs]);
|
||||
const log = useCallback(
|
||||
(value: string) => {
|
||||
const newLogs = logs.slice();
|
||||
newLogs.push(value);
|
||||
setLogs(newLogs);
|
||||
},
|
||||
[logs, setLogs]
|
||||
);
|
||||
|
||||
const contextValue = useMemo(
|
||||
() => ({
|
||||
logs,
|
||||
clear,
|
||||
log,
|
||||
}),
|
||||
[logs, clear, log]
|
||||
);
|
||||
return (
|
||||
<LoggerProviderContext.Provider value={contextValue}>
|
||||
{children}
|
||||
</LoggerProviderContext.Provider>
|
||||
);
|
||||
};
|
||||
export const useLogger = () => {
|
||||
return useContext(LoggerProviderContext);
|
||||
};
|
|
@ -0,0 +1,20 @@
|
|||
import { WalletDialogProvider } from "@solana/wallet-adapter-material-ui";
|
||||
import { useWallet, WalletProvider } from "@solana/wallet-adapter-react";
|
||||
import { getPhantomWallet } from "@solana/wallet-adapter-wallets";
|
||||
import React, { FC, useMemo } from "react";
|
||||
|
||||
export const SolanaWalletProvider: FC = (props) => {
|
||||
// @solana/wallet-adapter-wallets includes all the adapters but supports tree shaking --
|
||||
// Only the wallets you want to instantiate here will be compiled into your application
|
||||
const wallets = useMemo(() => {
|
||||
return [getPhantomWallet()];
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<WalletProvider wallets={wallets}>
|
||||
<WalletDialogProvider>{props.children}</WalletDialogProvider>
|
||||
</WalletProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useSolanaWallet = useWallet;
|
|
@ -0,0 +1,18 @@
|
|||
import { CssBaseline } from "@material-ui/core";
|
||||
import { ThemeProvider } from "@material-ui/core/styles";
|
||||
import ReactDOM from "react-dom";
|
||||
import App from "./App";
|
||||
import { LoggerProvider } from "./contexts/Logger";
|
||||
import { SolanaWalletProvider } from "./contexts/SolanaWalletContext";
|
||||
import { theme } from "./muiTheme";
|
||||
ReactDOM.render(
|
||||
<ThemeProvider theme={theme}>
|
||||
<CssBaseline />
|
||||
<SolanaWalletProvider>
|
||||
<LoggerProvider>
|
||||
<App />
|
||||
</LoggerProvider>
|
||||
</SolanaWalletProvider>
|
||||
</ThemeProvider>,
|
||||
document.getElementById("root")
|
||||
);
|
|
@ -0,0 +1,38 @@
|
|||
import { createTheme, responsiveFontSizes } from "@material-ui/core";
|
||||
|
||||
export const theme = responsiveFontSizes(
|
||||
createTheme({
|
||||
palette: {
|
||||
type: "dark",
|
||||
background: {
|
||||
default: "#080808",
|
||||
paper: "#020202",
|
||||
},
|
||||
divider: "#4e4e54",
|
||||
text: {
|
||||
primary: "rgba(255,255,255,0.98)",
|
||||
},
|
||||
primary: {
|
||||
main: "rgba(0, 116, 255, 0.8)", // #0074FF
|
||||
},
|
||||
secondary: {
|
||||
main: "rgb(0,239,216,0.8)", // #00EFD8
|
||||
light: "rgb(51, 242, 223, 1)",
|
||||
},
|
||||
error: {
|
||||
main: "#FD3503",
|
||||
},
|
||||
},
|
||||
typography: {
|
||||
fontFamily: "'Sora', sans-serif",
|
||||
},
|
||||
overrides: {
|
||||
MuiButton: {
|
||||
root: {
|
||||
borderRadius: 0,
|
||||
textTransform: "none",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
|
@ -0,0 +1 @@
|
|||
/// <reference types="react-scripts" />
|
|
@ -0,0 +1 @@
|
|||
export const value = "";
|
|
@ -0,0 +1,55 @@
|
|||
import {
|
||||
Container,
|
||||
makeStyles,
|
||||
Typography,
|
||||
Paper,
|
||||
Tab,
|
||||
} from "@material-ui/core";
|
||||
import { useCallback, useState } from "react";
|
||||
import LogWatcher from "../components/LogWatcher";
|
||||
import SolanaWalletKey from "../components/SolanaWalletKey";
|
||||
import { useSolanaWallet } from "../contexts/SolanaWalletContext";
|
||||
import TabContext from "@material-ui/lab/TabContext";
|
||||
import TabList from "@material-ui/lab/TabList";
|
||||
import TabPanel from "@material-ui/lab/TabPanel";
|
||||
|
||||
const useStyles = makeStyles(() => ({}));
|
||||
|
||||
function Main() {
|
||||
const classes = useStyles();
|
||||
const wallet = useSolanaWallet();
|
||||
const [selectedTab, setSelectedTab] = useState("createPool");
|
||||
const handleChange = useCallback(
|
||||
(event, value) => {
|
||||
setSelectedTab(value);
|
||||
},
|
||||
[setSelectedTab]
|
||||
);
|
||||
|
||||
const content = !wallet.publicKey ? (
|
||||
<Typography>Please connect your wallet.</Typography>
|
||||
) : (
|
||||
<TabContext value={selectedTab}>
|
||||
<TabList onChange={handleChange} aria-label="simple tabs example">
|
||||
<Tab label="Create Pool" value="createPool" />
|
||||
<Tab label="Add Liquidity" value="Add Liquidity" />
|
||||
<Tab label="Redeem Liquidity" value="Redeem Liquidity" />
|
||||
</TabList>
|
||||
<TabPanel value="1">Item One</TabPanel>
|
||||
<TabPanel value="2">Item Two</TabPanel>
|
||||
<TabPanel value="3">Item Three</TabPanel>
|
||||
</TabContext>
|
||||
);
|
||||
|
||||
return (
|
||||
<Container maxWidth="md">
|
||||
<Paper style={{ padding: "3rem" }}>
|
||||
<SolanaWalletKey />
|
||||
{content}
|
||||
</Paper>
|
||||
<LogWatcher />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
export default Main;
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"downlevelIteration": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue