Skip to content

Commit

Permalink
expose private methods to subclasses
Browse files Browse the repository at this point in the history
allow an inheriting class to override the behavior of some internal functions.
  • Loading branch information
AddressXception committed Aug 12, 2022
1 parent 1a7d04c commit 50382b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion WalletConnectSharp.Core/WalletConnectProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public WalletConnectProvider(string url, ITransport transport = null, ICipher ci
this.ParseUrl();
}

private void ParseUrl()
protected void ParseUrl()
{
/*
* var topicEncode = WebUtility.UrlEncode(_handshakeTopic);
Expand Down
22 changes: 14 additions & 8 deletions WalletConnectSharp.Core/WalletConnectSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public string URI
}
}

/// <summary>
/// Create a WalletConnect Session from a SavedSession
/// </summary>
public WalletConnectSession(SavedSession savedSession, ITransport transport = null, ICipher cipher = null, EventDelegator eventDelegator = null) : base(savedSession, transport, cipher, eventDelegator)
{
this.DappMetadata = savedSession.DappMeta;
Expand All @@ -72,6 +75,9 @@ public WalletConnectSession(SavedSession savedSession, ITransport transport = nu
this.SessionConnected = true;
}

/// <summary>
/// Create a new WalletConnect Session
/// </summary>
public WalletConnectSession(ClientMeta clientMeta, string bridgeUrl = null, ITransport transport = null, ICipher cipher = null, int chainId = 1, EventDelegator eventDelegator = null) : base(transport, cipher, eventDelegator)
{
if (clientMeta == null)
Expand Down Expand Up @@ -120,7 +126,7 @@ public WalletConnectSession(ClientMeta clientMeta, string bridgeUrl = null, ITra
CreateNewSession();
}

private void CreateNewSession()
protected void CreateNewSession()
{
if (SessionConnected)
{
Expand All @@ -146,7 +152,7 @@ private void CreateNewSession()
ReadyForUserPrompt = false;
}

private void EnsureNotDisconnected()
protected void EnsureNotDisconnected()
{
if (Disconnected)
{
Expand All @@ -155,7 +161,7 @@ private void EnsureNotDisconnected()
}
}

private void GenerateKey()
protected void GenerateKey()
{
//Generate a random secret
byte[] secret = new byte[32];
Expand Down Expand Up @@ -450,7 +456,7 @@ public virtual async Task<R> Send<T, R>(T data) where T : JsonRpcRequest where R
/// Create a new WalletConnect session with a Wallet.
/// </summary>
/// <returns></returns>
private async Task<WCSessionData> CreateSession()
protected async Task<WCSessionData> CreateSession()
{
EnsureNotDisconnected();

Expand Down Expand Up @@ -511,7 +517,7 @@ private async Task<WCSessionData> CreateSession()
return response;
}

private void HandleSessionResponse(object sender, JsonRpcResponseEvent<WCSessionRequestResponse> jsonresponse)
protected void HandleSessionResponse(object sender, JsonRpcResponseEvent<WCSessionRequestResponse> jsonresponse)
{
var response = jsonresponse.Response.result;

Expand All @@ -529,7 +535,7 @@ private void HandleSessionResponse(object sender, JsonRpcResponseEvent<WCSession
}
}

private void HandleSessionUpdate(WCSessionData data)
protected void HandleSessionUpdate(WCSessionData data)
{
if (data == null) return;

Expand Down Expand Up @@ -567,7 +573,7 @@ private void HandleSessionUpdate(WCSessionData data)
SessionUpdate(this, data);
}

private void HandleSessionDisconnect(string msg, string topic = "disconnect", bool createNewSession = true)
protected void HandleSessionDisconnect(string msg, string topic = "disconnect", bool createNewSession = true)
{
SessionConnected = false;
Disconnected = true;
Expand Down Expand Up @@ -662,4 +668,4 @@ public static SavedSession ReadSession(Stream stream, bool leaveStreamOpen = tru
return JsonConvert.DeserializeObject<SavedSession>(json);
}
}
}
}

0 comments on commit 50382b7

Please sign in to comment.