@@ -390,6 +390,83 @@ app.get("/challenges", withRole("admin"), async (request, response) => {
390
390
}
391
391
} ) ;
392
392
393
+ app . post ( "/api/frame" , ( req , res ) => {
394
+ const baseUrl = "https://speedrunethereum.com" ;
395
+ const SRE_BACKEND = "https://scaffold-directory-dev.ew.r.appspot.com" ;
396
+
397
+ const challengeButtons = {
398
+ 0 : {
399
+ label : "🎟 Simple NFT Example" ,
400
+ link : "https://speedrunethereum.com/challenge/simple-nft-example" ,
401
+ } ,
402
+ 1 : {
403
+ label : "🥩 Staking App" ,
404
+ link : "https://speedrunethereum.com/challenge/decentralized-staking" ,
405
+ } ,
406
+ 2 : {
407
+ label : "🏵 Token Vendor" ,
408
+ link : "https://speedrunethereum.com/challenge/token-vendor" ,
409
+ } ,
410
+ 3 : {
411
+ label : "🎲 Dice Game" ,
412
+ link : "https://speedrunethereum.com/challenge/dice-game" ,
413
+ } ,
414
+ 4 : {
415
+ label : "⚖️ Build a DEX" ,
416
+ link : "https://speedrunethereum.com/challenge/minimum-viable-exchange" ,
417
+ } ,
418
+ 5 : {
419
+ label : "📺 State Channel App" ,
420
+ link : "https://speedrunethereum.com/challenge/state-channels" ,
421
+ } ,
422
+ } ;
423
+
424
+ try {
425
+ const { query } = req ;
426
+
427
+ let idAsNumber = 0 ;
428
+
429
+ if ( query && query . id ) {
430
+ idAsNumber = Number ( query . id ) ;
431
+ }
432
+
433
+ const nextId = idAsNumber + 1 ;
434
+
435
+ if ( idAsNumber === 6 ) {
436
+ res . status ( 200 ) . send ( `<!DOCTYPE html><html><head>
437
+ <title>Speed Run Ethereum</title>
438
+ <meta property="og:image" content="${ baseUrl } /frames/buidlguidl.jpg" />
439
+ <meta property="fc:frame" content="vNext" />
440
+ <meta property="fc:frame:image" content="${ baseUrl } /frames/buidlguidl.jpg" />
441
+ <meta property="fc:frame:button:1" content="🛠️ GitHub" />
442
+ <meta property="fc:frame:button:1:action" content="link" />
443
+ <meta property="fc:frame:button:1:target" content="https://github.com/scaffold-eth/se-2-challenges" />
444
+ <meta property="fc:frame:button:2" content="🏰 BuidlGuidl" />
445
+ <meta property="fc:frame:button:2:action" content="link" />
446
+ <meta property="fc:frame:button:2:target" content="https://buidlguidl.com/" />
447
+ <meta property="fc:frame:button:3" content="💬 Telegram" />
448
+ <meta property="fc:frame:button:3:action" content="link" />
449
+ <meta property="fc:frame:button:3:target" content="https://t.me/joinchat/KByvmRe5wkR-8F_zz6AjpA" />
450
+ </head></html>` ) ;
451
+ } else {
452
+ res . status ( 200 ) . send ( `<!DOCTYPE html><html><head>
453
+ <title>Speed Run Ethereum</title>
454
+ <meta property="og:image" content="${ baseUrl } /frames/challenge-${ idAsNumber } .png" />
455
+ <meta property="fc:frame" content="vNext" />
456
+ <meta property="fc:frame:image" content="${ baseUrl } /frames/challenge-${ idAsNumber } .png" />
457
+ <meta property="fc:frame:button:1" content="${ challengeButtons [ idAsNumber ] . label } " />
458
+ <meta property="fc:frame:button:1:action" content="link" />
459
+ <meta property="fc:frame:button:1:target" content="${ challengeButtons [ idAsNumber ] . link } " />
460
+ <meta property="fc:frame:button:2" content="Next →" />
461
+ <meta property="fc:frame:post_url" content="${ SRE_BACKEND } /api/frame?id=${ nextId } " />
462
+ </head></html>` ) ;
463
+ }
464
+ } catch ( err ) {
465
+ console . log ( "err" , err ) ;
466
+ res . status ( 500 ) . send ( { error : "failed to load frame" } ) ;
467
+ }
468
+ } ) ;
469
+
393
470
// If nothing processed the request, return 404
394
471
app . use ( ( req , res ) => {
395
472
console . log ( `Request to ${ req . path } resulted in 404` ) ;
0 commit comments