From ecbb0c11e5dfe23981c5cd148e0cd91a4993ce0c Mon Sep 17 00:00:00 2001 From: lmcmz Date: Thu, 19 Sep 2024 21:41:58 +1000 Subject: [PATCH] Update FlowAccount.swift --- Sources/Models/FlowAccount.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/Models/FlowAccount.swift b/Sources/Models/FlowAccount.swift index 68c9cf8..d24897f 100644 --- a/Sources/Models/FlowAccount.swift +++ b/Sources/Models/FlowAccount.swift @@ -26,7 +26,7 @@ public extension Flow { public let address: Address /// The balance of account in `BigInt` type - public let balance: BigInt + public let balance: BigInt? /// The list of public key in `Flow.AccountKey` type public var keys: [AccountKey] @@ -34,18 +34,22 @@ public extension Flow { /// The dictionary of all cadence contracts public var contracts: [String: Code]? - public init(address: Flow.Address, balance: BigInt, keys: [Flow.AccountKey], contracts: [String: Flow.Code]) { + public init(address: Flow.Address, balance: BigInt? = nil, keys: [Flow.AccountKey], contracts: [String: Flow.Code]? = nil) { self.address = address self.balance = balance self.keys = keys self.contracts = contracts } - public init(address: Flow.Address, balance: UInt64, keys: [Flow.AccountKey], contracts: [String: Flow.Code]) { + public init(address: Flow.Address, balance: UInt64? = nil, keys: [Flow.AccountKey], contracts: [String: Flow.Code]? = nil) { self.address = address - self.balance = BigInt(balance) self.keys = keys self.contracts = contracts + if let balance { + self.balance = BigInt(balance) + } else { + self.balance = nil + } } public init(from decoder: Decoder) throws {