-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1259 from CityOfZion/CU-86dtfv7aw
#86dtfv7aw - Error when compiling smart contract with custom class th…
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
boa3_test/test_sc/class_test/ReturnDictWithClassAttributes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from typing import Any | ||
|
||
from boa3.builtin.compile_time import public | ||
|
||
|
||
class Example: | ||
def __init__(self, shape: str, color: str, background: str, size: str): | ||
self.shape = shape | ||
self.color = color | ||
self.background = background | ||
self.size = size | ||
|
||
def test_value(self) -> dict[str, str]: | ||
return { | ||
'shape': self.shape, | ||
'color': self.color, | ||
'background': self.background, | ||
'size': self.size | ||
} | ||
|
||
def test_keys(self) -> dict[str, str]: | ||
return { | ||
self.shape: 'shape', | ||
self.color: 'color', | ||
self.background: 'background', | ||
self.size: 'size' | ||
} | ||
|
||
def test_pair(self) -> dict[str, str]: | ||
return { | ||
self.shape: self.shape, | ||
self.color: self.color, | ||
self.background: self.background, | ||
self.size: self.size | ||
} | ||
|
||
|
||
@public | ||
def test_only_values() -> Any: | ||
example = Example('Rectangle', 'Blue', 'Black', 'Small') | ||
return example.test_value() | ||
|
||
|
||
@public | ||
def test_only_keys() -> Any: | ||
example = Example('Rectangle', 'Blue', 'Black', 'Small') | ||
return example.test_keys() | ||
|
||
|
||
@public | ||
def test_pair() -> Any: | ||
example = Example('Rectangle', 'Blue', 'Black', 'Small') | ||
return example.test_pair() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters