-
Notifications
You must be signed in to change notification settings - Fork 36
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
base: develop
Are you sure you want to change the base?
IOS-8332 [Casper] make casper address service #4140
Conversation
…_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
@@ -1,5 +1,5 @@ | |||
{ | |||
"originHash" : "584ca60af0fbbc527d504d4d480a556058e05f97a79e92bf44c594618d31cc9a", | |||
"originHash" : "279320f6fd232b7bb4b2b24520941724ff8087e6be3fcae17ffa02b6129981e1", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не стал пока упаковывать в blockchain.casper(curve) так пользоваться будем все равно secp по итогу ресерча
let isCorrectEd25519Address = address.count == CasperConstants.lengthED25519 && address.hasPrefix(CasperConstants.prefixED25519) | ||
let isCorrectSecp256k1Address = address.count == CasperConstants.lengthSECP256K1 && address.hasPrefix(CasperConstants.prefixSECP256K1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А у нас разве нет какого-то стандартного механизма проверки валидности адресов?
Как работают все остальные сети, там же нет такой логики
Или у каспера что-то свое специфичное?
btw проверок только на префикс + длину мне кажется мало для того, чтобы считать адрес валидным
как минимум у secp есть всякие sec bit и т.д.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А какой смысл в этой регулярке?
В nibbleByte лежит байт, сконвертить в hex его можно любым hex экстеншеном
There was a problem hiding this comment.
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 , реализация с официального кошелька как я понимаю
BlockchainSdk/Extensions/Byte+.swift
Outdated
func toBitArray() -> [Bit] { | ||
let arrayBits = map { $0.toBits() } | ||
return arrayBits.reduce(into: []) { partialResult, bits in partialResult.append(contentsOf: bits) } | ||
} |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Базовая имплементация сервиса адресов каспера