tokenary/Shared/Extension/Account.swift
Ivan Grachev f631e61565 Add Near
2022-05-09 16:22:14 +03:00

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)
}
}
}