Skip to content

Commit 8c54510

Browse files
committed
feat: add request fucntion in Web3Auth.cs and updats ui and example for Web3AuthSample.cs and Web3AuthSample.unity
Signed-off-by: Gaurav Goel <[email protected]>
1 parent a381844 commit 8c54510

File tree

5 files changed

+526
-22
lines changed

5 files changed

+526
-22
lines changed

Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public class Web3AuthSample : MonoBehaviour
5656
[SerializeField]
5757
Button launchWalletServicesButton;
5858

59+
[SerializeField]
60+
Button signMessageButton;
61+
62+
[SerializeField]
63+
Button signResponseButton;
64+
5965
void Start()
6066
{
6167
var loginConfigItem = new LoginConfigItem()
@@ -102,11 +108,15 @@ void Start()
102108
logoutButton.gameObject.SetActive(false);
103109
mfaSetupButton.gameObject.SetActive(false);
104110
launchWalletServicesButton.gameObject.SetActive(false);
111+
signMessageButton.gameObject.SetActive(false);
112+
signResponseButton.gameObject.SetActive(false);
105113

106114
loginButton.onClick.AddListener(login);
107115
logoutButton.onClick.AddListener(logout);
108116
mfaSetupButton.onClick.AddListener(enableMFA);
109-
launchWalletServicesButton.onClick.AddListener(request);
117+
launchWalletServicesButton.onClick.AddListener(launchWalletServices);
118+
signMessageButton.onClick.AddListener(request);
119+
signResponseButton.onClick.AddListener(getSignResponse);
110120

111121
verifierDropdown.AddOptions(verifierList.Select(x => x.name).ToList());
112122
verifierDropdown.onValueChanged.AddListener(onVerifierDropDownChange);
@@ -124,6 +134,8 @@ private void onLogin(Web3AuthResponse response)
124134
logoutButton.gameObject.SetActive(true);
125135
mfaSetupButton.gameObject.SetActive(true);
126136
launchWalletServicesButton.gameObject.SetActive(true);
137+
signMessageButton.gameObject.SetActive(true);
138+
signResponseButton.gameObject.SetActive(true);
127139
}
128140

129141
private void onLogout()
@@ -133,6 +145,8 @@ private void onLogout()
133145
logoutButton.gameObject.SetActive(false);
134146
mfaSetupButton.gameObject.SetActive(false);
135147
launchWalletServicesButton.gameObject.SetActive(false);
148+
signMessageButton.gameObject.SetActive(false);
149+
signResponseButton.gameObject.SetActive(false);
136150

137151
loginResponseText.text = "";
138152
}
@@ -225,7 +239,6 @@ private void request() {
225239
chainNamespace = Web3Auth.ChainNamespace.EIP155
226240
};
227241

228-
Debug.Log("PrivateKey " + web3Auth.getPrivKey());
229242
JArray paramsArray = new JArray
230243
{
231244
"Hello, World!",
@@ -260,4 +273,16 @@ public string getPublicAddressFromPrivateKey(string privateKeyHex)
260273

261274
return publicAddress;
262275
}
276+
277+
public void getSignResponse() {
278+
SignResponse signResponse = Web3Auth.getSignResponse();
279+
if (signResponse != null)
280+
{
281+
Debug.Log("Retrieved SignResponse: " + signResponse);
282+
}
283+
else
284+
{
285+
Debug.Log("SignResponse is null");
286+
}
287+
}
263288
}

0 commit comments

Comments
 (0)