File tree 1 file changed +14
-6
lines changed
src/Packages/Marketplace/Runtime/Swap
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -38,17 +38,25 @@ public Swap(string environment)
38
38
/// <param name="fromTokenAddress">The address of the token being swapped from.</param>
39
39
/// <param name="toTokenAddress">The address of the token being swapped to.</param>
40
40
/// <returns>A swap URL</returns>
41
- public string GetLink ( string fromTokenAddress , string toTokenAddress )
41
+ public string GetLink ( string ? fromTokenAddress = null , string ? toTokenAddress = null )
42
42
{
43
43
var baseUrl = BaseUrls [ _environment ] ;
44
44
var apiKey = ApiKeys [ _environment ] ;
45
45
46
46
var queryParams = new Dictionary < string , string >
47
- {
48
- { "publishableKey" , apiKey } ,
49
- { "fromTokenAddress" , fromTokenAddress } ,
50
- { "toTokenAddress" , toTokenAddress }
51
- } ;
47
+ {
48
+ { "publishableKey" , apiKey }
49
+ } ;
50
+
51
+ if ( ! string . IsNullOrEmpty ( fromTokenAddress ) )
52
+ {
53
+ queryParams [ "fromTokenAddress" ] = fromTokenAddress ;
54
+ }
55
+
56
+ if ( ! string . IsNullOrEmpty ( toTokenAddress ) )
57
+ {
58
+ queryParams [ "toTokenAddress" ] = toTokenAddress ;
59
+ }
52
60
53
61
var queryString = string . Join ( "&" , queryParams . Select ( kvp => $ "{ kvp . Key } ={ Uri . EscapeDataString ( kvp . Value ) } ") . ToArray ( ) ) ;
54
62
return $ "{ baseUrl } ?{ queryString } ";
You can’t perform that action at this time.
0 commit comments