import { computeCreate2Address } from '../../util/createx/computeCreate2Address.js';
import { createBaseSalt, createGuardedSalt } from '../../util/createx/salt.js';
import { getEncodedConstructorArgs } from '../../util/abi.js';
import { concatHex, keccak256, toHex } from 'viem';
// Prepares params for deployCreate2
export const computeDeploymentParams = ({ forgeArtifact, constructorArgs, salt, }) => {
    const baseSalt = createBaseSalt({
        shouldAddRedeployProtection: false,
        additionalEntropy: toHex(salt, { size: 32 }),
    });
    const guardedSalt = createGuardedSalt({
        baseSalt: toHex(salt, { size: 32 }),
    });
    const encodedConstructorArgs = getEncodedConstructorArgs(forgeArtifact.abi, constructorArgs);
    const initCode = encodedConstructorArgs
        ? concatHex([forgeArtifact.bytecode.object, encodedConstructorArgs])
        : forgeArtifact.bytecode.object;
    const deterministicAddress = computeCreate2Address({
        guardedSalt,
        initCodeHash: keccak256(initCode),
    });
    return {
        initCode,
        baseSalt,
        deterministicAddress,
    };
};
