Skip to content

Commit

Permalink
fix: fixing cast error
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Mar 4, 2024
1 parent a9e5559 commit bb46b66
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/EOSIO/ABIDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ public extension ABIDecoder {
case is UInt.Type:
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 {
throw Error.typeNotConformingToABIDecodable(type)
}
default:
throw Error.typeNotConformingToABIDecodable(type)
}
Expand Down

0 comments on commit bb46b66

Please sign in to comment.