From 7364880fb3cd087aed052538a4b915d063838c6e Mon Sep 17 00:00:00 2001 From: Hugo Montenegro Date: Fri, 18 Aug 2023 21:45:19 +0200 Subject: [PATCH] feat: added github prettier action --- .github/workflows/prettier.yml | 27 +++++++++++++++++++++++ src/app/claim/page.tsx | 6 ++--- src/app/layout.tsx | 4 ++-- src/components/claim/claim.tsx | 16 +++++--------- src/components/claim/views/claim.view.tsx | 12 ++-------- src/store/store.tsx | 4 +--- 6 files changed, 41 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/prettier.yml diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 00000000..b05e7e2f --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,27 @@ +name: Continuous Integration + +# This action works with pull requests and pushes +on: + pull_request: + push: + branches: + - main + - staging + - develop + +jobs: + prettier: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + # Make sure the actual branch is checked out when running on pull requests + ref: ${{ github.head_ref }} + + - name: Prettify code + uses: creyD/prettier_action@v4.3 + with: + # This part is also where you can pass other options, for example: + prettier_options: --write --ignore-path .prettierignore --config .prettier.config.js \ No newline at end of file diff --git a/src/app/claim/page.tsx b/src/app/claim/page.tsx index 41e804df..699a275c 100644 --- a/src/app/claim/page.tsx +++ b/src/app/claim/page.tsx @@ -4,10 +4,10 @@ import * as components from '@/components' import { useSearchParams } from 'next/navigation' export default function ClaimPage() { - const pageUrl = typeof window !== 'undefined' ? window.location.href : '' - return ( + const pageUrl = typeof window !== 'undefined' ? window.location.href : '' + return ( ) -} \ No newline at end of file +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index a1703b95..c427be6b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -7,7 +7,7 @@ import { WagmiConfig } from 'wagmi' import * as config from '@/config' import { Store } from '@/store/store' import { useState, useEffect } from 'react' -import ReactGA from "react-ga4"; +import ReactGA from 'react-ga4' const inter = Inter({ subsets: ['latin'] }) @@ -17,7 +17,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) //this useEffect is needed to prevent hydration error when autoConnect in wagmiConfig is true useEffect(() => { setReady(true) - ReactGA.initialize(process.env.GA_KEY ?? ""); + ReactGA.initialize(process.env.GA_KEY ?? '') }, []) return ( diff --git a/src/components/claim/claim.tsx b/src/components/claim/claim.tsx index 2afda459..24d39c09 100644 --- a/src/components/claim/claim.tsx +++ b/src/components/claim/claim.tsx @@ -58,11 +58,11 @@ export function Claim({ link }: { link: string }) { const checkLink = async (link: string) => { console.log(link) - const [baseUrl, fragment] = link.split('#'); + const [baseUrl, fragment] = link.split('#') console.log('baseUrl', baseUrl) console.log('fragment', fragment) - const urlSearchParams = new URLSearchParams(fragment); - const linkChainId = urlSearchParams.get('c'); + const urlSearchParams = new URLSearchParams(fragment) + const linkChainId = urlSearchParams.get('c') // const linkChainId = link.get('c') // get the chain id from the link (params are after #) // const urlSearchParams = new URLSearchParams(link); @@ -78,16 +78,12 @@ export function Claim({ link }: { link: string }) { const provider = getEthersProvider({ chainId: Number(linkChainId) }) console.log('provider', provider) console.log('linkChainId', linkChainId) - + try { console.log('getting link details') - const linkDetails: interfaces.ILinkDetails = await peanut.getLinkDetails( - provider, - pageUrl, - true - ) + const linkDetails: interfaces.ILinkDetails = await peanut.getLinkDetails(provider, pageUrl, true) console.log('linkDetails', linkDetails) - + if (Number(linkDetails.tokenAmount) <= 0) { setLinkState('ALREADY_CLAIMED') } else { diff --git a/src/components/claim/views/claim.view.tsx b/src/components/claim/views/claim.view.tsx index 800c694b..ec99862a 100644 --- a/src/components/claim/views/claim.view.tsx +++ b/src/components/claim/views/claim.view.tsx @@ -64,11 +64,7 @@ export function ClaimView({ onNextScreen, claimDetails, claimLink, setTxHash }: if (claimLink && address) { setLoadingStates('executing transaction...') console.log('claiming link:' + claimLink) - const claimTx = await peanut.claimLinkGasless( - claimLink, - address, - process.env.PEANUT_API_KEY - ) + const claimTx = await peanut.claimLinkGasless(claimLink, address, process.env.PEANUT_API_KEY) console.log(claimTx) setTxHash(claimTx.tx_hash ?? claimTx.transactionHash ?? claimTx.hash ?? '') onNextScreen() @@ -131,11 +127,7 @@ export function ClaimView({ onNextScreen, claimDetails, claimLink, setTxHash }: setLoadingStates('executing transaction...') if (claimLink && data.address) { console.log('claiming link:' + claimLink) - const claimTx = await peanut.claimLinkGasless( - claimLink, - data.address, - process.env.PEANUT_API_KEY - ) + const claimTx = await peanut.claimLinkGasless(claimLink, data.address, process.env.PEANUT_API_KEY) setTxHash(claimTx.tx_hash ?? claimTx.transactionHash ?? claimTx.hash ?? '') onNextScreen() diff --git a/src/store/store.tsx b/src/store/store.tsx index c6b85190..7fbdadb1 100644 --- a/src/store/store.tsx +++ b/src/store/store.tsx @@ -56,9 +56,7 @@ export function Store({ children }: { children: React.ReactNode }) { const getPeanutChainAndTokenDetails = async () => { if (peanut) { - const chainDetailsArray = Object.keys(peanut.CHAIN_DETAILS).map( - (key) => peanut.CHAIN_DETAILS[key] - ) + const chainDetailsArray = Object.keys(peanut.CHAIN_DETAILS).map((key) => peanut.CHAIN_DETAILS[key]) const tokenDetailsArray = peanut.TOKEN_DETAILS setDefaultChainDetails(chainDetailsArray) setDefaultTokenDetails(tokenDetailsArray)