diff --git a/WalletConnectSharp.Sign/Engine.cs b/WalletConnectSharp.Sign/Engine.cs index 99bdee4..e301f12 100644 --- a/WalletConnectSharp.Sign/Engine.cs +++ b/WalletConnectSharp.Sign/Engine.cs @@ -306,8 +306,8 @@ public async Task Connect(ConnectOptions options) var id = await MessageHandler.SendRequest(topic, proposal); logger.Log($"Got back {id} as request pending id"); - - var expiry = Clock.CalculateExpiry(Clock.FIVE_MINUTES); + + var expiry = Clock.CalculateExpiry(options.Expiry); await PrivateThis.SetProposal(id, new ProposalStruct() { diff --git a/WalletConnectSharp.Sign/Models/Engine/ConnectOptions.cs b/WalletConnectSharp.Sign/Models/Engine/ConnectOptions.cs index cd8ad59..dcf6d48 100644 --- a/WalletConnectSharp.Sign/Models/Engine/ConnectOptions.cs +++ b/WalletConnectSharp.Sign/Models/Engine/ConnectOptions.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using WalletConnectSharp.Common.Model.Relay; +using WalletConnectSharp.Common.Utils; using WalletConnectSharp.Core.Models.Relay; namespace WalletConnectSharp.Sign.Models.Engine @@ -42,6 +43,13 @@ public class ConnectOptions [JsonProperty("relays")] public ProtocolOptions Relays; + /// + /// How long the session will be open before it's considered expired. If the session + /// is expired, then Extend must be called on the session to extend the expiry + /// + [JsonProperty("expiry")] + public long Expiry = Clock.FIVE_MINUTES; + /// /// Create blank options with no required namespaces /// @@ -156,5 +164,27 @@ public ConnectOptions WithOptions(ProtocolOptions options) Relays = options; return this; } + + /// + /// Set the expiry duration for the session + /// + /// The amount of seconds that should pass before the session expires + /// This object, acts a builder function + public ConnectOptions WithExpiry(long seconds) + { + Expiry = seconds; + return this; + } + + /// + /// Set the expiry duration for the session + /// + /// The amount of time that should pass before the session expires + /// This object, acts a builder function + public ConnectOptions WithExpiry(TimeSpan expiry) + { + Expiry = (long)expiry.TotalSeconds; + return this; + } } }