Feat/tip refund mechanism#408
Merged
Merged
Conversation
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.
Smart contract (
tipstream.clar
)
Added 5 new error constants (err-refund-window-expired, err-already-refunded, err-not-tip-sender, err-refund-not-found, err-refund-not-pending)
Added refund-window-blocks constant (144 blocks ≈ 24 hours) and status constants
Added refund-requests and refunded-tips data maps
Added request-refund, approve-refund, reject-refund public functions
Added get-refund-request, is-tip-refunded, is-refund-eligible, get-refund-window-blocks read-only functions
Backend (chainhook/)
storage.js — MemoryRefundStore and PostgresRefundStore with full CRUD, createRefundStore factory, REFUND_STATUSES and REFUND_WINDOW_MS exports
schema.sql — refund_requests table with indexes on sender, recipient, status
server.js — POST /api/refunds, GET /api/refunds, GET /api/refunds/:tipId, PATCH /api/refunds/:tipId endpoints with full validation
refund.test.js — 16 store unit tests
refund-api.test.js — 18 validation and lifecycle tests
Frontend (frontend/src/)
contracts.js
— 7 new refund function name constants
routes.js
— ROUTE_REFUNDS with labels, titles, and metadata
useRefund.js
— useRefund hook with requestRefund, resolveRefund, fetchRefundRequest, fetchUserRefunds, isWithinRefundWindow
RefundRequest.jsx
— sender-side refund initiation with confirm dialog and on-chain call
RefundApproval.jsx
— recipient-side approve/reject with on-chain calls
RefundHistory.jsx
— paginated history with direction and status filters
RefundManager.jsx
— page-level container
TipHistory.jsx
— integrated RefundRequest and RefundApproval into each tip row
App.jsx — ROUTE_REFUNDS route, RefundManager lazy import, RotateCcw nav icon, addToast passed to TipHistory
RefundRequest.test.jsx — 12 component tests
RefundHistory.test.jsx — 12 component tests
Closes #392