Skip to content

Commit 98f436f

Browse files
committed
fix: tolerate missing properties in chain sync
Signed-off-by: William Richter <[email protected]>
1 parent 6702aef commit 98f436f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

fearless/Common/Services/ChainRegistry/ChainSyncService.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,23 @@ final class ChainSyncService {
137137
"tokens": []
138138
]
139139
}
140+
141+
if array[i]["properties"] == nil {
142+
let prefixValue = array[i]["addressPrefix"]
143+
let prefixString: String
144+
145+
if let intValue = prefixValue as? Int {
146+
prefixString = String(intValue)
147+
} else if let stringValue = prefixValue as? String {
148+
prefixString = stringValue
149+
} else if let number = prefixValue as? NSNumber {
150+
prefixString = number.stringValue
151+
} else {
152+
prefixString = "0"
153+
}
154+
155+
array[i]["properties"] = ["addressPrefix": prefixString]
156+
}
140157
}
141158

142159
return try JSONSerialization.data(withJSONObject: array, options: [])

0 commit comments

Comments
 (0)