feat(crosschain): centralize cross-chain accounting log in the hook (Step 3a)#26
Merged
Merged
Conversation
… v3 fields (Step 3a) 調査の結果、cross-chain 決済は「記録なし」ではなく CrossChainHint が executeOption 成功後に logPaymentEvent していた。ただし (1) 全 execute 完了後に発火するため fee mint 失敗で merchant 着金ログを取りこぼす (Gateway/CCTP は merchant を fee より先に mint)、(2) saleAmount/bridge fee を持たず merchantAmount=bridgedAmount を settled income として記録、(3) CrossChainSource Chooser 経路は未ログ、という課題があった。会計ログを hook の onMerchantMint (merchant mint 確定時・fee mint より前) に集約して是正する。 - execute.ts: OnMerchantMint callback を追加し、Gateway/CCTP とも merchant mint 確定直後 (fee mint より前・resume 経路含む) に発火。fee mint 失敗でも merchant 着金を取りこぼさない。 - useCrossChainPayment: onMerchantMint で logPaymentEvent を発火 (全実行経路を集約)。 flow:'direct' / bridge / sourceChainId / saleAmount(gross) / merchantAmount(=bridged intent) / bridgeFeeMax(ceiling) / burnTxHash / feeAmount(0)。 - CrossChainHint: 重複する明示ログを削除 (hook に集約)。 - paymentLog + route: bridgedAmount / bridgeFeeMax / burnTxHash を追加・検証 (全て unreconciled)。 - cctp.ts / gateway.ts: estimateCctp/GatewayMaxFee を export (calldata と同一計算)。 - stats: cross-chain success を (bridge+chainId+txHash) で dedup、bridged intent を settled totalMerchantWei から除外 (byBridge には残す)、totalBridgeFeeMaxWei / crossChainDeduped を追加、 saleAmount を GMV に計上。 - 実着金 (minted) と実 bridge fee は mint receipt 照合 (B-3) で verified、本記録は reported。 Verified: tsc 0 · eslint 0 · full suite 2564 passed/0 failed · /pay bundle 421kB (予算内)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… test coverage (Codex review) Codex code-review (approve-with-changes) の minor 2 点: - 隔離: fireMerchantMint helper で onMerchantMint を try/catch 包み、会計ログ (best-effort) の例外が確定済 merchant mint 後の決済 flow を中断させないようにした (3 fire site 全て)。 - テスト: (a) CCTP resume-merchant-landed が fee mint より前に callback を 1 度発火、 (b) CCTP fee mint 失敗でも merchant callback は発火済 (income 取りこぼし無し)、 (c) onMerchantMint throw が executor に伝播しない (隔離の検証)。 bridgeFeeMax の override 乖離 (Codex minor #4) は現状 override 経路の caller が無く latent。 将来 override 対応 caller を足す際は executor から実 ceiling を callback に渡す follow-up が必要 (estimator は default overrides 前提)。 Verified: tsc 0 · eslint 0 · full suite 2566 passed/0 failed。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… for onMerchantMint Codex re-review の非ブロッキング推奨: resume で merchant mint が landed 済かつ fee mint が 失敗するケースで、merchant callback が fee mint の「前」に発火することを fence する。callback を fee mint の後ろに動かすとこの test が落ちる (ordering の退行検知)。
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Option B Step 3a — cross-chain 決済の会計記録を hook に集約。
調査で判明したこと
cross-chain は「記録なし」ではなく
CrossChainHintがexecuteOption成功後にlogPaymentEventしていた。ただし: (1) 全 execute 完了後に発火するため fee mint 失敗で merchant 着金ログを取りこぼす(Gateway/CCTP は merchant を fee より先に mint)、(2)saleAmount/bridge fee が無くmerchantAmount=bridgedAmountを settled income として記録、(3)CrossChainSourceChooser経路は未ログ。是正
会計ログを hook の
onMerchantMintcallback(merchant mint 確定時・fee mint より前) に集約:execute.ts:OnMerchantMint追加。Gateway/CCTP とも merchant mint 確定直後(resume 経路含む)に発火。fireMerchantMintで try/catch 隔離(audit ログ例外が決済を中断しない)。useCrossChainPayment:onMerchantMintでlogPaymentEvent(全実行経路を集約)。flow:'direct'/bridge/sourceChainId/saleAmount(gross)/merchantAmount(=bridged intent)/bridgeFeeMax(ceiling)/burnTxHash。CrossChainHint: 重複ログ削除。paymentLog+route:bridgedAmount/bridgeFeeMax/burnTxHash追加・検証(全て unreconciled)。(bridge+chainId+txHash)で dedup、bridged intent を settledtotalMerchantWeiから除外(byBridge には残す)、totalBridgeFeeMaxWei/crossChainDeduped追加、saleAmount→GMV。実着金(minted)と実 bridge fee は mint receipt 照合(B-3)で verified、本記録は reported。
検証
Codex 計画レビュー approve-with-changes → 解決。コードレビュー 2 round → approve(once-and-only-once / fee-mint 失敗で income 取りこぼし無し / dedup / 隔離 を確認)。tsc 0 · eslint 0 · 全 2566 passed/0 failed ·
/pay421kB(予算内)。🤖 Generated with Claude Code