Beispiel #1
0
 def encode_for_smc(self) -> bytes:
     encoded = b"".join([
         int_to_bytes32(self.shard_id),
         self.chunk_root,
         int_to_bytes32(self.period),
         pad32(self.proposer_address),
     ])
     if len(encoded) != self.smc_encoded_size:
         raise ValueError(
             "Encoded header size is {} instead of {} bytes".format(
                 len(encoded),
                 self.smc_encoded_size,
             ))
     return encoded
Beispiel #2
0
def generate_safe_contract_address(address: Address, salt: int,
                                   call_data: bytes) -> Address:
    return force_bytes_to_address(
        keccak(b'\xff' + address + int_to_bytes32(salt) + keccak(call_data)))
def test_int_to_bytes32_invalid(value):
    with pytest.raises(ValueError):
        int_to_bytes32(value)
def test_int_to_bytes32_valid(value, expected):
    assert int_to_bytes32(value) == expected