Skip to content

Commit

Permalink
- bug fix: include ledger children in helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Aug 14, 2024
1 parent 2416714 commit d89988e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Sources/KukaiCoreSwift/Models/WalletMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public class WalletMetadataList: Codable, Hashable {

for metadata in ledgerWallets {
if metadata.address == address { return metadata }

for childMetadata in metadata.children {
if childMetadata.address == address { return childMetadata }
}
}

for metaData in watchWallets {
Expand Down Expand Up @@ -104,6 +108,10 @@ public class WalletMetadataList: Codable, Hashable {

for (index, metadata) in ledgerWallets.enumerated() {
if metadata.address == address { ledgerWallets[index] = newMetadata; return true }

for (childIndex, childMetadata) in metadata.children.enumerated() {
if childMetadata.address == address { hdWallets[index].children[childIndex] = newMetadata; return true }
}
}

for (index, metadata) in watchWallets.enumerated() {
Expand Down Expand Up @@ -154,12 +162,16 @@ public class WalletMetadataList: Codable, Hashable {
}

public func count() -> Int {
var total = (socialWallets.count + linearWallets.count + ledgerWallets.count + watchWallets.count)
var total = (socialWallets.count + linearWallets.count + watchWallets.count)

for wallet in hdWallets {
total += (1 + wallet.children.count)
}

for wallet in ledgerWallets {
total += (1 + wallet.children.count)
}

return total
}

Expand All @@ -184,6 +196,10 @@ public class WalletMetadataList: Codable, Hashable {

for metadata in ledgerWallets {
temp.append(metadata.address)

for childMetadata in metadata.children {
temp.append(childMetadata.address)
}
}

for metadata in watchWallets {
Expand Down

0 comments on commit d89988e

Please sign in to comment.