Skip to content
Merged
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/Editor/SequencePlatformCompileTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private static void LogErrorsToFile(BuildReport report, BuildTarget target)

private static void AndroidBuildTest(string path, string[] scenes)
{
SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.None);
bool isSecureStorageEnabled = config.StoreSessionPrivateKeyInSecureStorage;
BuildTarget target = BuildTarget.Android;

Expand Down
2 changes: 1 addition & 1 deletion Assets/SequenceSDK/WaaS/Tests/HttpClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void TestHttpClientIncludesAPIKey()
var request = client.BuildRequest<object>("", null);
string header = request.Item1.GetRequestHeader("X-Access-Key");
Assert.IsTrue(header.Length > 0);
Assert.AreEqual(SequenceConfig.GetConfig().BuilderAPIKey, header);
Assert.AreEqual(SequenceConfig.GetConfig(SequenceService.WaaS).BuilderAPIKey, header);
Assert.IsTrue(request.Item2.Contains(header));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/SequenceSDK/WaaS/Tests/IntentSenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public async Task TestGetTransactionReceipt_noWallet()
[TestCase(1000)] // intent will have been issued in the future
public async Task TestTimeMismatchExceptionResultsInRetry(int timeOffset)
{
SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.WaaS);
ConfigJwt configJwt = SequenceConfig.GetConfigJwt();
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*"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Sequence.EmbeddedWallet.Tests
public class WaaSToWalletAdapterUnitTests
{
private IEthClient _client =
new SequenceEthClient("https://nodes.sequence.app/polygon/YfeuczOMRyP7fpr1v7h8SvrCAAAAAAAAA");
new SequenceEthClient(Chain.Polygon);
private Address address = new Address("0xc683a014955b75F5ECF991d4502427c8fa1Aa249");

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void OnPreprocessBuild(BuildReport report)
{
if (report.summary.platform == BuildTarget.Android)
{
SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.None);
if (!config.StoreSessionPrivateKeyInSecureStorage)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void OnPreprocessBuild(BuildReport report)
defineList = new List<string>(defines.Split(';'));
}

SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.None);
if (config.StoreSessionPrivateKeyInSecureStorage)
{
if (!defineList.Contains(EnableAndroidSecureStorage))
Expand Down
2 changes: 1 addition & 1 deletion Packages/Sequence-Unity/Editor/CheckUrlScheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CheckUrlScheme
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
{
SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.None);
_urlScheme = config.UrlScheme;

if (string.IsNullOrWhiteSpace(_urlScheme))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private void OnDestroy()
private void OnWalletCreated(SequenceWallet wallet)
{
_wallet = wallet;
var sdkVersion = SequenceConfig.GetConfig().WaaSVersion;
var sdkVersion = SequenceConfig.GetConfig(SequenceService.WaaS).WaaSVersion;
var email = PlayerPrefs.GetString(OpenIdAuthenticator.LoginEmail);

if (_wallet == null || string.IsNullOrEmpty(email))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void Open(params object[] args)
$"Invalid use. {GetType().Name} must be opened with a {typeof(List<LoginMethod>)} as an argument");
}

_enableMultipleAccountsPerEmail = SequenceConfig.GetConfig().EnableMultipleAccountsPerEmail;
_enableMultipleAccountsPerEmail = SequenceConfig.GetConfig(SequenceService.WaaS).EnableMultipleAccountsPerEmail;


_overrideAccountButton.SetActive(_enableMultipleAccountsPerEmail);
Expand Down Expand Up @@ -84,7 +84,7 @@ public void ReturnToLogin()

