mirror of
https://github.com/lil-org/wallet.git
synced 2025-01-07 13:46:25 +03:00
30 lines
747 B
Swift
30 lines
747 B
Swift
// Copyright © 2022 Tokenary. All rights reserved.
|
|
|
|
import WalletCore
|
|
|
|
extension Account {
|
|
|
|
var croppedAddress: String {
|
|
let dropFirstCount: Int
|
|
switch coin {
|
|
case .ethereum:
|
|
dropFirstCount = 2
|
|
case .near, .solana:
|
|
dropFirstCount = 0
|
|
default:
|
|
fatalError(Strings.somethingWentWrong)
|
|
}
|
|
let withoutCommonPart = String(address.dropFirst(dropFirstCount))
|
|
return withoutCommonPart.prefix(4) + "..." + withoutCommonPart.suffix(4)
|
|
}
|
|
|
|
var image: Image? {
|
|
if coin == .ethereum {
|
|
return Blockies(seed: address.lowercased()).createImage()
|
|
} else {
|
|
return Images.logo(coin: coin)
|
|
}
|
|
}
|
|
|
|
}
|