This repository has been archived by the owner on Jun 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(init): Initialize project with default template
- Loading branch information
1 parent
dbf4d01
commit d4b59d7
Showing
21 changed files
with
11,985 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# dhedge-gnosis-safe-app | ||
Interface for Gnosis Safe integration | ||
|
||
[Getting Started](app/README.md). |
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 @@ | ||
PORT=3000 | ||
HTTPS=true | ||
REACT_APP_INFURA_ID= |
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,24 @@ | ||
# 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 | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
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,51 @@ | ||
# My Safe App | ||
|
||
## Getting Started | ||
|
||
Install dependencies and start a local dev server. | ||
|
||
``` | ||
yarn install | ||
cp .env.sample .env | ||
yarn start | ||
``` | ||
|
||
Then: | ||
|
||
- If HTTPS is used (by default enabled) | ||
- Open your Safe app locally (by default via https://localhost:3000/) and accept the SSL error. | ||
- Go to Safe Multisig web interface | ||
- [Mainnet](https://app.gnosis-safe.io) | ||
- [Rinkeby](https://rinkeby.gnosis-safe.io/app) | ||
- Create your test safe | ||
- Go to Apps -> Manage Apps -> Add Custom App | ||
- Paste your localhost URL, default is https://localhost:3000/ | ||
- You should see Safe App Starter as a new app | ||
- Develop your app from there | ||
|
||
## Features | ||
|
||
Gnosis Safe App Starter combines recommendations described in the following repositories: | ||
|
||
- [Safe Apps SDK](https://github.com/gnosis/safe-apps-sdk) | ||
- [safe-react-components](https://github.com/gnosis/safe-react-components) | ||
|
||
You can use the `useSafe` React hook to interact with the Safe Apps SDK | ||
|
||
``` | ||
const safe = useSafe(); | ||
console.log(safe.info); | ||
``` | ||
|
||
Safe React Components are also integrated and ready to use. [See all components](https://components.gnosis-safe.io/). | ||
|
||
## Dependencies | ||
|
||
### Included | ||
- [`@gnosis.pm/safe-react-components`](https://github.com/gnosis/safe-react-components) (UI components themed for the Safe Multisig interface) | ||
- [`@rmeissner/safe-apps-react-sdk`](https://github.com/rmeissner/safe-sdks-js/tree/master/safe-apps-react-sdk) (React hook for the Safe Apps SDK) | ||
|
||
### Recommended | ||
- [`ethers`](https://github.com/ethers-io/ethers.js) (Library for interacting with Ethereum) | ||
- [`web3`](https://github.com/ethereum/web3.js/) (Library for interacting with Ethereum) | ||
- [`@studydefi/money-legos`](https://github.com/studydefi/money-legos) (Library for DeFi interactions) |
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 @@ | ||
module.exports = { | ||
webpack: function (config, env) { | ||
return config; | ||
}, | ||
jest: function (config) { | ||
return config; | ||
}, | ||
devServer: function (configFunction) { | ||
return function (proxy, allowedHost) { | ||
const config = configFunction(proxy, allowedHost); | ||
|
||
config.headers = { | ||
"Access-Control-Allow-Origin": "*", | ||
"Access-Control-Allow-Methods": "GET", | ||
"Access-Control-Allow-Headers": | ||
"X-Requested-With, content-type, Authorization", | ||
}; | ||
|
||
return config; | ||
}; | ||
}, | ||
paths: function (paths, env) { | ||
return paths; | ||
}, | ||
}; |
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,53 @@ | ||
{ | ||
"name": "app", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@gnosis.pm/safe-apps-sdk": "^0.3.1", | ||
"@gnosis.pm/safe-react-components": "^0.2.0", | ||
"@material-ui/core": "^4.11.0", | ||
"@rmeissner/safe-apps-react-sdk": "0.4.0", | ||
"@testing-library/jest-dom": "^5.11.4", | ||
"@testing-library/react": "^10.4.9", | ||
"@testing-library/user-event": "^12.1.3", | ||
"@types/jest": "^26.0.10", | ||
"@types/node": "^14.6.2", | ||
"@types/react": "^16.9.0", | ||
"@types/react-dom": "^16.9.0", | ||
"@types/styled-components": "^5.1.2", | ||
"react": "^16.13.1", | ||
"react-app-rewired": "^2.1.6", | ||
"react-dom": "^16.13.1", | ||
"react-scripts": "3.4.3", | ||
"styled-components": "^5.1.1", | ||
"typescript": "~4.0.2" | ||
}, | ||
"scripts": { | ||
"start": "react-app-rewired start", | ||
"build": "react-app-rewired build", | ||
"test": "react-app-rewired test", | ||
"eject": "react-scripts eject" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"plugin:jsx-a11y/recommended" | ||
], | ||
"plugins": [ | ||
"jsx-a11y" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"homepage": "./" | ||
} |
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,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>Gnosis Safe 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> |
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.
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,27 @@ | ||
{ | ||
"short_name": "Safe App", | ||
"name": "Gnosis Safe App Starter", | ||
"description": "Describe your Safe App here", | ||
"iconPath": "logo.svg", | ||
"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,51 @@ | ||
import React, { useCallback, useState } from 'react'; | ||
import styled from "styled-components"; | ||
import { Button, Loader, Title } from "@gnosis.pm/safe-react-components"; | ||
import { useSafe } from '@rmeissner/safe-apps-react-sdk'; | ||
|
||
const Container = styled.form` | ||
margin-bottom: 2rem; | ||
width: 100%; | ||
max-width: 480px; | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
grid-column-gap: 1rem; | ||
grid-row-gap: 1rem; | ||
`; | ||
|
||
const App: React.FC = () => { | ||
const safe = useSafe() | ||
const [submitting, setSubmitting] = useState(false) | ||
const submitTx = useCallback(async () => { | ||
setSubmitting(true) | ||
try { | ||
const safeTxHash = await safe.sendTransactions([ | ||
{ | ||
"to": safe.info.safeAddress, | ||
"value": "0", | ||
"data": "0x" | ||
} | ||
]) | ||
console.log({safeTxHash}) | ||
const safeTx = await safe.loadSafeTransaction(safeTxHash) | ||
console.log({safeTx}) | ||
} catch (e) { | ||
console.error(e) | ||
} | ||
setSubmitting(false) | ||
}, [safe]) | ||
return <Container> | ||
<Title size="md">{safe.info.safeAddress}</Title> | ||
{submitting ? | ||
<> | ||
<Loader size="md" /><br/> | ||
<Button size="lg" color="secondary" onClick={() => {setSubmitting(false)}}>Cancel</Button> | ||
</> | ||
: | ||
<Button size="lg" color="primary" onClick={submitTx}>Submit</Button> | ||
} | ||
</Container> | ||
}; | ||
|
||
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,34 @@ | ||
import { createGlobalStyle } from "styled-components"; | ||
import avertaFont from "@gnosis.pm/safe-react-components/dist/fonts/averta-normal.woff2"; | ||
import avertaBoldFont from "@gnosis.pm/safe-react-components/dist/fonts/averta-bold.woff2"; | ||
|
||
const GlobalStyle = createGlobalStyle` | ||
html { | ||
height: 100% | ||
} | ||
body { | ||
height: 100%; | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
#root { | ||
height: 100%; | ||
padding-right: 0.5rem; | ||
} | ||
.MuiFormControl-root, | ||
.MuiInputBase-root { | ||
width: 100% !important; | ||
} | ||
@font-face { | ||
font-family: 'Averta'; | ||
src: local('Averta'), local('Averta Bold'), | ||
url(${avertaFont}) format('woff2'), | ||
url(${avertaBoldFont}) format('woff'); | ||
} | ||
`; | ||
|
||
export default GlobalStyle; |
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,2 @@ | ||
declare module "*.woff"; | ||
declare module "*.woff2"; |
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,27 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import { ThemeProvider } from "styled-components"; | ||
import { theme } from "@gnosis.pm/safe-react-components"; | ||
import { Loader, Title } from "@gnosis.pm/safe-react-components"; | ||
import SafeProvider from '@rmeissner/safe-apps-react-sdk'; | ||
|
||
|
||
import GlobalStyle from "./GlobalStyle"; | ||
import App from "./App"; | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<ThemeProvider theme={theme}> | ||
<GlobalStyle /> | ||
<SafeProvider loading={( | ||
<> | ||
<Title size="md">Waiting for Safe...</Title> | ||
<Loader size="md" /> | ||
</> | ||
)}> | ||
<App /> | ||
</SafeProvider> | ||
</ThemeProvider> | ||
</React.StrictMode>, | ||
document.getElementById("root") | ||
); |
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 @@ | ||
/// <reference types="react-scripts" /> |
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,5 @@ | ||
// jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
// allows you to do things like: | ||
// expect(element).toHaveTextContent(/react/i) | ||
// learn more: https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom/extend-expect'; |
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,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"jsx": "react" | ||
}, | ||
"include": ["src"], | ||
"exclude": ["node_modules"] | ||
} |
Oops, something went wrong.