Skip to content

Commit

Permalink
update podspec to define modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Vlasov committed Jun 10, 2018
1 parent 338e0c7 commit afdae20
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 3 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 = "0.8.0"
s.version = "0.8.1"
s.summary = "Web3 implementation in vanilla Swift for iOS ans macOS"

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

s.frameworks = 'CoreImage'
s.dependency 'Alamofire', '~> 4.7'
s.dependency 'Alamofire-Synchronous', '~> 4.0'
s.dependency 'BigInt', '~> 3.0.1'
s.dependency 'Result', '~> 3.0.0'
s.dependency 'CryptoSwift', '~> 0.9.0'
s.dependency 'CryptoSwift', '~> 0.10.0'
s.dependency 'libsodium', '~> 1.0.12'
s.dependency 'secp256k1_ios', '~> 0.1.3'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class ContractCallOperation: Web3Operation {
if (options?.gasLimit != nil) {
mergedOptions.gasLimit = options?.gasLimit
}
guard let _ = mergedOptions.from else {return processError(Web3Error.inputError("Invalid input supplied"))}
// guard let _ = mergedOptions.from else {return processError(Web3Error.inputError("Invalid input supplied"))}
let transaction = intermediate.transaction

let parsingCallback = { (res: Result<AnyObject, Web3Error>) -> () in
Expand Down
8 changes: 8 additions & 0 deletions web3swift/Web3/Classes/Web3+Structures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public struct EventLog {
public var logIndex: BigUInt
public var removed: Bool
public var topics: [Data]
public var transactionHash: Data

public init? (_ json: [String: AnyObject]) {
guard let ad = json["address"] as? String else {return nil}
Expand All @@ -134,6 +135,13 @@ public struct EventLog {
guard let tpc = json["topics"] as? [String] else {return nil}
guard let addr = EthereumAddress(ad) else {return nil}
address = addr
guard let txhash = json["transactionHash"] as? String else{return nil}
let hash = Data.fromHex(txhash)
if hash != nil {
transactionHash = hash!
} else {
transactionHash = Data()
}
data = Data.fromHex(d)!
guard let liUnwrapped = BigUInt(li.stripHexPrefix(), radix: 16) else {return nil}
logIndex = liUnwrapped
Expand Down
11 changes: 11 additions & 0 deletions web3swiftTests/web3swiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2398,6 +2398,17 @@ class web3swiftTests: XCTestCase {
}
}

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


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

0 comments on commit afdae20

Please sign in to comment.