MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / ProcessAxcInFee

Function ProcessAxcInFee

src/entities/proposal.cpp:587–625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585}
586
587bool ProcessAxcInFee(CTxExecuteContext& context, CBaseTx& tx, TokenSymbol& selfChainTokenSymbol, uint64_t& swapFees) {
588 IMPLEMENT_DEFINE_CW_STATE
589
590 vector<CRegID> govBpRegIds;
591 TxID proposalId = ((CProposalApprovalTx &) tx).proposal_id;
592 if (!cw.sysGovernCache.GetApprovalList(proposalId, govBpRegIds) || govBpRegIds.size() == 0)
593 return state.DoS(100, ERRORMSG("failed to get BP Governors"),
594 REJECT_INVALID, "bad-get-bp-governors");
595
596 uint64_t swapFeesPerBp = swapFees / (govBpRegIds.size() + 3);
597 for (const auto &bpRegID : govBpRegIds) {
598 auto spBpAccount = tx.GetAccount(context, bpRegID, "self_chain");
599 if (!spBpAccount) return false;
600
601 if (!spBpAccount->OperateBalance(selfChainTokenSymbol, BalanceOpType::ADD_FREE, swapFeesPerBp,
602 ReceiptType::AXC_REWARD_FEE_TO_GOVERNOR, tx.receipts))
603 return state.DoS(100,
604 ERRORMSG("opreate balance failed, swapFeesPerBp=%llu",
605 swapFeesPerBp), REJECT_INVALID, "bad-operate-balance");
606 }
607
608 uint64_t swapFeeForGw = swapFees - swapFeesPerBp * govBpRegIds.size();
609
610 CRegID axcgwId;
611 if(!cw.sysParamCache.GetAxcSwapGwRegId(axcgwId)) {
612 return state.DoS(100, ERRORMSG("failed to get GW regid (%s)",
613 axcgwId.ToString()),
614 REJECT_INVALID, "bad-get-gw-account");
615 }
616
617 auto spAxcgwAccount = tx.GetAccount(context, axcgwId, "axcgwId");
618 if (!spAxcgwAccount) return false;
619
620 if (!spAxcgwAccount->OperateBalance(selfChainTokenSymbol, BalanceOpType::ADD_FREE, swapFeeForGw,
621 ReceiptType::AXC_REWARD_FEE_TO_GW, tx.receipts))
622 return state.DoS(100, ERRORMSG("opreate balance failed, swapFeesPerBp=%llu",
623 swapFeesPerBp), REJECT_INVALID, "bad-operate-balance");
624 return true;
625}
626
627bool CGovAxcInProposal::ExecuteProposal(CTxExecuteContext& context, CBaseTx& tx) {
628 IMPLEMENT_DEFINE_CW_STATE;

Callers 1

ExecuteProposalMethod · 0.85

Calls 7

GetApprovalListMethod · 0.80
DoSMethod · 0.80
OperateBalanceMethod · 0.80
GetAxcSwapGwRegIdMethod · 0.80
sizeMethod · 0.45
GetAccountMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected