Пример #1
0
def handle_propose_state_set(state_entries,
                             header,
                             payload,
                             address,
                             proposal_type,
                             state,
                             related_type='user_id'):
    try:

        entry = get_state_entry(state_entries, address=address)
        proposal_container = return_prop_container(entry)
    except KeyError:
        proposal_container = proposal_state_pb2.ProposalsContainer()

    proposal = proposal_container.proposals.add()

    proposal.proposal_id = payload.proposal_id
    proposal.object_id = payload.task_id
    proposal.target_id = getattr(payload, related_type)
    proposal.proposal_type = proposal_type
    proposal.status = proposal_state_pb2.Proposal.OPEN
    proposal.opener = header.signer_public_key
    proposal.open_reason = payload.reason
    proposal.metadata = payload.metadata

    set_state(state, {address: proposal_container.SerializeToString()})
Пример #2
0
def handle_state_set(proposal_state_entries, header, user_proposal, state):
    proposal_address = addresser.make_proposal_address(
        user_proposal.user_id, user_proposal.new_manager_id)
    try:

        state_entry = get_state_entry(proposal_state_entries, proposal_address)
        proposal_container = return_prop_container(state_entry)

    except KeyError:
        proposal_container = proposal_state_pb2.ProposalsContainer()

    proposal = proposal_container.proposals.add()
    proposal.proposal_id = user_proposal.proposal_id
    proposal.proposal_type = proposal_state_pb2.Proposal.UPDATE_USER_MANAGER
    proposal.object_id = user_proposal.user_id
    proposal.target_id = user_proposal.new_manager_id
    proposal.opener = header.signer_pubkey
    proposal.status = proposal_state_pb2.Proposal.OPEN
    proposal.open_reason = user_proposal.reason
    proposal.metadata = user_proposal.metadata

    set_state(state, [
        StateEntry(address=proposal_address,
                   data=proposal_container.SerializeToString())
    ])
Пример #3
0
def return_prop_container(entry):

    prop_container = proposal_state_pb2.ProposalsContainer()
    prop_container.ParseFromString(entry.data)

    return prop_container