Repository navigation
Fix: 2 issues (#880, #882) - #947
Open
GenesisPray wants to merge 1 commit into
Open
GenesisPray wants to merge 1 commit into
GenesisPray wants to merge 1 commit into
Conversation
Co-authored-by: Simple Agent <agent@simple.dev>
|
@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. |
|
@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! 🚀 |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #880
Closes #882
Issues
#880 Implement creator reputation and trust scoring
#882 Implement multi-wallet connection with wallet switching
Summary
Issue 880: the scoring module should reuse
gradeForScore/MIN_INVOICES_FOR_SCOREfrom creatorAccountability.ts andgetTrustBadges/getTrustTierfrom 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 keepaddressandwalletTypeon the context value as aliases of the active connection so existing consumers (WalletAddress, useWalletBalance, header nav) keep working unchanged. Migrate the oldstellarsplit_walletsessionStorage entry to the newstellarsplit_walletslocalStorage 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
src/lib/creatorReputation.tsthat defines the creator reputation algorithm. It should export aCreatorReputationInputinterface (totalInvoices, fulfilledInvoices, onTimeInvoices, cancelledInvoices, disputes, disputesLost, avgResponseHours, accountAgeDays, completedInvoices), aCreatorReputationResultinterface (score 0-100 or null when below MIN_INVOICES_FOR_SCORE, grade, breakdown of onTime/completion/disputes/responsiveness, trustTier, badges), and acomputeCreatorReputation(input)function. Weight the score as: on-time payment rate 35, completion rate 25, dispute rate 25 (lost disputes count double), responsiveness 15. ReusegradeForScoreandMIN_INVOICES_FOR_SCOREfromsrc/lib/creatorAccountability.tsandgetTrustBadges/getTrustTierfromsrc/lib/creatorVerification.tsto derive trust badges and tier. Also export aReputationAppealinterface (id, creatorAddress, reason, status: 'pending'|'approved'|'rejected', submittedAt, resolvedAt, resolutionNote) and an in-memory appeal store withsubmitReputationAppeal,listAppealsForCreator, andresolveAppealfunctions (persist to localStorage when available). This resolves the scoring algorithm, dispute-rate calculation, and appeal data model for issue 880. (src/lib/creatorReputation.ts)src/lib/creatorAccountability.tsto support real-time metric tracking. Add anAccountabilityMetricstype and asubscribeAccountabilityMetrics(address, listener)/recordAccountabilityEvent(address, event)pair backed by an in-memory map plus awindowevent ('stellarsplit:accountability-updated') so components can react to metric changes without polling. Keep the existingcomputeAccountabilityScorebehaviour intact; the new subscription layer feeds it. This provides the real-time update mechanism required by issue 880. (src/lib/creatorAccountability.ts)useCreatorReputation(address)hook in a new filesrc/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), callcomputeCreatorReputationfromsrc/lib/creatorReputation.ts, and subscribe tosubscribeAccountabilityMetricsso 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)src/components/ReputationBadge.tsxwith real data. Accept an optionalreputationprop (aCreatorReputationResult); when omitted, calluseCreatorReputation(address)to load it. Render the numeric score, grade, and trust tier with the existing tooltip, and show an 'unrated' state whenscoreis null. Keep the existing accessibility attributes and tooltip behaviour. This makes trust badges display correctly for issue 880. (src/components/ReputationBadge.tsx)src/components/CreatorBadges.tsxso the badge catalogue includes the new trust badges fromgetTrustBadgesinsrc/lib/creatorVerification.ts(email, wallet, kyc, established, reliable) alongside the existing achievement badges. ExtendCreatorStatswithtrustBadges?: TrustBadge[]andtrustTier?: 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)src/components/CreatorReputationProfile.tsx. It should take a creatoraddress, calluseCreatorReputation(address), and render: the score gauge and grade, the breakdown (on-time rate, completion rate, dispute rate, responsiveness), the trust tier and trust badges (viaCreatorBadges), 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)src/components/ReputationAppealForm.tsx. It should render a modal/form where a creator submits an appeal (reason textarea, optional evidence URL), callsubmitReputationAppealfromsrc/lib/creatorReputation.ts, list the creator's existing appeals with their status, and show a success/error message. Wire it intoCreatorReputationProfilevia the 'Dispute this score' button. This implements the reputation appeal process for issue 880. (src/components/ReputationAppealForm.tsx)src/hooks/useWallet.tsinto a multi-wallet registry. Replace the singleCachedWalletwith aWalletConnectiontype ({ address, walletType, connectedAt }) and aWalletStatethat holdsconnections: 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), andreconnect(address)(re-runs the silent verification for a stored connection). Persist the full connection list and active address tolocalStorageunderstellarsplit_wallets(migrate from the oldstellarsplit_walletsessionStorage 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)src/contexts/WalletContext.tsxto expose the new multi-wallet API fromuseWallet:connections,activeAddress,activeWalletType,switchTo,disconnect(address?), andreconnect. Keep the existingaddress/walletTypefields as aliases of the active connection so existing consumers keep working. The SEP-10 auto-authentication effect should key offactiveAddressso switching wallets re-authenticates. This wires the multi-wallet registry into the app for issue 882. (src/contexts/WalletContext.tsx)src/context/UserPreferencesContext.tsx. ExtendUserPreferenceswithpreferredWalletType?: WalletTypeandautoReconnect?: boolean, addsetPreferredWalletTypeandsetAutoReconnectsetters, and merge them into the existing localStorage read/write (preservingfiatCurrency). This lets the selected wallet preference survive sessions for issue 882. (src/context/UserPreferencesContext.tsx)src/components/WalletConnect.tsxto support multiple wallets. In the connected state, render a wallet selector (dropdown or list) showing every entry inconnectionswith its truncated address and wallet type, a checkmark on the active one, a 'Switch' action callingswitchTo(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 viauseUserPreferences().setPreferredWalletType. Route errors throughclassifyWalletErrorandWalletErrorModalwith actionable messages, and passonRetrythat re-invokes the failed connect. This implements the selection UI, switching, status indicator, and error handling for issue 882. (src/components/WalletConnect.tsx)src/components/WalletErrorModal.tsxwith a newwalletconnect_failederror type and awallet_switch_failedtype. Add corresponding content components with actionable guidance (retry, choose another wallet, or open the WalletConnect QR flow) and make sureonRetryis wired for both. This ensures wallet-specific errors are clear and actionable for issue 882. (src/components/WalletErrorModal.tsx)src/lib/walletMonitor.tsto monitor all connected wallets rather than only Freighter. ChangestartWalletPollingto accept a list of{ address, walletType }connections, poll each adapter (getFreighterPublicKey/getWalletConnectPublicKey), and emitWalletStateevents that include thewalletTypeand the affectedaddressso 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)