/// This module recovers a Diem-style storage model where objects are collected /// into a heterogeneous global storage, identified by their type. /// /// Under the hood, it uses dynamic object fields, but set up in a way that the /// key is derived from the value's type. module token_bridge::dynamic_set { use sui::dynamic_object_field as ofield; use sui::object::{UID}; /// Wrap the value type. Avoids key collisions with other uses of dynamic /// fields. struct Wrapper has copy, drop, store { } public fun add( object: &mut UID, value: Value, ) { ofield::add(object, Wrapper{}, value) } public fun borrow( object: &UID, ): &Value { ofield::borrow(object, Wrapper{}) } public fun borrow_mut( object: &mut UID, ): &mut Value { ofield::borrow_mut(object, Wrapper{}) } public fun remove( object: &mut UID, ): Value { ofield::remove(object, Wrapper{}) } public fun exists_( object: &UID, ): bool { ofield::exists_>(object, Wrapper{}) } }