var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
        to[j] = from[i];
    return to;
};
import { PublicKey, SystemProgram, SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY, } from "@solana/web3.js";
import { createReadOnlyWormholeProgramInterface } from "../program";
import { deriveFeeCollectorKey, deriveGuardianSetKey, deriveWormholeBridgeDataKey, } from "../accounts";
export function createInitializeInstruction(wormholeProgramId, payer, guardianSetExpirationTime, fee, initialGuardians) {
    var methods = createReadOnlyWormholeProgramInterface(wormholeProgramId).methods.initialize(guardianSetExpirationTime, fee, initialGuardians);
    // @ts-ignore
    return methods._ixFn.apply(methods, __spreadArray(__spreadArray([], __read(methods._args)), [{
            accounts: getInitializeAccounts(wormholeProgramId, payer),
            signers: undefined,
            remainingAccounts: undefined,
            preInstructions: undefined,
            postInstructions: undefined,
        }]));
}
export function getInitializeAccounts(wormholeProgramId, payer) {
    return {
        bridge: deriveWormholeBridgeDataKey(wormholeProgramId),
        guardianSet: deriveGuardianSetKey(wormholeProgramId, 0),
        feeCollector: deriveFeeCollectorKey(wormholeProgramId),
        payer: new PublicKey(payer),
        clock: SYSVAR_CLOCK_PUBKEY,
        rent: SYSVAR_RENT_PUBKEY,
        systemProgram: SystemProgram.programId,
    };
}