public void NewAccount()
{
if (!SequenceConfig.GetConfig().EnableMultipleAccountsPerEmail)
if (!SequenceConfig.GetConfig(SequenceService.WaaS).EnableMultipleAccountsPerEmail)
{
throw new SystemException("Creating accounts with the same email is not enabled");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override void Awake()

_demoPage = FindObjectOfType<EmbeddedWalletDemoPage>();

SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.WaaS);

SequenceWallet.OnFailedToRecoverSession += OnFailedToRecoverSession;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void InjectRedirectUrl(string redirectUrl)

public OpenIdAuthenticator(string nonce = null)
{
SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.None);

_urlScheme = config.UrlScheme;
SetClientIds(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ public class SequenceConfig : ScriptableObject
public bool EditorStoreSessionPrivateKeyInSecureStorage = false;

private static SequenceConfig _config;

public static SequenceConfig GetConfig()
public static SequenceConfig GetConfig(SequenceService sequenceService = SequenceService.Unspecified)
{
if (_config == null)
{
_config = LoadConfig();
_config = GetAppropriateConfig(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");
Expand All @@ -63,10 +62,64 @@ public static SequenceConfig GetConfig()
return _config;
}

private static SequenceConfig LoadConfig()
private static SequenceConfig GetAppropriateConfig(SequenceService sequenceService)
{
switch (sequenceService)
{
case SequenceService.WaaS:
#if SEQUENCE_DEV_WAAS || SEQUENCE_DEV
return LoadDevConfig();
#else
return LoadProdConfig();
#endif
case SequenceService.Indexer:
#if SEQUENCE_DEV_INDEXER || SEQUENCE_DEV
return LoadDevConfig();
#else
return LoadProdConfig();
#endif
case SequenceService.NodeGateway:
#if SEQUENCE_DEV_NODEGATEWAY || SEQUENCE_DEV
return LoadDevConfig();
#else
return LoadProdConfig();
#endif
case SequenceService.Marketplace:
#if SEQUENCE_DEV_MARKETPLACE || SEQUENCE_DEV
return LoadDevConfig();
#else
return LoadProdConfig();
#endif
case SequenceService.Stack:
#if SEQUENCE_DEV_STACK || SEQUENCE_DEV
return LoadDevConfig();
#else
return LoadProdConfig();
#endif

default:
#if SEQUENCE_DEV
return LoadDevConfig();
#else
return LoadProdConfig();
#endif
}
}

private static SequenceConfig LoadDevConfig()
{
return LoadConfig("SequenceDevConfig");
}

private static SequenceConfig LoadProdConfig()
{
return LoadConfig("SequenceConfig");
}

private static SequenceConfig LoadConfig(string configName)
{
#if UNITY_EDITOR
string[] guids = AssetDatabase.FindAssets($"SequenceConfig t:{nameof(SequenceConfig)}");
string[] guids = AssetDatabase.FindAssets($"{configName} t:{nameof(SequenceConfig)}");
foreach (string guid in guids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
Expand All @@ -76,9 +129,9 @@ private static SequenceConfig LoadConfig()
}
}

return Resources.Load<SequenceConfig>("SequenceConfig");
return Resources.Load<SequenceConfig>(configName);
#else
return Resources.Load<SequenceConfig>("SequenceConfig");
return Resources.Load<SequenceConfig>(configName);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Sequence.Config
{
public enum SequenceService
{
WaaS,
Indexer,
NodeGateway,
Marketplace,
Stack,
Unspecified,
None
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public HttpClient(string url)
this._defaultHeaders = new Dictionary<string, string>();
_defaultHeaders["Content-Type"] = "application/json";
_defaultHeaders["Accept"] = "application/json";
SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.WaaS);
_defaultHeaders["X-Access-Key"] = config.BuilderAPIKey;
_defaultHeaders["Accept-Signature"] = "sig=()";
if (string.IsNullOrWhiteSpace(config.BuilderAPIKey))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ public class ResponseSignatureValidator
{
private RSAParameters _waasPublicKey;
public bool PublicKeyFetched { get; private set; }
#if SEQUENCE_DEV_WAAS || SEQUENCE_DEV
private const string _jwks = "{\"keys\":[{\"alg\":\"RS256\",\"e\":\"AQAB\",\"kid\":\"9LkLZyHdNq1N2aeHMlC5jw\",\"kty\":\"RSA\",\"n\":\"qllUB_ERsOjbKx4SirGow4XDov05lQyhiF7Duo4sPkH9CwMN11OqhLuIqeIXPq0rPNIXGP99A7riXTcpRNk-5ZNL29zs-Xjj3idp7nZQZLIU1CBQErTcbxbwUYp8Q46k7lJXVlMmwoLQvQAgH8BZLuSe-Xk1tye0mDC-bHvmrMfqm2zmuWeDnZercU3Jg2iYwyPrjKWx7YSBSMTXTKPGndws4m3s3XIEpI2alLcLLWsPQk2UjIlux6I7vLwvjM_BgjFhYHqgg1tgZUPn_Xxt4wvhobF8UIacRVmGcuyYBnhRxKnBQhEClGSBVtnFYYBSvRjTgliOwf3DhFoXdnmyPQ\",\"use\":\"sig\"}]}";
#else
private const string _jwks = "{\"keys\":[{\"alg\":\"RS256\",\"e\":\"AQAB\",\"kid\":\"nWh-_3nQ1lnhhI1ZSQTQmw\",\"kty\":\"RSA\",\"n\":\"pECaEq2k0k22J9e7hFLAFmKbzPLlWToUJJmFeWAdEiU4zpW17EUEOyfjRzjgBewc7KFJQEblC3eTD7Vc5bh9-rafPEj8LaKyZzzS5Y9ZATXhlMo5Pnlar3BrTm48XcnT6HnLsvDeJHUVbrYd1JyE1kqeTjUKWvgKX4mgIJiuYhpdzbOC22cPaWb1dYCVhArDVAPHGqaEwRjX7JneETdY5hLJ6JhsAws706W7fwfNKddPQo2mY95S9q8HFxMr5EaXEMmhwxk8nT5k-Ouar2dobMXRMmQiEZSt9fJaGKlK7KWJSnbPOVa2cZud1evs1Rz2SdCSA2bhuZ6NnZCxkqnagw\",\"use\":\"sig\"}]}";

#endif

public ResponseSignatureValidator()
{
LoadPublicKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public SequenceLogin(IValidator validator = null, IAuthenticator authenticator =
_automaticallyFederateAccountsWhenPossible = automaticallyFederateAccountsWhenPossible;
SetConnectedWalletAddress(connectedWalletAddress);

bool storeSessionWallet = SequenceConfig.GetConfig().StoreSessionKey() && SecureStorageFactory.IsSupportedPlatform() && connectedWalletAddress == null;
bool storeSessionWallet = SequenceConfig.GetConfig(SequenceService.WaaS).StoreSessionKey() && SecureStorageFactory.IsSupportedPlatform() && connectedWalletAddress == null;
if (storeSessionWallet)
{
_storeSessionWallet = true;
Expand Down Expand Up @@ -190,7 +190,7 @@ private void SetupAuthenticatorAndListeners()

private void Configure()
{
SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.WaaS);
string waasVersion = config.WaaSVersion;
if (string.IsNullOrWhiteSpace(waasVersion))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public class SequenceWallet : IWallet
public SequenceWallet(Address address, string sessionId, IIntentSender intentSender, string email = "")
{
_address = address;
#if SEQUENCE_DEV_WAAS || SEQUENCE_DEV
_httpClient = new HttpClient("https://dev-api.sequence.app/rpc");
#else
_httpClient = new HttpClient("https://api.sequence.app/rpc");
#endif
_intentSender = intentSender;
SessionId = sessionId;
_builderApiKey = SequenceConfig.GetConfig().BuilderAPIKey;
_builderApiKey = SequenceConfig.GetConfig(SequenceService.WaaS).BuilderAPIKey;
_email = email;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private void AddSession(SequenceWallet sessionWallet)

private void OnApplicationQuit()
{
if (SequenceConfig.GetConfig().StoreSessionKey() && SecureStorageFactory.IsSupportedPlatform())
if (SequenceConfig.GetConfig(SequenceService.WaaS).StoreSessionKey() && SecureStorageFactory.IsSupportedPlatform())
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class HttpRpcClient : IRpcClient
public HttpRpcClient(string url)
{
_url = url;
_builderApiKey = SequenceConfig.GetConfig().BuilderAPIKey;
_builderApiKey = SequenceConfig.GetConfig(SequenceService.NodeGateway).BuilderAPIKey;
}

public async Task<RpcResponse> SendRequest(RpcRequest rpcRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ namespace Sequence.Provider
{
public static class NodeGatewayBridge
{
private static SequenceConfig _config = SequenceConfig.GetConfig();
private static SequenceConfig _config = SequenceConfig.GetConfig(SequenceService.NodeGateway);

#if SEQUENCE_DEV_NODEGATEWAY || SEQUENCE_DEV
private const string _baseUrl = "https://dev-nodes.sequence.app/";
#else
private const string _baseUrl = "https://nodes.sequence.app/";
#endif

public static string GetNodeGatewayUrl(Chain chain)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ private string Url(string chainID, string endPoint)
private string HostName(string chainID)
{
var indexerName = Indexer.IndexerNames[chainID];
#if SEQUENCE_DEV_INDEXER || SEQUENCE_DEV
return $"https://dev-{indexerName}-indexer.sequence.app";
#else
return $"https://{indexerName}-indexer.sequence.app";
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal static readonly Dictionary<string, string> IndexerNames
{ Chain.TestnetMoonbaseAlpha.GetChainId(), "moonbase-alpha" }
};

private static string _builderApiKey = SequenceConfig.GetConfig().BuilderAPIKey;
private static string _builderApiKey = SequenceConfig.GetConfig(SequenceService.Indexer).BuilderAPIKey;

public static Action<string> OnQueryFailed;
public static Action<string> OnQueryIssue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ public class CurrencySwap : ISwap
{
private Chain _chain;
private IHttpClient _client;
#if SEQUENCE_DEV_STACK || SEQUENCE_DEV
private const string BaseUrl = "https://dev-api.sequence.app/rpc/API";
#else
private const string BaseUrl = "https://api.sequence.app/rpc/API";
#endif
private IIndexer _indexer;

public CurrencySwap(Chain chain, IHttpClient client = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class HttpClient : IHttpClient
{
private string _apiKey;
private const string _prodUrl = "https://marketplace-api.sequence.app/";
private const string _devUrl = "https://dev-marketplace-api.sequence-dev.app/";
private static string _baseUrl = "https://marketplace-api.sequence.app/";
private const string _endUrl = "/rpc/Marketplace/";
private JsonSerializerSettings serializerSettings = new JsonSerializerSettings
Expand All @@ -24,9 +25,13 @@ public class HttpClient : IHttpClient

public HttpClient()
{
SequenceConfig config = SequenceConfig.GetConfig();
SequenceConfig config = SequenceConfig.GetConfig(SequenceService.Marketplace);
_apiKey = config.BuilderAPIKey;
#if SEQUENCE_DEV_MARKETPLACE || SEQUENCE_DEV
_baseUrl = _devUrl;
#else
_baseUrl = _prodUrl;
#endif
}

public static HttpClient UseHttpClientWithDevEnvironment(string devApiKey)
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.1",
"version": "3.19.2",
"displayName": "Sequence Embedded Wallet SDK",
"description": "A Unity SDK for the Sequence WaaS API",
"unity": "2021.3",
Expand Down
Loading