Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ DB_PASSWORD=password
DB_DATABASE=starshop
DB_SSL=true
JWT_SECRET=tu_jwt_secret
TRUSTLESS_WORK_ENV=development

SOROBAN_RPC_URL=https://your-soroban-endpoint
SOROBAN_SERVER_SECRET=your-secret-key

TRUSTLESS_WORK_ENV=testnet
TRUSTLESS_WORK_BASE_URL=https://api.trustlesswork.com
Comment on lines +15 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Deduplicate and order TRUSTLESS_WORK_ keys*

You added TRUSTLESS_WORK_ENV twice and placed TRUSTLESS_WORK_BASE_URL after it. This can mislead users and break dotenv linters.

Apply this diff:

-TRUSTLESS_WORK_ENV=development
+TRUSTLESS_WORK_BASE_URL=https://api.trustlesswork.com
+TRUSTLESS_WORK_ENV=development
...
-TRUSTLESS_WORK_ENV=testnet
-TRUSTLESS_WORK_BASE_URL=https://api.trustlesswork.com

Optional: document valid values for TRUSTLESS_WORK_ENV (development|testnet|production).

πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
TRUSTLESS_WORK_ENV=development
SOROBAN_RPC_URL=https://your-soroban-endpoint
SOROBAN_SERVER_SECRET=your-secret-key
TRUSTLESS_WORK_ENV=testnet
TRUSTLESS_WORK_BASE_URL=https://api.trustlesswork.com
TRUSTLESS_WORK_BASE_URL=https://api.trustlesswork.com
TRUSTLESS_WORK_ENV=development
SOROBAN_RPC_URL=https://your-soroban-endpoint
SOROBAN_SERVER_SECRET=your-secret-key
🧰 Tools
πŸͺ› dotenv-linter (3.3.0)

[warning] 20-20: [DuplicatedKey] The TRUSTLESS_WORK_ENV key is duplicated

(DuplicatedKey)


[warning] 21-21: [UnorderedKey] The TRUSTLESS_WORK_BASE_URL key should go before the TRUSTLESS_WORK_ENV key

(UnorderedKey)

πŸ€– Prompt for AI Agents
In .env.example around lines 15 to 21, TRUSTLESS_WORK_ENV is declared twice and
TRUSTLESS_WORK_BASE_URL is placed after the duplicate which can confuse users
and break dotenv linters; remove the duplicate TRUSTLESS_WORK_ENV so it appears
only once, place TRUSTLESS_WORK_BASE_URL immediately next to the
TRUSTLESS_WORK_* group, and add a short comment documenting valid values for
TRUSTLESS_WORK_ENV (development|testnet|production).


# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
Expand Down
22 changes: 21 additions & 1 deletion package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"description": "StarShop Backend API",
"dependencies": {
"@aws-sdk/client-s3": "^3.802.0",
"@nestjs/axios": "^4.0.1",
"@nestjs/common": "^11.1.3",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.1.3",
Expand All @@ -56,6 +57,7 @@
"class-transformer": "^0.5.1",
"class-validator": "^0.14.2",
"cloudinary": "^1.41.3",
"crypto": "^1.0.1",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Remove npm "crypto" dependency; use built‑in Node crypto.

The npm package crypto@^1.0.1 is unnecessary and risks shadowing the Node core module. Drop it and import from node:crypto.

Apply this diff:

   "class-validator": "^0.14.2",
   "cloudinary": "^1.41.3",
-  "crypto": "^1.0.1",
   "dotenv": "^16.4.7",

Outside this file, ensure imports use the core module:

import { createHmac } from 'node:crypto';

Find and fix any non‑core imports:


🏁 Script executed:

#!/bin/bash
rg -nP --type=ts -C1 "from ['\"]crypto['\"]|require\(['\"]crypto['\"]\)"

Length of output: 180


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "package.json: matching '\"crypto\":'"
rg -n '^\s*"crypto"\s*:' package.json || true
echo
echo "Search repo for imports/requires of 'crypto' or 'node:crypto':"
rg -nP -C1 "(from\s+['\"](crypto|node:crypto)['\"])|(require\(['\"](crypto|node:crypto)['\"]\))" || true
echo
echo "Show src/config/crypto-global.ts (if present):"
sed -n '1,160p' src/config/crypto-global.ts || true

Length of output: 1211


Remove npm "crypto" dependency; import from Node core 'node:crypto'.

Delete the npm "crypto" entry from package.json and update imports to the Node core specifier to avoid shadowing the built-in module.

   "class-validator": "^0.14.2",
   "cloudinary": "^1.41.3",
-  "crypto": "^1.0.1",
   "dotenv": "^16.4.7",

Change in src/config/crypto-global.ts:

  • replace: import * as crypto from 'crypto';
  • with: import * as crypto from 'node:crypto';
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"crypto": "^1.0.1",
"class-validator": "^0.14.2",
"cloudinary": "^1.41.3",
"dotenv": "^16.4.7",
Suggested change
"crypto": "^1.0.1",
import * as crypto from 'node:crypto';
πŸ€– Prompt for AI Agents
In package.json around line 57 remove the "crypto": "^1.0.1" dependency entry;
then update code imports that reference the npm package to use the Node core
specifier (e.g., in src/config/crypto-global.ts replace imports from 'crypto'
with 'node:crypto'); after removing the dependency run npm install (or yarn) to
update package-lock.json/yarn.lock and search the repo to replace any remaining
"crypto" imports with "node:crypto" to avoid shadowing the built-in module.

"dotenv": "^16.4.7",
"env-var": "^7.5.0",
"express": "^4.21.2",
Expand All @@ -73,7 +75,7 @@
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2",
"soroban-client": "^1.0.1",
"stellar-sdk": "^11.0.0",
"stellar-sdk": "^11.3.0",
"swagger-ui-express": "^5.0.1",
"typeorm": "^0.3.25",
"uuid": "^11.1.0",
Expand Down
26 changes: 14 additions & 12 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import { BuyerRequestsModule } from './modules/buyer-requests/buyer-requests.mod
import { OffersModule } from './modules/offers/offers.module';
import { EscrowModule } from './modules/escrow/escrow.module';
import { SupabaseModule } from './modules/supabase/supabase.module';
import { EscrowModule } from './modules/escrow/escrow.module';
import { AppCacheModule } from './cache/cache.module';
import { StoresModule } from './modules/stores/stores.module';
import { TrustlessWorkModule } from './modules/trustlessWork/trustless-work.module';
import { EscrowsModule } from './modules/escrows/escrows.module';

// Entities
import { User } from './modules/users/entities/user.entity';
Expand All @@ -45,13 +46,15 @@ import { Milestone } from './modules/escrow/entities/milestone.entity';
import { Escrow } from './modules/escrow/entities/escrow.entity';
import { EscrowFundingTx } from './modules/escrow/entities/escrow-funding-tx.entity';
import { Store } from './modules/stores/entities/store.entity';
import { Escrow } from './modules/escrows/entities/escrow.entity';
import { Milestone } from './modules/escrows/entities/milestone.entity';
import { EscrowsModule } from './modules/escrows/escrows.module';
import { Escrow as EscrowV2 } from './modules/escrows/entities/escrow.entity';
import { Milestone as MilestoneV2 } from './modules/escrows/entities/milestone.entity';
Comment on lines +49 to +50
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

🧩 Analysis chain

Clarify the dual entity architecture.

Aliasing entities as EscrowV2 and MilestoneV2 while retaining the original Escrow and Milestone entities (lines 45-46) suggests a parallel system or incomplete migration. Both versions are registered in TypeORM (lines 83-84 and 87-88), which will cause table conflicts unless the entities explicitly use different table names via the @Entity decorator.

Run the following script to verify the table names configured for these entities:

If the entities target the same tables, this will cause schema conflicts. Consider:

  1. Using different table names if both systems must coexist
  2. Removing the old entities if migrating to the new architecture
  3. Documenting the migration strategy clearly

🏁 Script executed:

#!/bin/bash
# Description: Check @Entity decorator table names for all Escrow and Milestone entities

echo "=== Old Escrow entity ==="
ast-grep --pattern $'@Entity($$$)
export class Escrow $$$'

echo -e "\n=== New Escrow (EscrowV2) entity ==="
ast-grep --pattern $'@Entity($$$)
export class Escrow $$$' ./src/modules/escrows/entities/escrow.entity.ts

echo -e "\n=== Old Milestone entity ==="
ast-grep --pattern $'@Entity($$$)
export class Milestone $$$'

echo -e "\n=== New Milestone (MilestoneV2) entity ==="
ast-grep --pattern $'@Entity($$$)
export class Milestone $$$' ./src/modules/escrows/entities/milestone.entity.ts

Length of output: 137


🏁 Script executed:

#!/bin/bash
echo "=== escrow.entity.ts files and @Entity decorators ==="
fd "escrow.entity.ts" -x sh -c 'echo "-- File: {}"; rg -n "@Entity" {} || echo "No @Entity found"'

echo -e "\n=== milestone.entity.ts files and @Entity decorators ==="
fd "milestone.entity.ts" -x sh -c 'echo "-- File: {}"; rg -n "@Entity" {} || echo "No @Entity found"'

Length of output: 443


Escrow entities conflict on the same table

  • Both Escrow (./src/modules/escrow/entities/escrow.entity.ts) and EscrowV2 (./src/modules/escrows/entities/escrow.entity.ts) use @Entity('escrows'), causing schema collisions. Rename one table or remove the legacy entity.
  • Milestone ('milestones') and MilestoneV2 ('escrow_milestones') map to different tables, so no collision there.
πŸ€– Prompt for AI Agents
In src/app.module.ts around lines 49-50, two different entity classes are both
mapped to the same database table name ('escrows') causing a schema collision;
remove or rename one mapping to resolve it. Identify which entity is legacy
(Escrow from ./modules/escrow) or the v2 (EscrowV2 from ./modules/escrows), then
either delete the legacy entity import and usages or change its @Entity()
decorator to a distinct table name (or rename V2 instead) so only one class maps
to 'escrows'. Update all imports/usages across the codebase and any TypeORM
config/migrations to reflect the chosen canonical entity, and run
tests/migrations to ensure no further schema conflicts.


@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
ConfigModule.forRoot({
isGlobal: true,
envFilePath: ['.env'],
}),
ScheduleModule.forRoot(),
AppCacheModule,
TypeOrmModule.forRoot({
Expand All @@ -78,12 +81,11 @@ import { EscrowsModule } from './modules/escrows/escrows.module';
OfferAttachment,
EscrowAccount,
Milestone,

Escrow,
EscrowFundingTx,
Escrow,
EscrowFundingTx,
Store,
Escrow,
Milestone,
EscrowV2,
MilestoneV2,
],
synchronize: false,
logging: process.env.NODE_ENV === 'development',
Expand All @@ -103,9 +105,9 @@ import { EscrowsModule } from './modules/escrows/escrows.module';
OffersModule,
EscrowModule,
SupabaseModule,
EscrowModule,
TrustlessWorkModule,
StoresModule,
EscrowsModule,
],
})
export class AppModule { }
export class AppModule { }
Loading