diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml index 09c06b52..e57e19cc 100644 --- a/.github/workflows/update-version.yml +++ b/.github/workflows/update-version.yml @@ -94,19 +94,25 @@ jobs: sed -i -E "s/[0-9]+\.[0-9]+\.[0-9]+/$NEW_VERSION/g" $FILE echo "Updated SDK version in SdkVersionInfoHelpers.cs to $NEW_VERSION" - - name: Ensure Passport Samples~/SamplesScenesScripts directory exists and clear contents + - name: Ensure Samples~/SamplesScenesScripts directory exists and clear contents run: | mkdir -p ./src/Packages/Passport/Samples~/SamplesScenesScripts rm -rf ./src/Packages/Passport/Samples~/SamplesScenesScripts/* + mkdir -p ./src/Packages/Marketplace/Samples~/SamplesScenesScripts + rm -rf ./src/Packages/Marketplace/Samples~/SamplesScenesScripts/* + - name: Install rsync run: sudo apt-get install -y rsync - name: Copy sample scenes and scripts to Passport package Samples~ id: copy_sample_scenes_and_scripts run: | - rsync -av --exclude='*.meta' ./sample/Assets/Scenes/ ./src/Packages/Passport/Samples~/SamplesScenesScripts/Scenes/ - rsync -av --exclude='*.meta' ./sample/Assets/Scripts/ ./src/Packages/Passport/Samples~/SamplesScenesScripts/Scripts/ + rsync -av --exclude='*.meta' ./sample/Assets/Scenes/Passport ./src/Packages/Passport/Samples~/SamplesScenesScripts/Scenes/ + rsync -av --exclude='*.meta' ./sample/Assets/Scripts/Passport ./src/Packages/Passport/Samples~/SamplesScenesScripts/Scripts/ + + rsync -av --exclude='*.meta' ./sample/Assets/Scenes/Marketplace ./src/Packages/Marketplace/Samples~/SamplesScenesScripts/Scenes/ + rsync -av --exclude='*.meta' ./sample/Assets/Scripts/Marketplace ./src/Packages/Marketplace/Samples~/SamplesScenesScripts/Scripts/ - uses: gr2m/create-or-update-pull-request-action@v1 env: diff --git a/sample/Assets/Scenes/Marketplace/BridgeScene.unity b/sample/Assets/Scenes/Marketplace/BridgeScene.unity index 0d9bfdbf..9dc73025 100644 --- a/sample/Assets/Scenes/Marketplace/BridgeScene.unity +++ b/sample/Assets/Scenes/Marketplace/BridgeScene.unity @@ -1908,7 +1908,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: sandbox + m_Text: Sandbox --- !u!222 &827625658 CanvasRenderer: m_ObjectHideFlags: 0 @@ -2892,7 +2892,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 89265f0596214bb5a23345888806c8de, type: 3} m_Name: m_EditorClassIdentifier: - Environment: {fileID: 1351870715} + EnvironmentDropdown: {fileID: 1351870715} FromTokenAddress: {fileID: 949453541} FromChain: {fileID: 1152654601} ToTokenAddress: {fileID: 1363329117} @@ -3301,9 +3301,9 @@ MonoBehaviour: m_Value: 0 m_Options: m_Options: - - m_Text: sandbox + - m_Text: Sandbox m_Image: {fileID: 0} - - m_Text: production + - m_Text: Production m_Image: {fileID: 0} m_OnValueChanged: m_PersistentCalls: diff --git a/sample/Assets/Scenes/Marketplace/OnRampScene.unity b/sample/Assets/Scenes/Marketplace/OnRampScene.unity index 5763518a..691722ed 100644 --- a/sample/Assets/Scenes/Marketplace/OnRampScene.unity +++ b/sample/Assets/Scenes/Marketplace/OnRampScene.unity @@ -1990,7 +1990,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: sandbox + m_Text: Sandbox --- !u!222 &827625658 CanvasRenderer: m_ObjectHideFlags: 0 @@ -2887,7 +2887,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 90ea1df5aa4d54e4bbc702d843424073, type: 3} m_Name: m_EditorClassIdentifier: - Environment: {fileID: 1351870715} + EnvironmentDropdown: {fileID: 1351870715} EmailInput: {fileID: 1142338628822901615} AddressInput: {fileID: 1142338629240194742} FiatCurrencyInput: {fileID: 949453541} @@ -3298,9 +3298,9 @@ MonoBehaviour: m_Value: 0 m_Options: m_Options: - - m_Text: sandbox + - m_Text: Sandbox m_Image: {fileID: 0} - - m_Text: production + - m_Text: Production m_Image: {fileID: 0} m_OnValueChanged: m_PersistentCalls: diff --git a/sample/Assets/Scenes/Marketplace/SwapScene.unity b/sample/Assets/Scenes/Marketplace/SwapScene.unity index 46375b12..38ce7a2e 100644 --- a/sample/Assets/Scenes/Marketplace/SwapScene.unity +++ b/sample/Assets/Scenes/Marketplace/SwapScene.unity @@ -1474,7 +1474,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: sandbox + m_Text: Sandbox --- !u!222 &827625658 CanvasRenderer: m_ObjectHideFlags: 0 @@ -2288,7 +2288,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 371b71184b3d4a72853fcb8fdb41383d, type: 3} m_Name: m_EditorClassIdentifier: - Environment: {fileID: 1351870715} + EnvironmentDropdown: {fileID: 1351870715} KeyInput: {fileID: 1142338628822901615} FromTokenAddress: {fileID: 949453541} ToTokenAddress: {fileID: 1363329117} @@ -2696,9 +2696,9 @@ MonoBehaviour: m_Value: 0 m_Options: m_Options: - - m_Text: sandbox + - m_Text: Sandbox m_Image: {fileID: 0} - - m_Text: production + - m_Text: Production m_Image: {fileID: 0} m_OnValueChanged: m_PersistentCalls: diff --git a/sample/Assets/Scripts/Marketplace/BridgeScript.cs b/sample/Assets/Scripts/Marketplace/BridgeScript.cs index d61cb7d1..fe6bdc47 100644 --- a/sample/Assets/Scripts/Marketplace/BridgeScript.cs +++ b/sample/Assets/Scripts/Marketplace/BridgeScript.cs @@ -1,20 +1,20 @@ +using System; using AltWebSocketSharp; -using Immutable.Marketplace.Bridge; -using Immutable.Marketplace.OnRamp; -using Immutable.Marketplace.Swap; +using Immutable.Marketplace; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; +using Environment = Immutable.Marketplace.Environment; public class BridgeScript : MonoBehaviour { - [SerializeField] private Dropdown Environment; + [SerializeField] private Dropdown EnvironmentDropdown; [SerializeField] private InputField FromTokenAddress; [SerializeField] private InputField FromChain; [SerializeField] private InputField ToTokenAddress; [SerializeField] private InputField ToChain; - + [SerializeField] private Button OpenButton; /// @@ -22,15 +22,15 @@ public class BridgeScript : MonoBehaviour /// public void OpenWidget() { - var environment = Environment.options[Environment.value].text; - - var bridge = new Bridge(environment); + var environments = (Environment[])Enum.GetValues(typeof(Environment)); + var environment = environments[EnvironmentDropdown.value]; - var link = bridge.GetLink( + var link = LinkFactory.GenerateBridgeLink( + environment: environment, fromTokenAddress: FromTokenAddress.text.IsNullOrEmpty() ? null : FromTokenAddress.text, - fromChain: FromChain.text.IsNullOrEmpty() ? null : FromChain.text, + fromChainID: FromChain.text.IsNullOrEmpty() ? null : FromChain.text, toTokenAddress: ToTokenAddress.text.IsNullOrEmpty() ? null : ToTokenAddress.text, - toChain: ToChain.text.IsNullOrEmpty() ? null : ToChain.text + toChainID: ToChain.text.IsNullOrEmpty() ? null : ToChain.text ); Application.OpenURL(link); diff --git a/sample/Assets/Scripts/Marketplace/MarketplaceScript.cs b/sample/Assets/Scripts/Marketplace/MarketplaceScript.cs index 192df97c..de176c9d 100644 --- a/sample/Assets/Scripts/Marketplace/MarketplaceScript.cs +++ b/sample/Assets/Scripts/Marketplace/MarketplaceScript.cs @@ -7,12 +7,12 @@ public void OnRamp() { SceneManager.LoadScene("OnRampScene"); } - + public void Swap() { SceneManager.LoadScene("SwapScene"); } - + public void Bridge() { SceneManager.LoadScene("BridgeScene"); diff --git a/sample/Assets/Scripts/Marketplace/OnRampScript.cs b/sample/Assets/Scripts/Marketplace/OnRampScript.cs index d8c8eef3..cb6e2443 100644 --- a/sample/Assets/Scripts/Marketplace/OnRampScript.cs +++ b/sample/Assets/Scripts/Marketplace/OnRampScript.cs @@ -1,12 +1,14 @@ +using System; using AltWebSocketSharp; -using Immutable.Marketplace.OnRamp; +using Immutable.Marketplace; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; +using Environment = Immutable.Marketplace.Environment; public class OnRampScript : MonoBehaviour { - [SerializeField] private Dropdown Environment; + [SerializeField] private Dropdown EnvironmentDropdown; [SerializeField] private InputField EmailInput; [SerializeField] private InputField AddressInput; @@ -14,7 +16,7 @@ public class OnRampScript : MonoBehaviour [SerializeField] private InputField FiatAmountInput; [SerializeField] private InputField CryptoCurrency; [SerializeField] private InputField CryptoCurrencyList; - + [SerializeField] private Button OpenButton; private void Start() @@ -39,13 +41,15 @@ private void ValidateInputFields() /// public void OpenWidget() { - var environment = Environment.options[Environment.value].text; + var environments = (Environment[])Enum.GetValues(typeof(Environment)); + var environment = environments[EnvironmentDropdown.value]; var email = EmailInput.text; var walletAddress = AddressInput.text; - var onRamp = new OnRamp(environment, email, walletAddress); - - var link = onRamp.GetLink( + var link = LinkFactory.GenerateOnRampLink( + environment: environment, + email: email, + address: walletAddress, fiatCurrency: FiatCurrencyInput.text.IsNullOrEmpty() ? "USD" : FiatCurrencyInput.text, fiatAmount: FiatAmountInput.text.IsNullOrEmpty() ? "50" : FiatAmountInput.text, cryptoCurrency: CryptoCurrency.text.IsNullOrEmpty() ? "IMX" : CryptoCurrency.text, @@ -54,7 +58,7 @@ public void OpenWidget() Application.OpenURL(link); } - + /// /// Returns to the marketplace scene. /// diff --git a/sample/Assets/Scripts/Marketplace/SwapScript.cs b/sample/Assets/Scripts/Marketplace/SwapScript.cs index 29c8f9cd..5fc6f3ed 100644 --- a/sample/Assets/Scripts/Marketplace/SwapScript.cs +++ b/sample/Assets/Scripts/Marketplace/SwapScript.cs @@ -1,18 +1,19 @@ +using System; using AltWebSocketSharp; -using Immutable.Marketplace.OnRamp; -using Immutable.Marketplace.Swap; +using Immutable.Marketplace; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; +using Environment = Immutable.Marketplace.Environment; public class SwapScript : MonoBehaviour { - [SerializeField] private Dropdown Environment; + [SerializeField] private Dropdown EnvironmentDropdown; [SerializeField] private InputField KeyInput; [SerializeField] private InputField FromTokenAddress; [SerializeField] private InputField ToTokenAddress; - + [SerializeField] private Button OpenButton; private void Start() @@ -36,12 +37,13 @@ private void ValidateInputFields() /// public void OpenWidget() { - var environment = Environment.options[Environment.value].text; + var environments = (Environment[])Enum.GetValues(typeof(Environment)); + var environment = environments[EnvironmentDropdown.value]; var publishableKey = KeyInput.text; - var swap = new Swap(environment, publishableKey); - - var link = swap.GetLink( + var link = LinkFactory.GenerateSwapLink( + environment: environment, + publishableKey: publishableKey, fromTokenAddress: FromTokenAddress.text.IsNullOrEmpty() ? null : FromTokenAddress.text, toTokenAddress: ToTokenAddress.text.IsNullOrEmpty() ? null : ToTokenAddress.text ); diff --git a/src/Packages/Marketplace/Runtime/Bridge.meta b/src/Packages/Marketplace/Runtime/Bridge.meta deleted file mode 100644 index 39f22cd4..00000000 --- a/src/Packages/Marketplace/Runtime/Bridge.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 26141e7abf8c424b86b1a7301e8ad20d -timeCreated: 1737318271 \ No newline at end of file diff --git a/src/Packages/Marketplace/Runtime/Bridge/Bridge.cs b/src/Packages/Marketplace/Runtime/Bridge/Bridge.cs deleted file mode 100644 index 9c18d8b8..00000000 --- a/src/Packages/Marketplace/Runtime/Bridge/Bridge.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Immutable.Marketplace.Bridge -{ - /// - /// Provides functionality for generating a link to the bridge flow, - /// simplifying the process of moving tokens from and to the Immutable zkEVM network. - /// - public class Bridge - { - private readonly string _environment; - private static readonly Dictionary BaseUrls = new() - { - { "sandbox", "https://checkout-playground.sandbox.immutable.com/checkout/squid" }, - { "production", "https://toolkit.immutable.com/checkout/squid" } - }; - - /// - /// Initialises a new instance of the class. - /// - /// Specifies the environment (sandbox or production). - public Bridge(string environment) - { - _environment = environment; - } - - /// - /// Generates a link for the bridge flow. - /// - /// The address of the token being moved from (default is null). - /// The ID of the source blockchain (default is null). - /// The address of the token being moved to (default is null). - /// The ID of the destination blockchain (default is null). - /// A bridge URL. - public string GetLink(string? fromTokenAddress = null, string? fromChain = null, string? toTokenAddress = null, string? toChain = null) - { - var baseUrl = BaseUrls[_environment]; - - var queryParams = new Dictionary(); - - if (!string.IsNullOrEmpty(fromTokenAddress)) - queryParams["fromToken"] = fromTokenAddress.ToLower(); - - if (!string.IsNullOrEmpty(fromChain)) - queryParams["fromChain"] = fromChain; - - if (!string.IsNullOrEmpty(toTokenAddress)) - queryParams["toToken"] = toTokenAddress.ToLower(); - - if (!string.IsNullOrEmpty(toChain)) - queryParams["toChain"] = toChain; - - var queryString = string.Join("&", queryParams.Select(kvp => $"{kvp.Key}={Uri.EscapeDataString(kvp.Value)}").ToArray()); - return $"{baseUrl}?{queryString}"; - } - } -} \ No newline at end of file diff --git a/src/Packages/Marketplace/Runtime/Bridge/Bridge.cs.meta b/src/Packages/Marketplace/Runtime/Bridge/Bridge.cs.meta deleted file mode 100644 index 60af3ea0..00000000 --- a/src/Packages/Marketplace/Runtime/Bridge/Bridge.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 9c9cfc4602c840068916eb5806790758 -timeCreated: 1737318271 \ No newline at end of file diff --git a/src/Packages/Marketplace/Runtime/LinkConfig.cs b/src/Packages/Marketplace/Runtime/LinkConfig.cs new file mode 100644 index 00000000..85fed286 --- /dev/null +++ b/src/Packages/Marketplace/Runtime/LinkConfig.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Immutable.Marketplace +{ + public enum Flow + { + OnRamp, + Swap, + Bridge + } + + public enum Environment + { + Sandbox, + Production + } + + public static class LinkConfig + { + private static string _onRampBaseUrlSandbox = "https://global-stg.transak.com"; + private static string _onRampBaseUrlProduction = "https://global.transak.com"; + + private static string _swapBaseUrlSandbox = "https://checkout-playground.sandbox.immutable.com/checkout/swap"; + private static string _swapBaseUrlProduction = "https://toolkit.immutable.com/checkout/swap"; + + private static string _bridgeBaseUrlSandbox = "https://checkout-playground.sandbox.immutable.com/checkout/squid"; + private static string _bridgeBaseUrlProduction = "https://toolkit.immutable.com/checkout/squid"; + + // These can be hardcoded as they are public API keys + private static string _apiOnRampKeySandbox = "d14b44fb-0f84-4db5-affb-e044040d724b"; + private static string _apiOnRampKeyProduction = "ad1bca70-d917-4628-bb0f-5609537498bc"; + + public static string GetBaseUrl(Environment env, Flow flow) + { + return flow switch + { + Flow.OnRamp => env == Environment.Sandbox ? _onRampBaseUrlSandbox : _onRampBaseUrlProduction, + Flow.Swap => env == Environment.Sandbox ? _swapBaseUrlSandbox : _swapBaseUrlProduction, + Flow.Bridge => env == Environment.Sandbox ? _bridgeBaseUrlSandbox : _bridgeBaseUrlProduction, + _ => throw new ArgumentException("Invalid flow") + }; + } + + public static string GetApiKey(Environment env, Flow flow) + { + return flow is Flow.OnRamp ? + env == Environment.Sandbox ? _apiOnRampKeySandbox : _apiOnRampKeyProduction : + string.Empty; + } + } +} diff --git a/src/Packages/Marketplace/Runtime/LinkConfig.cs.meta b/src/Packages/Marketplace/Runtime/LinkConfig.cs.meta new file mode 100644 index 00000000..42d139b1 --- /dev/null +++ b/src/Packages/Marketplace/Runtime/LinkConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e112a98765f745648beee3b7916b89d9 +timeCreated: 1738034483 \ No newline at end of file diff --git a/src/Packages/Marketplace/Runtime/LinkFactory.cs b/src/Packages/Marketplace/Runtime/LinkFactory.cs new file mode 100644 index 00000000..b6629e17 --- /dev/null +++ b/src/Packages/Marketplace/Runtime/LinkFactory.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Immutable.Marketplace +{ + public class LinkFactory + { + /// + /// Generates a URL for the on-ramp flow. + /// + /// Specifies the environment (Sandbox or Production). + /// The user's email address, pre-filled in the on-ramp flow. + /// The user's wallet address, where tokens will be sent. + /// The fiat currency to use (default: "USD"). + /// The amount of fiat currency to spend when purchasing cryptocurrency (default: "50"). + /// The cryptocurrency to purchase (default: "IMX"). + /// A comma-separated list of available cryptocurrencies for purchase (default: "imx,eth,usdc"). + /// The generated on-ramp URL. + public static string GenerateOnRampLink( + Environment environment, + string email, + string address, + string fiatCurrency = "USD", + string fiatAmount = "50", + string cryptoCurrency = "IMX", + string cryptoCurrencyList = "imx,eth,usdc" + ) + { + var baseUrl = LinkConfig.GetBaseUrl(environment, Flow.OnRamp); + var apiKey = LinkConfig.GetApiKey(environment, Flow.OnRamp); + + var queryParams = new Dictionary + { + {"apiKey", apiKey}, + {"network", "immutablezkevm"}, + {"defaultPaymentMethod", "credit_debit_card"}, + {"disablePaymentMethods", ""}, + {"productsAvailed", "buy"}, + {"exchangeScreenTitle", "Buy"}, + {"themeColor", "0D0D0D"}, + {"defaultCryptoCurrency", cryptoCurrency}, + {"email", Uri.EscapeDataString(email)}, + {"isAutoFillUserData", "true"}, + {"disableWalletAddressForm", "true"}, + {"defaultFiatAmount", fiatAmount}, + {"defaultFiatCurrency", fiatCurrency}, + {"walletAddress", address}, + {"cryptoCurrencyList", cryptoCurrencyList} + }; + + var queryString = string.Join("&", queryParams.Select(kvp => $"{kvp.Key}={Uri.EscapeDataString(kvp.Value)}").ToArray()); + return $"{baseUrl}?{queryString}"; + } + + /// + /// Generates a link for the swap flow. + /// + /// Specifies the environment (Sandbox or Production). + /// The publishable key obtained from Immutable Hub. See API keys for more details. + /// The address of the token being swapped from (default is null). + /// The address of the token being swapped to (default is null). + /// A swap URL + public static string GenerateSwapLink( + Environment environment, + string publishableKey, + string? fromTokenAddress = null, + string? toTokenAddress = null + ) + { + var baseUrl = LinkConfig.GetBaseUrl(environment, Flow.Swap); + + var queryParams = new Dictionary + { + {"publishableKey", publishableKey} + }; + + if (!string.IsNullOrEmpty(fromTokenAddress)) + { + queryParams["fromTokenAddress"] = fromTokenAddress; + } + + if (!string.IsNullOrEmpty(toTokenAddress)) + { + queryParams["toTokenAddress"] = toTokenAddress; + } + + var queryString = string.Join("&", queryParams.Select(kvp => $"{kvp.Key}={Uri.EscapeDataString(kvp.Value)}").ToArray()); + return $"{baseUrl}?{queryString}"; + } + + /// + /// Generates a link for the bridge flow. + /// + /// Specifies the environment (Sandbox or Production). + /// The address of the token being moved from (default is null). + /// The ID of the source blockchain (default is null). + /// The address of the token being moved to (default is null). + /// The ID of the destination blockchain (default is null). + /// A bridge URL. + public static string GenerateBridgeLink( + Environment environment, + string? fromTokenAddress = null, + string? fromChainID = null, + string? toTokenAddress = null, + string? toChainID = null + ) + { + var baseUrl = LinkConfig.GetBaseUrl(environment, Flow.Bridge); + + var queryParams = new Dictionary(); + + if (!string.IsNullOrEmpty(fromTokenAddress)) + queryParams["fromToken"] = fromTokenAddress.ToLower(); + + if (!string.IsNullOrEmpty(fromChainID)) + queryParams["fromChain"] = fromChainID; + + if (!string.IsNullOrEmpty(toTokenAddress)) + queryParams["toToken"] = toTokenAddress.ToLower(); + + if (!string.IsNullOrEmpty(toChainID)) + queryParams["toChain"] = toChainID; + + var queryString = string.Join("&", queryParams.Select(kvp => $"{kvp.Key}={Uri.EscapeDataString(kvp.Value)}").ToArray()); + return $"{baseUrl}?{queryString}"; + } + } +} \ No newline at end of file diff --git a/src/Packages/Marketplace/Runtime/LinkFactory.cs.meta b/src/Packages/Marketplace/Runtime/LinkFactory.cs.meta new file mode 100644 index 00000000..5daac5d5 --- /dev/null +++ b/src/Packages/Marketplace/Runtime/LinkFactory.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e4a7d8c348f1409fa53c0ebda943ab20 +timeCreated: 1738034473 \ No newline at end of file diff --git a/src/Packages/Marketplace/Runtime/OnRamp.meta b/src/Packages/Marketplace/Runtime/OnRamp.meta deleted file mode 100644 index 1397a22e..00000000 --- a/src/Packages/Marketplace/Runtime/OnRamp.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ddb0de63ab0184d7fb2cf71a08124a02 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/Packages/Marketplace/Runtime/OnRamp/OnRamp.cs b/src/Packages/Marketplace/Runtime/OnRamp/OnRamp.cs deleted file mode 100644 index 9e2d333e..00000000 --- a/src/Packages/Marketplace/Runtime/OnRamp/OnRamp.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Immutable.Marketplace.OnRamp -{ - /// - /// Provides functionality for generating an on-ramp link, allowing players to purchase tokens - /// using fiat currency and transfer them directly to the Immutable zkEVM network. - /// - public class OnRamp - { - private readonly string _environment; - private readonly string _email; - private readonly string _address; - private static readonly Dictionary BaseUrls = new() - { - { "sandbox", "https://global-stg.transak.com" }, - { "production", "https://global.transak.com" } - }; - - private static readonly Dictionary ApiKeys = new() - { - { "sandbox", "d14b44fb-0f84-4db5-affb-e044040d724b" }, // This can be hardcoded as it is a public API key - { "production", "ad1bca70-d917-4628-bb0f-5609537498bc" } - }; - - /// - /// Initialises a new instance of the class. - /// - /// Specifies the environment (sandbox or production). - /// The user's email address, pre-filled in the on-ramp flow. - /// The user's wallet address, where tokens will be sent. - public OnRamp(string environment, string email, string address) - { - _environment = environment; - _email = email; - _address = address; - } - - /// - /// Generates a URL for the on-ramp flow. - /// - /// The fiat currency to use (default: "USD"). - /// The amount of fiat currency to spend when purchasing cryptocurrency (default: "50"). - /// The cryptocurrency to purchase (default: "IMX"). - /// A comma-separated list of available cryptocurrencies for purchase (default: "imx,eth,usdc"). - /// The generated on-ramp URL. - public string GetLink( - string fiatCurrency = "USD", - string fiatAmount = "50", - string cryptoCurrency = "IMX", - string cryptoCurrencyList = "imx,eth,usdc" - ) - { - var baseUrl = BaseUrls[_environment]; - var apiKey = ApiKeys[_environment]; - - var queryParams = new Dictionary - { - {"apiKey", apiKey}, - {"network", "immutablezkevm"}, - {"defaultPaymentMethod", "credit_debit_card"}, - {"disablePaymentMethods", ""}, - {"productsAvailed", "buy"}, - {"exchangeScreenTitle", "Buy"}, - {"themeColor", "0D0D0D"}, - {"defaultCryptoCurrency", cryptoCurrency}, - {"email", Uri.EscapeDataString(_email)}, - {"isAutoFillUserData", "true"}, - {"disableWalletAddressForm", "true"}, - {"defaultFiatAmount", fiatAmount}, - {"defaultFiatCurrency", fiatCurrency}, - {"walletAddress", _address}, - {"cryptoCurrencyList", cryptoCurrencyList} - }; - - var queryString = string.Join("&", queryParams.Select(kvp => $"{kvp.Key}={Uri.EscapeDataString(kvp.Value)}").ToArray()); - return $"{baseUrl}?{queryString}"; - } - } -} \ No newline at end of file diff --git a/src/Packages/Marketplace/Runtime/OnRamp/OnRamp.cs.meta b/src/Packages/Marketplace/Runtime/OnRamp/OnRamp.cs.meta deleted file mode 100644 index 3efcaadd..00000000 --- a/src/Packages/Marketplace/Runtime/OnRamp/OnRamp.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ebb99edbcb8c04a90abe7d962fef8a3d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/Packages/Marketplace/Runtime/Swap.meta b/src/Packages/Marketplace/Runtime/Swap.meta deleted file mode 100644 index 422bff91..00000000 --- a/src/Packages/Marketplace/Runtime/Swap.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ecc83add57164e7f9bebe81b9336b6d1 -timeCreated: 1736976769 \ No newline at end of file diff --git a/src/Packages/Marketplace/Runtime/Swap/Swap.cs b/src/Packages/Marketplace/Runtime/Swap/Swap.cs deleted file mode 100644 index 3901584d..00000000 --- a/src/Packages/Marketplace/Runtime/Swap/Swap.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Immutable.Marketplace.Swap -{ - /// - /// Provides functionality for generating a link to the swap flow, - /// simplifying the process of swapping tokens on the Immutable zkEVM network. - /// - public class Swap - { - private readonly string _environment; - private readonly string _publishableKey; - private static readonly Dictionary BaseUrls = new() - { - { "sandbox", "https://checkout-playground.sandbox.immutable.com/checkout/swap" }, - { "production", "https://toolkit.immutable.com/checkout/swap" } - }; - - /// - /// Initialises a new instance of the class. - /// - /// The environment to use (sandbox or production). - /// The publishable key obtained from Immutable Hub. - /// See API keys for more details. - public Swap(string environment, string publishableKey) - { - _environment = environment; - _publishableKey = publishableKey; - } - - /// - /// Generates a link for the swap flow. - /// - /// The address of the token being swapped from (default is null). - /// The address of the token being swapped to (default is null). - /// A swap URL - public string GetLink(string? fromTokenAddress = null, string? toTokenAddress = null) - { - var baseUrl = BaseUrls[_environment]; - - var queryParams = new Dictionary - { - {"publishableKey", _publishableKey} - }; - - if (!string.IsNullOrEmpty(fromTokenAddress)) - { - queryParams["fromTokenAddress"] = fromTokenAddress; - } - - if (!string.IsNullOrEmpty(toTokenAddress)) - { - queryParams["toTokenAddress"] = toTokenAddress; - } - - var queryString = string.Join("&", queryParams.Select(kvp => $"{kvp.Key}={Uri.EscapeDataString(kvp.Value)}").ToArray()); - return $"{baseUrl}?{queryString}"; - } - } -} \ No newline at end of file diff --git a/src/Packages/Marketplace/Runtime/Swap/Swap.cs.meta b/src/Packages/Marketplace/Runtime/Swap/Swap.cs.meta deleted file mode 100644 index 3844c791..00000000 --- a/src/Packages/Marketplace/Runtime/Swap/Swap.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 8c465e6a6157457c9c11e43759058ee1 -timeCreated: 1736976774 \ No newline at end of file