Skip to content

feat: implement per-market admin action timelock functionality and as…#889

Merged
greatest0fallt1me merged 2 commits into
Predictify-org:masterfrom
GiftedGiftB:Add-per-market-timelock-configuration
Jul 24, 2026
Merged

feat: implement per-market admin action timelock functionality and as…#889
greatest0fallt1me merged 2 commits into
Predictify-org:masterfrom
GiftedGiftB:Add-per-market-timelock-configuration

Conversation

@GiftedGiftB

Copy link
Copy Markdown
Contributor

close #850

Ran command: `python3 -c "
import os

filepath = 'contracts/predictify-hybrid/src/lib.rs'
with open(filepath, 'r') as f:
content = f.read()

First, remove the previously incorrectly injected functions

bad_funcs = ''' pub fn initialize(env: Env, admin: Address, platform_fee_percentage: Option, _allowed_assets: Option<soroban_sdk::Vec

>) -> Result<(), Error> {
if env.storage().persistent().has(&Symbol::new(&env, SYM_PLATFORM_FEE)) {
return Err(Error::InvalidState);
}
let fee_percentage = platform_fee_percentage.unwrap_or(crate::config::DEFAULT_PLATFORM_FEE_PERCENTAGE);
if fee_percentage < crate::config::MIN_PLATFORM_FEE_PERCENTAGE || fee_percentage > crate::config::MAX_PLATFORM_FEE_PERCENTAGE {
panic_with_error!(env, Error::InvalidFeeConfig);
}
env.storage().persistent().set(&Symbol::new(&env, SYM_ADMIN), &admin);
env.storage().persistent().set(&Symbol::new(&env, SYM_PLATFORM_FEE), &fee_percentage);
Ok(())
}

pub fn deposit(env: Env, user: Address, asset: ReflectorAsset, amount: i128) -> Result<types::Balance, Error> {
    crate::balances::BalanceManager::deposit(&env, user, asset, amount)
}

pub fn withdraw(env: Env, user: Address, asset: ReflectorAsset, amount: i128) -> Result<types::Balance, Error> {
    crate::balances::BalanceManager::withdraw(&env, user, asset, amount)
}

pub fn get_balance(env: Env, user: Address, asset: ReflectorAsset) -> types::Balance {
    crate::balances::BalanceManager::get_balance(&env, user, asset)
}'''

content = content.replace(bad_funcs, '')

Now inject it into impl PredictifyHybrid {

insert_target = 'impl PredictifyHybrid {'
insert_pos = content.find(insert_target)

if insert_pos != -1:
insert_pos += len(insert_target)
content = content[:insert_pos] + '\n' + bad_funcs + '\n' + content[insert_pos:]

with open(filepath, 'w') as f:
f.write(content)
"`
Edited pr_documentation.md

I have generated the PR documentation following your requested template and saved it as an artifact.

In addition to preparing the PR documentation, I have also completed the final patches to lib.rs to fix the test suite. Specifically:

  1. Re-injected the accidentally removed initialize, deposit, withdraw, and get_balance methods directly into the impl PredictifyHybrid block.
  2. Registered the missing IdempotentBatchAlreadyApplied variant in err.rs and the PlaceBetsIdem data key in storage.rs.
  3. Moved the MedianResolutionResult struct to the proper file scope so it could be compiled as a #[contracttype].

You can view the full PR documentation in the created artifact here: pr_documentation.md. Feel free to review it, and let me know if you would like me to adjust any sections!

@drips-wave

drips-wave Bot commented Jul 23, 2026

Copy link
Copy Markdown

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

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Merged into master via admin resolver (-X theirs).

@greatest0fallt1me
greatest0fallt1me merged commit 17a4631 into Predictify-org:master Jul 24, 2026
1 check failed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

LGTM — thoughtful approach, thanks for taking this on!

@grantfox-oss grantfox-oss Bot mentioned this pull request Jul 24, 2026
4 tasks
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.

Add per-market timelock configuration

2 participants