1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
- using Cysharp . Threading . Tasks ;
5
4
6
5
namespace Immutable . Marketplace . OnRamp
7
6
{
7
+ /// <summary>
8
+ /// Provides functionality for generating an on-ramp link, allowing players to purchase tokens
9
+ /// using fiat currency and transfer them directly to the Immutable zkEVM network.
10
+ /// </summary>
8
11
public class OnRamp
9
12
{
10
13
private readonly string _environment ;
11
14
private readonly string _email ;
12
15
private readonly string _address ;
13
- private static readonly Dictionary < string , string > TransakBaseUrls = new Dictionary < string , string >
16
+ private static readonly Dictionary < string , string > BaseUrls = new ( )
14
17
{
15
18
{ "sandbox" , "https://global-stg.transak.com" } ,
16
- { "production" , "https://global.transak.com/ " }
19
+ { "production" , "https://global.transak.com" }
17
20
} ;
18
21
19
- private static readonly Dictionary < string , string > TransakApiKeys = new Dictionary < string , string >
22
+ private static readonly Dictionary < string , string > ApiKeys = new ( )
20
23
{
21
24
{ "sandbox" , "d14b44fb-0f84-4db5-affb-e044040d724b" } , // This can be hardcoded as it is a public API key
22
25
{ "production" , "ad1bca70-d917-4628-bb0f-5609537498bc" }
23
26
} ;
24
27
28
+ /// <summary>
29
+ /// Initialises a new instance of the <see cref="OnRamp"/> class.
30
+ /// </summary>
31
+ /// <param name="environment">Specifies the environment (<c>sandbox</c> or <c>production</c>).</param>
32
+ /// <param name="email">The user's email address, pre-filled in the on-ramp flow.</param>
33
+ /// <param name="address">The user's wallet address, where tokens will be sent.</param>
25
34
public OnRamp ( string environment , string email , string address )
26
35
{
27
36
_environment = environment ;
28
37
_email = email ;
29
38
_address = address ;
30
39
}
31
40
32
- public async UniTask < string > GetLink (
41
+ /// <summary>
42
+ /// Generates a link for the on-ramp flow.
43
+ /// </summary>
44
+ /// <param name="fiatCurrency">The fiat currency to be used (default is "USD").</param>
45
+ /// <param name="defaultFiatAmount">The default amount of fiat currency (default is "50").</param>
46
+ /// <param name="defaultCryptoCurrency">The default cryptocurrency (default is "IMX")..</param>
47
+ /// <param name="defaultCryptoCurrencyList">A comma-separated list of available cryptocurrencies to purchase (default is "imx,eth,usdc").</param>
48
+ /// <returns>An on-ramp URL</returns>
49
+ public string GetLink (
33
50
string fiatCurrency = "USD" ,
34
51
string defaultFiatAmount = "50" ,
35
52
string defaultCryptoCurrency = "IMX" ,
36
53
string defaultCryptoCurrencyList = "imx,eth,usdc"
37
54
)
38
55
{
39
- string baseUrl = TransakBaseUrls [ _environment ] ;
40
- string apiKey = TransakApiKeys [ _environment ] ;
56
+ var baseUrl = BaseUrls [ _environment ] ;
57
+ var apiKey = ApiKeys [ _environment ] ;
41
58
42
59
var queryParams = new Dictionary < string , string >
43
60
{
@@ -58,7 +75,7 @@ public async UniTask<string> GetLink(
58
75
{ "cryptoCurrencyList" , defaultCryptoCurrencyList }
59
76
} ;
60
77
61
- string queryString = string . Join ( "&" , queryParams . Select ( kvp => $ "{ kvp . Key } ={ Uri . EscapeDataString ( kvp . Value ) } ") . ToArray ( ) ) ;
78
+ var queryString = string . Join ( "&" , queryParams . Select ( kvp => $ "{ kvp . Key } ={ Uri . EscapeDataString ( kvp . Value ) } ") . ToArray ( ) ) ;
62
79
return $ "{ baseUrl } ?{ queryString } ";
63
80
}
64
81
}
0 commit comments