Skip to content

Commit

Permalink
Merge pull request #295 from immutable/feature/sdk-3286-transak-link
Browse files Browse the repository at this point in the history
[sdk-3286] add marketplace package to support transak link
  • Loading branch information
andrew-yangy authored Sep 30, 2024
2 parents b64f817 + a63bf2f commit 975f961
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 4 deletions.
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
16 changes: 16 additions & 0 deletions src/Packages/Marketplace/Immutable.Marketplace.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Immutable.Marketplace",
"rootNamespace": "Immutable.Marketplace",
"references": [
"UniTask"
],
"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 string _environment;
private readonly string _email;
private readonly string _address;
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(string environment, string email, string address)
{
_environment = environment;
_email = email;
_address = address;
}

public async UniTask<string> GetLink(
string fiatCurrency = "USD",
string defaultFiatAmount = "50",
string defaultCryptoCurrency = "IMX",
string networks = "immutablezkevm",
bool disableWalletAddressForm = true
)
{
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", _address},
{"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.

0 comments on commit 975f961

Please sign in to comment.