import { utils } from '@project-serum/anchor';
import { PublicKey } from '@solana/web3.js';
export const findProgramAddress = (label, programId, extraSeeds) => {
    const seeds = [Buffer.from(utils.bytes.utf8.encode(label))];
    if (extraSeeds) {
        for (const extraSeed of extraSeeds) {
            if (typeof extraSeed === 'string') {
                seeds.push(Buffer.from(utils.bytes.utf8.encode(extraSeed)));
            }
            else if (Array.isArray(extraSeed)) {
                seeds.push(Buffer.from(extraSeed));
            }
            else if (Buffer.isBuffer(extraSeed)) {
                seeds.push(extraSeed);
            }
            else {
                seeds.push(extraSeed.toBuffer());
            }
        }
    }
    const res = PublicKey.findProgramAddressSync(seeds, programId);
    return { publicKey: res[0], bump: res[1] };
};
//# sourceMappingURL=index.js.map