fix: resolve Gateway depositor address in payout burn path#36
Open
theyavuzarslan wants to merge 1 commit into
Open
fix: resolve Gateway depositor address in payout burn path#36theyavuzarslan wants to merge 1 commit into
theyavuzarslan wants to merge 1 commit into
Conversation
depositorWallet was declared but never assigned, so every payout that reached the Gateway execution path (auto-mode fallback and user-selected cross-chain) threw 'Cannot read properties of undefined' at the burn call and surfaced as a generic 500. Replace it with a hoisted depositorAddress that is assigned in both routing branches: the selected wallet's address in wallet mode, and the EOA found holding the Gateway balance in auto mode. Guard the burn call so an unresolved depositor returns an explicit error instead of a crash.
theyavuzarslan
force-pushed
the
fix/gateway-depositor-address
branch
from
July 13, 2026 13:48
2ac6757 to
5311707
Compare
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.
depositorWalletis declared inapp/api/payout/route.ts(line 137 on current master) but never assigned anywhere in the function. Any payout that reaches the Gateway execution path dereferencesdepositorWallet.addressat the burn call, throwsTypeError: Cannot read properties of undefined, and the outer catch turns that into a generic500 Internal server error.This hits two routing paths:
sourceType: "wallet"with a different destination chain, which also setsuseGateway = true)In both cases the burn intent never gets submitted, so Gateway payouts on these paths always fail.
The fix replaces the never-assigned
depositorWalletwith adepositorAddresshoisted to function scope and assigned in both branches: the selected wallet's address in wallet mode, andeoaAddressWithBalancein auto mode (that variable was previously scoped inside the auto-mode block, so it was unusable at the burn site anyway). I also guarded the burn call so an unresolved depositor returns an explicit error instead of crashing.Found by inspection rather than a repro:
grep -n depositorWallet app/api/payout/route.tsshows one declaration and one dereference, zero assignments, so the Gateway branch can't complete. It compiles despitestrict: truebecausewalletscomes from an untyped Supabase query, which makestypeof wallets[0]resolve toany.