Skip to content

azero-id/contract-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AZERO.ID - Contract level integration

License: GPL v3 Rust

This repository contains Rust crate to resolve domains & addresses registered with AZERO.ID.

Integration Guide 📃

  1. Include this crate in the contract's Cargo.toml file.
// file: ./Cargo.toml
[dependencies]
azns-integration = { git = "https://github.com/azero-id/contract-integration", default-features = false }

[features]
std = [
    "azns-integration/std",
    ..
]
  1. Store the router address and import the type AccountIdOrDomain
// file: ./lib.rs
#[ink::contract]
mod example {
    // 1. Import `AccountIdOrDomain` type
    use azns_integration::AccountIdOrDomain;

    #[ink(storage)]
    pub struct Example {
        // 2. Store AZERO-ID's router-contract address
        domain_router: AccountId,
    }

    impl Example {
        #[ink(constructor)]
        pub fn new(domain_router: AccountId) -> Self {
            Self { domain_router }
        }

        /// Returns the AccountId associated with the `user`
        #[ink(message)]
        pub fn simple_integration(&self, user: AccountIdOrDomain) -> Option<AccountId> {
            user.get_address(self.domain_router) // Resolves user to AccountId
        }
    }
}

Refer to the sample example for more details.

Documentation 👩‍💻

View the full documentation & types here:

https://docs.azero.id/integration/contract-level

Contract deployments link

https://docs.azero.id/developers/deployments

APIs exposed by AznsRouterRef

  • get_all_registries() -> Vec
  • get_registry(tld: String) -> Option
  • get_address(domain: String) -> Result<AccountId, u8>
  • get_primary_domains(account: AccountId, tld: Option) -> Vec<(AccountId, String)>

Type - AccountIdOrDomain

Allows user to pass their AccountId or their AZERO.ID Domain

pub enum AccountIdOrDomain {
    AccountId(AccountId),
    Domain(String),
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages