Пример #1
0
 public TokenBalance(CurrencySymbol currencySymbol, decimal balance, string ethereumAddress, string contract)
 {
     CurrencySymbol  = currencySymbol;
     Balance         = balance;
     EthereumAddress = ethereumAddress;
     Contract        = contract;
 }
        public override async Task <Collection <ExchangePairPrice> > GetPairs(CurrencySymbol baseSymbol, PriceType priceType)
        {
            var retVal = new Collection <ExchangePairPrice>();
            var prices = await RESTClient.GetAsync <Collection <PairPrice> >("/api/v1/ticker/price");

            foreach (var price in prices)
            {
                var toSymbolName   = price.symbol.Substring(0, price.symbol.Length - 3);
                var baseSymbolName = price.symbol.Substring(price.symbol.Length - 3, 3);

                var currentBaseSymbol = new CurrencySymbol(baseSymbolName);

                if (baseSymbol != null)
                {
                    if (!currentBaseSymbol.Equals(baseSymbol))
                    {
                        continue;
                    }
                }

                retVal.Add(new ExchangePairPrice(null)
                {
                    BaseSymbol = baseSymbol, ToSymbol = new CurrencySymbol(toSymbolName), Price = price.price
                });
            }

            return(retVal);
        }
Пример #3
0
 public GetTransactionsAtAddressArgs(RestClient rESTClient, string address, CurrencySymbol currency, BlockchainClientBase blockchainClientBase)
 {
     this.rESTClient           = rESTClient;
     this.address              = address;
     this.currency             = currency;
     this.blockchainClientBase = blockchainClientBase;
 }
Пример #4
0
        public AtWord(Language language, CurrencySymbol currencySymbol, CurrencyOptions currencyOptions)
        {
            _currencySymbol  = currencySymbol;
            _currencyOptions = currencyOptions;

            _currencyTransformer = new CurrencyTransformerFactory().Create(language);
        }
        private static async Task TestCoin(CurrencySymbol symbol, List <string> inputAddresses, int repeatCount = 10)
        {
            var blockchainClientManager = new BlockchainClientManager(new RESTClientFactory());

            for (var i = 0; i < repeatCount; i++)
            {
                var addressDictionary = await blockchainClientManager.GetAddresses(symbol, inputAddresses);

                foreach (var key in addressDictionary.Keys)
                {
                    var outputAddresses = addressDictionary[key].ToList();
                    foreach (var address in outputAddresses)
                    {
                        Assert.AreEqual(inputAddresses.Count, outputAddresses.Count, "The number of addresses returned was not the same as the number of addresses called");

                        for (var x = 0; x < inputAddresses.Count; x++)
                        {
                            Assert.AreEqual(inputAddresses[x].ToLower(), outputAddresses[x].Address.ToLower(), "An inputted address turned out to be different to the outputted address");
                        }

                        Assert.IsTrue(address.IsUnused.HasValue || address.TransactionCount.HasValue, "Can't tell if the address has transactions");

                        Console.WriteLine($"Address: {address.Address} Balance: {address.Balance} Transaction Count: {address.TransactionCount} Is Unused: {address.IsUnused}");
                    }
                }
            }
        }
Пример #6
0
        public override async Task <Collection <ExchangePairPrice> > GetPairs(CurrencySymbol baseSymbol, PriceType priceType)
        {
            var retVal  = new Collection <ExchangePairPrice>();
            var markets = await RESTClient.GetAsync <Markets>("/api/v1.1/public/getmarketsummaries");

            foreach (var pair in markets.result)
            {
                var baseSymbolName = pair.MarketName.Substring(0, 3);
                var toSymbolName   = pair.MarketName.Substring(4, pair.MarketName.Length - 4);

                var currentBaseSymbol = new CurrencySymbol(baseSymbolName);

                if (baseSymbol != null)
                {
                    if (!currentBaseSymbol.Equals(baseSymbol))
                    {
                        continue;
                    }
                }

                retVal.Add(new ExchangePairPrice(pair.Volume)
                {
                    BaseSymbol = currentBaseSymbol, ToSymbol = new CurrencySymbol(toSymbolName), Price = priceType == PriceType.Ask ? pair.Ask : pair.Bid
                });
            }

            return(retVal);
        }
        public async Task <double?> ConvertCurrency(CurrencySymbol from, CurrencySymbol to, double value)
        {
            var rates = await this.Get(new ListArgs <OrderCloudIntegrationsConversionRate>(), from);

            var rate = rates.Items.FirstOrDefault(r => r.Currency == to)?.Rate;

            return(value * rate);
        }
        public GenericCurrencyTransformerTests()
        {
            _currency = CurrencySymbol.USD;

            _transformer = new GenericCurrencyTransformer(
                GenericNumberTransformer.GetNumberTransformer(),
                new EnglishCurrencyDictionary(),
                new EnglishNounInflector());
        }
        private static double?FixRate(ExchangeRatesValues values, CurrencySymbol e)
        {
            var t = values?.GetType().GetProperty($"{e}")?.GetValue(values, null).To <double?>();

            if (!t.HasValue)
            {
                return(1);
            }
            return(t.Value == 0 ? 1 : t.Value);
        }
        /// <summary>
        /// Intended for private consumption by functions that update the cached resources.
        /// </summary>
        /// <param name="rateArgs"></param>
        /// <returns></returns>
        public async Task <OrderCloudIntegrationsExchangeRate> Get(CurrencySymbol symbol)
        {
            var rates = await _client.Get(symbol);

            return(new OrderCloudIntegrationsExchangeRate()
            {
                BaseSymbol = symbol,
                Rates = MapRates(rates.rates)
            });
        }
