Beispiel #1
0
    public void LoadSavedExpressionSets(List <ExpressionSet> expressionSets)
    {
        List <ExpressionSet> ess = new List <ExpressionSet>();

        for (int i = 0; i < expressionSets.Count; i++)
        {
            ess.Add(expressionSets[i].DeepCopy());
            ess[ess.Count - 1].CompileAll();
        }

        //var expression = new Dictionary<string, object>();
        var expressionString = "";

        foreach (var es in ess)
        {
            foreach (var e in es.expressions)
            {
                expressionString += e.Value.AKExpression.ToString() + "\n";
            }
        }
        //expression["expression"] = expressionString;
        StatisticsTracking.InstantEvent("Load Expression", expressionString);

        paramSurface.expressionSets = ess;
        pieceWiseControl.ForceNumberOfTabs(ess.Count);
        expressionSet = paramSurface.expressionSets[0];
        calcInput.ChangeOutput(expressionSet.expressions["X"]);
        if (boundsManager != null)
        {
            boundsManager.UpdateButtonText();
        }
        inputReceived = true;
    }
Beispiel #2
0
 protected void OnApplicationQuit()
 {
     StatisticsTracking.InstantEvent("Average Size", gameObject.name, new Dictionary <string, object>()
     {
         { "Size", average }
     });
 }
Beispiel #3
0
    public bool CompileAll()
    {
        bool isValid = true;

        foreach (string RO in ranges.Keys)
        {
            solver.SetGlobalVariable(RO, -666);
            ranges[RO].Min.compileTokens();
            expValidity[RO] = ranges[RO].Min.GenerateAKSolver(solver);
            ranges[RO].Max.compileTokens();
            expValidity[RO] &= ranges[RO].Max.GenerateAKSolver(solver);
            isValid         &= expValidity[RO];
        }
        foreach (string EX in expressions.Keys)
        {
            expressions[EX].compileTokens();
            expValidity[EX.ToString()] = expressions[EX].GenerateAKSolver(solver);
            isValid &= expValidity[EX.ToString()];
        }
        StatisticsTracking.InstantEvent("Expression Value", "Value Updated", new Dictionary <string, object>()
        {
            { "valid", isValid }
        });
        return(isValid);
    }
Beispiel #4
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     StatisticsTracking.InstantEvent("Average Size", gameObject.name, new Dictionary <string, object>()
     {
         { "Size", average }
     });
 }
    public void TakeInput()
    {
        if (!ValidateInputs())
        {
            return;
        }

        InvalidText.gameObject.SetActive(false);

        BigInteger bounty   = new BigInteger(Bounty.CurrentValue) * new BigInteger(1e18);
        BigInteger entryFee = new BigInteger(EntryFee.CurrentValue) * new BigInteger(1e18);

        double start    = Utils.Time.ToUnixTime(startDatePicker.fecha);
        double end      = Utils.Time.ToUnixTime(endDatePicker.fecha);
        double duration = (endDatePicker.fecha - startDatePicker.fecha).TotalSeconds;

        MatryxRound.RoundDetails roundDetails = new MatryxRound.RoundDetails()
        {
            Start    = new BigInteger(start),
            Duration = new BigInteger(duration),
            Bounty   = bounty,
            Review   = 60 * 60 * 24 * 14
        };
        MatryxTournament tournament = new MatryxTournament(Title.text, Description.text, null, "math", bounty, entryFee, roundDetails);

        resultsMenu.GetComponent <ResultsMenu>().Start();

        Async.runInCoroutine(delegate(Async thread, object param)
        {
            return(tournament.create(delegate(object result)
            {
                // Check success
                if ((bool)result)
                {
                    StatisticsTracking.EndEvent("Matryx", "Tournament Creation");
                    ResultsMenu.Instance.PostSuccess(tournament,
                                                     (nothin) =>
                    {
                        Instance.ClearInputs(true);
                        TournamentsMenu.Instance.ReloadTournaments(0);
                    }
                                                     );
                }
                else
                {
                    ResultsMenu.Instance.PostFailure(tournament);
                }
            }));
        });

        this.gameObject.SetActive(false);
        resultsMenu.SetActive(true);
    }
    public void MakeSubmission()
    {
        var title = TitleField.text;

        if (!TitleField.gameObject.GetComponent <InputValidator>().isValid)
        {
            InvalidLabel.gameObject.SetActive(true);
            return;
        }

        this.gameObject.SetActive(false);
        InvalidLabel.gameObject.SetActive(false);

        var submission = new MatryxSubmission(tournament, title, "", DescriptionField.text, SerializeSurface(), Convert.ToInt32(ValueField.text));

        clearInputs();

        resultsCanvasObject.SetActive(true);
        gameObject.SetActive(false);
        Async.runInCoroutine(delegate(Async thread, object param)
        {
            return(submission.submit(delegate(object result)
            {
                // Debug
                Debug.Log("Submission uploaded");
                Debug.Log(result);
                // Check success
                if ((bool)result)
                {
                    StatisticsTracking.EndEvent("Matryx", "Submission Creation");
                    ResultsMenu.Instance.PostSuccess(submission,
                                                     (nothin) =>
                    {
                        TournamentMenu.Instance.ReloadSubmissions(3f);
                    }
                                                     );
                }
                else
                {
                    ResultsMenu.Instance.PostFailure(submission);
                }
            }));
        });
    }
