Skip to content

Commit

Permalink
Update CNAME and package.json, delete unused files and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
backmeupplz committed Dec 28, 2023
1 parent efeadd9 commit 026c596
Show file tree
Hide file tree
Showing 44 changed files with 4,010 additions and 210 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_CONTRACT=0x357b4Ef40A5cF049114B4566773e8A6a57F8E862
VITE_ALCHEMY_BASE=123
2 changes: 2 additions & 0 deletions .github/workflows/deployflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
env:
NODE_OPTIONS: '--max_old_space_size=4096'
VITE_CONTRACT: ${{ secrets.VITE_CONTRACT }}
VITE_ALCHEMY_BASE: ${{ secrets.VITE_ALCHEMY_BASE }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
},
"editor.quickSuggestions": {
"strings": true
}
},
"cSpell.words": ["AMENO", "DORIME", "rainbowkit", "wagmi"]
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-present Borodutch
Copyright (c) 2023-present Borodutch

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
# Frontend code template in `preact`

This template is to be used for frontend applications.

## Features

- State management with `jotai`
- Around 13.53kb after brotli compression (this includes **everything**) 😱
- `preact` under the hood with `preact/compat` makes it compatible with virtually any `react` library but still makes it faster
- Full TypeScript support β€” no dangling types
- `vite` packager and devtools make building and development lightning fast
- `tailwind-css` built-in with 'daisyui'
- GitHub Actions that lint and check the code on pull requests
- `prettier` and `eslint` configured, enabled and formatting your code on save
- List of recommended extensions for VSCode
- It is important to keep the bundle small, so a `stats.html` file is generated on `yarn build` to visually show you the bundle size
# $AMENO frontend

## Local launch

