1.1.1 • Published 5 months ago

@cns-space/cns-resolver-sdk v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

CNS Resolver SDK

This is the for resolving official CNS information. This documentation would outline the technical details and APIs provided. For any projects interested in integrating CNS information, here provides sufficient information on either implementing the resolving logics separately or directly using the SDK.

Getting Started

Install

yarn add @cns-space/cns-resolver-sdk

or

npm install @cns-space/cns-resolver-sdk

Using the resolver

import { CNSResolver, MaestroCNS } from '@cns-space/cns-resolver-sdk';

// Initiating the resolver instance
const network: 'preprod' | 'mainnet' = 'preprod';
const resolver = new CNSResolver(new MaestroCNS(apiKey, network));

// Resolving domain
const addr = await resolver.resolveAddress('cns.ada');

// Resolving virtual sub-domain
const addr = await resolver.resolveAddress('mysubdomain.cns.ada');

// Resolving user records
const records = await resolver.resolveUserRecord('cns.ada');

Information CNS provided

  1. Domain Address

    • The current address owning the CNS token.
    • Example of a domain name: cns.ada
  2. Virtual Sub-domain Address

    • The pointer configured by CNS owner to other customized Cardano addresses.
    • Information represents by a key-value on chain through inline datum.
    • Example of a virtual sub-domain name: mysubdomain.cns.ada (key: mysubdomain, value: the Cardano address)
  3. Social Records

    • The social medias handle configured by the CNS owner.
    • Information represents by a key-value on chain through inline datum.
    • key: capitalized social media type (e.g. TELEGRAM, TWITTER, DISCORD etc)
    • value: the handle as configured.
  4. Customized Records

    • Any other key value information the user wishes to set.
    • Information represents by a key-value on chain through inline datum.

Resolving Methodology

ItemValidationResolving MethodsSDK API
Domain AddressExpiry1. Get the current address the CNS residing onresolveAddress
All User RecordsExpiry1. Get the inline datum of the user recordresolveUserRecord
Virtual Sub-domain AddressExpiry & Enabled1. Get the inline datum of the user record 2. Resolve the one with correct virtual sub-domain keyresolveAddress & resolveVirtualSubdomains
Social RecordsExpiry1. Get the inline datum of the user record 2. Resolve the one with correct social keyresolveSocialRecord & resolveSocialRecords
Customized RecordsExpiry1. Get the inline datum of the user record 2. Resolve the one with correct keyresolveOtherRecord & resolveOtherRecords

Validation Approach

  1. Expiry - Expiry Validation

    • Read the metadata attached with the CNS, and get the expiry field
    • Compare the current millisecond with expiry record
    • Valid if current millisecond < expiry
    • Example implementation
  2. Enabled - Virtual Sub-domain Enabled

Schemas

CNS Metadata

interface CNSMetadata {
    name: string;
    image: string;
    expiry: number; // Timestamp Millisecond
    origin: string;
    cnsType: string;
    mediaType: string;
    description: string;
    virtualSubdomainLimits: number;
    virtualSubdomainEnabled: 'Enabled' | 'Disabled';
}

User Record Inline Datum (JSON example)

import PlutusTx.AssocMap (Map(..))

data CNSUserRecordDatum = CNSUserRecordDatum
  (Map BuiltinByteString Address)           -- First map represents virtual sub-domain mapping
  (Map BuiltinByteString BuiltinByteString) -- Second map represents social profile mapping
  (Map BuiltinByteString BuiltinByteString) -- Third map represents custom records
1.1.1

5 months ago

1.1.0

5 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.10

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago

0.2.6

7 months ago

0.2.5

7 months ago

0.2.4

7 months ago

0.2.3

7 months ago

0.2.2

7 months ago

0.2.1

7 months ago

0.2.0

7 months ago

0.1.13

7 months ago

0.1.12

7 months ago

0.1.11

7 months ago

0.1.10

7 months ago

0.1.9

8 months ago

0.1.8

8 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago