Skip to content

Commit

Permalink
Merge pull request #750 from JeneaVranceanu/feat/convert-bool-to-data
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslavyaroslav authored Feb 4, 2023
2 parents 84ce50f + 3ed6d08 commit e08de34
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/Web3Core/EthereumABI/ABIEncoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public struct ABIEncoder {

/// Attempts to convert given object into `Data`.
/// Used as a part of ABI encoding process.
/// Supported types are `Data`, `String`, `[UInt8]`, ``EthereumAddress`` and `[IntegerLiteralType]`.
/// Supported types are `Data`, `String`, `[UInt8]`, ``EthereumAddress``, `[IntegerLiteralType]` and `Bool`.
/// Note: if `String` has `0x` prefix an attempt to interpret it as a hexadecimal number will take place. Otherwise, UTF-8 bytes are returned.
/// - Parameter value: any object.
/// - Returns: `Data` representation of an object ready for ABI encoding.
Expand All @@ -123,6 +123,8 @@ public struct ABIEncoder {
bytesArray.append(UInt8(el))
}
return Data(bytesArray)
case let b as Bool:
return b ? Data([UInt8(1)]) : Data(count: 1)
default:
return nil
}
Expand Down

0 comments on commit e08de34

Please sign in to comment.