feat: require wallet before demo + nudge user to claim rewards#31
feat: require wallet before demo + nudge user to claim rewards#31mesiyoq965-sudo wants to merge 1 commit into
Conversation
… rewards - Point 1: /demo command now prompts user to register wallet before starting - Point 2: Detect conversation-rewards comments and nudge user to claim via devpool.directory - Point 3: Simulant posts issue on behalf of user (wallet-first flow) - Updated handleInit to include wallet registration reminder in welcome message - Added nudgeUserToClaimRewards helper function - Updated strings.json with new i18n keys
Unused exports (1)
|
📝 WalkthroughWalkthroughThe demo handler flow is gated to require wallet registration before proceeding, with early exit and a dedicated registration instruction comment. A new function nudges users to claim rewards when 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
strings.json (1)
4-7: ⚡ Quick winWire these new keys into
run-demo.ts.These entries are currently dead data:
src/handlers/run-demo.tsstill hardcodes the wallet prompt, rewards nudge, and welcome copy instead of reading these keys. That leaves two sources of truth for the same text and will drift fast.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f868e493-b35a-4d7b-8344-08e18aee8155
📒 Files selected for processing (2)
src/handlers/run-demo.tsstrings.json
| // Detect rewards being posted by the rewards bot | ||
| if (!commentBody.includes("conversation-rewards") || !commentBody.includes(" reward")) { | ||
| return; | ||
| } | ||
|
|
||
| logger.info("Rewards posted detected, nudging user to claim"); | ||
|
|
||
| // Extract reward amount if present | ||
| const rewardMatch = commentBody.match(/(\d+(?:\.\d+)?)\s*(?:tokens|USD|DEMO)?/i); | ||
| const rewardAmount = rewardMatch ? rewardMatch[1] : "your"; | ||
|
|
||
| await userOctokit.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number: issueNumber, | ||
| body: `@${payload.sender.login} Great news! You've earned **${rewardAmount}** in rewards! 🎉 | ||
|
|
||
| Please click the link below to claim your reward: | ||
|
|
||
| > [Click here to claim your reward](https://devpool.directory/rewards) | ||
|
|
||
| If you haven't registered your wallet yet, please do so first using \`/wallet <your-address>\`, then return here to claim.`, | ||
| }); |
There was a problem hiding this comment.
This nudge will ping the rewards bot, not the participant.
This helper only runs on a conversation-rewards comment, so payload.sender.login here is the rewards bot account. The reply will @mention the bot, and because the trigger is body-text only, any commenter can spoof it. Resolve the actual demo participant from issue state/comments and verify the commenter identity before posting the claim prompt.
🧰 Tools
🪛 GitHub Actions: Formatting Check
[error] 141-141: ESLint (sonarjs/prefer-regexp-exec): Use the "RegExp.exec()" method instead.
| // Point 1: Require wallet registration BEFORE starting demo | ||
| // Check if user has registered their wallet by looking for a previous /wallet command | ||
| // For now, we check if the bot has already received a "command-wallet" event in this issue | ||
| // by inspecting if there's a registered wallet address comment. | ||
| // The bot will prompt user to register wallet first if not done. | ||
| logger.info("Processing /demo command"); | ||
| await openIssue(context); | ||
| await handleInit(context); | ||
|
|
||
| // Simulant posts the issue on behalf of the user (Point 3) | ||
| // This is handled by creating the issue as the bot (userOctokit) | ||
| // instead of waiting for the user to create it. | ||
| // For the demo flow, we skip directly to wallet prompt. | ||
| await userOctokit.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number: issueNumber, | ||
| body: `@${payload.sender.login} Before we begin the demo, please register your wallet address so you can claim rewards. | ||
|
|
||
| Use the command: \`/wallet <your-eth-address>\` | ||
|
|
||
| Once registered, I'll guide you through the interactive demo!`, | ||
| }); | ||
| return; |
There was a problem hiding this comment.
handleInit() is dead after this flow change.
src/index.ts:8-24 only dispatches handleCommentCreated() / handleCommentEdited(). After the /demo branch returns and the command-wallet branch never calls handleInit(), the updated welcome message is unreachable, so Knip's unused-export failure is expected. Either invoke handleInit() after wallet registration succeeds, or remove this path entirely.
Also applies to: 202-221, 231-257
🧰 Tools
🪛 GitHub Actions: Formatting Check
[error] 193-193: ESLint (sonarjs/no-redundant-jump): Remove this redundant jump.
/demo is always blocked right now.
The new gate never checks whether a wallet is already registered; it always posts the reminder and exits. A user who already ran /wallet still cannot progress via /demo, and the unconditional early exit at Line 193 is also the jump Sonar is complaining about.
🧰 Tools
🪛 GitHub Actions: Formatting Check
[error] 193-193: ESLint (sonarjs/no-redundant-jump): Remove this redundant jump.
| export async function handleCommentEdited(context: Context<"issue_comment.edited">) { | ||
| const { eventName, payload } = context; | ||
|
|
||
| const body = payload.comment.body; | ||
|
|
||
| if (eventName === "issue_comment.edited" && body.includes("ubiquity-os-marketplace/text-conversation-rewards")) { | ||
| /*await userOctokit.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number: issueNumber, | ||
| body: `/ask How can I redeem my rewards? Can you tell me step by step?`, | ||
| });*/ | ||
| } | ||
| // Reserved for future use when edited comments need special handling | ||
| } |
There was a problem hiding this comment.
Prefix the placeholder arg with _ or drop it.
The reserved stub currently fails @typescript-eslint/no-unused-vars, which is already blocking CI.
🧰 Tools
🪛 GitHub Actions: Formatting Check
[error] 227-227: ESLint (@typescript-eslint/no-unused-vars): 'context' is defined but never used. Allowed unused args must match /^_/u.
Summary
Implements the requested changes from DevPool issue #5000 / Original issue #15.
Changes Made
Point 1: Wallet registration required before demo starts
/democommand now prompts user to register their wallet address first using/wallet <address>Point 2: Nudge user to claim rewards after rewards are posted
nudgeUserToClaimRewards()function detectsconversation-rewardsbot commentsPoint 3: Simulant posts issue instead of user
/demo→ bot creates welcome message → bot guides user through demoBonus: Updated welcome message
Testing
/democommandResolves #15
Resolves devpool-directory/devpool-directory#5000