-
Notifications
You must be signed in to change notification settings - Fork 90
Change cairo_version into Account property
#1183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ec2e124 to
6907be0
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## development #1183 +/- ##
===============================================
+ Coverage 97.44% 97.58% +0.13%
===============================================
Files 92 92
Lines 4661 4680 +19
===============================================
+ Hits 4542 4567 +25
+ Misses 119 113 -6
☔ View full report in Codecov by Sentry. |
drknzz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Let's just have a second look around the library to make sure no place with account was omitted.
ClementWalter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you should get the cairo_version completely internal, and set it async based on the address in the fixture, though the current code works as well
|
|
||
| @property | ||
| def cairo_version(self) -> int: | ||
| return self._cairo_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you could do instead something like
@property
async def cairo_version(self) -> int:
if self._cairo_version is None:
# Get the class hash of self.address
class_ = await self._client.get_class_at(self.address)
self.cairo_version = 1 if isinstance(class, Sierra) else 0
return self._cairo_version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if an async property would be a good UI. However, we've got a sync interface for that, so something like this would work without awaiting:
@property
def cairo_version(self) -> int:
if self._cairo_version is None:
if isinstance(self._client, GatewayClient):
contract_class = self._client.get_full_contract_sync(contract_address=self._address)
else:
contract_class = self.client.get_class_at_sync(contract_address=self._address)
self._cairo_version = 1 if isinstance(contract_class, SierraContractClass) else 0
return self._cairo_versionwdyt?
edit: this breaks a lot of things, but the same question applies, is an async property a good UI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, just see this comment now. Async property you're right may not have been the best thing, but with sync definitely as It's quite common to use property to cache a given computed/fetched data
there is no information regarding the internal implementation for the outside world, use you still use self.cairo_version
Closes #1182
Introduced changes
cairo_versionparameter toAccountconstructor andAccount.deploy_accountmethodcairo_versionproperty