-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,098 additions
and
47 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 100 | ||
trim_trailing_whitespace = true | ||
|
||
[*.{css,html,js,jsx,ts,tsx}] | ||
indent_size = 2 | ||
|
||
[*.py] | ||
indent_size = 4 |
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,5 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; |
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { HashRouter } from 'react-router-dom'; | ||
import { MetamaskStateProvider } from 'use-metamask'; | ||
import React, { ReactElement } from 'react'; | ||
|
||
import './styles/index.scss'; | ||
import RootRoutes from './routes/root-routes/root.routes'; | ||
|
||
const App = (): ReactElement => { | ||
// @ts-ignore | ||
const proposalsAddress = import.meta.env.VITE_PROPOSALS_ADDRESS; | ||
import './styles/index.scss'; | ||
|
||
return ( | ||
<div> | ||
<p>Client app.</p> | ||
<p>{proposalsAddress}</p> | ||
</div> | ||
); | ||
}; | ||
const App = (): ReactElement => ( | ||
<HashRouter> | ||
<MetamaskStateProvider> | ||
<RootRoutes /> | ||
</MetamaskStateProvider> | ||
</HashRouter> | ||
); | ||
|
||
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,16 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import ButtonProps from './types'; | ||
|
||
const Button: FC<ButtonProps> = ({ children, label, onClick, type = 'button' }) => ( | ||
<button | ||
onClick={onClick} | ||
// eslint-disable-next-line react/button-has-type | ||
type={type} | ||
> | ||
{children} | ||
{label} | ||
</button> | ||
); | ||
|
||
export default Button; |
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,10 @@ | ||
import { ButtonHTMLAttributes, ReactNode } from 'react'; | ||
|
||
export type ButtonType = ButtonHTMLAttributes<Element>['type']; | ||
|
||
export default interface ButtonProps { | ||
children?: ReactNode; | ||
label?: string; | ||
onClick: () => void; | ||
type?: ButtonType; | ||
} |
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,31 @@ | ||
import { ethers } from 'ethers'; | ||
import { useMetamask } from 'use-metamask'; | ||
import React, { FC } from 'react'; | ||
|
||
import Button from 'components/core/button/button.component'; | ||
|
||
import MainLayoutProps from './types'; | ||
|
||
const MainLayout: FC<MainLayoutProps> = ({ children }) => { | ||
const { | ||
connect, | ||
metaState: { isConnected }, | ||
} = useMetamask(); | ||
|
||
const authUser = async () => { | ||
if (!isConnected) { | ||
await connect(ethers.providers.Web3Provider, 'any'); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div> | ||
<Button label="Connect MetaMask" onClick={authUser} /> | ||
</div> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default MainLayout; |
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 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
export default interface MainLayoutProps { | ||
children: ReactNode; | ||
} |
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,18 @@ | ||
import { Navigate, Route, Routes } from 'react-router-dom'; | ||
import React, { ReactElement } from 'react'; | ||
|
||
import MainLayout from 'layouts/main-layout/main.layout'; | ||
import ProposalsView from 'views/proposals-view/proposals.view'; | ||
|
||
import { ROOT_ROUTES } from './routes'; | ||
|
||
const RootRoutes = (): ReactElement => ( | ||
<MainLayout> | ||
<Routes> | ||
<Route element={<ProposalsView />} path={`${ROOT_ROUTES.proposals.relative}/*`} /> | ||
<Route element={<Navigate to={ROOT_ROUTES.proposals.absolute} />} path="*" /> | ||
</Routes> | ||
</MainLayout> | ||
); | ||
|
||
export default RootRoutes; |
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,7 @@ | ||
import { getPathObject } from 'utils/routing'; | ||
|
||
const ROOT = getPathObject('', ''); | ||
|
||
export const ROOT_ROUTES = { | ||
proposals: getPathObject(ROOT, 'proposals'), | ||
}; |
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,36 @@ | ||
import { getPathObject } from './routing'; | ||
|
||
describe('getPathObject', () => { | ||
it('properly creates base root path object', () => { | ||
expect(getPathObject('', '')).toMatchObject({ | ||
absolute: '/', | ||
relative: '', | ||
}); | ||
}); | ||
it('properly creates path object for "/" given as root', () => { | ||
expect(getPathObject('/', 'test')).toMatchObject({ | ||
absolute: '/test', | ||
relative: 'test', | ||
}); | ||
}); | ||
it('properly creates path object for given relative path', () => { | ||
expect(getPathObject('some-path/some-subpath', 'relative-subpath')).toMatchObject({ | ||
absolute: 'some-path/some-subpath/relative-subpath', | ||
relative: 'relative-subpath', | ||
}); | ||
}); | ||
it('properly creates path object for Path object given as root path', () => { | ||
expect( | ||
getPathObject( | ||
{ | ||
absolute: 'some-path/some-subpath', | ||
relative: 'some-subpath', | ||
}, | ||
'relative-subpath', | ||
), | ||
).toMatchObject({ | ||
absolute: 'some-path/some-subpath/relative-subpath', | ||
relative: 'relative-subpath', | ||
}); | ||
}); | ||
}); |
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,12 @@ | ||
export interface Path { | ||
absolute: string; | ||
relative: string; | ||
} | ||
|
||
export const getPathObject = (root: string | Path, relativePath: string): Path => { | ||
const rootPath = root && typeof root === 'object' ? root.absolute : root; | ||
return { | ||
absolute: rootPath !== '/' ? `${rootPath}/${relativePath}` : `/${relativePath}`, | ||
relative: relativePath, | ||
}; | ||
}; |
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,9 @@ | ||
import React, { ReactElement } from 'react'; | ||
|
||
const ProposalsView = (): ReactElement => { | ||
// @ts-ignore | ||
const proposalsAddress = import.meta.env.VITE_PROPOSALS_ADDRESS; | ||
return <div>ProposalsView {proposalsAddress}</div>; | ||
}; | ||
|
||
export default ProposalsView; |
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
Oops, something went wrong.