Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding farcaster frames metadata #199

Merged
merged 4 commits into from
Mar 26, 2024
Merged
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
77 changes: 77 additions & 0 deletions packages/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,83 @@ app.get("/challenges", withRole("admin"), async (request, response) => {
}
});

app.post("/api/frame", (req, res) => {
const baseUrl = "https://speedrunethereum.com";
const SRE_BACKEND = "https://scaffold-directory-dev.ew.r.appspot.com";

const challengeButtons = {
0: {
label: "🎟 Simple NFT Example",
link: "https://speedrunethereum.com/challenge/simple-nft-example",
},
1: {
label: "🥩 Staking App",
link: "https://speedrunethereum.com/challenge/decentralized-staking",
},
2: {
label: "🏵 Token Vendor",
link: "https://speedrunethereum.com/challenge/token-vendor",
},
3: {
label: "🎲 Dice Game",
link: "https://speedrunethereum.com/challenge/dice-game",
},
4: {
label: "⚖️ Build a DEX",
link: "https://speedrunethereum.com/challenge/minimum-viable-exchange",
},
5: {
label: "📺 State Channel App",
link: "https://speedrunethereum.com/challenge/state-channels",
},
};

try {
const { query } = req;

let idAsNumber = 0;

if (query && query.id) {
idAsNumber = Number(query.id);
}

const nextId = idAsNumber + 1;

if (idAsNumber === 6) {
carletex marked this conversation as resolved.
Show resolved Hide resolved
res.status(200).send(`<!DOCTYPE html><html><head>
<title>Speed Run Ethereum</title>
<meta property="og:image" content="${baseUrl}/frames/buidlguidl.jpg" />
<meta property="fc:frame" content="vNext" />
<meta property="fc:frame:image" content="${baseUrl}/frames/buidlguidl.jpg" />
<meta property="fc:frame:button:1" content="🛠️ GitHub" />
<meta property="fc:frame:button:1:action" content="link" />
<meta property="fc:frame:button:1:target" content="https://github.com/scaffold-eth/se-2-challenges" />
<meta property="fc:frame:button:2" content="🏰 BuidlGuidl" />
<meta property="fc:frame:button:2:action" content="link" />
<meta property="fc:frame:button:2:target" content="https://buidlguidl.com/" />
<meta property="fc:frame:button:3" content="💬 Telegram" />
<meta property="fc:frame:button:3:action" content="link" />
<meta property="fc:frame:button:3:target" content="https://t.me/joinchat/KByvmRe5wkR-8F_zz6AjpA" />
</head></html>`);
} else {
res.status(200).send(`<!DOCTYPE html><html><head>
<title>Speed Run Ethereum</title>
<meta property="og:image" content="${baseUrl}/frames/challenge-${idAsNumber}.png" />
<meta property="fc:frame" content="vNext" />
<meta property="fc:frame:image" content="${baseUrl}/frames/challenge-${idAsNumber}.png" />
<meta property="fc:frame:button:1" content="${challengeButtons[idAsNumber].label}" />
<meta property="fc:frame:button:1:action" content="link" />
<meta property="fc:frame:button:1:target" content="${challengeButtons[idAsNumber].link}" />
<meta property="fc:frame:button:2" content="Next →" />
<meta property="fc:frame:post_url" content="${SRE_BACKEND}/api/frame?id=${nextId}" />
</head></html>`);
}
} catch (err) {
console.log("err", err);
res.status(500).send({ error: "failed to load frame" });
}
});

// If nothing processed the request, return 404
app.use((req, res) => {
console.log(`Request to ${req.path} resulted in 404`);
Expand Down
Binary file added packages/react-app/public/frames/buidlguidl.jpg
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 packages/react-app/public/frames/challenge-0.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 packages/react-app/public/frames/challenge-1.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 packages/react-app/public/frames/challenge-2.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 packages/react-app/public/frames/challenge-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 packages/react-app/public/frames/challenge-5.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 packages/react-app/public/frames/challenge-6.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 packages/react-app/public/frames/challenge-7.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 packages/react-app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />

<meta property="og:title" content="Speed Run Ethereum" />
<meta name="description" content="Learn how to build on Ethereum; the superpowers and the gotchas.">
<meta name="description" content="Learn how to build on Ethereum; the superpowers and the gotchas." />
<meta property="og:description" content="Learn how to build on Ethereum; the superpowers and the gotchas." />
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:card" content="summary_large_image" />
<meta property="og:image" content="%PUBLIC_URL%/thumbnail.png" />
<meta property="twitter:image" content="%PUBLIC_URL%/thumbnail.png" />

<meta property="fc:frame" content="vNext" />
<meta property="fc:frame:image" content="%PUBLIC_URL%/thumbnail.png" />

<meta property="fc:frame:button:1" content="🛠️ GitHub" />
<meta property="fc:frame:button:1:action" content="link" />
<meta property="fc:frame:button:1:target" content="https://github.com/scaffold-eth/se-2-challenges" />

<meta property="fc:frame:button:2" content="⚡️ Start" />
<meta property="fc:frame:post_url" content="https://scaffold-directory-dev.ew.r.appspot.com/api/frame?id=0" />

<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Speed Run Ethereum</title>
<script defer data-domain="speedrunethereum.com" src="https://plausible.io/js/plausible.js"></script>
Expand Down
Loading