Example #1
0
 def _parse_other_section(self, config_parser: ConfigParser,
                          parsed_config: GatewayConfigFile) -> None:
     parsed_config.waves_chain = config_parser.get('other',
                                                   'waves_chain',
                                                   fallback="mainnet")
     parsed_config.environment = config_parser.get('other',
                                                   'environment',
                                                   fallback="prod")
Example #2
0
 def _parse_server_section(self, config_parser: ConfigParser,
                           parsed_config: GatewayConfigFile):
     parsed_config.gateway_host = config_parser.get('server',
                                                    'host',
                                                    fallback='localhost')
     parsed_config.gateway_port = config_parser.getint('server',
                                                       'port',
                                                       fallback=5000)
Example #3
0
    def parse_config_file_content(self,
                                  file_content: str) -> GatewayConfigFile:
        """Parses the given config file."""
        config_parser = ConfigParser()
        config_parser.read_string(file_content)
        parsed_config = GatewayConfigFile()

        self._assert_not_old_format(config_parser)

        self._parse_node_section(config_parser, parsed_config)

        if config_parser.has_section('fee'):
            self._parse_fee_section(config_parser, parsed_config)

        self._parse_gateway_address_section(config_parser, parsed_config)

        if config_parser.has_section('mongodb'):
            self._parse_mongodb_section(config_parser, parsed_config)

        if config_parser.has_section('other'):
            self._parse_other_section(config_parser, parsed_config)

        self._parse_server_section(config_parser, parsed_config)

        return parsed_config
Example #4
0
    def _parse_gateway_address_section(self, config_parser: ConfigParser,
                                       parsed_config: GatewayConfigFile):
        parsed_config.gateway_owner_address = config_parser.get(
            'gateway_address', 'owner')

        gateway_waves_address_public_key = config_parser.get(
            'gateway_address', 'waves_public_key')
        gateway_waves_address_private_key = config_parser.get(
            'gateway_address', 'waves_private_key')
        gateway_coin_address_public_key = config_parser.get(
            'gateway_address', 'coin_public_key')
        gateway_coin_address_private_key = config_parser.get(
            'gateway_address', 'coin_private_key',
            fallback=None)  # type: Optional[str]

        parsed_config.gateway_waves_address_secret = KeyPair(
            public=gateway_waves_address_public_key,
            secret=gateway_waves_address_private_key)
        parsed_config.gateway_coin_address_secret = KeyPair(
            public=gateway_coin_address_public_key,
            secret=gateway_coin_address_private_key)
    def parse_config_file_content(self,
                                  file_content: str) -> GatewayConfigFile:
        """Parses the given config file."""
        config_parser = ConfigParser()
        config_parser.read_string(file_content)
        parsed_config = GatewayConfigFile()

        self._parse_node_section(config_parser, parsed_config)
        self._parse_fee_section(config_parser, parsed_config)
        self._parse_gateway_address_section(config_parser, parsed_config)
        self._parse_mongodb_section(config_parser, parsed_config)
        self._parse_other_section(config_parser, parsed_config)
        self._parse_server_section(config_parser, parsed_config)
        self._parse_coin_section(config_parser, parsed_config)
        self._parse_explorer_section(config_parser, parsed_config)
        return parsed_config
Example #6
0
 def _parse_mongodb_section(self, config_parser: ConfigParser,
                            parsed_config: GatewayConfigFile) -> None:
     parsed_config.mongo_host = config_parser.get('mongodb', 'host')
     parsed_config.mongo_port = config_parser.getint('mongodb', 'port')
     parsed_config.mongo_database = config_parser.get('mongodb', 'database')
Example #7
0
 def _parse_fee_section(self, config_parser: ConfigParser,
                        parsed_config: GatewayConfigFile) -> None:
     parsed_config.coin_fee = self._parse_number(config_parser, 'fee',
                                                 'coin')
     parsed_config.gateway_fee = self._parse_number(config_parser, 'fee',
                                                    'gateway')
Example #8
0
 def _parse_node_section(self, config_parser: ConfigParser,
                         parsed_config: GatewayConfigFile) -> None:
     parsed_config.waves_node = config_parser.get('node', 'waves')
     parsed_config.coin_node = config_parser.get('node', 'coin')
 def _parse_explorer_section(self, config_parser: ConfigParser,
                             parsed_config: GatewayConfigFile):
     parsed_config.transaction_explorer_link = config_parser.get(
         'explorer', 'transaction_link')
     parsed_config.address_explorer_link = config_parser.get(
         'explorer', 'address_link')
 def _parse_coin_section(self, config_parser: ConfigParser,
                         parsed_config: GatewayConfigFile):
     parsed_config.coin_name = config_parser.get('coin', 'name')
     parsed_config.coin_factor = config_parser.get('coin', 'factor')
     parsed_config.coin_precision = config_parser.get('coin', 'precision')