public void Enqueue(DeployedContractModel contract) { lock (_enqueueLock) { try { var payloadString = JsonConvert.SerializeObject(contract); var payloadBytes = Encoding.UTF8.GetBytes(payloadString); _queueUpdateLock.EnterReadLock(); _channel.BasicPublish ( exchange: string.Empty, routingKey: Queue, basicProperties: _publishProperties, body: payloadBytes ); } finally { _queueUpdateLock.ExitReadLock(); } } }
public async Task IndexContractAsync(DeployedContractModel deployedContract) { if (await TransactionExists(deployedContract.TransactionHash) && await _erc20Detector.IsContractErc20Compatible(deployedContract.Address)) { var ethereumContract = _web3.Eth.GetContract(MetadataAbi, deployedContract.Address); var erc20Contract = new Erc20ContractModel { Address = deployedContract.Address, BlockHash = deployedContract.BlockHash, BlockNumber = BigInteger.Parse(deployedContract.BlockNumber), BlockTimestamp = BigInteger.Parse(deployedContract.BlockTimestamp), DeployerAddress = deployedContract.DeployerAddress, TransactionHash = deployedContract.TransactionHash }; if (TryCallFunction(ethereumContract, "name", out string name)) { erc20Contract.TokenName = name; } if (TryCallFunction(ethereumContract, "symbol", out string symbol)) { erc20Contract.TokenSymbol = symbol; } if (TryCallFunction(ethereumContract, "decimals", out uint decimals)) { erc20Contract.TokenDecimals = decimals; } if (TryCallFunction(ethereumContract, "totalSupply", out BigInteger totalSupply)) { erc20Contract.TokenTotalSupply = totalSupply; } await _erc20ContractRepository.SaveAsync(erc20Contract); await _rabbitQueuePublisher.NotifyAsync(new Lykke.Service.EthereumSamurai.Models.Messages.RabbitContractIndexingMessage() { Address = erc20Contract.Address, BlockHash = erc20Contract.BlockHash, BlockNumber = (ulong)erc20Contract.BlockNumber, BlockTimestamp = (int)erc20Contract.BlockTimestamp, DeployerAddress = erc20Contract.DeployerAddress, IndexingMessageType = Lykke.Service.EthereumSamurai.Models.Messages.IndexingMessageType.ErcContract, TokenDecimals = erc20Contract.TokenDecimals, TokenName = erc20Contract.TokenName, TokenSymbol = erc20Contract.TokenSymbol, TokenTotalSupply = erc20Contract.TokenTotalSupply.ToString(), TransactionHash = erc20Contract.TransactionHash }); } }
public Erc20ContractDeployedMessage(DeployedContractModel deployedContractModel) { DeployedContractModel = deployedContractModel; }
public static Erc20ContractDeployedMessage CreateErc20ContractDeployedMessage(DeployedContractModel deployedContractModel) { return(new Erc20ContractDeployedMessage(deployedContractModel)); }