"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasUidClaim = void 0;
const types_1 = require("@polymathnetwork/polymesh-sdk/types");
const formatters_1 = require("./formatters");
exports.hasUidClaim = ({ sdk, did, ticker, }) => __awaiter(void 0, void 0, void 0, function* () {
    const tickersWithUidClaim = [];
    const uniquenessClaim = yield sdk._polkadotApi.query.identity.claims.entries({
        target: did,
        claim_type: types_1.ClaimType.InvestorUniqueness,
    });
    (uniquenessClaim || []).forEach((uc) => {
        const { claim: { value: claimValues }, } = uc[1];
        const scope = claimValues[0];
        const parsedTicker = formatters_1.hexToUnpaddedString(scope.value.toString());
        if (scope.type === types_1.ScopeType.Ticker) {
            tickersWithUidClaim.push(parsedTicker);
        }
    });
    return tickersWithUidClaim.includes(ticker);
});
//# sourceMappingURL=hasUidClaim.js.map