-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
huge refactoring, generics, remove redudant class et c
- Loading branch information
Showing
13 changed files
with
1,546 additions
and
1,216 deletions.
There are no files selected for viewing
1,890 changes: 943 additions & 947 deletions
1,890
Example/web3swiftBrowser/Pods/Pods.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 79 additions & 36 deletions
115
Example/web3swiftBrowser/web3swiftBrowser/Base.lproj/Main.storyboard
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Example/web3swiftBrowser/web3swiftBrowser/PrefferedModels.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// PrefferedModels.swift | ||
// web3swiftBrowser | ||
// | ||
// Created by Petr Korolev on 26.10.2020. | ||
// Copyright © 2020 Matter Labs. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import web3swift | ||
|
||
struct Wallet { | ||
enum walletType: Int { | ||
case EthereumKeystoreV3 | ||
case BIP39 | ||
} | ||
|
||
var name: String = "Wallet" | ||
var bitsOfEntropy: Int = 128 // Entropy is a measure of password strength. Usually used 128 or 256 bits. | ||
var password = "web3swift" // We recommend here and everywhere to use the password set by the user. | ||
|
||
var address: String | ||
var keystore: AbstractKeystore | ||
var data: Data | ||
var isHD: Bool | ||
|
||
init(type: walletType) { | ||
switch type { | ||
case .EthereumKeystoreV3: | ||
keystore = try! EthereumKeystoreV3(password: password)! | ||
self.address = keystore.addresses!.first!.address | ||
self.data = try! JSONEncoder().encode(keystore.giveKeystoreParams()) | ||
self.isHD = false | ||
|
||
case .BIP39: | ||
let mnemonics = try! BIP39.generateMnemonics(bitsOfEntropy: bitsOfEntropy)! | ||
keystore = try! BIP32Keystore( | ||
mnemonics: mnemonics, | ||
password: password, | ||
mnemonicsPassword: "", | ||
language: .english)! | ||
self.name = "HD Wallet" | ||
self.data = try! JSONEncoder().encode(keystore.giveKeystoreParams()) | ||
self.isHD = true | ||
} | ||
|
||
self.address = keystore.addresses!.first!.address | ||
} | ||
} | ||
|
||
struct HDKey { | ||
let name: String? | ||
let address: String | ||
} | ||
|
||
struct ERC20Token { | ||
var name: String | ||
var address: String | ||
var decimals: String | ||
var symbol: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.