trilitech / tezos-unity-sdk

Tezos Unity SDK for developers. Discover the future of Web3 gaming.
https://tezos.com/unity
MIT License
24 stars 12 forks source link

Fix: Redundant line of code in TrackTransaction method #75

Closed umutkutlu closed 1 year ago

umutkutlu commented 1 year ago

Issue Definition

This line of code is redundant because the while loop condition already checks the success variable, and the loop will not continue if success is true.

Code Snippet

public IEnumerator TrackTransaction(string transactionHash)
{
    var success = false;
    const float timeout = 30f; // seconds
    var timestamp = Time.time;

    // keep making requests until time out or success
    while (!success && Time.time - timestamp < timeout)
    {
        if (success) break;                                                <---
        Logger.LogDebug($"Checking tx status: {transactionHash}");
        yield return TezosSingleton.Instance.GetOperationStatus(result =>
        {
            if (result != null)
                success = JsonSerializer.Deserialize<bool>(result);
        }, transactionHash);

        yield return new WaitForSecondsRealtime(3);
    }

    ContractCallInjectionResult result;
    result.success = success;
    result.transactionHash = transactionHash;
    ContractCallCompleted?.Invoke(JsonUtility.ToJson(result));
}

Additional Context

This fix will not affect the functionality of the method.