Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Name Service #28

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Added Name Service #28

wants to merge 14 commits into from

Conversation

niklabh
Copy link
Contributor

@niklabh niklabh commented Nov 9, 2022

Name Service example

This example is intended to create a domain name service with wasm.

Custom trait implements

  • fn createSubdomain(&mut self, subdomain: vec, domain: vec) -> Result<()>;

  • fn transferSubdomain(&mut self, subdomain: vec, domain: vec, newOwner: AccountId) -> Result<()>;

  • unit test is implemented

  • deployed on Shibuya

  • deployed on Shiden

Deployment on Shibuya

soon

Deployment on Shiden

soon

Copy link
Member

@PierreOssun PierreOssun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @niklabh
Some suggestions:

  1. please use snake_case in Rust (excpect for strcut & enum names)
  2. Do not use panic! - you fns should return a Result - you can use this macro for assertations
  3. ensure it is building with cargo contract build

nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
nameservice/contracts/src/lib.rs Outdated Show resolved Hide resolved
niklabh and others added 10 commits November 9, 2022 10:49
Co-authored-by: Pierre Giraud <35110271+PierreOssun@users.noreply.github.com>
Co-authored-by: Pierre Giraud <35110271+PierreOssun@users.noreply.github.com>
Co-authored-by: Pierre Giraud <35110271+PierreOssun@users.noreply.github.com>
Co-authored-by: Pierre Giraud <35110271+PierreOssun@users.noreply.github.com>
Co-authored-by: Pierre Giraud <35110271+PierreOssun@users.noreply.github.com>
Co-authored-by: Pierre Giraud <35110271+PierreOssun@users.noreply.github.com>
Co-authored-by: Pierre Giraud <35110271+PierreOssun@users.noreply.github.com>
Co-authored-by: Pierre Giraud <35110271+PierreOssun@users.noreply.github.com>
Co-authored-by: Pierre Giraud <35110271+PierreOssun@users.noreply.github.com>
@niklabh
Copy link
Contributor Author

niklabh commented Nov 14, 2022

Review comments resolved.

Copy link
Member

@PierreOssun PierreOssun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Add nameservice to workspace Cargo.toml
  • Ensure it is building with cargo contract build in the contract dir

pub struct EnsSubdomainFactory {
owner: AccountId,
locked: bool,
ethname_hash = 0x00,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: expected :, found =``

creator: AccountId,
owner: AccountId,
subdomain: vec[u8],
domain: vec[u8],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niklabh still not updated

assert_eq!(self.locked, false, "Domain transfers are locked");
let subdomain_hash = self.namehash(subdomain, domain);
let subdomain_owner = self.getOwner(subdomain_hash);
assert_eq!(subdomain_owner, AccountId::from([0x0; 32]), "Subdomain already exists");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use any panic! assertion
return Result::Err if anything wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flipper also using assert_eq!

Can you suggest one change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flipper doesn't use asser_eq!
https://github.com/paritytech/ink/blob/master/examples/flipper/lib.rs
You need to return Result::Err

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants