fix: contract error semantics, token validation, and O(1) swap lookups - #387
Merged
cypriannwokolo2-creator merged 3 commits intoAug 31, 2026
Conversation
The initialize function returned NotInitialized when the contract was already initialized, which is semantically wrong. Added an AlreadyInitialized variant and use it. Closes cocor-tech#312
…tokens rescue_tokens now rejects token addresses that are not deployed contracts, preventing attempts to send tokens to invalid addresses. Closes cocor-tech#313
Replaced the linear Vec scan for swap lookups with a Map<u64, SwapRequest> keyed by swap ID, giving O(1) access in accept_swap, complete_swap, cancel_swap and get_swap. Closes cocor-tech#298
|
@matteorossi-codes Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Fixes three issues in the moistello contracts:
initializenow returns a properAlreadyInitializederror instead of the misleadingNotInitializedwhen the contract is already initialized.rescue_tokensnow validates that the target token address is a deployed contract before transferring, preventing attempts to send tokens to invalid addresses.Vecscan to aMap<u64, SwapRequest>keyed by swap ID, giving O(1) lookup inaccept_swap,complete_swap,cancel_swap, andget_swap.ContractNotPausederror variant was dead code;rescue_tokensnow returns it when attempting a rescue while the treasury is not paused, so the variant is used again.Closes #298
Closes #312
Closes #313
Closes #314