Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTranslation, Trans } from 'react-i18next'
import type { EscrowCancel } from 'xrpl'
import { findNode } from '../../../transactionUtils'
import { findNode, getSponsorScopes } from '../../../transactionUtils'
import { Account } from '../../Account'
import {
TransactionDescriptionComponent,
Expand Down Expand Up @@ -45,8 +45,10 @@ const Description: TransactionDescriptionComponent = (
<b>
<Amount
value={formatAmount(
deleted.FinalFields.Amount -
parseInt(data.tx.Fee || '0', 10),
getSponsorScopes(data.tx.SponsorFlags).includes('fee')
? deleted.FinalFields.Amount
: deleted.FinalFields.Amount -
parseInt(data.tx.Fee || '0', 10),
)}
/>
</b>{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ describe('EscrowCancelDescription', () => {
unmount()
})

it('skips fee subtraction when SponsorFlags has fee scope', () => {
const { container, unmount } = renderComponent(
getTestByName('EscrowCancel having XRP escrowed with sponsor-paid fee'),
)
expect(
container.querySelector('[data-testid="amount-line"]'),
).toHaveTextContent(
`The escrowed amount of \uE900135.79 XRP was returned to rpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56 (\uE900135.79 XRP after transaction cost)`,
)

unmount()
})

it('test IOU amount', () => {
const { container, unmount } = renderComponent(
getTestByName('EscrowCancel having IOU escrowed'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,76 @@
"ledger_hash": "DCE739424F1DF8313DBFFAA80EE521F8487961F7CF886B46713B35BBF7DC7155",
"close_time_iso": "2025-07-21T17:24:30Z",
"ctid": "C04713B500000002"
},
"EscrowCancel having XRP escrowed with sponsor-paid fee": {
"hash": "C6A85A5DAC39F60F52372A5992A3760F2E042AD4146C5BB1D332EB7B6671E67D",
"ledger_index": 36481307,
"date": "2018-02-10T23:45:21+00:00",
"tx": {
"TransactionType": "EscrowCancel",
"Flags": 2147483648,
"Sequence": 14,
"OfferSequence": 9,
"Fee": "10",
"SigningPubKey": "03A0452D88684D99C2E64FA9C21D749E496E8BF6E2339A78ED7CE90F009789A868",
"TxnSignature": "3045022100A395018AE11415150546340FC4E8A8903E473626540D9804967089617EA6DB49022016F1415F974526F2D09FE5831696D2C964AC3EB68D78360C963AA9DAE7244EF4",
"Account": "rpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56",
"Owner": "rpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56",
"SponsorFlags": 1
},
"meta": {
"TransactionIndex": 21,
"AffectedNodes": [
{
"ModifiedNode": {
"LedgerEntryType": "AccountRoot",
"PreviousTxnLgrSeq": 36481294,
"PreviousTxnID": "CDA75ED59DBA56E6B699793EBF984C7702D3BB37BBFB4DFE429259FB49830CD1",
"LedgerIndex": "585A58602324683ED54FAE51B2DA583979879392B41BB906251FFB8293889974",
"PreviousFields": {
"Sequence": 14,
"OwnerCount": 1,
"Balance": "508959870"
},
"FinalFields": {
"Flags": 0,
"Sequence": 15,
"OwnerCount": 0,
"Balance": "644749860",
"Account": "rpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56"
}
}
},
{
"DeletedNode": {
"LedgerEntryType": "Escrow",
"LedgerIndex": "CEE1B7E04519FAEC58F4F440EFE714A91DDE7E83A3599B050ED24E84A598BF46",
"FinalFields": {
"Flags": 0,
"PreviousTxnLgrSeq": 36480365,
"CancelAfter": 571621204,
"FinishAfter": 571620604,
"OwnerNode": "0000000000000000",
"PreviousTxnID": "A979AD5C6A6C844913DA51D71BF5F0B8E254D9A211FA837C4B322C4A8FD358E6",
"Amount": "135790000",
"Account": "rpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56",
"Destination": "rpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56"
}
}
},
{
"ModifiedNode": {
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "F7DBEAAF43ACF1C656C878489D307A49A31EAF96A41951B00A043D262B4B6717",
"FinalFields": {
"Flags": 0,
"RootIndex": "F7DBEAAF43ACF1C656C878489D307A49A31EAF96A41951B00A043D262B4B6717",
"Owner": "rpmqbo5FWoydTL2Ufh5YdtzmRjbeLyxt56"
}
}
}
],
"TransactionResult": "tesSUCCESS"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTranslation, Trans } from 'react-i18next'
import type { EscrowFinish } from 'xrpl'
import { findNode } from '../../../transactionUtils'
import { findNode, getSponsorScopes } from '../../../transactionUtils'
import { Account } from '../../Account'
import {
TransactionDescriptionComponent,
Expand Down Expand Up @@ -46,8 +46,10 @@ const Description: TransactionDescriptionComponent = (
<b>
<Amount
value={formatAmount(
deleted.FinalFields.Amount -
parseInt(data.tx.Fee || '0', 10),
getSponsorScopes(data.tx.SponsorFlags).includes('fee')
? deleted.FinalFields.Amount
: deleted.FinalFields.Amount -
parseInt(data.tx.Fee || '0', 10),
)}
/>
</b>{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ describe('EscrowFinishDescription', () => {
unmount()
})

it('skips fee subtraction when SponsorFlags has fee scope', () => {
const { container, unmount } = renderComponent(
getTestByName('EscrowFinish having XRP escrowed with sponsor-paid fee'),
)
expect(
container.querySelector('[data-testid="amount-line"]'),
).toHaveTextContent(
`The escrowed amount of \uE9000.0154 XRP was delivered to r4UDXF4nL7Tgss8uQxn39cCocd8GnGyXS8 (\uE9000.0154 XRP after transaction cost)`,
)

unmount()
})

it('test IOU amount', () => {
const { container, unmount } = renderComponent(
getTestByName('EscrowFinish having IOU escrowed'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,5 +396,78 @@
"ledger_hash": "4941D35B768EAC6F3B57CC4BACEF864B76BFEF8B25B589872318BEAB6D62532E",
"close_time_iso": "2025-07-17T14:12:30Z",
"ctid": "C045546C00000002"
},
"EscrowFinish having XRP escrowed with sponsor-paid fee": {
"hash": "985F9CA6FD2256D5C59F8B2CC1F51BDB2F12EB7C58CB2CCA7E4A74161432B7C4",
"ledger_index": 37467862,
"date": "2018-03-25T00:45:12+00:00",
"tx": {
"TransactionType": "EscrowFinish",
"Flags": 2147483648,
"Fulfillment": "Fulfillment",
"Sequence": 31,
"OfferSequence": 28,
"LastLedgerSequence": 37467863,
"Fee": "12",
"SigningPubKey": "0380BB0305B1192D1F20E2E15C93E99434F8DF52ED72FC18FA4F69671B578691DF",
"TxnSignature": "30450221009254A6DE4960F185E19A6717B000EB542C1340BABB5E1C0447D743FB00A026A50220232DFE95819DA27B789DF47359C3EDD29FC539041EFF8526185D42485CF886A6",
"Account": "r4UDXF4nL7Tgss8uQxn39cCocd8GnGyXS8",
"Owner": "r4UDXF4nL7Tgss8uQxn39cCocd8GnGyXS8",
"SponsorFlags": 1
},
"meta": {
"TransactionIndex": 23,
"AffectedNodes": [
{
"ModifiedNode": {
"LedgerEntryType": "AccountRoot",
"PreviousTxnLgrSeq": 37467849,
"PreviousTxnID": "C730DAD26F068100CDD7F5CF17CFB7EA729D3000BFDF92BBC36590C4FE906866",
"LedgerIndex": "70AD67C13AB61B6FCAF9CD65862478E079B05C772D65F60179EC8E7E7701740E",
"PreviousFields": {
"Sequence": 31,
"OwnerCount": 4,
"Balance": "59916121"
},
"FinalFields": {
"Flags": 0,
"Sequence": 32,
"OwnerCount": 3,
"Balance": "59931509",
"Account": "r4UDXF4nL7Tgss8uQxn39cCocd8GnGyXS8"
}
}
},
{
"ModifiedNode": {
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "7C3EC8879AD0E00BAE0957F7A5F1DBDD0E84F04202912AF9910296CD6FC427E0",
"FinalFields": {
"Flags": 0,
"RootIndex": "7C3EC8879AD0E00BAE0957F7A5F1DBDD0E84F04202912AF9910296CD6FC427E0",
"Owner": "r4UDXF4nL7Tgss8uQxn39cCocd8GnGyXS8"
}
}
},
{
"DeletedNode": {
"LedgerEntryType": "Escrow",
"LedgerIndex": "C4B2935F1E8BBCF7C10FBF5E3C98897DE37A2DA6C6F3E3A591B55D1A6DC8FDEF",
"FinalFields": {
"Flags": 0,
"PreviousTxnLgrSeq": 37466547,
"DestinationTag": 0,
"FinishAfter": 575249422,
"OwnerNode": "0000000000000000",
"PreviousTxnID": "3E2E755FA75FF1020C39E2ECC407E9F1C0E49A7229EDD15FF93B9F869878F1CC",
"Amount": "15400",
"Account": "r4UDXF4nL7Tgss8uQxn39cCocd8GnGyXS8",
"Destination": "r4UDXF4nL7Tgss8uQxn39cCocd8GnGyXS8"
}
}
}
],
"TransactionResult": "tesSUCCESS"
}
}
}
7 changes: 5 additions & 2 deletions src/containers/shared/metaParser.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BaseTransaction } from 'xrpl'
import { XRP_BASE } from './transactionUtils'
import { XRP_BASE, getSponsorScopes } from './transactionUtils'
import { ExplorerAmount } from './types'

export const LedgerEntryTypes = {
Expand Down Expand Up @@ -104,7 +104,10 @@ function findXRPAmount(
? Number(xrp.FinalFields.Balance) - Number(xrp.PreviousFields.Balance)
: Number(xrp?.NewFields?.Balance),
)
balance = Math.abs(balance - Number(tx.Fee))
const feeSponsored = getSponsorScopes(tx.SponsorFlags).includes('fee')
if (!feeSponsored) {
balance = Math.abs(balance - Number(tx.Fee))
}

return balance && balance !== 0
? {
Expand Down