diff --git a/CHANGELOG.md b/CHANGELOG.md index 46816bf..c6c9ad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Bug Fixes -* **ci:** remove explicit pnpm version to avoid packageManager conflict ([f6d4724](https://github.com/ReineiraOS/platform-modules/commit/f6d4724e84aaa3a1a085eba2f9922fec148192ae)) +- **ci:** remove explicit pnpm version to avoid packageManager conflict ([f6d4724](https://github.com/ReineiraOS/platform-modules/commit/f6d4724e84aaa3a1a085eba2f9922fec148192ae)) # Changelog diff --git a/eslint.config.js b/eslint.config.js index cc2269f..989ad84 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,18 +1,12 @@ -import eslint from "@eslint/js"; -import tseslint from "typescript-eslint"; -import reactHooks from "eslint-plugin-react-hooks"; -import reactRefresh from "eslint-plugin-react-refresh"; -import globals from "globals"; +import eslint from '@eslint/js'; +import tseslint from 'typescript-eslint'; +import reactHooks from 'eslint-plugin-react-hooks'; +import reactRefresh from 'eslint-plugin-react-refresh'; +import globals from 'globals'; export default tseslint.config( { - ignores: [ - "**/dist/**", - "**/node_modules/**", - "**/drizzle/**", - "**/src/generated/**", - "**/*.gen.*", - ], + ignores: ['**/dist/**', '**/node_modules/**', '**/drizzle/**', '**/src/generated/**', '**/*.gen.*'], }, eslint.configs.recommended, @@ -25,22 +19,19 @@ export default tseslint.config( }, }, rules: { - "@typescript-eslint/no-unused-vars": [ - "warn", - { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, - ], - "@typescript-eslint/no-explicit-any": "warn", - "@typescript-eslint/no-empty-object-type": "off", - "@typescript-eslint/no-require-imports": "off", - "@typescript-eslint/no-non-null-asserted-optional-chain": "warn", - "no-empty": "warn", - "no-loss-of-precision": "off", - "preserve-caught-error": "off", + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-require-imports': 'off', + '@typescript-eslint/no-non-null-asserted-optional-chain': 'warn', + 'no-empty': 'warn', + 'no-loss-of-precision': 'off', + 'preserve-caught-error': 'off', }, }, { - files: ["packages/backend/**/*.ts"], + files: ['packages/backend/**/*.ts'], languageOptions: { globals: { ...globals.node, @@ -49,10 +40,10 @@ export default tseslint.config( }, { - files: ["packages/app/**/*.{ts,tsx}"], + files: ['packages/app/**/*.{ts,tsx}'], plugins: { - "react-hooks": reactHooks, - "react-refresh": reactRefresh, + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, }, languageOptions: { globals: { @@ -61,12 +52,9 @@ export default tseslint.config( }, rules: { ...reactHooks.configs.recommended.rules, - "react-hooks/set-state-in-effect": "warn", - "react-hooks/refs": "warn", - "react-refresh/only-export-components": [ - "warn", - { allowConstantExport: true }, - ], + 'react-hooks/set-state-in-effect': 'warn', + 'react-hooks/refs': 'warn', + 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], }, }, ); diff --git a/packages/backend/openapi.json b/packages/backend/openapi.json index 5188363..2b0f6ad 100644 --- a/packages/backend/openapi.json +++ b/packages/backend/openapi.json @@ -20,9 +20,7 @@ "/auth/wallet/nonce": { "post": { "operationId": "requestNonce", - "tags": [ - "Auth" - ], + "tags": ["Auth"], "summary": "Request authentication nonce", "security": [], "requestBody": { @@ -36,9 +34,7 @@ "pattern": "^0x[a-fA-F0-9]{40}$" } }, - "required": [ - "wallet_address" - ] + "required": ["wallet_address"] } } } @@ -55,9 +51,7 @@ "type": "string" } }, - "required": [ - "nonce" - ] + "required": ["nonce"] } } } @@ -79,11 +73,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -94,9 +84,7 @@ "/auth/wallet/verify": { "post": { "operationId": "verifyWallet", - "tags": [ - "Auth" - ], + "tags": ["Auth"], "summary": "Verify wallet signature", "security": [], "requestBody": { @@ -122,11 +110,7 @@ "format": "email" } }, - "required": [ - "wallet_address", - "message", - "signature" - ] + "required": ["wallet_address", "message", "signature"] } } } @@ -153,12 +137,7 @@ "type": "number" } }, - "required": [ - "access_token", - "refresh_token", - "token_type", - "expires_in" - ] + "required": ["access_token", "refresh_token", "token_type", "expires_in"] } } } @@ -180,11 +159,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -206,11 +181,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -221,9 +192,7 @@ "/auth/tokens/refresh": { "post": { "operationId": "refreshToken", - "tags": [ - "Auth" - ], + "tags": ["Auth"], "summary": "Refresh access token", "security": [], "requestBody": { @@ -237,9 +206,7 @@ "minLength": 1 } }, - "required": [ - "refresh_token" - ] + "required": ["refresh_token"] } } } @@ -266,12 +233,7 @@ "type": "number" } }, - "required": [ - "access_token", - "refresh_token", - "token_type", - "expires_in" - ] + "required": ["access_token", "refresh_token", "token_type", "expires_in"] } } } @@ -293,11 +255,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -308,9 +266,7 @@ "/auth/tokens": { "post": { "operationId": "logout", - "tags": [ - "Auth" - ], + "tags": ["Auth"], "summary": "Revoke tokens (logout)", "security": [ { @@ -338,11 +294,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -353,9 +305,7 @@ "/escrows": { "post": { "operationId": "createEscrow", - "tags": [ - "Escrow" - ], + "tags": ["Escrow"], "summary": "Create a new escrow", "security": [ { @@ -393,31 +343,21 @@ "properties": { "type": { "type": "string", - "enum": [ - "fiat", - "crypto" - ] + "enum": ["fiat", "crypto"] }, "code": { "type": "string", "minLength": 1 } }, - "required": [ - "type", - "code" - ] + "required": ["type", "code"] }, "metadata": { "type": "object", "additionalProperties": {} } }, - "required": [ - "type", - "amount", - "currency" - ] + "required": ["type", "amount", "currency"] } } } @@ -487,20 +427,10 @@ "type": "string" } }, - "required": [ - "encrypted_owner", - "encrypted_amount", - "resolver", - "resolver_data" - ] + "required": ["encrypted_owner", "encrypted_amount", "resolver", "resolver_data"] } }, - "required": [ - "public_id", - "contract_address", - "abi_function_signature", - "abi_parameters" - ] + "required": ["public_id", "contract_address", "abi_function_signature", "abi_parameters"] } } } @@ -522,11 +452,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -548,11 +474,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -561,9 +483,7 @@ }, "get": { "operationId": "listEscrows", - "tags": [ - "Escrow" - ], + "tags": ["Escrow"], "summary": "List escrows for current user", "security": [ { @@ -631,19 +551,13 @@ "properties": { "type": { "type": "string", - "enum": [ - "fiat", - "crypto" - ] + "enum": ["fiat", "crypto"] }, "code": { "type": "string" } }, - "required": [ - "type", - "code" - ] + "required": ["type", "code"] }, "status": { "type": "string" @@ -662,14 +576,7 @@ "type": "string" } }, - "required": [ - "public_id", - "type", - "amount", - "currency", - "status", - "created_at" - ] + "required": ["public_id", "type", "amount", "currency", "status", "created_at"] } }, "continuation_token": { @@ -682,11 +589,7 @@ "type": "number" } }, - "required": [ - "items", - "has_more", - "limit" - ] + "required": ["items", "has_more", "limit"] } } } @@ -708,11 +611,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -723,9 +622,7 @@ "/escrows/{publicId}": { "get": { "operationId": "getEscrow", - "tags": [ - "Escrow" - ], + "tags": ["Escrow"], "summary": "Get escrow by public ID", "security": [ { @@ -773,19 +670,13 @@ "properties": { "type": { "type": "string", - "enum": [ - "fiat", - "crypto" - ] + "enum": ["fiat", "crypto"] }, "code": { "type": "string" } }, - "required": [ - "type", - "code" - ] + "required": ["type", "code"] }, "status": { "type": "string" @@ -804,14 +695,7 @@ "type": "string" } }, - "required": [ - "public_id", - "type", - "amount", - "currency", - "status", - "created_at" - ] + "required": ["public_id", "type", "amount", "currency", "status", "created_at"] } } } @@ -833,11 +717,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -859,11 +739,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -874,9 +750,7 @@ "/public/escrows/{publicId}": { "get": { "operationId": "getPublicEscrow", - "tags": [ - "Escrow" - ], + "tags": ["Escrow"], "summary": "Get public escrow details (no auth required)", "security": [], "parameters": [ @@ -923,19 +797,13 @@ "properties": { "type": { "type": "string", - "enum": [ - "fiat", - "crypto" - ] + "enum": ["fiat", "crypto"] }, "code": { "type": "string" } }, - "required": [ - "type", - "code" - ] + "required": ["type", "code"] }, "status": { "type": "string" @@ -977,11 +845,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -992,9 +856,7 @@ "/withdrawals": { "post": { "operationId": "createWithdrawal", - "tags": [ - "Withdrawal" - ], + "tags": ["Withdrawal"], "summary": "Create a new withdrawal", "security": [ { @@ -1017,22 +879,14 @@ }, "destination_chain": { "type": "string", - "enum": [ - "BASE", - "ETH", - "POLYGON" - ] + "enum": ["BASE", "ETH", "POLYGON"] }, "recipient_address": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" } }, - "required": [ - "escrow_ids", - "destination_chain", - "recipient_address" - ] + "required": ["escrow_ids", "destination_chain", "recipient_address"] } } } @@ -1064,11 +918,7 @@ "additionalProperties": {} } }, - "required": [ - "contract_address", - "abi_function_signature", - "abi_parameters" - ] + "required": ["contract_address", "abi_function_signature", "abi_parameters"] } }, "status": { @@ -1078,12 +928,7 @@ "type": "number" } }, - "required": [ - "public_id", - "calls", - "status", - "estimated_amount" - ] + "required": ["public_id", "calls", "status", "estimated_amount"] } } } @@ -1105,11 +950,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1131,11 +972,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1144,9 +981,7 @@ }, "get": { "operationId": "listWithdrawals", - "tags": [ - "Withdrawal" - ], + "tags": ["Withdrawal"], "summary": "List withdrawals for current user", "security": [ { @@ -1262,11 +1097,7 @@ "type": "number" } }, - "required": [ - "items", - "has_more", - "limit" - ] + "required": ["items", "has_more", "limit"] } } } @@ -1288,11 +1119,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1303,9 +1130,7 @@ "/withdrawals/{publicId}": { "get": { "operationId": "getWithdrawal", - "tags": [ - "Withdrawal" - ], + "tags": ["Withdrawal"], "summary": "Get withdrawal by public ID", "security": [ { @@ -1410,11 +1235,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1436,11 +1257,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1451,9 +1268,7 @@ "/withdrawals/{publicId}/bridge-readiness": { "get": { "operationId": "checkBridgeReadiness", - "tags": [ - "Withdrawal" - ], + "tags": ["Withdrawal"], "summary": "Check if withdrawal is ready for bridging", "security": [ { @@ -1488,11 +1303,7 @@ "type": "string" } }, - "required": [ - "public_id", - "ready", - "status" - ] + "required": ["public_id", "ready", "status"] } } } @@ -1514,11 +1325,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1540,11 +1347,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1555,9 +1358,7 @@ "/withdrawals/{publicId}/bridge-challenge": { "post": { "operationId": "createBridgeChallenge", - "tags": [ - "Withdrawal" - ], + "tags": ["Withdrawal"], "summary": "Initiate bridge challenge for withdrawal", "security": [ { @@ -1592,10 +1393,7 @@ "type": "number" } }, - "required": [ - "public_id", - "status" - ] + "required": ["public_id", "status"] } } } @@ -1617,11 +1415,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1643,11 +1437,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1669,11 +1459,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1684,9 +1470,7 @@ "/users/me": { "get": { "operationId": "getCurrentUser", - "tags": [ - "User" - ], + "tags": ["User"], "summary": "Get current authenticated user", "security": [ { @@ -1717,12 +1501,7 @@ "type": "string" } }, - "required": [ - "id", - "wallet_address", - "wallet_provider", - "created_at" - ] + "required": ["id", "wallet_address", "wallet_provider", "created_at"] } } } @@ -1744,11 +1523,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1759,9 +1534,7 @@ "/balance": { "get": { "operationId": "getBalance", - "tags": [ - "Balance" - ], + "tags": ["Balance"], "summary": "Get wallet balance", "security": [ { @@ -1792,13 +1565,7 @@ "type": "number" } }, - "required": [ - "wallet_address", - "balance", - "formatted_balance", - "currency", - "chain_id" - ] + "required": ["wallet_address", "balance", "formatted_balance", "currency", "chain_id"] } } } @@ -1820,11 +1587,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1835,9 +1598,7 @@ "/business-profiles": { "post": { "operationId": "createBusinessProfile", - "tags": [ - "Business Profile" - ], + "tags": ["Business Profile"], "summary": "Create a business profile", "security": [ { @@ -1857,10 +1618,7 @@ }, "business_type": { "type": "string", - "enum": [ - "RETAIL", - "SERVICE" - ] + "enum": ["RETAIL", "SERVICE"] }, "business_address": { "type": "string", @@ -1871,10 +1629,7 @@ "maxLength": 50 } }, - "required": [ - "business_name", - "business_type" - ] + "required": ["business_name", "business_type"] } } } @@ -1903,11 +1658,7 @@ "type": "string" } }, - "required": [ - "id", - "business_name", - "business_type" - ] + "required": ["id", "business_name", "business_type"] } } } @@ -1929,11 +1680,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1955,11 +1702,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -1970,9 +1713,7 @@ "/api-credentials": { "post": { "operationId": "generateCredentials", - "tags": [ - "Credentials" - ], + "tags": ["Credentials"], "summary": "Generate new API credentials", "security": [ { @@ -2000,12 +1741,7 @@ "type": "string" } }, - "required": [ - "client_id", - "client_secret", - "status", - "created_at" - ] + "required": ["client_id", "client_secret", "status", "created_at"] } } } @@ -2027,11 +1763,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2040,9 +1772,7 @@ }, "get": { "operationId": "listCredentials", - "tags": [ - "Credentials" - ], + "tags": ["Credentials"], "summary": "List API credentials", "security": [ { @@ -2075,17 +1805,11 @@ "type": "string" } }, - "required": [ - "client_id", - "status", - "created_at" - ] + "required": ["client_id", "status", "created_at"] } } }, - "required": [ - "credentials" - ] + "required": ["credentials"] } } } @@ -2107,11 +1831,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2122,9 +1842,7 @@ "/api-credentials/{clientId}": { "delete": { "operationId": "revokeCredentials", - "tags": [ - "Credentials" - ], + "tags": ["Credentials"], "summary": "Revoke API credentials", "security": [ { @@ -2162,11 +1880,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2188,11 +1902,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2203,9 +1913,7 @@ "/api-credentials/oauth/token": { "post": { "operationId": "oauthTokenExchange", - "tags": [ - "Credentials" - ], + "tags": ["Credentials"], "summary": "Exchange client credentials for access token", "security": [], "requestBody": { @@ -2227,11 +1935,7 @@ "minLength": 1 } }, - "required": [ - "grant_type", - "client_id", - "client_secret" - ] + "required": ["grant_type", "client_id", "client_secret"] } } } @@ -2255,11 +1959,7 @@ "type": "number" } }, - "required": [ - "access_token", - "token_type", - "expires_in" - ] + "required": ["access_token", "token_type", "expires_in"] } } } @@ -2281,11 +1981,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2307,11 +2003,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2322,9 +2014,7 @@ "/transactions/escrows/report": { "post": { "operationId": "reportEscrowTransaction", - "tags": [ - "Transactions" - ], + "tags": ["Transactions"], "summary": "Report an escrow transaction hash", "security": [ { @@ -2346,10 +2036,7 @@ "minLength": 1 } }, - "required": [ - "tx_hash", - "entity_id" - ] + "required": ["tx_hash", "entity_id"] } } } @@ -2372,11 +2059,7 @@ "type": "string" } }, - "required": [ - "entity_id", - "tx_hash", - "status" - ] + "required": ["entity_id", "tx_hash", "status"] } } } @@ -2398,11 +2081,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2424,11 +2103,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2439,9 +2114,7 @@ "/transactions/withdrawals/report": { "post": { "operationId": "reportWithdrawalTransaction", - "tags": [ - "Transactions" - ], + "tags": ["Transactions"], "summary": "Report a withdrawal transaction hash", "security": [ { @@ -2460,16 +2133,10 @@ }, "step": { "type": "string", - "enum": [ - "redeem", - "bridge" - ] + "enum": ["redeem", "bridge"] } }, - "required": [ - "tx_hash", - "step" - ] + "required": ["tx_hash", "step"] } } } @@ -2492,11 +2159,7 @@ "type": "string" } }, - "required": [ - "entity_id", - "tx_hash", - "status" - ] + "required": ["entity_id", "tx_hash", "status"] } } } @@ -2518,11 +2181,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2544,11 +2203,7 @@ "type": "number" } }, - "required": [ - "error", - "message", - "statusCode" - ] + "required": ["error", "message", "statusCode"] } } } @@ -2559,9 +2214,7 @@ "/webhooks/quicknode": { "post": { "operationId": "quicknodeWebhook", - "tags": [ - "Webhooks" - ], + "tags": ["Webhooks"], "summary": "QuickNode event webhook receiver", "security": [], "responses": { @@ -2574,9 +2227,7 @@ "/webhooks/relay-callback": { "post": { "operationId": "relayCallbackWebhook", - "tags": [ - "Webhooks" - ], + "tags": ["Webhooks"], "summary": "Relay operator callback webhook", "security": [], "responses": { diff --git a/packages/backend/src/infrastructure/repository/postgres/db.ts b/packages/backend/src/infrastructure/repository/postgres/db.ts index 279d35b..509705a 100644 --- a/packages/backend/src/infrastructure/repository/postgres/db.ts +++ b/packages/backend/src/infrastructure/repository/postgres/db.ts @@ -10,8 +10,7 @@ let _db: Db | null = null; export function getDb(): Db { if (!_db) { const url = getEnv().DATABASE_URL; - if (!url) - throw new Error('DATABASE_URL is required when DB_PROVIDER is postgres'); + if (!url) throw new Error('DATABASE_URL is required when DB_PROVIDER is postgres'); const sql = neon(url); _db = drizzle(sql, { schema }); } diff --git a/packages/backend/src/infrastructure/repository/postgres/pg-api-credential.repository.ts b/packages/backend/src/infrastructure/repository/postgres/pg-api-credential.repository.ts index f5542f1..4e66313 100644 --- a/packages/backend/src/infrastructure/repository/postgres/pg-api-credential.repository.ts +++ b/packages/backend/src/infrastructure/repository/postgres/pg-api-credential.repository.ts @@ -1,9 +1,6 @@ import { eq } from 'drizzle-orm'; import type { IApiCredentialRepository } from '../../../domain/api-credential/repository/api-credential.repository.js'; -import { - ApiCredential, - type ApiCredentialStatus, -} from '../../../domain/api-credential/model/api-credential.js'; +import { ApiCredential, type ApiCredentialStatus } from '../../../domain/api-credential/model/api-credential.js'; import { apiCredentials } from './schema.js'; import type { Db } from './db.js'; diff --git a/packages/backend/src/infrastructure/repository/postgres/pg-business-profile.repository.ts b/packages/backend/src/infrastructure/repository/postgres/pg-business-profile.repository.ts index 3f7a1c2..1968028 100644 --- a/packages/backend/src/infrastructure/repository/postgres/pg-business-profile.repository.ts +++ b/packages/backend/src/infrastructure/repository/postgres/pg-business-profile.repository.ts @@ -1,15 +1,10 @@ import { eq } from 'drizzle-orm'; import type { IBusinessProfileRepository } from '../../../domain/business-profile/repository/business-profile.repository.js'; -import { - BusinessProfile, - type BusinessType, -} from '../../../domain/business-profile/model/business-profile.js'; +import { BusinessProfile, type BusinessType } from '../../../domain/business-profile/model/business-profile.js'; import { businessProfiles } from './schema.js'; import type { Db } from './db.js'; -export class PgBusinessProfileRepository - implements IBusinessProfileRepository -{ +export class PgBusinessProfileRepository implements IBusinessProfileRepository { constructor(private readonly db: Db) {} async findByUserId(userId: string): Promise { @@ -41,9 +36,7 @@ export class PgBusinessProfileRepository }); } - private toDomain( - row: typeof businessProfiles.$inferSelect, - ): BusinessProfile { + private toDomain(row: typeof businessProfiles.$inferSelect): BusinessProfile { return new BusinessProfile({ id: row.id, userId: row.userId, diff --git a/packages/backend/src/infrastructure/repository/postgres/pg-escrow-event.repository.ts b/packages/backend/src/infrastructure/repository/postgres/pg-escrow-event.repository.ts index 10ba2ac..fb9e31f 100644 --- a/packages/backend/src/infrastructure/repository/postgres/pg-escrow-event.repository.ts +++ b/packages/backend/src/infrastructure/repository/postgres/pg-escrow-event.repository.ts @@ -1,9 +1,6 @@ import { eq } from 'drizzle-orm'; import type { IEscrowEventRepository } from '../../../domain/escrow/events/repository/escrow-event.repository.js'; -import { - EscrowEvent, - type EscrowEventType, -} from '../../../domain/escrow/events/model/escrow-event.js'; +import { EscrowEvent, type EscrowEventType } from '../../../domain/escrow/events/model/escrow-event.js'; import { escrowEvents } from './schema.js'; import type { Db } from './db.js'; @@ -38,9 +35,7 @@ export class PgEscrowEventRepository implements IEscrowEventRepository { } async delete(txHash: string): Promise { - await this.db - .delete(escrowEvents) - .where(eq(escrowEvents.txHash, txHash)); + await this.db.delete(escrowEvents).where(eq(escrowEvents.txHash, txHash)); } private toDomain(row: typeof escrowEvents.$inferSelect): EscrowEvent { diff --git a/packages/backend/src/infrastructure/repository/postgres/pg-escrow.repository.ts b/packages/backend/src/infrastructure/repository/postgres/pg-escrow.repository.ts index c8a00f6..66046c9 100644 --- a/packages/backend/src/infrastructure/repository/postgres/pg-escrow.repository.ts +++ b/packages/backend/src/infrastructure/repository/postgres/pg-escrow.repository.ts @@ -27,10 +27,7 @@ export class PgEscrowRepository implements IEscrowRepository { return row ? this.toDomain(row) : null; } - async findByUserId( - userId: string, - options?: FindByUserIdOptions, - ): Promise> { + async findByUserId(userId: string, options?: FindByUserIdOptions): Promise> { const limit = options?.limit ?? 20; const conditions = [eq(escrows.userId, userId)]; diff --git a/packages/backend/src/infrastructure/repository/postgres/pg-nonce.repository.ts b/packages/backend/src/infrastructure/repository/postgres/pg-nonce.repository.ts index 8f86492..ec83b16 100644 --- a/packages/backend/src/infrastructure/repository/postgres/pg-nonce.repository.ts +++ b/packages/backend/src/infrastructure/repository/postgres/pg-nonce.repository.ts @@ -6,11 +6,7 @@ import type { Db } from './db.js'; export class PgNonceRepository implements INonceRepository { constructor(private readonly db: Db) {} - async save( - walletAddress: string, - nonce: string, - ttlSeconds: number, - ): Promise { + async save(walletAddress: string, nonce: string, ttlSeconds: number): Promise { const expiresAt = Math.floor(Date.now() / 1000) + ttlSeconds; await this.db .insert(nonces) @@ -21,16 +17,11 @@ export class PgNonceRepository implements INonceRepository { }); } - async findAndDelete( - walletAddress: string, - nonce: string, - ): Promise { + async findAndDelete(walletAddress: string, nonce: string): Promise { const now = Math.floor(Date.now() / 1000); const deleted = await this.db .delete(nonces) - .where( - and(eq(nonces.walletAddress, walletAddress), eq(nonces.nonce, nonce)), - ) + .where(and(eq(nonces.walletAddress, walletAddress), eq(nonces.nonce, nonce))) .returning(); if (deleted.length === 0) return false; diff --git a/packages/backend/src/infrastructure/repository/postgres/pg-withdrawal.repository.ts b/packages/backend/src/infrastructure/repository/postgres/pg-withdrawal.repository.ts index 12da2b8..3ce81e1 100644 --- a/packages/backend/src/infrastructure/repository/postgres/pg-withdrawal.repository.ts +++ b/packages/backend/src/infrastructure/repository/postgres/pg-withdrawal.repository.ts @@ -27,10 +27,7 @@ export class PgWithdrawalRepository implements IWithdrawalRepository { return row ? this.toDomain(row) : null; } - async findByUserId( - userId: string, - options?: FindWithdrawalsByUserIdOptions, - ): Promise> { + async findByUserId(userId: string, options?: FindWithdrawalsByUserIdOptions): Promise> { const limit = options?.limit ?? 20; const conditions = [eq(withdrawals.userId, userId)]; @@ -71,10 +68,7 @@ export class PgWithdrawalRepository implements IWithdrawalRepository { .update(withdrawals) .set({ status: withdrawal.status, - actualAmount: - withdrawal.actualAmount != null - ? String(withdrawal.actualAmount) - : null, + actualAmount: withdrawal.actualAmount != null ? String(withdrawal.actualAmount) : null, fee: withdrawal.fee != null ? String(withdrawal.fee) : null, redeemTxHash: withdrawal.redeemTxHash, bridgeTxHash: withdrawal.bridgeTxHash, @@ -99,10 +93,7 @@ export class PgWithdrawalRepository implements IWithdrawalRepository { status: withdrawal.status, estimatedAmount: String(withdrawal.estimatedAmount), walletProvider: withdrawal.walletProvider, - actualAmount: - withdrawal.actualAmount != null - ? String(withdrawal.actualAmount) - : null, + actualAmount: withdrawal.actualAmount != null ? String(withdrawal.actualAmount) : null, fee: withdrawal.fee != null ? String(withdrawal.fee) : null, redeemTxHash: withdrawal.redeemTxHash, bridgeTxHash: withdrawal.bridgeTxHash, diff --git a/packages/backend/src/infrastructure/repository/postgres/schema.ts b/packages/backend/src/infrastructure/repository/postgres/schema.ts index 1b1dca0..bcbb8a2 100644 --- a/packages/backend/src/infrastructure/repository/postgres/schema.ts +++ b/packages/backend/src/infrastructure/repository/postgres/schema.ts @@ -1,14 +1,4 @@ -import { - pgTable, - pgEnum, - text, - timestamp, - integer, - numeric, - jsonb, - index, - primaryKey, -} from 'drizzle-orm/pg-core'; +import { pgTable, pgEnum, text, timestamp, integer, numeric, jsonb, index, primaryKey } from 'drizzle-orm/pg-core'; export const escrowStatusEnum = pgEnum('escrow_status', [ 'PENDING', @@ -29,22 +19,13 @@ export const withdrawalStatusEnum = pgEnum('withdrawal_status', [ 'FAILED', ]); -export const walletProviderEnum = pgEnum('wallet_provider', [ - 'zerodev', - 'walletconnect', -]); +export const walletProviderEnum = pgEnum('wallet_provider', ['zerodev', 'walletconnect']); export const businessTypeEnum = pgEnum('business_type', ['RETAIL', 'SERVICE']); -export const credentialStatusEnum = pgEnum('credential_status', [ - 'active', - 'revoked', -]); +export const credentialStatusEnum = pgEnum('credential_status', ['active', 'revoked']); -export const escrowEventTypeEnum = pgEnum('escrow_event_type', [ - 'EscrowCreated', - 'EscrowSettled', -]); +export const escrowEventTypeEnum = pgEnum('escrow_event_type', ['EscrowCreated', 'EscrowSettled']); export const users = pgTable( 'users', @@ -71,10 +52,7 @@ export const sessions = pgTable( userAgent: text('user_agent'), ipAddress: text('ip_address'), }, - (t) => [ - index('sessions_refresh_token_idx').on(t.refreshToken), - index('sessions_user_id_idx').on(t.userId), - ], + (t) => [index('sessions_refresh_token_idx').on(t.refreshToken), index('sessions_user_id_idx').on(t.userId)], ); export const nonces = pgTable( @@ -179,10 +157,7 @@ export const apiCredentials = pgTable( createdAt: timestamp('created_at').notNull().defaultNow(), lastUsedAt: timestamp('last_used_at'), }, - (t) => [ - index('api_credentials_client_id_idx').on(t.clientId), - index('api_credentials_user_id_idx').on(t.userId), - ], + (t) => [index('api_credentials_client_id_idx').on(t.clientId), index('api_credentials_user_id_idx').on(t.userId)], ); export const escrowEvents = pgTable(