diff --git a/Assets/SequenceSDK/Editor/SequencePlatformCompileTest.cs b/Assets/SequenceSDK/Editor/SequencePlatformCompileTest.cs index c048ddfc7..472df1403 100644 --- a/Assets/SequenceSDK/Editor/SequencePlatformCompileTest.cs +++ b/Assets/SequenceSDK/Editor/SequencePlatformCompileTest.cs @@ -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; diff --git a/Assets/SequenceSDK/WaaS/Tests/HttpClientTests.cs b/Assets/SequenceSDK/WaaS/Tests/HttpClientTests.cs index 4b10a632f..2e3cd13ae 100644 --- a/Assets/SequenceSDK/WaaS/Tests/HttpClientTests.cs +++ b/Assets/SequenceSDK/WaaS/Tests/HttpClientTests.cs @@ -12,7 +12,7 @@ public void TestHttpClientIncludesAPIKey() var request = client.BuildRequest("", 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)); } } diff --git a/Assets/SequenceSDK/WaaS/Tests/IntentSenderTests.cs b/Assets/SequenceSDK/WaaS/Tests/IntentSenderTests.cs index 010fec625..ccb6d58c4 100644 --- a/Assets/SequenceSDK/WaaS/Tests/IntentSenderTests.cs +++ b/Assets/SequenceSDK/WaaS/Tests/IntentSenderTests.cs @@ -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*")); diff --git a/Assets/SequenceSDK/WaaS/Tests/WaaSToWalletAdapterUnitTests.cs b/Assets/SequenceSDK/WaaS/Tests/WaaSToWalletAdapterUnitTests.cs index 853e072fd..b0bba857d 100644 --- a/Assets/SequenceSDK/WaaS/Tests/WaaSToWalletAdapterUnitTests.cs +++ b/Assets/SequenceSDK/WaaS/Tests/WaaSToWalletAdapterUnitTests.cs @@ -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] diff --git a/Packages/Sequence-Unity/Editor/AndroidCustomGradleCheck.cs b/Packages/Sequence-Unity/Editor/AndroidCustomGradleCheck.cs index c79be2837..d1952214b 100644 --- a/Packages/Sequence-Unity/Editor/AndroidCustomGradleCheck.cs +++ b/Packages/Sequence-Unity/Editor/AndroidCustomGradleCheck.cs @@ -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; diff --git a/Packages/Sequence-Unity/Editor/AndroidScriptDefineSetup.cs b/Packages/Sequence-Unity/Editor/AndroidScriptDefineSetup.cs index 86e99c1f0..4a5ff8195 100644 --- a/Packages/Sequence-Unity/Editor/AndroidScriptDefineSetup.cs +++ b/Packages/Sequence-Unity/Editor/AndroidScriptDefineSetup.cs @@ -34,7 +34,7 @@ public void OnPreprocessBuild(BuildReport report) defineList = new List(defines.Split(';')); } - SequenceConfig config = SequenceConfig.GetConfig(); + SequenceConfig config = SequenceConfig.GetConfig(SequenceService.None); if (config.StoreSessionPrivateKeyInSecureStorage) { if (!defineList.Contains(EnableAndroidSecureStorage)) diff --git a/Packages/Sequence-Unity/Editor/CheckUrlScheme.cs b/Packages/Sequence-Unity/Editor/CheckUrlScheme.cs index 130e465ef..72b6205ce 100644 --- a/Packages/Sequence-Unity/Editor/CheckUrlScheme.cs +++ b/Packages/Sequence-Unity/Editor/CheckUrlScheme.cs @@ -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)) diff --git a/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/EmailSignedInText.cs b/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/EmailSignedInText.cs index d1391c64b..e4f3e284b 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/EmailSignedInText.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/EmailSignedInText.cs @@ -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)) diff --git a/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/FederatedAuthExplanationPage.cs b/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/FederatedAuthExplanationPage.cs index cab6c2d35..37e06d17e 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/FederatedAuthExplanationPage.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/FederatedAuthExplanationPage.cs @@ -39,7 +39,7 @@ public override void Open(params object[] args) $"Invalid use. {GetType().Name} must be opened with a {typeof(List)} as an argument"); } - _enableMultipleAccountsPerEmail = SequenceConfig.GetConfig().EnableMultipleAccountsPerEmail; + _enableMultipleAccountsPerEmail = SequenceConfig.GetConfig(SequenceService.WaaS).EnableMultipleAccountsPerEmail; _overrideAccountButton.SetActive(_enableMultipleAccountsPerEmail); @@ -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"); } diff --git a/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/LoginPanel.cs b/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/LoginPanel.cs index cecb566b2..1f03694a3 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/LoginPanel.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceFrontend/Scripts/UI/LoginPanel.cs @@ -39,7 +39,7 @@ protected override void Awake() _demoPage = FindObjectOfType(); - SequenceConfig config = SequenceConfig.GetConfig(); + SequenceConfig config = SequenceConfig.GetConfig(SequenceService.WaaS); SequenceWallet.OnFailedToRecoverSession += OnFailedToRecoverSession; diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Authentication/OpenIdAuthenticator.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/Authentication/OpenIdAuthenticator.cs index 6d337b8ef..fc9553d13 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/Authentication/OpenIdAuthenticator.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Authentication/OpenIdAuthenticator.cs @@ -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); diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceConfig.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceConfig.cs index 3c3ec1cd3..c5403937e 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceConfig.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceConfig.cs @@ -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"); @@ -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); @@ -76,9 +129,9 @@ private static SequenceConfig LoadConfig() } } - return Resources.Load("SequenceConfig"); + return Resources.Load(configName); #else - return Resources.Load("SequenceConfig"); + return Resources.Load(configName); #endif } diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceService.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceService.cs new file mode 100644 index 000000000..6468f02bb --- /dev/null +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceService.cs @@ -0,0 +1,13 @@ +namespace Sequence.Config +{ + public enum SequenceService + { + WaaS, + Indexer, + NodeGateway, + Marketplace, + Stack, + Unspecified, + None + } +} \ No newline at end of file diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceService.cs.meta b/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceService.cs.meta new file mode 100644 index 000000000..f5cb53ee1 --- /dev/null +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceService.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3e2123e72232465a97c3086e07ce3049 +timeCreated: 1739981691 \ No newline at end of file diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/HttpClient.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/HttpClient.cs index 93445b3c6..948355f83 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/HttpClient.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/HttpClient.cs @@ -38,7 +38,7 @@ public HttpClient(string url) this._defaultHeaders = new Dictionary(); _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)) diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/ResponseSignatureValidator.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/ResponseSignatureValidator.cs index 432658f43..b7708a2d7 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/ResponseSignatureValidator.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/ResponseSignatureValidator.cs @@ -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(); diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SequenceLogin.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SequenceLogin.cs index 01e18b79c..a0d8da173 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SequenceLogin.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SequenceLogin.cs @@ -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; @@ -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)) { diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SequenceWallet.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SequenceWallet.cs index 67e988b29..2aa799190 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SequenceWallet.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SequenceWallet.cs @@ -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; } diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SessionManager.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SessionManager.cs index 0af4c9a0c..45c7b4b53 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SessionManager.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/EmbeddedWallet/SessionManager.cs @@ -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; } diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Ethereum/Provider/HttpRpcClient.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/Ethereum/Provider/HttpRpcClient.cs index b024b4e5e..1c5f82f61 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/Ethereum/Provider/HttpRpcClient.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Ethereum/Provider/HttpRpcClient.cs @@ -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 SendRequest(RpcRequest rpcRequest) diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Ethereum/Provider/NodeGatewayBridge.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/Ethereum/Provider/NodeGatewayBridge.cs index 72a986406..693e9ea7f 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/Ethereum/Provider/NodeGatewayBridge.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Ethereum/Provider/NodeGatewayBridge.cs @@ -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) { diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Indexer/HttpHandler.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/Indexer/HttpHandler.cs index acca96977..ae0ab976b 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/Indexer/HttpHandler.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Indexer/HttpHandler.cs @@ -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 } } } diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Indexer/Indexer.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/Indexer/Indexer.cs index 1a58302fa..943378258 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/Indexer/Indexer.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Indexer/Indexer.cs @@ -117,7 +117,7 @@ internal static readonly Dictionary 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 OnQueryFailed; public static Action OnQueryIssue; diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Marketplace/CurrencySwap.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/Marketplace/CurrencySwap.cs index cec164832..702cc7000 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/Marketplace/CurrencySwap.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Marketplace/CurrencySwap.cs @@ -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) diff --git a/Packages/Sequence-Unity/Sequence/SequenceSDK/Marketplace/HttpClient.cs b/Packages/Sequence-Unity/Sequence/SequenceSDK/Marketplace/HttpClient.cs index edbd70c3e..fca6d94fc 100644 --- a/Packages/Sequence-Unity/Sequence/SequenceSDK/Marketplace/HttpClient.cs +++ b/Packages/Sequence-Unity/Sequence/SequenceSDK/Marketplace/HttpClient.cs @@ -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 @@ -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) diff --git a/Packages/Sequence-Unity/package.json b/Packages/Sequence-Unity/package.json index 6c2b1312a..489d6fc69 100644 --- a/Packages/Sequence-Unity/package.json +++ b/Packages/Sequence-Unity/package.json @@ -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", diff --git a/README.md b/README.md index c0aa6fc71..ebbb75e53 100644 --- a/README.md +++ b/README.md @@ -74,11 +74,26 @@ The SDK comes with a number of samples that can be imported via `Samples` using These live inside the `Samples~` folder as required by the [Package Manager specification](https://docs.unity3d.com/Manual/cus-samples.html). However, the Unity Editor will ignore any folders/files with a '~' character in their name and will not create a `.meta` file for them or import them. In order to facilitate our development, we create a symbolic link named `Samples` that points to the `Samples~` folder - allowing us to see and interact with our Samples and Setup scripts. +## Environments + +Sequence generally uses two environments for our backend services: dev and production. By default, the SDK will always use production. + +However, during development, it is occasionally useful to send requests against the dev environment. To do this, you'll first need to have access to the dev version of the Sequence Builder; here, you can generate credentials (API key, WaaS config key, etc.) for your SequenceConfig. This time however, you'll place your configuration in a SequenceConfig instance titled 'SequenceDevConfig' in a `Resources` folder. + +In order to use the dev environment, you'll want to set the appropriate scripting define symbol for your service in your Player Settings. + +- `SEQUENCE_DEV` - every Sequence service +- `SEQUENCE_DEV_WAAS` - the WaaS/EmbeddedWallet service +- `SEQUENCE_DEV_INDEXER` - the Indexer service +- `SEQUENCE_DEV_MARKETPLACE` - the Marketplace service +- `SEQUENCE_DEV_NODEGATEWAY` - the Node Gateway services +- `SEQUENCE_DEV_STACK` - generic Sequence API; unnamed services and functions + ## Assembly Overview The SDK is split into a number of assemblies with different purposes. Each assembly also has a Test assembly or assembly reference containing tests - this way, our tests aren't included in builds. -### SequenceExamples +### SequenceFrontend This contains front-end and example code. Front-end/UI code is considered "example" code for the purposes of this SDK, though it may still be used in production applications. @@ -90,6 +105,10 @@ This contains code related to authentication via Email + OTP, [OIDC](https://ope Defines the `SequenceConfig` scriptable object and scripts needed to read it. Configuration is done in conjunction with the [Sequence Builder](https://sequence.build/). +### SequenceEmbeddedWallet + +The integration with our [WaaS/Embedded Wallet API](https://docs.sequence.xyz/solutions/wallets/embedded-wallet/overview). Used to provide users with a seemless and invisible Web3 wallet experience. + ### SequenceEthereum This is our custom Ethereum library, purpose-built for Unity. @@ -102,6 +121,10 @@ The integration with our [Indexer API](https://docs.sequence.xyz/api/indexer/ove Houses code integrating with third-party service providers like [Transak](https://transak.com/). +### SequenceMarketplace + +The integration with our Marketplace API v2. Used to enable secondary marketplace sales of ERC721/1155s. + ### SequenceRelayer SDK-side extensions to our Sequence Relayer - e.g. transaction queuers. @@ -110,10 +133,6 @@ SDK-side extensions to our Sequence Relayer - e.g. transaction queuers. Universally useful extension methods, helpers, and platform native code used throughout the SDK for a variety of purposes. -### SequenceWaaS - -The integration with our [WaaS/Embedded Wallet API](https://docs.sequence.xyz/solutions/wallets/embedded-wallet/overview). Used to provide users with a seemless and invisible Web3 wallet experience. - ## Component Overview - Ethereum Client (SequenceEthereum) The SDK is broken into a number of components with different responsibilities. This section will give an overview of some of the most important components for users and their intended purposes.