This commit is contained in:
einhornimmond 2025-10-24 08:36:07 +02:00
parent 65c1669712
commit b9d51269ca
3 changed files with 10 additions and 6 deletions

View File

@ -2,4 +2,4 @@ export const LOG4JS_BASE_CATEGORY = 'dlt'
// 7 days
export const MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_UPDATE = 1000 * 60 * 60 * 24 * 7
// 10 minutes
export const MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_SEND_MESSAGE = 1000 * 60 * 10
export const MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_SEND_MESSAGE = 1000 * 60 * 10

View File

@ -21,6 +21,7 @@ import {
HieroTransactionIdString,
hieroTransactionIdStringSchema,
} from '../../schemas/typeGuard.schema'
import { isTopicStillOpen } from '../../utils/hiero'
import { AbstractTransactionRole } from './AbstractTransaction.role'
import { CommunityRootTransactionRole } from './CommunityRootTransaction.role'
import { CreationTransactionRole } from './CreationTransaction.role'
@ -28,7 +29,7 @@ import { DeferredTransferTransactionRole } from './DeferredTransferTransaction.r
import { RedeemDeferredTransferTransactionRole } from './RedeemDeferredTransferTransaction.role'
import { RegisterAddressTransactionRole } from './RegisterAddressTransaction.role'
import { TransferTransactionRole } from './TransferTransaction.role'
import { isTopicStillOpen } from '../../utils/hiero'
const logger = getLogger(`${LOG4JS_BASE_CATEGORY}.interactions.sendToHiero.SendToHieroContext`)
/**

View File

@ -1,9 +1,9 @@
import { HieroId } from '../schemas/typeGuard.schema'
import { HieroClient } from '../client/hiero/HieroClient'
import { MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_SEND_MESSAGE } from '../config/const'
import { HieroId } from '../schemas/typeGuard.schema'
/**
* Checks whether the given topic in the Hedera network will remain open
* Checks whether the given topic in the Hedera network will remain open
* for sending messages for at least `MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_SEND_MESSAGE` milliseconds.
*
* @param {HieroId} hieroTopicId - The topic ID to check.
@ -12,5 +12,8 @@ import { MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_SEND_MESSAGE } from '../config/const'
export async function isTopicStillOpen(hieroTopicId: HieroId): Promise<boolean> {
const hieroClient = HieroClient.getInstance()
const topicInfo = await hieroClient.getTopicInfo(hieroTopicId)
return topicInfo.expirationTime.getTime() > new Date().getTime() + MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_SEND_MESSAGE
}
return (
topicInfo.expirationTime.getTime() >
new Date().getTime() + MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_SEND_MESSAGE
)
}