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

Create wallet from the seed #262

Merged
merged 10 commits into from
Apr 4, 2023
Merged

Conversation

tureck1y
Copy link
Collaborator

No description provided.

@tureck1y tureck1y requested a review from Andoran90 March 27, 2023 17:13
@tureck1y
Copy link
Collaborator Author

tureck1y commented Mar 29, 2023

Переименовал все на IsImported / keysImport

@@ -44,7 +44,8 @@ class WalletDeserializer {

func deserializeWallet(from decoder: TlvDecoder) throws -> Card.Wallet {
let status: Card.Wallet.Status = try decoder.decode(.status)
guard status == .loaded || status == .backuped else { //We need only loaded wallets
Copy link
Member

Choose a reason for hiding this comment

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

loaded надо переименовать на generated видимо. Непонятно вообще. Не читается.

Copy link
Member

Choose a reason for hiding this comment

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

Типа Imported, Generated
GeneratedAndBackedup
ImportedAndBackedup

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

это же внутрянка сдк, не хочется ее делать сильно далеко от документации карты

Copy link
Member

Choose a reason for hiding this comment

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

Ну пока ок, тогда, на надо и в документации поправить просто.

@@ -44,7 +44,8 @@ class WalletDeserializer {

func deserializeWallet(from decoder: TlvDecoder) throws -> Card.Wallet {
let status: Card.Wallet.Status = try decoder.decode(.status)
guard status == .loaded || status == .backuped else { //We need only loaded wallets

if !status.isLoaded { //We need only loaded wallets
Copy link
Member

Choose a reason for hiding this comment

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

Вообще не поймешь, что это значит

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

сделал isAvailable

private let signingMethod = SigningMethod.signHash

/// Default initializer
/// - Parameter curve: Elliptic curve of the wallet. `Card.supportedCurves` contains all curves supported by the card
init(curve: EllipticCurve) {
/// - Parameter seed: An optional BIP39 seed to create wallet from. COS v6.10+.
init(curve: EllipticCurve, seed: Data?) throws {
Copy link
Member

Choose a reason for hiding this comment

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

А нельзя сделать два конструктора? Мне кажется понятнее будет.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Имхо так понятнее. Сид есть - будет использоваться, Сида нет - не будет.

if let seed {
self.keyToImport = try BIP32().makeMasterKey(from: seed, curve: curve)
} else {
self.keyToImport = nil
Copy link
Member

Choose a reason for hiding this comment

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

А он изначально не nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

нет, это же константа и ее надо проинициализировать явно в конструкторе

private var derivationTask: DeriveWalletPublicKeysTask? = nil
/// Default initializer
/// - Parameter curve: Elliptic curve of the wallet. `Card.supportedCurves` contains all curves supported by the card
public init(curve: EllipticCurve) {
/// - Parameter seed: An optional BIP39 seed to create wallet from. COS v6.10+. Nil by default.
public init(curve: EllipticCurve, seed: Data? = nil) {
Copy link
Member

Choose a reason for hiding this comment

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

Опять же, может разные конструкторы? все же хочется разделить на столько разные задачи

@tureck1y
Copy link
Collaborator Author

Обновил код. Ответил там, где по комментам не правил

@tureck1y tureck1y merged commit 6a731aa into develop Apr 4, 2023
@tureck1y tureck1y deleted the IOS-3219_create_wallet_from_seed branch April 4, 2023 08:17
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