Skip to content

Commit

Permalink
Some cosmetics
Browse files Browse the repository at this point in the history
removed json file from tests #153
Updated swift version in podspec
  • Loading branch information
v57 committed Oct 3, 2018
1 parent 8245acf commit 6283602
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions web3swift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "web3swift"
s.version = "1.1.5"
s.version = "1.1.6"
s.summary = "Web3 implementation in vanilla Swift for iOS ans macOS"

s.description = <<-DESC
Expand All @@ -13,7 +13,7 @@ s.author = { "Alex Vlasov" => "[email protected]" }
s.source = { :git => 'https://github.com/bankex/web3swift.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/shamatar'

s.swift_version = '4.1'
s.swift_version = '4.2'
s.module_name = 'web3swift'
s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.11"
Expand Down
6 changes: 1 addition & 5 deletions web3swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
81DDECCF1FDF004E0063684A /* Web3.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81DDECCE1FDF004E0063684A /* Web3.swift */; };
81DFB3FF210775320011DC85 /* Web3+Infura.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81DFB3FE210775320011DC85 /* Web3+Infura.swift */; };
81DFB400210775320011DC85 /* Web3+Infura.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81DFB3FE210775320011DC85 /* Web3+Infura.swift */; };
81DFCC4C20F7546300603123 /* key.json in Resources */ = {isa = PBXBuildFile; fileRef = 81DFCC4B20F7546300603123 /* key.json */; };
81EB1E4B208173D7003BD47F /* Web3+Personal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81EB1E4A208173D7003BD47F /* Web3+Personal.swift */; };
81EB1E4C208173D7003BD47F /* Web3+Personal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81EB1E4A208173D7003BD47F /* Web3+Personal.swift */; };
81FA43F62044097100EE14D5 /* web3swift_macOS_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81FA43F52044097100EE14D5 /* web3swift_macOS_Tests.swift */; };
Expand Down Expand Up @@ -315,7 +314,7 @@
81A1824A20D7DF1B0016741F /* Promise+Web3+Personal+UnlockAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Promise+Web3+Personal+UnlockAccount.swift"; sourceTree = "<group>"; };
81C0FCEF20440C3600D82FAF /* Web3+Wallet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3+Wallet.swift"; sourceTree = "<group>"; };
81C0FCF120440EB500D82FAF /* Web3+Protocols.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+Protocols.swift"; sourceTree = "<group>"; };
81C0FCF320440F0900D82FAF /* Web3+Options.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+Options.swift"; sourceTree = "<group>"; };
81C0FCF320440F0900D82FAF /* Web3+Options.swift */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = "Web3+Options.swift"; sourceTree = "<group>"; tabWidth = 2; };
81C0FCF520440F9900D82FAF /* TransactionSigner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionSigner.swift; sourceTree = "<group>"; };
81C0FCF8204456E600D82FAF /* Web3+BrowserFunctions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+BrowserFunctions.swift"; sourceTree = "<group>"; };
81C0FCFC20449D1400D82FAF /* Web3+TransactionIntermediate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+TransactionIntermediate.swift"; sourceTree = "<group>"; };
Expand All @@ -335,7 +334,6 @@
81D7D97720A61E3800A193EC /* EventFiltering.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventFiltering.swift; sourceTree = "<group>"; };
81DDECCE1FDF004E0063684A /* Web3.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Web3.swift; sourceTree = "<group>"; };
81DFB3FE210775320011DC85 /* Web3+Infura.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3+Infura.swift"; sourceTree = "<group>"; };
81DFCC4B20F7546300603123 /* key.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = key.json; path = ../../../../Desktop/key.json; sourceTree = "<group>"; };
81EB1E4A208173D7003BD47F /* Web3+Personal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+Personal.swift"; sourceTree = "<group>"; };
81FA43F32044097000EE14D5 /* web3swift-macOS_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "web3swift-macOS_Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
81FA43F52044097100EE14D5 /* web3swift_macOS_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = web3swift_macOS_Tests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -488,7 +486,6 @@
children = (
8102F5C2211E00820032DF60 /* scrypt_Tests.swift */,
81FECD5D211AEFCE006DA367 /* web3swift_ObjC_Tests.swift */,
81DFCC4B20F7546300603123 /* key.json */,
815C74C720ECBF3E00DE2AC4 /* web3swift_User_cases.swift */,
00E5FE8120EA3FF40030E0D6 /* web3swift_infura_Tests.swift */,
00E5FE7F20EA3CEA0030E0D6 /* web3swift_RLP_Tests.swift */,
Expand Down Expand Up @@ -970,7 +967,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
81DFCC4C20F7546300603123 /* key.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
16 changes: 7 additions & 9 deletions web3swift/Promises/Classes/Promise+Batching.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class JSONRPCrequestDispatcher {
var pendingTrigger: Guarantee<Void>?
var provider: Web3Provider
var queue: DispatchQueue
var lockQueue : DispatchQueue
var triggered : Bool = false
var lockQueue: DispatchQueue
var triggered: Bool = false
func add(_ request: JSONRPCrequest, maxWaitTime: TimeInterval) throws -> Promise<JSONRPCresponse> {
if self.triggered {
throw Web3Error.nodeError("Batch is already in flight")
Expand All @@ -62,12 +62,10 @@ public class JSONRPCrequestDispatcher {

func trigger() {
self.lockQueue.async {
if self.triggered {
return
}
guard !self.triggered else { return }
self.triggered = true
let requestsBatch = JSONRPCrequestBatch(requests: self.requests)
_ = self.provider.sendAsync(requestsBatch, queue: self.queue).done(on: self.queue){batch in
self.provider.sendAsync(requestsBatch, queue: self.queue).done(on: self.queue) { batch in
for response in batch.responses {
if self.promisesDict[UInt64(response.id)] == nil {
for k in self.promisesDict.keys {
Expand All @@ -80,7 +78,7 @@ public class JSONRPCrequestDispatcher {
let promise = self.promisesDict[UInt64(response.id)]!
promise.resolver.fulfill(response)
}
}.catch(on:self.queue) {err in
}.catch(on: self.queue) { err in
for k in self.promisesDict.keys {
self.promisesDict[k]?.resolver.reject(err)
}
Expand Down Expand Up @@ -125,9 +123,9 @@ public class JSONRPCrequestDispatcher {
do {
let batch = try self.getBatch()
let internalPromise = try batch.add(request, maxWaitTime: self.MAX_WAIT_TIME)
internalPromise.done(on: self.queue) {resp in
internalPromise.done(on: self.queue) { resp in
seal.fulfill(resp)
}.catch(on: self.queue){err in
}.catch(on: self.queue) { err in
seal.reject(err)
}
} catch {
Expand Down
16 changes: 8 additions & 8 deletions web3swift/Web3/Classes/Web3+Instance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import PromiseKit

/// A web3 instance bound to provider. All further functionality is provided under web.*. namespaces.
public class web3: Web3OptionsInheritable {
public var provider : Web3Provider
public var options : Web3Options = Web3Options.defaultOptions()
public var provider: Web3Provider
public var options: Web3Options = Web3Options.defaultOptions()
public var defaultBlock = "latest"
public var requestDispatcher: JSONRPCrequestDispatcher

Expand Down Expand Up @@ -74,7 +74,7 @@ public class web3: Web3OptionsInheritable {
return self.personalInstance!
}

public class Personal:Web3OptionsInheritable {
public class Personal: Web3OptionsInheritable {
var provider:Web3Provider
// weak var web3: web3?
var web3: web3
Expand All @@ -94,12 +94,12 @@ public class web3: Web3OptionsInheritable {
if (self.walletInstance != nil) {
return self.walletInstance!
}
self.walletInstance = web3.Web3Wallet(provider : self.provider, web3: self)
self.walletInstance = web3.Web3Wallet(provider: self.provider, web3: self)
return self.walletInstance!
}

public class Web3Wallet {
var provider:Web3Provider
var provider: Web3Provider
// weak var web3: web3?
var web3: web3
public init(provider prov: Web3Provider, web3 web3instance: web3) {
Expand All @@ -115,12 +115,12 @@ public class web3: Web3OptionsInheritable {
if (self.browserFunctionsInstance != nil) {
return self.browserFunctionsInstance!
}
self.browserFunctionsInstance = web3.BrowserFunctions(provider : self.provider, web3: self)
self.browserFunctionsInstance = web3.BrowserFunctions(provider: self.provider, web3: self)
return self.browserFunctionsInstance!
}

public class BrowserFunctions:Web3OptionsInheritable {
var provider:Web3Provider
public class BrowserFunctions: Web3OptionsInheritable {
var provider: Web3Provider
// weak var web3: web3?
var web3: web3
public var options: Web3Options {
Expand Down
6 changes: 3 additions & 3 deletions web3swift/Web3/Classes/Web3+Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public struct Web3Options {
options.value = valueBiguint
}
if let fromString = json["from"] as? String {
guard let addressFrom = EthereumAddress(fromString) else { return nil }
guard let addressFrom = EthereumAddress(fromString) else {return nil}
options.from = addressFrom
}
return options
Expand Down Expand Up @@ -110,7 +110,7 @@ public struct Web3Options {
///
/// Please refer to the source code for a logic.
public static func smartMergeGasLimit(originalOptions: Web3Options?, extraOptions: Web3Options?, gasEstimate: BigUInt) -> BigUInt? {
guard let mergedOptions = Web3Options.merge(originalOptions, with: extraOptions) else { return nil } //just require any non-nils
guard let mergedOptions = Web3Options.merge(originalOptions, with: extraOptions) else {return nil} //just require any non-nils
if mergedOptions.gasLimit == nil {
return gasEstimate // for user's convenience we just use an estimate
// return nil // there is no opinion from user, so we can not proceed
Expand All @@ -134,7 +134,7 @@ public struct Web3Options {
}

public static func smartMergeGasPrice(originalOptions: Web3Options?, extraOptions: Web3Options?, priceEstimate: BigUInt) -> BigUInt? {
guard let mergedOptions = Web3Options.merge(originalOptions, with: extraOptions) else { return nil } //just require any non-nils
guard let mergedOptions = Web3Options.merge(originalOptions, with: extraOptions) else {return nil} //just require any non-nils
if mergedOptions.gasPrice == nil {
return priceEstimate
} else if mergedOptions.gasPrice == 0 {
Expand Down
2 changes: 1 addition & 1 deletion web3swiftTests/web3swift_infura_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class web3swift_infura_Tests: XCTestCase {
case .success(let result):
let balance = result
let balString = Web3.Utils.formatToEthereumUnits(balance, toUnits: .eth, decimals: 3)
print(balString)
print(balString ?? "nil")
}
}

Expand Down

0 comments on commit 6283602

Please sign in to comment.