Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/SequenceSDK/WaaS/Tests/IntentSenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public async Task TestGetTransactionReceipt_noWallet()
public async Task TestTimeMismatchExceptionResultsInRetry(int timeOffset)
{
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.WaaS);
ConfigJwt configJwt = SequenceConfig.GetConfigJwt();
ConfigJwt configJwt = SequenceConfig.GetConfigJwt(config);
IntentSender intentSender = new IntentSender(new HttpClient($"{configJwt.rpcServer.AppendTrailingSlashIfNeeded()}rpc/WaasAuthenticator"), new EOAWallet(), "", configJwt.projectId, config.WaaSVersion);
LogAssert.Expect(LogType.Warning, new Regex("Time mismatch*"));
try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.Internal;
using UnityEditor;
Expand Down Expand Up @@ -33,33 +34,37 @@ public class SequenceConfig : ScriptableObject
public bool StoreSessionPrivateKeyInSecureStorage = false;
public bool EditorStoreSessionPrivateKeyInSecureStorage = false;

private static SequenceConfig _config;
private static Dictionary<SequenceService, SequenceConfig> _configs = new Dictionary<SequenceService, SequenceConfig>();
public static SequenceConfig GetConfig(SequenceService sequenceService = SequenceService.Unspecified)
{
if (_config == null)
if (_configs.TryGetValue(sequenceService, out SequenceConfig cachedConfig))
{
_config = GetAppropriateConfig(sequenceService);
if (_config == null)
return cachedConfig;
}
else
{
_configs[sequenceService] = GetAppropriateConfig(sequenceService);
SequenceConfig config = _configs[sequenceService];
if (config == null)
{
throw new Exception("SequenceConfig not found. Make sure to create and configure it and place it at the root of your Resources folder. Create it from the top bar with Assets > Create > Sequence > SequenceConfig");
}

TextAsset versionFile = Resources.Load<TextAsset>("sequence-unity-version");
if (versionFile != null)
{
_config.WaaSVersion = $"1 (Unity {versionFile.text})";
config.WaaSVersion = $"1 (Unity {versionFile.text})";
}
else
{
_config.WaaSVersion = $"1 (Unity {PackageVersionReader.GetVersion()})";
config.WaaSVersion = $"1 (Unity {PackageVersionReader.GetVersion()})";
}

#if UNITY_EDITOR
_config.WaaSVersion = $"1 (Unity {PackageVersionReader.GetVersion()})"; // version file is only updated when building
config.WaaSVersion = $"1 (Unity {PackageVersionReader.GetVersion()})"; // version file is only updated when building
#endif
return config;
}

return _config;
}

private static SequenceConfig GetAppropriateConfig(SequenceService sequenceService)
Expand Down Expand Up @@ -140,9 +145,15 @@ public static Exception MissingConfigError(string valueName)
return new Exception($"{valueName} is not set. Please set it in SequenceConfig asset in your Resources folder.");
}

public static ConfigJwt GetConfigJwt()
public static ConfigJwt GetConfigJwt(SequenceService service = SequenceService.Unspecified)
{
SequenceConfig config = GetConfig(service);
return GetConfigJwt(config);
}

public static ConfigJwt GetConfigJwt(SequenceConfig config)
{
string configKey = _config.WaaSConfigKey;
string configKey = config.WaaSConfigKey;
if (string.IsNullOrWhiteSpace(configKey))
{
throw SequenceConfig.MissingConfigError("WaaS Config Key");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public HttpClient(string url)
throw SequenceConfig.MissingConfigError("Builder API Key");
}

ConfigJwt configJwt = SequenceConfig.GetConfigJwt();
ConfigJwt configJwt = SequenceConfig.GetConfigJwt(config);
string rpcUrl = configJwt.rpcServer;
if (string.IsNullOrWhiteSpace(rpcUrl))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void ResetLoginAfterTest()

public void SetupAuthenticator(IValidator validator = null, IAuthenticator authenticator = null)
{
ConfigJwt configJwt = SequenceConfig.GetConfigJwt();
ConfigJwt configJwt = SequenceConfig.GetConfigJwt(SequenceConfig.GetConfig(SequenceService.WaaS));
if (_connectedWalletAddress == null || _sessionWallet == null)
{
_sessionWallet = new EOAWallet();
Expand Down Expand Up @@ -198,7 +198,7 @@ private void Configure()
}
_waasVersion = waasVersion;

ConfigJwt configJwt = SequenceConfig.GetConfigJwt();
ConfigJwt configJwt = SequenceConfig.GetConfigJwt(config);

string rpcUrl = configJwt.rpcServer;
if (string.IsNullOrWhiteSpace(rpcUrl))
Expand Down
2 changes: 1 addition & 1 deletion Packages/Sequence-Unity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xyz.0xsequence.waas-unity",
"version": "3.19.2",
"version": "3.19.3",
"displayName": "Sequence Embedded Wallet SDK",
"description": "A Unity SDK for the Sequence WaaS API",
"unity": "2021.3",
Expand Down