Skip to content

[sdk-3286] add marketplace package to support transak link #295

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 4 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 10 additions & 4 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ jobs:
- name: Update Version in package.json
id: replace_version
run: |
FILE=./src/Packages/Passport/package.json
PASSPORT_FILE=./src/Packages/Passport/package.json
MARKETPLACE_FILE=./src/Packages/Marketplace/package.json

CURRENT_VERSION=$(jq -r '.version' $FILE)
CURRENT_VERSION=$(jq -r '.version' $PASSPORT_FILE)
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"

# Increment version based on UPGRADE_TYPE
Expand All @@ -75,9 +76,14 @@ jobs:
esac

NEW_VERSION="$MAJOR.$MINOR.$PATCH"
jq --arg version "$NEW_VERSION" '.version = $version' $FILE > tmp.$$.json && mv tmp.$$.json $FILE
echo "Updated version in package.json from $CURRENT_VERSION to $NEW_VERSION"

# Update Passport package.json
jq --arg version "$NEW_VERSION" '.version = $version' $PASSPORT_FILE > tmp.$$.json && mv tmp.$$.json $PASSPORT_FILE
echo "Updated version in Passport package.json from $CURRENT_VERSION to $NEW_VERSION"

# Update Marketplace package.json
jq --arg version "$NEW_VERSION" '.version = $version' $MARKETPLACE_FILE > tmp.$$.json && mv tmp.$$.json $MARKETPLACE_FILE
echo "Updated version in Marketplace package.json from $CURRENT_VERSION to $NEW_VERSION"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"

- name: Update SDK Version in SdkVersionInfoHelpers.cs
Expand Down
19 changes: 19 additions & 0 deletions src/Packages/Marketplace/Immutable.Marketplace.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Immutable.Integrations",
"rootNamespace": "Immutable.Integrations",
"references": [
"UniTask",
"Immutable.Browser.Core",
"Immutable.Passport.Runtime.Public",
"Immutable.Passport.Runtime.Private"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions src/Packages/Marketplace/Immutable.Marketplace.asmdef.meta

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

8 changes: 8 additions & 0 deletions src/Packages/Marketplace/OnRamp.meta

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

67 changes: 67 additions & 0 deletions src/Packages/Marketplace/OnRamp/OnRamp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Cysharp.Threading.Tasks;
using UnityEngine;

namespace Immutable.Marketplace.OnRamp
{
public class OnRamp
{
private readonly Passport.Passport _passport;
private static readonly Dictionary<string, string> TransakBaseUrls = new Dictionary<string, string>
{
{ "sandbox", "https://global-stg.transak.com" },
{ "production", "https://global.transak.com/" }
};

private static readonly Dictionary<string, string> TransakApiKeys = new Dictionary<string, string>
{
{ "sandbox", "d14b44fb-0f84-4db5-affb-e044040d724b" }, // This can be hardcoded as it is a public API key
{ "production", "ad1bca70-d917-4628-bb0f-5609537498bc" }
};

public OnRamp(Passport.Passport passport)
{
_passport = passport;
}

public async UniTask<string> GetLink(
string fiatCurrency = "USD",
string defaultFiatAmount = "50",
string defaultCryptoCurrency = "IMX",
string networks = "immutablezkevm",
bool disableWalletAddressForm = true)
{
await _passport.ConnectImx();
string environment = _passport.GetPassportImpl().environment;

string email = await _passport.GetEmail();
string walletAddress = await _passport.GetAddress();
string baseUrl = TransakBaseUrls[environment];
string apiKey = TransakApiKeys[environment];

var queryParams = new Dictionary<string, string>
{
{"apiKey", apiKey},
{"network", networks},
{"defaultPaymentMethod", "credit_debit_card"},
{"disablePaymentMethods", ""},
{"productsAvailed", "buy"},
{"exchangeScreenTitle", "Buy"},
{"themeColor", "0D0D0D"},
{"defaultCryptoCurrency", defaultCryptoCurrency},
{"email", Uri.EscapeDataString(email)},
{"isAutoFillUserData", "true"},
{"disableWalletAddressForm", disableWalletAddressForm.ToString().ToLower()},
{"defaultFiatAmount", defaultFiatAmount},
{"defaultFiatCurrency", fiatCurrency},
{"walletAddress", walletAddress},
{"cryptoCurrencyList", "imx,eth,usdc"}
};

string queryString = string.Join("&", queryParams.Select(kvp => $"{kvp.Key}={Uri.EscapeDataString(kvp.Value)}").ToArray());
return $"{baseUrl}?{queryString}";
}
}
}
11 changes: 11 additions & 0 deletions src/Packages/Marketplace/OnRamp/OnRamp.cs.meta

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

19 changes: 19 additions & 0 deletions src/Packages/Marketplace/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "com.immutable.marketplace",
"version": "1.26.0",
"description": "Marketplace package for the Immutable SDK for Unity",
"displayName": "Immutable Marketplace",
"author": {
"name": "Immutable",
"url": "https://immutable.com"
},
"dependencies": {
"com.cysharp.unitask": "2.3.3"
},
"keywords": [
"unity",
"immutable",
"Marketplace"
],
"unity": "2021.3"
}
7 changes: 7 additions & 0 deletions src/Packages/Marketplace/package.json.meta

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

Loading