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
const rpcUrl = CHAIN_CONFIGS[1].rpcUrls[0]; | |
const provider = new providers.StaticJsonRpcProvider(rpcUrl, 1); | |
const UniswapV3Pool = await import('../../config/abi/UniswapV3Pool.json'); | |
const sxUsdcPoolAddress = "0xCb3b931E1e02C26399aCc651bFD9c8c4385EECd0"; | |
const ethUsdcPoolAddress = "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8"; | |
const sxUsdcPoolContract = new Contract(sxUsdcPoolAddress, UniswapV3Pool.abi, provider); | |
const ethUsdcPoolContract = new Contract(ethUsdcPoolAddress, UniswapV3Pool.abi, provider); |
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
import Web3 from 'web3'; | |
export const getMetamask = (windowObject) => { | |
if(!windowObject.web3) { | |
return false | |
} | |
return windowObject.web3; | |
} |
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
class Spiderman { | |
lookOut() { | |
alert('My Spider-Sense is tingling.'); | |
} | |
} | |
let miles = new Spiderman(); | |
miles.lookOut(); |
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
import axios from 'axios'; | |
/** | |
* Pull public gists from a Github user by their username | |
* @param {string} username Github username | |
*/ | |
export const getGistsByUsername = async (username) => { | |
try { | |
let response = await axios({ |
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
// useSockets.js | |
import React, { | |
useState | |
} from 'react'; | |
import io from 'socket.io-client'; | |
export default function useSocket() { | |
const [Socket, setSocket] = useState(null); |
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
const RandomNumberGenerator = () => { | |
const [number, setNumber] = useState(Math.random()); | |
const regenerate = () => { | |
setNumber(Math.random()); | |
} | |
const RandomNumber = () => { | |
return number; | |
} | |
return { regenerate, RandomNumber }; |
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
import React from 'react'; | |
import { act, renderHook } from '@testing-library/react-hooks'; // Don't forget to install this package | |
import { useValue } from "./useValue"; | |
it("Custom hook hooks:)", () => { | |
const { result } = renderHook(useValue); | |
act(() => { | |
result.current.assignValue('Hello World'); | |
}); | |
expect(result.current.value).toBe('Hello World'); |
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
// LoginPage.js | |
import React from 'react'; | |
import { LoginForm } from 'LoginForm'; | |
import { useValue } from 'useValue'; | |
export default function LoginPage() { | |
const { value, assignValue } = useValue(false); // Calling our custom hook; false is the initial value this time around |
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
import React from 'react'; | |
import { LoginForm } from 'LoginForm'; | |
import { useValue } from 'useValue'; | |
export default function LoginPage() { | |
const { value, assignValue } = useValue(false); // Calling our custom hook; false is the initial value this time around | |
function handleSubmit() { | |
assignValue(true); |
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
// LoginForm.js | |
import React from 'react'; | |
import { useValue } from './useValue'; | |
export function LoginForm({ handleSubmit }) { | |
const { value, assignValue } = useValue(''); // empty string is the initial value; | |
function handleChange(e) { |
NewerOlder