-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Developer UI: Header, connect a provider (#134)
* signer wip * signer wip * signer wip * wip * da mvp * dep bump * Signer wip * ethers signer * remove yalc from signer * remove console.logs * change ethersprovider version * add docs * type fixes * utils/poll: remove double increment * dep updatE * doc fix * remove jsonrpc error check logic in checkError * ui: hello world * safe dev ui: hello world * pin jest version to the one required by react-scripts * test script fix * dep bump * use jest 26.6.0 * bootstrapping * wip * wip * wip * dep bump * wip * trying to make header work * got this thing to render * logo alignment * a battle with changing default font family in mui * a battle with font scaling * header * header battle continues * material ui warning fixes * Fix web3modal * provider store wip * provider store wip * provider details wip * provider details wip * wip: * connected account details * connect/disconnect provider * change node version for tesT * dep update * dep update * import casing fix * remove test * Eslint fix * remove unused stuff * remove unused stuff * add props to provider
- Loading branch information
Showing
55 changed files
with
15,395 additions
and
7,981 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ dist | |
.idea | ||
.vscode | ||
lerna-debug.log | ||
yalc.lock | ||
yalc.lock | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Getting Started with Create React App | ||
|
||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `yarn start` | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.\ | ||
You will also see any lint errors in the console. | ||
|
||
### `yarn test` | ||
|
||
Launches the test runner in the interactive watch mode.\ | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `yarn build` | ||
|
||
Builds the app for production to the `build` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.\ | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `yarn eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"name": "@gnosis.pm/safe-apps-developer-ui", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@gnosis.pm/safe-apps-react-sdk": "2.1.0", | ||
"@material-ui/core": "^4.11.3", | ||
"@material-ui/icons": "^4.11.2", | ||
"@testing-library/jest-dom": "^5.11.4", | ||
"@testing-library/react": "^11.1.0", | ||
"@testing-library/user-event": "^12.8.3", | ||
"@types/styled-components": "^5.1.7", | ||
"@walletconnect/web3-provider": "^1.3.6", | ||
"clsx": "^1.1.1", | ||
"ethereum-blockies-base64": "^1.0.2", | ||
"ethers": "^5.0.32", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"react-router": "^5.2.0", | ||
"react-router-dom": "^5.2.0", | ||
"react-scripts": "4.0.3", | ||
"styled-components": "^5.2.1", | ||
"web3modal": "1.9.3", | ||
"zustand": "^3.3.3" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --passWithNoTests", | ||
"eject": "react-scripts eject" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.15", | ||
"@types/node": "^14.14.33", | ||
"@types/react": "^17.0.3", | ||
"@types/react-dom": "^17.0.2", | ||
"@types/react-router": "^5.1.12", | ||
"@types/react-router-dom": "^5.1.7", | ||
"eslint-config-react-app": "^6.0.0", | ||
"eslint-plugin-flowtype": "^5.3.1", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-jsx-a11y": "^6.3.1", | ||
"eslint-plugin-react": "^7.22.0", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"web-vitals": "^1.0.1" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!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>Gnosis Safe Developer</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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
import Header from 'src/components/Header'; | ||
|
||
function App(): React.ReactElement { | ||
return ( | ||
<Router> | ||
<div className="App"> | ||
<Header /> | ||
</div> | ||
</Router> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Web3Modal, { IProviderOptions } from 'web3modal'; | ||
import WalletConnectProvider from '@walletconnect/web3-provider'; | ||
|
||
const WALLET_PROVIDER = { | ||
SAFE: 'SAFE', | ||
METAMASK: 'METAMASK', | ||
REMOTE: 'REMOTE', | ||
TORUS: 'TORUS', | ||
PORTIS: 'PORTIS', | ||
FORTMATIC: 'FORTMATIC', | ||
SQUARELINK: 'SQUARELINK', | ||
WALLETCONNECT: 'WALLETCONNECT', | ||
OPERA: 'OPERA', | ||
WALLETLINK: 'WALLETLINK', | ||
AUTHEREUM: 'AUTHEREUM', | ||
LEDGER: 'LEDGER', | ||
TREZOR: 'TREZOR', | ||
LATTICE: 'LATTICE', | ||
UNKNOWN: 'UNKNOWN', | ||
}; | ||
|
||
enum ETHEREUM_NETWORK_TO_ID { | ||
MAINNET = 1, | ||
MORDEN = 2, | ||
ROPSTEN = 3, | ||
RINKEBY = 4, | ||
GOERLI = 5, | ||
KOVAN = 42, | ||
XDAI = 100, | ||
ENERGY_WEB_CHAIN = 246, | ||
VOLTA = 73799, | ||
UNKNOWN = 0, | ||
LOCAL = 4447, | ||
} | ||
|
||
const providerOptions: IProviderOptions = { | ||
walletconnect: { | ||
package: WalletConnectProvider, | ||
options: { | ||
infuraId: '82b8340f4bd146a2bfc606609ffbec41', | ||
}, | ||
}, | ||
}; | ||
|
||
const web3Modal = new Web3Modal({ network: 'rinkeby', providerOptions }); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const connectToProvider = async (): Promise<any> => { | ||
const provider = await web3Modal.connect(); | ||
console.log({ provider }); | ||
return provider; | ||
}; | ||
|
||
export { WALLET_PROVIDER, ETHEREUM_NETWORK_TO_ID, connectToProvider }; |
Binary file added
BIN
+48.9 KB
packages/safe-apps-developer-ui/src/assets/fonts/Averta-ExtraBold.woff2
Binary file not shown.
Binary file not shown.
30 changes: 30 additions & 0 deletions
30
packages/safe-apps-developer-ui/src/components/ConnectButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { Web3Provider } from '@ethersproject/providers'; | ||
|
||
import Button from '@material-ui/core/Button'; | ||
import { connectToProvider } from '../api/provider'; | ||
import { useProviderStore } from 'src/stores/provider'; | ||
|
||
const SButton = styled(Button)` | ||
min-width: 140px; | ||
`; | ||
|
||
const ConnectButton = (): React.ReactElement => { | ||
const fetchAndSetProvider = useProviderStore((state) => state.fetchAndSetProvider); | ||
|
||
const handleClick = async () => { | ||
const connection = await connectToProvider(); | ||
const provider = new Web3Provider(connection); | ||
|
||
fetchAndSetProvider(provider); | ||
}; | ||
|
||
return ( | ||
<SButton color="primary" type="button" onClick={handleClick} variant="contained"> | ||
Connect | ||
</SButton> | ||
); | ||
}; | ||
|
||
export default ConnectButton; |
3 changes: 3 additions & 0 deletions
3
packages/safe-apps-developer-ui/src/components/Header/assets/dotRinkeby.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
...fe-apps-developer-ui/src/components/Header/assets/gnosis-safe-multisig-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/safe-apps-developer-ui/src/components/Header/assets/key.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/safe-apps-developer-ui/src/components/Header/assets/triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/safe-apps-developer-ui/src/components/Header/assets/wallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions
22
packages/safe-apps-developer-ui/src/components/Header/components/CircleDot.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
type Props = { | ||
className: string; | ||
}; | ||
|
||
const CircleDot = (props: Props): React.ReactElement => ( | ||
<div className={props.className}> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10"> | ||
<circle | ||
cx="208" | ||
cy="203" | ||
r="3" | ||
fill="none" | ||
fillRule="evenodd" | ||
stroke="#FF685E" | ||
strokeWidth="3" | ||
transform="translate(-203 -198)" | ||
/> | ||
</svg> | ||
</div> | ||
); | ||
|
||
export { CircleDot }; |
Oops, something went wrong.