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

Commit

Permalink
IOS-7275 EVM blockchains / Blast (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseiMuraveinik1 authored Aug 8, 2024
1 parent cf7f8db commit c2419e8
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 13 deletions.
4 changes: 4 additions & 0 deletions BlockchainSdk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@
B6FC9DC52B62A3AC00448D8A /* HederaWalletAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FC9DC42B62A3AC00448D8A /* HederaWalletAssembly.swift */; };
B6FC9DC82B62A45600448D8A /* HederaAddressService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FC9DC72B62A45600448D8A /* HederaAddressService.swift */; };
BFF1171432045E1915ABA71F /* Pods_BlockchainSdk.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF8BC4C03E68061ED530292C /* Pods_BlockchainSdk.framework */; };
DA02C7AC2C61016A0086718D /* BlastExternalLinkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA02C7AB2C61016A0086718D /* BlastExternalLinkProvider.swift */; };
DA0B68522C0DFF4800F38AB8 /* KoinosWalletManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA0B68512C0DFF4800F38AB8 /* KoinosWalletManager.swift */; };
DA0E98D22C04708E00C92985 /* KoinosNetworkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA0E98D12C04708E00C92985 /* KoinosNetworkProvider.swift */; };
DA0E98D42C0472DB00C92985 /* KoinosTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA0E98D32C0472DB00C92985 /* KoinosTarget.swift */; };
Expand Down Expand Up @@ -1365,6 +1366,7 @@
B6FC9DC72B62A45600448D8A /* HederaAddressService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HederaAddressService.swift; sourceTree = "<group>"; };
BF8BC4C03E68061ED530292C /* Pods_BlockchainSdk.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BlockchainSdk.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D1A207847B605E0517D9A55F /* Pods_BlockchainSdkTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BlockchainSdkTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DA02C7AB2C61016A0086718D /* BlastExternalLinkProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlastExternalLinkProvider.swift; sourceTree = "<group>"; };
DA07EFEA28191631008712F1 /* TronTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TronTests.swift; sourceTree = "<group>"; };
DA0B68512C0DFF4800F38AB8 /* KoinosWalletManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KoinosWalletManager.swift; sourceTree = "<group>"; };
DA0E98D12C04708E00C92985 /* KoinosNetworkProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KoinosNetworkProvider.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3661,6 +3663,7 @@
DAFE0D0B2BB1841B005CBD9C /* FlareExternalLinkProvider.swift */,
DAB9BE712BBD902C00E77545 /* TaraxaExternalLinkProvider.swift */,
B63E63072BC5CD470086F04F /* BaseExternalLinkProvider.swift */,
DA02C7AB2C61016A0086718D /* BlastExternalLinkProvider.swift */,
);
path = OtherChains;
sourceTree = "<group>";
Expand Down Expand Up @@ -5019,6 +5022,7 @@
B675E9612B320DBE004AF179 /* VeChainNetworkResult.AccountInfo.swift in Sources */,
B05144FD2B57F13900EDAD1E /* EVMSmartContractInteractor.swift in Sources */,
DC5E65312B1650F400E81AA5 /* OP_VERNOTIF.swift in Sources */,
DA02C7AC2C61016A0086718D /* BlastExternalLinkProvider.swift in Sources */,
EFD717CC2A25EB0B00E5430D /* ABIEncoder.swift in Sources */,
DC5E64F02B1650F400E81AA5 /* OP_SUB.swift in Sources */,
DC5E651A2B1650F400E81AA5 /* OP_3DUP.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// BlastExternalLinkProvider.swift
// BlockchainSdk
//
// Created by Aleksei Muraveinik on 05.08.24.
// Copyright © 2024 Tangem AG. All rights reserved.
//

import Foundation

struct BlastExternalLinkProvider {
private let isTestnet: Bool

private var baseExplorerUrl: String {
if isTestnet {
"https://sepolia.blastexplorer.io"
} else {
"https://blastscan.io"
}
}

init(isTestnet: Bool) {
self.isTestnet = isTestnet
}
}

extension BlastExternalLinkProvider: ExternalLinkProvider {
var testnetFaucetURL: URL? {
URL(string: "https://docs.blast.io/tools/faucets")
}

func url(transaction hash: String) -> URL? {
URL(string: "\(baseExplorerUrl)/tx/\(hash)")
}

func url(address: String, contractAddress: String?) -> URL? {
URL(string: "\(baseExplorerUrl)/address/\(address)")
}
}
6 changes: 6 additions & 0 deletions BlockchainSdk/Common/API/TestnetAPINodeInfoProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ struct TestnetAPINodeInfoProvider {
return [
.init(url: URL(string: "https://harbinger-api.koinos.io")!)
]
case .blast:
return [
.init(url: URL(string: "https://sepolia.blast.io")!),
.init(url: URL(string: "https://blast-sepolia.drpc.org")!),
.init(url: URL(string: "https://blast-sepolia.blockpi.network/v1/rpc/public")!)
]
// TODO: Refactor in IOS-6639
case .bitcoin, .litecoin, .disChain, .rsk, .bitcoinCash, .binance, .cardano,
.xrp, .ducatus, .tezos, .dogecoin, .solana, .kusama, .dash, .gnosis, .kaspa,
Expand Down
3 changes: 2 additions & 1 deletion BlockchainSdk/Common/Address/AddressTypesConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ struct AddressTypesConfig {
.joystream,
.bittensor,
.internetComputer,
.koinos:
.koinos,
.blast:
return [.default]
}
}
Expand Down
19 changes: 15 additions & 4 deletions 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 blast(testnet: Bool)

public var isTestnet: Bool {
switch self {
Expand Down Expand Up @@ -117,7 +118,8 @@ public indirect enum Blockchain: Equatable, Hashable {
.taraxa(let testnet),
.radiant(let testnet),
.base(let testnet),
.koinos(let testnet):
.koinos(let testnet),
.blast(let testnet):
return testnet
case .litecoin,
.ducatus,
Expand Down Expand Up @@ -264,7 +266,8 @@ public indirect enum Blockchain: Equatable, Hashable {
.mantle,
.flare,
.taraxa,
.base:
.base,
.blast:
return 18
case .cardano,
.xrp,
Expand Down Expand Up @@ -312,7 +315,8 @@ public indirect enum Blockchain: Equatable, Hashable {
.manta,
.zkSync,
.polygonZkEVM,
.base:
.base,
.blast:
return "ETH"
case .ethereumClassic:
return "ETC"
Expand Down Expand Up @@ -699,6 +703,7 @@ extension Blockchain {
case .flare: return isTestnet ? 114 : 14
case .taraxa: return isTestnet ? 842 : 841
case .base: return isTestnet ? 84532 : 8453
case .blast: return isTestnet ? 168587773 : 81457
default:
return nil
}
Expand Down Expand Up @@ -743,6 +748,7 @@ extension Blockchain {
case .flare: return true
case .taraxa: return false
case .base: return true
case .blast: return false
default:
assertionFailure("Don't forget about evm here")
return false
Expand Down Expand Up @@ -869,6 +875,7 @@ extension Blockchain: Codable {
case .bittensor: return "bittensor"
case .koinos: return "koinos"
case .internetComputer: return "internet-computer"
case .blast: return "blast"
}
}

Expand Down Expand Up @@ -957,6 +964,7 @@ extension Blockchain: Codable {
case "bittensor": self = .bittensor(curve: curve)
case "koinos": self = .koinos(testnet: isTestnet)
case "internet-computer": self = .internetComputer(curve: curve)
case "blast": self = .blast(testnet: isTestnet)
default:
throw BlockchainSdkError.decodingFailed
}
Expand Down Expand Up @@ -1160,6 +1168,8 @@ private extension Blockchain {
return "koinos"
case .internetComputer:
return "internet-computer"
case .blast:
return "blast"
}
}

Expand Down Expand Up @@ -1216,7 +1226,8 @@ extension Blockchain {
return EthereumWalletAssembly()
case .optimism,
.manta,
.base:
.base,
.blast:
return EthereumOptimisticRollupWalletAssembly()
case .bitcoinCash:
return BitcoinCashWalletAssembly()
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 .blast: break
// READ BELOW:
//
// Did you get a compilation error here? If so, add your new blockchain to the array below
Expand Down Expand Up @@ -149,6 +150,7 @@ public extension Blockchain {
.bittensor(curve: .ed25519_slip0010),
.koinos(testnet: false),
.internetComputer(curve: .secp256k1),
.blast(testnet: false),
]
}
}
3 changes: 2 additions & 1 deletion BlockchainSdk/Common/Derivations/DerivationConfigV1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public struct DerivationConfigV1: DerivationConfig {
.mantle,
.flare,
.taraxa,
.base:
.base,
.blast:
return "m/44'/60'/0'/0/0"
case .ethereumClassic:
return "m/44'/61'/0'/0/0"
Expand Down
3 changes: 2 additions & 1 deletion BlockchainSdk/Common/Derivations/DerivationConfigV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public struct DerivationConfigV2: DerivationConfig {
.mantle,
.flare,
.taraxa,
.base:
.base,
.blast:
return "m/44'/60'/0'/0/0"
case .binance:
return "m/44'/714'/0'/0/0"
Expand Down
3 changes: 2 additions & 1 deletion BlockchainSdk/Common/Derivations/DerivationConfigV3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public struct DerivationConfigV3: DerivationConfig {
.mantle,
.flare,
.taraxa,
.base:
.base,
.blast:
return "m/44'/60'/0'/0/0"
case .ethereumClassic:
return "m/44'/61'/0'/0/0"
Expand Down
3 changes: 2 additions & 1 deletion BlockchainSdk/Common/Factories/AddressServiceFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public struct AddressServiceFactory {
.mantle,
.flare,
.taraxa,
.base:
.base,
.blast:
return EthereumAddressService()
case .rsk:
return RskAddressService()
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:
.flare, .taraxa, .base, .blast:
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 .blast:
return BlastExternalLinkProvider(isTestnet: isTestnet)
}
}
}
4 changes: 2 additions & 2 deletions BlockchainSdk/Extensions/TWCoin+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ extension CoinType {
.base,
.joystream,
.bittensor,
.internetComputer,
.koinos:
.koinos,
.blast:
// Blockchains that are not in WalletCore yet
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion BlockchainSdkTests/Extensions/TWPublicKeyType+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ extension PublicKeyType {
.flare,
.taraxa,
.internetComputer,
.base:
.base,
.blast:
self = PublicKeyType.secp256k1Extended
case .stellar,
.ton,
Expand Down

0 comments on commit c2419e8

Please sign in to comment.