public override BoolValue Approve(ApproveInput approvalInput) { var proposalInfo = State.Proposals[approvalInput.ProposalId]; Assert(proposalInfo != null, "Not found proposal."); if (Context.CurrentBlockTime > proposalInfo.ExpiredTime) { // expired proposal // TODO: Set null to delete data from state db. //State.Proposals[approvalInput.ProposalId] = null; return(new BoolValue { Value = false }); } // check approval not existed Assert(!proposalInfo.ApprovedRepresentatives.Contains(Context.Sender), "Approval already existed."); var minerList = GetCurrentMinerList(); Assert(IsValidRepresentative(minerList), "Not authorized approval."); proposalInfo.ApprovedRepresentatives.Add(Context.Sender); State.Proposals[approvalInput.ProposalId] = proposalInfo; return(new BoolValue { Value = true }); }
public override BoolValue Approve(ApproveInput approvalInput) { var proposalInfo = State.Proposals[approvalInput.ProposalId]; Assert(proposalInfo != null, "Not found proposal."); if (Context.CurrentBlockTime > proposalInfo.ExpiredTime) { // expired proposal //State.Proposals[approvalInput.ProposalId] = null; return(new BoolValue { Value = false }); } // check approval not existed Assert(!proposalInfo.ApprovedReviewer.Contains(Context.Sender), "Approval already exists."); var organization = GetOrganization(proposalInfo.OrganizationAddress); var reviewer = organization.Reviewers.FirstOrDefault(r => r.Address.Equals(Context.Sender)); Assert(reviewer != null, "Not authorized approval."); proposalInfo.ApprovedReviewer.Add(Context.Sender); proposalInfo.ApprovedWeight += reviewer.Weight; State.Proposals[approvalInput.ProposalId] = proposalInfo; return(new BoolValue { Value = true }); }
public override BoolValue Approve(ApproveInput approvalInput) { var proposalInfo = State.Proposals[approvalInput.ProposalId]; Assert(proposalInfo != null, "Not found proposal."); DateTime timestamp = proposalInfo.ExpiredTime.ToDateTime(); if (Context.CurrentBlockTime > timestamp) { // expired proposal //State.Proposals[approvalInput.ProposalId] = null; return(new BoolValue { Value = false }); } // check approval not existed Assert(!proposalInfo.ApprovedReviewer.Contains(Context.Sender), "Approval already exists."); var organization = GetOrganization(proposalInfo.OrganizationAddress); var reviewer = organization.Reviewers.FirstOrDefault(r => r.Address.Equals(Context.Sender)); Assert(reviewer != null, "Not authorized approval."); proposalInfo.ApprovedReviewer.Add(Context.Sender); proposalInfo.ApprovedWeight += reviewer.Weight; State.Proposals[approvalInput.ProposalId] = proposalInfo; if (IsReadyToRelease(proposalInfo, organization)) { Context.SendVirtualInline(organization.OrganizationHash, proposalInfo.ToAddress, proposalInfo.ContractMethodName, proposalInfo.Params); //State.Proposals[approvalInput.ProposalId] = null; } return(new BoolValue { Value = true }); }
public override Empty Approve(ApproveInput input) { AssertValidToken(input.Symbol, input.Amount); State.Allowances[Context.Sender][input.Spender][input.Symbol] = State.Allowances[Context.Sender][input.Spender][input.Symbol].Add(input.Amount); Context.Fire(new Approved() { Owner = Context.Sender, Spender = input.Spender, Symbol = input.Symbol, Amount = input.Amount }); return(new Empty()); }
public override BoolValue Approve(ApproveInput approvalInput) { var proposal = GetValidProposal(approvalInput.ProposalId); AssertProposalNotYetApprovedBySender(proposal); AssertSenderIsParliamentMember(); proposal.ApprovedRepresentatives.Add(Context.Sender); State.Proposals[approvalInput.ProposalId] = proposal; return(new BoolValue { Value = true }); }
public override Empty Approve(ApproveInput input) { var tokenInfo = AssertValidToken(input.Symbol, input.Amount); Assert(!tokenInfo.IsTransferDisabled, "Token can't transfer."); State.Allowances[Context.Sender][input.Spender][input.Symbol] = State.Allowances[Context.Sender][input.Spender][input.Symbol].Add(input.Amount); Context.Fire(new Approved() { Owner = Context.Sender, Spender = input.Spender, Symbol = input.Symbol, Amount = input.Amount }); return(new Empty()); }
public override BoolValue Approve(ApproveInput input) { var proposal = GetValidProposal(input.ProposalId); AssertProposalNotYetApprovedBySender(proposal); var organization = GetOrganization(proposal.OrganizationAddress); var reviewer = GetReviewerObjectForSender(organization); proposal.ApprovedReviewer.Add(Context.Sender); proposal.ApprovedWeight += reviewer.Weight; State.Proposals[input.ProposalId] = proposal; return(new BoolValue { Value = true }); }
public override BoolValue Approve(ApproveInput approvalInput) { var proposalInfo = State.Proposals[approvalInput.ProposalId]; Assert(proposalInfo != null, "Not found proposal."); DateTime timestamp = proposalInfo.ExpiredTime.ToDateTime(); if (Context.CurrentBlockTime > timestamp) { // expired proposal // TODO: Set null to delete data from state db. //State.Proposals[approvalInput.ProposalId] = null; return(new BoolValue { Value = false }); } // check approval not existed Assert(!proposalInfo.ApprovedRepresentatives.Contains(Context.Sender), "Approval already existed."); var representatives = GetRepresentatives(); Assert(IsValidRepresentative(representatives), "Not authorized approval."); proposalInfo.ApprovedRepresentatives.Add(Context.Sender); State.Proposals[approvalInput.ProposalId] = proposalInfo; var organization = State.Organisations[proposalInfo.OrganizationAddress]; if (IsReadyToRelease(proposalInfo, organization, representatives)) { Context.SendVirtualInline(organization.OrganizationHash, proposalInfo.ToAddress, proposalInfo.ContractMethodName, proposalInfo.Params); //State.Proposals[approvalInput.ProposalId] = null; } return(new BoolValue { Value = true }); }