// Goal of this file is to inject all necessary device/signer dependency to coin-modules
import { createBridges } from "@ledgerhq/coin-solana/bridge/js";
import makeCliTools from "@ledgerhq/coin-solana/cli-transaction";
import solanaResolver from "@ledgerhq/coin-solana/hw-getAddress";
import { createMessageSigner, createResolver, executeWithSigner } from "../../bridge/setup";
import { getCurrencyConfiguration } from "../../config";
import { getCryptoCurrencyById } from "../../currencies";
import { signMessage } from "@ledgerhq/coin-solana/hw-signMessage";
import { LegacySignerSolana, DmkSignerSol } from "@ledgerhq/live-signer-solana";
import { DeviceManagementKit } from "@ledgerhq/device-management-kit";
let _solanaLdmkFFEnabled = false;
let _dmkSignerInstance = null;
// temporary solution to dynamically enable/disable the Solana DMK signer,
// waiting for LIVE-20250 to be implemented
// to be removed together with useFeature("ldmkSolanaSigner")
export function setSolanaLdmkEnabled(enabled) {
    _solanaLdmkFFEnabled = enabled;
}
const canDMKSignerBeUsed = (transport) => _solanaLdmkFFEnabled &&
    transport.dmk instanceof DeviceManagementKit &&
    typeof transport.sessionId === "string";
// get the same instance if FF gets flipped
export function getSolanaSignerInstance(transport) {
    if (canDMKSignerBeUsed(transport)) {
        if (!_dmkSignerInstance) {
            _dmkSignerInstance = new DmkSignerSol(transport.dmk, transport.sessionId);
        }
        return _dmkSignerInstance;
    }
    else {
        return new LegacySignerSolana(transport);
    }
}
const getCurrencyConfig = () => getCurrencyConfiguration(getCryptoCurrencyById("solana"));
const bridge = createBridges(executeWithSigner(getSolanaSignerInstance), getCurrencyConfig);
const messageSigner = {
    signMessage: createMessageSigner(getSolanaSignerInstance, signMessage),
};
const resolver = createResolver(getSolanaSignerInstance, solanaResolver);
const cliTools = makeCliTools();
export { bridge, cliTools, messageSigner, resolver };
//# sourceMappingURL=setup.js.map