Skip to content

Commit afdae20

Browse files
author
Alex Vlasov
committed
update podspec to define modules
1 parent 338e0c7 commit afdae20

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

web3swift.podspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "web3swift"
3-
s.version = "0.8.0"
3+
s.version = "0.8.1"
44
s.summary = "Web3 implementation in vanilla Swift for iOS ans macOS"
55

66
s.description = <<-DESC
@@ -19,13 +19,14 @@ s.ios.deployment_target = "9.0"
1919
s.osx.deployment_target = "10.13"
2020
s.source_files = "web3swift/**/*.{h,swift}",
2121
s.public_header_files = "web3swift/**/*.{h}"
22+
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
2223

2324
s.frameworks = 'CoreImage'
2425
s.dependency 'Alamofire', '~> 4.7'
2526
s.dependency 'Alamofire-Synchronous', '~> 4.0'
2627
s.dependency 'BigInt', '~> 3.0.1'
2728
s.dependency 'Result', '~> 3.0.0'
28-
s.dependency 'CryptoSwift', '~> 0.9.0'
29+
s.dependency 'CryptoSwift', '~> 0.10.0'
2930
s.dependency 'libsodium', '~> 1.0.12'
3031
s.dependency 'secp256k1_ios', '~> 0.1.3'
3132

web3swift/Concurrency/Classes/Web3+TransactionOperations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ final class ContractCallOperation: Web3Operation {
4141
if (options?.gasLimit != nil) {
4242
mergedOptions.gasLimit = options?.gasLimit
4343
}
44-
guard let _ = mergedOptions.from else {return processError(Web3Error.inputError("Invalid input supplied"))}
44+
// guard let _ = mergedOptions.from else {return processError(Web3Error.inputError("Invalid input supplied"))}
4545
let transaction = intermediate.transaction
4646

4747
let parsingCallback = { (res: Result<AnyObject, Web3Error>) -> () in

web3swift/Web3/Classes/Web3+Structures.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public struct EventLog {
125125
public var logIndex: BigUInt
126126
public var removed: Bool
127127
public var topics: [Data]
128+
public var transactionHash: Data
128129

129130
public init? (_ json: [String: AnyObject]) {
130131
guard let ad = json["address"] as? String else {return nil}
@@ -134,6 +135,13 @@ public struct EventLog {
134135
guard let tpc = json["topics"] as? [String] else {return nil}
135136
guard let addr = EthereumAddress(ad) else {return nil}
136137
address = addr
138+
guard let txhash = json["transactionHash"] as? String else{return nil}
139+
let hash = Data.fromHex(txhash)
140+
if hash != nil {
141+
transactionHash = hash!
142+
} else {
143+
transactionHash = Data()
144+
}
137145
data = Data.fromHex(d)!
138146
guard let liUnwrapped = BigUInt(li.stripHexPrefix(), radix: 16) else {return nil}
139147
logIndex = liUnwrapped

web3swiftTests/web3swiftTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,17 @@ class web3swiftTests: XCTestCase {
23982398
}
23992399
}
24002400

2401+
func testERC20tokenBalance() {
2402+
let web3 = Web3.InfuraMainnetWeb3()
2403+
let contract = web3.contract(Web3.Utils.erc20ABI, at: EthereumAddress("0x45245bc59219eeaaf6cd3f382e078a461ff9de7b")!, abiVersion: 2)
2404+
var options = Web3Options();
2405+
options.from = EthereumAddress("0x6394b37Cf80A7358b38068f0CA4760ad49983a1B")!
2406+
let addressOfUser = EthereumAddress("0x6394b37Cf80A7358b38068f0CA4760ad49983a1B")!
2407+
guard let tokenBalanceResult = contract?.method("balanceOf", parameters: [addressOfUser] as [AnyObject], options: options)?.call(options: nil) else {return XCTFail()}
2408+
guard case .success(let tokenBalance) = tokenBalanceResult, let bal = tokenBalance["0"] as? BigUInt else {return XCTFail()}
2409+
print(String(bal))
2410+
}
2411+
24012412

24022413
func getKeystoreData() -> Data? {
24032414
let bundle = Bundle(for: type(of: self))

0 commit comments

Comments
 (0)