Beispiel #7
0
 protected override void FixedUpdate()
 {
     base.FixedUpdate();
     if (count == uint.MaxValue)
     {
         count = 1;
         StatisticsTracking.InstantEvent("Average Size", gameObject.name, new Dictionary <string, object>()
         {
             { "Size", average }
         });
     }
     if (skipCount++ >= skip)
     {
         skipCount = 0;
         float weight = 1f / count;
         average = (average + transform.localScale * weight) / (1 + weight);
         count++;
     }
 }
Beispiel #8
0
        public virtual void UnpressButton(GameObject other)
        {
#if UNITY_EDITOR
            if (verbose)
            {
                print("button released");
            }
#endif
            if (OnButtonExit != null)
            {
                OnButtonExit.Invoke(other);
            }

            string eventName = gameObject.name;
            if (!eventName.Equals("Body"))
            {
                StatisticsTracking.EndEvent("Button Press", eventName);
            }
        }
Beispiel #9
0
        public virtual void PressButton(GameObject other)
        {
#if UNITY_EDITOR
            if (verbose)
            {
                print("button pressed");
            }
#endif
            if (OnButtonEnter != null)
            {
                OnButtonEnter.Invoke(other);
            }

            string eventName = gameObject.name;
            var    extra     = new Dictionary <string, object>();
            extra["parent"] = gameObject.transform.parent.name;
            if (!eventName.Equals("Body"))
            {
                StatisticsTracking.StartEvent("Button Press", eventName, extra);
            }
        }
Beispiel #10
0
    void OnEnable()
    {
        StatisticsTracking.StartEvent("Tool Switching", "To Drawing Tool");

        leftController.components[ButtonId.TRIGGER].ComponentPressing  += startDrawing;
        leftController.components[ButtonId.TRIGGER].ComponentUnpressed += stopDrawing;
        leftController.components[ButtonId.GRIP].ComponentPressed      += startErasing;
        leftController.components[ButtonId.GRIP].ComponentPressing     += startErasing;
        leftController.components[ButtonId.GRIP].ComponentUnpressed    += stopErasing;

        rightController.components[ButtonId.TRIGGER].ComponentPressing  += startDrawing;
        rightController.components[ButtonId.TRIGGER].ComponentUnpressed += stopDrawing;
        rightController.components[ButtonId.GRIP].ComponentPressed      += startErasing;
        rightController.components[ButtonId.GRIP].ComponentPressing     += startErasing;
        rightController.components[ButtonId.GRIP].ComponentUnpressed    += stopErasing;

        leftController.transform.Find("Pen").gameObject.SetActive(true);
        rightController.transform.Find("Pen").gameObject.SetActive(true);

        leftController.transform.Find("Controller (right)").Find("PenLabel").gameObject.SetActive(true);
        rightController.transform.Find("Controller (left)").Find("PenLabel").gameObject.SetActive(true);
    }
