Skip to content

Add Sendable conformance to various structs and enums #894

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

Merged
merged 1 commit into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 2 deletions Sources/Web3Core/EthereumAddress/EthereumAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import Foundation
import CryptoSwift

public struct EthereumAddress: Equatable {
public enum AddressType {
public struct EthereumAddress: Equatable, Sendable {
public enum AddressType: Sendable {
case normal
case contractDeployment
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Web3Core/KeystoreManager/BIP32Keystore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class BIP32Keystore: AbstractKeystore {

private static let KeystoreParamsBIP32Version = 4

public private (set) var addressStorage: PathAddressStorage
public private(set) var addressStorage: PathAddressStorage

public convenience init?(_ jsonString: String) {
let lowercaseJSON = jsonString.lowercased()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Web3Core/Structure/Block/BlockNumber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import BigInt

public enum BlockNumber: CustomStringConvertible {
public enum BlockNumber: CustomStringConvertible, Sendable {

case pending
/// Latest block of a chain
Expand Down
2 changes: 1 addition & 1 deletion Sources/Web3Core/Transaction/CodableTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import BigInt
/// Structure capable of carying the parameters for any transaction type.
/// While most fields in this struct are optional, they are not necessarily
/// optional for the type of transaction they apply to.
public struct CodableTransaction {
public struct CodableTransaction: Sendable {
/// internal access only. The transaction envelope object itself that contains all the transaction data
/// and type specific implementation
internal var envelope: AbstractEnvelope
Expand Down
4 changes: 2 additions & 2 deletions Sources/Web3Core/Transaction/Envelope/AbstractEnvelope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import BigInt
*/

/// Enumeration for supported transaction types
public enum TransactionType: UInt, CustomStringConvertible, CaseIterable {
public enum TransactionType: UInt, CustomStringConvertible, CaseIterable, Sendable {

/// For untyped and type 0 transactions EIP155 and older
case legacy
Expand Down Expand Up @@ -62,7 +62,7 @@ public enum EncodeType {
/// All envelopes must conform to this protocol to work with `CodableTransaction`
/// each implementation holds all the type specific data
/// and implements the type specific encoding/decoding
protocol AbstractEnvelope: CustomStringConvertible { // possibly add Codable?
protocol AbstractEnvelope: CustomStringConvertible, Sendable { // possibly add Codable?

/// The type of transaction this envelope represents
var type: TransactionType { get }
Expand Down
3 changes: 2 additions & 1 deletion Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Foundation
import BigInt

public struct EIP2930Envelope: EIP2718Envelope, EIP2930Compatible {

public let type: TransactionType = .eip2930

// common parameters for any transaction
Expand Down Expand Up @@ -221,7 +222,7 @@ extension EIP2930Envelope {
}
}

public struct AccessListEntry: CustomStringConvertible, Codable {
public struct AccessListEntry: CustomStringConvertible, Codable, Sendable {
var address: EthereumAddress
var storageKeys: [BigUInt]

Expand Down
2 changes: 1 addition & 1 deletion Sources/Web3Core/Transaction/TransactionMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BigInt
/// returned by nodes when reading a transaction
/// from the blockchain. The data here is not
/// part of the transaction itself
public struct TransactionMetadata {
public struct TransactionMetadata: Sendable {

/// hash for the block that contains this transaction on chain
public var blockHash: Data?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public final class ERC20BasePropertiesProvider {
var decimals: UInt8?

private let contract: Web3.Contract
private (set) var hasReadProperties: Bool = false
private(set) var hasReadProperties: Bool = false
init(contract: Web3.Contract) {
self.contract = contract
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/web3swiftTests/localTests/EventloopTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EventloopTests: XCTestCase {
let expectation = self.expectation(description: "Waiting")
func getBlockNumber(_ web3: Web3) async {
do {
let blockNumber = try await web3.eth.blockNumber()
_ = try await web3.eth.blockNumber()
ticksToWait = ticksToWait - 1
if ticksToWait == 0 {
expectation.fulfill()
Expand Down
Loading