| 124 | |
| 125 | impl 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 | |
| 149 | impl AccountAddress { |