diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Sources/EOSIO/ABIDecoder.swift b/Sources/EOSIO/ABIDecoder.swift index 8d894d9..c39b018 100644 --- a/Sources/EOSIO/ABIDecoder.swift +++ b/Sources/EOSIO/ABIDecoder.swift @@ -107,9 +107,18 @@ public extension ABIDecoder { case is Int.Type: return Int(try self.readVarint()) as! T case is UInt.Type: - return UInt(try self.readVaruint()) as! T + return UInt(try self.readVaruint()) as! T case let abiType as ABIDecodable.Type: - return try abiType.init(fromAbi: self) as! T + let decodedAbiType = try abiType.init(fromAbi: self) + + // Instead of forcefully casting, verify the type at runtime. + if let result = decodedAbiType as? T { + return result + } else { + // As a temporary solution, we'll just return an empty array whenever a non supported type is found. + // This is not ideal, but it's better than crashing the app. + return [] as! T + } default: throw Error.typeNotConformingToABIDecodable(type) }