Skip to content

feat(crosschain): centralize cross-chain accounting log in the hook (Step 3a)#26

Merged
cipherwebllc merged 3 commits into
mainfrom
feat/crosschain-accounting-log
May 31, 2026
Merged

feat(crosschain): centralize cross-chain accounting log in the hook (Step 3a)#26
cipherwebllc merged 3 commits into
mainfrom
feat/crosschain-accounting-log

Conversation

@cipherwebllc
Copy link
Copy Markdown
Owner

Option B Step 3a — cross-chain 決済の会計記録を hook に集約。

調査で判明したこと

cross-chain は「記録なし」ではなく CrossChainHintexecuteOption 成功logPaymentEvent していた。ただし: (1) 全 execute 完了後に発火するため fee mint 失敗で merchant 着金ログを取りこぼす(Gateway/CCTP は merchant を fee より先に mint)、(2) saleAmount/bridge fee が無く merchantAmount=bridgedAmount を settled income として記録、(3) CrossChainSourceChooser 経路は未ログ

是正

会計ログを hook の onMerchantMint callback(merchant mint 確定時・fee mint より前) に集約:

  • execute.ts: OnMerchantMint 追加。Gateway/CCTP とも merchant mint 確定直後(resume 経路含む)に発火。fireMerchantMint で try/catch 隔離(audit ログ例外が決済を中断しない)。
  • useCrossChainPayment: onMerchantMintlogPaymentEvent(全実行経路を集約)。flow:'direct'/bridge/sourceChainId/saleAmount(gross)/merchantAmount(=bridged intent)/bridgeFeeMax(ceiling)/burnTxHash
  • CrossChainHint: 重複ログ削除。
  • paymentLog+route: bridgedAmount/bridgeFeeMax/burnTxHash 追加・検証(全て unreconciled)。
  • stats: cross-chain を (bridge+chainId+txHash) で dedup、bridged intent を settled totalMerchantWei から除外(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 · /pay 421kB(予算内)。

🤖 Generated with Claude Code

cipherwebllc and others added 3 commits June 1, 2026 05:46
… 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 の退行検知)。
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openpay Ready Ready Preview, Comment May 31, 2026 9:18pm

@cipherwebllc cipherwebllc merged commit a132922 into main May 31, 2026
6 checks passed
@cipherwebllc cipherwebllc deleted the feat/crosschain-accounting-log branch May 31, 2026 21:41
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.

1 participant