Expand Down
Binary file added designs/designs.sketch
Binary file not shown.
37 changes: 34 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Frontend starter preact</title>
<meta name="description" content="Frontend starter example" />
<title>$AMENO</title>
<meta name="description" content="Let's DORIME this $AMENO 😱" />
<!-- Favicon -->
<link
rel="apple-touch-icon"
sizes="180x180"
href="/img/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/img/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/img/favicon-16x16.png"
/>
<link rel="manifest" href="/img/site.webmanifest" />
<link rel="mask-icon" href="/img/safari-pinned-tab.svg" color="#cbcbcb" />
<link rel="shortcut icon" href="/img/favicon.ico" />
<meta name="msapplication-TileColor" content="#2b5797" />
<meta name="msapplication-config" content="/img/browserconfig.xml" />
<meta name="theme-color" content="#ffffff" />
<!-- OG -->
<meta property="og:title" content="$AMENO" />
<meta property="og:description" content="Let's DORIME this $AMENO 😱 πŸ™" />
<meta property="og:image" content="/img/og.jpg" />
<meta property="og:url" content="http://ameno.lol" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="$AMENO" />
</head>
<body>
<noscript>Please, turn on JavaScript to see this page.</noscript>
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "frontend-starter",
"name": "ameno-frontend",
"version": "1.0.0",
"license": "MIT",
"scripts": {
Expand All @@ -10,8 +10,14 @@
"preview": "yarn build && yarn vite preview"
},
"dependencies": {
"@borodutch/ameno-contract": "^1.0.2",
"@rainbow-me/rainbowkit": "^1.3.2",
"envalid": "^8.0.0",
"ethers": "^6.9.1",
"jotai": "^2.6.0",
"preact": "^10.19.3"
"preact": "^10.19.3",
"viem": "^1.21.1",
"wagmi": "^1.4.12"
},
"devDependencies": {
"@preact/preset-vite": "^2.7.0",
Expand Down
2 changes: 1 addition & 1 deletion public/CNAME
Original file line number Diff line number Diff line change
@@ -1 +1 @@
google.com
ameno.lol
Binary file added public/img/android-chrome-192x192.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/img/android-chrome-512x512.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/img/apple-touch-icon.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/img/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/img/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/img/mstile-150x150.png"/>
<TileColor>#2b5797</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added public/img/favicon-16x16.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/img/favicon-32x32.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/img/favicon.ico
Binary file not shown.
Binary file added public/img/mstile-150x150.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/img/og.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions public/img/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions public/img/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/img/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/img/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
20 changes: 12 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { Suspense } from 'preact/compat'
import UserCount from 'components/UserCount'
import CrucialActions from 'components/CrucialActions'
import Description from 'components/Description'
import Mint from 'components/Mint'
import Wallet from 'components/Wallet'

export default function () {
return (
<div className="container mx-auto max-w-prose p-10 prose">
<h1>Frontend template</h1>
<Suspense fallback={<p>Loading...</p>}>
<UserCount />
</Suspense>
</div>
<Wallet>
<div className="container mx-auto max-w-prose p-10 prose">
<h1>$AMENO</h1>
<Description />
<Mint />
<CrucialActions />
</div>
</Wallet>
)
}
4 changes: 0 additions & 4 deletions src/atoms/userCount.ts

This file was deleted.

19 changes: 19 additions & 0 deletions src/components/Buy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default function () {
return (
<>
<div className="flex flex-col items-stretch gap-4 mt-8">
<button
class="btn btn-primary btn-lg"
onClick={() => {
window.open(
'https://dexscreener.com/base/0x357b4Ef40A5cF049114B4566773e8A6a57F8E862',
'_blank'
)
}}
>
πŸ‘ Buy $AMENO πŸ‘
</button>
</div>
</>
)
}
54 changes: 54 additions & 0 deletions src/components/Claim.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { ConnectButton } from '@rainbow-me/rainbowkit'
import { useAccount } from 'wagmi'
import { useEthersSigner } from 'hooks/useEthers'
import { useState } from 'preact/hooks'
import ClaimDashboard from 'components/ClaimDashboard'
import getVerificationMessage from 'helpers/getVerificationMessage'

export default function () {
const signer = useEthersSigner()
const [signature, setSignature] = useState('')
const { address, isConnected } = useAccount()

async function authorize() {
try {
if (!signer) {
throw new Error('No signer')
}
if (!address) {
throw new Error('No address')
}
const signature = await signer.signMessage(
getVerificationMessage(address)
)
setSignature(signature)
} catch (error) {
console.error(error)
}
}

return (
<div className="flex flex-col items-stetch gap-4">
<h2>NEW 😱 CLAIM $SPAM FOR FARCASTER ACTIVITY!</h2>
<ul>
<li>You get 5 $SPAM for every unique cast containing "$SPAM"</li>
<li>Casts that only contain the word $SPAM don't count</li>
<li>Every like on a cast increases the claim for the cast by 1%</li>
<li>So does every recast</li>
<li>Go use $SPAM in your casts!</li>
<li>You can claim every 24 hours 🫦</li>
</ul>
<ConnectButton />
{isConnected && (
<>
{!signature && (
<button class="btn btn-primary btn-lg" onClick={authorize}>
Authorize $SPAM
</button>
)}
{signature && <ClaimDashboard signature={signature} />}
</>
)}
</div>
)
}
110 changes: 110 additions & 0 deletions src/components/ClaimDashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { Spam__factory } from '@borodutch/spam-contract'
import { ethers } from 'ethers'
import { useAccount } from 'wagmi'
import { useEthersSigner } from 'hooks/useEthers'
import { useState } from 'preact/hooks'
import GeneratedTicket from 'models/GeneratedTIcket'
import env from 'helpers/env'
import generateTicket from 'helpers/api'

export default function ({ signature }: { signature: string }) {
const [loading, setLoading] = useState(false)
const [error, setError] = useState('')
const [success, setSuccess] = useState(false)
const [ticket, setTicket] = useState<GeneratedTicket | null>(null)

const { address } = useAccount()
const signer = useEthersSigner()

async function getTicket() {
setSuccess(false)
setLoading(true)
setError('')
try {
if (!address) throw new Error('No address found')
const ticket = await generateTicket(address, signature)
setTicket(ticket)
} catch (error) {
console.error(error)
setError(error instanceof Error ? error.message : `${error}`)
} finally {
setLoading(false)
}
}

async function claimSpam() {
setLoading(true)
setSuccess(false)
try {
if (!ticket) {
throw new Error('No ticket found')
}
const contract = Spam__factory.connect(env.VITE_CONTRACT, signer)
const { r, yParityAndS } = ethers.Signature.from(
ticket.signature.signature
)
const tx = await contract.claimSpam(
new Uint8Array(ticket.signature.message),
r,
yParityAndS
)
await tx.wait()
setSuccess(true)
} catch (error) {
console.error(error)
setError(error instanceof Error ? error.message : `${error}`)
} finally {
setLoading(false)
}
}

return (
<>
<div role="alert" class="alert alert-success">
You have authorized $SPAM! Now let's see if you have any $SPAM to claim
🫦
</div>
{!ticket && (
<button
class="btn btn-primary btn-lg"
onClick={getTicket}
disabled={loading}
>
{loading ? ' πŸ€”' : ''}Get ticket to claim $SPAM πŸ’ŽπŸ€²
</button>
)}
{ticket && (
<div class="alert alert-success flex flex-col gap-4 items-stretch">
<p>
You have a ticket to claim {ticket.total} $SPAM! It consists of{' '}
{ticket.baseAmount} $SPAM for unique casts containing $SPAM,{' '}
{ticket.additionalForLikes} $SPAM for likes, and{' '}
{ticket.additionalForRecasts} $SPAM for recasts. Do not reload this
page or you will lose this ticket!
</p>
<button
class="btn btn-primary btn-lg"
onClick={() => {
void claimSpam()
}}
>
Claim $SPAM πŸ’ŽπŸ€²
</button>
</div>
)}
{success && (
<div role="alert" class="alert alert-success">
<span role="img" aria-label="success">
πŸŽ‰
</span>{' '}
You successfully claimed $SPAM! Check your wallet for details πŸš€
</div>
)}
{error && (
<div role="alert" class="alert alert-error break-all">
{error}
</div>
)}
</>
)
}
Loading

0 comments on commit 026c596

Please sign in to comment.