Skip to content

feat: require wallet before demo + nudge user to claim rewards#31

Closed
mesiyoq965-sudo wants to merge 1 commit into
ubiquity-os:developmentfrom
mesiyoq965-sudo:development
Closed

feat: require wallet before demo + nudge user to claim rewards#31
mesiyoq965-sudo wants to merge 1 commit into
ubiquity-os:developmentfrom
mesiyoq965-sudo:development

Conversation

@mesiyoq965-sudo
Copy link
Copy Markdown

Summary

Implements the requested changes from DevPool issue #5000 / Original issue #15.

Changes Made

Point 1: Wallet registration required before demo starts

  • /demo command now prompts user to register their wallet address first using /wallet <address>
  • Demo does not proceed until wallet is registered
  • Clear instruction message posted to guide user

Point 2: Nudge user to claim rewards after rewards are posted

  • New nudgeUserToClaimRewards() function detects conversation-rewards bot comments
  • Automatically posts a claim link to https://devpool.directory/rewards
  • Includes reminder to register wallet if not already done

Point 3: Simulant posts issue instead of user

  • The bot now posts the demo issue/welcome message as the Simulant (userOctokit)
  • This avoids privacy concerns of having users post issues themselves
  • Flow: admin triggers /demo → bot creates welcome message → bot guides user through demo

Bonus: Updated welcome message

  • Added wallet registration reminder in the welcome message

Testing

  • Manual testing with /demo command
  • Verified wallet nudge appears after rewards bot posts

Resolves #15
Resolves devpool-directory/devpool-directory#5000

… 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
@github-actions
Copy link
Copy Markdown
Contributor

Unused exports (1)

Filename exports
src/handlers/run-demo.ts handleInit

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

📝 Walkthrough

Walkthrough

The 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 conversation-rewards appears in comments, extracting the reward amount and providing a claim link. The welcome flow text is updated with a consolidated wallet registration reminder. Supporting user-facing strings are added to handle wallet registration prompts, rewards-claim nudges, and welcome messages. Unused commented code is removed.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and concisely describes the two main changes: wallet registration requirement and rewards nudge functionality.
Description check ✅ Passed Description covers all major changes, testing approach, and properly links to both resolved issues using the correct GitHub keyword.
Linked Issues check ✅ Passed Changes implement core requirements: wallet required before demo [#15], nudge to claim rewards [#15, #5000], and bot posts demo issue [#15]. Rewards cap adjustment not addressed but noted as out-of-scope.
Out of Scope Changes check ✅ Passed All changes align with PR objectives. Only known out-of-scope item is rewards label/pricing adjustment, which is acknowledged in the PR as not implemented.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
strings.json (1)

4-7: ⚡ Quick win

Wire these new keys into run-demo.ts.

These entries are currently dead data: src/handlers/run-demo.ts still 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7bff235 and 105be06.

📒 Files selected for processing (2)
  • src/handlers/run-demo.ts
  • strings.json

Comment thread src/handlers/run-demo.ts
Comment on lines +133 to +155
// 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.`,
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

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.

Comment thread src/handlers/run-demo.ts
Comment on lines +171 to +193
// 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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.


⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

/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.

Comment thread src/handlers/run-demo.ts
Comment on lines 227 to 229
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
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nudge to claim DEMO currency Nudge to claim DEMO currency

1 participant