forked from icon-project/Temp-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: storage migration on bnusd * fix: storage migration to bnusd * fix: nid data type removed * fix: removed admin and package renamed * fix: duplicate script removed * fix: unwrap changes * fix: unwrap fix
- Loading branch information
Showing
19 changed files
with
135 additions
and
407 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
use soroban_sdk::{contracttype, Address, Env, String}; | ||
|
||
use crate::errors::ContractError; | ||
|
||
pub(crate) const DAY_IN_LEDGERS: u32 = 17280; | ||
pub(crate) const INSTANCE_BUMP_AMOUNT: u32 = 7 * DAY_IN_LEDGERS; | ||
pub(crate) const INSTANCE_LIFETIME_THRESHOLD: u32 = INSTANCE_BUMP_AMOUNT - DAY_IN_LEDGERS; | ||
|
||
pub(crate) const BALANCE_BUMP_AMOUNT: u32 = 30 * DAY_IN_LEDGERS; | ||
pub(crate) const BALANCE_LIFETIME_THRESHOLD: u32 = BALANCE_BUMP_AMOUNT - DAY_IN_LEDGERS; | ||
|
||
#[derive(Clone)] | ||
#[contracttype] | ||
pub struct AllowanceDataKey { | ||
pub from: Address, | ||
pub spender: Address, | ||
} | ||
|
||
#[contracttype] | ||
pub struct AllowanceValue { | ||
pub amount: i128, | ||
pub expiration_ledger: u32, | ||
} | ||
|
||
#[derive(Clone)] | ||
#[contracttype] | ||
pub enum DataKey { | ||
Allowance(AllowanceDataKey), | ||
Balance(Address), | ||
XcallManager, | ||
XCall, | ||
IconBnusd, | ||
UpgradeAuthority | ||
} | ||
|
||
pub fn set_xcall_manager(e: &Env, value: Address) { | ||
e.storage().instance().set(&DataKey::XcallManager, &value); | ||
} | ||
|
||
pub fn set_xcall(e: &Env, value: Address) { | ||
e.storage().instance().set(&DataKey::XCall, &value); | ||
} | ||
|
||
pub fn set_icon_bnusd(e: &Env, value: String) { | ||
e.storage().instance().set(&DataKey::IconBnusd, &value); | ||
} | ||
|
||
pub fn set_upgrade_authority(e: &Env, value: Address) { | ||
e.storage().instance().set(&DataKey::UpgradeAuthority, &value); | ||
} | ||
|
||
pub fn has_upgrade_auth(e: &Env) -> bool { | ||
let key = DataKey::UpgradeAuthority; | ||
e.storage().instance().has(&key) | ||
} | ||
|
||
pub fn get_xcall_manager(e: &Env) -> Result<Address, ContractError> { | ||
let key = DataKey::XcallManager; | ||
e.storage() | ||
.instance() | ||
.get(&key) | ||
.ok_or(ContractError::Uninitialized)} | ||
|
||
pub fn get_xcall(e: &Env) -> Result<Address, ContractError> { | ||
let key = DataKey::XCall; | ||
e.storage() | ||
.instance() | ||
.get(&key) | ||
.ok_or(ContractError::Uninitialized)} | ||
|
||
pub fn get_icon_bnusd(e: &Env) -> Result<String, ContractError> { | ||
let key = DataKey::IconBnusd; | ||
e.storage() | ||
.instance() | ||
.get(&key) | ||
.ok_or(ContractError::Uninitialized)} | ||
|
||
pub fn get_upgrade_authority(e: &Env) -> Result<Address, ContractError> { | ||
let key = DataKey::UpgradeAuthority; | ||
e.storage() | ||
.instance() | ||
.get(&key) | ||
.ok_or(ContractError::Uninitialized)} | ||
|
||
|
||
|
||
|
This file contains 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
File renamed without changes.
Oops, something went wrong.