"use strict";
// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AWSKMSTransactionAdapter = void 0;
const hedera_custodians_integration_1 = require("@hashgraph/hedera-custodians-integration");
const tsyringe_1 = require("tsyringe");
const LogService_1 = __importDefault(require("../../../../app/service/log/LogService"));
const WalletEvent_1 = require("../../../../app/service/event/WalletEvent");
const Wallet_1 = require("../../../../domain/context/network/Wallet");
const CustodialTransactionAdapter_1 = require("./CustodialTransactionAdapter");
let AWSKMSTransactionAdapter = class AWSKMSTransactionAdapter extends CustodialTransactionAdapter_1.CustodialTransactionAdapter {
    init() {
        this.eventService.emit(WalletEvent_1.WalletEvents.walletInit, {
            wallet: Wallet_1.SupportedWallets.AWSKMS,
            initData: {},
        });
        LogService_1.default.logTrace("AWS KMS Initialized");
        return Promise.resolve(this.networkService.environment);
    }
    initCustodialWalletService(settings) {
        this.custodialWalletService = new hedera_custodians_integration_1.CustodialWalletService(new hedera_custodians_integration_1.AWSKMSConfig(settings.awsAccessKeyId, settings.awsSecretAccessKey, settings.awsRegion, settings.awsKmsKeyId));
    }
    getSupportedWallet() {
        return Wallet_1.SupportedWallets.AWSKMS;
    }
    stop() {
        this.client?.close();
        LogService_1.default.logTrace("AWS KMS stopped");
        this.eventService.emit(WalletEvent_1.WalletEvents.walletDisconnect, {
            wallet: Wallet_1.SupportedWallets.AWSKMS,
        });
        return Promise.resolve(true);
    }
};
exports.AWSKMSTransactionAdapter = AWSKMSTransactionAdapter;
exports.AWSKMSTransactionAdapter = AWSKMSTransactionAdapter = __decorate([
    (0, tsyringe_1.singleton)()
], AWSKMSTransactionAdapter);
