Skip to content

Commit 73b55a7

Browse files
Merge pull request #37 from Web3Auth/feat/config_api
feat: observable action added for signature method result.
2 parents bc77c45 + 03010bd commit 73b55a7

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs

+6-14
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void Start()
9494
{"CUSTOM_VERIFIER", loginConfigItem}
9595
}
9696
*/
97-
clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
97+
clientId = "BFuUqebV5I8Pz5F7a5A2ihW7YVmbv_OHXnHYDv6OltAD5NGr6e-ViNvde3U4BHdn6HvwfkgobhVu4VwC-OSJkik",
9898
buildEnv = BuildEnv.TESTING,
9999
redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity/auth"),
100100
network = Web3Auth.Network.SAPPHIRE_DEVNET,
@@ -103,6 +103,7 @@ void Start()
103103
web3Auth.onLogin += onLogin;
104104
web3Auth.onLogout += onLogout;
105105
web3Auth.onMFASetup += onMFASetup;
106+
web3Auth.onSignResponse += onSignResponse;
106107

107108
emailAddressField.gameObject.SetActive(false);
108109
logoutButton.gameObject.SetActive(false);
@@ -116,7 +117,6 @@ void Start()
116117
mfaSetupButton.onClick.AddListener(enableMFA);
117118
launchWalletServicesButton.onClick.AddListener(launchWalletServices);
118119
signMessageButton.onClick.AddListener(request);
119-
signResponseButton.onClick.AddListener(getSignResponse);
120120

121121
verifierDropdown.AddOptions(verifierList.Select(x => x.name).ToList());
122122
verifierDropdown.onValueChanged.AddListener(onVerifierDropDownChange);
@@ -155,6 +155,10 @@ private void onMFASetup(bool response) {
155155
Debug.Log("MFA Setup: " + response);
156156
}
157157

158+
private void onSignResponse(SignResponse signResponse)
159+
{
160+
Debug.Log("Retrieved SignResponse: " + signResponse);
161+
}
158162

159163
private void onVerifierDropDownChange(int selectedIndex)
160164
{
@@ -273,16 +277,4 @@ public string getPublicAddressFromPrivateKey(string privateKeyHex)
273277

274278
return publicAddress;
275279
}
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-
}
288280
}

Assets/Plugins/Web3AuthSDK/Web3Auth.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public enum Language
4747
public event Action<Web3AuthResponse> onLogin;
4848
public event Action onLogout;
4949
public event Action<bool> onMFASetup;
50+
public event Action<SignResponse> onSignResponse;
5051

5152
private static SignResponse signResponse = null;
5253

@@ -55,11 +56,6 @@ public static void setSignResponse(SignResponse _response)
5556
signResponse = _response;
5657
}
5758

58-
public static SignResponse getSignResponse()
59-
{
60-
return signResponse;
61-
}
62-
6359
[SerializeField]
6460
private string clientId;
6561

@@ -409,7 +405,7 @@ public void setResultUrl(Uri uri)
409405
try
410406
{
411407
signResponse = JsonUtility.FromJson<SignResponse>(decodedString);
412-
setSignResponse(signResponse);
408+
this.Enqueue(() => this.onSignResponse?.Invoke(signResponse));
413409
}
414410
catch (Exception e)
415411
{

0 commit comments

Comments
 (0)