{"version":3,"file":"with-abstract-params.cjs","sources":["../../../../../src/modules/abstract/common/with-abstract-params.js"],"sourcesContent":["import {\n  withExtendedPrototypeProperties,\n  withExtendedStaticProperties,\n} from '../../../utils';\n\n/**\n * This function takes a class as an argument and returns a new class that extends the input class. The returned class includes additional static methods for preparing parameters and instance methods for adding, retrieving, and managing parameters associated with DIDs (Decentralized Identifiers). The abstract logic allows operations on public keys and parameters.\n * @param {Function} klass - A constructor function or an ES6 class representing the base class to extend.\n * @returns {class} A new class that extends the input class, including additional methods for managing parameters associated with DIDs.\n */\nexport default function withAbstractParams(klass) {\n  const name = `withAbstractParams(${klass.name})`;\n\n  /**\n   * This object contains a single property representing a class that extends the provided 'klass'. It includes several static and instance methods for managing parameters associated with DIDs.\n   */\n  const obj = {\n    [name]: class extends klass {\n      /**\n       * Create an object to add new parameters on chain. This method is responsible for creating an instance of Params with the provided arguments.\n       * @param {...*} prepareAddPublicKey - Additional parameters for preparing to add a public key.\n       * @param {string} curveType - The type of elliptic curve used in cryptography (e.g., 'Ed25519', 'P-256').\n       * @param {string} label - A human-readable string that describes the parameter.\n       * @returns {Params} An instance of Params with the provided properties.\n       */\n      static prepareAddParameters(...args) {\n        const { Params } = this;\n\n        return new Params(...args);\n      }\n\n      /**\n       * Add new parameters associated with a supplied DID to the blockchain. This method signs and sends a transaction that adds parameters to the blockchain.\n       * @param {string} id - A unique identifier for the new parameter set to be added.\n       * @param {Params} params - The parameters to add, associated with the provided targetDid.\n       * @param {*} targetDid - The DID of the entity that owns the parameters being added.\n       * @param {DidKeypair} didKeypair - A key pair object for signing transactions related to the parameter addition.\n       * @param {object} txParams - Optional transaction parameters, such as a gas limit or fee.\n       * @returns {Promise<*>} A promise that resolves with the result of adding parameters to the blockchain.\n       */\n      async addParams(id, params, targetDid, didKeypair, txParams) {\n        return await this.signAndSend(\n          await this.addParamsTx(id, params, targetDid, didKeypair),\n          txParams,\n        );\n      }\n\n      /**\n       * Retrieve parameters associated with a specific DID and unique identifier from the blockchain. This method should be implemented by the subclass to define the behavior for retrieving parameters.\n       * @param {string} did - The DID of the entity whose parameters are being fetched.\n       * @param {string} id - A unique identifier for the parameter set to retrieve.\n       * @returns {Promise<Params>} A promise that resolves with an instance of Params containing the retrieved information.\n       */\n      async getParams(_did, _id) {\n        throw new Error('Unimplemented');\n      }\n\n      /**\n       * Retrieve all parameter sets associated with a specific DID from the blockchain. This method should be implemented by the subclass to define the behavior for retrieving parameters.\n       * @param {string} did - The DID of the entity whose parameters are being fetched.\n       * @returns {Promise<Map<Id, Params>>} A promise that resolves with a Map containing all parameter sets associated with the provided DID.\n       */\n      async getAllParamsByDid(_did) {\n        throw new Error('Unimplemented');\n      }\n\n      /**\n       * Retrieve the identifier of the most recently used parameter set for a specific DID from the blockchain. This method should be implemented by the subclass to define the behavior for retrieving parameters.\n       * @param {*} targetDid - The DID of the entity whose last parameter identifier is being fetched.\n       * @returns {Promise<Id>} A promise that resolves with the identifier (Id) of the most recently used parameter set for the provided DID.\n       */\n      async lastParamsId(_targetDid) {\n        throw new Error('Unimplemented');\n      }\n\n      /**\n       * Retrieve the next available identifier to be used in a parameter set associated with a specific DID from the blockchain. This method should be implemented by the subclass to define the behavior for retrieving parameters.\n       * @param {*} targetDid - The DID of the entity whose next parameter identifier is being fetched.\n       * @returns {Promise<Id>} A promise that resolves with an Id representing the next available identifier to be used in a parameter set associated with the provided DID.\n       */\n      async nextParamsId(_targetDid) {\n        throw new Error('Unimplemented');\n      }\n    },\n  };\n\n  /**\n   * Abstract logic allowing to operate with public keys and parameters.\n   */\n  return withExtendedPrototypeProperties(\n    [\n      'addParamsTx',\n      'getParams',\n      'getAllParamsByDid',\n      'lastParamsId',\n      'nextParamsId',\n    ],\n    withExtendedStaticProperties(['Params'], obj[name]),\n  );\n}\n"],"names":["withExtendedPrototypeProperties","withExtendedStaticProperties"],"mappings":";;;;;;;;;;;;AAKA;AACA;AACA;AACA;AACA;AACe,SAAS,kBAAkB,CAAC,KAAK,EAAE;AAClD,EAA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