"use strict";
// This script queries the state of a given spoke pool.
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const anchor = __importStar(require("@coral-xyz/anchor"));
const anchor_1 = require("@coral-xyz/anchor");
const web3_js_1 = require("@solana/web3.js");
const yargs_1 = __importDefault(require("yargs"));
const helpers_1 = require("yargs/helpers");
// Set up the provider
const provider = anchor_1.AnchorProvider.env();
anchor.setProvider(provider);
const idl = require("../../target/idl/svm_spoke.json");
const program = new anchor_1.Program(idl, provider);
const programId = program.programId;
// Parse arguments
const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)).option("seed", {
    type: "string",
    demandOption: true,
    describe: "Seed for the state account PDA",
}).argv;
async function queryState() {
    const resolvedArgv = await argv;
    const seed = new anchor_1.BN(resolvedArgv.seed);
    // Define the state account PDA
    const [statePda, _] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("state"), seed.toArrayLike(Buffer, "le", 8)], programId);
    console.log("Querying state...");
    console.table([
        { Property: "seed", Value: seed.toString() },
        { Property: "programId", Value: programId.toString() },
        { Property: "statePda", Value: statePda.toString() },
    ]);
    try {
        const state = await program.account.state.fetch(statePda);
        console.log("State fetched successfully:");
        console.table([
            { Property: "Owner", Value: state.owner.toString() },
            { Property: "Deposits Paused", Value: state.pausedDeposits },
            { Property: "Fills Paused", Value: state.pausedFills },
            { Property: "Number of Deposits", Value: state.numberOfDeposits.toString() },
            { Property: "Chain ID", Value: state.chainId.toString() },
            { Property: "Current Time", Value: state.currentTime.toString() },
            { Property: "Remote Domain", Value: state.remoteDomain.toString() },
            { Property: "Cross Domain Admin", Value: state.crossDomainAdmin.toString() },
            { Property: "Root Bundle ID", Value: state.rootBundleId.toString() },
            { Property: "Deposit Quote Time Buffer", Value: state.depositQuoteTimeBuffer.toString() },
            { Property: "Fill Deadline Buffer", Value: state.fillDeadlineBuffer.toString() },
        ]);
    }
    catch (error) {
        console.error("An error occurred while fetching the state:", error);
    }
}
// Run the queryState function
queryState();
