vyper-language-server 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. vyper_language_server-0.2.2/.github/workflows/lint.yml +20 -0
  2. vyper_language_server-0.2.2/.github/workflows/release.yml +23 -0
  3. vyper_language_server-0.2.2/.github/workflows/test.yml +30 -0
  4. vyper_language_server-0.2.2/.gitignore +7 -0
  5. vyper_language_server-0.2.2/.pre-commit-config.yaml +12 -0
  6. vyper_language_server-0.2.2/LICENSE +21 -0
  7. vyper_language_server-0.2.2/PKG-INFO +156 -0
  8. vyper_language_server-0.2.2/README.md +141 -0
  9. vyper_language_server-0.2.2/architecture.md +65 -0
  10. vyper_language_server-0.2.2/examples/BondingCurve.vy +58 -0
  11. vyper_language_server-0.2.2/examples/BondingCurveUser.vy +27 -0
  12. vyper_language_server-0.2.2/examples/Foo.vy +64 -0
  13. vyper_language_server-0.2.2/examples/LiquidityGauge.vy +863 -0
  14. vyper_language_server-0.2.2/pyproject.toml +37 -0
  15. vyper_language_server-0.2.2/run.py +3 -0
  16. vyper_language_server-0.2.2/tests/conftest.py +131 -0
  17. vyper_language_server-0.2.2/tests/test_ast.py +451 -0
  18. vyper_language_server-0.2.2/tests/test_completions.py +183 -0
  19. vyper_language_server-0.2.2/tests/test_debouncer.py +23 -0
  20. vyper_language_server-0.2.2/tests/test_document_handling.py +87 -0
  21. vyper_language_server-0.2.2/tests/test_info.py +101 -0
  22. vyper_language_server-0.2.2/tests/test_multifile.py +112 -0
  23. vyper_language_server-0.2.2/tests/test_navigation.py +152 -0
  24. vyper_language_server-0.2.2/tests/test_parameterized.py +93 -0
  25. vyper_language_server-0.2.2/tests/test_utils.py +37 -0
  26. vyper_language_server-0.2.2/uv.lock +543 -0
  27. vyper_language_server-0.2.2/vyper_language_server/__init__.py +1 -0
  28. vyper_language_server-0.2.2/vyper_language_server/__main__.py +30 -0
  29. vyper_language_server-0.2.2/vyper_language_server/analyzer/__init__.py +0 -0
  30. vyper_language_server-0.2.2/vyper_language_server/ast.py +390 -0
  31. vyper_language_server-0.2.2/vyper_language_server/debounce.py +19 -0
  32. vyper_language_server-0.2.2/vyper_language_server/grammar/__init__.py +0 -0
  33. vyper_language_server-0.2.2/vyper_language_server/grammar/grammar.lark +323 -0
  34. vyper_language_server-0.2.2/vyper_language_server/handlers/completion.py +201 -0
  35. vyper_language_server-0.2.2/vyper_language_server/handlers/hover.py +102 -0
  36. vyper_language_server-0.2.2/vyper_language_server/handlers/signatures.py +99 -0
  37. vyper_language_server-0.2.2/vyper_language_server/logging.py +20 -0
  38. vyper_language_server-0.2.2/vyper_language_server/main.py +186 -0
  39. vyper_language_server-0.2.2/vyper_language_server/navigation.py +184 -0
  40. vyper_language_server-0.2.2/vyper_language_server/utils.py +216 -0
