Skip to content

Commit 278418d

Browse files
authored
bug fix (#821)
1 parent f69a2c3 commit 278418d

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/Stratis.Features.Unity3dApi/NFTTransferIndexer.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private async Task IndexNFTsContinuouslyAsync()
149149
List<ReceiptResponse> receipts = this.smartContractTransactionService.ReceiptSearch(
150150
contractAddr, "TransferLog", null, currentContract.LastUpdatedBlock + 1, null);
151151

152-
if (receipts == null)
152+
if ((receipts == null) || (receipts.Count == 0))
153153
continue;
154154

155155
int lastReceiptHeight = 0;
@@ -162,15 +162,16 @@ private async Task IndexNFTsContinuouslyAsync()
162162

163163
foreach (ReceiptResponse receiptRes in receipts)
164164
{
165-
string jsonLog = JsonConvert.SerializeObject(receiptRes.Logs.First().Log);
166-
167-
TransferLog infoObj = JsonConvert.DeserializeObject<TransferLog>(jsonLog);
168-
transferLogs.Add(infoObj);
165+
LogData log = receiptRes.Logs.First().Log;
166+
string jsonLog = JsonConvert.SerializeObject(log);
167+
168+
TransferLogRoot infoObj = JsonConvert.DeserializeObject<TransferLogRoot>(jsonLog);
169+
transferLogs.Add(infoObj.Data);
169170
}
170171

171172
foreach (TransferLog transferInfo in transferLogs)
172173
{
173-
if (currentContract.OwnedIDsByAddress.ContainsKey(transferInfo.From))
174+
if ((transferInfo.From != null) && currentContract.OwnedIDsByAddress.ContainsKey(transferInfo.From))
174175
{
175176
currentContract.OwnedIDsByAddress[transferInfo.From].Remove(transferInfo.TokenId);
176177

@@ -227,16 +228,23 @@ public class OwnedNFTsModel
227228
public Dictionary<string, List<long>> OwnedIDsByContractAddress { get; set; }
228229
}
229230

231+
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")]
232+
public partial class TransferLogRoot
233+
{
234+
public string Event { get; set; }
235+
public TransferLog Data { get; set; }
236+
}
237+
230238
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")]
231239
public partial class TransferLog
232240
{
233-
[JsonProperty("from", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
241+
[JsonProperty("From", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
234242
public string From { get; set; }
235243

236-
[JsonProperty("to", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
244+
[JsonProperty("To", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
237245
public string To { get; set; }
238246

239-
[JsonProperty("tokenId", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
247+
[JsonProperty("TokenId", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
240248
public long TokenId { get; set; }
241249
}
242250
}

0 commit comments

Comments
 (0)