SINAI STANDARD

HoldPeriodManager

Manage the Hold Period Transfer Hook — lock-up enforcement for Token-2022 tokens

Import

import { HoldPeriodManager } from "@sinai-standard/sdk";
const mgr = new HoldPeriodManager(anchorProgram, mintPubkey);

Properties

PropertyTypeDescription
configPDAPublicKeyThe HoldConfig PDA address
extraAccountMetasPDAPublicKeyThe ExtraAccountMetas PDA address

Methods

initialize(authority, holdPeriodSeconds)

Creates the HoldConfig PDA for the mint.

ParameterTypeDescription
authorityPublicKeyAdmin who can manage the hold config
holdPeriodSecondsnumberLock-up duration in seconds

initializeExtraAccountMetas(payer)

Creates the ExtraAccountMetaList PDA.

Must be called before any transfer.

recordAcquisition(payer, authority, wallet)

Records when a wallet acquires tokens. Sets unlockAt = now + holdPeriodSeconds.

ParameterTypeDescription
payerPublicKeyTransaction fee payer
authorityPublicKeyHoldConfig authority
walletPublicKeyWallet that acquired tokens

updateHoldPeriod(authority, newSeconds)

Changes the hold period duration. Does not affect existing locks.

toggleActive(authority, isActive)

Kill switch. When isActive=false, hold periods are not enforced.

updateAuthority(authority, newAuthority)

Transfers admin rights.

fetchConfig()

Fetches the current on-chain hold config.

interface HoldConfigData {
  authority: PublicKey;
  mint: PublicKey;
  holdPeriodSeconds: number;
  isActive: boolean;
}

fetchWalletLock(wallet)

Fetches a specific wallet's lock state.

interface WalletLockData {
  wallet: PublicKey;
  mint: PublicKey;
  acquiredAt: number;   // Unix timestamp
  unlockAt: number;     // Unix timestamp
}

isUnlocked(wallet)

Checks if a wallet's hold period has expired. Returns true if no lock exists.