Skip to content

Commit afe86cf

Browse files
Merge branch 'develop-upstream' into hot-fix/data-to-hex-string
# Conflicts: # Tests/web3swiftTests/remoteTests/ST20AndSecurityTokenTests.swift
2 parents 7b3e396 + 53a216e commit afe86cf

File tree

7 files changed

+79
-141
lines changed

7 files changed

+79
-141
lines changed

Sources/Core/Utility/BigUInt+Extension.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ public extension BigUInt {
1313
self = value
1414
}
1515
}
16+
17+
#if COCOAPODS
18+
extension BigUInt {
19+
var isZero: Bool { self == 0 }
20+
}
21+
#endif

Sources/web3swift/Browser/BrowserViewController.swift

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

Sources/web3swift/Web3/Web3.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ extension Web3 {
3333
}
3434

3535
/// Initialized Web3 instance bound to Infura's rinkeby provider.
36+
@available(*, deprecated, message: "This network support was deprecated by Infura")
3637
public static func InfuraRinkebyWeb3(accessToken: String? = nil) async -> Web3 {
3738
let infura = await InfuraProvider(Networks.Rinkeby, accessToken: accessToken)!
3839
return Web3(provider: infura)
3940
}
4041

4142
/// Initialized Web3 instance bound to Infura's ropsten provider.
43+
@available(*, deprecated, message: "This network support was deprecated by Infura")
4244
public static func InfuraRopstenWeb3(accessToken: String? = nil) async -> Web3 {
4345
let infura = await InfuraProvider(Networks.Ropsten, accessToken: accessToken)!
4446
return Web3(provider: infura)
4547
}
4648

4749
/// Initialized Web3 instance bound to Infura's kovan provider.
50+
@available(*, deprecated, message: "This network support was deprecated by Infura")
4851
public static func InfuraKovanWeb3(accessToken: String? = nil) async -> Web3 {
4952
let infura = await InfuraProvider(Networks.Kovan, accessToken: accessToken)!
5053
return Web3(provider: infura)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// EIP1559Tests.swift
3+
//
4+
//
5+
// Created by Jann Driessen on 01.11.22.
6+
//
7+
8+
import XCTest
9+
import Core
10+
11+
@testable import web3swift
12+
13+
final class EIP1559Tests: XCTestCase {
14+
15+
func testEIP1159MainnetTransaction() async throws {
16+
let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)
17+
var tx = CodableTransaction(
18+
type: .eip1559,
19+
to: EthereumAddress("0xb47292B7bBedA4447564B8336E4eD1f93735e7C7")!,
20+
chainID: web3.provider.network!.chainID,
21+
value: Utilities.parseToBigUInt("0.1", units: .eth)!,
22+
gasLimit: 21_000
23+
)
24+
// Vitalik's address
25+
tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")!
26+
// Should fail if there would be something wrong with the tx
27+
let res = try await web3.eth.estimateGas(for: tx)
28+
XCTAssertGreaterThan(res, 0)
29+
}
30+
31+
func testEIP1159GoerliTransaction() async throws {
32+
let web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken)
33+
var tx = CodableTransaction(
34+
type: .eip1559,
35+
to: EthereumAddress("0xeBec795c9c8bBD61FFc14A6662944748F299cAcf")!,
36+
chainID: web3.provider.network!.chainID,
37+
value: Utilities.parseToBigUInt("0.1", units: .eth)!,
38+
gasLimit: 21_000
39+
)
40+
// Vitalik's address
41+
tx.from = EthereumAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")!
42+
// Should fail if there would be something wrong with the tx
43+
let res = try await web3.eth.estimateGas(for: tx)
44+
XCTAssertGreaterThan(res, 0)
45+
}
46+
47+
}

