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 struct ConfirmedTransaction: Decodable {4 public let message: Message5 public let signatures: [String]6}78public extension ConfirmedTransaction {9 struct Message: Decodable {10 public let accountKeys: [AccountMeta]11 public let instructions: [ParsedInstruction]12 public let recentBlockhash: String13 }14}1516public struct ParsedInstruction: Decodable {17 public struct Parsed: Decodable {18 public struct Info: Decodable {19 public let owner: String?20 public let account: String?21 public let source: String?22 public let destination: String?2324 // create account25 public let lamports: UInt64?26 public let newAccount: String?27 public let space: UInt64?2829 // initialize account30 public let mint: String?31 public let rentSysvar: String?3233 // approve34 public let amount: String?35 public let delegate: String?3637 // transfer38 public let authority: String?39 public let wallet: String? // spl-associated-token-account4041 // transferChecked42 public let tokenAmount: TokenAccountBalance?43 }4445 public let info: Info46 public let type: String?47 }4849 public let program: String?50 public let programId: String51 public let parsed: Parsed?5253 // swap54 public let data: String?55 public let accounts: [String]?5657 public enum CodingKeys: CodingKey {58 case program59 case programId60 case parsed61 case data62 case accounts63 }6465 public init(from decoder: Decoder) throws {66 let container = try decoder.container(keyedBy: CodingKeys.self)67 program = try container.decodeIfPresent(String.self, forKey: .program)68 programId = try container.decode(String.self, forKey: .programId)69 parsed = try? container.decodeIfPresent(ParsedInstruction.Parsed.self, forKey: .parsed)70 data = try container.decodeIfPresent(String.self, forKey: .data)71 accounts = try container.decodeIfPresent([String].self, forKey: .accounts)72 }73}7475extension Sequence where Iterator.Element == ParsedInstruction {76 func containProgram(with name: String) -> Bool {77 getFirstProgram(with: name) != nil78 }7980 func getFirstProgram(with name: String) -> ParsedInstruction? {81 first(where: { $0.program == name })82 }83}84