const zero = "0x0000000000000000000000000000000000000000";
/**
 * CREATE2-deterministic core addresses — identical on every chain (gitCommit 1199b33,
 * deployment mode: create2-global-salt, factory: 0x4e59b44847b379578588920cA78FbF26c0B4956C).
 *
 * Because kernel, safeModuleEnabler, and standardFeePolicy are the same on every chain,
 * SailKernel.createAccount produces the same SMA address with the same owner/manager/salt
 * on every supported chain — enabling true cross-chain deterministic SMA deployment.
 */
const CREATE2_KERNEL = "0x02ABC18B65A328de2e749F56ba79ACF2718a6659";
const CREATE2_GOVERNANCE = "0x7A478118715791728BDE3bc7A4D7ECfdEB89C6EC";
const CREATE2_TIMELOCK = "0xE48Ba8DB6d748adafD13155c3590f62e58a77f56";
const CREATE2_SAFE_MODULE_ENABLER = "0x7897Cb53a4be4a2eaAf46D60573C4Fd83b33fE1F";
const CREATE2_MANDATE_FACTORY = "0x14EDd6c2a56EfC0d71E215ab13094B9AF90543d2";
const CREATE2_STANDARD_FEE_POLICY = "0xe7B5901b839cFFDEd9D4108A22712C8BfdA1D80D";
const CREATE2_TREASURY = "0xB01dCE443d052e44b7D13726c0EC9fFB7f5815B6";
export const sailDeployments = {
    // ── Ethereum mainnet ─────────────────────────────────────────────────────────
    1: {
        // CREATE2 deterministic deploy (2026-06-09, gitCommit 1199b33).
        // allowlistBootstrapped=true (genesis bootstrap), zero fees, 48h timelock.
        chainId: 1,
        blockNumber: 25280925,
        deployer: CREATE2_TREASURY,
        governance: CREATE2_GOVERNANCE,
        timelock: CREATE2_TIMELOCK,
        kernel: CREATE2_KERNEL,
        mandateFactory: CREATE2_MANDATE_FACTORY,
        standardFeePolicy: CREATE2_STANDARD_FEE_POLICY,
        safeModuleEnabler: CREATE2_SAFE_MODULE_ENABLER,
        treasury: CREATE2_TREASURY,
        maxPermissionFeeWei: 1000000000000000n,
        initialBaseFee: 0n,
        initialComplexityRate: 0n,
        dispatchModel: "selective",
        knownTemplates: [],
        standaloneTemplates: {},
    },
    // ── Base mainnet ─────────────────────────────────────────────────────────────
    8453: {
        // CREATE2 deterministic deploy (2026-06-09, gitCommit 1199b33). Supersedes
        // 0x6319d3dfDDe3804ba93D65752b00c52bFb05a1ab (SAIL-405 redeploy).
        // allowlistBootstrapped=true, zero fees, 48h timelock.
        chainId: 8453,
        blockNumber: 47115338,
        deployer: CREATE2_TREASURY,
        governance: CREATE2_GOVERNANCE,
        timelock: CREATE2_TIMELOCK,
        kernel: CREATE2_KERNEL,
        mandateFactory: CREATE2_MANDATE_FACTORY,
        standardFeePolicy: CREATE2_STANDARD_FEE_POLICY,
        safeModuleEnabler: CREATE2_SAFE_MODULE_ENABLER,
        treasury: CREATE2_TREASURY,
        maxPermissionFeeWei: 1000000000000000n,
        initialBaseFee: 0n,
        initialComplexityRate: 0n,
        dispatchModel: "selective",
        knownTemplates: [],
        standaloneTemplates: {},
    },
    // ── Arbitrum mainnet ─────────────────────────────────────────────────────────
    42161: {
        // CREATE2 deterministic deploy (2026-06-09, gitCommit 1199b33). Supersedes
        // 0x2716B12832DED0EF5688519c5Fe069EFc0374E02 (SAIL-405 redeploy).
        // allowlistBootstrapped=true, zero fees, 48h timelock.
        chainId: 42161,
        blockNumber: 471736462,
        deployer: CREATE2_TREASURY,
        governance: CREATE2_GOVERNANCE,
        timelock: CREATE2_TIMELOCK,
        kernel: CREATE2_KERNEL,
        mandateFactory: CREATE2_MANDATE_FACTORY,
        standardFeePolicy: CREATE2_STANDARD_FEE_POLICY,
        safeModuleEnabler: CREATE2_SAFE_MODULE_ENABLER,
        treasury: CREATE2_TREASURY,
        maxPermissionFeeWei: 1000000000000000n,
        initialBaseFee: 0n,
        initialComplexityRate: 0n,
        dispatchModel: "selective",
        knownTemplates: [],
        standaloneTemplates: {},
    },
    // ── Unichain mainnet ─────────────────────────────────────────────────────────
    130: {
        // CREATE2 deterministic deploy (2026-06-09, gitCommit 1199b33). Supersedes
        // 0xD985029960a9B7C2E7E38e102C448b8b8539B156 (SAIL-406 deploy).
        // NOTE: knownTemplates and standaloneTemplates from SAIL-406 were deployed
        // against the old kernel 0xD985029... and are now invalid. They must be
        // redeployed against the new kernel 0x02ABC1... and re-populated here.
        chainId: 130,
        blockNumber: 50271704,
        deployer: CREATE2_TREASURY,
        governance: CREATE2_GOVERNANCE,
        timelock: CREATE2_TIMELOCK,
        kernel: CREATE2_KERNEL,
        mandateFactory: CREATE2_MANDATE_FACTORY,
        standardFeePolicy: CREATE2_STANDARD_FEE_POLICY,
        safeModuleEnabler: CREATE2_SAFE_MODULE_ENABLER,
        treasury: CREATE2_TREASURY,
        maxPermissionFeeWei: 1000000000000000n,
        initialBaseFee: 0n,
        initialComplexityRate: 0n,
        dispatchModel: "selective",
        // Templates cleared: the SAIL-406 shared + standalone templates were deployed
        // against the old kernel (0xD985029...) and are invalid against the new one.
        // Re-populate after redeploying templates against 0x02ABC1...
        knownTemplates: [],
        standaloneTemplates: {},
    },
    // ── Base Sepolia (testnet) ───────────────────────────────────────────────────
    84532: {
        // CREATE2 deterministic deploy (2026-06-09, gitCommit 1199b33). Supersedes
        // 0xf1D0F4C9893612627409948BAa9d82a01a373799 (SAIL-405 redeploy).
        // allowlistBootstrapped=true, zero fees, 48h timelock.
        chainId: 84532,
        blockNumber: 42625843,
        deployer: CREATE2_TREASURY,
        governance: CREATE2_GOVERNANCE,
        timelock: CREATE2_TIMELOCK,
        kernel: CREATE2_KERNEL,
        mandateFactory: CREATE2_MANDATE_FACTORY,
        standardFeePolicy: CREATE2_STANDARD_FEE_POLICY,
        safeModuleEnabler: CREATE2_SAFE_MODULE_ENABLER,
        treasury: CREATE2_TREASURY,
        maxPermissionFeeWei: 1000000000000000n,
        initialBaseFee: 0n,
        initialComplexityRate: 0n,
        dispatchModel: "selective",
        knownTemplates: [],
        standaloneTemplates: {},
    },
    // ── Eth Sepolia (testnet) ────────────────────────────────────────────────────
    11155111: {
        // CREATE2 deterministic deploy (2026-06-09, gitCommit 1199b33).
        // allowlistBootstrapped=true, zero fees, 48h timelock.
        chainId: 11155111,
        blockNumber: 11023571,
        deployer: CREATE2_TREASURY,
        governance: CREATE2_GOVERNANCE,
        timelock: CREATE2_TIMELOCK,
        kernel: CREATE2_KERNEL,
        mandateFactory: CREATE2_MANDATE_FACTORY,
        standardFeePolicy: CREATE2_STANDARD_FEE_POLICY,
        safeModuleEnabler: CREATE2_SAFE_MODULE_ENABLER,
        treasury: CREATE2_TREASURY,
        maxPermissionFeeWei: 1000000000000000n,
        initialBaseFee: 0n,
        initialComplexityRate: 0n,
        dispatchModel: "selective",
        knownTemplates: [],
        standaloneTemplates: {},
    },
};
export function getSailDeployment(chainId) {
    const deployment = sailDeployments[chainId];
    if (!deployment) {
        throw new Error(`No Sail deployment is bundled for chain ${chainId}`);
    }
    return deployment;
}
export function normalizeDeployment(input) {
    // Guard: mandateFactory is required. Accept the legacy permissionFactory alias too,
    // but if both are absent the config is malformed — cast-to-Address would silently
    // produce undefined and cause a confusing runtime error far from the source.
    if (!input.mandateFactory && !input.permissionFactory) {
        throw new Error('normalizeDeployment: deployment config is missing "mandateFactory" ' +
            '(and the legacy "permissionFactory" alias). ' +
            "Add a mandateFactory address to the deployment configuration.");
    }
    return {
        chainId: Number(input.chainId),
        blockNumber: Number(input.blockNumber),
        deployer: input.deployer ?? zero,
        governance: input.governance,
        timelock: input.timelock,
        kernel: input.kernel,
        // Accept both names: new manifests use mandateFactory; old ones used permissionFactory.
        mandateFactory: (input.mandateFactory ?? input.permissionFactory),
        standardFeePolicy: input.standardFeePolicy,
        safeModuleEnabler: input.safeModuleEnabler,
        treasury: input.treasury,
        maxPermissionFeeWei: BigInt(input.maxPermissionFeeWei),
        initialBaseFee: BigInt(input.initialBaseFee),
        initialComplexityRate: BigInt(input.initialComplexityRate),
        dispatchModel: input.dispatchModel,
    };
}
//# sourceMappingURL=deployments.js.map