fix: KEEP-393 drop stale ethValue when target function is non-payable#1092
Merged
fix: KEEP-393 drop stale ethValue when target function is non-payable#1092
Conversation
Form state can retain ethValue from a previous action configuration (e.g. WETH.deposit) when the action type is changed to a non-payable function (e.g. Uniswap V3 exactInputSingle). The stale value caused writeContractCore to surface "Function 'X' is not payable" instead of the swap succeeding. protocol-write now drops ethValue when the resolved function ABI declares a non-payable mutability. When the function is missing from the ABI or its mutability cannot be determined, the value passes through so writeContractCore's existing errors are unchanged.
Silently dropping ethValue could mask user intent (e.g. a fork exposing a payable variant the reduced ABI does not). Emit a CONFIGURATION warning via logUserError when the drop fires, with the function name, protocol slug, and the dropped value as labels. Surfaces in console (warn level) and Prometheus, no DevOps alert.
Cover the conservative-pass-through contract:
- ABI is valid JSON but not an array (e.g. wrapped {abi: [...]})
- function ABI item has no stateMutability field (pre-0.5 ABIs)
- function is view or pure (parameterised case via it.each)
The view/pure cases also assert the drop logs with the matching
state_mutability label so downstream metrics can distinguish causes.
🧹 PR Environment Cleaned UpThe PR environment has been successfully deleted. Deleted Resources:
All resources have been cleaned up and will no longer incur costs. |
ℹ️ No PR Environment to Clean UpNo PR environment was found for this PR. This is expected if:
|
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.
Summary
When an action node is reconfigured (e.g. from a Wrap WETH
depositto a Uniswap V3 swap), the form retains staleethValueandabiFunctionfields from the previous configuration. The staleethValuereacheswriteContractCore, which rejects the call against the (correctly) non-payableexactInputSingleABI:protocol-writenow dropsethValuewhen the resolved function ABI declares a non-payable mutability. When the function is missing from the ABI or its mutability cannot be determined, the value passes through unchanged sowriteContractCore's existing errors are preserved.This is the server-side defense in depth. The companion UI fix (clear
ethValue/abiFunction/ contract overrides on action-type change) is tracked separately in KEEP-393.Linear
KEEP-393
Test plan
pnpm vitest run tests/unit/protocol-write-step.test.ts- 23/23 pass (4 new cases for KEEP-393)pnpm check- clean on changed filespnpm type-check- cleanpayable) still receivesethValue