"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pairs = void 0;
const util_1 = require("@pezkuwi/util");
const util_crypto_1 = require("@pezkuwi/util-crypto");
class Pairs {
    #map = {};
    add(pair) {
        this.#map[(0, util_crypto_1.decodeAddress)(pair.address).toString()] = pair;
        return pair;
    }
    all() {
        return Object.values(this.#map);
    }
    get(address) {
        const pair = this.#map[(0, util_crypto_1.decodeAddress)(address).toString()];
        if (!pair) {
            throw new Error(`Unable to retrieve keypair '${(0, util_1.isU8a)(address) || (0, util_1.isHex)(address)
                ? (0, util_1.u8aToHex)((0, util_1.u8aToU8a)(address))
                : address}'`);
        }
        return pair;
    }
    remove(address) {
        delete this.#map[(0, util_crypto_1.decodeAddress)(address).toString()];
    }
}
exports.Pairs = Pairs;
