def _encode_proposal(w: bytearray, proposal): write_uint8(w, helpers.OP_TAG_PROPOSALS) write_bytes_fixed(w, proposal.source, helpers.TAGGED_PUBKEY_HASH_SIZE) write_uint32_be(w, proposal.period) write_uint32_be(w, len(proposal.proposals) * helpers.PROPOSAL_HASH_SIZE) for proposal_hash in proposal.proposals: write_bytes_fixed(w, proposal_hash, helpers.PROPOSAL_HASH_SIZE)
def _encode_ballot(w: bytearray, ballot): ballot_tag = 6 write_uint8(w, ballot_tag) write_bytes_unchecked(w, ballot.source) write_uint32_be(w, ballot.period) write_bytes_unchecked(w, ballot.proposal) write_uint8(w, ballot.ballot)
def _encode_proposal(w: bytearray, proposal): proposal_tag = 5 write_uint8(w, proposal_tag) write_bytes_unchecked(w, proposal.source) write_uint32_be(w, proposal.period) write_uint32_be(w, len(proposal.proposals) * PROPOSAL_LENGTH) for proposal_hash in proposal.proposals: write_bytes_unchecked(w, proposal_hash)
def _encode_manager_common(w: bytearray, sequence_length, operation, to_contract=False): IMPLICIT_ADDRESS_LENGTH = 21 SMART_CONTRACT_ADDRESS_LENGTH = 22 # 5 = tag and sequence_length (1 byte + 4 bytes) argument_length = sequence_length + 5 helpers.write_bool(w, True) write_uint8(w, helpers.DO_ENTRYPOINT_TAG) write_uint32_be(w, argument_length) write_uint8(w, helpers.MICHELSON_SEQUENCE_TAG) write_uint32_be(w, sequence_length) helpers.write_instruction(w, "DROP") helpers.write_instruction(w, "NIL") helpers.write_instruction(w, "operation") helpers.write_instruction(w, operation) if to_contract is True: helpers.write_instruction(w, "address") else: helpers.write_instruction(w, "key_hash") if operation == "PUSH": write_bytes_unchecked(w, bytes([10])) # byte sequence if to_contract is True: write_uint32_be(w, SMART_CONTRACT_ADDRESS_LENGTH) else: write_uint32_be(w, IMPLICIT_ADDRESS_LENGTH)
def _encode_manager_common(w: bytearray, sequence_length, operation, to_contract=False): # 5 = tag and sequence_length (1 byte + 4 bytes) argument_length = sequence_length + 5 helpers.write_bool(w, True) write_uint8(w, helpers.DO_ENTRYPOINT_TAG) write_uint32_be(w, argument_length) write_uint8(w, helpers.MICHELSON_SEQUENCE_TAG) write_uint32_be(w, sequence_length) helpers.write_instruction(w, "DROP") helpers.write_instruction(w, "NIL") helpers.write_instruction(w, "operation") helpers.write_instruction(w, operation) if to_contract is True: helpers.write_instruction(w, "address") else: helpers.write_instruction(w, "key_hash") if operation == "PUSH": write_uint8(w, 10) # byte sequence if to_contract is True: write_uint32_be(w, helpers.CONTRACT_ID_SIZE) else: write_uint32_be(w, helpers.TAGGED_PUBKEY_HASH_SIZE)
def _encode_ballot(w: bytearray, ballot): write_uint8(w, helpers.OP_TAG_BALLOT) write_bytes_fixed(w, ballot.source, helpers.TAGGED_PUBKEY_HASH_SIZE) write_uint32_be(w, ballot.period) write_bytes_fixed(w, ballot.proposal, helpers.PROPOSAL_HASH_SIZE) write_uint8(w, ballot.ballot)