Skip to content

feat: upgrade error codes, Result-based error propagation, oracle price feed, and multi-token support - #1062

Merged
nafiuishaaq merged 2 commits into
MentoNest:mainfrom
khaadish:feature/contract-error-oracle-multitoken
Jul 30, 2026
Merged

feat: upgrade error codes, Result-based error propagation, oracle price feed, and multi-token support#1062
nafiuishaaq merged 2 commits into
MentoNest:mainfrom
khaadish:feature/contract-error-oracle-multitoken

Conversation

@khaadish

Copy link
Copy Markdown
Contributor

Summary

This PR implements four contract improvements for the SkillSync Soroban smart contract:

#942 — Upgrade Error Codes

  • Added InvalidWasmHash (600) and UpgradeFailed (601) error variants to ContractError
  • The upgrade() function now validates that the provided WASM hash is not all zeros before attempting the upgrade

#943 — Error Propagation via Result Types

  • Converted all public contract functions from panic_with_error! to return Result<T, ContractError>
  • Introduced Result-returning helper functions:
    equire_initialized_result,
    equire_admin_result, get_session_result
  • All error conditions now use the ? operator for clean propagation
  • Updated tests to use ry_* methods for precise error code verification

#944 — Oracle Price Feed Module

  • Added set_oracle(oracle_id: Address) admin function to register an oracle contract
  • Added set_fallback_price(asset, price) for admin-provided fallback pricing
  • Added get_asset_price(asset) that queries the oracle first and falls back to admin price
  • Added get_cached_oracle_price(asset) and get_fallback_price(asset) view functions
  • Oracle results are cached with timestamps for freshness tracking

#945 — Multi-Token Support

  • Added oken_address: Option to the Session struct
  • lock_funds now accepts an optional oken_address parameter
  • When a token address is provided, the contract pulls tokens from the buyer via SEP-41 ransfer_from
  • �pprove_session transfers tokens to the seller when a token is set

efund_session and �uto_refund return tokens to the buyer

  • Sessions track which token is used; mixed-token sessions are prevented by design

Test Results

All existing tests updated and new tests added for:

  • Upgrade error validation
  • Error propagation (duplicate session, not found, amount validation, fee limits, not initialized)
  • Oracle: set oracle, fallback price, price querying without oracle
  • Multi-token: session creation with optional token address

Closes #942
Closes #943
Closes #944
Closes #945

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@khaadish 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

@nafiuishaaq
nafiuishaaq merged commit 4582c7a into MentoNest:main Jul 30, 2026
0 of 2 checks passed
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.

Multi-token support (Soroban tokens) Oracle integration — Price feed module Error propagation in contract functions Upgrade errors

2 participants