import { PublicKeys } from '@aztec/stdlib/keys';
import { ProtocolContractAddress, ProtocolContractClassId, ProtocolContractClassIdPreimage, ProtocolContractInitializationHash, ProtocolContractPrivateFunctions, ProtocolContractSalt } from './protocol_contract_data.js';
/**
 * Reconstructs a ProtocolContract from precomputed data without performing any hash computations.
 * Internal to the protocol-contracts package — not part of the public API.
 */ export function makeProtocolContract(name, artifact) {
    const address = ProtocolContractAddress[name];
    const salt = ProtocolContractSalt[name];
    const classId = ProtocolContractClassId[name];
    const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment } = ProtocolContractClassIdPreimage[name];
    const initializationHash = ProtocolContractInitializationHash[name];
    const contractClass = {
        id: classId,
        version: 1,
        artifactHash,
        privateFunctionsRoot,
        publicBytecodeCommitment,
        packedBytecode: artifact.functions.find((f)=>f.name === 'public_dispatch')?.bytecode ?? Buffer.alloc(0),
        privateFunctions: ProtocolContractPrivateFunctions[name]
    };
    const instance = {
        version: 1,
        currentContractClassId: classId,
        originalContractClassId: classId,
        initializationHash,
        publicKeys: PublicKeys.default(),
        salt,
        deployer: address,
        address
    };
    return {
        instance,
        contractClass,
        artifact,
        address
    };
}
