@@ -11,25 +11,23 @@ namespace Immutable.Marketplace.Swap
11
11
public class Swap
12
12
{
13
13
private readonly string _environment ;
14
+ private readonly string _publishableKey ;
14
15
private static readonly Dictionary < string , string > BaseUrls = new ( )
15
16
{
16
17
{ "sandbox" , "https://checkout-playground.sandbox.immutable.com/checkout/swap" } ,
17
18
{ "production" , "https://toolkit.immutable.com/checkout/swap" }
18
19
} ;
19
20
20
- private static readonly Dictionary < string , string > ApiKeys = new ( )
21
- {
22
- { "sandbox" , "pk_imapik-test-7-hfC5T$W$eEDE8Mc5mp" } , // This can be hardcoded as it is a public API key
23
- { "production" , "pk_imapik-WGd9orNd8mLdtTCTb3CP" }
24
- } ;
25
-
26
21
/// <summary>
27
22
/// Initialises a new instance of the <see cref="Swap"/> class.
28
23
/// </summary>
29
- /// <param name="environment">Specifies the environment (<c>sandbox</c> or <c>production</c>).</param>
30
- public Swap ( string environment )
24
+ /// <param name="environment">The environment to use (<c>sandbox</c> or <c>production</c>).</param>
25
+ /// <param name="publishableKey">The publishable key obtained from <a href="https://hub.immutable.com/">Immutable Hub</a>.
26
+ /// See <a href="https://docs.immutable.com/api/zkEVM/apikeys">API keys</a> for more details.</param>
27
+ public Swap ( string environment , string publishableKey )
31
28
{
32
29
_environment = environment ;
30
+ _publishableKey = publishableKey ;
33
31
}
34
32
35
33
/// <summary>
@@ -41,11 +39,10 @@ public Swap(string environment)
41
39
public string GetLink ( string ? fromTokenAddress = null , string ? toTokenAddress = null )
42
40
{
43
41
var baseUrl = BaseUrls [ _environment ] ;
44
- var apiKey = ApiKeys [ _environment ] ;
45
42
46
43
var queryParams = new Dictionary < string , string >
47
44
{
48
- { "publishableKey" , apiKey }
45
+ { "publishableKey" , _publishableKey }
49
46
} ;
50
47
51
48
if ( ! string . IsNullOrEmpty ( fromTokenAddress ) )
0 commit comments