"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletController = void 0;
const maskWallet = (wallet) => {
    return {
        id: wallet.id,
        name: wallet.name,
        syncType: wallet.syncType,
        syncedAt: wallet.syncedAt,
        deviceIds: wallet.deviceIds,
        isAdmin: wallet.isAdmin,
        isActive: wallet.isActive,
        lastAccessedAt: wallet.lastAccessedAt,
        version: wallet.version,
        createdAt: wallet.createdAt,
        updatedAt: wallet.updatedAt,
    };
};
class WalletController {
    generateSeedphraseUseCase;
    createWalletUseCase;
    getWalletByIdUseCase;
    getWalletsByDeviceUseCase;
    getWalletAddressForNetworkUseCase;
    getAllNetworkAddressesForWalletUseCase;
    getWalletSeedPhraseUseCase;
    constructor(generateSeedphraseUseCase, createWalletUseCase, getWalletByIdUseCase, getWalletsByDeviceUseCase, getWalletAddressForNetworkUseCase, getAllNetworkAddressesForWalletUseCase, getWalletSeedPhraseUseCase) {
        this.generateSeedphraseUseCase = generateSeedphraseUseCase;
        this.createWalletUseCase = createWalletUseCase;
        this.getWalletByIdUseCase = getWalletByIdUseCase;
        this.getWalletsByDeviceUseCase = getWalletsByDeviceUseCase;
        this.getWalletAddressForNetworkUseCase = getWalletAddressForNetworkUseCase;
        this.getAllNetworkAddressesForWalletUseCase = getAllNetworkAddressesForWalletUseCase;
        this.getWalletSeedPhraseUseCase = getWalletSeedPhraseUseCase;
    }
    generateSeedphrase = async (req, res, next) => {
        try {
            const result = await this.generateSeedphraseUseCase.execute(req.body);
            res.status(200).json({ success: true, data: result });
        }
        catch (error) {
            next(error);
        }
    };
    create = async (req, res, next) => {
        try {
            const wallet = await this.createWalletUseCase.execute(req.body);
            res.status(201).json({ success: true, data: maskWallet(wallet) });
        }
        catch (error) {
            next(error);
        }
    };
    getById = async (req, res, next) => {
        try {
            const wallet = await this.getWalletByIdUseCase.execute(req.params.id);
            res.status(200).json({ success: true, data: maskWallet(wallet) });
        }
        catch (error) {
            next(error);
        }
    };
    getByDevice = async (req, res, next) => {
        try {
            const wallets = await this.getWalletsByDeviceUseCase.execute(req.params.deviceId);
            res.status(200).json({ success: true, data: wallets.map(maskWallet) });
        }
        catch (error) {
            next(error);
        }
    };
    getAddressForNetwork = async (req, res, next) => {
        try {
            const address = await this.getWalletAddressForNetworkUseCase.execute(req.params.walletId, req.params.networkId);
            res.status(200).json({ success: true, data: address });
        }
        catch (error) {
            next(error);
        }
    };
    getAllAddresses = async (req, res, next) => {
        try {
            const addresses = await this.getAllNetworkAddressesForWalletUseCase.execute(req.params.walletId);
            res.status(200).json({ success: true, data: addresses });
        }
        catch (error) {
            next(error);
        }
    };
    getSeedPhrase = async (req, res, next) => {
        try {
            const seedPhrase = await this.getWalletSeedPhraseUseCase.execute(req.params.id);
            res.status(200).json({ success: true, data: seedPhrase });
        }
        catch (error) {
            next(error);
        }
    };
}
exports.WalletController = WalletController;
//# sourceMappingURL=wallet.controller.js.map