Skip to content
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

feat: AlgorandClient #71

Merged
merged 42 commits into from
Apr 26, 2024
Merged

feat: AlgorandClient #71

merged 42 commits into from
Apr 26, 2024

Conversation

joe-p
Copy link
Contributor

@joe-p joe-p commented Apr 8, 2024

Proposed Changes

  • Adds AlgorandClient to beta namespace to mirror the AlgorandClient in algokit-utils-ts (and includes required classes)

@@ -1,98 +1,71 @@
from algokit_utils._debugging import PersistSourceMapInput, persist_sourcemaps, simulate_and_persist_response
Copy link
Contributor

Choose a reason for hiding this comment

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

This project has pre-commit configured to run the various linting tools (black, ruff, mypy) https://github.com/algorandfoundation/algokit-utils-py/blob/main/.pre-commit-config.yaml.

You will need to run these and fix any issues to get the PR to pass the various checks, they will also help reduce some of the unnecessary noise in the changeset due to IDE formatting differences.

def get_asset_information(self, sender: str, asset_id: int):
return self._client_manager.algod.account_asset_info(sender, asset_id)

# TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO?

self.set_signer(account.address, account.signer)
return AddressAndSigner(address=account.address, signer=account.signer)

# TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Another TODO?

Copy link
Member

@CiottiGiorgio CiottiGiorgio left a comment

Choose a reason for hiding this comment

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

This new AlgorandClient class seems to do less than the old one. Can you argue for the benefits of using this new client instead of the current one?

self._default_validity_window: int = 10

def _unwrap_single_send_result(self, results: AtomicTransactionResponse) -> dict[str, Any]:
return {
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to have typed return objects with dataclasses

self.txns.append(atc)
return self

def add_method_call(self, params: MethodCallParams) -> 'AlgokitComposer':
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why we are abandoning ad-hoc clients that offer you typed method calls in favor of generic clients where the user needs to know more about the arguments of the methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're still expecting people to use generated clients for apps. This PR is mainly for addressing non-app related stuff. Wanted to support method calls for more advanced composition which is not currently possible with ATC (ie. nested method calls). Eventually the plan is to use this in the generated clients

src/algokit_utils/beta/account_manager.py Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any code to attach the client to existing deployments and to perform idempotent deployments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah for now we are keeping app-related stuff in the existing ApplicationClient class. Eventually we want to refactor it to better fit with AlgorandClient, but for now we're just focusing on stuff not covered by ApplicationClient



@dataclass
class AddressAndSigner:
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's possible to use an Account here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I went with AddressAndSigner is because Account has a private key property, which is not applicable outside of localnet in most cases. Also I want to try to get away from Account terminology and instead use Address (with account being for HD wallet accounts that are used to derive addresses)

…pipx; adding dependabot; patching snapshot tests (#72)

* fix: testing ci

* chore: testing ci

* chore: test

* chore: test

* chore: testing ci

* chore: testing ci

* chore: test

* chore: testing

* chore: test

* chore: test

* chore: removing tmp tweak

* chore: testing ci

* chore: lockfile maintenance (poetry update); reverting ci tweaks

* chore: testing ci

* chore: testing ci

* chore: testing ci
Copy link

github-actions bot commented Apr 16, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit_utils
   _debugging.py140795%20, 41, 76, 80, 89, 129, 157
   _ensure_funded.py69199%99
   _transfer.py62395%13, 76–77
   account.py851385%14–17, 61–65, 96, 109, 136, 139, 183
   application_client.py5489782%58–59, 100, 117, 168, 173, 202, 314, 319–320, 322, 324, 407, 416, 425, 475, 483, 492, 536, 544, 553, 597, 605, 614, 671, 679, 688, 730, 738, 747, 807, 822, 840–843, 933, 973, 985, 998, 1040, 1100–1106, 1110–1115, 1117, 1153, 1160, 1273, 1303, 1317, 1355–1357, 1359, 1369–1426, 1437–1442, 1462–1465
   application_specification.py971189%92, 94, 193–202, 206
   asset.py79594%9, 27–30
   common.py13192%13
   config.py511865%38–39, 50, 55, 60, 64–69, 100–109
   deploy.py4552395%30–33, 168, 172–173, 190, 246, 402, 413–421, 438–441, 451, 459, 652–653, 677
   dispenser_api.py821285%112–113, 117–120, 155–157, 176–178
   logic_error.py38295%6, 29
   models.py126794%45, 50–52, 61–62, 125
   network_clients.py74396%106–107, 138
src/algokit_utils/beta
   account_manager.py551475%39–40, 64, 123–130, 183–187, 198–200
   algorand_client.py1011585%111–112, 121–122, 143–145, 154–155, 224, 259, 274, 290, 303, 319
   client_manager.py371073%40, 61–63, 68–70, 75–78
   composer.py3207178%335–336, 339–340, 343–344, 347–348, 355–356, 359–360, 389, 391, 393, 396, 399, 404, 407, 411, 414, 456–489, 494–505, 510–516, 521–529, 549–562, 566, 590, 593–610, 618, 643, 659–660, 662–663, 665–666, 668–669, 671–672, 678–682
TOTAL244631387% 

Tests Skipped Failures Errors Time
204 0 💤 0 ❌ 0 🔥 1m 44s ⏱️

@joe-p joe-p merged commit 5ee3a3b into main Apr 26, 2024
4 checks passed
@aorumbayev
Copy link
Contributor

@joe-p please remove the branch if no longer needed

@joe-p joe-p deleted the feat/algorand_client branch April 30, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants