Security review improvements across utility contracts#187
Open
joshuahannan wants to merge 2 commits intomasterfrom
Open
Security review improvements across utility contracts#187joshuahannan wants to merge 2 commits intomasterfrom
joshuahannan wants to merge 2 commits intomasterfrom
Conversation
- TokenForwarding: typed Capability<&{FungibleToken.Receiver}>, fix init error message,
CEI comment, eliminate TOCTOU in getSupportedVaultTypes, simplify isSupportedVaultType
- PrivateReceiverForwarder: recipient var→let (immutable), fix CEI violation (emit before
external deposit call), replace force-unwrap with descriptive panic
- FungibleTokenSwitchboard: fix addNewVaultWrapper to use pre-condition instead of assert,
eliminate nil-check+force-unwrap in checkReceiverByType/safeBorrowByType, fix TOCTOU in
getSupportedVaultTypes/getVaultTypesWithAddress (single borrow replaces check+borrow),
fix dictionary iteration (keys pattern instead of broken for-key,value syntax),
simplify isSupportedVaultType
- ExampleToken: remove redundant getSupportedVaultTypes/isSupportedVaultType overrides
(FungibleToken.Vault interface provides identical default implementations)
- FungibleToken: fix typo "panicing" -> "panicking"
- Burner: update stale comment about Cadence 1.0
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Changing a stored field type is not allowed in Cadence contract upgrades.
Revert recipient from Capability<&{FungibleToken.Receiver}> back to the
untyped Capability, and restore explicit type parameters on all borrow()
and check() calls that depend on it.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
joshuahannan
commented
Mar 12, 2026
| return ExampleToken.resolveContractView(resourceType: nil, viewType: view) | ||
| } | ||
|
|
||
| /// getSupportedVaultTypes optionally returns a list of vault types that this receiver accepts |
Member
Author
There was a problem hiding this comment.
removed because they have identical default implementations in FungibleToken.
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
init; fix force-unwrap indeposit; eliminate TOCTOU ingetSupportedVaultTypes(single borrow instead of check + borrow); simplifyisSupportedVaultTyperecipientfieldlet(nochangeRecipientexists so it was always effectively immutable); fix CEI violation —PrivateDepositevent was emitted after the externaldepositcall, now emitted before; replace force-unwrap with descriptive panicassert()withpreblock inaddNewVaultWrapper; eliminate nil+force-unwrap antipattern incheckReceiverByTypeandsafeBorrowByType; fix TOCTOU ingetSupportedVaultTypes/getVaultTypesWithAddress(single borrow replaces check+borrow); fix broken dictionary iteration (for key, value in dictgives integer index in Cadence — rewritten usingfor key in dict.keys); simplifyisSupportedVaultTypegetSupportedVaultTypes/isSupportedVaultTypeoverrides —FungibleToken.Vaultalready provides identical default implementations"panicing"→"panicking"Test plan
flow test --cover --covercode="contracts" tests/*.cdccd lib/go && make testmake cipasses clean (includesgo generate+git diff --exit-codecheck)🤖 Generated with Claude Code