|
1 | | -import { PlainMessage } from '@bufbuild/protobuf' |
| 1 | +import { PlainMessage, toPlainMessage } from '@bufbuild/protobuf' |
2 | 2 | import { useQuery } from '@tanstack/react-query' |
3 | 3 | import { AuctionWithStats, ListTopAuctionsRequest } from '@uniswap/client-data-api/dist/data/v1/auction_pb' |
4 | 4 | import { DynamicConfigs, useDynamicConfigValue, VerifiedAuctionsConfigKey } from '@universe/gating' |
@@ -144,29 +144,44 @@ export function useTopAuctions(): { |
144 | 144 |
|
145 | 145 | return topAuctions.auctions |
146 | 146 | .map((auction, index) => { |
| 147 | + const coreAuction = auction.auction |
| 148 | + const currencyInfo = currencyInfos[index] |
| 149 | + |
147 | 150 | const startBlockTimestamp = |
148 | | - auction.auction?.startBlock && auction.auction.chainId |
149 | | - ? getBlockTimestamp(auction.auction.chainId, auction.auction.startBlock) |
| 151 | + coreAuction?.startBlock && coreAuction.chainId |
| 152 | + ? getBlockTimestamp(coreAuction.chainId, coreAuction.startBlock) |
150 | 153 | : undefined |
151 | 154 |
|
152 | 155 | const endBlockTimestamp = |
153 | | - auction.auction && auction.auction.chainId && auction.auction.endBlock |
154 | | - ? getBlockTimestamp(auction.auction.chainId, auction.auction.endBlock) |
| 156 | + coreAuction && coreAuction.chainId && coreAuction.endBlock |
| 157 | + ? getBlockTimestamp(coreAuction.chainId, coreAuction.endBlock) |
155 | 158 | : undefined |
156 | 159 |
|
| 160 | + let auctionWithCurrency: PlainMessage<AuctionWithStats>['auction'] |
| 161 | + if (coreAuction !== undefined) { |
| 162 | + auctionWithCurrency = { |
| 163 | + ...toPlainMessage(coreAuction), |
| 164 | + tokenName: currencyInfo?.currency.name, |
| 165 | + tokenSymbol: currencyInfo?.currency.symbol ?? coreAuction.tokenSymbol, |
| 166 | + } |
| 167 | + } else { |
| 168 | + auctionWithCurrency = undefined |
| 169 | + } |
| 170 | + |
157 | 171 | return { |
158 | 172 | // oxlint-disable-next-line typescript/no-misused-spread -- biome-parity: oxlint is stricter here |
159 | 173 | ...auction, |
160 | | - verified: auction.auction ? verifiedSet.has(auction.auction.auctionId) : false, |
161 | | - logoUrl: currencyInfos[index]?.logoUrl, |
| 174 | + verified: coreAuction ? verifiedSet.has(coreAuction.auctionId) : false, |
| 175 | + logoUrl: currencyInfo?.logoUrl, |
162 | 176 | timeRemaining: { |
163 | 177 | startBlockTimestamp, |
164 | 178 | endBlockTimestamp, |
165 | 179 | isCompleted: isAuctionCompleted({ |
166 | | - endBlock: auction.auction?.endBlock, |
167 | | - blockNumber: auction.auction?.chainId ? blocksByChain.get(auction.auction.chainId)?.number : undefined, |
| 180 | + endBlock: coreAuction?.endBlock, |
| 181 | + blockNumber: coreAuction?.chainId ? blocksByChain.get(coreAuction.chainId)?.number : undefined, |
168 | 182 | }), |
169 | 183 | }, |
| 184 | + auction: auctionWithCurrency, |
170 | 185 | } |
171 | 186 | }) |
172 | 187 | .filter((auctionWithInfo) => { |
|
0 commit comments