@trustless-work/blocks 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +326 -105
- package/package.json +1 -1
- package/templates/dashboard/dashboard-01/useDashboard.ts +1 -1
- package/templates/dashboard/deps.json +8 -0
- package/templates/deps.json +12 -26
- package/templates/escrows/deps.json +30 -0
- package/templates/escrows/details/Actions.tsx +46 -45
- package/templates/escrows/details/GeneralInformation.tsx +10 -7
- package/templates/escrows/details/MilestoneCard.tsx +31 -16
- package/templates/escrows/details/MilestoneDetailDialog.tsx +2 -2
- package/templates/escrows/details/SuccessReleaseDialog.tsx +1 -1
- package/templates/escrows/details/useDetailsEscrow.ts +1 -1
- package/templates/escrows/escrows-by-role/cards/EscrowsCards.tsx +4 -4
- package/templates/escrows/escrows-by-role/table/EscrowsTable.tsx +2 -2
- package/templates/escrows/escrows-by-role/useEscrowsByRole.shared.ts +1 -1
- package/templates/escrows/escrows-by-signer/cards/EscrowsCards.tsx +4 -4
- package/templates/escrows/escrows-by-signer/table/EscrowsTable.tsx +2 -2
- package/templates/escrows/escrows-by-signer/useEscrowsBySigner.shared.ts +1 -1
- package/templates/escrows/multi-release/dispute-milestone/button/DisputeMilestone.tsx +1 -1
- package/templates/escrows/multi-release/dispute-milestone/shared/useDisputeMilestone.ts +1 -1
- package/templates/escrows/multi-release/initialize-escrow/shared/useInitializeEscrow.ts +1 -1
- package/templates/escrows/multi-release/release-milestone/button/ReleaseMilestone.tsx +1 -1
- package/templates/escrows/multi-release/release-milestone/shared/useReleaseMilestone.ts +1 -1
- package/templates/escrows/multi-release/resolve-dispute/button/ResolveDispute.tsx +1 -1
- package/templates/escrows/multi-release/resolve-dispute/dialog/ResolveDispute.tsx +1 -1
- package/templates/escrows/multi-release/resolve-dispute/form/ResolveDispute.tsx +1 -1
- package/templates/escrows/multi-release/resolve-dispute/shared/useResolveDispute.ts +23 -5
- package/templates/escrows/multi-release/update-escrow/shared/schema.ts +3 -0
- package/templates/escrows/multi-release/update-escrow/shared/useUpdateEscrow.ts +4 -8
- package/templates/escrows/multi-release/withdraw-remaining-funds/button/WithdrawRemainingFunds.tsx +1 -1
- package/templates/escrows/multi-release/withdraw-remaining-funds/dialog/WithdrawRemainingFunds.tsx +1 -1
- package/templates/escrows/multi-release/withdraw-remaining-funds/form/WithdrawRemainingFunds.tsx +1 -1
- package/templates/escrows/multi-release/withdraw-remaining-funds/shared/useWithdrawRemainingFunds.ts +1 -1
- package/templates/escrows/single-multi-release/approve-milestone/button/ApproveMilestone.tsx +1 -1
- package/templates/escrows/single-multi-release/approve-milestone/shared/useApproveMilestone.ts +1 -1
- package/templates/escrows/single-multi-release/change-milestone-status/button/ChangeMilestoneStatus.tsx +1 -1
- package/templates/escrows/single-multi-release/change-milestone-status/shared/useChangeMilestoneStatus.ts +1 -1
- package/templates/escrows/single-multi-release/fund-escrow/button/FundEscrow.tsx +1 -1
- package/templates/escrows/single-multi-release/fund-escrow/shared/useFundEscrow.ts +1 -1
- package/templates/escrows/single-release/dispute-escrow/button/DisputeEscrow.tsx +1 -1
- package/templates/escrows/single-release/initialize-escrow/dialog/InitializeEscrow.tsx +1 -0
- package/templates/escrows/single-release/initialize-escrow/form/InitializeEscrow.tsx +1 -0
- package/templates/escrows/single-release/initialize-escrow/shared/useInitializeEscrow.ts +1 -1
- package/templates/escrows/single-release/release-escrow/button/ReleaseEscrow.tsx +1 -1
- package/templates/escrows/single-release/resolve-dispute/button/ResolveDispute.tsx +1 -1
- package/templates/escrows/single-release/resolve-dispute/dialog/ResolveDispute.tsx +1 -1
- package/templates/escrows/single-release/resolve-dispute/shared/useResolveDispute.ts +1 -1
- package/templates/escrows/single-release/update-escrow/shared/useUpdateEscrow.ts +3 -7
- package/templates/handle-errors/deps.json +7 -0
- package/templates/helpers/deps.json +5 -0
- package/templates/providers/deps.json +8 -0
- package/templates/tanstack/deps.json +8 -0
- package/templates/wallet-kit/WalletButtons.tsx +1 -1
- package/templates/wallet-kit/deps.json +7 -0
- package/templates/wallet-kit/trustlines.ts +5 -5
- package/templates/wallet-kit/useWallet.ts +1 -1
- /package/templates/{wallet-kit → providers}/WalletProvider.tsx +0 -0
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
GetEscrowsFromIndexerResponse as Escrow,
|
|
15
15
|
Role,
|
|
16
16
|
} from "@trustless-work/escrow/types";
|
|
17
|
-
import { FundEscrowDialog } from "../../single-multi-release/fund-escrow/dialog/FundEscrow";
|
|
17
|
+
// import { FundEscrowDialog } from "../../single-multi-release/fund-escrow/dialog/FundEscrow";
|
|
18
18
|
|
|
19
19
|
interface ActionsProps {
|
|
20
20
|
selectedEscrow: Escrow;
|
|
@@ -28,49 +28,49 @@ export const roleActions: {
|
|
|
28
28
|
icon: React.ReactNode;
|
|
29
29
|
color: string;
|
|
30
30
|
}[] = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
];
|
|
31
|
+
{
|
|
32
|
+
role: "signer",
|
|
33
|
+
actions: ["fundEscrow"],
|
|
34
|
+
icon: <Wallet className="h-6 w-6 text-primary" />,
|
|
35
|
+
color: "",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
role: "approver",
|
|
39
|
+
actions: ["fundEscrow", "approveMilestone", "startDispute"],
|
|
40
|
+
icon: <CheckCircle className="h-6 w-6 text-primary" />,
|
|
41
|
+
color: "0",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
role: "serviceProvider",
|
|
45
|
+
actions: ["fundEscrow", "completeMilestone", "startDispute"],
|
|
46
|
+
icon: <Briefcase className="h-6 w-6 text-primary" />,
|
|
47
|
+
color: "0",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
role: "disputeResolver",
|
|
51
|
+
actions: ["fundEscrow", "resolveDispute"],
|
|
52
|
+
icon: <Scale className="h-6 w-6 text-primary" />,
|
|
53
|
+
color: "00",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
role: "releaseSigner",
|
|
57
|
+
actions: ["fundEscrow", "releasePayment"],
|
|
58
|
+
icon: <Unlock className="h-6 w-6 text-primary" />,
|
|
59
|
+
color: "",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
role: "platformAddress",
|
|
63
|
+
actions: ["fundEscrow", "editEscrow"],
|
|
64
|
+
icon: <Settings className="h-6 w-6 text-primary" />,
|
|
65
|
+
color: "0",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
role: "receiver",
|
|
69
|
+
actions: ["fundEscrow"],
|
|
70
|
+
icon: <DollarSign className="h-6 w-6 text-primary" />,
|
|
71
|
+
color: "",
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
74
|
|
|
75
75
|
export const actionIcons: Record<string, React.ReactNode> = {
|
|
76
76
|
fundEscrow: <DollarSign className="h-6 w-6 text-primary/60" />,
|
|
@@ -160,7 +160,8 @@ export const Actions = ({
|
|
|
160
160
|
</div>
|
|
161
161
|
)}
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
{/* FundEscrow */}
|
|
164
|
+
{/* <FundEscrowDialog /> */}
|
|
164
165
|
</div>
|
|
165
166
|
);
|
|
166
167
|
};
|
|
@@ -96,7 +96,10 @@ export const GeneralInformation = ({
|
|
|
96
96
|
<StatisticsCard
|
|
97
97
|
title="Amount"
|
|
98
98
|
icon={CircleDollarSign}
|
|
99
|
-
value={formatCurrency(
|
|
99
|
+
value={formatCurrency(
|
|
100
|
+
totalAmount,
|
|
101
|
+
selectedEscrow.trustline?.symbol
|
|
102
|
+
)}
|
|
100
103
|
/>
|
|
101
104
|
|
|
102
105
|
<StatisticsCard
|
|
@@ -104,7 +107,7 @@ export const GeneralInformation = ({
|
|
|
104
107
|
icon={Wallet}
|
|
105
108
|
value={formatCurrency(
|
|
106
109
|
selectedEscrow.balance ?? 0,
|
|
107
|
-
selectedEscrow.trustline?.
|
|
110
|
+
selectedEscrow.trustline?.symbol
|
|
108
111
|
)}
|
|
109
112
|
/>
|
|
110
113
|
</div>
|
|
@@ -136,7 +139,7 @@ export const GeneralInformation = ({
|
|
|
136
139
|
<div className="flex-1 min-w-0">
|
|
137
140
|
<div className="flex items-center justify-between mb-2">
|
|
138
141
|
<span className="text-sm font-medium text-muted-foreground">
|
|
139
|
-
{selectedEscrow.trustline?.
|
|
142
|
+
{selectedEscrow.trustline?.symbol || "No Trustline"} |
|
|
140
143
|
Escrow ID
|
|
141
144
|
</span>
|
|
142
145
|
<button
|
|
@@ -237,7 +240,7 @@ export const GeneralInformation = ({
|
|
|
237
240
|
<span className="font-medium">
|
|
238
241
|
{formatCurrency(
|
|
239
242
|
selectedEscrow.amount,
|
|
240
|
-
selectedEscrow.trustline?.
|
|
243
|
+
selectedEscrow.trustline?.symbol
|
|
241
244
|
)}
|
|
242
245
|
</span>
|
|
243
246
|
</div>
|
|
@@ -256,7 +259,7 @@ export const GeneralInformation = ({
|
|
|
256
259
|
<span className="font-medium">
|
|
257
260
|
{formatCurrency(
|
|
258
261
|
Number(receiverAmount.toFixed(2)),
|
|
259
|
-
selectedEscrow.trustline?.
|
|
262
|
+
selectedEscrow.trustline?.symbol
|
|
260
263
|
)}
|
|
261
264
|
</span>
|
|
262
265
|
</div>
|
|
@@ -276,7 +279,7 @@ export const GeneralInformation = ({
|
|
|
276
279
|
<span className="font-medium">
|
|
277
280
|
{formatCurrency(
|
|
278
281
|
Number(platformFeeAmount.toFixed(2)),
|
|
279
|
-
selectedEscrow.trustline?.
|
|
282
|
+
selectedEscrow.trustline?.symbol
|
|
280
283
|
)}
|
|
281
284
|
</span>
|
|
282
285
|
</div>
|
|
@@ -297,7 +300,7 @@ export const GeneralInformation = ({
|
|
|
297
300
|
<span className="font-medium">
|
|
298
301
|
{formatCurrency(
|
|
299
302
|
Number(trustlessWorkAmount.toFixed(2)),
|
|
300
|
-
selectedEscrow.trustline?.
|
|
303
|
+
selectedEscrow.trustline?.symbol
|
|
301
304
|
)}
|
|
302
305
|
</span>
|
|
303
306
|
</div>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Button } from "__UI_BASE__/button";
|
|
4
4
|
import { Card, CardContent, CardHeader, CardTitle } from "__UI_BASE__/card";
|
|
5
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "__UI_BASE__/tooltip";
|
|
5
6
|
import {
|
|
6
7
|
FileCheck2,
|
|
7
8
|
Eye,
|
|
@@ -17,8 +18,8 @@ import {
|
|
|
17
18
|
SingleReleaseMilestone,
|
|
18
19
|
} from "@trustless-work/escrow";
|
|
19
20
|
import { Badge } from "__UI_BASE__/badge";
|
|
20
|
-
import { ChangeMilestoneStatusDialog } from "../../single-multi-release/change-milestone-status/dialog/ChangeMilestoneStatus";
|
|
21
|
-
import { ApproveMilestoneButton } from "../../single-multi-release/approve-milestone/button/ApproveMilestone";
|
|
21
|
+
// import { ChangeMilestoneStatusDialog } from "../../single-multi-release/change-milestone-status/dialog/ChangeMilestoneStatus";
|
|
22
|
+
// import { ApproveMilestoneButton } from "../../single-multi-release/approve-milestone/button/ApproveMilestone";
|
|
22
23
|
import { formatCurrency } from "@/components/tw-blocks/helpers/format.helper";
|
|
23
24
|
|
|
24
25
|
interface MilestoneCardProps {
|
|
@@ -107,10 +108,10 @@ const MilestoneCardComponent = ({
|
|
|
107
108
|
!("flags" in milestone && milestone.flags?.approved)
|
|
108
109
|
) {
|
|
109
110
|
buttons.push(
|
|
110
|
-
<ChangeMilestoneStatusDialog
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
/>
|
|
111
|
+
// <ChangeMilestoneStatusDialog
|
|
112
|
+
// key={`change-status-${milestoneIndex}`}
|
|
113
|
+
// milestoneIndex={milestoneIndex}
|
|
114
|
+
// />
|
|
114
115
|
);
|
|
115
116
|
}
|
|
116
117
|
|
|
@@ -124,10 +125,10 @@ const MilestoneCardComponent = ({
|
|
|
124
125
|
!milestone.flags?.resolved))
|
|
125
126
|
) {
|
|
126
127
|
buttons.push(
|
|
127
|
-
<ApproveMilestoneButton
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
/>
|
|
128
|
+
// <ApproveMilestoneButton
|
|
129
|
+
// key={`approve-${milestoneIndex}`}
|
|
130
|
+
// milestoneIndex={milestoneIndex}
|
|
131
|
+
// />
|
|
131
132
|
);
|
|
132
133
|
}
|
|
133
134
|
|
|
@@ -190,11 +191,22 @@ const MilestoneCardComponent = ({
|
|
|
190
191
|
className="hover:shadow-lg transition-all duration-200"
|
|
191
192
|
>
|
|
192
193
|
<CardHeader className="pb-4">
|
|
193
|
-
<div className="flex items-center justify-between">
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
<div className="flex items-center justify-between gap-2 min-w-0">
|
|
195
|
+
<div className="min-w-0 flex-1 overflow-hidden">
|
|
196
|
+
<Tooltip>
|
|
197
|
+
<TooltipTrigger asChild>
|
|
198
|
+
<CardTitle className="text-base font-semibold text-foreground truncate block">
|
|
199
|
+
{milestone.description}
|
|
200
|
+
</CardTitle>
|
|
201
|
+
</TooltipTrigger>
|
|
202
|
+
<TooltipContent side="top" className="max-w-[min(20rem,90vw)]">
|
|
203
|
+
{milestone.description}
|
|
204
|
+
</TooltipContent>
|
|
205
|
+
</Tooltip>
|
|
206
|
+
</div>
|
|
207
|
+
<div className="flex-shrink-0">
|
|
208
|
+
{getMilestoneStatusBadge(milestone)}
|
|
209
|
+
</div>
|
|
198
210
|
</div>
|
|
199
211
|
</CardHeader>
|
|
200
212
|
|
|
@@ -202,7 +214,10 @@ const MilestoneCardComponent = ({
|
|
|
202
214
|
{"amount" in milestone && (
|
|
203
215
|
<div className="flex items-center gap-2 py-2">
|
|
204
216
|
<span className="text-2xl font-bold text-foreground">
|
|
205
|
-
{formatCurrency(
|
|
217
|
+
{formatCurrency(
|
|
218
|
+
milestone.amount,
|
|
219
|
+
selectedEscrow.trustline?.symbol
|
|
220
|
+
)}
|
|
206
221
|
</span>
|
|
207
222
|
</div>
|
|
208
223
|
)}
|
|
@@ -178,7 +178,7 @@ export const MilestoneDetailDialog = ({
|
|
|
178
178
|
<span className="font-bold text-foreground">
|
|
179
179
|
{formatCurrency(
|
|
180
180
|
selectedMilestone.milestone.amount,
|
|
181
|
-
selectedEscrow?.trustline?.
|
|
181
|
+
selectedEscrow?.trustline?.symbol ?? "USDC"
|
|
182
182
|
)}
|
|
183
183
|
</span>
|
|
184
184
|
</div>
|
|
@@ -268,7 +268,7 @@ export const MilestoneDetailDialog = ({
|
|
|
268
268
|
<p className="text-sm font-medium text-red-700 dark:text-red-300">
|
|
269
269
|
<span className="font-bold">Disputed by:</span>{" "}
|
|
270
270
|
{selectedMilestone.milestone.disputeStartedBy ===
|
|
271
|
-
|
|
271
|
+
"serviceProvider"
|
|
272
272
|
? "Service Provider"
|
|
273
273
|
: "Approver"}
|
|
274
274
|
</p>
|
|
@@ -35,7 +35,7 @@ export const SuccessReleaseDialog = ({
|
|
|
35
35
|
const trustlessPercentage = 0.3;
|
|
36
36
|
const receiverPercentage = 100 - (platformFee + trustlessPercentage);
|
|
37
37
|
|
|
38
|
-
const currency = selectedEscrow?.trustline?.
|
|
38
|
+
const currency = selectedEscrow?.trustline?.symbol ?? "";
|
|
39
39
|
|
|
40
40
|
const cards = useMemo<
|
|
41
41
|
Array<{
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
GetEscrowsFromIndexerResponse as Escrow,
|
|
4
4
|
MultiReleaseMilestone,
|
|
5
5
|
} from "@trustless-work/escrow/types";
|
|
6
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
6
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
7
7
|
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
8
8
|
import { useEscrowAmountContext } from "@/components/tw-blocks/providers/EscrowAmountProvider";
|
|
9
9
|
|
|
@@ -293,7 +293,7 @@ export const EscrowsByRoleCards = () => {
|
|
|
293
293
|
{escrow.type === "single-release"
|
|
294
294
|
? formatCurrency(
|
|
295
295
|
escrow.amount,
|
|
296
|
-
escrow.trustline.
|
|
296
|
+
escrow.trustline.symbol
|
|
297
297
|
)
|
|
298
298
|
: formatCurrency(
|
|
299
299
|
escrow.milestones.reduce(
|
|
@@ -303,7 +303,7 @@ export const EscrowsByRoleCards = () => {
|
|
|
303
303
|
.amount,
|
|
304
304
|
0
|
|
305
305
|
),
|
|
306
|
-
escrow.trustline.
|
|
306
|
+
escrow.trustline.symbol
|
|
307
307
|
)}
|
|
308
308
|
</span>
|
|
309
309
|
</div>
|
|
@@ -316,7 +316,7 @@ export const EscrowsByRoleCards = () => {
|
|
|
316
316
|
<span className="font-medium text-green-800 dark:text-green-600">
|
|
317
317
|
{formatCurrency(
|
|
318
318
|
escrow.balance,
|
|
319
|
-
escrow.trustline.
|
|
319
|
+
escrow.trustline.symbol
|
|
320
320
|
)}
|
|
321
321
|
</span>
|
|
322
322
|
</div>
|
|
@@ -362,7 +362,7 @@ export const EscrowsByRoleCards = () => {
|
|
|
362
362
|
<span className="text-muted-foreground">
|
|
363
363
|
{formatCurrency(
|
|
364
364
|
milestone.amount,
|
|
365
|
-
escrow.trustline.
|
|
365
|
+
escrow.trustline.symbol
|
|
366
366
|
)}
|
|
367
367
|
</span>
|
|
368
368
|
|
|
@@ -160,9 +160,9 @@ export const EscrowsByRoleTable = () => {
|
|
|
160
160
|
cell: ({ row }) => (
|
|
161
161
|
<span
|
|
162
162
|
className="max-w-[220px] truncate block"
|
|
163
|
-
title={`${row.original.trustline.
|
|
163
|
+
title={`${row.original.trustline.symbol} (${row.original.trustline.address})`}
|
|
164
164
|
>
|
|
165
|
-
{row.original.trustline.
|
|
165
|
+
{row.original.trustline.symbol}
|
|
166
166
|
</span>
|
|
167
167
|
),
|
|
168
168
|
},
|
|
@@ -5,7 +5,7 @@ import { startOfDay, endOfDay, format } from "date-fns";
|
|
|
5
5
|
import type { DateRange as DayPickerDateRange } from "react-day-picker";
|
|
6
6
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
7
7
|
import type { SortingState } from "@tanstack/react-table";
|
|
8
|
-
import { useWalletContext } from "../../
|
|
8
|
+
import { useWalletContext } from "../../providers/WalletProvider";
|
|
9
9
|
import { useEscrowsByRoleQuery } from "../../tanstack/useEscrowsByRoleQuery";
|
|
10
10
|
import type { GetEscrowsFromIndexerByRoleParams } from "@trustless-work/escrow";
|
|
11
11
|
import { GetEscrowsFromIndexerResponse as Escrow } from "@trustless-work/escrow/types";
|
|
@@ -281,7 +281,7 @@ export const EscrowsBySignerCards = () => {
|
|
|
281
281
|
{escrow.type === "single-release"
|
|
282
282
|
? formatCurrency(
|
|
283
283
|
escrow.amount,
|
|
284
|
-
escrow.trustline.
|
|
284
|
+
escrow.trustline.symbol
|
|
285
285
|
)
|
|
286
286
|
: formatCurrency(
|
|
287
287
|
escrow.milestones.reduce(
|
|
@@ -291,7 +291,7 @@ export const EscrowsBySignerCards = () => {
|
|
|
291
291
|
.amount,
|
|
292
292
|
0
|
|
293
293
|
),
|
|
294
|
-
escrow.trustline.
|
|
294
|
+
escrow.trustline.symbol
|
|
295
295
|
)}
|
|
296
296
|
</span>
|
|
297
297
|
</div>
|
|
@@ -304,7 +304,7 @@ export const EscrowsBySignerCards = () => {
|
|
|
304
304
|
<span className="font-medium text-green-800 dark:text-green-600">
|
|
305
305
|
{formatCurrency(
|
|
306
306
|
escrow.balance,
|
|
307
|
-
escrow.trustline.
|
|
307
|
+
escrow.trustline.symbol
|
|
308
308
|
)}
|
|
309
309
|
</span>
|
|
310
310
|
</div>
|
|
@@ -350,7 +350,7 @@ export const EscrowsBySignerCards = () => {
|
|
|
350
350
|
<span className="text-muted-foreground">
|
|
351
351
|
{formatCurrency(
|
|
352
352
|
milestone.amount,
|
|
353
|
-
escrow.trustline.
|
|
353
|
+
escrow.trustline.symbol
|
|
354
354
|
)}
|
|
355
355
|
</span>
|
|
356
356
|
|
|
@@ -150,9 +150,9 @@ export const EscrowsBySignerTable = () => {
|
|
|
150
150
|
cell: ({ row }) => (
|
|
151
151
|
<span
|
|
152
152
|
className="max-w-[220px] truncate block"
|
|
153
|
-
title={`${row.original.trustline.
|
|
153
|
+
title={`${row.original.trustline.symbol} (${row.original.trustline.address})`}
|
|
154
154
|
>
|
|
155
|
-
{row.original.trustline.
|
|
155
|
+
{row.original.trustline.symbol}
|
|
156
156
|
</span>
|
|
157
157
|
),
|
|
158
158
|
},
|
|
@@ -5,7 +5,7 @@ import { startOfDay, endOfDay, format } from "date-fns";
|
|
|
5
5
|
import type { DateRange as DayPickerDateRange } from "react-day-picker";
|
|
6
6
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
7
7
|
import type { SortingState } from "@tanstack/react-table";
|
|
8
|
-
import { useWalletContext } from "../../
|
|
8
|
+
import { useWalletContext } from "../../providers/WalletProvider";
|
|
9
9
|
import { useEscrowsBySignerQuery } from "../../tanstack/useEscrowsBySignerQuery";
|
|
10
10
|
import { GetEscrowsFromIndexerResponse as Escrow } from "@trustless-work/escrow/types";
|
|
11
11
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Button } from "__UI_BASE__/button";
|
|
3
3
|
import { useEscrowsMutations } from "@/components/tw-blocks/tanstack/useEscrowsMutations";
|
|
4
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
4
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
5
5
|
import {
|
|
6
6
|
MultiReleaseStartDisputePayload,
|
|
7
7
|
MultiReleaseMilestone,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
ErrorResponse,
|
|
17
17
|
handleError,
|
|
18
18
|
} from "@/components/tw-blocks/handle-errors/handle";
|
|
19
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
19
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
20
20
|
|
|
21
21
|
export function useDisputeMilestone({
|
|
22
22
|
onSuccess,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
InitializeMultiReleaseEscrowResponse,
|
|
9
9
|
} from "@trustless-work/escrow/types";
|
|
10
10
|
import { toast } from "sonner";
|
|
11
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
11
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
12
12
|
import { useEscrowsMutations } from "@/components/tw-blocks/tanstack/useEscrowsMutations";
|
|
13
13
|
import {
|
|
14
14
|
ErrorResponse,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Button } from "__UI_BASE__/button";
|
|
3
3
|
import { useEscrowsMutations } from "@/components/tw-blocks/tanstack/useEscrowsMutations";
|
|
4
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
4
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
5
5
|
import {
|
|
6
6
|
MultiReleaseReleaseFundsPayload,
|
|
7
7
|
MultiReleaseMilestone,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
ErrorResponse,
|
|
17
17
|
handleError,
|
|
18
18
|
} from "@/components/tw-blocks/handle-errors/handle";
|
|
19
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
19
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
20
20
|
import { useEscrowDialogs } from "@/components/tw-blocks/providers/EscrowDialogsProvider";
|
|
21
21
|
import { useEscrowAmountContext } from "@/components/tw-blocks/providers/EscrowAmountProvider";
|
|
22
22
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Button } from "__UI_BASE__/button";
|
|
3
3
|
import { useEscrowsMutations } from "@/components/tw-blocks/tanstack/useEscrowsMutations";
|
|
4
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
4
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
5
5
|
import {
|
|
6
6
|
MultiReleaseResolveDisputePayload,
|
|
7
7
|
MultiReleaseMilestone,
|
|
@@ -204,7 +204,7 @@ export const ResolveDisputeDialog = ({
|
|
|
204
204
|
<span className="font-bold">Total Balance: </span>
|
|
205
205
|
{formatCurrency(
|
|
206
206
|
selectedEscrow?.balance || 0,
|
|
207
|
-
selectedEscrow?.trustline.
|
|
207
|
+
selectedEscrow?.trustline.symbol || ""
|
|
208
208
|
)}
|
|
209
209
|
</p>
|
|
210
210
|
</div>
|
|
@@ -184,7 +184,7 @@ export const ResolveDisputeForm = ({
|
|
|
184
184
|
<span className="font-bold">Total Balance: </span>
|
|
185
185
|
{formatCurrency(
|
|
186
186
|
selectedEscrow?.balance || 0,
|
|
187
|
-
selectedEscrow?.trustline.
|
|
187
|
+
selectedEscrow?.trustline.symbol || ""
|
|
188
188
|
)}
|
|
189
189
|
</p>
|
|
190
190
|
</div>
|
|
@@ -13,11 +13,13 @@ import {
|
|
|
13
13
|
ErrorResponse,
|
|
14
14
|
handleError,
|
|
15
15
|
} from "@/components/tw-blocks/handle-errors/handle";
|
|
16
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
16
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
17
17
|
|
|
18
18
|
type DistributionInput = { address: string; amount: string | number };
|
|
19
19
|
|
|
20
|
-
export function useResolveDispute({
|
|
20
|
+
export function useResolveDispute({
|
|
21
|
+
onSuccess,
|
|
22
|
+
}: { onSuccess?: () => void } = {}) {
|
|
21
23
|
const { resolveDispute } = useEscrowsMutations();
|
|
22
24
|
const { selectedEscrow, updateEscrow } = useEscrowContext();
|
|
23
25
|
const { walletAddress } = useWalletContext();
|
|
@@ -50,7 +52,12 @@ export function useResolveDispute({ onSuccess }: { onSuccess?: () => void } = {}
|
|
|
50
52
|
const idx = Number(milestoneIndexWatch);
|
|
51
53
|
const milestones = selectedEscrow.milestones as MultiReleaseMilestone[];
|
|
52
54
|
const m = milestones?.[idx];
|
|
53
|
-
|
|
55
|
+
const amount = m?.amount;
|
|
56
|
+
// Handle both string and number types
|
|
57
|
+
if (amount === undefined || amount === null) return 0;
|
|
58
|
+
const numAmount =
|
|
59
|
+
typeof amount === "string" ? Number(amount) : Number(amount);
|
|
60
|
+
return isNaN(numAmount) ? 0 : numAmount;
|
|
54
61
|
}, [selectedEscrow, milestoneIndexWatch]);
|
|
55
62
|
|
|
56
63
|
const distributions = form.watch("distributions") as DistributionInput[];
|
|
@@ -63,11 +70,22 @@ export function useResolveDispute({ onSuccess }: { onSuccess?: () => void } = {}
|
|
|
63
70
|
}, [distributions]);
|
|
64
71
|
|
|
65
72
|
const isExactMatch = React.useMemo(() => {
|
|
66
|
-
|
|
73
|
+
const allowed = Number(allowedAmount);
|
|
74
|
+
const distributed = Number(distributedSum);
|
|
75
|
+
// Use epsilon comparison for floating point numbers
|
|
76
|
+
// Round to 2 decimal places to avoid precision issues
|
|
77
|
+
const roundedAllowed = Math.round(allowed * 100) / 100;
|
|
78
|
+
const roundedDistributed = Math.round(distributed * 100) / 100;
|
|
79
|
+
return Math.abs(roundedAllowed - roundedDistributed) < 0.01;
|
|
67
80
|
}, [allowedAmount, distributedSum]);
|
|
68
81
|
|
|
69
82
|
const difference = React.useMemo(() => {
|
|
70
|
-
|
|
83
|
+
const allowed = Number(allowedAmount);
|
|
84
|
+
const distributed = Number(distributedSum);
|
|
85
|
+
// Round to 2 decimal places to avoid precision issues
|
|
86
|
+
const roundedAllowed = Math.round(allowed * 100) / 100;
|
|
87
|
+
const roundedDistributed = Math.round(distributed * 100) / 100;
|
|
88
|
+
return Math.abs(roundedAllowed - roundedDistributed);
|
|
71
89
|
}, [allowedAmount, distributedSum]);
|
|
72
90
|
|
|
73
91
|
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@trustless-work/escrow/types";
|
|
11
11
|
import { toast } from "sonner";
|
|
12
12
|
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
13
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
13
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
14
14
|
import { useEscrowsMutations } from "@/components/tw-blocks/tanstack/useEscrowsMutations";
|
|
15
15
|
import {
|
|
16
16
|
ErrorResponse,
|
|
@@ -47,7 +47,6 @@ export function useUpdateEscrow({
|
|
|
47
47
|
| undefined,
|
|
48
48
|
trustline: {
|
|
49
49
|
address: selectedEscrow?.trustline?.address || "",
|
|
50
|
-
symbol: selectedEscrow?.trustline?.name || "",
|
|
51
50
|
},
|
|
52
51
|
roles: {
|
|
53
52
|
approver: selectedEscrow?.roles?.approver || "",
|
|
@@ -87,7 +86,6 @@ export function useUpdateEscrow({
|
|
|
87
86
|
| undefined) || "",
|
|
88
87
|
trustline: {
|
|
89
88
|
address: selectedEscrow?.trustline?.address || "",
|
|
90
|
-
symbol: selectedEscrow?.trustline?.name || "",
|
|
91
89
|
},
|
|
92
90
|
roles: {
|
|
93
91
|
approver: selectedEscrow?.roles?.approver || "",
|
|
@@ -207,9 +205,10 @@ export function useUpdateEscrow({
|
|
|
207
205
|
: payload.platformFee,
|
|
208
206
|
trustline: {
|
|
209
207
|
address: payload.trustline.address,
|
|
208
|
+
symbol: payload.trustline.symbol,
|
|
210
209
|
},
|
|
211
210
|
roles: payload.roles,
|
|
212
|
-
milestones: payload.milestones.map((milestone, index) => ({
|
|
211
|
+
milestones: payload.milestones.map((milestone, index: number) => ({
|
|
213
212
|
...milestone,
|
|
214
213
|
amount:
|
|
215
214
|
typeof milestone.amount === "string"
|
|
@@ -240,10 +239,7 @@ export function useUpdateEscrow({
|
|
|
240
239
|
...selectedEscrow,
|
|
241
240
|
...finalPayload.escrow,
|
|
242
241
|
trustline: {
|
|
243
|
-
|
|
244
|
-
selectedEscrow.trustline?.name ||
|
|
245
|
-
(selectedEscrow.trustline?.address as string) ||
|
|
246
|
-
"",
|
|
242
|
+
symbol: selectedEscrow?.trustline?.symbol || "",
|
|
247
243
|
address: finalPayload.escrow.trustline.address,
|
|
248
244
|
},
|
|
249
245
|
};
|
package/templates/escrows/multi-release/withdraw-remaining-funds/button/WithdrawRemainingFunds.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Button } from "__UI_BASE__/button";
|
|
3
3
|
import { useEscrowsMutations } from "@/components/tw-blocks/tanstack/useEscrowsMutations";
|
|
4
|
-
import { useWalletContext } from "@/components/tw-blocks/
|
|
4
|
+
import { useWalletContext } from "@/components/tw-blocks/providers/WalletProvider";
|
|
5
5
|
import { WithdrawRemainingFundsPayload } from "@trustless-work/escrow/types";
|
|
6
6
|
import { toast } from "sonner";
|
|
7
7
|
import {
|
package/templates/escrows/multi-release/withdraw-remaining-funds/dialog/WithdrawRemainingFunds.tsx
CHANGED
|
@@ -145,7 +145,7 @@ export const WithdrawRemainingFundsDialog = () => {
|
|
|
145
145
|
<span className="font-bold">Total Balance: </span>
|
|
146
146
|
{formatCurrency(
|
|
147
147
|
selectedEscrow?.balance || 0,
|
|
148
|
-
selectedEscrow?.trustline.
|
|
148
|
+
selectedEscrow?.trustline.symbol || ""
|
|
149
149
|
)}
|
|
150
150
|
</p>
|
|
151
151
|
</div>
|