Skip to content

Commit

Permalink
Merge pull request #37 from Web3Auth/feat/config_api
Browse files Browse the repository at this point in the history
feat: observable action added for signature method result.
  • Loading branch information
chaitanyapotti authored Aug 29, 2024
2 parents bc77c45 + 03010bd commit 73b55a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
20 changes: 6 additions & 14 deletions Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void Start()
{"CUSTOM_VERIFIER", loginConfigItem}
}
*/
clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
clientId = "BFuUqebV5I8Pz5F7a5A2ihW7YVmbv_OHXnHYDv6OltAD5NGr6e-ViNvde3U4BHdn6HvwfkgobhVu4VwC-OSJkik",
buildEnv = BuildEnv.TESTING,
redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity/auth"),
network = Web3Auth.Network.SAPPHIRE_DEVNET,
Expand All @@ -103,6 +103,7 @@ void Start()
web3Auth.onLogin += onLogin;
web3Auth.onLogout += onLogout;
web3Auth.onMFASetup += onMFASetup;
web3Auth.onSignResponse += onSignResponse;

emailAddressField.gameObject.SetActive(false);
logoutButton.gameObject.SetActive(false);
Expand All @@ -116,7 +117,6 @@ void Start()
mfaSetupButton.onClick.AddListener(enableMFA);
launchWalletServicesButton.onClick.AddListener(launchWalletServices);
signMessageButton.onClick.AddListener(request);
signResponseButton.onClick.AddListener(getSignResponse);

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

private void onSignResponse(SignResponse signResponse)
{
Debug.Log("Retrieved SignResponse: " + signResponse);
}

private void onVerifierDropDownChange(int selectedIndex)
{
Expand Down Expand Up @@ -273,16 +277,4 @@ public string getPublicAddressFromPrivateKey(string privateKeyHex)

return publicAddress;
}

public void getSignResponse() {
SignResponse signResponse = Web3Auth.getSignResponse();
if (signResponse != null)
{
Debug.Log("Retrieved SignResponse: " + signResponse);
}
else
{
Debug.Log("SignResponse is null");
}
}
}
8 changes: 2 additions & 6 deletions Assets/Plugins/Web3AuthSDK/Web3Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public enum Language
public event Action<Web3AuthResponse> onLogin;
public event Action onLogout;
public event Action<bool> onMFASetup;
public event Action<SignResponse> onSignResponse;

private static SignResponse signResponse = null;

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

public static SignResponse getSignResponse()
{
return signResponse;
}

[SerializeField]
private string clientId;

Expand Down Expand Up @@ -409,7 +405,7 @@ public void setResultUrl(Uri uri)
try
{
signResponse = JsonUtility.FromJson<SignResponse>(decodedString);
setSignResponse(signResponse);
this.Enqueue(() => this.onSignResponse?.Invoke(signResponse));
}
catch (Exception e)
{
Expand Down

0 comments on commit 73b55a7

Please sign in to comment.