Conversation
|
|
@jbrauck-unchained is attempting to deploy a commit to the Unchained Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ed/caravan into transaction-flow trying to fix this
@jbrauck-unchained maybe you'll have do the formatting ( run the linter ) and get the unsed imports out for the ci to pass :)
|
|
This pull request has been inactive for 30 days and has been marked as stale. It will be closed in 7 days if no further activity occurs. To keep this PR open, add the "long-lived" label or comment on it. |
Legend101Zz
left a comment
There was a problem hiding this comment.
@jbrauck-unchained thanks for the awesome work , I tested it and it looks super good to me , now I guess we can move towards the code changes , the main concern I have is over modularity and an IIFE used in rendering of the flow status
apps/coordinator/src/components/Wallet/TransactionFlowDiagram.tsx
Outdated
Show resolved
Hide resolved
apps/coordinator/src/components/Wallet/TransactionFlowDiagram.tsx
Outdated
Show resolved
Hide resolved
| return `${address.slice(0, 10)}...${address.slice(-8)}`; | ||
| }; | ||
|
|
||
| const getStatusDisplay = () => { |
There was a problem hiding this comment.
this can go in the utils file then
| }; | ||
|
|
||
| // Format script type for display | ||
| const formatScriptType = (scriptType?: string) => { |
There was a problem hiding this comment.
can you add this and formatAddress in the general utils file as they can be used by other components too :)
There was a problem hiding this comment.
Is there a different general utils file you are talking about? For now I added to the TransactionFlowUtils.ts file
There was a problem hiding this comment.
that works perfectly for me :)
- Create TransactionFlowDiagram directory structure with separate files: - index.tsx: Main component file (cleaner, more focused) - hooks.ts: Custom useFlowPaths hook for SVG path calculations - utils.ts: Utility functions (buildCurvePath, formatAddress, formatScriptType, getScriptTypeColor, getStatusDisplay) - FlowDrawers.tsx: Input and output drawer components - FlowSummary.tsx: Summary section with legend and transaction totals - Move formatSats and formatAddress to transactionFlowUtils.ts for reuse - Remove old 1704-line monolithic TransactionFlowDiagram.tsx file This addresses code review feedback to improve maintainability and readability.
- Remove unused variables in TransactionPreview.jsx render method - Fix prettier formatting in TransactionsTable.tsx - Fix prettier formatting in useTransactionDetails.ts - Remove unused blockHeight variable in transactionFlowUtils.ts
Legend101Zz
left a comment
There was a problem hiding this comment.
Thanks alot for the changes , it's looking really good now , nothing from my end now :)
@bucko13 can you please review it when you get the chance ...
bucko13
left a comment
There was a problem hiding this comment.
I don't love all of the inline stylings that we have throughout this. it will make the aesthetics come out inconsistent with the rest of the app and also harder to maintain. we should be able to use existing theming or components and/or update to the theme.
few other opportunities for code consolidation/cleanup. Also would like to add type safety where possible.
| }} | ||
| > | ||
| {inputs.map((input, idx) => { | ||
| const inputAmount = BigNumber( |
There was a problem hiding this comment.
We should pull this out to be its own component and then just pass in the props.
| label="Economical" | ||
| color="success" | ||
| size="small" | ||
| sx={{ height: 20, fontSize: "0.7rem" }} |
There was a problem hiding this comment.
seems like there's some room for code consolidation here. this styling is repeated on every box as far as I can tell and it should be generalized. If we change the look somehow you'll have to change every single line. do we want this to be a specialized kind of component?
| }} | ||
| > | ||
| {inputs.slice(0, 4).map((input, idx) => { | ||
| const inputAmount = BigNumber( |
There was a problem hiding this comment.
another one that should be its own component to simplify this file a bit. and what can we do to clean up the inline styles?
|
|
||
| {/* Change Outputs */} | ||
| {flowData.changeOutputs.map((output, idx) => { | ||
| const amount = BigNumber(output.amount); |
There was a problem hiding this comment.
modular component opportunity here.
There was a problem hiding this comment.
lots of simplification we can get here.
| const blockchainClient = useGetClient(); | ||
|
|
||
| return useQuery( | ||
| [TRANSACTION_DETAILS_KEY, txid], |
There was a problem hiding this comment.
see some of the other hooks for how we setup the query cache keys.
| return updateState(state); | ||
| case SET_TXID: | ||
| return updateState(state, { txid: action.value }); | ||
| case SET_BROADCASTING: |
There was a problem hiding this comment.
now i'm curious what this is actually indicating. also wonder if there's a way we can avoid adding to the redux store. It's hard in caravan since we have a lot of tightly coupled legacy code, but if we can avoid adding to the redux store that would definitely be the preference.
| changeAddress?: string; | ||
| inputsTotalSats: BigNumber; | ||
| status: | ||
| | "draft" |
There was a problem hiding this comment.
see we're using these values in other places. what if we made this a shareable type and then could make all uses of it type safe.
| /** | ||
| * Detect script type from address prefix (heuristic) | ||
| */ | ||
| const detectScriptTypeFromAddress = (address?: string): string | undefined => { |
There was a problem hiding this comment.
we have address type detection tools in caravan-bitcoin
| * @returns FlowDiagramProps ready for the component | ||
| */ | ||
| export const transformTransactionToFlowDiagram = ( | ||
| tx: any, |
There was a problem hiding this comment.
I think we have some types for this don't we @Legend101Zz ?




What kind of change does this PR introduce?
This introduces a new tranasction flow diagram feature
Issue Number:
Fixes #393 #393
Snapshots/Videos:
If relevant, did you update the documentation?
Summary
I like what sparrow does to try and give a user a sense of understanding their own transaction. I think this is a small lift to gain feature parity in a place that makes caravan more educational.
Does this PR introduce a breaking change?
Checklist
npm run changeset)Other information
Have you read the contributing guide?
For information on creating and using changesets, please refer to our documentation on changesets.