Skip to content

Commit

Permalink
fix: fix accidental mutation of stateful arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
dib542 committed May 24, 2024
1 parent 1648ee8 commit a36b8c1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/lib/web3/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export function getLastPrice(
{ tokenA, tokenB }: { tokenA: Token; tokenB: Token }
) {
const lastTickUpdate = events
.slice()
.reverse()
.find((event): event is DexTickUpdateEvent => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Orderbook/OrderbookChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ export default function OrderBookChart({
const resolutionInMs = resolutionInMsMap[resolution];
// note: the data needs to be in chronological order
// and our API delivers results in reverse-chronological order
const chronologicalUpdates = dataUpdates.reverse();
const chronologicalUpdates = dataUpdates.slice().reverse();
for (const row of chronologicalUpdates) {
const bar = getBarFromTimeSeriesRow(row);
// add extra empty bars if there would be a gap in time
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Orderbook/OrderbookList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ export default function OrderBookList({
// add token B bucket offsets
...filteredBucketsB
.filter((bucket): bucket is Bucket => !!bucket)
.reverse()
.map(
([innerBound, outerBound], index): [PriceOffset, PriceOffset] => [
[innerBound, topCenterOffset - index * tableRowHeight],
Expand Down Expand Up @@ -306,7 +305,7 @@ export default function OrderBookList({
</tr>
</tbody>
<tbody className="orderbook-list__table__ticks-top">
{filteredBucketsB?.reverse().map((bucket, index) => {
{[...filteredBucketsB].reverse().map((bucket, index) => {
const [minPrice, price, reserves] = bucket || [];
const lastBucket = bucketsB?.at(-1);
return minPrice && price && reserves && lastBucket ? (
Expand Down

0 comments on commit a36b8c1

Please sign in to comment.