Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/1_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/1_mint_successfull.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/1_successfull_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/2_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/2_successfull_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/3_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/3_successfull_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/4_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/4_successfull_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/5_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/5_successfull_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/5_welcome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/already_claimed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/not_eligable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/not_eligable.png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/start-mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/successfull_mint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions src/components/leaderboard-desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export type LeaderboardProps = {
}

export default function LeaderboardDesktop(props: LeaderboardProps) {
const { leaderboard, currentDay} = props
const { leaderboard, currentDay } = props

const renderDay = (
day: number,
from: number,
to: number,
color: string,
dayFourIndex?: number,
dayFourIndex?: number
) => {
return (
<>
Expand All @@ -37,6 +37,15 @@ export default function LeaderboardDesktop(props: LeaderboardProps) {
day={day}
/>
)}
{day === 5 ? (
<div className="justify-between-grid">
<div className="pair">
<br></br>
<br></br>
<div className="channel-name-box">mfres</div>
</div>
</div>
) : null}
<div style={{ height: 300 }}></div>

<div style={{ position: 'absolute', bottom: 0 }}>
Expand All @@ -47,6 +56,7 @@ export default function LeaderboardDesktop(props: LeaderboardProps) {
)
}

console.log(leaderboard, 'leaderboard')
return (
<div className="body-desktop">
<div className="flex-direction-row">
Expand Down
5 changes: 4 additions & 1 deletion src/components/leaderboard-mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export default function LeaderboardMobile(props: LeaderboardProps) {
</>
)}
<div className="winner-box">
<br></br>Clash-of-Channels Winner: <br></br>Revealed on March 3rd
<br></br>Clash-of-Channels Winner: <br></br>
<div style={{
fontSize: 24
}}>mfers</div>
</div>
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@ alter table
add
column options json NOT null default '[]' :: json;

create index idx_questions_id_expires ON questions (id, expires_at);
create index idx_questions_id_expires ON questions (id, expires_at);


alter table
users
add
column has_minted BOOLEAN DEFAULT false;
96 changes: 96 additions & 0 deletions src/pages/api/mint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import { IMAGES } from '@/utils/image-paths'
import { validateMsgWithNeynar } from '@/validate'
import { TSignedMessage, TUntrustedData } from '@/types'
import { generateFarcasterFrame, SERVER_URL } from '@/utils/generate-frames'
import {
calculateIfWinningOrNot,
checkIfAvailableForMintAndMint,
getChannel,
getQuestionFromId,
} from '@/utils/database-operations'
import { HANDLE_QUESTION } from '@/utils/question'
import { mintSporkNFT } from '@/utils/contract-operations'
import { getChannelFromCastHash } from '@/utils/neynar-api'
import { channel } from 'diagnostics_channel'

const QUESTION_ID = parseInt(process.env.QUESTION_ID || '')

export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
if (req.method !== 'POST') {
res.status(405).json({ error: 'Method Not Allowed' })
return
}

const signedMessage = req.body as TSignedMessage

const reqId = req.query.data
console.log('request query IN MINT: ', reqId)

const isMessageValid = await validateMsgWithNeynar(
signedMessage.trustedData?.messageBytes
)

if (!isMessageValid) {
return res.status(400).json({ error: 'Invalid message' })
}

const ud: TUntrustedData = signedMessage.untrustedData

let html: string = ''
let statusCode: number = 200
let locationHeader: string = ''
//let userIsInChannel: TUserProfileNeynar | null | undefined = null
//let castHash = '0x75fb5866c3105e82500406c94d0f295af4a74d32'
let castHash = '0x4c9595bba3cc8f6490d7cc67265aa6a3938c1afb' //BASE
//let castHash = '0x222d2e841b4edadeaa4de273dee5add20ee18f41' //zora
//let castHash = '0x03475d45887f13c592c44829de3de18a7d95619d' //farcasther
//let castHash = '0x7aadf31bcdd0adfe41e593c5bc6c32bb81118471' //cryptostocks cast
let channel = await getChannelFromCastHash(castHash)
const response = res.status(statusCode).setHeader('Content-Type', 'text/html')

console.log(`${SERVER_URL}/${IMAGES.mint}`, 'beeee')
switch (reqId) {
case 'start-mint':
if (channel) {
const channelDb = await getChannel(channel)

html = generateFarcasterFrame(
`${SERVER_URL}/${channelDb.question_id + '_mint.png'}`,
'mint'
)
}

break
case 'mint':
if (QUESTION_ID && channel) {
console.log('Not in mint start question')

console.log('MINTING THE MINT')
html = await checkIfAvailableForMintAndMint(ud.fid, channel)
} else {
html = generateFarcasterFrame(
`${SERVER_URL}/${IMAGES.expired}`,
'leaderboard'
)
}
break

case 'leaderboard':
locationHeader = 'https://leaderboard.liquality.io'
return response.redirect(302, locationHeader)

default:
html = generateFarcasterFrame(
`${SERVER_URL}/${IMAGES.start_mint}`,
'start-mint'
)
break
}

console.log(html, 'wat is html? XXXX')
return response.send(html)
}
1 change: 1 addition & 0 deletions src/pages/api/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default async function handler(
res.status(405).json({ error: 'Method Not Allowed' })
return
}
console.log(req, 'wats re?')

const signedMessage = req.body as TSignedMessage

Expand Down
29 changes: 18 additions & 11 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import LeaderboardMobile from '../components/leaderboard-mobile'
export default function Home() {

const [isMobileState, setIsMobileState] = useState(false)
const [questionId, setQuestionId] = useState(4)
const [questionId, setQuestionId] = useState(5)
const [leaderboard, setLeaderboard] = useState<null | ClashDataMap[]>(null)
const [loading, setLoading] = useState(false)
const [expandedDay, setExpandedDay] = useState<number | null>(null)

useEffect(() => {
setIsMobileState(isMobile)
}, [isMobile])
Expand All @@ -31,23 +32,29 @@ export default function Home() {
}
}, [leaderboard])

let image = ''
let postUrl = ''
let text = ''
if (questionId === 5) {
image = IMAGES.start_mint
postUrl = '/api/mint?data=start-mint'
text = '🔆 Mint your sporkwhale!'
} else {
image = IMAGES.welcome
postUrl = '/api/post?data=start'
text = '🔆 Play Clash of Channels!'
}
return (
<>
<Head>
<meta property="og:title" content="Frame" />
<meta property="og:image" content={`${SERVER_URL}/${IMAGES.welcome}`} />
<meta property="og:image" content={`${SERVER_URL}/${image}`} />
<meta property="fc:frame" content="vNext" />
<meta
property="fc:frame:image"
content={`${SERVER_URL}/${IMAGES.welcome}`}
/>
<meta
property="fc:frame:button:1"
content="🔆 Play Clash of Channels!"
/>
<meta property="fc:frame:image" content={`${SERVER_URL}/${image}`} />
<meta property="fc:frame:button:1" content={text} />
<meta
property="fc:frame:post_url"
content={`${SERVER_URL}/api/post?data=start`}
content={`${SERVER_URL}${postUrl}`}
/>
</Head>
{leaderboard ? (
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export type TPostData =
| 'correct-or-incorrect'
| 'leaderboard'
| 'error-be-a-follower'
| 'start-mint'
| 'mint'

export type TUserProfileNeynar = {
object: 'user'
Expand Down
Loading