Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions sui/packages/ntt/sources/inbox.move
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,37 @@ module ntt::inbox {
public fun borrow_inbox_item<K: store + copy + drop>(inbox: &Inbox<K>, key: InboxKey<K>): &InboxItem<K> {
inbox.entries.borrow(key)
}

#[test_only]
/// True if the item is queued for delayed release (`ReleaseAfter`).
public fun is_release_after<K>(self: &InboxItem<K>): bool {
match (&self.release_status) {
ReleaseStatus::ReleaseAfter(_) => true,
_ => false,
}
}

#[test_only]
/// The release timestamp of a queued item. Aborts unless the item is in the
/// `ReleaseAfter` state.
public fun release_after_timestamp<K>(self: &InboxItem<K>): u64 {
match (&self.release_status) {
ReleaseStatus::ReleaseAfter(release_timestamp) => *release_timestamp,
_ => abort ETransferCannotBeRedeemed,
}
}

#[test_only]
public fun is_released<K>(self: &InboxItem<K>): bool {
match (&self.release_status) {
ReleaseStatus::Released => true,
_ => false,
}
}

#[test_only]
/// Number of votes recorded on the item, regardless of which transceivers are enabled.
public fun count_votes<K>(self: &InboxItem<K>): u8 {
self.votes.count_ones()
}
}
2 changes: 1 addition & 1 deletion sui/packages/ntt/sources/ntt.move
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module ntt::ntt {
// consumed. refill inbox rate limit
state.borrow_peer_mut(recipient_chain)
.borrow_inbound_rate_limit_mut()
.refill(clock, trimmed_amount.amount());
.refill(clock, trimmed_amount.untrim(coin_meta.get_decimals()));
clock.timestamp_ms()
};

Expand Down
5 changes: 5 additions & 0 deletions sui/packages/ntt/sources/outbox.move
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ module ntt::outbox {
&outbox_item.recipient_ntt_manager
}

#[test_only]
public fun borrow_release_timestamp<T: store>(outbox_item: &OutboxItem<T>): u64 {
outbox_item.release_timestamp
}

public(package) fun try_release<T: store>(
outbox: &mut Outbox<T>,
key: OutboxKey,
Expand Down
12 changes: 12 additions & 0 deletions sui/packages/ntt/sources/rate_limit.move
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ module ntt::rate_limit {
let new_amount = min!(new_amount, 0xFFFF_FFFF_FFFF_FFFF) as u64;

self.capacity_at_last_tx = min!(new_amount, self.limit);
let now = clock.timestamp_ms();
self.last_tx_timestamp = now;
}

public fun set_limit(self: &mut RateLimitState, limit: u64, clock: &Clock) {
Expand Down Expand Up @@ -139,4 +141,14 @@ module ntt::rate_limit {
self.capacity_at_last_tx = new_capacity.min(limit);
self.last_tx_timestamp = now;
}

#[test_only]
public fun limit(self: &RateLimitState): u64 { self.limit }

#[test_only]
public fun capacity_at_last_tx(self: &RateLimitState): u64 { self.capacity_at_last_tx }

#[test_only]
public fun last_tx_timestamp(self: &RateLimitState): u64 { self.last_tx_timestamp }

}
Loading
Loading