From 58b2e4fc9c982e14f852e85ae510247a96a08f44 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Wed, 1 Feb 2023 18:08:53 +0200 Subject: [PATCH] feat: convertToData handles Bool --- Sources/Web3Core/EthereumABI/ABIEncoding.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Web3Core/EthereumABI/ABIEncoding.swift b/Sources/Web3Core/EthereumABI/ABIEncoding.swift index f62177ec8..727196a10 100755 --- a/Sources/Web3Core/EthereumABI/ABIEncoding.swift +++ b/Sources/Web3Core/EthereumABI/ABIEncoding.swift @@ -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. @@ -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 }