Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "eth-ens-namehash in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'eth-ens-namehash' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

it("should be able to register one unique label per user", async () => {
      const username = "test";
      const username2 = "test2";
      const hash = namehash.hash("test.user.joincolony.eth");

      // User cannot register blank label
      await checkErrorRevert(colonyNetwork.registerUserLabel("", orbitDBAddress, { from: accounts[1] }), "colony-user-label-invalid");

      // User can register unique label
      await colonyNetwork.registerUserLabel("test", orbitDBAddress, { from: accounts[1] });

      // Check label resolves correctly.
      // First, query the registry to get the resolver
      const resolverAddress = await ensRegistry.resolver(hash);
      expect(resolverAddress).to.equal(colonyNetwork.address);
      // Then query the resolver
      const resolvedAddress = await colonyNetwork.addr(hash);
      expect(resolvedAddress).to.equal(accounts[1]);
      const owner = await ensRegistry.owner(hash);
      expect(owner).to.equal(colonyNetwork.address);
async function send() {
          self.ensContract = new web3.eth.Contract(config.registryAbi, config.registryAddress);
          self.registrarContract = new web3.eth.Contract(config.registrarAbi, config.registrarAddress);
          self.resolverContract = new web3.eth.Contract(config.resolverAbi, config.resolverAddress);

          const defaultAccount = await self.web3DefaultAccount;

          const rootNode = namehash.hash(registration.rootDomain);
          const reverseNode = namehash.hash(defaultAccount.toLowerCase().substr(2) + reverseAddrSuffix);
          const owner = await self.ensContract.methods.owner(rootNode).call();

          if (owner === defaultAccount) {
            return next();
          }

          // Set defaultAccount as the owner of the Registry
          secureSend(web3, self.ensContract.methods.setOwner(rootNode, defaultAccount), {
            from: defaultAccount,
            gas: ENS_GAS_PRICE
          }, false).then(() => {
            // Set Registry's resolver to the one deployed above
            return secureSend(web3, self.ensContract.methods.setResolver(rootNode, config.resolverAddress), {
              from: defaultAccount,
              gas: ENS_GAS_PRICE
return callback('No rootDomain is declared in config/namesystem.js (register.rootDomain). Unable to register a subdomain until then.');
  }
  if (!address || !Web3.utils.isAddress(address)) {
    return callback('You need to specify a valid address for the subdomain');
  }

  // Register function generated by the index
  ENSFunctions.registerSubDomain(
    this.web3,
    this.ens,
    this.registrar,
    this.resolver,
    this.web3.eth.defaultAccount,
    name,
    this.registration.rootDomain,
    namehash.hash(address.toLowerCase().substr(2) + reverseAddrSuffix),
    address,
    console,
    EmbarkJS.Utils.secureSend,
    (err, result) => {
      if (err && err.indexOf('Transaction has been reverted by the EVM') > -1) {
        return callback('Registration was rejected. Are you the owner of the root domain?');
      }
      callback(err, result);
    });
};
return callback('No rootDomain is declared in config/namesystem.js (register.rootDomain). Unable to register a subdomain until then.');
  }
  if (!address || !Web3.utils.isAddress(address)) {
    return callback('You need to specify a valid address for the subdomain');
  }

  // Register function generated by the index
  ENSFunctions.registerSubDomain(
    EmbarkJS.Blockchain.blockchainConnector.getInstance(),
    this.ens,
    this.registrar,
    this.resolver,
    EmbarkJS.Blockchain.blockchainConnector.getDefaultAccount(),
    name,
    this.registration.rootDomain,
    namehash.hash(address.toLowerCase().substr(2) + reverseAddrSuffix),
    address,
    console,
    EmbarkJS.Utils.secureSend,
    (err, result) => {
      if (err && err.indexOf('Transaction has been reverted by the EVM') > -1) {
        return callback('Registration was rejected. Are you the owner of the root domain?');
      }
      callback(err, result);
    });
};
return callback('No rootDomain is declared in config/namesystem.js (register.rootDomain). Unable to register a subdomain until then.');
  }
  if (!address || !Web3.utils.isAddress(address)) {
    return callback('You need to specify a valid address for the subdomain');
  }

  // Register function generated by the index
  ENSFunctions.registerSubDomain(
    EmbarkJS.Blockchain.blockchainConnector.getInstance(),
    this.ens,
    this.registrar,
    this.resolver,
    EmbarkJS.Blockchain.blockchainConnector.getDefaultAccount(),
    name,
    this.registration.rootDomain,
    namehash.hash(address.toLowerCase().substr(2) + reverseAddrSuffix),
    address,
    console,
    EmbarkJS.Utils.secureSend,
    (err, result) => {
      if (err && err.indexOf('Transaction has been reverted by the EVM') > -1) {
        return callback('Registration was rejected. Are you the owner of the root domain?');
      }
      callback(err, result);
    });
};
it('should slash invalid username', async () => {
      let username = 'alicé';
      let label = web3Utils.sha3(username);
      let usernameHash = namehash.hash(username + '.' + registry.registry);
      let registrant = accountsArr[1];
      await TestToken.methods.mint(registry.price).send({from: registrant});
      await TestToken.methods.approve(UsernameRegistrar.address, registry.price).send({from: registrant});
      await UsernameRegistrar.methods.register(
        web3Utils.sha3(username),

        utils.zeroAddress,
        utils.zeroBytes32,
        utils.zeroBytes32
      ).send({from: registrant});
      await utils.increaseTime(20000)
      assert.equal(await ENSRegistry.methods.owner(usernameHash).call(), registrant);
      assert.notEqual(await UsernameRegistrar.methods.getCreationTime(label).call(), 0);
      const creationTime = await UsernameRegistrar.methods.getCreationTime(web3Utils.sha3(username)).call();
      const reserveSecret = 1337;
      const secret = web3Utils.soliditySha3(usernameHash, creationTime, reserveSecret);
it('should slash invalid free subdomain', async () => {
    let subdomain = 'alicé';
    let usernameHash = namehash.hash(subdomain + '.' + domains.free.name);
    let registrant = accountsArr[1];
    let result = await ENSSubdomainRegistry.methods.register(
      web3Utils.sha3(subdomain),
      domains.free.namehash,
      utils.zeroAddress,
      utils.zeroBytes32,
      utils.zeroBytes32
    ).send({from: registrant});

    //TODO: check events
    result = await ens.methods.owner(usernameHash).call()
    assert.equal(result, registrant);
    
    let accountCreationTime = await ENSSubdomainRegistry.methods.getCreationTime(usernameHash).call();
    assert(accountCreationTime > 0);
it('should slash invalid subdomain', async () => {
      let subdomain = 'alicé';
      let subdomainHash = namehash.hash(subdomain + '.' + domains.free.name);
      let registrant = accountsArr[1];
      await ENSSubdomainRegistry.methods.register(
        web3Utils.sha3(subdomain),
        domains.free.namehash,
        utils.zeroAddress,
        utils.zeroBytes32,
        utils.zeroBytes32
      ).send({from: registrant});
      assert.equal(await ens.methods.owner(subdomainHash).call(), registrant);
      assert.notEqual(await ENSSubdomainRegistry.methods.getCreationTime(subdomainHash).call(), 0);
      await ENSSubdomainRegistry.methods.slashInvalidSubdomain(web3Utils.toHex(subdomain), domains.free.namehash, 4).send()
      //TODO: check events
      assert.equal(await ENSSubdomainRegistry.methods.getCreationTime(subdomainHash).call(), 0);
      assert.equal(await ens.methods.owner(subdomainHash).call(), utils.zeroAddress);
    });
    it('should not slash valid subdomain', async () => {
it('should register free status contact code only resolver-defined subdomain', async () => {
    let registrant = accountsArr[2];
    let subdomain = 'bob2';
    let usernameHash = namehash.hash(subdomain + '.' + domains.free.name);
    let contactCode = '0x04dbb31252d9bddb4e4d362c7b9c80cba74732280737af97971f42ccbdc716f3f3efb1db366880e52d09b1bfd59842e833f3004088892b7d14b9ce9e957cea9a82';
    let points = utils.generateXY(contactCode);
    let result = await ENSSubdomainRegistry.methods.register(
      web3Utils.sha3(subdomain),
      domains.free.namehash,
      registrant,
      points.x,
      points.y
    ).send({from: registrant});

    result = await ens.methods.owner(usernameHash).call()
    assert.equal(result, registrant, "Owner not set");
    result = await ens.methods.resolver(usernameHash).call()
    assert.equal(result, PublicResolver.address, "PublicResolver not set");
    result = await PublicResolver.methods.pubkey(usernameHash).call();
    let pubKey = utils.keyFromXY(result[0], result[1]);
} = {}
) => {
  const log = (...args) => {
    if (verbose) {
      console.log(...args)
    }
  }

  const accounts = await getAccounts(web3)

  log(`Deploying AragonID with ENS: ${ensAddress} and owner: ${owner}`)
  const FIFSResolvingRegistrar = artifacts.require('FIFSResolvingRegistrar')
  const ENS = artifacts.require('AbstractENS')

  const publicResolver = await ENS.at(ensAddress).resolver(
    namehash('resolver.eth')
  )
  const aragonID = await FIFSResolvingRegistrar.new(
    ensAddress,
    publicResolver,
    node
  )
  await logDeploy(aragonID, { verbose })

  log('assigning ENS name to AragonID')
  const ens = ENS.at(ensAddress)

  if ((await ens.owner(node)) === accounts[0]) {
    log('Transferring name ownership from deployer to AragonID')
    await ens.setOwner(node, aragonID.address)
  } else {
    log('Creating subdomain and assigning it to AragonID')

Is your System Free of Underlying Vulnerabilities?
Find Out Now