From 876f525b612fedec8e296cec1b948cd8bdaa73bf Mon Sep 17 00:00:00 2001 From: yan-gurevich-mc14 Date: Wed, 16 Apr 2025 15:30:28 +0300 Subject: [PATCH 01/11] Add workflows and secrets --- .github/scripts/check_pr_branch_name.py | 73 ++++++++++++++++++++ .github/scripts/verify_new_member.py | 88 +++++++++++++++++++++++++ .github/workflows/build.yml | 25 +++++++ .github/workflows/deploy-to-s3.yml | 42 ++++++++++++ .github/workflows/lint.yml | 28 ++++++++ .github/workflows/manual.yml | 20 ++++++ .github/workflows/playwright.yml | 29 ++++++++ .vscode/launch.json | 24 +++++++ .vscode/settings.json | 5 ++ .vscode/tasks.json | 43 ++++++++++++ src/config.ts | 6 +- src/services/analytics/analytics.ts | 4 +- src/services/apiClient/index.ts | 4 +- src/utils/FuulSDK/FuulFunctions.ts | 3 +- src/web3Config/premia/fillQuote.ts | 2 +- src/web3Config/reownConfig.ts | 2 +- vite-env.d.ts | 2 +- 17 files changed, 385 insertions(+), 15 deletions(-) create mode 100644 .github/scripts/check_pr_branch_name.py create mode 100644 .github/scripts/verify_new_member.py create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/deploy-to-s3.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/manual.yml create mode 100644 .github/workflows/playwright.yml create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.github/scripts/check_pr_branch_name.py b/.github/scripts/check_pr_branch_name.py new file mode 100644 index 0000000..d3c5bd9 --- /dev/null +++ b/.github/scripts/check_pr_branch_name.py @@ -0,0 +1,73 @@ +import http.client +import json +import os +from urllib.parse import urlparse +import sys # Import sys for exit functionality + +branch_name = os.getenv('BRANCH_NAME', '') +pr_creator = os.getenv('PR_CREATOR', '') +webhook_url = os.getenv('DISCORD_ALERT_DEVELOP_WEBHOOK_URL', '') + +# Dynamically get repository information +github_repository = os.getenv('GITHUB_REPOSITORY', 'mc14labs/interface') # Default if not set + +# Try to get the PR number directly from an environment variable or parse it from the GitHub event path +pr_number = os.getenv('PR_NUMBER') +if not pr_number: + event_path = os.getenv('GITHUB_EVENT_PATH', '') + if event_path: + try: + with open(event_path, 'r') as event_file: + event_data = json.load(event_file) + pr_number = event_data.get('pull_request', {}).get('number') + except Exception as e: + print(f"Error reading GitHub event file: {e}") + sys.exit(1) # Exit if the PR number can't be read + +if not pr_number: + print("PR number not found.") + sys.exit(1) + +# Construct the PR URL dynamically +pr_url = f"https://github.com/{github_repository}/pull/{pr_number}" + +# Mapping from GitHub usernames to Discord user IDs +github_to_discord_mapping = { + "asalef10": "1130376965354954823", + "4tal": "459310419056525324", + "Tomelia1999": "1160224372313833472", + "galbit": "1082599634519719986", +} + +# Check for missing 'CU' prefix in branch name and alert if necessary +if 'CU' not in branch_name: + alert_message = json.dumps({ + "embeds": [ + { + "title": "Branch Naming Alert", + "description": f"Interface : Pull request for branch '{branch_name}' is missing 'CU' prefix. Created by <@{github_to_discord_mapping.get(pr_creator, pr_creator)}>. Please ensure the branch name is linked correctly to ClickUp tasks. PR URL: {pr_url}", + "color": 16711680 # Red color + } + ], + "content": f"<@{github_to_discord_mapping.get(pr_creator, pr_creator)}>" + }) + + parsed_url = urlparse(webhook_url) + connection = http.client.HTTPSConnection(parsed_url.hostname) + headers = { + "Content-Type": "application/json", + "Content-Length": str(len(alert_message)) + } + + connection.request("POST", parsed_url.path, body=alert_message, headers=headers) + response = connection.getresponse() + connection.close() + + # Handle non-success response from Discord + if response.status != 204: + print(f"Failed to send Discord webhook message, status code: {response.status}") + + print("::error::Branch naming convention violation detected.") + sys.exit(1) # Ensure script exits with a non-zero status to indicate failure + + \ No newline at end of file diff --git a/.github/scripts/verify_new_member.py b/.github/scripts/verify_new_member.py new file mode 100644 index 0000000..1c71339 --- /dev/null +++ b/.github/scripts/verify_new_member.py @@ -0,0 +1,88 @@ +import json +import os +import re +import sys +from glob import glob +import requests # Import the requests library + + +# Switch To Typescript. +# Verify Only One Json +# Verify Json Keys +# Split the verify member and update user (Do on PR, Do on merge) + +def is_valid_evm_address(address): + return bool(re.match(r'^0x[a-fA-F0-9]{40}$', address)) + + +def verify_file(file_path): + file_name = os.path.basename(file_path) + if not re.match(r'^[a-zA-Z0-9]+$', file_name.split('.')[0]): + print(f"File name {file_name} does not meet the naming convention.") + return False, None + + # Load and check the JSON content + with open(file_path, 'r') as file: + try: + content = json.load(file) + print(content) + except json.JSONDecodeError: + print(f"File {file_name} does not contain valid JSON.") + return False, None + + if 'evmAddress' not in content or not is_valid_evm_address(content['evmAddress']): + print(f"Invalid or missing EVM address in file {file_name}.") + return False, None + if 'githubHandle' not in content or not content['githubHandle'].strip(): + print(f"Missing or empty github handle in file {file_name}.") + return False, None + + return True, content + + +def send_content_to_backend(content): + # Replace with your actual backend URL + backend_url = "https://u6udeff7tg.execute-api.us-east-1.amazonaws.com/dev/github" + headers = {"Content-Type": "application/json"} + + try: + response = requests.post(backend_url, headers=headers, json=content) + + if response.status_code != 200: + print( + f"Failed to send data to backend. Status code: {response.status_code}") + # Exit with error status to indicate failure in sending data to the backend + sys.exit(1) + else: + print("Successfully sent data to backend.") + + except requests.exceptions.ConnectionError as e: + print(f"Failed to connect to backend. Error: {e}") + # Exit with error status to indicate failure in connecting to the backend + sys.exit(1) + except requests.exceptions.RequestException as e: + # Handles other requests-related exceptions + print(f"Request failed. Error: {e}") + sys.exit(1) + + +def main(): + new_files = glob('new members/*') + if len(new_files) == 0: + print("No new files to verify.") + sys.exit(0) # No files to process, exit normally + + file_path = new_files[0] # Assuming only one file is added per PR + verification_passed, content = verify_file(file_path) + if not verification_passed: + sys.exit(1) # Exit with error status to indicate verification failure + + # If verification passed, send the content to the backend + send_content_to_backend(content) + + print("Verification succeeded.") + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..08aa0ad --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,25 @@ +name: Build + +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Install pnpm + run: npm install -g pnpm + + - name: Install dependencies + run: pnpm i + + - name: Build app + run: pnpm run build diff --git a/.github/workflows/deploy-to-s3.yml b/.github/workflows/deploy-to-s3.yml new file mode 100644 index 0000000..351db07 --- /dev/null +++ b/.github/workflows/deploy-to-s3.yml @@ -0,0 +1,42 @@ +name: Deploy to Amazon S3 + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: pnpm/action-setup@v3 + with: + version: 9 + + - name: Use Node.js 18 + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm run build + env: + VITE_ENV: 'dev' + VITE_WHITELIST_MODE: true + - name: Deploy to S3 + uses: jakejarvis/s3-sync-action@v0.5.1 + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: ${{ github.ref == 'refs/heads/main' && 'app.grix.finance' || 'v0.grix.finance' }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} + AWS_REGION: us-east-1 + SOURCE_DIR: 'dist' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..51d615d --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: Lint + +on: + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Install pnpm + run: npm install -g pnpm + + - name: Install dependencies + run: pnpm i + + - name: Run ESLint + run: pnpm run lint + + - name: Run prettier + run: pnpm run prettier diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 0000000..6481440 --- /dev/null +++ b/.github/workflows/manual.yml @@ -0,0 +1,20 @@ +name: PR Review Action +on: + pull_request: + types: [opened] + +jobs: + send-pr-review: + runs-on: ubuntu-latest + steps: + - name: Send PR Review Request + run: | + curl -X POST https://u6udeff7tg.execute-api.us-east-1.amazonaws.com/dev/prReview \ + -H "Content-Type: application/json" \ + -H "x-api-key: ${{ secrets.EXTERNAL_API_KEY }}" \ + -d "{ + \"prNumber\": ${{ github.event.pull_request.number }}, + \"branch\": \"${{ github.event.pull_request.head.ref }}\", + \"owner\": \"${{ github.repository_owner }}\", + \"repo\": \"${{ github.event.repository.name }}\" + }" diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..5c9c0aa --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,29 @@ +name: Playwright Tests +on: + pull_request: + branches: [main, master] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm install -g pnpm && pnpm install + - name: Install Playwright Browsers + run: pnpm exec playwright install chromium --with-deps + - name: Run Playwright tests + run: pnpm exec playwright test + env: + # Add environment variables to ensure tests work with new navigation + PLAYWRIGHT_NAVIGATION_TIMEOUT: 60000 + PLAYWRIGHT_EXPECT_TIMEOUT: 30000 + - uses: actions/upload-artifact@v4 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..38f6e31 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "Brave", + "url": "http://localhost:4000", + "webRoot": "${workspaceFolder}", + "runtimeExecutable": "/Applications/Brave Browser.app" + }, + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome with pnpm", + "url": "http://localhost:5173", + "webRoot": "${workspaceFolder}", + "preLaunchTask": "pnpm: dev" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d8a12c7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": ["Grix"], + "colorize.languages": ["css", "sass", "scss", "less", "sss", "stylus", "xml", "svg", "typescript"], + "git.allowNoVerifyCommit": false +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..5bf2763 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,43 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "pnpm: dev", + "type": "shell", + "command": "pnpm", + "args": ["run", "dev"], + "isBackground": true, + "problemMatcher": { + "owner": "custom", + "pattern": [ + { + "regexp": ".", + "file": 1, + "location": 2, + "message": 3 + } + ], + "background": { + "activeOnStart": true, + "beginsPattern": ".*VITE v.*", + "endsPattern": ".*Local:.*" + } + }, + "detail": "This task runs pnpm run dev" + }, + { + "label": "Format before merge", + "type": "shell", + "command": "pnpm run prettier:fix && pnpm lint --fix", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [], + "presentation": { + "reveal": "always", + "close": false + } + } + ] +} diff --git a/src/config.ts b/src/config.ts index 73c17d3..4302c09 100644 --- a/src/config.ts +++ b/src/config.ts @@ -101,7 +101,6 @@ export const OptionType = { export const DECIMAL_PLACES_18 = 18; export const DECIMAL_PLACES_8 = 8; -export const VITE_FUUL_API_KEY = import.meta.env.VITE_FUUL_API_KEY; export const COINGECKO_API_URL = 'https://api.coingecko.com/api/v3/simple/price'; @@ -253,7 +252,4 @@ export const deBridgeScriptSrc = 'https://app.debridge.finance/assets/scripts/wi export const WBTC_Address = '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f'; -export const PREMIA_KEY = 'grix_3ZkT6qWxydnaWLZArWMjE3jm'; - -export const grixLogoUrl = - 'https://statics.solscan.io/cdn/imgs/s60?ref=68747470733a2f2f697066732e696f2f697066732f516d52556977584b515a624d445766587a567833594c4c5a6852436d4a744c376a75557a5148437a795559427454'; +export const grixLogoUrl = 'https://statics.solscan.io/cdn/imgs/s60?ref=68747470733a2f2f697066732e696f2f697066732f516d52556977584b515a624d445766587a567833594c4c5a6852436d4a744c376a75557a5148437a795559427454'; diff --git a/src/services/analytics/analytics.ts b/src/services/analytics/analytics.ts index cde89a9..be56285 100644 --- a/src/services/analytics/analytics.ts +++ b/src/services/analytics/analytics.ts @@ -2,7 +2,7 @@ import Mixpanel from 'mixpanel-browser'; import { config, env } from '../../config'; -Mixpanel.init('2111331d11fb90732a2aa39342002652', { +Mixpanel.init(import.meta.env.VITE_MIXPANEL_TOKEN, { track_pageview: true, persistence: 'localStorage', ignore_dnt: true, @@ -16,7 +16,7 @@ Mixpanel.init('2111331d11fb90732a2aa39342002652', { engage: 'data/account', }, xhr_headers: { - 'x-api-key': config[env].apiKey, + 'x-api-key': import.meta.env.VITE_GRIX_API_KEY, }, }); diff --git a/src/services/apiClient/index.ts b/src/services/apiClient/index.ts index c415f63..b1df802 100644 --- a/src/services/apiClient/index.ts +++ b/src/services/apiClient/index.ts @@ -1,10 +1,8 @@ import axios from 'axios'; -import { config, env } from '../../config'; - export const apiClient = axios.create({ baseURL: 'https://z61hgkwkn8.execute-api.us-east-1.amazonaws.com/dev', //temp headers: { - 'x-api-key': config[env].apiKey, + 'x-api-key': import.meta.env.VITE_GRIX_API_KEY, }, }); diff --git a/src/utils/FuulSDK/FuulFunctions.ts b/src/utils/FuulSDK/FuulFunctions.ts index 4224e7c..8959bdf 100644 --- a/src/utils/FuulSDK/FuulFunctions.ts +++ b/src/utils/FuulSDK/FuulFunctions.ts @@ -1,7 +1,6 @@ import { Fuul } from '@fuul/sdk'; import type { GetPointsLeaderboardParams } from '@fuul/sdk/dist/types/api'; -import { VITE_FUUL_API_KEY } from '@/config'; type TotalPoints = { totalPoints: number; @@ -9,7 +8,7 @@ type TotalPoints = { export const fuulInit = () => { Fuul.init({ - apiKey: VITE_FUUL_API_KEY, + apiKey: import.meta.env.VITE_FUUL_API_KEY, }); }; diff --git a/src/web3Config/premia/fillQuote.ts b/src/web3Config/premia/fillQuote.ts index 6f216c0..3396112 100644 --- a/src/web3Config/premia/fillQuote.ts +++ b/src/web3Config/premia/fillQuote.ts @@ -72,7 +72,7 @@ export const fetchPoolQuery = async ( method: 'GET', headers: { 'Content-Type': 'application/json', - 'x-apikey': PREMIA_KEY, + 'x-apikey': import.meta.env.VITE_PREMIA_KEY, }, body: null, }; diff --git a/src/web3Config/reownConfig.ts b/src/web3Config/reownConfig.ts index e8addde..0a885e0 100644 --- a/src/web3Config/reownConfig.ts +++ b/src/web3Config/reownConfig.ts @@ -3,7 +3,7 @@ import { SolanaAdapter } from '@reown/appkit-adapter-solana/react'; import { WagmiAdapter } from '@reown/appkit-adapter-wagmi'; import { PhantomWalletAdapter, SolflareWalletAdapter } from '@solana/wallet-adapter-wallets'; -export const projectId = import.meta.env.VITE_ENV_WAGMI_PROJECT_ID; +export const projectId = import.meta.env.VITE_WAGMI_PROJECT_ID; export const wagmiAdapter = new WagmiAdapter({ networks: [arbitrum], diff --git a/vite-env.d.ts b/vite-env.d.ts index 5253bd9..31a7cd4 100644 --- a/vite-env.d.ts +++ b/vite-env.d.ts @@ -4,7 +4,7 @@ interface ImportMetaEnv { readonly VITE_ENV: 'debug' | 'dev' | 'staging' | 'main'; readonly VITE_WHITELIST_MODE: string; readonly VITE_FUUL_API_KEY: string; - readonly PROJECTID: string; + readonly VITE_WAGMI_PROJECT_ID: string; // Add other env variables as needed } From e3fe9c0f77676a9cc6ac6291ad5ae68bb02407e6 Mon Sep 17 00:00:00 2001 From: yan-gurevich-mc14 Date: Wed, 16 Apr 2025 15:37:30 +0300 Subject: [PATCH 02/11] return non-secret keys --- src/services/analytics/analytics.ts | 2 +- src/utils/FuulSDK/FuulFunctions.ts | 4 +++- src/web3Config/reownConfig.ts | 2 +- vite-env.d.ts | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/services/analytics/analytics.ts b/src/services/analytics/analytics.ts index be56285..e0d84cf 100644 --- a/src/services/analytics/analytics.ts +++ b/src/services/analytics/analytics.ts @@ -2,7 +2,7 @@ import Mixpanel from 'mixpanel-browser'; import { config, env } from '../../config'; -Mixpanel.init(import.meta.env.VITE_MIXPANEL_TOKEN, { +Mixpanel.init('2111331d11fb90732a2aa39342002652', { track_pageview: true, persistence: 'localStorage', ignore_dnt: true, diff --git a/src/utils/FuulSDK/FuulFunctions.ts b/src/utils/FuulSDK/FuulFunctions.ts index 8959bdf..39ed785 100644 --- a/src/utils/FuulSDK/FuulFunctions.ts +++ b/src/utils/FuulSDK/FuulFunctions.ts @@ -6,9 +6,11 @@ type TotalPoints = { totalPoints: number; }; +const FUUL_API_KEY = "8d5dbc2bc85b953e795b97c38865741f95172d79857e1cece53e059ee07dfd15"; + export const fuulInit = () => { Fuul.init({ - apiKey: import.meta.env.VITE_FUUL_API_KEY, + apiKey: FUUL_API_KEY, }); }; diff --git a/src/web3Config/reownConfig.ts b/src/web3Config/reownConfig.ts index 0a885e0..d4d784f 100644 --- a/src/web3Config/reownConfig.ts +++ b/src/web3Config/reownConfig.ts @@ -3,7 +3,7 @@ import { SolanaAdapter } from '@reown/appkit-adapter-solana/react'; import { WagmiAdapter } from '@reown/appkit-adapter-wagmi'; import { PhantomWalletAdapter, SolflareWalletAdapter } from '@solana/wallet-adapter-wallets'; -export const projectId = import.meta.env.VITE_WAGMI_PROJECT_ID; +export const projectId = "02389d7b577faa031f008f9017390007"; export const wagmiAdapter = new WagmiAdapter({ networks: [arbitrum], diff --git a/vite-env.d.ts b/vite-env.d.ts index 31a7cd4..4c6dc61 100644 --- a/vite-env.d.ts +++ b/vite-env.d.ts @@ -3,8 +3,8 @@ interface ImportMetaEnv { readonly VITE_ENV: 'debug' | 'dev' | 'staging' | 'main'; readonly VITE_WHITELIST_MODE: string; - readonly VITE_FUUL_API_KEY: string; - readonly VITE_WAGMI_PROJECT_ID: string; + readonly VITE_GRIX_API_KEY: string; + readonly VITE_PREMIA_KEY: string; // Add other env variables as needed } From 0f7a2071cb5301f02f108ec5b39fc1dcbf5decc7 Mon Sep 17 00:00:00 2001 From: yan-gurevich-mc14 Date: Wed, 16 Apr 2025 15:40:45 +0300 Subject: [PATCH 03/11] unused scripts --- .github/scripts/check_pr_branch_name.py | 73 -------------------- .github/scripts/verify_new_member.py | 88 ------------------------- 2 files changed, 161 deletions(-) delete mode 100644 .github/scripts/check_pr_branch_name.py delete mode 100644 .github/scripts/verify_new_member.py diff --git a/.github/scripts/check_pr_branch_name.py b/.github/scripts/check_pr_branch_name.py deleted file mode 100644 index d3c5bd9..0000000 --- a/.github/scripts/check_pr_branch_name.py +++ /dev/null @@ -1,73 +0,0 @@ -import http.client -import json -import os -from urllib.parse import urlparse -import sys # Import sys for exit functionality - -branch_name = os.getenv('BRANCH_NAME', '') -pr_creator = os.getenv('PR_CREATOR', '') -webhook_url = os.getenv('DISCORD_ALERT_DEVELOP_WEBHOOK_URL', '') - -# Dynamically get repository information -github_repository = os.getenv('GITHUB_REPOSITORY', 'mc14labs/interface') # Default if not set - -# Try to get the PR number directly from an environment variable or parse it from the GitHub event path -pr_number = os.getenv('PR_NUMBER') -if not pr_number: - event_path = os.getenv('GITHUB_EVENT_PATH', '') - if event_path: - try: - with open(event_path, 'r') as event_file: - event_data = json.load(event_file) - pr_number = event_data.get('pull_request', {}).get('number') - except Exception as e: - print(f"Error reading GitHub event file: {e}") - sys.exit(1) # Exit if the PR number can't be read - -if not pr_number: - print("PR number not found.") - sys.exit(1) - -# Construct the PR URL dynamically -pr_url = f"https://github.com/{github_repository}/pull/{pr_number}" - -# Mapping from GitHub usernames to Discord user IDs -github_to_discord_mapping = { - "asalef10": "1130376965354954823", - "4tal": "459310419056525324", - "Tomelia1999": "1160224372313833472", - "galbit": "1082599634519719986", -} - -# Check for missing 'CU' prefix in branch name and alert if necessary -if 'CU' not in branch_name: - alert_message = json.dumps({ - "embeds": [ - { - "title": "Branch Naming Alert", - "description": f"Interface : Pull request for branch '{branch_name}' is missing 'CU' prefix. Created by <@{github_to_discord_mapping.get(pr_creator, pr_creator)}>. Please ensure the branch name is linked correctly to ClickUp tasks. PR URL: {pr_url}", - "color": 16711680 # Red color - } - ], - "content": f"<@{github_to_discord_mapping.get(pr_creator, pr_creator)}>" - }) - - parsed_url = urlparse(webhook_url) - connection = http.client.HTTPSConnection(parsed_url.hostname) - headers = { - "Content-Type": "application/json", - "Content-Length": str(len(alert_message)) - } - - connection.request("POST", parsed_url.path, body=alert_message, headers=headers) - response = connection.getresponse() - connection.close() - - # Handle non-success response from Discord - if response.status != 204: - print(f"Failed to send Discord webhook message, status code: {response.status}") - - print("::error::Branch naming convention violation detected.") - sys.exit(1) # Ensure script exits with a non-zero status to indicate failure - - \ No newline at end of file diff --git a/.github/scripts/verify_new_member.py b/.github/scripts/verify_new_member.py deleted file mode 100644 index 1c71339..0000000 --- a/.github/scripts/verify_new_member.py +++ /dev/null @@ -1,88 +0,0 @@ -import json -import os -import re -import sys -from glob import glob -import requests # Import the requests library - - -# Switch To Typescript. -# Verify Only One Json -# Verify Json Keys -# Split the verify member and update user (Do on PR, Do on merge) - -def is_valid_evm_address(address): - return bool(re.match(r'^0x[a-fA-F0-9]{40}$', address)) - - -def verify_file(file_path): - file_name = os.path.basename(file_path) - if not re.match(r'^[a-zA-Z0-9]+$', file_name.split('.')[0]): - print(f"File name {file_name} does not meet the naming convention.") - return False, None - - # Load and check the JSON content - with open(file_path, 'r') as file: - try: - content = json.load(file) - print(content) - except json.JSONDecodeError: - print(f"File {file_name} does not contain valid JSON.") - return False, None - - if 'evmAddress' not in content or not is_valid_evm_address(content['evmAddress']): - print(f"Invalid or missing EVM address in file {file_name}.") - return False, None - if 'githubHandle' not in content or not content['githubHandle'].strip(): - print(f"Missing or empty github handle in file {file_name}.") - return False, None - - return True, content - - -def send_content_to_backend(content): - # Replace with your actual backend URL - backend_url = "https://u6udeff7tg.execute-api.us-east-1.amazonaws.com/dev/github" - headers = {"Content-Type": "application/json"} - - try: - response = requests.post(backend_url, headers=headers, json=content) - - if response.status_code != 200: - print( - f"Failed to send data to backend. Status code: {response.status_code}") - # Exit with error status to indicate failure in sending data to the backend - sys.exit(1) - else: - print("Successfully sent data to backend.") - - except requests.exceptions.ConnectionError as e: - print(f"Failed to connect to backend. Error: {e}") - # Exit with error status to indicate failure in connecting to the backend - sys.exit(1) - except requests.exceptions.RequestException as e: - # Handles other requests-related exceptions - print(f"Request failed. Error: {e}") - sys.exit(1) - - -def main(): - new_files = glob('new members/*') - if len(new_files) == 0: - print("No new files to verify.") - sys.exit(0) # No files to process, exit normally - - file_path = new_files[0] # Assuming only one file is added per PR - verification_passed, content = verify_file(file_path) - if not verification_passed: - sys.exit(1) # Exit with error status to indicate verification failure - - # If verification passed, send the content to the backend - send_content_to_backend(content) - - print("Verification succeeded.") - sys.exit(0) - - -if __name__ == "__main__": - main() From 9ec057144d8a65f4d7a66caf8949aa364850c13b Mon Sep 17 00:00:00 2001 From: yan-gurevich-mc14 Date: Wed, 16 Apr 2025 15:42:35 +0300 Subject: [PATCH 04/11] unused --- .github/workflows/manual.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .github/workflows/manual.yml diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml deleted file mode 100644 index 6481440..0000000 --- a/.github/workflows/manual.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: PR Review Action -on: - pull_request: - types: [opened] - -jobs: - send-pr-review: - runs-on: ubuntu-latest - steps: - - name: Send PR Review Request - run: | - curl -X POST https://u6udeff7tg.execute-api.us-east-1.amazonaws.com/dev/prReview \ - -H "Content-Type: application/json" \ - -H "x-api-key: ${{ secrets.EXTERNAL_API_KEY }}" \ - -d "{ - \"prNumber\": ${{ github.event.pull_request.number }}, - \"branch\": \"${{ github.event.pull_request.head.ref }}\", - \"owner\": \"${{ github.repository_owner }}\", - \"repo\": \"${{ github.event.repository.name }}\" - }" From a9572d58541db9fe931acb8beb3dec0cfacbe231 Mon Sep 17 00:00:00 2001 From: yan-gurevich-mc14 Date: Wed, 16 Apr 2025 15:48:45 +0300 Subject: [PATCH 05/11] formatting --- .eslintrc.js | 160 ++++++++++++++++++ .prettierrc.js | 6 + favicon-old.ico | Bin 15406 -> 0 bytes playwright.config.ts | 4 +- src/api/apiKeys/useApiKeys.ts | 16 +- .../trade-agents/getAgents/useTradeAgents.ts | 3 +- src/api/tradeboard/useTradeboard.ts | 15 +- src/api/user-orders/types.ts | 5 +- src/api/user-orders/useUserOrders.ts | 17 +- .../FormControls/FormMultiSelect.tsx | 12 +- .../FormControls/FormNumberInput.tsx | 10 +- src/components/FormControls/theme.ts | 5 +- .../OptionPriceGraph/ChartTooltip.tsx | 10 +- src/components/OptionPriceGraph/DataBox.tsx | 13 +- .../OptionPriceGraph/SeriesToggle.tsx | 4 +- .../helpers/addEntryMarker.ts | 7 +- src/components/OptionPriceGraph/index.tsx | 23 +-- .../OptionPriceGraph/pnlCalculator.ts | 26 ++- .../useChart/useChartInit.tsx | 4 +- .../useChart/useChartResize.tsx | 5 +- src/components/chatbot/chatbotChat.tsx | 9 +- .../chatbot/components/chatbotMessage.tsx | 8 +- .../chatbot/pageContext/portfolioContext.ts | 4 +- .../chatbot/pageContext/signalContext.ts | 6 +- .../pageContext/tradeAgentSignalContext.ts | 3 +- .../chatbot/pageContext/tradeContext.ts | 15 +- src/components/chatbot/useSendMessage.ts | 8 +- src/components/errors/ErrorModal.tsx | 21 +-- src/components/footer/index.tsx | 31 ++-- src/components/header/HeaderRouterLink.tsx | 8 +- src/components/header/MobileNavbar.tsx | 10 +- src/components/header/useNavbarRoutes.tsx | 7 +- src/components/navigation/NavigationItem.tsx | 23 +-- src/components/navigation/SubNavigation.tsx | 20 +-- src/components/reviewOrder/constants.tsx | 6 +- .../reviewOrder/hooks/useOrderToken.ts | 4 +- src/components/reviewOrder/index.tsx | 30 ++-- src/config.ts | 4 +- src/ds/CurrencyDropdown/index.tsx | 7 +- src/ds/OptionButtonTab/index.tsx | 8 +- src/ds/OptionsContainer/index.tsx | 7 +- .../components/referenceLinesComponent.tsx | 4 +- src/ds/PNLChart/components/textComponent.tsx | 16 +- src/ds/PNLChart/generateGraphData-OLD.ts | 7 +- src/ds/PNLChart/generateGraphData.ts | 7 +- src/ds/PNLChart/index.tsx | 6 +- src/ds/SliderPicker/index.tsx | 13 +- src/ds/Table/index.tsx | 20 +-- src/ds/ToastBox/index.tsx | 11 +- src/ds/WheelPicker/hooks/useObserver.ts | 13 +- src/ds/procedureDisplay/index.tsx | 15 +- src/hooks/useIsBigScreen.ts | 3 +- src/pages/ApiKeys/ApiKeysPage.tsx | 48 +----- src/pages/ApiKeys/components/ApiKeysTable.tsx | 66 +------- .../ApiKeys/components/CreditPackageCard.tsx | 4 +- src/pages/ApiKeys/components/StatCard.tsx | 5 +- .../components/useCalculatorFields.ts | 7 +- .../components/useCalculatorTable.tsx | 14 +- src/pages/Calculator/index.tsx | 6 +- .../GuideSection/feedSection/SignalCard.tsx | 14 +- .../components/GuideSection/index.tsx | 9 +- .../shared/mainDashboardPage/index.tsx | 16 +- .../addNewAgentCard/components/StepOne.tsx | 5 +- .../addNewAgentCard/components/StepThree.tsx | 6 +- .../socialAgents/constants/templates.ts | 6 +- .../agentsSection/socialAgents/index.tsx | 9 +- .../socialAgents/instantAction/index.tsx | 13 +- .../components/ActionSignalCard.tsx | 8 +- .../components/ActivitySection.tsx | 4 +- .../components/ConfigurationSection.tsx | 4 +- .../socialAgents/selectedAgent/index.tsx | 19 +-- .../socialAgents/sidebarAgentsList/index.tsx | 21 +-- .../tradeAgentsV2/TradeAgentsV2.tsx | 10 +- .../components/AgentsList/AgentCard/index.tsx | 33 +--- .../components/AgentsList/index.tsx | 7 +- .../components/CreateAgentForm/index.tsx | 23 +-- .../SignalsList/SignalCard/index.tsx | 34 +--- .../SignalsList/hooks/useRequestMaxProfit.ts | 5 +- .../components/SignalsList/index.tsx | 25 +-- .../tradeAgentsV2/utils/agentMetrics.ts | 3 +- .../shareSignalWebhook/NotificationModal.tsx | 40 ++--- .../shareSignalWebhook/TelegramGuideModal.tsx | 22 +-- .../prepareSignalMessage.ts | 23 +-- .../featureRequestPage.tsx | 18 +- .../playbooksSection/PlaybooksMarketplace.tsx | 55 +----- .../strategiesSection/defaultView.tsx | 14 +- .../strategiesSection/designGetters.ts | 11 +- .../selectedStrategyCard.tsx | 14 +- src/pages/CalypsoHub/index.tsx | 14 +- .../CalypsoHub/navigation/NavigationItem.tsx | 9 +- src/pages/CalypsoHub/navigation/config.tsx | 12 +- .../components/ExpirationSelector.tsx | 7 +- .../components/OptionsAssetDropdown.tsx | 21 +-- .../components/StrikeOptionTableCell.tsx | 8 +- .../components/TableHeader.tsx | 16 +- .../hooks/useOptionsMatrix.tsx | 5 +- .../hooks/useOptionsMatrixTable.tsx | 27 ++- src/pages/OptionsMatrixPage/index.tsx | 28 ++- .../PointsPage/components/Leaderboard.tsx | 10 +- .../PointsPage/components/Milestones.tsx | 8 +- .../PointsPage/components/MyPointsHistory.tsx | 4 +- .../PointsPage/components/TradeAndEarn.tsx | 17 +- src/pages/PointsPage/hooks/useUserPoints.ts | 5 +- src/pages/PointsPage/index.tsx | 9 +- .../OrdersTable/GenericTableCell.tsx | 12 +- .../PortfolioPage/OrdersTable/columns.tsx | 55 ++---- .../OrdersTable/columnsHelpers.tsx | 9 +- .../PortfolioPage/OrdersTable/helpers.ts | 3 +- .../PortfolioPage/OrdersTable/noResults.tsx | 6 +- src/pages/PortfolioPage/index.tsx | 6 +- src/pages/StatsPage/index.tsx | 24 +-- src/pages/StatsPage/statsComponents.tsx | 16 +- src/pages/StatsPage/types.ts | 6 +- .../StatusPage/components/LinkComponent.tsx | 4 +- .../components/NodeTextComponent.tsx | 9 +- .../helpers/generateGraphComponents.ts | 7 +- src/pages/StatusPage/helpers/processData.ts | 9 +- .../components/NetworkAvailability.tsx | 8 +- .../components/PillarMarketplace.tsx | 83 ++------- .../components/TokenPageComponents.tsx | 11 +- .../components/TokenPageSections.tsx | 29 ++-- src/pages/TokenPage/index.tsx | 23 +-- src/pages/TokenPage/renderTokenPageExtras.tsx | 88 +++------- .../TokenPage/renderTokenPageSections.tsx | 51 +----- src/pages/TradePage/TradeForm.tsx | 11 +- .../components/ExpirationDatePicker.tsx | 17 +- .../OptionPicker/OptionPriceList.tsx | 16 +- .../components/StrikePricePicker.tsx | 31 +--- .../TradePage/components/SuggestionBadge.tsx | 13 +- .../components/submitPurchaseButton.tsx | 6 +- .../hooks/useExecuteProtocolRequest.ts | 8 +- .../hooks/useExercisePositionRequest.ts | 22 ++- .../TradePage/hooks/useOnProtocolSubmit.tsx | 6 +- src/pages/deBridgePage/deBridge.tsx | 4 +- .../stakingPage/components/RewardsCard.tsx | 4 +- .../stakingPage/components/StakingCard.tsx | 8 +- .../components/StakingCardContent.tsx | 24 +-- .../stakingPage/components/VestingCard.tsx | 15 +- .../VestingComponents/VestingInfo.tsx | 3 +- .../VestingComponents/VestingStats.tsx | 8 +- src/pages/stakingPage/index.tsx | 9 +- .../UnderDevelopment.tsx | 21 +-- src/services/analytics/types.ts | 4 +- src/utils/FuulSDK/FuulFunctions.ts | 7 +- src/utils/optionKey/generateOptionKey.ts | 4 +- src/utils/web3Util.ts | 15 +- src/web3Config/premia/fillQuote.ts | 6 +- src/web3Config/reownConfig.ts | 2 +- src/widgets/cowswap/index.tsx | 7 +- tests/drivers/TradePage.driver.ts | 5 +- tests/integrations/CoreApp.spec.ts | 5 +- vite-env.d.ts | 1 - 152 files changed, 783 insertions(+), 1478 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .prettierrc.js delete mode 100644 favicon-old.ico diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..0396745 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,160 @@ +const excludeFolders = ['node_modules', 'build', 'dist', '']; +const excludedFiles = `**/(${excludeFolders.join('|')})/**`; + +module.exports = { + env: { + browser: true, + es6: true, + }, + parserOptions: { + project: ['tsconfig.json'], + }, + root: true, + ignorePatterns: excludeFolders.map((folder) => `**/${folder}/**`), + extends: [ + 'eslint:recommended', + 'plugin:import/recommended', + 'plugin:json/recommended', + 'plugin:react/recommended', + 'plugin:react-hooks/recommended', + 'prettier', + ], + rules: { + '@typescript-eslint/no-misused-promises': 'off', + 'object-shorthand': 'error', + 'simple-import-sort/imports': 'error', + 'simple-import-sort/exports': 'error', + 'import/no-cycle': [ + 2, + { + ignoreExternal: false, + maxDepth: 3, + }, + ], + 'import/no-absolute-path': 'error', + 'import/no-dynamic-require': 'error', + 'import/no-self-import': 'error', + 'import/no-useless-path-segments': 'error', + 'import/no-named-as-default': 'error', + 'import/no-named-as-default-member': 'error', + 'import/no-deprecated': 'off', + 'import/no-default-export': 'error', + 'react/prop-types': 'off', + 'react/react-in-jsx-scope': 'off', + 'react/jsx-curly-brace-presence': ['error', 'never'], + 'react/display-name': 'off', + 'one-var': ['error', 'never'], + 'no-console': 'error', + 'no-alert': 'error', + 'arrow-body-style': 'error', + 'object-curly-newline': [ + 'error', + { + ObjectExpression: { + multiline: true, + consistent: true, + }, + ObjectPattern: { + multiline: true, + consistent: true, + }, + ImportDeclaration: { + multiline: true, + consistent: true, + }, + ExportDeclaration: { + multiline: true, + consistent: true, + }, + }, + ], + 'max-len': [ + 'error', + { + code: 120, + ignoreUrls: true, + ignoreStrings: true, + ignoreRegExpLiterals: true, + ignoreComments: true, + ignoreTemplateLiterals: true, + }, + ], + 'max-lines': 'error', + radix: 'error', + 'react-hooks/exhaustive-deps': 'error', + 'react/jsx-boolean-value': 'error', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + vars: 'all', + args: 'after-used', + ignoreRestSiblings: true, + varsIgnorePattern: '^_', + argsIgnorePattern: '^_' + } + ], + }, + overrides: [ + { + files: ['**/*.spec.*'], + plugins: ['jest', 'jest-dom', 'no-only-tests'], + extends: ['plugin:jest/recommended', 'plugin:jest/style', 'plugin:jest-dom/recommended'], + rules: { + 'jest/consistent-test-it': [ + 'error', + { + fn: 'it', + }, + ], + 'jest/no-focused-tests': 'off', + 'jest/no-disabled-tests': 'off', + 'jest/expect-expect': 'off', + 'no-only-tests/no-only-tests': [ + 'error', + { + block: ['it', 'specify', 'describe'], + focus: ['only', 'skip'], + }, + ], + }, + excludedFiles, + env: { + jest: true, + }, + }, + { + files: ['**/*.ts', '**/*.tsx'], + excludedFiles, + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint', 'simple-import-sort'], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'plugin:import/typescript', + ], + rules: { + '@typescript-eslint/no-redundant-type-constituents': 'off', + '@typescript-eslint/naming-convention': [ + 'error', + { + selector: 'typeLike', + format: ['PascalCase'], + }, + ], + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'error', + '@typescript-eslint/prefer-optional-chain': 'error', + '@typescript-eslint/consistent-type-definitions': ['error', 'type'], + '@typescript-eslint/no-non-null-assertion': 'error', + }, + }, + ], + settings: { + react: { + version: 'detect', + }, + 'import/resolver': { + typescript: {}, + }, + }, +}; diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..6b1bcf1 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,6 @@ +module.exports = { + trailingComma: "es5", + tabWidth: 2, + singleQuote: true, + printWidth: 140, +}; diff --git a/favicon-old.ico b/favicon-old.ico deleted file mode 100644 index f98f9a4370567716e4593eab39f0d72854deb59b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15406 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 t!`5 { args: [CREDIT_PAYMENT_ADDRESS as Address, priceInUsdcWei], }); - const approveReceipt = await publicClient.waitForTransactionReceipt({ hash: approveTx }); + const approveReceipt = await publicClient.waitForTransactionReceipt({ + hash: approveTx, + }); if (!approveReceipt.status) throw new Error('Approval failed'); // Finally process payment with credit amount and keyId @@ -131,7 +133,9 @@ export const useCreateApiKey = () => { args: [USDC_ADDRESS, BigInt(creditAmount), keyId], }); - const payReceipt = await publicClient.waitForTransactionReceipt({ hash: payTx }); + const payReceipt = await publicClient.waitForTransactionReceipt({ + hash: payTx, + }); if (!payReceipt.status) throw new Error('Payment failed'); // After successful payment, send POST request to initiate API payment @@ -187,7 +191,9 @@ export const useRechargeApiKey = () => { args: [CREDIT_PAYMENT_ADDRESS as Address, priceInUsdcWei], }); - const approveReceipt = await publicClient.waitForTransactionReceipt({ hash: approveTx }); + const approveReceipt = await publicClient.waitForTransactionReceipt({ + hash: approveTx, + }); if (!approveReceipt.status) throw new Error('Approval failed'); // Finally process payment with credit amount and keyId @@ -198,7 +204,9 @@ export const useRechargeApiKey = () => { args: [USDC_ADDRESS, BigInt(creditAmount), keyId], }); - const payReceipt = await publicClient.waitForTransactionReceipt({ hash: payTx }); + const payReceipt = await publicClient.waitForTransactionReceipt({ + hash: payTx, + }); if (!payReceipt.status) throw new Error('Payment failed'); // After successful payment, send POST request to initiate API payment diff --git a/src/api/trade-agents/getAgents/useTradeAgents.ts b/src/api/trade-agents/getAgents/useTradeAgents.ts index 31c21eb..1a58ecf 100644 --- a/src/api/trade-agents/getAgents/useTradeAgents.ts +++ b/src/api/trade-agents/getAgents/useTradeAgents.ts @@ -17,8 +17,7 @@ export const useTradeAgents = ({ address }: TradeAgentsGetRequest) => } const hasRunningRequests = agents.personalAgents.some( (agent) => - agent.signal_requests.some((request) => request.progress !== RequestProgress.completed) && - agent.status === AgentStatus.active + agent.signal_requests.some((request) => request.progress !== RequestProgress.completed) && agent.status === AgentStatus.active ); return hasRunningRequests ? msValues.second * 2 : msValues.second * 10; }, diff --git a/src/api/tradeboard/useTradeboard.ts b/src/api/tradeboard/useTradeboard.ts index 29c6797..5eacd8c 100644 --- a/src/api/tradeboard/useTradeboard.ts +++ b/src/api/tradeboard/useTradeboard.ts @@ -22,7 +22,13 @@ export const useTradeboard = ({ }) => { const { data, isLoading, isError, error, isFetching } = useQuery({ queryKey: ['tradeboard', asset, optionType, positionType, shouldFilterExecutionProtocols], - queryFn: () => fetchTradeboard({ shouldFilterExecutionProtocols, positionType, optionType, asset }), + queryFn: () => + fetchTradeboard({ + shouldFilterExecutionProtocols, + positionType, + optionType, + asset, + }), enabled: !!asset && !!optionType && !!positionType, refetchInterval, }); @@ -44,8 +50,7 @@ export const fetchTradeboard = async ({ asset: SupportedAsset; }) => { const protocolsFilter = - protocols ?? - protocolsArrayData.filter((p) => !shouldFilterExecutionProtocols || p.isExecution).map((p) => p.protocolName); + protocols ?? protocolsArrayData.filter((p) => !shouldFilterExecutionProtocols || p.isExecution).map((p) => p.protocolName); const filters: TradeboardQueryFilters = { positionType, @@ -53,6 +58,8 @@ export const fetchTradeboard = async ({ asset, protocols: protocolsFilter.join(','), }; - const response = await apiClient.get(`/tradeboard`, { params: filters }); + const response = await apiClient.get(`/tradeboard`, { + params: filters, + }); return response.data; }; diff --git a/src/api/user-orders/types.ts b/src/api/user-orders/types.ts index 342c732..58433af 100644 --- a/src/api/user-orders/types.ts +++ b/src/api/user-orders/types.ts @@ -84,4 +84,7 @@ export type UserOrdersParams = { fetchAll?: boolean; }; -export type UserOrdersCountParams = { type: UserOrderType; userAddress?: string }; +export type UserOrdersCountParams = { + type: UserOrderType; + userAddress?: string; +}; diff --git a/src/api/user-orders/useUserOrders.ts b/src/api/user-orders/useUserOrders.ts index eef912d..244f512 100644 --- a/src/api/user-orders/useUserOrders.ts +++ b/src/api/user-orders/useUserOrders.ts @@ -6,21 +6,16 @@ import { apiClient } from '@/services/apiClient'; import { PaginatedResponse, UserOrdersCountParams, UserOrdersParams, UserOrderType, UserRequest } from './types'; const queryKey = { - list: ({ userAddress, type, limit, offset, fetchAll }: UserOrdersParams) => [ - 'user-orders', - userAddress, - type, - limit, - offset, - fetchAll, - ], + list: ({ userAddress, type, limit, offset, fetchAll }: UserOrdersParams) => ['user-orders', userAddress, type, limit, offset, fetchAll], totalCount: ({ userAddress, type }: UserOrdersCountParams) => ['user-orders-count', userAddress, type], }; const queryFn = async (url: string, fetchAll: boolean, userAddress?: string, limit?: number, offset?: number) => { const params = fetchAll ? { limit: 50 } : { user_account: userAddress, limit, offset }; - const response = await apiClient.get>(url, { params }); + const response = await apiClient.get>(url, { + params, + }); return response.data; }; @@ -43,7 +38,9 @@ export const useUserOrders = ( ) => { const queryClient = useQueryClient(); useEffect(() => { - void queryClient.invalidateQueries({ queryKey: queryKey.totalCount({ userAddress, type }) }); + void queryClient.invalidateQueries({ + queryKey: queryKey.totalCount({ userAddress, type }), + }); }, [queryClient, userAddress, type, limit, offset, fetchAll]); return useQuery({ diff --git a/src/components/FormControls/FormMultiSelect.tsx b/src/components/FormControls/FormMultiSelect.tsx index 64ec4eb..361103f 100644 --- a/src/components/FormControls/FormMultiSelect.tsx +++ b/src/components/FormControls/FormMultiSelect.tsx @@ -30,9 +30,7 @@ export const FormMultiSelect: React.FC = ({ isRequired = false, }) => { const handleToggle = (value: string) => { - const newValues = selectedValues.includes(value) - ? selectedValues.filter((v) => v !== value) - : [...selectedValues, value]; + const newValues = selectedValues.includes(value) ? selectedValues.filter((v) => v !== value) : [...selectedValues, value]; onChange(newValues); }; @@ -58,13 +56,7 @@ export const FormMultiSelect: React.FC = ({ color={formControlStyles.label.color} borderWidth={0} onClick={() => handleToggle(value)} - leftIcon={ - iconUrl ? ( - - ) : ( - icon || undefined - ) - } + leftIcon={iconUrl ? : icon || undefined} > {optionLabel} diff --git a/src/components/FormControls/FormNumberInput.tsx b/src/components/FormControls/FormNumberInput.tsx index 50fdef0..53f2e60 100644 --- a/src/components/FormControls/FormNumberInput.tsx +++ b/src/components/FormControls/FormNumberInput.tsx @@ -1,12 +1,4 @@ -import { - FormControl, - FormErrorMessage, - FormLabel, - HStack, - NumberInput, - NumberInputField, - Text, -} from '@chakra-ui/react'; +import { FormControl, FormErrorMessage, FormLabel, HStack, NumberInput, NumberInputField, Text } from '@chakra-ui/react'; import { formControlStyles } from './theme'; diff --git a/src/components/FormControls/theme.ts b/src/components/FormControls/theme.ts index 969da00..4ec997a 100644 --- a/src/components/FormControls/theme.ts +++ b/src/components/FormControls/theme.ts @@ -3,7 +3,10 @@ export const formControlStyles = { bg: 'whiteAlpha.50', borderColor: 'whiteAlpha.200', _hover: { borderColor: 'whiteAlpha.400' }, - _focus: { borderColor: 'blue.400', boxShadow: '0 0 0 1px var(--chakra-colors-blue-400)' }, + _focus: { + borderColor: 'blue.400', + boxShadow: '0 0 0 1px var(--chakra-colors-blue-400)', + }, }, button: { selected: { diff --git a/src/components/OptionPriceGraph/ChartTooltip.tsx b/src/components/OptionPriceGraph/ChartTooltip.tsx index 4e4783a..39b13e0 100644 --- a/src/components/OptionPriceGraph/ChartTooltip.tsx +++ b/src/components/OptionPriceGraph/ChartTooltip.tsx @@ -52,15 +52,7 @@ const TooltipContent = ({ series, seriesData, time }: TooltipContentProps) => { }; const TooltipContainer = ({ children }: { children: React.ReactNode }) => ( - + {children} ); diff --git a/src/components/OptionPriceGraph/DataBox.tsx b/src/components/OptionPriceGraph/DataBox.tsx index dcb4adc..82ac322 100644 --- a/src/components/OptionPriceGraph/DataBox.tsx +++ b/src/components/OptionPriceGraph/DataBox.tsx @@ -65,18 +65,9 @@ export const DataBox: React.FC = ({ title, hoveredData, borderColo - + - {protocol && ( - {protocol.label} - )} + {protocol && {protocol.label}} {quote ? protocol?.label || quote.protocol : '-'} diff --git a/src/components/OptionPriceGraph/SeriesToggle.tsx b/src/components/OptionPriceGraph/SeriesToggle.tsx index 643eb46..c4811d1 100644 --- a/src/components/OptionPriceGraph/SeriesToggle.tsx +++ b/src/components/OptionPriceGraph/SeriesToggle.tsx @@ -16,9 +16,7 @@ export const SeriesToggle: React.FC = ({ seriesConfigs, onTog