Beispiel #11
0
 protected override void StateChanged(int _old, int _new, GameObject source = null)
 {
     if (_new == -1)
     {
         transform.Find("Body").GetComponent <Renderer>().material.color = disabledColor;
     }
     else if (_new == 1)
     {
         transform.Find("Body").GetComponent <Renderer>().material.color = hoveringColor;
         string eventName = "Unknown";
         if (gameObject != null)
         {
             eventName = gameObject.name;
         }
         if (!eventName.Equals("Body"))
         {
             StatisticsTracking.StartEvent("Button Hover", eventName);
         }
     }
     else if (_new == 2)
     {
         transform.Find("Body").GetComponent <Renderer>().material.color = selectedColor;
     }
     else
     {
         transform.Find("Body").GetComponent <Renderer>().material.color = passiveColor;
         string eventName = "Unknown";
         if (gameObject != null)
         {
             eventName = gameObject.name;
         }
         if (!eventName.Equals("Body") && _old == 1)
         {
             StatisticsTracking.EndEvent("Button Hover", eventName);
         }
     }
 }
    public void FireSelectWinners()
    {
        Async.runInCoroutine(delegate(Async thread, object param)
        {
            var submissions = winningSubmissions.Select(sub => Utils.HexStringToByteArray(sub.hash)).ToList();
            return(TournamentMenu.Tournament.selectWinners(submissions, distribution, new BigInteger((int)MatryxTournament.SelectWinnerAction.DoNothing), BigInteger.Zero, BigInteger.Zero, BigInteger.Zero, BigInteger.Zero,
                                                           delegate(object result)
            {
                Debug.Log((bool)result ? "Successfully selected winners!" : "Winner selection unsuccessful.");
                SpinForTheWin(false);
                SetButtonsEnabled(true);
                PressButton("WinnersOnlyButton");
                if ((bool)result)
                {
                    StatisticsTracking.EndEvent("Matryx", "Winner Selection Only", new Dictionary <string, object>()
                    {
                        { "success", true }
                    });
                    Tippies.SpawnTippy("Winner Selection Transaction Successful", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 5f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true);
                    TournamentMenu.Tournament.currentRound.winningSubmissions = winningSubmissions;
                    TournamentMenu.Instance.ProcessRound(TournamentMenu.Tournament.currentRound);
                    Close();

                    TournamentMenu.Instance.actionState = TournamentMenu.ActionState.ManageTournament;
                    TournamentMenuCenterButton.Instance.updateState();
                }
                else
                {
                    StatisticsTracking.EndEvent("Matryx", "Winner Selection Only", new Dictionary <string, object>()
                    {
                        { "success", false }
                    });
                    Tippies.SpawnTippy("Winner Selection Transaction Failed", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 15f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true);
                }
            }));
        });
    }
