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%
1import Foundation23public enum SocketEntity: String {4 case account5 case signature6 case logs7 case program8 case slot9}1011public enum SocketAction: String, CaseIterable {12 case subscribe13 case unsubscribe14 case notification15}1617public struct SocketMethod: Equatable, RawRepresentable {18 public let entity: SocketEntity19 public let action: SocketAction2021 public init(_ entity: SocketEntity, _ action: SocketAction) {22 self.entity = entity23 self.action = action24 }2526 public var rawValue: String {27 entity.rawValue + action.rawValue.capitalizingFirstLetter()28 }2930 public init?(rawValue: String) {31 for action in SocketAction.allCases {32 if rawValue.hasSuffix(action.rawValue.capitalizingFirstLetter()),33 let entity = SocketEntity(rawValue: rawValue34 .replacingOccurrences(of: action.rawValue.capitalizingFirstLetter(), with: ""))35 {36 self.action = action37 self.entity = entity38 return39 }40 }41 return nil42 }43}4445private extension String {46 func capitalizingFirstLetter() -> String {47 prefix(1).uppercased() + lowercased().dropFirst()48 }4950 mutating func capitalizeFirstLetter() {51 self = capitalizingFirstLetter()52 }53}54