Skip to content
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
68c9ab1
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 6, 2025
1a354ad
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 7, 2025
0db9fa2
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 7, 2025
c2c74bf
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 9, 2025
b4e4971
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 14, 2025
56fbe4a
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 15, 2025
5d86d50
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 20, 2025
7baea76
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 21, 2025
eeaf5ed
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 22, 2025
1a5a1d0
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 23, 2025
b013ce6
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 26, 2025
fde6101
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp May 27, 2025
b25042b
merge
svenvoskamp May 30, 2025
56e5ba4
merge
svenvoskamp May 30, 2025
5b41e3d
merge
svenvoskamp Jun 2, 2025
a4b6118
merge
svenvoskamp Jun 3, 2025
68d55e0
merge
svenvoskamp Jun 4, 2025
66bbf81
merge
svenvoskamp Jun 4, 2025
4c9db2b
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 10, 2025
cd48517
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 12, 2025
0e4d5e9
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 13, 2025
4de1358
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 16, 2025
9cd447d
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 17, 2025
246db01
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 18, 2025
b80e6e4
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 18, 2025
8bf379c
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 19, 2025
decf027
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 19, 2025
a1f1405
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 20, 2025
313246e
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 20, 2025
5befd64
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 20, 2025
33d2ca8
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 23, 2025
ac46d2a
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 27, 2025
730718e
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jun 30, 2025
9da5202
merge
svenvoskamp Jul 1, 2025
ddd1b3d
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jul 1, 2025
5308a73
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jul 7, 2025
f33646b
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jul 7, 2025
e1b49ab
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jul 9, 2025
a18032b
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jul 22, 2025
22fcbe8
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Jul 25, 2025
ca16773
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 1, 2025
fd7c100
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 7, 2025
b333d2b
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 8, 2025
11fc605
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 18, 2025
a997028
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 19, 2025
8eb99d2
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 22, 2025
d5b512a
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 25, 2025
7082b4c
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 26, 2025
a4d6ebc
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 29, 2025
96ec56e
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Aug 29, 2025
307940a
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Sep 1, 2025
b045dc7
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Sep 1, 2025
f3fbd48
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Sep 22, 2025
a8f3428
Merge branch 'main' of github.com:reown-com/appkit
svenvoskamp Sep 23, 2025
7eece45
fix activity tab
svenvoskamp Sep 23, 2025
d29bda2
Merge branch 'main' into APKT-3858
svenvoskamp Sep 23, 2025
79fd71e
Merge branch 'APKT-3858' of github.com:reown-com/appkit into APKT-3858
svenvoskamp Sep 23, 2025
7a6239a
use const
svenvoskamp Sep 23, 2025
e427625
Update packages/ui/src/utils/TransactionUtil.ts
svenvoskamp Sep 23, 2025
15ce76d
Merge branch 'main' into APKT-3858
svenvoskamp Sep 23, 2025
fc30e87
handle bridged transactions
svenvoskamp Sep 24, 2025
25f53dc
Merge branch 'APKT-3858' of github.com:reown-com/appkit into APKT-3858
svenvoskamp Sep 24, 2025
90d258a
handle edge case direction for bridged transactions
svenvoskamp Sep 24, 2025
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
6 changes: 6 additions & 0 deletions .changeset/chatty-baboons-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-ui': patch
---

