/* * realigns text and makes it look centred */ private void allignText() { DisplayInstruction.SelectAll(); DisplayInstruction.SelectionAlignment = HorizontalAlignment.Center; DisplayInput.SelectAll(); DisplayInput.SelectionAlignment = HorizontalAlignment.Center; Title.SelectAll(); Title.SelectionAlignment = HorizontalAlignment.Center; }
public static (DisplayInput[] DisplayInputs, DisplayOutput[] DisplayOutputs) GenerateCellbaseDisplayInfos(Client client, string txHash, Output[] outputs, UInt64 blockNumber, string prefix) { if (blockNumber < (UInt64)TxProposalWindow) { var dInputs = new DisplayInput[] { new DisplayInput { FromCellbase = true, Capacity = "", AddressHash = "", TargetBlockNumber = "0", GeneratedTxHash = txHash, } }; // var dOutputs = Array.Empty<DisplayOutput>(); var dOutputs = outputs.Select((output, i) => { return(new DisplayOutput { Id = $"{txHash}:{i}", Capacity = Hex.HexToUInt64(output.Capacity).ToString(), AddressHash = Ckb.Address.Address.GenerateAddress(output.Lock, prefix), TargetBlockNumber = blockNumber.ToString(), RealId = i, //PrimaryReward = Hex.HexToUInt64(minerReward.Primary).ToString(), //SecondaryReward = Hex.HexToUInt64(minerReward.Secondary).ToString(), //CommitReward = Hex.HexToUInt64(minerReward.Committed).ToString(), //ProposalReward = Hex.HexToUInt64(minerReward.Proposal).ToString(), // TODO: update Status & ConsumedTxHash Status = "live", ConsumedTxHash = "", }); }).ToArray(); var doutlist = dOutputs.ToList(); //if the 0 block,specal deal unuse data if (blockNumber == 0 && doutlist.Count > 9) { doutlist.RemoveRange(0, 5); //by the dev setting cell doutlist.RemoveRange(doutlist.Count() - 4, 4); //by the dev setting cell } return(dInputs, doutlist.ToArray()); } UInt64 targetBlockNumber = blockNumber + 1 - (UInt64)TxProposalWindow; var displayInputs = new DisplayInput[] { new DisplayInput { FromCellbase = true, Capacity = "", AddressHash = "", TargetBlockNumber = targetBlockNumber.ToString(), GeneratedTxHash = txHash, } }; Header?targetBlockHeader = client.GetHeaderByNumber(targetBlockNumber); if (targetBlockHeader == null) { throw new Exception("Target header not found!"); } BlockEconomicState?targetEconomicState = client.GetBlockEconomicState(targetBlockHeader.Hash); if (targetEconomicState == null) { throw new Exception("Target economic state not found!"); } MinerReward minerReward = targetEconomicState.MinerReward; var displayOutputs = outputs.Select((output, i) => { return(new DisplayOutput { Id = $"{txHash}:{i}", Capacity = Hex.HexToUInt64(output.Capacity).ToString(), AddressHash = Ckb.Address.Address.GenerateAddress(output.Lock, prefix), TargetBlockNumber = targetBlockNumber.ToString(), RealId = i, PrimaryReward = Hex.HexToUInt64(minerReward.Primary).ToString(), SecondaryReward = Hex.HexToUInt64(minerReward.Secondary).ToString(), CommitReward = Hex.HexToUInt64(minerReward.Committed).ToString(), ProposalReward = Hex.HexToUInt64(minerReward.Proposal).ToString(), // TODO: update Status & ConsumedTxHash Status = "live", ConsumedTxHash = "", }); }).ToArray(); return(displayInputs, displayOutputs); }
void Awake() { Instance = this; }