diff --git a/documentation/README.md b/documentation/README.md index 2e9317cd..5856dbb5 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -2,5 +2,5 @@ To run locally: -1. `pnpm i` (only needed first time) +1. `pnpm i` (needed first time and when modules change) 2. `pnpm dev` \ No newline at end of file diff --git a/documentation/pages/contracts/_meta.json b/documentation/draft/contracts/_meta.json similarity index 100% rename from documentation/pages/contracts/_meta.json rename to documentation/draft/contracts/_meta.json diff --git a/documentation/pages/contracts/architecture.mdx b/documentation/draft/contracts/architecture.mdx similarity index 100% rename from documentation/pages/contracts/architecture.mdx rename to documentation/draft/contracts/architecture.mdx diff --git a/documentation/pages/contracts/packages.mdx b/documentation/draft/contracts/packages.mdx similarity index 100% rename from documentation/pages/contracts/packages.mdx rename to documentation/draft/contracts/packages.mdx diff --git a/documentation/pages/contracts/packages/coupons.mdx b/documentation/draft/contracts/packages/coupons.mdx similarity index 100% rename from documentation/pages/contracts/packages/coupons.mdx rename to documentation/draft/contracts/packages/coupons.mdx diff --git a/documentation/pages/contracts/packages/day-one.mdx b/documentation/draft/contracts/packages/day-one.mdx similarity index 100% rename from documentation/pages/contracts/packages/day-one.mdx rename to documentation/draft/contracts/packages/day-one.mdx diff --git a/documentation/pages/contracts/packages/denylist.mdx b/documentation/draft/contracts/packages/denylist.mdx similarity index 100% rename from documentation/pages/contracts/packages/denylist.mdx rename to documentation/draft/contracts/packages/denylist.mdx diff --git a/documentation/pages/contracts/packages/discounts.mdx b/documentation/draft/contracts/packages/discounts.mdx similarity index 100% rename from documentation/pages/contracts/packages/discounts.mdx rename to documentation/draft/contracts/packages/discounts.mdx diff --git a/documentation/pages/contracts/packages/name-registration.mdx b/documentation/draft/contracts/packages/name-registration.mdx similarity index 100% rename from documentation/pages/contracts/packages/name-registration.mdx rename to documentation/draft/contracts/packages/name-registration.mdx diff --git a/documentation/pages/contracts/packages/name-renewal.mdx b/documentation/draft/contracts/packages/name-renewal.mdx similarity index 100% rename from documentation/pages/contracts/packages/name-renewal.mdx rename to documentation/draft/contracts/packages/name-renewal.mdx diff --git a/documentation/pages/contracts/packages/subdomains.mdx b/documentation/draft/contracts/packages/subdomains.mdx similarity index 100% rename from documentation/pages/contracts/packages/subdomains.mdx rename to documentation/draft/contracts/packages/subdomains.mdx diff --git a/documentation/pages/sdk/building.mdx b/documentation/draft/sdk/building.mdx similarity index 100% rename from documentation/pages/sdk/building.mdx rename to documentation/draft/sdk/building.mdx diff --git a/documentation/pages/sdk/querying.mdx b/documentation/draft/sdk/querying.mdx similarity index 100% rename from documentation/pages/sdk/querying.mdx rename to documentation/draft/sdk/querying.mdx diff --git a/documentation/pages/_meta.json b/documentation/pages/_meta.json index 0dd1eb91..804a6d22 100644 --- a/documentation/pages/_meta.json +++ b/documentation/pages/_meta.json @@ -2,6 +2,6 @@ "index": "SuiNS Documentation", "integration": "Integration", "subnames": "Subnames", - "contracts": "Smart Contracts", - "sdk": "SDK" + "indexing": "Indexing", + "examples": "Examples" } diff --git a/documentation/pages/contracts.mdx b/documentation/pages/contracts.mdx deleted file mode 100644 index 4c0740e6..00000000 --- a/documentation/pages/contracts.mdx +++ /dev/null @@ -1,26 +0,0 @@ -# Smart Contracts - -## Looking up a name - -You can perform on-chain lookups for names for various examples in your packages. -For example, to transfer some tokens to a given address: - -```rust -use suins::{ - suins, - registry::{Self, Registry}, - name_record::NameRecord, - domain -} - -// Find the name_record on-chain for a given domain. -// that way we can check if it's expired, whether it points to an address etc. -fun get_name_record(suins: &SuiNS, name: String) { - let name_record = registry::lookup(suins.registry(), name.new()); -} - -/// Gives access to the main registry -fun registry(suins: &SuiNS): &Registry { - suins.registry() -} -``` \ No newline at end of file diff --git a/documentation/pages/examples.mdx b/documentation/pages/examples.mdx new file mode 100644 index 00000000..67853cde --- /dev/null +++ b/documentation/pages/examples.mdx @@ -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(suins: &SuiNS, obj: T, name: String, clock: &Clock) { + // Look up the name on the registry. + let mut optional = suins.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()) + } +} +``` diff --git a/documentation/pages/index.mdx b/documentation/pages/index.mdx index 9ec35167..d7997f44 100644 --- a/documentation/pages/index.mdx +++ b/documentation/pages/index.mdx @@ -1,17 +1,15 @@ import { Tabs } from 'nextra/components' import { Callout } from 'nextra/components' -# SuiNS Documentation +# Sui Name Service Documentation -SuiNS documentation is a place to find the available ways of integration with SuiNS. +Sui Name Service documentation details how to integrate Sui Name Service (SuiNS) with you projects. This includes ways to integrate using both the on-chain resolution, as well as off-chain resolution, depending on the use case. -This includes ways to integrate using both the on-chain resolution, as well as off-chain resolution, -based on the use-case. +The documentation is early in its development. As the site matures, the content will include instructio on how to use the SuiNS portal, as well. +## Active constants -## Active Constants - -This is a list of our current active objects to interact with SuiNS. +This is a list of the current active objects to interact with SuiNS. It's recommended to look here for the latest state, as some of the active constants might be changed. @@ -21,13 +19,44 @@ This is a list of our current active objects to interact with SuiNS. -| Kind | ObjectID | + SuiNS deploys, authorizes, and maintains the following packages on Mainnet. + + +| Kind | Package Id | |-------------- |---------------------------------------------------------------------- | -| SuiNS Shared Object | `0x6e0ddefc0ad98889c04bab9639e512c21766c5e6366f89e696956d9be6952871` | | SuiNS Core V2 (latest) | `0xb7004c7914308557f7afbaf0dca8dd258e18e306cb7a45b28019f3d0a693f162` | | SuiNS Core V1 | `0xd22b24490e0bae52676651b4f56660a5ff8022a2576e0089f79b3c88d44e08f0` | +| Registration | `0x9d451fa0139fef8f7c1f0bd5d7e45b7fa9dbb84c2e63c2819c7abd0a7f7d749d` | +| Renewal | `0xd5e5f74126e7934e35991643b0111c3361827fc0564c83fa810668837c6f0b0f` | +| Utilities (setup) | `0xdac22652eb400beb1f5e2126459cae8eedc116b73b8ad60b71e3e8d7fdb317e2` | +| Discounts Package | `0x6a6ea140e095ddd82f7c745905054b3203129dd04a09d0375416c31161932d2d` | + + +| Kind | Object Id | +|-------------- |---------------------------------------------------------------------- | +| SuiNS Core Object | `0x6e0ddefc0ad98889c04bab9639e512c21766c5e6366f89e696956d9be6952871` | +| SuiNS Discounts | `0x7fdd883c0b7427f18cdb498c4c87a4a79d6bec4783cb3f21aa3816bbc64ce8ef` | + + - test + SuiNS deploys, authorizes, and maintains the following packages on Testnet. + + +| Kind | Package Id | +|-------------- |---------------------------------------------------------------------- | +| SuiNS Core | `0x22fa05f21b1ad71442491220bb9338f7b7095fe35000ef88d5400d28523bdd93` | +| Registration | `0x4255184a0143c0ce4394a3f16a6f5aa5d64507269e54e51ea396d569fe8f1ba5` | +| Renewal | `0x54800ebb4606fd0c03b4554976264373b3374eeb3fd63e7ff69f31cac786ba8c` | +| Utilities (setup) | `0x6ed81fd808a23eae2da488052334d50478b36527474fc99707c1aed0e43104b1` | +| Subnames | `0x3c272bc45f9157b7818ece4f7411bdfa8af46303b071aca4e18c03119c9ff636` | +| Subnames Proxy | `0x3489ab5dcd346afee8b681267bcab2583a5eba9855680ec9931355e50e21c148` | + + +| Kind | Object Id | +|-------------- |---------------------------------------------------------------------- | +| SuiNS Core Object | `0x300369e8909b9a6464da265b9a5a9ab6fe2158a040e84e808628cde7a07ee5a3` | + + diff --git a/documentation/pages/indexing.mdx b/documentation/pages/indexing.mdx new file mode 100644 index 00000000..6a1c81ca --- /dev/null +++ b/documentation/pages/indexing.mdx @@ -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). diff --git a/documentation/pages/sdk.mdx b/documentation/pages/sdk.mdx deleted file mode 100644 index 3658f382..00000000 --- a/documentation/pages/sdk.mdx +++ /dev/null @@ -1,16 +0,0 @@ -# SDK - -You can use the SuiNS SDK to interact with the SuiNS Contracts. - -That'll allow ease of use for your application. - -The SDK helps with querying data, as well as building PTBs for changes to names. - - -## Installation - -Todo... - -## Setup - -Todo... diff --git a/documentation/pages/subnames.mdx b/documentation/pages/subnames.mdx index 4a581f35..d863d304 100644 --- a/documentation/pages/subnames.mdx +++ b/documentation/pages/subnames.mdx @@ -42,8 +42,8 @@ The following table provides more details on the differences between the two typ Similar to regular names, you can look up subnames through JSON-RPC and GraphQL. You can also look up subnames on chain, as described in [Integrations](./integration.mdx). -## Creating subnames +{/* ## Creating subnames TODO: Show how someone could create subnames through the SDK (being the parent). -TODO: Show how someone can integrate with the subdomains package to create subnames. +TODO: Show how someone can integrate with the subdomains package to create subnames. */}