fix: convert acbuAmount to Decimal type in transferService#102
Conversation
acbuAmount was being passed as a string to prisma.transaction.create(), but the schema expects a Decimal type. This can cause type or precision issues. Convert the string amount to Decimal using new Decimal() before passing to Prisma, consistent with the pattern used in mintController.ts and rewardService.ts. The amount string is already validated to ensure it's a positive number with up to 7 decimal places before conversion.
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/services/transfer/transferService.ts (1)
6-6: Use the public Prisma Decimal API instead of internal runtime modules.The import from
@prisma/client/runtime/libraryaccesses Prisma's internal runtime module, which is not part of the public API surface and may change without notice across version upgrades. UsePrisma.Decimalfrom@prisma/clientinstead—this is the documented and supported way to construct Decimal values.Suggested change
-import { Decimal } from "@prisma/client/runtime/library"; +import { Prisma } from "@prisma/client";At line 105 (or wherever the Decimal is instantiated):
- acbuAmount: new Decimal(amount), + acbuAmount: new Prisma.Decimal(amount),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/services/transfer/transferService.ts` at line 6, The code imports Decimal from the internal module "@prisma/client/runtime/library"; replace that import with the public Prisma export by importing { Prisma } from "@prisma/client" and update any instantiation/usages of Decimal (the symbol "Decimal") in transferService.ts to use Prisma.Decimal (e.g., new Prisma.Decimal(...) or Prisma.Decimal(...)) so you rely on the supported public API rather than internal runtime modules.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/services/transfer/transferService.ts`:
- Line 6: The code imports Decimal from the internal module
"@prisma/client/runtime/library"; replace that import with the public Prisma
export by importing { Prisma } from "@prisma/client" and update any
instantiation/usages of Decimal (the symbol "Decimal") in transferService.ts to
use Prisma.Decimal (e.g., new Prisma.Decimal(...) or Prisma.Decimal(...)) so you
rely on the supported public API rather than internal runtime modules.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5b605204-09c9-41db-94c2-a48b5bb03a82
📒 Files selected for processing (1)
src/services/transfer/transferService.ts
acbuAmount was being passed as a string to prisma.transaction.create(), but the schema expects a Decimal type. This can cause type or precision issues. Convert the string amount to Decimal using new Decimal() before passing to Prisma, consistent with the pattern used in mintController.ts and rewardService.ts.
The amount string is already validated to ensure it's a positive number with up to 7 decimal places before conversion.
Summary by CodeRabbit
CLOSE #34