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 TokenAccountState: TokenAccountLayoutState {4 public static let BUFFER_LENGTH: UInt64 = 16556 public let mint: PublicKey7 public let owner: PublicKey8 public let lamports: UInt649 public let delegateOption: UInt3210 public var delegate: PublicKey?11 public let isInitialized: Bool12 public let isFrozen: Bool13 public let state: UInt814 public let isNativeOption: UInt3215 public let rentExemptReserve: UInt64?16 public let isNativeRaw: UInt6417 public let isNative: Bool18 public var delegatedAmount: UInt6419 public let closeAuthorityOption: UInt3220 public var closeAuthority: PublicKey?2122 public init(23 mint: PublicKey,24 owner: PublicKey,25 lamports: UInt64,26 delegateOption: UInt32,27 delegate: PublicKey? = nil,28 isInitialized: Bool,29 isFrozen: Bool,30 state: UInt8,31 isNativeOption: UInt32,32 rentExemptReserve: UInt64? = nil,33 isNativeRaw: UInt64,34 isNative: Bool,35 delegatedAmount: UInt64,36 closeAuthorityOption: UInt32,37 closeAuthority: PublicKey? = nil38 ) {39 self.mint = mint40 self.owner = owner41 self.lamports = lamports42 self.delegateOption = delegateOption43 self.delegate = delegate44 self.isInitialized = isInitialized45 self.isFrozen = isFrozen46 self.state = state47 self.isNativeOption = isNativeOption48 self.rentExemptReserve = rentExemptReserve49 self.isNativeRaw = isNativeRaw50 self.isNative = isNative51 self.delegatedAmount = delegatedAmount52 self.closeAuthorityOption = closeAuthorityOption53 self.closeAuthority = closeAuthority54 }55}5657extension TokenAccountState: BorshCodable {58 public func serialize(to writer: inout Data) throws {59 try serializeCommonProperties(to: &writer)60 }6162 public init(from reader: inout BinaryReader) throws {63 mint = try .init(from: &reader)64 owner = try .init(from: &reader)65 lamports = try .init(from: &reader)66 delegateOption = try .init(from: &reader)67 let tempdelegate = try? PublicKey(from: &reader)68 state = try .init(from: &reader)69 isNativeOption = try .init(from: &reader)70 isNativeRaw = try .init(from: &reader)71 delegatedAmount = try .init(from: &reader)72 closeAuthorityOption = try .init(from: &reader)73 closeAuthority = try? PublicKey(from: &reader)7475 if delegateOption == 0 {76 delegate = nil77 delegatedAmount = 078 } else {79 delegate = tempdelegate80 }8182 isInitialized = state != 083 isFrozen = state == 28485 if isNativeOption == 1 {86 rentExemptReserve = isNativeRaw87 isNative = true88 } else {89 rentExemptReserve = nil90 isNative = false91 }9293 if closeAuthorityOption == 0 {94 closeAuthority = nil95 }96 }97}98