// SPDX-License-Identifier: Apache-2.0
import ContractId from "./ContractId";
import { InvalidEvmAddress } from "./error/InvalidEvmAddress";
export default class EvmAddress {
    value;
    constructor(value) {
        if (value.length == 42 && value.startsWith("0x")) {
            this.value = value;
        }
        else if (value.length === 40) {
            this.value = "0x" + value;
        }
        else {
            throw new InvalidEvmAddress(value);
        }
    }
    toContractId() {
        return ContractId.fromHederaEthereumAddress(this.value);
    }
    toString() {
        return this.value;
    }
}