@@ -0,0 +1,20 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ pre-commit:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v4
16
+ - name: Set up Python
17
+ run: uv python install
18
+ - name: Install dependencies
19
+ run: uv sync --all-extras --dev
20
+ - run: uv run pre-commit run --all-files
@@ -0,0 +1,23 @@
1
+ name: Release to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ environment: pypi
11
+ permissions:
12
+ id-token: write
13
+ contents: read
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v4
18
+ - name: Set up Python
19
+ run: uv python install
20
+ - name: Build
21
+ run: uv build
22
+ - name: Publish
23
+ run: uv publish
@@ -0,0 +1,30 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ pytest:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v4
16
+ - name: Set up Python
17
+ run: uv python install
18
+ - name: Install dependencies
19
+ run: uv sync --all-extras --dev
20
+ - name: Run pytest with coverage
21
+ run: uv run coverage run -m pytest
22
+ - name: Report coverage
23
+ run: |
24
+ uv run coverage html
25
+ uv run coverage report --fail-under=75
26
+ - name: Upload coverage report
27
+ uses: actions/upload-artifact@v4
28
+ with:
29
+ name: coverage-report
30
+ path: ./htmlcov
@@ -0,0 +1,7 @@
1
+ .DS_Store
2
+ .idea
3
+ *.log
4
+ tmp/
5
+ __pycache__
6
+ dist/
7
+ .python-version
@@ -0,0 +1,12 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: check-yaml
6
+ - id: end-of-file-fixer
7
+ - id: trailing-whitespace
8
+ - repo: https://github.com/astral-sh/ruff-pre-commit
9
+ rev: v0.8.3
10
+ hooks:
11
+ - id: ruff
12
+ - id: ruff-format
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Vyperlang team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: vyper-language-server
3
+ Version: 0.2.2
4
+ Summary: Language server for Vyper, a pythonic smart contract language
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Keywords: language-server,lsp,vyper
8
+ Requires-Python: >=3.12
9
+ Requires-Dist: lark<2.0.0,>=1.1.7
10
+ Requires-Dist: lsprotocol<2024.0.0,>=2023.0.1
11
+ Requires-Dist: packaging>=23.1.0
12
+ Requires-Dist: pygls<2.0.0,>=1.3.1
13
+ Requires-Dist: vyper<0.5.0,>=0.4.1
14
+ Description-Content-Type: text/markdown
15
+
16
+ # Vyper Language Server
17
+
18
+ A language server for [Vyper](https://github.com/vyperlang/vyper), a pythonic smart contract language for the EVM.
19
+
20
+ Forked from [vyperlang/vyper-lsp](https://github.com/vyperlang/vyper-lsp).
21
+
22
+ ## Requirements
23
+
24
+ - Python >= 3.12
25
+ - Vyper >= 0.4.1
26
+
27
+ The Vyper version installed in your virtual environment must be capable of compiling your contract for full support.
28
+
29
+ ## Installation
30
+
31
+ This language server imports Vyper as a library, so it should be installed in the same environment as your project's Vyper.
32
+
33
+ ### As a project dev dependency (recommended)
34
+
35
+ ```toml
36
+ # pyproject.toml
37
+ [dependency-groups]
38
+ dev = [
39
+ "vyper-language-server",
40
+ ]
41
+
42
+ [tool.uv.sources]
43
+ vyper-language-server = { git = "https://github.com/latticafi/vyper-language-server" }
44
+ ```
45
+
46
+ Then `uv sync`.
47
+
48
+ ### Via pipx (global)
49
+
50
+ ```bash
51
+ pipx install git+https://github.com/latticafi/vyper-language-server.git
52
+ ```
53
+
54
+ Note: when installed globally, the server will use whatever Vyper version is in its own environment, which may not match your project.
55
+
56
+ ### Verify
57
+
58
+ ```bash
59
+ which vyper-language-server
60
+ ```
61
+
62
+ ## Editor Setup
63
+
64
+ ### Neovim
65
+
66
+ Add to `~/.config/nvim/init.lua`:
67
+
68
+ ```lua
69
+ vim.api.nvim_create_autocmd({ "BufEnter" }, {
70
+ pattern = { "*.vy" },
71
+ callback = function()
72
+ vim.lsp.start({
73
+ name = "vyper-language-server",
74
+ cmd = { "vyper-language-server" },
75
+ root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1])
76
+ })
77
+ end,
78
+ })
79
+ ```
80
+
81
+ If installed as a project dep, point to the venv binary:
82
+
83
+ ```lua
84
+ vim.api.nvim_create_autocmd({ "BufEnter" }, {
85
+ pattern = { "*.vy" },
86
+ callback = function()
87
+ local venv = vim.fs.find({ ".venv" }, { upward = true })[1]
88
+ local cmd = venv and (venv .. "/bin/vyper-language-server") or "vyper-language-server"
89
+ vim.lsp.start({
90
+ name = "vyper-language-server",
91
+ cmd = { cmd },
92
+ root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1])
93
+ })
94
+ end,
95
+ })
96
+ ```
97
+
98
+ ### Emacs
99
+
100
+ ```emacs-lisp
101
+ (define-derived-mode vyper-mode python-mode "Vyper" "Major mode for editing Vyper.")
102
+
103
+ (add-to-list 'auto-mode-alist '("\\.vy\\'" . vyper-mode))
104
+
105
+ (with-eval-after-load 'lsp-mode
106
+ (add-to-list 'lsp-language-id-configuration
107
+ '(vyper-mode . "vyper"))
108
+ (lsp-register-client
109
+ (make-lsp-client :new-connection
110
+ (lsp-stdio-connection `(,(executable-find "vyper-language-server")))
111
+ :activation-fn (lsp-activate-on "vyper")
112
+ :server-id 'vyper-language-server)))
113
+ ```
114
+
115
+ ## Features
116
+
117
+ - Diagnostics (compile errors and warnings)
118
+ - Completions (state variables, functions, decorators, types, imports)
119
+ - Hover information
120
+ - Go to definition / declaration
121
+ - Find references
122
+ - Signature help
123
+
124
+ ## Development
125
+
126
+ ### Setup
127
+
128
+ 1. **Install uv** (Fast Python package installer and resolver)
129
+
130
+ ```bash
131
+ pip install uv
132
+ # Or on macOS with Homebrew
133
+ brew install uv
134
+ ```
135
+
136
+ 2. **Clone and install**
137
+
138
+ ```bash
139
+ git clone https://github.com/latticafi/vyper-language-server.git
140
+ cd vyper-language-server
141
+ uv sync
142
+ ```
143
+
144
+ ### Commands
145
+
146
+ ```bash
147
+ uv run pytest # run tests
148
+ uv run ruff check . # lint
149
+ uv run ruff format . # format
150
+ uv run coverage run -m pytest # test with coverage
151
+ uv run coverage report # view coverage
152
+ ```
153
+
154
+ ## License
155
+
156
+ MIT
@@ -0,0 +1,141 @@
1
+ # Vyper Language Server
2
+
3
+ A language server for [Vyper](https://github.com/vyperlang/vyper), a pythonic smart contract language for the EVM.
4
+
5
+ Forked from [vyperlang/vyper-lsp](https://github.com/vyperlang/vyper-lsp).
6
+
7
+ ## Requirements
8
+
9
+ - Python >= 3.12
10
+ - Vyper >= 0.4.1
11
+
12
+ The Vyper version installed in your virtual environment must be capable of compiling your contract for full support.
13
+
14
+ ## Installation
15
+
16
+ This language server imports Vyper as a library, so it should be installed in the same environment as your project's Vyper.
17
+
18
+ ### As a project dev dependency (recommended)
19
+
20
+ ```toml
21
+ # pyproject.toml
22
+ [dependency-groups]
23
+ dev = [
24
+ "vyper-language-server",
25
+ ]
26
+
27
+ [tool.uv.sources]
28
+ vyper-language-server = { git = "https://github.com/latticafi/vyper-language-server" }
29
+ ```
30
+
31
+ Then `uv sync`.
32
+
33
+ ### Via pipx (global)
34
+
35
+ ```bash
36
+ pipx install git+https://github.com/latticafi/vyper-language-server.git
37
+ ```
38
+
39
+ Note: when installed globally, the server will use whatever Vyper version is in its own environment, which may not match your project.
40
+
41
+ ### Verify
42
+
43
+ ```bash
44
+ which vyper-language-server
45
+ ```
46
+
47
+ ## Editor Setup
48
+
49
+ ### Neovim
50
+
51
+ Add to `~/.config/nvim/init.lua`:
52
+
53
+ ```lua
54
+ vim.api.nvim_create_autocmd({ "BufEnter" }, {
55
+ pattern = { "*.vy" },
56
+ callback = function()
57
+ vim.lsp.start({
58
+ name = "vyper-language-server",
59
+ cmd = { "vyper-language-server" },
60
+ root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1])
61
+ })
62
+ end,
63
+ })
64
+ ```
65
+
66
+ If installed as a project dep, point to the venv binary:
67
+
68
+ ```lua
69
+ vim.api.nvim_create_autocmd({ "BufEnter" }, {
70
+ pattern = { "*.vy" },
71
+ callback = function()
72
+ local venv = vim.fs.find({ ".venv" }, { upward = true })[1]
73
+ local cmd = venv and (venv .. "/bin/vyper-language-server") or "vyper-language-server"
74
+ vim.lsp.start({
75
+ name = "vyper-language-server",
76
+ cmd = { cmd },
77
+ root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1])
78
+ })
79
+ end,
80
+ })
81
+ ```
82
+
83
+ ### Emacs
84
+
85
+ ```emacs-lisp
86
+ (define-derived-mode vyper-mode python-mode "Vyper" "Major mode for editing Vyper.")
87
+
88
+ (add-to-list 'auto-mode-alist '("\\.vy\\'" . vyper-mode))
89
+
90
+ (with-eval-after-load 'lsp-mode
91
+ (add-to-list 'lsp-language-id-configuration
92
+ '(vyper-mode . "vyper"))
93
+ (lsp-register-client
94
+ (make-lsp-client :new-connection
95
+ (lsp-stdio-connection `(,(executable-find "vyper-language-server")))
96
+ :activation-fn (lsp-activate-on "vyper")
97
+ :server-id 'vyper-language-server)))
98
+ ```
99
+
100
+ ## Features
101
+
102
+ - Diagnostics (compile errors and warnings)
103
+ - Completions (state variables, functions, decorators, types, imports)
104
+ - Hover information
105
+ - Go to definition / declaration
106
+ - Find references
107
+ - Signature help
108
+
109
+ ## Development
110
+
111
+ ### Setup
112
+
113
+ 1. **Install uv** (Fast Python package installer and resolver)
114
+
115
+ ```bash
116
+ pip install uv
117
+ # Or on macOS with Homebrew
118
+ brew install uv
119
+ ```
120
+
121
+ 2. **Clone and install**
122
+
123
+ ```bash
124
+ git clone https://github.com/latticafi/vyper-language-server.git
125
+ cd vyper-language-server
126
+ uv sync
127
+ ```
128
+
129
+ ### Commands
130
+
131
+ ```bash
132
+ uv run pytest # run tests
133
+ uv run ruff check . # lint
134
+ uv run ruff format . # format
135
+ uv run coverage run -m pytest # test with coverage
136
+ uv run coverage report # view coverage
137
+ ```
138
+
139
+ ## License
140
+
141
+ MIT
@@ -0,0 +1,65 @@
1
+ # Vyper LSP Architecture
2
+
3
+ LSP stands for Language Server Protocol. It enables us to provide IDE-like features in an editor-agnostic way. LSP defines certain methods that a client and server can expect to use to communicate with each other, such that the server can be language-specific and the client can be editor-specific, and the user gets the best of both.
4
+
5
+ Pygls is a very intuitive framework for building an LSP server. It follows an approach similar to FastAPI, letting us define and assign handlers for each "method" the LSP server should speak.
6
+
7
+ We have separated concerns across a few different layers in order to best allow the LSP server to grow and extend over time.
8
+
9
+ ## Server Layer
10
+
11
+ This is currently confined to `vyper_lsp/main.py`
12
+
13
+ In this layer, we want to define handlers for each LSP method, and in those handlers invoke the appropriate module to compute a valid response.
14
+
15
+ This means this layer should have minimal logic of its own. There should be no concept of ASTs, any source-code level features, syntax, etc. at this layer. Only what is required to start up the server itself, and hook up LSP methods to the appropriate sources of data.
16
+
17
+ ## Analyzer Layer
18
+
19
+ This is currently made up of the modules under `vyper_lsp/analyzers/`. Here, we define a base class called `BaseAnalyzer` which defines the interface our server layer will use to communicate with the Analyzer layer.
20
+
21
+ Currently there are two "analysis" functions we support
22
+
23
+ - `hover_info`: returns information about a symbol being hovered over
24
+ - `get_diagnostics`: returns a list of errors or warnings to be reported to the user
25
+ - `get_completions`: returns a list of suggested completions for the current cursor position
26
+
27
+ Analyzers classes expose functions which act on `Document` and `Params` arguments. `Document` represents the file being worked on. Through the `Document` class, `Analyzers` can easily access the entire source of the contract, as well as line-by-line information, filename, etc. `Params` will be specific to each method, and contain necessary information to answer queries for that method. For example, the params object when looking up information about a given symbol will include the current cursor position, which in combination with the line-by-line source code exposed by the `Document`, can be used to determine what symbol we're looking up.
28
+
29
+ It is up to Analyzers to determine how they will return appropriate results given a query. They should abstract this away from the Server layer entirely.
30
+
31
+ The two currently implemented `Analyzers` are the `ASTAnalyzer` and the `SourceAnalyzer`.
32
+
33
+ ### ASTAnalyzer
34
+
35
+ This is where the most rich processing can happen, but where our tightest requirements around Vyper versions are.
36
+
37
+ This analyzer attempts to compile the current contract via Vyper as a library. This means the version of Vyper we have installed must
38
+
39
+ - Be capable of compiling this contract according to version requirements
40
+ - Be >= 0.3.7 so we can use the internal APIs our analysis depends on
41
+
42
+ This Analyzer is a good example of abstracting things away from the Server layer. It operates primarily on ASTs and nodes within it, but should not expose any implementation details about this to the Server layer.
43
+
44
+ ### SourceAnalyzer
45
+
46
+ This analyzer should not be used unless the Vyper version of the contract being worked with is too old to run AST analysis on.
47
+
48
+ This is a sort of "fallback" analyzer. This does not depend on Vyper as a library, in hopes of loosening Vyper version requirements. It does two stages of analysis.
49
+
50
+ #### Syntax Analysis
51
+
52
+ This leverages Vyper's `lark` grammar to check for syntax errors. This does not catch semantic errors. For example, with syntax analysis we can tell that `x + foo(7) = 24;` is wrong for many reasons (not valid syntax), but we can't tell that `x: uint256 = "hello"` is wrong (not valid semantics)
53
+
54
+ #### Semantic Analysis
55
+
56
+ This analyzer also tries to do some semantic analysis. It leverages `vvm` to compile contracts with version requirements incompatible with currently installed Vyper, and reports any errors encountered.
57
+
58
+ This lets us work with a wider array of Vyper versions, but is significantly slower to use, due to overhead involved in going through the shell. There is also a big limit on what information we can gain other than compilation errors, because for successful compilation, we're limited to the cli outputs as defined in that Vyper version.
59
+
60
+
61
+ ## Navigation Layer
62
+
63
+ This layer is made up of modules which expose classes that can handle navigation-related lookups. This is stuff like "find the declaration of this symbol". We currently have an AST navigator implemented in `vyper_lsp/navigation.py`
64
+
65
+ There is potential to implement navigation support that does not require AST analysis by leveraging the Lark grammar to parse into an unchecked Lark AST. This will be lacking any Vyper information such as type, etc. but is nicer to work with than raw source.
@@ -0,0 +1,58 @@
1
+ # version ^0.4.0
2
+ """
3
+ @title Bonding Curve Functions
4
+ @custom:contract-name BondingCurve
5
+ @license MIT License
6
+ @author z80
7
+ @notice These functions can be used to implement a basic bonding curve
8
+ """
9
+ current_step: uint256
10
+ EXPONENT: immutable(uint256)
11
+ SCALING_FACTOR: immutable(uint256)
12
+ TICK_SIZE: immutable(uint256)
13
+
14
+ @deploy
15
+ def __init__(start_step: uint256, exponent: uint256, scaling_factor: uint256, tick_size: uint256):
16
+ self.current_step = start_step
17
+ EXPONENT = exponent
18
+ SCALING_FACTOR = scaling_factor
19
+ TICK_SIZE = tick_size
20
+
21
+ @view
22
+ @internal
23
+ def _get_current_price() -> uint256:
24
+ """
25
+ Returns the current price of the token
26
+ """
27
+ current_step_exp: uint256 = pow_mod256(self.current_step, EXPONENT)
28
+ return current_step_exp * SCALING_FACTOR // TICK_SIZE
29
+
30
+ @view
31
+ @internal
32
+ def _get_price_at_step(step: uint256) -> uint256:
33
+ """
34
+ Returns the price of the token at a given step
35
+ """
36
+ step_exp: uint256 = pow_mod256(step, EXPONENT)
37
+ return step_exp * SCALING_FACTOR // TICK_SIZE
38
+
39
+ @internal
40
+ def _increment_step():
41
+ """
42
+ Increments the current step by 1
43
+ """
44
+ self.current_step += 1
45
+
46
+ @internal
47
+ def _decrement_step():
48
+ """
49
+ Decrements the current step by 1
50
+ """
51
+ self.current_step -= 1
52
+
53
+ @internal
54
+ def _set_step(step: uint256):
55
+ """
56
+ Sets the current step to a given value
57
+ """
58
+ self.current_step = step
@@ -0,0 +1,27 @@
1
+ #pragma version ^0.4.0
2
+
3
+ import BondingCurve
4
+
5
+ initializes: BondingCurve
6
+
7
+ x: uint256
8
+
9
+ s: constant(uint256) = 10**18
10
+
11
+ event Transfer:
12
+ foo: address
13
+ bar: uint256
14
+
15
+ flag Foo:
16
+ BAR
17
+ BAZ
18
+
19
+ struct FooStruct:
20
+ foo: uint256
21
+ bar: uint256
22
+
23
+ @deploy
24
+ def __init__(shares_name: String[25], shares_symbol: String[5], shares_decimals: uint8):
25
+ foo: Foo = Foo.BAR
26
+ foo_s: FooStruct = FooStruct(foo=1, bar=2)
27
+ BondingCurve.__init__(0, 2, 10**18, 16000)
@@ -0,0 +1,64 @@
1
+ #pragma version ^0.4.0
2
+
3
+ event Foo:
4
+ arg1: uint256
5
+ arg2: address
6
+
7
+ struct Bar:
8
+ x: uint256
9
+
10
+ flag Roles:
11
+ ADMIN
12
+ USER
13
+
14
+ m: Bar
15
+ n: Roles
16
+
17
+ FEE: constant(uint256) = 100
18
+
19
+ @deploy
20
+ def __init__():
21
+ y: uint256 = 100_000_100
22
+ x: uint256 = FEE
23
+ z: Bar = Bar(x=y)
24
+ m: Roles = Roles.ADMIN
25
+ log Foo(1, msg.sender)
26
+ n: Roles = Roles.USER
27
+ self.m = z
28
+ self.n = n
29
+ a: address = empty(address)
30
+ self.m.x = 1
31
+ log Foo(1, msg.sender)
32
+ log Foo(1, msg.sender)
33
+
34
+ @external
35
+ def foo() -> uint256:
36
+ return self.bar(10, 12)[0]
37
+
38
+ x: uint256
39
+
40
+ @internal
41
+ def bar(x: uint256, y: uint256) -> uint256[2]:
42
+ return [self.x + x + y, x]
43
+
44
+ @external
45
+ def baz(a: uint256, b: uint256) -> Bar:
46
+ return self.m
47
+
48
+ _owner: address
49
+
50
+ interface Ownable:
51
+ # get address of owner
52
+ def owner() -> address: view
53
+
54
+ implements: Ownable
55
+
56
+ @view
57
+ @external
58
+ def owner() -> address:
59
+ return self._owner
60
+
61
+ N_COINS: constant(uint256) = 2
62
+ A_MULTIPLIER: constant(uint256) = 10000
63
+
64
+ MIN_A: constant(uint256) = N_COINS**N_COINS * A_MULTIPLIER // 10