Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: convertToData handles Bool #750

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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