Skip to content

Commit f7c5126

Browse files
committed
fix: chainid default not passed, expiry not passed
1 parent cb5d93a commit f7c5126

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

WalletConnectSharp.Core/Controllers/TypedMessageHandler.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,11 @@ public PublishOptions RpcResponseOptionsForType<T>()
263263
/// </summary>
264264
/// <param name="topic">The topic to send the request in</param>
265265
/// <param name="parameters">The typed request message to send</param>
266+
/// <param name="expiry">An override to specify how long this request will live for. If null is given, then expiry will be taken from either T or TR attributed options</param>
266267
/// <typeparam name="T">The request type</typeparam>
267268
/// <typeparam name="TR">The response type</typeparam>
268269
/// <returns>The id of the request sent</returns>
269-
public async Task<long> SendRequest<T, TR>(string topic, T parameters)
270+
public async Task<long> SendRequest<T, TR>(string topic, T parameters, long? expiry = null)
270271
{
271272
var method = RpcMethodAttribute.MethodForType<T>();
272273

@@ -275,6 +276,11 @@ public async Task<long> SendRequest<T, TR>(string topic, T parameters)
275276
var message = await this.Core.Crypto.Encode(topic, payload);
276277

277278
var opts = RpcRequestOptionsFromType<T, TR>();
279+
280+
if (expiry != null)
281+
{
282+
opts.TTL = (long)expiry;
283+
}
278284

279285
(await this.Core.History.JsonRpcHistoryOfType<T, TR>()).Set(topic, payload, null);
280286

WalletConnectSharp.Core/Interfaces/ITypedMessageHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ void HandleMessageType<T, TR>(Func<string, JsonRpcRequest<T>, Task> requestCallb
7979
/// </summary>
8080
/// <param name="topic">The topic to send the request in</param>
8181
/// <param name="parameters">The typed request message to send</param>
82+
/// <param name="expiry">An override to specify how long this request will live for. If null is given, then expiry will be taken from either T or TR attributed options</param>
8283
/// <typeparam name="T">The request type</typeparam>
8384
/// <typeparam name="TR">The response type</typeparam>
8485
/// <returns>The id of the request sent</returns>
85-
Task<long> SendRequest<T, TR>(string topic, T parameters);
86+
Task<long> SendRequest<T, TR>(string topic, T parameters, long? expiry = null);
8687

8788
/// <summary>
8889
/// Send a typed response message with the given request / response type pair T, TR to the given topic

WalletConnectSharp.Sign/Engine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ public async Task<IAcknowledgement> Extend(string topic)
506506
/// <typeparam name="T">The type of the request data. MUST define the RpcMethodAttribute</typeparam>
507507
/// <typeparam name="TR">The type of the response data.</typeparam>
508508
/// <returns>The response data as type TR</returns>
509-
public async Task<TR> Request<T, TR>(string topic, T data, string chainId = null)
509+
public async Task<TR> Request<T, TR>(string topic, T data, string chainId = null, long? expiry = null)
510510
{
511511
await IsValidSessionTopic(topic);
512512

@@ -546,7 +546,7 @@ public async Task<TR> Request<T, TR>(string topic, T data, string chainId = null
546546

547547
id[0] = await MessageHandler.SendRequest<SessionRequest<T>, TR>(topic, new SessionRequest<T>()
548548
{
549-
ChainId = chainId,
549+
ChainId = defaultChainId,
550550
Request = request
551551
});
552552

WalletConnectSharp.Sign/Interfaces/IEngineAPI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ public interface IEngineAPI
103103
/// <param name="topic">The topic of the session to send the request in</param>
104104
/// <param name="data">The data of the request</param>
105105
/// <param name="chainId">An (optional) chainId the request should be performed in</param>
106+
/// <param name="expiry">An override to specify how long this request will live for. If null is given, then expiry will be taken from either T or TR attributed options</param>
106107
/// <typeparam name="T">The type of the request data. MUST define the RpcMethodAttribute</typeparam>
107108
/// <typeparam name="TR">The type of the response data.</typeparam>
108109
/// <returns>The response data as type TR</returns>
109-
Task<TR> Request<T, TR>(string topic, T data, string chainId = null);
110+
Task<TR> Request<T, TR>(string topic, T data, string chainId = null, long? expiry = null);
110111

111112
/// <summary>
112113
/// Send a response to a request to the session in the given topic with the response data TR. This function

WalletConnectSharp.Sign/WalletConnectSignClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ public Task<IAcknowledgement> Extend(string topic)
318318
/// <typeparam name="T">The type of the request data. MUST define the RpcMethodAttribute</typeparam>
319319
/// <typeparam name="TR">The type of the response data.</typeparam>
320320
/// <returns>The response data as type TR</returns>
321-
public Task<TR> Request<T, TR>(string topic, T data, string chainId = null)
321+
public Task<TR> Request<T, TR>(string topic, T data, string chainId = null, long? expiry = null)
322322
{
323-
return Engine.Request<T, TR>(topic, data, chainId);
323+
return Engine.Request<T, TR>(topic, data, chainId, expiry);
324324
}
325325

326326
/// <summary>

0 commit comments

Comments
 (0)