Skip to content

Commit d0b84ab

Browse files
committed
feat: Add comprehensive Sendable conformance and thread safety
- https://argent.atlassian.net/browse/IOS-3436 Summary: - Add ThreadSafeBox utility class for thread-safe property wrapper - Implement Sendable conformance across all major classes and protocols: - Client classes (EthereumHttpClient, EthereumWebSocketClient, etc.) - ENS classes (ENSResolver, ENSMultiResolver, EthereumNameService) - ERC standard implementations (ERC20, ERC721, ERC1271, ERC165) - Account management (EthereumAccount, EthereumKeyLocalStorage) - Contract and ABI types - Network providers and utilities - Convert ENSResolver to use thread-safe property access with ThreadSafeBox - Fix ENSMultiResolver thread safety with atomic operations for queries and responses - Update EthereumKeyLocalStorage with thread-safe address handling - Mark classes as final where appropriate for performance - Use @unchecked Sendable for classes with internal synchronization - Update test classes to conform to Sendable requirements - Ensure all protocols inherit Sendable conformance where needed This enables safe concurrent usage across the entire web3.swift library while maintaining backward compatibility and performance.
1 parent 7df5fee commit d0b84ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+750
-440
lines changed

Package.resolved

Lines changed: 157 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.3
1+
// swift-tools-version:5.9
22
import PackageDescription
33

44
let package = Package(
@@ -13,11 +13,11 @@ let package = Package(
1313
.library(name: "web3-zksync.swift", targets: ["web3-zksync"])
1414
],
1515
dependencies: [
16-
.package(name: "BigInt", url: "https://github.com/attaswift/BigInt", from: "5.3.0"),
17-
.package(name: "GenericJSON", url: "https://github.com/iwill/generic-json-swift", .upToNextMajor(from: "2.0.0")),
16+
.package(url: "https://github.com/attaswift/BigInt", from: "5.3.0"),
17+
.package(url: "https://github.com/iwill/generic-json-swift", .upToNextMajor(from: "2.0.2")),
1818
.package(url: "https://github.com/GigaBitcoin/secp256k1.swift.git", .upToNextMajor(from: "0.6.0")),
19-
.package(url: "https://github.com/vapor/websocket-kit.git", from: "2.0.0"),
20-
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0")
19+
.package(url: "https://github.com/vapor/websocket-kit.git", from: "2.16.1"),
20+
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.4")
2121
],
2222
targets: [
2323
.target(
@@ -28,7 +28,7 @@ let package = Package(
2828
.target(name: "aes"),
2929
.target(name: "Internal_CryptoSwift_PBDKF2"),
3030
"BigInt",
31-
"GenericJSON",
31+
.product(name: "GenericJSON", package: "generic-json-swift"),
3232
.product(name: "secp256k1", package: "secp256k1.swift"),
3333
.product(name: "WebSocketKit", package: "websocket-kit"),
3434
.product(name: "Logging", package: "swift-log")
@@ -70,6 +70,14 @@ let package = Package(
7070
.copy("Account/cryptofights_712.json"),
7171
.copy("Account/ethermail_signTypedDataV4.json"),
7272
.copy("Account/real_word_opensea_signTypedDataV4.json"),
73+
.copy("Resources/ERC1271CheckerBool.sol"),
74+
.copy("Resources/TestERC721.sol"),
75+
.copy("Resources/ERC1271Checker.sol"),
76+
.copy("Resources/Multicall2.sol"),
77+
.copy("Resources/ERC721Metadata.json"),
78+
.copy("Resources/ABITests.sol"),
79+
.copy("Resources/ERC165Sample.sol"),
80+
.copy("Resources/DummyOffchainResolver.sol"),
7381
]
7482
)
7583
]

[email protected]

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// swift-tools-version:6.1
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "web3.swift",
6+
platforms: [
7+
.iOS(SupportedPlatform.IOSVersion.v13),
8+
.macOS(SupportedPlatform.MacOSVersion.v11),
9+
.watchOS(.v7)
10+
],
11+
products: [
12+
.library(name: "web3.swift", targets: ["web3"]),
13+
.library(name: "web3-zksync.swift", targets: ["web3-zksync"])
14+
],
15+
dependencies: [
16+
.package(url: "https://github.com/attaswift/BigInt", from: "5.3.0"),
17+
.package(url: "https://github.com/iwill/generic-json-swift", .upToNextMajor(from: "2.0.2")),
18+
.package(url: "https://github.com/GigaBitcoin/secp256k1.swift.git", .upToNextMajor(from: "0.6.0")),
19+
.package(url: "https://github.com/vapor/websocket-kit.git", from: "2.16.1"),
20+
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.4")
21+
],
22+
targets: [
23+
.target(
24+
name: "web3",
25+
dependencies:
26+
[
27+
.target(name: "keccaktiny"),
28+
.target(name: "aes"),
29+
.target(name: "Internal_CryptoSwift_PBDKF2"),
30+
"BigInt",
31+
.product(name: "GenericJSON", package: "generic-json-swift"),
32+
.product(name: "secp256k1", package: "secp256k1.swift"),
33+
.product(name: "WebSocketKit", package: "websocket-kit"),
34+
.product(name: "Logging", package: "swift-log")
35+
],
36+
path: "web3swift/src",
37+
exclude: ["ZKSync"]
38+
),
39+
.target(
40+
name: "web3-zksync",
41+
dependencies:
42+
[
43+
.target(name: "web3")
44+
],
45+
path: "web3swift/src/ZKSync"
46+
),
47+
.target(
48+
name: "keccaktiny",
49+
dependencies: [],
50+
path: "web3swift/lib/keccak-tiny",
51+
exclude: ["module.map"]
52+
),
53+
.target(
54+
name: "aes",
55+
dependencies: [],
56+
path: "web3swift/lib/aes",
57+
exclude: ["module.map"]
58+
),
59+
.target(
60+
name: "Internal_CryptoSwift_PBDKF2",
61+
dependencies: [],
62+
path: "web3swift/lib/CryptoSwift"
63+
),
64+
.testTarget(
65+
name: "web3swiftTests",
66+
dependencies: ["web3", "web3-zksync"],
67+
path: "web3sTests",
68+
resources: [
69+
.copy("Resources/rlptests.json"),
70+
.copy("Account/cryptofights_712.json"),
71+
.copy("Account/ethermail_signTypedDataV4.json"),
72+
.copy("Account/real_word_opensea_signTypedDataV4.json"),
73+
.copy("Resources/ERC1271CheckerBool.sol"),
74+
.copy("Resources/TestERC721.sol"),
75+
.copy("Resources/ERC1271Checker.sol"),
76+
.copy("Resources/Multicall2.sol"),
77+
.copy("Resources/ERC721Metadata.json"),
78+
.copy("Resources/ABITests.sol"),
79+
.copy("Resources/ERC165Sample.sol"),
80+
.copy("Resources/DummyOffchainResolver.sol"),
81+
]
82+
)
83+
]
84+
)

0 commit comments

Comments
 (0)