Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes & github actions #51

Merged
merged 25 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8b21383
feat: adding gh actions
sandoche Sep 11, 2024
b5a3586
fix: updating pnpm-lock
sandoche Sep 11, 2024
6c87a53
fix: fixing some linting issues
sandoche Sep 11, 2024
3537f9a
fix: fixing lint issues
sandoche Sep 11, 2024
b180b4f
fix: fixing postinstall script
sandoche Sep 11, 2024
e6fb5d9
fix: types and queries fixes
sandoche Sep 11, 2024
e7e7f43
docs: updating doc
sandoche Sep 11, 2024
4af0e69
Merge branch 'sandoche/gh-actions' into sandoche/various-fixes
sandoche Sep 11, 2024
aad11a4
fix: fixing issue with coingecko returning 429
sandoche Sep 11, 2024
1da0cd0
docs: updating doc
sandoche Sep 11, 2024
65233b6
fix: improving ux when prices are wrong to display an error message
sandoche Sep 11, 2024
d5ec124
fix: pagination issue fixed
sandoche Sep 11, 2024
19d5bd8
style: updating style title
sandoche Sep 11, 2024
2b97305
fix: renamed GITHUB to GH because of github limitations for secret keys
sandoche Sep 11, 2024
fdfc37e
fix: fixing secrets for gh actions
sandoche Sep 11, 2024
25ace66
fix: fixing typo
sandoche Sep 11, 2024
bd3848f
fix: fixing restore keys
sandoche Sep 11, 2024
1345bca
fix: adding symbol for external links everywhere
sandoche Sep 12, 2024
ca5c9b2
fix: updating calculation for price fetching from coingecko
sandoche Sep 12, 2024
ccbbb66
fix: fixing issue related to price
sandoche Sep 12, 2024
756805f
feat: improving bidding ux
sandoche Sep 12, 2024
b460621
fix: fixing state issue
sandoche Sep 12, 2024
9537d3e
fix: fixing templating issue
sandoche Sep 12, 2024
71d0732
fix: trying to refactor the github action
sandoche Sep 12, 2024
b7e933b
fix: restore previous test that worked and faster
sandoche Sep 12, 2024
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
106 changes: 106 additions & 0 deletions .github/workflows/types-lint-license-tests.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
🚧 Work in progress, not ready for production 🚧

<div align="center">
<h1> Evmos Burn Auction Instant dApp </h1>
</div>
Expand Down Expand Up @@ -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
```
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -73,4 +73,3 @@
"vitest": "^2.0.5"
}
}

4 changes: 4 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions src/app/_components/AuctionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;

Expand Down
11 changes: 7 additions & 4 deletions src/app/_components/Countdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,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();
Expand Down Expand Up @@ -57,10 +60,10 @@ 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);
};
Expand Down
4 changes: 3 additions & 1 deletion src/app/api/v1/indexer/auction-end-events/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/app/api/v1/indexer/bid-events/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/app/history/[pageNumber]/page.tsx
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
7 changes: 4 additions & 3 deletions src/app/history/_components/HistoryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<section className="mb-10">
Expand Down
3 changes: 2 additions & 1 deletion src/app/history/_components/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 1 addition & 7 deletions src/app/history/page.tsx
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 2 additions & 1 deletion src/queries/__tests__/fetchAuctionHistory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions src/queries/__tests__/fetchBiddingHistory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ 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';

vi.mock('../prismaFetchBidEvent');
vi.mock('../rpcFetchBlockDate');

/* eslint-disable no-magic-numbers */
describe('fetchBiddingHistory(round)', () => {
beforeEach(() => {
vi.resetAllMocks();
Expand Down
1 change: 0 additions & 1 deletion src/queries/__tests__/fetchCurrentAuction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading
Loading