@@ -21,6 +21,8 @@ import {
2121 resumeStream ,
2222 toSorobanErrorMessage ,
2323} from "@/lib/soroban" ;
24+ import { formatAmount , parseAmount , hasValidPrecision , formatRate } from "@/lib/amount" ;
25+ import type { WalletSession } from "@/lib/wallet" ;
2426interface StreamDetail {
2527 id : string ;
2628 sender : string ;
@@ -170,10 +172,15 @@ export default function StreamDetailsPage() {
170172 return ;
171173 }
172174
175+ if ( ! hasValidPrecision ( topUpAmount , 7 ) ) {
176+ toast . error ( "Amount exceeds maximum precision (7 decimal places)" ) ;
177+ return ;
178+ }
179+
173180 try {
174181 await topUpStream ( session , {
175182 streamId : BigInt ( streamId ) ,
176- amount : BigInt ( parseFloat ( topUpAmount ) * 1e7 ) , // Convert to stroops
183+ amount : parseAmount ( topUpAmount , 7 ) ,
177184 } ) ;
178185 toast . success ( "Stream topped up successfully!" ) ;
179186 setShowTopUp ( false ) ;
@@ -276,8 +283,8 @@ export default function StreamDetailsPage() {
276283 ) ;
277284 }
278285
279- const deposited = parseFloat ( stream . depositedAmount ) / 1e7 ;
280- const withdrawn = parseFloat ( stream . withdrawnAmount ) / 1e7 ;
286+ const deposited = parseFloat ( formatAmount ( BigInt ( stream . depositedAmount ) , 7 ) ) ;
287+ const withdrawn = parseFloat ( formatAmount ( BigInt ( stream . withdrawnAmount ) , 7 ) ) ;
281288 const claimable = deposited - withdrawn ;
282289 const displayedClaimable = withdrawStatus === "submitted" ? 0 : claimable ;
283290 const percentage = Math . round ( ( withdrawn / deposited ) * 100 ) ;
@@ -351,7 +358,7 @@ export default function StreamDetailsPage() {
351358 </ div >
352359 < div style = { { textAlign : "right" } } >
353360 < p style = { { margin : "0.2rem 0" , fontSize : "0.9rem" } } >
354- Rate: { ( parseFloat ( stream . ratePerSecond ) / 1e7 ) . toFixed ( 7 ) } / sec
361+ Rate: { formatRate ( BigInt ( stream . ratePerSecond ) , 7 ) }
355362 </ p >
356363 < p style = { { margin : "0.2rem 0" , fontSize : "0.9rem" } } >
357364 Started: { new Date ( stream . startTime * 1000 ) . toLocaleDateString ( ) }
@@ -459,6 +466,14 @@ export default function StreamDetailsPage() {
459466 { resuming ? "Resuming..." : "Resume Stream" }
460467 </ Button >
461468 ) }
469+ < Button
470+ onClick = { ( ) => setShowCancelModal ( true ) }
471+ disabled = { cancelling || ! stream . isActive }
472+ style = { { borderColor : "#ef4444" , color : "#ef4444" } }
473+ variant = "outline"
474+ >
475+ { cancelling ? "Cancelling..." : "Cancel Stream" }
476+ </ Button >
462477 </ div >
463478
464479 { showTopUp && (
@@ -496,7 +511,6 @@ export default function StreamDetailsPage() {
496511 />
497512 </ div >
498513 ) }
499-
500514 { withdrawStatus !== "idle" && (
501515 < div style = { { marginTop : "1rem" } } >
502516 < TransactionTracker
0 commit comments