Skip to content

fix: contract error semantics, token validation, and O(1) swap lookups - #387

Merged
cypriannwokolo2-creator merged 3 commits into
cocor-tech:masterfrom
matteorossi-codes:feat/stellar-drips-wave-298-312-313-314
Aug 31, 2026
Merged

fix: contract error semantics, token validation, and O(1) swap lookups#387
cypriannwokolo2-creator merged 3 commits into
cocor-tech:masterfrom
matteorossi-codes:feat/stellar-drips-wave-298-312-313-314

Conversation

@matteorossi-codes

@matteorossi-codes matteorossi-codes commented Aug 31, 2026

Copy link
Copy Markdown

Summary

Fixes three issues in the moistello contracts:

  1. Governance-token initialize uses wrong error for already-initialized #312 — Governance token initialize now returns a proper AlreadyInitialized error instead of the misleading NotInitialized when the contract is already initialized.
  2. Treasury rescue_tokens lacks token address validation #313 — Treasury rescue_tokens now validates that the target token address is a deployed contract before transferring, preventing attempts to send tokens to invalid addresses.
  3. Escrow-swap linear scan for swap lookup by ID #298 — Escrow-swap swap storage switched from a linear Vec scan to a Map<u64, SwapRequest> keyed by swap ID, giving O(1) lookup in accept_swap, complete_swap, cancel_swap, and get_swap.
  4. Treasury unused ContractNotPaused error variant #314 — The Treasury ContractNotPaused error variant was dead code; rescue_tokens now 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

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
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@cypriannwokolo2-creator
cypriannwokolo2-creator merged commit 540903e into cocor-tech:master Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants