Skip to content

Add dataclasses for transactions #649

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

war-in
Copy link
Contributor

@war-in war-in commented Jan 9, 2023

Closes #640
Closes #634
Closes #662

Introduced changes

  • Transactions from cairo-lang are replaced with our implementation
  • QUERY_VERSION_BASE is removed

  • This PR contains breaking changes

@war-in war-in requested review from cptartur and drknzz January 9, 2023 14:10
@war-in war-in self-assigned this Jan 10, 2023
@codecov
Copy link

codecov bot commented Jan 10, 2023

Codecov Report

❗ No coverage uploaded for pull request base (refactor/remove-cairo-lang-dependency@8b18177). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@                           Coverage Diff                            @@
##             refactor/remove-cairo-lang-dependency     #649   +/-   ##
========================================================================
  Coverage                                         ?   97.49%           
========================================================================
  Files                                            ?       57           
  Lines                                            ?     2796           
  Branches                                         ?        0           
========================================================================
  Hits                                             ?     2726           
  Misses                                           ?       70           
  Partials                                         ?        0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@war-in war-in linked an issue Jan 12, 2023 that may be closed by this pull request
Copy link
Member

@cptartur cptartur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to address the issue with our typing currently requiring casts in multiple places. Otherwise looks mostly good.

@war-in war-in merged commit 169d6a5 into refactor/remove-cairo-lang-dependency Jan 13, 2023
@war-in war-in deleted the refactor/add-dataclasses-for-transactions branch January 13, 2023 11:13
drknzz added a commit that referenced this pull request Feb 20, 2023
* Remove usages of `CastableToHash` (#587)

* Remove CastableToHash import

* Change hash to int

* Replace `FIELD_PRIME` in felt.py (#588)

* Add FIELD_PRIME constant

* Change FIELD_PRIME to hex

* Replace `get_random_private_key` (#597)

* Replace get_random_private_key

* Change key generation method

* Move func to test utils

* Add comment

* Replace `get_selector_from_name` and `get_storage_var_address` implementations (#586)

* Remove uses of starkware.starknet.public.api

* Add eth-utils dependency

* Change import path

* Apply review

* Move functions to separate files

* Fix path in cairo-lang comment

* Add unit tests

* Remove `ContractAddressSalt.get_random_value()` usages (#596)

* add custom `get_random_value`

* fix imports

* rename to `get_random_salt`

* move `get_random_salt` to deployer.py

* make it private

* do not use private `get_random_salt`

* Replace `compute_hash_on_elements` (#602)

* replace compute_hash_on_elements

* replace calculate_contract_address_from_hash

* remove unused PREFIX_TRANSACTION

* add tests

* fix pyright

* add type for data

* Update starknet_py/utils/crypto/facade.py

Co-authored-by: Kamil Jankowski <[email protected]>

* move to constants

* remove unnecessary function

* remove `hash_call_with` function & `hash_func` parameter

* fix the imports

Co-authored-by: Kamil Jankowski <[email protected]>

* Replace transaction hash calculation (#621)

* add functions to compute transaction hashes

* replace usages from starkware

* deprecate compute_invoke_hash

* add tests

* rename to compute_transaction_hash

* fix error

* add docstrings

* replace 0 with DEFAULT_ENTRY_POINT_SELECTOR

* modify test case

* update lock

* fixes after merge

* update lock

* fix imports in the `fmt: off` files

* fix import

* Add dataclasses for transactions (#649)

* `Declare` is working :o

* format

* [wip] adding transactions

* it is working!

* format

* remove QUERY_VERSION_BASE and change TransactionType to own implementation

* change `general_config` to `chain_id`

* [wip] bulk

* format

* repair bulk

* remove unused blockIdentifier

* bring DEFAULT_DECLARE_SENDER_ADDRESS to constants

* fix import

* add tx_type as @classmethod

* DEFAULT_DECLARE_SENDER_ADDRESS = 1

* post-merge fixes

* fix typing errors

* format

* resolve last typing issues

* format

* remove unnecessary file

* update docstrings and comments in transaction.py

* format

* Update starknet_py/net/account/account_client.py

Co-authored-by: Kamil Jankowski <[email protected]>

* rename `InvokeFunction` to `Invoke`

* apply part of the review changes. The biggest one:
remove SignableTransaction and replace it with AccountTransaction

* tx_type as a property

* fix docs

* rename `tx_type` to `type`
remove unnecessary `post_dump` method

* format

* remove comment

* make `_remove_entry_point_selector` private

* remove duplicated TransactionType

* NoneFelt docstring

* fix docs

* review suggestions

* _prepare_invoke_function -> _prepare_invoke

* add marshmallow-dataclass as dependency

* InvokeFunction -> Invoke in the docstring

* update typing

* Revert "add marshmallow-dataclass as dependency"

This reverts commit 7e0a163.

* change marshmallow-dataclass version

* remove casting

* remove types.py

* move `pylint:disable`

Co-authored-by: Kamil Jankowski <[email protected]>

* Replace compress and decompress program (#683)

* Use own compress and decompress program

* Fix lint

* Fix typing

* Inline `_compress_program`

* Add basic Declare test

* Fix tests typing

* Remove `_contract_attribute_name`

* remove unused imports

* update lock

* rename function

* add ABC to the AccountTransaction

* update base signer interface

* update comment

* move MASK_250

* Migration guide (remove cairo lang) (#670)

* migration guide v1

* add `the`

* add info about imports

* formatting

* Update docs/migration_guide.rst

Co-authored-by: Artur Michałek <[email protected]>

* add `Transaction's dataclasses` section

* fix bullet list

* remove unnecessary line

* suggested changes

* Update docs/migration_guide.rst

Co-authored-by: Artur Michałek <[email protected]>

* review suggestions

Co-authored-by: Artur Michałek <[email protected]>

* clean after merge

* update lock

* format

* aftermerge fixes

* fix types

* fix failing docs

* add tests for `Transaction.calculate_hash`

* Replace`StarkErrorCode` (#737)

* remove usage of StarknetErrorCode

* one last usage of `get_selector_from_name` from cairo lang

* Support calculating class_hash (#660)

* Add compute_class_hash

* Add tests

* Add tests

* Remove pre-0.10.0 class_hash calculation

* Fix sorted keys in serialized class

* Remove else branch

* Remove else branch

* Hash module (#677)

* Create hash module

* Format

* Fix docs build

* Add docstrings

* Add pedersen_hash tests

* Format

* Fix test

* Replace ContractClass (#686)

* Rename DeclaredContract to ContractClass

* Replace ContractClass

* Restore class hash < 0.10.0 [WIP]

* Use re.sub

* Remove int casting

* Add tests

* Add compute_class_hash

* Remove pre-0.10.0 class_hash calculation

* Fix sorted keys in serialized class

* Remove else branch

* Remove else branch

* Hash module (#677)

* Create hash module

* Format

* Fix docs build

* Add docstrings

* Add pedersen_hash tests

* Format

* Fix test

* Replace ContractClass (#686)

* Rename DeclaredContract to ContractClass

* Replace ContractClass

* Restore class hash < 0.10.0 [WIP]

* Use re.sub

* Remove int casting

* Post merge fixes

* Rename contract_class module

* Update starknet_py/hash/class_hash.py

* Add create_contract_class to compiler module

* Apply review

* Apply suggestions from code review

Co-authored-by: Artur Michałek <[email protected]>

* Add CompiledContract (#708)

* Add CompiledContract

* Review

* Add suggestions from review

* Remove factory method

* Fix ci

* Default abi to empty list

* Post merge

* Fix circular import

* Remove annotations import

---------

Co-authored-by: Artur Michałek <[email protected]>
Co-authored-by: war-in <[email protected]>

* Add comment about default_factory

* Fix lock

* Validate class_hash with cairo-lang

* Replace imports of already implemented methods

* Update migration guide

* Change deprecation version

* Circular imports detection (#760)

* Add circular.py

* Fix circular imports

* Remove import

* Update circular.py

Co-authored-by: war-in <[email protected]>

* Add circular check to CI

* Fix CI

---------

Co-authored-by: war-in <[email protected]>

* Fix lock

* Fix lint

* Final changes

* Fix docs

---------

Co-authored-by: Kamil Jankowski <[email protected]>
Co-authored-by: Artur Michałek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants