def reject_manager(txn_key, batch_key, proposal_id, reason, user_id,
                   manager_id):
    """Create a BatchList with a RejectUpdateUserManager in it.

    Args:
        txn_key (Key): The public/private key pair for signing the txn.
        batch_key (Key): The public/private key pair for signing the batch.
        proposal_id (str): The identifier of the proposal.
        reason (str): The client supplied reason for rejecting the proposal.
        user_id (str): The user's public key.
        manager_id (str): The manager's public key.

    Returns:
        tuple
            BatchList, signature tuple
    """

    reject_update_payload = user_transaction_pb2.RejectUpdateUserManager(
        proposal_id=proposal_id,
        user_id=user_id,
        manager_id=manager_id,
        reason=reason)

    inputs = [
        addresser.proposal.address(object_id=user_id, related_id=manager_id),
        addresser.user.address(txn_key.public_key),
    ]

    outputs = [
        addresser.proposal.address(object_id=user_id, related_id=manager_id)
    ]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject_update_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_UPDATE_USER_MANAGER,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(
        rbac_payload=rbac_payload,
        inputs=inputs,
        outputs=outputs,
        txn_key=txn_key,
        batch_key=batch_key,
    )
コード例 #2
0
def apply_user_reject(header, payload, state):
    reject_payload = user_transaction_pb2.RejectUpdateUserManager()
    reject_payload.ParseFromString(payload.content)

    proposal_address = addresser.proposal.address(
        object_id=reject_payload.user_id, target_id=reject_payload.manager_id
    )

    state_entries = state_accessor.get_state(state, [proposal_address])

    if not proposal_validator.proposal_exists_and_open(
        state_entries=state_entries,
        proposal_address=proposal_address,
        proposal_id=reject_payload.proposal_id,
    ):
        raise InvalidTransaction(
            "Proposal {} is not open or does not "
            "exist".format(reject_payload.proposal_id)
        )

    entry = state_accessor.get_state_entry(state_entries, proposal_address)

    proposal_container = message_accessor.get_prop_container(entry)

    if not reject_payload.manager_id == header.signer_public_key:
        raise InvalidTransaction(
            "Proposal expected closer to be {} while txn "
            "signer was {}".format(reject_payload.manager_id, header.signer_public_key)
        )

    proposal = message_accessor.get_prop_from_container(
        proposal_container, reject_payload.proposal_id
    )

    state_change.reject_state_change(
        container=proposal_container,
        proposal=proposal,
        closer=header.signer_public_key,
        reason=reject_payload.reason,
        address=proposal_address,
        state=state,
    )