isAvailable()

/**
   * Checks if the Collective Portrait is available for registration.
   *
   * @remarks
   * The Collective Portrait is available for registration if the valid until time + grace period is greater than the current timestamp.
   * It is recommend to use this in conjunction with the timestamp from the block. You can use the Ethers library to get the timestamp from the block.
   *
   * @param {CollectivePortraitName} identity - The name of the Collective Portrait that the user would like to check if it is available for registration.
   * @returns {boolean} - True if the Collective Portrait is available for registration, false otherwise.
   * @beta
   * @async
   */
  isAvailable(identity: CollectivePortraitName): boolean {
    const validUntil = this.getValidUntil(identity);

    const currentBlock = this.portrait.portraitProvider.getBlockNumber();
    const timestamp =
      this.portrait.portraitProvider.getBlock(currentBlock).timestamp;

    return validUntil + this.getGracePeriod() > timestamp ? true : false;
  }

Last updated