Пример #11
0
        public IntegerMoney(int amount, CurrencySymbol currency)
        {
            Amount   = amount;
            Currency = currency;

            if (!IsValid())
            {
                throw new ValueObjectValidationException("IntegerMoney");
            }
        }
 private static string GetIcon(CurrencySymbol symbol)
 {
     using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"ordercloud.integrations.exchangerates.Icons.{symbol}.gif");
     if (stream == null)
     {
         return(null);
     }
     using var ms = new MemoryStream();
     stream.CopyTo(ms);
     return($"data:image/jpg;base64,{Convert.ToBase64String(ms.ToArray())}");
 }
Пример #13
0
        public ActionResult HotelInfos()
        {
            CurrencySymbol currency       = new CurrencySymbol();
            var            fer            = getHotelInfo();
            string         cSymbol        = fer.HotelRoomsDetails[0].Price.CurrencyCode;
            string         currencySymbol = currency.TryGetCurrencySymbol(cSymbol);

            ViewBag.Curency = currencySymbol;
            ViewBag.Msg     = GetHotelRooms();
            return(View(fer));
        }
Пример #14
0
        public ZchaClient(CurrencySymbol currency, IRestClientFactory restClientFactory) : base(currency, restClientFactory)
        {
            RESTClient = (RestClient)restClientFactory.CreateRESTClient(new Uri("https://api.zcha.in"));

            //When this client can't see the address it returns "null" with a status code of 404 so we just return a blank address instead
            //TODO: Check that this isn't just returning null for all ZEC addresses
            RESTClient.HttpStatusCodeFuncs.Add(HttpStatusCode.NotFound, data =>
            {
                //TODO: This is just a byte array. It needs to be converted to text and probably deserialized
                Logger.Log($"ZEC Blockchain Error: {data}", null, LogSection);
                return(new Address());
            });
        }
Пример #15
0
        public int CompareTo(Money other)
        {
            if (CurrencySymbol != other.CurrencySymbol)
            {
                return(CurrencySymbol.CompareTo(other.CurrencySymbol));
            }
            if (Amount != other.Amount)
            {
                return(Amount.CompareTo(other.Amount));
            }

            return(0);
        }
        private static ResponseDTO CurrencyExistAndIsEnabled(CurrencySymbol currency, string symbol)
        {
            if (currency == null)
            {
                return(ResponseDTO.Fail($"'{symbol}' currency is not registered."));
            }

            if (!currency.Enabled)
            {
                return(ResponseDTO.Fail($"'{symbol}' currency is disabled."));
            }

            return(true);
        }
