Skip to content

Commit

Permalink
feat: added github prettier action
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo0 committed Aug 18, 2023
1 parent 99c9f8b commit 7364880
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 28 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions src/app/claim/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<global_components.PageWrapper>
<components.Claim link={pageUrl} />
</global_components.PageWrapper>
)
}
}
4 changes: 2 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'] })

Expand All @@ -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 (
Expand Down
16 changes: 6 additions & 10 deletions src/components/claim/claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
12 changes: 2 additions & 10 deletions src/components/claim/views/claim.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions src/store/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7364880

Please sign in to comment.