• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CityOfZion / neo3-boa / 235d0fc0-04aa-49cd-8c06-541e00690aff

pending completion
235d0fc0-04aa-49cd-8c06-541e00690aff

Pull #1090

circleci

luc10921
CU-864euhg5d - add a simpler NEP-17 token
Pull Request #1090: Add a simpler NEP-17 token

19242 of 21070 relevant lines covered (91.32%)

2.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/boa3/internal/cli_commands/compile_command.py
1
import logging
×
2
import os
×
3
import sys
×
4
from argparse import _SubParsersAction
×
5
from typing import Optional
×
6

7
from boa3.boa3 import Boa3
×
8
from boa3.internal.cli_commands.icommand import ICommand
×
9
from boa3.internal.exception.NotLoadedException import NotLoadedException
×
10

11

12
class CompileCommand(ICommand):
×
13

14
    def __init__(self, main_parser: _SubParsersAction):
×
15
        super().__init__(main_parser, 'compile', 'Compiles your smart contract')
×
16

17
    def add_arguments_and_callback(self):
×
18
        self.parser.add_argument("input",
×
19
                                 type=str,
20
                                 help=".py smart contract to compile")
21
        self.parser.add_argument("-db", "--debug",
×
22
                                 action='store_true',
23
                                 help="generates a .nefdbgnfo file")
24
        self.parser.add_argument("--project-path",
×
25
                                 type=str,
26
                                 help="Project root path. Path of the contract by default.")
27
        self.parser.add_argument("-e", "--env",
×
28
                                 type=str,
29
                                 help="Set the contract environment for compiling.")
30
        self.parser.add_argument("-o", "--output-path",
×
31
                                 metavar='NEF_OUTPUT',
32
                                 type=str,
33
                                 default=None,
34
                                 help="Chooses the name and where the compiled files will be generated, "
35
                                      "if not specified it will be generated on the same directory with the same name "
36
                                      "as the python file.")
37

38
        self.parser.set_defaults(func=self.execute_command)
×
39

40
    @staticmethod
×
41
    def execute_command(args: dict):
×
42
        sc_path: str = args['input']
×
43
        project_path: str = args['project_path']
×
44
        debug: bool = args['debug']
×
45
        env: str = args['env']
×
46
        output_path: Optional[str] = args['output_path']
×
47

48
        if not sc_path.endswith(".py") or not os.path.isfile(sc_path):
×
49
            logging.error("Input file is not .py")
×
50
            sys.exit(1)
×
51

52
        fullpath = os.path.realpath(sc_path)
×
53
        path, filename = os.path.split(fullpath)
×
54

55
        if isinstance(output_path, str):
×
56
            if not output_path.endswith('.nef'):
×
57
                logging.error("Output path file extension is not .nef")
×
58
                sys.exit(1)
×
59

60
            path, filename = os.path.split(os.path.realpath(output_path))
×
61

62
        try:
×
63
            Boa3.compile_and_save(sc_path, output_path=output_path, debug=debug, root_folder=project_path, env=env)
×
64
            logging.info(f"Wrote {filename.replace('.py', '.nef')} to {path}")
×
65
        except NotLoadedException as e:
×
66
            error_message = e.message
×
67
            log_error = 'Could not compile'
×
68
            if len(error_message) > 0:
×
69
                log_error += f': {error_message}'
×
70

71
            logging.error(log_error)
×
72
        except Exception as e:
×
73
            logging.exception(e)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc