Skip to content

Commit ef1c8fd

Browse files
committed
feat: update swap to take in publishable key
1 parent 62db9e3 commit ef1c8fd

File tree

1 file changed

+7
-10
lines changed
  • src/Packages/Marketplace/Runtime/Swap

1 file changed

+7
-10
lines changed

src/Packages/Marketplace/Runtime/Swap/Swap.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,23 @@ namespace Immutable.Marketplace.Swap
1111
public class Swap
1212
{
1313
private readonly string _environment;
14+
private readonly string _publishableKey;
1415
private static readonly Dictionary<string, string> BaseUrls = new()
1516
{
1617
{ "sandbox", "https://checkout-playground.sandbox.immutable.com/checkout/swap" },
1718
{ "production", "https://toolkit.immutable.com/checkout/swap" }
1819
};
1920

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-
2621
/// <summary>
2722
/// Initialises a new instance of the <see cref="Swap"/> class.
2823
/// </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)
3128
{
3229
_environment = environment;
30+
_publishableKey = publishableKey;
3331
}
3432

3533
/// <summary>
@@ -41,11 +39,10 @@ public Swap(string environment)
4139
public string GetLink(string? fromTokenAddress = null, string? toTokenAddress = null)
4240
{
4341
var baseUrl = BaseUrls[_environment];
44-
var apiKey = ApiKeys[_environment];
4542

4643
var queryParams = new Dictionary<string, string>
4744
{
48-
{"publishableKey", apiKey}
45+
{"publishableKey", _publishableKey}
4946
};
5047

5148
if (!string.IsNullOrEmpty(fromTokenAddress))

0 commit comments

Comments
 (0)