Fixes an issue where the activity tab was not showing the correct data
3 changes: 1 addition & 2 deletions packages/scaffold-ui/src/partials/w3m-activity-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,8 @@ export class W3mActivityList extends LitElement {

private getTransactionListItemProps(transaction: Transaction) {
const date = DateUtil.formatDate(transaction?.metadata?.minedAt)
const descriptions = TransactionUtil.getTransactionDescriptions(transaction)

const transfers = TransactionUtil.mergeTransfers(transaction?.transfers)
const descriptions = TransactionUtil.getTransactionDescriptions(transaction, transfers)
const transfer = transfers?.[0]
const isAllNFT = Boolean(transfer) && transfers?.every(item => Boolean(item.nft_info))
const images = TransactionUtil.getTransactionImages(transfers)
Expand Down
112 changes: 92 additions & 20 deletions packages/ui/src/utils/TransactionUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { UiHelperUtil } from './UiHelperUtil.js'

// -- Helpers --------------------------------------------- //
const FLOAT_FIXED_VALUE = 3
const GAS_FEE_THRESHOLD = 0.1
const plusTypes: TransactionType[] = ['receive', 'deposit', 'borrow', 'claim']
const minusTypes: TransactionType[] = ['withdraw', 'repay', 'burn']

Expand Down Expand Up @@ -67,12 +68,12 @@ export const TransactionUtil = {
return undefined
},

getTransactionDescriptions(transaction: Transaction) {
getTransactionDescriptions(transaction: Transaction, mergedTransfers?: TransactionTransfer[]) {
const type = transaction?.metadata?.operationType as TransactionType

const transfers = transaction?.transfers
const haveTransfer = transaction?.transfers?.length > 0
const haveMultipleTransfers = transaction?.transfers?.length > 1
const transfers = mergedTransfers || transaction?.transfers
const haveTransfer = transfers?.length > 0
const haveMultipleTransfers = transfers?.length > 1
const isFungible =
haveTransfer && transfers?.every(transfer => Boolean(transfer?.fungible_info))
const [firstTransfer, secondTransfer] = transfers
Expand Down Expand Up @@ -146,26 +147,97 @@ export const TransactionUtil = {
return description
},
mergeTransfers(transfers: TransactionTransfer[]) {
let mergedTransfers = transfers
// If we have more than two transfers, we need to merge transfers with same direction and same token
if (transfers?.length > 1) {
mergedTransfers = transfers.reduce<TransactionTransfer[]>((acc, t) => {
const name = t?.fungible_info?.name
const existingTransfer = acc.find(
({ fungible_info }) => name && name === fungible_info?.name
)
if (existingTransfer) {
const quantity = Number(existingTransfer.quantity.numeric) + Number(t.quantity.numeric)
existingTransfer.quantity.numeric = quantity.toString()
if (transfers?.length <= 1) {
return transfers
}

// Filter out gas fee transfers (small opposite-direction amounts of same token)
const filteredTransfers = this.filterGasFeeTransfers(transfers)

// Merge transfers with same token and same direction
const mergedTransfers = filteredTransfers.reduce<TransactionTransfer[]>((acc, t) => {
const name = t?.fungible_info?.name
const existingTransfer = acc.find(
({ fungible_info, direction }) =>
name && name === fungible_info?.name && direction === t.direction
)
if (existingTransfer) {
const quantity = Number(existingTransfer.quantity.numeric) + Number(t.quantity.numeric)
existingTransfer.quantity.numeric = quantity.toString()

existingTransfer.value = (existingTransfer.value || 0) + (t.value || 0)
} else {
acc.push(t)
}

return acc
}, [])

return mergedTransfers
},

filterGasFeeTransfers(transfers: TransactionTransfer[]): TransactionTransfer[] {
// Group transfers by token name
const tokenGroups = transfers.reduce<Record<string, TransactionTransfer[]>>(
(groups, transfer) => {
const tokenName = transfer?.fungible_info?.name
if (tokenName) {
if (!groups[tokenName]) {
groups[tokenName] = []
}
groups[tokenName].push(transfer)
}

return groups
},
{}
)

const filteredTransfers: TransactionTransfer[] = []

Object.values(tokenGroups).forEach(tokenTransfers => {
if (tokenTransfers.length === 1) {
const firstTransfer = tokenTransfers[0]
if (firstTransfer) {
filteredTransfers.push(firstTransfer)
}
} else {
// Multiple transfers for same token, check for gas fee pattern
const inTransfers = tokenTransfers.filter(t => t.direction === 'in')
const outTransfers = tokenTransfers.filter(t => t.direction === 'out')

if (inTransfers.length === 1 && outTransfers.length === 1) {
const inTransfer = inTransfers[0]
const outTransfer = outTransfers[0]

if (inTransfer && outTransfer) {
const inAmount = Number(inTransfer.quantity.numeric)
const outAmount = Number(outTransfer.quantity.numeric)

// If one amount is less than 10% of the other, consider it gas and filter out the gas transfer
if (outAmount < inAmount * GAS_FEE_THRESHOLD) {
filteredTransfers.push(inTransfer)
} else if (inAmount < outAmount * GAS_FEE_THRESHOLD) {
filteredTransfers.push(outTransfer)
} else {
filteredTransfers.push(...tokenTransfers)
}
} else {
filteredTransfers.push(...tokenTransfers)
}
} else {
acc.push(t)
filteredTransfers.push(...tokenTransfers)
}
}
})

return acc
}, [])
}
transfers.forEach(transfer => {
if (!transfer?.fungible_info?.name) {
filteredTransfers.push(transfer)
}
})

return mergedTransfers
return filteredTransfers
},

getQuantityFixedValue(value: string | undefined) {
Expand Down
47 changes: 47 additions & 0 deletions packages/ui/tests/TransactionUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,51 @@ describe('TransactionUtil.mergeTransfers', () => {
expect(result.find(t => t?.fungible_info?.name === 'Token1')?.quantity.numeric).toBe('100')
expect(result.find(t => !t?.fungible_info?.name)?.quantity.numeric).toBe('50')
})

it('filters out gas fee transfers (small opposite-direction amounts)', () => {
const usdcInTransfer = {
fungible_info: {
name: 'USD Coin',
symbol: 'USDC',
icon: { url: 'usdc-url' }
},
direction: 'in' as const,
quantity: { numeric: '0.224784' },
value: 0.2246140943611488
}

const usdcOutTransfer = {
fungible_info: {
name: 'USD Coin',
symbol: 'USDC',
icon: { url: 'usdc-url' }
},
direction: 'out' as const,
quantity: { numeric: '0.005830' },
value: 0.005825593325706
}

const polOutTransfer = {
fungible_info: {
name: 'Polygon',
symbol: 'POL',
icon: { url: 'pol-url' }
},
direction: 'out' as const,
quantity: { numeric: '1.000000000000000000' },
value: 0.2267439626
}

const result = TransactionUtil.mergeTransfers([usdcInTransfer, polOutTransfer, usdcOutTransfer])

expect(result.length).toBe(2)

const usdcResult = result.find(t => t?.fungible_info?.name === 'USD Coin')
expect(usdcResult?.direction).toBe('in')
expect(usdcResult?.quantity.numeric).toBe('0.224784')

const polResult = result.find(t => t?.fungible_info?.name === 'Polygon')
expect(polResult?.direction).toBe('out')
expect(polResult?.quantity.numeric).toBe('1.000000000000000000')
})
})