Beispiel #1
0
        public async Task <Erc20Token> AddAsync(IErc20Token token)
        {
            await InvalidateCache();

            await _tokenService.AddAsync(token);

            return(AutoMapper.Mapper.Map <Erc20Token>(token));
        }
        public async Task UpdateAsync(IErc20Token erc20Token)
        {
            var entity = Mapper.Map <Erc20TokenEntity>(erc20Token);

            SetEntityKeys(entity);
            var index = new AzureIndex(AssetIndexPartition, erc20Token.AssetId, entity);

            await _erc20AssetEntityTable.InsertOrMergeAsync(entity);

            if (erc20Token.AssetId != null)
            {
                await _indexAssetIdTable.InsertOrMergeAsync(index);
            }
        }
Beispiel #3
0
        private async Task <(string BlockchainId, string DisplayId)> GetBlockchainAndDisplayIdsAsync(IErc20Token token)
        {
            var assets        = (await _assetService.GetAllAsync(true)).ToArray();
            var blockchainIds = assets.Select(x => x.BlockChainId).ToArray();
            var displayIds    = assets.Select(x => x.DisplayId).ToArray();

            string GetUniqueId(string[] existingIds)
            {
                var uniqueId        = token.TokenSymbol;
                var duplicatesCount = 0;

                while (existingIds.Contains(uniqueId))
                {
                    duplicatesCount++;

                    uniqueId = $"{token.TokenSymbol}_{duplicatesCount + 1}";
                }

                return(uniqueId);
            }

            return(GetUniqueId(blockchainIds), GetUniqueId(displayIds));
        }
Beispiel #4
0
 private static string GetAssetName(IErc20Token token)
 {
     return(!string.IsNullOrEmpty(token.TokenName)
         ? $"Erc20 token {token.TokenName} ({token.Address})"
         : $"Erc20 token {token.Address}");
 }
Beispiel #5
0
        public async Task UpdateAsync(IErc20Token token)
        {
            await InvalidateCache(token.AssetId);

            await _tokenService.UpdateAsync(token);
        }
 public async Task UpdateAsync(IErc20Token token)
 {
     await _erc20TokenRepository.AddAsync(token);
 }
        public async Task <IErc20Token> AddAsync(IErc20Token token)
        {
            await _erc20TokenRepository.AddAsync(token);

            return(token);
        }