From 9ec97d3150d2dc03d04702ed854f4d4db90883e2 Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:42:13 +0900 Subject: [PATCH 1/4] add setup-git (#46) --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3eb519e6..d796b9cb 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,10 @@ install-toolchains: @echo Install toolchains for uniffi @cd core/gemstone && make prepare-apple -bootstrap: install generate +bootstrap: install generate setup-git + +setup-git: + @git config submodule.recurse true core-upgrade: git submodule update --recursive --remote From 04e299d6402358123925ec7db8f4e137fe72b771 Mon Sep 17 00:00:00 2001 From: gemcoder21 <104884878+gemcoder21@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:23:59 +0100 Subject: [PATCH 2/4] Add ChainIDFetchable protocol --- .../Blockchain/Sources/Aptos/AptosService.swift | 8 ++++++++ .../Sources/Bitcoin/BitcoinService.swift | 8 ++++++++ Packages/Blockchain/Sources/ChainService.swift | 6 ++++++ .../Sources/Cosmos/CosmosProvider.swift | 9 +++++++-- .../Sources/Cosmos/CosmosService.swift | 10 ++++++++++ .../Sources/Cosmos/Models/CosmosNodeInfo.swift | 16 ++++++++++++++++ .../Sources/Ethereum/EthereumService.swift | 12 ++++++++++++ .../Blockchain/Sources/Near/NearService.swift | 8 ++++++++ .../Sources/Protocols/ChainServiceable.swift | 7 ++++++- .../Sources/Solana/SolanaService.swift | 8 ++++++++ Packages/Blockchain/Sources/Sui/SuiService.swift | 8 ++++++++ Packages/Blockchain/Sources/Ton/TonService.swift | 8 ++++++++ .../Blockchain/Sources/Tron/TronService.swift | 8 ++++++++ Packages/Blockchain/Sources/Xrp/XRPService.swift | 8 ++++++++ core | 2 +- 15 files changed, 122 insertions(+), 4 deletions(-) diff --git a/Packages/Blockchain/Sources/Aptos/AptosService.swift b/Packages/Blockchain/Sources/Aptos/AptosService.swift index 61294a6a..89d79d11 100644 --- a/Packages/Blockchain/Sources/Aptos/AptosService.swift +++ b/Packages/Blockchain/Sources/Aptos/AptosService.swift @@ -113,3 +113,11 @@ extension AptosService: ChainTokenable { false } } + +// MARK: - ChainIDFetchable + +extension AptosService: ChainIDFetchable { + public func getChainID() async throws -> String { + fatalError() + } +} diff --git a/Packages/Blockchain/Sources/Bitcoin/BitcoinService.swift b/Packages/Blockchain/Sources/Bitcoin/BitcoinService.swift index 4660ffa2..d51b7aa0 100644 --- a/Packages/Blockchain/Sources/Bitcoin/BitcoinService.swift +++ b/Packages/Blockchain/Sources/Bitcoin/BitcoinService.swift @@ -164,6 +164,14 @@ extension BitcoinService: ChainTokenable { } } +// MARK: - ChainIDFetchable + +extension BitcoinService: ChainIDFetchable { + public func getChainID() async throws -> String { + fatalError() + } +} + public extension UTXO { func mapToUnspendTransaction(address: String, coinType: CoinType) -> BitcoinUnspentTransaction { BitcoinUnspentTransaction.with { diff --git a/Packages/Blockchain/Sources/ChainService.swift b/Packages/Blockchain/Sources/ChainService.swift index 22708328..75565621 100644 --- a/Packages/Blockchain/Sources/ChainService.swift +++ b/Packages/Blockchain/Sources/ChainService.swift @@ -122,3 +122,9 @@ extension ChainService: ChainTokenable { } } +extension ChainService: ChainIDFetchable { + public func getChainID() async throws -> String { + return try await Self.service(chain: chain, with: url) + .getChainID() + } +} diff --git a/Packages/Blockchain/Sources/Cosmos/CosmosProvider.swift b/Packages/Blockchain/Sources/Cosmos/CosmosProvider.swift index 9d38ab47..fba55d73 100644 --- a/Packages/Blockchain/Sources/Cosmos/CosmosProvider.swift +++ b/Packages/Blockchain/Sources/Cosmos/CosmosProvider.swift @@ -14,6 +14,7 @@ public enum CosmosProvider: TargetType { case broadcast(data: String) case transaction(id: String) case syncing + case nodeInfo public var baseUrl: URL { return URL(string: "")! @@ -29,7 +30,8 @@ public enum CosmosProvider: TargetType { .delegations, .undelegations, .rewards, - .validators: + .validators, + .nodeInfo: return .GET case .broadcast: return .POST @@ -58,6 +60,8 @@ public enum CosmosProvider: TargetType { return "/cosmos/tx/v1beta1/txs/\(id)" case .syncing: return "/cosmos/base/tendermint/v1beta1/syncing" + case .nodeInfo: + return "/cosmos/base/tendermint/v1beta1/node_info" } } @@ -71,7 +75,8 @@ public enum CosmosProvider: TargetType { .validators, .block, .transaction, - .syncing: + .syncing, + .nodeInfo: return .plain case .broadcast(let data): return .data(Data(data.utf8)) diff --git a/Packages/Blockchain/Sources/Cosmos/CosmosService.swift b/Packages/Blockchain/Sources/Cosmos/CosmosService.swift index 16f5a39d..b277ff14 100644 --- a/Packages/Blockchain/Sources/Cosmos/CosmosService.swift +++ b/Packages/Blockchain/Sources/Cosmos/CosmosService.swift @@ -351,3 +351,13 @@ extension CosmosService: ChainTokenable { false } } + +// MARK: - ChainIDFetchable + +extension CosmosService: ChainIDFetchable { + public func getChainID() async throws -> String { + return try await provider + .request(.nodeInfo) + .map(as: CosmosNodeInfoResponse.self).default_node_info.network + } +} diff --git a/Packages/Blockchain/Sources/Cosmos/Models/CosmosNodeInfo.swift b/Packages/Blockchain/Sources/Cosmos/Models/CosmosNodeInfo.swift index 0f291644..82822dd8 100644 --- a/Packages/Blockchain/Sources/Cosmos/Models/CosmosNodeInfo.swift +++ b/Packages/Blockchain/Sources/Cosmos/Models/CosmosNodeInfo.swift @@ -27,3 +27,19 @@ public struct CosmosBlockResponse: Codable { self.block = block } } + +public struct CosmosNodeInfo: Codable { + public let network: String + + public init(network: String) { + self.network = network + } +} + +public struct CosmosNodeInfoResponse: Codable { + public let default_node_info: CosmosNodeInfo + + public init(default_node_info: CosmosNodeInfo) { + self.default_node_info = default_node_info + } +} diff --git a/Packages/Blockchain/Sources/Ethereum/EthereumService.swift b/Packages/Blockchain/Sources/Ethereum/EthereumService.swift index c65307dd..2c35653e 100644 --- a/Packages/Blockchain/Sources/Ethereum/EthereumService.swift +++ b/Packages/Blockchain/Sources/Ethereum/EthereumService.swift @@ -249,6 +249,8 @@ extension EthereumService: ChainStakable { } } +// MARK: - ChainTokenable + extension EthereumService: ChainTokenable { public func getTokenData(tokenId: String) async throws -> Asset { guard let address = WalletCore.AnyAddress(string: tokenId, coin: chain.chain.coinType)?.description else { @@ -275,3 +277,13 @@ extension EthereumService: ChainTokenable { tokenId.hasPrefix("0x") && Data(fromHex: tokenId) != nil && tokenId.count == 42 } } + +// MARK: - ChainIDFetchable + +extension EthereumService: ChainIDFetchable { + public func getChainID() async throws -> String { + return try await provider + .request(.chainId) + .map(as: JSONRPCResponse.self).result.value.description + } +} diff --git a/Packages/Blockchain/Sources/Near/NearService.swift b/Packages/Blockchain/Sources/Near/NearService.swift index 8dc18971..969b3159 100644 --- a/Packages/Blockchain/Sources/Near/NearService.swift +++ b/Packages/Blockchain/Sources/Near/NearService.swift @@ -154,6 +154,14 @@ extension NearService: ChainTokenable { } } +// MARK: - ChainIDFetchable + +extension NearService: ChainIDFetchable { + public func getChainID() async throws -> String { + fatalError() + } +} + extension NearRPCError: LocalizedError { public var errorDescription: String? { if let data = error.data{ diff --git a/Packages/Blockchain/Sources/Protocols/ChainServiceable.swift b/Packages/Blockchain/Sources/Protocols/ChainServiceable.swift index 80c281f1..d7e91239 100644 --- a/Packages/Blockchain/Sources/Protocols/ChainServiceable.swift +++ b/Packages/Blockchain/Sources/Protocols/ChainServiceable.swift @@ -9,7 +9,8 @@ public typealias ChainServiceable = ChainBalanceable & ChainTransactionStateFetchable & ChainSyncable & ChainStakable & - ChainTokenable + ChainTokenable & + ChainIDFetchable public protocol ChainBalanceable { func coinBalance(for address: String) async throws -> AssetBalance @@ -36,6 +37,10 @@ public protocol ChainSyncable { func getInSync() async throws -> Bool } +public protocol ChainIDFetchable { + func getChainID() async throws -> String +} + public protocol ChainStakable { func getValidators(apr: Double) async throws -> [DelegationValidator] func getStakeDelegations(address: String) async throws -> [DelegationBase] diff --git a/Packages/Blockchain/Sources/Solana/SolanaService.swift b/Packages/Blockchain/Sources/Solana/SolanaService.swift index f1e7393f..0dad8279 100644 --- a/Packages/Blockchain/Sources/Solana/SolanaService.swift +++ b/Packages/Blockchain/Sources/Solana/SolanaService.swift @@ -361,3 +361,11 @@ extension SolanaService: ChainTokenable { tokenId.count.isBetween(40, and: 60) && Base58.decodeNoCheck(string: tokenId) != nil } } + +// MARK: - ChainIDFetchable + +extension SolanaService: ChainIDFetchable { + public func getChainID() async throws -> String { + fatalError() + } +} diff --git a/Packages/Blockchain/Sources/Sui/SuiService.swift b/Packages/Blockchain/Sources/Sui/SuiService.swift index 2f602c6f..85f33927 100644 --- a/Packages/Blockchain/Sources/Sui/SuiService.swift +++ b/Packages/Blockchain/Sources/Sui/SuiService.swift @@ -395,6 +395,14 @@ extension SuiService: ChainStakable { } } +// MARK: - ChainIDFetchable + +extension SuiService: ChainIDFetchable { + public func getChainID() async throws -> String { + fatalError() + } +} + extension SuiSystemState { var epochStartDate: Date { Date(timeIntervalSince1970: (TimeInterval(epochStartTimestampMs) ?? 0) / 1000) diff --git a/Packages/Blockchain/Sources/Ton/TonService.swift b/Packages/Blockchain/Sources/Ton/TonService.swift index c4c07f3a..3899f981 100644 --- a/Packages/Blockchain/Sources/Ton/TonService.swift +++ b/Packages/Blockchain/Sources/Ton/TonService.swift @@ -234,6 +234,14 @@ extension TonService: ChainTokenable { } } +// MARK: - ChainIDFetchable + +extension TonService: ChainIDFetchable { + public func getChainID() async throws -> String { + fatalError() + } +} + struct RunGetMethod: Codable { let stack: [[StackItem]] } diff --git a/Packages/Blockchain/Sources/Tron/TronService.swift b/Packages/Blockchain/Sources/Tron/TronService.swift index 625e58d1..bcf4cd3a 100644 --- a/Packages/Blockchain/Sources/Tron/TronService.swift +++ b/Packages/Blockchain/Sources/Tron/TronService.swift @@ -293,6 +293,14 @@ extension TronService: ChainStakable { } } +// MARK: - ChainIDFetchable + +extension TronService: ChainIDFetchable { + public func getChainID() async throws -> String { + fatalError() + } +} + extension TronService: ChainTokenable { public func getTokenData(tokenId: String) async throws -> Asset { guard let address = WalletCore.AnyAddress(string: tokenId, coin: chain.coinType)?.description else { diff --git a/Packages/Blockchain/Sources/Xrp/XRPService.swift b/Packages/Blockchain/Sources/Xrp/XRPService.swift index b4e90ff6..74607409 100644 --- a/Packages/Blockchain/Sources/Xrp/XRPService.swift +++ b/Packages/Blockchain/Sources/Xrp/XRPService.swift @@ -124,3 +124,11 @@ extension XRPService: ChainTokenable { false } } + +// MARK: - ChainIDFetchable + +extension XRPService: ChainIDFetchable { + public func getChainID() async throws -> String { + fatalError() + } +} diff --git a/core b/core index 20d6ec26..09777228 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 20d6ec265a262a7a6368bd28ebe772d1c053039d +Subproject commit 09777228e5055b0bb393ce3f8b40280bf1ef45a8 From cabd788d44089fb08ea6f34d6fdb90083edec2d0 Mon Sep 17 00:00:00 2001 From: gemcoder21 <104884878+gemcoder21@users.noreply.github.com> Date: Thu, 13 Jun 2024 00:53:11 +0100 Subject: [PATCH 3/4] Remove Colors.xcassets in favor of programatic hex values --- Gem.xcodeproj/project.pbxproj | 4 - Gem/Resources/Colors.xcassets/Contents.json | 6 -- .../black.colorset/Contents.json | 38 ---------- .../blue.colorset/Contents.json | 38 ---------- .../blueDark.colorset/Contents.json | 38 ---------- .../gray.colorset/Contents.json | 38 ---------- .../grayBackground.colorset/Contents.json | 38 ---------- .../grayDarkBackground.colorset/Contents.json | 38 ---------- .../grayLight.colorset/Contents.json | 38 ---------- .../grayVeryLight.colorset/Contents.json | 38 ---------- .../green.colorset/Contents.json | 38 ---------- .../greenLight.colorset/Contents.json | 38 ---------- .../Contents.json | 38 ---------- .../orange.colorset/Contents.json | 29 ------- .../red.colorset/Contents.json | 38 ---------- .../redLight.colorset/Contents.json | 38 ---------- .../secondaryText.colorset/Contents.json | 38 ---------- .../white.colorset/Contents.json | 38 ---------- .../whiteSolid.colorset/Contents.json | 20 ----- Packages/Style/Sources/Colors.swift | 76 ++++++++++++++----- .../{ => Extentions}/Color+Style.swift | 17 ++++- .../Sources/Extentions/UIColor+Style.swift | 22 ++++++ 22 files changed, 96 insertions(+), 648 deletions(-) delete mode 100644 Gem/Resources/Colors.xcassets/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/black.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/blue.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/blueDark.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/gray.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/grayBackground.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/grayDarkBackground.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/grayLight.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/grayVeryLight.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/green.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/greenLight.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/launchScreenBackground.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/orange.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/red.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/redLight.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/secondaryText.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/white.colorset/Contents.json delete mode 100644 Gem/Resources/Colors.xcassets/whiteSolid.colorset/Contents.json rename Packages/Style/Sources/{ => Extentions}/Color+Style.swift (71%) create mode 100644 Packages/Style/Sources/Extentions/UIColor+Style.swift diff --git a/Gem.xcodeproj/project.pbxproj b/Gem.xcodeproj/project.pbxproj index 279743dc..af6e9b6f 100644 --- a/Gem.xcodeproj/project.pbxproj +++ b/Gem.xcodeproj/project.pbxproj @@ -28,7 +28,6 @@ C34C7CFA29FF19A3009EEC21 /* WelcomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C34C7CF929FF19A3009EEC21 /* WelcomeViewModel.swift */; }; C34C7CFD29FF2A07009EEC21 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C34C7CFF29FF2A07009EEC21 /* Localizable.strings */; }; C34C7D0829FF5818009EEC21 /* Localized.swift in Sources */ = {isa = PBXBuildFile; fileRef = C34C7D0629FF5817009EEC21 /* Localized.swift */; }; - C34C7D0A29FF58CB009EEC21 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C34C7D0929FF58CB009EEC21 /* Colors.xcassets */; }; C34C7D132A006E9F009EEC21 /* SecretPhraseViewableModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C34C7D122A006E9F009EEC21 /* SecretPhraseViewableModel.swift */; }; C3549B3129C42E8F00B4BE01 /* AssetListViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3549B3029C42E8F00B4BE01 /* AssetListViewModelTests.swift */; }; C3549B3529C4396A00B4BE01 /* AssetViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3549B3429C4396A00B4BE01 /* AssetViewModelTests.swift */; }; @@ -275,7 +274,6 @@ C34C7D0029FF2A0B009EEC21 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; C34C7D0129FF57CA009EEC21 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; C34C7D0629FF5817009EEC21 /* Localized.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Localized.swift; sourceTree = ""; }; - C34C7D0929FF58CB009EEC21 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = ""; }; C34C7D122A006E9F009EEC21 /* SecretPhraseViewableModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretPhraseViewableModel.swift; sourceTree = ""; }; C3549B3029C42E8F00B4BE01 /* AssetListViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssetListViewModelTests.swift; sourceTree = ""; }; C3549B3429C4396A00B4BE01 /* AssetViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssetViewModelTests.swift; sourceTree = ""; }; @@ -1520,7 +1518,6 @@ C30952B9299C39D80004C0F9 /* Gem.entitlements */, C34C7D0629FF5817009EEC21 /* Localized.swift */, C34C7CFF29FF2A07009EEC21 /* Localizable.strings */, - C34C7D0929FF58CB009EEC21 /* Colors.xcassets */, C30952B7299C39D80004C0F9 /* Images.xcassets */, ); path = Resources; @@ -1695,7 +1692,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C34C7D0A29FF58CB009EEC21 /* Colors.xcassets in Resources */, C34C7CFD29FF2A07009EEC21 /* Localizable.strings in Resources */, C3866B612A803B19004FB60C /* Launch Screen.storyboard in Resources */, DF1167112BC36240000F8C8C /* PrivacyInfo.xcprivacy in Resources */, diff --git a/Gem/Resources/Colors.xcassets/Contents.json b/Gem/Resources/Colors.xcassets/Contents.json deleted file mode 100644 index 73c00596..00000000 --- a/Gem/Resources/Colors.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/black.colorset/Contents.json b/Gem/Resources/Colors.xcassets/black.colorset/Contents.json deleted file mode 100644 index 2f1745a6..00000000 --- a/Gem/Resources/Colors.xcassets/black.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x22", - "green" : "0x22", - "red" : "0x22" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/blue.colorset/Contents.json b/Gem/Resources/Colors.xcassets/blue.colorset/Contents.json deleted file mode 100644 index 5609bb43..00000000 --- a/Gem/Resources/Colors.xcassets/blue.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xE6", - "green" : "0x5B", - "red" : "0x2D" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xE6", - "green" : "0x5B", - "red" : "0x2D" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/blueDark.colorset/Contents.json b/Gem/Resources/Colors.xcassets/blueDark.colorset/Contents.json deleted file mode 100644 index 4bc032d7..00000000 --- a/Gem/Resources/Colors.xcassets/blueDark.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xC5", - "green" : "0x42", - "red" : "0x17" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xC5", - "green" : "0x42", - "red" : "0x17" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/gray.colorset/Contents.json b/Gem/Resources/Colors.xcassets/gray.colorset/Contents.json deleted file mode 100644 index 9310753a..00000000 --- a/Gem/Resources/Colors.xcassets/gray.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.506", - "green" : "0.506", - "red" : "0.506" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x81", - "green" : "0x81", - "red" : "0x81" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/grayBackground.colorset/Contents.json b/Gem/Resources/Colors.xcassets/grayBackground.colorset/Contents.json deleted file mode 100644 index 4c8ef69a..00000000 --- a/Gem/Resources/Colors.xcassets/grayBackground.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF7", - "green" : "0xF2", - "red" : "0xF2" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x1E", - "green" : "0x1C", - "red" : "0x1C" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/grayDarkBackground.colorset/Contents.json b/Gem/Resources/Colors.xcassets/grayDarkBackground.colorset/Contents.json deleted file mode 100644 index eb228215..00000000 --- a/Gem/Resources/Colors.xcassets/grayDarkBackground.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF0", - "green" : "0xE6", - "red" : "0xE6" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x1E", - "green" : "0x1C", - "red" : "0x1C" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/grayLight.colorset/Contents.json b/Gem/Resources/Colors.xcassets/grayLight.colorset/Contents.json deleted file mode 100644 index 5801c238..00000000 --- a/Gem/Resources/Colors.xcassets/grayLight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.592", - "green" : "0.600", - "red" : "0.592" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.592", - "green" : "0.600", - "red" : "0.592" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/grayVeryLight.colorset/Contents.json b/Gem/Resources/Colors.xcassets/grayVeryLight.colorset/Contents.json deleted file mode 100644 index 3a962ac1..00000000 --- a/Gem/Resources/Colors.xcassets/grayVeryLight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xF4", - "green" : "0xF4", - "red" : "0xF4" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x33", - "green" : "0x33", - "red" : "0x33" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/green.colorset/Contents.json b/Gem/Resources/Colors.xcassets/green.colorset/Contents.json deleted file mode 100644 index a6828852..00000000 --- a/Gem/Resources/Colors.xcassets/green.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.427", - "green" : "0.604", - "red" : "0.106" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.427", - "green" : "0.604", - "red" : "0.106" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/greenLight.colorset/Contents.json b/Gem/Resources/Colors.xcassets/greenLight.colorset/Contents.json deleted file mode 100644 index 286e06c4..00000000 --- a/Gem/Resources/Colors.xcassets/greenLight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.961", - "green" : "0.984", - "red" : "0.918" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x3C", - "green" : "0x42", - "red" : "0x27" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/launchScreenBackground.colorset/Contents.json b/Gem/Resources/Colors.xcassets/launchScreenBackground.colorset/Contents.json deleted file mode 100644 index 4b4777b0..00000000 --- a/Gem/Resources/Colors.xcassets/launchScreenBackground.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0xFF", - "green" : "0xFF", - "red" : "0xFF" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x22", - "green" : "0x22", - "red" : "0x22" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/orange.colorset/Contents.json b/Gem/Resources/Colors.xcassets/orange.colorset/Contents.json deleted file mode 100644 index 5257126d..00000000 --- a/Gem/Resources/Colors.xcassets/orange.colorset/Contents.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x14", - "green" : "0x93", - "red" : "0xFF" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/red.colorset/Contents.json b/Gem/Resources/Colors.xcassets/red.colorset/Contents.json deleted file mode 100644 index 5a04d1d2..00000000 --- a/Gem/Resources/Colors.xcassets/red.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x4E", - "green" : "0x4E", - "red" : "0xF8" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x4E", - "green" : "0x4E", - "red" : "0xF8" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/redLight.colorset/Contents.json b/Gem/Resources/Colors.xcassets/redLight.colorset/Contents.json deleted file mode 100644 index 84df143a..00000000 --- a/Gem/Resources/Colors.xcassets/redLight.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.949", - "green" : "0.949", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x30", - "green" : "0x2D", - "red" : "0x46" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/secondaryText.colorset/Contents.json b/Gem/Resources/Colors.xcassets/secondaryText.colorset/Contents.json deleted file mode 100644 index 99588300..00000000 --- a/Gem/Resources/Colors.xcassets/secondaryText.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.506", - "green" : "0.506", - "red" : "0.506" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.506", - "green" : "0.506", - "red" : "0.506" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/white.colorset/Contents.json b/Gem/Resources/Colors.xcassets/white.colorset/Contents.json deleted file mode 100644 index 6ca89b1c..00000000 --- a/Gem/Resources/Colors.xcassets/white.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0x22", - "green" : "0x22", - "red" : "0x22" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Gem/Resources/Colors.xcassets/whiteSolid.colorset/Contents.json b/Gem/Resources/Colors.xcassets/whiteSolid.colorset/Contents.json deleted file mode 100644 index 97650a1a..00000000 --- a/Gem/Resources/Colors.xcassets/whiteSolid.colorset/Contents.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Packages/Style/Sources/Colors.swift b/Packages/Style/Sources/Colors.swift index e8523058..f478bf60 100644 --- a/Packages/Style/Sources/Colors.swift +++ b/Packages/Style/Sources/Colors.swift @@ -1,21 +1,63 @@ import SwiftUI public struct Colors { - public static let white = Color("white", bundle: .main) - public static let whiteSolid = Color("whiteSolid", bundle: .main) - public static let black = Color("black", bundle: .main) - public static let blue = Color("blue", bundle: .main) - public static let blueDark = Color("blueDark", bundle: .main) - public static let red = Color("red", bundle: .main) - public static let redLight = Color("redLight", bundle: .main) - public static let green = Color("green", bundle: .main) - public static let orange = Color("orange", bundle: .main) - public static let orangeLight = Color("orangeLight", bundle: .main) - public static let greenLight = Color("greenLight", bundle: .main) - public static let gray = Color("gray", bundle: .main) - public static let grayBackground = Color("grayBackground", bundle: .main) - public static let grayDarkBackground = Color("grayDarkBackground", bundle: .main) - public static let grayLight = Color("grayLight", bundle: .main) - public static let grayVeryLight = Color("grayVeryLight", bundle: .main) - public static let secondaryText = Color("secondaryText", bundle: .main) + public static let white = Color.dynamicColor("#FFFFFF", dark: "#222222") + public static let whiteSolid = Color.dynamicColor("FFFFFF") + public static let black = Color.dynamicColor("#222222", dark: "FFFFFF") + public static let blue = Color.dynamicColor("#2D5BE6") + public static let blueDark = Color.dynamicColor("#1742C5") + public static let red = Color.dynamicColor("#F84E4E") + public static let redLight = Color.dynamicColor("#FFF1F1", dark: "#462D30") + public static let green = Color.dynamicColor("#1B9A6C") + public static let greenLight = Color.dynamicColor("EAFAF5", dark: "27423C") + public static let orange = Color.dynamicColor("#FF9314") + public static let gray = Color.dynamicColor("#818181") + public static let grayLight = Color.dynamicColor("#969996") + public static let grayVeryLight = Color.dynamicColor("#F4F4F4", dark: "#333333") + public static let grayBackground = Color.dynamicColor("#F2F2F7", dark: "#1C1C1E") + public static let grayDarkBackground = Color.dynamicColor("#E6E6F0", dark: "#1C1C1E") + public static let secondaryText = Color.dynamicColor("#818181") } + +#Preview { + let colors: [(name: String, color: Color)] = [ + ("White", Colors.white), + ("White Solid", Colors.whiteSolid), + ("Black", Colors.black), + ("Blue", Colors.blue), + ("Blue Dark", Colors.blueDark), + ("Red", Colors.red), + ("Red Light", Colors.redLight), + ("Green", Colors.green), + ("Green Light", Colors.greenLight), + ("Orange", Colors.orange), + ("Gray", Colors.gray), + ("Gray Light", Colors.grayLight), + ("Gray Very Light", Colors.grayVeryLight), + ("Gray Background", Colors.grayBackground), + ("Gray Dark Background", Colors.grayDarkBackground), + ("Secondary Text", Colors.secondaryText), + ] + return List { + ForEach(colors, id: \.name) { color in + HStack { + Text(color.name) + .multilineTextAlignment(.leading) + .frame(width: 174) + + RoundedRectangle(cornerRadius: 4) + .fill(color.color) + .padding(Spacing.extraSmall) + .colorScheme(.light) + + RoundedRectangle(cornerRadius: 4) + .fill(color.color) + .padding(Spacing.extraSmall) + .colorScheme(.dark) + } + .listRowInsets(EdgeInsets(top: 0, leading: 8, bottom: 0, trailing: 0)) + } + } + .listStyle(InsetGroupedListStyle()) +} + diff --git a/Packages/Style/Sources/Color+Style.swift b/Packages/Style/Sources/Extentions/Color+Style.swift similarity index 71% rename from Packages/Style/Sources/Color+Style.swift rename to Packages/Style/Sources/Extentions/Color+Style.swift index da3aba2c..5d49b480 100644 --- a/Packages/Style/Sources/Color+Style.swift +++ b/Packages/Style/Sources/Extentions/Color+Style.swift @@ -1,7 +1,14 @@ +// Copyright (c). Gem Wallet. All rights reserved. + import Foundation import SwiftUI extension Color { + + public var uiColor: UIColor { + return UIColor(self) + } + public init(hex: String) { let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) var int: UInt64 = 0 @@ -27,7 +34,13 @@ extension Color { ) } - public var uiColor: UIColor { - return UIColor(self) + // hex values + static func dynamicColor(_ light: String, dark: String? = .none) -> Color { + let lightColor = Color(hex: light) + let darkColor: Color? = switch dark { + case .some(let color): Color(color) + case .none: .none + } + return UIColor.dynamicColor(lightColor, dark: darkColor) } } diff --git a/Packages/Style/Sources/Extentions/UIColor+Style.swift b/Packages/Style/Sources/Extentions/UIColor+Style.swift new file mode 100644 index 00000000..a71a5f71 --- /dev/null +++ b/Packages/Style/Sources/Extentions/UIColor+Style.swift @@ -0,0 +1,22 @@ +// Copyright (c). Gem Wallet. All rights reserved. + +import Foundation +import SwiftUI + +extension UIColor { + + public var color: Color { + Color(self) + } + + public class func dynamicColor(_ light: Color, dark: Color?) -> Color { + return UIColor { + switch $0.userInterfaceStyle { + case .dark: + return dark?.uiColor ?? light.uiColor + default: + return light.uiColor + } + }.color + } +} From 44b0f9f2b85971534a00682ca2c13708ee2b5d2a Mon Sep 17 00:00:00 2001 From: gemcoder21 <104884878+gemcoder21@users.noreply.github.com> Date: Thu, 13 Jun 2024 01:49:32 +0100 Subject: [PATCH 4/4] Implement using chain config --- Gem/Transactions/Services/TransactionService.swift | 2 +- .../Blockchain/Sources/Bitcoin/BitcoinProvider.swift | 9 +++++++-- .../Sources/GemstoneSwift/Config.swift | 6 ++++++ core | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Gem/Transactions/Services/TransactionService.swift b/Gem/Transactions/Services/TransactionService.swift index 41d61f91..c31c446c 100644 --- a/Gem/Transactions/Services/TransactionService.swift +++ b/Gem/Transactions/Services/TransactionService.swift @@ -38,7 +38,7 @@ class TransactionService { NSLog("pending transactions request: chain \(transaction.assetId.chain.rawValue), for: (\(transaction.hash))") try await updateState(for: transaction) } catch { - let timeout = Gemstone.chainTransactionTimeoutSeconds(chain: transaction.assetId.chain.rawValue) + let timeout = Config.shared.getChainConfig(chain: transaction.assetId.chain.rawValue).transactionTimeout let interval = Date.now.timeIntervalSince(transaction.createdAt) if interval > timeout { let _ = try transactionStore.updateState(id: transaction.id, state: .failed) diff --git a/Packages/Blockchain/Sources/Bitcoin/BitcoinProvider.swift b/Packages/Blockchain/Sources/Bitcoin/BitcoinProvider.swift index 5359cc45..89935b37 100644 --- a/Packages/Blockchain/Sources/Bitcoin/BitcoinProvider.swift +++ b/Packages/Blockchain/Sources/Bitcoin/BitcoinProvider.swift @@ -9,6 +9,7 @@ public enum BitcoinProvider: TargetType { case nodeInfo case utxo(address: String) case fee(priority: Int) + case block(block: Int) case broadcast(data: String) public var baseUrl: URL { @@ -27,6 +28,8 @@ public enum BitcoinProvider: TargetType { return "/api/v2/utxo/\(address)" case .fee(let priority): return "/api/v2/estimatefee/\(priority)" + case .block(let block): + return "/api/v2/block/\(block)" case .broadcast: return "/api/v2/sendtx/" } @@ -38,7 +41,8 @@ public enum BitcoinProvider: TargetType { .transaction, .nodeInfo, .utxo, - .fee: + .fee, + .block: return .GET case .broadcast: return .POST @@ -51,7 +55,8 @@ public enum BitcoinProvider: TargetType { .transaction, .nodeInfo, .utxo, - .fee: + .fee, + .block: return .plain case .broadcast(let data): return .data(Data(data.utf8)) diff --git a/Packages/GemstonePrimitives/Sources/GemstoneSwift/Config.swift b/Packages/GemstonePrimitives/Sources/GemstoneSwift/Config.swift index 808103a5..299f1433 100644 --- a/Packages/GemstonePrimitives/Sources/GemstoneSwift/Config.swift +++ b/Packages/GemstonePrimitives/Sources/GemstoneSwift/Config.swift @@ -32,6 +32,12 @@ public struct StakeConfig { } } +public struct ChainConfig { + public static func config(chain: Chain) -> Gemstone.ChainConfig { + Config.shared.getChainConfig(chain: chain.rawValue) + } +} + public struct WalletConnectConfig { public static func config() -> Gemstone.WalletConnectConfig { Config.shared.getWalletConnectConfig() diff --git a/core b/core index 09777228..9034a953 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 09777228e5055b0bb393ce3f8b40280bf1ef45a8 +Subproject commit 9034a953458f3fd93f6dd4b6dfea54ae2121197d