Skip to content

Commit

Permalink
feat: Player wallet connect now also provides users connected network…
Browse files Browse the repository at this point in the history
… ID at Port.ConnectedPlayerNetworkID.
  • Loading branch information
saszer committed Jun 23, 2022
1 parent 38ca195 commit add3604
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions Runtime/ConnectPlayerWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ namespace NFTPort
using UnityEngine;
using UnityEngine.Events;
using Internal;

[AddComponentMenu(PortConstants.BaseComponentMenu + PortConstants.FeatureName_ConnectUserWallet)]
[HelpURL(PortConstants.Docs_ConnectUserWallet)]
public class ConnectPlayerWallet : MonoBehaviour
{
public string connectedWalletAddress;
public string connectedNetworkID;

[HideInInspector] public string MockconnectedWalletAddress;
[HideInInspector] public string MockconnectedNetworkID;

public UnityEvent afterSuccess;
private UnityAction<string,string> OnCompleteAction;
Expand Down Expand Up @@ -47,8 +51,12 @@ public ConnectPlayerWallet OnComplete(UnityAction<string,string> action)
public void WebSend_GetAddress()
{
#if UNITY_EDITOR
connectedWalletAddress = MockconnectedWalletAddress;
connectedNetworkID = MockconnectedNetworkID;

Port.ConnectedPlayerAddress = connectedWalletAddress;
Debug.Log("Editor Mock Wallet Connect , Address: " + Port.ConnectedPlayerAddress);
Port.ConnectedPlayerNetworkID = connectedNetworkID;
Debug.Log("Editor Mock Wallet Connected , Address: " + Port.ConnectedPlayerAddress + " at Network ID:" + Port.ConnectedPlayerNetworkID +" | Access it via Port.ConnectedPlayerAddress");
#endif
#if !UNITY_EDITOR
SendCallTo_GetAddress();
Expand All @@ -59,7 +67,10 @@ void Awake()
{

#if UNITY_EDITOR


Port.ConnectedPlayerAddress = connectedWalletAddress;
Port.ConnectedPlayerNetworkID = connectedNetworkID;
#endif

this.gameObject.name = "PlayerConnect_NFTPort";
Expand All @@ -70,6 +81,7 @@ void Awake()
public void WebHook_GetNetworkID(string networkID)
{
Port.ConnectedPlayerNetworkID = networkID;
connectedNetworkID = networkID;
}

//called from index - For WebGL
Expand Down
4 changes: 2 additions & 2 deletions Runtime/Internal/Port.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public static class Port
/// <summary>
/// Wallet Connect
/// </summary>
public static string ConnectedPlayerAddress;
public static string ConnectedPlayerAddress = "";
/// <summary>
/// Wallet Connected Network ID
/// </summary>
public static string ConnectedPlayerNetworkID;
public static string ConnectedPlayerNetworkID = "";
}
}

0 comments on commit add3604

Please sign in to comment.