mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-12 12:33:42 +03:00
31 lines
768 B
Swift
31 lines
768 B
Swift
// Copyright © 2022 Tokenary. All rights reserved.
|
|
|
|
import WalletCore
|
|
import BlockiesSwift
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
}
|