Skip to content

Commit

Permalink
docs: update tutorials to reflect changes in name registration
Browse files Browse the repository at this point in the history
dashUniqueIdentityId and dashAliasIdentityId records were deprecated. Now records.identity is used.
  • Loading branch information
thephez committed Aug 13, 2024
1 parent 491d30d commit 293e0bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ The purpose of this tutorial is to walk through the steps necessary to register

## Overview

Dash Platform names make cryptographic identities easy to remember and communicate. An identity may have multiple alias names (`dashAliasIdentityId`) in addition to its default name (`dashUniqueIdentityId`). Additional details regarding identities can be found in the [Identity description](../../explanations/identity.md).

**Note**: An identity must have a default name before any aliases can be created for the identity.
Dash Platform names make cryptographic identities easy to remember and communicate by enabling them to link to one or more names. Additional details regarding identities can be found in the [Identity description](../../explanations/identity.md).

## Prerequisites

Expand All @@ -22,12 +20,10 @@ Dash Platform names make cryptographic identities easy to remember and communica

## Code

The examples below demonstrate creating both the default name and alias names.

**Note**: the name must be the full domain name including the parent domain (i.e. `myname.dash` instead of just `myname`). Currently `dash` is the only top-level domain that may be used.
:::{tip}
The name must be the full domain name including the parent domain (i.e. `myname.dash` rather than `myname`). Currently, only the `dash` top-level domain may be used.
:::

::::{tab-set}
:::{tab-item} Register Name for Identity
```javascript
const setupDashClient = require('../setupDashClient');

Expand All @@ -39,7 +35,7 @@ const registerName = async () => {
const identity = await platform.identities.get('an identity ID goes here');
const nameRegistration = await platform.names.register(
'<identity name goes here>.dash',
{ dashUniqueIdentityId: identity.getId() },
{ identity: identity.getId() },
identity,
);

Expand All @@ -51,33 +47,6 @@ registerName()
.catch((e) => console.error('Something went wrong:\n', e))
.finally(() => client.disconnect());
```
:::

:::{tab-item} Register Alias for Identity
```javascript
const setupDashClient = require('../setupDashClient');

const client = setupDashClient();

const registerAlias = async () => {
const platform = client.platform;
const identity = await platform.identities.get('an identity ID goes here');
const aliasRegistration = await platform.names.register(
'<identity alias goes here>.dash',
{ dashAliasIdentityId: identity.getId() },
identity,
);

return aliasRegistration;
};

registerAlias()
.then((d) => console.log('Alias registered:\n', d.toJSON()))
.catch((e) => console.error('Something went wrong:\n', e))
.finally(() => client.disconnect());
```
:::
::::

## What's Happening

Expand Down
17 changes: 8 additions & 9 deletions docs/tutorials/identities-and-names/retrieve-a-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const client = setupDashClient();
const retrieveNameByRecord = async () => {
// Retrieve by a name's identity ID
return client.platform.names.resolveByRecord(
'dashUniqueIdentityId',
'identity',
'<identity id>',
);
};
Expand Down Expand Up @@ -78,18 +78,17 @@ retrieveNameBySearch()

## Example Name

The following example response shows a retrieved name (`user-9999.dash`):
The following example response shows a retrieved name:

```json
{
"label": "Alice",
"normalizedLabel": "alice",
"label": "Tutorial-Test-Jettie-94475",
"normalizedLabel": "tut0r1a1-test-jett1e-94475",
"normalizedParentDomainName": "dash",
"preorderSalt": "lQEiixHMO5TJmbKwKtavg6eAkxuXzvSlrs/OX9glcYI=",
"parentDomainName": "dash",
"records": {
"dashAliasIdentityId": null,
"dashUniqueIdentityId": "YhCPn6pSbZ11hCiFmFL6WJkmC3GSwuUSzhS4QAy84EF"
},
"identity": "woTQprzGS4bLqqbAhY2heG8QfD58Doo2UhDbiVVrLKG"
},
"subdomainRules": {
"allowSubdomains": false
}
Expand All @@ -101,7 +100,7 @@ The following example response shows a retrieved name (`user-9999.dash`):
After we initialize the Client, we request a name. The [code examples](#code) demonstrate the three ways to request a name:

1. Resolve by name. The `platform.names.resolve` method takes a single argument: a fully-qualified name (e.g., `user-9999.dash`).
2. Resolve by record. The `platform.names.resolveByRecord` method takes two arguments: the record type (e.g., `dashUniqueIdentityId`) and the record value to resolve.
2. Resolve by record. The `platform.names.resolveByRecord` method takes two arguments: the record type (e.g., `identity`) and the record value to resolve.
3. Search. The `platform.names.search` method takes two arguments: the leading characters of the name to search for and the domain to search (e.g., `dash` for names in the `*.dash` domain). The search will return names that begin the with string provided in the first parameter.

After the name is retrieved, it is displayed on the console.

0 comments on commit 293e0bc

Please sign in to comment.