void AuthorizationManager_OnAuthorizationChanged(AuthorizationManager.AuthorizationData authorization) { Repository.OnObjectUpdate -= Repository_OnObjectUpdate; if (authorization.IsNull()) { me = null; return; } me = authorization.UserNameData.FullAccount.Account; Repository.OnObjectUpdate += Repository_OnObjectUpdate; }
void UpdateAccountBalances(AuthorizationManager.AuthorizationData data) { if (data.IsNull()) { return; } var me = data.UserNameData.FullAccount; ApiManager.Instance.Database.GetAccountBalances(me.Account.Id.Id, Array.ConvertAll(me.Balances, balance => balance.AssetType.Id)) .Then(result => { accountBalances.Clear(); accountBalances.AddRange(result); if (OnBalanceUpdate != null) { OnBalanceUpdate(); } }); }
void UpdateBalances(AuthorizationManager.AuthorizationData data) { assetsData.Clear(); balanceDropdown.ClearOptions(); if (data.IsNull()) { return; } if (AuthorizationController.Instance.accountBalances.Count == 0) { var options = new List <Dropdown.OptionData>(); options.Add(new Dropdown.OptionData("PPY")); balanceDropdown.AddOptions(options); TournamentManager.Instance.GetAssetObject() .Then(asset => { selectAssetObject = asset; SetAvailableBalanceText(0 + " " + selectAssetObject.Symbol); assetsData.Add(asset); }); } else { TournamentManager.Instance.GetAssetsObject(Array.ConvertAll(AuthorizationController.Instance.accountBalances.ToArray(), assetId => assetId.Asset.Id)) .Then(objects => { var options = new List <Dropdown.OptionData>(); foreach (var assetObject in objects) { assetsData.Add(assetObject); options.Add(new Dropdown.OptionData(assetObject.Symbol)); } balanceDropdown.AddOptions(options); selectAssetObject = objects[0]; SetAvailableBalanceText((AuthorizationController.Instance.accountBalances[0].Amount / Mathf.Pow(10, selectAssetObject.Precision)) + " " + selectAssetObject.Symbol); }); } }