Fix: three FungibleTokenSwitchboard bugs#186
Merged
joshuahannan merged 4 commits intomasterfrom Mar 12, 2026
Merged
Conversation
turbolent
approved these changes
Mar 11, 2026
jribbink
approved these changes
Mar 11, 2026
1. removeVault: panic message incorrectly named the function as "addNewVaultWrapper" instead of "removeVault", making error messages misleading when the capability cannot be borrowed. 2. addNewVaultWrappersByPath: no guard on the paths and types arrays having equal length. If paths is longer than types, accessing types[i] panics with an index out-of-bounds. Added a pre-condition requiring paths.length == types.length. 3. addNewVaultsByPath: redundant force-unwrap operators (vaultRef!) on a value already safely unwrapped by the surrounding if-let binding. Removed the unnecessary unwraps. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- testRemoveVaultPanicsWithCorrectFunctionName: verifies the panic message from removeVault names the correct function (not "addNewVaultWrapper") - testAddNewVaultWrappersByPathPanicsOnMismatchedArrayLengths: verifies the pre-condition fires when paths and types arrays have different lengths - testAddNewVaultsByPathAddsCapabilitiesCorrectly: verifies addNewVaultsByPath correctly indexes capabilities by vault type from the given address Also adds a test helper transaction for the mismatched arrays scenario and regenerates assets.go to embed the updated FungibleTokenSwitchboard.cdc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
afc2b7b to
be27fd2
Compare
The curl-based install script fails in CI with "can't access tty" because it requires an interactive terminal to fetch the latest release version. Replace it with the official onflow/flow-cli-action which handles installation reliably in non-interactive environments. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This reverts commit 5d71b4b.
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
removeVaultwrong error message: The panic message inremoveVaultreferred toaddNewVaultWrapperinstead ofremoveVault, producing misleading errors when the capability cannot be borrowed.addNewVaultWrappersByPathmissing array length guard: No check thatpathsandtypeshave equal length before the loop accessestypes[i]. Ifpathsis longer thantypes, the function panics with an index out-of-bounds error. Added aprecondition requiringpaths.length == types.length.addNewVaultsByPathredundant force-unwraps:vaultRef!.getType()used the force-unwrap operator on a value already safely unwrapped by the enclosingif let vaultRef = capability.borrow()binding. Removed the unnecessary!operators.Test plan
removeVaultproduces an error message containing "removeVault" when the capability is invalidaddNewVaultWrappersByPathpanics with a clear message whenpaths.length != types.lengthaddNewVaultWrappersByPathstill works correctly when arrays are the same length🤖 Generated with Claude Code