Beispiel #13
0
        public IEnumerator submit(Async.EventDelegate callback = null)
        {
            StatisticsTracking.StartEvent("Matryx", "Submission Creation");

            ResultsMenu.transactionObject = this;
            var isEntrant = new Utils.CoroutineWithData <EthereumTypes.Bool>(MatryxCortex.Instance, tournament.isEntrant(NetworkSettings.currentAddress));

            yield return(isEntrant);

            var tournamentInfo = new Utils.CoroutineWithData <TournamentInfo>(MatryxCortex.Instance, tournament.getInfo());

            yield return(tournamentInfo);

            if (tournament.owner.Equals(NetworkSettings.currentAddress, System.StringComparison.CurrentCultureIgnoreCase))
            {
                ResultsMenu.Instance.PostFailure(this, "You own this tournament; Unable to create submission.");
                yield break;
            }

            if (!isEntrant.result.Value)
            {
                var allowance = new Utils.CoroutineWithData <BigInteger>(MatryxCortex.Instance, MatryxToken.allowance(NetworkSettings.currentAddress, MatryxPlatform.address));
                yield return(allowance);

                var balance = new Utils.CoroutineWithData <BigInteger>(MatryxCortex.Instance, MatryxToken.balanceOf(NetworkSettings.currentAddress));
                yield return(balance);

                if (balance.result < tournament.entryFee)
                {
                    ResultsMenu.Instance.SetStatus("Insufficient MTX. Please visit <link=https://app.matryx.ai/><u>our Matryx Dapp</u></link> for MTX Tokens.", true);
                    yield break;
                }

                if (allowance.result < tournament.entryFee)
                {
                    ResultsMenu.Instance.SetStatus("Approving entry fee...");

                    if (allowance.result != BigInteger.Zero)
                    {
                        var approveZero = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, MatryxToken.approve(MatryxPlatform.address, BigInteger.Zero));
                        yield return(approveZero);

                        if (!approveZero.result)
                        {
                            Debug.Log("Failed to reset tournament's allowance to zero for this user. Please check the allowance this user has granted the tournament");
                            ResultsMenu.Instance.PostFailure(this);
                            yield break;
                        }
                    }

                    var approveEntryFee = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, MatryxToken.approve(MatryxPlatform.address, tournament.entryFee));
                    yield return(approveEntryFee);

                    if (!approveEntryFee.result)
                    {
                        Debug.Log("Failed to set the tournament's allowance from this user to the tournament's entry fee");
                        ResultsMenu.Instance.PostFailure(this);
                        yield break;
                    }
                }

                ResultsMenu.Instance.SetStatus("Entering Tournament...");

                var enterTournament = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, tournament.enter());
                yield return(enterTournament);

                if (!enterTournament.result)
                {
                    Debug.Log("Failed to enter tournament");
                    ResultsMenu.Instance.PostFailure(this);
                    yield break;
                }
            }

            ResultsMenu.Instance.SetStatus("Claiming Content...");
            bool shouldBreak = false;

            yield return(commit.claim((res) => { },
                                      (nada) =>
            {
                ResultsMenu.Instance.PostFailure(this, "Could not claim your content on Matryx...");
                shouldBreak = true;
            }));

            if (shouldBreak)
            {
                yield break;
            }

            ResultsMenu.Instance.SetStatus("Hashing to Matryx...");
            yield return(commit.create());

            ResultsMenu.Instance.SetStatus("Uploading submission content...");
            yield return(uploadContent());

            if (!dto.Content.Contains("Qm"))
            {
                Debug.Log("Failed to upload file to IPFS");
                ResultsMenu.Instance.PostFailure(this);
                yield break;
            }

            ResultsMenu.Instance.SetStatus("Creating Submission in Matryx...");
            var createSubmission = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, tournament.createSubmission(this));

            yield return(createSubmission);

            callback?.Invoke(createSubmission.result);

            if (!createSubmission.result)
            {
                Debug.Log("Failed to create submission");
                yield break;
            }
        }
        //function createSubmission(string calldata content, bytes32 commitHash) external;
        public IEnumerator create(Async.EventDelegate callback = null)
        {
            StatisticsTracking.StartEvent("Matryx", "Tournament Creation");

            ResultsMenu.transactionObject = this;
            ResultsMenu.Instance.SetStatus("Checking MTX balance and platform allowance...");

            var allowance = new Utils.CoroutineWithData <BigInteger>(MatryxCortex.Instance, MatryxToken.allowance(NetworkSettings.currentAddress, MatryxPlatform.address));

            yield return(allowance);

            var balance = new Utils.CoroutineWithData <BigInteger>(MatryxCortex.Instance, MatryxToken.balanceOf(NetworkSettings.currentAddress));

            yield return(balance);

            if (balance.result < bounty)
            {
                ResultsMenu.Instance.SetStatus("Insufficient MTX. Please visit <link=https://app.matryx.ai/><u>our Matryx Dapp</u></link> for MTX Tokens.", true);
                ResultsMenu.Instance.ReturnToCalcflowAfterSeconds(8f);
                yield break;
            }

            if (allowance.result < bounty)
            {
                ResultsMenu.Instance.SetStatus("Approving MatryxPlatform for " + Bounty + " MTX...");

                if (allowance.result != BigInteger.Zero)
                {
                    var approveZero = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, MatryxToken.approve(MatryxPlatform.address, BigInteger.Zero));
                    yield return(approveZero);

                    if (!approveZero.result)
                    {
                        ResultsMenu.Instance.PostFailure(this, "Failed to reset the platform allowance to zero");
                        yield break;
                    }
                }

                var approveBounty = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, MatryxToken.approve(MatryxPlatform.address, bounty));
                yield return(approveBounty);

                if (!approveBounty.result)
                {
                    ResultsMenu.Instance.PostFailure(this, "Failed to give the platform an MTX allowance");
                    yield break;
                }
            }

            if (contentHash.Equals(""))
            {
                ResultsMenu.Instance.SetStatus("Uploading Tournament Content...");
                var uploadToIPFS = new Utils.CoroutineWithData <string[]>(MatryxCortex.Instance, uploadContent());
                yield return(uploadToIPFS);

                if (!uploadToIPFS.result[0].Equals(string.Empty))
                {
                    contentHash = uploadToIPFS.result[0];
                }
                if (!uploadToIPFS.result[1].Equals(string.Empty))
                {
                    fileHash = uploadToIPFS.result[1];
                }
            }

            ResultsMenu.Instance.SetStatus("Creating Tournament " + title + "...");
            var createTournament = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, MatryxPlatform.createTournament(this));

            yield return(createTournament);

            callback?.Invoke(createTournament.result);
        }
    public void FireCloseTournament()
    {
        if (TournamentMenu.Tournament.currentRound.winningSubmissions.Count == 0)
        {
            Async.runInCoroutine(delegate(Async thread, object param)
            {
                var submissions = winningSubmissions.Select(sub => Utils.HexStringToByteArray(sub.hash)).ToList();
                return(TournamentMenu.Tournament.selectWinners(submissions, distribution, new BigInteger((int)MatryxTournament.SelectWinnerAction.CloseTournament), BigInteger.Zero, BigInteger.Zero, BigInteger.Zero, BigInteger.Zero,
                                                               delegate(object result)
                {
                    Debug.Log((bool)result ? "Successfully closed the tournament!" : "Close tournament unsuccessful.");
                    SpinForTheClose(false);
                    PressButton("CloseTournamentButton");
                    if ((bool)result)
                    {
                        StatisticsTracking.EndEvent("Matryx", "Winner Selection & Tournament Close", new Dictionary <string, object>()
                        {
                            { "success", true }
                        });
                        Tippies.SpawnTippy("Close Tournament Transaction Successful", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 5f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true);
                        Close();

                        TournamentMenu.Instance.actionState = TournamentMenu.ActionState.NoAction;
                        TournamentMenuCenterButton.Instance.updateState();
                    }
                    else
                    {
                        StatisticsTracking.EndEvent("Matryx", "Winner Selection Only", new Dictionary <string, object>()
                        {
                            { "success", false }
                        });
                        Tippies.SpawnTippy("Close Tournament Transaction Failed", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 15f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true);
                    }
                }));
            });
        }
        else
        {
            Async.runInCoroutine(delegate(Async thread, object param)
            {
                var submissions = winningSubmissions.Select(sub => Utils.HexStringToByteArray(sub.hash)).ToList();
                return(TournamentMenu.Tournament.closeTournament(
                           delegate(object result)
                {
                    Debug.Log((bool)result ? "Successfully closed the tournament!" : "Close tournament unsuccessful.");
                    SetButtonsEnabled(true);
                    SpinForTheClose(false);
                    if ((bool)result)
                    {
                        StatisticsTracking.EndEvent("Matryx", "Tournament Close Only", new Dictionary <string, object>()
                        {
                            { "success", true }
                        });
                        Tippies.SpawnTippy("Close Tournament Transaction Successful", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 5f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true);
                        buttons["CloseButton"].transform.Find("Body").GetComponent <RayCastButton>().PressButton(null);
                        Close();

                        TournamentMenu.Instance.actionState = TournamentMenu.ActionState.NoAction;
                        TournamentMenuCenterButton.Instance.updateState();
                    }
                    else
                    {
                        StatisticsTracking.EndEvent("Matryx", "Tournament Close Only", new Dictionary <string, object>()
                        {
                            { "success", false }
                        });
                        Tippies.SpawnTippy("Close Tournament Transaction Failed", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 15f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true);
                    }
                }));
            });
        }
    }
