Skip to content

Done#37

Merged
toaru005 merged 1 commit intotoaru-blockchainfrom
toaru-connect/Ver2
Feb 21, 2026
Merged

Done#37
toaru005 merged 1 commit intotoaru-blockchainfrom
toaru-connect/Ver2

Conversation

@toaru005
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 21, 2026 16:30
@toaru005 toaru005 merged commit 363da88 into toaru-blockchain Feb 21, 2026
1 of 2 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 roomName through 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.

Comment on lines +71 to 79
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
}),
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

/SendTokenByNFC/ のGETレスポンスがバックエンド側で handToken (camelCase) に変わっているのに、この画面は従来どおり HandToken を前提にしているため、予約開始前に残高表示が更新されず NaN になる可能性があります。フロント側を data.handToken に合わせるか、バックエンドで互換キーも返すなど、キー名を揃えてください。

Copilot uses AI. Check for mistakes.
async function HandleReserveForNFC() {
try {
const res = await fetch('/SendTokenByNFC/NFC/Submit', {
const res = await fetch(`/SendTokenByNFC/NFC/Submit/${decodedRoomName}`, {
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

decodedRoomName をそのままパスに埋め込むと、スペースやスラッシュ等を含むルーム名でURLが壊れたり意図しないルーティングになります。encodeURIComponent(decodedRoomName) を使ってパスパラメータをエンコードしてください。

Suggested change
const res = await fetch(`/SendTokenByNFC/NFC/Submit/${decodedRoomName}`, {
const res = await fetch(`/SendTokenByNFC/NFC/Submit/${encodeURIComponent(decodedRoomName)}`, {

Copilot uses AI. Check for mistakes.
body: JSON.stringify({
sendtoUserID: address,
Amount: token,
roomName: decodedRoomName
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

このリクエストボディの roomName はバックエンド側で参照されておらず(req.params.roomName のみ使用)、クライアントとサーバーでルーム指定が二重化しています。片方に寄せる(例: パスのみ or ボディのみ)か、両方送るなら不一致時にサーバーで弾くなどして混乱を避けてください。

Suggested change
roomName: decodedRoomName

Copilot uses AI. Check for mistakes.
roomName: targetRoomName,
mosaicName: mosaicName[0].MosaicName,
mosaicId: targetMosaicId,
handToken: Number(balance)
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

残高取得APIのレスポンスが { HandToken: ... } から { handToken: ... } に変更されていますが、フロント側は HandToken を参照しているため既存画面が壊れます。互換性のために HandToken も併記して返すか、フロント側の参照を同PR内で更新してキー名を統一してください。

Suggested change
handToken: Number(balance)
handToken: Number(balance),
HandToken: Number(balance)

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +99
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() : '';
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

/NFC/Submit/:roomName 必須ルートに変わっているため、ルーム名無しで呼んでいた既存クライアントは 404 になります。後方互換が必要なら /:roomName? にして未指定時は従来どおりDBから決定するか、別ルートで旧パスを残してください。

Copilot uses AI. Check for mistakes.
Comment on lines +217 to +219
const currencyMosaicId = await GetCurrencyMosaicId(nodeUrl);
const xymAmount = await LeftTokenAmount(fromAddressInfo[0].Address, currencyMosaicId, nodeUrl);
const transferFee = 100_000n;
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

GetCurrencyMosaicId を送金ごとに呼ぶと、NFCタッチのたびにネットワークへ追加のHTTPリクエストが発生します(確認待ちも含めると体感遅延/負荷増に繋がります)。nodeUrl ごとにメモリキャッシュ(TTL付き)するか、プロセス起動時に取得して再利用する形にすると安定します。

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants