spb/os-vault Public
Self-custody, multi-chain crypto wallet for macOS. One recovery phrase, six chain families, zero API keys — nothing leaves your Mac.
Swift 96%
Shell 3.4%
Makefile 0.6%
1//2// Asset.swift3// OS Vault4//5// Author: Simon-Pierre Boucher6// Mail: contact@spboucher.ai7//89import Foundation1011/// Anything the wallet can send on an EVM chain: the chain's native coin12/// (ETH, POL, BNB, AVAX, xDAI… — also the gas currency) or a registered13/// ERC-20 stablecoin. Native symbol/name depend on the chain, so they are14/// resolved against a Network.15public enum Asset: Identifiable, Hashable, Sendable {16 case native17 case token(Token)1819 public var id: String {20 switch self {21 case .native: return "native"22 case .token(let token): return "token-\(token.symbol)"23 }24 }2526 public func symbol(on network: Network) -> String {27 switch self {28 case .native: return network.config.nativeSymbol29 case .token(let token): return token.symbol30 }31 }3233 public func name(on network: Network) -> String {34 switch self {35 case .native: return network.config.nativeName36 case .token(let token): return token.name37 }38 }3940 /// All supported natives are 18 decimals (ETH, POL, BNB, AVAX, xDAI).41 public var decimals: Int {42 switch self {43 case .native: return 1844 case .token(let token): return token.decimals45 }46 }4748 public static func available(on network: Network) -> [Asset] {49 Token.available(on: network).map(Asset.token) + [.native]50 }51}52