"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.owner = exports.connection = exports.program = exports.provider = void 0;
exports.createQuoteSigner = createQuoteSigner;
exports.getProgramData = getProgramData;
exports.initializeState = initializeState;
const anchor = __importStar(require("@coral-xyz/anchor"));
const web3_js_1 = require("@solana/web3.js");
const ethers_1 = require("ethers");
const web3_v1_1 = require("../../src/svm/web3-v1");
exports.provider = anchor.AnchorProvider.env();
exports.program = anchor.workspace.SponsoredCctpSrcPeriphery;
exports.connection = exports.provider.connection;
exports.owner = exports.provider.wallet.publicKey;
const solanaDomain = 5; // CCTP domain.
function createQuoteSigner() {
    const quoteSigner = ethers_1.ethers.Wallet.createRandom();
    const quoteSignerPubkey = (0, web3_v1_1.evmAddressToPublicKey)(quoteSigner.address);
    return { quoteSigner, quoteSignerPubkey };
}
function getProgramData() {
    const [programData] = web3_js_1.PublicKey.findProgramAddressSync([exports.program.programId.toBuffer()], new web3_js_1.PublicKey("BPFLoaderUpgradeab1e11111111111111111111111"));
    return programData;
}
async function initializeState({ sourceDomain = solanaDomain, signer = web3_js_1.PublicKey.default, } = {}) {
    const seeds = [Buffer.from("state")];
    const [state] = web3_js_1.PublicKey.findProgramAddressSync(seeds, exports.program.programId);
    const programData = getProgramData();
    await exports.program.methods.initialize({ sourceDomain, signer }).accounts({ programData }).rpc();
    return { programData, state, sourceDomain, signer };
}
