import { estimateContractGas, simulateContract } from 'viem/actions';
import { CREATEX_ADDRESS, createXABI } from './constants.js';
export const deployCreate2Contract = async ({ client, salt, initCode, createXAddress, }) => {
    const hash = await client.writeContract({
        abi: createXABI,
        chain: client.chain,
        account: client.account,
        address: createXAddress ?? CREATEX_ADDRESS,
        functionName: 'deployCreate2',
        args: [salt, initCode],
    });
    return hash;
};
export const simulateDeployCreate2Contract = async ({ client, salt, initCode, createXAddress, }) => {
    const result = await simulateContract(client, {
        abi: createXABI,
        account: client.account?.address,
        address: createXAddress ?? CREATEX_ADDRESS,
        functionName: 'deployCreate2',
        args: [salt, initCode],
    });
    return result.result;
};
export const estimateDeployCreate2Contract = async ({ client, salt, initCode, createXAddress, }) => {
    return await estimateContractGas(client, {
        abi: createXABI,
        address: createXAddress ?? CREATEX_ADDRESS,
        functionName: 'deployCreate2',
        args: [salt, initCode],
    });
};
