public async Task <TResult> ExecuteTransactionAsync <TResult>(string rawTransaction) where TResult : IMessage <TResult>, new() { var hexString = await ExecuteTransactionAsync(rawTransaction); if (string.IsNullOrEmpty(hexString)) { throw new AElfChainApiException("ExecuteTransactionAsync response is null or empty."); } var byteArray = ByteArrayHelper.FromHexString(hexString); var messageParser = new MessageParser <TResult>(() => new TResult()); return(messageParser.ParseFrom(byteArray)); }
private SystemContractDeploymentInput.Types.SystemTransactionMethodCallList GenerateTokenInitializationCallList( Address issuer) { var tokenContractCallList = new SystemContractDeploymentInput.Types.SystemTransactionMethodCallList(); tokenContractCallList.Add(nameof(TokenContractContainer.TokenContractStub.CreateNativeToken), new CreateNativeTokenInput { Symbol = _tokenInitialOptions.Symbol, Decimals = _tokenInitialOptions.Decimals, IsBurnable = _tokenInitialOptions.IsBurnable, TokenName = _tokenInitialOptions.Name, TotalSupply = _tokenInitialOptions.TotalSupply, // Set the contract zero address as the issuer temporarily. Issuer = issuer, LockWhiteSystemContractNameList = { ElectionSmartContractAddressNameProvider.Name, VoteSmartContractAddressNameProvider.Name, ProfitSmartContractAddressNameProvider.Name, } }); tokenContractCallList.Add(nameof(TokenContractContainer.TokenContractStub.IssueNativeToken), new IssueNativeTokenInput { Symbol = _tokenInitialOptions.Symbol, Amount = (long)(_tokenInitialOptions.TotalSupply * _tokenInitialOptions.DividendPoolRatio), ToSystemContractName = ElectionSmartContractAddressNameProvider.Name, Memo = "Set dividends.", }); //TODO: Maybe should be removed after testing. foreach (var tokenReceiver in _consensusOptions.InitialMiners) { tokenContractCallList.Add(nameof(TokenContractContainer.TokenContractStub.Issue), new IssueInput { Symbol = _tokenInitialOptions.Symbol, Amount = (long)(_tokenInitialOptions.TotalSupply * (1 - _tokenInitialOptions.DividendPoolRatio)) / _consensusOptions.InitialMiners.Count, To = Address.FromPublicKey(ByteArrayHelper.FromHexString(tokenReceiver)), Memo = "Set initial miner's balance." }); } // Set fee pool address to election contract address. tokenContractCallList.Add(nameof(TokenContractContainer.TokenContractStub.SetFeePoolAddress), ElectionSmartContractAddressNameProvider.Name); return(tokenContractCallList); }