Beispiel #1
0
    def resolve_threshold(self: Project, info) -> float or None:
        if self is None:
            return None

        base_dao_contract = deploy.get_dao_contract(self.dao_address)

        return base_dao_contract.functions.threshold().call()
Beispiel #2
0
def _get_voters_for_asc(asc: ASC) -> List[str]:
    # If the asc hasn't been deployed, we can't call any functions on it because
    # it has no address
    if asc.blockchain_state != BlockchainState.COMPLETED:
        return []

    dao_contract = deploy.get_dao_contract(asc.project.dao_address)

    return dao_contract.functions.getAscVotes(asc.address).call()
Beispiel #3
0
    def resolve_vote_amount(self: ASC, info) -> float:
        voters = _get_voters_for_asc(self)
        dao_contract = deploy.get_dao_contract(self.project.dao_address)

        vote_counts = 0.0
        for voter in voters:
            vote_counts += dao_contract.functions.balanceOf(voter).call()

        return vote_counts
Beispiel #4
0
    def resolve_balances(self: Project, info) -> List[BalanceType] or None:
        if self is None:
            return None

        balances = {}

        base_dao_contract = deploy.get_dao_contract(self.dao_address)

        transactors = base_dao_contract.functions.getTransactors().call()

        for transactor in transactors:
            balances[transactor] = base_dao_contract.functions.balanceOf(
                transactor).call()

        return [
            BalanceType(address=transactor, balance=balance)
            for transactor, balance in balances.items()
        ]
Beispiel #5
0
def _get_voters_for_asc(asc: ASC) -> List[str]:
    dao_contract = deploy.get_dao_contract(asc.project.dao_address)

    return dao_contract.functions.getAscVotes(asc.address).call()