Skip to content

Commit e08de34

Browse files
Merge pull request #750 from JeneaVranceanu/feat/convert-bool-to-data
2 parents 84ce50f + 3ed6d08 commit e08de34

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/Web3Core/EthereumABI/ABIEncoding.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public struct ABIEncoder {
9898

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

0 commit comments

Comments
 (0)