Skip to content

Commit 1e5ec85

Browse files
Merge branch 'develop' into ganache-tests
2 parents 11d64d9 + 2c755ba commit 1e5ec85

File tree

10 files changed

+49
-36
lines changed

10 files changed

+49
-36
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
- hotfix
99
- ganache-tests
1010
paths:
11+
- Packag*.swift
12+
- web3swift.podspec
13+
- Cartfile
1114
- Sources/**
1215
- 'Tests/**'
1316
- 'web3swift*/**'

Cartfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github "attaswift/BigInt" ~> 5.2.1
1+
github "attaswift/BigInt" ~> 5.3.0
22
github "attaswift/SipHash" ~> 1.2.2
33
github "daltoniam/Starscream" ~> 4.0.4
4-
github "krzyzanowskim/CryptoSwift" ~> 1.4.0
5-
github "mxcl/PromiseKit" ~> 6.15.3
4+
github "krzyzanowskim/CryptoSwift" ~> 1.4.2
5+
github "mxcl/PromiseKit" ~> 6.16.2

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ github "attaswift/BigInt" "v5.3.0"
22
github "attaswift/SipHash" "v1.2.2"
33
github "daltoniam/Starscream" "4.0.4"
44
github "krzyzanowskim/CryptoSwift" "1.4.2"
5-
github "mxcl/PromiseKit" "6.16.1"
5+
github "mxcl/PromiseKit" "6.16.2"

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let package = Package(
2323

2424
dependencies: [
2525
.package(url: "https://github.com/attaswift/BigInt.git", from: "5.3.0"),
26-
.package(url: "https://github.com/mxcl/PromiseKit.git", from: "6.15.4"),
26+
.package(url: "https://github.com/mxcl/PromiseKit.git", from: "6.16.2"),
2727
.package(url: "https://github.com/daltoniam/Starscream.git", from: "4.0.4"),
2828
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.4.2")
2929
],

Sources/web3swift/EthereumABI/ABIElements.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,40 @@ extension ABI.Element {
187187
case .fallback(_):
188188
return nil
189189
case .function(let function):
190+
// the response size greater than equal 100 bytes, when read function aborted by "require" statement.
191+
// if "require" statement has no message argument, the response is empty (0 byte).
192+
if( data.bytes.count >= 100 ){
193+
let check00_31 = BigUInt( "08C379A000000000000000000000000000000000000000000000000000000000", radix:16 )!
194+
let check32_63 = BigUInt( "0000002000000000000000000000000000000000000000000000000000000000", radix:16 )!
195+
196+
// check data[00-31] and data[32-63]
197+
if check00_31 == BigUInt( data[0...31] ) && check32_63 == BigUInt( data[32...63] ) {
198+
// data.bytes[64-67] contains the length of require message
199+
let len = (Int(data.bytes[64])<<24) | (Int(data.bytes[65])<<16) | (Int(data.bytes[66])<<8) | Int(data.bytes[67])
200+
201+
let message = String( bytes:data.bytes[68..<(68+len)], encoding:.utf8 )!
202+
203+
print( "read function aborted by require statement: \(message)" )
204+
205+
var returnArray = [String:Any]()
206+
207+
// set infomation
208+
returnArray["_abortedByRequire"] = true
209+
returnArray["_errorMessageFromRequire"] = message
210+
211+
// set empty values
212+
for i in 0 ..< function.outputs.count {
213+
let name = "\(i)"
214+
returnArray[name] = function.outputs[i].type.emptyValue
215+
if function.outputs[i].name != "" {
216+
returnArray[function.outputs[i].name] = function.outputs[i].type.emptyValue
217+
}
218+
}
219+
220+
return returnArray
221+
}
222+
}
223+
// the "require" statement with no message argument will be caught here
190224
if (data.count == 0 && function.outputs.count == 1) {
191225
let name = "0"
192226
let value = function.outputs[0].type.emptyValue
@@ -210,6 +244,8 @@ extension ABI.Element {
210244
}
211245
i = i + 1
212246
}
247+
// set a flag to detect the request succeeded
248+
returnArray["_success"] = true
213249
return returnArray
214250
case .receive(_):
215251
return nil

Sources/web3swift/KeystoreManager/BIP32HDNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ extension HDNode {
231231
let newNode = HDNode()
232232
newNode.chaincode = cc
233233
newNode.depth = self.depth + 1
234-
newNode.publicKey = pubKeyCandidate
234+
newNode.publicKey = newPublicKey
235235
newNode.childNumber = index
236236
guard let fprint = try? RIPEMD160.hash(message: self.publicKey.sha256())[0..<4] else {
237237
return nil

web3swift.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'web3swift'
3-
spec.version = '2.3.0'
3+
spec.version = '2.5.0'
44
spec.ios.deployment_target = "9.0"
5-
spec.osx.deployment_target = "10.11"
5+
spec.osx.deployment_target = "10.12"
66
spec.license = { :type => 'Apache License 2.0', :file => 'LICENSE.md' }
77
spec.summary = 'Web3 implementation in vanilla Swift for iOS, macOS, and Linux'
88
spec.homepage = 'https://github.com/matter-labs/web3swift'
@@ -13,9 +13,9 @@ Pod::Spec.new do |spec|
1313
spec.resource_bundle = { "Browser" => "Sources/web3swift/Browser/*.js" }
1414
spec.swift_version = '5.0'
1515
spec.frameworks = 'CoreImage'
16-
spec.dependency 'BigInt', '~> 5.2'
16+
spec.dependency 'BigInt', '~> 5.2.0'
1717
spec.dependency 'Starscream', '~> 4.0.4'
18-
spec.dependency 'CryptoSwift', '~> 1.4.0'
18+
spec.dependency 'CryptoSwift', '~> 1.4.2'
1919
spec.dependency 'secp256k1.c', '~> 0.1'
2020
spec.dependency 'PromiseKit', '~> 6.15.3'
2121
end

web3swift.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 10 deletions
This file was deleted.

web3swift.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

Lines changed: 0 additions & 8 deletions
This file was deleted.

web3swift.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)