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: migrate stacks generate txs, closes LEA-1732 #627

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

fbwoolf
Copy link
Contributor

@fbwoolf fbwoolf commented Nov 17, 2024

This PR migrates code from the extension to generate the unsigned stacks tx for the STX send flow.

Approach here now uses a separate Provider for each chain/protocol form so that we can handle loading data in the provider. I also did a version using our loader pattern, which seemed ok too, but felt using this approach might be more straightforward with using React context for the forms. We can add a loading state later, etc.

I also removed any helper functions I wasn't directly using with generating the unsigned tx. I realized I had ported over some unnec functions for this work. I got rid of all the stacks connect types.

I did add two new money formatters that can eventually help to replace stacksValue, thought I didn't end up needing them anywhere for now.

Copy link

linear bot commented Nov 17, 2024

Copy link

codecov bot commented Nov 17, 2024

Codecov Report

Attention: Patch coverage is 3.90625% with 123 lines in your changes missing coverage. Please review.

Project coverage is 23.33%. Comparing base (ab26689) to head (d869a60).

Files with missing lines Patch % Lines
.../src/transactions/generate-unsigned-transaction.ts 0.00% 45 Missing ⚠️
packages/stacks/src/stacks.utils.ts 7.31% 38 Missing ⚠️
...es/stacks/src/transactions/post-condition.utils.ts 0.00% 15 Missing ⚠️
...kages/stacks/src/transactions/transaction.types.ts 0.00% 11 Missing ⚠️
packages/utils/src/money/format-money.ts 16.66% 10 Missing ⚠️
packages/stacks/src/transactions/index.ts 0.00% 3 Missing ⚠️
packages/stacks/src/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #627      +/-   ##
==========================================
- Coverage   23.73%   23.33%   -0.41%     
==========================================
  Files         165      169       +4     
  Lines        6181     6309     +128     
  Branches      335      339       +4     
==========================================
+ Hits         1467     1472       +5     
- Misses       4714     4837     +123     
Files with missing lines Coverage Δ
packages/stacks/src/index.ts 0.00% <0.00%> (ø)
packages/stacks/src/transactions/index.ts 0.00% <0.00%> (ø)
packages/utils/src/money/format-money.ts 53.73% <16.66%> (-8.09%) ⬇️
...kages/stacks/src/transactions/transaction.types.ts 0.00% <0.00%> (ø)
...es/stacks/src/transactions/post-condition.utils.ts 0.00% <0.00%> (ø)
packages/stacks/src/stacks.utils.ts 48.80% <7.31%> (-39.57%) ⬇️
.../src/transactions/generate-unsigned-transaction.ts 0.00% <0.00%> (ø)
Components Coverage Δ
bitcoin 62.04% <ø> (ø)
query 12.67% <ø> (ø)
utils 47.17% <16.66%> (-0.76%) ⬇️
crypto 68.21% <ø> (ø)
stacks 27.47% <2.58%> (-27.24%) ⬇️
---- 🚨 Try these New Features:

Copy link
Contributor

@pete-watters pete-watters left a comment

Choose a reason for hiding this comment

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

Nice work @fbwoolf 👍

There's some console logs + commented code to remove.

For the stacks package work, maybe we could add some of the functions into smaller independent files and generate some unit tests for them also?

Copy link
Collaborator

@edgarkhanzadian edgarkhanzadian left a comment

Choose a reason for hiding this comment

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

Great work!🚀

Copy link
Collaborator

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

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

Great work @fbwoolf

Lots to discuss here though. I think there's some code, and general patterns here, we might want to reconsider bringing over if possible

packages/stacks/src/stacks.utils.ts Outdated Show resolved Hide resolved
packages/stacks/src/stacks.utils.ts Outdated Show resolved Hide resolved
packages/stacks/src/stacks.utils.ts Outdated Show resolved Hide resolved
packages/stacks/src/transactions/stacks-connect.types.ts Outdated Show resolved Hide resolved
@kyranjamie
Copy link
Collaborator

I used an approach where for each form we have a SendForm.StacksSetter (or appropriate chain/prototool) to set nec form data. We do this in the extension with NonceSetter. I think we can use this later to load/set fee values, etc. Open to other ideas here too.

I would investigate options where we do not even render the form components until we have this data loaded from the external source. Either the loader pattern, or some kind of route loader if Expo has those.

@fbwoolf
Copy link
Contributor Author

fbwoolf commented Nov 18, 2024

Great work @fbwoolf

Lots to discuss here though. I think there's some code, and general patterns here, we might want to reconsider bringing over if possible

Yep, agree, I was debating abt just doing a draft PR but wasn't sure how quickly we wanted to push the send form forward. I'll change this to draft and tackle some of the refactoring you pointed out. I mostly wanted to make sure I got feedback on effort here so far. 👍

@fbwoolf fbwoolf marked this pull request as draft November 18, 2024 13:54
@fbwoolf fbwoolf force-pushed the feat/migrate-stacks-generate-txs branch 2 times, most recently from f99a878 to 1f9ea83 Compare November 19, 2024 20:16
@fbwoolf fbwoolf force-pushed the feat/migrate-stacks-generate-txs branch 2 times, most recently from 9d90998 to 81d205b Compare November 20, 2024 01:02
@fbwoolf fbwoolf force-pushed the feat/migrate-stacks-generate-txs branch from 81d205b to d869a60 Compare November 20, 2024 01:06
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