Skip to content

Fix: 2 issues (#880, #882) - #947

Open
GenesisPray wants to merge 1 commit into
Stellar-split:mainfrom
GenesisPray:simple/880-882
Open

GenesisPray wants to merge 1 commit into
Stellar-split:mainfrom
GenesisPray:simple/880-882

Conversation

@GenesisPray

Copy link
Copy Markdown
Contributor

Closes #880
Closes #882

Issues

#880 Implement creator reputation and trust scoring

Overview

Track creator reliability metrics (on-time payment rate, dispute rate, completion rate).

Requirements

  • Design scoring algorithm
  • Track payment completion metrics
  • Calculate dispute rates
  • Implement trust badge system
  • Add public reputation display
  • Create reputation appeal process

Acceptance Criteria

[ ] Scores calculated accurately
[ ] Metrics updated in real-time
[ ] Trust badges display correctly
[ ] Public profiles show scores
[ ] Appeal process works

Definition of Done

All CI checks must pass before the PR is reviewed.

#882 Implement multi-wallet connection with wallet switching

Overview

Allow users to connect and switch between multiple wallet providers seamlessly.

Requirements

  • Add wallet selection UI
  • Implement wallet switching logic
  • Support wallet disconnect/reconnect
  • Store wallet preferences
  • Handle wallet-specific errors gracefully
  • Add wallet connection status indicator

Acceptance Criteria

[ ] Multiple wallets can be connected
[ ] Switching between wallets works smoothly
[ ] Wallet status always visible
[ ] Connection errors clear and actionable
[ ] Preferences persisted across sessions

Definition of Done

All CI checks must pass before the PR is reviewed.

Summary

Issue 880: the scoring module should reuse gradeForScore/MIN_INVOICES_FOR_SCORE from creatorAccountability.ts and getTrustBadges/getTrustTier from creatorVerification.ts to avoid duplicating thresholds. Real-time updates are implemented via a lightweight event bus in creatorAccountability.ts rather than websockets; swap in a real subscription when the backend supports it. The appeal store is localStorage-backed for now and should be replaced by an API call once a backend endpoint exists. Issue 882: the multi-wallet refactor must keep address and walletType on the context value as aliases of the active connection so existing consumers (WalletAddress, useWalletBalance, header nav) keep working unchanged. Migrate the old stellarsplit_wallet sessionStorage entry to the new stellarsplit_wallets localStorage key on first read and then remove it. The WalletConnect kit is currently a stub returning null, so the WalletConnect path will still surface a clear 'not available' error via the new modal type until a real kit is provided. Run the full CI (lint, typecheck, tests) before opening the PR.

Changes

  • Create a new reputation scoring module src/lib/creatorReputation.ts that defines the creator reputation algorithm. It should export a CreatorReputationInput interface (totalInvoices, fulfilledInvoices, onTimeInvoices, cancelledInvoices, disputes, disputesLost, avgResponseHours, accountAgeDays, completedInvoices), a CreatorReputationResult interface (score 0-100 or null when below MIN_INVOICES_FOR_SCORE, grade, breakdown of onTime/completion/disputes/responsiveness, trustTier, badges), and a computeCreatorReputation(input) function. Weight the score as: on-time payment rate 35, completion rate 25, dispute rate 25 (lost disputes count double), responsiveness 15. Reuse gradeForScore and MIN_INVOICES_FOR_SCORE from src/lib/creatorAccountability.ts and getTrustBadges/getTrustTier from src/lib/creatorVerification.ts to derive trust badges and tier. Also export a ReputationAppeal interface (id, creatorAddress, reason, status: 'pending'|'approved'|'rejected', submittedAt, resolvedAt, resolutionNote) and an in-memory appeal store with submitReputationAppeal, listAppealsForCreator, and resolveAppeal functions (persist to localStorage when available). This resolves the scoring algorithm, dispute-rate calculation, and appeal data model for issue 880. (src/lib/creatorReputation.ts)
  • Extend src/lib/creatorAccountability.ts to support real-time metric tracking. Add an AccountabilityMetrics type and a subscribeAccountabilityMetrics(address, listener) / recordAccountabilityEvent(address, event) pair backed by an in-memory map plus a window event ('stellarsplit:accountability-updated') so components can react to metric changes without polling. Keep the existing computeAccountabilityScore behaviour intact; the new subscription layer feeds it. This provides the real-time update mechanism required by issue 880. (src/lib/creatorAccountability.ts)
  • Add a useCreatorReputation(address) hook in a new file src/hooks/useCreatorReputation.ts. It should fetch the creator's raw metrics (total/fulfilled/on-time/cancelled invoices, disputes, disputes lost, avg response hours, account age, completed invoices) from the existing API/SDK (fall back to a mock fetch when unavailable), call computeCreatorReputation from src/lib/creatorReputation.ts, and subscribe to subscribeAccountabilityMetrics so the score recomputes in real time. Return { reputation, loading, error, refetch }. This wires the scoring algorithm into React for issue 880. (src/hooks/useCreatorReputation.ts)
  • Replace the mock random reputation in src/components/ReputationBadge.tsx with real data. Accept an optional reputation prop (a CreatorReputationResult); when omitted, call useCreatorReputation(address) to load it. Render the numeric score, grade, and trust tier with the existing tooltip, and show an 'unrated' state when score is null. Keep the existing accessibility attributes and tooltip behaviour. This makes trust badges display correctly for issue 880. (src/components/ReputationBadge.tsx)
  • Update src/components/CreatorBadges.tsx so the badge catalogue includes the new trust badges from getTrustBadges in src/lib/creatorVerification.ts (email, wallet, kyc, established, reliable) alongside the existing achievement badges. Extend CreatorStats with trustBadges?: TrustBadge[] and trustTier?: TrustTier, and render a dedicated 'Trust' section that shows the earned trust badges and the current tier. This implements the trust badge system for issue 880. (src/components/CreatorBadges.tsx)
  • Create a public reputation profile component src/components/CreatorReputationProfile.tsx. It should take a creator address, call useCreatorReputation(address), and render: the score gauge and grade, the breakdown (on-time rate, completion rate, dispute rate, responsiveness), the trust tier and trust badges (via CreatorBadges), and a 'Dispute this score' button that opens the appeal form. Include loading and unrated states. This satisfies the public reputation display requirement for issue 880. (src/components/CreatorReputationProfile.tsx)
  • Create the reputation appeal UI src/components/ReputationAppealForm.tsx. It should render a modal/form where a creator submits an appeal (reason textarea, optional evidence URL), call submitReputationAppeal from src/lib/creatorReputation.ts, list the creator's existing appeals with their status, and show a success/error message. Wire it into CreatorReputationProfile via the 'Dispute this score' button. This implements the reputation appeal process for issue 880. (src/components/ReputationAppealForm.tsx)
  • Refactor src/hooks/useWallet.ts into a multi-wallet registry. Replace the single CachedWallet with a WalletConnection type ({ address, walletType, connectedAt }) and a WalletState that holds connections: WalletConnection[], activeAddress: string | null, activeWalletType: WalletType | null, connecting, error, freighterInstalled. Add actions: connect(type) (adds/updates a connection and makes it active), switchTo(address) (sets the active connection), disconnect(address?) (removes one connection or all), and reconnect(address) (re-runs the silent verification for a stored connection). Persist the full connection list and active address to localStorage under stellarsplit_wallets (migrate from the old stellarsplit_wallet sessionStorage key on first read). Keep the existing silent re-verification on mount, iterating over stored connections. This implements multi-wallet connection, switching, disconnect/reconnect, and persistence for issue 882. (src/hooks/useWallet.ts)
  • Update src/contexts/WalletContext.tsx to expose the new multi-wallet API from useWallet: connections, activeAddress, activeWalletType, switchTo, disconnect(address?), and reconnect. Keep the existing address/walletType fields as aliases of the active connection so existing consumers keep working. The SEP-10 auto-authentication effect should key off activeAddress so switching wallets re-authenticates. This wires the multi-wallet registry into the app for issue 882. (src/contexts/WalletContext.tsx)
  • Add wallet preference persistence to src/context/UserPreferencesContext.tsx. Extend UserPreferences with preferredWalletType?: WalletType and autoReconnect?: boolean, add setPreferredWalletType and setAutoReconnect setters, and merge them into the existing localStorage read/write (preserving fiatCurrency). This lets the selected wallet preference survive sessions for issue 882. (src/context/UserPreferencesContext.tsx)
  • Rewrite src/components/WalletConnect.tsx to support multiple wallets. In the connected state, render a wallet selector (dropdown or list) showing every entry in connections with its truncated address and wallet type, a checkmark on the active one, a 'Switch' action calling switchTo(address), and a per-wallet 'Disconnect' plus a 'Disconnect all'. Add a compact connection status indicator (green dot + active address, amber while connecting, red on error) that is always visible in both compact and full modes. In the disconnected state, show both Freighter and WalletConnect options and remember the last used type via useUserPreferences().setPreferredWalletType. Route errors through classifyWalletError and WalletErrorModal with actionable messages, and pass onRetry that re-invokes the failed connect. This implements the selection UI, switching, status indicator, and error handling for issue 882. (src/components/WalletConnect.tsx)
  • Extend src/components/WalletErrorModal.tsx with a new walletconnect_failed error type and a wallet_switch_failed type. Add corresponding content components with actionable guidance (retry, choose another wallet, or open the WalletConnect QR flow) and make sure onRetry is wired for both. This ensures wallet-specific errors are clear and actionable for issue 882. (src/components/WalletErrorModal.tsx)
  • Update src/lib/walletMonitor.ts to monitor all connected wallets rather than only Freighter. Change startWalletPolling to accept a list of { address, walletType } connections, poll each adapter (getFreighterPublicKey / getWalletConnectPublicKey), and emit WalletState events that include the walletType and the affected address so the multi-wallet context can update the correct connection on external account switches or disconnects. Keep the existing subscribe/stop API backward compatible. This supports graceful handling of wallet-specific state changes for issue 882. (src/lib/walletMonitor.ts)

Co-authored-by: Simple Agent <agent@simple.dev>
@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

@GenesisPray is attempting to deploy a commit to the kingsman-99's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@GenesisPray Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

This branch has not been deployed

No deployments
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.

Implement multi-wallet connection with wallet switching Implement creator reputation and trust scoring

1 participant