Tests/web3swiftTests/remoteTests/ST20AndSecurityTokenTests.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Core
1515
// MARK: Works only with network connection
1616
class ST20AndSecurityTokenTests: XCTestCase {
1717

18+
<<<<<<< HEAD
1819
func testERC20TokenCreation() async throws {
1920
let web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken)
2021
let w3sTokenAddress = EthereumAddress("0x33d191db2486e0d245b44fde3fae5ed667d5694b")!
@@ -24,6 +25,19 @@ class ST20AndSecurityTokenTests: XCTestCase {
2425
XCTAssertEqual(st20token.name(), "Mimi")
2526
XCTAssertEqual(st20token.decimals(), 18)
2627
}
28+
=======
29+
// FIXME: Enable me back again
30+
// Test fails because there's no such wallet on goerli chain as well as token.
31+
// func testERC20TokenCreation() async throws {
32+
// let web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken)
33+
// let w3sTokenAddress = EthereumAddress("0x2dD33957C90880bE4Ee9fd5F703110BDA2E579EC")!
34+
// let st20token = ST20.init(web3: web3, provider: web3.provider, address: w3sTokenAddress)
35+
// try await st20token.readProperties()
36+
// XCTAssertEqual(st20token.symbol(), "MIMI")
37+
// XCTAssertEqual(st20token.name(), "Mimi")
38+
// XCTAssertEqual(st20token.decimals(), 18)
39+
// }
40+
>>>>>>> develop-upstream
2741

2842
func testST20tokenBalanceAndAllowance() async throws {
2943
let web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken)
@@ -32,7 +46,7 @@ class ST20AndSecurityTokenTests: XCTestCase {
3246
let userAddress = EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")!
3347
let balance = try await st20token.getBalance(account: userAddress)
3448
let allowance = try await st20token.getAllowance(originalOwner: userAddress, delegate: userAddress)
35-
XCTAssertEqual(String(balance), "0")
49+
XCTAssertEqual(balance, 0)
3650
XCTAssertEqual(allowance, 0)
3751
}
3852

@@ -41,11 +55,11 @@ class ST20AndSecurityTokenTests: XCTestCase {
4155
let w3sTokenAddress = EthereumAddress("0x2dD33957C90880bE4Ee9fd5F703110BDA2E579EC")!
4256
let stoken = SecurityToken.init(web3: web3, provider: web3.provider, address: w3sTokenAddress)
4357
let investorsCount = try await stoken.investorCount()
44-
let stringInvestorsCount = String(investorsCount)
45-
XCTAssertEqual(stringInvestorsCount, "0")
58+
XCTAssertEqual(investorsCount, 0)
4659
}
4760

4861
// FIXME: Enable me back again
62+
// Test fails because there's no such wallet on goerli chain as well as token.
4963
// func testSecurityTokenGranularity() async throws {
5064
// let web3 = await Web3.InfuraGoerliWeb3(accessToken: Constants.infuraToken)
5165
// let w3sTokenAddress = EthereumAddress("0x2dD33957C90880bE4Ee9fd5F703110BDA2E579EC")!

Web3Core.podspec

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Pod::Spec.new do |spec|
2+
spec.compiler_flags = '-DCOCOAPODS'
3+
24
spec.name = 'Web3Core'
3-
spec.version = '3.0.0'
5+
spec.version = '3.0.4'
46
spec.module_name = 'Core'
57
spec.ios.deployment_target = "13.0"
68
spec.osx.deployment_target = "10.15"
@@ -12,7 +14,7 @@ Pod::Spec.new do |spec|
1214
spec.swift_version = '5.5'
1315

1416
spec.dependency 'secp256k1.c', '~> 0.1'
15-
spec.dependency 'BigInt', '~> 5.2.0'
17+
spec.dependency 'BigInt', '~> 5.2.0' # no newer version in pods.
1618
spec.dependency 'CryptoSwift', '~> 1.5.1'
1719
spec.source_files = "Sources/Core/**/*.swift"
1820
end

web3swift.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
WEB3CORE_VERSION ||= '3.0.0'
1+
WEB3CORE_VERSION ||= '3.0.4'
22

33
Pod::Spec.new do |spec|
44
spec.name = 'web3swift'
@@ -13,7 +13,7 @@ Pod::Spec.new do |spec|
1313
spec.swift_version = '5.5'
1414

1515
# Make this line same as Web3Core sources
16-
spec.source_files = "Sources/web3swift/{Contract,Convenience,EthereumABI,HookedFunctions,EthereumAPICalls,Web3}/*.swift", "Sources/web3swift/{EthereumAPICalls,Tokens,Utils}/**/*.swift"
16+
spec.source_files = "Sources/web3swift/**/*.swift"
1717
spec.ios.source_files = 'Sources/web3swift/Browser/*.swift'
1818
spec.resource_bundle = { "Browser" => "Sources/web3swift/Browser/*.js" }
1919
spec.frameworks = 'CoreImage'

0 commit comments

Comments
 (0)