Skip to content

Commit e607b9f

Browse files
Merge branch 'develop' into feature/EIP-1559
2 parents 41a2814 + beea97d commit e607b9f

38 files changed

+1134
-789
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@ jobs:
3232
run: swift package resolve
3333
- name: Build
3434
run: swift build --build-tests
35-
# - name: Run local tests
36-
# run: swift test --skip-build -c debug --filter localTests
35+
- name: Install ganache
36+
run: npm install ganache --global
37+
- name: Start ganache in background
38+
run: ganache &
39+
- name: Wait till ganache starts
40+
run: sleep 1
41+
- name: Run local tests
42+
run: swift test --skip-build -c debug --filter localTests
43+
# - name: Run remote tests
44+
# run: swift test --skip-build -c debug --filter remoteTests
3745
carthage:
3846
name: Carthage
3947
runs-on: macOS-11
@@ -53,5 +61,13 @@ jobs:
5361
run: carthage build --no-use-binaries --platform iOS Simulator --use-xcframeworks
5462
- name: Building framework
5563
run: xcodebuild build-for-testing -project "web3swift.xcodeproj" -scheme "web3swift" -destination "${{matrix.destination}}" -testPlan LocalTests
56-
# - name: Running local tests
57-
# run: xcodebuild test-without-building -project "web3swift.xcodeproj" -scheme "web3swift" -destination "${{matrix.destination}}" -testPlan LocalTests
64+
- name: Install ganache
65+
run: npm install ganache --global
66+
- name: Start ganache in background
67+
run: ganache &
68+
- name: Wait till ganache starts
69+
run: sleep 1
70+
- name: Run local tests
71+
run: xcodebuild test-without-building -project "web3swift.xcodeproj" -scheme "web3swift" -destination "${{matrix.destination}}" -testPlan LocalTests
72+
# - name: Run remote tests
73+
# run: xcodebuild test-without-building -project "web3swift.xcodeproj" -scheme "web3swift" -destination "${{matrix.destination}}" -testPlan RemoteTests

CHANGELOG.md

Lines changed: 528 additions & 237 deletions
Large diffs are not rendered by default.

Package.resolved

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

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let package = Package(
4242
.testTarget(
4343
name: "localTests",
4444
dependencies: ["web3swift"],
45-
path: "Tests/web3swiftTests/local_tests",
45+
path: "Tests/web3swiftTests/localTests",
4646
resources: [
4747
.copy("../../../TestToken/Helpers/SafeMath/SafeMath.sol"),
4848
.copy("../../../TestToken/Helpers/TokenBasics/ERC20.sol"),
@@ -53,7 +53,7 @@ let package = Package(
5353
.testTarget(
5454
name: "remoteTests",
5555
dependencies: ["web3swift"],
56-
path: "Tests/web3swiftTests/infura_tests",
56+
path: "Tests/web3swiftTests/remoteTests",
5757
resources: [
5858
.copy("../../../TestToken/Helpers/SafeMath/SafeMath.sol"),
5959
.copy("../../../TestToken/Helpers/TokenBasics/ERC20.sol"),

Sources/web3swift/Convenience/Data+Extension.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import Foundation
99
public extension Data {
1010

1111
init<T>(fromArray values: [T]) {
12-
var values = values
13-
self.init(buffer: UnsafeBufferPointer(start: &values, count: values.count))
12+
let values = values
13+
let ptrUB = values.withUnsafeBufferPointer { (ptr: UnsafeBufferPointer) in return ptr }
14+
self.init(buffer: ptrUB)
1415
}
1516

1617
func toArray<T>(type: T.Type) throws -> [T] {

Sources/web3swift/Convenience/SECP256k1.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension SECP256K1 {
116116
let result = privateKey.withUnsafeBytes { (pkRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in
117117
if let pkRawPointer = pkRawBufferPointer.baseAddress, pkRawBufferPointer.count > 0 {
118118
let privateKeyPointer = pkRawPointer.assumingMemoryBound(to: UInt8.self)
119-
let res = secp256k1_ec_pubkey_create(context!, UnsafeMutablePointer<secp256k1_pubkey>(&publicKey), privateKeyPointer)
119+
let res = secp256k1_ec_pubkey_create(context!, &publicKey, privateKeyPointer)
120120
return res
121121
} else {
122122
return nil
@@ -163,7 +163,7 @@ extension SECP256K1 {
163163
let result = serializedKey.withUnsafeBytes { (serializedKeyRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in
164164
if let serializedKeyRawPointer = serializedKeyRawBufferPointer.baseAddress, serializedKeyRawBufferPointer.count > 0 {
165165
let serializedKeyPointer = serializedKeyRawPointer.assumingMemoryBound(to: UInt8.self)
166-
let res = secp256k1_ec_pubkey_parse(context!, UnsafeMutablePointer<secp256k1_pubkey>(&publicKey), serializedKeyPointer, keyLen)
166+
let res = secp256k1_ec_pubkey_parse(context!, &publicKey, serializedKeyPointer, keyLen)
167167
return res
168168
} else {
169169
return nil

Sources/web3swift/EthereumABI/ABIDecoding.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ extension ABIDecoder {
205205
guard data.count >= pointer + type.memoryUsage else {return (nil, nil)}
206206
let dataSlice = data[pointer ..< pointer + type.memoryUsage]
207207
let bn = BigUInt(dataSlice)
208-
if bn > UINT64_MAX || bn >= data.count {
208+
if bn > UInt64.max || bn >= data.count {
209209
// there are ERC20 contracts that use bytes32 intead of string. Let's be optimistic and return some data
210210
if case .string = type {
211211
let nextElement = pointer + type.memoryUsage

Sources/web3swift/KeystoreManager/BIP32HDNode.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ public class HDNode {
7979
}
8080
depth = data[4..<5].bytes[0]
8181
parentFingerprint = data[5..<9]
82-
let cNum = data[9..<13].bytes
83-
childNumber = UnsafePointer(cNum).withMemoryRebound(to: UInt32.self, capacity: 1) {
84-
$0.pointee
85-
}
82+
childNumber = data[9..<13].bytes.withUnsafeBytes { $0.load(as: UInt32.self) }
8683
chaincode = data[13..<45]
8784
if serializePrivate {
8885
privateKey = data[46..<78]

0 commit comments

Comments
 (0)