Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS-8091 Core DAO SDK #856

Merged
merged 8 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions BlockchainSdk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@
DA55032F2BFDF47500817BDA /* KoinosTransactionParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55032E2BFDF47500817BDA /* KoinosTransactionParams.swift */; };
DA570CEF27A802BE007F34EB /* SolanaError+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA570CEE27A802BE007F34EB /* SolanaError+.swift */; };
DA570CF927A82322007F34EB /* PolkadotBlockchainMeta.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA570CF727A82322007F34EB /* PolkadotBlockchainMeta.swift */; };
DA5766AC2CAAD14F00F96564 /* CoreExternalLinkProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5766AB2CAAD14F00F96564 /* CoreExternalLinkProvider.swift */; };
DA59750B27D744A7009F0A1F /* BlockchainSdkExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA59750A27D744A7009F0A1F /* BlockchainSdkExampleApp.swift */; };
DA59750D27D744A7009F0A1F /* BlockchainSdkExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA59750C27D744A7009F0A1F /* BlockchainSdkExampleView.swift */; };
DA59750F27D744A9009F0A1F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DA59750E27D744A9009F0A1F /* Assets.xcassets */; };
Expand Down Expand Up @@ -1463,6 +1464,7 @@
DA55032E2BFDF47500817BDA /* KoinosTransactionParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KoinosTransactionParams.swift; sourceTree = "<group>"; };
DA570CEE27A802BE007F34EB /* SolanaError+.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SolanaError+.swift"; sourceTree = "<group>"; };
DA570CF727A82322007F34EB /* PolkadotBlockchainMeta.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PolkadotBlockchainMeta.swift; sourceTree = "<group>"; };
DA5766AB2CAAD14F00F96564 /* CoreExternalLinkProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreExternalLinkProvider.swift; sourceTree = "<group>"; };
DA59750827D744A7009F0A1F /* BlockchainSdkExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BlockchainSdkExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
DA59750A27D744A7009F0A1F /* BlockchainSdkExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockchainSdkExampleApp.swift; sourceTree = "<group>"; };
DA59750C27D744A7009F0A1F /* BlockchainSdkExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockchainSdkExampleView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3848,6 +3850,7 @@
B63E63072BC5CD470086F04F /* BaseExternalLinkProvider.swift */,
DA02C7AB2C61016A0086718D /* BlastExternalLinkProvider.swift */,
1CF315322C39B5B0004EF522 /* CyberExternalLinkProvider.swift */,
DA5766AB2CAAD14F00F96564 /* CoreExternalLinkProvider.swift */,
);
path = OtherChains;
sourceTree = "<group>";
Expand Down Expand Up @@ -5373,6 +5376,7 @@
EFAD40A52A965BA800364D65 /* BlockBookNode.swift in Sources */,
DAD156652C7DD25800DE52B3 /* FilecoinSignedMessage.swift in Sources */,
DA5339A52BFCBE8600BA3D80 /* KoinosProtocol.swift in Sources */,
DA5766AC2CAAD14F00F96564 /* CoreExternalLinkProvider.swift in Sources */,
DC5E65012B1650F400E81AA5 /* OP_NEGATE.swift in Sources */,
EF3B191E2AA85C150084AA1C /* CardanoExternalLinkProvider.swift in Sources */,
B633EA252B8FC79000F11BFF /* TronTransactionHistoryProvider.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// CoreExternalLinkProvider.swift
// BlockchainSdk
//
// Created by Aleksei Muraveinik on 30.9.24..
// Copyright © 2024 Tangem AG. All rights reserved.
//

import Foundation

struct CoreExternalLinkProvider {
private let baseExplorerUrl: String

init(isTestnet: Bool) {
baseExplorerUrl = isTestnet
? "https://scan.test.btcs.network"
: "https://scan.coredao.org"
}
}

extension CoreExternalLinkProvider: ExternalLinkProvider {
var testnetFaucetURL: URL? {
URL(string: "https://scan.test.btcs.network/faucet")
}

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

func url(transaction hash: String) -> URL? {
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 @@ -227,6 +227,10 @@ struct TestnetAPINodeInfoProvider {
return [
.init(url: URL(string: "https://api-tn10.kaspa.org")!)
]
case .core:
return [
.init(url: URL(string: "https://rpc.test.btcs.network")!)
]
// TODO: Refactor in IOS-6639
case .bitcoin, .litecoin, .disChain, .rsk, .bitcoinCash, .binance, .cardano,
.xrp, .ducatus, .tezos, .dogecoin, .solana, .kusama, .dash, .gnosis,
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 @@ -85,7 +85,8 @@ struct AddressTypesConfig {
.blast,
.sui,
.filecoin,
.sei:
.sei,
.core:
return [.default]
}
}
Expand Down
18 changes: 15 additions & 3 deletions BlockchainSdk/Common/Blockchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public indirect enum Blockchain: Equatable, Hashable {
case sui(curve: EllipticCurve, testnet: Bool)
case filecoin
case sei(testnet: Bool)
case core(testnet: Bool)

public var isTestnet: Bool {
switch self {
Expand Down Expand Up @@ -126,7 +127,8 @@ public indirect enum Blockchain: Equatable, Hashable {
.cyber(let testnet),
.blast(let testnet),
.sei(let testnet),
.kaspa(let testnet):
.kaspa(let testnet),
.core(let testnet):
return testnet
case .litecoin,
.ducatus,
Expand Down Expand Up @@ -277,7 +279,8 @@ public indirect enum Blockchain: Equatable, Hashable {
.base,
.cyber,
.blast,
.filecoin:
.filecoin,
.core:
return 18
case .cardano,
.xrp,
Expand Down Expand Up @@ -446,6 +449,8 @@ public indirect enum Blockchain: Equatable, Hashable {
return "FIL"
case .sei:
return "SEI"
case .core:
return isTestnet ? "tCORE" : "CORE"
}
}

Expand Down Expand Up @@ -728,6 +733,7 @@ extension Blockchain {
case .base: return isTestnet ? 84532 : 8453
case .cyber: return isTestnet ? 111557560 : 7560
case .blast: return isTestnet ? 168587773 : 81457
case .core: return isTestnet ? 1115 : 1116
default:
return nil
}
Expand Down Expand Up @@ -791,6 +797,7 @@ extension Blockchain {
case .base: return true
case .cyber: return false
case .blast: return false
case .core: return false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже нет EIP1559?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тоже глянул explorer там вроде как нет, вопрос как и у энерджи веб, что приходит в фи хистори

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В фи хистори пришло:

EthereumFeeHistory(
    baseFee: 0, 
    lowBaseFee: 0, 
    marketBaseFee: 0, 
    fastBaseFee: 0, 
    lowPriorityFee: 30000000000, 
    marketPriorityFee: 36000000000,
    fastPriorityFee: 45000000000
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Более низкоуровнево вот так, но тут в целом то же самое

(lldb) po response
▿ EthereumFeeHistoryResponse
  ▿ baseFeePerGas : 2 elements
    - 0 : "0x0"
    - 1 : "0x0"
  ▿ reward : 1 element
    ▿ 0 : 3 elements
      - 0 : "0x70e054f00"
      - 1 : "0x737be7600"
      - 2 : "0x9502f9000"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кажется просто фоллбэк сработал на gasPrice и заполнил фи хистори, ну чет нули странно, видимо не поддерживает

default:
assertionFailure("Don't forget about evm here")
return false
Expand Down Expand Up @@ -922,6 +929,7 @@ extension Blockchain: Codable {
case .sui: return "sui"
case .filecoin: return "filecoin"
case .sei: return "sei"
case .core: return "core"
}
}

Expand Down Expand Up @@ -1015,6 +1023,7 @@ extension Blockchain: Codable {
case "sui": self = .sui(curve: curve, testnet: isTestnet)
case "filecoin": self = .filecoin
case "sei": self = .sei(testnet: isTestnet)
case "core": self = .core(testnet: isTestnet)
default:
throw BlockchainSdkError.decodingFailed
}
Expand Down Expand Up @@ -1238,6 +1247,8 @@ private extension Blockchain {
return "filecoin"
case .sei:
return "sei-network"
case .core:
return "core"
}
}

Expand Down Expand Up @@ -1290,7 +1301,8 @@ extension Blockchain {
.taraxa,
.decimal,
.xdc,
.telos:
.telos,
.core:
return EthereumWalletAssembly()
case .optimism,
.manta,
Expand Down
4 changes: 3 additions & 1 deletion BlockchainSdk/Common/Blockchain/Blockchain+AllCases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public extension Blockchain {
case .sui: break
case .filecoin: break
case .sei: break
case .core: break
// READ BELOW:
//
// Did you get a compilation error here? If so, add your new blockchain to the array below
Expand Down Expand Up @@ -158,7 +159,8 @@ public extension Blockchain {
.blast(testnet: false),
.sui(curve: .ed25519_slip0010, testnet: false),
.filecoin,
.sei(testnet: false)
.sei(testnet: false),
.core(testnet: false)
]
}
}
2 changes: 2 additions & 0 deletions BlockchainSdk/Common/Derivations/DerivationConfigV1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public struct DerivationConfigV1: DerivationConfig {
return "m/44'/784'/0'/0'/0'"
case .filecoin:
return "m/44'/461'/0'/0/0"
case .core:
return "m/44'/1116'/0'/0/0"
}
}
}
3 changes: 2 additions & 1 deletion BlockchainSdk/Common/Derivations/DerivationConfigV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public struct DerivationConfigV2: DerivationConfig {
.taraxa,
.base,
.cyber,
.blast:
.blast,
.core:
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 @@ -67,7 +67,8 @@ public struct DerivationConfigV3: DerivationConfig {
.taraxa,
.base,
.cyber,
.blast:
.blast,
.core:
return "m/44'/60'/0'/0/0"
case .ethereumClassic:
return "m/44'/61'/0'/0/0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public struct AddressServiceFactory {
.taraxa,
.base,
.cyber,
.blast:
.blast,
.core:
return EthereumAddressService()
case .rsk:
return RskAddressService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct EstimationFeeAddressFactory {
.kava, .cronos, .telos, .octa, .shibarium, .disChain,
.areon, .playa3ullGames, .pulsechain, .aurora, .manta,
.zkSync, .moonbeam, .polygonZkEVM, .moonriver, .mantle,
.flare, .taraxa, .base, .blast, .cyber:
.flare, .taraxa, .base, .blast, .cyber, .core:
return "0x52bb4012854f808CF9BAbd855e44E506dAf6C077"
case .ethereumClassic:
return "0xc49722a6f4Fe5A1347710dEAAa1fafF4c275689b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ public struct ExternalLinkProviderFactory {
return FilecoinExternalLinkProvider()
case .sei:
return SeiExternalLinkProvider(isTestnet: isTestnet)
case .core:
return CoreExternalLinkProvider(isTestnet: isTestnet)
}
}
}
3 changes: 2 additions & 1 deletion BlockchainSdk/Extensions/TWCoin+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ extension CoinType {
.bittensor,
.cyber,
.koinos,
.blast:
.blast,
.core:
// 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 @@ -59,7 +59,8 @@ extension PublicKeyType {
.internetComputer,
.base,
.blast,
.cyber:
.cyber,
.core:
self = PublicKeyType.secp256k1Extended
case .stellar,
.ton,
Expand Down
Loading