blockchainethereumblockchain-walleterc20erc721walletxdaidappdecentralizederc1155erc875iosswifttokens
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.0 KiB
57 lines
2.0 KiB
// Copyright SIX DAY LLC. All rights reserved.
|
|
|
|
import Foundation
|
|
import BigInt
|
|
import JSONRPCKit
|
|
import APIKit
|
|
import Result
|
|
import TrustKeystore
|
|
|
|
class GetIsStormBirdCoordinator {
|
|
|
|
private let web3: Web3Swift
|
|
|
|
init(
|
|
web3: Web3Swift
|
|
) {
|
|
self.web3 = web3
|
|
}
|
|
|
|
func getIsStormBirdContract(
|
|
for contract: Address,
|
|
completion: @escaping (Result<Bool, AnyError>) -> Void
|
|
) {
|
|
let request = GetIsStormBirdEncode()
|
|
web3.request(request: request) { result in
|
|
switch result {
|
|
case .success(let res):
|
|
let request2 = EtherServiceRequest(
|
|
batch: BatchFactory().create(CallRequest(to: contract.description, data: res))
|
|
)
|
|
Session.send(request2) { [weak self] result2 in
|
|
switch result2 {
|
|
case .success(let balance):
|
|
let request = GetIsStormBirdDecode(data: balance)
|
|
self?.web3.request(request: request) { result in
|
|
switch result {
|
|
case .success(let res):
|
|
let isStormBird = res.toBool()
|
|
NSLog("getIsStormBirdContract result \(isStormBird) ")
|
|
completion(.success(isStormBird))
|
|
case .failure(let error):
|
|
NSLog("getIsStormBirdContract 3 error \(error)")
|
|
completion(.failure(AnyError(error)))
|
|
}
|
|
}
|
|
case .failure(let error):
|
|
NSLog("getIsStormBirdContract 2 error \(error)")
|
|
completion(.failure(AnyError(error)))
|
|
}
|
|
}
|
|
case .failure(let error):
|
|
NSLog("getIsStormBirdContract error \(error)")
|
|
completion(.failure(AnyError(error)))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|