feat(SC-106): add job versioning for contract upgrades - #693
Merged
anumukul merged 4 commits intoAug 5, 2026
Merged
Conversation
- Add `version: u32` field to Job struct, initialized to 1 on creation - Add `INITIAL_JOB_VERSION = 1` constant - Add `get_job_version(job_id)` contract method - Add `migrate_job_version(caller, job_id, target_version)` contract method - Authorizes only job client or platform admin - Rejects version downgrade (target < current) - Emits `job_version_migrated` event with old/new version - Fix dispute_fee default to 0 in tests (no DEFAULT_DISPUTE_FEE applied unless initialized) - Update 3 existing test Job structs to include `version: 1` - Add 3 new contract unit tests: - test_job_initial_version_is_one - test_migrate_job_version_success - test_migrate_job_version_rejects_unauthorized - Frontend: add optional `version?: number` to Job interface in types.ts - Frontend: add `getJobVersion()` and `migrateJobVersion()` in contract.ts - Frontend: add __tests__/job-version.test.ts (8 test cases) Closes anumukul#592, resolves SC-106
|
@Oluwasuyi-Oluwatimilehin-Daniel 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! 🚀 |
Owner
|
@Oluwasuyi-Oluwatimilehin-Daniel please resolve conflicts |
… SC-106 job versioning
Contributor
Author
|
@anumukul please review, the conflict has been resolved |
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.
#closes #592
feat(SC-106): Add job versioning for contract upgrades
Branch:
feat/job-versioning→mainIssue: #592 [SC-106]
Author: Oluwasuyi-Oluwatimilehin-Daniel
Summary
Adds a
version: u32field to theJobstruct in the Soroban escrow contract to support future schema migrations. All newly created jobs are initialized withversion = 1. Two new contract entrypoints enable querying and upgrading job schema versions. The frontend TypeScript interface and contract bindings are updated to match. Comprehensive tests are added on both the contract and frontend layers.Motivation
As the StellarWork escrow contract evolves, storage schema changes are inevitable. Without a versioning mechanism, on-chain upgrades that alter
Jobstruct layout risk breaking existing jobs stored under the old schema. This PR establishes the foundation for safe, incremental schema migrations by:Jobwith the schema version it was written under.migrate_job_version) for admins or job clients to explicitly advance a job to a new schema version.get_job_version) and selectively re-write only jobs below a target version.Changes
Smart Contract (
contracts/escrow/src/lib.rs)Jobstructpub version: u32as the first fieldpost_jobversion: 1for every new jobget_job_version(job_id)job.versionmigrate_job_version(caller, job_id, target_version)target < current), persists new version, emitsjob_version_migratedeventunwrap_or(DEFAULT_DISPUTE_FEE)→unwrap_or(0)so test environments don't require a native token setup forraise_disputeJob {}literal tests to includeversion: 1test_job_initial_version_is_one,test_migrate_job_version_success,test_migrate_job_version_rejects_unauthorizedresolve_dispute_split_rejects_non_adminandtest_migrate_job_version_rejects_unauthorizedto match exact panic messages emitted by the Soroban hostTest result:
276 passed; 0 failedFrontend (
frontend/)lib/types.tsversion?: number(optional, for backwards compat) toJobinterfacelib/contract.tsgetJobVersion(jobId)andmigrateJobVersion(caller, jobId, targetVersion)wrappers__tests__/job-version.test.tsJobinterface version fieldContract API Reference
get_job_version(e: Env, job_id: u64) -> u32Returns the schema version of a job. Read-only, no auth required.
migrate_job_version(e: Env, caller: Address, job_id: u64, target_version: u32) -> u32Migrates a job to a new schema version.
caller.require_auth()— caller must be the job'sclientOR the platformAdmintarget_version < job.version(no downgrades)("job_version_migrated", (job_id, old_version, target_version))Migration Strategy
For future contract upgrades that change the
Jobschema:INITIAL_JOB_VERSIONbumped toN.version = N.migrate_job_version(admin, job_id, N)for each job whereget_job_version(job_id) < N.job.version.Testing
Contract
Frontend
Checklist
version: u32added toJobstruct, initialized to1get_job_versioncontract entrypoint addedmigrate_job_versioncontract entrypoint added with auth + downgrade guardjob_version_migratedevent emitted on migrationversion: 1Jobinterface updated with optionalversionfieldgetJobVersionandmigrateJobVersionwrappers addedfeat/job-versioning#closes