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!: resolve witness indexes automatically #1069

Merged
merged 31 commits into from
Aug 24, 2023
Merged

Conversation

hal3e
Copy link
Contributor

@hal3e hal3e commented Jul 31, 2023

closes: #965

Previously, when spending signed resource, the user had to manually set witness indexes. This meant that the user had to pay attention on the signing order and make sure to offset the index if some witnesses where already set.

This PR automates the whole process.

Proposed workflow:

  • wallet's sign_transaction now accepts a TransactionBuilder
  • when a wallet signs a TransactionBuilder the intention is saved in UnresolvedSignatures
  • when the user builds the transaction all signatures are resolved
  • after building the transaction can not be changed except with append_witness - this allows the user to add custom witnesses and it will not affect the TxId

Additionally, building a transaction will fail if there are signed resources that are missing corresponding signatures.

BREAKING CHANGE:

  • send_transaction, dry_run, dry_run_no_validation and estimate_transaction_cost need ownership of the tx.
  • removed witness index from Input and corresponding functions
  • wallet's sign_transaction now accepts a TransactionBuilder

Checklist

  • I have linked to any relevant issues.
  • I have added necessary labels.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@hal3e hal3e added the enhancement New feature or request label Jul 31, 2023
@hal3e hal3e self-assigned this Jul 31, 2023
@hal3e hal3e changed the title feat!: add witness indexes automatically feat!: resolve witness indexes automatically Jul 31, 2023
@MujkicA
Copy link
Contributor

MujkicA commented Aug 1, 2023

Regarding tests, we could include a case with multiple inputs coming from different wallets for a simple transfer and one for a create transaction

Copy link
Contributor

@segfault-magnet segfault-magnet left a comment

Choose a reason for hiding this comment

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

Love it. Left suggestions around macros.

packages/fuels-core/src/types/wrappers/transaction.rs Outdated Show resolved Hide resolved
packages/fuels-core/src/types/wrappers/transaction.rs Outdated Show resolved Hide resolved
segfault-magnet
segfault-magnet previously approved these changes Aug 7, 2023
Salka1988
Salka1988 previously approved these changes Aug 7, 2023
Copy link
Member

@Salka1988 Salka1988 left a comment

Choose a reason for hiding this comment

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

👍

Br1ght0ne
Br1ght0ne previously approved these changes Aug 7, 2023
@hal3e
Copy link
Contributor Author

hal3e commented Aug 8, 2023

I will turn this PR into a draft. Even though I implemented the requested feature, we still have some use-cases with witnesses we need to cover. I will soon make a new version and then we can discuss it.

@hal3e hal3e marked this pull request as draft August 8, 2023 12:22
iqdecay
iqdecay previously approved these changes Aug 21, 2023
Copy link
Contributor

@MujkicA MujkicA left a comment

Choose a reason for hiding this comment

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

I left some questions.
Nice addition to the UX 👍

packages/fuels-core/src/types/wrappers/transaction.rs Outdated Show resolved Hide resolved
@hal3e hal3e requested review from MujkicA and iqdecay August 23, 2023 08:36
Salka1988
Salka1988 previously approved these changes Aug 23, 2023
MujkicA
MujkicA previously approved these changes Aug 24, 2023
@MujkicA MujkicA dismissed stale reviews from segfault-magnet, Salka1988, and themself via 2718b1f August 24, 2023 09:35
@hal3e hal3e merged commit a38d9db into master Aug 24, 2023
35 checks passed
@hal3e hal3e deleted the feat/witness-indexes2 branch August 24, 2023 13:03
segfault-magnet pushed a commit that referenced this pull request Aug 28, 2023
closes: #965

BREAKING CHANGE: 
- `send_transaction`, `dry_run`, `dry_run_no_validation` and
`estimate_transaction_cost` need ownership of the `tx`.
- removed witness index from `Input` and corresponding functions
- wallet's `sign_transaction` now accepts a `TransactionBuilder`

Co-authored-by: MujkicA <ahmedmujkic2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abstract away the need for setting witness indexes
6 participants