MCPcopy Create free account
hub / github.com/dfinity/orbit / validate_address

Method validate_address

core/station/impl/src/models/account.rs:126–146  ·  view source on GitHub ↗
(&self, address: &str)

Source from the content-addressed store, hash-verified

124
125impl AddressFormat {
126 pub fn validate_address(&self, address: &str) -> ModelValidatorResult<AccountError> {
127 match self {
128 AddressFormat::ICPAccountIdentifier => AccountIdentifier::from_hex(address)
129 .map_err(|_| AccountError::InvalidAddress {
130 address: address.to_string(),
131 address_format: self.to_string(),
132 })
133 .map(|_| ()),
134 AddressFormat::ICRC1Account => {
135 icrc_ledger_types::icrc1::account::Account::from_str(address)
136 .map_err(|_| AccountError::InvalidAddress {
137 address: address.to_string(),
138 address_format: self.to_string(),
139 })
140 .map(|_| ())
141 }
142 AddressFormat::EthereumAddress => todo!(),
143 AddressFormat::BitcoinAddressP2WPKH => todo!(),
144 AddressFormat::BitcoinAddressP2TR => todo!(),
145 }
146 }
147}
148
149impl AccountAddress {

Callers 2

validateMethod · 0.80

Calls 1

mapMethod · 0.80

Tested by 1