refactor: break monolithic lib.rs into focused modules#228
Merged
ISTIFANUS-N merged 5 commits intorinafcode:mainfrom Mar 30, 2026
Merged
Conversation
- constants.rs — compile-time config values (fees, chains, oracle, storage) - errors.rs — TeachLinkError enum + handle_error panic helper - types.rs — BridgeConfig struct - storage.rs — storage key symbols + nonce/config helpers - validation.rs — all input validation guards - bridge.rs — bridge_out and add_chain_support logic - oracle.rs — update_oracle_price logic - lib.rs — thin wiring layer (#[contractimpl] only, <140 lines) Each file is under 500 lines. lib.rs is now a clear public interface with all business logic delegated to single-responsibility modules.
- storage.rs: rename symbol keys exceeding 9-char limit
('error_count' -> 'err_count', 'bridge_txs' -> 'brdg_txs')
- types.rs: add #[contracttype] to BridgeConfig so it can be
stored/retrieved from Soroban instance storage
- validation.rs: remove Address::to_string() call (not available
in no_std); Address is always valid if present
- bridge.rs: remove Symbol::to_string().len() call (not available
in no_std); drop chain name length check
- lib.rs: move use imports inside #[cfg(not(test))] to prevent
unused import warnings/errors in test compilation
- Remove #[cfg(not(test))] from TeachLinkBridge struct and impl so the Soroban test client (TeachLinkBridgeClient) is generated and available to integration tests that import it - Restore storage key names to match main branch (sdk 25 supports symbol names longer than 9 chars) - Fix lib.rs corrupted by rebase merge (old monolithic code had been appended inside the #[cfg(test)] block) - Keep #[contracttype] on BridgeConfig for sdk 25 storage compatibility
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.
Problem
contracts/teachlink/src/lib.rs contained all contract functionality in a single 456-line file —
constants, error types, data types, storage helpers, validation, bridge logic, and oracle logic
all mixed together. This made the code hard to read, test, and audit.
Changes
Acceptance criteria met
Closes #142