This repository was archived by the owner on Feb 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSetupWalletScreen.cs
More file actions
110 lines (96 loc) · 3.06 KB
/
SetupWalletScreen.cs
File metadata and controls
110 lines (96 loc) · 3.06 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using HyperCasual.Core;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections.Generic;
using System.Threading;
using Immutable.Passport;
namespace HyperCasual.Runner
{
/// <summary>
/// This View contains celebration screen functionalities
/// </summary>
public class SetupWalletScreen : View
{
[SerializeField]
TextMeshProUGUI m_Title;
[SerializeField]
GameObject m_Loading;
[SerializeField]
GameObject m_Success;
[SerializeField]
TextMeshProUGUI m_ErrorMessage;
[SerializeField]
HyperCasualButton m_NextButton;
[SerializeField]
HyperCasualButton m_TryAgainButton;
[SerializeField]
AbstractGameEvent m_MintEvent;
[SerializeField]
AbstractGameEvent m_NextEvent;
public void OnEnable()
{
// Set listener to 'Next' button
m_NextButton.RemoveListener(OnNextButtonClicked);
m_NextButton.AddListener(OnNextButtonClicked);
// Set listener to "Try again" button
m_TryAgainButton.RemoveListener(SetupWallet);
m_TryAgainButton.AddListener(SetupWallet);
SetupWallet();
}
private async void SetupWallet()
{
try
{
m_Title.text = "Setting up your wallet...";
ShowLoading(true);
ShowError(false);
ShowSuccess(false);
// Set up provider
await Passport.Instance.ConnectImx();
Debug.Log("Checking if wallet is registered offchain...");
bool isRegistered = await Passport.Instance.IsRegisteredOffchain();
if (!isRegistered)
{
Debug.Log("Registering wallet offchain...");
await Passport.Instance.RegisterOffchain();
}
m_Title.text = "Your wallet has been successfully set up!";
ShowLoading(false);
ShowError(false);
ShowSuccess(true);
}
catch (Exception ex)
{
// Failed to create wallet, let the player try again
Debug.Log($"Failed to create wallet: {ex.Message}");
ShowLoading(false);
ShowError(true);
ShowSuccess(false);
}
}
private void OnNextButtonClicked()
{
m_MintEvent.Raise();
}
private void ShowNextButton(bool show)
{
m_NextButton.gameObject.SetActive(show);
}
private void ShowLoading(bool show)
{
m_Loading.gameObject.SetActive(show);
}
private void ShowError(bool show)
{
m_ErrorMessage.gameObject.SetActive(show);
m_TryAgainButton.gameObject.SetActive(show);
}
private void ShowSuccess(bool show)
{
m_Success.gameObject.SetActive(show);
ShowNextButton(show);
}
}
}