Updating Tokens Data Store to retrieve decimals

pull/6/head
Oguzhan Gungor 7 years ago
parent ba26bf8b56
commit 9f71de140a
  1. 12
      Trust.xcodeproj/project.pbxproj
  2. 48
      Trust/Tokens/Types/TokensDataStore.swift

@ -267,9 +267,12 @@
29FF6D6B2011D2AF00A3011C /* InCoordinatorError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF6D6A2011D2AF00A3011C /* InCoordinatorError.swift */; }; 29FF6D6B2011D2AF00A3011C /* InCoordinatorError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF6D6A2011D2AF00A3011C /* InCoordinatorError.swift */; };
29FF6D73201200D500A3011C /* FieldAppereance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF6D72201200D500A3011C /* FieldAppereance.swift */; }; 29FF6D73201200D500A3011C /* FieldAppereance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF6D72201200D500A3011C /* FieldAppereance.swift */; };
3CDDD1E2CD1B0180754B7992 /* Pods_Trust.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 646C8C822C986358D7388602 /* Pods_Trust.framework */; }; 3CDDD1E2CD1B0180754B7992 /* Pods_Trust.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 646C8C822C986358D7388602 /* Pods_Trust.framework */; };
442FC249C2A39F85BDBD7987 /* GetDecimalsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC0F2E3BB3EE420BC2C16 /* GetDecimalsCoordinator.swift */; };
442FC39ABE8DD7162BAA4B02 /* ERC875Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC86BDB73BD2AE6F20731 /* ERC875Token.swift */; };
442FC58B7558F28F9452D383 /* GetIsECR875Coordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCEBC98D0A367D258D2C3 /* GetIsECR875Coordinator.swift */; }; 442FC58B7558F28F9452D383 /* GetIsECR875Coordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCEBC98D0A367D258D2C3 /* GetIsECR875Coordinator.swift */; };
442FC5F70AF003F331F7C841 /* GetSymbolCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCB2726DB345481C1FDA1 /* GetSymbolCoordinator.swift */; }; 442FC5F70AF003F331F7C841 /* GetSymbolCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCB2726DB345481C1FDA1 /* GetSymbolCoordinator.swift */; };
442FC65BFA2D42879648EC06 /* Int.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCCAC6A172506637A2FF6 /* Int.swift */; }; 442FC65BFA2D42879648EC06 /* Int.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCCAC6A172506637A2FF6 /* Int.swift */; };
442FC9C4FAC64192FF5DCC40 /* GetERC20Decimals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC72F9D22CC36AC015274 /* GetERC20Decimals.swift */; };
442FCB2B0DD39EB2D9233A2F /* GetERC875Balance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC8B1D5B4317DE7D68325 /* GetERC875Balance.swift */; }; 442FCB2B0DD39EB2D9233A2F /* GetERC875Balance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC8B1D5B4317DE7D68325 /* GetERC875Balance.swift */; };
442FCB9850FC6F2D28978199 /* GETERC20Symbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCBDD3A69DF75551B10AC /* GETERC20Symbol.swift */; }; 442FCB9850FC6F2D28978199 /* GETERC20Symbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCBDD3A69DF75551B10AC /* GETERC20Symbol.swift */; };
442FCBBFCC5926B4D416E6D3 /* GetNameCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC630874D29159799EEB6 /* GetNameCoordinator.swift */; }; 442FCBBFCC5926B4D416E6D3 /* GetNameCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FC630874D29159799EEB6 /* GetNameCoordinator.swift */; };
@ -651,7 +654,10 @@
29FF6D712011E20500A3011C /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; }; 29FF6D712011E20500A3011C /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
29FF6D72201200D500A3011C /* FieldAppereance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FieldAppereance.swift; sourceTree = "<group>"; }; 29FF6D72201200D500A3011C /* FieldAppereance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FieldAppereance.swift; sourceTree = "<group>"; };
442FC002CDEA792B8ECD3E13 /* Get875BalanceCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Get875BalanceCoordinator.swift; sourceTree = "<group>"; }; 442FC002CDEA792B8ECD3E13 /* Get875BalanceCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Get875BalanceCoordinator.swift; sourceTree = "<group>"; };
442FC0F2E3BB3EE420BC2C16 /* GetDecimalsCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetDecimalsCoordinator.swift; sourceTree = "<group>"; };
442FC630874D29159799EEB6 /* GetNameCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetNameCoordinator.swift; sourceTree = "<group>"; }; 442FC630874D29159799EEB6 /* GetNameCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetNameCoordinator.swift; sourceTree = "<group>"; };
442FC72F9D22CC36AC015274 /* GetERC20Decimals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetERC20Decimals.swift; sourceTree = "<group>"; };
442FC86BDB73BD2AE6F20731 /* ERC875Token.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ERC875Token.swift; sourceTree = "<group>"; };
442FC8B1D5B4317DE7D68325 /* GetERC875Balance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetERC875Balance.swift; sourceTree = "<group>"; }; 442FC8B1D5B4317DE7D68325 /* GetERC875Balance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetERC875Balance.swift; sourceTree = "<group>"; };
442FCA1F19B6293FE5FAD494 /* GetIsECR875.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetIsECR875.swift; sourceTree = "<group>"; }; 442FCA1F19B6293FE5FAD494 /* GetIsECR875.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetIsECR875.swift; sourceTree = "<group>"; };
442FCB2726DB345481C1FDA1 /* GetSymbolCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetSymbolCoordinator.swift; sourceTree = "<group>"; }; 442FCB2726DB345481C1FDA1 /* GetSymbolCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetSymbolCoordinator.swift; sourceTree = "<group>"; };
@ -962,6 +968,7 @@
442FCBDD3A69DF75551B10AC /* GETERC20Symbol.swift */, 442FCBDD3A69DF75551B10AC /* GETERC20Symbol.swift */,
442FC8B1D5B4317DE7D68325 /* GetERC875Balance.swift */, 442FC8B1D5B4317DE7D68325 /* GetERC875Balance.swift */,
442FCA1F19B6293FE5FAD494 /* GetIsECR875.swift */, 442FCA1F19B6293FE5FAD494 /* GetIsECR875.swift */,
442FC72F9D22CC36AC015274 /* GetERC20Decimals.swift */,
); );
path = Commands; path = Commands;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1366,6 +1373,7 @@
294DFBAD1FE6F254004CEB56 /* TokenObject.swift */, 294DFBAD1FE6F254004CEB56 /* TokenObject.swift */,
29E9CFCE1FE7347200017744 /* ERC20Token.swift */, 29E9CFCE1FE7347200017744 /* ERC20Token.swift */,
29C0FCE4200EBAF6004A13CB /* TokenType.swift */, 29C0FCE4200EBAF6004A13CB /* TokenType.swift */,
442FC86BDB73BD2AE6F20731 /* ERC875Token.swift */,
); );
path = Types; path = Types;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1733,6 +1741,7 @@
442FCB2726DB345481C1FDA1 /* GetSymbolCoordinator.swift */, 442FCB2726DB345481C1FDA1 /* GetSymbolCoordinator.swift */,
442FC002CDEA792B8ECD3E13 /* Get875BalanceCoordinator.swift */, 442FC002CDEA792B8ECD3E13 /* Get875BalanceCoordinator.swift */,
442FCEBC98D0A367D258D2C3 /* GetIsECR875Coordinator.swift */, 442FCEBC98D0A367D258D2C3 /* GetIsECR875Coordinator.swift */,
442FC0F2E3BB3EE420BC2C16 /* GetDecimalsCoordinator.swift */,
); );
path = Coordinators; path = Coordinators;
sourceTree = "<group>"; sourceTree = "<group>";
@ -2842,6 +2851,9 @@
442FCED8B618930EFD1F7BA8 /* GetIsECR875.swift in Sources */, 442FCED8B618930EFD1F7BA8 /* GetIsECR875.swift in Sources */,
442FC58B7558F28F9452D383 /* GetIsECR875Coordinator.swift in Sources */, 442FC58B7558F28F9452D383 /* GetIsECR875Coordinator.swift in Sources */,
442FC65BFA2D42879648EC06 /* Int.swift in Sources */, 442FC65BFA2D42879648EC06 /* Int.swift in Sources */,
442FC39ABE8DD7162BAA4B02 /* ERC875Token.swift in Sources */,
442FC9C4FAC64192FF5DCC40 /* GetERC20Decimals.swift in Sources */,
442FC249C2A39F85BDBD7987 /* GetDecimalsCoordinator.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

@ -38,6 +38,10 @@ class TokensDataStore {
return GetIsECR875Coordinator(web3: self.web3) return GetIsECR875Coordinator(web3: self.web3)
}() }()
private lazy var getDecimalsCoordinator: GetDecimalsCoordinator = {
return GetDecimalsCoordinator(web3: self.web3)
}()
private let provider = TrustProviderFactory.makeProvider() private let provider = TrustProviderFactory.makeProvider()
let account: Wallet let account: Wallet
@ -119,44 +123,42 @@ class TokensDataStore {
} }
// TODO: Clean this up // TODO: Clean this up
func getContractName(for addressString: String) { func getContractName(for addressString: String,
completion: @escaping (Result<String, AnyError>) -> Void) {
let address = Address(string: addressString) let address = Address(string: addressString)
getNameCoordinator.getName(for: address!) { (result) in getNameCoordinator.getName(for: address!) { (result) in
NSLog("command.object \(result)") completion(result)
} }
} }
func getContractSymbol(for addressString: String) { func getContractSymbol(for addressString: String,
completion: @escaping (Result<String, AnyError>) -> Void) {
let address = Address(string: addressString) let address = Address(string: addressString)
getSymbolCoordinator.getSymbol(for: address!) { result in
getSymbolCoordinator.getSymbol(for: address!) { (result) in completion(result)
NSLog("command.object \(result)")
} }
} }
func getDecimals(for addressString: String,
func getContractBalanceOf(for addressString: String) { completion: @escaping (Result<UInt8, AnyError>) -> Void) {
let address = Address(string: addressString) let address = Address(string: addressString)
getDecimalsCoordinator.getDecimals(for: address!) { result in
get875BalanceCoordinator.getBalance(for: account.address, contract: address!) { (result) in completion(result)
NSLog("command.object \(result)")
} }
} }
func getIsECR875(for addressString: String) { func getContractBalance(for addressString: String,
completion: @escaping (Result<[UInt16], AnyError>) -> Void) {
let address = Address(string: addressString) let address = Address(string: addressString)
get875BalanceCoordinator.getBalance(for: account.address, contract: address!) { result in
getIsECR875Coordinator.getIsECR875(for: address!) { [weak self] result in completion(result)
NSLog("command.object \(result)") }
guard let `self` = self else { return }
switch result {
case .success(let name):
NSLog("name: \(name)")
case .failure: break
} }
func getIsECR875(for addressString: String,
completion: @escaping (Result<Bool, AnyError>) -> Void) {
let address = Address(string: addressString)
getIsECR875Coordinator.getIsECR875(for: address!) { result in
completion(result)
} }
} }

Loading…
Cancel
Save