Beispiel #16
0
        IEnumerator InitRoutine()
        {
            // instantiate platform contract
            using (WWW www = new WWW(latestPlatformInfoEndpt))
            {
                yield return(www);

                var jsonObj = serializer.Deserialize <object>(www.bytes) as Dictionary <string, object>;

                var platformAbi = Encoding.UTF8.GetString(serializer.Serialize(jsonObj["abi"]));
                platformAddress  = jsonObj["address"] as string;
                platformContract = new Contract(null, platformAbi, platformAddress);
            }

            // instantiate token contract
            using (WWW www2 = new WWW(latestTokenInfoEndpt))
            {
                yield return(www2);

                var tokenJsonObj = serializer.Deserialize <object>(www2.bytes) as Dictionary <string, object>;
                var tokenAddress = tokenJsonObj["address"] as string;

                var tokenAbi = Encoding.UTF8.GetString(serializer.Serialize(tokenJsonObj["abi"]));
                tokenContract = new Contract(null, tokenAbi, tokenAddress);
            }

            // instantiate tournament contract (without address)
            using (WWW www3 = new WWW(latestTournamentAbiEndpt))
            {
                yield return(www3);

                var tournyJsonObj = serializer.Deserialize <object>(www3.bytes) as Dictionary <string, object>;
                tournamentAbi = Encoding.UTF8.GetString(serializer.Serialize(tournyJsonObj["abi"]));
                //var tournamentAbi = Encoding.UTF8.GetString(serializer.Serialize(tournyJsonObj["abi"]));
            }

            // Get accounts
            var requestAccounts = new EthAccountsUnityRequest(mtxNode);

            yield return(requestAccounts.SendRequest());

            var resultsAccounts = requestAccounts.Result;

            if (resultsAccounts != null && resultsAccounts[0] != null)
            {
                StatisticsTracking.InstantEvent("Matryx Init", "Eth Node", new Dictionary <string, object>()
                {
                    { "Node Found", true },
                });

                var usedAccount = resultsAccounts[0];
                Debug.Log("Used account:" + usedAccount);
                var function         = platformContract.GetFunction("prepareBalance");
                var transactionInput = function.CreateTransactionInput(usedAccount, (long)42);
                transactionInput.Gas = new HexBigInteger(3000000);
                // Do request
                var requestTransaction = new EthSendTransactionUnityRequest(customRPCNode);
                yield return(requestTransaction.SendRequest(transactionInput));

                var resultsTransaction = requestTransaction.Result;
            }
            else
            {
                StatisticsTracking.InstantEvent("Matryx Init", "Eth Node", new Dictionary <string, object>()
                {
                    { "Node Found", false },
                });
            }
        }
