-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSIWE plus text username
More file actions
55 lines (40 loc) · 1.93 KB
/
SIWE plus text username
File metadata and controls
55 lines (40 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import UIKit
import EthereumKit
class SignupViewController: UIViewController {
// MARK: - Properties
let ethereumClient = EthereumClient()
// MARK: - View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
// Generate a new Ethereum address
let newAddress = ethereumClient.createAddress()
// Generate a private recovery key for the Ethereum address
let privateRecoveryKey = ethereumClient.createPrivateRecoveryKey(from: newAddress)
// Show the private recovery key to the user
let recoveryKeyLabel = UILabel()
recoveryKeyLabel.text = "Private Recovery Key: \(privateRecoveryKey)"
view.addSubview(recoveryKeyLabel)
// Prompt the user to write down their private recovery key
let recoveryKeyPromptLabel = UILabel()
recoveryKeyPromptLabel.text = "Please write down your private recovery key on a piece of paper and store it safely. This is the ONLY way to recover your blockchain rewards."
view.addSubview(recoveryKeyPromptLabel)
// Set up a text field for the user to enter their in-app username
let usernameTextField = UITextField()
usernameTextField.placeholder = "Username"
view.addSubview(usernameTextField)
// Set up a button to confirm the user's in-app username
let confirmButton = UIButton(type: .system)
confirmButton.setTitle("Confirm", for: .normal)
confirmButton.addTarget(self, action: #selector(confirmButtonTapped), for: .touchUpInside)
view.addSubview(confirmButton)
}
// MARK: - Actions
@objc
func confirmButtonTapped() {
// Get the user's in-app username from the text field
let username = usernameTextField.text
// Associate the user's Ethereum address with their in-app username
ethereumClient.setUsername(username, for: newAddress)
// Proceed to the next screen in the app
}
}