Ejemplo n.º 1
0
    def _assign_ens(self):
        '''
        Updates ENS entries
        '''
        # prepare domain
        ens_domain = self._ens_name
        node = ENS.namehash(ens_domain)

        # connect to registry and resolver
        ens_registry = ContractConnection("ens_registry", self.app_config)
        ens_resolver = ContractConnection("ens_resolver", self.app_config)

        
        # set resolver
        curr_resolver = ens_registry.functions.call("resolver", node)
        if curr_resolver == "0x0000000000000000000000000000000000000000":
            resolver_address = ContractConnection.get_ens_address(self.app_config.chain, "ens_resolver")
            ens_registry.functions.transact("setResolver", node, resolver_address)
        else:
            logging.info("Resolver already set for %s", ens_domain)

        # set ABI
        ens_resolver.functions.transact("setABI", node, 1, json.dumps(self.abi).encode())

        # set address
        self.contr_address = self._w3.toChecksumAddress(self.contr_address)
        ens_resolver.functions.transact("setAddr", node, self.contr_address)
        ens_resolver.functions.transact("setName", node, ens_domain)

        # get data for output
        addr = ens_resolver.functions.call("addr", node)
        name = ens_resolver.functions.call("name", node)

        logging.info("SUCCESS – Set contract with address %s to name %s", addr, name)
Ejemplo n.º 2
0
    def _security_check(self):
        '''
        Makes sure that an existing contract does not get overwritten unintensionally
        '''
        # connect to public resolver
        ens_resolver = ContractConnection("ens_resolver", self.app_config)
        node = ENS.namehash(self._ens_name)
        temp = ens_resolver.functions.call("addr", node)

        # check if ens address is already linked to a contract and potential overwriting intended
        if temp != "0x0000000000000000000000000000000000000000" and self.app_config.overwrite_ens_link is not True:
            logging.error("A smart Contract already deployed on this domain and overwrite_ens_link is not True.")
            exit("Stopping process.")
Ejemplo n.º 3
0
    def _assign_name(self):
    
        # prepare domain
        

        url = self.app_config.ens_name
        url = re.sub('\.berg$', '', url)
        
        
        labelhash = self._w3.sha3(text=url);
        ens_registrar = ContractConnection("ens_registrar", self.app_config)
        print(ens_registrar)
 
        # set subdomain
        tx_hash = ens_registrar.functions.transact("register", labelhash, self.app_config.deploying_address)
        print(tx_hash)