Beispiel #17
0
    public IEnumerator runCreateRound()
    {
        InvalidLabel.gameObject.SetActive(false);

        if (!InputsValid().Equals(string.Empty))
        {
            yield break;
        }

        gameObject.SetActive(false);
        InvalidLabel.gameObject.SetActive(false);

        resultsCanvasObject.SetActive(true);

        var start          = new BigInteger(Utils.Time.ToUnixTime(startDatePicker.fecha));
        var duration       = new BigInteger((endDatePicker.fecha - startDatePicker.fecha).TotalSeconds);
        var reviewDuration = new BigInteger((reviewEndDatePicker.fecha - endDatePicker.fecha).TotalSeconds);
        var bounty         = new BigInteger(Convert.ToDecimal(bountyPicker.CurrentValue));

        MatryxRound.RoundDetails details = new MatryxRound.RoundDetails()
        {
            Start    = start,
            Duration = duration,
            Review   = reviewDuration,
            Bounty   = bounty * new BigInteger(1e18)
        };
        MatryxRound newRound = new MatryxRound(tournament.currentRound.index + 1, details);

        newRound.tournament = TournamentMenu.Tournament;

        ManageTournamentMenu.SetButtonsEnabled(false);

        resultsMenu.SetStatus("Checking MTX balance and platform allowance...");
        var allowance = new Utils.CoroutineWithData <BigInteger>(MatryxCortex.Instance, MatryxToken.allowance(NetworkSettings.currentAddress, MatryxPlatform.address));

        yield return(allowance);

        var balance = new Utils.CoroutineWithData <BigInteger>(MatryxCortex.Instance, MatryxToken.balanceOf(NetworkSettings.currentAddress));

        yield return(balance);

        if (balance.result < details.Bounty)
        {
            ResultsMenu.Instance.SetStatus("Insufficient MTX. Please visit <link=https://app.matryx.ai/><u>our Matryx Dapp</u></link> for MTX Tokens.", true);
            ResultsMenu.Instance.ReturnToCalcflowAfterSeconds(8f);
            yield break;
        }

        if (allowance.result < details.Bounty)
        {
            ResultsMenu.Instance.SetStatus("Approving MatryxPlatform for " + bounty + " MTX...");

            if (allowance.result != BigInteger.Zero)
            {
                var approveZero = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, MatryxToken.approve(MatryxPlatform.address, BigInteger.Zero));
                yield return(approveZero);

                if (!approveZero.result)
                {
                    resultsMenu.PostFailure(newRound, "Failed to reset the platform allowance to zero");
                    yield break;
                }
            }

            var approveBounty = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, MatryxToken.approve(MatryxPlatform.address, details.Bounty));
            yield return(approveBounty);

            if (!approveBounty.result)
            {
                resultsMenu.PostFailure(newRound, "Failed to give the platform an MTX allowance");
                yield break;
            }
        }

        resultsMenu.SetStatus("Adding to Tournament bounty...");
        var addToBountyCoroutine = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, TournamentMenu.Tournament.addToBounty(details.Bounty));

        yield return(addToBountyCoroutine);

        if (!addToBountyCoroutine.result)
        {
            resultsMenu.PostFailure(newRound, "Could not add to tournament bounty");
            yield break;
        }

        resultsMenu.SetStatus("Creating new round...");
        var submissions = ManageTournamentMenu.winningSubmissions.Select(sub => Utils.HexStringToByteArray(sub.hash)).ToList();

        if (TournamentMenu.Tournament.currentRound.winningSubmissions.Count == 0)
        {
            IEnumerator selectWinnersCoroutine     = tournament.selectWinners(submissions, ManageTournamentMenu.distribution, new BigInteger((int)MatryxTournament.SelectWinnerAction.StartNextRound), details.Start, details.Duration, details.Review, details.Bounty);
            var         selectWinnersDataCoroutine = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, selectWinnersCoroutine);
            yield return(selectWinnersDataCoroutine);

            ClearInputs();
            gameObject.SetActive(false);
            ManageTournamentMenu.SetButtonsEnabled(true);
            ManageTournamentMenu.Instance.PressButton("NewRoundButton");
            ResultsMenu.transactionObject = newRound;
            Debug.Log((bool)selectWinnersDataCoroutine.result ? "Successfully created new round!" : "Round creation unsuccessful.");

            if (selectWinnersDataCoroutine.result)
            {
                StatisticsTracking.EndEvent("Matryx", "New Round Creation", new Dictionary <string, object>()
                {
                    { "success", true }
                });
                tournament.currentRound = newRound;
                resultsMenu.PostSuccess(newRound,
                                        delegate(object nothin)
                {
                    TournamentMenu.Instance.SetRound(newRound.index);
                    TournamentMenu.Instance.UpdateActionState();
                    ManageTournamentMenu.Close();

                    TournamentMenu.Instance.actionState = TournamentMenu.ActionState.NoAction;
                    TournamentMenuCenterButton.Instance.updateState();
                });
            }
            else
            {
                StatisticsTracking.EndEvent("Matryx", "New Round Creation", new Dictionary <string, object>()
                {
                    { "success", false }
                });
                resultsMenu.PostFailure(newRound, "Failed to create new round");
            }
        }
        else
        {
            resultsMenu.SetStatus("Updating next round...");
            IEnumerator updateNextRoundCoroutine     = tournament.updateNextRound(details);
            var         updateNextRoundDataCoroutine = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, updateNextRoundCoroutine);
            yield return(updateNextRoundDataCoroutine);

            ClearInputs();
            gameObject.SetActive(false);
            ManageTournamentMenu.SetButtonsEnabled(true);
            ManageTournamentMenu.Instance.PressButton("NewRoundButton");

            if (updateNextRoundDataCoroutine.result)
            {
                StatisticsTracking.EndEvent("Matryx", "New Round Creation", new Dictionary <string, object>()
                {
                    { "success", true }
                });
                tournament.currentRound = newRound;

                resultsMenu.PostSuccess(newRound, (nothin) =>
                {
                    TournamentMenu.Instance.actionState = TournamentMenu.ActionState.ManageTournament;
                    TournamentMenuCenterButton.Instance.updateState();
                });
            }
            else
            {
                StatisticsTracking.EndEvent("Matryx", "New Round Creation", new Dictionary <string, object>()
                {
                    { "success", false }
                });
                resultsMenu.PostFailure(newRound, "Failed to create new round");
            }
        }
    }