// Goal of this file is to inject all necessary device/signer dependency to coin-modules
import { createBridges } from "@ledgerhq/coin-evm/bridge/js";
import makeCliTools from "@ledgerhq/coin-evm/cli-transaction";
import evmResolver from "@ledgerhq/coin-evm/hw-getAddress";
import { prepareMessageToSign, signMessage } from "@ledgerhq/coin-evm/hw-signMessage";
import { createMessageSigner, createResolver, executeWithSigner, } from "../../bridge/setup";
import { getCurrencyConfiguration } from "../../config";
import { DmkSignerEth, LegacySignerEth } from "@ledgerhq/live-signer-evm";
const createSigner = (transport) => {
    if (isDmkTransport(transport)) {
        return new DmkSignerEth(transport.dmk, transport.sessionId);
    }
    return new LegacySignerEth(transport);
};
const isDmkTransport = (transport) => {
    return ("dmk" in transport &&
        transport.dmk !== undefined &&
        "sessionId" in transport &&
        transport.sessionId !== undefined);
};
const getCurrencyConfig = (currency) => {
    return { info: getCurrencyConfiguration(currency) };
};
const bridge = createBridges(executeWithSigner(createSigner), getCurrencyConfig);
const messageSigner = {
    prepareMessageToSign,
    signMessage: createMessageSigner(createSigner, signMessage),
};
const resolver = createResolver(createSigner, evmResolver);
const cliTools = makeCliTools();
export { bridge, cliTools, resolver, messageSigner };
//# sourceMappingURL=setup.js.map