Skip to content

Commit

Permalink
feat: Solana support for NFTs of a contract
Browse files Browse the repository at this point in the history
  • Loading branch information
saszer committed Aug 17, 2022
1 parent ae0420d commit 8561f5d
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions Runtime/NFTs_OfAContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public enum Chains
{
ethereum,
polygon,
rinkeby
rinkeby,
solana
}

public enum Includes
Expand All @@ -46,9 +47,10 @@ public enum Includes
[Tooltip("default is the default response, metadata includes NFT metadata and cached_file_url, and all includes extra information like file_information and mint_date in Retrieve NFT details.")]
[SerializeField]
Includes include = Includes.all;

[Tooltip("One API call might not be able to provide all NFTs in one go if user holds a lot of NFTs and not filtered, this string is passed in API call which can be used in next one to continue from last query")]
public string continuation;

[Tooltip(
"One API call might not be able to provide all NFTs in one go if user holds a lot of NFTs and not filtered, this string is passed in API call which can be used in next one to continue from last query")]
public string continuation = "";


private string RequestUriInit = "https://api.nftport.xyz/v0/nfts/";
Expand Down Expand Up @@ -153,7 +155,7 @@ public NFTs_OfAContract OnComplete(UnityAction<NFTs_model> action)
/// <summary>
/// Set Continuation
/// </summary>
///<param name="continuation"> as string.</param>
///<param name="continuation"> page number as int.</param>
public NFTs_OfAContract SetContinuation(string continuation)
{
this.continuation = continuation;
Expand Down Expand Up @@ -188,12 +190,27 @@ public NFTs_model Run()

string BuildUrl()
{
WEB_URL = RequestUriInit + contract_address + "?chain=" + chain.ToString().ToLower();
if (continuation != "")
if (chain == Chains.solana)
{
WEB_URL = WEB_URL + "&continuation=" + continuation;
WEB_URL = "https://api.nftport.xyz/v0/solana/nfts/" + contract_address;
if (continuation != "")
{
WEB_URL = WEB_URL + "?page_number=" + continuation.ToString() + "&include=" + include.ToString().ToLower();;
}
else
{
WEB_URL += "?include=" + include.ToString().ToLower();
}
}
else
{
WEB_URL = RequestUriInit + contract_address + "?chain=" + chain.ToString().ToLower();
if (continuation != "")
{
WEB_URL = WEB_URL + "&page_number=" + continuation.ToString();
}
WEB_URL = WEB_URL + "&include=" + include.ToString().ToLower();
}
WEB_URL = WEB_URL + "&include=" + include.ToString().ToLower();
return WEB_URL;
}

Expand Down

0 comments on commit 8561f5d

Please sign in to comment.