Skip to content

Commit bfcb921

Browse files
Enhance/improve nft loading & bug fixes (#131)
* ⚡ Notify when total nfts = 0 * 🐛 Fix loading nfts * 🔖 Bump version to v0.1.5
1 parent 083c9f9 commit bfcb921

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

Packages/Solana.Unity.Metaplex.dll

-2 KB
Binary file not shown.

Packages/Solana.Unity.Rpc.dll

512 Bytes
Binary file not shown.

Runtime/codebase/WalletBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,11 @@ private IRpcClient StartConnection()
318318
{
319319
if (_activeRpcClient == null && CustomRpcUri.IsNullOrEmpty())
320320
{
321-
_activeRpcClient = ClientFactory.GetClient(_rpcClusterMap[(int)RpcCluster], logger: true);
321+
_activeRpcClient = ClientFactory.GetClient(_rpcClusterMap[(int)RpcCluster]);
322322
}
323323
if (_activeRpcClient == null && !CustomRpcUri.IsNullOrEmpty())
324324
{
325-
_activeRpcClient = ClientFactory.GetClient(CustomRpcUri, logger: true);
325+
_activeRpcClient = ClientFactory.GetClient(CustomRpcUri);
326326
}
327327

328328
return _activeRpcClient;
@@ -349,7 +349,7 @@ private IStreamingRpcClient StartStreamingConnection()
349349
if (CustomStreamingRpcUri != null)
350350
{
351351
_webSocketConnection = new TaskCompletionSource<object>();
352-
_activeStreamingRpcClient = ClientFactory.GetStreamingClient(CustomStreamingRpcUri, true);
352+
_activeStreamingRpcClient = ClientFactory.GetStreamingClient(CustomStreamingRpcUri);
353353
_activeStreamingRpcClient
354354
.ConnectAsync()
355355
.AsUniTask()

Runtime/codebase/Web3.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,24 +348,27 @@ public static async UniTask UpdateNFTs(Commitment commitment = Commitment.Confir
348348
.Select(x => x.First())
349349
.ToList()
350350
.FindAll(x => x.metaplexData.data.offchainData != null);
351-
351+
352352
// Fetch nfts
353353
List<UniTask> loadingTasks = new List<UniTask>();
354354
List<Nft.Nft> nfts = new List<Nft.Nft>(_nfts);
355+
356+
var total = 0;
355357
if (tokens is {Count: > 0})
356358
{
357359
var toFetch = tokens
358360
.Where(item => item.Account.Data.Parsed.Info.TokenAmount.AmountUlong == 1)
359361
.Where(item => nfts
360362
.All(t => t.metaplexData.data.mint!= item.Account.Data.Parsed.Info.Mint)).ToArray();
361-
var total = nfts.Count + toFetch.Length;
363+
total = nfts.Count + toFetch.Length;
364+
362365
foreach (var item in toFetch)
363366
{
364367
var tNft = Nft.Nft.TryGetNftData(item.Account.Data.Parsed.Info.Mint, Rpc, loadTexture: loadTexture).AsUniTask();
365368
loadingTasks.Add(tNft);
366369
tNft.ContinueWith(nft =>
367370
{
368-
if(nft == null) {
371+
if(tNft.AsTask().Exception != null || nft == null) {
369372
total--;
370373
return;
371374
}
@@ -376,6 +379,7 @@ public static async UniTask UpdateNFTs(Commitment commitment = Commitment.Confir
376379
}
377380
}
378381
await UniTask.WhenAll(loadingTasks);
382+
if(total == 0) OnNFTsUpdateInternal?.Invoke(nfts, total);
379383
_nfts = nfts;
380384
return nfts;
381385
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.solana.unity_sdk",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"unity": "2019.4",
55
"displayName": "Solana SDK",
66
"description": "Open-Source Unity-Solana SDK with Full RPC coverage, NFT support and more",

0 commit comments

Comments
 (0)