@ic-wallet-kit/hpl
Version:
Ic middleware wallet HPL protocol
51 lines (50 loc) • 2.52 kB
JavaScript
;
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 __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CheckDictionaryPrincipalHandler = void 0;
const common_1 = require("@ic-wallet-kit/common");
const hplWrappers_1 = require("../../../hplWrappers");
const typedi_1 = require("typedi");
let CheckDictionaryPrincipalHandler = class CheckDictionaryPrincipalHandler extends common_1.BaseHandler {
identifierService;
constructor(logger, identifierService) {
super(logger);
this.identifierService = identifierService;
}
validate(form) {
if (!form.dictionaryPrincipal) {
throw new common_1.ValidationError("check.dictionary.principal.dictionaryPrincipal.is.required", (0, common_1.getPropertyName)(form, f => f.dictionaryPrincipal), "Field dictionaryPrincipal is required");
}
return Promise.resolve();
}
async process(form) {
let exists = true;
try {
const dictionaryActorWrapper = hplWrappers_1.DictionaryActorWrapper.create(this.identifierService.getAgent(), form.dictionaryPrincipal);
await dictionaryActorWrapper.allTokens();
}
catch (e) {
exists = false;
}
return {
isPrincipalExist: exists
};
}
};
exports.CheckDictionaryPrincipalHandler = CheckDictionaryPrincipalHandler;
exports.CheckDictionaryPrincipalHandler = CheckDictionaryPrincipalHandler = __decorate([
(0, typedi_1.Service)(),
__param(0, (0, typedi_1.Inject)("ILogger")),
__metadata("design:paramtypes", [Object, common_1.IdentifierService])
], CheckDictionaryPrincipalHandler);