Skip to content

Commit ebcf9cf

Browse files
committed
fix(explorer): hide private zone receipt side amounts
1 parent f5cc742 commit ebcf9cf

3 files changed

Lines changed: 46 additions & 2 deletions

File tree

apps/explorer/src/lib/domain/receipt-presentation.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ const RECEIVE_POLICY_GUARD = Address.from(
1919
'0xB10C000000000000000000000000000000000000',
2020
)
2121

22+
const PRIVATE_ZONE_ACTIONS = new Set([
23+
'Private Zone Deposit',
24+
'Private Zone Withdrawal',
25+
])
26+
2227
export type ReceiptVoucher = {
2328
packetSize: number
2429
packetCount: number
@@ -201,6 +206,12 @@ function enrichAmount(
201206
export function getReceiptEventSideAmount(
202207
event: KnownEvent,
203208
): NonNullable<KnownEvent['totalAmount']> | undefined {
209+
if (
210+
event.parts.some(
211+
(part) => part.type === 'action' && PRIVATE_ZONE_ACTIONS.has(part.value),
212+
)
213+
)
214+
return undefined
204215
if (event.totalAmount) return event.totalAmount
205216
const amounts = event.parts.flatMap((part) =>
206217
part.type === 'amount' ? [part.value] : [],

apps/explorer/test/receipt-presentation.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,39 @@ describe('receipt presentation', () => {
147147
).toBe('$6')
148148
})
149149

150+
test('hides side amounts for private Zone activity', () => {
151+
const amount = { token, value: 5_000n, decimals: 6 }
152+
const privateDeposit: KnownEvent = {
153+
type: 'private-assets-deposited',
154+
parts: [
155+
{ type: 'action', value: 'Private Zone Deposit' },
156+
{ type: 'amount', value: amount },
157+
],
158+
}
159+
const privateWithdrawal: KnownEvent = {
160+
type: 'private-shares-redeemed',
161+
parts: [
162+
{ type: 'action', value: 'Private Zone Withdrawal' },
163+
{ type: 'amount', value: amount },
164+
],
165+
totalAmount: { ...amount, value: 10_000n },
166+
}
167+
const publicWithdrawal: KnownEvent = {
168+
...privateWithdrawal,
169+
parts: [
170+
{ type: 'action', value: 'Withdraw from Zone 1' },
171+
{ type: 'amount', value: amount },
172+
],
173+
}
174+
175+
expect(getReceiptEventSideAmount(privateDeposit)).toBeUndefined()
176+
expect(getReceiptEventSideAmount(privateWithdrawal)).toBeUndefined()
177+
expect(getReceiptEventSideAmount(publicWithdrawal)).toEqual({
178+
...amount,
179+
value: 10_000n,
180+
})
181+
})
182+
150183
test('derives regular totals from the same visible token flows', () => {
151184
const presentation = build([
152185
{

apps/explorer/test/receipt-text.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ describe('renderReceiptText', () => {
117117

118118
expect(text).toContain('SUMMARY: PRIVATE ZONE WITHDRAWAL')
119119
expect(lines.find((line) => line.startsWith('1. '))).toMatch(
120-
/^1\. PRIVATE ZONE WITHDRAWAL\s+0\.25 SENPATHUSDE$/,
120+
/^1\. PRIVATE ZONE WITHDRAWAL\s+$/,
121121
)
122122
expect(text).toContain(' 0.25012 SENPATHUSDE TO 0X8117…DFB6')
123123
expect(lines.find((line) => line.startsWith('2. '))).toMatch(
124124
/^2\. EARN REDEMPTION\s+$/,
125125
)
126126
expect(text).toContain(' 0.25012 SENPATHUSDE FOR 0.5 DLUSD')
127127
expect(lines.find((line) => line.startsWith('3. '))).toMatch(
128-
/^3\. PRIVATE ZONE DEPOSIT\s+0\.5 DLUSD$/,
128+
/^3\. PRIVATE ZONE DEPOSIT\s+$/,
129129
)
130130
expect(lines.find((line) => line.startsWith('FEE '))).toMatch(
131131
/^FEE \(PATHUSD\)\s+<\$0\.01$/,

0 commit comments

Comments
 (0)