Skip to content

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
Collaborator

@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

@niklabh
Copy link
Contributor Author

niklabh commented Nov 14, 2022

Review comments resolved.

@niklabh niklabh requested a review from PierreOssun November 14, 2022 09:52
Copy link
Collaborator

@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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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.

3 participants