-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
940 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
|
||
<a name="0x3_display"></a> | ||
|
||
# Module `0x3::display` | ||
|
||
|
||
|
||
- [Resource `Display`](#0x3_display_Display) | ||
- [Function `new`](#0x3_display_new) | ||
- [Function `set`](#0x3_display_set) | ||
- [Function `borrow`](#0x3_display_borrow) | ||
- [Function `borrow_mut`](#0x3_display_borrow_mut) | ||
- [Function `remove`](#0x3_display_remove) | ||
- [Function `keys`](#0x3_display_keys) | ||
- [Function `values`](#0x3_display_values) | ||
- [Function `contains_key`](#0x3_display_contains_key) | ||
|
||
|
||
<pre><code><b>use</b> <a href="">0x1::string</a>; | ||
<b>use</b> <a href="">0x2::context</a>; | ||
<b>use</b> <a href="">0x2::object_ref</a>; | ||
<b>use</b> <a href="">0x2::simple_map</a>; | ||
</code></pre> | ||
|
||
|
||
|
||
<a name="0x3_display_Display"></a> | ||
|
||
## Resource `Display` | ||
|
||
|
||
|
||
<pre><code><b>struct</b> <a href="display.md#0x3_display_Display">Display</a><T> <b>has</b> <b>copy</b>, drop, store, key | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Fields</summary> | ||
|
||
|
||
<dl> | ||
<dt> | ||
<code>sample_map: <a href="_SimpleMap">simple_map::SimpleMap</a><<a href="_String">string::String</a>, <a href="_String">string::String</a>></code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
</dl> | ||
|
||
|
||
</details> | ||
|
||
<a name="0x3_display_new"></a> | ||
|
||
## Function `new` | ||
|
||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_new">new</a><T>(ctx: &<b>mut</b> <a href="_Context">context::Context</a>): <a href="_ObjectRef">object_ref::ObjectRef</a><<a href="display.md#0x3_display_Display">display::Display</a><T>> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_new">new</a><T>(ctx: &<b>mut</b> Context): ObjectRef<<a href="display.md#0x3_display_Display">Display</a><T>> { | ||
<a href="_new_singleton_object">context::new_singleton_object</a>(ctx, <a href="display.md#0x3_display_Display">Display</a><T> { | ||
sample_map: <a href="_create">simple_map::create</a>() | ||
}) | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x3_display_set"></a> | ||
|
||
## Function `set` | ||
|
||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_set">set</a><T>(self: &<b>mut</b> <a href="_ObjectRef">object_ref::ObjectRef</a><<a href="display.md#0x3_display_Display">display::Display</a><T>>, key: <a href="_String">string::String</a>, value: <a href="_String">string::String</a>) | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_set">set</a><T>(self: &<b>mut</b> ObjectRef<<a href="display.md#0x3_display_Display">Display</a><T>>, key: String, value: String) { | ||
<b>let</b> display_ref = <a href="_borrow_mut">object_ref::borrow_mut</a>(self); | ||
<a href="_add">simple_map::add</a>(&<b>mut</b> display_ref.sample_map, key, value); | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x3_display_borrow"></a> | ||
|
||
## Function `borrow` | ||
|
||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_borrow">borrow</a><T>(self: &<a href="_ObjectRef">object_ref::ObjectRef</a><<a href="display.md#0x3_display_Display">display::Display</a><T>>, key: &<a href="_String">string::String</a>): &<a href="_String">string::String</a> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_borrow">borrow</a><T>(self: & ObjectRef<<a href="display.md#0x3_display_Display">Display</a><T>> , key: &String): &String { | ||
<b>let</b> display_ref = <a href="_borrow">object_ref::borrow</a>(self); | ||
<a href="_borrow">simple_map::borrow</a>(&display_ref.sample_map, key) | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x3_display_borrow_mut"></a> | ||
|
||
## Function `borrow_mut` | ||
|
||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_borrow_mut">borrow_mut</a><T>(self: &<b>mut</b> <a href="_ObjectRef">object_ref::ObjectRef</a><<a href="display.md#0x3_display_Display">display::Display</a><T>>, key: &<a href="_String">string::String</a>): &<b>mut</b> <a href="_String">string::String</a> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_borrow_mut">borrow_mut</a><T>(self: &<b>mut</b> ObjectRef<<a href="display.md#0x3_display_Display">Display</a><T>>, key: &String): &<b>mut</b> String { | ||
<b>let</b> display_ref = <a href="_borrow_mut">object_ref::borrow_mut</a>(self); | ||
<a href="_borrow_mut">simple_map::borrow_mut</a>(&<b>mut</b> display_ref.sample_map, key) | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x3_display_remove"></a> | ||
|
||
## Function `remove` | ||
|
||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_remove">remove</a><T>(self: &<b>mut</b> <a href="_ObjectRef">object_ref::ObjectRef</a><<a href="display.md#0x3_display_Display">display::Display</a><T>>, key: &<a href="_String">string::String</a>) | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_remove">remove</a><T>(self: &<b>mut</b> ObjectRef<<a href="display.md#0x3_display_Display">Display</a><T>>, key: &String) { | ||
<b>let</b> display_ref = <a href="_borrow_mut">object_ref::borrow_mut</a>(self); | ||
<a href="_remove">simple_map::remove</a>(&<b>mut</b> display_ref.sample_map, key); | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x3_display_keys"></a> | ||
|
||
## Function `keys` | ||
|
||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_keys">keys</a><T>(self: &<a href="_ObjectRef">object_ref::ObjectRef</a><<a href="display.md#0x3_display_Display">display::Display</a><T>>): <a href="">vector</a><<a href="_String">string::String</a>> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_keys">keys</a><T>(self: & ObjectRef<<a href="display.md#0x3_display_Display">Display</a><T>>): <a href="">vector</a><String> { | ||
<b>let</b> display_ref = <a href="_borrow">object_ref::borrow</a>(self); | ||
<a href="_keys">simple_map::keys</a>(& display_ref.sample_map) | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x3_display_values"></a> | ||
|
||
## Function `values` | ||
|
||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_values">values</a><T>(self: &<a href="_ObjectRef">object_ref::ObjectRef</a><<a href="display.md#0x3_display_Display">display::Display</a><T>>): <a href="">vector</a><<a href="_String">string::String</a>> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_values">values</a><T>(self: & ObjectRef<<a href="display.md#0x3_display_Display">Display</a><T>>): <a href="">vector</a><String> { | ||
<b>let</b> display_ref = <a href="_borrow">object_ref::borrow</a>(self); | ||
<a href="_values">simple_map::values</a>(& display_ref.sample_map) | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x3_display_contains_key"></a> | ||
|
||
## Function `contains_key` | ||
|
||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_contains_key">contains_key</a><T>(self: &<a href="_ObjectRef">object_ref::ObjectRef</a><<a href="display.md#0x3_display_Display">display::Display</a><T>>, key: &<a href="_String">string::String</a>): bool | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x3_display_contains_key">contains_key</a><T>(self: & ObjectRef<<a href="display.md#0x3_display_Display">Display</a><T>>, key: &String): bool { | ||
<b>let</b> display_ref = <a href="_borrow">object_ref::borrow</a>(self); | ||
<a href="_contains_key">simple_map::contains_key</a>(& display_ref.sample_map, key) | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module rooch_framework::display{ | ||
use std::string::String; | ||
use moveos_std::object_ref; | ||
use moveos_std::context::Context; | ||
use moveos_std::context; | ||
use moveos_std::object_ref::ObjectRef; | ||
use moveos_std::simple_map; | ||
|
||
struct Display<phantom T> has key, store,drop,copy { | ||
sample_map: simple_map::SimpleMap<String, String> | ||
} | ||
|
||
public fun new<T>(ctx: &mut Context): ObjectRef<Display<T>> { | ||
context::new_singleton_object(ctx, Display<T> { | ||
sample_map: simple_map::create() | ||
}) | ||
} | ||
|
||
public fun set<T>(self: &mut ObjectRef<Display<T>>, key: String, value: String) { | ||
let display_ref = object_ref::borrow_mut(self); | ||
simple_map::add(&mut display_ref.sample_map, key, value); | ||
} | ||
|
||
public fun borrow<T>(self: & ObjectRef<Display<T>> , key: &String): &String { | ||
let display_ref = object_ref::borrow(self); | ||
simple_map::borrow(&display_ref.sample_map, key) | ||
} | ||
|
||
public fun borrow_mut<T>(self: &mut ObjectRef<Display<T>>, key: &String): &mut String { | ||
let display_ref = object_ref::borrow_mut(self); | ||
simple_map::borrow_mut(&mut display_ref.sample_map, key) | ||
} | ||
|
||
public fun remove<T>(self: &mut ObjectRef<Display<T>>, key: &String) { | ||
let display_ref = object_ref::borrow_mut(self); | ||
simple_map::remove(&mut display_ref.sample_map, key); | ||
} | ||
|
||
public fun keys<T>(self: & ObjectRef<Display<T>>): vector<String> { | ||
let display_ref = object_ref::borrow(self); | ||
simple_map::keys(& display_ref.sample_map) | ||
} | ||
|
||
public fun values<T>(self: & ObjectRef<Display<T>>): vector<String> { | ||
let display_ref = object_ref::borrow(self); | ||
simple_map::values(& display_ref.sample_map) | ||
} | ||
|
||
public fun contains_key<T>(self: & ObjectRef<Display<T>>, key: &String): bool { | ||
let display_ref = object_ref::borrow(self); | ||
simple_map::contains_key(& display_ref.sample_map, key) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "nft" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
MoveStdlib = { local = "../../moveos/moveos-stdlib/move-stdlib" } | ||
MoveosStdlib = { local = "../../moveos/moveos-stdlib/moveos-stdlib" } | ||
RoochFramework = { local = "../../crates/rooch-framework" } | ||
|
||
[addresses] | ||
nft = "_" | ||
|
||
[dev-addresses] | ||
nft = "0x42" |
Empty file.
Oops, something went wrong.