forked from Vero-protocol/vero-core-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddress.rs
More file actions
23 lines (19 loc) · 851 Bytes
/
Copy pathaddress.rs
File metadata and controls
23 lines (19 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#![allow(missing_docs)]
use soroban_sdk::{Address, Env, String};
use crate::types::ContractError;
/// The Stellar "zero" account address (G... strkey for an all-zero public key).
/// Passing this address to administrative functions must be rejected to avoid
/// black-holing permissions or funds.
pub const ZERO_ADDRESS_STR: &str = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
/// Reject the Stellar zero-address.
///
/// Returns [`ContractError::InvalidAddress`] when `address` matches the
/// all-zero account strkey. This is the centralized sanitizer referenced in
/// issue #126.
pub fn validate_address(env: &Env, address: &Address) -> Result<(), ContractError> {
let zero = String::from_str(env, ZERO_ADDRESS_STR);
if address.to_string() == zero {
return Err(ContractError::InvalidAddress);
}
Ok(())
}