Hashgraph
Hashgraph copied to clipboard
Bug in NetworkResult.ToRecord()
As coded NeworkResult.ToRecord() fails when fetching a record for a smart contract call because it is processed as a smart contract create. The fix is:
internal TransactionRecord ToRecord() { if (Receipt.AccountID != null) { return new CreateAccountRecord(this); } else if (Receipt.FileID != null) { return new FileRecord(this); } else if (Receipt.TopicID != null) { return new CreateTopicRecord(this); } // Need to check for Contract calls before Contract creates // // Move this case up from commented out below and add additional check for a Record?ContractCallResult // Otherwise the next else if case will process as a CreateContractRecord // // *** NOTE: May need a similar fix in the Network.Result.ToReceipt() method // else if (Receipt.ContractID != null && Record?.ContractCallResult != null) { return new CallContractRecord(this); } else if (Receipt.ContractID != null) { return new CreateContractRecord(this); } else if (Receipt.TokenID != null) { return new CreateTokenRecord(this); } else if (!Receipt.TopicRunningHash.IsEmpty) { return new SubmitMessageRecord(this); } else if (Receipt.SerialNumbers != null && Receipt.SerialNumbers.Count > 0) { return new AssetMintRecord(this); } else if (Receipt.NewTotalSupply != 0) { return new TokenRecord(this); } //else if (Record?.ContractCallResult != null) //{ // return new CallContractRecord(this); //} else { return new TransactionRecord(this); } }