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-8332 [Casper] make casper address service #4140

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from

Conversation

skibinalexander
Copy link
Contributor

Базовая имплементация сервиса адресов каспера

…_casper_address_service

# Conflicts:
#	TangemApp.xcodeproj/project.pbxproj
#	TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved
…_casper_address_service

# Conflicts:
#	BlockchainSdk/Common/API/TestnetAPINodeInfoProvider.swift
#	BlockchainSdk/Common/Blockchain.swift
#	BlockchainSdk/Common/Blockchain/Blockchain+AllCases.swift
#	BlockchainSdkTests/Extensions/TWPublicKeyType+.swift
#	TangemApp.xcodeproj/project.pbxproj
#	TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved
…ddress_service

# Conflicts:
#	TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved
…ddress_service

# Conflicts:
#	TangemApp.xcodeproj/project.pbxproj
…ddress_service

# Conflicts:
#	BlockchainSdk/Common/Address/AddressTypesConfig.swift
#	BlockchainSdk/Common/Blockchain.swift
#	BlockchainSdk/Common/Blockchain/Blockchain+AllCases.swift
#	BlockchainSdk/Common/Factories/ExternalLinkProviderFactory.swift
#	BlockchainSdk/Extensions/TWCoin+.swift
#	Tangem/App/Services/ExchangeService/MercuryoService.swift
#	Tangem/App/Services/ExchangeService/MoonPayService.swift
#	Tangem/App/Utilities/CustomTokenContractAddressConverter.swift
#	Tangem/App/Utilities/TokenInteractionAvailabilityProvider.swift
#	Tangem/Modules/Send/Services/TransactionParamsBuilder.swift
@skibinalexander skibinalexander marked this pull request as ready for review November 5, 2024 07:56
@skibinalexander skibinalexander requested review from tureck1y and a team as code owners November 5, 2024 07:56
@skibinalexander skibinalexander requested review from Andoran90, amuraveinik, Vyachesl0ve and m3g0byt3 and removed request for Andoran90 November 5, 2024 07:56
@@ -1,5 +1,5 @@
{
"originHash" : "584ca60af0fbbc527d504d4d480a556058e05f97a79e92bf44c594618d31cc9a",
"originHash" : "279320f6fd232b7bb4b2b24520941724ff8087e6be3fcae17ffa02b6129981e1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Почищу / уберу

public struct CasperAddressService {
// MARK: - Private Properties

private let curve: EllipticCurve
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Не стал пока упаковывать в blockchain.casper(curve) так пользоваться будем все равно secp по итогу ресерча

Vyachesl0ve
Vyachesl0ve previously approved these changes Nov 5, 2024
Comment on lines +42 to +43
let isCorrectEd25519Address = address.count == CasperConstants.lengthED25519 && address.hasPrefix(CasperConstants.prefixED25519)
let isCorrectSecp256k1Address = address.count == CasperConstants.lengthSECP256K1 && address.hasPrefix(CasperConstants.prefixSECP256K1)
Copy link
Contributor

Choose a reason for hiding this comment

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

А у нас разве нет какого-то стандартного механизма проверки валидности адресов?
Как работают все остальные сети, там же нет такой логики
Или у каспера что-то свое специфичное?

btw проверок только на префикс + длину мне кажется мало для того, чтобы считать адрес валидным
как минимум у secp есть всякие sec bit и т.д.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Я тут не очень понял, сделать проверка префиска в самом начале, дальше проверка кейсов и дальше проверка чексуммы

let result: String = inputNibbles.reduce(into: "") { partialResult, nibbleByte in
let char = String(format: "%X", nibbleByte)

if char.range(of: Constants.regexEncodeByte, options: .regularExpression) != nil, hashBitsValues.next() ?? false {
Copy link
Contributor

Choose a reason for hiding this comment

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

А какой смысл в этой регулярке?
В nibbleByte лежит байт, сконвертить в hex его можно любым hex экстеншеном

Copy link
Contributor Author

Choose a reason for hiding this comment

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

А какой смысл в этой регулярке? В nibbleByte лежит байт, сконвертить в hex его можно любым hex экстеншеном

тут же не %2x а %x , реализация с официального кошелька как я понимаю

Comment on lines 36 to 39
func toBitArray() -> [Bit] {
let arrayBits = map { $0.toBits() }
return arrayBits.reduce(into: []) { partialResult, bits in partialResult.append(contentsOf: bits) }
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Кажется можно return flatMmap { $0.toBits() }

@@ -40,7 +40,7 @@
{
"identity" : "bigint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/attaswift/BigInt",
"location" : "https://github.com/attaswift/BigInt.git",
Copy link
Contributor

Choose a reason for hiding this comment

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

А какая у тебя версия Xcode?
В блейме я вижу что этот суффикс то добавляется то пропадает у разных людей

Screenshot 2024-11-05 at 15 32 25
Screenshot 2024-11-05 at 15 32 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants