Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Cyber network support (#756)
Browse files Browse the repository at this point in the history
Co-authored-by: Denis Baturin <[email protected]>
Co-authored-by: Aleksei Muraveinik <[email protected]>
  • Loading branch information
3 people authored Aug 9, 2024
1 parent c2419e8 commit 3eb99d8
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 3 deletions.
4 changes: 4 additions & 0 deletions BlockchainSdk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
0AF90CD92B87655A00772F04 /* Playa3ullGamesExternalLinkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF90CD82B87655A00772F04 /* Playa3ullGamesExternalLinkProvider.swift */; };
0AF90CDB2B87657F00772F04 /* PulsechainExternalLinkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF90CDA2B87657F00772F04 /* PulsechainExternalLinkProvider.swift */; };
0AF90CDD2B87658600772F04 /* AuroraExternalLinkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF90CDC2B87658600772F04 /* AuroraExternalLinkProvider.swift */; };
1CF315332C39B5B0004EF522 /* CyberExternalLinkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CF315322C39B5B0004EF522 /* CyberExternalLinkProvider.swift */; };
2D01EBFD2B04FC6700DEF1CC /* DecimalAddressService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D01EBFC2B04FC6700DEF1CC /* DecimalAddressService.swift */; };
2D01EC002B05223900DEF1CC /* DecimalExternalLinkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D01EBFF2B05223900DEF1CC /* DecimalExternalLinkProvider.swift */; };
2D01EC042B05281800DEF1CC /* DecimalAddressConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D01EC032B05281800DEF1CC /* DecimalAddressConverter.swift */; };
Expand Down Expand Up @@ -929,6 +930,7 @@
0AF90CDA2B87657F00772F04 /* PulsechainExternalLinkProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PulsechainExternalLinkProvider.swift; sourceTree = "<group>"; };
0AF90CDC2B87658600772F04 /* AuroraExternalLinkProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuroraExternalLinkProvider.swift; sourceTree = "<group>"; };
0C79DB7FEDD8D4029AFA208D /* Pods-BlockchainSdk.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlockchainSdk.release.xcconfig"; path = "Target Support Files/Pods-BlockchainSdk/Pods-BlockchainSdk.release.xcconfig"; sourceTree = "<group>"; };
1CF315322C39B5B0004EF522 /* CyberExternalLinkProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CyberExternalLinkProvider.swift; sourceTree = "<group>"; };
2D01EBFC2B04FC6700DEF1CC /* DecimalAddressService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecimalAddressService.swift; sourceTree = "<group>"; };
2D01EBFF2B05223900DEF1CC /* DecimalExternalLinkProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecimalExternalLinkProvider.swift; sourceTree = "<group>"; };
2D01EC032B05281800DEF1CC /* DecimalAddressConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecimalAddressConverter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3664,6 +3666,7 @@
DAB9BE712BBD902C00E77545 /* TaraxaExternalLinkProvider.swift */,
B63E63072BC5CD470086F04F /* BaseExternalLinkProvider.swift */,
DA02C7AB2C61016A0086718D /* BlastExternalLinkProvider.swift */,
1CF315322C39B5B0004EF522 /* CyberExternalLinkProvider.swift */,
);
path = OtherChains;
sourceTree = "<group>";
Expand Down Expand Up @@ -4660,6 +4663,7 @@
2D78F4142A5D955700962CCA /* ClvmProgram.swift in Sources */,
B0BAEE9825FF1E0400F318A6 /* RosettaBody.swift in Sources */,
DA198B6129E4090C00DB6EEA /* CosmosRestProvider.swift in Sources */,
1CF315332C39B5B0004EF522 /* CyberExternalLinkProvider.swift in Sources */,
B6F89EAE2BB20DB50009A453 /* SubscanAPIResult.ExtrinsicInfo.swift in Sources */,
EF937BE12B90EF0C009B8374 /* MaximumAmountRestrictable.swift in Sources */,
2D3829C929D34A93001D4785 /* TWCoin+.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// File.swift
// BlockchainSdk
//
// Created by Vadim Sitak on 06.07.2024.
// Copyright © 2024 Tangem AG. All rights reserved.
//

import Foundation


struct CyberExternalLinkProvider: ExternalLinkProvider {
let testnetFaucetURL = URL(string: "https://faucet.quicknode.com/cyber/sepolia")
private let baseExplorerUrl: String

init(isTestnet: Bool) {
baseExplorerUrl = isTestnet ? "https://testnet.cyberscan.co" : "https://cyberscan.co"
}

func url(address: String, contractAddress: String?) -> URL? {
return URL(string: "\(baseExplorerUrl)/address/\(address)")
}

func url(transaction hash: String) -> URL? {
return URL(string: "\(baseExplorerUrl)/tx/\(hash)")
}
}
4 changes: 4 additions & 0 deletions BlockchainSdk/Common/API/TestnetAPINodeInfoProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ struct TestnetAPINodeInfoProvider {
return [
.init(url: URL(string: "https://harbinger-api.koinos.io")!)
]
case .cyber:
return [
.init(url: URL(string: "https://cyber-testnet.alt.technology")!)
]
case .blast:
return [
.init(url: URL(string: "https://sepolia.blast.io")!),
Expand Down
1 change: 1 addition & 0 deletions BlockchainSdk/Common/Address/AddressTypesConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct AddressTypesConfig {
.bittensor,
.internetComputer,
.koinos,
.cyber,
.blast:
return [.default]
}
Expand Down
17 changes: 16 additions & 1 deletion BlockchainSdk/Common/Blockchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public indirect enum Blockchain: Equatable, Hashable {
case bittensor(curve: EllipticCurve)
case koinos(testnet: Bool)
case internetComputer(curve: EllipticCurve)
case cyber(testnet: Bool)
case blast(testnet: Bool)

public var isTestnet: Bool {
Expand Down Expand Up @@ -119,6 +120,7 @@ public indirect enum Blockchain: Equatable, Hashable {
.radiant(let testnet),
.base(let testnet),
.koinos(let testnet),
.cyber(let testnet),
.blast(let testnet):
return testnet
case .litecoin,
Expand Down Expand Up @@ -267,6 +269,7 @@ public indirect enum Blockchain: Equatable, Hashable {
.flare,
.taraxa,
.base,
.cyber,
.blast:
return 18
case .cardano,
Expand Down Expand Up @@ -316,6 +319,7 @@ public indirect enum Blockchain: Equatable, Hashable {
.zkSync,
.polygonZkEVM,
.base,
.cyber,
.blast:
return "ETH"
case .ethereumClassic:
Expand Down Expand Up @@ -552,7 +556,8 @@ public indirect enum Blockchain: Equatable, Hashable {
.manta(let testnet),
.zkSync(let testnet),
.polygonZkEVM(let testnet),
.base(let testnet):
.base(let testnet),
.cyber(let testnet):
return Blockchain.ethereum(testnet: testnet).coinId
default:
return coinId
Expand Down Expand Up @@ -703,6 +708,7 @@ extension Blockchain {
case .flare: return isTestnet ? 114 : 14
case .taraxa: return isTestnet ? 842 : 841
case .base: return isTestnet ? 84532 : 8453
case .cyber: return isTestnet ? 111557560 : 7560
case .blast: return isTestnet ? 168587773 : 81457
default:
return nil
Expand Down Expand Up @@ -748,6 +754,7 @@ extension Blockchain {
case .flare: return true
case .taraxa: return false
case .base: return true
case .cyber: return false
case .blast: return false
default:
assertionFailure("Don't forget about evm here")
Expand Down Expand Up @@ -875,6 +882,7 @@ extension Blockchain: Codable {
case .bittensor: return "bittensor"
case .koinos: return "koinos"
case .internetComputer: return "internet-computer"
case .cyber: return "cyber"
case .blast: return "blast"
}
}
Expand Down Expand Up @@ -964,6 +972,7 @@ extension Blockchain: Codable {
case "bittensor": self = .bittensor(curve: curve)
case "koinos": self = .koinos(testnet: isTestnet)
case "internet-computer": self = .internetComputer(curve: curve)
case "cyber": self = .cyber(testnet: isTestnet)
case "blast": self = .blast(testnet: isTestnet)
default:
throw BlockchainSdkError.decodingFailed
Expand Down Expand Up @@ -1168,6 +1177,11 @@ private extension Blockchain {
return "koinos"
case .internetComputer:
return "internet-computer"
case .cyber:
switch type {
case .network: return "cyber"
case .coin: return "cyberconnect"
}
case .blast:
return "blast"
}
Expand Down Expand Up @@ -1227,6 +1241,7 @@ extension Blockchain {
case .optimism,
.manta,
.base,
.cyber,
.blast:
return EthereumOptimisticRollupWalletAssembly()
case .bitcoinCash:
Expand Down
2 changes: 2 additions & 0 deletions BlockchainSdk/Common/Blockchain/Blockchain+AllCases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public extension Blockchain {
case .bittensor: break
case .koinos: break
case .internetComputer: break
case .cyber: break
case .blast: break
// READ BELOW:
//
Expand Down Expand Up @@ -150,6 +151,7 @@ public extension Blockchain {
.bittensor(curve: .ed25519_slip0010),
.koinos(testnet: false),
.internetComputer(curve: .secp256k1),
.cyber(testnet: false),
.blast(testnet: false),
]
}
Expand Down
1 change: 1 addition & 0 deletions BlockchainSdk/Common/Derivations/DerivationConfigV1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public struct DerivationConfigV1: DerivationConfig {
.flare,
.taraxa,
.base,
.cyber,
.blast:
return "m/44'/60'/0'/0/0"
case .ethereumClassic:
Expand Down
1 change: 1 addition & 0 deletions BlockchainSdk/Common/Derivations/DerivationConfigV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public struct DerivationConfigV2: DerivationConfig {
.flare,
.taraxa,
.base,
.cyber,
.blast:
return "m/44'/60'/0'/0/0"
case .binance:
Expand Down
1 change: 1 addition & 0 deletions BlockchainSdk/Common/Derivations/DerivationConfigV3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public struct DerivationConfigV3: DerivationConfig {
.flare,
.taraxa,
.base,
.cyber,
.blast:
return "m/44'/60'/0'/0/0"
case .ethereumClassic:
Expand Down
1 change: 1 addition & 0 deletions BlockchainSdk/Common/Factories/AddressServiceFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public struct AddressServiceFactory {
.flare,
.taraxa,
.base,
.cyber,
.blast:
return EthereumAddressService()
case .rsk:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct EstimationFeeAddressFactory {
.kava, .cronos, .telos, .octa, .shibarium, .disChain,
.areon, .playa3ullGames, .pulsechain, .aurora, .manta,
.zkSync, .moonbeam, .polygonZkEVM, .moonriver, .mantle,
.flare, .taraxa, .base, .blast:
.flare, .taraxa, .base, .blast, .cyber:
return "0x52bb4012854f808CF9BAbd855e44E506dAf6C077"
case .ethereumClassic:
return "0xc49722a6f4Fe5A1347710dEAAa1fafF4c275689b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public struct ExternalLinkProviderFactory {
return KoinosExternalLinkProvider(isTestnet: isTestnet)
case .internetComputer:
return ICPExternalLinkProvider()
case .cyber:
return CyberExternalLinkProvider(isTestnet: isTestnet)
case .blast:
return BlastExternalLinkProvider(isTestnet: isTestnet)
}
Expand Down
1 change: 1 addition & 0 deletions BlockchainSdk/Extensions/TWCoin+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ extension CoinType {
.base,
.joystream,
.bittensor,
.cyber,
.koinos,
.blast:
// Blockchains that are not in WalletCore yet
Expand Down
3 changes: 2 additions & 1 deletion BlockchainSdkTests/Extensions/TWPublicKeyType+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ extension PublicKeyType {
.taraxa,
.internetComputer,
.base,
.blast:
.blast,
.cyber:
self = PublicKeyType.secp256k1Extended
case .stellar,
.ton,
Expand Down

0 comments on commit 3eb99d8

Please sign in to comment.