UNPKG

lisk-framework

Version:

Lisk blockchain application platform

70 lines 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuthAccountStore = exports.authAccountSchema = void 0; const lisk_db_1 = require("@liskhq/lisk-db"); const base_store_1 = require("../../base_store"); const constants_1 = require("../constants"); exports.authAccountSchema = { $id: '/auth/account', type: 'object', properties: { nonce: { dataType: 'uint64', fieldNumber: 1, }, numberOfSignatures: { dataType: 'uint32', fieldNumber: 2, minimum: 0, maximum: constants_1.MAX_NUMBER_OF_SIGNATURES, }, mandatoryKeys: { type: 'array', items: { dataType: 'bytes', minLength: constants_1.ED25519_PUBLIC_KEY_LENGTH, maxLength: constants_1.ED25519_PUBLIC_KEY_LENGTH, }, minItems: 0, maxItems: constants_1.MAX_NUMBER_OF_SIGNATURES, fieldNumber: 3, }, optionalKeys: { type: 'array', items: { dataType: 'bytes', minLength: constants_1.ED25519_PUBLIC_KEY_LENGTH, maxLength: constants_1.ED25519_PUBLIC_KEY_LENGTH, }, minItems: 0, maxItems: constants_1.MAX_NUMBER_OF_SIGNATURES, fieldNumber: 4, }, }, required: ['nonce', 'numberOfSignatures', 'mandatoryKeys', 'optionalKeys'], }; class AuthAccountStore extends base_store_1.BaseStore { constructor() { super(...arguments); this.schema = exports.authAccountSchema; } async getOrDefault(context, address) { try { const authAccount = await this.get(context, address); return authAccount; } catch (error) { if (!(error instanceof lisk_db_1.NotFoundError)) { throw error; } return { nonce: BigInt(0), numberOfSignatures: 0, mandatoryKeys: [], optionalKeys: [], }; } } } exports.AuthAccountStore = AuthAccountStore; //# sourceMappingURL=auth_account.js.map