"use strict";
// Goal of this file is to inject all necessary device/signer dependency to coin-modules
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolver = exports.messageSigner = exports.cliTools = exports.bridge = void 0;
const index_1 = require("@ledgerhq/coin-filecoin/index");
const ledger_filecoin_1 = __importDefault(require("@zondax/ledger-filecoin"));
const index_2 = __importDefault(require("@ledgerhq/coin-filecoin/signer/index"));
const hw_signMessage_1 = require("@ledgerhq/coin-filecoin/hw-signMessage");
const cli_1 = __importDefault(require("@ledgerhq/coin-filecoin/test/cli"));
const setup_1 = require("../../bridge/setup");
const common_1 = require("./common");
const createSigner = (transport) => {
    const filecoin = new ledger_filecoin_1.default(transport);
    return {
        showAddressAndPubKey: async (path) => {
            const r = await filecoin.showAddressAndPubKey((0, common_1.getPath)(path));
            (0, common_1.isError)(r);
            return r;
        },
        getAddressAndPubKey: async (path) => {
            const r = await filecoin.getAddressAndPubKey((0, common_1.getPath)(path));
            (0, common_1.isError)(r);
            return r;
        },
        sign: async (path, message) => {
            const r = await filecoin.sign((0, common_1.getPath)(path), message);
            (0, common_1.isError)(r);
            return r;
        },
    };
};
const bridge = (0, index_1.createBridges)((0, setup_1.executeWithSigner)(createSigner));
exports.bridge = bridge;
const messageSigner = {
    signMessage: hw_signMessage_1.signMessage,
};
exports.messageSigner = messageSigner;
const resolver = (0, setup_1.createResolver)(createSigner, index_2.default);
exports.resolver = resolver;
const cliTools = (0, cli_1.default)();
exports.cliTools = cliTools;
//# sourceMappingURL=setup.js.map