import { encodeFunctionData } from "viem";
import { ContractType, ENVIRONMENT } from "../types/dimo.js";
import { BURN_VEHICLE } from "../constants/methods.js";
import { CHAIN_ABI_MAPPING, ENV_MAPPING } from "../constants/mappings.js";
import { executeTransaction } from "../transactions/execute.js";
export function burnVehicleCallData(args, environment = "prod") {
    var _a;
    const contracts = CHAIN_ABI_MAPPING[(_a = ENV_MAPPING.get(environment)) !== null && _a !== void 0 ? _a : ENVIRONMENT.PROD].contracts;
    return encodeFunctionData({
        abi: contracts[ContractType.DIMO_VEHICLE_ID].abi,
        functionName: BURN_VEHICLE,
        args: [args.tokenId],
    });
}
export const burnVehicleTransaction = async (args, subOrganizationId, walletAddress, passkeyStamper, config) => {
    var _a, _b;
    const env = (_b = ENV_MAPPING.get((_a = config.environment) !== null && _a !== void 0 ? _a : "prod")) !== null && _b !== void 0 ? _b : ENVIRONMENT.PROD;
    const contracts = CHAIN_ABI_MAPPING[env].contracts;
    const sendDIMOCallData = burnVehicleCallData(args, config.environment);
    const txData = {
        callType: "call",
        to: contracts[ContractType.DIMO_VEHICLE_ID].address,
        value: BigInt("0"),
        data: sendDIMOCallData,
    };
    const resp = await executeTransaction(subOrganizationId, walletAddress, txData, passkeyStamper, config);
    return resp;
};
export async function burnVehicle(args, client, environment = "prod") {
    var _a;
    const contracts = CHAIN_ABI_MAPPING[(_a = ENV_MAPPING.get(environment)) !== null && _a !== void 0 ? _a : ENVIRONMENT.PROD].contracts;
    return await client.account.encodeCallData({
        to: contracts[ContractType.DIMO_VEHICLE_ID].address,
        value: BigInt(0),
        data: encodeFunctionData({
            abi: contracts[ContractType.DIMO_VEHICLE_ID].abi,
            functionName: BURN_VEHICLE,
            args: [args.tokenId],
        }),
    });
}
export async function burnVehicleBatch(args, client, environment = "prod") {
    var _a;
    const contracts = CHAIN_ABI_MAPPING[(_a = ENV_MAPPING.get(environment)) !== null && _a !== void 0 ? _a : ENVIRONMENT.PROD].contracts;
    const callData = args.map((arg) => {
        return {
            to: contracts[ContractType.DIMO_VEHICLE_ID].address,
            value: BigInt(0),
            data: encodeFunctionData({
                abi: contracts[ContractType.DIMO_VEHICLE_ID].abi,
                functionName: BURN_VEHICLE,
                args: [arg.tokenId],
            }),
        };
    });
    return await client.account.encodeCallData(callData);
}
// Burn Vehicle-- cant burn if you still have AD attached
// 0xc46a516800000000000000000000000000000000000000000000000000000000000000f6
//# sourceMappingURL=burnVehicle.js.map