forked from project-serum/spl-token-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
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
12 changed files
with
2,085 additions
and
1,142 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 |
---|---|---|
|
@@ -21,3 +21,5 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.idea |
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
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
import React from 'react'; | ||
import Toolbar from '@material-ui/core/Toolbar'; | ||
import AppBar from '@material-ui/core/AppBar'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
content: { | ||
paddingTop: theme.spacing(3), | ||
paddingBottom: theme.spacing(3), | ||
}, | ||
})); | ||
|
||
export default function NavigationFrame({ children }) { | ||
const classes = useStyles(); | ||
return ( | ||
<> | ||
<AppBar position="static"> | ||
<Toolbar> | ||
<Typography variant="h6">Solana SPL Wallet</Typography> | ||
</Toolbar> | ||
</AppBar> | ||
<main className={classes.content}>{children}</main> | ||
</> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
import React, { useContext, useMemo } from 'react'; | ||
import { clusterApiUrl, Connection } from '@solana/web3.js'; | ||
import { useLocalStorageState } from './utils'; | ||
|
||
const ConnectionContext = React.createContext(null); | ||
|
||
export function ConnectionProvider({ children }) { | ||
const [endpoint, setEndpoint] = useLocalStorageState( | ||
'endpoint', | ||
clusterApiUrl('devnet'), | ||
); | ||
|
||
const connection = useMemo(() => new Connection(endpoint), [endpoint]); | ||
|
||
return ( | ||
<ConnectionContext.Provider value={{ endpoint, setEndpoint, connection }}> | ||
{children} | ||
</ConnectionContext.Provider> | ||
); | ||
} | ||
|
||
export function useConnection() { | ||
return useContext(ConnectionContext).connection; | ||
} |
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,33 @@ | ||
import { useCallback, useState } from 'react'; | ||
|
||
export async function sleep(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
|
||
export function useLocalStorageState(key, defaultState = null) { | ||
const [state, setState] = useState(() => { | ||
let storedState = localStorage.getItem(key); | ||
if (storedState) { | ||
return JSON.parse(storedState); | ||
} | ||
return defaultState; | ||
}); | ||
|
||
const setLocalStorageState = useCallback( | ||
(newState) => { | ||
let changed = state !== newState; | ||
if (!changed) { | ||
return; | ||
} | ||
setState(state); | ||
if (newState === null) { | ||
localStorage.removeItem(key); | ||
} else { | ||
localStorage.setItem(key, JSON.stringify(newState)); | ||
} | ||
}, | ||
[state, key], | ||
); | ||
|
||
return [state, setLocalStorageState]; | ||
} |
Oops, something went wrong.