-
Notifications
You must be signed in to change notification settings - Fork 1
feat: v4 tokenomics + count trees (YAPP token, buy/moderation UX) #291
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
Open
PastaPastaPasta
wants to merge
11
commits into
master
Choose a base branch
from
feat/v4-tokenomics-count-trees
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6c6632d
feat: v4 tokenomics + count trees (YAPP token, buy/moderation UX)
PastaPastaPasta 0652fc9
fix: address PR review on v4 tokenomics
PastaPastaPasta 911ee70
fix: address PR review round 2 (buy cap + BigInt-safe amounts)
PastaPastaPasta 29db286
fix: address CodeRabbit review (settings title, a11y labels, matcher …
PastaPastaPasta 028c716
fix: resolve deep-review findings on v4 tokenomics
PastaPastaPasta 5efbafa
perf: batch feed-page count-tree reads via grouped DAPI queries
PastaPastaPasta af0ae27
fix: detect Drive insufficient-token-balance phrasing so Buy-YAPP mod…
PastaPastaPasta deb20a2
feat: show action costs and coverage estimate in Buy-YAPP modal
PastaPastaPasta c6c0119
fix: sign YAPP purchases with a CRITICAL key, prompting when login ke…
PastaPastaPasta 1248873
fix: resolve review findings on balances, interaction lookups, and ti…
PastaPastaPasta bf695e1
fix: improve buy yapp modal accessibility
PastaPastaPasta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| 'use client' | ||
|
|
||
| import { useState } from 'react' | ||
| import toast from 'react-hot-toast' | ||
| import { NoSymbolIcon, ArrowUturnLeftIcon, FireIcon } from '@heroicons/react/24/outline' | ||
| import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' | ||
| import { Button } from '@/components/ui/button' | ||
| import { useAuth } from '@/contexts/auth-context' | ||
| import { tokenService } from '@/lib/services/token-service' | ||
|
|
||
| /** | ||
| * Owner-only YAPP moderation: freeze (suspend), unfreeze (reinstate), and | ||
| * destroyFrozen (slash the staked balance). Rendered only for the token | ||
| * authority identity (gated in the settings page). | ||
| */ | ||
| export function ModerationSettings() { | ||
| const { user } = useAuth() | ||
| const [targetId, setTargetId] = useState('') | ||
| const [note, setNote] = useState('') | ||
| const [busy, setBusy] = useState<null | 'freeze' | 'unfreeze' | 'destroyFrozen'>(null) | ||
|
|
||
| const run = async (action: 'freeze' | 'unfreeze' | 'destroyFrozen') => { | ||
| if (!user) return | ||
| const id = targetId.trim() | ||
| if (!id) { | ||
| toast.error('Enter the identity ID to moderate') | ||
| return | ||
| } | ||
| if (action === 'destroyFrozen' && !window.confirm( | ||
| `Permanently burn ${id}'s YAPP balance? This slashes their stake and cannot be undone. The account must already be frozen.` | ||
| )) return | ||
|
|
||
| setBusy(action) | ||
| const fn = action === 'freeze' ? tokenService.freeze | ||
| : action === 'unfreeze' ? tokenService.unfreeze | ||
| : tokenService.destroyFrozen | ||
| const result = await fn.call(tokenService, user.identityId, id, note.trim() || undefined) | ||
| setBusy(null) | ||
|
|
||
| if (result.success) { | ||
| toast.success( | ||
| action === 'freeze' ? 'Identity frozen (suspended)' | ||
| : action === 'unfreeze' ? 'Identity unfrozen (reinstated)' | ||
| : 'Frozen balance destroyed (slashed)' | ||
| ) | ||
| } else { | ||
| toast.error(result.error || 'Action failed') | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <Card> | ||
| <CardHeader> | ||
| <CardTitle>YAPP Moderation</CardTitle> | ||
| <CardDescription> | ||
| Freeze suspends an account (blocks posting and transfers immediately). Slash permanently | ||
| burns a frozen account's YAPP stake. Use unfreeze to reinstate. | ||
| </CardDescription> | ||
| </CardHeader> | ||
| <CardContent className="space-y-4"> | ||
| <div> | ||
| <label htmlFor="moderation-target-id" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Identity ID</label> | ||
| <input | ||
| id="moderation-target-id" | ||
| type="text" | ||
| value={targetId} | ||
| onChange={(e) => setTargetId(e.target.value)} | ||
| placeholder="Base58 identity ID to moderate" | ||
| className="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-neutral-800 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-yappr-500" | ||
| /> | ||
| </div> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| <div> | ||
| <label htmlFor="moderation-note" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Public note (optional)</label> | ||
| <input | ||
| id="moderation-note" | ||
| type="text" | ||
| value={note} | ||
| onChange={(e) => setNote(e.target.value)} | ||
| placeholder="Reason recorded on-chain" | ||
| className="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-neutral-800 text-sm focus:outline-none focus:ring-2 focus:ring-yappr-500" | ||
| /> | ||
| </div> | ||
| <div className="flex flex-wrap gap-2"> | ||
| <Button variant="outline" disabled={busy !== null} onClick={() => run('freeze')} className="gap-2"> | ||
| <NoSymbolIcon className="h-4 w-4" /> {busy === 'freeze' ? 'Freezing…' : 'Freeze'} | ||
| </Button> | ||
| <Button variant="outline" disabled={busy !== null} onClick={() => run('unfreeze')} className="gap-2"> | ||
| <ArrowUturnLeftIcon className="h-4 w-4" /> {busy === 'unfreeze' ? 'Unfreezing…' : 'Unfreeze'} | ||
| </Button> | ||
| <Button variant="destructive" disabled={busy !== null} onClick={() => run('destroyFrozen')} className="gap-2"> | ||
| <FireIcon className="h-4 w-4" /> {busy === 'destroyFrozen' ? 'Slashing…' : 'Slash'} | ||
| </Button> | ||
| </div> | ||
| </CardContent> | ||
| </Card> | ||
| ) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.