Skip to content

Commit

Permalink
Docs: DD Domains (#39)
Browse files Browse the repository at this point in the history
* Docs

* update docs
  • Loading branch information
TarekkMA authored Apr 20, 2022
1 parent 2aaf1ee commit d65653d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pallets/domains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ Domains pallet allows users to register and manage domains.

## Resolving Domain Names
- **Pallet Name:** domains
- **Storage:** `RegisteredDomains`: `DomainName` => `DomainMeta`
- **Storages:**
- `RegisteredDomains: Map<DomainName,DomainMeta>`\
Metadata associated per domain.
- `DomainsByOwner: Map<AccountId, DomainName[]>`\
Domains owned per account.

Domain name can be resolved to obtain the owner.

Expand Down Expand Up @@ -113,4 +117,12 @@ async function fetchDomainOwner(domain) {
const domainMeta = await api.query.domains.registeredDomains(domain);
return domainMeta.unwrap().owner;
}
```

### Fetch domain owned by account.
```javascript
async function fetchDomains(account) {
const domains = await api.query.domains.domainsByOwner(account);
return domains;
}
```
3 changes: 3 additions & 0 deletions pallets/domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ pub mod pallet {
pub(super) type ReservedWords<T: Config> =
StorageMap<_, Blake2_128Concat, DomainName<T>, bool, ValueQuery>;

/// Metadata associated per domain.
#[pallet::storage]
#[pallet::getter(fn registered_domain)]
pub(super) type RegisteredDomains<T: Config> =
StorageMap<_, Blake2_128Concat, DomainName<T>, DomainMeta<T>>;

/// Domains owned per account.
///
/// TWOX-NOTE: Safe as `AccountId`s are crypto hashes anyway.
#[pallet::storage]
#[pallet::getter(fn domains_by_owner)]
Expand Down

0 comments on commit d65653d

Please sign in to comment.