/// <summary> /// Checks if purpose was removed as the most recently removed TradableAsset, and stops updating the LockPRPSManager if so. /// </summary> /// <param name="tradableAsset"> The most recently removed TradableAsset from the TradableAssetManager. </param> private void CheckIfPRPSRemoved(TradableAsset tradableAsset) { if (tradableAsset.AssetAddress.EqualsIgnoreCase(prpsContract.ContractAddress)) { periodicUpdateManager.RemovePeriodicUpdater(this); } }
/// <summary> /// Adds the newly created TradableAsset to the TradableAssetManager and TradableAssetButtonManager. /// </summary> /// <param name="tradableAsset"> The asset to add. </param> /// <param name="onUpdateFinished"> Action to call once the tradable asset updating has finished. </param> private void UpdateTradableAssets(TradableAsset tradableAsset, Action onUpdateFinished) { if (tradableAsset.AssetSymbol != null) { OnTokenAdded?.Invoke(tradableAsset); } onUpdateFinished?.Invoke(); }
/// <summary> /// Updates the visuals of the AssetButton to the new TradableAsset. /// </summary> /// <param name="info"> The TradableAsset to use to set the visuals of this button. </param> protected override void OnValueUpdated(TradableAsset info) { SubscribeBalanceEventListener(); UpdateButtonBalance(); UpdateButtonSymbol(); UpdateButtonImage(); UpdateButtonTransformOrder(); UpdateAssetNotifications(); }
/// <summary> /// Sets the amount of the asset that was traded in this transaction. /// </summary> /// <param name="transaction"> The info of this transaction. </param> /// <param name="tradableAsset"> The asset that was traded. </param> private void SetAmount(TransactionInfo transaction, TradableAsset tradableAsset) { var send = transaction.Type == TransactionInfo.TransactionType.Send; var start = send ? "-" : "+"; var amount = start + SolidityUtils.ConvertFromUInt(transaction.Value, tradableAsset.AssetDecimals); var symbol = tradableAsset.AssetSymbol; amountText.SetText(amount.LimitEnd(18 - symbol.Length, "...") + "<style=Symbol> " + symbol + "</style>"); amountText.color = send ? UIColors.Red : UIColors.Green; }
private void OnDubiExPriceFound(TradableAsset tradableAsset, decimal?price) { if (!prices.ContainsKey(tradableAsset.AssetSymbol)) { prices.Add(tradableAsset.AssetSymbol, price.Value * prices["ETH"]); } else { prices[tradableAsset.AssetSymbol] = price.Value * prices["ETH"]; } OnPriceUpdateSucceeded?.Invoke(); }
private void OnCoinMarketCapPriceFound(TradableAsset tradableAsset, decimal?price) { if (!prices.ContainsKey(tradableAsset.AssetSymbol)) { prices.Add(tradableAsset.AssetSymbol, price.Value); } else { prices[tradableAsset.AssetSymbol] = price.Value; } OnPriceUpdateSucceeded?.Invoke(); }
private void UpdatePrice(TradableAsset tradableAsset) { if (tradableAsset == null) { return; } OnPriceUpdateStarted?.Invoke(); coinMarketCapDataManager.GetCoinPrice(tradableAsset.AssetSymbol) .OnSuccess(price => OnCoinMarketCapPriceFound(tradableAsset, price)) .OnError(_ => OnCoinMarketCapPriceNotFound(tradableAsset)); }
/// <summary> /// Adds an asset to the list of assets to scrape transactions for. /// </summary> /// <param name="asset"> The asset to scrape transactions for. </param> private void AddAssetToScrape(TradableAsset asset) { if (asset?.AssetAddress == null) { return; } if (asset is EtherAsset) { QueueEther(userWalletManager.GetWalletAddress()); } else { QueueToken(asset.AssetAddress, userWalletManager.GetWalletAddress()); } }
private void OnCoinMarketCapPriceNotFound(TradableAsset tradableAsset) { coinMarketCapDataManager.GetCoinPrice("ETH").OnSuccess(ethPrice => { if (!prices.ContainsKey("ETH")) { prices.Add("ETH", ethPrice.Value); } else { prices["ETH"] = ethPrice.Value; } dubiexDataManager.GetRecentEthPrice(tradableAsset.AssetSymbol) .OnSuccess(price => OnDubiExPriceFound(tradableAsset, price)) .OnError(_ => OnPriceUpdateFailed?.Invoke()); }); }
/// <summary> /// Removes a TradableAsset's button from the list of buttons, and destroys the gameobject. /// </summary> /// <param name="assetToRemove"> The TradableAsset to remove. </param> private void RemoveButton(TradableAsset assetToRemove) { for (int i = 0; i < assetButtons.Count; i++) { ITradableAssetButton assetButton = assetButtons[i]; if (assetButton.ButtonInfo == assetToRemove) { if (assetButton == activeAssetButton) { assetButtons[0].ButtonLeftClicked(); } assetButtons.Remove(assetButton); OnTradableAssetButtonRemoved?.Invoke(assetButton); return; } } }
/// <summary> /// Adds a new asset to the collection of TradableAssets to manage. /// </summary> /// <param name="tradableAsset"> The TradableAsset to add to the manager. </param> public void AddTradableAsset(TradableAsset tradableAsset) { var address = tradableAsset.AssetAddress; if (TradableAssets.ContainsKey(address)) { return; } if (tradableAsset is EtherAsset) { EtherAsset = tradableAsset as EtherAsset; SetNewActiveAsset(tradableAsset); } TradableAssets.Add(address, tradableAsset); tradableAsset.OnAssetBalanceChanged += _ => OnBalancesUpdated?.Invoke(); OnTradableAssetAdded?.Invoke(tradableAsset); }
/// <summary> /// Adds a asset button to the list of asset buttons visible. /// </summary> /// <param name="tradableAsset"> The TokenContract which will be assigned to this button. </param> private void AddAssetButton(TradableAsset tradableAsset) { ITradableAssetButton assetButton; if (tradableAsset is EtherAsset) { assetButton = etherAssetButtonFactory.Create().SetButtonInfo(tradableAsset); EnableNewTokenButton(assetButton); } else { assetButton = erc20TokenButtonFactory.Create().SetButtonInfo(tradableAsset); } assetButtons.Add(assetButton); SortButtons(); OptimizedScrollview.GetScrollview("asset_scrollview")?.Refresh(); OnTradableAssetButtonCreated?.Invoke(assetButton); }
/// <summary> /// Sets a new active asset given a TradableAsset. /// Active asset is determined based on which button was selected. /// </summary> /// <param name="tradableAsset"> The new TradableAsset ot be our active asset. </param> public void SetNewActiveAsset(TradableAsset tradableAsset) { ActiveTradableAsset = tradableAsset; OnBalancesUpdated?.Invoke(); }
/// <summary> /// Sets the image of this transaction to the asset's image. /// </summary> /// <param name="tradableAsset"> The asset to use to set the image. </param> private void SetImage(TradableAsset tradableAsset) { tradableAssetImageManager.LoadImage(tradableAsset.AssetSymbol, img => assetImage.sprite = img); }
private void AssetRemoved(TradableAsset tradableAsset) { notificationsByAddress.Remove(tradableAsset.AssetAddress); }
private void AssetAdded(TradableAsset tradableAsset) { notificationsByAddress.Add(tradableAsset.AssetAddress.ToLower(), null); }