Exemplo n.º 1
0
def reject_add_role_admins(txn_key, batch_key, proposal_id, role_id, user_id,
                           reason):

    reject_add_payload = role_transaction_pb2.RejectAddRoleAdmin(
        proposal_id=proposal_id,
        role_id=role_id,
        user_id=user_id,
        reason=reason)

    inputs = [
        addresser.role.admin.address(role_id, txn_key.public_key),
        addresser.user.address(txn_key.public_key),
    ]
    inputs.append(addresser.proposal.address(role_id, user_id))

    outputs = [addresser.proposal.address(role_id, user_id)]

    rbac_payload = rbac_payload_pb2.RBACPayload(
        content=reject_add_payload.SerializeToString(),
        message_type=rbac_payload_pb2.RBACPayload.REJECT_ADD_ROLE_ADMIN,
        inputs=inputs,
        outputs=outputs,
    )

    return make_header_and_batch(rbac_payload, inputs, outputs, txn_key,
                                 batch_key)
def apply_reject(header, payload, state):
    reject_payload = role_transaction_pb2.RejectAddRoleAdmin()
    reject_payload.ParseFromString(payload.content)

    txn_signer_admin_address = addresser.make_role_admins_address(
        role_id=reject_payload.role_id, user_id=header.signer_public_key
    )

    state_entries = role_validator.get_state_entries(
        header=header,
        confirm=reject_payload,
        txn_signer_rel_address=txn_signer_admin_address,
        state=state,
    )

    state_change.reject_role_action(
        state_entries, header, reject=reject_payload, state=state
    )