Skip to content

Commit e94f2e1

Browse files
Merge pull request #209 from matter-labs/infuraV3update
infura v3 complete update
2 parents 5c0e7e8 + c5212c1 commit e94f2e1

File tree

8 files changed

+58
-49
lines changed

8 files changed

+58
-49
lines changed

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
github "mxcl/PromiseKit" ~> 6.8.4
2-
github "attaswift/BigInt" ~> 3.1
2+
github "attaswift/BigInt" ~> 4.0
33
github "daltoniam/Starscream" ~> 3.1.0
44
github "krzyzanowskim/CryptoSwift" ~> 1.0.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Build Status](https://travis-ci.com/matter-labs/web3swift.svg?branch=develop)](https://travis-ci.com/matter-labs/web3swift)
66
[![Swift](https://img.shields.io/badge/Swift-5.0-orange.svg?style=flat)](https://developer.apple.com/swift/)
77
[![Platform](https://img.shields.io/cocoapods/p/web3swift.svg?style=flat)](http://cocoapods.org/pods/web3.swift.pod)
8-
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/web3swift.svg?style=flat)](http://cocoapods.org/pods/web3.swift.pod)
8+
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/web3.swift.pod.svg?style=flat)](http://cocoapods.org/pods/web3.swift.pod)
99
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
1010
[![License](https://img.shields.io/cocoapods/l/web3swift.svg?style=flat)](http://cocoapods.org/pods/web3.swift.pod)
1111
[![support](https://brianmacdonald.github.io/Ethonate/svg/eth-support-blue.svg)](https://brianmacdonald.github.io/Ethonate/address#0xe22b8979739d724343bd002f9f432f5990879901)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Web3+Constants.swift
3+
// web3swift
4+
//
5+
// Created by Anton on 24/06/2019.
6+
// Copyright © 2019 Bankex Foundation. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
struct Constants {
12+
static let infuraHttpScheme = ".infura.io/v3/"
13+
static let infuraWsScheme = ".infura.io/ws/v3/"
14+
static let infuraToken = "4406c3acf862426c83991f1752c46dd8"
15+
}

Sources/web3swift/Web3/Web3+InfuraProviders.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ public enum BlockNumber {
3030
/// Custom Web3 HTTP provider of Infura nodes.
3131
public final class InfuraProvider: Web3HttpProvider {
3232
public init?(_ net:Networks, accessToken token: String? = nil, keystoreManager manager: KeystoreManager? = nil) {
33-
var requestURLstring = "https://" + net.name + ".infura.io/"
34-
if token != nil {
35-
requestURLstring = requestURLstring + token!
36-
}
33+
var requestURLstring = "https://" + net.name + Constants.infuraHttpScheme
34+
requestURLstring += token != nil ? token! : Constants.infuraToken
3735
let providerURL = URL(string: requestURLstring)
3836
super.init(providerURL!, network: net, keystoreManager: manager)
3937
}
@@ -55,7 +53,7 @@ public final class InfuraWebsocketProvider: WebsocketProvider {
5553
|| network == Networks.Ropsten
5654
|| network == Networks.Mainnet else {return nil}
5755
let networkName = network.name
58-
let urlString = "wss://\(networkName).infura.io/ws/v3/"
56+
let urlString = "wss://" + networkName + Constants.infuraWsScheme
5957
guard URL(string: urlString) != nil else {return nil}
6058
super.init(urlString,
6159
delegate: delegate,

Sources/web3swift/Web3/Web3+WebsocketProvider.swift

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ public class WebsocketProvider: Web3Provider, IWebsocketProvider, WebSocketDeleg
127127
if !(endpointString.hasPrefix("wss://") || endpointString.hasPrefix("ws://")) {
128128
return nil
129129
}
130-
if net == nil {
131-
if endpointString.hasPrefix("wss://") && endpointString.hasSuffix(".infura.io/ws") {
130+
if endpointString.hasPrefix("wss://") && endpointString.hasSuffix(Constants.infuraWsScheme) {
131+
if net == nil {
132132
let networkString = endpointString.replacingOccurrences(of: "wss://", with: "")
133-
.replacingOccurrences(of: ".infura.io/ws", with: "")
133+
.replacingOccurrences(of: Constants.infuraWsScheme, with: "")
134134
switch networkString {
135135
case "mainnet":
136136
network = Networks.Mainnet
@@ -143,17 +143,17 @@ public class WebsocketProvider: Web3Provider, IWebsocketProvider, WebSocketDeleg
143143
default:
144144
break
145145
}
146+
} else {
147+
network = net
148+
}
149+
if network != nil {
150+
endpointString += projectId ?? Constants.infuraToken
146151
}
147-
} else {
148-
network = net
149-
}
150-
if network != nil {
151-
endpointString += projectId ?? "4406c3acf862426c83991f1752c46dd8"
152152
}
153153
url = URL(string: endpointString)!
154154
delegate = wsdelegate
155155
attachedKeystoreManager = manager
156-
socket = WebSocket(url: endpoint)
156+
socket = WebSocket(url: url)
157157
socket.delegate = self
158158
}
159159

@@ -162,22 +162,16 @@ public class WebsocketProvider: Web3Provider, IWebsocketProvider, WebSocketDeleg
162162
projectId: String? = nil,
163163
keystoreManager manager: KeystoreManager? = nil,
164164
network net: Networks? = nil) {
165+
guard URL(string: endpoint) != nil else {return nil}
166+
var finalEndpoint = endpoint
165167
websocketConnected = false
166-
var endpointString = endpoint
167-
if !(endpointString.hasPrefix("wss://") || endpointString.hasPrefix("ws://")) {
168+
if !(endpoint.hasPrefix("wss://") || endpoint.hasPrefix("ws://")) {
168169
return nil
169170
}
170-
if net == nil {
171-
if endpointString.hasPrefix("wss://")
172-
&& (endpointString.hasSuffix(".infura.io/ws/v3/")
173-
|| endpointString.hasSuffix(".infura.io/ws/v3")
174-
|| endpointString.hasSuffix(".infura.io/ws/")
175-
|| endpointString.hasSuffix(".infura.io/ws")) {
176-
let networkString = endpointString.replacingOccurrences(of: "wss://", with: "")
177-
.replacingOccurrences(of: ".infura.io/ws/v3/", with: "")
178-
.replacingOccurrences(of: ".infura.io/ws/v3", with: "")
179-
.replacingOccurrences(of: ".infura.io/ws/", with: "")
180-
.replacingOccurrences(of: ".infura.io/ws", with: "")
171+
if endpoint.hasPrefix("wss://") && endpoint.hasSuffix(Constants.infuraWsScheme) {
172+
if net == nil {
173+
let networkString = endpoint.replacingOccurrences(of: "wss://", with: "")
174+
.replacingOccurrences(of: Constants.infuraWsScheme, with: "")
181175
switch networkString {
182176
case "mainnet":
183177
network = Networks.Mainnet
@@ -190,21 +184,17 @@ public class WebsocketProvider: Web3Provider, IWebsocketProvider, WebSocketDeleg
190184
default:
191185
break
192186
}
187+
} else {
188+
network = net
189+
}
190+
if network != nil {
191+
finalEndpoint += projectId ?? Constants.infuraToken
193192
}
194-
} else {
195-
network = net
196-
}
197-
if network != nil {
198-
if endpointString.hasSuffix(".infura.io/ws/v3") { endpointString += "/"}
199-
else if endpointString.hasSuffix(".infura.io/ws/") { endpointString += "v3/"}
200-
else if endpointString.hasSuffix(".infura.io/ws") { endpointString += "/v3/"}
201-
endpointString += projectId ?? "4406c3acf862426c83991f1752c46dd8"
202193
}
203-
guard let endpointUrl = URL(string: endpointString) else {return nil}
204-
url = endpointUrl
194+
url = URL(string: finalEndpoint)!
205195
delegate = wsdelegate
206196
attachedKeystoreManager = manager
207-
socket = WebSocket(url: endpointUrl)
197+
socket = WebSocket(url: url)
208198
socket.delegate = self
209199
}
210200

Web3swift.pod.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'Web3swift.pod'
3-
spec.version = '2.2.0'
3+
spec.version = '2.2.1'
44
spec.ios.deployment_target = "9.0"
55
spec.osx.deployment_target = "10.11"
66
spec.license = { :type => 'Apache License 2.0', :file => 'LICENSE.md' }
@@ -13,7 +13,7 @@ Pod::Spec.new do |spec|
1313
spec.module_name = 'web3swift'
1414
spec.frameworks = 'CoreImage'
1515
spec.dependency 'PromiseKit', '~> 6.8.4'
16-
spec.dependency 'BigInt', '~> 3.1'
16+
spec.dependency 'BigInt', '~> 4.0'
1717
spec.dependency 'Starscream', '~> 3.1.0'
1818
spec.dependency 'CryptoSwift', '~> 1.0.0'
1919
spec.dependency 'secp256k1.c', '~> 0.1'

web3swift.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'web3swift'
3-
spec.version = '2.2.0'
3+
spec.version = '2.2.1'
44
spec.ios.deployment_target = "9.0"
55
spec.osx.deployment_target = "10.11"
66
spec.license = { :type => 'Apache License 2.0', :file => 'LICENSE.md' }
@@ -12,7 +12,7 @@ Pod::Spec.new do |spec|
1212
spec.swift_version = '5.0'
1313
spec.frameworks = 'CoreImage'
1414
spec.dependency 'PromiseKit', '~> 6.8.4'
15-
spec.dependency 'BigInt', '~> 3.1'
15+
spec.dependency 'BigInt', '~> 4.0'
1616
spec.dependency 'Starscream', '~> 3.1.0'
1717
spec.dependency 'CryptoSwift', '~> 1.0.0'
1818
spec.dependency 'secp256k1.c', '~> 0.1'

web3swift.xcodeproj/project.pbxproj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
3AA816372276E48400F5DB52 /* web3swift_Eventloop_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA816222276E48400F5DB52 /* web3swift_Eventloop_Tests.swift */; };
187187
3AA816382276E48400F5DB52 /* web3swift_Websockets_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA816232276E48400F5DB52 /* web3swift_Websockets_Tests.swift */; };
188188
3AA8163A2276E4AE00F5DB52 /* SECP256k1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA816392276E4AE00F5DB52 /* SECP256k1.swift */; };
189+
3AEF4ABF22C0B6BE00AC7929 /* Web3+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AEF4ABE22C0B6BE00AC7929 /* Web3+Constants.swift */; };
189190
/* End PBXBuildFile section */
190191

191192
/* Begin PBXFileReference section */
@@ -383,6 +384,7 @@
383384
3AA8163F2276E5A800F5DB52 /* LICENSE.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = LICENSE.md; sourceTree = "<group>"; };
384385
3AA816402276E5A800F5DB52 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
385386
3AA816412276E5A900F5DB52 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
387+
3AEF4ABE22C0B6BE00AC7929 /* Web3+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+Constants.swift"; sourceTree = "<group>"; };
386388
/* End PBXFileReference section */
387389

388390
/* Begin PBXFrameworksBuildPhase section */
@@ -697,6 +699,7 @@
697699
3AA815542276E44100F5DB52 /* Web3+Utils.swift */,
698700
3AA815552276E44100F5DB52 /* Web3+MutatingTransaction.swift */,
699701
3AA815562276E44100F5DB52 /* Web3+JSONRPC.swift */,
702+
3AEF4ABE22C0B6BE00AC7929 /* Web3+Constants.swift */,
700703
3AA815572276E44100F5DB52 /* Web3+Instance.swift */,
701704
3AA815582276E44100F5DB52 /* Web3+Contract.swift */,
702705
3AA815592276E44100F5DB52 /* Web3+EventParser.swift */,
@@ -1177,6 +1180,7 @@
11771180
3AA816062276E44100F5DB52 /* Web3+ST20.swift in Sources */,
11781181
3AA815FA2276E44100F5DB52 /* Promise+Web3+Eth+GetAccounts.swift in Sources */,
11791182
3AA815E72276E44100F5DB52 /* Array+Extension.swift in Sources */,
1183+
3AEF4ABF22C0B6BE00AC7929 /* Web3+Constants.swift in Sources */,
11801184
3AA815DD2276E44100F5DB52 /* Web3+Options.swift in Sources */,
11811185
3AA815A92276E44100F5DB52 /* ENSReverseRegistrar.swift in Sources */,
11821186
3AA815EF2276E44100F5DB52 /* Promise+HttpProvider.swift in Sources */,
@@ -1449,7 +1453,7 @@
14491453
CODE_SIGN_STYLE = Automatic;
14501454
COMBINE_HIDPI_IMAGES = YES;
14511455
DEFINES_MODULE = YES;
1452-
DEVELOPMENT_TEAM = "";
1456+
DEVELOPMENT_TEAM = 8DB897QKJA;
14531457
DYLIB_COMPATIBILITY_VERSION = 1;
14541458
DYLIB_CURRENT_VERSION = 1;
14551459
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1496,7 +1500,7 @@
14961500
CODE_SIGN_STYLE = Automatic;
14971501
COMBINE_HIDPI_IMAGES = YES;
14981502
DEFINES_MODULE = YES;
1499-
DEVELOPMENT_TEAM = "";
1503+
DEVELOPMENT_TEAM = 8DB897QKJA;
15001504
DYLIB_COMPATIBILITY_VERSION = 1;
15011505
DYLIB_CURRENT_VERSION = 1;
15021506
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1545,7 +1549,7 @@
15451549
CLANG_ENABLE_OBJC_WEAK = YES;
15461550
CODE_SIGN_IDENTITY = "Mac Developer";
15471551
CODE_SIGN_STYLE = Automatic;
1548-
DEVELOPMENT_TEAM = "";
1552+
DEVELOPMENT_TEAM = 8DB897QKJA;
15491553
"FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]" = "$(SRCROOT)/Carthage/Build/iOS";
15501554
"FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]" = "$(SRCROOT)/Carthage/Build/iOS";
15511555
"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = "$(SRCROOT)/Carthage/Build/Mac";
@@ -1577,7 +1581,7 @@
15771581
CLANG_ENABLE_OBJC_WEAK = YES;
15781582
CODE_SIGN_IDENTITY = "Mac Developer";
15791583
CODE_SIGN_STYLE = Automatic;
1580-
DEVELOPMENT_TEAM = "";
1584+
DEVELOPMENT_TEAM = 8DB897QKJA;
15811585
"FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]" = "$(SRCROOT)/Carthage/Build/iOS";
15821586
"FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]" = "$(SRCROOT)/Carthage/Build/iOS";
15831587
"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = "$(SRCROOT)/Carthage/Build/Mac";
@@ -1607,10 +1611,11 @@
16071611
CLANG_CXX_LIBRARY = "libc++";
16081612
CLANG_ENABLE_MODULES = YES;
16091613
CLANG_ENABLE_OBJC_WEAK = YES;
1610-
CODE_SIGN_IDENTITY = "";
1614+
CODE_SIGN_IDENTITY = "Mac Developer";
16111615
CODE_SIGN_STYLE = Automatic;
16121616
COMBINE_HIDPI_IMAGES = YES;
16131617
DEFINES_MODULE = YES;
1618+
DEVELOPMENT_TEAM = 8DB897QKJA;
16141619
DYLIB_COMPATIBILITY_VERSION = 1;
16151620
DYLIB_CURRENT_VERSION = 1;
16161621
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1647,6 +1652,7 @@
16471652
CODE_SIGN_STYLE = Automatic;
16481653
COMBINE_HIDPI_IMAGES = YES;
16491654
DEFINES_MODULE = YES;
1655+
DEVELOPMENT_TEAM = 8DB897QKJA;
16501656
DYLIB_COMPATIBILITY_VERSION = 1;
16511657
DYLIB_CURRENT_VERSION = 1;
16521658
DYLIB_INSTALL_NAME_BASE = "@rpath";

0 commit comments

Comments
 (0)