Skip to content

[DX-3550] refactor: marketplace package to use static functions for generating urls #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 28, 2025
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
12 changes: 9 additions & 3 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions sample/Assets/Scenes/Marketplace/BridgeScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions sample/Assets/Scenes/Marketplace/OnRampScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions sample/Assets/Scenes/Marketplace/SwapScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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:
Expand Down
22 changes: 11 additions & 11 deletions sample/Assets/Scripts/Marketplace/BridgeScript.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
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;

/// <summary>
/// Opens the bridge widget with specified inputs, defaulting to pre-set values when fields are empty.
/// </summary>
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);
Expand Down
4 changes: 2 additions & 2 deletions sample/Assets/Scripts/Marketplace/MarketplaceScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public void OnRamp()
{
SceneManager.LoadScene("OnRampScene");
}

public void Swap()
{
SceneManager.LoadScene("SwapScene");
}

public void Bridge()
{
SceneManager.LoadScene("BridgeScene");
Expand Down
20 changes: 12 additions & 8 deletions sample/Assets/Scripts/Marketplace/OnRampScript.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
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;

[SerializeField] private InputField FiatCurrencyInput;
[SerializeField] private InputField FiatAmountInput;
[SerializeField] private InputField CryptoCurrency;
[SerializeField] private InputField CryptoCurrencyList;

[SerializeField] private Button OpenButton;

private void Start()
Expand All @@ -39,13 +41,15 @@ private void ValidateInputFields()
/// </summary>
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,
Expand All @@ -54,7 +58,7 @@ public void OpenWidget()

Application.OpenURL(link);
}

/// <summary>
/// Returns to the marketplace scene.
/// </summary>
Expand Down
18 changes: 10 additions & 8 deletions sample/Assets/Scripts/Marketplace/SwapScript.cs
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -36,12 +37,13 @@ private void ValidateInputFields()
/// </summary>
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
);
Expand Down
3 changes: 0 additions & 3 deletions src/Packages/Marketplace/Runtime/Bridge.meta

This file was deleted.

59 changes: 0 additions & 59 deletions src/Packages/Marketplace/Runtime/Bridge/Bridge.cs

This file was deleted.

3 changes: 0 additions & 3 deletions src/Packages/Marketplace/Runtime/Bridge/Bridge.cs.meta

This file was deleted.

Loading
Loading