Пример #17
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = DisplaySymbol.GetHashCode();
         hashCode = (hashCode * 397) ^ (IsoCode != null ? IsoCode.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ SymbolFirst.GetHashCode();
         hashCode = (hashCode * 397) ^ (CurrencySymbol != null ? CurrencySymbol.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DecimalDigits;
         hashCode = (hashCode * 397) ^ (DecimalSeparator != null ? DecimalSeparator.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (GroupSeparator != null ? GroupSeparator.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ExampleFormat != null ? ExampleFormat.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #18
0
 private string GetMerchantID(CurrencySymbol userCurrency)
 {
     if (userCurrency == CurrencySymbol.USD)
     {
         return(_settings.CardConnectSettings.UsdMerchantID);
     }
     else if (userCurrency == CurrencySymbol.CAD)
     {
         return(_settings.CardConnectSettings.CadMerchantID);
     }
     else
     {
         return(_settings.CardConnectSettings.EurMerchantID);
     }
 }
        private static async Task TestCoin(CurrencySymbol symbol, IReadOnlyCollection <string> addresses2)
        {
            var blockchainClientManager = new BlockchainClientManager(new RESTClientFactory());

            for (var i = 0; i < 10; i++)
            {
                var addressDictionary = await blockchainClientManager.GetAddresses(symbol, addresses2);

                foreach (var key in addressDictionary.Keys)
                {
                    var addresses = addressDictionary[key];
                    foreach (var address in addresses)
                    {
                        Assert.IsTrue(address.IsUnused.HasValue || address.TransactionCount.HasValue, "Can't tell if the address has transactions");
                    }
                }
            }
        }
        public override async Task <BlockChainAddressInformation> GetAddress(string address)
        {
            //https://www.blockcypher.com/dev/bitcoin/#rate-limits-and-tokens
            await Task.Delay(MillisecondsDelay);

            //Do a ToLower on ethereum coins but not other coins
            var isEthereum = CurrencySymbol.IsEthereum(Currency);

            address = isEthereum ? address.ToLower() : address;

            var apiKeyPart   = !string.IsNullOrEmpty(APIKey) ? $"?token={APIKey}" : string.Empty;
            var balanceModel = await RESTClient.GetAsync <Address>($"v1/{Currency.Name.ToLower()}/main/addrs/{address}/balance{apiKeyPart}");

            //This website returns satoshis/wei so need to divide
            var balance = isEthereum ? balanceModel.balance / CurrencySymbol.Wei : balanceModel.balance / CurrencySymbol.Satoshi;

            return(new BlockChainAddressInformation(address, balance, balanceModel.final_n_tx));
        }
Пример #21
0
        ///<inheritdoc/>
        public string ToWords(decimal amount, CurrencySymbol currencySymbol,
                              CurrencyOptions currencyOptions)
        {
            var currency = _currencyDictionary.GetCurrency(currencySymbol);

            var integerWords = IntegerPartToWords(amount, currency);

            var withDecimalPart = !currencyOptions?.IntegerPartOnly ?? true;
            var integerAndDecimalPartSeparator = currencyOptions?.IntegerAndDecimalPartSeparator;

            var decimalWords = new ArrayList();

            if (withDecimalPart)
            {
                decimalWords = DecimalPartToWords(amount, currency, currencyOptions);
            }

            return(JoinNumberParts(integerWords, decimalWords, integerAndDecimalPartSeparator));
        }
Пример #22
0
        private OrderCloudIntegrationsExchangeRate GetExchangeRate(CurrencySymbol baseCurrency, CurrencySymbol toCurrency, double returnedRate)
        {
            Fixture fixture = new Fixture();

            return(new OrderCloudIntegrationsExchangeRate()
            {
                BaseSymbol = baseCurrency,
                Rates = new List <OrderCloudIntegrationsConversionRate>()
                {
                    new OrderCloudIntegrationsConversionRate()
                    {
                        Currency = toCurrency,
                        Rate = returnedRate
                    },
                    fixture.Create <OrderCloudIntegrationsConversionRate>(),
                    fixture.Create <OrderCloudIntegrationsConversionRate>()
                }
            });
        }
Пример #23
0
        public async Task <JobDto> Handle(CreateJobCommand request, CancellationToken cancellationToken)
        {
            var currency  = new CurrencySymbol(request.CurrencySymbol);
            var minSalary = new IntegerMoney(request.MinSalary, currency);
            var maxSalary = new IntegerMoney(request.MaxSalary, currency);
            var job       = new JobEntity(
                name: request.Name,
                minSalary: minSalary,
                maxSalary: maxSalary,
                description: request.Description,
                shortDescription: request.ShortDescription
                );

            await _dbContext.Jobs.AddAsync(_mapper.Map <JobModel>(job), cancellationToken);

            await _dbContext.SaveChangesAsync(cancellationToken);

            return(_mapper.Map <JobDto>(job));
        }
Пример #24
0
        public override async Task <Collection <ExchangePairPrice> > GetPairs(CurrencySymbol baseSymbol, PriceType priceType)
        {
            var retVal  = new Collection <ExchangePairPrice>();
            var symbols = await RESTClient.GetAsync <List <string> >("/v1/symbols");

            foreach (var symbol in symbols)
            {
                var toSymbolName   = symbol.Substring(0, 3);
                var baseSymbolName = symbol.Substring(symbol.Length - 3, 3);

                var currentBaseSymbol = new CurrencySymbol(baseSymbolName);

                if (baseSymbol != null)
                {
                    if (!currentBaseSymbol.Equals(baseSymbol))
                    {
                        continue;
                    }
                }

                Tick tick = null;
                while (tick == null)
                {
                    try
                    {
                        tick = await RESTClient.GetAsync <Tick>($"/v1/pubticker/{symbol}");
                    }
                    catch
                    {
                        //Wait for the rate to come back
                        Thread.Sleep(61000);
                    }
                }

                retVal.Add(new ExchangePairPrice(tick.volume)
                {
                    BaseSymbol = currentBaseSymbol, ToSymbol = new CurrencySymbol(toSymbolName), Price = priceType == PriceType.Bid ? tick.bid : tick.ask
                });
            }

            return(retVal);
        }
        public override async Task <Collection <ExchangePairPrice> > GetPairs(CurrencySymbol baseSymbol, PriceType priceType)
        {
            if (baseSymbol == null)
            {
                throw new ArgumentNullException(nameof(baseSymbol));
            }

            var retVal = new Collection <ExchangePairPrice>();
            var prices = await RESTClient.GetAsync <Prices>($"/api/GetMarkets/{baseSymbol.Name}");

            foreach (var pair in prices.Data)
            {
                var toSymbolName   = pair.Label.Substring(0, 3);
                var baseSymbolName = pair.Label.Substring(4, pair.Label.Length - 4);

                var currentBaseSymbol = new CurrencySymbol(baseSymbolName);
                if (!currentBaseSymbol.Equals(baseSymbol))
                {
                    continue;
                }

                if (pair.LastPrice == 0)
                {
                    continue;
                }

                //Duplicate coin name
                if (toSymbolName == "BTG" || toSymbolName == "BAT" || toSymbolName == "PLC" || toSymbolName == "CMT" || toSymbolName == "ACC")
                {
                    continue;
                }

                retVal.Add(new ExchangePairPrice(pair.Volume)
                {
                    BaseSymbol = currentBaseSymbol, ToSymbol = new CurrencySymbol(toSymbolName), Price = priceType == PriceType.Ask ? pair.AskPrice : pair.BidPrice
                });
            }

            return(retVal);
        }
        private Bundle buildBundleFromNPCs(ServerNpcModel[] serverNPCModels)
        {
            ItemModel[] rewardItemModels = new ItemModel[serverNPCModels.Length];
            for (int n = 0; n < serverNPCModels.Length; n++)
            {
                rewardItemModels[n] = serverNPCModels[n].DropTableModel.GetRandomItem(RandomGen.NextNormalizedFloat());
            }

            // TODO: for now award 1 gold and xp on zone completion and multiply by 2 if final zone.
            int goldAmount = 1;
            int xpAmount   = 1;

            if (isFinalZone)
            {
                goldAmount *= 2;
                xpAmount   *= 2;
            }
            CurrencySymbol[] currencySymbols = new CurrencySymbol[] { CurrencySymbol.GC, CurrencySymbol.XP };
            int[]            currencyValues  = new int[] { goldAmount, xpAmount };

            return(new Bundle(rewardItemModels, currencySymbols, currencyValues));
        }
Пример #27
0
 public BitcoinGoldClient(CurrencySymbol currency, IRestClientFactory restClientFactory) : base(currency, restClientFactory)
 {
 }
 public DogeChainClient(CurrencySymbol currency, IRestClientFactory restClientFactory) : base(currency, restClientFactory)
 {
     RESTClient = restClientFactory.CreateRESTClient(new Uri("https://dogechain.info"));
 }
Пример #29
0
 protected BlockchainClientBase(CurrencySymbol currency, IRestClientFactory restClientFactory) : base(restClientFactory)
 {
     Currency = currency;
 }
Пример #30
0
 public RippleClient(CurrencySymbol currency, IRestClientFactory restClientFactory) : base(currency, restClientFactory)
 {
     RESTClient = restClientFactory.CreateRESTClient(new Uri("https://data.ripple.com"));
 }