-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFT Standard] #963
Merged
Merged
[NFT Standard] #963
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
247d445
init
WGB5445 8135aa3
add nft.move
WGB5445 7c8a16c
add burn nft
WGB5445 522d22b
add Display
WGB5445 9442a64
init
WGB5445 f760a27
add nft.move
WGB5445 c849b42
add burn nft
WGB5445 4a8a68c
add Display
WGB5445 a8a199b
Merge remote-tracking branch 'origin/NFT' into NFT
WGB5445 b2743fa
add unit test
WGB5445 606f3bd
Fix unit test
WGB5445 d5d27bc
Fix unit test
WGB5445 eb4a09b
Merge branch 'main' into NFT
WGB5445 efa28e8
Merge remote-tracking branch 'origin/NFT' into NFT
WGB5445 b4d1744
Fix unit test
WGB5445 0619ff2
Merge branch 'main' into NFT
WGB5445 c7d4208
Fix Error
WGB5445 1d38d63
Singleton Object Display and NFT example
WGB5445 d33ffad
Merge branch 'main' into NFT
WGB5445 915619d
Singleton Object Display and NFT example
WGB5445 ba12bf6
fix context singleton object create function
WGB5445 a4799b4
fix examples name_address
WGB5445 771b3cd
Merge branch 'main' into NFT
WGB5445 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly provide an update method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, whether the ObjectRef can be obtained is controlled by the Module creator, so there will be no problem