diff --git a/Trust.xcodeproj/project.pbxproj b/Trust.xcodeproj/project.pbxproj index 1fdb3b33d..a429e5ea7 100644 --- a/Trust.xcodeproj/project.pbxproj +++ b/Trust.xcodeproj/project.pbxproj @@ -267,9 +267,12 @@ 29FF6D6B2011D2AF00A3011C /* InCoordinatorError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FF6D6A2011D2AF00A3011C /* InCoordinatorError.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 */; }; + 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 */; }; 442FC5F70AF003F331F7C841 /* GetSymbolCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCB2726DB345481C1FDA1 /* GetSymbolCoordinator.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 */; }; 442FCB9850FC6F2D28978199 /* GETERC20Symbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442FCBDD3A69DF75551B10AC /* GETERC20Symbol.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 = ""; }; 29FF6D72201200D500A3011C /* FieldAppereance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FieldAppereance.swift; sourceTree = ""; }; 442FC002CDEA792B8ECD3E13 /* Get875BalanceCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Get875BalanceCoordinator.swift; sourceTree = ""; }; + 442FC0F2E3BB3EE420BC2C16 /* GetDecimalsCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetDecimalsCoordinator.swift; sourceTree = ""; }; 442FC630874D29159799EEB6 /* GetNameCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetNameCoordinator.swift; sourceTree = ""; }; + 442FC72F9D22CC36AC015274 /* GetERC20Decimals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetERC20Decimals.swift; sourceTree = ""; }; + 442FC86BDB73BD2AE6F20731 /* ERC875Token.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ERC875Token.swift; sourceTree = ""; }; 442FC8B1D5B4317DE7D68325 /* GetERC875Balance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetERC875Balance.swift; sourceTree = ""; }; 442FCA1F19B6293FE5FAD494 /* GetIsECR875.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetIsECR875.swift; sourceTree = ""; }; 442FCB2726DB345481C1FDA1 /* GetSymbolCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetSymbolCoordinator.swift; sourceTree = ""; }; @@ -962,6 +968,7 @@ 442FCBDD3A69DF75551B10AC /* GETERC20Symbol.swift */, 442FC8B1D5B4317DE7D68325 /* GetERC875Balance.swift */, 442FCA1F19B6293FE5FAD494 /* GetIsECR875.swift */, + 442FC72F9D22CC36AC015274 /* GetERC20Decimals.swift */, ); path = Commands; sourceTree = ""; @@ -1366,6 +1373,7 @@ 294DFBAD1FE6F254004CEB56 /* TokenObject.swift */, 29E9CFCE1FE7347200017744 /* ERC20Token.swift */, 29C0FCE4200EBAF6004A13CB /* TokenType.swift */, + 442FC86BDB73BD2AE6F20731 /* ERC875Token.swift */, ); path = Types; sourceTree = ""; @@ -1733,6 +1741,7 @@ 442FCB2726DB345481C1FDA1 /* GetSymbolCoordinator.swift */, 442FC002CDEA792B8ECD3E13 /* Get875BalanceCoordinator.swift */, 442FCEBC98D0A367D258D2C3 /* GetIsECR875Coordinator.swift */, + 442FC0F2E3BB3EE420BC2C16 /* GetDecimalsCoordinator.swift */, ); path = Coordinators; sourceTree = ""; @@ -2842,6 +2851,9 @@ 442FCED8B618930EFD1F7BA8 /* GetIsECR875.swift in Sources */, 442FC58B7558F28F9452D383 /* GetIsECR875Coordinator.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; }; diff --git a/Trust/Tokens/Types/TokensDataStore.swift b/Trust/Tokens/Types/TokensDataStore.swift index 71e4ceb57..10469a2dd 100644 --- a/Trust/Tokens/Types/TokensDataStore.swift +++ b/Trust/Tokens/Types/TokensDataStore.swift @@ -38,6 +38,10 @@ class TokensDataStore { return GetIsECR875Coordinator(web3: self.web3) }() + private lazy var getDecimalsCoordinator: GetDecimalsCoordinator = { + return GetDecimalsCoordinator(web3: self.web3) + }() + private let provider = TrustProviderFactory.makeProvider() let account: Wallet @@ -119,44 +123,42 @@ class TokensDataStore { } // TODO: Clean this up - func getContractName(for addressString: String) { + func getContractName(for addressString: String, + completion: @escaping (Result) -> Void) { let address = Address(string: addressString) - 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) -> Void) { let address = Address(string: addressString) - - getSymbolCoordinator.getSymbol(for: address!) { (result) in - NSLog("command.object \(result)") + getSymbolCoordinator.getSymbol(for: address!) { result in + completion(result) } } - - func getContractBalanceOf(for addressString: String) { + func getDecimals(for addressString: String, + completion: @escaping (Result) -> Void) { let address = Address(string: addressString) - - get875BalanceCoordinator.getBalance(for: account.address, contract: address!) { (result) in - NSLog("command.object \(result)") + getDecimalsCoordinator.getDecimals(for: address!) { result in + completion(result) } } - func getIsECR875(for addressString: String) { + func getContractBalance(for addressString: String, + completion: @escaping (Result<[UInt16], AnyError>) -> Void) { let address = Address(string: addressString) + get875BalanceCoordinator.getBalance(for: account.address, contract: address!) { result in + completion(result) + } + } - getIsECR875Coordinator.getIsECR875(for: address!) { [weak self] result in - 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) -> Void) { + let address = Address(string: addressString) + getIsECR875Coordinator.getIsECR875(for: address!) { result in + completion(result) } }