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

chore: swiftlint auto fixes #761

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
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
Expand All @@ -31,6 +29,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
Expand Down Expand Up @@ -47,6 +46,4 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// to restore the scene back to its current state.
}


}

2 changes: 0 additions & 2 deletions Example/myWeb3Wallet/myWeb3Wallet/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ class ViewController: UIViewController {
// Do any additional setup after loading the view.
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class DashboardViewController: UIViewController {

}
}


/*
// MARK: - Navigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ import UIKit
class SplashViewController: UIViewController {

@IBOutlet weak var logoView: UIImageView!

override func viewDidLoad() {
super.viewDidLoad()
UIView.animate(withDuration: 0.9) {
self.logoView.center.y = self.view.center.y
Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.moveToWalletView), userInfo: nil, repeats: false)

}


// Do any additional setup after loading the view.
}
@objc func moveToWalletView(){
@objc func moveToWalletView() {

guard let walletScreen = self.storyboard?.instantiateViewController(withIdentifier: "WalletViewController") as? WalletViewController else {
#if DEBUG
printContent("Unable to get Wallet controller")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import UIKit
import web3swift
class WalletViewController: UIViewController {

@IBOutlet weak var continueButton: UIButton!
@IBOutlet weak var walletAddressLabel: UILabel!
@IBOutlet weak var importWalletButton: UIButton!
@IBOutlet weak var createWalletButton: UIButton!
var _walletAddress: String {
set{
set {
self.continueButton.isHidden = false
self.walletAddressLabel.text = newValue
}
Expand All @@ -27,23 +27,22 @@ class WalletViewController: UIViewController {
super.viewDidLoad()
self.createWalletButton.layer.cornerRadius = 5.0
self.importWalletButton.layer.cornerRadius = 5.0

// Do any additional setup after loading the view.
}



@IBAction func onClickCreateWallet(_ sender: UIButton) {
#if DEBUG
print("Clicked on Create Wallet Option")
#endif
self.createMnemonics()

}
@IBAction func onClickImportWalletButton(_ sender: UIButton) {
print("Clicked on import Wallet Option")
self.showImportALert()
}

@IBAction func onClickContinueButton(_ sender: UIButton) {
print("Clicked on COntinue button")
guard let dashboardScreen = self.storyboard?.instantiateViewController(withIdentifier: "DashboardViewController") as? DashboardViewController else {
Expand All @@ -54,7 +53,7 @@ class WalletViewController: UIViewController {
}
self.navigationController?.pushViewController(dashboardScreen, animated: true)
}
fileprivate func showImportALert(){
fileprivate func showImportALert() {
let alert = UIAlertController(title: "MyWeb3Wallet", message: "", preferredStyle: .alert)
alert.addTextField { textfied in
textfied.placeholder = "Enter mnemonics/private Key"
Expand All @@ -69,15 +68,15 @@ class WalletViewController: UIViewController {
guard let privateKey = alert.textFields?[0].text else { return }
print(privateKey)
self.importWalletWith(privateKey: privateKey)

}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
alert.addAction(mnemonicsAction)
alert.addAction(privateKeyAction)
alert.addAction(cancelAction)
self.present(alert, animated: true, completion: nil)
}
func importWalletWith(privateKey: String){
func importWalletWith(privateKey: String) {
let formattedKey = privateKey.trimmingCharacters(in: .whitespacesAndNewlines)
guard let dataKey = Data.fromHex(formattedKey) else {
self.showAlertMessage(title: "Error", message: "Please enter a valid Private key ", actionName: "Ok")
Expand All @@ -94,7 +93,7 @@ class WalletViewController: UIViewController {
#endif
let walletAddress = manager.addresses?.first?.address
self.walletAddressLabel.text = walletAddress ?? "0x"

print(walletAddress)
} else {
print("error")
Expand All @@ -109,34 +108,31 @@ class WalletViewController: UIViewController {
alert.addAction(okAction)
self.present(alert, animated: true)
}




}
func importWalletWith(mnemonics: String) {
let walletAddress = try? BIP32Keystore(mnemonics: mnemonics , prefixPath: "m/44'/77777'/0'/0")
let walletAddress = try? BIP32Keystore(mnemonics: mnemonics, prefixPath: "m/44'/77777'/0'/0")
print(walletAddress?.addresses)
self.walletAddressLabel.text = "\(walletAddress?.addresses?.first?.address ?? "0x")"

}



}
extension WalletViewController {
fileprivate func createMnemonics(){

fileprivate func createMnemonics() {
let userDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let web3KeystoreManager = KeystoreManager.managerForPath(userDir + "/keystore")
do {
if (web3KeystoreManager?.addresses?.count ?? 0 >= 0) {
if web3KeystoreManager?.addresses?.count ?? 0 >= 0 {
let tempMnemonics = try? BIP39.generateMnemonics(bitsOfEntropy: 256, language: .english)
guard let tMnemonics = tempMnemonics else {
self.showAlertMessage(title: "", message: "We are unable to create wallet", actionName: "Ok")
return
}
self._mnemonics = tMnemonics
print(_mnemonics)
let tempWalletAddress = try? BIP32Keystore(mnemonics: self._mnemonics , prefixPath: "m/44'/77777'/0'/0")
let tempWalletAddress = try? BIP32Keystore(mnemonics: self._mnemonics, prefixPath: "m/44'/77777'/0'/0")
print(tempWalletAddress?.addresses?.first?.address)
guard let walletAddress = tempWalletAddress?.addresses?.first else {
self.showAlertMessage(title: "", message: "We are unable to create wallet", actionName: "Ok")
Expand All @@ -151,9 +147,9 @@ extension WalletViewController {
FileManager.default.createFile(atPath: userDir + "/keystore"+"/key.json", contents: keyData, attributes: nil)
}
} catch {

}

}
}
extension UIViewController {
Expand All @@ -163,5 +159,5 @@ extension UIViewController {
alertController.addAction(action)
self.present(alertController, animated: true)
}

}
56 changes: 28 additions & 28 deletions Sources/Web3Core/EthereumABI/ABIElements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,35 +274,35 @@ extension ABI.Element.Function {
///
/// Return cases:
/// - when no `outputs` declared and `data` is not an error response:
///```swift
///["_success": true]
///```
/// ```swift
/// ["_success": true]
/// ```
/// - when `outputs` declared and decoding completed successfully:
///```swift
///["_success": true, "0": value_1, "1": value_2, ...]
///```
///Additionally this dictionary will have mappings to output names if these names are specified in the ABI;
/// ```swift
/// ["_success": true, "0": value_1, "1": value_2, ...]
/// ```
/// Additionally this dictionary will have mappings to output names if these names are specified in the ABI;
/// - function call was aborted using `revert(message)` or `require(expression, message)`:
///```swift
///["_success": false, "_abortedByRevertOrRequire": true, "_errorMessage": message]`
///```
/// ```swift
/// ["_success": false, "_abortedByRevertOrRequire": true, "_errorMessage": message]`
/// ```
/// - function call was aborted using `revert CustomMessage()` and `errors` argument contains the ABI of that custom error type:
///```swift
///["_success": false,
///"_abortedByRevertOrRequire": true,
///"_error": error_name_and_types, // e.g. `MyCustomError(uint256, address senderAddress)`
///"0": error_arg1,
///"1": error_arg2,
///...,
///"error_arg1_name": error_arg1, // Only named arguments will be mapped to their names, e.g. `"senderAddress": EthereumAddress`
///"error_arg2_name": error_arg2, // Otherwise, you can query them by position index.
///...]
///```
///- in case of any error:
///```swift
///["_success": false, "_failureReason": String]
///```
///Error reasons include:
/// ```swift
/// ["_success": false,
/// "_abortedByRevertOrRequire": true,
/// "_error": error_name_and_types, // e.g. `MyCustomError(uint256, address senderAddress)`
/// "0": error_arg1,
/// "1": error_arg2,
/// ...,
/// "error_arg1_name": error_arg1, // Only named arguments will be mapped to their names, e.g. `"senderAddress": EthereumAddress`
/// "error_arg2_name": error_arg2, // Otherwise, you can query them by position index.
/// ...]
/// ```
/// - in case of any error:
/// ```swift
/// ["_success": false, "_failureReason": String]
/// ```
/// Error reasons include:
/// - `outputs` declared but at least one value failed to be decoded;
/// - `data.count` is less than `outputs.count * 32`;
/// - `outputs` defined and `data` is empty;
Expand Down Expand Up @@ -479,7 +479,7 @@ extension ABIDecoder {
guard inputs.count * 32 <= data.count else { return nil }

var i = 0
guard let values = ABIDecoder.decode(types: inputs, data: data) else {return nil}
guard let values = ABIDecoder.decode(types: inputs, data: data) else { return nil }
for input in inputs {
let name = "\(i)"
returnArray[name] = values[i]
Expand All @@ -491,4 +491,4 @@ extension ABIDecoder {
}
return returnArray
}
}
}
2 changes: 1 addition & 1 deletion Sources/Web3Core/Transaction/CodableTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public struct CodableTransaction {
set { envelope.value = newValue }
}

public var data: Data {
public var data: Data {
get { return envelope.data }
set { envelope.data = newValue }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public extension IEth {
func estimateGas(for transaction: CodableTransaction) async throws -> BigUInt {
try await estimateGas(for: transaction, onBlock: .latest)
}

func estimateGas(for transaction: CodableTransaction, onBlock: BlockNumber) async throws -> BigUInt {
let request = APIRequest.estimateGas(transaction, onBlock)
return try await APIRequest.sendRequest(with: provider, for: request).result
Expand Down
1 change: 0 additions & 1 deletion Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,3 @@ extension ERC1376 {
}

}

Loading