From 8b21383bbcc86cb9d41f8893f69d7fc4af110aee Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 15:33:18 +0100
Subject: [PATCH 01/24] feat: adding gh actions
---
.../workflows/types-lint-license-tests.yml | 106 ++++++++++++++++++
1 file changed, 106 insertions(+)
create mode 100644 .github/workflows/types-lint-license-tests.yml
diff --git a/.github/workflows/types-lint-license-tests.yml b/.github/workflows/types-lint-license-tests.yml
new file mode 100644
index 0000000..4b4330f
--- /dev/null
+++ b/.github/workflows/types-lint-license-tests.yml
@@ -0,0 +1,106 @@
+name: Check types, lint, license and run tests
+
+on:
+ pull_request:
+ branches:
+ - main
+
+jobs:
+ setup:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20.16.0'
+
+ - name: Install pnpm
+ uses: pnpm/action-setup@v2
+ with:
+ version: 8
+
+ - name: Install dependencies
+ run: pnpm install
+
+ - name: Cache dependencies
+ uses: actions/cache@v3
+ with:
+ path: ~/.pnpm-store
+ key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ restore-keys: |
+ ${{ runner.os }}-pnpm-
+
+ test:
+ needs: setup
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '20.16.0'
+ - uses: pnpm/action-setup@v2
+ with:
+ version: 8
+ - uses: actions/cache@v3
+ with:
+ path: ~/.pnpm-store
+ key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ - run: pnpm install
+ - run: pnpm test
+
+ typecheck:
+ needs: setup
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '20.16.0'
+ - uses: pnpm/action-setup@v2
+ with:
+ version: 8
+ - uses: actions/cache@v3
+ with:
+ path: ~/.pnpm-store
+ key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ - run: pnpm install
+ - run: pnpm typecheck
+
+ lint:
+ needs: setup
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '20.16.0'
+ - uses: pnpm/action-setup@v2
+ with:
+ version: 8
+ - uses: actions/cache@v3
+ with:
+ path: ~/.pnpm-store
+ key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ - run: pnpm install
+ - run: pnpm lint
+
+ license:
+ needs: setup
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '20.16.0'
+ - uses: pnpm/action-setup@v2
+ with:
+ version: 8
+ - uses: actions/cache@v3
+ with:
+ path: ~/.pnpm-store
+ key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ - run: pnpm install
+ - run: pnpm license
From b5a358675a1ed52559c1c6f7e18ca79fba53b44e Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:04:32 +0100
Subject: [PATCH 02/24] fix: updating pnpm-lock
---
pnpm-lock.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2357417..4cdd49c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1538,6 +1538,10 @@ packages:
resolution: {integrity: sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==}
dev: true
+ /@types/luxon@3.4.2:
+ resolution: {integrity: sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==}
+ dev: false
+
/@types/mime@1.3.5:
resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==}
dev: false
From 6c87a5360bf333e0120c08c40aba8af8be23ec39 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:05:51 +0100
Subject: [PATCH 03/24] fix: fixing some linting issues
---
package.json | 1 -
src/app/_components/AuctionDetails.tsx | 7 +------
src/app/_components/Countdown.tsx | 6 ++++--
src/app/history/[pageNumber]/page.tsx | 3 ++-
src/app/history/_components/HistoryContent.tsx | 7 ++++---
src/app/history/_components/Pagination.tsx | 3 ++-
src/app/history/page.tsx | 8 +-------
src/queries/__tests__/fetchAuctionHistory.spec.ts | 2 +-
src/queries/__tests__/fetchBiddingHistory.spec.ts | 2 --
src/queries/__tests__/fetchCurrentAuction.spec.ts | 1 -
src/queries/__tests__/rpcFetchAuctionEnd.spec.ts | 2 +-
src/queries/fetchAuctionHistory.ts | 4 +---
src/queries/fetchBiddingHistory.ts | 5 +----
src/queries/fetchPastAuction.ts | 6 +++---
14 files changed, 21 insertions(+), 36 deletions(-)
diff --git a/package.json b/package.json
index 2ac901b..ac268b8 100644
--- a/package.json
+++ b/package.json
@@ -73,4 +73,3 @@
"vitest": "^2.0.5"
}
}
-
diff --git a/src/app/_components/AuctionDetails.tsx b/src/app/_components/AuctionDetails.tsx
index 25e559a..7dfe1c0 100644
--- a/src/app/_components/AuctionDetails.tsx
+++ b/src/app/_components/AuctionDetails.tsx
@@ -10,6 +10,7 @@ import { formatUnits } from '@/utilities/formatUnits';
import { EVMOS_DECIMALS } from '@/constants';
import { ButtonLink } from '@/components/ui/ButtonLink';
import { fetchCurrentCryptoPrice } from '@/queries/fetchCurrentCryptoPrice';
+import { Tooltip } from '@/components/ui/Tooltip';
import { AssetsTable } from './AssetsTable';
import { BiddingHistory } from './BiddingHistory';
@@ -18,12 +19,6 @@ import { Countdown } from './Countdown';
import { BiddingProgress } from './BiddingProgress';
import { DiscountChip } from './DiscountChip';
-import { EVMOS_DECIMALS } from '@/constants';
-import { ButtonLink } from '@/components/ui/ButtonLink';
-import Image from 'next/image';
-import { Tooltip } from '@/components/ui/Tooltip';
-import { fetchCurrentCryptoPrice } from '@/queries/fetchCurrentCryptoPrice';
-
export const AuctionDetails = async ({ auctionDetails }: { auctionDetails: AuctionDetailed }) => {
const { round, auction, highestBid }: AuctionDetailed = auctionDetails;
diff --git a/src/app/_components/Countdown.tsx b/src/app/_components/Countdown.tsx
index 79adacc..8337943 100644
--- a/src/app/_components/Countdown.tsx
+++ b/src/app/_components/Countdown.tsx
@@ -3,9 +3,11 @@
'use client';
import { useState, useEffect } from 'react';
-import reloadData from '../_actions/reloadData';
+
import { Log } from '@/utilities/logger';
+import reloadData from '../_actions/reloadData';
+
type TimeLeft = {
days: number;
hours: number;
@@ -60,7 +62,7 @@ export const Countdown = ({ date }: { date: Date }) => {
}, 5000);
}
}, 1000);
-
+
return () => {
clearInterval(interval);
};
diff --git a/src/app/history/[pageNumber]/page.tsx b/src/app/history/[pageNumber]/page.tsx
index af2ecdc..e23a5c4 100644
--- a/src/app/history/[pageNumber]/page.tsx
+++ b/src/app/history/[pageNumber]/page.tsx
@@ -1,10 +1,11 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/burn-auction-dapp/blob/main/LICENSE)
-import { HistoryContent } from '../_components/HistoryContent';
import { fetchAuctionHistory } from '@/queries/fetchAuctionHistory';
import { PAGINATION_ITEMS_PER_PAGE } from '@/constants';
+import { HistoryContent } from '../_components/HistoryContent';
+
const HistoryPaginated = async ({ params }: { params: { pageNumber: number } }) => {
const auctionHistory = await fetchAuctionHistory(params.pageNumber, PAGINATION_ITEMS_PER_PAGE);
diff --git a/src/app/history/_components/HistoryContent.tsx b/src/app/history/_components/HistoryContent.tsx
index 1ec3db4..0665865 100644
--- a/src/app/history/_components/HistoryContent.tsx
+++ b/src/app/history/_components/HistoryContent.tsx
@@ -2,13 +2,14 @@
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/burn-auction-dapp/blob/main/LICENSE)
import Image from 'next/image';
-import { AuctionHistoryTable } from './AuctionHistoryTable';
+
import { formatUnits } from '@/utilities/formatUnits';
-import { EVMOS_DECIMALS } from '@/constants';
-import Pagination from '../_components/Pagination';
import type { AuctionHistory } from '@/types/AuctionHistory';
import { PAGINATION_ITEMS_PER_PAGE } from '@/constants';
+import Pagination from '../_components/Pagination';
+import { AuctionHistoryTable } from './AuctionHistoryTable';
+
export const HistoryContent = ({ auctionHistory, pageNumber }: { auctionHistory: AuctionHistory; pageNumber: number }) => {
return (
diff --git a/src/app/history/_components/Pagination.tsx b/src/app/history/_components/Pagination.tsx
index babfe23..eed2181 100644
--- a/src/app/history/_components/Pagination.tsx
+++ b/src/app/history/_components/Pagination.tsx
@@ -1,10 +1,11 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/burn-auction-dapp/blob/main/LICENSE)
-import { ButtonLink } from '@/components/ui/ButtonLink';
import Image from 'next/image';
import { clsx } from 'clsx';
+import { ButtonLink } from '@/components/ui/ButtonLink';
+
interface PaginationProps {
currentPage: number;
itemsPerPage: number;
diff --git a/src/app/history/page.tsx b/src/app/history/page.tsx
index b62ff6e..6582318 100644
--- a/src/app/history/page.tsx
+++ b/src/app/history/page.tsx
@@ -1,16 +1,10 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/burn-auction-dapp/blob/main/LICENSE)
-import Image from 'next/image';
-
-import { fetchAuctionHistory } from '@/queries/fetchAuctionHistory';
-import { formatUnits } from '@/utilities/formatUnits';
-import { EVMOS_DECIMALS } from '@/constants';
-import { HistoryContent } from './_components/HistoryContent';
import { fetchAuctionHistory } from '@/queries/fetchAuctionHistory';
import { PAGINATION_ITEMS_PER_PAGE } from '@/constants';
-import { AuctionHistoryTable } from './_components/AuctionHistoryTable';
+import { HistoryContent } from './_components/HistoryContent';
const History = async () => {
const auctionHistory = await fetchAuctionHistory(1, PAGINATION_ITEMS_PER_PAGE);
diff --git a/src/queries/__tests__/fetchAuctionHistory.spec.ts b/src/queries/__tests__/fetchAuctionHistory.spec.ts
index 986d950..5ad460e 100644
--- a/src/queries/__tests__/fetchAuctionHistory.spec.ts
+++ b/src/queries/__tests__/fetchAuctionHistory.spec.ts
@@ -4,11 +4,11 @@
import { expect, describe, it, expectTypeOf, beforeEach, afterEach, vi } from 'vitest';
import type { AuctionHistory } from '@/types/AuctionHistory';
+import { EVMOS_DECIMALS } from '@/constants';
import { fetchAuctionHistory } from '../fetchAuctionHistory';
import { mockAuctionEndEvents } from './mockedData';
import * as prismaModule from '../prismaFetchAuctionEvents';
-import { EVMOS_DECIMALS } from '@/constants';
// Mock the entire module
vi.mock('../prismaFetchAuctionEvents');
diff --git a/src/queries/__tests__/fetchBiddingHistory.spec.ts b/src/queries/__tests__/fetchBiddingHistory.spec.ts
index 8edb38c..be43231 100644
--- a/src/queries/__tests__/fetchBiddingHistory.spec.ts
+++ b/src/queries/__tests__/fetchBiddingHistory.spec.ts
@@ -6,8 +6,6 @@ import { expect, describe, it, expectTypeOf, beforeEach, afterEach, vi } from 'v
import type { BiddingHistory } from '@/types/BiddingHistory';
import { fetchBiddingHistory } from '../fetchBiddingHistory';
-import { mockBiddingHistoryResponse } from './mockedData';
-import type { BiddingHistory } from '@/types/BiddingHistory';
import { prismaFetchBidEvent } from '../prismaFetchBidEvent';
import { rpcFetchBlockDate } from '../rpcFetchBlockDate';
diff --git a/src/queries/__tests__/fetchCurrentAuction.spec.ts b/src/queries/__tests__/fetchCurrentAuction.spec.ts
index 8bea453..7410035 100644
--- a/src/queries/__tests__/fetchCurrentAuction.spec.ts
+++ b/src/queries/__tests__/fetchCurrentAuction.spec.ts
@@ -3,7 +3,6 @@
import { expect, describe, it, expectTypeOf, beforeEach, afterEach, vi } from 'vitest';
-import { fetchCurrentAuction } from '../fetchCurrentAuction';
import type { AuctionDetailed } from '@/types/AuctionDetailed';
import { fetchCurrentAuction } from '../fetchCurrentAuction';
diff --git a/src/queries/__tests__/rpcFetchAuctionEnd.spec.ts b/src/queries/__tests__/rpcFetchAuctionEnd.spec.ts
index f8ef986..16198d4 100644
--- a/src/queries/__tests__/rpcFetchAuctionEnd.spec.ts
+++ b/src/queries/__tests__/rpcFetchAuctionEnd.spec.ts
@@ -6,7 +6,7 @@ import { expect, describe, it, expectTypeOf, beforeEach, afterEach, vi } from 'v
import type { AuctionEndEvent } from '@/types/AuctionEndEvent';
import { rpcFetchAuctionEnd } from '../rpcFetchAuctionEnd';
-import { mockAuctionEndEvents, mockAuctionEndEventsRound3 } from './mockedData';
+import { mockAuctionEndEvents } from './mockedData';
beforeEach(() => {
vi.mock('../rpcFetchAuctionEnd', async (importOriginal) => {
diff --git a/src/queries/fetchAuctionHistory.ts b/src/queries/fetchAuctionHistory.ts
index c87235a..b6d3b6f 100644
--- a/src/queries/fetchAuctionHistory.ts
+++ b/src/queries/fetchAuctionHistory.ts
@@ -1,14 +1,12 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/burn-auction-dapp/blob/main/LICENSE)
-
-import { prismaFetchAuctionEvents } from './prismaFetchAuctionEvents';
-
import { E } from '@/utilities/error-handling';
import { Log } from '@/utilities/logger';
import type { AuctionHistory } from '@/types/AuctionHistory';
import { HexAddress } from '@/types/HexAddress';
+import { prismaFetchAuctionEvents } from './prismaFetchAuctionEvents';
export const fetchAuctionHistory = async (page: number, itemsPerPage: number): Promise => {
const [error, auctionEvents] = await E.try(() => prismaFetchAuctionEvents(page, itemsPerPage));
diff --git a/src/queries/fetchBiddingHistory.ts b/src/queries/fetchBiddingHistory.ts
index ed15e10..4f9e9cb 100644
--- a/src/queries/fetchBiddingHistory.ts
+++ b/src/queries/fetchBiddingHistory.ts
@@ -1,16 +1,13 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/burn-auction-dapp/blob/main/LICENSE)
-
-import { prismaFetchBidEvent } from './prismaFetchBidEvent';
-import { rpcFetchBlockDate } from './rpcFetchBlockDate';
import { E } from '@/utilities/error-handling';
import { Log } from '@/utilities/logger';
import type { BiddingHistory } from '@/types/BiddingHistory';
import { HexAddress } from '@/types/HexAddress';
import { rpcFetchBlockDate } from './rpcFetchBlockDate';
-import { rpcFetchBiddingHistory } from './rpcFetchBiddingHistory';
+import { prismaFetchBidEvent } from './prismaFetchBidEvent';
export const fetchBiddingHistory = async (round: bigint): Promise => {
const [error, biddingEvents] = await E.try(() => prismaFetchBidEvent(round));
diff --git a/src/queries/fetchPastAuction.ts b/src/queries/fetchPastAuction.ts
index 8c401ee..9ee30af 100644
--- a/src/queries/fetchPastAuction.ts
+++ b/src/queries/fetchPastAuction.ts
@@ -8,11 +8,11 @@ import { AuctionnedAsset } from '@/types/AuctionnedAsset';
import { fetchChainRegistryDir } from '@/utilities/fetchChainRegistryDir';
import { TokenEntity } from '@/utilities//registry/autogen/token-entity';
import { EVMOS_DECIMALS, UNKNOWN_TOKEN_METADATA_DEFAULT } from '@/constants';
+import type { HexAddress } from '@/types/HexAddress';
+
import { fetchAuctionDates } from './fetchAuctionDates';
-import { rpcFetchAuctionEnd } from './rpcFetchAuctionEnd';
import { fetchPastCryptoPrice } from './fetchPastCryptoPrice';
import { prismaFetchAuctionEvent } from './prismaFetchAuctionEvent';
-import type { HexAddress } from '@/types/HexAddress';
export const fetchPastAuction = async (round: bigint): Promise => {
const [error, auctionEndEvent] = await E.try(() => prismaFetchAuctionEvent(round));
@@ -71,7 +71,7 @@ export const fetchPastAuction = async (round: bigint): Promise
...UNKNOWN_TOKEN_METADATA_DEFAULT,
denom: token.denom,
amount: BigInt(token.amount),
- priceError: true
+ priceError: true,
};
if (!tokenMetadata) {
From 3537f9a32e4925d9e1f169b334f486d4f39a30f6 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:14:55 +0100
Subject: [PATCH 04/24] fix: fixing lint issues
---
src/app/_components/Countdown.tsx | 5 +++--
src/app/api/v1/indexer/auction-end-events/route.ts | 4 +++-
src/app/api/v1/indexer/bid-events/route.ts | 3 ++-
src/constants/index.ts | 1 +
src/queries/__tests__/fetchAuctionHistory.spec.ts | 1 +
src/queries/__tests__/fetchBiddingHistory.spec.ts | 1 +
src/queries/__tests__/fetchPastAuction.spec.ts | 13 ++++---------
src/queries/__tests__/rpcFetchAuctionEnd.spec.ts | 14 ++------------
.../__tests__/rpcFetchBiddingHistory.spec.ts | 1 +
9 files changed, 18 insertions(+), 25 deletions(-)
diff --git a/src/app/_components/Countdown.tsx b/src/app/_components/Countdown.tsx
index 8337943..510f4ae 100644
--- a/src/app/_components/Countdown.tsx
+++ b/src/app/_components/Countdown.tsx
@@ -16,6 +16,7 @@ type TimeLeft = {
};
const REFRESH_INTERVAL = 1000;
+const DELAY_BEFORE_RELOAD_AFTER_COUNTDOWN_GOES_TO_ZERO = 5000;
const calculateTimeLeft = (date: Date): TimeLeft => {
const difference = +date - +new Date();
@@ -59,9 +60,9 @@ export const Countdown = ({ date }: { date: Date }) => {
setTimeout(() => {
Log().info('Reloading data after countdown to 0');
reloadData();
- }, 5000);
+ }, DELAY_BEFORE_RELOAD_AFTER_COUNTDOWN_GOES_TO_ZERO);
}
- }, 1000);
+ }, REFRESH_INTERVAL);
return () => {
clearInterval(interval);
diff --git a/src/app/api/v1/indexer/auction-end-events/route.ts b/src/app/api/v1/indexer/auction-end-events/route.ts
index 5c32362..513bd67 100644
--- a/src/app/api/v1/indexer/auction-end-events/route.ts
+++ b/src/app/api/v1/indexer/auction-end-events/route.ts
@@ -7,8 +7,9 @@ import { viemPublicClient } from '@/utilities/viem';
import { Log } from '@/utilities/logger';
import { EVMOS_DECIMALS } from '@/constants';
+const MAX_BLOCKS_PER_REQUEST = 10000;
const FIRST_AUCTION_BLOCK = process.env.FIRST_AUCTION_BLOCK ? BigInt(process.env.FIRST_AUCTION_BLOCK) : BigInt(0);
-const BATCH_SIZE = BigInt(10000);
+const BATCH_SIZE = BigInt(MAX_BLOCKS_PER_REQUEST);
export async function GET() {
try {
@@ -45,6 +46,7 @@ export async function GET() {
},
burned: event.args.burned.toString(),
blockNumber: event.blockNumber.toString(),
+ // eslint-disable-next-line no-magic-numbers
burnedWithoutDecimals: Number(BigInt(event.args.burned) / BigInt(10 ** EVMOS_DECIMALS)),
transactionHash: event.transactionHash,
transactionIndex: event.transactionIndex,
diff --git a/src/app/api/v1/indexer/bid-events/route.ts b/src/app/api/v1/indexer/bid-events/route.ts
index 4c86b4a..d0ebc69 100644
--- a/src/app/api/v1/indexer/bid-events/route.ts
+++ b/src/app/api/v1/indexer/bid-events/route.ts
@@ -6,8 +6,9 @@ import { rpcFetchBiddingHistory } from '@/queries/rpcFetchBiddingHistory';
import { viemPublicClient } from '@/utilities/viem';
import { Log } from '@/utilities/logger';
+const MAX_BLOCKS_PER_REQUEST = 10000;
const FIRST_AUCTION_BLOCK = process.env.FIRST_AUCTION_BLOCK ? BigInt(process.env.FIRST_AUCTION_BLOCK) : BigInt(0);
-const BATCH_SIZE = BigInt(10000);
+const BATCH_SIZE = BigInt(MAX_BLOCKS_PER_REQUEST);
export async function GET() {
try {
diff --git a/src/constants/index.ts b/src/constants/index.ts
index b3f7226..8a71c39 100644
--- a/src/constants/index.ts
+++ b/src/constants/index.ts
@@ -15,4 +15,5 @@ export const UNKNOWN_TOKEN_METADATA_DEFAULT = {
amountWithDecimals: 0,
};
+// eslint-disable-next-line no-magic-numbers
export const PAGINATION_ITEMS_PER_PAGE = process.env.PAGINATION_ITEMS_PER_PAGE ? parseInt(process.env.PAGINATION_ITEMS_PER_PAGE) : 10;
diff --git a/src/queries/__tests__/fetchAuctionHistory.spec.ts b/src/queries/__tests__/fetchAuctionHistory.spec.ts
index 5ad460e..4beacdf 100644
--- a/src/queries/__tests__/fetchAuctionHistory.spec.ts
+++ b/src/queries/__tests__/fetchAuctionHistory.spec.ts
@@ -30,6 +30,7 @@ afterEach(() => {
vi.clearAllMocks();
});
+/* eslint-disable no-magic-numbers */
describe('fetchAuctionHistory()', () => {
it('should return the auction history and the correct total burned amount', async () => {
mockPrismaFetchAuctionEvents.mockResolvedValue(
diff --git a/src/queries/__tests__/fetchBiddingHistory.spec.ts b/src/queries/__tests__/fetchBiddingHistory.spec.ts
index be43231..9f1d5d1 100644
--- a/src/queries/__tests__/fetchBiddingHistory.spec.ts
+++ b/src/queries/__tests__/fetchBiddingHistory.spec.ts
@@ -12,6 +12,7 @@ import { rpcFetchBlockDate } from '../rpcFetchBlockDate';
vi.mock('../prismaFetchBidEvent');
vi.mock('../rpcFetchBlockDate');
+/* eslint-disable no-magic-numbers */
describe('fetchBiddingHistory(round)', () => {
beforeEach(() => {
vi.resetAllMocks();
diff --git a/src/queries/__tests__/fetchPastAuction.spec.ts b/src/queries/__tests__/fetchPastAuction.spec.ts
index b970e45..36ca11b 100644
--- a/src/queries/__tests__/fetchPastAuction.spec.ts
+++ b/src/queries/__tests__/fetchPastAuction.spec.ts
@@ -4,14 +4,14 @@
import { expect, describe, it, expectTypeOf, beforeEach, afterEach, vi } from 'vitest';
import type { AuctionDetailed } from '@/types/AuctionDetailed';
+import { fetchChainRegistryDir } from '@/utilities/fetchChainRegistryDir';
+import { EVMOS_DECIMALS } from '@/constants';
import { fetchPastAuction } from '../fetchPastAuction';
-import { mockCoinGeckoResponse, mockAuctionResponse, epochInfoResponse, mockAuctionEndEventsRound3 } from './mockedData';
import { prismaFetchAuctionEvent } from '../prismaFetchAuctionEvent';
import { fetchAuctionDates } from '../fetchAuctionDates';
import { fetchPastCryptoPrice } from '../fetchPastCryptoPrice';
-import { fetchChainRegistryDir } from '@/utilities/fetchChainRegistryDir';
-import { EVMOS_DECIMALS } from '@/constants';
+
vi.mock('../prismaFetchAuctionEvent');
vi.mock('../fetchAuctionDates');
@@ -29,6 +29,7 @@ afterEach(() => {
vi.clearAllMocks();
});
+/* eslint-disable no-magic-numbers */
describe('fetchPastAuction()', () => {
it('should return the past auction info of type AuctionDetailed', async () => {
const mockAuctionEvent = {
@@ -192,12 +193,6 @@ describe('fetchPastAuction()', () => {
});
vi.mocked(fetchChainRegistryDir).mockRejectedValue(new Error('Failed to fetch chain registry'));
-describe('fetchPastAuction(5)', async () => {
- it('should return the current auction info of type AuctionDetailed', async () => {
- // eslint-disable-next-line no-magic-numbers
- const result = await fetchPastAuction(BigInt(40));
- expect(result).toBeDefined();
- expectTypeOf(result).toMatchTypeOf();
await expect(fetchPastAuction(BigInt(6))).rejects.toThrow('Failed to fetch chain registry');
});
});
diff --git a/src/queries/__tests__/rpcFetchAuctionEnd.spec.ts b/src/queries/__tests__/rpcFetchAuctionEnd.spec.ts
index 16198d4..91dbdef 100644
--- a/src/queries/__tests__/rpcFetchAuctionEnd.spec.ts
+++ b/src/queries/__tests__/rpcFetchAuctionEnd.spec.ts
@@ -14,7 +14,7 @@ beforeEach(() => {
return {
// @ts-ignore
...actual,
- rpcFetchAuctionEnd: vi.fn((from, to) => mockAuctionEndEvents),
+ rpcFetchAuctionEnd: vi.fn(() => mockAuctionEndEvents),
};
});
});
@@ -23,6 +23,7 @@ afterEach(() => {
vi.clearAllMocks();
});
+/* eslint-disable no-magic-numbers */
describe('rpcFetchAuctionEnd(from, to)', async () => {
it('should return all the AuctionEnd events', async () => {
const result = await rpcFetchAuctionEnd(BigInt(1), BigInt(3));
@@ -30,14 +31,3 @@ describe('rpcFetchAuctionEnd(from, to)', async () => {
expectTypeOf(result).toMatchTypeOf();
});
});
-
-describe('rpcFetchAuctionEnd(round)', async () => {
- it('should return a specific AuctionEnd event', async () => {
- // eslint-disable-next-line no-magic-numbers
- const result = await rpcFetchAuctionEnd(BigInt(3));
- expect(result).toBeDefined();
- expect(result.length).toEqual(1);
- expect(result.length).toEqual(2);
- expectTypeOf(result).toMatchTypeOf();
- });
-});
diff --git a/src/queries/__tests__/rpcFetchBiddingHistory.spec.ts b/src/queries/__tests__/rpcFetchBiddingHistory.spec.ts
index 8ffc74b..abd3c28 100644
--- a/src/queries/__tests__/rpcFetchBiddingHistory.spec.ts
+++ b/src/queries/__tests__/rpcFetchBiddingHistory.spec.ts
@@ -21,6 +21,7 @@ afterEach(() => {
vi.clearAllMocks();
});
+/* eslint-disable no-magic-numbers */
describe('rpcFetchBiddingHistory(from, to)', async () => {
it('should return the Bids for a given round number', async () => {
const result = await rpcFetchBiddingHistory(BigInt(1), BigInt(3));
From b180b4f51607d4460621b6ea21c09e6e0d6b1e3b Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:17:29 +0100
Subject: [PATCH 05/24] fix: fixing postinstall script
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index ac268b8..3bbe9d0 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,7 @@
"prepare": "husky",
"test": "vitest",
"gen:types": "cross-env NODE_OPTIONS='--experimental-import-meta-resolve' tsx ./src/utilities/registry/scripts/gen-schema-types.mts",
- "postinstall": "npm run gen:types",
+ "postinstall": "npm run gen:types && npm run prisma:generate",
"license": "node ./check-license.mjs",
"license:fix": "node ./check-license.mjs --fix",
"typecheck": "tsc --noEmit",
From e6fb5d955015bf7150f4ffc3f6a018e17a574d56 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:21:30 +0100
Subject: [PATCH 06/24] fix: types and queries fixes
---
src/queries/__tests__/fetchPastAuction.spec.ts | 4 +++-
src/queries/prismaFetchAuctionEvent.ts | 4 +---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/queries/__tests__/fetchPastAuction.spec.ts b/src/queries/__tests__/fetchPastAuction.spec.ts
index 36ca11b..d1af86b 100644
--- a/src/queries/__tests__/fetchPastAuction.spec.ts
+++ b/src/queries/__tests__/fetchPastAuction.spec.ts
@@ -12,7 +12,6 @@ import { prismaFetchAuctionEvent } from '../prismaFetchAuctionEvent';
import { fetchAuctionDates } from '../fetchAuctionDates';
import { fetchPastCryptoPrice } from '../fetchPastCryptoPrice';
-
vi.mock('../prismaFetchAuctionEvent');
vi.mock('../fetchAuctionDates');
vi.mock('../fetchPastCryptoPrice');
@@ -53,6 +52,7 @@ describe('fetchPastAuction()', () => {
vi.mocked(prismaFetchAuctionEvent).mockResolvedValue([
{
...mockAuctionEvent,
+ // @ts-ignore
coins: mockAuctionEvent.coins.map((coin) => ({
...coin,
id: 1,
@@ -132,6 +132,7 @@ describe('fetchPastAuction()', () => {
vi.mocked(prismaFetchAuctionEvent).mockResolvedValue([
{
...mockAuctionEvent,
+ // @ts-ignore
coins: mockAuctionEvent.coins.map((coin) => ({
...coin,
id: 1,
@@ -180,6 +181,7 @@ describe('fetchPastAuction()', () => {
vi.mocked(prismaFetchAuctionEvent).mockResolvedValue([
{
...mockAuctionEvent,
+ // @ts-ignore
coins: mockAuctionEvent.coins.map((coin) => ({
...coin,
id: 1,
diff --git a/src/queries/prismaFetchAuctionEvent.ts b/src/queries/prismaFetchAuctionEvent.ts
index 2b4dc2f..03655d4 100644
--- a/src/queries/prismaFetchAuctionEvent.ts
+++ b/src/queries/prismaFetchAuctionEvent.ts
@@ -11,9 +11,7 @@ export const prismaFetchAuctionEvent = async (round: bigint) => {
round: 'asc',
},
where: {
- where: {
- round: BigInt(round),
- },
+ round: Number(round),
},
include: {
coins: true,
From e7e7f4370e294c27e773cde13efbfe25eeee94b9 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:22:41 +0100
Subject: [PATCH 07/24] docs: updating doc
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index d1ffb15..d53588a 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,3 @@
-🚧 Work in progress, not ready for production 🚧
-
Evmos Burn Auction Instant dApp
@@ -32,6 +30,8 @@ Pre-requisites:
```bash
pnpm install
+pnpm prisma:db:push
+
cp .env.example .env
# edit the .env file with your own values
```
From aad11a40e7cab8e537b65773dc32bb0ed7d43c4e Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:36:37 +0100
Subject: [PATCH 08/24] fix: fixing issue with coingecko returning 429
---
src/queries/fetchCurrentCryptoPrice.ts | 3 ++-
src/queries/fetchPastCryptoPrice.ts | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/queries/fetchCurrentCryptoPrice.ts b/src/queries/fetchCurrentCryptoPrice.ts
index c828fbb..e8d6ea5 100644
--- a/src/queries/fetchCurrentCryptoPrice.ts
+++ b/src/queries/fetchCurrentCryptoPrice.ts
@@ -12,6 +12,7 @@ type CryptoPrice = {
};
const MOCK_COINGECKO_API = process.env.MOCK_COINGECKO_API === 'true';
+const STATUS_OK = 200;
export const fetchCurrentCryptoPrice = async (ids: string[]): Promise => {
// To avoid hitting the rate limit of the Coingecko API
@@ -31,7 +32,7 @@ export const fetchCurrentCryptoPrice = async (ids: string[]): Promise fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${coingeckoIds}&vs_currencies=usd`, { next: { revalidate: 60 } }));
Log().info('Fetching crypto price:', coingeckoIds);
- if (error) {
+ if (error || result.status !== STATUS_OK) {
Log().error('Error fetching crypto price:', error);
return Object.fromEntries(ids.map((id) => [id, { usd: 0, error: true }]));
}
diff --git a/src/queries/fetchPastCryptoPrice.ts b/src/queries/fetchPastCryptoPrice.ts
index 60839fd..167aa66 100644
--- a/src/queries/fetchPastCryptoPrice.ts
+++ b/src/queries/fetchPastCryptoPrice.ts
@@ -7,6 +7,7 @@ import { Log } from '@/utilities/logger';
const MOCK_COINGECKO_API = process.env.MOCK_COINGECKO_API === 'true';
// eslint-disable-next-line no-magic-numbers
const ONE_YEAR_IN_SECONDS = 60 * 60 * 24 * 365;
+const STATUS_OK = 200;
export const fetchPastCryptoPrice = async (coinId: string, date: Date): Promise => {
// To avoid hitting the rate limit of the Coingecko API
@@ -20,7 +21,7 @@ export const fetchPastCryptoPrice = async (coinId: string, date: Date): Promise<
const [error, result] = await E.try(() => fetch(`https://api.coingecko.com/api/v3/coins/${coinId}/history?date=${formattedDate}`, { next: { revalidate: ONE_YEAR_IN_SECONDS } }));
Log().info('Fetching crypto price:', { coinId, date });
- if (error) {
+ if (error || result.status !== STATUS_OK) {
Log().error('Error fetching crypto price:', error);
throw error;
}
From 1da0cd03d0d4e7e0eadd763f77ee8a8b373dd1a1 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:39:08 +0100
Subject: [PATCH 09/24] docs: updating doc
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index d53588a..ea34288 100644
--- a/README.md
+++ b/README.md
@@ -55,7 +55,7 @@ pnpm build
### Test with a local node
-Follow the instructions described in this issue in order to run a local node with the Burn Auction module enabled: https://github.com/evmos/burn-auction-dapp/issues/5
+Follow the instructions described in this issue in order to run a local node with the Burn Auction module enabled check this [file](./docs/DEVELOP_WITH_LOCAL_NODE.md).
### Indexing Endpoints
From 65233b64665a0d4f7aadf6776a34d1173ee78c95 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:50:14 +0100
Subject: [PATCH 10/24] fix: improving ux when prices are wrong to display an
error message
---
src/app/_components/AuctionDetails.tsx | 2 +-
src/app/_components/BiddingForm.tsx | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/app/_components/AuctionDetails.tsx b/src/app/_components/AuctionDetails.tsx
index 7dfe1c0..d70c8e7 100644
--- a/src/app/_components/AuctionDetails.tsx
+++ b/src/app/_components/AuctionDetails.tsx
@@ -119,7 +119,7 @@ export const AuctionDetails = async ({ auctionDetails }: { auctionDetails: Aucti
)}
- {round.isLast && }
+ {round.isLast && }
diff --git a/src/app/_components/BiddingForm.tsx b/src/app/_components/BiddingForm.tsx
index 55394f2..94c192e 100644
--- a/src/app/_components/BiddingForm.tsx
+++ b/src/app/_components/BiddingForm.tsx
@@ -13,8 +13,9 @@ import { viemPublicClient } from '@/utilities/viem';
import { formatUnits } from '@/utilities/formatUnits';
import { EVMOS_DECIMALS } from '@/constants';
import { LoadingSpinner } from '@/components/ui/LoadingSpinner';
+import { Tooltip } from '@/components/ui/Tooltip';
-export const BiddingForm = ({ evmosToUsdRate }: { evmosToUsdRate: number }) => {
+export const BiddingForm = ({ evmosToUsdRate, priceError }: { evmosToUsdRate: number; priceError: boolean }) => {
const [state, send] = useMachine(biddingStateMachine);
dappstore.onAccountsChange((accounts) => send({ type: 'SET_WALLET', wallet: accounts[0] }));
@@ -77,8 +78,13 @@ export const BiddingForm = ({ evmosToUsdRate }: { evmosToUsdRate: number }) => {
{state.matches('submitting') ? : 'Bid'}
-
- {Number(state.context.bidAmount) > 0 &&
≈ ${(Number(state.context.bidAmount) * evmosToUsdRate).toFixed(2)}}
+
+ {Number(state.context.bidAmount) > 0 && ≈ ${(Number(state.context.bidAmount) * evmosToUsdRate).toFixed(2)}}
+ {Number(state.context.bidAmount) > 0 && priceError && (
+
+
+
+ )}
{errorMessage &&
{errorMessage}
}
From d5ec124097a0f54d8c97c9ee7d040adc3728ca8d Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:57:24 +0100
Subject: [PATCH 11/24] fix: pagination issue fixed
---
src/app/history/page.tsx | 2 +-
src/queries/fetchAuctionHistory.ts | 17 +++++++++--------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/app/history/page.tsx b/src/app/history/page.tsx
index 6582318..b5e0823 100644
--- a/src/app/history/page.tsx
+++ b/src/app/history/page.tsx
@@ -7,7 +7,7 @@ import { PAGINATION_ITEMS_PER_PAGE } from '@/constants';
import { HistoryContent } from './_components/HistoryContent';
const History = async () => {
- const auctionHistory = await fetchAuctionHistory(1, PAGINATION_ITEMS_PER_PAGE);
+ let auctionHistory = await fetchAuctionHistory('last', PAGINATION_ITEMS_PER_PAGE);
const totalItems = auctionHistory.totalItems;
const itemsPerPage = PAGINATION_ITEMS_PER_PAGE;
const totalPages = Math.ceil(totalItems / itemsPerPage);
diff --git a/src/queries/fetchAuctionHistory.ts b/src/queries/fetchAuctionHistory.ts
index b6d3b6f..45ac0b4 100644
--- a/src/queries/fetchAuctionHistory.ts
+++ b/src/queries/fetchAuctionHistory.ts
@@ -8,9 +8,16 @@ import { HexAddress } from '@/types/HexAddress';
import { prismaFetchAuctionEvents } from './prismaFetchAuctionEvents';
-export const fetchAuctionHistory = async (page: number, itemsPerPage: number): Promise => {
- const [error, auctionEvents] = await E.try(() => prismaFetchAuctionEvents(page, itemsPerPage));
+export const fetchAuctionHistory = async (page: number | 'last', itemsPerPage: number): Promise => {
+ const [errorTotalItems, totalItems] = await E.try(() => prismaFetchAuctionEvents.count());
+ if (errorTotalItems) {
+ Log().error('Error fetching total items:', errorTotalItems);
+ throw errorTotalItems;
+ }
+
+ const lastPage = Math.ceil(totalItems / itemsPerPage);
+ const [error, auctionEvents] = await E.try(() => prismaFetchAuctionEvents(page === 'last' ? lastPage : page, itemsPerPage));
if (error) {
Log().error('Error fetching events date:', error);
throw error;
@@ -25,12 +32,6 @@ export const fetchAuctionHistory = async (page: number, itemsPerPage: number): P
};
});
- const [errorTotalItems, totalItems] = await E.try(() => prismaFetchAuctionEvents.count());
- if (errorTotalItems) {
- Log().error('Error fetching total items:', errorTotalItems);
- throw error;
- }
-
const [errorTotalBurned, totalBurned] = await E.try(() => prismaFetchAuctionEvents.totalBurned());
if (errorTotalBurned) {
Log().error('Error fetching total burned:', errorTotalBurned);
From 19d5bd8e9bfe00730712afcdc2f65103d6fd117d Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 20:58:35 +0100
Subject: [PATCH 12/24] style: updating style title
---
src/app/_components/AuctionDetails.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/_components/AuctionDetails.tsx b/src/app/_components/AuctionDetails.tsx
index d70c8e7..be9bfe3 100644
--- a/src/app/_components/AuctionDetails.tsx
+++ b/src/app/_components/AuctionDetails.tsx
@@ -58,7 +58,7 @@ export const AuctionDetails = async ({ auctionDetails }: { auctionDetails: Aucti
)}
- Auction #{Number(round.round)}
+ Auction #{Number(round.round)}
{round.isLast && (
From 2b97305bc16f2032f0317a7bbf172d7b08d54f7e Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 21:09:33 +0100
Subject: [PATCH 13/24] fix: renamed GITHUB to GH because of github limitations
for secret keys
---
.env.example | 2 +-
src/utilities/fetchChainRegistryDir.ts | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.env.example b/.env.example
index c5cde61..d50a27a 100644
--- a/.env.example
+++ b/.env.example
@@ -3,7 +3,7 @@ NEXT_PUBLIC_RPC_HOST=http://127.0.0.1:8545
COSMOS_RPC_HOST=http://127.0.0.1:1317
# Proxy
-GITHUB_API_PROXY=
+GH_API_PROXY=
# Chain info
NEXT_PUBLIC_CHAIN_ID=9000
diff --git a/src/utilities/fetchChainRegistryDir.ts b/src/utilities/fetchChainRegistryDir.ts
index 6ddeff8..38b6972 100644
--- a/src/utilities/fetchChainRegistryDir.ts
+++ b/src/utilities/fetchChainRegistryDir.ts
@@ -4,10 +4,10 @@
'use server';
import { isString } from '@/utilities/assertions';
-const GITHUB_API_PROXY = process.env.GITHUB_API_PROXY;
+const GH_API_PROXY = process.env.GH_API_PROXY;
async function getContent(owner: string, repo: string, path: string, ref: string) {
- return fetch(GITHUB_API_PROXY + 'repos/' + owner + '/' + repo + '/contents/' + path + '?ref=' + ref);
+ return fetch(GH_API_PROXY + 'repos/' + owner + '/' + repo + '/contents/' + path + '?ref=' + ref);
}
export const fetchChainRegistryDir = async (dir: string) => {
From fdfc37eaa90e4e682a42caaebfadd3bf89be00ff Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 21:25:01 +0100
Subject: [PATCH 14/24] fix: fixing secrets for gh actions
---
.github/workflows/types-lint-license-tests.yml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/.github/workflows/types-lint-license-tests.yml b/.github/workflows/types-lint-license-tests.yml
index 4b4330f..42f53c4 100644
--- a/.github/workflows/types-lint-license-tests.yml
+++ b/.github/workflows/types-lint-license-tests.yml
@@ -36,6 +36,11 @@ jobs:
test:
needs: setup
runs-on: ubuntu-latest
+ env:
+ NEXT_PUBLIC_RPC_HOST: 'http://127.0.0.1:8545'
+ NEXT_PUBLIC_ENABLED_LOGS: true
+ GITHUB_API_PROXY: ${{ secrets.GH_API_PROXY }}
+ MOCK_COINGECKO_API: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
From 25ace66c36f78e67295508c2fdfb43e1e3b3984e Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 21:33:55 +0100
Subject: [PATCH 15/24] fix: fixing typo
---
.github/workflows/types-lint-license-tests.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/types-lint-license-tests.yml b/.github/workflows/types-lint-license-tests.yml
index 42f53c4..3ecfa76 100644
--- a/.github/workflows/types-lint-license-tests.yml
+++ b/.github/workflows/types-lint-license-tests.yml
@@ -39,7 +39,7 @@ jobs:
env:
NEXT_PUBLIC_RPC_HOST: 'http://127.0.0.1:8545'
NEXT_PUBLIC_ENABLED_LOGS: true
- GITHUB_API_PROXY: ${{ secrets.GH_API_PROXY }}
+ GH_API_PROXY: ${{ secrets.GH_API_PROXY }}
MOCK_COINGECKO_API: true
steps:
- uses: actions/checkout@v4
From bd3848f9df0afa70bd5c092e809683a47ec2fe85 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Wed, 11 Sep 2024 21:44:27 +0100
Subject: [PATCH 16/24] fix: fixing restore keys
---
.github/workflows/types-lint-license-tests.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/types-lint-license-tests.yml b/.github/workflows/types-lint-license-tests.yml
index 3ecfa76..31358f3 100644
--- a/.github/workflows/types-lint-license-tests.yml
+++ b/.github/workflows/types-lint-license-tests.yml
@@ -31,7 +31,7 @@ jobs:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
- ${{ runner.os }}-pnpm-
+ ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
test:
needs: setup
From 1345bca5fa58268c6078a1daad042a970bb58a1d Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Thu, 12 Sep 2024 10:18:58 +0100
Subject: [PATCH 17/24] fix: adding symbol for external links everywhere
---
src/app/_components/AuctionDetails.tsx | 4 ++--
src/app/_components/BiddingHistoryData.tsx | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/app/_components/AuctionDetails.tsx b/src/app/_components/AuctionDetails.tsx
index be9bfe3..0ab352e 100644
--- a/src/app/_components/AuctionDetails.tsx
+++ b/src/app/_components/AuctionDetails.tsx
@@ -114,8 +114,8 @@ export const AuctionDetails = async ({ auctionDetails }: { auctionDetails: Aucti
{highestBid.bidderAddress !== '0x0000000000000000000000000000000000000000' && (
-
- {highestBid.bidderAddress}
+
+ {highestBid.bidderAddress}
)}
diff --git a/src/app/_components/BiddingHistoryData.tsx b/src/app/_components/BiddingHistoryData.tsx
index efe9b34..a874635 100644
--- a/src/app/_components/BiddingHistoryData.tsx
+++ b/src/app/_components/BiddingHistoryData.tsx
@@ -30,8 +30,8 @@ export const BiddingHistoryData = async ({ round }: { round: bigint }) => {
{bids.map((bid) => (
-
- {shortenAddress(bid.bidder)}
+
+ {shortenAddress(bid.bidder)}
|
@@ -40,8 +40,8 @@ export const BiddingHistoryData = async ({ round }: { round: bigint }) => {
|
{bid.time ? dayjs(bid.time).fromNow() : ''} |
-
- {shortenAddress(bid.transactionHash)}
+
+ {shortenAddress(bid.transactionHash)}
|
From ca5c9b291d1d948ae660053fa3a69bb2de8f9652 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Thu, 12 Sep 2024 10:42:18 +0100
Subject: [PATCH 18/24] fix: updating calculation for price fetching from
coingecko
---
src/app/_components/AuctionDetails.tsx | 5 +----
src/queries/fetchCurrentAuction.ts | 4 +++-
src/queries/fetchPastAuction.ts | 4 +++-
src/types/AuctionDetailed.ts | 1 +
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/app/_components/AuctionDetails.tsx b/src/app/_components/AuctionDetails.tsx
index 0ab352e..c1f5d44 100644
--- a/src/app/_components/AuctionDetails.tsx
+++ b/src/app/_components/AuctionDetails.tsx
@@ -9,7 +9,6 @@ import type { AuctionDetailed } from '@/types/AuctionDetailed';
import { formatUnits } from '@/utilities/formatUnits';
import { EVMOS_DECIMALS } from '@/constants';
import { ButtonLink } from '@/components/ui/ButtonLink';
-import { fetchCurrentCryptoPrice } from '@/queries/fetchCurrentCryptoPrice';
import { Tooltip } from '@/components/ui/Tooltip';
import { AssetsTable } from './AssetsTable';
@@ -44,8 +43,6 @@ export const AuctionDetails = async ({ auctionDetails }: { auctionDetails: Aucti
timeZoneName: 'short',
});
- const evmosToUsdRate = await fetchCurrentCryptoPrice(['evmos']).then((res) => res.evmos.usd);
-
return (
@@ -119,7 +116,7 @@ export const AuctionDetails = async ({ auctionDetails }: { auctionDetails: Aucti
)}
- {round.isLast && }
+ {round.isLast && }
diff --git a/src/queries/fetchCurrentAuction.ts b/src/queries/fetchCurrentAuction.ts
index 43730cb..d06240a 100644
--- a/src/queries/fetchCurrentAuction.ts
+++ b/src/queries/fetchCurrentAuction.ts
@@ -35,7 +35,7 @@ export const fetchCurrentAuction = async (): Promise => {
throw errorEndDate;
}
- const currentAuctionInfo = {
+ const currentAuctionInfo: AuctionDetailed = {
round: {
round: auctionInfo.currentRound,
isLast: true,
@@ -53,6 +53,7 @@ export const fetchCurrentAuction = async (): Promise => {
assets: [] as AuctionnedAsset[],
totalValue: 0,
hasPriceError: false,
+ evmosToUsdRate: 0,
},
};
@@ -103,6 +104,7 @@ export const fetchCurrentAuction = async (): Promise => {
return asset;
});
+ currentAuctionInfo.auction.evmosToUsdRate = prices['evmos']['usd'];
currentAuctionInfo.highestBid.bidInUsd = currentAuctionInfo.highestBid.bidInEvmosWithDecimals * prices['evmos']['usd'];
currentAuctionInfo.auction.totalValue = currentAuctionInfo.auction.assets.reduce((acc, asset) => acc + asset.valueInUsd, 0);
diff --git a/src/queries/fetchPastAuction.ts b/src/queries/fetchPastAuction.ts
index 9ee30af..e4023d3 100644
--- a/src/queries/fetchPastAuction.ts
+++ b/src/queries/fetchPastAuction.ts
@@ -59,6 +59,7 @@ export const fetchPastAuction = async (round: bigint): Promise
assets: [] as AuctionnedAsset[],
totalValue: 0,
hasPriceError: false,
+ evmosToUsdRate: 0,
},
};
@@ -108,8 +109,9 @@ export const fetchPastAuction = async (round: bigint): Promise
auctionDetails.auction.assets.push(asset);
}
+ auctionDetails.auction.evmosToUsdRate = await fetchPastCryptoPrice('evmos', dates.end);
auctionDetails.auction.totalValue = totalValue;
- auctionDetails.highestBid.bidInUsd = (await fetchPastCryptoPrice('evmos', dates.end)) * auctionDetails.highestBid.bidInEvmosWithDecimals;
+ auctionDetails.highestBid.bidInUsd = auctionDetails.auction.evmosToUsdRate * auctionDetails.highestBid.bidInEvmosWithDecimals;
return auctionDetails;
};
diff --git a/src/types/AuctionDetailed.ts b/src/types/AuctionDetailed.ts
index 8c636fe..dc002bc 100644
--- a/src/types/AuctionDetailed.ts
+++ b/src/types/AuctionDetailed.ts
@@ -15,6 +15,7 @@ export type AuctionDetailed = {
assets: AuctionnedAsset[];
totalValue: number;
hasPriceError: boolean;
+ evmosToUsdRate: number;
};
highestBid: {
bidInEvmos: bigint;
From ccbbb66ebe4dc977e3fb8c3cae4b4d0c842653b5 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Thu, 12 Sep 2024 10:47:56 +0100
Subject: [PATCH 19/24] fix: fixing issue related to price
---
src/queries/fetchPastAuction.ts | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/queries/fetchPastAuction.ts b/src/queries/fetchPastAuction.ts
index e4023d3..87ce6fa 100644
--- a/src/queries/fetchPastAuction.ts
+++ b/src/queries/fetchPastAuction.ts
@@ -109,7 +109,11 @@ export const fetchPastAuction = async (round: bigint): Promise
auctionDetails.auction.assets.push(asset);
}
- auctionDetails.auction.evmosToUsdRate = await fetchPastCryptoPrice('evmos', dates.end);
+ // eslint-disable-next-line no-unused-vars
+ const [_, evmosToUsdRateCoingecko] = await E.try(() => fetchPastCryptoPrice('evmos', dates.end));
+ const evmosToUsdRate = evmosToUsdRateCoingecko ?? 0;
+
+ auctionDetails.auction.evmosToUsdRate = evmosToUsdRate;
auctionDetails.auction.totalValue = totalValue;
auctionDetails.highestBid.bidInUsd = auctionDetails.auction.evmosToUsdRate * auctionDetails.highestBid.bidInEvmosWithDecimals;
From 756805fd8e0a2f249b3c80949ac79fa4819adba6 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Thu, 12 Sep 2024 11:01:24 +0100
Subject: [PATCH 20/24] feat: improving bidding ux
---
src/app/_components/BiddingForm.tsx | 8 ++++----
src/app/_state-machines/biddingStateMachine.ts | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/app/_components/BiddingForm.tsx b/src/app/_components/BiddingForm.tsx
index 94c192e..adb53e6 100644
--- a/src/app/_components/BiddingForm.tsx
+++ b/src/app/_components/BiddingForm.tsx
@@ -40,7 +40,7 @@ export const BiddingForm = ({ evmosToUsdRate, priceError }: { evmosToUsdRate: nu
send({ type: 'SUBMIT' });
};
- const isSubmitDisabled = (state.context.bidAmount !== '' && !state.can({ type: 'SUBMIT' })) || state.matches('submitting');
+ const isSubmitDisabled = (state.context.bidAmount !== '' && !state.can({ type: 'SUBMIT' })) || state.matches('submitting') || state.matches('success');
const errorMessage =
Number(state.context.bidAmount) < 0
? 'Bid amount must be greater than 0'
@@ -67,7 +67,7 @@ export const BiddingForm = ({ evmosToUsdRate, priceError }: { evmosToUsdRate: nu
placeholder="Amount"
value={state.context.bidAmount}
onChange={(e) => send({ type: 'SET_BID_AMOUNT', value: e.target.value })}
- disabled={state.matches('submitting')}
+ disabled={isSubmitDisabled}
/>
@@ -75,7 +75,7 @@ export const BiddingForm = ({ evmosToUsdRate, priceError }: { evmosToUsdRate: nu
className="disabled:text-evmos-gray-light disabled:bg-evmos-gray disabled:border-evmos-gray items-center justify-center rounded-full transition-[background-color,outline-color,filter] transition-200 flex gap-x-1 outline outline-offset-2 outline-1 outline-transparent bg-evmos-orange-500 hover:bg-evmos-orange-400 py-[9px] px-5 active:outline-evmos-secondary-dark"
disabled={isSubmitDisabled}
>
- {state.matches('submitting') ? : 'Bid'}
+ {state.matches('submitting') || state.matches('success') ? : 'Bid'}
@@ -89,7 +89,7 @@ export const BiddingForm = ({ evmosToUsdRate, priceError }: { evmosToUsdRate: nu
{errorMessage &&
{errorMessage}
}
{state.matches('error') &&
{state.context.error}
}
- {state.matches('success') &&
Bid placed successfully!
}
+ {state.matches('success') &&
Bid placed successfully! It will appear in a few seconds.
}
);
};
diff --git a/src/app/_state-machines/biddingStateMachine.ts b/src/app/_state-machines/biddingStateMachine.ts
index 476a989..97ac51c 100644
--- a/src/app/_state-machines/biddingStateMachine.ts
+++ b/src/app/_state-machines/biddingStateMachine.ts
@@ -115,7 +115,7 @@ export const biddingStateMachine = setup({
after: {
// average block time is 3 seconds, added a bit of buffer here
5000: {
- target: 'success',
+ target: 'idle',
actions: 'refreshPage',
},
},
From b4606219ec3c2ce2d7b85c1dddbc16ced3a97832 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Thu, 12 Sep 2024 11:07:17 +0100
Subject: [PATCH 21/24] fix: fixing state issue
---
src/app/_state-machines/biddingStateMachine.ts | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/app/_state-machines/biddingStateMachine.ts b/src/app/_state-machines/biddingStateMachine.ts
index 97ac51c..d2f2a34 100644
--- a/src/app/_state-machines/biddingStateMachine.ts
+++ b/src/app/_state-machines/biddingStateMachine.ts
@@ -42,6 +42,10 @@ export const biddingStateMachine = setup({
bidAmount: ({ context }) => Math.max(Number(formatUnits(context.balance, EVMOS_DECIMALS, 2)) - DECIMAL_DISPLAY_FIX, 0),
error: () => null,
}),
+ resetBidAmount: assign({
+ bidAmount: () => '',
+ error: () => null,
+ }),
refreshPage: () => {
reloadData();
},
@@ -116,7 +120,7 @@ export const biddingStateMachine = setup({
// average block time is 3 seconds, added a bit of buffer here
5000: {
target: 'idle',
- actions: 'refreshPage',
+ actions: ['refreshPage', 'resetBidAmount'], // Reset bid amount here
},
},
},
From 9537d3eee7698dea1f76fa94c978b7d23d23fc5e Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Thu, 12 Sep 2024 11:09:04 +0100
Subject: [PATCH 22/24] fix: fixing templating issue
---
src/app/_components/BiddingHistory.tsx | 30 ++++++++++++++------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/app/_components/BiddingHistory.tsx b/src/app/_components/BiddingHistory.tsx
index cc82ad4..a8f4888 100644
--- a/src/app/_components/BiddingHistory.tsx
+++ b/src/app/_components/BiddingHistory.tsx
@@ -40,20 +40,22 @@ export const BiddingHistory = async ({ round }: { round: bigint }) => {
-
-
- |
-
-
- |
-
-
- |
-
-
- |
-
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
}
>
From 71d0732a5ebf0ba060f2989cde142b77bd988679 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Thu, 12 Sep 2024 11:12:09 +0100
Subject: [PATCH 23/24] fix: trying to refactor the github action
---
.../workflows/types-lint-license-tests.yml | 41 +++++++++++--------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/types-lint-license-tests.yml b/.github/workflows/types-lint-license-tests.yml
index 31358f3..e228419 100644
--- a/.github/workflows/types-lint-license-tests.yml
+++ b/.github/workflows/types-lint-license-tests.yml
@@ -6,11 +6,13 @@ on:
- main
jobs:
- setup:
+ install-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
@@ -22,19 +24,22 @@ jobs:
with:
version: 8
- - name: Install dependencies
- run: pnpm install
-
- name: Cache dependencies
uses: actions/cache@v3
+ id: cache
with:
- path: ~/.pnpm-store
+ path: |
+ **/node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
- ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ ${{ runner.os }}-pnpm-
+
+ - name: Install dependencies
+ if: steps.cache.outputs.cache-hit != 'true'
+ run: pnpm install
test:
- needs: setup
+ needs: install-dependencies
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_RPC_HOST: 'http://127.0.0.1:8545'
@@ -51,13 +56,13 @@ jobs:
version: 8
- uses: actions/cache@v3
with:
- path: ~/.pnpm-store
+ path: |
+ **/node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- - run: pnpm install
- run: pnpm test
typecheck:
- needs: setup
+ needs: install-dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -69,13 +74,13 @@ jobs:
version: 8
- uses: actions/cache@v3
with:
- path: ~/.pnpm-store
+ path: |
+ **/node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- - run: pnpm install
- run: pnpm typecheck
lint:
- needs: setup
+ needs: install-dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -87,13 +92,13 @@ jobs:
version: 8
- uses: actions/cache@v3
with:
- path: ~/.pnpm-store
+ path: |
+ **/node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- - run: pnpm install
- run: pnpm lint
license:
- needs: setup
+ needs: install-dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -105,7 +110,7 @@ jobs:
version: 8
- uses: actions/cache@v3
with:
- path: ~/.pnpm-store
+ path: |
+ **/node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- - run: pnpm install
- run: pnpm license
From b7e933bd46499e4f1915614e70c66391bd4354e5 Mon Sep 17 00:00:00 2001
From: Sandoche
Date: Thu, 12 Sep 2024 11:19:35 +0100
Subject: [PATCH 24/24] fix: restore previous test that worked and faster
---
.../workflows/types-lint-license-tests.yml | 38 +++++++++----------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/.github/workflows/types-lint-license-tests.yml b/.github/workflows/types-lint-license-tests.yml
index e228419..3d908cf 100644
--- a/.github/workflows/types-lint-license-tests.yml
+++ b/.github/workflows/types-lint-license-tests.yml
@@ -6,13 +6,11 @@ on:
- main
jobs:
- install-dependencies:
+ setup:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- with:
- fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
@@ -24,22 +22,20 @@ jobs:
with:
version: 8
+ - name: Install dependencies
+ run: pnpm install
+
- name: Cache dependencies
uses: actions/cache@v3
id: cache
with:
- path: |
- **/node_modules
+ path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- - name: Install dependencies
- if: steps.cache.outputs.cache-hit != 'true'
- run: pnpm install
-
test:
- needs: install-dependencies
+ needs: setup
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_RPC_HOST: 'http://127.0.0.1:8545'
@@ -56,13 +52,13 @@ jobs:
version: 8
- uses: actions/cache@v3
with:
- path: |
- **/node_modules
+ path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ - run: pnpm install
- run: pnpm test
typecheck:
- needs: install-dependencies
+ needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -74,13 +70,13 @@ jobs:
version: 8
- uses: actions/cache@v3
with:
- path: |
- **/node_modules
+ path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ - run: pnpm install
- run: pnpm typecheck
lint:
- needs: install-dependencies
+ needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -92,13 +88,13 @@ jobs:
version: 8
- uses: actions/cache@v3
with:
- path: |
- **/node_modules
+ path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ - run: pnpm install
- run: pnpm lint
license:
- needs: install-dependencies
+ needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -110,7 +106,7 @@ jobs:
version: 8
- uses: actions/cache@v3
with:
- path: |
- **/node_modules
+ path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
+ - run: pnpm install
- run: pnpm license