feat: Sync player level updates from progress contract#198
Merged
Conversation
- Add DataKey::ProgressContract to registration types
- Add set_progress_contract(env, addr) admin function — stores the
progress contract address in DataKey::ProgressContract
- Add set_player_level(env, player_id, level) — only callable by the
registered progress contract address (require_auth enforced); updates
profile.level and profile.updated_at, emits player_level_synced event;
returns Unauthorized when no progress contract is configured
- Add player_level_synced event to events.rs
- Add three unit tests:
test_set_player_level_updates_level_and_timestamp
test_set_player_level_emits_event
test_set_player_level_rejects_unauthorized_caller
|
@gracious01-tech 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! 🚀 |
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.
Description
Implemented external player level synchronization for the registration contract to ensure
PlayerProfile.updated_atremains accurate when player progression is updated outside ofupdate_profile.Previously, when the progress contract advanced a player's level, the registration contract's
updated_atfield remained stale because it was only refreshed during profile updates.This PR introduces a secure synchronization flow between the progress contract and registration contract.
Related Issue
Closes #27
Type of Change
Changes Included
set_player_level(env, player_id, level)functionDataKey::ProgressContractset_progress_contract(env, addr)functionlevelandupdated_atatomicallyplayer_level_syncedevent emissionProblem Solved
Previously:
updated_atonly changed duringupdate_profileThis PR ensures external progression updates correctly synchronize registration state.
Security Impact
No payment or admin ownership logic changed beyond authorized configuration updates.
Testing
updated_atrefreshes correctlyplayer_level_syncedevent emissionManual Testing Steps
set_player_levelfrom authorized progress contractupdated_attimestamp refreshesAcceptance Criteria Coverage
set_player_levelupdates bothlevelandupdated_atBreaking Changes
No breaking changes.
Adds optional synchronization support between contracts.
Checklist
Additional Context
This synchronization mechanism improves data consistency across the ecosystem by ensuring profile metadata accurately reflects externally-driven progression updates.
The implementation keeps contract coupling minimal by using a configurable authorized progress contract address.
Reviewer Notes
Please focus on: