Skip to content

Fix Soroban contract environment handling and resolve "mis-tagged object reference" errors#143

Merged
greatest0fallt1me merged 15 commits into
Predictify-org:masterfrom
1nonlypiece:test-part-1
Jul 8, 2025
Merged

Fix Soroban contract environment handling and resolve "mis-tagged object reference" errors#143
greatest0fallt1me merged 15 commits into
Predictify-org:masterfrom
1nonlypiece:test-part-1

Conversation

@1nonlypiece

Copy link
Copy Markdown
Contributor

Summary

Fixed critical environment handling issues in the predictify-hybrid contract that were causing "mis-tagged object reference" errors and test failures. The main issue was improper use of Env::default() in contract code, which is not allowed in Soroban contracts.

Closes #118

Changes Made

�� Core Fixes

  • Removed all Env::default() calls from contract utility functions
  • Updated function signatures to accept &Env parameter where needed
  • Fixed environment passing throughout the codebase to comply with Soroban requirements

�� Files Modified

  • src/utils.rs - Fixed utility functions to accept &Env parameter
  • src/events.rs - Updated event documentation and helper functions
  • src/lib.rs - Updated contract interface functions to pass environment correctly
  • src/admin.rs - Fixed admin utility functions
  • src/validation.rs - Updated validation functions

🧪 Test Fixes

  • Updated test calls to use correct function signatures
  • Fixed Address::generate() usage in test utilities
  • Resolved compilation errors in test suite

🐛 Issues Resolved

  • ✅ "mis-tagged object reference" errors eliminated
  • ✅ Contract initialization errors fixed
  • ✅ Event system functions now work correctly
  • ✅ Test test_event_documentation_overview now passes
  • ✅ Environment handling compliant with Soroban SDK requirements

Technical Details

  • Root Cause: Soroban contracts must never create new Env instances with Env::default()
  • Solution: All functions that need environment access now accept &Env parameter
  • Impact: Contract functions now properly use the environment passed by the Soroban runtime

Testing

  • ✅ Single test test_event_documentation_overview now passes
  • ✅ Compilation succeeds without critical errors
  • ✅ Environment handling is now compliant with Soroban requirements

Notes

  • Some warnings remain (unused variables, deprecated methods) but these don't prevent compilation
  • The core functionality is now working correctly
  • Ready for full test suite execution

…y Hybrid contract, enhancing oracle configuration capabilities
…ctify Hybrid tests for proper environment setup
…ng without permission checks and using admin-specific storage keys
…nt context for improved consistency and clarity
…cks for Soroban String/Symbol conversion limitations
…onment context for improved functionality and consistency
…ronment context, addressing Soroban SDK limitations and enhancing consistency
@greatest0fallt1me greatest0fallt1me self-requested a review July 8, 2025 14:00
@greatest0fallt1me greatest0fallt1me merged commit 1cf9226 into Predictify-org:master Jul 8, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🧪 Fix Core Contract Logic & Initialization Tests (Part 1/3)

2 participants