public async Task <BlockAPIResult> CreateProfitingAccountAsync(string Name, ProfitingType ptype, decimal shareRito, int maxVoter) { var tags = new Dictionary <string, string> { { Block.REQSERVICETAG, BrokerActions.BRK_PFT_CRPFT }, { "name", Name }, // get by name. name can't duplicate { "ptype", ptype.ToString() }, { "share", $"{shareRito}" }, { "seats", $"{maxVoter}" } }; var amounts = new Dictionary <string, decimal> { { LyraGlobal.OFFICIALTICKERCODE, PoolFactoryBlock.ProfitingAccountCreateFee } }; var result = await SendExAsync(PoolFactoryBlock.FactoryAccount, amounts, tags); if (result.ResultCode != APIResultCodes.Success) { return new BlockAPIResult { ResultCode = result.ResultCode } } ; for (int i = 0; i < 10; i++) { // then find by RelatedTx var blocks = await _node.GetBlocksByRelatedTxAsync((await GetLatestBlockAsync()).Hash); if (blocks.Successful()) { var txs = blocks.GetBlocks(); var gen = txs.FirstOrDefault(a => a is ProfitingBlock pb && pb.OwnerAccountId == AccountId); if (gen != null) { var ret = new BlockAPIResult { ResultCode = APIResultCodes.Success, }; ret.SetBlock(gen); return(ret); } } await Task.Delay(500); } return(new BlockAPIResult { ResultCode = APIResultCodes.ConsensusTimeout }); }
public async Task <ProfitInfo> CreateProfitingAccountAsync(string accountId, string Name, ProfitingType ptype, decimal shareRito, int maxVoter) { var klWallet = CreateWallet(accountId); var result = await klWallet.CreateProfitingAccountAsync(Name, ptype, shareRito, maxVoter); if (result.ResultCode == APIResultCodes.Success) { var pgen = result.GetBlock() as ProfitingGenesis; var pftinfo = new ProfitInfo { owner = pgen.OwnerAccountId, pftid = pgen.AccountID, seats = pgen.Seats, shareratio = pgen.ShareRito, name = pgen.Name, type = pgen.PType.ToString() }; return(pftinfo); } else { throw new Exception($"{result.ResultCode}: {result.ResultMessage}"); } }