Skip to content

Commit ff3e034

Browse files
authored
replaced txn history account addresses with checksum equivalents (#369)
* replaced txn history account addresses with checksum equivalents * changed getAddress dep from ethers to viem
1 parent ee6155f commit ff3e034

File tree

4 files changed

+149
-41
lines changed

4 files changed

+149
-41
lines changed

packages/hooks/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"@0xsequence/network": ">=2.2.13",
3737
"@tanstack/react-query": ">= 5",
3838
"react": ">= 17",
39-
"react-dom": ">= 17"
39+
"react-dom": ">= 17",
40+
"viem": ">= 2.0.0"
4041
},
4142
"devDependencies": {
4243
"@0xsequence/api": "^2.2.13",
@@ -54,6 +55,7 @@
5455
"react-dom": "^19.0.0",
5556
"typescript": "^5.8.2",
5657
"vite": "^6.0.2",
57-
"vitest": "^2.1.8"
58+
"vitest": "^2.1.8",
59+
"viem": "^2.23.10"
5860
}
5961
}

packages/hooks/src/hooks/Indexer/useGetTransactionHistory.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { GetTransactionHistoryReturn, Page, SequenceIndexer } from '@0xsequence/indexer'
22
import { InfiniteData, useInfiniteQuery, UseInfiniteQueryResult } from '@tanstack/react-query'
3+
import { getAddress } from 'viem'
34

45
import { QUERY_KEYS, time } from '../../constants'
56
import { HooksOptions } from '../../types'
@@ -44,7 +45,7 @@ const getTransactionHistory = async (
4445
indexerClient: SequenceIndexer,
4546
{ contractAddress, accountAddress, tokenId, page }: GetTransactionHistoryArgs
4647
) => {
47-
const res = indexerClient.getTransactionHistory({
48+
const res = await indexerClient.getTransactionHistory({
4849
includeMetadata: true,
4950
page,
5051
filter: {
@@ -54,7 +55,21 @@ const getTransactionHistory = async (
5455
}
5556
})
5657

57-
return res
58+
const transactions = res.transactions.map(transaction => {
59+
return {
60+
...transaction,
61+
transfers: transaction.transfers?.map(transfer => ({
62+
...transfer,
63+
from: getAddress(transfer.from),
64+
to: getAddress(transfer.to)
65+
}))
66+
}
67+
})
68+
69+
return {
70+
...res,
71+
transactions
72+
}
5873
}
5974

6075
/**

packages/hooks/src/hooks/Indexer/useGetTransactionHistorySummary.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SequenceIndexer, Transaction } from '@0xsequence/indexer'
22
import { useQuery } from '@tanstack/react-query'
3+
import { getAddress } from 'viem'
34

45
import { QUERY_KEYS, time } from '../../constants'
56
import { HooksOptions } from '../../types'
@@ -33,7 +34,16 @@ const getTransactionHistorySummary = async (
3334
return secondDate - firstDate
3435
})
3536

36-
return orderedTransactions
37+
const transactions = orderedTransactions.map(transaction => ({
38+
...transaction,
39+
transfers: transaction.transfers?.map(transfer => ({
40+
...transfer,
41+
from: getAddress(transfer.from),
42+
to: getAddress(transfer.to)
43+
}))
44+
}))
45+
46+
return transactions
3747
}
3848

3949
/**

0 commit comments

Comments
 (0)