Skip to main content

Module 0x107a::timelock_unlock_condition

use 0x2::tx_context;

Struct TimelockUnlockCondition

The Stardust timelock unlock condition.

struct TimelockUnlockCondition has store

Fields
unix_time: u32

The unix time (seconds since Unix epoch) starting from which the output can be consumed.

Constants

The timelock is not expired error.

const ETimelockNotExpired: u64 = 0;

Function unlock

Check the unlock condition.

public fun unlock(condition: timelock_unlock_condition::TimelockUnlockCondition, ctx: &tx_context::TxContext)

Implementation

public fun unlock(condition: TimelockUnlockCondition, ctx: &TxContext) { assert!(!is_timelocked(&condition, ctx), ETimelockNotExpired);

let TimelockUnlockCondition { unix_time: _, } = condition; }

Function is_timelocked

Check if the output is locked by the Timelock condition.

public fun is_timelocked(condition: &timelock_unlock_condition::TimelockUnlockCondition, ctx: &tx_context::TxContext): bool

Implementation

public fun is_timelocked(condition: &TimelockUnlockCondition, ctx: &TxContext): bool { condition.unix_time() > ((tx_context::epoch_timestamp_ms(ctx) / 1000) as u32) }

Function unix_time

Get the unlock condition's unix_time.

public fun unix_time(condition: &timelock_unlock_condition::TimelockUnlockCondition): u32

Implementation

public fun unix_time(condition: &TimelockUnlockCondition): u32 { condition.unix_time }