-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs work * Style guide update --------- Co-authored-by: Ronny Roland <[email protected]>
- Loading branch information
1 parent
0a9c6ae
commit d909143
Showing
20 changed files
with
101 additions
and
57 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 was deleted.
Oops, something went wrong.
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,44 @@ | ||
# Examples | ||
|
||
The following code sample is an initial example of how to integrate with SuiNS on chain. This page will host more examples in the future. | ||
|
||
## Transferring any object to a SuiNS name fully on-chain | ||
|
||
The following `demo` module demonstrates how to transfer an object of any type to a SuiNS name. This is a basic example of how to interact with SuiNS on chain. | ||
|
||
```rust | ||
module demo::demo { | ||
use std::string::String; | ||
use sui::clock::Clock; | ||
|
||
/// Import the SuiNS dependency. | ||
use suins::{ | ||
suins::SuiNS, | ||
registry::Registry, | ||
domain | ||
}; | ||
|
||
/// Different custom error messages. | ||
const ENameNotFound: u64 = 0; | ||
const ENameNotPointingToAddress: u64 = 1; | ||
const ENameExpired: u64 = 2; | ||
|
||
/// A function to transfer an object of any type T to a name (for instance `example.sui`) | ||
public fun send_to_name<T: key + store>(suins: &SuiNS, obj: T, name: String, clock: &Clock) { | ||
// Look up the name on the registry. | ||
let mut optional = suins.registry<Registry>().lookup(domain::new(name)); | ||
// Check that the name indeed exists. | ||
assert!(optional.is_some(), ENameNotFound); | ||
|
||
let name_record = optional.extract(); | ||
// Check that name has not expired. | ||
// This check is optional, but it's recommended you perform the verification. | ||
assert!(name_record.has_expired(clock), ENameExpired); | ||
// Check that the name has a target address set. | ||
assert!(name_record.target_address().is_some(), ENameNotPointingToAddress); | ||
|
||
// Transfer the object to that name. | ||
transfer::public_transfer(obj, name_record.target_address().extract()) | ||
} | ||
} | ||
``` |
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,13 @@ | ||
# Indexing | ||
|
||
The indexer enables more expressive queries about the active domain state, as the on-chain resolution wasn't enough to power the interface. | ||
|
||
This allows for complex queries such as: | ||
|
||
- **Get all the subnames for a given parent:** Retrieve every subdomain linked to a parent domain, enhancing the ability to manage and analyze domain structures. | ||
- **Get all names pointing to a specified address:** Identify all domain names associated with a specific wallet address to track ownership and usage. | ||
|
||
You can find the indexer in the [suins-indexer GitHub repository](https://github.com/MystenLabs/sui/tree/main/crates/suins-indexer). | ||
Feel free to spin up your own service if you're looking to index data tailored to your needs. | ||
|
||
For a deeper understanding of how the indexer works and how to integrate it into your projects, refer to [Sui's custom indexer documentation](https://docs.sui.io/guides/developer/advanced/custom-indexer). |
This file was deleted.
Oops, something went wrong.
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