Skip to content

Commit

Permalink
feat(iota-framework): added contains_display_object function
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriyr committed Nov 6, 2024
1 parent 121180f commit 267ca2a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,15 @@ module iota_system::iota_system {
self.borrow_extra_field_mut(key)
}

/// Returns true if there is an extra field associated with the key.
public(package) fun contains_extra_field<K: copy + drop + store>(
wrapper: &mut IotaSystemState,
key: K,
): bool {
let self = load_system_state_mut(wrapper);
self.contains_extra_field(key)
}

#[allow(unused_function)]
/// This function should be called at the end of an epoch, and advances the system to the next epoch.
/// It does the following things:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ module iota_system::iota_system_state_inner {
self.extra_fields.borrow_mut(key)
}

/// Returns true if there is an extra field associated with the key.
public(package) fun contains_extra_field<K: copy + drop + store>(
self: &IotaSystemStateV1,
key: K,
): bool {
self.extra_fields.contains(key)
}

// ==== validator metadata management functions ====

/// Create a new `UnverifiedValidatorOperationCap`, transfer it to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ module iota_system::system_display {
iota_system.borrow_extra_field_mut(key)
}

/// Returns true if the related display object exists.
public(package) fun contains_display_object<T: key>(iota_system: &mut IotaSystemState): bool {
// Get a display object unique key.
let key = display_object_key<T>();

// Check if the related display object exists.
iota_system.contains_extra_field(key)
}

/// Return a fully qualified type name with the original package IDs
/// that is used as a display object key.
fun display_object_key<T>(): String {
Expand Down
Binary file modified crates/iota-framework/packages_compiled/iota-system
Binary file not shown.
9 changes: 9 additions & 0 deletions crates/iota-framework/published_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ borrow_extra_field
borrow_extra_field_mut
public(package) fun
0x3::iota_system_state_inner
contains_extra_field
public(package) fun
0x3::iota_system_state_inner
rotate_operation_cap
public(package) fun
0x3::iota_system_state_inner
Expand Down Expand Up @@ -910,6 +913,9 @@ borrow_extra_field
borrow_extra_field_mut
public(package) fun
0x3::iota_system
contains_extra_field
public(package) fun
0x3::iota_system
advance_epoch
fun
0x3::iota_system
Expand Down Expand Up @@ -1033,6 +1039,9 @@ borrow_display_object
borrow_display_object_mut
public(package) fun
0x3::system_display
contains_display_object
public(package) fun
0x3::system_display
display_object_key
fun
0x3::system_display
Expand Down

0 comments on commit 267ca2a

Please sign in to comment.