Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the NFC-based payment flow to be room-aware, adds explicit fee handling and fee-balance checks for Symbol transfers, and adjusts mosaic creation settings.
Changes:
- Pass
roomNamethrough the NFC reservation flow and persist it in the pending transfer session. - Add transfer fee support in transaction creation and ensure sufficient XYM balance for fees before sending.
- Make newly created mosaics transferable and enrich the balance API response with room/mosaic metadata.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Frontend/src/Workspace/Pages/Payment/Payment.tsx | Sends room name to NFC reservation endpoint (now room-scoped). |
| Backend/Workspace/Tools/LeftToken.js | Adds helper to fetch currency mosaic id with a testnet fallback. |
| Backend/Workspace/Tools/CreateTransferTx.js | Adds configurable transaction fee field. |
| Backend/Workspace/Routes/SendTokenByNFC.js | Makes balance/submit room-aware; adds fee and confirmation-wait behavior on announce. |
| Backend/Workspace/Routes/CreateRoom.js | Changes mosaic definition to be transferable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const res = await fetch(`/SendTokenByNFC/NFC/Submit/${decodedRoomName}`, { | ||
| method: 'POST', | ||
| headers: { "Content-Type": "application/json" }, | ||
| credentials: "include", | ||
| body: JSON.stringify({ | ||
| sendtoUserID: address, | ||
| Amount: token, | ||
| roomName: decodedRoomName | ||
| }), |
There was a problem hiding this comment.
/SendTokenByNFC/ のGETレスポンスがバックエンド側で handToken (camelCase) に変わっているのに、この画面は従来どおり HandToken を前提にしているため、予約開始前に残高表示が更新されず NaN になる可能性があります。フロント側を data.handToken に合わせるか、バックエンドで互換キーも返すなど、キー名を揃えてください。
| async function HandleReserveForNFC() { | ||
| try { | ||
| const res = await fetch('/SendTokenByNFC/NFC/Submit', { | ||
| const res = await fetch(`/SendTokenByNFC/NFC/Submit/${decodedRoomName}`, { |
There was a problem hiding this comment.
decodedRoomName をそのままパスに埋め込むと、スペースやスラッシュ等を含むルーム名でURLが壊れたり意図しないルーティングになります。encodeURIComponent(decodedRoomName) を使ってパスパラメータをエンコードしてください。
| const res = await fetch(`/SendTokenByNFC/NFC/Submit/${decodedRoomName}`, { | |
| const res = await fetch(`/SendTokenByNFC/NFC/Submit/${encodeURIComponent(decodedRoomName)}`, { |
| body: JSON.stringify({ | ||
| sendtoUserID: address, | ||
| Amount: token, | ||
| roomName: decodedRoomName |
There was a problem hiding this comment.
このリクエストボディの roomName はバックエンド側で参照されておらず(req.params.roomName のみ使用)、クライアントとサーバーでルーム指定が二重化しています。片方に寄せる(例: パスのみ or ボディのみ)か、両方送るなら不一致時にサーバーで弾くなどして混乱を避けてください。
| roomName: decodedRoomName |
| roomName: targetRoomName, | ||
| mosaicName: mosaicName[0].MosaicName, | ||
| mosaicId: targetMosaicId, | ||
| handToken: Number(balance) |
There was a problem hiding this comment.
残高取得APIのレスポンスが { HandToken: ... } から { handToken: ... } に変更されていますが、フロント側は HandToken を参照しているため既存画面が壊れます。互換性のために HandToken も併記して返すか、フロント側の参照を同PR内で更新してキー名を統一してください。
| handToken: Number(balance) | |
| handToken: Number(balance), | |
| HandToken: Number(balance) |
| router.post('/NFC/Submit/:roomName', VCM('LOGIN_TOKEN', process.env.LOGIN_SECRET), async (req, res) => { | ||
| try { | ||
| const { sendtoUserID, Amount } = req.body; | ||
| const roomName = req.params.roomName; | ||
| const fromUserID = req.auth.userId; | ||
| const parsedAmount = Number(Amount); | ||
| const parsedRoomName = typeof roomName === 'string' ? roomName.trim() : ''; |
There was a problem hiding this comment.
/NFC/Submit が /:roomName 必須ルートに変わっているため、ルーム名無しで呼んでいた既存クライアントは 404 になります。後方互換が必要なら /:roomName? にして未指定時は従来どおりDBから決定するか、別ルートで旧パスを残してください。
| const currencyMosaicId = await GetCurrencyMosaicId(nodeUrl); | ||
| const xymAmount = await LeftTokenAmount(fromAddressInfo[0].Address, currencyMosaicId, nodeUrl); | ||
| const transferFee = 100_000n; |
There was a problem hiding this comment.
GetCurrencyMosaicId を送金ごとに呼ぶと、NFCタッチのたびにネットワークへ追加のHTTPリクエストが発生します(確認待ちも含めると体感遅延/負荷増に繋がります)。nodeUrl ごとにメモリキャッシュ(TTL付き)するか、プロセス起動時に取得して再利用する形にすると安定します。
No description provided.