Phoenix-Protocol-Group / phoenix-contracts

Source code of the smart contracts of the Phoenix DeFi hub DEX protocol
GNU General Public License v3.0
10 stars 6 forks source link

possible issue with persistent storage #285

Closed gangov closed 1 week ago

gangov commented 4 months ago

the fn get_vesting listed below fails with the following error:

3: [Failed Diagnostic Event (not emitted)] contract:CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMDR4, topics:[log], data:["cau
ght panic 'called `Result::unwrap()` on an `Err` value: ConversionError' from contract function 'Symbol(obj#217)'", CAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4, CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M, 100]
pub fn save_vesting(env: &Env, address: &Address, vesting_info: VestingInfo) {
    env.storage().persistent().set(address, &vesting_info);
}

pub fn get_vesting(env: &Env, address: &Address) -> Result<VestingInfo, ContractError> {
    let vesting_info = env.storage().persistent().get(address).unwrap_or_else(|| {
        log!(&env, "Vesting: Get vesting schedule: Critical error - No vesting schedule found for the given address");
        panic_with_error!(env, ContractError::VestingNotFoundForAddress);
    });

    Ok(vesting_info)
}

however, when using instance() storage in feature branch of vesting contract we can access the stored value.

gangov commented 4 months ago

note to self: check the result of writing two times to persistent storage with the same key but storing different values

gangov commented 1 week ago

issue is no longer present