From 2b430d1cbd45afecb4baaa8381df7e46da487538 Mon Sep 17 00:00:00 2001 From: "Ranju G.C." <58603583+Itshyphen@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:37:18 +0545 Subject: [PATCH] fix: storage migration on bnusd --- contracts/balanced_doller/src/contract.rs | 2 +- .../balanced_doller/src/storage_types.rs | 66 ++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/contracts/balanced_doller/src/contract.rs b/contracts/balanced_doller/src/contract.rs index 8802007..347a1ac 100644 --- a/contracts/balanced_doller/src/contract.rs +++ b/contracts/balanced_doller/src/contract.rs @@ -24,7 +24,7 @@ pub struct BalancedDollar; #[contractimpl] impl BalancedDollar { - pub fn initialize(e: Env, admin: Address, config: ConfigData) { + pub fn initialize(e: Env, admin: Address, xcall: Address, xcall_manager: Address, nid: String, icon_bnusd: String, upgrade_auth: Address) { if has_administrator(&e) { panic_with_error!(e, ContractError::ContractAlreadyInitialized) } diff --git a/contracts/balanced_doller/src/storage_types.rs b/contracts/balanced_doller/src/storage_types.rs index 069bbab..c5f23ab 100644 --- a/contracts/balanced_doller/src/storage_types.rs +++ b/contracts/balanced_doller/src/storage_types.rs @@ -20,11 +20,75 @@ pub struct AllowanceValue { pub expiration_ledger: u32, } +#[derive(Clone)] +#[contracttype] +pub struct ConfigData { + pub xcall: Address, + pub xcall_manager: Address, + pub nid: String, + pub icon_bn_usd: String, + pub upgrade_authority: Address, +} + #[derive(Clone)] #[contracttype] pub enum DataKey { Allowance(AllowanceDataKey), Balance(Address), Admin, - Config, + XcallManager, + XCall, + Nid, + IconBnusd, + UpgradeAuthority +} + +pub fn set_xcall_manager(e: &Env, value: XcallManager) { + e.storage().instance().set(&DataKey::XcallManager, &value); +} + +pub fn set_xcall(e: &Env, value: Xcall) { + e.storage().instance().set(&DataKey::Xcall, &value); } + +pub fn set_nid(e: &Env, value: Nid) { + e.storage().instance().set(&DataKey::Nid, &value); +} + +pub fn set_icon_bnusd(e: &Env, value: IconBnusd) { + e.storage().instance().set(&DataKey::IconBnusd, &value); +} + +pub fn set_upgrade_authority(e: &Env, value: UpgradeAuthority) { + e.storage().instance().set(&DataKey::UpgradeAuthority, &value); +} + + +pub fn get_xcall_manager(e: &Env) -> XcallManager { + let key = DataKey::XcallManager; + e.storage().instance().get(&key).unwrap_optimized() +} + +pub fn get_xcall(e: &Env) -> Xcall { + let key = DataKey::Xcall; + e.storage().instance().get(&key).unwrap_optimized() +} + +pub fn get_nid(e: &Env) -> Nid { + let key = DataKey::Nid; + e.storage().instance().get(&key).unwrap_optimized() +} + +pub fn get_icon_bnusd(e: &Env) -> IconBnusd { + let key = DataKey::IconBnusd; + e.storage().instance().get(&key).unwrap_optimized() +} + +pub fn get_upgrade_authority(e: &Env) -> UpgradeAuthority { + let key = DataKey::UpgradeAuthority; + e.storage().instance().get(&key).unwrap_optimized() +} + + + +